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