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
, VideoTemp
->VisScreenHeight
))
95 VideoTemp
->Length
= 0;
98 VideoTemp
= (PVIDEO_MODE_INFORMATION
)(((PUCHAR
)VideoTemp
) + modes
.ModeInformationLength
);
101 return modes
.NumModes
;
104 BOOL
InitVGA(PPDEV ppdev
, BOOL bFirst
)
106 ULONG ReturnedDataLength
;
108 ppdev
->sizeSurf
.cx
= 640;
109 ppdev
->sizeSurf
.cy
= 480;
112 // Set the mode that was requested
113 if (EngDeviceIoControl(ppdev
->KMDriver
,
114 IOCTL_VIDEO_SET_CURRENT_MODE
,
119 &ReturnedDataLength
)) {
123 // set up internal palette
124 if (EngDeviceIoControl(ppdev
->KMDriver
,
125 IOCTL_VIDEO_SET_PALETTE_REGISTERS
,
126 (PVOID
) PaletteBuffer
,
127 sizeof (PaletteBuffer
),
130 &ReturnedDataLength
)) {
135 if (EngDeviceIoControl(ppdev
->KMDriver
,
136 IOCTL_VIDEO_SET_COLOR_REGISTERS
,
138 sizeof (ColorBuffer
),
141 &ReturnedDataLength
)) {
147 gotta fix this up.. it prevents drawing to vidmem right now
150 // map video memory into virtual memory
151 VideoMemory.RequestedVirtualAddress = NULL;
153 if (EngDeviceIoControl(ppdev->KMDriver,
154 IOCTL_VIDEO_MAP_VIDEO_MEMORY,
155 (PVOID) &VideoMemory,
156 sizeof (VIDEO_MEMORY),
157 (PVOID) &VideoMemoryInfo,
158 sizeof (VideoMemoryInfo),
159 &ReturnedDataLength)) {
160 // Failed to map to virtual memory
164 ppdev->fbScreen = VideoMemoryInfo.FrameBufferBase;