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

102 lines
2.5 KiB
C++
Raw Permalink Normal View History

2019-08-31 12:33:24 -04:00
#include <stdio.h>
#include <string.h>
#include <QHeaderView>
#include <QMenu>
#include "RegViewFPU.h"
CRegViewFPU::CRegViewFPU(QWidget* parent, CMIPS* pC)
: CRegViewPage(parent)
, m_pCtx(pC)
, m_nViewMode(VIEWMODE_SINGLE)
{
// Setup the register names
2019-12-19 22:13:49 +00:00
AllocateTableEntries(2, 35);
setColumnWidth(0, 40);
horizontalHeader()->setStretchLastSection(true);
2019-08-31 12:33:24 -04:00
for(unsigned int x = 0; x < 32; x++)
{
2019-12-19 22:13:49 +00:00
setRowHeight(x, 16);
2021-01-14 16:24:06 -05:00
WriteTableLabel(x, "F%d", x);
2019-08-31 12:33:24 -04:00
}
2019-12-19 22:13:49 +00:00
WriteTableLabel(32, "ACC");
WriteTableLabel(33, "FCSR");
WriteTableLabel(34, "CC");
Update();
2019-08-31 12:33:24 -04:00
// Add a context menu for switching between modes
2019-12-19 22:13:49 +00:00
setContextMenuPolicy(Qt::CustomContextMenu);
2019-08-31 12:33:24 -04:00
connect(this, &CRegViewFPU::customContextMenuRequested, this, &CRegViewFPU::ShowContextMenu);
}
void CRegViewFPU::Update()
{
switch(m_nViewMode)
{
case VIEWMODE_WORD:
RenderWord();
break;
case VIEWMODE_SINGLE:
RenderSingle();
break;
default:
break;
}
RenderFCSR();
}
void CRegViewFPU::RenderFCSR()
{
2019-12-19 22:13:49 +00:00
WriteTableEntry(33, "0x%08X", m_pCtx->m_State.nFCSR);
WriteTableEntry(34, "%i%i%i%i%i%i%i%ib",
2019-12-20 20:52:55 +00:00
(m_pCtx->m_State.nFCSR & 0x80000000) != 0 ? 1 : 0,
(m_pCtx->m_State.nFCSR & 0x40000000) != 0 ? 1 : 0,
(m_pCtx->m_State.nFCSR & 0x20000000) != 0 ? 1 : 0,
(m_pCtx->m_State.nFCSR & 0x10000000) != 0 ? 1 : 0,
(m_pCtx->m_State.nFCSR & 0x04000000) != 0 ? 1 : 0,
(m_pCtx->m_State.nFCSR & 0x08000000) != 0 ? 1 : 0,
(m_pCtx->m_State.nFCSR & 0x02000000) != 0 ? 1 : 0,
(m_pCtx->m_State.nFCSR & 0x00800000) != 0 ? 1 : 0);
2019-08-31 12:33:24 -04:00
}
void CRegViewFPU::RenderWord()
{
MIPSSTATE* s = &m_pCtx->m_State;
for(unsigned int i = 0; i < 32; i++)
{
2019-12-19 22:13:49 +00:00
WriteTableEntry(i, "0x%08X", ((uint32*)s->nCOP1)[i]);
2019-08-31 12:33:24 -04:00
}
}
void CRegViewFPU::RenderSingle()
{
MIPSSTATE* s = &m_pCtx->m_State;
for(unsigned int i = 0; i < 32; i++)
{
uint32 nData = ((uint32*)s->nCOP1)[i];
float nValue = *(float*)(&nData);
2019-12-19 22:13:49 +00:00
WriteTableEntry(i, "%+.24e", nValue);
2019-08-31 12:33:24 -04:00
}
2019-12-19 22:13:49 +00:00
WriteTableEntry(32, "%+.24e", *(float*)(&s->nCOP1A));
2019-08-31 12:33:24 -04:00
}
void CRegViewFPU::ShowContextMenu(const QPoint& pos)
{
QMenu contextMenu("Context menu", this);
2019-12-19 22:13:49 +00:00
contextMenu.addAction("Word Mode", [&]() {m_nViewMode=VIEWMODE_WORD; Update(); });
contextMenu.addAction("Single Mode", [&]() {m_nViewMode=VIEWMODE_SINGLE; Update(); });
2019-08-31 12:33:24 -04:00
contextMenu.exec(mapToGlobal(pos));
}
void CRegViewFPU::OnRunningStateChange()
{
Update();
}
void CRegViewFPU::OnMachineStateChange()
{
Update();
}