Cleanup the API docs. Few indentation/formatting fixes.
[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 "windef.h"
24 #include "wownt32.h"
25 #include "gdi.h"
26 #include "wine/wingdi16.h"
27 #include "wine/debug.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(wing);
30
31 /*************************************************************************
32  * WING {WING}
33  *
34  * The Windows Game dll provides a number of functions designed to allow
35  * programmers to bypass Gdi and write directly to video memory. The intention
36  * was to bolster the use of Windows as a gaming platform and remove the
37  * need for Dos based games using 32 bit Dos extenders.
38  *
39  * This initial approach could not compete with the performance of Dos games
40  * (such as Doom and Warcraft) at the time, and so this dll was eventually
41  * superseded by DirectX. It should not be used by new applications, and is
42  * provided only for compatibility with older Windows programs.
43  */
44
45 typedef enum WING_DITHER_TYPE
46 {
47   WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
48 } WING_DITHER_TYPE;
49
50 /*
51  * WinG DIB bitmaps can be selected into DC and then scribbled upon
52  * by GDI functions. They can also be changed directly. This gives us
53  * three choices
54  *      - use original WinG 16-bit DLL
55  *              requires working 16-bit driver interface
56  *      - implement DIB graphics driver from scratch
57  *              see wing.zip size
58  *      - use shared pixmaps
59  *              won't work with some videocards and/or videomodes
60  * 961208 - AK
61  */
62
63 /***********************************************************************
64  *          WinGCreateDC        (WING.1001)
65  *
66  * Create a new WinG device context.
67  *
68  * PARAMS
69  *  None.
70  *
71  * RETURNS
72  *  Success: A handle to the created device context.
73  *  Failure: A NULL handle.
74  */
75 HDC16 WINAPI WinGCreateDC16(void)
76 {
77     TRACE("(void)\n");
78         return CreateCompatibleDC16(0);
79 }
80
81 /***********************************************************************
82  *  WinGRecommendDIBFormat    (WING.1002)
83  *
84  * Get the recommended format of bitmaps for the current display.
85  *
86  * PARAMS
87  *  bmpi [O] Destination for format information
88  *
89  * RETURNS
90  *  Success: TRUE. bmpi is filled with the best (fastest) bitmap format
91  *  Failure: FALSE, if bmpi is NULL.
92  */
93 BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
94 {
95     static const WCHAR szDisplayW[] = { 'D','I','S','P','L','A','Y','\0' };
96     HDC hdc;
97     TRACE("(%p)\n", bmpi);
98     if (!bmpi)
99         return FALSE;
100
101     hdc = CreateDCW( szDisplayW, NULL, NULL, NULL );
102     bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
103     bmpi->bmiHeader.biWidth = 320;
104     bmpi->bmiHeader.biHeight = -1;
105     bmpi->bmiHeader.biPlanes = 1;
106     bmpi->bmiHeader.biBitCount = 8;
107     bmpi->bmiHeader.biCompression = BI_RGB;
108     bmpi->bmiHeader.biSizeImage = 0;
109     bmpi->bmiHeader.biXPelsPerMeter = 0;
110     bmpi->bmiHeader.biYPelsPerMeter = 0;
111     bmpi->bmiHeader.biClrUsed = 0;
112     bmpi->bmiHeader.biClrImportant = 0;
113     DeleteDC(hdc);
114     return TRUE;
115 }
116
117 /***********************************************************************
118  *        WinGCreateBitmap    (WING.1003)
119  *
120  * Create a new WinG bitmap.
121  *
122  * PARAMS
123  *  hdc  [I] WinG device context
124  *  bmpi [I] Information about the bitmap
125  *  bits [I] Location of the bitmap image data
126  *
127  * RETURNS
128  *  Success: A handle to the created bitmap.
129  *  Failure: A NULL handle.
130  */
131 HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
132                                     SEGPTR *bits)
133 {
134     TRACE("(%d,%p,%p)\n", hdc, bmpi, bits);
135     TRACE(": create %ldx%ldx%d bitmap\n", bmpi->bmiHeader.biWidth,
136           bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
137     return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
138 }
139
140 /***********************************************************************
141  *  WinGGetDIBPointer   (WING.1004)
142  */
143 SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
144 {
145     BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( HBITMAP_32(hWinGBitmap),
146                                                   BITMAP_MAGIC );
147     SEGPTR res = 0;
148
149     TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
150     if (!bmp) return 0;
151
152     if (bmpi) FIXME(": Todo - implement setting BITMAPINFO\n");
153
154     res = bmp->segptr_bits;
155     GDI_ReleaseObj( HBITMAP_32(hWinGBitmap) );
156     return res;
157 }
158
159 /***********************************************************************
160  *  WinGSetDIBColorTable   (WING.1006)
161  *
162  * Set all or part of the color table for a WinG device context.
163  *
164  * PARAMS
165  *  hdc    [I] WinG device context
166  *  start  [I] Start color
167  *  num    [I] Number of entries to set
168  *  colors [I] Array of color data
169  *
170  * RETURNS
171  *  The number of entries set.
172  */
173 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
174                                      RGBQUAD *colors)
175 {
176     TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
177     return SetDIBColorTable16(hdc, start, num, colors);
178 }
179
180 /***********************************************************************
181  *  WinGGetDIBColorTable   (WING.1005)
182  *
183  * Get all or part of the color table for a WinG device context.
184  *
185  * PARAMS
186  *  hdc    [I] WinG device context
187  *  start  [I] Start color
188  *  num    [I] Number of entries to set
189  *  colors [O] Destination for the array of color data
190  *
191  * RETURNS
192  *  The number of entries retrieved.
193  */
194 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
195                                      RGBQUAD *colors)
196 {
197     TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
198     return GetDIBColorTable16(hdc, start, num, colors);
199 }
200
201 /***********************************************************************
202  *  WinGCreateHalfTonePalette   (WING.1007)
203  *
204  * Create a half tone palette.
205  *
206  * PARAMS
207  *  None.
208  *
209  * RETURNS
210  *  Success: A handle to the created palette.
211  *  Failure: A NULL handle.
212  */
213 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
214 {
215     HDC16 hdc = CreateCompatibleDC16(0);
216     HPALETTE16 ret = CreateHalftonePalette16(hdc);
217     TRACE("(void)\n");
218     DeleteDC16(hdc);
219     return ret;
220 }
221
222 /***********************************************************************
223  *  WinGCreateHalfToneBrush   (WING.1008)
224  *
225  * Create a half tone brush for a WinG device context.
226  *
227  * PARAMS
228  *  winDC [I] WinG device context
229  *  col   [I] Color
230  *  type  [I] Desired dithering type.
231  *
232  * RETURNS
233  *  Success: A handle to the created brush.
234  *  Failure: A NULL handle.
235  */
236 HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
237                                             WING_DITHER_TYPE type)
238 {
239     TRACE("(%d,%ld,%d)\n", winDC, col, type);
240     return CreateSolidBrush16(col);
241 }
242
243 /***********************************************************************
244  *  WinGStretchBlt   (WING.1009)
245  *
246  * See StretchBlt16.
247  */
248 BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
249                                INT16 widDest, INT16 heiDest,
250                                HDC16 srcDC, INT16 xSrc, INT16 ySrc,
251                                INT16 widSrc, INT16 heiSrc)
252 {
253     BOOL16 retval;
254     TRACE("(%d,%d,...)\n", destDC, srcDC);
255     SetStretchBltMode16 ( destDC, COLORONCOLOR );
256     retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
257                         xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
258     SetStretchBltMode16 ( destDC, BLACKONWHITE );
259     return retval;
260 }
261
262 /***********************************************************************
263  *  WinGBitBlt   (WING.1010)
264  *
265  * See BitBlt16.
266  */
267 BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
268                            INT16 widDest, INT16 heiDest, HDC16 srcDC,
269                            INT16 xSrc, INT16 ySrc)
270 {
271     TRACE("(%d,%d,...)\n", destDC, srcDC);
272     return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
273                     xSrc, ySrc, SRCCOPY);
274 }