Add support for specific EOI PIC command.
[wine] / dlls / gdi / wing.c
1 /*
2  * WinG support
3  *
4  * Copyright (C) Robert Pouliot <krynos@clic.net>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include "wine/winuser16.h"
24 #include "bitmap.h"
25 #include "wine/debug.h"
26 #include "palette.h"
27 #include "windef.h"
28 #include "wownt32.h"
29
30 WINE_DEFAULT_DEBUG_CHANNEL(wing);
31
32
33 typedef enum WING_DITHER_TYPE
34 {
35   WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
36 } WING_DITHER_TYPE;
37
38 /*
39  * WinG DIB bitmaps can be selected into DC and then scribbled upon
40  * by GDI functions. They can also be changed directly. This gives us
41  * three choices
42  *      - use original WinG 16-bit DLL
43  *              requires working 16-bit driver interface
44  *      - implement DIB graphics driver from scratch
45  *              see wing.zip size
46  *      - use shared pixmaps
47  *              won't work with some videocards and/or videomodes
48  * 961208 - AK
49  */
50
51 /***********************************************************************
52  *          WinGCreateDC        (WING.1001)
53  */
54 HDC16 WINAPI WinGCreateDC16(void)
55 {
56     TRACE("(void)\n");
57         return CreateCompatibleDC16(0);
58 }
59
60 /***********************************************************************
61  *  WinGRecommendDIBFormat    (WING.1002)
62  */
63 BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
64 {
65     HDC hdc;
66     TRACE("(%p)\n", bmpi);
67     if (!bmpi)
68         return FALSE;
69
70     hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
71     bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
72     bmpi->bmiHeader.biWidth = 320;
73     bmpi->bmiHeader.biHeight = -1;
74     bmpi->bmiHeader.biPlanes = 1;
75     bmpi->bmiHeader.biBitCount = 8;
76     bmpi->bmiHeader.biCompression = BI_RGB;
77     bmpi->bmiHeader.biSizeImage = 0;
78     bmpi->bmiHeader.biXPelsPerMeter = 0;
79     bmpi->bmiHeader.biYPelsPerMeter = 0;
80     bmpi->bmiHeader.biClrUsed = 0;
81     bmpi->bmiHeader.biClrImportant = 0;
82     DeleteDC(hdc);
83     return TRUE;
84 }
85
86 /***********************************************************************
87  *        WinGCreateBitmap    (WING.1003)
88  */
89 HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
90                                     SEGPTR *bits)
91 {
92     TRACE("(%d,%p,%p)\n", hdc, bmpi, bits);
93     TRACE(": create %ldx%ldx%d bitmap\n", bmpi->bmiHeader.biWidth,
94           bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
95     return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
96 }
97
98 /***********************************************************************
99  *  WinGGetDIBPointer   (WING.1004)
100  */
101 SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
102 {
103     BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( HBITMAP_32(hWinGBitmap),
104                                                   BITMAP_MAGIC );
105     SEGPTR res = 0;
106
107     TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
108     if (!bmp) return 0;
109
110     if (bmpi) FIXME(": Todo - implement setting BITMAPINFO\n");
111
112     res = bmp->segptr_bits;
113     GDI_ReleaseObj( HBITMAP_32(hWinGBitmap) );
114     return res;
115 }
116
117 /***********************************************************************
118  *  WinGSetDIBColorTable   (WING.1006)
119  */
120 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
121                                      RGBQUAD *colors)
122 {
123     TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
124     return SetDIBColorTable16(hdc, start, num, colors);
125 }
126
127 /***********************************************************************
128  *  WinGGetDIBColorTable   (WING.1005)
129  */
130 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
131                                      RGBQUAD *colors)
132 {
133     TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
134     return GetDIBColorTable16(hdc, start, num, colors);
135 }
136
137 /***********************************************************************
138  *  WinGCreateHalfTonePalette   (WING.1007)
139  */
140 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
141 {
142     HDC16 hdc = CreateCompatibleDC16(0);
143     HPALETTE16 ret = CreateHalftonePalette16(hdc);
144     TRACE("(void)\n");
145     DeleteDC16(hdc);
146     return ret;
147 }
148
149 /***********************************************************************
150  *  WinGCreateHalfToneBrush   (WING.1008)
151  */
152 HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
153                                             WING_DITHER_TYPE type)
154 {
155     TRACE("(%d,%ld,%d)\n", winDC, col, type);
156     return CreateSolidBrush16(col);
157 }
158
159 /***********************************************************************
160  *  WinGStretchBlt   (WING.1009)
161  */
162 BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
163                                INT16 widDest, INT16 heiDest,
164                                HDC16 srcDC, INT16 xSrc, INT16 ySrc,
165                                INT16 widSrc, INT16 heiSrc)
166 {
167     BOOL16 retval;
168     TRACE("(%d,%d,...)\n", destDC, srcDC);
169     SetStretchBltMode16 ( destDC, COLORONCOLOR );
170     retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
171                         xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
172     SetStretchBltMode16 ( destDC, BLACKONWHITE );
173     return retval;
174 }
175
176 /***********************************************************************
177  *  WinGBitBlt   (WING.1010)
178  */
179 BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
180                            INT16 widDest, INT16 heiDest, HDC16 srcDC,
181                            INT16 xSrc, INT16 ySrc)
182 {
183     TRACE("(%d,%d,...)\n", destDC, srcDC);
184     return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
185                     xSrc, ySrc, SRCCOPY);
186 }