source: branches/virtcpu varint/Forms/UFormCpuState.pas

Last change on this file was 197, checked in by chronos, 5 years ago
  • Modified: All parts of virtual machine have own form in Forms subdirectory.
  • Modified: Main form moved to Forms subdirectory.
  • Modified: TCpu class moved to UCpu unit.
  • Added: Assembler and dissasembler forms.
File size: 1.4 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 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
27var
28 FormCpuState: TFormCpuState;
29
30implementation
31
32{$R *.lfm}
33
34{ TFormCpuState }
35
36procedure TFormCpuState.Reload;
37begin
38 ListViewRegisters.Items.Count := Length(Machine.Cpu.Registers);
39 ListViewRegisters.Refresh;
40 LabelTicks.Caption := 'Ticks: ' + IntToStr(Machine.Cpu.Ticks);
41end;
42
43procedure TFormCpuState.ListViewRegistersData(Sender: TObject; Item: TListItem);
44begin
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;
58end;
59
60procedure TFormCpuState.Timer1Timer(Sender: TObject);
61begin
62 if Visible then Reload;
63end;
64
65end.
66
Note: See TracBrowser for help on using the repository browser.