| 1 | unit UFormCpuState;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
|
|---|
| 9 | ExtCtrls, UMachine, UCpu;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 12 |
|
|---|
| 13 | { TFormCpuState }
|
|---|
| 14 |
|
|---|
| 15 | TFormCpuState = class(TForm)
|
|---|
| 16 | LabelTicks: TLabel;
|
|---|
| 17 | ListViewRegisters: TListView;
|
|---|
| 18 | Timer1: TTimer;
|
|---|
| 19 | procedure ListViewRegistersData(Sender: TObject; Item: TListItem);
|
|---|
| 20 | procedure Timer1Timer(Sender: TObject);
|
|---|
| 21 | private
|
|---|
| 22 | public
|
|---|
| 23 | Machine: TMachine;
|
|---|
| 24 | procedure Reload;
|
|---|
| 25 | end;
|
|---|
| 26 |
|
|---|
| 27 | var
|
|---|
| 28 | FormCpuState: TFormCpuState;
|
|---|
| 29 |
|
|---|
| 30 | implementation
|
|---|
| 31 |
|
|---|
| 32 | {$R *.lfm}
|
|---|
| 33 |
|
|---|
| 34 | { TFormCpuState }
|
|---|
| 35 |
|
|---|
| 36 | procedure TFormCpuState.Reload;
|
|---|
| 37 | begin
|
|---|
| 38 | ListViewRegisters.Items.Count := Length(Machine.Cpu.Registers);
|
|---|
| 39 | ListViewRegisters.Refresh;
|
|---|
| 40 | LabelTicks.Caption := 'Ticks: ' + IntToStr(Machine.Cpu.Ticks);
|
|---|
| 41 | end;
|
|---|
| 42 |
|
|---|
| 43 | procedure TFormCpuState.ListViewRegistersData(Sender: TObject; Item: TListItem);
|
|---|
| 44 | begin
|
|---|
| 45 | if Item.Index < Length(Machine.Cpu.Registers) + 2 then begin
|
|---|
| 46 | if Item.Index = 0 then begin
|
|---|
| 47 | Item.Caption := 'IP';
|
|---|
| 48 | Item.SubItems.Add(IntToHex(NativeUInt(Machine.Cpu.IP), 16));
|
|---|
| 49 | end else
|
|---|
| 50 | if Item.Index = 1 then begin
|
|---|
| 51 | Item.Caption := 'SP';
|
|---|
| 52 | Item.SubItems.Add(IntToHex(NativeUInt(Machine.Cpu.SP), 16));
|
|---|
| 53 | end else begin
|
|---|
| 54 | Item.Caption := 'R' + IntToStr(Item.Index - 2);
|
|---|
| 55 | Item.SubItems.Add(IntToHex(NativeUInt(Machine.Cpu.Registers[Item.Index - 2]), 16));
|
|---|
| 56 | end;
|
|---|
| 57 | end;
|
|---|
| 58 | end;
|
|---|
| 59 |
|
|---|
| 60 | procedure TFormCpuState.Timer1Timer(Sender: TObject);
|
|---|
| 61 | begin
|
|---|
| 62 | if Visible then Reload;
|
|---|
| 63 | end;
|
|---|
| 64 |
|
|---|
| 65 | end.
|
|---|
| 66 |
|
|---|