Skip to content

Commit

Permalink
Skip saving/loading GBA flash state if SRAM is null
Browse files Browse the repository at this point in the history
  • Loading branch information
rzumer committed Dec 22, 2019
1 parent 2abdcc5 commit a57ba13
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/GBACart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,24 @@ void DoSavestate(Savestate* file)
u32 oldlen = SRAMLength;

file->Var32(&SRAMLength);

if (SRAMLength != oldlen)
{
printf("savestate (GBA): VERY BAD!!!! SRAM LENGTH DIFFERENT. %d -> %d\n", oldlen, SRAMLength);
printf("oh well. loading it anyway. iojkjkojo\n");

// reallocate save memory
if (oldlen) delete[] SRAM;
if (SRAMLength) SRAM = new u8[SRAMLength];
}
if (SRAMLength)
{
// fill save memory if data is present
file->VarArray(SRAM, SRAMLength);
}
else
{
// no save data, nothing left to do
SRAMType = SaveType::S_NULL;
return;
}

// persist some extra state info
file->Var8(&SRAMFlashState.bank);
Expand Down

0 comments on commit a57ba13

Please sign in to comment.