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