15 #include "vgavideo/vgavideo.h"
16 #include "objects/brush.h"
17 #include "objects/bitblt.h"
20 #define DPRINT DbgPrint
24 #define DPRINT1 DbgPrint
26 /* FIXME - what a headers mess.... */
28 #define DDKFASTAPI __fastcall
29 #define FASTCALL __fastcall
30 #define DDKCDECLAPI __cdecl
32 ULONG
DbgPrint(PCCH Format
,...);
34 static __inline BOOLEAN
41 OldFlink
= Entry
->Flink
;
42 OldBlink
= Entry
->Blink
;
43 OldFlink
->Blink
= OldBlink
;
44 OldBlink
->Flink
= OldFlink
;
45 return (OldFlink
== OldBlink
);
50 IN PLIST_ENTRY ListHead
,
54 OldFlink
= ListHead
->Flink
;
55 Entry
->Flink
= OldFlink
;
56 Entry
->Blink
= ListHead
;
57 OldFlink
->Blink
= Entry
;
58 ListHead
->Flink
= Entry
;
63 IN PLIST_ENTRY ListHead
)
65 ListHead
->Flink
= ListHead
->Blink
= ListHead
;
68 /***********************************************************/
70 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
72 #define DS_SOLIDBRUSH 0x00000001
73 #define DS_GREYBRUSH 0x00000002
74 #define DS_BRUSH 0x00000004
75 #define DS_DIB 0x00000008
77 #define POW2(stride) (!((stride) & ((stride)-1))) // TRUE if stride is power of 2
78 #define BROKEN_RASTERS(stride,cy) ((!(POW2(stride))) && ((stride*cy) > 0x10000))
80 #define ENUM_RECT_LIMIT 50
82 typedef struct _RECT_ENUM
85 RECTL arcl
[ENUM_RECT_LIMIT
];
89 typedef struct _XYPAIR
95 typedef struct _SAVED_SCREEN_BITS
100 LIST_ENTRY ListEntry
;
101 } SAVED_SCREEN_BITS
, *PSAVED_SCREEN_BITS
;
104 #define CURSOR_COLOR 0x00000004
105 #define CURSOR_HW 0x00000010
106 #define CURSOR_HW_ACTIVE 0x00000020
107 #define CURSOR_ANIMATE 0x00000040
111 ULONG fl
; // driver flags
115 HDEV GDIDevHandle
; // engine's handle to PDEV
116 HSURF SurfHandle
; // engine's handle to surface
117 PVOID AssociatedSurf
; // associated surface
120 XYPAIR xyHotSpot
; // cursor hotspot
123 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes
; // HW Pointer Attributes
124 PSAVED_SCREEN_BITS ImageBehindCursor
;
125 ULONG XorMaskStartOffset
; // Start offset of hardware pointer
126 // XOR mask relative to AND mask for
127 // passing to HW pointer
128 DWORD PointerAttributes
; // Size of buffer allocated
129 DWORD flPreallocSSBBufferInUse
; // True if preallocated saved screen
130 // bits buffer is in use
131 PUCHAR pjPreallocSSBBuffer
; // Pointer to preallocated saved screen
132 // bits buffer, if there is one
133 ULONG ulPreallocSSBSize
; // Size of preallocated saved screen
135 VIDEO_POINTER_CAPABILITIES PointerCapabilities
; // HW pointer abilities
136 PUCHAR pucDIB4ToVGAConvBuffer
; // DIB4->VGA conversion table buffer
137 PUCHAR pucDIB4ToVGAConvTables
; // Pointer to DIB4->VGA conversion
140 ULONG ModeNum
; // mode index for current VGA mode
142 SIZEL sizeSurf
; // displayed size of the surface
143 PBYTE fbScreen
; // pointer to the frame buffer
144 RECTL SavedBitsRight
; // invisible part right of screen
145 RECTL SavedBitsBottom
; // invisible part at the bottom of the screen
146 BOOL BitsSaved
; // TRUE if bits are currently saved
147 SIZEL sizeMem
; // actual size (in pixels) of video memory
148 LONG NumScansUsedByPointer
; // # scans of offscreen memory used by
153 RECTL BankBounds
; // Pixels addressable in this bank
154 ULONG BankOffset
; // Offset of bank start from bitmap start if linearly addressable
155 } BANK_INFO
, *PBANK_INFO
;
162 // bank control function vector
163 //typedef VOID (*PFN_BankControl)(PDEVSURF, ULONG, BANK_JUST);
164 typedef VOID (*PFN_BankControl
)(PVOID
, ULONG
, BANK_JUST
);
166 // DEVSURF -- definition of a surface as seen and used by the various VGA
169 typedef struct _DEVSURF
171 IDENT ident
; // Identifier for debugging ease
172 ULONG flSurf
; // DS_ flags as defined below
173 BYTE Color
; // Solid color surface if DS_SOLIDBRUSH
175 // If DS_SOLIDBRUSH, the following fields are undefined and not guaranteed to
176 // have been allocated!
178 BYTE Format
; // BMF_*, BMF_PHYSDEVICE
179 BYTE jReserved1
; // Reserved
180 BYTE jReserved2
; // Reserved
181 PPDEV ppdev
; // Pointer to associated PDEV
182 SIZEL sizeSurf
; // Size of the surface
183 ULONG NextScan
; // Offset from scan "n" to "n+1"
184 ULONG NextPlane
; // Offset from plane "n" to "n+1"
185 PVOID Scan0
; // Pointer to scan 0 of bitmap
186 // (actual address of start of bank, for banked VGA surface)
187 PVOID StartBmp
; // Pointer to start of bitmap
188 PVOID Conv
; // Pointer to DIB/Planer conversion buffer
190 // Banking variables; used only for banked VGA surfaces
192 PVIDEO_BANK_SELECT BankSelectInfo
;
193 ULONG Bank2RWSkip
; // Offset from one bank index to next to make two 32K banks appear to be
194 // one seamless 64K bank
195 PFN pfnBankSwitchCode
;
196 VIDEO_BANK_TYPE BankingType
;
197 ULONG BitmapSize
; // Length of bitmap if there were no banking, in CPU addressable bytes
198 ULONG PtrBankScan
; // Last scan line in pointer work bank
199 RECTL WindowClip1
; // Single-window banking clip rect
200 RECTL WindowClip2
[2]; // Double-window banking clip rects for
202 ULONG WindowBank
[2]; // Current banks mapped into windows
203 // 0 & 1 (used in 2 window mode only)
204 PBANK_INFO BankInfo
; // Pointer to array of bank clip info
205 ULONG BankInfoLength
; // Length of pbiBankInfo, in entries
206 PBANK_INFO BankInfo2RW
; // Same as above, but for 2RW window
207 ULONG BankInfo2RWLength
; // case
208 PFN_BankControl pfnBankControl
; // Pointer to bank control function
209 PFN_BankControl pfnBankControl2Window
; // Pointer to double-window bank
211 PVOID BitmapStart
; // Single-window bitmap start pointer (adjusted as
212 // necessary to make window map in at proper offset)
213 PVOID BitmapStart2Window
[2]; // Double-window window 0 and 1 bitmap start
214 PVOID BankBufferPlane0
; // Pointer to temp buffer capable of
215 // storing one full bank for plane 0 for 1
216 // R/W case; capable of storing one full
217 // bank height of edge bytes for all four
218 // planes for the 1R/1W case. Also used to
219 // point to text building buffer in all
220 // cases. This is the pointer used to
221 // dealloc bank working storage for all
224 // The following 3 pointers used by 1 R/W banked devices
225 PVOID BankBufferPlane1
; // Like above, but for plane 1
226 PVOID BankBufferPlane2
; // Like above, but for plane 2
227 PVOID BankBufferPlane3
; // Like above, but for plane 3
228 ULONG TempBufferSize
; // Full size of temp buffer pointed to
229 // by pvBankBufferPlane0
231 ULONG ajBits
[1]; // Bits will start here for device bitmaps
232 PSAVED_SCREEN_BITS ssbList
; // Pointer to start of linked list of
233 // saved screen bit blocks
234 } DEVSURF
, *PDEVSURF
;
236 typedef VOID (*PFN_ScreenToScreenBlt
)(PDEVSURF
, PRECTL
, PPOINTL
, INT
);
238 // BMF_PHYSDEVICE format type
240 #define BMF_PHYSDEVICE 0xFF
243 // Identifiers used in debugging (DEVSURF.ident)
245 #define PDEV_IDENT ('V' + ('P' << 8) + ('D' << 16) + ('V' << 24))
246 #define DEVSURF_IDENT ('V' + ('S' << 8) + ('R' << 16) + ('F' << 24))
248 BOOL
InitVGA(PPDEV ppdev
, BOOL bFirst
); // screen.c: initialize VGA mode
249 BOOL
DeinitVGA(PPDEV ppdev
); // screen.c: Free resources allocated in InitVGA
251 #define DRIVER_EXTRA_SIZE 0
252 #define ALLOC_TAG TAG('D', 'v', 'g', 'a') // Dvga tag
253 #define DLL_NAME L"vga" // DLL name in Unicode
255 #define MAX_SCAN_WIDTH 2048 // pixels
256 #define DRIVER_OFFSCREEN_REFRESHED 0x04L // if not set, don't use offscreen memory
257 #define PLANAR_PELS_PER_CPU_ADDRESS 8
258 #define PACKED_PELS_PER_CPU_ADDRESS 2
261 SURFOBJ
*Dest
, SURFOBJ
*Source
, SURFOBJ
*Mask
, XLATEOBJ
*ColorTranslation
,
262 RECTL
*DestRect
, POINTL
*SourcePoint
);
265 VGADDI_BltFromSavedScreenBits(ULONG DestX
,
267 PSAVED_SCREEN_BITS Src
,
271 VGADDI_BltToSavedScreenBits(PSAVED_SCREEN_BITS Dest
,
277 VGADDI_FreeSavedScreenBits(PSAVED_SCREEN_BITS SavedBits
);
279 VGADDI_AllocSavedScreenBits(ULONG Size
);
281 VGADDI_InitializeOffScreenMem(ULONG Start
, ULONG Length
);
283 BOOL
InitPointer(PPDEV ppdev
);
284 DWORD
getAvailableModes(HANDLE Driver
,
285 PVIDEO_MODE_INFORMATION
*modeInformation
,
289 vgaReadScan(int x
, int y
, int w
, void *b
);
292 vgaWriteScan(int x
, int y
, int w
, void *b
);
294 #endif /* _VGADDI_H_ */