📄 puworker.cpp
字号:
// PUWorker.cpp : implementation file
//
#include "stdafx.h"
#include "MDIDemo.h"
#include "PUWorker.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPUWorker dialog
CPUWorker::CPUWorker(CWnd* pParent /*=NULL*/)
: CDialog(CPUWorker::IDD, pParent)
{
//{{AFX_DATA_INIT(CPUWorker)
m_addrstr = _T("0x00");
m_datastr = _T("0x00");
//}}AFX_DATA_INIT
pcpu=NULL;
}
unsigned int CPUWorker::HextoDec1(TCHAR * p)
{
unsigned int r = 0;
TCHAR *str=p;
while(*str)
{
r = r<<4;
if((*str| 0x20 ) >= 'a' &&(*str | 0x20) <= 'f')
{
r += ((*str| 0x20 ) - 'a' + 10 );
}
else
if(*str >= '0' &&*str <= '9')
{
r += ((*str ) - '0');
}
str++;
}
return r;
}
void CPUWorker::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPUWorker)
DDX_Control(pDX, IDC_EDITRAM, m_editram);
DDX_Control(pDX, IDC_EDITData, m_editdata);
DDX_Control(pDX, IDC_EDITADDR, m_editaddr);
DDX_Text(pDX, IDC_EDITADDR, m_addrstr);
DDX_Text(pDX, IDC_EDITData, m_datastr);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPUWorker, CDialog)
//{{AFX_MSG_MAP(CPUWorker)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_WM_LBUTTONDOWN()
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPUWorker message handlers
void CPUWorker::OnButton1()
{
int d=DeviceMag.isrun;
if(DeviceMag.isrunth==1)
{
AfxMessageBox("请先停止处理器运行");
return ;
}
// TODO: Add your control notification handler code here
//theApp.m_pMainWndSendMessage(WM_COMMAND ,IDC_RUNALL,0);
cpuwatch.FlashSign();
if(d==1)
{
DeviceMag.RUN();
}
CWnd * wnd=GetDlgItem(IDC_CPUReg);
wnd->SetWindowText(pcpustr);
}
void CPUWorker::OnButton3()
{
if(DeviceMag.isrunth==1)
{
AfxMessageBox("请先停止处理器运行");
return ;
}
this->UpdateData();
unsigned int addr=HextoDec1(m_addrstr.GetBuffer(m_addrstr.GetLength()));
TCHAR SignStr[1024*8];
TCHAR strbuf[256];
memset(SignStr,0,sizeof(TCHAR)*1024*8);
memset(strbuf,0,sizeof(TCHAR)*256);
sprintf(SignStr,"地址0x%04X: ",addr);
int d=DeviceMag.isrun;
DeviceMag.STOP();
for(int i=0;i<1024;i++)
{
if(addr+i>65535)
{
break;
}
sprintf(strbuf,"%02X ",pcpu->mem->idata[addr+i]);
strcat(SignStr,strbuf);
if((i+1)%8==0&&i!=1023&&addr+i!=65535)//
{
sprintf(strbuf,"\r\n地址0x%04X: ",(addr+i+1));
strcat(SignStr,strbuf);
}
}
if(d==1)
{
DeviceMag.RUN();
}
m_editram.SetSel(0,-1,TRUE);
m_editram.Clear();
m_editram.SendMessage(EM_REPLACESEL,0,(LPARAM)SignStr);
//str.Format("addr=%x",addr);
//AfxMessageBox(str);
// TODO: Add your control notification handler code here
}
void CPUWorker::OnButton2()
{
if(DeviceMag.isrunth==1)
{
AfxMessageBox("请先停止处理器运行");
return ;
}
this->UpdateData();
unsigned int addr=HextoDec1(m_addrstr.GetBuffer(m_addrstr.GetLength()));
unsigned int data=HextoDec1(m_addrstr.GetBuffer(m_datastr.GetLength()));
//DeviceMag.STOP();
pcpu->mem->idata[addr]=data;
//DeviceMag.RUN();
// TODO: Add your control notification handler code here
}
void CPUWorker::OnButton4()
{
if(DeviceMag.isrunth==1)
{
AfxMessageBox("请先停止处理器运行");
return ;
}
this->UpdateData();
unsigned int addr=HextoDec1(m_addrstr.GetBuffer(m_addrstr.GetLength()));
unsigned int data=HextoDec1(m_addrstr.GetBuffer(m_datastr.GetLength()));
//DeviceMag.STOP();
pcpu->mem->pxdata[addr]=data;
//DeviceMag.RUN();
// TODO: Add your control notification handler code here
}
void CPUWorker::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x,point.y));
//this;
//this->ShowWindow(SW_HIDE);
::SetWindowPos(this->m_hWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW|SWP_FRAMECHANGED);
// RECT rect;
// this->GetWindowRect(&rect);
this->Invalidate();
this->UpdateWindow();
this->ShowWindow(SW_SHOW);
CDialog::OnLButtonDown(nFlags, point);
CDialog::OnLButtonDown(nFlags, point);
}
int CPUWorker::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
pcpustr=cpuwatch.GetSignStr();
cpuwatch.mem=pcpu->mem;
cpuwatch.pinst=pcpu->inst;
// TODO: Add your specialized creation code here
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -