1 | unit UFormCpu;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
|
---|
7 | ExtCtrls, UCpu;
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | { TFormCpu }
|
---|
12 |
|
---|
13 | TFormCpu = class(TForm)
|
---|
14 | Label1: TLabel;
|
---|
15 | Label2: TLabel;
|
---|
16 | LabelTicks: TLabel;
|
---|
17 | ListViewMemory: TListView;
|
---|
18 | ListViewRegs: TListView;
|
---|
19 | Timer1: TTimer;
|
---|
20 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
21 | procedure FormShow(Sender: TObject);
|
---|
22 | procedure Timer1Timer(Sender: TObject);
|
---|
23 | procedure ListViewMemoryData(Sender: TObject; Item: TListItem);
|
---|
24 | procedure ListViewRegsData(Sender: TObject; Item: TListItem);
|
---|
25 | private
|
---|
26 |
|
---|
27 | public
|
---|
28 | Cpu: TCpu;
|
---|
29 | end;
|
---|
30 |
|
---|
31 | var
|
---|
32 | FormCpu: TFormCpu;
|
---|
33 |
|
---|
34 | const
|
---|
35 | DataPerLine = 16;
|
---|
36 |
|
---|
37 |
|
---|
38 | implementation
|
---|
39 |
|
---|
40 | {$R *.lfm}
|
---|
41 |
|
---|
42 | { TFormCpu }
|
---|
43 |
|
---|
44 | procedure TFormCpu.ListViewMemoryData(Sender: TObject; Item: TListItem);
|
---|
45 | var
|
---|
46 | Line: string;
|
---|
47 | I: Integer;
|
---|
48 | begin
|
---|
49 | if Item.Index * DataPerLine < Cpu.Memory.Size then begin
|
---|
50 | Item.Caption := IntToHex(Item.Index * DataPerLine, 8);
|
---|
51 | Line := '';
|
---|
52 | for I := 0 to DataPerLine - 1 do
|
---|
53 | Line := Line + IntToHex(Cpu.Memory.Data[Item.Index * DataPerLine + I], 4) + ' ';
|
---|
54 | Item.SubItems.Add(Line);
|
---|
55 | end;
|
---|
56 | end;
|
---|
57 |
|
---|
58 | procedure TFormCpu.ListViewRegsData(Sender: TObject; Item: TListItem);
|
---|
59 | begin
|
---|
60 | if Item.Index < Length(Cpu.R) + 2 then begin
|
---|
61 | if Item.Index = 0 then begin
|
---|
62 | Item.Caption := 'IP';
|
---|
63 | Item.SubItems.Add(IntToHex(Cpu.IP, 8));
|
---|
64 | end else
|
---|
65 | if Item.Index = 1 then begin
|
---|
66 | Item.Caption := 'SP';
|
---|
67 | Item.SubItems.Add(IntToHex(Cpu.SP, 8));
|
---|
68 | end else begin
|
---|
69 | Item.Caption := 'R' + IntToStr(Item.Index - 2);
|
---|
70 | Item.SubItems.Add(IntToHex(Cpu.R[Item.Index - 2], 8));
|
---|
71 | end;
|
---|
72 | end;
|
---|
73 | end;
|
---|
74 |
|
---|
75 | procedure TFormCpu.Timer1Timer(Sender: TObject);
|
---|
76 | begin
|
---|
77 | ListViewMemory.Items.Count := Cpu.Memory.Size div DataPerLine;
|
---|
78 | ListViewMemory.Refresh;
|
---|
79 | ListViewRegs.Items.Count := Length(Cpu.R) + 2;
|
---|
80 | ListViewRegs.Refresh;
|
---|
81 | LabelTicks.Caption := 'Ticks: ' + IntToStr(Cpu.Ticks);
|
---|
82 | end;
|
---|
83 |
|
---|
84 | procedure TFormCpu.FormShow(Sender: TObject);
|
---|
85 | begin
|
---|
86 | Timer1.Enabled := True;
|
---|
87 | end;
|
---|
88 |
|
---|
89 | procedure TFormCpu.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
90 | begin
|
---|
91 | Timer1.Enabled := False;
|
---|
92 | end;
|
---|
93 |
|
---|
94 | end.
|
---|
95 |
|
---|