2006-06-15 04:19:30 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2006-12-26 21:53:04 +00:00
|
|
|
#include <boost/bind.hpp>
|
2006-06-15 04:19:30 +00:00
|
|
|
#include "RegViewFPU.h"
|
|
|
|
|
|
|
|
using namespace Framework;
|
2006-12-26 21:53:04 +00:00
|
|
|
using namespace boost;
|
2008-05-14 03:09:54 +00:00
|
|
|
using namespace std;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2007-12-01 04:08:34 +00:00
|
|
|
CRegViewFPU::CRegViewFPU(HWND hParent, RECT* pR, CVirtualMachine& virtualMachine, CMIPS* pC) :
|
2006-06-15 04:19:30 +00:00
|
|
|
CRegViewPage(hParent, pR)
|
|
|
|
{
|
|
|
|
m_nViewMode = VIEWMODE_SINGLE;
|
|
|
|
|
|
|
|
m_pCtx = pC;
|
|
|
|
|
2007-12-01 04:08:34 +00:00
|
|
|
virtualMachine.m_OnMachineStateChange.connect(bind(&CRegViewFPU::OnMachineStateChange, this));
|
|
|
|
virtualMachine.m_OnRunningStateChange.connect(bind(&CRegViewFPU::OnRunningStateChange, this));
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CRegViewFPU::~CRegViewFPU()
|
|
|
|
{
|
2006-12-26 21:53:04 +00:00
|
|
|
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CRegViewFPU::Update()
|
|
|
|
{
|
2008-05-14 03:09:54 +00:00
|
|
|
SetDisplayText(GetDisplayText().c_str());
|
2006-06-15 04:19:30 +00:00
|
|
|
CRegViewPage::Update();
|
|
|
|
}
|
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
string CRegViewFPU::GetDisplayText()
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
switch(m_nViewMode)
|
|
|
|
{
|
|
|
|
case VIEWMODE_WORD:
|
2008-05-14 03:09:54 +00:00
|
|
|
return RenderWord();
|
2006-06-15 04:19:30 +00:00
|
|
|
break;
|
|
|
|
case VIEWMODE_SINGLE:
|
2008-05-14 03:09:54 +00:00
|
|
|
return RenderSingle();
|
2006-06-15 04:19:30 +00:00
|
|
|
break;
|
2008-05-14 03:09:54 +00:00
|
|
|
default:
|
|
|
|
return string();
|
|
|
|
break;
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
string CRegViewFPU::RenderFCSR()
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
char sText[256];
|
2008-05-14 03:09:54 +00:00
|
|
|
string result;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
sprintf(sText, "FCSR: 0x%0.8X\r\n", m_pCtx->m_State.nFCSR);
|
2008-05-14 03:09:54 +00:00
|
|
|
result += sText;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
sprintf(sText, "CC : %i%i%i%i%i%i%i%ib\r\n", \
|
|
|
|
(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);
|
2008-05-14 03:09:54 +00:00
|
|
|
result += sText;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
return result;
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
string CRegViewFPU::RenderWord()
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
2008-05-14 03:09:54 +00:00
|
|
|
string result;
|
|
|
|
MIPSSTATE* s = &m_pCtx->m_State;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
for(unsigned int i = 0; i < 32; i++)
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
2008-05-14 03:09:54 +00:00
|
|
|
char sText[256];
|
|
|
|
char sReg[256];
|
|
|
|
|
2006-06-15 04:19:30 +00:00
|
|
|
if(i < 10)
|
|
|
|
{
|
|
|
|
sprintf(sReg, "F%i ", i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(sReg, "F%i ", i);
|
|
|
|
}
|
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
uint32 nData = ((uint32*)s->nCOP10)[i * 2];
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
sprintf(sText, "%s: 0x%0.8X\r\n", sReg, nData);
|
2008-05-14 03:09:54 +00:00
|
|
|
result += sText;
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
result += RenderFCSR();
|
|
|
|
return result;
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
string CRegViewFPU::RenderSingle()
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
2008-05-14 03:09:54 +00:00
|
|
|
char sText[256];
|
|
|
|
string result;
|
|
|
|
MIPSSTATE* s = &m_pCtx->m_State;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
for(unsigned int i = 0; i < 32; i++)
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
2008-05-14 03:09:54 +00:00
|
|
|
char sReg[256];
|
|
|
|
|
2006-06-15 04:19:30 +00:00
|
|
|
if(i < 10)
|
|
|
|
{
|
|
|
|
sprintf(sReg, "F%i ", i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(sReg, "F%i ", i);
|
|
|
|
}
|
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
uint32 nData = ((uint32*)s->nCOP10)[i * 2];
|
|
|
|
float nValue = *(float*)(&nData);
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
sprintf(sText, "%s: %+.24e\r\n", sReg, nValue);
|
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
result += sText;
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
float nValue = *(float*)(&s->nCOP1A);
|
2006-06-15 04:19:30 +00:00
|
|
|
sprintf(sText, "ACC : %+.24e\r\n", nValue);
|
2008-05-14 03:09:54 +00:00
|
|
|
result += sText;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2008-05-14 03:09:54 +00:00
|
|
|
result += RenderFCSR();
|
|
|
|
return result;
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
2006-07-09 00:45:09 +00:00
|
|
|
long CRegViewFPU::OnRightButtonUp(int nX, int nY)
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
POINT pt;
|
|
|
|
HMENU hMenu;
|
|
|
|
|
|
|
|
pt.x = nX;
|
|
|
|
pt.y = nY;
|
|
|
|
ClientToScreen(m_hWnd, &pt);
|
|
|
|
|
|
|
|
hMenu = CreatePopupMenu();
|
2007-02-20 21:16:34 +00:00
|
|
|
InsertMenu(hMenu, 0, MF_BYPOSITION | (m_nViewMode == 0 ? MF_CHECKED : 0), 40000 + 0, _T("32 Bits Integers"));
|
|
|
|
InsertMenu(hMenu, 1, MF_BYPOSITION | (m_nViewMode == 1 ? MF_CHECKED : 0), 40000 + 1, _T("64 Bits Integers"));
|
|
|
|
InsertMenu(hMenu, 2, MF_BYPOSITION | (m_nViewMode == 2 ? MF_CHECKED : 0), 40000 + 2, _T("Single Precision Floating-Point Numbers"));
|
|
|
|
InsertMenu(hMenu, 3, MF_BYPOSITION | (m_nViewMode == 3 ? MF_CHECKED : 0), 40000 + 3, _T("Double Precision Floating-Point Numbers"));
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, m_hWnd, NULL);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
long CRegViewFPU::OnCommand(unsigned short nID, unsigned short nCmd, HWND hSender)
|
|
|
|
{
|
|
|
|
if((nID >= 40000) && (nID < (40000 + VIEWMODE_MAX)))
|
|
|
|
{
|
|
|
|
m_nViewMode = (VIEWMODE)(nID - 40000);
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-12-26 21:53:04 +00:00
|
|
|
void CRegViewFPU::OnRunningStateChange()
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
2006-12-26 21:53:04 +00:00
|
|
|
void CRegViewFPU::OnMachineStateChange()
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
Update();
|
|
|
|
}
|