diff --git a/pcsx2/IopMem.cpp b/pcsx2/IopMem.cpp index 3f8da49ffa..98898a0150 100644 --- a/pcsx2/IopMem.cpp +++ b/pcsx2/IopMem.cpp @@ -23,10 +23,10 @@ #include "DEV9/DEV9.h" #include "IopHw.h" -uptr *psxMemWLUT = NULL; -const uptr *psxMemRLUT = NULL; +uptr *psxMemWLUT = nullptr; +const uptr *psxMemRLUT = nullptr; -IopVM_MemoryAllocMess* iopMem = NULL; +IopVM_MemoryAllocMess* iopMem = nullptr; alignas(__pagesize) u8 iopHw[Ps2MemSize::IopHardware]; @@ -104,6 +104,8 @@ void iopMemReset() // this one looks like an old hack for some special write-only memory area, // but leaving it in for reference (air) //for (i=0; i<0x0008; i++) psxMemWLUT[i + 0xbfc0] = (uptr)&psR[i << 16]; + + std::memset(iopMem, 0, sizeof(*iopMem)); } u8 iopMemRead8(u32 mem) diff --git a/pcsx2/Memory.cpp b/pcsx2/Memory.cpp index 89fb669100..04e7ff3c0a 100644 --- a/pcsx2/Memory.cpp +++ b/pcsx2/Memory.cpp @@ -41,6 +41,7 @@ BIOS #include "VUmicro.h" #include "MTVU.h" #include "DEV9/DEV9.h" +#include "SaveState.h" #include "ps2/HwInternal.h" #include "ps2/BiosTools.h" @@ -53,6 +54,7 @@ BIOS #endif int MemMode = 0; // 0 is Kernel Mode, 1 is Supervisor Mode, 2 is User Mode +static int s_ba6 = 0; void memSetKernelMode() { //Do something here @@ -70,11 +72,12 @@ u16 ba0R16(u32 mem) { //MEM_LOG("ba00000 Memory read16 address %x", mem); - if (mem == 0x1a000006) { - static int ba6; - ba6++; - if (ba6 == 3) ba6 = 0; - return ba6; + if (mem == 0x1a000006) + { + s_ba6++; + if (s_ba6 == 3) + s_ba6 = 0; + return s_ba6; } return 0; } @@ -824,6 +827,10 @@ void memReset() vtlb_VMap(0x00000000,0x00000000,0x20000000); vtlb_VMapUnmap(0x20000000,0x60000000); + s_ba6 = 0; + + // BIOS is included in eeMem, so it needs to be copied after zeroing. + std::memset(eeMem, 0, sizeof(*eeMem)); CopyBIOSToMemory(); } @@ -831,3 +838,9 @@ void memRelease() { eeMem = nullptr; } + +bool SaveStateBase::memFreeze() +{ + Freeze(s_ba6); + return IsOkay(); +} diff --git a/pcsx2/SaveState.cpp b/pcsx2/SaveState.cpp index fbe54cc801..089bf6bb09 100644 --- a/pcsx2/SaveState.cpp +++ b/pcsx2/SaveState.cpp @@ -218,6 +218,7 @@ bool SaveStateBase::FreezeInternals() return false; bool okay = rcntFreeze(); + okay = okay && memFreeze(); okay = okay && gsFreeze(); okay = okay && vuMicroFreeze(); okay = okay && vuJITFreeze(); diff --git a/pcsx2/SaveState.h b/pcsx2/SaveState.h index 5ee8130d52..efdf859444 100644 --- a/pcsx2/SaveState.h +++ b/pcsx2/SaveState.h @@ -37,7 +37,7 @@ enum class FreezeAction // [SAVEVERSION+] // This informs the auto updater that the users savestates will be invalidated. -static const u32 g_SaveVersion = (0x9A49 << 16) | 0x0000; +static const u32 g_SaveVersion = (0x9A4A << 16) | 0x0000; // the freezing data between submodules and core @@ -204,6 +204,7 @@ protected: bool vmFreeze(); bool mtvuFreeze(); bool rcntFreeze(); + bool memFreeze(); bool vuMicroFreeze(); bool vuJITFreeze(); bool vif0Freeze();