From 5f0ec71ad27b5c147367e42970133c9622c62b9b Mon Sep 17 00:00:00 2001 From: squall-leonhart Date: Thu, 26 Jun 2008 02:50:57 +0000 Subject: [PATCH] GBC Battery fix git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@578 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/dmg/GB.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/dmg/GB.cpp b/src/dmg/GB.cpp index 5e8068e8..24dc59bb 100644 --- a/src/dmg/GB.cpp +++ b/src/dmg/GB.cpp @@ -215,6 +215,8 @@ bool gbCapture = false; bool gbCapturePrevious = false; int gbJoymask[4] = { 0, 0, 0, 0 }; +u8 gbRamFill = 0xff; + int gbRomSizes[] = { 0x00008000, // 32K 0x00010000, // 64K 0x00020000, // 128K @@ -4125,12 +4127,6 @@ bool gbUpdateSizes() gbRamSize = gbRamSizes[ramsize]; gbRamSizeMask = gbRamSizesMasks[ramsize]; - if(gbRamSize) { - gbRam = (u8 *)malloc(gbRamSize); - memset(gbRam, 0xff, gbRamSize); - } - - gbRomType = gbRom[0x147]; if (genericflashcardEnable) { @@ -4214,6 +4210,8 @@ bool gbUpdateSizes() mapper = mapperMBC7ROM; mapperRAM = mapperMBC7RAM; mapperReadRAM = mapperMBC7ReadRAM; + gbRamSize = 0x200; + gbRamSizeMask = 0x1ff; break; // GG (GameGenie) case 0x55: @@ -4234,8 +4232,7 @@ bool gbUpdateSizes() ramsize = 3; gbRamSize = gbRamSizes[3]; gbRamSizeMask = gbRamSizesMasks[3]; - gbRam = (u8 *)malloc(gbRamSize); - memset(gbRam, 0x0, gbRamSize); + gbRamFill = 0x0; gbTAMA5ramSize = 0x100; @@ -4264,6 +4261,11 @@ bool gbUpdateSizes() return false; } + if(gbRamSize) { + gbRam = (u8 *)malloc(gbRamSize); + memset(gbRam, gbRamFill, gbRamSize); + } + switch(gbRomType) { case 0x03: case 0x06: