source: branches/CpuSingleSize/Forms/FormScreen.pas

Last change on this file was 238, checked in by chronos, 16 months ago
  • Modified: Removed U prefix from unit names.
  • Fixed: Memory leaks.
File size: 1.6 KB
Line 
1unit FormScreen;
2
3interface
4
5uses
6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, Machine;
7
8type
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
29implementation
30
31{$R *.lfm}
32
33{ TFormScreen }
34
35procedure TFormScreen.Timer1Timer(Sender: TObject);
36var
37 P: ^Integer;
38 X, Y: Integer;
39begin
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;
54end;
55
56function TFormScreen.GetDevice: TDevice;
57begin
58 Result := Screen;
59end;
60
61procedure TFormScreen.SetDevice(AValue: TDevice);
62begin
63 if AValue is TDeviceScreen then
64 Screen := TDeviceScreen(AValue);
65end;
66
67procedure TFormScreen.PaintBox1Paint(Sender: TObject);
68begin
69 PaintBox1.Canvas.Draw(0, 0, TempBitmap);
70end;
71
72procedure TFormScreen.FormCreate(Sender: TObject);
73begin
74 TempBitmap := TBitmap.Create;
75end;
76
77procedure TFormScreen.FormDestroy(Sender: TObject);
78begin
79 FreeAndNil(TempBitmap);
80end;
81
82end.
83
Note: See TracBrowser for help on using the repository browser.