mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
cpu_type removed, system_type added
cpu_state -> cpu_flag vm::stack_allocator template improved ppu_cmd type changed to enum, cmd64 type added
This commit is contained in:
parent
009ac37a7d
commit
bdeccd889f
39 changed files with 449 additions and 492 deletions
|
|
@ -1,8 +1,10 @@
|
|||
#include "stdafx.h"
|
||||
#include "stdafx_gui.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/CPU/CPUThread.h"
|
||||
#include "Emu/CPU/CPUDisAsm.h"
|
||||
#include "Emu/Cell/PPUThread.h"
|
||||
#include "Emu/Cell/SPUThread.h"
|
||||
#include "InstructionEditor.h"
|
||||
|
||||
|
|
@ -59,7 +61,7 @@ InstructionEditorDialog::InstructionEditorDialog(wxPanel *parent, u32 _pc, cpu_t
|
|||
s_panel_margin_x->Add(s_panel_margin_y);
|
||||
s_panel_margin_x->AddSpacer(12);
|
||||
|
||||
const u32 cpu_offset = cpu->type == cpu_type::spu ? static_cast<SPUThread&>(*cpu).offset : 0;
|
||||
const u32 cpu_offset = g_system == system_type::ps3 && cpu->id < ppu_thread::id_min ? static_cast<SPUThread&>(*cpu).offset : 0;
|
||||
|
||||
this->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(InstructionEditorDialog::updatePreview));
|
||||
t2_instr->SetValue(wxString::Format("%08x", vm::ps3::read32(cpu_offset + pc).value()));
|
||||
|
|
@ -81,7 +83,7 @@ void InstructionEditorDialog::updatePreview(wxCommandEvent& event)
|
|||
ulong opcode;
|
||||
if (t2_instr->GetValue().ToULong(&opcode, 16))
|
||||
{
|
||||
if (cpu->type == cpu_type::arm)
|
||||
if (g_system == system_type::psv)
|
||||
{
|
||||
t3_preview->SetLabel("Preview for ARMv7Thread not implemented yet.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,10 @@ std::map<u32, bool> g_breakpoints;
|
|||
|
||||
u32 InterpreterDisAsmFrame::GetPc() const
|
||||
{
|
||||
switch (cpu->type)
|
||||
switch (g_system)
|
||||
{
|
||||
case cpu_type::ppu: return static_cast<ppu_thread*>(cpu)->cia;
|
||||
case cpu_type::spu: return static_cast<SPUThread*>(cpu)->pc;
|
||||
case cpu_type::arm: return static_cast<ARMv7Thread*>(cpu)->PC;
|
||||
case system_type::ps3: return cpu->id >= ppu_thread::id_min ? static_cast<ppu_thread*>(cpu)->cia : static_cast<SPUThread*>(cpu)->pc;
|
||||
case system_type::psv: return static_cast<ARMv7Thread*>(cpu)->PC;
|
||||
}
|
||||
|
||||
return 0xabadcafe;
|
||||
|
|
@ -137,21 +136,23 @@ void InterpreterDisAsmFrame::OnSelectUnit(wxCommandEvent& event)
|
|||
|
||||
if (cpu = (cpu_thread*)event.GetClientData())
|
||||
{
|
||||
switch (cpu->type)
|
||||
switch (g_system)
|
||||
{
|
||||
case cpu_type::ppu:
|
||||
case system_type::ps3:
|
||||
{
|
||||
m_disasm = std::make_unique<PPUDisAsm>(CPUDisAsm_InterpreterMode);
|
||||
if (cpu->id >= ppu_thread::id_min)
|
||||
{
|
||||
m_disasm = std::make_unique<PPUDisAsm>(CPUDisAsm_InterpreterMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_disasm = std::make_unique<SPUDisAsm>(CPUDisAsm_InterpreterMode);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case cpu_type::spu:
|
||||
{
|
||||
m_disasm = std::make_unique<SPUDisAsm>(CPUDisAsm_InterpreterMode);
|
||||
break;
|
||||
}
|
||||
|
||||
case cpu_type::arm:
|
||||
case system_type::psv:
|
||||
{
|
||||
m_disasm = std::make_unique<ARMv7DisAsm>(CPUDisAsm_InterpreterMode);
|
||||
break;
|
||||
|
|
@ -249,7 +250,7 @@ void InterpreterDisAsmFrame::ShowAddr(u32 addr)
|
|||
}
|
||||
else
|
||||
{
|
||||
const u32 cpu_offset = cpu->type == cpu_type::spu ? static_cast<SPUThread&>(*cpu).offset : 0;
|
||||
const u32 cpu_offset = g_system == system_type::ps3 && cpu->id < ppu_thread::id_min ? static_cast<SPUThread&>(*cpu).offset : 0;
|
||||
m_disasm->offset = (u8*)vm::base(cpu_offset);
|
||||
for (uint i = 0, count = 4; i<m_item_count; ++i, m_pc += count)
|
||||
{
|
||||
|
|
@ -438,7 +439,7 @@ void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event))
|
|||
{
|
||||
if (cpu && test(cpu->state & cpu_state_pause))
|
||||
{
|
||||
cpu->state -= cpu_state::dbg_pause;
|
||||
cpu->state -= cpu_flag::dbg_pause;
|
||||
(*cpu)->lock_notify();
|
||||
}
|
||||
}
|
||||
|
|
@ -447,7 +448,7 @@ void InterpreterDisAsmFrame::DoPause(wxCommandEvent& WXUNUSED(event))
|
|||
{
|
||||
if (cpu)
|
||||
{
|
||||
cpu->state += cpu_state::dbg_pause;
|
||||
cpu->state += cpu_flag::dbg_pause;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -455,10 +456,10 @@ void InterpreterDisAsmFrame::DoStep(wxCommandEvent& WXUNUSED(event))
|
|||
{
|
||||
if (cpu)
|
||||
{
|
||||
if (test(cpu_state::dbg_pause, cpu->state.fetch_op([](bs_t<cpu_state>& state)
|
||||
if (test(cpu_flag::dbg_pause, cpu->state.fetch_op([](bs_t<cpu_flag>& state)
|
||||
{
|
||||
state += cpu_state::dbg_step;
|
||||
state -= cpu_state::dbg_pause;
|
||||
state += cpu_flag::dbg_step;
|
||||
state -= cpu_flag::dbg_pause;
|
||||
})))
|
||||
{
|
||||
(*cpu)->lock_notify();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "stdafx.h"
|
||||
#include "stdafx_gui.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/CPU/CPUThread.h"
|
||||
#include "Emu/CPU/CPUDisAsm.h"
|
||||
#include "Emu/Cell/PPUThread.h"
|
||||
|
|
@ -53,22 +54,28 @@ RegisterEditorDialog::RegisterEditorDialog(wxPanel *parent, u32 _pc, cpu_thread*
|
|||
|
||||
Bind(wxEVT_COMBOBOX, &RegisterEditorDialog::updateRegister, this);
|
||||
|
||||
switch (cpu->type)
|
||||
switch (g_system)
|
||||
{
|
||||
case cpu_type::ppu:
|
||||
for (int i = 0; i<32; i++) t1_register->Append(wxString::Format("GPR[%d]", i));
|
||||
for (int i = 0; i<32; i++) t1_register->Append(wxString::Format("FPR[%d]", i));
|
||||
for (int i = 0; i<32; i++) t1_register->Append(wxString::Format("VR[%d]", i));
|
||||
t1_register->Append("CR");
|
||||
t1_register->Append("LR");
|
||||
t1_register->Append("CTR");
|
||||
//t1_register->Append("XER");
|
||||
//t1_register->Append("FPSCR");
|
||||
break;
|
||||
case system_type::ps3:
|
||||
{
|
||||
if (_cpu->id >= ppu_thread::id_min)
|
||||
{
|
||||
for (int i = 0; i < 32; i++) t1_register->Append(wxString::Format("GPR[%d]", i));
|
||||
for (int i = 0; i < 32; i++) t1_register->Append(wxString::Format("FPR[%d]", i));
|
||||
for (int i = 0; i < 32; i++) t1_register->Append(wxString::Format("VR[%d]", i));
|
||||
t1_register->Append("CR");
|
||||
t1_register->Append("LR");
|
||||
t1_register->Append("CTR");
|
||||
//t1_register->Append("XER");
|
||||
//t1_register->Append("FPSCR");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 128; i++) t1_register->Append(wxString::Format("GPR[%d]", i));
|
||||
}
|
||||
|
||||
case cpu_type::spu:
|
||||
for (int i = 0; i<128; i++) t1_register->Append(wxString::Format("GPR[%d]", i));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
wxMessageBox("Not supported thread.", "Error");
|
||||
|
|
@ -82,33 +89,28 @@ RegisterEditorDialog::RegisterEditorDialog(wxPanel *parent, u32 _pc, cpu_thread*
|
|||
std::string reg = fmt::ToUTF8(t1_register->GetStringSelection());
|
||||
std::string value = fmt::ToUTF8(t2_value->GetValue());
|
||||
|
||||
switch (cpu->type)
|
||||
{
|
||||
case cpu_type::ppu:
|
||||
if (g_system == system_type::ps3 && cpu->id >= ppu_thread::id_min)
|
||||
{
|
||||
auto& ppu = *static_cast<ppu_thread*>(cpu);
|
||||
|
||||
while (value.length() < 32) value = "0" + value;
|
||||
std::string::size_type first_brk = reg.find('[');
|
||||
const auto first_brk = reg.find('[');
|
||||
try
|
||||
{
|
||||
if (first_brk != std::string::npos)
|
||||
if (first_brk != -1)
|
||||
{
|
||||
long reg_index = atol(reg.substr(first_brk + 1, reg.length() - first_brk - 2).c_str());
|
||||
const long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - first_brk - 2).c_str());
|
||||
if (reg.find("GPR") == 0 || reg.find("FPR") == 0)
|
||||
{
|
||||
unsigned long long reg_value;
|
||||
reg_value = std::stoull(value.substr(16, 31), 0, 16);
|
||||
const ullong reg_value = std::stoull(value.substr(16, 31), 0, 16);
|
||||
if (reg.find("GPR") == 0) ppu.gpr[reg_index] = (u64)reg_value;
|
||||
if (reg.find("FPR") == 0) (u64&)ppu.fpr[reg_index] = (u64)reg_value;
|
||||
return;
|
||||
}
|
||||
if (reg.find("VR") == 0)
|
||||
{
|
||||
unsigned long long reg_value0;
|
||||
unsigned long long reg_value1;
|
||||
reg_value0 = std::stoull(value.substr(16, 31), 0, 16);
|
||||
reg_value1 = std::stoull(value.substr(0, 15), 0, 16);
|
||||
const ullong reg_value0 = std::stoull(value.substr(16, 31), 0, 16);
|
||||
const ullong reg_value1 = std::stoull(value.substr(0, 15), 0, 16);
|
||||
ppu.vr[reg_index]._u64[0] = (u64)reg_value0;
|
||||
ppu.vr[reg_index]._u64[1] = (u64)reg_value1;
|
||||
return;
|
||||
|
|
@ -116,58 +118,46 @@ RegisterEditorDialog::RegisterEditorDialog(wxPanel *parent, u32 _pc, cpu_thread*
|
|||
}
|
||||
if (reg == "LR" || reg == "CTR")
|
||||
{
|
||||
unsigned long long reg_value;
|
||||
reg_value = std::stoull(value.substr(16, 31), 0, 16);
|
||||
const ullong reg_value = std::stoull(value.substr(16, 31), 0, 16);
|
||||
if (reg == "LR") ppu.lr = (u64)reg_value;
|
||||
if (reg == "CTR") ppu.ctr = (u64)reg_value;
|
||||
return;
|
||||
}
|
||||
if (reg == "CR")
|
||||
{
|
||||
unsigned long long reg_value;
|
||||
reg_value = std::stoull(value.substr(24, 31), 0, 16);
|
||||
const ullong reg_value = std::stoull(value.substr(24, 31), 0, 16);
|
||||
if (reg == "CR") ppu.cr_unpack((u32)reg_value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (std::invalid_argument&)//if any of the stoull conversion fail
|
||||
catch (std::invalid_argument&) //if any of the stoull conversion fail
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case cpu_type::spu:
|
||||
else if (g_system == system_type::ps3 && cpu->id < ppu_thread::id_min)
|
||||
{
|
||||
auto& spu = *static_cast<SPUThread*>(cpu);
|
||||
|
||||
while (value.length() < 32) value = "0" + value;
|
||||
std::string::size_type first_brk = reg.find('[');
|
||||
if (first_brk != std::string::npos)
|
||||
const auto first_brk = reg.find('[');
|
||||
try
|
||||
{
|
||||
long reg_index;
|
||||
reg_index = atol(reg.substr(first_brk + 1, reg.length() - 2).c_str());
|
||||
if (reg.find("GPR") == 0)
|
||||
if (first_brk != -1)
|
||||
{
|
||||
ullong reg_value0;
|
||||
ullong reg_value1;
|
||||
try
|
||||
const long reg_index = std::atol(reg.substr(first_brk + 1, reg.length() - 2).c_str());
|
||||
if (reg.find("GPR") == 0)
|
||||
{
|
||||
reg_value0 = std::stoull(value.substr(16, 31), 0, 16);
|
||||
reg_value1 = std::stoull(value.substr(0, 15), 0, 16);
|
||||
const ullong reg_value0 = std::stoull(value.substr(16, 31), 0, 16);
|
||||
const ullong reg_value1 = std::stoull(value.substr(0, 15), 0, 16);
|
||||
spu.gpr[reg_index]._u64[0] = (u64)reg_value0;
|
||||
spu.gpr[reg_index]._u64[1] = (u64)reg_value1;
|
||||
return;
|
||||
}
|
||||
catch (std::invalid_argument& /*e*/)
|
||||
{
|
||||
break;
|
||||
}
|
||||
spu.gpr[reg_index]._u64[0] = (u64)reg_value0;
|
||||
spu.gpr[reg_index]._u64[1] = (u64)reg_value1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
catch (std::invalid_argument&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
wxMessageBox("This value could not be converted.\nNo changes were made.", "Error");
|
||||
|
|
@ -179,9 +169,7 @@ void RegisterEditorDialog::updateRegister(wxCommandEvent& event)
|
|||
std::string reg = fmt::ToUTF8(t1_register->GetStringSelection());
|
||||
std::string str;
|
||||
|
||||
switch (cpu->type)
|
||||
{
|
||||
case cpu_type::ppu:
|
||||
if (g_system == system_type::ps3 && cpu->id >= ppu_thread::id_min)
|
||||
{
|
||||
auto& ppu = *static_cast<ppu_thread*>(cpu);
|
||||
|
||||
|
|
@ -196,9 +184,8 @@ void RegisterEditorDialog::updateRegister(wxCommandEvent& event)
|
|||
if (reg == "CR") str = fmt::format("%08x", ppu.cr_pack());
|
||||
if (reg == "LR") str = fmt::format("%016llx", ppu.lr);
|
||||
if (reg == "CTR") str = fmt::format("%016llx", ppu.ctr);
|
||||
break;
|
||||
}
|
||||
case cpu_type::spu:
|
||||
else if (g_system == system_type::ps3 && cpu->id < ppu_thread::id_min)
|
||||
{
|
||||
auto& spu = *static_cast<SPUThread*>(cpu);
|
||||
|
||||
|
|
@ -209,8 +196,6 @@ void RegisterEditorDialog::updateRegister(wxCommandEvent& event)
|
|||
reg_index = atol(reg.substr(first_brk + 1, reg.length() - 2).c_str());
|
||||
if (reg.find("GPR") == 0) str = fmt::format("%016llx%016llx", spu.gpr[reg_index]._u64[1], spu.gpr[reg_index]._u64[0]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
t2_value->SetValue(fmt::FromUTF8(str));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue