gsdump: various logic and code formatting improvements

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2021-03-07 03:21:43 +01:00 committed by Kojin
parent 65291ace12
commit 3bb8fcf655
2 changed files with 166 additions and 182 deletions

View File

@ -1,5 +1,5 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team
* Copyright (C) 2002-2020 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
@ -158,10 +158,8 @@ void Dialogs::GSDumpDialog::SelectedDump(wxListEvent& evt)
m_selected_dump = new wxString(filename);
}
else
{
m_preview_image->SetBitmap(EmbeddedImage<res_NoIcon>().Get());
}
}
void Dialogs::GSDumpDialog::RunDump(wxCommandEvent& event)
{
@ -193,30 +191,22 @@ void Dialogs::GSDumpDialog::ProcessDumpEvent(GSData event, char* regs)
break;
}
case Path1New:
{
GSgifTransfer((u32*)event.data, event.length / 16);
break;
}
case Path2:
{
GSgifTransfer2((u32*)event.data, event.length / 16);
break;
}
case Path3:
{
GSgifTransfer3((u32*)event.data, event.length / 16);
break;
}
default:
break;
}
break;
}
case VSync:
{
GSvsync((*((int*)(regs + 4096)) & 0x2000) > 0 ? (u8)1 : (u8)0);
break;
}
case ReadFIFO2:
{
u64* arr = (u64*)malloc(*((int*)event.data));
@ -225,12 +215,10 @@ void Dialogs::GSDumpDialog::ProcessDumpEvent(GSData event, char* regs)
break;
}
case Registers:
{
memcpy(regs, event.data, 8192);
break;
}
}
}
void Dialogs::GSDumpDialog::StepPacket(wxCommandEvent& event)
{
@ -260,9 +248,9 @@ void Dialogs::GSDumpDialog::GenPacketList(std::vector<GSData>& dump)
wxTreeItemId rootId = m_gif_list->AppendItem(mainrootId, "0 - VSync");
for (auto& element : dump)
{
wxString s;
([&] { return element.id == Transfer; })() ? (s.Printf("%d - %s - %s - %d byte", i, GSTypeNames[element.id], GSTransferPathNames[element.path], element.length)) :
s.Printf("%d - %s - %d byte", i, GSTypeNames[element.id], element.length);
wxString s, t;
element.id == Transfer ? t.Printf(" - %s", GSTransferPathNames[element.path]) : t.Printf("");
s.Printf("%d - %s%s - %d byte", i, GSTypeNames[element.id], t, element.length);
if (element.id == VSync)
{
m_gif_list->SetItemText(rootId, s);
@ -289,12 +277,12 @@ void Dialogs::GSDumpDialog::GenPacketInfo(GSData& dump)
trootId = m_gif_packet->AppendItem(rootId, s);
u64 tag = *(u64*)(dump.data);
u64 regs = *(u64*)(dump.data + 8);
u8 nloop = tag & ((u64)(1 << 15) - 1);
u32 nloop = tag & ((1 << 15) - 1);
u8 eop = (tag >> 15) & 1;
u8 pre = (tag >> 46) & 1;
u32 prim = (tag >> 47) & ((u64)(1 << 11) - 1);
u32 prim = (tag >> 47) & ((1 << 11) - 1);
u8 flg = ((tag >> 58) & 3);
u32 nreg = (u32)((tag >> 60) & ((u64)(1 << 4) - 1));
u32 nreg = (u32)((tag >> 60) & ((1 << 4) - 1));
if (nreg == 0)
nreg = 16;
@ -330,7 +318,7 @@ void Dialogs::GSDumpDialog::GenPacketInfo(GSData& dump)
{
case GIF_FLG_PACKED:
{
for (int j = 0; j < nloop; j++)
for (u32 j = 0; j < nloop; j++)
{
for (u32 i = 0; i < nreg; i++)
{
@ -345,7 +333,7 @@ void Dialogs::GSDumpDialog::GenPacketInfo(GSData& dump)
}
case GIF_FLG_REGLIST:
{
for (int j = 0; j < nloop; j++)
for (u32 j = 0; j < nloop; j++)
{
for (u32 i = 0; i < nreg; i++)
{
@ -366,8 +354,6 @@ void Dialogs::GSDumpDialog::GenPacketInfo(GSData& dump)
break;
}
}
//m_gif_packet->AppendItem(trootId, s);
break;
}
case VSync:
@ -385,11 +371,9 @@ void Dialogs::GSDumpDialog::GenPacketInfo(GSData& dump)
break;
}
case Registers:
{
m_gif_packet->AppendItem(rootId, "Registers");
break;
}
}
m_gif_packet->ExpandAll();
}
@ -405,10 +389,8 @@ void Dialogs::GSDumpDialog::ParseTreeReg(wxTreeItemId& id, GIFReg reg, u128 data
switch (reg)
{
case PRIM:
{
ParseTreePrim(rootId, data.lo);
break;
}
case RGBAQ:
{
std::vector<wxString> rgb_infos(5);
@ -697,7 +679,9 @@ void Dialogs::GSDumpDialog::GSThread::ExecuteTaskInThread()
if (m_root_window->m_debug_mode->GetValue())
m_root_window->GenPacketList(m_root_window->m_dump_packets);
return;
//return here to debug pre gs
//return;
GetCorePlugins().Init();
GSsetBaseMem((void*)regs);
if (GSopen2((void*)pDsp, renderer_override) != 0)

View File

@ -22,7 +22,8 @@
#include <wx/wizard.h>
#include <wx/treectrl.h>
#define GSDUMP_GIFREG \
// clang-format off
#define GSDUMP_GIFREG(X) \
X(PRIM, 0x00) \
X(RGBAQ, 0x01) \
X(ST, 0x02) \
@ -79,8 +80,7 @@ X(HWREG,0x54) \
X(SIGNAL, 0x60) \
X(FINISH, 0x61) \
X(LABEL, 0x62)
#define X(name, value) name = value,
// clang-format on
#define GSDUMP_GIFREG_NAME GIFReg
#define GSDUMP_GIFREG_TYPE u8
@ -312,10 +312,10 @@ namespace Dialogs
// the actual type is defined above thanks to preprocessing magic
enum GSDUMP_GIFREG_NAME : GSDUMP_GIFREG_TYPE
{
GSDUMP_GIFREG
};
#define X(name, value) name = value,
GSDUMP_GIFREG(X)
#undef X
};
constexpr auto GIFRegName(GSDUMP_GIFREG_NAME e) noexcept
{
#define X(name, value) \
@ -323,11 +323,11 @@ namespace Dialogs
return #name;
switch (e)
{
GSDUMP_GIFREG
GSDUMP_GIFREG(X)
}
#undef X
return "UNKNOWN";
}
};
struct GSEvent
{
ButtonState btn;