diff --git a/Core/Config.cpp b/Core/Config.cpp index ab9ac697a1..7406193224 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -294,6 +294,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { } IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); + pspConfig->Get("PSPModel", &iPSPModel, PSP_MODEL_SLIM); pspConfig->Get("NickName", &sNickName, "PPSSPP"); pspConfig->Get("proAdhocServer", &proAdhocServer, "localhost"); pspConfig->Get("MacAddress", &localMacAddress, "01:02:03:04:05:06"); @@ -519,6 +520,7 @@ void Config::Save() { IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); + pspConfig->Set("PSPModel", iPSPModel); pspConfig->Set("NickName", sNickName.c_str()); pspConfig->Set("proAdhocServer", proAdhocServer.c_str()); pspConfig->Set("MacAddress", localMacAddress.c_str()); diff --git a/Core/Config.h b/Core/Config.h index c2803bd71b..98d5b3ca8f 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -27,6 +27,8 @@ extern const char *PPSSPP_GIT_VERSION; #endif const int MAX_CONFIG_VOLUME = 8; +const int PSP_MODEL_FAT = 0; +const int PSP_MODEL_SLIM = 1; namespace http { class Download; @@ -213,6 +215,7 @@ public: bool bEncryptSave; int iWlanAdhocChannel; bool bWlanPowerSave; + int iPSPModel; // TODO: Make this work with your platform, too! #ifdef _WIN32 bool bBypassOSKWithKeyboard; diff --git a/Core/HLE/scePower.cpp b/Core/HLE/scePower.cpp index 8130ec6d57..ac068a9fdc 100644 --- a/Core/HLE/scePower.cpp +++ b/Core/HLE/scePower.cpp @@ -45,9 +45,6 @@ const int PSP_POWER_CB_BATTERY_FULL = 0x00000064; const int POWER_CB_AUTO = -1; -const int PSP_MODEL_FAT = 0; -const int PSP_MODEL_SLIM = 1; - const int numberOfCBPowerSlots = 16; const int numberOfCBPowerSlotsPrivate = 32; @@ -55,7 +52,7 @@ static bool volatileMemLocked; static int powerCbSlots[numberOfCBPowerSlots]; static std::vector volatileWaitingThreads; -// this should belong here on in CoreTiming? +// Should this belong here, or in CoreTiming? static int pllFreq = 222; static int busFreq = 111; @@ -412,7 +409,9 @@ int scePowerTick() { u32 IsPSPNonFat() { - return PSP_MODEL_FAT; + DEBUG_LOG(HLE, "%d=scePower_a85880d0_IsPSPNonFat()", g_Config.iPSPModel); + + return g_Config.iPSPModel; } static const HLEFunction scePower[] = { diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 541bd6b885..aea9633e7e 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -27,6 +27,7 @@ #include "HLE/HLE.h" #include "CPU.h" #include "Debugger/SymbolMap.h" +#include "Core/Config.h" namespace Memory { @@ -60,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[] = @@ -98,12 +101,25 @@ void Init() void DoState(PointerWrap &p) { - auto s = p.Section("Memory", 1); + auto s = p.Section("Memory", 1, 2); if (!s) return; + if (s < 2) { + if (!g_RemasterMode) + g_MemorySize = RAM_NORMAL_SIZE; + g_PSPModel = PSP_MODEL_FAT; + } + else { + p.Do(g_PSPModel); + p.DoMarker("PSPModel"); + if (!g_RemasterMode) + g_MemorySize = g_PSPModel == PSP_MODEL_FAT ? RAM_NORMAL_SIZE : RAM_DOUBLE_SIZE; + } + p.DoArray(m_pRAM, g_MemorySize); p.DoMarker("RAM"); + p.DoArray(m_pVRAM, VRAM_SIZE); p.DoMarker("VRAM"); p.DoArray(m_pScratchPad, SCRATCHPAD_SIZE); diff --git a/Core/MemMap.h b/Core/MemMap.h index e82ed7b272..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 { @@ -82,6 +83,9 @@ enum RAM_NORMAL_SIZE = 0x02000000, RAM_NORMAL_MASK = RAM_NORMAL_SIZE - 1, + // Used if the PSP model is PSP-2000 (Slim). + RAM_DOUBLE_SIZE = RAM_NORMAL_SIZE * 2, + VRAM_SIZE = 0x200000, VRAM_MASK = VRAM_SIZE - 1, diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index 0f0e825bca..7dfce911a8 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -41,6 +41,7 @@ #include "HLE/sceKernelModule.h" #include "HLE/sceKernelMemory.h" #include "ELF/ParamSFO.h" +#include "Core/Config.h" // We gather the game info before actually loading/booting the ISO // to determine if the emulator should enable extra memory and diff --git a/Core/System.cpp b/Core/System.cpp index 37a461ee43..161af350ca 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -153,9 +153,14 @@ void CPU_Init() { // Default memory settings // Seems to be the safest place currently.. - Memory::g_MemorySize = Memory::RAM_NORMAL_SIZE; // 32 MB of ram by default + if (g_Config.iPSPModel == PSP_MODEL_FAT) + Memory::g_MemorySize = Memory::RAM_NORMAL_SIZE; // 32 MB of ram by default + else + Memory::g_MemorySize = Memory::RAM_DOUBLE_SIZE; + g_RemasterMode = false; g_DoubleTextureCoordinates = false; + Memory::g_PSPModel = g_Config.iPSPModel; std::string filename = coreParameter.fileToStart; IdentifiedFileType type = Identify_File(filename);