Cleaned up font encoding handling. Added 'Ignore#' option to the
[wine/multimedia.git] / graphics / dispdib.c
blob8432e9f8e1aa1f640a4ea44568cd0af05aa962ea
1 /*
2 * DISPDIB.dll
3 *
4 * Copyright 1998 Ove Kåven (with some help from Marcus Meissner)
6 */
8 #include <string.h>
9 #include "windows.h"
10 #include "miscemu.h"
11 #include "dispdib.h"
12 #include "vga.h"
13 #include "debug.h"
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;
28 default:
29 return DISPLAYDIB_NOTSUPPORTED;
31 if (VGA_SetMode(Xres,Yres,Depth)) return DISPLAYDIB_NOTSUPPORTED;
32 return DISPLAYDIB_NOERROR;
35 static void DISPDIB_End(void)
37 VGA_Exit();
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;
52 sPitch=320;
54 Delta=(Height<0)*2-1;
55 Height*=-Delta; Pitch*=Delta;
57 if (uFlags&DISPLAYDIB_NOCENTER) {
58 Xofs=0; Yofs=0;
59 } else {
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);
69 VGA_Poll(0);
72 /*********************************************************************
73 * DisplayDib (DISPDIB.1)
75 * Disables GDI and takes over the VGA screen to show DIBs in full screen.
77 * FLAGS
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
88 * RETURNS
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
96 * BUGS
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 */
103 WORD wFlags
106 WORD ret;
108 if (wFlags&DISPLAYDIB_END) {
109 if (dispdib_multi) DISPDIB_End();
110 dispdib_multi = 0;
111 return DISPLAYDIB_NOERROR;
113 if (!dispdib_multi) {
114 ret=DISPDIB_Begin(wFlags);
115 if (ret) return ret;
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... */
122 if (lpBits) {
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;