From 5d310e60145e204a48f155ae8a32cb396f62e465 Mon Sep 17 00:00:00 2001 From: The Dax Date: Thu, 28 Nov 2013 12:35:15 -0500 Subject: [PATCH 1/7] Add an option to allow the emulated PSP model to be changed. Some games require a PSP-2000 for features such as multiplayer. --- Core/Config.cpp | 3 +++ Core/Config.h | 1 + Core/HLE/scePower.cpp | 6 ++++-- UI/GameSettingsScreen.cpp | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 2cf4ece238..86c379d378 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -294,6 +294,8 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { } IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); + // 0 = PSP Fat, 1 = PSP Slim + pspConfig->Get("PSPModel", &iPSPModel, 0); pspConfig->Get("NickName", &sNickName, "PPSSPP"); pspConfig->Get("proAdhocServer", &proAdhocServer, "localhost"); pspConfig->Get("MacAddress", &localMacAddress, "01:02:03:04:05:06"); @@ -520,6 +522,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..978fca81c6 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -213,6 +213,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..32760e5299 100644 --- a/Core/HLE/scePower.cpp +++ b/Core/HLE/scePower.cpp @@ -55,7 +55,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 +412,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/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 9d57987d0e..1520b7b56b 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -295,6 +295,9 @@ void GameSettingsScreen::CreateViews() { systemSettings->Add(new PopupMultiChoice(&g_Config.iTimeFormat, s->T("Time Format"), timeFormat, 1, 2, s, screenManager())); static const char *buttonPref[] = { "Use O to confirm", "Use X to confirm" }; systemSettings->Add(new PopupMultiChoice(&g_Config.iButtonPreference, s->T("Confirmation Button"), buttonPref, 0, 2, s, screenManager())); + static const char *pspModels[] = { "PSP-1000 (Fat)", "PSP-2000 (Slim)" }; + systemSettings->Add(new PopupMultiChoice(&g_Config.iPSPModel, s->T("PSP Model"), pspModels, 0, 2, s, screenManager())); + } UI::EventReturn GameSettingsScreen::OnRenderingMode(UI::EventParams &e) { From 85e3a2dbfbb6d0962af96dfad9639ae86a09dbfb Mon Sep 17 00:00:00 2001 From: The Dax Date: Thu, 28 Nov 2013 14:37:10 -0500 Subject: [PATCH 2/7] Make the model option ini-only. Move PSP_MODEL_FAT and PSP_MODEL_SLIM to Config.h. Default to a PSP Slim, and enable 64 megs of memory by default. --- Core/Config.cpp | 3 +-- Core/Config.h | 2 ++ Core/HLE/scePower.cpp | 3 --- Core/MemMap.h | 3 +++ Core/PSPLoaders.cpp | 1 + Core/System.cpp | 6 +++++- UI/GameSettingsScreen.cpp | 3 --- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 86c379d378..fa89f5d2a4 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -294,8 +294,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { } IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam"); - // 0 = PSP Fat, 1 = PSP Slim - pspConfig->Get("PSPModel", &iPSPModel, 0); + 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"); diff --git a/Core/Config.h b/Core/Config.h index 978fca81c6..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; diff --git a/Core/HLE/scePower.cpp b/Core/HLE/scePower.cpp index 32760e5299..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; diff --git a/Core/MemMap.h b/Core/MemMap.h index e82ed7b272..d8f160fa98 100644 --- a/Core/MemMap.h +++ b/Core/MemMap.h @@ -82,6 +82,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..8fd570cae1 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -153,7 +153,11 @@ 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; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 1520b7b56b..9d57987d0e 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -295,9 +295,6 @@ void GameSettingsScreen::CreateViews() { systemSettings->Add(new PopupMultiChoice(&g_Config.iTimeFormat, s->T("Time Format"), timeFormat, 1, 2, s, screenManager())); static const char *buttonPref[] = { "Use O to confirm", "Use X to confirm" }; systemSettings->Add(new PopupMultiChoice(&g_Config.iButtonPreference, s->T("Confirmation Button"), buttonPref, 0, 2, s, screenManager())); - static const char *pspModels[] = { "PSP-1000 (Fat)", "PSP-2000 (Slim)" }; - systemSettings->Add(new PopupMultiChoice(&g_Config.iPSPModel, s->T("PSP Model"), pspModels, 0, 2, s, screenManager())); - } UI::EventReturn GameSettingsScreen::OnRenderingMode(UI::EventParams &e) { From 1b8df0d8260ba9f19fa00db46b3aa64b28d14bb7 Mon Sep 17 00:00:00 2001 From: The Dax Date: Thu, 28 Nov 2013 14:58:59 -0500 Subject: [PATCH 3/7] Save the model into the save state. --- Core/MemMap.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 541bd6b885..97fadb36ee 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 { @@ -108,6 +109,8 @@ void DoState(PointerWrap &p) p.DoMarker("VRAM"); p.DoArray(m_pScratchPad, SCRATCHPAD_SIZE); p.DoMarker("ScratchPad"); + p.Do(g_Config.iPSPModel); + p.DoMarker("PSPModel"); } void Shutdown() From ba31e1806091f55eedfbaa2156a3f57e45e66cd0 Mon Sep 17 00:00:00 2001 From: The Dax Date: Thu, 28 Nov 2013 15:34:11 -0500 Subject: [PATCH 4/7] 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); From 998a6f6fdb0ea926358a5f2ed8012eb7d0c932ac Mon Sep 17 00:00:00 2001 From: The Dax Date: Thu, 28 Nov 2013 15:36:24 -0500 Subject: [PATCH 5/7] Load the model from the savestate before deciding the memory size. --- Core/MemMap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 3049fe77f5..80d28d0da7 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -110,9 +110,10 @@ void DoState(PointerWrap &p) 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"); + + g_MemorySize = g_PSPModel == PSP_MODEL_FAT ? RAM_NORMAL_SIZE : RAM_DOUBLE_SIZE; } p.DoArray(m_pRAM, g_MemorySize); From 3e07e88e43cd5bce61df33d6d0bee084c32110aa Mon Sep 17 00:00:00 2001 From: The Dax Date: Thu, 28 Nov 2013 16:28:25 -0500 Subject: [PATCH 6/7] Don't break savestates made by HD Remasters. --- Core/MemMap.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 80d28d0da7..1f5c1773f1 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -106,14 +106,15 @@ void DoState(PointerWrap &p) return; if (s < 2) { - g_MemorySize = RAM_NORMAL_SIZE; + if (!g_RemasterMode) + g_MemorySize = RAM_NORMAL_SIZE; g_PSPModel = PSP_MODEL_FAT; } else { p.Do(g_PSPModel); p.DoMarker("PSPModel"); - - g_MemorySize = g_PSPModel == PSP_MODEL_FAT ? RAM_NORMAL_SIZE : RAM_DOUBLE_SIZE; + if (!g_RemasterMode) + g_MemorySize = g_PSPModel == PSP_MODEL_FAT ? RAM_NORMAL_SIZE : RAM_DOUBLE_SIZE; } p.DoArray(m_pRAM, g_MemorySize); From e0f0409f82165bd1916c9a7060da4eb036e7d24f Mon Sep 17 00:00:00 2001 From: The Dax Date: Thu, 28 Nov 2013 17:46:33 -0500 Subject: [PATCH 7/7] Minimum version for the memory savestate section is 1, not 0. --- Core/MemMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 1f5c1773f1..aea9633e7e 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -101,7 +101,7 @@ void Init() void DoState(PointerWrap &p) { - auto s = p.Section("Memory", 0, 2); + auto s = p.Section("Memory", 1, 2); if (!s) return;