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 /* more or less dummy calls to Death/Resurrection, for completeness */
32 /* FIXME: what arguments should they get? */
34 if (VGA_SetMode(Xres,Yres,Depth)) {
35 Resurrection(0,0,0,0,0,0,0);
36 return DISPLAYDIB_NOTSUPPORTED;
38 return DISPLAYDIB_NOERROR;
41 static void DISPDIB_End(void)
43 Resurrection(0,0,0,0,0,0,0); /* FIXME: arguments */
47 static void DISPDIB_Palette(LPBITMAPINFO lpbi)
49 VGA_SetQuadPalette(lpbi->bmiColors,0,256);
52 static void DISPDIB_Show(LPBITMAPINFOHEADER lpbi,LPSTR lpBits,WORD uFlags)
54 int Xofs,Yofs,Width=lpbi->biWidth,Height=lpbi->biHeight,Delta;
55 unsigned Pitch=(Width+3)&~3,sPitch,sWidth,sHeight;
56 LPSTR surf = DOSMEM_MapDosToLinear(0xa0000);
58 if (VGA_GetMode(&sHeight,&sWidth,NULL)) return;
62 Height*=-Delta; Pitch*=Delta;
64 if (uFlags&DISPLAYDIB_NOCENTER) {
67 Xofs=(sWidth-Width)/2;
68 Yofs=(sHeight-Height)/2;
70 surf += (Yofs*sPitch)+Xofs;
71 if (Pitch<0) lpBits-=Pitch*(Height-1);
72 for (; Height; Height--,lpBits+=Pitch,surf+=sPitch) {
73 memcpy(surf,lpBits,Width);
79 /*********************************************************************
80 * DisplayDib (DISPDIB.1)
82 * Disables GDI and takes over the VGA screen to show DIBs in full screen.
86 * DISPLAYDIB_NOPALETTE: don't change palette
87 * DISPLAYDIB_NOCENTER: don't center bitmap
88 * DISPLAYDIB_NOWAIT: don't wait (for keypress) before returning
89 * DISPLAYDIB_BEGIN: start of multiple calls (does not restore the screen)
90 * DISPLAYDIB_END: end of multiple calls (restores the screen)
91 * DISPLAYDIB_MODE_DEFAULT: default display mode
92 * DISPLAYDIB_MODE_320x200x8: Standard VGA 320x200 256 colors
93 * DISPLAYDIB_MODE_320x240x8: Tweaked VGA 320x240 256 colors
97 * DISPLAYDIB_NOERROR: success
98 * DISPLAYDIB_NOTSUPPORTED: function not supported
99 * DISPLAYDIB_INVALIDDIB: null or invalid DIB header
100 * DISPLAYDIB_INVALIDFORMAT: invalid DIB format
101 * DISPLAYDIB_INVALIDTASK: not called from current task
105 * Waiting for keypresses is not implemented.
107 WORD WINAPI DisplayDib(
108 LPBITMAPINFO lpbi, /* DIB header with resolution and palette */
109 LPSTR lpBits, /* Bitmap bits to show */
115 if (wFlags&DISPLAYDIB_END) {
116 if (dispdib_multi) DISPDIB_End();
118 return DISPLAYDIB_NOERROR;
120 if (!dispdib_multi) {
121 ret=DISPDIB_Begin(wFlags);
124 if (wFlags&DISPLAYDIB_BEGIN) dispdib_multi = 1;
125 if (!(wFlags&DISPLAYDIB_NOPALETTE)) {
126 DISPDIB_Palette(lpbi);
128 /* FIXME: not sure if it's valid to draw images in DISPLAYDIB_BEGIN, so... */
130 DISPDIB_Show(&(lpbi->bmiHeader),lpBits,wFlags);
132 if (!(wFlags&DISPLAYDIB_NOWAIT)) {
133 FIXME(ddraw,"wait not implemented\n");
135 if (!dispdib_multi) DISPDIB_End();
136 return DISPLAYDIB_NOERROR;