From 9f22d3a64ecf0ef9d6b7271aa3a43492081f9f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 25 Mar 2025 00:11:42 +0100 Subject: [PATCH] Re-enable the "HLE module browser". Add ability to export modules as jpscptrace definitions. --- Common/Data/Text/Parsers.h | 4 ++++ UI/ImDebugger/ImDebugger.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Common/Data/Text/Parsers.h b/Common/Data/Text/Parsers.h index f111a29964..7ddfa3eabe 100644 --- a/Common/Data/Text/Parsers.h +++ b/Common/Data/Text/Parsers.h @@ -91,6 +91,10 @@ public: } StringWriter(const StringWriter &) = delete; + size_t size() const { + return p_ - start_; + } + // Assumes the input is zero-terminated. // C: Copies a string literal (which always are zero-terminated, the count includes the zero) directly to the stream. template diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index b7a31b2c58..e70dbd88ea 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -1544,6 +1544,30 @@ void DrawHLEModules(ImConfig &config) { } ImGui::TreePop(); } + if (ImGui::BeginPopupContextItem(label.c_str())) { + if (ImGui::MenuItem("Copy as JpscpTrace")) { + char *buffer = new char[1000000]; + StringWriter w(buffer, 1000000); + + for (int j = 0; j < mod->numFunctions; j++) { + auto &func = mod->funcTable[j]; + // Translate the argmask to fit jpscptrace + std::string amask = func.argmask; + for (int i = 0; i < amask.size(); i++) { + switch (amask[i]) { + case 'i': + case 'I': amask[i] = 'd'; break; + case 'f': + case 'F': amask[i] = 'x'; break; + } + } + w.F("%s 0x%08x %d %s", func.name, func.ID, strlen(func.argmask), amask.c_str()).endl(); + } + System_CopyStringToClipboard(std::string_view(buffer, w.size())); + delete[] buffer; + } + ImGui::EndPopup(); + } } ImGui::End(); @@ -1684,6 +1708,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu ImGui::EndMenu(); } if (ImGui::BeginMenu("OS HLE")) { + ImGui::MenuItem("HLE module browser", nullptr, &cfg_.hleModulesOpen); ImGui::MenuItem("File System Browser", nullptr, &cfg_.filesystemBrowserOpen); ImGui::MenuItem("Kernel Objects", nullptr, &cfg_.kernelObjectsOpen); ImGui::MenuItem("Threads", nullptr, &cfg_.threadsOpen);