📄 compiledlg.cpp
字号:
// CompileDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TEC2000.h"
#include "CompileDlg.h"
#include"InteruptSetDlg.h"
//#include "VBScriptEditDlg.h"
class CTWScriptEdit;
//
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCompileDlg dialog
CCompileDlg::CCompileDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCompileDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCompileDlg)
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
// keydown=0;
// curchar=0;
//text="\0";
}
void CCompileDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCompileDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCompileDlg, CDialog)
//{{AFX_MSG_MAP(CCompileDlg)
ON_BN_CLICKED(IDC_INTERUPTSET, OnInteruptset)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_CODLOAD, OnCodload)
ON_BN_CLICKED(IDC_INTER1, OnInter1)
ON_BN_CLICKED(IDC_INTER2, OnInter2)
ON_BN_CLICKED(IDC_INTER3, OnInter3)
ON_BN_CLICKED(IDC_RESET, OnReset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCompileDlg message handlers
// TWSCRIPTEDIT ->
static LPCTSTR szKeywords = " ADD SUB AND CMP XOR TEST Exit OR MVRR DEC INC "
"SHL SHR JR JRC JRNC JRZ JRNZ JMPA LDRR IN STRR PSHF PUSH OUT POP "
"MVRD POPF RET CALL ADC SBB RCL RCR ASR NOT JMPR JRS JRNS IRET "
"CLC STC EI DI CALR LDRA LDRX OFFSET STRX OFFSET STRX STRA "
" A U G P R D B E ";
static LPCTSTR szConstants = " R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 "
" AA AB AC AD AE AF "
" BA BB BC BD BE BF "
" CA CB CC CD CE CF "
" DA DB DC DD DE DF "
" EA EB EC ED EE EF "
" FA FB FC FD FE FF ";
// <- TWSCRIPTEDIT
void CCompileDlg::OnInteruptset()
{
CInteruptSetDlg dlg;
dlg.DoModal();
}
BOOL CCompileDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TWSCRIPTEDIT ->
ModifyStyle(0, WS_CLIPCHILDREN);
m_wndScriptEdit.SubclassDlgItem(IDC_RICHEDIT1, this);
m_wndScriptEdit.Initialize();
m_wndScriptEdit.SetCaseSensitive(FALSE);
m_wndScriptEdit.SetStringQuotes(_T(";"));
m_wndScriptEdit.SetSLComment(_T('/'));
m_wndScriptEdit.SetSLComment(_T("rem"));
m_wndScriptEdit.AddKeywords(szKeywords);
m_wndScriptEdit.AddConstants(szConstants);
CString str;
str="TEC-2000 CRT MONITOR";
str+="\r\n";
str+="VerSion 1.0 2005.11";
str+="\r\n";
str+="Computer Architectur Lab.,NanJing University";
str+="\r\n";
str+="Copyright Computer Science";
str+="\r\n";
str+=">";
m_wndScriptEdit.SetWindowText(str);
m_wndScriptEdit.text=str;
// m_wndScriptEdit.FormatAll();
// <- TWSCRIPTEDIT
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCompileDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CCompileDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCompileDlg::OnCodload()
{
CString OpenFileName;
char *FilterStr = "COD Files (*.cod)|*.cod; *.cod|All Files (*.*)|*.*||";
CFileDialog OpenFile(TRUE, ".cod", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,FilterStr, NULL);
if (OpenFile.DoModal() == IDOK)
OpenFileName = OpenFile.GetPathName();
else return;
CString add=OpenFileName;
UINT lengthadd=add.GetLength();
CString a;
a.Format("%d",lengthadd);
add.SetAt(lengthadd-4,'.');
add.SetAt(lengthadd-3,'C');
add.SetAt(lengthadd-2,'O');
add.SetAt(lengthadd-1,'D');
char file[100];
strcpy(file,add);
CTEC2000App *pApp;
pApp=(CTEC2000App *)AfxGetApp();
CMainFrame *pFrm;
pFrm=(CMainFrame *)pApp->GetMainWnd();
CWnd *pStatusDlg=pFrm->m_wndCStatusDlg.GetDlgItem(IDC_STATUSEDIT);
CEdit * ph=(CEdit *)pStatusDlg;
CString temp;
if(WriteToMemCom(file)){
temp=add;
temp+="\r\n";
temp+="导入内存成功!";
ph->SetWindowText(temp);
}
else{
temp=add;
temp+="\r\n";
temp+="导入内存失败!";
ph->SetWindowText(temp);
}
}
int CCompileDlg::ReadCharmemCom(int o){
infmem.seekg(o);
return (int)infmem.get();
}
bool CCompileDlg::WriteToMemCom(char * cod){
CTEC2000App *pApp;
pApp=(CTEC2000App *)AfxGetApp();
memory=pApp->memory;
infmem.open(cod,ios::binary);
if(!infmem){return false;}
int j=ReadCharmemCom(2)*256+ReadCharmemCom(1);
int i=5;
while(infmem.eof()==0){
memory[j]=ReadCharmemCom(i)*256+ReadCharmemCom(i+1);
i+=2;
j++;
}
return true;
}
void CCompileDlg::OnInter1()
{
if(m_wndScriptEdit.inter==true)
if(m_wndScriptEdit.inter2_1==false&&m_wndScriptEdit.inter3_1==false){
m_wndScriptEdit.inter1_0=true;
m_wndScriptEdit.inter1_1=true;
}
}
void CCompileDlg::OnInter2()
{
if(m_wndScriptEdit.inter==true)
if(m_wndScriptEdit.inter3_1==false){
m_wndScriptEdit.inter2_0=true;
m_wndScriptEdit.inter2_1=true;
}
}
void CCompileDlg::OnInter3()
{
if(m_wndScriptEdit.inter==true){
m_wndScriptEdit.inter3_0=true;
m_wndScriptEdit.inter3_1=true;
}
}
void CCompileDlg::OnReset()
{
m_wndScriptEdit.end=1;
m_wndScriptEdit.runflag=false;
SetEvent(m_wndScriptEdit.m_hEvent);
m_wndScriptEdit.hTh=NULL;
CString str;
str="\r\n\r\n\r\nTEC-2000 CRT MONITOR";
str+="\r\n";
str+="VerSion 1.0 2005.11";
str+="\r\n";
str+="Computer Architectur Lab.,NanJing University";
str+="\r\n";
str+="Copyright Computer Science";
str+="\r\n";
str+=">";
int CurrentlengthAll=m_wndScriptEdit.GetWindowTextLength();
m_wndScriptEdit.SetSel(CurrentlengthAll,CurrentlengthAll);
m_wndScriptEdit.ReplaceSel(str);
m_wndScriptEdit.text=str;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -