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 | LabelDataMode: TLabel;
|
---|
18 | LabelAddrMode: TLabel;
|
---|
19 | ListViewRegisters: TListView;
|
---|
20 | Timer1: TTimer;
|
---|
21 | procedure ListViewRegistersData(Sender: TObject; Item: TListItem);
|
---|
22 | procedure Timer1Timer(Sender: TObject);
|
---|
23 | private
|
---|
24 | public
|
---|
25 | Machine: TMachine;
|
---|
26 | procedure Reload;
|
---|
27 | end;
|
---|
28 |
|
---|
29 | var
|
---|
30 | FormCpuState: TFormCpuState;
|
---|
31 |
|
---|
32 | implementation
|
---|
33 |
|
---|
34 | {$R *.lfm}
|
---|
35 |
|
---|
36 | { TFormCpuState }
|
---|
37 |
|
---|
38 | procedure TFormCpuState.Reload;
|
---|
39 | begin
|
---|
40 | ListViewRegisters.Items.Count := Length(Machine.Cpu.Registers);
|
---|
41 | ListViewRegisters.Refresh;
|
---|
42 | LabelTicks.Caption := 'Ticks: ' + IntToStr(Machine.Cpu.Ticks);
|
---|
43 | LabelDataMode.Caption := 'Data mode: ' + BitWidthText[Machine.Cpu.DataSize];
|
---|
44 | LabelAddrMode.Caption := 'Address mode: ' + BitWidthText[Machine.Cpu.AddrSize];
|
---|
45 | end;
|
---|
46 |
|
---|
47 | procedure TFormCpuState.ListViewRegistersData(Sender: TObject; Item: TListItem);
|
---|
48 | begin
|
---|
49 | if Item.Index < Length(Machine.Cpu.Registers) + 2 then begin
|
---|
50 | if Item.Index = 0 then begin
|
---|
51 | Item.Caption := 'IP';
|
---|
52 | Item.SubItems.Add(IntToHex(Machine.Cpu.IP, 16));
|
---|
53 | end else
|
---|
54 | if Item.Index = 1 then begin
|
---|
55 | Item.Caption := 'SP';
|
---|
56 | Item.SubItems.Add(IntToHex(Machine.Cpu.SP, 16));
|
---|
57 | end else begin
|
---|
58 | Item.Caption := 'R' + IntToStr(Item.Index - 2);
|
---|
59 | Item.SubItems.Add(IntToHex(Machine.Cpu.Registers[Item.Index - 2].D, 16));
|
---|
60 | end;
|
---|
61 | end;
|
---|
62 | end;
|
---|
63 |
|
---|
64 | procedure TFormCpuState.Timer1Timer(Sender: TObject);
|
---|
65 | begin
|
---|
66 | if Visible then Reload;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | end.
|
---|
70 |
|
---|