From d579dc16f1728eee2e14bb5f888895015dcb51b8 Mon Sep 17 00:00:00 2001 From: Gauvain 'GovanifY' Roussel-Tarbouriech Date: Fri, 5 Mar 2021 01:51:04 +0100 Subject: [PATCH] gsdump: dump fully parsed --- common/include/PS2Edefs.h | 10 ++++- pcsx2/PluginManager.cpp | 4 ++ pcsx2/gui/Dialogs/GSDumpDialog.cpp | 64 ++++++++++++++++++++++++++---- pcsx2/gui/Dialogs/ModalPopups.h | 23 +++++++++++ 4 files changed, 93 insertions(+), 8 deletions(-) diff --git a/common/include/PS2Edefs.h b/common/include/PS2Edefs.h index 99962c19c9..cf04081e7d 100644 --- a/common/include/PS2Edefs.h +++ b/common/include/PS2Edefs.h @@ -166,8 +166,12 @@ typedef void(CALLBACK *_GSosdLog)(const char *utf8, u32 color); typedef void(CALLBACK *_GSosdMonitor)(const char *key, const char *value, u32 color); typedef s32(CALLBACK *_GSopen)(void *pDsp, const char *Title, int multithread); typedef s32(CALLBACK *_GSopen2)(void *pDsp, u32 flags); -typedef s32(CALLBACK* _GSReplay)(char* lpszCmdLine, int renderer); +typedef void(CALLBACK* _GSReplay)(char* lpszCmdLine, int renderer); typedef void(CALLBACK *_GSvsync)(int field); +typedef s32(CALLBACK* _GSinit)(); +typedef s32(CALLBACK* _GSfreeze)(int mode, freezeData* data); +typedef void(CALLBACK* _GSclose)(); +typedef void(CALLBACK* _GSshutdown)(); typedef void(CALLBACK *_GSgifTransfer)(const u32 *pMem, u32 size); typedef void(CALLBACK *_GSgifTransfer1)(u32 *pMem, u32 addr); typedef void(CALLBACK *_GSgifTransfer2)(u32 *pMem, u32 size); @@ -204,6 +208,10 @@ extern _GSosdMonitor GSosdMonitor; extern _GSopen GSopen; extern _GSopen2 GSopen2; extern _GSReplay GSReplay; +extern _GSinit GSinit; +extern _GSfreeze GSfreeze; +extern _GSclose GSclose; +extern _GSshutdown GSshutdown; extern _GSvsync GSvsync; extern _GSgifTransfer GSgifTransfer; extern _GSgifTransfer1 GSgifTransfer1; diff --git a/pcsx2/PluginManager.cpp b/pcsx2/PluginManager.cpp index ecc3822cf2..f3d4bd4ce8 100644 --- a/pcsx2/PluginManager.cpp +++ b/pcsx2/PluginManager.cpp @@ -158,6 +158,10 @@ _GSosdMonitor GSosdMonitor; _GSopen GSopen; _GSopen2 GSopen2; _GSReplay GSReplay; +_GSinit GSinit; +_GSfreeze GSfreeze; +_GSclose GSclose; +_GSshutdown GSshutdown; _GSgifTransfer GSgifTransfer; _GSgifTransfer1 GSgifTransfer1; _GSgifTransfer2 GSgifTransfer2; diff --git a/pcsx2/gui/Dialogs/GSDumpDialog.cpp b/pcsx2/gui/Dialogs/GSDumpDialog.cpp index 4f41e199bb..eb73a402a9 100644 --- a/pcsx2/gui/Dialogs/GSDumpDialog.cpp +++ b/pcsx2/gui/Dialogs/GSDumpDialog.cpp @@ -152,7 +152,8 @@ void Dialogs::GSDumpDialog::SelectedDump(wxListEvent& evt) void Dialogs::GSDumpDialog::RunDump(wxCommandEvent& event) { - pxInputStream dump_file(m_selected_dump, new wxFFileInputStream(m_selected_dump)); + //TODO: switch all of that to a pxThread + pxInputStream dump_file(*m_selected_dump, new wxFFileInputStream(*m_selected_dump)); if (!dump_file.IsOk()) return; @@ -166,13 +167,62 @@ void Dialogs::GSDumpDialog::RunDump(wxCommandEvent& event) dump_file.Read(&crc, 4); dump_file.Read(&ss, 4); - char state_data[ss]; - dump_file.Read(&state_data, ss); + + char* state_data = (char*)malloc(sizeof(char) * ss); + dump_file.Read(state_data, ss); dump_file.Read(®s, 8192); int ssi = ss; - GSFreezeData fd = {ssi, state_data}; + freezeData fd = {0, (s8*)state_data}; + std::vector dump; + while (dump_file.Tell() <= dump_file.Length()) + { + GSType id = Transfer; + dump_file.Read(&id, 1); + switch (id) + { + case Transfer: + { + GSTransferPath id_transfer; + dump_file.Read(&id_transfer, 1); + s32 size = 0; + dump_file.Read(&size, 4); + char* transfer_data = (char*)malloc(size); + dump_file.Read(transfer_data, size); + GSTransfer data = {{id, transfer_data}, id_transfer}; + dump.push_back(data); + break; + } + case VSync: + { + u8 vsync = 0; + dump_file.Read(&vsync, 1); + GSData data = {id, (char*)&vsync}; + dump.push_back(data); + break; + } + case ReadFIFO2: + { + u32 fifo = 0; + dump_file.Read(&fifo, 4); + GSData data = {id, (char*)&fifo}; + dump.push_back(data); + break; + } + case Registers: + { + char regs_tmp[8192]; + dump_file.Read(®s, 8192); + GSData data = {id, regs_tmp}; + dump.push_back(data); + break; + } + default: + break; + } + + } GSinit(); GSsetBaseMem((void*)regs); @@ -182,15 +232,15 @@ void Dialogs::GSDumpDialog::RunDump(wxCommandEvent& event) GSsetGameCRC((int)crc, 0); - if (GSfreeze(0, fd) == -1) + if (GSfreeze(0, &fd) == -1) { //DumpTooOld = true; //Running = false; } - GSVSync(1); + GSvsync(1); GSreset(); GSsetBaseMem((void*)regs); - GSfreeze(0, fd); + GSfreeze(0, &fd); while (0!=1) diff --git a/pcsx2/gui/Dialogs/ModalPopups.h b/pcsx2/gui/Dialogs/ModalPopups.h index 05a147b118..abad52d34f 100644 --- a/pcsx2/gui/Dialogs/ModalPopups.h +++ b/pcsx2/gui/Dialogs/ModalPopups.h @@ -95,6 +95,29 @@ namespace Dialogs ID_DUMP_LIST, ID_RUN_DUMP }; + enum GSType : u8 + { + Transfer = 0, + VSync = 1, + ReadFIFO2 = 2, + Registers = 3 + }; + enum GSTransferPath : u8 + { + Path1Old = 0, + Path2 = 1, + Path3 = 2, + Path1New = 3 + }; + struct GSData + { + GSType id; + char* data; + }; + struct GSTransfer : GSData + { + GSTransferPath path; + }; };