From abbfa4a6b7c9dc7031b908f69f663deae0ad0cea Mon Sep 17 00:00:00 2001 From: zeromus Date: Sat, 13 Aug 2016 23:50:25 +0000 Subject: [PATCH] fix #1134 (american girls julie finds a way) by changing behaviour of box test busy flag relative to fifo --- desmume/src/FIFO.cpp | 9 +++++++++ desmume/src/gfx3d.cpp | 31 +++++++++++++++++++------------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/desmume/src/FIFO.cpp b/desmume/src/FIFO.cpp index 542bae9fc..38f10876b 100644 --- a/desmume/src/FIFO.cpp +++ b/desmume/src/FIFO.cpp @@ -237,6 +237,15 @@ void GFX_FIFOsend(u8 cmd, u32 param) if(IsMatrixStackCommand(cmd)) gxFIFO.matrix_stack_op_size++; + //along the same lines: + //american girls julie finds a way will put a bunch of stuff and then a box test into the fifo and then immediately test the busy flag + //so we need to set the busy flag here. + //does it expect the fifo to be running then? well, it's definitely jammed -- making it unjammed at one point did fix this bug. + //it's still not clear whether we're handling the immediate vs fifo commands properly at all :( + //anyway, here we go, similar treatment. consider this a hack. + if(cmd == 0x70) MMU_new.gxstat.tb = 1; //just set the flag--youre insane if you queue more than one of these anyway + if(cmd == 0x71) MMU_new.gxstat.tb = 1; + if(gxFIFO.size>=HACK_GXIFO_SIZE) { printf("--FIFO FULL-- : %d\n",gxFIFO.size); } diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index 9ed7786e0..0af210e57 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -1496,8 +1496,9 @@ static void gfx3d_glViewPort(u32 v) static BOOL gfx3d_glBoxTest(u32 v) { //printf("boxtest\n"); - MMU_new.gxstat.tr = 0; // clear boxtest bit - MMU_new.gxstat.tb = 1; // busy + + //clear result flag. busy flag has been set by fifo component already + MMU_new.gxstat.tr = 0; BTcoords[BTind++] = v & 0xFFFF; BTcoords[BTind++] = v >> 16; @@ -1505,9 +1506,11 @@ static BOOL gfx3d_glBoxTest(u32 v) if (BTind < 5) return FALSE; BTind = 0; - MMU_new.gxstat.tb = 0; // clear busy GFX_DELAY(103); + //now that we're executing this, we're not busy anymore + MMU_new.gxstat.tb = 0; + #if 0 INFO("BoxTEST: x %f y %f width %f height %f depth %f\n", BTcoords[0], BTcoords[1], BTcoords[2], BTcoords[3], BTcoords[4], BTcoords[5]); @@ -1620,27 +1623,31 @@ static BOOL gfx3d_glBoxTest(u32 v) //if any portion of this poly was retained, then the test passes. if (boxtestClipper.clippedPolyCounter > 0) { - //printf("%06d PASS %d\n",boxcounter,gxFIFO.size); + //printf("%06d PASS %d\n",gxFIFO.size, i); MMU_new.gxstat.tr = 1; break; } + else + { + } + + //if(i==5) printf("%06d FAIL\n",gxFIFO.size); } - if (MMU_new.gxstat.tr == 0) - { - //printf("%06d FAIL %d\n",boxcounter,gxFIFO.size); - } - + //printf("%06d RESULT %d\n",gxFIFO.size, MMU_new.gxstat.tr); + return TRUE; } static BOOL gfx3d_glPosTest(u32 v) { - //printf("postest\n"); //this is apparently tested by transformers decepticons and ultimate spiderman - //printf("POSTEST\n"); - MMU_new.gxstat.tb = 1; + //clear result flag. busy flag has been set by fifo component already + MMU_new.gxstat.tr = 0; + + //now that we're executing this, we're not busy anymore + MMU_new.gxstat.tb = 0; PTcoords[PTind++] = float16table[v & 0xFFFF]; PTcoords[PTind++] = float16table[v >> 16];