From bea49a652ecafc57b77a20e41506accdfc3b4225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 3 Mar 2025 10:45:48 +0100 Subject: [PATCH] Hook framebuffer readback function in Persona 1. We really need a more general solution for this... Although we can't generally trap acceses on all platforms :( --- Core/HLE/ReplaceTables.cpp | 12 ++++++++++++ Core/MIPS/MIPSAnalyst.cpp | 1 + UI/ImDebugger/ImDebugger.cpp | 15 +++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 778209883cce..ea8074e12209 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -1280,6 +1280,17 @@ static int Hook_omertachinmokunookitethelegacy_download_frame() { return 0; } +// Function at 0886665C in US version +static int Hook_persona1_download_frame() { + const u32 fb_address = 0x04088000; // hardcoded at 088666D8 + // const u32 dest_address = currentMIPS->r[MIPS_REG_A1]; // not relevant + if (Memory::IsVRAMAddress(fb_address)) { + gpu->PerformReadbackToMemory(fb_address, 0x00088000); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "persona1_download_frame"); + } + return 0; +} + static int Hook_katamari_render_check() { const u32 fb_address = Memory::Read_U32(currentMIPS->r[MIPS_REG_A0] + 0x3C); const u32 fbInfoPtr = Memory::Read_U32(currentMIPS->r[MIPS_REG_A0] + 0x40); @@ -1595,6 +1606,7 @@ static const ReplacementTableEntry entries[] = { { "ZZT3_select_hack", &Hook_ZZT3_select_hack, 0, REPFLAG_HOOKENTER, 0xC4 }, { "blitz_fps_hack", &Hook_blitz_fps_hack, 0, REPFLAG_HOOKEXIT , 0 }, { "brian_lara_fps_hack", &Hook_brian_lara_fps_hack, 0, REPFLAG_HOOKEXIT , 0 }, + { "persona1_download_frame", &Hook_persona1_download_frame, 0, REPFLAG_HOOKENTER, 0 }, {} }; diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index a11ac03917fc..b5288963a4cf 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -514,6 +514,7 @@ static const HardHashTableEntry hardcodedHashes[] = { { 0x7624dde603717640, 288, "ZZT3_select_hack", }, // Zettai Zetsumei Toshi 3 - bypasses softlock on character select screen #4901 { 0x0dc5ca84f707863c, 452, "blitz_fps_hack", }, // Blitz: Overtime { 0xf93d3cd093595a6c, 856, "brian_lara_fps_hack", }, // Brian Lara 2007: Pressure Play + { 0xc1d4af42a4c8860f, 964, "persona1_download_frame", }, // Persona 1 (issue #13079) }; namespace MIPSAnalyst { diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index e6875c699273..e7604ce57b53 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -6,6 +6,7 @@ #include "Common/StringUtils.h" #include "Common/File/FileUtil.h" #include "Common/Data/Format/IniFile.h" +#include "Common/Data/Text/Parsers.h" #include "Core/Config.h" #include "Core/System.h" #include "Core/RetroAchievements.h" @@ -181,6 +182,20 @@ static void DrawGPRs(ImConfig &config, ImControl &control, const MIPSDebugInterf bool noDiff = coreState == CORE_RUNNING_CPU || coreState == CORE_STEPPING_GE; + if (ImGui::Button("Copy all to clipboard")) { + char *buffer = new char[20000]; + StringWriter w(buffer); + for (int i = 0; i < 32; i++) { + u32 value = mipsDebug->GetGPR32Value(i); + w.F("%s: %08x (%d)", mipsDebug->GetRegName(0, i).c_str(), value, value).endl(); + } + w.F("hi: %08x", mipsDebug->GetHi()).endl(); + w.F("lo: %08x", mipsDebug->GetLo()).endl(); + w.F("pc: %08x", mipsDebug->GetPC()).endl(); + System_CopyStringToClipboard(buffer); + delete[] buffer; + } + if (ImGui::BeginTable("gpr", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) { ImGui::TableSetupColumn("Reg", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthFixed);