Use MapLS/UnMapLS instead of SEGPTR_* macros.
[wine/wine-kai.git] / graphics / dispdib.c
blob92b63c9ba5226a8e8cd9df6896310b1caccedafb
1 /*
2 * DISPDIB.dll
3 *
4 * Copyright 1998 Ove Kåven (with some help from Marcus Meissner)
6 */
8 #include <string.h>
9 #include "windef.h"
10 #include "wingdi.h"
11 #include "wine/wingdi16.h"
12 #include "dispdib.h"
13 #include "debugtools.h"
15 DEFAULT_DEBUG_CHANNEL(ddraw);
17 #if 0
19 static int dispdib_multi = 0;
21 static WORD DISPDIB_Begin(WORD wFlags)
23 unsigned Xres,Yres,Depth;
25 switch(wFlags&DISPLAYDIB_MODE) {
26 case DISPLAYDIB_MODE_DEFAULT:
27 /* FIXME: is this supposed to autodetect? */
28 case DISPLAYDIB_MODE_320x200x8:
29 Xres=320; Yres=200; Depth=8; break;
30 case DISPLAYDIB_MODE_320x240x8:
31 Xres=320; Yres=240; Depth=8; break;
32 default:
33 return DISPLAYDIB_NOTSUPPORTED;
35 /* more or less dummy calls to Death/Resurrection, for completeness */
36 /* FIXME: what arguments should they get? */
37 Death16(0);
38 if (VGA_SetMode(Xres,Yres,Depth)) {
39 Resurrection16(0,0,0,0,0,0,0);
40 return DISPLAYDIB_NOTSUPPORTED;
42 return DISPLAYDIB_NOERROR;
45 static void DISPDIB_End(void)
47 Resurrection16(0,0,0,0,0,0,0); /* FIXME: arguments */
48 VGA_Exit();
51 static void DISPDIB_Palette(LPBITMAPINFO lpbi)
53 VGA_SetQuadPalette(lpbi->bmiColors,0,256);
56 static void DISPDIB_Show(LPBITMAPINFOHEADER lpbi,LPSTR lpBits,WORD uFlags)
58 int Xofs,Yofs,Width=lpbi->biWidth,Height=lpbi->biHeight,Delta;
59 int Pitch = (Width + 3) & ~3;
60 unsigned int sPitch,sWidth,sHeight;
61 LPSTR surf = DOSMEM_MapDosToLinear(0xa0000);
63 if (VGA_GetMode(&sHeight,&sWidth,NULL)) return;
64 sPitch=320;
66 Delta=(Height<0)*2-1;
67 Height*=-Delta; Pitch*=Delta;
69 if (uFlags&DISPLAYDIB_NOCENTER) {
70 Xofs=0; Yofs=0;
71 } else {
72 Xofs=(sWidth-Width)/2;
73 Yofs=(sHeight-Height)/2;
75 surf += (Yofs*sPitch)+Xofs;
76 if (Pitch<0) lpBits-=Pitch*(Height-1);
77 for (; Height; Height--,lpBits+=Pitch,surf+=sPitch) {
78 memcpy(surf,lpBits,Width);
81 VGA_Poll(0);
83 #endif
86 /*********************************************************************
87 * DisplayDib (DISPDIB.1)
89 * Disables GDI and takes over the VGA screen to show DIBs in full screen.
91 * FLAGS
93 * DISPLAYDIB_NOPALETTE: don't change palette
94 * DISPLAYDIB_NOCENTER: don't center bitmap
95 * DISPLAYDIB_NOWAIT: don't wait (for keypress) before returning
96 * DISPLAYDIB_BEGIN: start of multiple calls (does not restore the screen)
97 * DISPLAYDIB_END: end of multiple calls (restores the screen)
98 * DISPLAYDIB_MODE_DEFAULT: default display mode
99 * DISPLAYDIB_MODE_320x200x8: Standard VGA 320x200 256 colors
100 * DISPLAYDIB_MODE_320x240x8: Tweaked VGA 320x240 256 colors
102 * RETURNS
104 * DISPLAYDIB_NOERROR: success
105 * DISPLAYDIB_NOTSUPPORTED: function not supported
106 * DISPLAYDIB_INVALIDDIB: null or invalid DIB header
107 * DISPLAYDIB_INVALIDFORMAT: invalid DIB format
108 * DISPLAYDIB_INVALIDTASK: not called from current task
110 * BUGS
112 * Waiting for keypresses is not implemented.
114 WORD WINAPI DisplayDib(
115 LPBITMAPINFO lpbi, /* [in] DIB header with resolution and palette */
116 LPSTR lpBits, /* [in] Bitmap bits to show */
117 WORD wFlags /* [in] */
120 #if 0
121 WORD ret;
123 if (wFlags&DISPLAYDIB_END) {
124 if (dispdib_multi) DISPDIB_End();
125 dispdib_multi = 0;
126 return DISPLAYDIB_NOERROR;
128 if (!dispdib_multi) {
129 ret=DISPDIB_Begin(wFlags);
130 if (ret) return ret;
132 if (wFlags&DISPLAYDIB_BEGIN) dispdib_multi = 1;
133 if (!(wFlags&DISPLAYDIB_NOPALETTE)) {
134 DISPDIB_Palette(lpbi);
136 /* FIXME: not sure if it's valid to draw images in DISPLAYDIB_BEGIN, so... */
137 if (lpBits) {
138 DISPDIB_Show(&(lpbi->bmiHeader),lpBits,wFlags);
140 if (!(wFlags&DISPLAYDIB_NOWAIT)) {
141 FIXME("wait not implemented\n");
143 if (!dispdib_multi) DISPDIB_End();
144 #endif
145 FIXME( "broken, should be rewritten using ddraw\n" );
146 return DISPLAYDIB_NOERROR;