From 74702bae5a4c15e247b31bc7e20b2deb6243b1ae Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 27 Jul 2009 20:15:07 +0000 Subject: [PATCH] gpu: fix a bug in affine start register regeneration which may have made some games (pokemon dash?) fail to make it back from a savestate with scroll variables intact --- desmume/src/saves.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index 2e06a4e4b..b57ea3867 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -998,10 +998,19 @@ static void loadstate() // This should regenerate the graphics configuration //zero 27-jul-09 : was formerly up to 7F but that wrote to dispfifo which is dumb (one of nitsuja's desynch bugs [that he found, not caused]) - for (int i = REG_BASE_DISPA; i<=REG_BASE_DISPA + 0x66; i+=2) - _MMU_write16(i, _MMU_read16(i)); - for (int i = REG_BASE_DISPB; i<=REG_BASE_DISPB + 0x7F; i+=2) - _MMU_write16(i, _MMU_read16(i)); + //so then i brought it down to 66 but this resulted in a conceptual bug with affine start registers, which shouldnt get regenerated + //so then i just made this exhaustive list + // for (int i = REG_BASE_DISPA; i<=REG_BASE_DISPA + 0x66; i+=2) + //_MMU_write16(i, _MMU_read16(i)); + // for (int i = REG_BASE_DISPB; i<=REG_BASE_DISPB + 0x7F; i+=2) + //_MMU_write16(i, _MMU_read16(i)); + static const u8 mainRegenAddr[] = {0x00,0x02,0x08,0x0a,0x0c,0x0e,0x40,0x42,0x44,0x46,0x48,0x4a,0x4c,0x50,0x52,0x54,0x60,0x64,0x66,0x6c}; + static const u8 subRegenAddr[] = {0x00,0x02,0x08,0x0a,0x0c,0x0e,0x40,0x42,0x44,0x46,0x48,0x4a,0x4c,0x50,0x52,0x54,0x6c}; + for(int i=0;i(REG_BASE_DISPA+mainRegenAddr[i], _MMU_read16(REG_BASE_DISPA+mainRegenAddr[i])); + for(int i=0;i(REG_BASE_DISPB+subRegenAddr[i], _MMU_read16(REG_BASE_DISPB+subRegenAddr[i])); + SetupMMU(nds.debugConsole); }