source: branches/virtualcpu4/Forms/UFormMemory.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.3 KB
Line 
1unit UFormMemory;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls,
9 UMachine;
10
11type
12
13 { TFormMemory }
14
15 TFormMemory = class(TForm)
16 ListViewMemory: TListView;
17 Timer1: TTimer;
18 procedure ListViewMemoryData(Sender: TObject; Item: TListItem);
19 procedure Timer1Timer(Sender: TObject);
20 private
21 public
22 Machine: TMachine;
23 procedure Reload;
24 end;
25
26var
27 FormMemory: TFormMemory;
28
29const
30 ItemsPerLine = 16;
31
32
33implementation
34
35{$R *.lfm}
36
37procedure TFormMemory.Reload;
38begin
39 ListViewMemory.Items.Count := Machine.MemorySize div ItemsPerLine;
40 ListViewMemory.Refresh;
41end;
42
43procedure TFormMemory.ListViewMemoryData(Sender: TObject; Item: TListItem);
44var
45 Line: string;
46 I: Integer;
47 Text: string;
48 One: Byte;
49begin
50 if Item.Index < Machine.MemorySize div ItemsPerLine then begin
51 Line := '';
52 Text := '';
53 for I := 0 to ItemsPerLine - 1 do begin
54 One := PByte(Machine.Memory + Item.Index * ItemsPerLine + I)^;
55 Line := Line + IntToHex(One, 2) + ' ';
56 if One >= 32 then Text := Text + Char(One)
57 else Text := Text + ' ';
58 end;
59 Item.Caption := IntToHex(Item.Index * ItemsPerLine, 8);
60 Item.SubItems.Add(Line);
61 Item.SubItems.Add(Text);
62 end;
63end;
64
65procedure TFormMemory.Timer1Timer(Sender: TObject);
66begin
67 if Visible then Reload;
68end;
69
70
71end.
72
Note: See TracBrowser for help on using the repository browser.