From ba31e1806091f55eedfbaa2156a3f57e45e66cd0 Mon Sep 17 00:00:00 2001 From: The Dax Date: Thu, 28 Nov 2013 15:34:11 -0500 Subject: [PATCH] Perform savestate actions more intelligently. --- Core/MemMap.cpp | 17 ++++++++++++++--- Core/MemMap.h | 1 + Core/System.cpp | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 97fadb36ee..3049fe77f5 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -61,6 +61,8 @@ u8 *m_pUncachedVRAM; // These replace RAM_NORMAL_SIZE and RAM_NORMAL_MASK, respectively. u32 g_MemorySize; u32 g_MemoryMask; +// Used to store the PSP model on game startup. +u32 g_PSPModel; // We don't declare the IO region in here since its handled by other means. static MemoryView views[] = @@ -99,18 +101,27 @@ void Init() void DoState(PointerWrap &p) { - auto s = p.Section("Memory", 1); + auto s = p.Section("Memory", 0, 2); if (!s) return; + if (s < 2) { + g_MemorySize = RAM_NORMAL_SIZE; + g_PSPModel = PSP_MODEL_FAT; + } + else { + g_MemorySize = g_PSPModel == PSP_MODEL_FAT ? RAM_NORMAL_SIZE : RAM_DOUBLE_SIZE; + p.Do(g_PSPModel); + p.DoMarker("PSPModel"); + } + p.DoArray(m_pRAM, g_MemorySize); p.DoMarker("RAM"); + p.DoArray(m_pVRAM, VRAM_SIZE); p.DoMarker("VRAM"); p.DoArray(m_pScratchPad, SCRATCHPAD_SIZE); p.DoMarker("ScratchPad"); - p.Do(g_Config.iPSPModel); - p.DoMarker("PSPModel"); } void Shutdown() diff --git a/Core/MemMap.h b/Core/MemMap.h index d8f160fa98..7f0ec6d814 100644 --- a/Core/MemMap.h +++ b/Core/MemMap.h @@ -75,6 +75,7 @@ extern u8 *m_pUncachedVRAM; // These replace RAM_NORMAL_SIZE and RAM_NORMAL_MASK, respectively. extern u32 g_MemorySize; extern u32 g_MemoryMask; +extern u32 g_PSPModel; enum { diff --git a/Core/System.cpp b/Core/System.cpp index 8fd570cae1..161af350ca 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -160,6 +160,7 @@ void CPU_Init() { g_RemasterMode = false; g_DoubleTextureCoordinates = false; + Memory::g_PSPModel = g_Config.iPSPModel; std::string filename = coreParameter.fileToStart; IdentifiedFileType type = Identify_File(filename);