This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
/
SDL_dx5video.c
2581 lines (2393 loc) · 87.1 KB
1
2
/*
SDL - Simple DirectMedia Layer
3
Copyright (C) 1997-2006 Sam Lantinga
4
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
9
10
11
12
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
13
Lesser General Public License for more details.
14
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19
Sam Lantinga
20
slouken@libsdl.org
21
*/
22
#include "SDL_config.h"
23
24
25
26
27
28
29
30
31
32
33
#include "directx.h"
/* Not yet in the mingw32 cross-compile headers */
#ifndef CDS_FULLSCREEN
#define CDS_FULLSCREEN 4
#endif
#include "SDL_timer.h"
#include "SDL_events.h"
#include "SDL_syswm.h"
34
35
36
#include "../SDL_sysvideo.h"
#include "../SDL_blit.h"
#include "../SDL_pixels_c.h"
37
#include "SDL_dx5video.h"
38
39
#include "../wincommon/SDL_syswm_c.h"
#include "../wincommon/SDL_sysmouse_c.h"
40
41
#include "SDL_dx5events_c.h"
#include "SDL_dx5yuv_c.h"
42
#include "../wincommon/SDL_wingl_c.h"
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifdef _WIN32_WCE
#define NO_CHANGEDISPLAYSETTINGS
#endif
#ifndef WS_MAXIMIZE
#define WS_MAXIMIZE 0
#endif
#ifndef SWP_NOCOPYBITS
#define SWP_NOCOPYBITS 0
#endif
#ifndef PC_NOCOLLAPSE
#define PC_NOCOLLAPSE 0
#endif
57
58
/* DirectX function pointers for video and events */
59
60
61
62
HRESULT(WINAPI * DDrawCreate) (GUID FAR * lpGUID, LPDIRECTDRAW FAR * lplpDD,
IUnknown FAR * pUnkOuter);
HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion,
LPDIRECTINPUT * ppDI, LPUNKNOWN punkOuter);
63
64
/* This is the rect EnumModes2 uses */
65
66
67
68
69
struct DX5EnumRect
{
SDL_Rect r;
int refreshRate;
struct DX5EnumRect *next;
70
71
72
73
74
75
76
77
78
79
};
static struct DX5EnumRect *enumlists[NUM_MODELISTS];
/*
* Experimentally determined values for c_cfDI* constants used in DirectX 5.0
*/
/* Keyboard */
static DIOBJECTDATAFORMAT KBD_fmt[] = {
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
{&GUID_Key, 0, 0x8000000C, 0x00000000},
{&GUID_Key, 1, 0x8000010C, 0x00000000},
{&GUID_Key, 2, 0x8000020C, 0x00000000},
{&GUID_Key, 3, 0x8000030C, 0x00000000},
{&GUID_Key, 4, 0x8000040C, 0x00000000},
{&GUID_Key, 5, 0x8000050C, 0x00000000},
{&GUID_Key, 6, 0x8000060C, 0x00000000},
{&GUID_Key, 7, 0x8000070C, 0x00000000},
{&GUID_Key, 8, 0x8000080C, 0x00000000},
{&GUID_Key, 9, 0x8000090C, 0x00000000},
{&GUID_Key, 10, 0x80000A0C, 0x00000000},
{&GUID_Key, 11, 0x80000B0C, 0x00000000},
{&GUID_Key, 12, 0x80000C0C, 0x00000000},
{&GUID_Key, 13, 0x80000D0C, 0x00000000},
{&GUID_Key, 14, 0x80000E0C, 0x00000000},
{&GUID_Key, 15, 0x80000F0C, 0x00000000},
{&GUID_Key, 16, 0x8000100C, 0x00000000},
{&GUID_Key, 17, 0x8000110C, 0x00000000},
{&GUID_Key, 18, 0x8000120C, 0x00000000},
{&GUID_Key, 19, 0x8000130C, 0x00000000},
{&GUID_Key, 20, 0x8000140C, 0x00000000},
{&GUID_Key, 21, 0x8000150C, 0x00000000},
{&GUID_Key, 22, 0x8000160C, 0x00000000},
{&GUID_Key, 23, 0x8000170C, 0x00000000},
{&GUID_Key, 24, 0x8000180C, 0x00000000},
{&GUID_Key, 25, 0x8000190C, 0x00000000},
{&GUID_Key, 26, 0x80001A0C, 0x00000000},
{&GUID_Key, 27, 0x80001B0C, 0x00000000},
{&GUID_Key, 28, 0x80001C0C, 0x00000000},
{&GUID_Key, 29, 0x80001D0C, 0x00000000},
{&GUID_Key, 30, 0x80001E0C, 0x00000000},
{&GUID_Key, 31, 0x80001F0C, 0x00000000},
{&GUID_Key, 32, 0x8000200C, 0x00000000},
{&GUID_Key, 33, 0x8000210C, 0x00000000},
{&GUID_Key, 34, 0x8000220C, 0x00000000},
{&GUID_Key, 35, 0x8000230C, 0x00000000},
{&GUID_Key, 36, 0x8000240C, 0x00000000},
{&GUID_Key, 37, 0x8000250C, 0x00000000},
{&GUID_Key, 38, 0x8000260C, 0x00000000},
{&GUID_Key, 39, 0x8000270C, 0x00000000},
{&GUID_Key, 40, 0x8000280C, 0x00000000},
{&GUID_Key, 41, 0x8000290C, 0x00000000},
{&GUID_Key, 42, 0x80002A0C, 0x00000000},
{&GUID_Key, 43, 0x80002B0C, 0x00000000},
{&GUID_Key, 44, 0x80002C0C, 0x00000000},
{&GUID_Key, 45, 0x80002D0C, 0x00000000},
{&GUID_Key, 46, 0x80002E0C, 0x00000000},
{&GUID_Key, 47, 0x80002F0C, 0x00000000},
{&GUID_Key, 48, 0x8000300C, 0x00000000},
{&GUID_Key, 49, 0x8000310C, 0x00000000},
{&GUID_Key, 50, 0x8000320C, 0x00000000},
{&GUID_Key, 51, 0x8000330C, 0x00000000},
{&GUID_Key, 52, 0x8000340C, 0x00000000},
{&GUID_Key, 53, 0x8000350C, 0x00000000},
{&GUID_Key, 54, 0x8000360C, 0x00000000},
{&GUID_Key, 55, 0x8000370C, 0x00000000},
{&GUID_Key, 56, 0x8000380C, 0x00000000},
{&GUID_Key, 57, 0x8000390C, 0x00000000},
{&GUID_Key, 58, 0x80003A0C, 0x00000000},
{&GUID_Key, 59, 0x80003B0C, 0x00000000},
{&GUID_Key, 60, 0x80003C0C, 0x00000000},
{&GUID_Key, 61, 0x80003D0C, 0x00000000},
{&GUID_Key, 62, 0x80003E0C, 0x00000000},
{&GUID_Key, 63, 0x80003F0C, 0x00000000},
{&GUID_Key, 64, 0x8000400C, 0x00000000},
{&GUID_Key, 65, 0x8000410C, 0x00000000},
{&GUID_Key, 66, 0x8000420C, 0x00000000},
{&GUID_Key, 67, 0x8000430C, 0x00000000},
{&GUID_Key, 68, 0x8000440C, 0x00000000},
{&GUID_Key, 69, 0x8000450C, 0x00000000},
{&GUID_Key, 70, 0x8000460C, 0x00000000},
{&GUID_Key, 71, 0x8000470C, 0x00000000},
{&GUID_Key, 72, 0x8000480C, 0x00000000},
{&GUID_Key, 73, 0x8000490C, 0x00000000},
{&GUID_Key, 74, 0x80004A0C, 0x00000000},
{&GUID_Key, 75, 0x80004B0C, 0x00000000},
{&GUID_Key, 76, 0x80004C0C, 0x00000000},
{&GUID_Key, 77, 0x80004D0C, 0x00000000},
{&GUID_Key, 78, 0x80004E0C, 0x00000000},
{&GUID_Key, 79, 0x80004F0C, 0x00000000},
{&GUID_Key, 80, 0x8000500C, 0x00000000},
{&GUID_Key, 81, 0x8000510C, 0x00000000},
{&GUID_Key, 82, 0x8000520C, 0x00000000},
{&GUID_Key, 83, 0x8000530C, 0x00000000},
{&GUID_Key, 84, 0x8000540C, 0x00000000},
{&GUID_Key, 85, 0x8000550C, 0x00000000},
{&GUID_Key, 86, 0x8000560C, 0x00000000},
{&GUID_Key, 87, 0x8000570C, 0x00000000},
{&GUID_Key, 88, 0x8000580C, 0x00000000},
{&GUID_Key, 89, 0x8000590C, 0x00000000},
{&GUID_Key, 90, 0x80005A0C, 0x00000000},
{&GUID_Key, 91, 0x80005B0C, 0x00000000},
{&GUID_Key, 92, 0x80005C0C, 0x00000000},
{&GUID_Key, 93, 0x80005D0C, 0x00000000},
{&GUID_Key, 94, 0x80005E0C, 0x00000000},
{&GUID_Key, 95, 0x80005F0C, 0x00000000},
{&GUID_Key, 96, 0x8000600C, 0x00000000},
{&GUID_Key, 97, 0x8000610C, 0x00000000},
{&GUID_Key, 98, 0x8000620C, 0x00000000},
{&GUID_Key, 99, 0x8000630C, 0x00000000},
{&GUID_Key, 100, 0x8000640C, 0x00000000},
{&GUID_Key, 101, 0x8000650C, 0x00000000},
{&GUID_Key, 102, 0x8000660C, 0x00000000},
{&GUID_Key, 103, 0x8000670C, 0x00000000},
{&GUID_Key, 104, 0x8000680C, 0x00000000},
{&GUID_Key, 105, 0x8000690C, 0x00000000},
{&GUID_Key, 106, 0x80006A0C, 0x00000000},
{&GUID_Key, 107, 0x80006B0C, 0x00000000},
{&GUID_Key, 108, 0x80006C0C, 0x00000000},
{&GUID_Key, 109, 0x80006D0C, 0x00000000},
{&GUID_Key, 110, 0x80006E0C, 0x00000000},
{&GUID_Key, 111, 0x80006F0C, 0x00000000},
{&GUID_Key, 112, 0x8000700C, 0x00000000},
{&GUID_Key, 113, 0x8000710C, 0x00000000},
{&GUID_Key, 114, 0x8000720C, 0x00000000},
{&GUID_Key, 115, 0x8000730C, 0x00000000},
{&GUID_Key, 116, 0x8000740C, 0x00000000},
{&GUID_Key, 117, 0x8000750C, 0x00000000},
{&GUID_Key, 118, 0x8000760C, 0x00000000},
{&GUID_Key, 119, 0x8000770C, 0x00000000},
{&GUID_Key, 120, 0x8000780C, 0x00000000},
{&GUID_Key, 121, 0x8000790C, 0x00000000},
{&GUID_Key, 122, 0x80007A0C, 0x00000000},
{&GUID_Key, 123, 0x80007B0C, 0x00000000},
{&GUID_Key, 124, 0x80007C0C, 0x00000000},
{&GUID_Key, 125, 0x80007D0C, 0x00000000},
{&GUID_Key, 126, 0x80007E0C, 0x00000000},
{&GUID_Key, 127, 0x80007F0C, 0x00000000},
{&GUID_Key, 128, 0x8000800C, 0x00000000},
{&GUID_Key, 129, 0x8000810C, 0x00000000},
{&GUID_Key, 130, 0x8000820C, 0x00000000},
{&GUID_Key, 131, 0x8000830C, 0x00000000},
{&GUID_Key, 132, 0x8000840C, 0x00000000},
{&GUID_Key, 133, 0x8000850C, 0x00000000},
{&GUID_Key, 134, 0x8000860C, 0x00000000},
{&GUID_Key, 135, 0x8000870C, 0x00000000},
{&GUID_Key, 136, 0x8000880C, 0x00000000},
{&GUID_Key, 137, 0x8000890C, 0x00000000},
{&GUID_Key, 138, 0x80008A0C, 0x00000000},
{&GUID_Key, 139, 0x80008B0C, 0x00000000},
{&GUID_Key, 140, 0x80008C0C, 0x00000000},
{&GUID_Key, 141, 0x80008D0C, 0x00000000},
{&GUID_Key, 142, 0x80008E0C, 0x00000000},
{&GUID_Key, 143, 0x80008F0C, 0x00000000},
{&GUID_Key, 144, 0x8000900C, 0x00000000},
{&GUID_Key, 145, 0x8000910C, 0x00000000},
{&GUID_Key, 146, 0x8000920C, 0x00000000},
{&GUID_Key, 147, 0x8000930C, 0x00000000},
{&GUID_Key, 148, 0x8000940C, 0x00000000},
{&GUID_Key, 149, 0x8000950C, 0x00000000},
{&GUID_Key, 150, 0x8000960C, 0x00000000},
{&GUID_Key, 151, 0x8000970C, 0x00000000},
{&GUID_Key, 152, 0x8000980C, 0x00000000},
{&GUID_Key, 153, 0x8000990C, 0x00000000},
{&GUID_Key, 154, 0x80009A0C, 0x00000000},
{&GUID_Key, 155, 0x80009B0C, 0x00000000},
{&GUID_Key, 156, 0x80009C0C, 0x00000000},
{&GUID_Key, 157, 0x80009D0C, 0x00000000},
{&GUID_Key, 158, 0x80009E0C, 0x00000000},
{&GUID_Key, 159, 0x80009F0C, 0x00000000},
{&GUID_Key, 160, 0x8000A00C, 0x00000000},
{&GUID_Key, 161, 0x8000A10C, 0x00000000},
{&GUID_Key, 162, 0x8000A20C, 0x00000000},
{&GUID_Key, 163, 0x8000A30C, 0x00000000},
{&GUID_Key, 164, 0x8000A40C, 0x00000000},
{&GUID_Key, 165, 0x8000A50C, 0x00000000},
{&GUID_Key, 166, 0x8000A60C, 0x00000000},
{&GUID_Key, 167, 0x8000A70C, 0x00000000},
{&GUID_Key, 168, 0x8000A80C, 0x00000000},
{&GUID_Key, 169, 0x8000A90C, 0x00000000},
{&GUID_Key, 170, 0x8000AA0C, 0x00000000},
{&GUID_Key, 171, 0x8000AB0C, 0x00000000},
{&GUID_Key, 172, 0x8000AC0C, 0x00000000},
{&GUID_Key, 173, 0x8000AD0C, 0x00000000},
{&GUID_Key, 174, 0x8000AE0C, 0x00000000},
{&GUID_Key, 175, 0x8000AF0C, 0x00000000},
{&GUID_Key, 176, 0x8000B00C, 0x00000000},
{&GUID_Key, 177, 0x8000B10C, 0x00000000},
{&GUID_Key, 178, 0x8000B20C, 0x00000000},
{&GUID_Key, 179, 0x8000B30C, 0x00000000},
{&GUID_Key, 180, 0x8000B40C, 0x00000000},
{&GUID_Key, 181, 0x8000B50C, 0x00000000},
{&GUID_Key, 182, 0x8000B60C, 0x00000000},
{&GUID_Key, 183, 0x8000B70C, 0x00000000},
{&GUID_Key, 184, 0x8000B80C, 0x00000000},
{&GUID_Key, 185, 0x8000B90C, 0x00000000},
{&GUID_Key, 186, 0x8000BA0C, 0x00000000},
{&GUID_Key, 187, 0x8000BB0C, 0x00000000},
{&GUID_Key, 188, 0x8000BC0C, 0x00000000},
{&GUID_Key, 189, 0x8000BD0C, 0x00000000},
{&GUID_Key, 190, 0x8000BE0C, 0x00000000},
{&GUID_Key, 191, 0x8000BF0C, 0x00000000},
{&GUID_Key, 192, 0x8000C00C, 0x00000000},
{&GUID_Key, 193, 0x8000C10C, 0x00000000},
{&GUID_Key, 194, 0x8000C20C, 0x00000000},
{&GUID_Key, 195, 0x8000C30C, 0x00000000},
{&GUID_Key, 196, 0x8000C40C, 0x00000000},
{&GUID_Key, 197, 0x8000C50C, 0x00000000},
{&GUID_Key, 198, 0x8000C60C, 0x00000000},
{&GUID_Key, 199, 0x8000C70C, 0x00000000},
{&GUID_Key, 200, 0x8000C80C, 0x00000000},
{&GUID_Key, 201, 0x8000C90C, 0x00000000},
{&GUID_Key, 202, 0x8000CA0C, 0x00000000},
{&GUID_Key, 203, 0x8000CB0C, 0x00000000},
{&GUID_Key, 204, 0x8000CC0C, 0x00000000},
{&GUID_Key, 205, 0x8000CD0C, 0x00000000},
{&GUID_Key, 206, 0x8000CE0C, 0x00000000},
{&GUID_Key, 207, 0x8000CF0C, 0x00000000},
{&GUID_Key, 208, 0x8000D00C, 0x00000000},
{&GUID_Key, 209, 0x8000D10C, 0x00000000},
{&GUID_Key, 210, 0x8000D20C, 0x00000000},
{&GUID_Key, 211, 0x8000D30C, 0x00000000},
{&GUID_Key, 212, 0x8000D40C, 0x00000000},
{&GUID_Key, 213, 0x8000D50C, 0x00000000},
{&GUID_Key, 214, 0x8000D60C, 0x00000000},
{&GUID_Key, 215, 0x8000D70C, 0x00000000},
{&GUID_Key, 216, 0x8000D80C, 0x00000000},
{&GUID_Key, 217, 0x8000D90C, 0x00000000},
{&GUID_Key, 218, 0x8000DA0C, 0x00000000},
{&GUID_Key, 219, 0x8000DB0C, 0x00000000},
{&GUID_Key, 220, 0x8000DC0C, 0x00000000},
{&GUID_Key, 221, 0x8000DD0C, 0x00000000},
{&GUID_Key, 222, 0x8000DE0C, 0x00000000},
{&GUID_Key, 223, 0x8000DF0C, 0x00000000},
{&GUID_Key, 224, 0x8000E00C, 0x00000000},
{&GUID_Key, 225, 0x8000E10C, 0x00000000},
{&GUID_Key, 226, 0x8000E20C, 0x00000000},
{&GUID_Key, 227, 0x8000E30C, 0x00000000},
{&GUID_Key, 228, 0x8000E40C, 0x00000000},
{&GUID_Key, 229, 0x8000E50C, 0x00000000},
{&GUID_Key, 230, 0x8000E60C, 0x00000000},
{&GUID_Key, 231, 0x8000E70C, 0x00000000},
{&GUID_Key, 232, 0x8000E80C, 0x00000000},
{&GUID_Key, 233, 0x8000E90C, 0x00000000},
{&GUID_Key, 234, 0x8000EA0C, 0x00000000},
{&GUID_Key, 235, 0x8000EB0C, 0x00000000},
{&GUID_Key, 236, 0x8000EC0C, 0x00000000},
{&GUID_Key, 237, 0x8000ED0C, 0x00000000},
{&GUID_Key, 238, 0x8000EE0C, 0x00000000},
{&GUID_Key, 239, 0x8000EF0C, 0x00000000},
{&GUID_Key, 240, 0x8000F00C, 0x00000000},
{&GUID_Key, 241, 0x8000F10C, 0x00000000},
{&GUID_Key, 242, 0x8000F20C, 0x00000000},
{&GUID_Key, 243, 0x8000F30C, 0x00000000},
{&GUID_Key, 244, 0x8000F40C, 0x00000000},
{&GUID_Key, 245, 0x8000F50C, 0x00000000},
{&GUID_Key, 246, 0x8000F60C, 0x00000000},
{&GUID_Key, 247, 0x8000F70C, 0x00000000},
{&GUID_Key, 248, 0x8000F80C, 0x00000000},
{&GUID_Key, 249, 0x8000F90C, 0x00000000},
{&GUID_Key, 250, 0x8000FA0C, 0x00000000},
{&GUID_Key, 251, 0x8000FB0C, 0x00000000},
{&GUID_Key, 252, 0x8000FC0C, 0x00000000},
{&GUID_Key, 253, 0x8000FD0C, 0x00000000},
{&GUID_Key, 254, 0x8000FE0C, 0x00000000},
{&GUID_Key, 255, 0x8000FF0C, 0x00000000},
336
337
338
339
340
341
342
343
};
const DIDATAFORMAT c_dfDIKeyboard = { 24, 16, 0x00000002, 256, 256, KBD_fmt };
/* Mouse */
static DIOBJECTDATAFORMAT PTR_fmt[] = {
344
345
346
347
348
349
350
{&GUID_XAxis, 0, 0x00FFFF03, 0x00000000},
{&GUID_YAxis, 4, 0x00FFFF03, 0x00000000},
{&GUID_ZAxis, 8, 0x80FFFF03, 0x00000000},
{NULL, 12, 0x00FFFF0C, 0x00000000},
{NULL, 13, 0x00FFFF0C, 0x00000000},
{NULL, 14, 0x80FFFF0C, 0x00000000},
{NULL, 15, 0x80FFFF0C, 0x00000000},
351
352
353
354
355
356
357
358
};
const DIDATAFORMAT c_dfDIMouse = { 24, 16, 0x00000002, 16, 7, PTR_fmt };
/* Joystick */
static DIOBJECTDATAFORMAT JOY_fmt[] = {
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
{&GUID_XAxis, 0, 0x80FFFF03, 0x00000100},
{&GUID_YAxis, 4, 0x80FFFF03, 0x00000100},
{&GUID_ZAxis, 8, 0x80FFFF03, 0x00000100},
{&GUID_RxAxis, 12, 0x80FFFF03, 0x00000100},
{&GUID_RyAxis, 16, 0x80FFFF03, 0x00000100},
{&GUID_RzAxis, 20, 0x80FFFF03, 0x00000100},
{&GUID_Slider, 24, 0x80FFFF03, 0x00000100},
{&GUID_Slider, 28, 0x80FFFF03, 0x00000100},
{&GUID_POV, 32, 0x80FFFF10, 0x00000000},
{&GUID_POV, 36, 0x80FFFF10, 0x00000000},
{&GUID_POV, 40, 0x80FFFF10, 0x00000000},
{&GUID_POV, 44, 0x80FFFF10, 0x00000000},
{NULL, 48, 0x80FFFF0C, 0x00000000},
{NULL, 49, 0x80FFFF0C, 0x00000000},
{NULL, 50, 0x80FFFF0C, 0x00000000},
{NULL, 51, 0x80FFFF0C, 0x00000000},
{NULL, 52, 0x80FFFF0C, 0x00000000},
{NULL, 53, 0x80FFFF0C, 0x00000000},
{NULL, 54, 0x80FFFF0C, 0x00000000},
{NULL, 55, 0x80FFFF0C, 0x00000000},
{NULL, 56, 0x80FFFF0C, 0x00000000},
{NULL, 57, 0x80FFFF0C, 0x00000000},
{NULL, 58, 0x80FFFF0C, 0x00000000},
{NULL, 59, 0x80FFFF0C, 0x00000000},
{NULL, 60, 0x80FFFF0C, 0x00000000},
{NULL, 61, 0x80FFFF0C, 0x00000000},
{NULL, 62, 0x80FFFF0C, 0x00000000},
{NULL, 63, 0x80FFFF0C, 0x00000000},
{NULL, 64, 0x80FFFF0C, 0x00000000},
{NULL, 65, 0x80FFFF0C, 0x00000000},
{NULL, 66, 0x80FFFF0C, 0x00000000},
{NULL, 67, 0x80FFFF0C, 0x00000000},
{NULL, 68, 0x80FFFF0C, 0x00000000},
{NULL, 69, 0x80FFFF0C, 0x00000000},
{NULL, 70, 0x80FFFF0C, 0x00000000},
{NULL, 71, 0x80FFFF0C, 0x00000000},
{NULL, 72, 0x80FFFF0C, 0x00000000},
{NULL, 73, 0x80FFFF0C, 0x00000000},
{NULL, 74, 0x80FFFF0C, 0x00000000},
{NULL, 75, 0x80FFFF0C, 0x00000000},
{NULL, 76, 0x80FFFF0C, 0x00000000},
{NULL, 77, 0x80FFFF0C, 0x00000000},
{NULL, 78, 0x80FFFF0C, 0x00000000},
{NULL, 79, 0x80FFFF0C, 0x00000000},
403
404
405
406
407
408
};
const DIDATAFORMAT c_dfDIJoystick = { 24, 16, 0x00000001, 80, 44, JOY_fmt };
/* Initialization/Query functions */
409
410
411
412
413
414
415
416
417
418
static int DX5_VideoInit(_THIS, SDL_PixelFormat * vformat);
static SDL_Rect **DX5_ListModes(_THIS, SDL_PixelFormat * format,
Uint32 flags);
static SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface * current, int width,
int height, int bpp, Uint32 flags);
static int DX5_SetColors(_THIS, int firstcolor, int ncolors,
SDL_Color * colors);
static int DX5_SetGammaRamp(_THIS, Uint16 * ramp);
static int DX5_GetGammaRamp(_THIS, Uint16 * ramp);
static void DX5_VideoQuit(_THIS);
419
420
/* Hardware surface functions */
421
422
423
424
425
426
427
428
429
430
431
432
433
static int DX5_AllocHWSurface(_THIS, SDL_Surface * surface);
static int DX5_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst);
static int DX5_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect,
Uint32 color);
static int DX5_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key);
static int DX5_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha);
static int DX5_LockHWSurface(_THIS, SDL_Surface * surface);
static void DX5_UnlockHWSurface(_THIS, SDL_Surface * surface);
static int DX5_FlipHWSurface(_THIS, SDL_Surface * surface);
static void DX5_FreeHWSurface(_THIS, SDL_Surface * surface);
static int DX5_AllocDDSurface(_THIS, SDL_Surface * surface,
LPDIRECTDRAWSURFACE3 requested, Uint32 flag);
434
435
/* Windows message handling functions */
436
437
438
static void DX5_RealizePalette(_THIS);
static void DX5_PaletteChanged(_THIS, HWND window);
static void DX5_WinPAINT(_THIS, HDC hdc);
439
440
/* WinDIB driver functions for manipulating gamma ramps */
441
442
443
extern int DIB_SetGammaRamp(_THIS, Uint16 * ramp);
extern int DIB_GetGammaRamp(_THIS, Uint16 * ramp);
extern void DIB_QuitGamma(_THIS);
444
445
446
447
448
449
/* Functions for loading the DirectX functions dynamically */
static int DX5_loaded = 0;
static HINSTANCE DDrawDLL = NULL;
static HINSTANCE DInputDLL = NULL;
450
void
451
DX5_Unload(void)
452
{
453
454
if (--DX5_loaded == 0) {
if (DDrawDLL != NULL) {
455
FreeLibrary(DDrawDLL);
456
457
458
459
DDrawCreate = NULL;
DDrawDLL = NULL;
}
if (DInputDLL != NULL) {
460
FreeLibrary(DInputDLL);
461
462
463
464
DInputCreate = NULL;
DInputDLL = NULL;
}
}
465
}
466
int
467
DX5_Load(void)
468
{
469
470
471
int status = 0;
if (++DX5_loaded == 1) {
472
DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL"));
473
if (DDrawDLL != NULL) {
474
475
DDrawCreate = (void *) GetProcAddress(DDrawDLL,
TEXT("DirectDrawCreate"));
476
}
477
DInputDLL = LoadLibrary(TEXT("DINPUT.DLL"));
478
if (DInputDLL != NULL) {
479
480
481
DInputCreate = (void *) GetProcAddress(DInputDLL,
TEXT
("DirectInputCreateA"));
482
483
484
485
}
if (DDrawDLL && DDrawCreate && DInputDLL && DInputCreate) {
status = 0;
} else {
486
DX5_Unload();
487
488
489
490
status = -1;
}
}
return status;
491
492
}
493
494
/* DX5 driver bootstrap functions */
495
static int
496
DX5_Available(void)
497
{
498
int ddraw_ok = 0;
499
HRESULT(WINAPI * DDrawCreate) (GUID *, LPDIRECTDRAW *, IUnknown *);
500
501
502
LPDIRECTDRAW DDraw;
/* Version check DINPUT.DLL and DDRAW.DLL (Is DirectX okay?) */
503
if (DX5_Load() < 0) {
504
505
506
507
return -1;
}
/* Try to create a valid DirectDraw object */
508
509
510
511
DDrawCreate = (void *) GetProcAddress(DDrawDLL, TEXT("DirectDrawCreate"));
if ((DDrawCreate != NULL) && !FAILED(DDrawCreate(NULL, &DDraw, NULL))) {
if (!FAILED(IDirectDraw_SetCooperativeLevel(DDraw,
NULL, DDSCL_NORMAL))) {
512
513
514
515
516
DDSURFACEDESC desc;
LPDIRECTDRAWSURFACE DDrawSurf;
LPDIRECTDRAWSURFACE3 DDrawSurf3;
/* Try to create a DirectDrawSurface3 object */
517
518
SDL_memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
519
520
521
522
desc.dwFlags = DDSD_CAPS;
desc.ddsCaps.dwCaps =
DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY;
if (!FAILED
523
(IDirectDraw_CreateSurface(DDraw, &desc, &DDrawSurf, NULL))) {
524
525
526
527
528
529
530
531
if (!FAILED
(IDirectDrawSurface_QueryInterface
(DDrawSurf, &IID_IDirectDrawSurface3,
(LPVOID *) & DDrawSurf3))) {
/* Yay! */
ddraw_ok = 1;
/* Clean up.. */
532
IDirectDrawSurface3_Release(DDrawSurf3);
533
}
534
IDirectDrawSurface_Release(DDrawSurf);
535
536
}
}
537
IDirectDraw_Release(DDraw);
538
539
}
540
DX5_Unload();
541
542
return ddraw_ok;
543
544
}
545
static void
546
DX5_DeleteDevice(SDL_VideoDevice * this)
547
{
548
549
/* Free DirectDraw object */
if (ddraw2 != NULL) {
550
IDirectDraw2_Release(ddraw2);
551
}
552
DX5_Unload();
553
554
555
if (this) {
if (this->hidden) {
556
SDL_free(this->hidden);
557
558
}
if (this->gl_data) {
559
SDL_free(this->gl_data);
560
}
561
SDL_free(this);
562
}
563
564
}
565
static SDL_VideoDevice *
566
DX5_CreateDevice(int devindex)
567
{
568
569
570
SDL_VideoDevice *device;
/* Load DirectX */
571
if (DX5_Load() < 0) {
572
573
574
575
return (NULL);
}
/* Initialize all variables that we clean on shutdown */
576
device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
577
if (device) {
578
SDL_memset(device, 0, (sizeof *device));
579
device->hidden = (struct SDL_PrivateVideoData *)
580
SDL_malloc((sizeof *device->hidden));
581
device->gl_data = (struct SDL_PrivateGLData *)
582
SDL_malloc((sizeof *device->gl_data));
583
584
585
}
if ((device == NULL) || (device->hidden == NULL) ||
(device->gl_data == NULL)) {
586
587
SDL_OutOfMemory();
DX5_DeleteDevice(device);
588
589
return (NULL);
}
590
591
SDL_memset(device->hidden, 0, (sizeof *device->hidden));
SDL_memset(device->gl_data, 0, (sizeof *device->gl_data));
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
/* Set the function pointers */
device->VideoInit = DX5_VideoInit;
device->ListModes = DX5_ListModes;
device->SetVideoMode = DX5_SetVideoMode;
device->UpdateMouse = WIN_UpdateMouse;
device->CreateYUVOverlay = DX5_CreateYUVOverlay;
device->SetColors = DX5_SetColors;
device->UpdateRects = NULL;
device->VideoQuit = DX5_VideoQuit;
device->AllocHWSurface = DX5_AllocHWSurface;
device->CheckHWBlit = DX5_CheckHWBlit;
device->FillHWRect = DX5_FillHWRect;
device->SetHWColorKey = DX5_SetHWColorKey;
device->SetHWAlpha = DX5_SetHWAlpha;
device->LockHWSurface = DX5_LockHWSurface;
device->UnlockHWSurface = DX5_UnlockHWSurface;
device->FlipHWSurface = DX5_FlipHWSurface;
device->FreeHWSurface = DX5_FreeHWSurface;
device->SetGammaRamp = DX5_SetGammaRamp;
device->GetGammaRamp = DX5_GetGammaRamp;
613
#if SDL_VIDEO_OPENGL
614
615
616
617
618
device->GL_LoadLibrary = WIN_GL_LoadLibrary;
device->GL_GetProcAddress = WIN_GL_GetProcAddress;
device->GL_GetAttribute = WIN_GL_GetAttribute;
device->GL_MakeCurrent = WIN_GL_MakeCurrent;
device->GL_SwapBuffers = WIN_GL_SwapBuffers;
619
#endif
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
device->SetCaption = WIN_SetWMCaption;
device->SetIcon = WIN_SetWMIcon;
device->IconifyWindow = WIN_IconifyWindow;
device->GrabInput = WIN_GrabInput;
device->GetWMInfo = WIN_GetWMInfo;
device->FreeWMCursor = WIN_FreeWMCursor;
device->CreateWMCursor = WIN_CreateWMCursor;
device->ShowWMCursor = WIN_ShowWMCursor;
device->WarpWMCursor = WIN_WarpWMCursor;
device->CheckMouseMode = WIN_CheckMouseMode;
device->InitOSKeymap = DX5_InitOSKeymap;
device->PumpEvents = DX5_PumpEvents;
/* Set up the windows message handling functions */
WIN_RealizePalette = DX5_RealizePalette;
WIN_PaletteChanged = DX5_PaletteChanged;
WIN_WinPAINT = DX5_WinPAINT;
HandleMessage = DX5_HandleMessage;
device->free = DX5_DeleteDevice;
/* We're finally ready */
return device;
643
644
645
}
VideoBootStrap DIRECTX_bootstrap = {
646
647
"directx", "Win95/98/2000 DirectX",
DX5_Available, DX5_CreateDevice
648
649
};
650
static int
651
cmpmodes(const void *va, const void *vb)
652
{
653
654
655
SDL_Rect *a = *(SDL_Rect **) va;
SDL_Rect *b = *(SDL_Rect **) vb;
if (a->w == b->w)
656
657
658
659
660
return b->h - a->h;
else
return b->w - a->w;
}
661
static HRESULT WINAPI
662
EnumModes2(DDSURFACEDESC * desc, VOID * udata)
663
{
664
665
SDL_VideoDevice *this = (SDL_VideoDevice *) udata;
struct DX5EnumRect *enumrect;
666
#if defined(NONAMELESSUNION)
667
668
int bpp = desc->ddpfPixelFormat.u1.dwRGBBitCount;
int refreshRate = desc->u2.dwRefreshRate;
669
#else
670
671
int bpp = desc->ddpfPixelFormat.dwRGBBitCount;
int refreshRate = desc->dwRefreshRate;
672
#endif
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
int maxRefreshRate;
if (desc->dwWidth <= SDL_desktop_mode.dmPelsWidth &&
desc->dwHeight <= SDL_desktop_mode.dmPelsHeight) {
maxRefreshRate = SDL_desktop_mode.dmDisplayFrequency;
} else {
maxRefreshRate = 85; /* safe value? */
}
switch (bpp) {
case 8:
case 16:
case 24:
case 32:
bpp /= 8;
--bpp;
if (enumlists[bpp] &&
enumlists[bpp]->r.w == (Uint16) desc->dwWidth &&
enumlists[bpp]->r.h == (Uint16) desc->dwHeight) {
if (refreshRate > enumlists[bpp]->refreshRate &&
refreshRate <= maxRefreshRate) {
enumlists[bpp]->refreshRate = refreshRate;
695
#ifdef DDRAW_DEBUG
696
697
698
699
fprintf(stderr,
"New refresh rate for %d bpp: %dx%d at %d Hz\n",
(bpp + 1) * 8, (int) desc->dwWidth,
(int) desc->dwHeight, refreshRate);
700
#endif
701
702
703
704
705
}
break;
}
++SDL_nummodes[bpp];
enumrect =
706
(struct DX5EnumRect *) SDL_malloc(sizeof(struct DX5EnumRect));
707
if (!enumrect) {
708
SDL_OutOfMemory();
709
710
711
712
713
714
715
716
717
return (DDENUMRET_CANCEL);
}
enumrect->refreshRate = refreshRate;
enumrect->r.x = 0;
enumrect->r.y = 0;
enumrect->r.w = (Uint16) desc->dwWidth;
enumrect->r.h = (Uint16) desc->dwHeight;
enumrect->next = enumlists[bpp];
enumlists[bpp] = enumrect;
718
#ifdef DDRAW_DEBUG
719
720
721
fprintf(stderr, "New mode for %d bpp: %dx%d at %d Hz\n",
(bpp + 1) * 8, (int) desc->dwWidth, (int) desc->dwHeight,
refreshRate);
722
#endif
723
724
break;
}
725
726
return (DDENUMRET_OK);
727
728
}
729
void
730
SetDDerror(const char *function, int code)
731
{
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
static char *error;
static char errbuf[1024];
errbuf[0] = 0;
switch (code) {
case DDERR_GENERIC:
error = "Undefined error!";
break;
case DDERR_EXCEPTION:
error = "Exception encountered";
break;
case DDERR_INVALIDOBJECT:
error = "Invalid object";
break;
case DDERR_INVALIDPARAMS:
error = "Invalid parameters";
break;
case DDERR_NOTFOUND:
error = "Object not found";
break;
case DDERR_INVALIDRECT:
error = "Invalid rectangle";
break;
case DDERR_INVALIDCAPS:
error = "Invalid caps member";
break;
case DDERR_INVALIDPIXELFORMAT:
error = "Invalid pixel format";
break;
case DDERR_OUTOFMEMORY:
error = "Out of memory";
break;
case DDERR_OUTOFVIDEOMEMORY:
error = "Out of video memory";
break;
case DDERR_SURFACEBUSY:
error = "Surface busy";
break;
case DDERR_SURFACELOST:
error = "Surface was lost";
break;
case DDERR_WASSTILLDRAWING:
error = "DirectDraw is still drawing";
break;
case DDERR_INVALIDSURFACETYPE:
error = "Invalid surface type";
break;
case DDERR_NOEXCLUSIVEMODE:
error = "Not in exclusive access mode";
break;
case DDERR_NOPALETTEATTACHED:
error = "No palette attached";
break;
case DDERR_NOPALETTEHW:
error = "No palette hardware";
break;
case DDERR_NOT8BITCOLOR:
error = "Not 8-bit color";
break;
case DDERR_EXCLUSIVEMODEALREADYSET:
error = "Exclusive mode was already set";
break;
case DDERR_HWNDALREADYSET:
error = "Window handle already set";
break;
case DDERR_HWNDSUBCLASSED:
error = "Window handle is subclassed";
break;
case DDERR_NOBLTHW:
error = "No blit hardware";
break;
case DDERR_IMPLICITLYCREATED:
error = "Surface was implicitly created";
break;
case DDERR_INCOMPATIBLEPRIMARY:
error = "Incompatible primary surface";
break;
case DDERR_NOCOOPERATIVELEVELSET:
error = "No cooperative level set";
break;
case DDERR_NODIRECTDRAWHW:
error = "No DirectDraw hardware";
break;
case DDERR_NOEMULATION:
error = "No emulation available";
break;
case DDERR_NOFLIPHW:
error = "No flip hardware";
break;
case DDERR_NOTFLIPPABLE:
error = "Surface not flippable";
break;
case DDERR_PRIMARYSURFACEALREADYEXISTS:
error = "Primary surface already exists";
break;
case DDERR_UNSUPPORTEDMODE:
error = "Unsupported mode";
break;
case DDERR_WRONGMODE:
error = "Surface created in different mode";
break;
case DDERR_UNSUPPORTED:
error = "Operation not supported";
break;
case E_NOINTERFACE:
error = "Interface not present";
break;
default:
840
841
SDL_snprintf(errbuf, SDL_arraysize(errbuf),
"%s: Unknown DirectDraw error: 0x%x", function, code);
842
843
844
break;
}
if (!errbuf[0]) {
845
846
SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function,
error);
847
}
848
SDL_SetError("%s", errbuf);
849
return;
850
851
852
}
853
static int
854
DX5_UpdateVideoInfo(_THIS)
855
{
856
/* This needs to be DDCAPS_DX5 for the DirectDraw2 interface */
857
858
859
#if DIRECTDRAW_VERSION <= 0x300
#error Your version of DirectX must be greater than or equal to 5.0
#endif
860
#ifndef IDirectDrawGammaControl_SetGammaRamp
861
862
/*if gamma is undefined then we really have directx <= 0x500 */
DDCAPS DDCaps;
863
#else
864
DDCAPS_DX5 DDCaps;
865
#endif
866
867
868
HRESULT result;
/* Fill in our hardware acceleration capabilities */
869
870
871
SDL_memset(&DDCaps, 0, sizeof(DDCaps));
DDCaps.dwSize = sizeof(DDCaps);
result = IDirectDraw2_GetCaps(ddraw2, (DDCAPS *) & DDCaps, NULL);
872
if (result != DD_OK) {
873
SetDDerror("DirectDraw2::GetCaps", result);
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
return (-1);
}
this->info.hw_available = 1;
if ((DDCaps.dwCaps & DDCAPS_BLT) == DDCAPS_BLT) {
this->info.blit_hw = 1;
}
if (((DDCaps.dwCaps & DDCAPS_COLORKEY) == DDCAPS_COLORKEY) &&
((DDCaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT) == DDCKEYCAPS_SRCBLT)) {
this->info.blit_hw_CC = 1;
}
if ((DDCaps.dwCaps & DDCAPS_ALPHA) == DDCAPS_ALPHA) {
/* This is only for alpha channel, and DirectX 6
doesn't support 2D alpha blits yet, so set it 0
*/
this->info.blit_hw_A = 0;
}
if ((DDCaps.dwCaps & DDCAPS_CANBLTSYSMEM) == DDCAPS_CANBLTSYSMEM) {
this->info.blit_sw = 1;
/* This isn't necessarily true, but the HEL will cover us */
this->info.blit_sw_CC = this->info.blit_hw_CC;
this->info.blit_sw_A = this->info.blit_hw_A;
}
if ((DDCaps.dwCaps & DDCAPS_BLTCOLORFILL) == DDCAPS_BLTCOLORFILL) {
this->info.blit_fill = 1;
}
/* Find out how much video memory is available */
{
DDSCAPS ddsCaps;
DWORD total_mem;
ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
905
906
result = IDirectDraw2_GetAvailableVidMem(ddraw2,
&ddsCaps, &total_mem, NULL);
907
908
909
910
911
912
if (result != DD_OK) {
total_mem = DDCaps.dwVidMemTotal;
}
this->info.video_mem = total_mem / 1024;
}
return (0);
913
914
}
915
int
916
DX5_VideoInit(_THIS, SDL_PixelFormat * vformat)
917
{
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
HRESULT result;
LPDIRECTDRAW ddraw;
int i, j;
HDC hdc;
/* Intialize everything */
ddraw2 = NULL;
SDL_primary = NULL;
SDL_clipper = NULL;
SDL_palette = NULL;
for (i = 0; i < NUM_MODELISTS; ++i) {
SDL_nummodes[i] = 0;
SDL_modelist[i] = NULL;
SDL_modeindex[i] = 0;
}
colorchange_expected = 0;
/* Create the window */
936
if (DX5_CreateWindow(this) < 0) {
937
938
return (-1);
}
939
#if !SDL_AUDIO_DISABLED
940
DX5_SoundFocus(SDL_Window);
941
#endif
942
943
/* Create the DirectDraw object */
944
result = DDrawCreate(NULL, &ddraw, NULL);
945
if (result != DD_OK) {
946
SetDDerror("DirectDrawCreate", result);
947
948
return (-1);
}
949
950
951
result = IDirectDraw_QueryInterface(ddraw, &IID_IDirectDraw2,
(LPVOID *) & ddraw2);
IDirectDraw_Release(ddraw);
952
if (result != DD_OK) {
953
SetDDerror("DirectDraw::QueryInterface", result);
954
955
956
957
return (-1);
}
/* Determine the screen depth */
958
959
960
961
hdc = GetDC(SDL_Window);
vformat->BitsPerPixel = GetDeviceCaps(hdc, PLANES) *
GetDeviceCaps(hdc, BITSPIXEL);
ReleaseDC(SDL_Window, hdc);
962
963
#ifndef NO_CHANGEDISPLAYSETTINGS
964
/* Query for the desktop resolution */
965
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode);
966
967
this->info.current_w = SDL_desktop_mode.dmPelsWidth;
this->info.current_h = SDL_desktop_mode.dmPelsHeight;
968
969
#endif
970
971
972
973
974
/* Enumerate the available fullscreen modes */
for (i = 0; i < NUM_MODELISTS; ++i)
enumlists[i] = NULL;
result =
975
976
IDirectDraw2_EnumDisplayModes(ddraw2, DDEDM_REFRESHRATES, NULL, this,
EnumModes2);
977
if (result != DD_OK) {
978
SetDDerror("DirectDraw2::EnumDisplayModes", result);
979
980
981
982
983
return (-1);
}
for (i = 0; i < NUM_MODELISTS; ++i) {
struct DX5EnumRect *rect;
SDL_modelist[i] = (SDL_Rect **)
984
SDL_malloc((SDL_nummodes[i] + 1) * sizeof(SDL_Rect *));
985
if (SDL_modelist[i] == NULL) {
986
SDL_OutOfMemory();
987
988
989
990
991
992
993
994
return (-1);
}
for (j = 0, rect = enumlists[i]; rect; ++j, rect = rect->next) {
SDL_modelist[i][j] = &rect->r;
}
SDL_modelist[i][j] = NULL;
if (SDL_nummodes[i] > 0) {
995
996
SDL_qsort(SDL_modelist[i], SDL_nummodes[i],
sizeof *SDL_modelist[i], cmpmodes);
997
998
999
1000
}
}
/* Fill in some window manager capabilities */