/// <summary> /// Updates the part of the UI displaying the DataTable window of all executed operations. /// </summary> /// <param name="updateEventArgs">The UpdateUIEventArgs instance contaning the state of the CPU and the last executed operation.</param> public void UpdateOperationsUI(UpdateUIEventArgs updateEventArgs) { if (updateEventArgs.OperationAddress == 0) { return; } operationsTable.ClearSelection(); if (!operationsIndexMap.ContainsKey(updateEventArgs.OperationAddress)) { DataTable dataTable = (DataTable)operationsTable.DataSource; DataRow row = dataTable.NewRow(); row["Address"] = updateEventArgs.OperationAddress; row["Opcode"] = updateEventArgs.OperationOpName; row["Operand"] = updateEventArgs.OperationOperand; dataTable.Rows.Add(row); operationsTable.CurrentCell = operationsTable[1, dataTable.Rows.Count - 1]; operationsTable.Rows[operationsTable.Rows.Count - 1].Selected = true; operationsIndexMap[updateEventArgs.OperationAddress] = operationsTable.Rows.Count - 1; } else { DataGridViewRow row = operationsTable.Rows[operationsIndexMap[updateEventArgs.OperationAddress]]; row.Selected = true; operationsTable.CurrentCell = operationsTable[1, row.Index]; } }
/// <summary> /// Updates the part of the UI displaying the content of each register and the DataTable window of all executed operations. /// </summary> /// <param name="updateEventArgs">The UpdateUIEventArgs instance containing the state of the CPU and the last executed operation.</param> public void UpdateStateUI(UpdateUIEventArgs updateEventArgs) { // Check if we're on a thread other than the UI thread if (InvokeRequired) { BeginInvoke(new MethodInvoker(() => UpdateStateUI(updateEventArgs))); return; } UpdateRegistersUI(updateEventArgs); UpdateOperationsUI(updateEventArgs); }
/// <summary> /// Updates the part of the UI displaying the content of each register. /// </summary> /// <param name="updateEventArgs">The UpdateUIEventArgs instance containing the state of the CPU and the last executed operation.</param> public void UpdateRegistersUI(UpdateUIEventArgs updateEventArgs) { if (accumulator.Tag == null || (byte)accumulator.Tag != updateEventArgs.Accumulator) { accumulator.Tag = updateEventArgs.Accumulator; accumulator.Text = updateEventArgs.Accumulator.ToString(); } if (registerX.Tag == null || (byte)registerX.Tag != updateEventArgs.RegisterX) { registerX.Tag = updateEventArgs.RegisterX; registerX.Text = updateEventArgs.RegisterX.ToString(); } if (registerY.Tag == null || (byte)registerY.Tag != updateEventArgs.RegisterY) { registerY.Tag = updateEventArgs.RegisterY; registerY.Text = updateEventArgs.RegisterY.ToString(); } if (stackPointer.Tag == null || (byte)stackPointer.Tag != updateEventArgs.StackPointer) { stackPointer.Tag = updateEventArgs.StackPointer; stackPointer.Text = updateEventArgs.StackPointer.ToString(); } if (programCounter.Tag == null || (ushort)programCounter.Tag != updateEventArgs.ProgramCounter) { programCounter.Tag = updateEventArgs.ProgramCounter; programCounter.Text = updateEventArgs.ProgramCounter.ToString(); } if (status.Tag == null || (byte)status.Tag != updateEventArgs.Status) { status.Tag = updateEventArgs.Status; status.Text = updateEventArgs.Status.ToString(); } if (carryFlag.Checked != updateEventArgs.HasCarryFlag) { carryFlag.Checked = updateEventArgs.HasCarryFlag; } if (negativeFlag.Checked != updateEventArgs.HasNegativeFlag) { negativeFlag.Checked = updateEventArgs.HasNegativeFlag; } if (interruptFlag.Checked != updateEventArgs.HasInterruptDisableFlag) { interruptFlag.Checked = updateEventArgs.HasInterruptDisableFlag; } if (breakFlag.Checked != updateEventArgs.HasBreakFlag) { breakFlag.Checked = updateEventArgs.HasBreakFlag; } if (decimalFlag.Checked != updateEventArgs.HasDecimalFlag) { decimalFlag.Checked = updateEventArgs.HasDecimalFlag; } if (overflowFlag.Checked != updateEventArgs.HasOverflowFlag) { overflowFlag.Checked = updateEventArgs.HasOverflowFlag; } if (zeroFlag.Checked != updateEventArgs.HasZeroFlag) { zeroFlag.Checked = updateEventArgs.HasZeroFlag; } }