|
Last change
on this file was 197, checked in by chronos, 6 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.3 KB
|
| Line | |
|---|
| 1 | unit UFormMemory;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls,
|
|---|
| 9 | UMachine;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 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 |
|
|---|
| 26 | var
|
|---|
| 27 | FormMemory: TFormMemory;
|
|---|
| 28 |
|
|---|
| 29 | const
|
|---|
| 30 | ItemsPerLine = 16;
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | implementation
|
|---|
| 34 |
|
|---|
| 35 | {$R *.lfm}
|
|---|
| 36 |
|
|---|
| 37 | procedure TFormMemory.Reload;
|
|---|
| 38 | begin
|
|---|
| 39 | ListViewMemory.Items.Count := Machine.MemorySize div ItemsPerLine;
|
|---|
| 40 | ListViewMemory.Refresh;
|
|---|
| 41 | end;
|
|---|
| 42 |
|
|---|
| 43 | procedure TFormMemory.ListViewMemoryData(Sender: TObject; Item: TListItem);
|
|---|
| 44 | var
|
|---|
| 45 | Line: string;
|
|---|
| 46 | I: Integer;
|
|---|
| 47 | Text: string;
|
|---|
| 48 | One: Byte;
|
|---|
| 49 | begin
|
|---|
| 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;
|
|---|
| 63 | end;
|
|---|
| 64 |
|
|---|
| 65 | procedure TFormMemory.Timer1Timer(Sender: TObject);
|
|---|
| 66 | begin
|
|---|
| 67 | if Visible then Reload;
|
|---|
| 68 | end;
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 | end.
|
|---|
| 72 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.