Skip to content

Commit

Permalink
Convert manifest constants for things like commands to symbolic const…
Browse files Browse the repository at this point in the history
…ants.
  • Loading branch information
jsgf committed Nov 5, 2005
1 parent 810c04c commit f83c85d
Show file tree
Hide file tree
Showing 31 changed files with 495 additions and 120 deletions.
2 changes: 1 addition & 1 deletion glAlphaFunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ void glAlphaFunc (GLenum func, GLclampf ref)

func &= 0x0007;

sendCommandi(219, (amsk << 16) | (aref << 8) | alphatestfunc_mapping[func]);
sendCommandi(CMD_ALPHA_FUNC, (amsk << 16) | (aref << 8) | alphatestfunc_mapping[func]);
}
6 changes: 3 additions & 3 deletions glBindTexture.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ void glBindTexture (GLenum target, GLuint texture)
uint32_t *texreg;
unsigned long i;

memcpy(c->texobj_current->ge_texreg_160x201, &c->ge_reg[160], sizeof(c->texobj_current->ge_texreg_160x201));
memcpy(c->texobj_current->ge_texreg_160x201, &c->ge_reg[CMD_TEX_MIPMAP0], sizeof(c->texobj_current->ge_texreg_160x201));
c->texobj_current = texobj;

for (i=160, texreg=c->texobj_current->ge_texreg_160x201; i<201; i++, texreg++)
for (i=CMD_TEX_MIPMAP0, texreg=c->texobj_current->ge_texreg_160x201; i<CMD_TEXENV_FUNC; i++, texreg++)
pspgl_context_writereg(c, i, *texreg);

pspgl_context_writereg_masked(c, 201, c->texobj0.ge_texreg_160x201[201-160], 0xffff00);
pspgl_context_writereg_masked(c, CMD_TEXENV_FUNC, c->texobj0.ge_texreg_160x201[CMD_TEXENV_FUNC-CMD_TEX_MIPMAP0], 0xffff00);
}
}

2 changes: 1 addition & 1 deletion glBlendEquation.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ void glBlendEquation (GLenum equation)
return;
}

pspgl_context_writereg_masked(pspgl_curctx, 223, (e << 8), 0xf00);
pspgl_context_writereg_masked(pspgl_curctx, CMD_BLEND_FUNC, (e << 8), 0xf00);
}

10 changes: 5 additions & 5 deletions glBlendFunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ void glBlendFunc (GLenum sfactor, GLenum dfactor)

switch (dfactor) {
case GL_ZERO:
sendCommandi(225, 0x000000);
sendCommandi(CMD_FIXEDCOL_DST, 0x000000);
dstfunc = GE_FIX;
break;
case GL_ONE:
sendCommandi(225, 0xffffff);
sendCommandi(CMD_FIXEDCOL_DST, 0xffffff);
dstfunc = GE_FIX;
break;
case GL_DST_COLOR:
Expand Down Expand Up @@ -53,11 +53,11 @@ void glBlendFunc (GLenum sfactor, GLenum dfactor)

switch (sfactor) {
case GL_ZERO:
sendCommandi(224, 0x000000);
sendCommandi(CMD_FIXEDCOL_SRC, 0x000000);
srcfunc = GE_FIX;
break;
case GL_ONE:
sendCommandi(224, 0xffffff);
sendCommandi(CMD_FIXEDCOL_SRC, 0xffffff);
srcfunc = GE_FIX;
break;
case GL_SRC_ALPHA:
Expand Down Expand Up @@ -86,6 +86,6 @@ void glBlendFunc (GLenum sfactor, GLenum dfactor)
return;
}

pspgl_context_writereg_masked(pspgl_curctx, 223, (dstfunc << 4) | srcfunc, 0x0ff);
pspgl_context_writereg_masked(pspgl_curctx, CMD_BLEND_FUNC, (dstfunc << 4) | srcfunc, 0x0ff);
}

16 changes: 8 additions & 8 deletions glClear.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ void glClear (GLbitfield mask)
static const char stencil_shift [] = { 31, 28, 24 };
clearmask &= 0x00ffffff;
clearmask |= (pspgl_curctx->clear.stencil) << stencil_shift[pspgl_curctx->draw->pixfmt-1];
cmd |= 1 << 9;
cmd |= GU_STENCIL_BUFFER_BIT << 8;
}
}

if (pspgl_curctx->draw->depth_buffer && (mask & GL_DEPTH_BUFFER_BIT))
cmd |= 1 << 10;
cmd |= GU_DEPTH_BUFFER_BIT << 8;

vbuf[0].color = clearmask;
vbuf[0].x = 0.0;
Expand All @@ -54,15 +54,15 @@ void glClear (GLbitfield mask)
vbuf[1].z = pspgl_curctx->clear.depth;

/* enable clear mode */
sendCommandi(211, cmd);
sendCommandi(CMD_CLEARMODE, cmd);

/* draw array */
sendCommandi(18, 0x80019c); /* xform: 2D, vertex format: RGB8888 (uint32), xyz (float32) */
sendCommandi(16, (((unsigned long) vbuf) >> 8) & 0xf0000); /* vertex array BASE */
sendCommandi(1, ((unsigned long) vbuf) & 0xffffff); /* vertex array, Adress */
sendCommandiUncached(4, (6 << 16) | 2); /* sprite (type 6), 2 vertices */
sendCommandi(CMD_VERTEXTYPE, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D); /* xform: 2D, vertex format: RGB8888 (uint32), xyz (float32) */
sendCommandiUncached(CMD_BASE, (((unsigned long) vbuf) >> 8) & 0xf0000); /* vertex array BASE */
sendCommandiUncached(CMD_VERTEXPTR, ((unsigned long) vbuf) & 0xffffff); /* vertex array, Adress */
sendCommandiUncached(CMD_PRIM, (GU_SPRITES << 16) | 2); /* sprite (type 6), 2 vertices */

/* leave clear mode */
sendCommandi(211, 0);
sendCommandi(CMD_CLEARMODE, 0);
}

6 changes: 3 additions & 3 deletions glColorMask.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ void glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alph

pspgl_curctx->write_mask.alpha = alpha ? 0x00: 0xff;

sendCommandi(232, mask);
sendCommandi(CMD_RGB_MASK, mask);

/**
* Alpha Channel and Stencil are shared. Only update Alpha mask register
* if stencil test is disabled.
*/
if ((pspgl_curctx->ge_reg[36] & 1) == 0)
sendCommandi(233, pspgl_curctx->write_mask.alpha);
if ((pspgl_curctx->ge_reg[CMD_ENA_STENCIL_TEST] & 1) == 0)
sendCommandi(CMD_ALPHA_MASK, pspgl_curctx->write_mask.alpha);
}

2 changes: 1 addition & 1 deletion glDepthFunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ void glDepthFunc (GLenum func)
return;
}

sendCommandi(222, depthfunc_mapping[func - GL_NEVER]);
sendCommandi(CMD_DEPTH_FUNC, depthfunc_mapping[func - GL_NEVER]);
}
2 changes: 1 addition & 1 deletion glDepthMask.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

void glDepthMask (GLboolean flag)
{
sendCommandi(231, flag ? 0 : ~0);
sendCommandi(CMD_DEPTH_MASK, flag ? 0 : ~0);
}

8 changes: 4 additions & 4 deletions glDepthRange.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
void glDepthRangef (GLclampf zNear, GLclampf zFar)
{
/* z Scale and Offset */
sendCommandf(68, (zNear - zFar) / 2);
sendCommandf(71, (zNear + zFar) / 2 + pspgl_curctx->depth_offset);
sendCommandf(CMD_VIEWPORT_SZ, (zNear - zFar) / 2);
sendCommandf(CMD_VIEWPORT_TZ, (zNear + zFar) / 2 + pspgl_curctx->depth_offset);

if (zNear > zFar) {
GLfloat temp = zNear;
Expand All @@ -14,8 +14,8 @@ void glDepthRangef (GLclampf zNear, GLclampf zFar)
}

/* Far and Near Clip Planes */
sendCommandi(214, (int) zNear);
sendCommandi(215, (int) zFar);
sendCommandi(CMD_CLIP_NEAR, (int) zNear);
sendCommandi(CMD_CLIP_FAR, (int) zFar);
}


Expand Down
28 changes: 14 additions & 14 deletions glEnable.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,56 @@ void pspgl_enable_state (GLenum cap, int enable)

switch (cap) {
case GL_FOG:
opcode = 31;
opcode = CMD_ENA_FOG;
break;
case GL_LIGHTING:
opcode = 23;
opcode = CMD_ENA_LIGHTING;
break;
case GL_TEXTURE_2D:
opcode = 30;
opcode = CMD_ENA_TEXTURE;
break;
case GL_CULL_FACE:
opcode = 29;
opcode = CMD_ENA_CULL;
break;
case GL_ALPHA_TEST:
opcode = 34;
opcode = CMD_ENA_ALPHA_TEST;
break;
case GL_BLEND:
opcode = 33;
opcode = CMD_ENA_BLEND;
break;
case GL_COLOR_LOGIC_OP:
opcode = 40;
opcode = CMD_ENA_LOGIC;
break;
case GL_DITHER:
opcode = 32;
opcode = CMD_ENA_DITHER;
break;
case GL_STENCIL_TEST:
if (enable && pspgl_curctx->draw->pixfmt == 0) { /* no room for stencil bits */
GLERROR(GL_INVALID_OPERATION);
enable = GL_FALSE;
}
if (enable)
sendCommandi(233, pspgl_curctx->write_mask.stencil);
sendCommandi(CMD_ALPHA_MASK, pspgl_curctx->write_mask.stencil);
else
sendCommandi(233, pspgl_curctx->write_mask.alpha);
opcode = 36;
sendCommandi(CMD_ALPHA_MASK, pspgl_curctx->write_mask.alpha);
opcode = CMD_ENA_STENCIL_TEST;
break;
case GL_DEPTH_TEST:
if (enable && pspgl_curctx->draw->depth_buffer == 0) {
GLERROR(GL_INVALID_OPERATION);
enable = GL_FALSE;
}
opcode = 35;
opcode = CMD_ENA_DEPTH_TEST;
break;
case GL_LIGHT0:
case GL_LIGHT1:
case GL_LIGHT2:
case GL_LIGHT3:
opcode = cap - GL_LIGHT0 + 24;
opcode = cap - GL_LIGHT0 + CMD_ENA_LIGHT0;
break;
case GL_LINE_SMOOTH:
case GL_POINT_SMOOTH:
opcode = 37; /* XXX : antialiasing. both line and point? */
opcode = CMD_ENA_ANTIALIAS; /* XXX : antialiasing. both line and point? */
break;
case GL_SCISSOR_TEST:
pspgl_curctx->scissor_test.enabled = enable;
Expand Down
10 changes: 5 additions & 5 deletions glEnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ void glEnd (void)
GLERROR(GL_INVALID_ENUM);
} else {
pspgl_context_flush_pending_matrix_changes(pspgl_curctx);
sendCommandi(204, 0); /* Texture Sync, need to await end of transfer if any is pending */
sendCommandi(18, 0x0001ff); /* xform: 3D, vertex format: t2f_c4ub_n3f_v3f */
sendCommandi(16, (adr >> 8) & 0xf0000); /* vertex array BASE */
sendCommandi(1, adr & 0xffffff); /* vertex array, Adress */
sendCommandiUncached(4, (prim << 16) | pspgl_curctx->current.vertex_count);
sendCommandiUncached(CMD_TEXCACHE_SYNC, 0); /* Texture Sync, need to await end of transfer if any is pending */
sendCommandi(CMD_VERTEXTYPE, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_NORMAL_32BITF | GU_VERTEX_32BITF); /* xform: 3D, vertex format: t2f_c4ub_n3f_v3f */
sendCommandi(CMD_BASE, (adr >> 8) & 0xf0000); /* vertex array BASE */
sendCommandi(CMD_VERTEXPTR, adr & 0xffffff); /* vertex array, Adress */
sendCommandiUncached(CMD_PRIM, (prim << 16) | pspgl_curctx->current.vertex_count);
}
}

Expand Down
6 changes: 3 additions & 3 deletions glFog.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ void glFogf (GLenum pname, GLfloat param)
distance = 1.0f / distance;
else
GLERROR(GL_INVALID_VALUE);
sendCommandf(206, distance);
sendCommandf(CMD_FOG_NEAR, distance);
break;
case GL_FOG_END:
pspgl_curctx->fog.far = param;
sendCommandf(205, pspgl_curctx->fog.far);
sendCommandf(CMD_FOG_FAR, pspgl_curctx->fog.far);
break;
/**
case XXXX:
Expand All @@ -45,7 +45,7 @@ void glFogfv (GLenum pname, const GLfloat *param)
{
switch (pname) {
case GL_FOG_COLOR:
sendCommandi(207, COLOR3(param));
sendCommandi(CMD_FOG_COLOR, COLOR3(param));
break;
default:
glFogf(pname, param[0]);
Expand Down
2 changes: 1 addition & 1 deletion glFrontFace.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void glFrontFace (GLenum mode)
switch (mode) {
case GL_CW:
case GL_CCW:
sendCommandi(155, (~mode & 1));
sendCommandi(CMD_CULL_FACE, (~mode & 1));
break;
default:
GLERROR(GL_INVALID_ENUM);
Expand Down
31 changes: 16 additions & 15 deletions glLight.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,45 @@ void glLightfv (GLenum light, GLenum pname, const GLfloat *params)

switch (pname) {
case GL_AMBIENT:
sendCommandi(143+3*light, COLOR3(params));
sendCommandi(CMD_LIGHT0_AMB_COL+3*light, COLOR3(params));
break;
case GL_DIFFUSE:
sendCommandi(144+3*light, COLOR3(params));
sendCommandi(CMD_LIGHT0_DIF_COL+3*light, COLOR3(params));
break;
case GL_SPECULAR:
sendCommandi(145+3*light, COLOR3(params));
sendCommandi(CMD_LIGHT0_SPC_COL+3*light, COLOR3(params));
break;
case GL_POSITION:
scale = 1.0 / params[3];
if (scale > 0 && scale < 0.001)
scale = 0.001;
else if (scale < 0 && scale > -0.001)
scale = -0.001;
sendCommandf(99+3*light, scale * params[0]);
sendCommandf(100+3*light, scale * params[1]);
sendCommandf(101+3*light, scale * params[2]);
sendCommandf(CMD_LIGHT0_POS_X+3*light, scale * params[0]);
sendCommandf(CMD_LIGHT0_POS_Y+3*light, scale * params[1]);
sendCommandf(CMD_LIGHT0_POS_Z+3*light, scale * params[2]);
break;
case GL_SPOT_DIRECTION:
sendCommandf(111+3*light, params[0]);
sendCommandf(112+3*light, params[1]);
sendCommandf(113+3*light, params[2]);
sendCommandf(CMD_LIGHT0_VEC_X+3*light, params[0]);
sendCommandf(CMD_LIGHT0_VEC_Y+3*light, params[1]);
sendCommandf(CMD_LIGHT0_VEC_Z+3*light, params[2]);
break;
case GL_SPOT_EXPONENT:
sendCommandf(139+light, params[0]);
sendCommandf(CMD_LIGHT0_SPOT_EXP+light, params[0]);
break;
case GL_SPOT_CUTOFF:
pspgl_context_writereg_masked(c, 95+light, ((params[0] == 0.0) ? 0 : (params[0] == 180.0) ? 1 : 2) << 8, 0x00ff00);
sendCommandf(135+light, params[0]);
pspgl_context_writereg_masked(c, CMD_LIGHT0_TYPE+light,
((params[0] == 0.0) ? 0 : (params[0] == 180.0) ? 1 : 2) << 8, 0x00ff00);
sendCommandf(CMD_LIGHT0_CUTOFF+light, params[0]);
break;
case GL_CONSTANT_ATTENUATION:
sendCommandf(123+3*light, params[0]);
sendCommandf(CMD_LIGHT0_ATT_CONST+3*light, params[0]);
break;
case GL_LINEAR_ATTENUATION:
sendCommandf(124+3*light, params[0]);
sendCommandf(CMD_LIGHT0_ATT_LINEAR+3*light, params[0]);
break;
case GL_QUADRATIC_ATTENUATION:
sendCommandf(125+3*light, params[0]);
sendCommandf(CMD_LIGHT0_ATT_QUAD+3*light, params[0]);
break;
default:
GLERROR(GL_INVALID_ENUM);
Expand Down
6 changes: 3 additions & 3 deletions glLightModel.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ void glLightModelfv (GLenum pname, const GLfloat *params)
{
switch (pname) {
case GL_LIGHT_MODEL_AMBIENT:
sendCommandi(92, COLOR3(params));
sendCommandi(93, (int) (255.0 * CLAMPF(params[3])));
sendCommandi(CMD_AMBIENT_COLOR, COLOR3(params));
sendCommandi(CMD_AMBIENT_ALPHA, (int) (255.0 * CLAMPF(params[3])));
break;
case GL_LIGHT_MODEL_COLOR_CONTROL:
sendCommandi(94, (params[0] == GL_SEPARATE_SPECULAR_COLOR) ? 1 : 0);
sendCommandi(CMD_LIGHTMODEL, (params[0] == GL_SEPARATE_SPECULAR_COLOR) ? 1 : 0);
break;
default:
GLERROR(GL_INVALID_ENUM);
Expand Down
2 changes: 1 addition & 1 deletion glLogicOp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void glLogicOp (GLenum opcode)
GLERROR(GL_INVALID_ENUM);
} else {
opcode &= 0x000f;
sendCommandi(230, opcode);
sendCommandi(CMD_LOGICOP, opcode);
}
}

12 changes: 6 additions & 6 deletions glMaterial.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ void glMaterialfv (GLenum face, GLenum pname, const GLfloat *params)
{
switch (pname) {
case GL_AMBIENT:
sendCommandi(85, COLOR3(params));
sendCommandi(88, (int) (255.0 * CLAMPF(params[3])));
sendCommandi(CMD_MATERIAL_AMB_C, COLOR3(params));
sendCommandi(CMD_MATERIAL_AMB_A, (int) (255.0 * CLAMPF(params[3])));
break;
case GL_EMISSION:
sendCommandi(84, COLOR3(params));
sendCommandi(CMD_MATERIAL_EMS_C, COLOR3(params));
break;
case GL_DIFFUSE:
sendCommandi(86, COLOR3(params));
sendCommandi(CMD_MATERIAL_DIF_C, COLOR3(params));
break;
case GL_AMBIENT_AND_DIFFUSE:
glMaterialfv(face, GL_AMBIENT, params);
glMaterialfv(face, GL_DIFFUSE, params);
break;
case GL_SPECULAR:
sendCommandi(87, COLOR3(params));
sendCommandi(CMD_MATERIAL_SPC_C, COLOR3(params));
break;
case GL_SHININESS:
sendCommandf(91, params[0]);
sendCommandf(CMD_MATERIAL_SPEC_POW, params[0]);
break;
default:
GLERROR(GL_INVALID_ENUM);
Expand Down
Loading

0 comments on commit f83c85d

Please sign in to comment.