- cleanup gfx3d.cpp;
This commit is contained in:
mtabachenko 2008-12-14 19:48:43 +00:00
parent 70fe9c0f86
commit ff328543a0
3 changed files with 341 additions and 463 deletions

View File

@ -2088,7 +2088,7 @@ void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val)
{ {
// Geometry commands (aka Dislay Lists) - Parameters:X // Geometry commands (aka Dislay Lists) - Parameters:X
((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x400>>2] = val; ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x400>>2] = val;
gfx3d_glCallList(val); gfx3d_glCallList(0xFFFFFFFF, val);
return; return;
} }
if(adr >= 0x04000380 && adr <= 0x040003BC) if(adr >= 0x04000380 && adr <= 0x040003BC)

View File

@ -78,11 +78,11 @@ static CACHE_ALIGN float mtxTemporal[16];
static u32 mode = 0; static u32 mode = 0;
// Indexes for matrix loading/multiplication // Indexes for matrix loading/multiplication
static int ML4x4ind = 0; static u8 ML4x4ind = 0;
static int ML4x3_c = 0, ML4x3_l = 0; static u8 ML4x3ind = 0;
static int MM4x4ind = 0; static u8 MM4x4ind = 0;
static int MM4x3_c = 0, MM4x3_l = 0; static u8 MM4x3ind = 0;
static int MM3x3_c = 0, MM3x3_l = 0; static u8 MM3x3ind = 0;
// Data for vertex submission // Data for vertex submission
static CACHE_ALIGN float coord[4] = {0.0, 0.0, 0.0, 0.0}; static CACHE_ALIGN float coord[4] = {0.0, 0.0, 0.0, 0.0};
@ -100,7 +100,6 @@ static int _t=0, _s=0;
static float last_t, last_s; static float last_t, last_s;
static u32 clCmd = 0; static u32 clCmd = 0;
static u32 clInd = 0; static u32 clInd = 0;
static u32 clInd2 = 0;
//raw ds format poly attributes //raw ds format poly attributes
static u32 polyAttr=0,textureFormat=0, texturePalette=0; static u32 polyAttr=0,textureFormat=0, texturePalette=0;
@ -262,30 +261,28 @@ void gfx3d_glLoadIdentity()
MatrixIdentity (mtxCurrent[1]); MatrixIdentity (mtxCurrent[1]);
} }
void gfx3d_glLoadMatrix4x4(signed long v) BOOL gfx3d_glLoadMatrix4x4(signed long v)
{ {
mtxCurrent[mode][ML4x4ind] = fix2float(v); mtxCurrent[mode][ML4x4ind] = fix2float(v);
++ML4x4ind; ++ML4x4ind;
if(ML4x4ind<16) return; if(ML4x4ind<16) return FALSE;
if (mode == 2) if (mode == 2)
MatrixCopy (mtxCurrent[1], mtxCurrent[2]); MatrixCopy (mtxCurrent[1], mtxCurrent[2]);
ML4x4ind = 0; ML4x4ind = 0;
return TRUE;
} }
void gfx3d_glLoadMatrix4x3(signed long v) BOOL gfx3d_glLoadMatrix4x3(signed long v)
{ {
mtxCurrent[mode][(ML4x3_l<<2)+ML4x3_c] = fix2float(v); mtxCurrent[mode][ML4x3ind] = fix2float(v);
++ML4x3_c; ML4x3ind++;
if(ML4x3_c<3) return; if((ML4x3ind & 0x03) == 3) ML4x3ind++;
if(ML4x3ind<16) return FALSE;
ML4x3_c = 0; ML4x3ind = 0;
++ML4x3_l;
if(ML4x3_l<4) return;
ML4x3_l = 0;
//fill in the unusued matrix values //fill in the unusued matrix values
mtxCurrent[mode][3] = mtxCurrent[mode][7] = mtxCurrent[mode][11] = 0; mtxCurrent[mode][3] = mtxCurrent[mode][7] = mtxCurrent[mode][11] = 0;
@ -293,6 +290,7 @@ void gfx3d_glLoadMatrix4x3(signed long v)
if (mode == 2) if (mode == 2)
MatrixCopy (mtxCurrent[1], mtxCurrent[2]); MatrixCopy (mtxCurrent[1], mtxCurrent[2]);
return TRUE;
} }
void gfx3d_glStoreMatrix(unsigned long v) void gfx3d_glStoreMatrix(unsigned long v)
@ -344,14 +342,14 @@ void gfx3d_glPopMatrix(signed long i)
MatrixCopy (mtxCurrent[1], MatrixStackPopMatrix (&mtxStack[1], i)); MatrixCopy (mtxCurrent[1], MatrixStackPopMatrix (&mtxStack[1], i));
} }
void gfx3d_glTranslate(signed long v) BOOL gfx3d_glTranslate(signed long v)
{ {
trans[transind] = fix2float(v); trans[transind] = fix2float(v);
++transind; ++transind;
if(transind<3) if(transind<3)
return; return FALSE;
transind = 0; transind = 0;
@ -359,9 +357,10 @@ void gfx3d_glTranslate(signed long v)
if (mode == 2) if (mode == 2)
MatrixTranslate (mtxCurrent[1], trans); MatrixTranslate (mtxCurrent[1], trans);
return TRUE;
} }
void gfx3d_glScale(signed long v) BOOL gfx3d_glScale(signed long v)
{ {
short mymode = (mode==2?1:mode); short mymode = (mode==2?1:mode);
@ -370,7 +369,7 @@ void gfx3d_glScale(signed long v)
++scaleind; ++scaleind;
if(scaleind<3) if(scaleind<3)
return; return FALSE;
scaleind = 0; scaleind = 0;
@ -381,19 +380,17 @@ void gfx3d_glScale(signed long v)
//so, I am leaving this commented out as an example of what not to do. //so, I am leaving this commented out as an example of what not to do.
//if (mode == 2) //if (mode == 2)
// MatrixScale (mtxCurrent[1], scale); // MatrixScale (mtxCurrent[1], scale);
return TRUE;
} }
void gfx3d_glMultMatrix3x3(signed long v) BOOL gfx3d_glMultMatrix3x3(signed long v)
{ {
mtxTemporal[(MM3x3_l<<2)+MM3x3_c] = fix2float(v); mtxTemporal[MM3x3ind] = fix2float(v);
++MM3x3_c; MM3x3ind++;
if(MM3x3_c<3) return; if((MM3x3ind & 0x03) == 3) MM3x3ind++;
if(MM3x3ind<12) return FALSE;
MM3x3_c = 0; MM3x3ind = 0;
++MM3x3_l;
if(MM3x3_l<3) return;
MM3x3_l = 0;
//fill in the unusued matrix values //fill in the unusued matrix values
mtxTemporal[3] = mtxTemporal[7] = mtxTemporal[11] = 0; mtxTemporal[3] = mtxTemporal[7] = mtxTemporal[11] = 0;
@ -407,19 +404,17 @@ void gfx3d_glMultMatrix3x3(signed long v)
//does this really need to be done? //does this really need to be done?
MatrixIdentity (mtxTemporal); MatrixIdentity (mtxTemporal);
return TRUE;
} }
void gfx3d_glMultMatrix4x3(signed long v) BOOL gfx3d_glMultMatrix4x3(signed long v)
{ {
mtxTemporal[(MM4x3_l<<2)+MM4x3_c] = fix2float(v); mtxTemporal[MM4x3ind] = fix2float(v);
++MM4x3_c; MM4x3ind++;
if(MM4x3_c<3) return; if((MM4x3ind & 0x03) == 3) MM4x3ind++;
if(MM4x3ind<16) return FALSE;
MM4x3_c = 0; MM4x3ind = 0;
++MM4x3_l;
if(MM4x3_l<4) return;
MM4x3_l = 0;
//fill in the unusued matrix values //fill in the unusued matrix values
mtxTemporal[3] = mtxTemporal[7] = mtxTemporal[11] = 0; mtxTemporal[3] = mtxTemporal[7] = mtxTemporal[11] = 0;
@ -431,14 +426,15 @@ void gfx3d_glMultMatrix4x3(signed long v)
//does this really need to be done? //does this really need to be done?
MatrixIdentity (mtxTemporal); MatrixIdentity (mtxTemporal);
return TRUE;
} }
void gfx3d_glMultMatrix4x4(signed long v) BOOL gfx3d_glMultMatrix4x4(signed long v)
{ {
mtxTemporal[MM4x4ind] = fix2float(v); mtxTemporal[MM4x4ind] = fix2float(v);
++MM4x4ind; MM4x4ind++;
if(MM4x4ind<16) return; if(MM4x4ind<16) return FALSE;
MM4x4ind = 0; MM4x4ind = 0;
@ -447,6 +443,7 @@ void gfx3d_glMultMatrix4x4(signed long v)
MatrixMultiply (mtxCurrent[1], mtxTemporal); MatrixMultiply (mtxCurrent[1], mtxTemporal);
MatrixIdentity (mtxTemporal); MatrixIdentity (mtxTemporal);
return TRUE;
} }
void gfx3d_glBegin(unsigned long v) void gfx3d_glBegin(unsigned long v)
@ -585,7 +582,7 @@ static void SetVertex()
} }
} }
void gfx3d_glVertex16b(unsigned int v) BOOL gfx3d_glVertex16b(unsigned int v)
{ {
if(coordind==0) if(coordind==0)
{ {
@ -593,13 +590,14 @@ void gfx3d_glVertex16b(unsigned int v)
coord[1] = float16table[v>>16]; coord[1] = float16table[v>>16];
++coordind; ++coordind;
return; return FALSE;
} }
coord[2] = float16table[v&0xFFFF]; coord[2] = float16table[v&0xFFFF];
coordind = 0; coordind = 0;
SetVertex (); SetVertex ();
return TRUE;
} }
void gfx3d_glVertex10b(unsigned long v) void gfx3d_glVertex10b(unsigned long v)
@ -704,15 +702,16 @@ void gfx3d_glMaterial1(unsigned long val)
dsEmission = val>>16; dsEmission = val>>16;
} }
void gfx3d_glShininess (unsigned long val) BOOL gfx3d_glShininess (unsigned long val)
{ {
shininessTable[shininessInd++] = ((val & 0xFF) / 256.0f); shininessTable[shininessInd++] = ((val & 0xFF) / 256.0f);
shininessTable[shininessInd++] = (((val >> 8) & 0xFF) / 256.0f); shininessTable[shininessInd++] = (((val >> 8) & 0xFF) / 256.0f);
shininessTable[shininessInd++] = (((val >> 16) & 0xFF) / 256.0f); shininessTable[shininessInd++] = (((val >> 16) & 0xFF) / 256.0f);
shininessTable[shininessInd++] = (((val >> 24) & 0xFF) / 256.0f); shininessTable[shininessInd++] = (((val >> 24) & 0xFF) / 256.0f);
if(shininessInd >= 128) if (shininessInd < 128) return FALSE;
shininessInd = 0; shininessInd = 0;
return TRUE;
} }
void gfx3d_UpdateToonTable(void* toonTable) void gfx3d_UpdateToonTable(void* toonTable)
@ -905,12 +904,24 @@ void gfx3d_glAlphaFunc(unsigned long v)
gfx3d.alphaTestRef = (v&31)/31.f; gfx3d.alphaTestRef = (v&31)/31.f;
} }
void gfx3d_glBoxTest(unsigned long v) BOOL gfx3d_glBoxTest(unsigned long v)
{ {
static u8 cycles = 0;
cycles++;
if (cycles < 3) return FALSE;
cycles = 0;
//INFO("BoxTest=%i\n",val);
return TRUE;
} }
void gfx3d_glPosTest(unsigned long v) BOOL gfx3d_glPosTest(unsigned long v)
{ {
static u8 cycles = 0;
cycles++;
if (cycles < 2) return FALSE;
cycles = 0;
//INFO("PosTest=%i\n",val);
return TRUE;
} }
void gfx3d_glVecTest(unsigned long v) void gfx3d_glVecTest(unsigned long v)
@ -930,422 +941,295 @@ void gfx3d_glGetVecRes(unsigned int index)
//return 0; //return 0;
} }
void gfx3d_glCallList(unsigned long v) void gfx3d_glCallList(u32 addr, u32 cmd)
{ {
//static unsigned long oldval = 0, shit = 0; if (addr != 0xFFFFFFFF)
if(!clInd)
{ {
clInd = 4; clInd = 4;
clCmd = v; clCmd = addr;
} // else FIFO commands
if (!clInd)
{
clInd = 4;
clCmd = cmd;
return; return;
} }
//INFO("3D command 0x%02X (full cmd = 0x%08X, val = 0x%08X)\n", clCmd&0xFF, clCmd, cmd);
for (;;) for (;;)
{ {
switch ((clCmd&0xFF)) switch (clCmd & 0xFF)
{ {
case 0x0: // 3D commands without parameters
{ case 0x00: // NOP - No Operation (for padding packed GXFIFO commands)
if (clInd > 0)
{ {
--clInd; if (clInd > 0)
{
clCmd >>= 8;
clInd--;
continue;
}
break;
}
case 0x11: // MTX_PUSH - Push Current Matrix on Stack (W)
{
*(u32 *)(ARM9Mem.ARM9_REG + 0x444) = cmd;
gfx3d_glPushMatrix();
clInd--;
clCmd >>= 8;
continue;
}
case 0x15: // MTX_IDENTITY - Load Unit Matrix to Current Matrix (W)
{
*(u32 *)(ARM9Mem.ARM9_REG + 0x454) = cmd;
gfx3d_glLoadIdentity();
clInd--;
clCmd >>= 8;
continue;
}
case 0x41: // END_VTXS - End of Vertex List (W)
{
*(u32 *)(ARM9Mem.ARM9_REG + 0x504) = cmd;
gfx3d_glEnd();
clInd--;
clCmd >>= 8; clCmd >>= 8;
continue; continue;
} }
break;
}
case 0x11 :
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x444>>2] = v;
gfx3d_glPushMatrix();
--clInd;
clCmd>>=8;
continue;
}
case 0x15:
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x454>>2] = v;
gfx3d_glLoadIdentity();
--clInd;
clCmd>>=8;
continue;
}
case 0x41:
{
gfx3d_glEnd();
--clInd;
clCmd>>=8;
continue;
}
} }
break; break;
} }
/*if (addr != 0xFFFFFFFF)
{
if (!clInd)
{
clInd = 4;
clCmd = addr;
return;
}
} // else FIFO commands
*/
if(!clInd) if (!clInd)
{ {
clInd = 4; clInd = 4;
clCmd = v; clCmd = cmd;
return; return;
} }
switch(clCmd&0xFF) switch (clCmd & 0xFF)
{ {
case 0x10: case 0x10: // MTX_MODE - Set Matrix Mode (W)
{ *(u32 *)(ARM9Mem.ARM9_REG + 0x440) = cmd;
((unsigned long *)ARM9Mem.ARM9_REG)[0x440>>2] = v; gfx3d_glMatrixMode(cmd);
gfx3d_glMatrixMode (v); clCmd >>= 8;
--clInd; clInd--;
clCmd>>=8; break;
break; case 0x12: // MTX_POP - Pop Current Matrix from Stack (W)
} *(u32 *)(ARM9Mem.ARM9_REG + 0x448) = cmd;
gfx3d_glPopMatrix(cmd);
case 0x12: clCmd >>= 8;
{ clInd--;
((unsigned long *)ARM9Mem.ARM9_REG)[0x448>>2] = v; break;
gfx3d_glPopMatrix(v); case 0x13: // MTX_STORE - Store Current Matrix on Stack (W)
--clInd; *(u32 *)(ARM9Mem.ARM9_REG + 0x44C) = cmd;
clCmd>>=8; gfx3d_glStoreMatrix(cmd);
break; clCmd >>= 8;
} clInd--;
break;
case 0x13: case 0x14: // MTX_RESTORE - Restore Current Matrix from Stack (W)
{ *(u32 *)(ARM9Mem.ARM9_REG + 0x450) = cmd;
((unsigned long *)ARM9Mem.ARM9_REG)[0x44C>>2] = v; gfx3d_glRestoreMatrix(cmd);
gfx3d_glStoreMatrix(v); clCmd >>= 8;
--clInd; clInd--;
clCmd>>=8; break;
break; case 0x16: // MTX_LOAD_4x4 - Load 4x4 Matrix to Current Matrix (W)
} *(u32 *)(ARM9Mem.ARM9_REG + 0x458) = cmd;
if (!gfx3d_glLoadMatrix4x4(cmd)) break;
case 0x14: clCmd >>= 8;
{ clInd--;
((unsigned long *)ARM9Mem.ARM9_REG)[0x450>>2] = v; break;
gfx3d_glRestoreMatrix (v); case 0x17: // MTX_LOAD_4x3 - Load 4x3 Matrix to Current Matrix (W)
--clInd; *(u32 *)(ARM9Mem.ARM9_REG + 0x45C) = cmd;
clCmd>>=8; if (!gfx3d_glLoadMatrix4x3(cmd)) break;
break; clCmd >>= 8;
} clInd--;
break;
case 0x16: case 0x18: // MTX_MULT_4x4 - Multiply Current Matrix by 4x4 Matrix (W)
{ *(u32 *)(ARM9Mem.ARM9_REG + 0x460) = cmd;
((unsigned long *)ARM9Mem.ARM9_REG)[0x458>>2] = v; if (!gfx3d_glMultMatrix4x4(cmd)) break;
gfx3d_glLoadMatrix4x4(v); clCmd >>= 8;
clInd2++; clInd--;
if(clInd2==16) break;
{ case 0x19: // MTX_MULT_4x3 - Multiply Current Matrix by 4x3 Matrix (W)
--clInd; *(u32 *)(ARM9Mem.ARM9_REG + 0x464) = cmd;
clCmd>>=8; if (!gfx3d_glMultMatrix4x3(cmd)) break;
clInd2 = 0; clCmd >>= 8;
} clInd--;
break; break;
} case 0x1A: // MTX_MULT_3x3 - Multiply Current Matrix by 3x3 Matrix (W)
*(u32 *)(ARM9Mem.ARM9_REG + 0x468) = cmd;
case 0x17: if (!gfx3d_glMultMatrix3x3(cmd)) break;
{ clCmd >>= 8;
((unsigned long *)ARM9Mem.ARM9_REG)[0x45C>>2] = v; clInd--;
gfx3d_glLoadMatrix4x3(v); break;
clInd2++; case 0x1B: // MTX_SCALE - Multiply Current Matrix by Scale Matrix (W)
if(clInd2==12) *(u32 *)(ARM9Mem.ARM9_REG + 0x46C) = cmd;
{ if (!gfx3d_glScale(cmd)) break;
--clInd; clCmd >>= 8;
clCmd>>=8; clInd--;
clInd2 = 0; break;
} case 0x1C: // MTX_TRANS - Mult. Curr. Matrix by Translation Matrix (W)
break; *(u32 *)(ARM9Mem.ARM9_REG + 0x470) = cmd;
} if (!gfx3d_glTranslate(cmd)) break;
clCmd >>= 8;
case 0x18: clInd--;
{ break;
((unsigned long *)ARM9Mem.ARM9_REG)[0x460>>2] = v; case 0x20: // COLOR - Directly Set Vertex Color (W)
gfx3d_glMultMatrix4x4(v); *(u32 *)(ARM9Mem.ARM9_REG + 0x480) = cmd;
clInd2++; gfx3d_glColor3b(cmd);
if(clInd2==16) clCmd >>= 8;
{ clInd--;
--clInd; break;
clCmd>>=8; case 0x21: // NORMAL - Set Normal Vector (W)
clInd2 = 0; *(u32 *)(ARM9Mem.ARM9_REG + 0x484) = cmd;
} gfx3d_glNormal(cmd);
break; clCmd >>= 8;
} clInd--;
break;
case 0x19: case 0x22: // TEXCOORD - Set Texture Coordinates (W)
{ *(u32 *)(ARM9Mem.ARM9_REG + 0x488) = cmd;
((unsigned long *)ARM9Mem.ARM9_REG)[0x464>>2] = v; gfx3d_glTexCoord(cmd);
gfx3d_glMultMatrix4x3(v); clCmd >>= 8;
clInd2++; clInd--;
if(clInd2==12) break;
{ case 0x23: // VTX_16 - Set Vertex XYZ Coordinates (W)
--clInd; *(u32 *)(ARM9Mem.ARM9_REG + 0x48C) = cmd;
clCmd>>=8; if (!gfx3d_glVertex16b(cmd)) break;
clInd2 = 0; clCmd >>= 8;
} clInd--;
break; break;
} case 0x24: // VTX_10 - Set Vertex XYZ Coordinates (W)
*(u32 *)(ARM9Mem.ARM9_REG + 0x490) = cmd;
case 0x1A: gfx3d_glVertex10b(cmd);
{ clCmd >>= 8;
((unsigned long *)ARM9Mem.ARM9_REG)[0x468>>2] = v; clInd--;
gfx3d_glMultMatrix3x3(v); break;
clInd2++; case 0x25: // VTX_XY - Set Vertex XY Coordinates (W)
if(clInd2==9) *(u32 *)(ARM9Mem.ARM9_REG + 0x494) = cmd;
{ gfx3d_glVertex3_cord(0, 1, cmd);
--clInd; clCmd >>= 8;
clCmd>>=8; clInd--;
clInd2 = 0; break;
} case 0x26: // VTX_XZ - Set Vertex XZ Coordinates (W)
break; *(u32 *)(ARM9Mem.ARM9_REG + 0x498) = cmd;
} gfx3d_glVertex3_cord(0, 2, cmd);
clCmd >>= 8;
case 0x1B: clInd--;
{ break;
((unsigned long *)ARM9Mem.ARM9_REG)[0x46C>>2] = v; case 0x27: // VTX_YZ - Set Vertex YZ Coordinates (W)
gfx3d_glScale (v); *(u32 *)(ARM9Mem.ARM9_REG + 0x49C) = cmd;
clInd2++; gfx3d_glVertex3_cord(1, 2, cmd);
if(clInd2==3) clCmd >>= 8;
{ clInd--;
--clInd; break;
clCmd>>=8; case 0x28: // VTX_DIFF - Set Relative Vertex Coordinates (W)
clInd2 = 0; *(u32 *)(ARM9Mem.ARM9_REG + 0x4A0) = cmd;
} gfx3d_glVertex_rel(cmd);
break; clCmd >>= 8;
} clInd--;
break;
case 0x1C: case 0x29: // POLYGON_ATTR - Set Polygon Attributes (W)
{ *(u32 *)(ARM9Mem.ARM9_REG + 0x4A4) = cmd;
((unsigned long *)ARM9Mem.ARM9_REG)[0x470>>2] = v; gfx3d_glPolygonAttrib(cmd);
gfx3d_glTranslate (v); clCmd >>= 8;
clInd2++; clInd--;
if(clInd2==3) break;
{ case 0x2A: // TEXIMAGE_PARAM - Set Texture Parameters (W)
--clInd; *(u32 *)(ARM9Mem.ARM9_REG + 0x4A8) = cmd;
clCmd>>=8; gfx3d_glTexImage(cmd);
clInd2 = 0; clCmd >>= 8;
} clInd--;
break; break;
} case 0x2B: // PLTT_BASE - Set Texture Palette Base Address (W)
*(u32 *)(ARM9Mem.ARM9_REG + 0x4AC) = cmd;
case 0x20 : gfx3d_glTexPalette(cmd);
{ clCmd >>= 8;
((unsigned long *)ARM9Mem.ARM9_REG)[0x480>>2] = v; clInd--;
gfx3d_glColor3b(v); break;
--clInd; case 0x30: // DIF_AMB - MaterialColor0 - Diffuse/Ambient Reflect. (W)
clCmd>>=8; *(u32 *)(ARM9Mem.ARM9_REG + 0x4C0) = cmd;
break; gfx3d_glMaterial0(cmd);
} clCmd >>= 8;
clInd--;
case 0x21 : break;
{ case 0x31: // SPE_EMI - MaterialColor1 - Specular Ref. & Emission (W)
((unsigned long *)ARM9Mem.ARM9_REG)[0x484>>2] = v; *(u32 *)(ARM9Mem.ARM9_REG + 0x4C4) = cmd;
gfx3d_glNormal(v); gfx3d_glMaterial1(cmd);
--clInd; clCmd >>= 8;
clCmd>>=8; clInd--;
break; break;
} case 0x32: // LIGHT_VECTOR - Set Light's Directional Vector (W)
*(u32 *)(ARM9Mem.ARM9_REG + 0x4C8) = cmd;
case 0x22 : gfx3d_glLightDirection(cmd);
{ clCmd >>= 8;
((unsigned long *)ARM9Mem.ARM9_REG)[0x488>>2] = v; clInd--;
gfx3d_glTexCoord(v); break;
--clInd; case 0x33: // LIGHT_COLOR - Set Light Color (W)
clCmd>>=8; *(u32 *)(ARM9Mem.ARM9_REG + 0x4CC) = cmd;
break; gfx3d_glLightColor(cmd);
} clCmd >>= 8;
clInd--;
case 0x23 : break;
{ case 0x34: // SHININESS - Specular Reflection Shininess Table (W)
((unsigned long *)ARM9Mem.ARM9_REG)[0x48C>>2] = v; *(u32 *)(ARM9Mem.ARM9_REG + 0x4D0) = cmd;
gfx3d_glVertex16b(v); if (!gfx3d_glShininess(cmd)) break;
clInd2++; clCmd >>= 8;
if(clInd2==2) clInd--;
{ break;
--clInd; case 0x40: // BEGIN_VTXS - Start of Vertex List (W)
clCmd>>=8; *(u32 *)(ARM9Mem.ARM9_REG + 0x500) = cmd;
clInd2 = 0; gfx3d_glBegin(cmd);
} clCmd >>= 8;
break; clInd--;
} break;
case 0x50: // SWAP_BUFFERS - Swap Rendering Engine Buffer (W)
case 0x24: *(u32 *)(ARM9Mem.ARM9_REG + 0x540) = cmd;
{ gfx3d_glFlush(cmd);
((unsigned long *)ARM9Mem.ARM9_REG)[0x490>>2] = v; clCmd >>= 8;
gfx3d_glVertex10b(v); clInd--;
--clInd; break;
clCmd>>=8; case 0x60: // VIEWPORT - Set Viewport (W)
break; *(u32 *)(ARM9Mem.ARM9_REG + 0x580) = cmd;
} gfx3d_glViewPort(cmd);
clCmd >>= 8;
case 0x25:// GFX_VERTEX_XY clInd--;
{ break;
((unsigned long *)ARM9Mem.ARM9_REG)[0x494>>2] = v; case 0x70: // BOX_TEST - Test if Cuboid Sits inside View Volume (W)
gfx3d_glVertex3_cord(0,1,v); *(u32 *)(ARM9Mem.ARM9_REG + 0x5C0) = cmd;
--clInd; if (!gfx3d_glBoxTest(cmd)) break;
clCmd>>=8; clCmd >>= 8;
break; clInd--;
} break;
case 0x71: // POS_TEST - Set Position Coordinates for Test (W)
case 0x26:// GFX_VERTEX_XZ *(u32 *)(ARM9Mem.ARM9_REG + 0x5C4) = cmd;
{ if (!gfx3d_glPosTest(cmd)) break;
((unsigned long *)ARM9Mem.ARM9_REG)[0x498>>2] = v; clCmd >>= 8;
gfx3d_glVertex3_cord(0,2,v); clInd--;
--clInd; break;
clCmd>>=8; case 0x72: // VEC_TEST - Set Directional Vector for Test (W)
break; *(u32 *)(ARM9Mem.ARM9_REG + 0x5C8) = cmd;
} gfx3d_glVecTest(cmd);
clCmd >>= 8;
case 0x27:// GFX_VERTEX_YZ clInd--;
{ break;
((unsigned long *)ARM9Mem.ARM9_REG)[0x49C>>2] = v;
gfx3d_glVertex3_cord(1,2,v);
--clInd;
clCmd>>=8;
break;
}
case 0x28: // GFX_VERTEX_DIFF
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x4A0>>2] = v;
gfx3d_glVertex_rel (v);
--clInd;
clCmd>>=8;
break;
}
case 0x29:
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x4A4>>2] = v;
gfx3d_glPolygonAttrib (v);
--clInd;
clCmd>>=8;
break;
}
case 0x2A:
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x4A8>>2] = v;
gfx3d_glTexImage (v);
--clInd;
clCmd>>=8;
break;
}
case 0x2B:
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x4AC>>2] = v;
gfx3d_glTexPalette (v&0x1FFF);
--clInd;
clCmd>>=8;
break;
}
case 0x30: // GFX_DIFFUSE_AMBIENT
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x4C0>>2] = v;
gfx3d_glMaterial0(v);
--clInd;
clCmd>>=8;
break;
}
case 0x31: // GFX_SPECULAR_EMISSION
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x4C4>>2] = v;
gfx3d_glMaterial1(v);
--clInd;
clCmd>>=8;
break;
}
case 0x32:
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x4C8>>2] = v;
gfx3d_glLightDirection(v);
--clInd;
clCmd>>=8;
break;
}
case 0x33:
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x4CC>>2] = v;
gfx3d_glLightColor(v);
--clInd;
clCmd>>=8;
break;
}
case 0x34:
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x4D0>>2] = v;
gfx3d_glShininess (v);
clInd2++;
if(clInd2==32)
{
--clInd;
clCmd>>=8;
clInd2 = 0;
}
break;
}
case 0x40 :
{
//old_vtxFormat=((unsigned long *)ARM9Mem.ARM9_REG)[0x500>>2];
((unsigned long *)ARM9Mem.ARM9_REG)[0x500>>2] = v;
gfx3d_glBegin(v);
--clInd;
clCmd>>=8;
break;
}
/*
case 0x50:
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x540>>2] = v;
NDS_glFlush(v);
--clInd;
clCmd>>=8;
break;
}
*/
case 0x60:
{
((unsigned long *)ARM9Mem.ARM9_REG)[0x580>>2] = v;
gfx3d_glViewPort(v);
--clInd;
clCmd>>=8;
break;
}
/*
case 0x80:
{
clInd2++;
if(clInd2==7)
{
--clInd;
clCmd>>=8;
clInd2 = 0;
}
break;
}
*/
default: default:
{ INFO("Unknown 3D command 0x%02X in cmd=0x%02X\n", clCmd&0xFF, cmd);
LOG ("Unknown 3D command %02X\n", clCmd&0xFF); clCmd >>= 8;
--clInd; clInd--;
clCmd>>=8; //NDS_Pause();
break; break;
}
}
if((clCmd&0xFF)==0x41)
{
--clInd;
clCmd>>=8;
} }
} }
@ -1355,10 +1239,6 @@ void gfx3d_glFlush(unsigned long v)
gfx3d.wbuffer = (v&1)!=0; gfx3d.wbuffer = (v&1)!=0;
gfx3d.sortmode = ((v>>1)&1)!=0; gfx3d.sortmode = ((v>>1)&1)!=0;
//reset GE state
clCmd = 0;
clInd = 0;
//the renderer wil lget the lists we just built //the renderer wil lget the lists we just built
gfx3d.polylist = polylist; gfx3d.polylist = polylist;
gfx3d.vertlist = vertlist; gfx3d.vertlist = vertlist;
@ -1482,13 +1362,10 @@ SFORMAT SF_GFX3D[]={
{ "GM3P", 4, 1, &mtxStack[3].position}, { "GM3P", 4, 1, &mtxStack[3].position},
{ "GM3M", 4,16, mtxStack[3].matrix}, { "GM3M", 4,16, mtxStack[3].matrix},
{ "ML4I", 1, 1, &ML4x4ind}, { "ML4I", 1, 1, &ML4x4ind},
{ "ML3C", 1, 1, &ML4x3_c}, { "ML3I", 1, 1, &ML4x3ind},
{ "ML3L", 1, 1, &ML4x3_l},
{ "MM4I", 1, 1, &MM4x4ind}, { "MM4I", 1, 1, &MM4x4ind},
{ "MM3C", 1, 1, &MM4x3_c}, { "MM3I", 1, 1, &MM4x3ind},
{ "MM3L", 1, 1, &MM4x3_l}, { "MMxI", 1, 1, &MM3x3ind},
{ "MMxC", 1, 1, &MM3x3_c},
{ "MMxL", 1, 1, &MM3x3_l},
{ "GCOR", 4, 1, coord}, { "GCOR", 4, 1, coord},
{ "GCOI", 1, 1, &coordind}, { "GCOI", 1, 1, &coordind},
{ "GVFM", 4, 1, &vtxFormat}, { "GVFM", 4, 1, &vtxFormat},
@ -1502,7 +1379,6 @@ SFORMAT SF_GFX3D[]={
{ "GL_S", 4, 1, &last_s}, { "GL_S", 4, 1, &last_s},
{ "GLCM", 4, 1, &clCmd}, { "GLCM", 4, 1, &clCmd},
{ "GLIN", 4, 1, &clInd}, { "GLIN", 4, 1, &clInd},
{ "GLI2", 4, 1, &clInd2},
{ "GCOL", 1, 4, colorRGB}, { "GCOL", 1, 4, colorRGB},
{ "GLCO", 4, 4, lightColor}, { "GLCO", 4, 4, lightColor},
{ "GLDI", 4, 4, lightDirection}, { "GLDI", 4, 4, lightDirection},
@ -1532,6 +1408,8 @@ SFORMAT SF_GFX3D[]={
{ "GSFC", 4, 4, gfx3d.fogColor}, { "GSFC", 4, 4, gfx3d.fogColor},
{ "GSFO", 4, 1, &gfx3d.fogOffset}, { "GSFO", 4, 1, &gfx3d.fogOffset},
{ "GSTT", 4, 32, gfx3d.rgbToonTable}, { "GSTT", 4, 32, gfx3d.rgbToonTable},
{ "GSST", 4, 128, shininessTable},
{ "GSSI", 2, 1, &shininessInd},
{ 0 } { 0 }
}; };

View File

@ -143,21 +143,21 @@ void gfx3d_glFogOffset (unsigned long v);
void gfx3d_glClearDepth(unsigned long v); void gfx3d_glClearDepth(unsigned long v);
void gfx3d_glMatrixMode(unsigned long v); void gfx3d_glMatrixMode(unsigned long v);
void gfx3d_glLoadIdentity(); void gfx3d_glLoadIdentity();
void gfx3d_glLoadMatrix4x4(signed long v); BOOL gfx3d_glLoadMatrix4x4(signed long v);
void gfx3d_glLoadMatrix4x3(signed long v); BOOL gfx3d_glLoadMatrix4x3(signed long v);
void gfx3d_glStoreMatrix(unsigned long v); void gfx3d_glStoreMatrix(unsigned long v);
void gfx3d_glRestoreMatrix(unsigned long v); void gfx3d_glRestoreMatrix(unsigned long v);
void gfx3d_glPushMatrix(void); void gfx3d_glPushMatrix(void);
void gfx3d_glPopMatrix(signed long i); void gfx3d_glPopMatrix(signed long i);
void gfx3d_glTranslate(signed long v); BOOL gfx3d_glTranslate(signed long v);
void gfx3d_glScale(signed long v); BOOL gfx3d_glScale(signed long v);
void gfx3d_glMultMatrix3x3(signed long v); BOOL gfx3d_glMultMatrix3x3(signed long v);
void gfx3d_glMultMatrix4x3(signed long v); BOOL gfx3d_glMultMatrix4x3(signed long v);
void gfx3d_glMultMatrix4x4(signed long v); BOOL gfx3d_glMultMatrix4x4(signed long v);
void gfx3d_glBegin(unsigned long v); void gfx3d_glBegin(unsigned long v);
void gfx3d_glEnd(void); void gfx3d_glEnd(void);
void gfx3d_glColor3b(unsigned long v); void gfx3d_glColor3b(unsigned long v);
void gfx3d_glVertex16b(unsigned int v); BOOL gfx3d_glVertex16b(unsigned int v);
void gfx3d_glVertex10b(unsigned long v); void gfx3d_glVertex10b(unsigned long v);
void gfx3d_glVertex3_cord(unsigned int one, unsigned int two, unsigned int v); void gfx3d_glVertex3_cord(unsigned int one, unsigned int two, unsigned int v);
void gfx3d_glVertex_rel(unsigned long v); void gfx3d_glVertex_rel(unsigned long v);
@ -167,7 +167,7 @@ int gfx3d_GetNumVertex();
void gfx3d_glPolygonAttrib (unsigned long val); void gfx3d_glPolygonAttrib (unsigned long val);
void gfx3d_glMaterial0(unsigned long val); void gfx3d_glMaterial0(unsigned long val);
void gfx3d_glMaterial1(unsigned long val); void gfx3d_glMaterial1(unsigned long val);
void gfx3d_glShininess (unsigned long val); BOOL gfx3d_glShininess (unsigned long val);
void gfx3d_UpdateToonTable(void* toonTable); void gfx3d_UpdateToonTable(void* toonTable);
void gfx3d_glTexImage(unsigned long val); void gfx3d_glTexImage(unsigned long val);
void gfx3d_glTexPalette(unsigned long val); void gfx3d_glTexPalette(unsigned long val);
@ -178,12 +178,12 @@ signed long gfx3d_GetDirectionalMatrix (unsigned int index);
void gfx3d_glLightDirection (unsigned long v); void gfx3d_glLightDirection (unsigned long v);
void gfx3d_glLightColor (unsigned long v); void gfx3d_glLightColor (unsigned long v);
void gfx3d_glAlphaFunc(unsigned long v); void gfx3d_glAlphaFunc(unsigned long v);
void gfx3d_glBoxTest(unsigned long v); BOOL gfx3d_glBoxTest(unsigned long v);
void gfx3d_glPosTest(unsigned long v); BOOL gfx3d_glPosTest(unsigned long v);
void gfx3d_glVecTest(unsigned long v); void gfx3d_glVecTest(unsigned long v);
void gfx3d_glGetPosRes(unsigned int index); void gfx3d_glGetPosRes(unsigned int index);
void gfx3d_glGetVecRes(unsigned int index); void gfx3d_glGetVecRes(unsigned int index);
void gfx3d_glCallList(unsigned long v); void gfx3d_glCallList(u32 addr, u32 cmd);
void gfx3d_glFlush(unsigned long v); void gfx3d_glFlush(unsigned long v);
void gfx3d_VBlankSignal(); void gfx3d_VBlankSignal();
void gfx3d_VBlankEndSignal(); void gfx3d_VBlankEndSignal();