diff --git a/Externals/Bochs_disasm/PowerPCDisasm.cpp b/Externals/Bochs_disasm/PowerPCDisasm.cpp index 722f6096c3..99cf7f8e0f 100644 --- a/Externals/Bochs_disasm/PowerPCDisasm.cpp +++ b/Externals/Bochs_disasm/PowerPCDisasm.cpp @@ -2247,8 +2247,8 @@ void DisassembleGekko(unsigned int opcode, unsigned int curInstAddr, char *dest, static const char *gprnames[] = { - "r00", "r01", "r02", "r03", "r04", "r05", "r06", "r07", - "r08", "r09", "r10", "r11", "r12", "r13", "r14", "r15", + " r0", " r1", " r2", " r3", " r4", " r5", " r6", " r7", + " r8", " r9", "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31" }; @@ -2259,3 +2259,19 @@ const char *GetGPRName(unsigned int index) return gprnames[index]; return 0; } + + +static const char *fprnames[] = +{ + " f0", " f1", " f2", " f3", " f4", " f5", " f6", " f7", + " f8", " f9", "f10", "f11", "f12", "f13", "f14", "f15", + "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", + "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31" +}; + +const char *GetFPRName(unsigned int index) +{ + if (index < 32) + return fprnames[index]; + return 0; +} diff --git a/Source/Core/DebuggerWX/Src/RegisterView.cpp b/Source/Core/DebuggerWX/Src/RegisterView.cpp index e8293ba981..113bf0133e 100644 --- a/Source/Core/DebuggerWX/Src/RegisterView.cpp +++ b/Source/Core/DebuggerWX/Src/RegisterView.cpp @@ -19,21 +19,74 @@ #include "RegisterView.h" #include "PowerPC/PowerPC.h" -extern const char* GetGPRName(unsigned int index); +// F-zero 80005e60 wtf?? +extern const char* GetGPRName(unsigned int index); +extern const char* GetFPRName(unsigned int index); + +static const char *special_reg_names[] = { + "PC", "LR", "CTR", "CR", "FPSCR", "SRR0", "SRR1", +}; + +static u32 GetSpecialRegValue(int reg) { + switch (reg) { + case 0: return PowerPC::ppcState.pc; + case 1: return PowerPC::ppcState.spr[SPR_LR]; + case 2: return PowerPC::ppcState.spr[SPR_CTR]; + case 3: return GetCR(); + case 4: return PowerPC::ppcState.fpscr; + case 5: return PowerPC::ppcState.spr[SPR_SRR0]; + case 6: return PowerPC::ppcState.spr[SPR_SRR1]; + default: return 0; + } +} wxString CRegTable::GetValue(int row, int col) { - if (col % 2 == 0) - return wxString::FromAscii(GetGPRName(16*col/2 + row)); - else - return wxString::Format(wxT("0x%08x"), GPR(col == 1 ? row : 16 + row)); + if (row < 32) { + switch (col) { + case 0: return wxString::FromAscii(GetGPRName(row)); + case 1: return wxString::Format(wxT("0x%08x"), GPR(row)); + case 2: return wxString::FromAscii(GetFPRName(row)); + case 3: return wxString::Format(wxT("%f"), rPS0(row)); + case 4: return wxString::Format(wxT("%f"), rPS1(row)); + default: return wxString::FromAscii(""); + } + } else { + if (row - 32 < NUM_SPECIALS) { + switch (col) { + case 0: return wxString::FromAscii(special_reg_names[row - 32]); + case 1: return wxString::Format(wxT("0x%08x"), GetSpecialRegValue(row - 32)); + default: return wxString::FromAscii(""); + } + } + } + return wxString::FromAscii(""); } void CRegTable::SetValue(int, int, const wxString &) { } +void CRegTable::UpdateCachedRegs() +{ + for (int i = 0; i < 32; ++i) + { + m_CachedRegHasChanged[i] = (m_CachedRegs[i] != GPR(i)); + m_CachedRegs[i] = GPR(i); + + m_CachedFRegHasChanged[i][0] = (m_CachedFRegs[i][0] != rPS0(i)); + m_CachedFRegs[i][0] = rPS0(i); + m_CachedFRegHasChanged[i][1] = (m_CachedFRegs[i][1] != rPS1(i)); + m_CachedFRegs[i][1] = rPS1(i); + } + for (int i = 0; i < 6; ++i) + { + m_CachedSpecialRegHasChanged[i] = (m_CachedSpecialRegs[i] != GetSpecialRegValue(i)); + m_CachedSpecialRegs[i] = GetSpecialRegValue(i); + } +} + wxGridCellAttr *CRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind) { wxGridCellAttr *attr = new wxGridCellAttr(); @@ -42,17 +95,15 @@ wxGridCellAttr *CRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind) attr->SetFont(DefaultFont); attr->SetAlignment(col & 1 ? wxALIGN_CENTER : wxALIGN_LEFT, wxALIGN_CENTER); - if (col % 2 == 0) + if (col == 0) attr->SetTextColour(wxColour(wxT("#000000"))); else - attr->SetTextColour(((CRegisterView*)GetView())->m_CachedRegHasChanged[col == 1 ? row : 16 + row] - ? wxColor(wxT("#FF0000")) : wxColor(wxT("#000000"))); + attr->SetTextColour(m_CachedRegHasChanged[row] ? wxColor(wxT("#FF0000")) : wxColor(wxT("#000000"))); attr->IncRef(); return attr; } - CRegisterView::CRegisterView(wxWindow *parent, wxWindowID id) : wxGrid(parent, id) { @@ -68,10 +119,5 @@ CRegisterView::CRegisterView(wxWindow *parent, wxWindowID id) void CRegisterView::Update() { ForceRefresh(); - - for (size_t i = 0; i < 32; ++i) - { - m_CachedRegHasChanged[i] = (m_CachedRegs[i] != GPR(i)); - m_CachedRegs[i] = GPR(i); - } + ((CRegTable *)GetTable())->UpdateCachedRegs(); } diff --git a/Source/Core/DebuggerWX/Src/RegisterView.h b/Source/Core/DebuggerWX/Src/RegisterView.h index 9b6a148b78..5807af6a7b 100644 --- a/Source/Core/DebuggerWX/Src/RegisterView.h +++ b/Source/Core/DebuggerWX/Src/RegisterView.h @@ -22,19 +22,49 @@ #include "Common.h" +// New register view: +// R0 0x8000000 F0 0.0000 F0_PS1 0.0000 +// R1 0x8000000 F1 0.0000 F1_PS1 0.0000 +// R31 0x8000000 F31 0.0000 F31_PS1 0.0000 +// PC (specials) +// LR +// CTR +// CR0 +// SRR0 +// SRR1 + class CRegTable : public wxGridTableBase { + enum { + NUM_SPECIALS = 7, + }; + public: - CRegTable() {} - int GetNumberCols(void){return 4;} - int GetNumberRows(void){return 16;} - bool IsEmptyCell(int, int){return false;} - wxString GetValue(int, int); - void SetValue(int, int, const wxString &); + CRegTable() { + memset(m_CachedRegs, 0, sizeof(m_CachedRegs)); + memset(m_CachedSpecialRegs, 0, sizeof(m_CachedSpecialRegs)); + memset(m_CachedFRegs, 0, sizeof(m_CachedFRegs)); + memset(m_CachedRegHasChanged, 0, sizeof(m_CachedRegHasChanged)); + memset(m_CachedSpecialRegHasChanged, 0, sizeof(m_CachedSpecialRegHasChanged)); + memset(m_CachedFRegHasChanged, 0, sizeof(m_CachedFRegHasChanged)); + } + int GetNumberCols(void) {return 5;} + int GetNumberRows(void) {return 32 + NUM_SPECIALS;} + bool IsEmptyCell(int row, int col) {return row > 31 && col > 2;} + wxString GetValue(int row, int col); + void SetValue(int row, int col, const wxString &); wxGridCellAttr *GetAttr(int, int, wxGridCellAttr::wxAttrKind); + void UpdateCachedRegs(); private: - DECLARE_NO_COPY_CLASS(CRegTable); + u32 m_CachedRegs[32]; + u32 m_CachedSpecialRegs[6]; + double m_CachedFRegs[32][2]; + bool m_CachedRegHasChanged[32]; + bool m_CachedSpecialRegHasChanged[6]; + bool m_CachedFRegHasChanged[32][2]; + + DECLARE_NO_COPY_CLASS(CRegTable); }; class CRegisterView : public wxGrid @@ -42,8 +72,6 @@ class CRegisterView : public wxGrid public: CRegisterView(wxWindow* parent, wxWindowID id); void Update(); - u32 m_CachedRegs[32]; - bool m_CachedRegHasChanged[32]; }; #endif