2006-06-15 04:19:30 +00:00
|
|
|
#include <stdio.h>
|
2006-12-26 21:53:04 +00:00
|
|
|
#include <boost/bind.hpp>
|
2006-06-15 04:19:30 +00:00
|
|
|
#include "MemoryViewMIPS.h"
|
|
|
|
#include "win32/InputBox.h"
|
|
|
|
|
|
|
|
#define ID_MEMORYVIEW_GOTOADDRESS 40001
|
|
|
|
|
|
|
|
using namespace Framework;
|
2006-12-26 21:53:04 +00:00
|
|
|
using namespace boost;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2007-11-22 19:49:28 +00:00
|
|
|
CMemoryViewMIPS::CMemoryViewMIPS(HWND hParent, RECT* pR, CVirtualMachine& virtualMachine, CMIPS* pCtx) :
|
|
|
|
CMemoryView(hParent, pR),
|
|
|
|
m_virtualMachine(virtualMachine),
|
|
|
|
m_pCtx(pCtx)
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
SetMemorySize(0x02004000);
|
|
|
|
|
2007-11-22 19:49:28 +00:00
|
|
|
m_virtualMachine.m_OnMachineStateChange.connect(bind(&CMemoryViewMIPS::OnMachineStateChange, this));
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CMemoryViewMIPS::~CMemoryViewMIPS()
|
|
|
|
{
|
2006-12-26 21:53:04 +00:00
|
|
|
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
2006-07-09 00:45:09 +00:00
|
|
|
long CMemoryViewMIPS::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, ID_MEMORYVIEW_GOTOADDRESS, _T("Goto Address..."));
|
2006-06-15 04:19:30 +00:00
|
|
|
//Goto register?
|
|
|
|
|
|
|
|
TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, m_hWnd, NULL);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
long CMemoryViewMIPS::OnCommand(unsigned short nID, unsigned short nCmd, HWND hSender)
|
|
|
|
{
|
|
|
|
switch(nID)
|
|
|
|
{
|
|
|
|
case ID_MEMORYVIEW_GOTOADDRESS:
|
|
|
|
GotoAddress();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
HFONT CMemoryViewMIPS::GetFont()
|
|
|
|
{
|
2007-02-20 21:16:34 +00:00
|
|
|
return CreateFont(-11, 0, 0, 0, 400, 0, 0, 0, 0, 1, 2, 1, 49, _T("Courier New"));
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8 CMemoryViewMIPS::GetByte(uint32 nAddress)
|
|
|
|
{
|
|
|
|
return m_pCtx->m_pMemoryMap->GetByte(nAddress);
|
|
|
|
}
|
|
|
|
|
2006-12-26 21:53:04 +00:00
|
|
|
void CMemoryViewMIPS::OnMachineStateChange()
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryViewMIPS::GotoAddress()
|
|
|
|
{
|
|
|
|
uint32 nAddress;
|
2007-02-20 21:16:34 +00:00
|
|
|
const TCHAR* sValue;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2007-11-22 19:49:28 +00:00
|
|
|
if(m_virtualMachine.GetStatus() == CVirtualMachine::RUNNING)
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
MessageBeep(-1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-20 21:16:34 +00:00
|
|
|
Win32::CInputBox i(_T("Goto Address"), _T("Enter new address:"), _T("00000000"));
|
2006-06-15 04:19:30 +00:00
|
|
|
sValue = i.GetValue(m_hWnd);
|
|
|
|
|
|
|
|
if(sValue != NULL)
|
|
|
|
{
|
2007-02-20 21:16:34 +00:00
|
|
|
_stscanf(sValue, _T("%x"), &nAddress);
|
2006-06-15 04:19:30 +00:00
|
|
|
ScrollToAddress(nAddress);
|
2007-02-28 20:51:06 +00:00
|
|
|
SetSelectionStart(nAddress);
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
}
|