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