4 * Copyright 1998 Ove Kåven (with some help from Marcus Meissner)
13 #include "wine/wingdi16.h"
15 DEFAULT_DEBUG_CHANNEL(ddraw
)
17 static int dispdib_multi
= 0;
19 static WORD
DISPDIB_Begin(WORD wFlags
)
21 unsigned Xres
,Yres
,Depth
;
23 switch(wFlags
&DISPLAYDIB_MODE
) {
24 case DISPLAYDIB_MODE_DEFAULT
:
25 /* FIXME: is this supposed to autodetect? */
26 case DISPLAYDIB_MODE_320x200x8
:
27 Xres
=320; Yres
=200; Depth
=8; break;
28 case DISPLAYDIB_MODE_320x240x8
:
29 Xres
=320; Yres
=240; Depth
=8; break;
31 return DISPLAYDIB_NOTSUPPORTED
;
33 /* more or less dummy calls to Death/Resurrection, for completeness */
34 /* FIXME: what arguments should they get? */
36 if (VGA_SetMode(Xres
,Yres
,Depth
)) {
37 Resurrection16(0,0,0,0,0,0,0);
38 return DISPLAYDIB_NOTSUPPORTED
;
40 return DISPLAYDIB_NOERROR
;
43 static void DISPDIB_End(void)
45 Resurrection16(0,0,0,0,0,0,0); /* FIXME: arguments */
49 static void DISPDIB_Palette(LPBITMAPINFO lpbi
)
51 VGA_SetQuadPalette(lpbi
->bmiColors
,0,256);
54 static void DISPDIB_Show(LPBITMAPINFOHEADER lpbi
,LPSTR lpBits
,WORD uFlags
)
56 int Xofs
,Yofs
,Width
=lpbi
->biWidth
,Height
=lpbi
->biHeight
,Delta
;
57 unsigned Pitch
=(Width
+3)&~3,sPitch
,sWidth
,sHeight
;
58 LPSTR surf
= DOSMEM_MapDosToLinear(0xa0000);
60 if (VGA_GetMode(&sHeight
,&sWidth
,NULL
)) return;
64 Height
*=-Delta
; Pitch
*=Delta
;
66 if (uFlags
&DISPLAYDIB_NOCENTER
) {
69 Xofs
=(sWidth
-Width
)/2;
70 Yofs
=(sHeight
-Height
)/2;
72 surf
+= (Yofs
*sPitch
)+Xofs
;
73 if (Pitch
<0) lpBits
-=Pitch
*(Height
-1);
74 for (; Height
; Height
--,lpBits
+=Pitch
,surf
+=sPitch
) {
75 memcpy(surf
,lpBits
,Width
);
81 /*********************************************************************
82 * DisplayDib (DISPDIB.1)
84 * Disables GDI and takes over the VGA screen to show DIBs in full screen.
88 * DISPLAYDIB_NOPALETTE: don't change palette
89 * DISPLAYDIB_NOCENTER: don't center bitmap
90 * DISPLAYDIB_NOWAIT: don't wait (for keypress) before returning
91 * DISPLAYDIB_BEGIN: start of multiple calls (does not restore the screen)
92 * DISPLAYDIB_END: end of multiple calls (restores the screen)
93 * DISPLAYDIB_MODE_DEFAULT: default display mode
94 * DISPLAYDIB_MODE_320x200x8: Standard VGA 320x200 256 colors
95 * DISPLAYDIB_MODE_320x240x8: Tweaked VGA 320x240 256 colors
99 * DISPLAYDIB_NOERROR: success
100 * DISPLAYDIB_NOTSUPPORTED: function not supported
101 * DISPLAYDIB_INVALIDDIB: null or invalid DIB header
102 * DISPLAYDIB_INVALIDFORMAT: invalid DIB format
103 * DISPLAYDIB_INVALIDTASK: not called from current task
107 * Waiting for keypresses is not implemented.
109 WORD WINAPI
DisplayDib(
110 LPBITMAPINFO lpbi
, /* DIB header with resolution and palette */
111 LPSTR lpBits
, /* Bitmap bits to show */
117 if (wFlags
&DISPLAYDIB_END
) {
118 if (dispdib_multi
) DISPDIB_End();
120 return DISPLAYDIB_NOERROR
;
122 if (!dispdib_multi
) {
123 ret
=DISPDIB_Begin(wFlags
);
126 if (wFlags
&DISPLAYDIB_BEGIN
) dispdib_multi
= 1;
127 if (!(wFlags
&DISPLAYDIB_NOPALETTE
)) {
128 DISPDIB_Palette(lpbi
);
130 /* FIXME: not sure if it's valid to draw images in DISPLAYDIB_BEGIN, so... */
132 DISPDIB_Show(&(lpbi
->bmiHeader
),lpBits
,wFlags
);
134 if (!(wFlags
&DISPLAYDIB_NOWAIT
)) {
135 FIXME(ddraw
,"wait not implemented\n");
137 if (!dispdib_multi
) DISPDIB_End();
138 return DISPLAYDIB_NOERROR
;