1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
{ From VGAlib, changed for svgalib }
{ partially copyrighted (C) 1993 by Hartmut Schirmer }
Program vgatest;
uses svgalib,strings;
Var
line : array [0..2048 * 3-1] of byte;
Procedure testmode (Mode : Longint);
var
xmax, ymax, i, x, y, yw, ys, c : longint;
modeinfo : Pvga_modeinfo;
begin
vga_setmode(mode);
modeinfo := vga_getmodeinfo(mode);
Writeln ('Width: ',modeinfo^.width,' Height: ',modeinfo^.height,
' Colors: ',modeinfo^.colors);
Write ('DisplayStartRange: ',modeinfo^.startaddressrange,
' Maxpixels: ',modeinfo^.maxpixels,' Blit: ');
if modeinfo^.haveblit<>0 then
writeln ('YES') else writeln ('NO');
vga_screenoff();
xmax := vga_getxdim - 1;
ymax := vga_getydim - 1;
vga_setcolor(vga_white);
vga_drawline(0, 0, xmax, 0);
vga_drawline(xmax, 0, xmax, ymax);
vga_drawline(xmax, ymax, 0, ymax);
vga_drawline(0, ymax, 0, 0);
for i := 0 to 25 do
begin
vga_setegacolor(i);
vga_drawline(10 + i * 5, 10, 90 + i * 5, 90);
end;
for i := 0 to 25 do
begin
vga_setegacolor(i);
vga_drawline(90 + i * 5, 10, 10 + i * 5, 90);
end;
vga_screenon();
ys := 100;
yw := (ymax - 100) div 4;
Case vga_getcolors of
256:
begin
for i := 0 to 60 do
begin
c := (i * 64) div 60;
vga_setpalette(i + 16, c, c, c);
vga_setpalette(i + 16 + 60, c, 0, 0);
vga_setpalette(i + 16 + (2 * 60), 0, c, 0);
vga_setpalette(i + 16 + (3 * 60), 0, 0, c);
end;
line[0] := 15;
line[xmax] := 15;
line[1] := 0;
line[xmax - 1] := 0;
for x := 2 to xmax - 1 do
line[x] := (((x - 2) * 60) div (xmax - 3)) + 16;
for y := ys to (ys + yw-1) do { gray }
vga_drawscanline(y, line);
for x := 2 to xmax - 1 do
inc(line[x],60);
inc(ys,yw);
for y := ys to ys + yw-1 do
vga_drawscanline(y, line);
for x := 2 to xmax - 1 do
inc(line[x],60);
inc(ys,yw);
for y := ys to ys + yw-1 do
vga_drawscanline(y, line);
for x := 2 to xmax - 1 do
inc(line[x],60);
inc(ys,yw);
for y := ys to ys + yw-1 do
vga_drawscanline(y, line);
end;
1 shl 15,
1 shl 16,
1 shl 24:
begin
for x := 2 to xmax - 1 do
begin
c := ((x - 2) * 256) div (xmax - 3);
y := ys;
vga_setrgbcolor(c, c, c);
vga_drawline(x, y, x, y + yw - 1);
inc (y,yw);
vga_setrgbcolor(c, 0, 0);
vga_drawline(x, y, x, y + yw - 1);
inc(y, yw);
vga_setrgbcolor(0, c, 0);
vga_drawline(x, y, x, y + yw - 1);
inc (y,yw);
vga_setrgbcolor(0, 0, c);
vga_drawline(x, y, x, y + yw - 1);
end;
for x := 0 to 63 do
for y := 0 to 63 do
begin
vga_setrgbcolor(x * 4 + 3, y * 4 + 3, 0);
vga_drawpixel(xmax div 2 - 160 + x, y + ymax div 2 - 80);
vga_setrgbcolor(x * 4 + 3, 0, y * 4 + 3);
vga_drawpixel(xmax div 2 - 32 + x, y + ymax div 2 - 80);
vga_setrgbcolor(0, x * 4 + 3, y * 4 + 3);
vga_drawpixel(xmax div 2 + 160 - 64 + x, y + ymax div 2 - 80);
vga_setrgbcolor(x * 4 + 3, y * 4 + 3, 255);
vga_drawpixel(xmax div 2 - 160 + x, y + ymax div 2 + 16);
vga_setrgbcolor(x * 4 + 3, 255, y * 4 + 3);
vga_drawpixel(xmax div 2 - 32 + x, y + ymax div 2 + 16);
vga_setrgbcolor(255, x * 4 + 3, y * 4 + 3);
vga_drawpixel(xmax div 2 + 160 - 64 + x, y + ymax div 2 + 16);
end;
end;
else
begin
if (vga_getcolors = 16) then
begin
for i := 0 to xmax - 2 do
line[i] := (i + 2) mod 16;
line[0] := 15;
line[xmax] := 15;
line[1] := 0;
line[xmax - 1] := 0;
end;
if (vga_getcolors = 2) then
begin
for i := 0 to xmax do
line[i] := $11;
line[0] := $91;
end;
for i := 100 to ymax - 1 do
vga_drawscanline(i, line);
end;
end;
readln;
vga_setmode(GTEXT);
end;
Var
i,highest,mode : longint;
info : pvga_modeinfo;
expl : pchar;
Const cols : pchar = NiL;
begin
getmem (expl,100);
vga_init(); { Initialize. }
mode := vga_getdefaultmode();
if (mode=-1) then
begin
Writeln ('Choose one of the following video modes:');
highest := 0;
for i := 1 to GLASTMODE do
if vga_hasmode(i) then
begin
expl[0]:=#0;
info := vga_getmodeinfo(i);
Case info^.colors of
2: begin
cols := '2';
strcopy(expl, '1 bitplane, monochrome');
end;
16: begin
cols := '16';
strcopy(expl, '4 bitplanes');
end;
256: begin
if i=G320x200x256 then
strcopy(pchar(@expl[0]), 'packed-pixel')
else if (i=G320x240x256) or
((i=G320x400x256) or
(i=G360x480x256)) then
strcopy(expl, 'Mode X')
else
strcopy(expl,'packed-pixel,banked');
end;
1 shl 15:
begin
cols := '32K';
strcopy(expl, '5-5-5 RGB,blue at LSB, banked');
end;
1 shl 16:
begin
cols := '64K';
strcopy(expl, '5-6-5 RGB,blue at LSB,banked');
end;
1 shl 24:
begin
cols := '16M';
if info^.bytesperpixel = 3 then
if (info^.flags and RGB_MISORDERED)=0 then
strcopy(expl, '8-8-8 BGR, red byte first, banked')
else
strcopy(expl, '8-8-8 RGB, blue byte first, banked')
else if (info^.flags and RGB_MISORDERED)=0 then
strcopy(expl, '8-8-8 RGBX, 32-bit pixels, X byte first, banked')
else
strcopy(expl, '8-8-8 XRGB, 32-bit pixels, blue byte first, banked')
end;
end;
if (info^.flags and IS_INTERLACED)=0 then
begin
if (expl[0] <> #0) then
strcat(expl, ',');
strcat(expl, 'interlaced');
end;
if (info^.flags and IS_DYNAMICMODE)=0 then
begin
if (expl[0] <> #0) then
strcat(expl, ',');
strcat(expl, 'dynamically loaded');
end;
highest := i;
Write (i,': ', info^.width,'x', info^.height,' ');
if (cols = NiL) then
write (info^.colors)
else
write (cols);
write (' colors ');
if (expl[0]<>#0) then
write('(', expl,')');
writeln;
end;
Write ('Enter mode number (1-', highest,') : ');
Readln (mode);
if (mode < 1) or (mode > GLASTMODE) then
begin
Writeln ('Error: Mode number out of range');
halt(1);
end;
end;
if (vga_hasmode(mode)) then
testmode(mode)
else
begin
Writeln ('Error: Video mode not supported by driver.');
Halt(1);
end;
end.
|