From f8d309ec996b332f3dc630a87a4dbbbe22abb958 Mon Sep 17 00:00:00 2001 From: The Dax Date: Fri, 21 Jun 2013 01:19:47 -0400 Subject: [PATCH] Add HD Remaster support. It's a HUGE hack right now, and needs to be properly rewritten so that allocation and stuff work better. This is based off the work of BlackDaemon, and I added in the auto check to switch the code on/off depending on if the game is a remaster or not. It does not affect or break any games that I know of. --- Core/Core.vcxproj | 2 ++ Core/Core.vcxproj.filters | 6 +++++ Core/HDRemaster.cpp | 20 ++++++++++++++ Core/HDRemaster.h | 41 +++++++++++++++++++++++++++++ Core/MemMap.cpp | 2 ++ Core/MemMap.h | 6 +++-- Core/MemMapFunctions.cpp | 18 +++++++++++++ Core/PSPLoaders.cpp | 11 +++++++- GPU/GLES/DisplayListInterpreter.cpp | 9 ++++++- 9 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 Core/HDRemaster.cpp create mode 100644 Core/HDRemaster.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 4997efdf63..e2fb23c1b0 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -188,6 +188,7 @@ + @@ -368,6 +369,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 4cf70aa22e..bf8e25e7ca 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -436,6 +436,9 @@ HLE\Libraries + + Core + @@ -807,6 +810,9 @@ HLE\Libraries + + Core + diff --git a/Core/HDRemaster.cpp b/Core/HDRemaster.cpp new file mode 100644 index 0000000000..5bf731b87f --- /dev/null +++ b/Core/HDRemaster.cpp @@ -0,0 +1,20 @@ +// Copyright (c) 2012- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#include "HDRemaster.h" + +bool g_RemasterMode = false; \ No newline at end of file diff --git a/Core/HDRemaster.h b/Core/HDRemaster.h new file mode 100644 index 0000000000..0e89c33ce1 --- /dev/null +++ b/Core/HDRemaster.h @@ -0,0 +1,41 @@ +// Copyright (c) 2012- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#pragma once + +#include + +const int REMASTER_COUNT = 9; + +// This bool is the key to having the HD remasters work. +// We keep it set to false by default in PSPLoaders.cpp +// in order to keep the 99% of other PSP games working happily. +extern bool g_RemasterMode; + +// TODO: Are those BLJM* IDs really valid? I haven't seen any +// HD Remasters with them, but they're included for safety. +const std::string g_RemastersGameIDs[REMASTER_COUNT] = { + "NPJB40001", // MONSTER HUNTER PORTABLE 3rd HD Ver. + "BLJM85002", // K-ON Houkago Live HD Ver + "NPJB40002", // K-ON Houkago Live HD Ver + "BLJM85003", // Shin Sangoku Musou Multi Raid 2 HD Ver + "NPJB40003", // Shin Sangoku Musou Multi Raid 2 HD Ver + "BLJM85004", // Eiyuu Densetsu Sora no Kiseki FC Kai HD Edition + "NPJB40004", // Eiyuu Densetsu Sora no Kiseki FC Kai HD Edition + "BLJM85005", // Eiyuu Densetsu: Sora no Kiseki SC Kai HD Edition + "NPJB40005", // Eiyuu Densetsu: Sora no Kiseki SC Kai HD Edition +}; diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 0879b20bcf..ba79340e02 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -90,6 +90,8 @@ void DoState(PointerWrap &p) p.DoMarker("VRAM"); p.DoArray(m_pScratchPad, SCRATCHPAD_SIZE); p.DoMarker("ScratchPad"); + p.Do(g_RemasterMode); + p.DoMarker("RemasterMode"); } void Shutdown() diff --git a/Core/MemMap.h b/Core/MemMap.h index 016c95e51b..ffa8042ce9 100644 --- a/Core/MemMap.h +++ b/Core/MemMap.h @@ -23,6 +23,8 @@ #include "Common.h" #include "CommonTypes.h" +#include "HDRemaster.h" + // Enable memory checks in the Debug/DebugFast builds, but NOT in release #if defined(_DEBUG) || defined(DEBUGFAST) #define ENABLE_MEM_CHECK @@ -64,7 +66,7 @@ inline u32 PSP_GetKernelMemoryEnd() { return 0x08400000;} // game through sceKernelVolatileMemTryLock. inline u32 PSP_GetUserMemoryBase() { return 0x08800000;} -inline u32 PSP_GetUserMemoryEnd() { return 0x0A000000;} +inline u32 PSP_GetUserMemoryEnd() { return g_RemasterMode? 0x0B8FFFFF : 0x0A000000;} inline u32 PSP_GetDefaultLoadAddress() { return 0x08804000;} //inline u32 PSP_GetDefaultLoadAddress() { return 0x0898dab0;} @@ -100,7 +102,7 @@ extern u8 *m_pUncachedVRAM; // TODO: Later PSP models got more RAM. enum { - RAM_SIZE = 0x2000000, // 32 MB - although only the upper 24 are available for the user. + RAM_SIZE = 0x4000000, // 32 MB - although only the upper 24 are available for the user. RAM_MASK = RAM_SIZE - 1, VRAM_SIZE = 0x200000, diff --git a/Core/MemMapFunctions.cpp b/Core/MemMapFunctions.cpp index 7858ce3bae..5ae51a106c 100644 --- a/Core/MemMapFunctions.cpp +++ b/Core/MemMapFunctions.cpp @@ -24,6 +24,8 @@ #include "MIPS/MIPS.h" +#include "Core/HDRemaster.h" + // TODO: Fix this #undef ENABLE_MEM_CHECK @@ -45,6 +47,10 @@ u8 *GetPointer(const u32 address) { return m_pRAM + (address & RAM_MASK); } + else if (g_RemasterMode && (address & 0x3E000000) != 0x08000000) + { + return m_pRAM + (address & RAM_MASK); + } else if ((address & 0x3F800000) == 0x04000000) { return m_pVRAM + (address & VRAM_MASK); @@ -76,6 +82,10 @@ inline void ReadFromHardware(T &var, const u32 address) { var = *((const T*)&m_pRAM[address & RAM_MASK]); } + else if (g_RemasterMode && (address & 0x3E000000) != 0x08000000) + { + var = *((const T*)&m_pRAM[address & RAM_MASK]); + } else if ((address & 0x3F800000) == 0x04000000) { var = *((const T*)&m_pVRAM[address & VRAM_MASK]); @@ -109,6 +119,10 @@ inline void WriteToHardware(u32 address, const T data) { *(T*)&m_pRAM[address & RAM_MASK] = data; } + else if (g_RemasterMode && (address & 0x3E000000) != 0x08000000) + { + *(T*)&m_pRAM[address & RAM_MASK] = data; + } else if ((address & 0x3F800000) == 0x04000000) { *(T*)&m_pVRAM[address & VRAM_MASK] = data; @@ -139,6 +153,10 @@ bool IsValidAddress(const u32 address) { return true; } + else if (g_RemasterMode && (address & 0x3E000000) != 0x08000000) + { + return true; + } else if ((address & 0x3F800000) == 0x04000000) { return true; diff --git a/Core/PSPLoaders.cpp b/Core/PSPLoaders.cpp index 1f8a7703f4..79466850b5 100644 --- a/Core/PSPLoaders.cpp +++ b/Core/PSPLoaders.cpp @@ -63,9 +63,18 @@ bool Load_PSP_ISO(const char *filename, std::string *error_string) if (g_paramSFO.ReadSFO(paramsfo, (size_t)fileInfo.size)) { char title[1024]; - sprintf(title, "%s : %s", g_paramSFO.GetValueString("DISC_ID").c_str(), g_paramSFO.GetValueString("TITLE").c_str()); + std::string gameID = g_paramSFO.GetValueString("DISC_ID"); + sprintf(title, "%s : %s", gameID.c_str(), g_paramSFO.GetValueString("TITLE").c_str()); INFO_LOG(LOADER, "%s", title); host->SetWindowTitle(title); + g_RemasterMode = false; + for(int i = 0; i < REMASTER_COUNT; i++) { + if(g_RemastersGameIDs[i] == gameID) { + g_RemasterMode = true; + break; + } + } + DEBUG_LOG(LOADER, "HDRemaster mode is %s", g_RemasterMode? "true": "false"); } delete [] paramsfo; } diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index 77c118f7de..54a4e256e8 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -36,6 +36,8 @@ #include "../../Core/HLE/sceKernelInterrupt.h" #include "../../Core/HLE/sceGe.h" +#include "../../Core/HDRemaster.h" + extern u32 curTextureWidth; extern u32 curTextureHeight; @@ -315,9 +317,14 @@ u32 GLES_GPU::DrawSync(int mode) return GPUCommon::DrawSync(mode); } +// TODO: Fix this so it doesn't crash void GLES_GPU::FastRunLoop(DisplayList &list) { for (; downcount > 0; --downcount) { - u32 op = Memory::ReadUnchecked_U32(list.pc); + u32 op; + if(g_RemasterMode) + op = Memory::Read_U32(list.pc); + else + op = Memory::ReadUnchecked_U32(list.pc); u32 cmd = op >> 24; u32 diff = op ^ gstate.cmdmem[cmd];