mirror of https://github.com/PCSX2/pcsx2.git
Change register value
This commit is contained in:
parent
b69dcb51a0
commit
c8a760832b
|
@ -418,6 +418,44 @@ void R5900DebugInterface::setPc(u32 newPc)
|
|||
cpuRegs.pc = newPc;
|
||||
}
|
||||
|
||||
void R5900DebugInterface::setRegister(int cat, int num, u128 newValue)
|
||||
{
|
||||
switch (cat)
|
||||
{
|
||||
case EECAT_GPR:
|
||||
switch (num)
|
||||
{
|
||||
case 32: // pc
|
||||
cpuRegs.pc = newValue._u32[0];
|
||||
break;
|
||||
case 33: // hi
|
||||
cpuRegs.HI.UQ = newValue;
|
||||
break;
|
||||
case 34: // lo
|
||||
cpuRegs.LO.UQ = newValue;
|
||||
break;
|
||||
default:
|
||||
cpuRegs.GPR.r[num].UQ = newValue;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case EECAT_CP0:
|
||||
cpuRegs.CP0.r[num] = newValue._u32[0];
|
||||
break;
|
||||
case EECAT_CP1:
|
||||
fpuRegs.fpr[num].UL = newValue._u32[0];
|
||||
break;
|
||||
case EECAT_CP2F:
|
||||
VU1.VF[num].UQ = newValue;
|
||||
break;
|
||||
case EECAT_CP2I:
|
||||
VU1.VI[num].UL = newValue._u32[0];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string R5900DebugInterface::disasm(u32 address)
|
||||
{
|
||||
std::string out;
|
||||
|
@ -617,6 +655,32 @@ void R3000DebugInterface::setPc(u32 newPc)
|
|||
psxRegs.pc = newPc;
|
||||
}
|
||||
|
||||
void R3000DebugInterface::setRegister(int cat, int num, u128 newValue)
|
||||
{
|
||||
switch (cat)
|
||||
{
|
||||
case IOPCAT_GPR:
|
||||
switch (num)
|
||||
{
|
||||
case 32: // pc
|
||||
psxRegs.pc = newValue._u32[0];
|
||||
break;
|
||||
case 33: // hi
|
||||
psxRegs.GPR.n.hi = newValue._u32[0];
|
||||
break;
|
||||
case 34: // lo
|
||||
psxRegs.GPR.n.lo = newValue._u32[0];
|
||||
break;
|
||||
default:
|
||||
psxRegs.GPR.r[num] = newValue._u32[0];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string R3000DebugInterface::disasm(u32 address)
|
||||
{
|
||||
std::string out;
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
virtual u128 getLO() = 0;
|
||||
virtual u32 getPC() = 0;
|
||||
virtual void setPc(u32 newPc) = 0;
|
||||
virtual void setRegister(int cat, int num, u128 newValue) = 0;
|
||||
|
||||
virtual std::string disasm(u32 address) = 0;
|
||||
virtual bool isValidAddress(u32 address) = 0;
|
||||
|
@ -62,6 +63,7 @@ public:
|
|||
virtual u128 getLO();
|
||||
virtual u32 getPC();
|
||||
virtual void setPc(u32 newPc);
|
||||
virtual void setRegister(int cat, int num, u128 newValue);
|
||||
|
||||
virtual std::string disasm(u32 address);
|
||||
virtual bool isValidAddress(u32 address);
|
||||
|
@ -91,6 +93,7 @@ public:
|
|||
virtual u128 getLO();
|
||||
virtual u32 getPC();
|
||||
virtual void setPc(u32 newPc);
|
||||
virtual void setRegister(int cat, int num, u128 newValue);
|
||||
|
||||
virtual std::string disasm(u32 address);
|
||||
virtual bool isValidAddress(u32 address);
|
||||
|
|
|
@ -19,6 +19,9 @@ enum DisassemblyMenuIdentifiers
|
|||
ID_REGISTERLIST_DISPLAY32 = 1,
|
||||
ID_REGISTERLIST_DISPLAY64,
|
||||
ID_REGISTERLIST_DISPLAY128,
|
||||
ID_REGISTERLIST_CHANGELOWER,
|
||||
ID_REGISTERLIST_CHANGEUPPER,
|
||||
ID_REGISTERLIST_CHANGEVALUE
|
||||
};
|
||||
|
||||
|
||||
|
@ -49,12 +52,6 @@ CtrlRegisterList::CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu)
|
|||
currentRows.push_back(0);
|
||||
}
|
||||
|
||||
menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY32, L"Display 32 bit");
|
||||
menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY64, L"Display 64 bit");
|
||||
menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY128, L"Display 128 bit");
|
||||
menu.Check(ID_REGISTERLIST_DISPLAY128,true);
|
||||
menu.Connect(wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)&CtrlRegisterList::onPopupClick, NULL, this);
|
||||
|
||||
SetDoubleBuffered(true);
|
||||
SetInitialBestSize(ClientToWindowSize(GetMinClientSize()));
|
||||
}
|
||||
|
@ -298,6 +295,46 @@ void CtrlRegisterList::render(wxDC& dc)
|
|||
}
|
||||
}
|
||||
|
||||
void CtrlRegisterList::changeValue(RegisterChangeMode mode)
|
||||
{
|
||||
wchar_t str[64];
|
||||
|
||||
u128 oldValue = cpu->getRegister(category,currentRows[category]);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case LOWER64:
|
||||
swprintf(str,64,L"0x%016llX",oldValue._u64[0]);
|
||||
break;
|
||||
case UPPER64:
|
||||
swprintf(str,64,L"0x%016llX",oldValue._u64[1]);
|
||||
break;
|
||||
case CHANGE32:
|
||||
swprintf(str,64,L"0x%08X",oldValue._u32[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
u64 newValue;
|
||||
if (executeExpressionWindow(this,cpu,newValue,str))
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case LOWER64:
|
||||
oldValue._u64[0] = newValue;
|
||||
break;
|
||||
case UPPER64:
|
||||
oldValue._u64[1] = newValue;
|
||||
break;
|
||||
case CHANGE32:
|
||||
oldValue._u32[0] = newValue;
|
||||
break;
|
||||
}
|
||||
|
||||
cpu->setRegister(category,currentRows[category],oldValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CtrlRegisterList::onPopupClick(wxCommandEvent& evt)
|
||||
{
|
||||
switch (evt.GetId())
|
||||
|
@ -320,6 +357,21 @@ void CtrlRegisterList::onPopupClick(wxCommandEvent& evt)
|
|||
postEvent(debEVT_UPDATELAYOUT,0);
|
||||
Refresh();
|
||||
break;
|
||||
case ID_REGISTERLIST_CHANGELOWER:
|
||||
changeValue(LOWER64);
|
||||
Refresh();
|
||||
break;
|
||||
case ID_REGISTERLIST_CHANGEUPPER:
|
||||
changeValue(UPPER64);
|
||||
Refresh();
|
||||
break;
|
||||
case ID_REGISTERLIST_CHANGEVALUE:
|
||||
if (cpu->getRegisterSize(category) == 32)
|
||||
changeValue(CHANGE32);
|
||||
else
|
||||
changeValue(LOWER64);
|
||||
Refresh();
|
||||
break;
|
||||
default:
|
||||
wxMessageBox( L"Unimplemented.", L"Unimplemented.", wxICON_INFORMATION);
|
||||
break;
|
||||
|
@ -374,7 +426,37 @@ void CtrlRegisterList::mouseEvent(wxMouseEvent& evt)
|
|||
if (row != currentRows[category] && row < cpu->getRegisterCount(category))
|
||||
setCurrentRow(row);
|
||||
}
|
||||
|
||||
|
||||
wxMenu menu;
|
||||
int bits = cpu->getRegisterSize(category);
|
||||
|
||||
menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY32, L"Display 32 bit");
|
||||
menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY64, L"Display 64 bit");
|
||||
menu.AppendRadioItem(ID_REGISTERLIST_DISPLAY128, L"Display 128 bit");
|
||||
menu.AppendSeparator();
|
||||
|
||||
if (bits >= 64)
|
||||
{
|
||||
menu.Append(ID_REGISTERLIST_CHANGELOWER, L"Change lower 64 bit");
|
||||
menu.Append(ID_REGISTERLIST_CHANGEUPPER, L"Change upper 64 bit");
|
||||
} else {
|
||||
menu.Append(ID_REGISTERLIST_CHANGEVALUE, L"Change value");
|
||||
}
|
||||
|
||||
switch (maxBits)
|
||||
{
|
||||
case 128:
|
||||
menu.Check(ID_REGISTERLIST_DISPLAY128,true);
|
||||
break;
|
||||
case 64:
|
||||
menu.Check(ID_REGISTERLIST_DISPLAY64,true);
|
||||
break;
|
||||
case 32:
|
||||
menu.Check(ID_REGISTERLIST_DISPLAY32,true);
|
||||
break;
|
||||
}
|
||||
|
||||
menu.Connect(wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)&CtrlRegisterList::onPopupClick, NULL, this);
|
||||
PopupMenu(&menu,evt.GetPosition());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -46,9 +46,12 @@ public:
|
|||
return GetMinClientSize();
|
||||
}
|
||||
private:
|
||||
enum RegisterChangeMode { LOWER64, UPPER64, CHANGE32 };
|
||||
|
||||
void render(wxDC& dc);
|
||||
void refreshChangedRegs();
|
||||
void setCurrentRow(int row);
|
||||
void changeValue(RegisterChangeMode mode);
|
||||
|
||||
void postEvent(wxEventType type, wxString text);
|
||||
void postEvent(wxEventType type, int value);
|
||||
|
@ -68,5 +71,4 @@ private:
|
|||
u32 lastPc;
|
||||
int category;
|
||||
int maxBits;
|
||||
wxMenu menu;
|
||||
};
|
|
@ -23,9 +23,9 @@ void displayExpressionError(wxWindow* parent)
|
|||
wxMessageBox(wxString(getExpressionError(),wxConvUTF8),L"Invalid expression",wxICON_ERROR);
|
||||
}
|
||||
|
||||
bool executeExpressionWindow(wxWindow* parent, DebugInterface* cpu, u64& dest)
|
||||
bool executeExpressionWindow(wxWindow* parent, DebugInterface* cpu, u64& dest, const wxString& defaultValue)
|
||||
{
|
||||
wxString result = wxGetTextFromUser(L"Enter expression",L"Expression",wxEmptyString,parent);
|
||||
wxString result = wxGetTextFromUser(L"Enter expression",L"Expression",defaultValue,parent);
|
||||
if (result.empty())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -12,4 +12,4 @@ DECLARE_LOCAL_EVENT_TYPE( debEVT_STEPOVER, wxNewEventType() )
|
|||
DECLARE_LOCAL_EVENT_TYPE( debEVT_STEPINTO, wxNewEventType() )
|
||||
DECLARE_LOCAL_EVENT_TYPE( debEVT_UPDATE, wxNewEventType() )
|
||||
|
||||
bool executeExpressionWindow(wxWindow* parent, DebugInterface* cpu, u64& dest);
|
||||
bool executeExpressionWindow(wxWindow* parent, DebugInterface* cpu, u64& dest, const wxString& defaultValue = wxEmptyString);
|
||||
|
|
Loading…
Reference in New Issue