- some cleanups GXFIFO;
This commit is contained in:
parent
d963afde7f
commit
2d288f338f
|
@ -70,7 +70,6 @@ void IPC_FIFOsend(u8 proc, u32 val)
|
||||||
T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l);
|
T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l);
|
||||||
T1WriteWord(MMU.MMU_MEM[proc_remote][0x40], 0x184, cnt_r);
|
T1WriteWord(MMU.MMU_MEM[proc_remote][0x40], 0x184, cnt_r);
|
||||||
|
|
||||||
// MMU.reg_IF[proc_remote] |= ( (cnt_l & 0x0400) << 8 );
|
|
||||||
setIF(proc_remote, ((cnt_l & 0x0400)<<8));
|
setIF(proc_remote, ((cnt_l & 0x0400)<<8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +111,6 @@ u32 IPC_FIFOrecv(u8 proc)
|
||||||
T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l);
|
T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l);
|
||||||
T1WriteWord(MMU.MMU_MEM[proc_remote][0x40], 0x184, cnt_r);
|
T1WriteWord(MMU.MMU_MEM[proc_remote][0x40], 0x184, cnt_r);
|
||||||
|
|
||||||
//MMU.reg_IF[proc_remote] |= ( (cnt_l & 0x0004) << 15);
|
|
||||||
setIF(proc_remote, ((cnt_l & 0x0004)<<15));
|
setIF(proc_remote, ((cnt_l & 0x0004)<<15));
|
||||||
|
|
||||||
return (val);
|
return (val);
|
||||||
|
@ -147,7 +145,6 @@ void GFX_FIFOclear()
|
||||||
|
|
||||||
gxFIFO.tail = 0;
|
gxFIFO.tail = 0;
|
||||||
gxstat |= 0x06000000;
|
gxstat |= 0x06000000;
|
||||||
gxstat |= 0x00000002; // this is hack (must be removed later)
|
|
||||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat);
|
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +155,6 @@ void GFX_FIFOsend(u8 cmd, u32 param)
|
||||||
if (gxstat & 0x01000000) return; // full
|
if (gxstat & 0x01000000) return; // full
|
||||||
|
|
||||||
gxstat &= 0x0000FFFF;
|
gxstat &= 0x0000FFFF;
|
||||||
gxstat |= 0x00000002; // this is hack (must be removed later)
|
|
||||||
|
|
||||||
gxFIFO.cmd[gxFIFO.tail] = cmd;
|
gxFIFO.cmd[gxFIFO.tail] = cmd;
|
||||||
gxFIFO.param[gxFIFO.tail] = param;
|
gxFIFO.param[gxFIFO.tail] = param;
|
||||||
|
@ -184,7 +180,6 @@ BOOL GFX_FIFOrecv(u8 *cmd, u32 *param)
|
||||||
{
|
{
|
||||||
u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600);
|
u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600);
|
||||||
gxstat &= 0xF000FFFF;
|
gxstat &= 0xF000FFFF;
|
||||||
gxstat |= 0x00000002; // this is hack (must be removed later)
|
|
||||||
if (!gxFIFO.tail) // empty
|
if (!gxFIFO.tail) // empty
|
||||||
{
|
{
|
||||||
//gxstat |= (0x01FF << 16);
|
//gxstat |= (0x01FF << 16);
|
||||||
|
@ -234,8 +229,6 @@ void GFX_FIFOcnt(u32 val)
|
||||||
|
|
||||||
if (gxstat & 0xC0000000)
|
if (gxstat & 0xC0000000)
|
||||||
{
|
{
|
||||||
//NDS_makeARM9Int(21);
|
|
||||||
//MMU.reg_IF[0] = (1<<21);
|
|
||||||
setIF(0, (1<<21));
|
setIF(0, (1<<21));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1313,7 +1313,7 @@ static INLINE void MMU_IPCSync(u8 proc, u32 val)
|
||||||
T1WriteLong(MMU.MMU_MEM[proc^1][0x40], 0x180, sync_r);
|
T1WriteLong(MMU.MMU_MEM[proc^1][0x40], 0x180, sync_r);
|
||||||
|
|
||||||
if ((val & 0x2000) && (sync_r & 0x4000))
|
if ((val & 0x2000) && (sync_r & 0x4000))
|
||||||
MMU.reg_IF[proc^1] |= ( 1 << 16 );
|
setIF(proc^1, ( 1 << 16 ));
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================================== ARM9 *
|
//================================================================================================== ARM9 *
|
||||||
|
@ -2255,6 +2255,7 @@ void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 0x04000600:
|
case 0x04000600:
|
||||||
|
((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x600>>2] = val;
|
||||||
GFX_FIFOcnt(val);
|
GFX_FIFOcnt(val);
|
||||||
return;
|
return;
|
||||||
// Alpha test reference value - Parameters:1
|
// Alpha test reference value - Parameters:1
|
||||||
|
@ -2825,19 +2826,6 @@ u32 FASTCALL _MMU_ARM9_read32(u32 adr)
|
||||||
{
|
{
|
||||||
switch(adr)
|
switch(adr)
|
||||||
{
|
{
|
||||||
#ifndef USE_GEOMETRY_FIFO_EMULATION
|
|
||||||
case 0x04000600: // Geometry Engine Status Register (R and R/W)
|
|
||||||
{
|
|
||||||
|
|
||||||
u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][(adr >> 20)],
|
|
||||||
adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20)]);
|
|
||||||
|
|
||||||
// this is hack
|
|
||||||
//gxstat |= 0x00000002;
|
|
||||||
return gxstat;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case 0x04000640:
|
case 0x04000640:
|
||||||
case 0x04000644:
|
case 0x04000644:
|
||||||
case 0x04000648:
|
case 0x04000648:
|
||||||
|
|
|
@ -351,8 +351,9 @@ static void BindTexture(u32 tx)
|
||||||
glLoadIdentity ();
|
glLoadIdentity ();
|
||||||
glScaled (texcache[tx].invSizeX, texcache[tx].invSizeY, 1.0f);
|
glScaled (texcache[tx].invSizeX, texcache[tx].invSizeY, 1.0f);
|
||||||
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (BIT16(texcache[tx].frm) ? (BIT18(texcache[tx].frm)?GL_MIRRORED_REPEAT:GL_REPEAT) : GL_CLAMP));
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (BIT16(texcache[tx].frm) ? (BIT18(texcache[tx].frm)?GL_MIRRORED_REPEAT:GL_REPEAT) : GL_CLAMP));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (BIT17(texcache[tx].frm) ? (BIT19(texcache[tx].frm)?GL_MIRRORED_REPEAT:GL_REPEAT) : GL_CLAMP));
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (BIT17(texcache[tx].frm) ? (BIT19(texcache[tx].frm)?GL_MIRRORED_REPEAT:GL_REPEAT) : GL_CLAMP));
|
||||||
}
|
}
|
||||||
|
@ -814,20 +815,20 @@ static void OGLRender()
|
||||||
|
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
|
|
||||||
for(int j = 1; j < (type-1); j++)
|
VERT *vert0 = &gfx3d.vertlist->list[poly->vertIndexes[0]];
|
||||||
{
|
u8 alpha = material_5bit_to_8bit[poly->getAlpha()];
|
||||||
VERT *vert0 = &gfx3d.vertlist->list[poly->vertIndexes[0]];
|
u8 color0[4] = {
|
||||||
VERT *vert1 = &gfx3d.vertlist->list[poly->vertIndexes[j]];
|
|
||||||
VERT *vert2 = &gfx3d.vertlist->list[poly->vertIndexes[j+1]];
|
|
||||||
|
|
||||||
u8 alpha = material_5bit_to_8bit[poly->getAlpha()];
|
|
||||||
|
|
||||||
u8 color0[4] = {
|
|
||||||
material_5bit_to_8bit[vert0->color[0]],
|
material_5bit_to_8bit[vert0->color[0]],
|
||||||
material_5bit_to_8bit[vert0->color[1]],
|
material_5bit_to_8bit[vert0->color[1]],
|
||||||
material_5bit_to_8bit[vert0->color[2]],
|
material_5bit_to_8bit[vert0->color[2]],
|
||||||
alpha
|
alpha
|
||||||
};
|
};
|
||||||
|
|
||||||
|
for(int j = 1; j < (type-1); j++)
|
||||||
|
{
|
||||||
|
VERT *vert1 = &gfx3d.vertlist->list[poly->vertIndexes[j]];
|
||||||
|
VERT *vert2 = &gfx3d.vertlist->list[poly->vertIndexes[j+1]];
|
||||||
|
|
||||||
u8 color1[4] = {
|
u8 color1[4] = {
|
||||||
material_5bit_to_8bit[vert1->color[0]],
|
material_5bit_to_8bit[vert1->color[0]],
|
||||||
material_5bit_to_8bit[vert1->color[1]],
|
material_5bit_to_8bit[vert1->color[1]],
|
||||||
|
|
|
@ -383,7 +383,7 @@ void gfx3d_glFogOffset (u32 v)
|
||||||
void gfx3d_glClearDepth(u32 v)
|
void gfx3d_glClearDepth(u32 v)
|
||||||
{
|
{
|
||||||
//formula from http://nocash.emubase.de/gbatek.htm#ds3drearplane
|
//formula from http://nocash.emubase.de/gbatek.htm#ds3drearplane
|
||||||
v &= 0x7FFFF;
|
v &= 0x7FFF;
|
||||||
gfx3d.clearDepth = (v*0x200)+((v+1)/0x8000)*0x01FF;
|
gfx3d.clearDepth = (v*0x200)+((v+1)/0x8000)*0x01FF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1115,6 +1115,7 @@ void gfx3d_glAlphaFunc(u32 v)
|
||||||
BOOL gfx3d_glBoxTest(u32 v)
|
BOOL gfx3d_glBoxTest(u32 v)
|
||||||
{
|
{
|
||||||
u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600);
|
u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600);
|
||||||
|
gxstat &= 0xFFFFFFFD; // clear boxtest bit
|
||||||
gxstat |= 0x00000001; // busy
|
gxstat |= 0x00000001; // busy
|
||||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat);
|
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat);
|
||||||
|
|
||||||
|
@ -1203,7 +1204,8 @@ faceInside:
|
||||||
gxstat |= 0x2;
|
gxstat |= 0x2;
|
||||||
|
|
||||||
noFaceInside:*/
|
noFaceInside:*/
|
||||||
gxstat &= 0xFFFFFFFE;
|
gxstat &= 0xFFFFFFFE; // clear busy bit
|
||||||
|
gxstat |= 0x00000002; // hack
|
||||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat);
|
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1410,16 +1412,11 @@ static bool gfx3d_ysort_compare(int num1, int num2)
|
||||||
const POLY &poly1 = polylist->list[num1];
|
const POLY &poly1 = polylist->list[num1];
|
||||||
const POLY &poly2 = polylist->list[num2];
|
const POLY &poly2 = polylist->list[num2];
|
||||||
|
|
||||||
if(poly1.maxy > poly2.maxy)
|
if (poly1.maxy > poly2.maxy) return true;
|
||||||
return true;
|
if (poly1.maxy < poly2.maxy) return false;
|
||||||
else if(poly1.maxy < poly2.maxy)
|
if (poly1.miny < poly2.miny) return true;
|
||||||
return false;
|
if (poly1.miny > poly2.miny) return false;
|
||||||
else if(poly1.miny < poly2.miny)
|
return false; //equal should always return false "strict weak ordering"
|
||||||
return true;
|
|
||||||
else if(poly1.miny > poly2.miny)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return false; //equal should always return false "strict weak ordering"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx3d_doFlush()
|
static void gfx3d_doFlush()
|
||||||
|
@ -1440,12 +1437,17 @@ static void gfx3d_doFlush()
|
||||||
|
|
||||||
//find the min and max y values for each poly.
|
//find the min and max y values for each poly.
|
||||||
//TODO - this could be a small waste of time if we are manual sorting the translucent polys
|
//TODO - this could be a small waste of time if we are manual sorting the translucent polys
|
||||||
for(int i=0;i<polycount;i++) {
|
for(int i=0; i<polycount; i++)
|
||||||
|
{
|
||||||
POLY &poly = polylist->list[i];
|
POLY &poly = polylist->list[i];
|
||||||
for(int j=0;j<poly.type;j++) {
|
float verty = 0.0f;
|
||||||
VERT &vert = vertlist->list[poly.vertIndexes[j]];
|
poly.miny = poly.maxy = vertlist->list[poly.vertIndexes[0]].y;
|
||||||
poly.miny = j==0?vert.y:min(poly.miny,vert.y);
|
|
||||||
poly.maxy = j==0?vert.y:max(poly.maxy,vert.y);
|
for(int j=1; j<poly.type; j++)
|
||||||
|
{
|
||||||
|
verty = vertlist->list[poly.vertIndexes[j]].y;
|
||||||
|
poly.miny = min(poly.miny, verty);
|
||||||
|
poly.maxy = max(poly.maxy, verty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1470,7 +1472,7 @@ static void gfx3d_doFlush()
|
||||||
//should this be done after clipping??
|
//should this be done after clipping??
|
||||||
//this must be a stable sort or else advance wars DOR will flicker in the main map mode
|
//this must be a stable sort or else advance wars DOR will flicker in the main map mode
|
||||||
std::stable_sort(gfx3d.indexlist, gfx3d.indexlist + opaqueCount, gfx3d_ysort_compare);
|
std::stable_sort(gfx3d.indexlist, gfx3d.indexlist + opaqueCount, gfx3d_ysort_compare);
|
||||||
|
|
||||||
if(!gfx3d.sortmode)
|
if(!gfx3d.sortmode)
|
||||||
{
|
{
|
||||||
//if we are autosorting translucent polys, we need to do this also
|
//if we are autosorting translucent polys, we need to do this also
|
||||||
|
|
Loading…
Reference in New Issue