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.
This commit is contained in:
saulfabreg Wii VC Project 2023-08-29 12:15:22 -05:00 committed by GitHub
parent 51702bb545
commit 8b49ff30cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2756,7 +2756,7 @@ void gbWriteSaveMBC2(const char * name)
return; return;
} }
fwrite(&gbMemoryMap[0x0a], fwrite(gbRam,
1, 1,
512, 512,
file); file);
@ -2938,7 +2938,7 @@ bool gbReadSaveMBC2(const char * name)
return false; return false;
} }
size_t read = fread(&gbMemoryMap[0x0a], size_t read = fread(gbRam,
1, 1,
512, 512,
file); file);
@ -5516,8 +5516,8 @@ int MemgbWriteSaveMBC1(char * membuffer) {
int MemgbWriteSaveMBC2(char * membuffer) { int MemgbWriteSaveMBC2(char * membuffer) {
if (gbRam) { if (gbRam) {
memcpy(membuffer, &gbMemory[0xa000], 256); memcpy(membuffer, gbRam, 512);
return 256; return 512;
} }
return 0; return 0;
} }
@ -5601,10 +5601,10 @@ bool MemgbReadSaveMBC1(char * membuffer, int read) {
bool MemgbReadSaveMBC2(char * membuffer, int read) { bool MemgbReadSaveMBC2(char * membuffer, int read) {
if (gbRam) if (gbRam)
{ {
if (read != 256) if (read != 512)
return false; return false;
else else
memcpy(&gbMemory[0xa000], membuffer, read); memcpy(gbRam, membuffer, read);
return true; return true;
} }
return false; return false;