⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pucontrolpan.cpp

📁 一款国产的8051模拟器(全部源代码) 本软件是一款8051模拟器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			str.Format("ROMRAM%d:%s",s,DeviceMag.DTCB[ID_TYPE_MEM].DEVICEINFO[i].pDeviceName);
			popmenu.AppendMenu(0,IDC_DEVICE_EPMEM_SELECT +i,str.GetBuffer(str.GetLength()));
			s++;
		}
	}
	if(i==0)
	{
		popmenu.AppendMenu(0,IDC_DEVICE_NULL_COM,"没有可用的EPROM");
	}
	
	CPoint pt;
	GetCursorPos(&pt);
	popmenu.TrackPopupMenu( TPM_LEFTBUTTON|TPM_RIGHTBUTTON , pt.x, pt.y, this);
	//CTL=m_clk-var8051[0]->inst->mem->CLKNUML;
	QueryPerformanceFrequency(&lFr);
	f2=lFr.QuadPart;
	QueryPerformanceCounter(&lCnt1);
	// TODO: Add your control notification handler code here
	//GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
	//GetDlgItem(IDC_BUTTON2)->EnableWindow(TRUE);
		
	//GetDlgItem(IDC_BUTTON4)->EnableWindow(TRUE);
	//GetDlgItem(IDC_BUTTON5)->EnableWindow(TRUE);
	//GetDlgItem(IDC_BUTTON6)->EnableWindow(TRUE);
	
	
}

void CPUControlPan::OnButton4() 
{
	popmenu.DestroyMenu();
	
	popmenu.CreatePopupMenu();
	CString str;
	//popmenu.
	int s=0;
	for(int i=0;i<DeviceMag.DTCB[ID_TYPE_MEM].Currentpos;i++)
	{
		if(!(DeviceMag.DTCB[ID_TYPE_MEM].DEVICEINFO[i].flag&ID_IS_CFG))
		{
			str.Format("ROMRAM%d:%s",s,DeviceMag.DTCB[ID_TYPE_MEM].DEVICEINFO[i].pDeviceName);
			popmenu.AppendMenu(0,IDC_DEVICE_RMEM_SELECT+i,str.GetBuffer(str.GetLength()));	
			s++;
		}
	}
	if(i==0)
	{
		popmenu.AppendMenu(0,IDC_DEVICE_NULL_COM,"没有可用RAM");
	}
	
	CPoint pt;
	GetCursorPos(&pt);
	popmenu.TrackPopupMenu( TPM_LEFTBUTTON|TPM_RIGHTBUTTON , pt.x, pt.y, this);
	
	// TODO: Add your control notification handler code here
	//GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
	//GetDlgItem(IDC_BUTTON2)->EnableWindow(TRUE);
	//GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE);
	//GetDlgItem(IDC_BUTTON4)->EnableWindow(FALSE);
	//GetDlgItem(IDC_BUTTON5)->EnableWindow(TRUE);
	//GetDlgItem(IDC_BUTTON6)->EnableWindow(TRUE);
	
	
}

void CPUControlPan::OnButton5() 
{
	// TODO: Add your control notification handler code here
	popmenu.DestroyMenu();
	
	popmenu.CreatePopupMenu();
	CString str;
	//popmenu.
	int s=0;
	for(int i=0;i<DeviceMag.DTCB[ID_TYPE_SerialBus].Currentpos;i++)
	{
		if(!(DeviceMag.DTCB[ID_TYPE_SerialBus].DEVICEINFO[i].flag&ID_IS_CFG))
		{
			str.Format("串行总线%d:%s",i,DeviceMag.DTCB[ID_TYPE_SerialBus].DEVICEINFO[i].pDeviceName);
			popmenu.AppendMenu(0,IDC_DEVICE_SBUSO_SELECT+i,str.GetBuffer(str.GetLength()));		
			s++;
		}
	}
	if(i==0)
	{
		popmenu.AppendMenu(0,IDC_DEVICE_NULL_COM,"没有可用的串行总线");
	}
	CPoint pt;
	GetCursorPos(&pt);
	popmenu.TrackPopupMenu( TPM_LEFTBUTTON|TPM_RIGHTBUTTON , pt.x, pt.y, this);
	//
	
	
	
}

void CPUControlPan::OnButton6() 
{
	// TODO: Add your control notification handler code here
	popmenu.DestroyMenu();
	
	popmenu.CreatePopupMenu();
	CString str;
	//popmenu.
	int s=0;
	for(int i=0;i<DeviceMag.DTCB[ID_TYPE_SerialBus].Currentpos;i++)
	{
		if(!(DeviceMag.DTCB[ID_TYPE_SerialBus].DEVICEINFO[i].flag&ID_IS_CFG))
		{
			str.Format("串行总线%d:%s",i,DeviceMag.DTCB[ID_TYPE_SerialBus].DEVICEINFO[i].pDeviceName);
			popmenu.AppendMenu(0,IDC_DEVICE_SBUSI_SELECT+i,str.GetBuffer(str.GetLength()));	
			s++;
		}
	}
	if(i==0)
	{
		popmenu.AppendMenu(0,IDC_DEVICE_NULL_COM,"没有可用的串行总线");
	}

	CPoint pt;
	GetCursorPos(&pt);
	popmenu.TrackPopupMenu( TPM_LEFTBUTTON|TPM_RIGHTBUTTON , pt.x, pt.y, this);
	
}

void CPUControlPan::OnButton7() 
{
	popmenu.DestroyMenu();
	
	popmenu.CreatePopupMenu();
	CString str;
	//popmenu.
	int s=0;
	for(int i=0;i<DeviceMag.DTCB[ID_TYPE_8051CPU].Currentpos;i++)
	{
		if(!(DeviceMag.DTCB[ID_TYPE_8051CPU].DEVICEINFO[i].flag&ID_IS_CFG))
		{
			str.Format("CPU%d:%s",s,DeviceMag.DTCB[ID_TYPE_8051CPU].DEVICEINFO[i].pDeviceName);
			popmenu.AppendMenu(0,IDC_DEVICE_SELECT+i,str.GetBuffer(str.GetLength()));
			s++;
		}
	}
	if(i==0)
	{
		popmenu.AppendMenu(0,IDC_DEVICE_NULL_COM,"没有可用的处理器");
	}
	
	CPoint pt;
	GetCursorPos(&pt);
	popmenu.TrackPopupMenu( TPM_LEFTBUTTON|TPM_RIGHTBUTTON , pt.x, pt.y, this);
	

	
}

void CPUControlPan::SetCPUInfo()
{
	
	CString tagstr1;

#if OS==0
	TCHAR tagstr[1024];
	memset(tagstr,0,1024);
	if(pcpuname!=NULL)
	{
		strcat(tagstr,"CPU名称:");
		strcat(tagstr,pcpuname);
		strcat(tagstr,"\r\n");
	}
	if(pepromstr!=NULL)
	{
		strcat(tagstr,"EPROM名称:");
		strcat(tagstr,pepromstr);
		strcat(tagstr,"\r\n");
	}
	if(!pathstr.IsEmpty())
	{
		strcat(tagstr,"EPROM路径名称:\r\n");
		//strlen(
		strcat(tagstr,pathstr.GetBuffer(pathstr.GetLength()));
		strcat(tagstr,"\r\n");
	}
	if(pramstr!=NULL)
	{
		strcat(tagstr,"RAM名称:");
		strcat(tagstr,pramstr);
		strcat(tagstr,"\r\n");
	}
	if(psbusi!=NULL)
	{
		strcat(tagstr,"RXD接入的串行总线名称:\r\n");
		strcat(tagstr,psbusi);
		strcat(tagstr,"\r\n");
	}
	if(psbuso!=NULL)
	{
		strcat(tagstr,"TXD接入的串行总线名称:\r\n");
		strcat(tagstr,psbuso);
		strcat(tagstr,"\r\n");
	}
	CWnd * wnd=GetDlgItem(IDC_CPUINFO);
	wnd->SetWindowText(tagstr);
#endif
#if OS==1
//	ZeroMemory(pCodeMemHookR,65536*sizeof(CodeMemHook));
	if(pcpuname!=NULL)
	{
		//strcat(tagstr,"CPU名称:");
		//strcat(tagstr,pcpuname);
		//strcat(tagstr,"\r\n");
		tagstr1+="CPU名称:";
		tagstr1+=pcpuname;
		tagstr1+="\r\n";
	}
	if(pepromstr!=NULL)
	{
		//strcat(tagstr,"EPROM名称:");
		//strcat(tagstr,pepromstr);
		//strcat(tagstr,"\r\n");
		tagstr1+="EPROM名称:";
		tagstr1+=pepromstr;
		tagstr1+="\r\n";
	}
	if(!pathstr.IsEmpty())
	{
		//strcat(tagstr,"EPROM路径名称:\r\n");
		//strlen(
		//strcat(tagstr,pathstr);
		//strcat(tagstr,"\r\n");
		tagstr1+="EPROM路径名称:\r\n";
		tagstr1+=pathstr;
		tagstr1+="\r\n";
	}
	if(pramstr!=NULL)
	{
		//strcat(tagstr,"RAM名称:");
		//strcat(tagstr,pramstr);
		//strcat(tagstr,"\r\n");
		tagstr1+="RAM名称:";
		tagstr1+=pramstr;
		tagstr1+="\r\n";
	}
	if(psbusi!=NULL)
	{
		//strcat(tagstr,"RXD接入的串行总线名称:\r\n");
		//strcat(tagstr,psbusi);
		//strcat(tagstr,"\r\n");
		tagstr1+="RXD接入的串行总线名称:\r\n";
		tagstr1+=psbusi;
		tagstr1+="\r\n";
	}
	if(psbuso!=NULL)
	{
		//strcat(tagstr,"TXD接入的串行总线名称:\r\n");
		//strcat(tagstr,psbuso);
		//strcat(tagstr,"\r\n");
		tagstr1+="TXD接入的串行总线名称:\r\n";
		tagstr1+=psbuso;
		tagstr1+="\r\n";
	}
	CWnd * wnd=GetDlgItem(IDC_CPUINFO);
	wnd->SetWindowText(tagstr1.GetBuffer(tagstr1.GetLength()));
#endif
	
}

void CPUControlPan::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	CDialog::OnTimer(nIDEvent);
	
	if(nIDEvent==1)
	{
		if(DeviceMag.isrun)
		{
			//读定时器部分
			QueryPerformanceCounter(&lCnt2);
			f1=lCnt2.QuadPart-lCnt1.QuadPart;	
			CTL=pcpu->inst->mem->CLKNUML-prclk;
			prclk=pcpu->inst->mem->CLKNUML;
			QueryPerformanceCounter(&lCnt1);
						
			if(sec>=1)
			{	
				//计算时间部分
				double fTime=(double)(f1/f2);
				totaltime+=fTime;
				double MIPS=CTL/(fTime*1000000);
				double fqy=MIPS*12;
				cpuspeedstr.Format("时钟: %06f MHz\r\n运行时间 %fs",fqy,totaltime);	
				CWnd * wnd=GetDlgItem(IDC_CPUSPEED);
				wnd->SetWindowText(cpuspeedstr);
			}
			else
			{
				sec++;
			}
		}
	}
	
}

void CPUControlPan::OnButton8() 
{
	// TODO: Add your control notification handler code here
	popmenu.DestroyMenu();
	
	popmenu.CreatePopupMenu();
	CString str;
	TCHAR pstr[512];
	TCITEM  ptcitem;
	memset(&ptcitem,0,sizeof(TCITEM));
	ptcitem.mask=TCIF_TEXT;
	//popmenu.
	//int s=0;
	popmenu.AppendMenu(0,IDC_WORK_SPACE_SELECT+257,"当前工作空间");
	for(int i=0;i<ptab.tatoloftab;i++)
	{
		ptcitem.mask=TCIF_TEXT;
		ptcitem.pszText=pstr;
		ptcitem.cchTextMax=512;
		ptab.GetItem(i,&ptcitem);
		str.Format("%d:%s",i,pstr);
		popmenu.AppendMenu(0,IDC_WORK_SPACE_SELECT+i,str.GetBuffer(str.GetLength()));
		//s++;
	}
	if(i==0)
	{
		popmenu.AppendMenu(0,IDC_DEVICE_NULL_COM,"没有可用的工作空间");
	}
	
	CPoint pt;
	GetCursorPos(&pt);
	popmenu.TrackPopupMenu( TPM_LEFTBUTTON|TPM_RIGHTBUTTON , pt.x, pt.y, this);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -