void Timer1Tick(object sender, EventArgs e) { vm_error error; pictureBox1.Invalidate(); if (vm.dt>0) vm.dt--; if (vm.st>0) vm.st--; switch (conState) { case eCSTATE.RUNNING: vm.speed=(byte)trackBar1.Value; error=vm.ccVM(); break; case eCSTATE.STEP: textBox1.Text="last step\r\n"; vm.speed=1; error=vm.ccVM(); displayVMState(vm.last); conState=eCSTATE.PAUSED; SetMenuState(); break; default: error=vm_error.VM_OK; break; } switch (error) { case vm_error.VM_OK: break; case vm_error.VM_BREAK: textBox1.Text="break point reached:\r\n"; conState=eCSTATE.PAUSED; SetMenuState(); displayVMState(vm.pc); break; case vm_error.VM_END: textBox1.Text="game termnated with no error"; conState=eCSTATE.STOPPED; SetMenuState(); vm.Reset(); break; default: textBox1.Text=String.Format("VM error:{0:S}\r\n",error_msg[(int)error]); displayVMState(vm.last); conState=eCSTATE.STOPPED; vm.Reset(); break; } }
public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // vm = new ChipConVM(); vm.text = new Text(this); pictureBox1.Image=vm.tv.display; vm.tv.cls(); conState=eCSTATE.IDLE; SetMenuState(); BreaksForm = new FormBreakPoints(this); VRESCombo.SelectedItem=0; VRESCombo.Text="72"; }
void StepToolBtnClick(object sender, EventArgs e) { textBox1.Text="Single step"; conState=eCSTATE.STEP; SetMenuState(); }
void StopToolBtnClick(object sender, EventArgs e) { textBox1.Text="Stopped\r\n"; vm.Reset(); conState=eCSTATE.STOPPED; SetMenuState(); }
void ResumeToolBtnClick(object sender, EventArgs e) { textBox1.Text="Resumed"; conState=eCSTATE.RUNNING; SetMenuState(); }
void StepMenuItemClick(object sender, EventArgs e) { conState=eCSTATE.STEP; SetMenuState(); }
void RestartMenuItemClick(object sender, EventArgs e) { if (vm.codeInStore) { vm.Reset(); textBox1.Text="Restarted"; conState=eCSTATE.RUNNING; SetMenuState(); } }
void ReloadLastFileMenuItemClick(object sender, EventArgs e) { byte[] data; try { System.IO.Stream fileStream = openFileDialog1.OpenFile(); data= new byte[Math.Min(ChipConVM.CODE_SIZE,fileStream.Length)]; using (System.IO.BinaryReader reader = new System.IO.BinaryReader(fileStream)) { reader.Read(data,0,(int)data.Length); } fileStream.Close(); vm.load(data); textBox1.Text="Running"; conState=eCSTATE.RUNNING; SetMenuState(); BreaksForm.ClearList(); string lbl_file=openFileDialog1.FileName.Split(new char[]{'.'})[0]+".lbl"; BreaksForm.LoadLabels(lbl_file); trackBar1.Focus(); } catch(FileNotFoundException ex){ MessageBox.Show(string.Format("file {0:s} was not found!",ex.FileName),"File error"); } }
void PauseToolBtnClick(object sender, EventArgs e) { textBox1.Text="Paused, last instruction:\r\n"; displayVMState(vm.last); conState=eCSTATE.PAUSED; SetMenuState(); }
void OpenFileMenuItemClick(object sender, EventArgs e) { byte[] data; openFileDialog1.Filter = "CHIPcon binary|*.bin|SCHIP files|*.SC,*.CH8|All Files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; openFileDialog1.Multiselect = false; openFileDialog1.FileName=""; DialogResult result=openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { System.IO.Stream fileStream = openFileDialog1.OpenFile(); data= new byte[Math.Min(ChipConVM.CODE_SIZE,fileStream.Length)]; using (System.IO.BinaryReader reader = new System.IO.BinaryReader(fileStream)) { reader.Read(data,0,(int)data.Length); } fileStream.Close(); vm.load(data); textBox1.Text="Running"; conState=eCSTATE.RUNNING; SetMenuState(); BreaksForm.ClearList(); reloadLastFileMenuItem.Enabled=true; trackBar1.Focus(); } gameName=openFileDialog1.FileName.Split(new char[]{'.'})[0]; string lbl_file=gameName+".lbl"; if (!BreaksForm.LoadLabels(lbl_file)){ textBox1.AppendText("\r\nNo label file found"); } string[] pathSplit= gameName.Split(new char[]{'\\'}); this.Text=String.Format("CHIPcon V2 emulator ( {0:S} )", pathSplit[pathSplit.Length-1]); }
void MainFormShown(object sender, EventArgs e) { textBox1.Text="console idle"; conState=eCSTATE.IDLE; SetMenuState(); }