コード例 #1
0
ファイル: TextGUI.cs プロジェクト: mr-marsh/uemu51
 public Frame(int row, int col, string title, int rows, int cols)
 {
     Position = CaretCoord.New(row, col);
     Title    = title;
     InitData(rows, cols);
     CreateFrame();
 }
コード例 #2
0
ファイル: TextGUI.cs プロジェクト: mr-marsh/uemu51
        public ByteHexGrid(int row, int col, int rows, int cols, char colSep)
        {
            Position = CaretCoord.New(row, col);
            int ccoordStep = colSep != 0x00 ? 1 : 0;

            GlobalCursorStep = CaretCoord.New(1, 2 + ccoordStep);
            _colSep          = colSep;
            InitData(rows, cols);
        }
コード例 #3
0
        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]);
            }
        }
コード例 #4
0
        private void ShowMessage(string msg)
        {
            if (!string.IsNullOrEmpty(_message))
            {
                WriteAt(CaretCoord.New(28, 46 - _message.Length),
                        new string(' ', _message.Length + 2));
            }

            if (msg == null)
            {
                return;
            }

            _message = msg;
            WriteAt(CaretCoord.New(28, 47), "<");
            WriteAt(CaretCoord.New(28, 46 - msg.Length), msg);
        }
コード例 #5
0
        private void RedrawStatic()
        {
            foreach (ATUiElement frame in _frames.Values)
            {
                if (!frame.Hidden)
                {
                    DrawUTUiElement(frame);
                }
            }

            // hints

            WriteAt(CaretCoord.New(25, 0), "[spc] step [r] run [xX] reset/wipe [+-]clk spd ");
            WriteAt(CaretCoord.New(26, 0), "[m]switch mem [tab]editor focus [0-9af] input  ");

            if (_focus != 3)
            {
                WriteAt(CaretCoord.New(27, 0), "[i]nteractive mode ");
            }
            else
            {
                WriteAt(CaretCoord.New(27, 0), "                   ");
            }

            if (_focus == 3)
            {
                WriteAt(CaretCoord.New(28, 0), "[g]o [p] breakpoint");
            }
            else
            {
                WriteAt(CaretCoord.New(28, 0), "                   ");
            }

            WriteAt(CaretCoord.New(29, 0),
                    "addr$ 0000                                       ");
        }
コード例 #6
0
ファイル: TextGUI.cs プロジェクト: mr-marsh/uemu51
 static public CaretCoord GetGlobalCoords(ATUiElement element, int row, int col)
 {
     return(CaretCoord.New(row + element.CursorPos.Y * element.GlobalCursorStep.Y,
                           col + element.CursorPos.X * element.GlobalCursorStep.X));
 }
コード例 #7
0
        private void RedrawData(bool updateHistory)
        {
            int row = 0;

            for (UInt16 addr = _memOffset; addr < _memOffset + 8 * 8; addr += 8)
            {
                byte[] addr_halfs = TGUIUtils.Get16BitHalfs(addr);

                for (int j = 0; j < 2; j++)
                {
                    _dataelements["memgrid_addr"][row, j] = addr_halfs[j];
                }

                for (int j = 0; j < 8; j++)
                {
                    byte b = _emu8051.ReadMem(_memoryFrameMode, addr + j);
                    _dataelements["memgrid"][row, j] = b;
                }
                row++;
            }

            // ASCII view

            if (!_dataelements["ascii"].Hidden)
            {
                int    asciiRow = 0;
                int    asciiCol = 5;
                byte   padd     = ASCIICoDec.CodeASCII('.');
                UInt16 memaddr  = _memOffset;
                for (int i = 0; i < 8; i++)
                {
                    if (i == 4)
                    {
                        asciiRow = 0;
                        asciiCol = 19;
                    }

                    string saddr = memaddr.ToString("X4");

                    int sp = 0;
                    for (int k = asciiCol - 5; k < asciiCol - 1; k++)
                    {
                        _dataelements["ascii"][asciiRow, k] = ASCIICoDec.CodeASCII(saddr[sp]);
                        sp++;
                    }

                    for (int j = 0; j < 8; j++)
                    {
                        byte val = _emu8051.ReadMem(_memoryFrameMode, memaddr);

                        if (val > 32 && val < 127)
                        {
                            _dataelements["ascii"][asciiRow, asciiCol + j] = val;
                        }
                        else
                        {
                            _dataelements["ascii"][asciiRow, asciiCol + j] = padd;
                        }

                        memaddr++;
                    }
                    asciiRow++;
                }
            }

            if (updateHistory)
            {
                UpdateHistory(_dataelements["machine_status_h"], _dataelements["machine_status"], 5, 7);
                UpdateHistory(_dataelements["ports_h"], _dataelements["ports"], 5, 7);
                UpdateHistory(_dataelements["common_regs_h"], _dataelements["common_regs"], 5, 10);
                UpdateHistory(_dataelements["data_pointer_h"], _dataelements["data_pointer"], 5, 2);
                UpdateHistory(_dataelements["code_h"], _dataelements["code"], 5, 38);
            }

            // Stack

            byte[] stackData = _emu8051.ReadStack();
            for (int i = 0; i < 14; i++)
            {
                _dataelements["stack"][i, 0] = stackData[i];
            }

            // Common registers

            for (int i = 0; i < 10; i++)
            {
                _dataelements["common_regs"][0, i] = (byte)_emu8051.ReadReg(i);
            }

            // Data pointer

            byte[] dptr = TGUIUtils.Get16BitHalfs((ushort)_emu8051.ReadReg(10));
            for (int j = 0; j < 2; j++)
            {
                _dataelements["data_pointer"][0, j] = dptr[j];
            }

            // Code

            Instruction instr  = _emu8051.DecodeOp(_programCounter);
            string      format = "{0:X4}  {1} {2} {3}  {4}";
            string      asm    = string.Empty;

            for (int i = 0; i < instr.Assembly.Length; i++)
            {
                byte b = instr.Assembly[i];
                if (b == 0x00) // end of cstring
                {
                    break;
                }
                asm += ASCIICoDec.DecodeASCII(b);
            }

            string outstr = string.Format(format, _programCounter,
                                          TGUIUtils.ByteToHex(instr.Opcodes[0]),
                                          instr.Opcodes.Length > 1 ? TGUIUtils.ByteToHex(instr.Opcodes[1]) : "  ",
                                          instr.Opcodes.Length > 2 ? TGUIUtils.ByteToHex(instr.Opcodes[2]) : "  ",
                                          asm
                                          );

            if (outstr.Length < 38)
            {
                outstr += new string(' ', 38 - outstr.Length);
            }

            for (int i = 0; i < outstr.Length; i++)
            {
                _dataelements["code"][0, i] = ASCIICoDec.CodeASCII(outstr[i]);
            }

            // Ports

            _dataelements["ports"][0, 0] = _emu8051.ReadMem(MEM_TYPES.SFR, SFR_REGS.REG_SP - 0x80);
            _dataelements["ports"][0, 1] = _emu8051.ReadMem(MEM_TYPES.SFR, SFR_REGS.REG_P0 - 0x80);
            _dataelements["ports"][0, 2] = _emu8051.ReadMem(MEM_TYPES.SFR, SFR_REGS.REG_P1 - 0x80);
            _dataelements["ports"][0, 3] = _emu8051.ReadMem(MEM_TYPES.SFR, SFR_REGS.REG_P2 - 0x80);
            _dataelements["ports"][0, 4] = _emu8051.ReadMem(MEM_TYPES.SFR, SFR_REGS.REG_P3 - 0x80);
            _dataelements["ports"][0, 5] = _emu8051.ReadMem(MEM_TYPES.SFR, SFR_REGS.REG_IP - 0x80);
            _dataelements["ports"][0, 6] = _emu8051.ReadMem(MEM_TYPES.SFR, SFR_REGS.REG_IE - 0x80);

            // Machine status word

            int[] machine_status = TGUIUtils.GetBits(
                _emu8051.ReadMem(MEM_TYPES.SFR, SFR_REGS.REG_PSW - 0x80));

            for (int i = 0; i < 8; i++)
            {
                _dataelements["machine_status"][0, i] = (byte)machine_status[i];
            }

            // Address input

            _dataelements["addr_input"][0, 0] = _addrInputVal[0];
            _dataelements["addr_input"][0, 1] = _addrInputVal[1];

            // Cursor info

            RefreshCursorInfo();

            if (!_writeCursorH)
            {
                _currentCaretPos = TGUIUtils.GetGlobalCoords(
                    _focusedElement, _focusedElement.Position.Y, _focusedElement.Position.X);
            }

            // Info display

            int[] bits = TGUIUtils.GetBits((byte)_cursorPointedDisplayValue);

            WriteAt(CaretCoord.New(11, 2),
                    string.Format("Sel     : {0} {1} {2} {3} {4} {5} {6} {7}",
                                  bits[0], bits[1], bits[2], bits[3], bits[4], bits[5], bits[6], bits[7]));

            WriteAt(CaretCoord.New(12, 2),
                    string.Format("Time    : {0}ms", _timer.ToString("1.000")));

            WriteAt(CaretCoord.New(13, 2),
                    string.Format("Cycles  : {0}", _emu8051.Cycles));

            string spd = string.Empty;

            if (Clock.SpeedMode == 0)
            {
                spd = "MAX   ";
            }
            else if (Clock.SpeedMode == 1)
            {
                spd = "HIGH  ";
            }
            else if (Clock.SpeedMode == 2)
            {
                spd = "MIDDLE";
            }
            else if (Clock.SpeedMode == 3)
            {
                spd = "LOW   ";
            }
            else if (Clock.SpeedMode == 4)
            {
                spd = "LOWEST";
            }

            WriteAt(CaretCoord.New(14, 2),
                    string.Format("Clk spd : {0}      ", spd));

            foreach (ATUiElement element in _dataelements.Values)
            {
                if (!element.Hidden)
                {
                    DrawUTUiElement(element);
                }
            }
        }