private void RunButton_Click(object sender, EventArgs e) { MMIO.Clear(); while (!chip.Finished) { chip.EmulateSingleInstruction(); //DebugStep(); } Visualize(); }
private void BuildButton_Click(object sender, EventArgs e) { MMIO.Clear(); for (int i = 0; i < Controls.Count; i++) { if (Controls[i].Tag as string == "RemoveMe") { Controls.RemoveAt(i); break; } } fileComboBox.SelectedIndex = -1; System.IO.File.WriteAllText("temp.txt", codeTextBox.Text); helper = new MappingsHelper(System.IO.File.ReadAllLines("temp.txt")); Display("temp.txt"); }
private void Form1_Load(object sender, EventArgs e) { cw = new ColorWheelControl() { Radius = 100, Location = new Point(0, ClientSize.Height - 200), }; encodedValueLabel = new Label() { Location = new Point(cw.Location.X, cw.Location.Y - 20), }; Controls.Add(cw); Controls.Add(encodedValueLabel); MemoryObserver = new PropertyChangeTracker <MemoryData, byte>(); ShortRegisterObserver = new PropertyChangeTracker <string, short>(); ByteRegisterObserver = new PropertyChangeTracker <string, byte>(); FlagsObserver = new PropertyChangeTracker <FlagData, bool>(); Computer.Ram = new Ram(MemoryObserver.OnPropChanged); mmioBox = new PictureBox() { Image = MMIO.ScaledMap(), SizeMode = PictureBoxSizeMode.AutoSize, }; mmioBox.Location = new Point(ClientSize.Width - mmioBox.Width - 50, 0); Controls.Add(mmioBox); fileComboBox.DropDownStyle = ComboBoxStyle.DropDownList; fileComboBox.FormattingEnabled = true; var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string[] files = Directory.GetFiles(path, "*.asm", SearchOption.TopDirectoryOnly); fileComboBox.Items.AddRange(files.Select(x => x.Remove(0, path.Length + 1)).ToArray()); debugInHex = new CheckBox() { Location = new Point(fileComboBox.Right, BuildButton.Location.Y), Text = "Display in Hex", Checked = true }; debugInHex.CheckedChanged += DebugInHex_CheckedChanged; debugMode = new CheckBox() { Location = new Point(debugInHex.Location.X, debugInHex.Bottom), Text = "Debug", Checked = false, }; debugMode.CheckedChanged += DebugMode_CheckedChanged; Controls.Add(debugInHex); Controls.Add(debugMode); Helper.Font = new Font(FontFamily.GenericMonospace, 14); codeTextBox.SelectionChanged += codeTextBox_SelectionChanged; PopulateDescriptions(); }
public void Visualize() { ResetCellColors(); ResetTextColor(); var index = chip.OffsetToIndexMap[chip.ProgramCounter.Value]; index = helper.DissassemblyIndexToLineIndex[index]; if (helper.LineIndexToDissassemblyIndex.ContainsKey(index)) { var row = dataGridView1.Rows[helper.LineIndexToDissassemblyIndex[index]]; foreach (DataGridViewCell cell in row.Cells) { cell.Style.BackColor = Color.Green; } } codeTextBox.Select(codeTextBox.GetFirstCharIndexFromLine(index), helper.LineIndexToLength[index]); codeTextBox.SelectionColor = Color.Red; DataTable table = new DataTable(); table.Columns.Add(); table.Columns.Add(); foreach (var memorykvp in MemoryObserver.ChangedPropValues) { var strKey = MemoryObserver.KeyDisplayMethod(memorykvp.Key); table.Rows.Add(strKey, "0x" + Convert.ToString(memorykvp.Value, 16)); } foreach (var flagvaluekvp in FlagsObserver.ChangedPropValues) { var strKey = FlagsObserver.KeyDisplayMethod(flagvaluekvp.Key); table.Rows.Add(strKey, flagvaluekvp.Value); } foreach (var registershortkvp in ShortRegisterObserver.ChangedPropValues) { var strKey = ShortRegisterObserver.KeyDisplayMethod(registershortkvp.Key); table.Rows.Add(strKey, "0x" + Convert.ToString(registershortkvp.Value, 16)); } foreach (var registerbytekvp in ByteRegisterObserver.ChangedPropValues) { var strKey = ByteRegisterObserver.KeyDisplayMethod(registerbytekvp.Key); table.Rows.Add(strKey, "0x" + Convert.ToString(registerbytekvp.Value, 16)); } var newDataGridView = new DataGridView() { Location = new Point(codeTextBox.Right, 0), DataSource = table, AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill, Height = this.Height, RowHeadersVisible = false, ColumnHeadersVisible = false, BorderStyle = BorderStyle.None, CellBorderStyle = DataGridViewCellBorderStyle.None, Tag = "RemoveMe", Name = "DebugView", BackgroundColor = BackColor, }; foreach (DataGridViewColumn col in newDataGridView.Columns) { col.SortMode = DataGridViewColumnSortMode.NotSortable; col.ReadOnly = true; } newDataGridView.ClearSelection(); mmioBox.Image = MMIO.ScaledMap(); mmioBox.Invalidate(); Controls.Add(newDataGridView); }