Added Finnish keyboard layout.
[wine/hacks.git] / graphics / dispdib.c
blobf3820732b02f9adb3830e828426d1f3b3b8dd31a
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 static int dispdib_multi = 0;
16 static WORD DISPDIB_Begin(WORD wFlags)
18 unsigned Xres,Yres,Depth;
20 switch(wFlags&DISPLAYDIB_MODE) {
21 case DISPLAYDIB_MODE_DEFAULT:
22 /* FIXME: is this supposed to autodetect? */
23 case DISPLAYDIB_MODE_320x200x8:
24 Xres=320; Yres=200; Depth=8; break;
25 case DISPLAYDIB_MODE_320x240x8:
26 Xres=320; Yres=240; Depth=8; break;
27 default:
28 return DISPLAYDIB_NOTSUPPORTED;
30 /* more or less dummy calls to Death/Resurrection, for completeness */
31 /* FIXME: what arguments should they get? */
32 Death16(0);
33 if (VGA_SetMode(Xres,Yres,Depth)) {
34 Resurrection16(0,0,0,0,0,0,0);
35 return DISPLAYDIB_NOTSUPPORTED;
37 return DISPLAYDIB_NOERROR;
40 static void DISPDIB_End(void)
42 Resurrection16(0,0,0,0,0,0,0); /* FIXME: arguments */
43 VGA_Exit();
46 static void DISPDIB_Palette(LPBITMAPINFO lpbi)
48 VGA_SetQuadPalette(lpbi->bmiColors,0,256);
51 static void DISPDIB_Show(LPBITMAPINFOHEADER lpbi,LPSTR lpBits,WORD uFlags)
53 int Xofs,Yofs,Width=lpbi->biWidth,Height=lpbi->biHeight,Delta;
54 unsigned Pitch=(Width+3)&~3,sPitch,sWidth,sHeight;
55 LPSTR surf = DOSMEM_MapDosToLinear(0xa0000);
57 if (VGA_GetMode(&sHeight,&sWidth,NULL)) return;
58 sPitch=320;
60 Delta=(Height<0)*2-1;
61 Height*=-Delta; Pitch*=Delta;
63 if (uFlags&DISPLAYDIB_NOCENTER) {
64 Xofs=0; Yofs=0;
65 } else {
66 Xofs=(sWidth-Width)/2;
67 Yofs=(sHeight-Height)/2;
69 surf += (Yofs*sPitch)+Xofs;
70 if (Pitch<0) lpBits-=Pitch*(Height-1);
71 for (; Height; Height--,lpBits+=Pitch,surf+=sPitch) {
72 memcpy(surf,lpBits,Width);
75 VGA_Poll(0);
78 /*********************************************************************
79 * DisplayDib (DISPDIB.1)
81 * Disables GDI and takes over the VGA screen to show DIBs in full screen.
83 * FLAGS
85 * DISPLAYDIB_NOPALETTE: don't change palette
86 * DISPLAYDIB_NOCENTER: don't center bitmap
87 * DISPLAYDIB_NOWAIT: don't wait (for keypress) before returning
88 * DISPLAYDIB_BEGIN: start of multiple calls (does not restore the screen)
89 * DISPLAYDIB_END: end of multiple calls (restores the screen)
90 * DISPLAYDIB_MODE_DEFAULT: default display mode
91 * DISPLAYDIB_MODE_320x200x8: Standard VGA 320x200 256 colors
92 * DISPLAYDIB_MODE_320x240x8: Tweaked VGA 320x240 256 colors
94 * RETURNS
96 * DISPLAYDIB_NOERROR: success
97 * DISPLAYDIB_NOTSUPPORTED: function not supported
98 * DISPLAYDIB_INVALIDDIB: null or invalid DIB header
99 * DISPLAYDIB_INVALIDFORMAT: invalid DIB format
100 * DISPLAYDIB_INVALIDTASK: not called from current task
102 * BUGS
104 * Waiting for keypresses is not implemented.
106 WORD WINAPI DisplayDib(
107 LPBITMAPINFO lpbi, /* DIB header with resolution and palette */
108 LPSTR lpBits, /* Bitmap bits to show */
109 WORD wFlags
112 WORD ret;
114 if (wFlags&DISPLAYDIB_END) {
115 if (dispdib_multi) DISPDIB_End();
116 dispdib_multi = 0;
117 return DISPLAYDIB_NOERROR;
119 if (!dispdib_multi) {
120 ret=DISPDIB_Begin(wFlags);
121 if (ret) return ret;
123 if (wFlags&DISPLAYDIB_BEGIN) dispdib_multi = 1;
124 if (!(wFlags&DISPLAYDIB_NOPALETTE)) {
125 DISPDIB_Palette(lpbi);
127 /* FIXME: not sure if it's valid to draw images in DISPLAYDIB_BEGIN, so... */
128 if (lpBits) {
129 DISPDIB_Show(&(lpbi->bmiHeader),lpBits,wFlags);
131 if (!(wFlags&DISPLAYDIB_NOWAIT)) {
132 FIXME(ddraw,"wait not implemented\n");
134 if (!dispdib_multi) DISPDIB_End();
135 return DISPLAYDIB_NOERROR;