1 | unit FormScreen;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, Machine;
|
---|
7 |
|
---|
8 | type
|
---|
9 |
|
---|
10 | { TFormScreen }
|
---|
11 |
|
---|
12 | TFormScreen = class(TFormDevice)
|
---|
13 | PaintBox1: TPaintBox;
|
---|
14 | Timer1: TTimer;
|
---|
15 | procedure FormCreate(Sender: TObject);
|
---|
16 | procedure FormDestroy(Sender: TObject);
|
---|
17 | procedure PaintBox1Paint(Sender: TObject);
|
---|
18 | procedure Timer1Timer(Sender: TObject);
|
---|
19 | private
|
---|
20 | TempBitmap: TBitmap;
|
---|
21 | protected
|
---|
22 | function GetDevice: TDevice; override;
|
---|
23 | procedure SetDevice(AValue: TDevice); override;
|
---|
24 | public
|
---|
25 | Screen: TDeviceScreen;
|
---|
26 | end;
|
---|
27 |
|
---|
28 |
|
---|
29 | implementation
|
---|
30 |
|
---|
31 | {$R *.lfm}
|
---|
32 |
|
---|
33 | { TFormScreen }
|
---|
34 |
|
---|
35 | procedure TFormScreen.Timer1Timer(Sender: TObject);
|
---|
36 | var
|
---|
37 | P: ^Integer;
|
---|
38 | X, Y: Integer;
|
---|
39 | begin
|
---|
40 | if Assigned(Screen) and Screen.Modified then begin
|
---|
41 | Screen.Modified := False;
|
---|
42 | TempBitmap.SetSize(PaintBox1.Width, PaintBox1.Height);
|
---|
43 | TempBitmap.BeginUpdate;
|
---|
44 | for Y := 0 to Screen.Size.Y - 1 do begin
|
---|
45 | P := TempBitmap.ScanLine[Y];
|
---|
46 | for X := 0 to Screen.Size.X - 1 do begin
|
---|
47 | P^ := Screen.VideoMem[Y * Screen.Size.Y + X] * $010101;
|
---|
48 | Inc(P);
|
---|
49 | end;
|
---|
50 | end;
|
---|
51 | TempBitmap.EndUpdate;
|
---|
52 | PaintBox1.Refresh;
|
---|
53 | end;
|
---|
54 | end;
|
---|
55 |
|
---|
56 | function TFormScreen.GetDevice: TDevice;
|
---|
57 | begin
|
---|
58 | Result := Screen;
|
---|
59 | end;
|
---|
60 |
|
---|
61 | procedure TFormScreen.SetDevice(AValue: TDevice);
|
---|
62 | begin
|
---|
63 | if AValue is TDeviceScreen then
|
---|
64 | Screen := TDeviceScreen(AValue);
|
---|
65 | end;
|
---|
66 |
|
---|
67 | procedure TFormScreen.PaintBox1Paint(Sender: TObject);
|
---|
68 | begin
|
---|
69 | PaintBox1.Canvas.Draw(0, 0, TempBitmap);
|
---|
70 | end;
|
---|
71 |
|
---|
72 | procedure TFormScreen.FormCreate(Sender: TObject);
|
---|
73 | begin
|
---|
74 | TempBitmap := TBitmap.Create;
|
---|
75 | end;
|
---|
76 |
|
---|
77 | procedure TFormScreen.FormDestroy(Sender: TObject);
|
---|
78 | begin
|
---|
79 | FreeAndNil(TempBitmap);
|
---|
80 | end;
|
---|
81 |
|
---|
82 | end.
|
---|
83 |
|
---|