MMU: Use templates for Read/Write functions

This commit is contained in:
Martino Fontana
2025-10-08 11:27:06 +02:00
parent 03ef9b4995
commit 8a97ce9124
32 changed files with 487 additions and 775 deletions
@@ -277,7 +277,7 @@ void ThreadWidget::Update()
};
const auto format_hex_from = [&format_hex](const Core::CPUThreadGuard& guard, u32 addr) {
addr =
PowerPC::MMU::HostIsRAMAddress(guard, addr) ? PowerPC::MMU::HostRead_U32(guard, addr) : 0;
PowerPC::MMU::HostIsRAMAddress(guard, addr) ? PowerPC::MMU::HostRead<u32>(guard, addr) : 0;
return format_hex(addr);
};
const auto get_state = [](u16 thread_state) {
@@ -463,7 +463,7 @@ void ThreadWidget::UpdateThreadCallstack(const Core::CPUThreadGuard& guard,
m_callstack_table->setItem(i, 0, new QTableWidgetItem(format_hex(sp)));
if (PowerPC::MMU::HostIsRAMAddress(guard, sp + 4))
{
const u32 lr_save = PowerPC::MMU::HostRead_U32(guard, sp + 4);
const u32 lr_save = PowerPC::MMU::HostRead<u32>(guard, sp + 4);
m_callstack_table->setItem(i, 2, new QTableWidgetItem(format_hex(lr_save)));
m_callstack_table->setItem(
i, 3,
@@ -474,7 +474,7 @@ void ThreadWidget::UpdateThreadCallstack(const Core::CPUThreadGuard& guard,
{
m_callstack_table->setItem(i, 2, new QTableWidgetItem(QStringLiteral("--------")));
}
sp = PowerPC::MMU::HostRead_U32(guard, sp);
sp = PowerPC::MMU::HostRead<u32>(guard, sp);
m_callstack_table->setItem(i, 1, new QTableWidgetItem(format_hex(sp)));
}
}
@@ -203,12 +203,12 @@ void WatchWidget::Update()
{
if (PowerPC::MMU::HostIsRAMAddress(guard, entry.address))
{
hex->setText(QStringLiteral("%1").arg(PowerPC::MMU::HostRead_U32(guard, entry.address), 8,
hex->setText(QStringLiteral("%1").arg(PowerPC::MMU::HostRead<u32>(guard, entry.address), 8,
16, QLatin1Char('0')));
decimal->setText(QString::number(PowerPC::MMU::HostRead_U32(guard, entry.address)));
decimal->setText(QString::number(PowerPC::MMU::HostRead<u32>(guard, entry.address)));
string->setText(
QString::fromStdString(PowerPC::MMU::HostGetString(guard, entry.address, 32)));
floatValue->setText(QString::number(PowerPC::MMU::HostRead_F32(guard, entry.address)));
floatValue->setText(QString::number(PowerPC::MMU::HostRead<float>(guard, entry.address)));
lockValue->setCheckState(entry.locked ? Qt::Checked : Qt::Unchecked);
}
}
@@ -425,7 +425,7 @@ void WatchWidget::OnItemChanged(QTableWidgetItem* item)
}
else
{
PowerPC::MMU::HostWrite_U32(guard, value, debug_interface.GetWatch(row).address);
PowerPC::MMU::HostWrite<u32>(guard, value, debug_interface.GetWatch(row).address);
}
}
else
+2 -2
View File
@@ -1644,7 +1644,7 @@ RSOVector MenuBar::DetectRSOModules(ParallelProgressDialog& progress)
for (; len < MODULE_NAME_MAX_LENGTH; ++len)
{
const auto res = PowerPC::MMU::HostRead_U8(guard, *found_addr - (len + 1));
const auto res = PowerPC::MMU::HostRead<u8>(guard, *found_addr - (len + 1));
if (!std::isprint(res))
{
break;
@@ -1988,7 +1988,7 @@ void MenuBar::SearchInstruction()
for (u32 addr = Memory::MEM1_BASE_ADDR; addr < Memory::MEM1_BASE_ADDR + memory.GetRamSizeReal();
addr += 4)
{
if (op_std == PPCTables::GetInstructionName(PowerPC::MMU::HostRead_U32(guard, addr), addr))
if (op_std == PPCTables::GetInstructionName(PowerPC::MMU::HostRead<u32>(guard, addr), addr))
{
NOTICE_LOG_FMT(POWERPC, "Found {} at {:08x}", op_std, addr);
found = true;