Play-/Source/ui_qt/DebugSupport/MemoryViewMIPSWnd.cpp

67 lines
1.6 KiB
C++
Raw Permalink Normal View History

2019-12-19 11:58:52 +00:00
#include "MemoryViewMIPSWnd.h"
2024-03-19 15:10:16 -04:00
#include "string_format.h"
2020-01-06 12:40:18 +00:00
#include "ui_MemoryViewMIPSWnd.h"
2019-12-19 11:58:52 +00:00
constexpr uint64 g_viewWindowThreshold = 0x100000;
CMemoryViewMIPSWnd::CMemoryViewMIPSWnd(QWidget* parent, CVirtualMachine& virtualMachine, CMIPS* ctx, uint64 size)
2020-02-05 21:17:51 +00:00
: QWidget(parent)
2020-01-06 12:40:18 +00:00
, ui(new Ui::CMemoryViewMIPSWnd)
2019-12-19 11:58:52 +00:00
{
2020-01-06 12:40:18 +00:00
ui->setupUi(this);
2019-12-19 21:37:47 +00:00
2019-12-21 18:48:44 +00:00
auto getByte = [ctx](uint32 address) {
uint32 physAddr = ctx->m_pAddrTranslator(ctx, address);
return ctx->m_pMemoryMap->GetByte(physAddr);
2019-12-21 18:05:47 +00:00
};
2024-03-20 15:14:57 -04:00
ui->tableView->SetContext(&virtualMachine, ctx);
ui->tableView->SetData(getByte, size, (size > g_viewWindowThreshold) ? g_viewWindowThreshold : 0);
2019-12-19 11:58:52 +00:00
2020-01-05 22:46:47 +00:00
UpdateStatusBar(0);
2020-01-06 12:40:18 +00:00
m_OnSelectionChangeConnection = ui->tableView->OnSelectionChange.Connect(std::bind(&CMemoryViewMIPSWnd::UpdateStatusBar, this, std::placeholders::_1));
2019-12-19 11:58:52 +00:00
}
CMemoryViewMIPSWnd::~CMemoryViewMIPSWnd()
{
2020-01-06 12:40:18 +00:00
delete ui;
2019-12-19 11:58:52 +00:00
}
void CMemoryViewMIPSWnd::showEvent(QShowEvent* evt)
{
2020-02-05 21:17:51 +00:00
QWidget::showEvent(evt);
2020-01-06 12:40:18 +00:00
ui->tableView->ShowEvent();
2019-12-19 11:58:52 +00:00
}
void CMemoryViewMIPSWnd::resizeEvent(QResizeEvent* evt)
{
2020-02-05 21:17:51 +00:00
QWidget::resizeEvent(evt);
2020-01-06 12:40:18 +00:00
ui->tableView->ResizeEvent();
2019-12-19 11:58:52 +00:00
}
void CMemoryViewMIPSWnd::HandleMachineStateChange()
{
2020-01-06 12:40:18 +00:00
ui->tableView->HandleMachineStateChange();
2019-12-19 11:58:52 +00:00
}
int CMemoryViewMIPSWnd::GetBytesPerLine()
{
2020-01-06 12:40:18 +00:00
return ui->tableView->GetBytesPerLine();
2019-12-19 11:58:52 +00:00
}
void CMemoryViewMIPSWnd::SetBytesPerLine(int bytesForLine)
{
2020-01-06 12:40:18 +00:00
ui->tableView->SetBytesPerLine(bytesForLine);
2019-12-19 11:58:52 +00:00
}
2023-08-12 10:31:28 -04:00
void CMemoryViewMIPSWnd::SetAddress(uint32 address)
{
ui->tableView->SetSelectionStart(address);
}
2020-01-05 22:46:47 +00:00
void CMemoryViewMIPSWnd::UpdateStatusBar(uint32 address)
2019-12-19 11:58:52 +00:00
{
2020-01-05 22:46:47 +00:00
auto caption = string_format("Address : 0x%08X", address);
2020-01-06 12:40:18 +00:00
ui->addressEdit->setText(caption.c_str());
2019-12-19 11:58:52 +00:00
}