3 static WORD PaletteBuffer
[] = {
4 16, 0, // 16 entries, start with 0
5 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
8 static BYTE ColorBuffer
[] = {
12 0x00, 0x00, 0x00, 0x00, // black
13 0x2A, 0x00, 0x15, 0x00, // red
14 0x00, 0x2A, 0x15, 0x00, // green
15 0x2A, 0x2A, 0x15, 0x00, // brown
16 0x00, 0x00, 0x2A, 0x00, // blue
17 0x2A, 0x15, 0x2A, 0x00, // magenta
18 0x15, 0x2A, 0x2A, 0x00, // cyan
19 0x21, 0x22, 0x23, 0x00, // dark gray
20 0x30, 0x31, 0x32, 0x00, // light gray
21 0x3F, 0x00, 0x00, 0x00, // bright red
22 0x00, 0x3F, 0x00, 0x00, // bright green
23 0x3F, 0x3F, 0x00, 0x00, // bright yellow
24 0x00, 0x00, 0x3F, 0x00, // bright blue
25 0x3F, 0x00, 0x3F, 0x00, // bright magenta
26 0x00, 0x3F, 0x3F, 0x00, // bright cyan
27 0x3F, 0x3F, 0x3F, 0x00 // bright white
30 DWORD
getAvailableModes(HANDLE Driver
,
31 PVIDEO_MODE_INFORMATION
*modeInformation
,
35 VIDEO_NUM_MODES modes
;
36 PVIDEO_MODE_INFORMATION VideoTemp
;
38 // get number of modes supported
39 if (EngDeviceIoControl(Driver
,
40 IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES
,
44 sizeof(VIDEO_NUM_MODES
),
51 *ModeSize
= modes
.ModeInformationLength
;
53 // allocate buffer for the mini-port to write the modes in
54 *modeInformation
= (PVIDEO_MODE_INFORMATION
)
55 EngAllocMem(0, modes
.NumModes
*
56 modes
.ModeInformationLength
, ALLOC_TAG
);
58 if (*modeInformation
== (PVIDEO_MODE_INFORMATION
) NULL
)
60 // couldn't allocate buffer
64 // Ask the mini-port to fill in the available modes.
65 if (EngDeviceIoControl(Driver
,
66 IOCTL_VIDEO_QUERY_AVAIL_MODES
,
70 modes
.NumModes
* modes
.ModeInformationLength
,
73 // failed to query modes
74 EngFreeMem(*modeInformation
);
75 *modeInformation
= (PVIDEO_MODE_INFORMATION
) NULL
;
80 // Which modes supported by miniport driver are also suppoted by us, the
83 Temp
= modes
.NumModes
;
84 VideoTemp
= *modeInformation
;
86 // Reject mode if it's not 4 planes or not graphic or not 1 bits per pel
89 if ((VideoTemp
->NumberOfPlanes
!= 4 ) ||
90 !(VideoTemp
->AttributeFlags
& VIDEO_MODE_GRAPHICS
) ||
91 (VideoTemp
->BitsPerPlane
!= 1) ||
92 BROKEN_RASTERS(VideoTemp
->ScreenStride
,
93 VideoTemp
->VisScreenHeight
))
96 VideoTemp
->Length
= 0;
99 VideoTemp
= (PVIDEO_MODE_INFORMATION
)
100 (((PUCHAR
)VideoTemp
) + modes
.ModeInformationLength
);
103 return modes
.NumModes
;
106 BOOL
InitVGA(PPDEV ppdev
, BOOL bFirst
)
108 UINT ReturnedDataLength
;
109 VIDEO_MEMORY VideoMemory
;
110 VIDEO_MEMORY_INFORMATION VideoMemoryInfo
;
116 // Set the mode that was requested
117 if (EngDeviceIoControl(ppdev
->KMDriver
,
118 IOCTL_VIDEO_SET_CURRENT_MODE
,
123 &ReturnedDataLength
)) {
127 // set up internal palette
128 if (EngDeviceIoControl(ppdev
->KMDriver
,
129 IOCTL_VIDEO_SET_PALETTE_REGISTERS
,
130 (PVOID
) PaletteBuffer
,
131 sizeof (PaletteBuffer
),
134 &ReturnedDataLength
)) {
139 if (EngDeviceIoControl(ppdev
->KMDriver
,
140 IOCTL_VIDEO_SET_COLOR_REGISTERS
,
142 sizeof (ColorBuffer
),
145 &ReturnedDataLength
)) {
151 gotta fix this up.. it prevents drawing to vidmem right now
154 // map video memory into virtual memory
155 VideoMemory.RequestedVirtualAddress = NULL;
157 if (EngDeviceIoControl(ppdev->KMDriver,
158 IOCTL_VIDEO_MAP_VIDEO_MEMORY,
159 (PVOID) &VideoMemory,
160 sizeof (VIDEO_MEMORY),
161 (PVOID) &VideoMemoryInfo,
162 sizeof (VideoMemoryInfo),
163 &ReturnedDataLength)) {
164 // Failed to map to virtual memory
168 ppdev->fbScreen = VideoMemoryInfo.FrameBufferBase;