Skip to content

Commit f40cd8b

Browse files
authored
Merge pull request #20067 from hrydgard/persona1-framebuffer-download
Hook framebuffer readback function in Persona 1.
2 parents 184749f + bea49a6 commit f40cd8b

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Core/HLE/ReplaceTables.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,17 @@ static int Hook_omertachinmokunookitethelegacy_download_frame() {
12801280
return 0;
12811281
}
12821282

1283+
// Function at 0886665C in US version
1284+
static int Hook_persona1_download_frame() {
1285+
const u32 fb_address = 0x04088000; // hardcoded at 088666D8
1286+
// const u32 dest_address = currentMIPS->r[MIPS_REG_A1]; // not relevant
1287+
if (Memory::IsVRAMAddress(fb_address)) {
1288+
gpu->PerformReadbackToMemory(fb_address, 0x00088000);
1289+
NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "persona1_download_frame");
1290+
}
1291+
return 0;
1292+
}
1293+
12831294
static int Hook_katamari_render_check() {
12841295
const u32 fb_address = Memory::Read_U32(currentMIPS->r[MIPS_REG_A0] + 0x3C);
12851296
const u32 fbInfoPtr = Memory::Read_U32(currentMIPS->r[MIPS_REG_A0] + 0x40);
@@ -1595,6 +1606,7 @@ static const ReplacementTableEntry entries[] = {
15951606
{ "ZZT3_select_hack", &Hook_ZZT3_select_hack, 0, REPFLAG_HOOKENTER, 0xC4 },
15961607
{ "blitz_fps_hack", &Hook_blitz_fps_hack, 0, REPFLAG_HOOKEXIT , 0 },
15971608
{ "brian_lara_fps_hack", &Hook_brian_lara_fps_hack, 0, REPFLAG_HOOKEXIT , 0 },
1609+
{ "persona1_download_frame", &Hook_persona1_download_frame, 0, REPFLAG_HOOKENTER, 0 },
15981610
{}
15991611
};
16001612

Core/MIPS/MIPSAnalyst.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ static const HardHashTableEntry hardcodedHashes[] = {
514514
{ 0x7624dde603717640, 288, "ZZT3_select_hack", }, // Zettai Zetsumei Toshi 3 - bypasses softlock on character select screen #4901
515515
{ 0x0dc5ca84f707863c, 452, "blitz_fps_hack", }, // Blitz: Overtime
516516
{ 0xf93d3cd093595a6c, 856, "brian_lara_fps_hack", }, // Brian Lara 2007: Pressure Play
517+
{ 0xc1d4af42a4c8860f, 964, "persona1_download_frame", }, // Persona 1 (issue #13079)
517518
};
518519

519520
namespace MIPSAnalyst {

UI/ImDebugger/ImDebugger.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "Common/StringUtils.h"
77
#include "Common/File/FileUtil.h"
88
#include "Common/Data/Format/IniFile.h"
9+
#include "Common/Data/Text/Parsers.h"
910
#include "Core/Config.h"
1011
#include "Core/System.h"
1112
#include "Core/RetroAchievements.h"
@@ -181,6 +182,20 @@ static void DrawGPRs(ImConfig &config, ImControl &control, const MIPSDebugInterf
181182

182183
bool noDiff = coreState == CORE_RUNNING_CPU || coreState == CORE_STEPPING_GE;
183184

185+
if (ImGui::Button("Copy all to clipboard")) {
186+
char *buffer = new char[20000];
187+
StringWriter w(buffer);
188+
for (int i = 0; i < 32; i++) {
189+
u32 value = mipsDebug->GetGPR32Value(i);
190+
w.F("%s: %08x (%d)", mipsDebug->GetRegName(0, i).c_str(), value, value).endl();
191+
}
192+
w.F("hi: %08x", mipsDebug->GetHi()).endl();
193+
w.F("lo: %08x", mipsDebug->GetLo()).endl();
194+
w.F("pc: %08x", mipsDebug->GetPC()).endl();
195+
System_CopyStringToClipboard(buffer);
196+
delete[] buffer;
197+
}
198+
184199
if (ImGui::BeginTable("gpr", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) {
185200
ImGui::TableSetupColumn("Reg", ImGuiTableColumnFlags_WidthFixed);
186201
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthFixed);

0 commit comments

Comments
 (0)