4 * Copyright 1998 Ove Kåven (with some help from Marcus Meissner)
14 static int dispdib_multi
= 0;
16 static WORD
DISPDIB_Begin(WORD wFlags
)
18 unsigned Xres
,Yres
,Depth
;
20 switch(wFlags
&DISPLAYDIB_MODE
) {
21 case DISPLAYDIB_MODE_DEFAULT
:
22 /* FIXME: is this supposed to autodetect? */
23 case DISPLAYDIB_MODE_320x200x8
:
24 Xres
=320; Yres
=200; Depth
=8; break;
25 case DISPLAYDIB_MODE_320x240x8
:
26 Xres
=320; Yres
=240; Depth
=8; break;
28 return DISPLAYDIB_NOTSUPPORTED
;
30 /* more or less dummy calls to Death/Resurrection, for completeness */
31 /* FIXME: what arguments should they get? */
33 if (VGA_SetMode(Xres
,Yres
,Depth
)) {
34 Resurrection16(0,0,0,0,0,0,0);
35 return DISPLAYDIB_NOTSUPPORTED
;
37 return DISPLAYDIB_NOERROR
;
40 static void DISPDIB_End(void)
42 Resurrection16(0,0,0,0,0,0,0); /* FIXME: arguments */
46 static void DISPDIB_Palette(LPBITMAPINFO lpbi
)
48 VGA_SetQuadPalette(lpbi
->bmiColors
,0,256);
51 static void DISPDIB_Show(LPBITMAPINFOHEADER lpbi
,LPSTR lpBits
,WORD uFlags
)
53 int Xofs
,Yofs
,Width
=lpbi
->biWidth
,Height
=lpbi
->biHeight
,Delta
;
54 unsigned Pitch
=(Width
+3)&~3,sPitch
,sWidth
,sHeight
;
55 LPSTR surf
= DOSMEM_MapDosToLinear(0xa0000);
57 if (VGA_GetMode(&sHeight
,&sWidth
,NULL
)) return;
61 Height
*=-Delta
; Pitch
*=Delta
;
63 if (uFlags
&DISPLAYDIB_NOCENTER
) {
66 Xofs
=(sWidth
-Width
)/2;
67 Yofs
=(sHeight
-Height
)/2;
69 surf
+= (Yofs
*sPitch
)+Xofs
;
70 if (Pitch
<0) lpBits
-=Pitch
*(Height
-1);
71 for (; Height
; Height
--,lpBits
+=Pitch
,surf
+=sPitch
) {
72 memcpy(surf
,lpBits
,Width
);
78 /*********************************************************************
79 * DisplayDib (DISPDIB.1)
81 * Disables GDI and takes over the VGA screen to show DIBs in full screen.
85 * DISPLAYDIB_NOPALETTE: don't change palette
86 * DISPLAYDIB_NOCENTER: don't center bitmap
87 * DISPLAYDIB_NOWAIT: don't wait (for keypress) before returning
88 * DISPLAYDIB_BEGIN: start of multiple calls (does not restore the screen)
89 * DISPLAYDIB_END: end of multiple calls (restores the screen)
90 * DISPLAYDIB_MODE_DEFAULT: default display mode
91 * DISPLAYDIB_MODE_320x200x8: Standard VGA 320x200 256 colors
92 * DISPLAYDIB_MODE_320x240x8: Tweaked VGA 320x240 256 colors
96 * DISPLAYDIB_NOERROR: success
97 * DISPLAYDIB_NOTSUPPORTED: function not supported
98 * DISPLAYDIB_INVALIDDIB: null or invalid DIB header
99 * DISPLAYDIB_INVALIDFORMAT: invalid DIB format
100 * DISPLAYDIB_INVALIDTASK: not called from current task
104 * Waiting for keypresses is not implemented.
106 WORD WINAPI
DisplayDib(
107 LPBITMAPINFO lpbi
, /* DIB header with resolution and palette */
108 LPSTR lpBits
, /* Bitmap bits to show */
114 if (wFlags
&DISPLAYDIB_END
) {
115 if (dispdib_multi
) DISPDIB_End();
117 return DISPLAYDIB_NOERROR
;
119 if (!dispdib_multi
) {
120 ret
=DISPDIB_Begin(wFlags
);
123 if (wFlags
&DISPLAYDIB_BEGIN
) dispdib_multi
= 1;
124 if (!(wFlags
&DISPLAYDIB_NOPALETTE
)) {
125 DISPDIB_Palette(lpbi
);
127 /* FIXME: not sure if it's valid to draw images in DISPLAYDIB_BEGIN, so... */
129 DISPDIB_Show(&(lpbi
->bmiHeader
),lpBits
,wFlags
);
131 if (!(wFlags
&DISPLAYDIB_NOWAIT
)) {
132 FIXME(ddraw
,"wait not implemented\n");
134 if (!dispdib_multi
) DISPDIB_End();
135 return DISPLAYDIB_NOERROR
;