11 #include "vgavideo/vgavideo.h"
14 #define DPRINT DbgPrint
18 #define DPRINT1 DbgPrint
20 /* FIXME - what a headers mess.... */
22 #define DDKFASTAPI __fastcall
23 #define FASTCALL __fastcall
25 ULONG
DbgPrint(PCCH Format
,...);
27 static __inline BOOLEAN
34 OldFlink
= Entry
->Flink
;
35 OldBlink
= Entry
->Blink
;
36 OldFlink
->Blink
= OldBlink
;
37 OldBlink
->Flink
= OldFlink
;
38 return (OldFlink
== OldBlink
);
43 IN PLIST_ENTRY ListHead
,
47 OldFlink
= ListHead
->Flink
;
48 Entry
->Flink
= OldFlink
;
49 Entry
->Blink
= ListHead
;
50 OldFlink
->Blink
= Entry
;
51 ListHead
->Flink
= Entry
;
56 IN PLIST_ENTRY ListHead
)
58 ListHead
->Flink
= ListHead
->Blink
= ListHead
;
61 /***********************************************************/
63 #define DS_SOLIDBRUSH 0x00000001
64 #define DS_GREYBRUSH 0x00000002
65 #define DS_BRUSH 0x00000004
66 #define DS_DIB 0x00000008
68 #define POW2(stride) (!((stride) & ((stride)-1))) // TRUE if stride is power of 2
69 #define BROKEN_RASTERS(stride,cy) ((!(POW2(stride))) && ((stride*cy) > 0x10000))
71 #define ENUM_RECT_LIMIT 50
73 typedef struct _RECT_ENUM
76 RECTL arcl
[ENUM_RECT_LIMIT
];
80 typedef struct _XYPAIR
86 typedef struct _SAVED_SCREEN_BITS
92 } SAVED_SCREEN_BITS
, *PSAVED_SCREEN_BITS
;
95 #define CURSOR_COLOR 0x00000004
96 #define CURSOR_HW 0x00000010
97 #define CURSOR_HW_ACTIVE 0x00000020
98 #define CURSOR_ANIMATE 0x00000040
102 ULONG fl
; // driver flags
106 HDEV GDIDevHandle
; // engine's handle to PDEV
107 HSURF SurfHandle
; // engine's handle to surface
108 PVOID AssociatedSurf
; // associated surface
111 XYPAIR xyHotSpot
; // cursor hotspot
114 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes
; // HW Pointer Attributes
115 PSAVED_SCREEN_BITS ImageBehindCursor
;
116 ULONG XorMaskStartOffset
; // Start offset of hardware pointer
117 // XOR mask relative to AND mask for
118 // passing to HW pointer
119 DWORD PointerAttributes
; // Size of buffer allocated
120 DWORD flPreallocSSBBufferInUse
; // True if preallocated saved screen
121 // bits buffer is in use
122 PUCHAR pjPreallocSSBBuffer
; // Pointer to preallocated saved screen
123 // bits buffer, if there is one
124 ULONG ulPreallocSSBSize
; // Size of preallocated saved screen
126 VIDEO_POINTER_CAPABILITIES PointerCapabilities
; // HW pointer abilities
127 PUCHAR pucDIB4ToVGAConvBuffer
; // DIB4->VGA conversion table buffer
128 PUCHAR pucDIB4ToVGAConvTables
; // Pointer to DIB4->VGA conversion
131 ULONG ModeNum
; // mode index for current VGA mode
133 SIZEL sizeSurf
; // displayed size of the surface
134 PBYTE fbScreen
; // pointer to the frame buffer
135 RECTL SavedBitsRight
; // invisible part right of screen
136 RECTL SavedBitsBottom
; // invisible part at the bottom of the screen
137 BOOL BitsSaved
; // TRUE if bits are currently saved
138 SIZEL sizeMem
; // actual size (in pixels) of video memory
139 LONG NumScansUsedByPointer
; // # scans of offscreen memory used by
144 RECTL BankBounds
; // Pixels addressable in this bank
145 ULONG BankOffset
; // Offset of bank start from bitmap start if linearly addressable
146 } BANK_INFO
, *PBANK_INFO
;
153 // bank control function vector
154 //typedef VOID (*PFN_BankControl)(PDEVSURF, ULONG, BANK_JUST);
155 typedef VOID (*PFN_BankControl
)(PVOID
, ULONG
, BANK_JUST
);
157 // DEVSURF -- definition of a surface as seen and used by the various VGA
160 typedef struct _DEVSURF
162 IDENT ident
; // Identifier for debugging ease
163 ULONG flSurf
; // DS_ flags as defined below
164 BYTE Color
; // Solid color surface if DS_SOLIDBRUSH
166 // If DS_SOLIDBRUSH, the following fields are undefined and not guaranteed to
167 // have been allocated!
169 BYTE Format
; // BMF_*, BMF_PHYSDEVICE
170 BYTE jReserved1
; // Reserved
171 BYTE jReserved2
; // Reserved
172 PPDEV ppdev
; // Pointer to associated PDEV
173 SIZEL sizeSurf
; // Size of the surface
174 ULONG NextScan
; // Offset from scan "n" to "n+1"
175 ULONG NextPlane
; // Offset from plane "n" to "n+1"
176 PVOID Scan0
; // Pointer to scan 0 of bitmap
177 // (actual address of start of bank, for banked VGA surface)
178 PVOID StartBmp
; // Pointer to start of bitmap
179 PVOID Conv
; // Pointer to DIB/Planer conversion buffer
181 // Banking variables; used only for banked VGA surfaces
183 PVIDEO_BANK_SELECT BankSelectInfo
;
184 ULONG Bank2RWSkip
; // Offset from one bank index to next to make two 32K banks appear to be
185 // one seamless 64K bank
186 PFN pfnBankSwitchCode
;
187 VIDEO_BANK_TYPE BankingType
;
188 ULONG BitmapSize
; // Length of bitmap if there were no banking, in CPU addressable bytes
189 ULONG PtrBankScan
; // Last scan line in pointer work bank
190 RECTL WindowClip1
; // Single-window banking clip rect
191 RECTL WindowClip2
[2]; // Double-window banking clip rects for
193 ULONG WindowBank
[2]; // Current banks mapped into windows
194 // 0 & 1 (used in 2 window mode only)
195 PBANK_INFO BankInfo
; // Pointer to array of bank clip info
196 ULONG BankInfoLength
; // Length of pbiBankInfo, in entries
197 PBANK_INFO BankInfo2RW
; // Same as above, but for 2RW window
198 ULONG BankInfo2RWLength
; // case
199 PFN_BankControl pfnBankControl
; // Pointer to bank control function
200 PFN_BankControl pfnBankControl2Window
; // Pointer to double-window bank
202 PVOID BitmapStart
; // Single-window bitmap start pointer (adjusted as
203 // necessary to make window map in at proper offset)
204 PVOID BitmapStart2Window
[2]; // Double-window window 0 and 1 bitmap start
205 PVOID BankBufferPlane0
; // Pointer to temp buffer capable of
206 // storing one full bank for plane 0 for 1
207 // R/W case; capable of storing one full
208 // bank height of edge bytes for all four
209 // planes for the 1R/1W case. Also used to
210 // point to text building buffer in all
211 // cases. This is the pointer used to
212 // dealloc bank working storage for all
215 // The following 3 pointers used by 1 R/W banked devices
216 PVOID BankBufferPlane1
; // Like above, but for plane 1
217 PVOID BankBufferPlane2
; // Like above, but for plane 2
218 PVOID BankBufferPlane3
; // Like above, but for plane 3
219 ULONG TempBufferSize
; // Full size of temp buffer pointed to
220 // by pvBankBufferPlane0
222 ULONG ajBits
[1]; // Bits will start here for device bitmaps
223 PSAVED_SCREEN_BITS ssbList
; // Pointer to start of linked list of
224 // saved screen bit blocks
225 } DEVSURF
, *PDEVSURF
;
227 typedef VOID (*PFN_ScreenToScreenBlt
)(PDEVSURF
, PRECTL
, PPOINTL
, INT
);
229 // BMF_PHYSDEVICE format type
231 #define BMF_PHYSDEVICE 0xFF
234 // Identifiers used in debugging (DEVSURF.ident)
236 #define PDEV_IDENT ('V' + ('P' << 8) + ('D' << 16) + ('V' << 24))
237 #define DEVSURF_IDENT ('V' + ('S' << 8) + ('R' << 16) + ('F' << 24))
239 BOOL
InitVGA(PPDEV ppdev
, BOOL bFirst
); // screen.c: initialize VGA mode
240 BOOL
DeinitVGA(PPDEV ppdev
); // screen.c: Free resources allocated in InitVGA
242 #define DRIVER_EXTRA_SIZE 0
243 #define ALLOC_TAG 'agvD' // Dvga tag
244 #define DLL_NAME L"vga" // DLL name in Unicode
246 #define MAX_SCAN_WIDTH 2048 // pixels
247 #define DRIVER_OFFSCREEN_REFRESHED 0x04L // if not set, don't use offscreen memory
248 #define PLANAR_PELS_PER_CPU_ADDRESS 8
249 #define PACKED_PELS_PER_CPU_ADDRESS 2
252 SURFOBJ
*Dest
, SURFOBJ
*Source
, SURFOBJ
*Mask
, XLATEOBJ
*ColorTranslation
,
253 RECTL
*DestRect
, POINTL
*SourcePoint
);
256 VGADDI_BltFromSavedScreenBits(ULONG DestX
,
258 PSAVED_SCREEN_BITS Src
,
262 VGADDI_BltToSavedScreenBits(PSAVED_SCREEN_BITS Dest
,
268 VGADDI_FreeSavedScreenBits(PSAVED_SCREEN_BITS SavedBits
);
270 VGADDI_AllocSavedScreenBits(ULONG Size
);
272 VGADDI_InitializeOffScreenMem(ULONG Start
, ULONG Length
);
274 BOOL
InitPointer(PPDEV ppdev
);
275 DWORD
getAvailableModes(HANDLE Driver
,
276 PVIDEO_MODE_INFORMATION
*modeInformation
,
280 vgaReadScan(int x
, int y
, int w
, void *b
);
283 vgaWriteScan(int x
, int y
, int w
, void *b
);