diff options
author | Raphaël Zumer <rzumer@tebako.net> | 2019-12-22 11:45:11 -0500 |
---|---|---|
committer | Raphaël Zumer <rzumer@tebako.net> | 2019-12-22 11:45:11 -0500 |
commit | a57ba1368e151484908052d696aa90f28928cfe2 (patch) | |
tree | afa62e6d26ff219a4e9e538dd39fc32ec7384c0e /src | |
parent | 2abdcc54dd159a89a2545e8c6c34e1f0687a64f4 (diff) |
Skip saving/loading GBA flash state if SRAM is null
Diffstat (limited to 'src')
-rw-r--r-- | src/GBACart.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/GBACart.cpp b/src/GBACart.cpp index 1829ca7..f6bed86 100644 --- a/src/GBACart.cpp +++ b/src/GBACart.cpp @@ -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);
|