-
Notifications
You must be signed in to change notification settings - Fork 40
/
SDL12_compat.c
9922 lines (8758 loc) · 328 KB
/
SDL12_compat.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
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
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
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
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <[email protected]>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* This file contains functions for backwards compatibility with SDL 1.2 */
#include "SDL20_include_wrapper.h"
/*
* We report the library version as 1.2.$(SDL12_COMPAT_VERSION). This number
* should be way ahead of what SDL-1.2 Classic would report, so apps can
* decide if they're running under the compat layer, if they really care.
*/
#define SDL12_COMPAT_VERSION 69
#include <stdarg.h>
#include <limits.h>
#include <stddef.h>
#if defined(_MSC_VER) && (_MSC_VER < 1600)
/* intptr_t already handled by stddef.h. */
#else
#include <stdint.h>
#endif
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#else
#include <stdio.h> /* fprintf(), etc. */
#include <stdlib.h> /* for abort() */
#include <string.h>
#endif
/* mingw headers may define these ... */
#undef strtod
#undef strcasecmp
#undef strncasecmp
#undef snprintf
#undef vsnprintf
#ifdef __linux__
#include <unistd.h> /* for readlink() */
#endif
#if defined(__unix__) || defined(__APPLE__)
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
#define SDL12_MAXPATH PATH_MAX
#elif defined _WIN32
#define SDL12_MAXPATH MAX_PATH
#elif defined __OS2__
#define SDL12_MAXPATH CCHMAXPATH
#else
#define SDL12_MAXPATH 1024
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* on x86 Linux builds, we have the public entry points force stack alignment to 16 bytes
on entry. This won't be a massive performance hit, but it might help extremely old
binaries that want to call into SDL to not crash in hard-to-diagnose ways. It's not a
panacea to the stack alignment problem, but it might help a little.
The force_align_arg_pointer attribute requires gcc >= 4.2.x. */
#if defined(__clang__)
#define HAVE_FORCE_ALIGN_ARG_POINTER
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
#define HAVE_FORCE_ALIGN_ARG_POINTER
#endif
#if defined(__linux__) && defined(__i386__) && defined(HAVE_FORCE_ALIGN_ARG_POINTER)
#define FORCEALIGNATTR __attribute__((force_align_arg_pointer))
#else
#define FORCEALIGNATTR
#endif
#define DECLSPEC12 DECLSPEC FORCEALIGNATTR
/** Enable this to have warnings about wrong prototypes in SDL20_syms.h.
* It won't compile but it helps to make sure it's sync'ed with SDL2 headers.
*/
#if 0
#define SDL20_SYM(rc,fn,params,args,ret) \
typedef rc (SDLCALL *SDL20_##fn##_t) params; \
static SDL20_##fn##_t SDL20_##fn = IGNORE_THIS_VERSION_OF_SDL_##fn;
#else
#define SDL20_SYM(rc,fn,params,args,ret) \
typedef rc (SDLCALL *SDL20_##fn##_t) params; \
static SDL20_##fn##_t SDL20_##fn = NULL;
#endif
#include "SDL20_syms.h"
/* Things that _should_ be binary compatible pass right through... */
#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \
DECLSPEC12 rc SDLCALL SDL_##fn params { ret SDL20_##fn args; }
#include "SDL20_syms.h"
/* these are macros (etc) in the SDL headers, so make our own. */
#define SDL20_OutOfMemory() SDL20_Error(SDL_ENOMEM)
#define SDL20_Unsupported() SDL20_Error(SDL_UNSUPPORTED)
#define SDL20_InvalidParamError(param) SDL20_SetError("Parameter '%s' is invalid", (param))
#define SDL20_zero(x) SDL20_memset(&(x), 0, sizeof((x)))
#define SDL20_zerop(x) SDL20_memset((x), 0, sizeof(*(x)))
#define SDL20_zeroa(x) SDL20_memset((x), 0, sizeof((x)))
#define SDL_ReportAssertion SDL20_ReportAssertion
/* for SDL_assert() : */
#define SDL_enabled_assert(condition) \
do { \
while ( !(condition) ) { \
static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
const SDL_AssertState sdl_assert_state = SDL20_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
continue; /* go again. */ \
} else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
SDL_TriggerBreakpoint(); \
} \
break; /* not retrying. */ \
} \
} while (SDL_NULL_WHILE_LOOP_CONDITION)
/* From SDL2.0's SDL_bits.h: a force-inlined function. */
#if defined(__WATCOMC__) && defined(__386__)
extern __inline int _SDL20_bsr_watcom(Uint32);
#pragma aux _SDL20_bsr_watcom = \
"bsr eax, eax" \
parm [eax] nomemory \
value [eax] \
modify exact [eax] nomemory;
#endif
SDL_FORCE_INLINE int
SDL20_MostSignificantBitIndex32(Uint32 x)
{
#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
/* Count Leading Zeroes builtin in GCC.
* http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html
*/
if (x == 0) {
return -1;
}
return 31 - __builtin_clz(x);
#elif defined(__WATCOMC__) && defined(__386__)
if (x == 0) {
return -1;
}
return _SDL20_bsr_watcom(x);
#elif defined(_MSC_VER)
unsigned long index;
if (_BitScanReverse(&index, x)) {
return index;
}
return -1;
#else
/* Based off of Bit Twiddling Hacks by Sean Eron Anderson
* <[email protected]>, released in the public domain.
* http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog
*/
const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
const int S[] = {1, 2, 4, 8, 16};
int msbIndex = 0;
int i;
if (x == 0) {
return -1;
}
for (i = 4; i >= 0; i--)
{
if (x & b[i])
{
x >>= S[i];
msbIndex |= S[i];
}
}
return msbIndex;
#endif
}
/* SDL_truncf needs SDL >=2.0.14, so copy it here. */
static float SDL20_truncf(float x)
{
return (x < 0.0f) ? (float)SDL20_ceil(x) : (float)SDL20_floor(x);
}
#define SDL12_DEFAULT_REPEAT_DELAY 500
#define SDL12_DEFAULT_REPEAT_INTERVAL 30
#define SDL12_INIT_TIMER 0x00000001
#define SDL12_INIT_AUDIO 0x00000010
#define SDL12_INIT_VIDEO 0x00000020
#define SDL12_INIT_CDROM 0x00000100
#define SDL12_INIT_JOYSTICK 0x00000200
#define SDL12_INIT_NOPARACHUTE 0x00100000
#define SDL12_INIT_EVENTTHREAD 0x01000000
#define SDL12_INIT_EVERYTHING 0x0000FFFF
#define SDL12_LOGPAL 1
#define SDL12_PHYSPAL 2
#ifndef SDL_SIMD_ALIGNED
#define SDL_SIMD_ALIGNED 0x00000008
#endif
typedef struct SDL12_Rect
{
Sint16 x;
Sint16 y;
Uint16 w;
Uint16 h;
} SDL12_Rect;
typedef struct SDL12_Palette
{
int ncolors;
SDL_Color *colors;
} SDL12_Palette;
typedef struct SDL12_PixelFormat
{
SDL12_Palette *palette;
Uint8 BitsPerPixel;
Uint8 BytesPerPixel;
Uint8 Rloss;
Uint8 Gloss;
Uint8 Bloss;
Uint8 Aloss;
Uint8 Rshift;
Uint8 Gshift;
Uint8 Bshift;
Uint8 Ashift;
Uint32 Rmask;
Uint32 Gmask;
Uint32 Bmask;
Uint32 Amask;
Uint32 colorkey;
Uint8 alpha;
} SDL12_PixelFormat;
typedef struct SDL12_Surface
{
Uint32 flags;
SDL12_PixelFormat *format;
int w;
int h;
Uint16 pitch;
void *pixels;
int offset;
SDL_Surface *surface20; /* the real SDL 1.2 has an opaque pointer to a platform-specific thing here named "hwdata". */
SDL12_Rect clip_rect;
Uint32 unused1;
Uint32 locked;
void *blitmap;
unsigned int format_version;
int refcount;
} SDL12_Surface;
#define SDL12_YV12_OVERLAY 0x32315659
#define SDL12_IYUV_OVERLAY 0x56555949
#define SDL12_YUY2_OVERLAY 0x32595559
#define SDL12_UYVY_OVERLAY 0x59565955
#define SDL12_YVYU_OVERLAY 0x55595659
typedef struct SDL12_Overlay
{
Uint32 format;
int w;
int h;
int planes;
Uint16 *pitches;
Uint8 **pixels;
void *hwfuncs;
void *hwdata;
Uint32 hw_overlay :1;
Uint32 UnusedBits :31;
} SDL12_Overlay;
typedef struct SDL12_YUVData /* internal struct, not part of public SDL 1.2 API */
{
SDL_Texture *texture20;
SDL_bool dirty;
Uint8 *pixelbuf;
Uint8 *pixels[3];
Uint16 pitches[3];
} SDL12_YUVData;
typedef struct
{
Uint32 hw_available :1;
Uint32 wm_available :1;
Uint32 UnusedBits1 :6;
Uint32 UnusedBits2 :1;
Uint32 blit_hw :1;
Uint32 blit_hw_CC :1;
Uint32 blit_hw_A :1;
Uint32 blit_sw :1;
Uint32 blit_sw_CC :1;
Uint32 blit_sw_A :1;
Uint32 blit_fill :1;
Uint32 UnusedBits3 :16;
Uint32 video_mem;
SDL12_PixelFormat *vfmt;
int current_w;
int current_h;
} SDL12_VideoInfo;
#define SDL12_HWSURFACE 0x00000001
#define SDL12_ASYNCBLIT 0x00000004
#define SDL12_ANYFORMAT 0x10000000
#define SDL12_HWPALETTE 0x20000000
#define SDL12_DOUBLEBUF 0x40000000
#define SDL12_FULLSCREEN 0x80000000
#define SDL12_OPENGL 0x00000002
#define SDL12_OPENGLBLIT 0x0000000A
#define SDL12_RESIZABLE 0x00000010
#define SDL12_NOFRAME 0x00000020
#define SDL12_HWACCEL 0x00000100
#define SDL12_SRCCOLORKEY 0x00001000
#define SDL12_RLEACCELOK 0x00002000
#define SDL12_RLEACCEL 0x00004000
#define SDL12_SRCALPHA 0x00010000
#define SDL12_PREALLOC 0x01000000
typedef enum
{
SDLK12_UNKNOWN = 0,
SDLK12_FIRST = 0,
SDLK12_BACKSPACE = 8,
SDLK12_TAB = 9,
SDLK12_CLEAR = 12,
SDLK12_RETURN = 13,
SDLK12_PAUSE = 19,
SDLK12_ESCAPE = 27,
SDLK12_SPACE = 32,
SDLK12_EXCLAIM = 33,
SDLK12_QUOTEDBL = 34,
SDLK12_HASH = 35,
SDLK12_DOLLAR = 36,
SDLK12_AMPERSAND = 38,
SDLK12_QUOTE = 39,
SDLK12_LEFTPAREN = 40,
SDLK12_RIGHTPAREN = 41,
SDLK12_ASTERISK = 42,
SDLK12_PLUS = 43,
SDLK12_COMMA = 44,
SDLK12_MINUS = 45,
SDLK12_PERIOD = 46,
SDLK12_SLASH = 47,
SDLK12_0 = 48,
SDLK12_1 = 49,
SDLK12_2 = 50,
SDLK12_3 = 51,
SDLK12_4 = 52,
SDLK12_5 = 53,
SDLK12_6 = 54,
SDLK12_7 = 55,
SDLK12_8 = 56,
SDLK12_9 = 57,
SDLK12_COLON = 58,
SDLK12_SEMICOLON = 59,
SDLK12_LESS = 60,
SDLK12_EQUALS = 61,
SDLK12_GREATER = 62,
SDLK12_QUESTION = 63,
SDLK12_AT = 64,
SDLK12_LEFTBRACKET = 91,
SDLK12_BACKSLASH = 92,
SDLK12_RIGHTBRACKET = 93,
SDLK12_CARET = 94,
SDLK12_UNDERSCORE = 95,
SDLK12_BACKQUOTE = 96,
SDLK12_a = 97,
SDLK12_b = 98,
SDLK12_c = 99,
SDLK12_d = 100,
SDLK12_e = 101,
SDLK12_f = 102,
SDLK12_g = 103,
SDLK12_h = 104,
SDLK12_i = 105,
SDLK12_j = 106,
SDLK12_k = 107,
SDLK12_l = 108,
SDLK12_m = 109,
SDLK12_n = 110,
SDLK12_o = 111,
SDLK12_p = 112,
SDLK12_q = 113,
SDLK12_r = 114,
SDLK12_s = 115,
SDLK12_t = 116,
SDLK12_u = 117,
SDLK12_v = 118,
SDLK12_w = 119,
SDLK12_x = 120,
SDLK12_y = 121,
SDLK12_z = 122,
SDLK12_DELETE = 127,
SDLK12_WORLD_0 = 160,
SDLK12_WORLD_1 = 161,
SDLK12_WORLD_2 = 162,
SDLK12_WORLD_3 = 163,
SDLK12_WORLD_4 = 164,
SDLK12_WORLD_5 = 165,
SDLK12_WORLD_6 = 166,
SDLK12_WORLD_7 = 167,
SDLK12_WORLD_8 = 168,
SDLK12_WORLD_9 = 169,
SDLK12_WORLD_10 = 170,
SDLK12_WORLD_11 = 171,
SDLK12_WORLD_12 = 172,
SDLK12_WORLD_13 = 173,
SDLK12_WORLD_14 = 174,
SDLK12_WORLD_15 = 175,
SDLK12_WORLD_16 = 176,
SDLK12_WORLD_17 = 177,
SDLK12_WORLD_18 = 178,
SDLK12_WORLD_19 = 179,
SDLK12_WORLD_20 = 180,
SDLK12_WORLD_21 = 181,
SDLK12_WORLD_22 = 182,
SDLK12_WORLD_23 = 183,
SDLK12_WORLD_24 = 184,
SDLK12_WORLD_25 = 185,
SDLK12_WORLD_26 = 186,
SDLK12_WORLD_27 = 187,
SDLK12_WORLD_28 = 188,
SDLK12_WORLD_29 = 189,
SDLK12_WORLD_30 = 190,
SDLK12_WORLD_31 = 191,
SDLK12_WORLD_32 = 192,
SDLK12_WORLD_33 = 193,
SDLK12_WORLD_34 = 194,
SDLK12_WORLD_35 = 195,
SDLK12_WORLD_36 = 196,
SDLK12_WORLD_37 = 197,
SDLK12_WORLD_38 = 198,
SDLK12_WORLD_39 = 199,
SDLK12_WORLD_40 = 200,
SDLK12_WORLD_41 = 201,
SDLK12_WORLD_42 = 202,
SDLK12_WORLD_43 = 203,
SDLK12_WORLD_44 = 204,
SDLK12_WORLD_45 = 205,
SDLK12_WORLD_46 = 206,
SDLK12_WORLD_47 = 207,
SDLK12_WORLD_48 = 208,
SDLK12_WORLD_49 = 209,
SDLK12_WORLD_50 = 210,
SDLK12_WORLD_51 = 211,
SDLK12_WORLD_52 = 212,
SDLK12_WORLD_53 = 213,
SDLK12_WORLD_54 = 214,
SDLK12_WORLD_55 = 215,
SDLK12_WORLD_56 = 216,
SDLK12_WORLD_57 = 217,
SDLK12_WORLD_58 = 218,
SDLK12_WORLD_59 = 219,
SDLK12_WORLD_60 = 220,
SDLK12_WORLD_61 = 221,
SDLK12_WORLD_62 = 222,
SDLK12_WORLD_63 = 223,
SDLK12_WORLD_64 = 224,
SDLK12_WORLD_65 = 225,
SDLK12_WORLD_66 = 226,
SDLK12_WORLD_67 = 227,
SDLK12_WORLD_68 = 228,
SDLK12_WORLD_69 = 229,
SDLK12_WORLD_70 = 230,
SDLK12_WORLD_71 = 231,
SDLK12_WORLD_72 = 232,
SDLK12_WORLD_73 = 233,
SDLK12_WORLD_74 = 234,
SDLK12_WORLD_75 = 235,
SDLK12_WORLD_76 = 236,
SDLK12_WORLD_77 = 237,
SDLK12_WORLD_78 = 238,
SDLK12_WORLD_79 = 239,
SDLK12_WORLD_80 = 240,
SDLK12_WORLD_81 = 241,
SDLK12_WORLD_82 = 242,
SDLK12_WORLD_83 = 243,
SDLK12_WORLD_84 = 244,
SDLK12_WORLD_85 = 245,
SDLK12_WORLD_86 = 246,
SDLK12_WORLD_87 = 247,
SDLK12_WORLD_88 = 248,
SDLK12_WORLD_89 = 249,
SDLK12_WORLD_90 = 250,
SDLK12_WORLD_91 = 251,
SDLK12_WORLD_92 = 252,
SDLK12_WORLD_93 = 253,
SDLK12_WORLD_94 = 254,
SDLK12_WORLD_95 = 255,
SDLK12_KP0 = 256,
SDLK12_KP1 = 257,
SDLK12_KP2 = 258,
SDLK12_KP3 = 259,
SDLK12_KP4 = 260,
SDLK12_KP5 = 261,
SDLK12_KP6 = 262,
SDLK12_KP7 = 263,
SDLK12_KP8 = 264,
SDLK12_KP9 = 265,
SDLK12_KP_PERIOD = 266,
SDLK12_KP_DIVIDE = 267,
SDLK12_KP_MULTIPLY = 268,
SDLK12_KP_MINUS = 269,
SDLK12_KP_PLUS = 270,
SDLK12_KP_ENTER = 271,
SDLK12_KP_EQUALS = 272,
SDLK12_UP = 273,
SDLK12_DOWN = 274,
SDLK12_RIGHT = 275,
SDLK12_LEFT = 276,
SDLK12_INSERT = 277,
SDLK12_HOME = 278,
SDLK12_END = 279,
SDLK12_PAGEUP = 280,
SDLK12_PAGEDOWN = 281,
SDLK12_F1 = 282,
SDLK12_F2 = 283,
SDLK12_F3 = 284,
SDLK12_F4 = 285,
SDLK12_F5 = 286,
SDLK12_F6 = 287,
SDLK12_F7 = 288,
SDLK12_F8 = 289,
SDLK12_F9 = 290,
SDLK12_F10 = 291,
SDLK12_F11 = 292,
SDLK12_F12 = 293,
SDLK12_F13 = 294,
SDLK12_F14 = 295,
SDLK12_F15 = 296,
SDLK12_NUMLOCK = 300,
SDLK12_CAPSLOCK = 301,
SDLK12_SCROLLOCK = 302,
SDLK12_RSHIFT = 303,
SDLK12_LSHIFT = 304,
SDLK12_RCTRL = 305,
SDLK12_LCTRL = 306,
SDLK12_RALT = 307,
SDLK12_LALT = 308,
SDLK12_RMETA = 309,
SDLK12_LMETA = 310,
SDLK12_LSUPER = 311,
SDLK12_RSUPER = 312,
SDLK12_MODE = 313,
SDLK12_COMPOSE = 314,
SDLK12_HELP = 315,
SDLK12_PRINT = 316,
SDLK12_SYSREQ = 317,
SDLK12_BREAK = 318,
SDLK12_MENU = 319,
SDLK12_POWER = 320,
SDLK12_EURO = 321,
SDLK12_UNDO = 322,
SDLK12_LAST
} SDL12Key;
typedef enum
{
KMOD12_NONE = 0x0000,
KMOD12_LSHIFT = 0x0001,
KMOD12_RSHIFT = 0x0002,
KMOD12_LCTRL = 0x0040,
KMOD12_RCTRL = 0x0080,
KMOD12_LALT = 0x0100,
KMOD12_RALT = 0x0200,
KMOD12_LMETA = 0x0400,
KMOD12_RMETA = 0x0800,
KMOD12_NUM = 0x1000,
KMOD12_CAPS = 0x2000,
KMOD12_MODE = 0x4000,
KMOD12_RESERVED = 0x8000
} SDL12Mod;
typedef struct SDL12_keysym
{
Uint8 scancode;
SDL12Key sym;
unsigned int mod; /* SDL12Mod */
Uint16 unicode;
} SDL12_keysym;
#define SDL12_RELEASED 0
#define SDL12_PRESSED 1
#if defined(SDL_VIDEO_DRIVER_X11) /* SDL_VIDEO_DRIVER_X11 refers to the SDL2 headers. */
typedef enum /* this is only used for 1.2 X11 syswm */
{
SDL12_SYSWM_X11
} SDL12_SYSWM_TYPE;
#endif
typedef struct SDL12_SysWMmsg
{
SDL_version version;
#if defined(_WIN32)
HWND hwnd;
UINT msg;
WPARAM wParam;
LPARAM lParam;
#elif defined(SDL_VIDEO_DRIVER_X11)
SDL12_SYSWM_TYPE subsystem;
union { XEvent xevent; } event;
#else
int data; /* unused at the moment. */
#endif
} SDL12_SysWMmsg;
typedef struct SDL12_SysWMinfo
{
SDL_version version;
#if defined(_WIN32)
HWND window;
HGLRC hglrc;
#elif defined(SDL_VIDEO_DRIVER_X11)
SDL12_SYSWM_TYPE subsystem;
union {
struct {
Display *display;
Window window;
void (*lock_func)(void);
void (*unlock_func)(void);
Window fswindow;
Window wmwindow;
Display *gfxdisplay;
} x11;
} info;
#else
int data; /* unused at the moment. */
#endif
} SDL12_SysWMinfo;
typedef enum
{
SDL12_NOEVENT = 0,
SDL12_ACTIVEEVENT,
SDL12_KEYDOWN,
SDL12_KEYUP,
SDL12_MOUSEMOTION,
SDL12_MOUSEBUTTONDOWN,
SDL12_MOUSEBUTTONUP,
SDL12_JOYAXISMOTION,
SDL12_JOYBALLMOTION,
SDL12_JOYHATMOTION,
SDL12_JOYBUTTONDOWN,
SDL12_JOYBUTTONUP,
SDL12_QUIT,
SDL12_SYSWMEVENT,
SDL12_EVENT_RESERVEDA,
SDL12_EVENT_RESERVEDB,
SDL12_VIDEORESIZE,
SDL12_VIDEOEXPOSE,
SDL12_USEREVENT = 24,
SDL12_NUMEVENTS = 32
} SDL12_EventType;
#define SDL12_APPMOUSEFOCUS (1<<0)
#define SDL12_APPINPUTFOCUS (1<<1)
#define SDL12_APPACTIVE (1<<2)
typedef struct
{
Uint8 type;
Uint8 gain;
Uint8 state;
} SDL12_ActiveEvent;
typedef struct
{
Uint8 type;
Uint8 which;
Uint8 state;
SDL12_keysym keysym;
} SDL12_KeyboardEvent;
typedef struct
{
Uint8 type;
Uint8 which;
Uint8 state;
Uint16 x, y;
Sint16 xrel;
Sint16 yrel;
} SDL12_MouseMotionEvent;
typedef struct
{
Uint8 type;
Uint8 which;
Uint8 button;
Uint8 state;
Uint16 x, y;
} SDL12_MouseButtonEvent;
typedef struct
{
Uint8 type;
Uint8 which;
Uint8 axis;
Sint16 value;
} SDL12_JoyAxisEvent;
typedef struct
{
Uint8 type;
Uint8 which;
Uint8 ball;
Sint16 xrel;
Sint16 yrel;
} SDL12_JoyBallEvent;
typedef struct
{
Uint8 type;
Uint8 which;
Uint8 hat;
Uint8 value;
} SDL12_JoyHatEvent;
typedef struct
{
Uint8 type;
Uint8 which;
Uint8 button;
Uint8 state;
} SDL12_JoyButtonEvent;
typedef struct
{
Uint8 type;
int w;
int h;
} SDL12_ResizeEvent;
typedef struct
{
Uint8 type;
} SDL12_ExposeEvent;
typedef struct
{
Uint8 type;
} SDL12_QuitEvent;
typedef struct
{
Uint8 type;
int code;
void *data1;
void *data2;
} SDL12_UserEvent;
typedef struct
{
Uint8 type;
SDL12_SysWMmsg *msg;
} SDL12_SysWMEvent;
typedef union
{
Uint8 type;
SDL12_ActiveEvent active;
SDL12_KeyboardEvent key;
SDL12_MouseMotionEvent motion;
SDL12_MouseButtonEvent button;
SDL12_JoyAxisEvent jaxis;
SDL12_JoyBallEvent jball;
SDL12_JoyHatEvent jhat;
SDL12_JoyButtonEvent jbutton;
SDL12_ResizeEvent resize;
SDL12_ExposeEvent expose;
SDL12_QuitEvent quit;
SDL12_UserEvent user;
SDL12_SysWMEvent syswm;
} SDL12_Event;
typedef int (SDLCALL *SDL12_EventFilter)(const SDL12_Event *event12);
static int SDLCALL EventFilter20to12(void *data, SDL_Event *event20);
typedef Uint32 (SDLCALL *SDL12_TimerCallback)(Uint32 interval);
typedef SDL_TimerCallback SDL12_NewTimerCallback;
typedef struct
{
SDL12_Rect area;
Sint16 hot_x;
Sint16 hot_y;
Uint8 *data;
Uint8 *mask;
Uint8 *save[2];
SDL_Cursor *wm_cursor; /* the real SDL 1.2 has an opaque pointer to a platform-specific cursor here. */
} SDL12_Cursor;
typedef enum
{
SDL12_GRAB_QUERY = -1,
SDL12_GRAB_OFF = 0,
SDL12_GRAB_ON = 1
} SDL12_GrabMode;
typedef enum
{
SDL12_GL_RED_SIZE,
SDL12_GL_GREEN_SIZE,
SDL12_GL_BLUE_SIZE,
SDL12_GL_ALPHA_SIZE,
SDL12_GL_BUFFER_SIZE,
SDL12_GL_DOUBLEBUFFER,
SDL12_GL_DEPTH_SIZE,
SDL12_GL_STENCIL_SIZE,
SDL12_GL_ACCUM_RED_SIZE,
SDL12_GL_ACCUM_GREEN_SIZE,
SDL12_GL_ACCUM_BLUE_SIZE,
SDL12_GL_ACCUM_ALPHA_SIZE,
SDL12_GL_STEREO,
SDL12_GL_MULTISAMPLEBUFFERS,
SDL12_GL_MULTISAMPLESAMPLES,
SDL12_GL_ACCELERATED_VISUAL,
SDL12_GL_SWAP_CONTROL,
SDL12_GL_MAX_ATTRIBUTE
} SDL12_GLattr;
typedef enum
{
SDL12_CD_TRAYEMPTY,
SDL12_CD_STOPPED,
SDL12_CD_PLAYING,
SDL12_CD_PAUSED,
SDL12_CD_ERROR = -1
} SDL12_CDstatus;
typedef struct
{
Uint8 id;
Uint8 type;
Uint16 unused;
Uint32 length;
Uint32 offset;
} SDL12_CDtrack;
typedef struct
{
int id;
SDL12_CDstatus status;
int numtracks;
int cur_track;
int cur_frame;
SDL12_CDtrack track[100]; /* in 1.2, this was SDL_MAX_TRACKS+1 */
} SDL12_CD;
typedef struct
{
Uint32 format;
int nummodes;
SDL12_Rect *modeslist12;
SDL12_Rect **modes12; /* ptrs to each item in modeslist, for SDL_ListModes() */
} VideoModeList;
typedef struct
{
char *name;
SDL_atomic_t refcount;
SDL_JoystickID instance_id;
union {
SDL_Joystick *joystick;
SDL_GameController *controller;
} dev;
} SDL12_Joystick;
struct SDL12_AudioCVT;
typedef void (SDLCALL *SDL12_AudioCVTFilter)(struct SDL12_AudioCVT *cvt, Uint16 format);
/* this is identical to SDL2, except SDL2 forced the structure packing in
some instances, so we can't passthrough without converting the struct. :( */
typedef struct SDL12_AudioCVT
{
int needed;
Uint16 src_format;
Uint16 dst_format;
double rate_incr;
Uint8 *buf;
int len;
int len_cvt;
int len_mult;
double len_ratio;
SDL12_AudioCVTFilter filters[10];
int filter_index;
} SDL12_AudioCVT;
#include "SDL_opengl.h"
#include "SDL_opengl_glext.h"
#define OPENGL_SYM(ext,rc,fn,params,args,ret) typedef rc (GLAPIENTRY *openglfn_##fn##_t) params;
#include "SDL20_syms.h"
typedef struct OpenGLEntryPoints
{
SDL_bool SUPPORTS_Core;
#define OPENGL_EXT(name) SDL_bool SUPPORTS_##name;
#include "SDL20_syms.h"
#define OPENGL_SYM(ext,rc,fn,params,args,ret) openglfn_##fn##_t fn;
#include "SDL20_syms.h"
} OpenGLEntryPoints;
typedef struct QueuedOverlayItem
{
SDL12_Overlay *overlay12;
SDL12_Rect dstrect12;
struct QueuedOverlayItem *next;
} QueuedOverlayItem;
typedef struct SDL12_TimerID_Data
{
SDL_TimerID timer_id;
SDL12_NewTimerCallback callback;
void *param;
struct SDL12_TimerID_Data *next;
struct SDL12_TimerID_Data *prev;
} SDL12_TimerID_Data;
/* This changed from an opaque pointer to an int in 2.0. */
typedef SDL12_TimerID_Data *SDL12_TimerID;
#define SDL12_MAXEVENTS 128
typedef struct EventQueueType
{
SDL12_SysWMmsg syswm_msg; /* save space for a copy of this in case we use it. */
SDL12_Event event12;
struct EventQueueType *next;
} EventQueueType;
static Uint32 InitializedSubsystems20 = 0;
static Uint32 LinkedSDL2VersionInt = 0;
static SDL_bool IsDummyVideo = SDL_FALSE;
static VideoModeList *VideoModes = NULL;
static int VideoModesCount = 0; /* this counts items in VideoModeList, not total video modes. */
static SDL12_VideoInfo VideoInfo12;
static SDL12_Palette VideoInfoPalette12;
static SDL12_PixelFormat VideoInfoVfmt12;
static SDL_PixelFormat *VideoInfoVfmt20 = NULL;
static SDL_bool VideoWindowGrabbed = SDL_FALSE;
static SDL_bool VideoCursorHidden = SDL_FALSE;
static SDL_bool SetVideoModeInProgress = SDL_FALSE;
static SDL_Window *VideoWindow20 = NULL;
static SDL_Renderer *VideoRenderer20 = NULL;
static SDL_mutex *VideoRendererLock = NULL;
static SDL_Texture *VideoTexture20 = NULL;
static SDL12_Surface VideoSurface12Location;
static SDL12_Surface *VideoSurface12 = NULL;
static SDL_Palette *VideoPhysicalPalette20 = NULL;
static Uint32 VideoSurfacePresentTicks = 0;
static Uint32 VideoSurfaceLastPresentTicks = 0;
static SDL_Surface *VideoConvertSurface20 = NULL;
static SDL_GLContext VideoGLContext20 = NULL;
static QueuedOverlayItem QueuedDisplayOverlays; /* the head node */
static QueuedOverlayItem *QueuedDisplayOverlaysTail = &QueuedDisplayOverlays;
static char *WindowTitle = NULL;
static char *WindowIconTitle = NULL;
static SDL_Surface *VideoIcon20 = NULL;
static int EnabledUnicode = 0;
static Uint32 KeyRepeatNextTicks = 0;
static Uint32 KeyRepeatDelay = 0;
static Uint32 KeyRepeatInterval = 0;
static SDL12_Event KeyRepeatEvent;
/* Windows SDL1.2 never uses translated keyboard layouts for compatibility with