private void breakPtList_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (breakPtList.SelectedItem != null) { //MessageBox.Show(breakPtList.SelectedItem.ToString()); String textVal = ((ListBoxItem)breakPtList.SelectedItem).Content.ToString().Substring(8); ushort selectedVal = (ushort)Convert.ToInt32(textVal, 16); //select instruction in codeview for (int i = 0; i < CodeSection.Children.Count; i++) { InstructionControl code = (InstructionControl)CodeSection.Children[i]; if (code.Addr == selectedVal) { code.BringIntoView(); } } } }
private void updateDebugger(bool breakPointFlag) { //load Vreg values into interface V0InputBox.Text = "0x" + (chip8.VRegs[0].ToString("x2")).ToUpper(); V1InputBox.Text = "0x" + (chip8.VRegs[1].ToString("x2")).ToUpper(); V2InputBox.Text = "0x" + (chip8.VRegs[2].ToString("x2")).ToUpper(); V3InputBox.Text = "0x" + (chip8.VRegs[3].ToString("x2")).ToUpper(); V4InputBox.Text = "0x" + (chip8.VRegs[4].ToString("x2")).ToUpper(); V5InputBox.Text = "0x" + (chip8.VRegs[5].ToString("x2")).ToUpper(); V6InputBox.Text = "0x" + (chip8.VRegs[6].ToString("x2")).ToUpper(); V7InputBox.Text = "0x" + (chip8.VRegs[7].ToString("x2")).ToUpper(); V8InputBox.Text = "0x" + (chip8.VRegs[8].ToString("x2")).ToUpper(); V9InputBox.Text = "0x" + (chip8.VRegs[9].ToString("x2")).ToUpper(); VAInputBox.Text = "0x" + (chip8.VRegs[0xA].ToString("x2")).ToUpper(); VBInputBox.Text = "0x" + (chip8.VRegs[0xB].ToString("x2")).ToUpper(); VCInputBox.Text = "0x" + (chip8.VRegs[0xC].ToString("x2")).ToUpper(); VDInputBox.Text = "0x" + (chip8.VRegs[0xD].ToString("x2")).ToUpper(); VEInputBox.Text = "0x" + (chip8.VRegs[0xE].ToString("x2")).ToUpper(); VFInputBox.Text = "0x" + (chip8.VRegs[0xF].ToString("x2")).ToUpper(); //load specialized registers IndexInputBox.Text = "0x" + (chip8.Ireg1.ToString("x2")).ToUpper(); pcInputBox.Text = "0x" + (chip8.Pc.ToString("x2")).ToUpper(); DelayTimerInputBox.Text = "0x" + (chip8.DelayTimer.ToString("x2")).ToUpper(); SoundTimerInputBox.Text = "0x" + (chip8.SoundTimer.ToString("x2")).ToUpper(); //select instruction in codeview for (int i = 0; i < CodeSection.Children.Count; i++) { InstructionControl code = (InstructionControl)CodeSection.Children[i]; if (code.Addr == chip8.Pc) { if (currSelectedCode > -1) { InstructionControl previousInstruc = (InstructionControl)CodeSection.Children[currSelectedCode]; previousInstruc.selectLine(false); } code.selectLine(true); code.BringIntoView(); currSelectedCode = i; if (breakPointFlag) { //code.Background = Brushes.Red; breakPointTrigger = true; } } } //load stack byte[] stack = chip8.Stack; string stackOutput = ""; if (stack != null) { for (int j = 0; j < stack.Length; j++) { if (stack[j] != 0) { stackOutput = stackOutput + "0x" + ((Chip8.STACK_BASE_ADDR - 1) - j).ToString("x2").ToUpper() + ": 0x" + stack[j].ToString("x2").ToUpper(); } else { stackOutput = stackOutput + "0x" + ((Chip8.STACK_BASE_ADDR - 1) - j).ToString("x2").ToUpper() + ": 0x00"; } if (j != (stack.Length - 1)) { stackOutput = stackOutput + "\n"; } } //stackOutput = stackOutput.Substring(0, (stackOutput.Length - 1)); stackBox.Text = stackOutput; } //updateHexEditor loadHexEditor(); }