-
Notifications
You must be signed in to change notification settings - Fork 0
/
DEMO2.C
286 lines (229 loc) · 6.62 KB
/
DEMO2.C
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#include <stdio.h>
#include <string.h>
#include "vbe.h"
#include "gfx.h"
void demo2_ShowDriverInfo( void )
{
VBEDriverInfo_t l_drvInfo;
memset( &l_drvInfo, 0, sizeof(l_drvInfo) );
vbe_GetDriverInfo( &l_drvInfo );
// Display select driver information
printf( "VBE Driver Info\n" );
printf( "---------------\n" );
printf( " Signature: '%c%c%c%c'\n",
l_drvInfo.VBESignature[0], l_drvInfo.VBESignature[1],
l_drvInfo.VBESignature[2], l_drvInfo.VBESignature[3] );
printf( " Version: %X.%X\n",
(l_drvInfo.VBEVersion >> 8), (l_drvInfo.VBEVersion & 0xFF) );
printf( " OEM String: '%s'\n", (char*)l_drvInfo.OEMStringPtr );
printf( "Capabilities: %0.8X\n", l_drvInfo.Capabilities );
if( l_drvInfo.Capabilities & VBE_CAPS_DAC8 )
{
printf( " * DAC registers switchable to 8-Bits\n" );
}
else
{
printf( " * DAC registers fixed at 6-Bits\n" );
}
if( l_drvInfo.Capabilities & VBE_CAPS_NOTVGA )
{
printf( " * Video card is not VGA compatible\n" );
}
if( l_drvInfo.Capabilities & VBE_CAPS_BLANKFN9 )
{
printf( " * Use Blank Bit in Function 09h\n" );
}
printf( "Video Memory: %u\n", l_drvInfo.TotalMemory * 64 );
if( l_drvInfo.VBEVersion >= 0x0200 )
{
printf( "OEM Soft Rev: %0.4X\n", l_drvInfo.OemSoftwareRev );
if( l_drvInfo.OemVendorNamePtr )
{
printf( " OEM Vendor: '%s'\n",
(char*)l_drvInfo.OemVendorNamePtr );
}
if( l_drvInfo.OemProductNamePtr )
{
printf( " OEM Product: '%s'\n",
(char*)l_drvInfo.OemProductNamePtr );
}
if( l_drvInfo.OemProductRevPtr )
{
printf( "OEM Revision: '%s'\n",
(char*)l_drvInfo.OemProductRevPtr );
}
}
printf( "\n" );
}
void demo2_ShowAvailableModes( void )
{
VBEDriverInfo_t l_drvInfo;
VBEModeInfo_t l_modeInfo;
uint16_t* l_modeList;
uint32_t l_i;
uint16_t l_mode;
printf( "Available Modes:\n" );
l_i = 0;
memset( &l_drvInfo, 0, sizeof(l_drvInfo) );
vbe_GetDriverInfo( &l_drvInfo );
l_modeList = (uint16_t*)l_drvInfo.VideoModePtr;
l_mode = *l_modeList;
while( l_mode != 0xFFFF )
{
l_mode = *l_modeList;
memset( &l_modeInfo, 0, sizeof(l_modeInfo) );
if( vbe_GetModeInfo(l_mode, &l_modeInfo) )
{
switch( l_modeInfo.BitsPerPixel )
{
case 8:
case 15:
case 16:
case 24:
case 32:
if( l_i == 14 )
{
printf( "\n" );
l_i = 0;
}
l_i++;
printf( " %0.4X", l_mode );
break;
}
}
l_modeList++;
}
}
void demo2_ShowModeInfo( uint16_t p_mode )
{
VBEDriverInfo_t l_drvInfo;
VBEModeInfo_t l_modeInfo;
memset( &l_drvInfo, 0, sizeof(l_drvInfo) );
memset( &l_modeInfo, 0, sizeof(l_modeInfo) );
vbe_GetDriverInfo( &l_drvInfo );
if( vbe_GetModeInfo(p_mode, &l_modeInfo) )
{
switch( l_modeInfo.BitsPerPixel )
{
case 8:
case 15:
case 16:
case 24:
case 32:
break;
default:
printf( "Mode %#.4X not 8/15/16/24/32-BPP\n", p_mode );
return;
}
}
else
{
printf( "Mode %#.4X not supported\n", p_mode );
return;
}
// Display select mode information
printf( "Mode Information\n" );
printf( "----------------\n" );
// Mode specified and validated, display mode information
printf( " Attributes: %.4X\n", l_modeInfo.ModeAttributes );
if( l_modeInfo.ModeAttributes & VBE_MA_MODEHW )
{
printf( " * Mode supported by hardware\n" );
}
if( l_modeInfo.ModeAttributes & VBE_MA_HASLFB )
{
printf( " * Linear Frame Buffer supported\n" );
}
if( l_modeInfo.ModeAttributes & VBE_MA_HW3BUF )
{
printf( " * Hardware Triple Buffering supported\n" );
}
printf( "Bytes Per Scanline: %u\n", l_modeInfo.BytesPerScanline );
printf( " Width: %u\n", l_modeInfo.XResolution );
printf( " Height: %u\n", l_modeInfo.YResolution );
printf( " Bits Per Pixel: %u\n", l_modeInfo.BitsPerPixel );
printf( " Memory Model: " );
switch( l_modeInfo.MemoryModel )
{
case VBE_MM_PACKED:
printf( "Packed Pixel\n" );
break;
case VBE_MM_DCOLOR:
printf( "Direct Color\n" );
break;
case VBE_MM_YUV:
printf( "YUV\n" );
break;
default:
printf( "%.2X\n", l_modeInfo.MemoryModel );
}
if( (l_modeInfo.MemoryModel == VBE_MM_DCOLOR) ||
(l_modeInfo.MemoryModel == VBE_MM_YUV) )
{
printf( " Red Mask Size: %u\n", l_modeInfo.RedMaskSize );
printf( " Red Field Pos: %u\n", l_modeInfo.RedFieldPosition );
printf( " Green Mask Size: %u\n", l_modeInfo.GreenMaskSize );
printf( " Green Field Pos: %u\n", l_modeInfo.GreenFieldPosition );
printf( " Blue Mask Size: %u\n", l_modeInfo.BlueMaskSize );
printf( " Blue Field Pos: %u\n", l_modeInfo.BlueFieldPosition );
printf( " Rsvd Mask Size: %u\n", l_modeInfo.RsvdMaskSize );
printf( " Rsvd Field Pos: %u\n", l_modeInfo.RsvdFieldPosition );
}
if( l_drvInfo.VBEVersion >= 0x0200 )
{
printf( " Phys Frame Buffer: %.8X\n", l_modeInfo.PhysBasePtr );
printf( " Off-Screen Offset: %u\n", l_modeInfo.Reserved2 );
printf( " Off-Screen Size: %u\n", l_modeInfo.Reserved3 );
}
}
void demo2_ShowEachAvailableModeInfo( void )
{
VBEDriverInfo_t l_drvInfo;
uint16_t* l_modeList;
uint16_t l_mode;
memset( &l_drvInfo, 0, sizeof(l_drvInfo) );
vbe_GetDriverInfo( &l_drvInfo );
l_modeList = (uint16_t*)l_drvInfo.VideoModePtr;
if( l_modeList == NULL )
{
return;
}
l_mode = *l_modeList;
while( l_mode != 0xFFFF )
{
l_mode = *l_modeList;
demo2_ShowModeInfo(l_mode);
l_modeList++;
}
}
int main( int argc, char* argv[] )
{
uint16_t l_mode;
if( vbe_Init() == 0 )
{
printf( "ERROR: VBE driver not supported.\n" );
return 0;
}
demo2_ShowDriverInfo();
if( argc < 2 )
{
// Display available 8/15/16/24/32-BPP modes by default
demo2_ShowAvailableModes();
goto Demo2_Exit;
}
if( strcmp(argv[1], "all") == 0 )
{
// Display mode information for each available mode
demo2_ShowEachAvailableModeInfo();
}
else
{
// Display mode information for specific mode
l_mode = strtoul(argv[1], NULL, 16);
demo2_ShowModeInfo( l_mode );
}
Demo2_Exit:
printf( "\n" );
vbe_Done( NULL );
return 0;
}