From 08714ea7f2dc046d41c30f855bd8a635148f7d53 Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 31 Mar 2010 06:58:14 +0000 Subject: [PATCH] make swap_buffers parameter take effect for subsequent frame, instead of previous frame, contrary to intuition and good sense. fixes some dual screen games which have been w/z broken for ages --- desmume/src/gfx3d.cpp | 15 +++++++++++++-- desmume/src/gfx3d.h | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/desmume/src/gfx3d.cpp b/desmume/src/gfx3d.cpp index 4af7dc615..edb45d4cf 100644 --- a/desmume/src/gfx3d.cpp +++ b/desmume/src/gfx3d.cpp @@ -25,6 +25,12 @@ //#define FLUSHMODE_HACK +//--------------- +//TODO TODO TODO TODO +//make up mind once and for all whether fog, toon, etc. should reside in memory buffers (for easier handling in MMU) +//if they do, then we need to copy them out in doFlush!!! +//--------------- + #include #include #include @@ -1944,8 +1950,7 @@ void gfx3d_execute3D() void gfx3d_glFlush(u32 v) { //printf("-------------FLUSH------------- (vcount=%d\n",nds.VCount); - gfx3d.state.sortmode = BIT0(v); - gfx3d.state.wbuffer = BIT1(v); + gfx3d.state.pendingFlushCommand = v; #if 0 if (isSwapBuffers) { @@ -2007,8 +2012,12 @@ static void gfx3d_doFlush() gfx3d.state.enableFog = BIT7(control); gfx3d.state.enableClearImage = BIT14(control); gfx3d.state.fogShift = (control>>8)&0xF; + gfx3d.state.sortmode = BIT0(gfx3d.state.activeFlushCommand); + gfx3d.state.wbuffer = BIT1(gfx3d.state.activeFlushCommand); gfx3d.renderState = gfx3d.state; + + gfx3d.state.activeFlushCommand = gfx3d.state.pendingFlushCommand; int polycount = polylist->count; @@ -2308,6 +2317,8 @@ SFORMAT SF_GFX3D[]={ { "GST3", 4, 32, gfx3d.state.rgbToonTable}, { "GSST", 4, 128, &gfx3d.state.shininessTable[0]}, { "GSSI", 4, 1, &shininessInd}, + { "GSAF", 4, 1, &gfx3d.state.activeFlushCommand}, + { "GSPF", 4, 1, &gfx3d.state.pendingFlushCommand}, //------------------------ { "GTST", 4, 1, &triStripToggle}, { "GTVC", 4, 1, &tempVertInfo.count}, diff --git a/desmume/src/gfx3d.h b/desmume/src/gfx3d.h index 37992c622..d4254fe89 100644 --- a/desmume/src/gfx3d.h +++ b/desmume/src/gfx3d.h @@ -311,6 +311,8 @@ struct GFX3D_State , fogOffset(0) , fogShift(0) , invalidateToon(true) + , activeFlushCommand(0) + , pendingFlushCommand(0) { for(u32 i=0;i