2008-12-08 05:30:24 +00:00
|
|
|
// Copyright (C) 2003-2008 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
|
|
#include "Debugger.h"
|
|
|
|
#include "RegisterView.h"
|
|
|
|
#include "PowerPC/PowerPC.h"
|
|
|
|
|
2009-01-20 19:15:33 +00:00
|
|
|
// F-zero 80005e60 wtf??
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-01-20 19:15:33 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2008-12-09 05:29:14 +00:00
|
|
|
wxString CRegTable::GetValue(int row, int col)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2009-01-20 19:15:33 +00:00
|
|
|
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("");
|
2008-12-09 05:29:14 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2008-12-09 05:29:14 +00:00
|
|
|
void CRegTable::SetValue(int, int, const wxString &)
|
|
|
|
{
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-01-20 19:15:33 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-09 05:29:14 +00:00
|
|
|
wxGridCellAttr *CRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind)
|
|
|
|
{
|
|
|
|
wxGridCellAttr *attr = new wxGridCellAttr();
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2008-12-09 05:29:14 +00:00
|
|
|
attr->SetBackgroundColour(wxColour(wxT("#FFFFFF")));
|
2008-12-26 03:46:04 +00:00
|
|
|
attr->SetFont(DefaultFont);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-01-20 19:41:45 +00:00
|
|
|
switch (col) {
|
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
attr->SetAlignment(wxALIGN_CENTER, wxALIGN_CENTER);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
|
|
|
|
break;
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-01-20 19:41:45 +00:00
|
|
|
bool red = false;
|
|
|
|
switch (col) {
|
|
|
|
case 1: red = row < 32 ? m_CachedRegHasChanged[row] : m_CachedSpecialRegHasChanged[row-32]; break;
|
|
|
|
case 3:
|
|
|
|
case 4: red = row < 32 ? m_CachedFRegHasChanged[row][col-3] : false; break;
|
|
|
|
}
|
|
|
|
attr->SetTextColour(red ? wxColor(wxT("#FF0000")) : wxColor(wxT("#000000")));
|
2008-12-09 05:29:14 +00:00
|
|
|
attr->IncRef();
|
|
|
|
return attr;
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2008-12-09 05:29:14 +00:00
|
|
|
CRegisterView::CRegisterView(wxWindow *parent, wxWindowID id)
|
|
|
|
: wxGrid(parent, id)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-09 05:29:14 +00:00
|
|
|
SetTable(new CRegTable(), true);
|
|
|
|
EnableGridLines(false);
|
|
|
|
SetRowLabelSize(0);
|
|
|
|
SetColLabelSize(0);
|
|
|
|
DisableDragGridSize();
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2008-12-09 05:29:14 +00:00
|
|
|
AutoSizeColumns();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2008-12-09 05:29:14 +00:00
|
|
|
void CRegisterView::Update()
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2008-12-09 05:29:14 +00:00
|
|
|
ForceRefresh();
|
2009-01-20 19:15:33 +00:00
|
|
|
((CRegTable *)GetTable())->UpdateCachedRegs();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|