source: branches/virtualcpu4/Forms/UFormCpuState.pas

Last change on this file was 180, checked in by chronos, 6 years ago
  • Modified: Memory dump, CPU state, screen, console moved to separate forms.
  • Added: Dissasembler form.
File size: 1.6 KB
Line 
1unit UFormCpuState;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
9 ExtCtrls, UMachine, UCpu;
10
11type
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
29var
30 FormCpuState: TFormCpuState;
31
32implementation
33
34{$R *.lfm}
35
36{ TFormCpuState }
37
38procedure TFormCpuState.Reload;
39begin
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];
45end;
46
47procedure TFormCpuState.ListViewRegistersData(Sender: TObject; Item: TListItem);
48begin
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;
62end;
63
64procedure TFormCpuState.Timer1Timer(Sender: TObject);
65begin
66 if Visible then Reload;
67end;
68
69end.
70
Note: See TracBrowser for help on using the repository browser.