New debug scheme with explicit debug channels declaration.
[wine/testsucceed.git] / graphics / dispdib.c
blob2b741b81a84f99646842a7905d64aa489b53b189
1 /*
2 * DISPDIB.dll
3 *
4 * Copyright 1998 Ove Kåven (with some help from Marcus Meissner)
6 */
8 #include <string.h>
9 #include "miscemu.h"
10 #include "dispdib.h"
11 #include "vga.h"
12 #include "debug.h"
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;
29 default:
30 return DISPLAYDIB_NOTSUPPORTED;
32 /* more or less dummy calls to Death/Resurrection, for completeness */
33 /* FIXME: what arguments should they get? */
34 Death16(0);
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 */
45 VGA_Exit();
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;
60 sPitch=320;
62 Delta=(Height<0)*2-1;
63 Height*=-Delta; Pitch*=Delta;
65 if (uFlags&DISPLAYDIB_NOCENTER) {
66 Xofs=0; Yofs=0;
67 } else {
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);
77 VGA_Poll(0);
80 /*********************************************************************
81 * DisplayDib (DISPDIB.1)
83 * Disables GDI and takes over the VGA screen to show DIBs in full screen.
85 * FLAGS
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
96 * RETURNS
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
104 * BUGS
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 */
111 WORD wFlags
114 WORD ret;
116 if (wFlags&DISPLAYDIB_END) {
117 if (dispdib_multi) DISPDIB_End();
118 dispdib_multi = 0;
119 return DISPLAYDIB_NOERROR;
121 if (!dispdib_multi) {
122 ret=DISPDIB_Begin(wFlags);
123 if (ret) return ret;
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... */
130 if (lpBits) {
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;