Skip to content

Commit 569635d

Browse files
authored
Merge pull request #2010 from nicolasnoble/psyqo-heap-viewer
Add PSYQo heap allocator viewer to Redux
2 parents c754d01 + 012cbe0 commit 569635d

11 files changed

Lines changed: 500 additions & 23 deletions

File tree

src/core/psxhw.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,10 @@ void PCSX::HW::write32(uint32_t add, uint32_t value) {
831831
g_emulator->m_mem->msanFree(value);
832832
break;
833833
}
834+
case 0x1f8020a0: {
835+
g_emulator->m_mem->m_psyqoHeapMetadata = value;
836+
break;
837+
}
834838
case 0x1f802094: {
835839
PSXAddress headerAddrInfo(value);
836840
switch (headerAddrInfo.type) {

src/core/psxmem.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ void PCSX::Memory::reset() {
174174
memset(m_wram, 0, 0x00800000);
175175
memset(m_exp1, 0xff, exp1_size);
176176
memset(m_bios, 0, bios_size);
177+
m_psyqoHeapMetadata = 0;
177178
static const uint32_t nobios[6] = {
178179
Mips::Encoder::lui(Mips::Encoder::Reg::V0, 0xbfc0), // v0 = 0xbfc00000
179180
Mips::Encoder::lui(Mips::Encoder::Reg::V1, 0x1f80), // v1 = 0x1f800000

src/core/psxmem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ class Memory {
331331
uint32_t m_msanPtr = 1024;
332332
EventBus::Listener m_listener;
333333

334+
// Address of the psyqo heap metadata struct in guest memory,
335+
// registered by the MIPS allocator via pcsxhw write to 0x1f8020a0.
336+
uint32_t m_psyqoHeapMetadata = 0;
337+
334338
std::unordered_map<uint32_t, uint32_t> m_msanAllocs;
335339
static constexpr uint32_t c_msanChainMarker = 0x7ffffd;
336340
std::unordered_map<uint32_t, uint32_t> m_msanChainRegistry;

src/gui/gui.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,7 @@ in Configuration->Emulation, restart PCSX-Redux, then try again.)"));
14591459
ImGui::MenuItem(_("Show SIO1 debug"), nullptr, &m_sio1.m_show);
14601460
ImGui::EndMenu();
14611461
}
1462+
ImGui::MenuItem(_("Show PSYQo heap viewer"), nullptr, &m_heapViewer.m_show);
14621463
ImGui::Separator();
14631464
if (ImGui::BeginMenu(_("Kernel"))) {
14641465
ImGui::MenuItem(_("Kernel Events"), nullptr, &m_events.m_show);
@@ -1742,6 +1743,7 @@ in Configuration->Emulation, restart PCSX-Redux, then try again.)"));
17421743
if (g_emulator->m_gpu->m_showCfg) changed |= g_emulator->m_gpu->configure();
17431744
if (g_emulator->m_gpu->m_showDebug) g_emulator->m_gpu->debug();
17441745
if (m_gpuLogger.m_show) m_gpuLogger.draw(g_emulator->m_gpuLogger.get(), _("GPU Logger"));
1746+
if (m_heapViewer.m_show) m_heapViewer.draw(g_emulator->m_mem.get(), _("PSYQo Heap Viewer"));
17451747

17461748
if (m_showUiCfg) {
17471749
if (ImGui::Begin(_("UI Configuration"), &m_showUiCfg)) {

src/gui/gui.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "gui/widgets/events.h"
4545
#include "gui/widgets/filedialog.h"
4646
#include "gui/widgets/gpulogger.h"
47+
#include "gui/widgets/heap_viewer.h"
4748
#include "gui/widgets/handlers.h"
4849
#include "gui/widgets/isobrowser.h"
4950
#include "gui/widgets/kernellog.h"
@@ -115,6 +116,7 @@ class GUI final : public UI {
115116
typedef Setting<bool, TYPESTRING("ShowIsoBrowser")> ShowIsoBrowser;
116117
typedef Setting<bool, TYPESTRING("ShowGPULogger")> ShowGPULogger;
117118
typedef Setting<bool, TYPESTRING("ShowRAMViewer")> ShowRAMViewer;
119+
typedef Setting<bool, TYPESTRING("ShowHeapViewer")> ShowHeapViewer;
118120
typedef Setting<int, TYPESTRING("WindowPosX"), 0> WindowPosX;
119121
typedef Setting<int, TYPESTRING("WindowPosY"), 0> WindowPosY;
120122
typedef Setting<int, TYPESTRING("WindowSizeX"), 1280> WindowSizeX;
@@ -159,7 +161,7 @@ class GUI final : public UI {
159161
ShowCLUTVRAMViewer, ShowVRAMViewer1, ShowVRAMViewer2, ShowVRAMViewer3, ShowVRAMViewer4, ShowMemoryObserver,
160162
ShowTypedDebugger, ShowPatches, ShowMemcardManager, ShowRegisters, ShowAssembly, ShowDisassembly,
161163
ShowBreakpoints, ShowNamedSaveStates, ShowEvents, ShowHandlers, ShowKernelLog, ShowCallstacks, ShowSIO1,
162-
ShowIsoBrowser, ShowGPULogger, ShowRAMViewer, MainFontSize, MonoFontSize, GUITheme,
164+
ShowIsoBrowser, ShowGPULogger, ShowRAMViewer, ShowHeapViewer, MainFontSize, MonoFontSize, GUITheme,
163165
AllowMouseCaptureToggle,
164166
EnableRawMouseMotion, WidescreenRatio, ShowPIOCartConfig, ShowMemoryEditor1, ShowMemoryEditor2,
165167
ShowMemoryEditor3, ShowMemoryEditor4, ShowMemoryEditor5, ShowMemoryEditor6, ShowMemoryEditor7,
@@ -407,6 +409,7 @@ class GUI final : public UI {
407409
Widgets::SIO1 m_sio1 = {settings.get<ShowSIO1>().value};
408410

409411
Widgets::GPULogger m_gpuLogger{settings.get<ShowGPULogger>().value};
412+
Widgets::HeapViewer m_heapViewer{settings.get<ShowHeapViewer>().value};
410413

411414
EventBus::Listener m_listener;
412415

0 commit comments

Comments
 (0)