Improve register view window (now shows fp, various special regs). If the window is too small, delete the RegisterView section in your Debugger.ini.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1963 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-01-20 19:15:33 +00:00
parent d3d4cc641c
commit 8cdbaa2714
3 changed files with 116 additions and 26 deletions

View File

@ -2247,8 +2247,8 @@ void DisassembleGekko(unsigned int opcode, unsigned int curInstAddr, char *dest,
static const char *gprnames[] = static const char *gprnames[] =
{ {
"r00", "r01", "r02", "r03", "r04", "r05", "r06", "r07", " r0", " r1", " r2", " r3", " r4", " r5", " r6", " r7",
"r08", "r09", "r10", "r11", "r12", "r13", "r14", "r15", " r8", " r9", "r10", "r11", "r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31" "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31"
}; };
@ -2259,3 +2259,19 @@ const char *GetGPRName(unsigned int index)
return gprnames[index]; return gprnames[index];
return 0; 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;
}

View File

@ -19,21 +19,74 @@
#include "RegisterView.h" #include "RegisterView.h"
#include "PowerPC/PowerPC.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) wxString CRegTable::GetValue(int row, int col)
{ {
if (col % 2 == 0) if (row < 32) {
return wxString::FromAscii(GetGPRName(16*col/2 + row)); switch (col) {
else case 0: return wxString::FromAscii(GetGPRName(row));
return wxString::Format(wxT("0x%08x"), GPR(col == 1 ? row : 16 + 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::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 *CRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind)
{ {
wxGridCellAttr *attr = new wxGridCellAttr(); wxGridCellAttr *attr = new wxGridCellAttr();
@ -42,17 +95,15 @@ wxGridCellAttr *CRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind)
attr->SetFont(DefaultFont); attr->SetFont(DefaultFont);
attr->SetAlignment(col & 1 ? wxALIGN_CENTER : wxALIGN_LEFT, wxALIGN_CENTER); attr->SetAlignment(col & 1 ? wxALIGN_CENTER : wxALIGN_LEFT, wxALIGN_CENTER);
if (col % 2 == 0) if (col == 0)
attr->SetTextColour(wxColour(wxT("#000000"))); attr->SetTextColour(wxColour(wxT("#000000")));
else else
attr->SetTextColour(((CRegisterView*)GetView())->m_CachedRegHasChanged[col == 1 ? row : 16 + row] attr->SetTextColour(m_CachedRegHasChanged[row] ? wxColor(wxT("#FF0000")) : wxColor(wxT("#000000")));
? wxColor(wxT("#FF0000")) : wxColor(wxT("#000000")));
attr->IncRef(); attr->IncRef();
return attr; return attr;
} }
CRegisterView::CRegisterView(wxWindow *parent, wxWindowID id) CRegisterView::CRegisterView(wxWindow *parent, wxWindowID id)
: wxGrid(parent, id) : wxGrid(parent, id)
{ {
@ -68,10 +119,5 @@ CRegisterView::CRegisterView(wxWindow *parent, wxWindowID id)
void CRegisterView::Update() void CRegisterView::Update()
{ {
ForceRefresh(); ForceRefresh();
((CRegTable *)GetTable())->UpdateCachedRegs();
for (size_t i = 0; i < 32; ++i)
{
m_CachedRegHasChanged[i] = (m_CachedRegs[i] != GPR(i));
m_CachedRegs[i] = GPR(i);
}
} }

View File

@ -22,18 +22,48 @@
#include "Common.h" #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 class CRegTable : public wxGridTableBase
{ {
enum {
NUM_SPECIALS = 7,
};
public: public:
CRegTable() {} CRegTable() {
int GetNumberCols(void){return 4;} memset(m_CachedRegs, 0, sizeof(m_CachedRegs));
int GetNumberRows(void){return 16;} memset(m_CachedSpecialRegs, 0, sizeof(m_CachedSpecialRegs));
bool IsEmptyCell(int, int){return false;} memset(m_CachedFRegs, 0, sizeof(m_CachedFRegs));
wxString GetValue(int, int); memset(m_CachedRegHasChanged, 0, sizeof(m_CachedRegHasChanged));
void SetValue(int, int, const wxString &); 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); wxGridCellAttr *GetAttr(int, int, wxGridCellAttr::wxAttrKind);
void UpdateCachedRegs();
private: private:
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); DECLARE_NO_COPY_CLASS(CRegTable);
}; };
@ -42,8 +72,6 @@ class CRegisterView : public wxGrid
public: public:
CRegisterView(wxWindow* parent, wxWindowID id); CRegisterView(wxWindow* parent, wxWindowID id);
void Update(); void Update();
u32 m_CachedRegs[32];
bool m_CachedRegHasChanged[32];
}; };
#endif #endif