1 | unit FrameBuffer;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, AddrChannel, Memory;
|
---|
7 |
|
---|
8 | type
|
---|
9 | {$MACRO ON}
|
---|
10 | TScreenMode = (smText, smGraphic1, smGraphic8, smGraphic16, smGraphic32, smGraphic64);
|
---|
11 |
|
---|
12 | {$DEFINE TGFrameBuffer := TFrameBuffer8}
|
---|
13 | {$DEFINE TGFrameBufferData := Byte}
|
---|
14 | {$DEFINE TGFrameBufferAddrChannel := TAddrChannel8}
|
---|
15 | {$DEFINE TGFrameBufferMemory := TMemory8}
|
---|
16 | {$DEFINE TGFrameBufferWidth := 8}
|
---|
17 | {$DEFINE INTERFACE}
|
---|
18 | {$I 'FrameBuffer.inc'}
|
---|
19 |
|
---|
20 | {$DEFINE TGFrameBuffer := TFrameBuffer16}
|
---|
21 | {$DEFINE TGFrameBufferData := Word}
|
---|
22 | {$DEFINE TGFrameBufferAddrChannel := TAddrChannel16}
|
---|
23 | {$DEFINE TGFrameBufferMemory := TMemory16}
|
---|
24 | {$DEFINE TGFrameBufferWidth := 16}
|
---|
25 | {$DEFINE INTERFACE}
|
---|
26 | {$I 'FrameBuffer.inc'}
|
---|
27 |
|
---|
28 | {$DEFINE TGFrameBuffer := TFrameBuffer32}
|
---|
29 | {$DEFINE TGFrameBufferData := DWord}
|
---|
30 | {$DEFINE TGFrameBufferAddrChannel := TAddrChannel32}
|
---|
31 | {$DEFINE TGFrameBufferMemory := TMemory32}
|
---|
32 | {$DEFINE TGFrameBufferWidth := 32}
|
---|
33 | {$DEFINE INTERFACE}
|
---|
34 | {$I 'FrameBuffer.inc'}
|
---|
35 |
|
---|
36 | {$DEFINE TGFrameBuffer := TFrameBuffer64}
|
---|
37 | {$DEFINE TGFrameBufferData := QWord}
|
---|
38 | {$DEFINE TGFrameBufferAddrChannel := TAddrChannel64}
|
---|
39 | {$DEFINE TGFrameBufferMemory := TMemory64}
|
---|
40 | {$DEFINE TGFrameBufferWidth := 64}
|
---|
41 | {$DEFINE INTERFACE}
|
---|
42 | {$I 'FrameBuffer.inc'}
|
---|
43 |
|
---|
44 | { TFrameBuffer }
|
---|
45 |
|
---|
46 | TFrameBuffer = class
|
---|
47 | private
|
---|
48 | FFrameBuffer16: TFrameBuffer16;
|
---|
49 | FFrameBuffer32: TFrameBuffer32;
|
---|
50 | FFrameBuffer64: TFrameBuffer64;
|
---|
51 | FFrameBuffer8: TFrameBuffer8;
|
---|
52 | FWidth: TBitWidth;
|
---|
53 | procedure SetWidth(AValue: TBitWidth);
|
---|
54 | public
|
---|
55 | procedure SetDataBus(Channel: TAddrChannel);
|
---|
56 | constructor Create;
|
---|
57 | property Width: TBitWidth read FWidth write SetWidth;
|
---|
58 | property FrameBuffer8: TFrameBuffer8 read FFrameBuffer8;
|
---|
59 | property FrameBuffer16: TFrameBuffer16 read FFrameBuffer16;
|
---|
60 | property FrameBuffer32: TFrameBuffer32 read FFrameBuffer32;
|
---|
61 | property FrameBuffer64: TFrameBuffer64 read FFrameBuffer64;
|
---|
62 | end;
|
---|
63 |
|
---|
64 | implementation
|
---|
65 |
|
---|
66 | { TFrameBuffer }
|
---|
67 |
|
---|
68 | procedure TFrameBuffer.SetWidth(AValue: TBitWidth);
|
---|
69 | begin
|
---|
70 | if FWidth = AValue then Exit;
|
---|
71 | case FWidth of
|
---|
72 | bw8: FreeAndNil(FFrameBuffer8);
|
---|
73 | bw16: FreeAndNil(FFrameBuffer16);
|
---|
74 | bw32: FreeAndNil(FFrameBuffer32);
|
---|
75 | bw64: FreeAndNil(FFrameBuffer64);
|
---|
76 | end;
|
---|
77 | FWidth := AValue;
|
---|
78 | case FWidth of
|
---|
79 | bw8: FFrameBuffer8 := TFrameBuffer8.Create;
|
---|
80 | bw16: FFrameBuffer16 := TFrameBuffer16.Create;
|
---|
81 | bw32: FFrameBuffer32 := TFrameBuffer32.Create;
|
---|
82 | bw64: FFrameBuffer64 := TFrameBuffer64.Create;
|
---|
83 | end;
|
---|
84 | end;
|
---|
85 |
|
---|
86 | procedure TFrameBuffer.SetDataBus(Channel: TAddrChannel);
|
---|
87 | begin
|
---|
88 | if Width <> Channel.Width then raise Exception.Create('Bit width mismatch.');
|
---|
89 | case Width of
|
---|
90 | bw8: FrameBuffer8.SetDataBus(Channel.AddrChannel8);
|
---|
91 | bw16: FrameBuffer16.SetDataBus(Channel.AddrChannel16);
|
---|
92 | bw32: FrameBuffer32.SetDataBus(Channel.AddrChannel32);
|
---|
93 | bw64: FrameBuffer64.SetDataBus(Channel.AddrChannel64);
|
---|
94 | end;
|
---|
95 | end;
|
---|
96 |
|
---|
97 | constructor TFrameBuffer.Create;
|
---|
98 | begin
|
---|
99 | FFrameBuffer8 := TFrameBuffer8.Create;
|
---|
100 | end;
|
---|
101 |
|
---|
102 | {$DEFINE TGFrameBuffer := TFrameBuffer8}
|
---|
103 | {$DEFINE TGFrameBufferData := Byte}
|
---|
104 | {$DEFINE TGFrameBufferAddrChannel := TAddrChannel8}
|
---|
105 | {$DEFINE TGFrameBufferMemory := TMemory8}
|
---|
106 | {$DEFINE TGFrameBufferWidth := 8}
|
---|
107 | {$DEFINE IMPLEMENTATION}
|
---|
108 | {$I 'FrameBuffer.inc'}
|
---|
109 |
|
---|
110 | {$DEFINE TGFrameBuffer := TFrameBuffer16}
|
---|
111 | {$DEFINE TGFrameBufferData := Word}
|
---|
112 | {$DEFINE TGFrameBufferAddrChannel := TAddrChannel16}
|
---|
113 | {$DEFINE TGFrameBufferMemory := TMemory16}
|
---|
114 | {$DEFINE TGFrameBufferWidth := 16}
|
---|
115 | {$DEFINE IMPLEMENTATION}
|
---|
116 | {$I 'FrameBuffer.inc'}
|
---|
117 |
|
---|
118 | {$DEFINE TGFrameBuffer := TFrameBuffer32}
|
---|
119 | {$DEFINE TGFrameBufferData := DWord}
|
---|
120 | {$DEFINE TGFrameBufferAddrChannel := TAddrChannel32}
|
---|
121 | {$DEFINE TGFrameBufferMemory := TMemory32}
|
---|
122 | {$DEFINE TGFrameBufferWidth := 32}
|
---|
123 | {$DEFINE IMPLEMENTATION}
|
---|
124 | {$I 'FrameBuffer.inc'}
|
---|
125 |
|
---|
126 | {$DEFINE TGFrameBuffer := TFrameBuffer64}
|
---|
127 | {$DEFINE TGFrameBufferData := QWord}
|
---|
128 | {$DEFINE TGFrameBufferAddrChannel := TAddrChannel64}
|
---|
129 | {$DEFINE TGFrameBufferMemory := TMemory64}
|
---|
130 | {$DEFINE TGFrameBufferWidth := 64}
|
---|
131 | {$DEFINE IMPLEMENTATION}
|
---|
132 | {$I 'FrameBuffer.inc'}
|
---|
133 |
|
---|
134 | end.
|
---|
135 |
|
---|