4 * Copyright 1998 Ove Kåven (with some help from Marcus Meissner)
15 static int dispdib_multi
= 0;
17 static WORD
DISPDIB_Begin(WORD wFlags
)
19 unsigned Xres
,Yres
,Depth
;
21 switch(wFlags
&DISPLAYDIB_MODE
) {
22 case DISPLAYDIB_MODE_DEFAULT
:
23 /* FIXME: is this supposed to autodetect? */
24 case DISPLAYDIB_MODE_320x200x8
:
25 Xres
=320; Yres
=200; Depth
=8; break;
26 case DISPLAYDIB_MODE_320x240x8
:
27 Xres
=320; Yres
=240; Depth
=8; break;
29 return DISPLAYDIB_NOTSUPPORTED
;
31 if (VGA_SetMode(Xres
,Yres
,Depth
)) return DISPLAYDIB_NOTSUPPORTED
;
32 return DISPLAYDIB_NOERROR
;
35 static void DISPDIB_End(void)
40 static void DISPDIB_Palette(LPBITMAPINFO lpbi
)
42 VGA_SetQuadPalette(lpbi
->bmiColors
,0,256);
45 static void DISPDIB_Show(LPBITMAPINFOHEADER lpbi
,LPSTR lpBits
,WORD uFlags
)
47 int Xofs
,Yofs
,Width
=lpbi
->biWidth
,Height
=lpbi
->biHeight
,Delta
;
48 unsigned Pitch
=(Width
+3)&~3,sPitch
,sWidth
,sHeight
;
49 LPSTR surf
= DOSMEM_MapDosToLinear(0xa0000);
51 if (VGA_GetMode(&sHeight
,&sWidth
,NULL
)) return;
55 Height
*=-Delta
; Pitch
*=Delta
;
57 if (uFlags
&DISPLAYDIB_NOCENTER
) {
60 Xofs
=(sWidth
-Width
)/2;
61 Yofs
=(sHeight
-Height
)/2;
63 surf
+= (Yofs
*sPitch
)+Xofs
;
64 if (Pitch
<0) lpBits
-=Pitch
*(Height
-1);
65 for (; Height
; Height
--,lpBits
+=Pitch
,surf
+=sPitch
) {
66 memcpy(surf
,lpBits
,Width
);
72 /*********************************************************************
73 * DisplayDib (DISPDIB.1)
75 * Disables GDI and takes over the VGA screen to show DIBs in full screen.
79 * DISPLAYDIB_NOPALETTE: don't change palette
80 * DISPLAYDIB_NOCENTER: don't center bitmap
81 * DISPLAYDIB_NOWAIT: don't wait (for keypress) before returning
82 * DISPLAYDIB_BEGIN: start of multiple calls (does not restore the screen)
83 * DISPLAYDIB_END: end of multiple calls (restores the screen)
84 * DISPLAYDIB_MODE_DEFAULT: default display mode
85 * DISPLAYDIB_MODE_320x200x8: Standard VGA 320x200 256 colors
86 * DISPLAYDIB_MODE_320x240x8: Tweaked VGA 320x240 256 colors
90 * DISPLAYDIB_NOERROR: success
91 * DISPLAYDIB_NOTSUPPORTED: function not supported
92 * DISPLAYDIB_INVALIDDIB: null or invalid DIB header
93 * DISPLAYDIB_INVALIDFORMAT: invalid DIB format
94 * DISPLAYDIB_INVALIDTASK: not called from current task
98 * Waiting for keypresses is not implemented.
100 WORD WINAPI
DisplayDib(
101 LPBITMAPINFO lpbi
, /* DIB header with resolution and palette */
102 LPSTR lpBits
, /* Bitmap bits to show */
108 if (wFlags
&DISPLAYDIB_END
) {
109 if (dispdib_multi
) DISPDIB_End();
111 return DISPLAYDIB_NOERROR
;
113 if (!dispdib_multi
) {
114 ret
=DISPDIB_Begin(wFlags
);
117 if (wFlags
&DISPLAYDIB_BEGIN
) dispdib_multi
= 1;
118 if (!(wFlags
&DISPLAYDIB_NOPALETTE
)) {
119 DISPDIB_Palette(lpbi
);
121 /* FIXME: not sure if it's valid to draw images in DISPLAYDIB_BEGIN, so... */
123 DISPDIB_Show(&(lpbi
->bmiHeader
),lpBits
,wFlags
);
125 if (!(wFlags
&DISPLAYDIB_NOWAIT
)) {
126 FIXME(ddraw
,"wait not implemented\n");
128 if (!dispdib_multi
) DISPDIB_End();
129 return DISPLAYDIB_NOERROR
;