wing.c 8.07 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1
/*
Alexandre Julliard's avatar
Alexandre Julliard committed
2
 * WinG support
Alexandre Julliard's avatar
Alexandre Julliard committed
3
 *
4 5 6 7 8 9 10 11 12 13 14 15 16 17
 * Copyright (C) Robert Pouliot <krynos@clic.net>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Alexandre Julliard's avatar
Alexandre Julliard committed
19 20
 */

21 22
#include "config.h"

23 24
#include <stdarg.h>

25
#include "windef.h"
26 27
#include "winbase.h"
#include "wingdi.h"
Michael Stefaniuc's avatar
Michael Stefaniuc committed
28
#include "wownt32.h"
29
#include "gdi_private.h"
30
#include "wine/wingdi16.h"
31
#include "wine/debug.h"
32

33
WINE_DEFAULT_DEBUG_CHANNEL(wing);
34

Jon Griffiths's avatar
Jon Griffiths committed
35 36 37 38 39 40 41 42 43 44
/*************************************************************************
 * WING {WING}
 *
 * The Windows Game dll provides a number of functions designed to allow
 * programmers to bypass Gdi and write directly to video memory. The intention
 * was to bolster the use of Windows as a gaming platform and remove the
 * need for Dos based games using 32 bit Dos extenders.
 *
 * This initial approach could not compete with the performance of Dos games
 * (such as Doom and Warcraft) at the time, and so this dll was eventually
Francois Gouget's avatar
Francois Gouget committed
45 46
 * superseded by DirectX. It should not be used by new applications, and is
 * provided only for compatibility with older Windows programs.
Jon Griffiths's avatar
Jon Griffiths committed
47
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
48

Alexandre Julliard's avatar
Alexandre Julliard committed
49 50 51 52 53
typedef enum WING_DITHER_TYPE
{
  WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
} WING_DITHER_TYPE;

54
/*
Alexandre Julliard's avatar
Alexandre Julliard committed
55
 * WinG DIB bitmaps can be selected into DC and then scribbled upon
56 57
 * by GDI functions. They can also be changed directly. This gives us
 * three choices
Alexandre Julliard's avatar
Alexandre Julliard committed
58 59 60 61 62 63 64 65 66
 *	- use original WinG 16-bit DLL
 *		requires working 16-bit driver interface
 * 	- implement DIB graphics driver from scratch
 *		see wing.zip size
 *	- use shared pixmaps
 *		won't work with some videocards and/or videomodes
 * 961208 - AK
 */

Alexandre Julliard's avatar
Alexandre Julliard committed
67
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
68
 *          WinGCreateDC	(WING.1001)
Jon Griffiths's avatar
Jon Griffiths committed
69 70 71 72 73 74 75 76 77
 *
 * Create a new WinG device context.
 *
 * PARAMS
 *  None.
 *
 * RETURNS
 *  Success: A handle to the created device context.
 *  Failure: A NULL handle.
Alexandre Julliard's avatar
Alexandre Julliard committed
78
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
79
HDC16 WINAPI WinGCreateDC16(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
80
{
81
    TRACE("(void)\n");
Alexandre Julliard's avatar
Alexandre Julliard committed
82
	return CreateCompatibleDC16(0);
Alexandre Julliard's avatar
Alexandre Julliard committed
83
}
Alexandre Julliard's avatar
Alexandre Julliard committed
84 85

/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
86
 *  WinGRecommendDIBFormat    (WING.1002)
Jon Griffiths's avatar
Jon Griffiths committed
87 88 89 90 91 92 93 94 95
 *
 * Get the recommended format of bitmaps for the current display.
 *
 * PARAMS
 *  bmpi [O] Destination for format information
 *
 * RETURNS
 *  Success: TRUE. bmpi is filled with the best (fastest) bitmap format
 *  Failure: FALSE, if bmpi is NULL.
Alexandre Julliard's avatar
Alexandre Julliard committed
96
 */
Brad Pepers's avatar
Brad Pepers committed
97
BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
Alexandre Julliard's avatar
Alexandre Julliard committed
98
{
99
    TRACE("(%p)\n", bmpi);
100

Brad Pepers's avatar
Brad Pepers committed
101 102 103 104 105 106
    if (!bmpi)
	return FALSE;

    bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmpi->bmiHeader.biWidth = 320;
    bmpi->bmiHeader.biHeight = -1;
107 108
    bmpi->bmiHeader.biPlanes = 1;
    bmpi->bmiHeader.biBitCount = 8;
Brad Pepers's avatar
Brad Pepers committed
109 110 111 112 113 114
    bmpi->bmiHeader.biCompression = BI_RGB;
    bmpi->bmiHeader.biSizeImage = 0;
    bmpi->bmiHeader.biXPelsPerMeter = 0;
    bmpi->bmiHeader.biYPelsPerMeter = 0;
    bmpi->bmiHeader.biClrUsed = 0;
    bmpi->bmiHeader.biClrImportant = 0;
115

Alexandre Julliard's avatar
Alexandre Julliard committed
116
    return TRUE;
117
}
Alexandre Julliard's avatar
Alexandre Julliard committed
118 119

/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
120
 *        WinGCreateBitmap    (WING.1003)
Jon Griffiths's avatar
Jon Griffiths committed
121 122 123 124 125 126 127 128 129 130 131
 *
 * Create a new WinG bitmap.
 *
 * PARAMS
 *  hdc  [I] WinG device context
 *  bmpi [I] Information about the bitmap
 *  bits [I] Location of the bitmap image data
 *
 * RETURNS
 *  Success: A handle to the created bitmap.
 *  Failure: A NULL handle.
Alexandre Julliard's avatar
Alexandre Julliard committed
132
 */
Brad Pepers's avatar
Brad Pepers committed
133 134
HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
                                    SEGPTR *bits)
Alexandre Julliard's avatar
Alexandre Julliard committed
135
{
136
    TRACE("(%d,%p,%p)\n", hdc, bmpi, bits);
137
    TRACE(": create %dx%dx%d bitmap\n", bmpi->bmiHeader.biWidth,
Brad Pepers's avatar
Brad Pepers committed
138 139
	  bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
    return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
140
}
Alexandre Julliard's avatar
Alexandre Julliard committed
141

Alexandre Julliard's avatar
Alexandre Julliard committed
142
/***********************************************************************
Alexandre Julliard's avatar
Alexandre Julliard committed
143
 *  WinGGetDIBPointer   (WING.1004)
Alexandre Julliard's avatar
Alexandre Julliard committed
144
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
145
SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
Alexandre Julliard's avatar
Alexandre Julliard committed
146
{
Michael Stefaniuc's avatar
Michael Stefaniuc committed
147 148
    BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( HBITMAP_32(hWinGBitmap),
						  BITMAP_MAGIC );
149
    SEGPTR res = 0;
Alexandre Julliard's avatar
Alexandre Julliard committed
150

151
    TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
152
    if (!bmp) return 0;
Brad Pepers's avatar
Brad Pepers committed
153

154
    if (bmpi) FIXME(": Todo - implement setting BITMAPINFO\n");
Brad Pepers's avatar
Brad Pepers committed
155

156
    res = bmp->segptr_bits;
Michael Stefaniuc's avatar
Michael Stefaniuc committed
157
    GDI_ReleaseObj( HBITMAP_32(hWinGBitmap) );
158
    return res;
Alexandre Julliard's avatar
Alexandre Julliard committed
159 160 161
}

/***********************************************************************
162
 *  WinGSetDIBColorTable   (WING.1006)
Jon Griffiths's avatar
Jon Griffiths committed
163 164 165 166 167 168 169 170 171 172 173
 *
 * Set all or part of the color table for a WinG device context.
 *
 * PARAMS
 *  hdc    [I] WinG device context
 *  start  [I] Start color
 *  num    [I] Number of entries to set
 *  colors [I] Array of color data
 *
 * RETURNS
 *  The number of entries set.
Alexandre Julliard's avatar
Alexandre Julliard committed
174
 */
Brad Pepers's avatar
Brad Pepers committed
175 176
UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
                                     RGBQUAD *colors)
Alexandre Julliard's avatar
Alexandre Julliard committed
177
{
178
    TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
Brad Pepers's avatar
Brad Pepers committed
179
    return SetDIBColorTable16(hdc, start, num, colors);
Alexandre Julliard's avatar
Alexandre Julliard committed
180 181 182
}

/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
183
 *  WinGGetDIBColorTable   (WING.1005)
Jon Griffiths's avatar
Jon Griffiths committed
184 185 186 187 188 189 190 191 192 193 194
 *
 * Get all or part of the color table for a WinG device context.
 *
 * PARAMS
 *  hdc    [I] WinG device context
 *  start  [I] Start color
 *  num    [I] Number of entries to set
 *  colors [O] Destination for the array of color data
 *
 * RETURNS
 *  The number of entries retrieved.
Alexandre Julliard's avatar
Alexandre Julliard committed
195
 */
Brad Pepers's avatar
Brad Pepers committed
196 197
UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
				     RGBQUAD *colors)
Alexandre Julliard's avatar
Alexandre Julliard committed
198
{
199
    TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
Brad Pepers's avatar
Brad Pepers committed
200
    return GetDIBColorTable16(hdc, start, num, colors);
Alexandre Julliard's avatar
Alexandre Julliard committed
201 202
}

Alexandre Julliard's avatar
Alexandre Julliard committed
203
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
204
 *  WinGCreateHalfTonePalette   (WING.1007)
Jon Griffiths's avatar
Jon Griffiths committed
205 206 207 208 209 210 211 212 213
 *
 * Create a half tone palette.
 *
 * PARAMS
 *  None.
 *
 * RETURNS
 *  Success: A handle to the created palette.
 *  Failure: A NULL handle.
Alexandre Julliard's avatar
Alexandre Julliard committed
214
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
215
HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
Alexandre Julliard's avatar
Alexandre Julliard committed
216
{
Michael Stefaniuc's avatar
Michael Stefaniuc committed
217
    HDC16 hdc = CreateCompatibleDC16(0);
218
    HPALETTE16 ret = CreateHalftonePalette16(hdc);
219
    TRACE("(void)\n");
Michael Stefaniuc's avatar
Michael Stefaniuc committed
220
    DeleteDC16(hdc);
221
    return ret;
Alexandre Julliard's avatar
Alexandre Julliard committed
222 223 224
}

/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
225
 *  WinGCreateHalfToneBrush   (WING.1008)
Jon Griffiths's avatar
Jon Griffiths committed
226 227 228 229 230 231 232 233 234 235 236
 *
 * Create a half tone brush for a WinG device context.
 *
 * PARAMS
 *  winDC [I] WinG device context
 *  col   [I] Color
 *  type  [I] Desired dithering type.
 *
 * RETURNS
 *  Success: A handle to the created brush.
 *  Failure: A NULL handle.
Alexandre Julliard's avatar
Alexandre Julliard committed
237
 */
Brad Pepers's avatar
Brad Pepers committed
238
HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
Alexandre Julliard's avatar
Alexandre Julliard committed
239
                                            WING_DITHER_TYPE type)
Alexandre Julliard's avatar
Alexandre Julliard committed
240
{
241
    TRACE("(%d,%d,%d)\n", winDC, col, type);
Brad Pepers's avatar
Brad Pepers committed
242
    return CreateSolidBrush16(col);
Alexandre Julliard's avatar
Alexandre Julliard committed
243 244
}

Alexandre Julliard's avatar
Alexandre Julliard committed
245
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
246
 *  WinGStretchBlt   (WING.1009)
Jon Griffiths's avatar
Jon Griffiths committed
247 248
 *
 * See StretchBlt16.
Alexandre Julliard's avatar
Alexandre Julliard committed
249
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
250 251 252 253
BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
                               INT16 widDest, INT16 heiDest,
                               HDC16 srcDC, INT16 xSrc, INT16 ySrc,
                               INT16 widSrc, INT16 heiSrc)
Alexandre Julliard's avatar
Alexandre Julliard committed
254
{
Peter Ganten's avatar
Peter Ganten committed
255
    BOOL16 retval;
256
    TRACE("(%d,%d,...)\n", destDC, srcDC);
Peter Ganten's avatar
Peter Ganten committed
257 258
    SetStretchBltMode16 ( destDC, COLORONCOLOR );
    retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
Brad Pepers's avatar
Brad Pepers committed
259
			xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
Peter Ganten's avatar
Peter Ganten committed
260 261
    SetStretchBltMode16 ( destDC, BLACKONWHITE );
    return retval;
Alexandre Julliard's avatar
Alexandre Julliard committed
262 263 264
}

/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
265
 *  WinGBitBlt   (WING.1010)
Jon Griffiths's avatar
Jon Griffiths committed
266 267
 *
 * See BitBlt16.
Alexandre Julliard's avatar
Alexandre Julliard committed
268
 */
Alexandre Julliard's avatar
Alexandre Julliard committed
269 270 271
BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
                           INT16 widDest, INT16 heiDest, HDC16 srcDC,
                           INT16 xSrc, INT16 ySrc)
Alexandre Julliard's avatar
Alexandre Julliard committed
272
{
273
    TRACE("(%d,%d,...)\n", destDC, srcDC);
Brad Pepers's avatar
Brad Pepers committed
274 275
    return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
		    xSrc, ySrc, SRCCOPY);
Alexandre Julliard's avatar
Alexandre Julliard committed
276
}