private void SwitchFocus(int setTo = -1) { if (setTo == -1) { _focus = _focus < 1 ? _focus + 1 : 0; } else { _focus = setTo; } if (_focus == 0) { _focusedElement = _dataelements["memgrid"]; } else if (_focus == 1) { _focusedElement = _dataelements["common_regs"]; } else if (_focus == 2) { _focusedElement = _dataelements["data_pointer"]; } else if (_focus == 3) { _focusedElement = _dataelements["addr_input"]; } _cursorPointedAddress = 0; RedrawStatic(); }
private void DrawUTUiElement(ATUiElement element) { string[] lines = element.GetLines(); for (int i = 0; i < lines.Length; i++) { _terminal.PlaceCaret(CaretCoord.New(i + element.Position.Y, element.Position.X)); _terminal.WriteLine(lines[i]); } }
private void UpdateHistory(ATUiElement historyElement, ATUiElement element, int rows, int cols) { byte[,] history = ShiftHistory(historyElement.GetData(), element.GetData()); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { historyElement[i, j] = history[i, j]; } } }
public Emu8051Dbg(Emu8051 emu, ITerminal term) { _emu8051 = emu; _terminal = term; // Create data grids _dataelements.Add("memgrid", new ByteHexGrid(1, 6, 8, 8, ' ')); _dataelements.Add("memgrid_addr", new ByteHexGrid(1, 1, 8, 2, (char)0x00)); _dataelements.Add("ports", new ByteHexGrid(6, 39, 1, 7, ' ')); _dataelements.Add("ports_h", new ByteHexGrid(1, 39, 5, 7, ' ')); _dataelements.Add("common_regs", new ByteHexGrid(22, 44, 1, 10, ' ')); _dataelements.Add("common_regs_h", new ByteHexGrid(17, 44, 5, 10, ' ')); _dataelements.Add("data_pointer", new ByteHexGrid(22, 74, 1, 2, (char)0x00)); _dataelements.Add("data_pointer_h", new ByteHexGrid(17, 74, 5, 2, (char)0x00)); _dataelements.Add("control_regs", new ByteHexGrid(14, 39, 1, 8, (char)0x00)); _dataelements.Add("control_regs_h", new ByteHexGrid(9, 39, 5, 8, (char)0x00)); _dataelements["control_regs"].LineOutputFormat = _dataelements["control_regs_h"].LineOutputFormat = "{0} {1} {2} {3} {4} {5} {6} {7}"; _dataelements.Add("machine_status", new ByteHexGrid(6, 63, 1, 8, ' ')); _dataelements.Add("machine_status_h", new ByteHexGrid(1, 63, 5, 8, ' ')); _dataelements["machine_status"].DataOutputFormat = _dataelements["machine_status_h"].DataOutputFormat = "DEC"; _dataelements.Add("stack", new ByteHexGrid(1, 33, 14, 1, (char)0x00)); _dataelements["stack"].LineOutputFormat = "{0:X2}"; _dataelements.Add("ascii", new ByteHexGrid(25, 51, 4, 27, (char)0x00)); _dataelements["ascii"].Hidden = true; _dataelements["ascii"].DataOutputFormat = "STR"; _dataelements.Add("addr_input", new ByteHexGrid(29, 6, 1, 2, (char)0x00)); _dataelements.Add("code", new ByteHexGrid(22, 2, 1, 38, (char)0x00)); _dataelements.Add("code_h", new ByteHexGrid(17, 2, 5, 38, (char)0x00)); _dataelements["code"].DataOutputFormat = _dataelements["code_h"].DataOutputFormat = "STR"; InitCodeFrame(); // Create frames _frames.Add("memframe", new Frame(0, 0, "m)", 10, 31)); _frames.Add("stackframe", new Frame(0, 31, "stck", 16, 6)); _frames["stackframe"][8, 0] = ASCIICoDec.CodeASCII('>'); _frames["stackframe"][8, 5] = ASCIICoDec.CodeASCII('<'); _frames.Add("stateframe", new Frame(10, 0, "", 6, 31)); _frames.Add("codeframe", new Frame(16, 0, "─PC────Opcodes───Assembly", 8, 42)); _frames["codeframe"][6, 0] = (byte)'>'; _frames["codeframe"][6, 41] = (byte)'<'; _frames.Add("portsframe", new Frame(0, 37, "─SP─P0─P1─P2─P3─IP─IE", 8, 24)); _frames["portsframe"][6, 0] = ASCIICoDec.CodeASCII('>'); _frames["portsframe"][6, 23] = ASCIICoDec.CodeASCII('<'); _frames.Add("commonregsframe", new Frame(16, 42, "─A──R0─R1─R2─R3─R4─R5─R6─R7─B──DPTR", 8, 38)); _frames["commonregsframe"][6, 0] = ASCIICoDec.CodeASCII('>'); _frames["commonregsframe"][6, 37] = ASCIICoDec.CodeASCII('<'); _frames.Add("controlregsframe", new Frame(8, 37, "─TMOD─TCON──TH0─TH1──TL0─TL1──SCON─PCON", 8, 43)); _frames["controlregsframe"][6, 0] = ASCIICoDec.CodeASCII('>'); _frames["controlregsframe"][6, 42] = ASCIICoDec.CodeASCII('<'); _frames.Add("pswframe", new Frame(0, 61, "─C─ACF0R1R0Ov──P", 8, 19)); _frames["pswframe"][6, 0] = ASCIICoDec.CodeASCII('>'); _frames["pswframe"][6, 18] = ASCIICoDec.CodeASCII('<'); _frames.Add("asciiframe", new Frame(24, 49, "ASCII──[t]", 7, 31)); // emulator init _emu8051.BreakpointCallback += () => ShowMessage("Breakpoint reached"); // terminal init _terminal.InputEnabled = false; // debugger init _focusedElement = _dataelements["memgrid"]; SwitchMemType(); }