From 8b49ff30ccbcc379068fb930c7f5c15f4c033cd3 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Tue, 29 Aug 2023 12:15:22 -0500 Subject: [PATCH] Fix MBC2 data saving (F-1 Race, Kirby's Pinball Land, etc.) (#460) The old MBC2 saving routine based on gbMemory the savedata generated/stored on mapper MBC2 to not save correctly. The affected games by this includes F-1 Race, Kirby's Pinball Land, etc. This fixes said issue, by replacing the save routine from gbMemory to gbRam, like the other mapper saving routines. Also changes the savefile size to 512 kB for avoid saving issues with all MBC2 games. Based on the same fix by Steelskin. --- source/vba/gb/GB.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/vba/gb/GB.cpp b/source/vba/gb/GB.cpp index f4aec49..cda3f87 100644 --- a/source/vba/gb/GB.cpp +++ b/source/vba/gb/GB.cpp @@ -2756,7 +2756,7 @@ void gbWriteSaveMBC2(const char * name) return; } - fwrite(&gbMemoryMap[0x0a], + fwrite(gbRam, 1, 512, file); @@ -2938,7 +2938,7 @@ bool gbReadSaveMBC2(const char * name) return false; } - size_t read = fread(&gbMemoryMap[0x0a], + size_t read = fread(gbRam, 1, 512, file); @@ -5516,8 +5516,8 @@ int MemgbWriteSaveMBC1(char * membuffer) { int MemgbWriteSaveMBC2(char * membuffer) { if (gbRam) { - memcpy(membuffer, &gbMemory[0xa000], 256); - return 256; + memcpy(membuffer, gbRam, 512); + return 512; } return 0; } @@ -5601,10 +5601,10 @@ bool MemgbReadSaveMBC1(char * membuffer, int read) { bool MemgbReadSaveMBC2(char * membuffer, int read) { if (gbRam) { - if (read != 256) + if (read != 512) return false; else - memcpy(&gbMemory[0xa000], membuffer, read); + memcpy(gbRam, membuffer, read); return true; } return false;