1 (*
2  * Hedgewars, a free turn based strategy game
3  * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; version 2 of the License
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  *)
18 
19 {$INCLUDE "options.inc"}
20 
21 unit SDLh;
22 interface
23 
24 {$IFDEF LINUX}
25     {$DEFINE UNIX}
26 {$ENDIF}
27 {$IFDEF FREEBSD}
28     {$DEFINE UNIX}
29 {$ENDIF}
30 {$IFDEF OPENBSD}
31     {$DEFINE UNIX}
32 {$ENDIF}
33 {$IFDEF DARWIN}
34     {$DEFINE UNIX}
35 {$ENDIF}
36 {$IFDEF HAIKU}
37     {$DEFINE UNIX}
38 {$ENDIF}
39 
40 {$IFDEF UNIX}
41     {$IFDEF HAIKU}
42         {$linklib root}
43     {$ELSE}
44         {$IFNDEF ANDROID}
45             {$linklib pthread}
46         {$ENDIF}
47     {$ENDIF}
48 {$ENDIF}
49 
50 {$IFDEF FPC}
51     {$PACKRECORDS C}
52 {$ELSE}
53     {$DEFINE cdecl attribute(cdecl)}
54     type PByte = ^Byte;
55     type PInteger = ^Integer;
56     type PLongInt = ^LongInt;
57 {$ENDIF}
58 
59 (*  SDL  *)
60 const
61 {$IFDEF WINDOWS}
62     SDLLibName = {$IFDEF VCPKG_DEBUG}'SDL2d.dll'{$ELSE}'SDL2.dll'{$ENDIF};
63     SDL_TTFLibName = 'SDL2_ttf.dll';
64     SDL_MixerLibName = 'SDL2_mixer.dll';
65     SDL_ImageLibName = 'SDL2_image.dll';
66     SDL_NetLibName = 'SDL2_net.dll';
67 {$ELSE}
68     SDLLibName = 'libSDL2';
69     SDL_TTFLibName = 'libSDL2_ttf';
70     SDL_MixerLibName = 'libSDL2_mixer';
71     SDL_ImageLibName = 'libSDL2_image';
72     SDL_NetLibName = 'libSDL2_net';
73 {$ENDIF}
74 
75 /////////////////////////////////////////////////////////////////
76 /////////////////////  CONSTANT DEFINITIONS /////////////////////
77 /////////////////////////////////////////////////////////////////
78 
79     SDL_FALSE = 0;
80     SDL_TRUE = 1;
81 
82     // SDL_Init() flags
83     SDL_INIT_TIMER          = $00000001;
84     SDL_INIT_AUDIO          = $00000010;
85     SDL_INIT_VIDEO          = $00000020; // implies SDL_INIT_EVENTS (sdl2)
86     SDL_INIT_JOYSTICK       = $00000200; // implies SDL_INIT_EVENTS (sdl2)
87     SDL_INIT_HAPTIC         = $00001000;
88     SDL_INIT_GAMECONTROLLER = $00002000; // implies SDL_INIT_JOYSTICK
89     SDL_INIT_EVENTS         = $00004000;
90     SDL_INIT_NOPARACHUTE    = $00100000;
91     //SDL_INIT_EVERYTHING                // unsafe, init subsystems one at a time
92 
93     SDL_ALLEVENTS        = $FFFFFFFF;    // dummy event type to prevent stack corruption
94     SDL_APPINPUTFOCUS    = $02;
95 
96     // (some) audio formats from SDL_audio.h
97     AUDIO_S16LSB         = $8010; // Signed 16-bit samples, in little-endian byte order
98     AUDIO_S16MSB         = $9010; // Signed 16-bit samples, in big-endian byte order
99     AUDIO_S16SYS         = {$IFDEF ENDIAN_LITTLE}AUDIO_S16LSB{$ELSE}AUDIO_S16MSB{$ENDIF};
100 
101     // default audio format from SDL_mixer.h
102     //MIX_DEFAULT_FORMAT   = AUDIO_S16SYS;
103     MIX_DEFAULT_FORMAT   = {$IFDEF ENDIAN_LITTLE}AUDIO_S16LSB{$ELSE}AUDIO_S16MSB{$ENDIF};
104 
105     SDL_BUTTON_LEFT      = 1;
106     SDL_BUTTON_MIDDLE    = 2;
107     SDL_BUTTON_RIGHT     = 3;
108     SDL_BUTTON_X1        = 4;
109     SDL_BUTTON_X2        = 5;
110 
111     // SDL_ShowCursor consts
112     SDL_QUERY = -1;
113     SDL_DISABLE = 0;
114     SDL_ENABLE = 1;
115 
116     SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32;
117     SDL_TEXTINPUTEVENT_TEXT_SIZE   = 32;
118 
119     // SDL_Event types
120     // pascal does not support unions as is, so we list here every possible event
121     // and later associate a struct type each
122     SDL_FIRSTEVENT        = 0;              // type
123     SDL_COMMONDEVENT      = 1;              // type and timestamp
124     SDL_QUITEV            = $100;
125     SDL_APP_TERMINATING   = $101;
126     SDL_APP_LOWMEMORY     = $102;
127     SDL_APP_WILLENTERBACKGROUND = $103;
128     SDL_APP_DIDENTERBACKGROUND = $104;
129     SDL_APP_WILLENTERFOREGROUND = $105;
130     SDL_APP_DIDENTERFOREGROUND = $106;
131     SDL_WINDOWEVENT       = $200;
132     SDL_SYSWMEVENT        = $201;
133     SDL_KEYDOWN           = $300;
134     SDL_KEYUP             = $301;
135     SDL_TEXTEDITING       = $302;
136     SDL_TEXTINPUT         = $303;
137     SDL_MOUSEMOTION       = $400;
138     SDL_MOUSEBUTTONDOWN   = $401;
139     SDL_MOUSEBUTTONUP     = $402;
140     SDL_MOUSEWHEEL        = $403;
141     SDL_JOYAXISMOTION     = $600;
142     SDL_JOYBALLMOTION     = $601;
143     SDL_JOYHATMOTION      = $602;
144     SDL_JOYBUTTONDOWN     = $603;
145     SDL_JOYBUTTONUP       = $604;
146     SDL_JOYDEVICEADDED    = $605;
147     SDL_JOYDEVICEREMOVED  = $606;
148     SDL_CONTROLLERAXISMOTION = $650;
149     SDL_CONTROLLERBUTTONDOWN = $651;
150     SDL_CONTROLLERBUTTONUP = $652;
151     SDL_CONTROLLERDEVICEADDED = $653;
152     SDL_CONTROLLERDEVICEREMOVED = $654;
153     SDL_CONTROLLERDEVICEREMAPPED = $655;
154     SDL_FINGERDOWN        = $700;
155     SDL_FINGERUP          = $701;
156     SDL_FINGERMOTION      = $702;
157     SDL_DOLLARGESTURE     = $800;
158     SDL_DOLLARRECORD      = $801;
159     SDL_MULTIGESTURE      = $802;
160     SDL_CLIPBOARDUPDATE   = $900;
161     SDL_DROPFILE          = $1000;
162     SDL_USEREVENT         = $8000;
163     SDL_LASTEVENT         = $FFFF;
164 
165     // SDL_Surface flags
166     SDL_SWSURFACE   = $00000000;  //*< Not used */
167     SDL_PREALLOC    = $00000001;  //*< Surface uses preallocated memory */
168     SDL_RLEACCEL    = $00000002;  //*< Surface is RLE encoded */
169     SDL_DONTFREE    = $00000004;  //*< Surface is referenced internally */
170     SDL_SRCCOLORKEY = $00020000;  // compatibility only
171 
172     // SDL_RendererFlags
173     SDL_RENDERER_SOFTWARE     = $00000001;     //*< The renderer is a software fallback */
174     SDL_RENDERER_ACCELERATED  = $00000002;     //*< The renderer uses hardware acceleration */
175     SDL_RENDERER_PRESENTVSYNC = $00000004;     //*< Present is synchronized with the refresh rate */
176     SDL_RENDERER_TARGETTEXTURE = $00000008;    //*< The renderer supports rendering to texture */
177 
178     // SDL_WindowFlags
179     SDL_WINDOW_FULLSCREEN    = $00000001;      //*< fullscreen window, implies borderless */
180     SDL_WINDOW_OPENGL        = $00000002;      //*< window usable with OpenGL context */
181     SDL_WINDOW_SHOWN         = $00000004;      //*< window is visible */
182     SDL_WINDOW_HIDDEN        = $00000008;      //*< window is not visible */
183     SDL_WINDOW_BORDERLESS    = $00000010;      //*< no window decoration */
184     SDL_WINDOW_RESIZABLE     = $00000020;      //*< window can be resized */
185     SDL_WINDOW_MINIMIZED     = $00000040;      //*< window is minimized */
186     SDL_WINDOW_MAXIMIZED     = $00000080;      //*< window is maximized */
187     SDL_WINDOW_INPUT_GRABBED = $00000100;      //*< window has grabbed input focus */
188     SDL_WINDOW_INPUT_FOCUS   = $00000200;      //*< window has input focus */
189     SDL_WINDOW_MOUSE_FOCUS   = $00000400;      //*< window has mouse focus */
190     SDL_WINDOW_FULLSCREEN_DESKTOP = $00001001; //*< fullscreen as maximed window */
191     SDL_WINDOW_FOREIGN       = $00000800;      //*< window not created by SDL */
192 
193     SDL_WINDOWPOS_CENTERED_MASK = $2FFF0000;
194 
195     // SDL_WindowEventID
196     SDL_WINDOWEVENT_NONE         = 0;    //*< Never used
197     SDL_WINDOWEVENT_SHOWN        = 1;    //*< Window has been shown
198     SDL_WINDOWEVENT_HIDDEN       = 2;    //*< Window has been hidden
199     SDL_WINDOWEVENT_EXPOSED      = 3;    //*< Window has been exposed and should be redrawn
200     SDL_WINDOWEVENT_MOVED        = 4;    //*< Window has been moved to data1, data2
201     SDL_WINDOWEVENT_RESIZED      = 5;    //*< Window size changed to data1xdata2
202     SDL_WINDOWEVENT_SIZE_CHANGED = 6;    //*< The window size has changed, [...] */
203     SDL_WINDOWEVENT_MINIMIZED    = 7;    //*< Window has been minimized
204     SDL_WINDOWEVENT_MAXIMIZED    = 8;    //*< Window has been maximized
205     SDL_WINDOWEVENT_RESTORED     = 9;    //*< Window has been restored to normal size and position
206     SDL_WINDOWEVENT_ENTER        = 10;   //*< Window has gained mouse focus
207     SDL_WINDOWEVENT_LEAVE        = 11;   //*< Window has lost mouse focus
208     SDL_WINDOWEVENT_FOCUS_GAINED = 12;   //*< Window has gained keyboard focus
209     SDL_WINDOWEVENT_FOCUS_LOST   = 13;   //*< Window has lost keyboard focus
210     SDL_WINDOWEVENT_CLOSE        = 14;   //*< The window manager requests that the window be closed */
211 
212 {$IFDEF ENDIAN_LITTLE}
213     RMask = $000000FF;
214     GMask = $0000FF00;
215     BMask = $00FF0000;
216     AMask = $FF000000;
217     RShift = 0;
218     GShift = 8;
219     BShift = 16;
220     AShift = 24;
221     AByteIndex = 3;
222 {$ELSE}
223     RMask = $FF000000;
224     GMask = $00FF0000;
225     BMask = $0000FF00;
226     AMask = $000000FF;
227     RShift = 24;
228     GShift = 16;
229     BShift = 8;
230     AShift = 0;
231     AByteIndex = 0;
232 {$ENDIF}
233 
234     KMOD_NONE   = $0000;
235     KMOD_LSHIFT = $0001;
236     KMOD_RSHIFT = $0002;
237     KMOD_LCTRL  = $0040;
238     KMOD_RCTRL  = $0080;
239     KMOD_LALT   = $0400;
240     KMOD_RALT   = $0800;
241     KMOD_LMETA  = $0400;
242     KMOD_RMETA  = $0800;
243     KMOD_NUM    = $1000;
244     KMOD_CAPS   = $2000;
245     KMOD_MODE   = $4000;
246 
247     {* SDL_mixer *}
248     MIX_MAX_VOLUME      = 128;
249     MIX_INIT_FLAC       = $00000001;
250     MIX_INIT_MOD        = $00000002;
251     MIX_INIT_MODPLUG    = $00000004;
252     MIX_INIT_MP3        = $00000008;
253     MIX_INIT_OGG        = $00000010;
254     MIX_INIT_FLUIDSYNTH = $00000020;
255     MIX_INIT_OPUS       = $00000040;
256 
257     {* SDL_TTF *}
258     TTF_STYLE_NORMAL = 0;
259     TTF_STYLE_BOLD   = 1;
260     TTF_STYLE_ITALIC = 2;
261 
262     {* SDL Joystick *}
263     SDL_HAT_CENTERED  = $00;
264     SDL_HAT_UP        = $01;
265     SDL_HAT_RIGHT     = $02;
266     SDL_HAT_DOWN      = $04;
267     SDL_HAT_LEFT      = $08;
268     SDL_HAT_RIGHTUP   = SDL_HAT_RIGHT or SDL_HAT_UP;
269     SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN;
270     SDL_HAT_LEFTUP    = SDL_HAT_LEFT  or SDL_HAT_UP;
271     SDL_HAT_LEFTDOWN  = SDL_HAT_LEFT  or SDL_HAT_DOWN;
272 
273     {* SDL_image *}
274     IMG_INIT_JPG = $00000001;
275     IMG_INIT_PNG = $00000002;
276     IMG_INIT_TIF = $00000004;
277 
278     {* SDL_keycode *}
279     SDLK_UNKNOWN = 0;
280     SDLK_BACKSPACE = 8;
281     SDLK_RETURN    = 13;
282     SDLK_ESCAPE    = 27;
283     SDLK_a         = 97;
284     SDLK_c         = 99;
285     SDLK_q         = 113;
286     SDLK_v         = 118;
287     SDLK_w         = 119;
288     SDLK_x         = 120;
289     SDLK_DELETE    = 127;
290     SDLK_KP_ENTER  = 271;
291     SDLK_UP        = 273;
292     SDLK_DOWN      = 274;
293     SDLK_RIGHT     = 275;
294     SDLK_LEFT      = 276;
295     SDLK_HOME      = 278;
296     SDLK_END       = 279;
297     SDLK_PAGEUP    = 280;
298     SDLK_PAGEDOWN  = 281;
299 
300     // special keycodes (for modifier keys etc. will have this bit set)
301     SDLK_SCANCODE_MASK = (1 shl 30);
302 
303     SDL_SCANCODE_UNKNOWN = 0;
304     SDL_SCANCODE_A = 4;
305     SDL_SCANCODE_B = 5;
306     SDL_SCANCODE_C = 6;
307     SDL_SCANCODE_D = 7;
308     SDL_SCANCODE_E = 8;
309     SDL_SCANCODE_F = 9;
310     SDL_SCANCODE_G = 10;
311     SDL_SCANCODE_H = 11;
312     SDL_SCANCODE_I = 12;
313     SDL_SCANCODE_J = 13;
314     SDL_SCANCODE_K = 14;
315     SDL_SCANCODE_L = 15;
316     SDL_SCANCODE_M = 16;
317     SDL_SCANCODE_N = 17;
318     SDL_SCANCODE_O = 18;
319     SDL_SCANCODE_P = 19;
320     SDL_SCANCODE_Q = 20;
321     SDL_SCANCODE_R = 21;
322     SDL_SCANCODE_S = 22;
323     SDL_SCANCODE_T = 23;
324     SDL_SCANCODE_U = 24;
325     SDL_SCANCODE_V = 25;
326     SDL_SCANCODE_W = 26;
327     SDL_SCANCODE_X = 27;
328     SDL_SCANCODE_Y = 28;
329     SDL_SCANCODE_Z = 29;
330     SDL_SCANCODE_1 = 30;
331     SDL_SCANCODE_2 = 31;
332     SDL_SCANCODE_3 = 32;
333     SDL_SCANCODE_4 = 33;
334     SDL_SCANCODE_5 = 34;
335     SDL_SCANCODE_6 = 35;
336     SDL_SCANCODE_7 = 36;
337     SDL_SCANCODE_8 = 37;
338     SDL_SCANCODE_9 = 38;
339     SDL_SCANCODE_0 = 39;
340     SDL_SCANCODE_RETURN = 40;
341     SDL_SCANCODE_ESCAPE = 41;
342     SDL_SCANCODE_BACKSPACE = 42;
343     SDL_SCANCODE_TAB = 43;
344     SDL_SCANCODE_SPACE = 44;
345     SDL_SCANCODE_MINUS = 45;
346     SDL_SCANCODE_EQUALS = 46;
347     SDL_SCANCODE_LEFTBRACKET = 47;
348     SDL_SCANCODE_RIGHTBRACKET = 48;
349     SDL_SCANCODE_BACKSLASH = 49;
350     SDL_SCANCODE_NONUSHASH = 50;
351     SDL_SCANCODE_SEMICOLON = 51;
352     SDL_SCANCODE_APOSTROPHE = 52;
353     SDL_SCANCODE_GRAVE = 53;
354     SDL_SCANCODE_COMMA = 54;
355     SDL_SCANCODE_PERIOD = 55;
356     SDL_SCANCODE_SLASH = 56;
357     SDL_SCANCODE_CAPSLOCK = 57;
358     SDL_SCANCODE_F1 = 58;
359     SDL_SCANCODE_F2 = 59;
360     SDL_SCANCODE_F3 = 60;
361     SDL_SCANCODE_F4 = 61;
362     SDL_SCANCODE_F5 = 62;
363     SDL_SCANCODE_F6 = 63;
364     SDL_SCANCODE_F7 = 64;
365     SDL_SCANCODE_F8 = 65;
366     SDL_SCANCODE_F9 = 66;
367     SDL_SCANCODE_F10 = 67;
368     SDL_SCANCODE_F11 = 68;
369     SDL_SCANCODE_F12 = 69;
370     SDL_SCANCODE_PRINTSCREEN = 70;
371     SDL_SCANCODE_SCROLLLOCK = 71;
372     SDL_SCANCODE_PAUSE = 72;
373     SDL_SCANCODE_INSERT = 73;
374     SDL_SCANCODE_HOME = 74;
375     SDL_SCANCODE_PAGEUP = 75;
376     SDL_SCANCODE_DELETE = 76;
377     SDL_SCANCODE_END = 77;
378     SDL_SCANCODE_PAGEDOWN = 78;
379     SDL_SCANCODE_RIGHT = 79;
380     SDL_SCANCODE_LEFT = 80;
381     SDL_SCANCODE_DOWN = 81;
382     SDL_SCANCODE_UP = 82;
383     SDL_SCANCODE_NUMLOCKCLEAR = 83;
384     SDL_SCANCODE_KP_DIVIDE = 84;
385     SDL_SCANCODE_KP_MULTIPLY = 85;
386     SDL_SCANCODE_KP_MINUS = 86;
387     SDL_SCANCODE_KP_PLUS = 87;
388     SDL_SCANCODE_KP_ENTER = 88;
389     SDL_SCANCODE_KP_1 = 89;
390     SDL_SCANCODE_KP_2 = 90;
391     SDL_SCANCODE_KP_3 = 91;
392     SDL_SCANCODE_KP_4 = 92;
393     SDL_SCANCODE_KP_5 = 93;
394     SDL_SCANCODE_KP_6 = 94;
395     SDL_SCANCODE_KP_7 = 95;
396     SDL_SCANCODE_KP_8 = 96;
397     SDL_SCANCODE_KP_9 = 97;
398     SDL_SCANCODE_KP_0 = 98;
399     SDL_SCANCODE_KP_PERIOD = 99;
400     SDL_SCANCODE_NONUSBACKSLASH = 100;
401     SDL_SCANCODE_APPLICATION = 101;
402     SDL_SCANCODE_POWER = 102;
403     SDL_SCANCODE_KP_EQUALS = 103;
404     SDL_SCANCODE_F13 = 104;
405     SDL_SCANCODE_F14 = 105;
406     SDL_SCANCODE_F15 = 106;
407     SDL_SCANCODE_F16 = 107;
408     SDL_SCANCODE_F17 = 108;
409     SDL_SCANCODE_F18 = 109;
410     SDL_SCANCODE_F19 = 110;
411     SDL_SCANCODE_F20 = 111;
412     SDL_SCANCODE_F21 = 112;
413     SDL_SCANCODE_F22 = 113;
414     SDL_SCANCODE_F23 = 114;
415     SDL_SCANCODE_F24 = 115;
416     SDL_SCANCODE_EXECUTE = 116;
417     SDL_SCANCODE_HELP = 117;
418     SDL_SCANCODE_MENU = 118;
419     SDL_SCANCODE_SELECT = 119;
420     SDL_SCANCODE_STOP = 120;
421     SDL_SCANCODE_AGAIN = 121;
422     SDL_SCANCODE_UNDO = 122;
423     SDL_SCANCODE_CUT = 123;
424     SDL_SCANCODE_COPY = 124;
425     SDL_SCANCODE_PASTE = 125;
426     SDL_SCANCODE_FIND = 126;
427     SDL_SCANCODE_MUTE = 127;
428     SDL_SCANCODE_VOLUMEUP = 128;
429     SDL_SCANCODE_VOLUMEDOWN = 129;
430     SDL_SCANCODE_KP_COMMA = 133;
431     SDL_SCANCODE_KP_EQUALSAS400 = 134;
432     SDL_SCANCODE_INTERNATIONAL1 = 135;
433     SDL_SCANCODE_INTERNATIONAL2 = 136;
434     SDL_SCANCODE_INTERNATIONAL3 = 137;
435     SDL_SCANCODE_INTERNATIONAL4 = 138;
436     SDL_SCANCODE_INTERNATIONAL5 = 139;
437     SDL_SCANCODE_INTERNATIONAL6 = 140;
438     SDL_SCANCODE_INTERNATIONAL7 = 141;
439     SDL_SCANCODE_INTERNATIONAL8 = 142;
440     SDL_SCANCODE_INTERNATIONAL9 = 143;
441     SDL_SCANCODE_LANG1 = 144; (*< Hangul/English toggle *)
442     SDL_SCANCODE_LANG2 = 145; (*< Hanja conversion *)
443     SDL_SCANCODE_LANG3 = 146; (*< Katakana *)
444     SDL_SCANCODE_LANG4 = 147; (*< Hiragana *)
445     SDL_SCANCODE_LANG5 = 148; (*< Zenkaku/Hankaku *)
446     SDL_SCANCODE_LANG6 = 149; (*< reserved *)
447     SDL_SCANCODE_LANG7 = 150; (*< reserved *)
448     SDL_SCANCODE_LANG8 = 151; (*< reserved *)
449     SDL_SCANCODE_LANG9 = 152; (*< reserved *)
450     SDL_SCANCODE_ALTERASE = 153;
451     SDL_SCANCODE_SYSREQ = 154;
452     SDL_SCANCODE_CANCEL = 155;
453     SDL_SCANCODE_CLEAR = 156;
454     SDL_SCANCODE_PRIOR = 157;
455     SDL_SCANCODE_RETURN2 = 158;
456     SDL_SCANCODE_SEPARATOR = 159;
457     SDL_SCANCODE_OUT = 160;
458     SDL_SCANCODE_OPER = 161;
459     SDL_SCANCODE_CLEARAGAIN = 162;
460     SDL_SCANCODE_CRSEL = 163;
461     SDL_SCANCODE_EXSEL = 164;
462     SDL_SCANCODE_KP_00 = 176;
463     SDL_SCANCODE_KP_000 = 177;
464     SDL_SCANCODE_THOUSANDSSEPARATOR = 178;
465     SDL_SCANCODE_DECIMALSEPARATOR = 179;
466     SDL_SCANCODE_CURRENCYUNIT = 180;
467     SDL_SCANCODE_CURRENCYSUBUNIT = 181;
468     SDL_SCANCODE_KP_LEFTPAREN = 182;
469     SDL_SCANCODE_KP_RIGHTPAREN = 183;
470     SDL_SCANCODE_KP_LEFTBRACE = 184;
471     SDL_SCANCODE_KP_RIGHTBRACE = 185;
472     SDL_SCANCODE_KP_TAB = 186;
473     SDL_SCANCODE_KP_BACKSPACE = 187;
474     SDL_SCANCODE_KP_A = 188;
475     SDL_SCANCODE_KP_B = 189;
476     SDL_SCANCODE_KP_C = 190;
477     SDL_SCANCODE_KP_D = 191;
478     SDL_SCANCODE_KP_E = 192;
479     SDL_SCANCODE_KP_F = 193;
480     SDL_SCANCODE_KP_XOR = 194;
481     SDL_SCANCODE_KP_PERCENT = 196;
482     SDL_SCANCODE_KP_LESS = 197;
483     SDL_SCANCODE_KP_GREATER = 198;
484     SDL_SCANCODE_KP_AMPERSAND = 199;
485     SDL_SCANCODE_KP_DBLAMPERSAND = 200;
486     SDL_SCANCODE_KP_VERTICALBAR = 201;
487     SDL_SCANCODE_KP_DBLVERTICALBAR = 202;
488     SDL_SCANCODE_KP_COLON = 203;
489     SDL_SCANCODE_KP_HASH = 204;
490     SDL_SCANCODE_KP_SPACE = 205;
491     SDL_SCANCODE_KP_AT = 206;
492     SDL_SCANCODE_KP_EXCLAM = 207;
493     SDL_SCANCODE_KP_MEMSTORE = 208;
494     SDL_SCANCODE_KP_MEMRECALL = 209;
495     SDL_SCANCODE_KP_MEMCLEAR = 210;
496     SDL_SCANCODE_KP_MEMADD = 211;
497     SDL_SCANCODE_KP_MEMSUBTRACT = 212;
498     SDL_SCANCODE_KP_MEMMULTIPLY = 213;
499     SDL_SCANCODE_KP_MEMDIVIDE = 214;
500     SDL_SCANCODE_KP_PLUSMINUS = 215;
501     SDL_SCANCODE_KP_CLEAR = 216;
502     SDL_SCANCODE_KP_CLEARENTRY = 217;
503     SDL_SCANCODE_KP_BINARY = 218;
504     SDL_SCANCODE_KP_OCTAL = 219;
505     SDL_SCANCODE_KP_DECIMAL = 220;
506     SDL_SCANCODE_KP_HEXADECIMAL = 221;
507     SDL_SCANCODE_LCTRL = 224;
508     SDL_SCANCODE_LSHIFT = 225;
509     SDL_SCANCODE_LALT = 226;
510     SDL_SCANCODE_LGUI = 227;
511     SDL_SCANCODE_RCTRL = 228;
512     SDL_SCANCODE_RSHIFT = 229;
513     SDL_SCANCODE_RALT = 230;
514     SDL_SCANCODE_RGUI = 231;
515     SDL_SCANCODE_MODE = 257;
516     SDL_SCANCODE_AUDIONEXT = 258;
517     SDL_SCANCODE_AUDIOPREV = 259;
518     SDL_SCANCODE_AUDIOSTOP = 260;
519     SDL_SCANCODE_AUDIOPLAY = 261;
520     SDL_SCANCODE_AUDIOMUTE = 262;
521     SDL_SCANCODE_MEDIASELECT = 263;
522     SDL_SCANCODE_WWW = 264;
523     SDL_SCANCODE_MAIL = 265;
524     SDL_SCANCODE_CALCULATOR = 266;
525     SDL_SCANCODE_COMPUTER = 267;
526     SDL_SCANCODE_AC_SEARCH = 268;
527     SDL_SCANCODE_AC_HOME = 269;
528     SDL_SCANCODE_AC_BACK = 270;
529     SDL_SCANCODE_AC_FORWARD = 271;
530     SDL_SCANCODE_AC_STOP = 272;
531     SDL_SCANCODE_AC_REFRESH = 273;
532     SDL_SCANCODE_AC_BOOKMARKS = 274;
533     SDL_SCANCODE_BRIGHTNESSDOWN = 275;
534     SDL_SCANCODE_BRIGHTNESSUP = 276;
535     SDL_SCANCODE_DISPLAYSWITCH = 277;
536     SDL_SCANCODE_KBDILLUMTOGGLE = 278;
537     SDL_SCANCODE_KBDILLUMDOWN = 279;
538     SDL_SCANCODE_KBDILLUMUP = 280;
539     SDL_SCANCODE_EJECT = 281;
540     SDL_SCANCODE_SLEEP = 282;
541     SDL_SCANCODE_APP1 = 283;
542     SDL_SCANCODE_APP2 = 284;
543 
544 /////////////////////////////////////////////////////////////////
545 ///////////////////////  TYPE DEFINITIONS ///////////////////////
546 /////////////////////////////////////////////////////////////////
547 
548 // two important reference points for the wanderers of this area
549 // https://www.freepascal.org/docs-html/ref/refsu5.html
550 // https://www.freepascal.org/docs-html/prog/progsu144.html
551 
552 type
553     PSDL_Window   = Pointer;
554     PSDL_Renderer = Pointer;
555     PSDL_Texture  = Pointer;
556     PSDL_GLContext= Pointer;
557     TSDL_TouchId  = Int64;
558     TSDL_FingerId = Int64;
559     TSDL_Keycode = LongInt;
560     TSDL_Scancode = LongInt;
561     TSDL_JoystickID = LongInt;
562     TSDL_bool = LongInt;
563 
564     TSDL_eventaction = (SDL_ADDEVENT, SDL_PEEPEVENT, SDL_GETEVENT);
565 
566     PSDL_Rect = ^TSDL_Rect;
567     TSDL_Rect = record
568         x, y, w, h: LongInt;
569         end;
570 
571     TPoint = record
572         x, y: LongInt;
573         end;
574 
575     PSDL_PixelFormat = ^TSDL_PixelFormat;
576     TSDL_PixelFormat = record
577         format: LongWord;
578         palette: Pointer;
579         BitsPerPixel : Byte;
580         BytesPerPixel: Byte;
581         padding: array[0..1] of Byte;
582         RMask : LongWord;
583         GMask : LongWord;
584         BMask : LongWord;
585         AMask : LongWord;
586         Rloss : Byte;
587         Gloss : Byte;
588         Bloss : Byte;
589         Aloss : Byte;
590         Rshift: Byte;
591         Gshift: Byte;
592         Bshift: Byte;
593         Ashift: Byte;
594         refcount: LongInt;
595         next: PSDL_PixelFormat;
596         end;
597 
598     PSDL_Surface = ^TSDL_Surface;
599     TSDL_Surface = record
600         flags : LongWord;
601         format: PSDL_PixelFormat;
602         w, h  : LongInt;
603         pitch : LongInt;
604         pixels: Pointer;
605 {$IFDEF PAS2C}
606         hwdata   : Pointer;
607         clip_rect: TSDL_Rect;
608         unsed1   : LongWord;
609         locked   : LongWord;
610         map      : Pointer;
611         format_version: Longword;
612         refcount : LongInt;
613         offset   : LongInt;
614 {$ELSE}
615         userdata  : Pointer;
616         locked    : LongInt;
617         lock_data : Pointer;
618         clip_rect : TSDL_Rect;
619         map       : Pointer;
620         refcount  : LongInt;
621 {$ENDIF}
622         end;
623 
624 
625     PSDL_Color = ^TSDL_Color;
626     TSDL_Color = record
627             r: Byte;
628             g: Byte;
629             b: Byte;
630             a: Byte; //sdl12 name is 'unused' but as long as size matches...
631         end;
632 
633 
634     (* SDL_RWops and friends *)
635     PSDL_RWops = ^TSDL_RWops;
contextnull636     TSize  = function( context: PSDL_RWops): Int64; cdecl;
contextnull637     TSeek  = function( context: PSDL_RWops; offset: Int64; whence: LongInt ): Int64; cdecl;
contextnull638     TRead  = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt;  cdecl;
contextnull639     TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl;
contextnull640     TClose = function( context: PSDL_RWops ): LongInt; cdecl;
641 
642     TStdio = record
643         autoclose: Boolean;
644         fp: Pointer;
645         end;
646 
647     TMem = record
648         base: PByte;
649         here: PByte;
650         stop: PByte;
651         end;
652 
653     TUnknown = record
654         data1: Pointer;
655         data2: Pointer;
656         end;
657 
658 {$IFDEF ANDROID}
659     TAndroidio = record
660         fileName, inputStream, readableByteChannel: Pointer;
661         readMethod, assetFileDescriptor: Pointer;
662         position, size, offset: Int64;
663         fd: LongInt;
664         end;
665 {$ELSE}
666 {$IFDEF WINDOWS}
667     TWinbuffer = record
668         data: Pointer;
669         size, left: LongInt;
670         end;
671     TWindowsio = record
672         append : Boolean;
673         h : Pointer;
674         buffer : TWinbuffer;
675         end;
676 {$ENDIF}
677 {$ENDIF}
678 
679     TSDL_RWops = record
680         size: TSize;
681         seek: TSeek;
682         read: TRead;
683         write: TWrite;
684         close: TClose;
685         type_: LongWord;
686         case Byte of
687 {$IFDEF ANDROID}
688             0: (androidio: TAndroidio);
689 {$ELSE}
690 {$IFDEF WINDOWS}
691             0: (windowsio: TWindowsio);
692 {$ENDIF}
693 {$ENDIF}
694             1: (stdio: TStdio);     // assumes HAVE_STDIO_H
695             2: (mem: TMem);
696             3: (unknown: TUnknown);
697             end;
698 
699 
700 {* SDL_Event type definition *}
701 
702     TSDL_Keysym = record
703         scancode: TSDL_Scancode;
704         sym: TSDL_Keycode;
705         modifier: Word;
706         unused: LongWord;
707         end;
708 
709     TSDL_WindowEvent = record
710         type_: LongWord;
711         timestamp: LongWord;
712         windowID: LongWord;
713         event: Byte;
714         padding1, padding2, padding3: Byte;
715         data1, data2: LongInt;
716         end;
717 
718     TSDL_TextEditingEvent = record
719         type_: Longword;
720         timestamp: Longword;
721         windowID: Longword;
722         text: array [0..SDL_TEXTEDITINGEVENT_TEXT_SIZE - 1] of char;
723         start: LongInt;
724         length: LongInt;
725         end;
726 
727     TSDL_TextInputEvent = record
728         type_: Longword;
729         timestamp: Longword;
730         windowID: Longword;
731         text: array [0..SDL_TEXTINPUTEVENT_TEXT_SIZE - 1] of char;
732         end;
733 
734     TSDL_TouchFingerEvent = record
735         type_: LongWord;
736         timestamp: LongWord;
737         touchId: TSDL_TouchId;
738         fingerId: TSDL_FingerId;
739         x, y, dx, dy: Single;
740         pressure: Single;
741         end;
742 
743     TSDL_MultiGestureEvent = record
744         type_: LongWord;
745         timestamp: LongWord;
746         touchId: TSDL_TouchId;
747         dTheta, dDist, x, y: Single;
748         numFingers, padding: Word;
749         end;
750 
751     TSDL_DollarGestureEvent = record
752         type_: LongWord;
753         timestamp: LongWord;
754         touchId: Int64;
755         gesturedId: Int64;
756         numFingers: LongWord;
757         error, x, y: Single;
758         end;
759 
760     TSDL_DropEvent = record
761         type_: LongWord;
762         timestamp: LongWord;
763         filename: PChar;
764         end;
765 
766     TSDL_SysWMEvent = record
767         type_: LongWord;
768         timestamp: LongWord;
769         msg: Pointer;
770         end;
771 
772     TSDL_ControllerAxisEvent = record
773         type_: LongWord;
774         timestamp: LongWord;
775         which: TSDL_JoystickID;
776         axis, padding1, padding2, padding3: Byte;
777         value: SmallInt;
778         padding4: Word;
779         end;
780 
781     TSDL_ControllerButtonEvent = record
782         type_: LongWord;
783         timestamp: LongWord;
784         which: TSDL_JoystickID;
785         button, states, padding1, padding2: Byte;
786         end;
787 
788     TSDL_ControllerDeviceEvent = record
789         type_: LongWord;
790         timestamp: LongWord;
791         which: LongInt;
792         end;
793 
794     TSDL_JoyDeviceEvent = TSDL_ControllerDeviceEvent;
795 
796     TSDL_CommonEvent = record
797         type_: LongWord;
798         timestamp: LongWord;
799         end;
800 
801     TSDL_OSEvent = TSDL_CommonEvent;
802 
803     TSDL_KeyboardEvent = record
804         type_: LongWord;
805         timestamp: LongWord;
806         windowID: LongWord;
807         state, repeat_, padding2, padding3: Byte;
808         keysym: TSDL_Keysym;
809         end;
810 
811     TSDL_MouseMotionEvent = record
812         type_: LongWord;
813         timestamp: LongWord;
814         windowID: LongWord;
815         which, state: LongWord;
816         x, y, xrel, yrel: LongInt;
817         end;
818 
819     TSDL_MouseButtonEvent = record
820         type_: LongWord;
821         timestamp: LongWord;
822         windowID: LongWord;
823         which: LongWord;
824         button, state, padding1, padding2: Byte;
825         x, y: LongInt;
826         end;
827 
828     TSDL_MouseWheelEvent = record
829         type_: LongWord;
830         timestamp: LongWord;
831         windowID: LongWord;
832         which: LongWord;
833         x, y: LongInt;
834         end;
835 
836     TSDL_JoyAxisEvent = record
837         type_: LongWord;
838         timestamp: LongWord;
839         which: TSDL_JoystickID;
840         axis: Byte;
841         padding1, padding2, padding3: Byte;
842         value: SmallInt;
843         padding4: Word;
844         end;
845 
846     TSDL_JoyBallEvent = record
847         type_: LongWord;
848         timestamp: LongWord;
849         which: TSDL_JoystickID;
850         ball: Byte;
851         padding1, padding2, padding3: Byte;
852         xrel, yrel: SmallInt;
853         end;
854 
855     TSDL_JoyHatEvent = record
856         type_: LongWord;
857         timestamp: LongWord;
858         which: TSDL_JoystickID;
859         hat: Byte;
860         value: Byte;
861         padding1, padding2: Byte;
862         end;
863 
864     TSDL_JoyButtonEvent = record
865         type_: LongWord;
866         timestamp: LongWord;
867         which: TSDL_JoystickID;
868         button: Byte;
869         state: Byte;
870         padding1: Byte;
871         padding2: Byte;
872         end;
873 
874     TSDL_QuitEvent = record
875         type_: LongWord;
876         timestamp: LongWord;
877         end;
878 
879     TSDL_UserEvent = record
880         type_: LongWord;
881         timestamp: LongWord;
882         windowID: LongWord;
883         code: LongInt;
884         data1, data2: Pointer;
885         end;
886 
887     PSDL_Event = ^TSDL_Event;
888     TSDL_Event = record
889         case LongInt of
890             SDL_FIRSTEVENT: (type_: LongWord);
891             SDL_COMMONDEVENT: (common: TSDL_CommonEvent);
892             SDL_WINDOWEVENT: (window: TSDL_WindowEvent);
893             SDL_KEYDOWN,
894             SDL_KEYUP: (key: TSDL_KeyboardEvent);
895             SDL_TEXTEDITING: (edit: TSDL_TextEditingEvent);
896             SDL_TEXTINPUT: (text: TSDL_TextInputEvent);
897             SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
898             SDL_MOUSEBUTTONDOWN,
899             SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
900             SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent);
901             SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
902             SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
903             SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
904             SDL_JOYBUTTONDOWN,
905             SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
906             SDL_JOYDEVICEADDED,
907             SDL_JOYDEVICEREMOVED: (jdevice: TSDL_JoyDeviceEvent);
908             SDL_CONTROLLERAXISMOTION: (caxis: TSDL_ControllerAxisEvent);
909             SDL_CONTROLLERBUTTONUP,
910             SDL_CONTROLLERBUTTONDOWN: (cbutton: TSDL_ControllerButtonEvent);
911             SDL_CONTROLLERDEVICEADDED,
912             SDL_CONTROLLERDEVICEREMAPPED,
913             SDL_CONTROLLERDEVICEREMOVED: (cdevice: TSDL_ControllerDeviceEvent);
914             SDL_QUITEV: (quit: TSDL_QuitEvent);
915             SDL_USEREVENT: (user: TSDL_UserEvent);
916             SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent);
917             SDL_FINGERDOWN,
918             SDL_FINGERUP,
919             SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent);
920             SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent);
921             SDL_DOLLARGESTURE: (dgesture: TSDL_DollarGestureEvent);
922             SDL_DROPFILE: (drop: TSDL_DropEvent);
923             SDL_ALLEVENTS: (foo: shortstring);
924         end;
925 
eventnull926     TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl;
927 
928     TByteArray = array[0..65535] of Byte;
929     PByteArray = ^TByteArray;
930 
931     TLongWordArray = array[0..16383] of LongWord;
932     PLongWordArray = ^TLongWordArray;
933 
934     PSDL_Thread = Pointer;
935     PSDL_mutex = Pointer;
936     PSDL_sem = Pointer;
937 
938     TSDL_GLattr = (
939         SDL_GL_RED_SIZE,
940         SDL_GL_GREEN_SIZE,
941         SDL_GL_BLUE_SIZE,
942         SDL_GL_ALPHA_SIZE,
943         SDL_GL_BUFFER_SIZE,
944         SDL_GL_DOUBLEBUFFER,
945         SDL_GL_DEPTH_SIZE,
946         SDL_GL_STENCIL_SIZE,
947         SDL_GL_ACCUM_RED_SIZE,
948         SDL_GL_ACCUM_GREEN_SIZE,
949         SDL_GL_ACCUM_BLUE_SIZE,
950         SDL_GL_ACCUM_ALPHA_SIZE,
951         SDL_GL_STEREO,
952         SDL_GL_MULTISAMPLEBUFFERS,
953         SDL_GL_MULTISAMPLESAMPLES,
954         SDL_GL_ACCELERATED_VISUAL,
955         SDL_GL_RETAINED_BACKING,
956         SDL_GL_CONTEXT_MAJOR_VERSION,
957         SDL_GL_CONTEXT_MINOR_VERSION,
958         SDL_GL_CONTEXT_EGL,
959         SDL_GL_CONTEXT_FLAGS,
960         SDL_GL_CONTEXT_PROFILE_MASK,
961         SDL_GL_SHARE_WITH_CURRENT_CONTEXT
962         );
963 
964     TSDL_ArrayByteOrder = (  // array component order, low Byte -> high Byte
965         SDL_ARRAYORDER_NONE,
966         SDL_ARRAYORDER_RGB,
967         SDL_ARRAYORDER_RGBA,
968         SDL_ARRAYORDER_ARGB,
969         SDL_ARRAYORDER_BGR,
970         SDL_ARRAYORDER_BGRA,
971         SDL_ARRAYORDER_ABGR
972         );
973 
974     // Joystick/Controller support
975     PSDL_Joystick = ^TSDL_Joystick;
976     TSDL_Joystick = record
977             end;
978 
979     {* SDL_TTF *}
980     PTTF_Font = ^TTTF_font;
981     TTTF_Font = record
982             end;
983 
984     {* SDL_mixer *}
985     PMixChunk = ^TMixChunk;
986     TMixChunk = record
987         allocated: LongWord;
988         abuf     : PByte;
989         alen     : LongWord;
990         volume   : PByte;
991         end;
992     TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3);
993     TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN);
994 
995     TMidiSong = record
996                 samples : LongInt;
997                 events  : Pointer;
998                 end;
999 
1000     TMusicUnion = record
1001         case Byte of
1002             0: ( midi : TMidiSong );
1003             1: ( ogg  : Pointer);
1004             end;
1005 
1006     PMixMusic = ^TMixMusic;
1007     TMixMusic = record
1008                 end;
1009 
1010     TPostMix = procedure(udata: Pointer; stream: PByte; len: LongInt); cdecl;
1011 
1012     {* SDL_net *}
1013     TIPAddress = record
1014                 host: LongWord;
1015                 port: Word;
1016                 end;
1017 
1018     PTCPSocket = ^TTCPSocket;
1019     TTCPSocket = record
1020                 ready: LongInt;
1021                 channel: LongInt;
1022                 remoteAddress: TIPaddress;
1023                 localAddress: TIPaddress;
1024                 sflag: LongInt;
1025                 end;
1026     PSDLNet_SocketSet = ^TSDLNet_SocketSet;
1027     TSDLNet_SocketSet = record
1028                         numsockets,
1029                         maxsockets: LongInt;
1030                         sockets: PTCPSocket;
1031                         end;
1032 
1033 {$IFDEF WINDOWS}
1034      TThreadFunction = function (p: pointer): Longword; stdcall;
1035      pfnSDL_CurrentBeginThread = function (
1036         _Security: pointer;
1037         _StackSize: LongWord;
1038         _StartAddress: TThreadFunction;
1039         _ArgList: pointer;
1040         _InitFlag: Longword;
1041         _ThrdAddr: PLongword): PtrUInt; cdecl;
1042     pfnSDL_CurrentEndThread = procedure (_Retval: LongInt); cdecl;
1043 {$ENDIF}
1044 
1045 /////////////////////////////////////////////////////////////////
DEFINITIONSnull1046 /////////////////////  FUNCTION DEFINITIONS /////////////////////
1047 /////////////////////////////////////////////////////////////////
1048 
1049 
1050 {* SDL *}
1051 function  SDL_Init(flags: LongWord): LongInt; cdecl; external SDLLibName;
SDL_InitSubSystemnull1052 function  SDL_InitSubSystem(flags: LongWord): LongInt; cdecl; external SDLLibName;
1053 procedure SDL_Quit; cdecl; external SDLLibName;
1054 
1055 procedure SDL_free(mem: Pointer); cdecl; external SDLLibName;
1056 
1057 procedure SDL_Delay(msec: LongWord); cdecl; external SDLLibName;
SDL_GetTicksnull1058 function  SDL_GetTicks: LongWord; cdecl; external SDLLibName;
1059 
SDL_MustLocknull1060 function  SDL_MustLock(Surface: PSDL_Surface): Boolean;
SDL_LockSurfacenull1061 function  SDL_LockSurface(Surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
1062 procedure SDL_UnlockSurface(Surface: PSDL_Surface); cdecl; external SDLLibName;
1063 
SDL_GetErrornull1064 function  SDL_GetError: PChar; cdecl; external SDLLibName;
1065 
SDL_CreateRGBSurfacenull1066 function  SDL_CreateRGBSurface(flags: LongWord; Width, Height, Depth: LongInt; RMask, GMask, BMask, AMask: LongWord): PSDL_Surface; cdecl; external SDLLibName;
SDL_CreateRGBSurfaceFromnull1067 function  SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch: LongInt; RMask, GMask, BMask, AMask: LongWord): PSDL_Surface; cdecl; external SDLLibName;
1068 procedure SDL_FreeSurface(Surface: PSDL_Surface); cdecl; external SDLLibName;
SDL_SetColorKeynull1069 function  SDL_SetColorKey(surface: PSDL_Surface; flag, key: LongWord): LongInt; cdecl; external SDLLibName;
SDL_SetAlphanull1070 function  SDL_SetAlpha(surface: PSDL_Surface; flag, key: LongWord): LongInt; cdecl; external SDLLibName;
SDL_ConvertSurfacenull1071 function  SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: LongWord): PSDL_Surface; cdecl; external SDLLibName;
1072 
SDL_UpperBlitnull1073 function  SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
SDL_FillRectnull1074 function  SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: LongWord): LongInt; cdecl; external SDLLibName;
1075 procedure SDL_UpdateRect(Screen: PSDL_Surface; x, y: LongInt; w, h: LongWord); cdecl; external SDLLibName;
SDL_Flipnull1076 function  SDL_Flip(Screen: PSDL_Surface): LongInt; cdecl; external SDLLibName;
1077 
1078 procedure SDL_GetRGB(pixel: LongWord; fmt: PSDL_PixelFormat; r, g, b: PByte); cdecl; external SDLLibName;
1079 procedure SDL_GetRGBA(pixel: LongWord; fmt: PSDL_PixelFormat; r, g, b, a: PByte); cdecl; external SDLLibName;
SDL_MapRGBnull1080 function  SDL_MapRGB(format: PSDL_PixelFormat; r, g, b: Byte): LongWord; cdecl; external SDLLibName;
SDL_MapRGBAnull1081 function  SDL_MapRGBA(format: PSDL_PixelFormat; r, g, b, a: Byte): LongWord; cdecl; external SDLLibName;
1082 
SDL_DisplayFormatnull1083 function  SDL_DisplayFormat(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName;
SDL_DisplayFormatAlphanull1084 function  SDL_DisplayFormatAlpha(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName;
1085 
SDL_RWFromFilenull1086 function  SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; cdecl; external SDLLibName;
SDL_SaveBMP_RWnull1087 function  SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName;
1088 
SDL_CreateWindownull1089 function  SDL_CreateWindow(title: PChar; x,y,w,h: LongInt; flags: LongWord): PSDL_Window; cdecl; external SDLLibName;
1090 procedure SDL_SetWindowIcon(window: PSDL_Window; icon: PSDL_Surface); cdecl; external SDLLibName;
1091 
SDL_CreateRenderernull1092 function  SDL_CreateRenderer(window: PSDL_Window; index: LongInt; flags: LongWord): PSDL_Renderer; cdecl; external SDLLibName;
SDL_DestroyWindownull1093 function  SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
SDL_DestroyRenderernull1094 function  SDL_DestroyRenderer(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
1095 procedure SDL_SetWindowPosition(window: PSDL_Window; w, h: LongInt); cdecl; external SDLLibName;
1096 procedure SDL_SetWindowSize(window: PSDL_Window; w, h: LongInt); cdecl; external SDLLibName;
1097 procedure SDL_SetWindowFullscreen(window: PSDL_Window; flags: LongWord); cdecl; external SDLLibName;
SDL_GetCurrentVideoDrivernull1098 function  SDL_GetCurrentVideoDriver:Pchar; cdecl; external SDLLibName;
1099 
SDL_GL_CreateContextnull1100 function  SDL_GL_CreateContext(window: PSDL_Window): PSDL_GLContext; cdecl; external SDLLibName;
1101 procedure SDL_GL_DeleteContext(context: PSDL_GLContext); cdecl; external SDLLibName;
1102 procedure SDL_GL_SwapWindow(window: PSDL_Window); cdecl; external SDLLibName;
SDL_GL_SetSwapIntervalnull1103 function  SDL_GL_SetSwapInterval(interval: LongInt): LongInt; cdecl; external SDLLibName;
1104 
1105 procedure SDL_VideoQuit; cdecl; external SDLLibName;
SDL_GetNumVideoDisplaysnull1106 function  SDL_GetNumVideoDisplays: LongInt; cdecl; external SDLLibName;
1107 procedure SDL_ShowWindow(window: PSDL_Window); cdecl; external SDLLibName;
1108 
SDL_SetRenderDrawColornull1109 function  SDL_SetRenderDrawColor(renderer: PSDL_Renderer; r,g,b,a: Byte): LongInt; cdecl; external SDLLibName;
SDL_GetRenderernull1110 function  SDL_GetRenderer(window: PSDL_Window): PSDL_Renderer; cdecl; external SDLLibName;
SDL_RenderFillRectnull1111 function  SDL_RenderFillRect(renderer: PSDL_Renderer; rect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
SDL_RenderClearnull1112 function  SDL_RenderClear(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
1113 procedure SDL_RenderPresent(renderer: PSDL_Renderer); cdecl; external SDLLibName;
SDL_RenderReadPixelsnull1114 function  SDL_RenderReadPixels(renderer: PSDL_Renderer; rect: PSDL_Rect; format: LongInt; pixels: Pointer; pitch: LongInt): LongInt; cdecl; external SDLLibName;
SDL_RenderSetViewportnull1115 function  SDL_RenderSetViewport(window: PSDL_Window; rect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
1116 
SDL_SetRelativeMouseModenull1117 function  SDL_SetRelativeMouseMode(enabled: TSDL_bool): LongInt; cdecl; external SDLLibName;
SDL_GetRelativeMouseStatenull1118 function  SDL_GetRelativeMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
SDL_PixelFormatEnumToMasksnull1119 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): Boolean; cdecl; external SDLLibName;
1120 
1121 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
SDL_SetHintnull1122 function  SDL_SetHint(name, value: PChar): Boolean; cdecl; external SDLLibName;
1123 procedure SDL_StartTextInput; cdecl; external SDLLibName;
1124 procedure SDL_StopTextInput; cdecl; external SDLLibName;
1125 procedure SDL_FlushEvent(eventType: LongWord); cdecl; external SDLLibName;
1126 
SDL_PeepEventsnull1127 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: TSDL_eventaction; minType, maxType: LongWord): LongInt; cdecl; external SDLLibName;
1128 
SDL_AllocFormatnull1129 function  SDL_AllocFormat(format: LongWord): PSDL_PixelFormat; cdecl; external SDLLibName;
1130 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); cdecl; external SDLLibName;
1131 
1132 
SDL_GetMouseStatenull1133 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
SDL_GetKeyNamenull1134 function  SDL_GetKeyName(key: TSDL_Keycode): PChar; cdecl; external SDLLibName;
SDL_GetScancodeNamenull1135 function  SDL_GetScancodeName(key: TSDL_Scancode): PChar; cdecl; external SDLLibName;
SDL_GetKeyFromScancodenull1136 function  SDL_GetKeyFromScancode(key: TSDL_Scancode): TSDL_Keycode; cdecl; external SDLLibName;
1137 // SDL2 functions has some additional functions (not listed here) for keycode/scancode translation
1138 
1139 procedure SDL_PumpEvents; cdecl; external SDLLibName;
SDL_PollEventnull1140 function  SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
SDL_WaitEventnull1141 function  SDL_WaitEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
1142 procedure SDL_SetEventFilter(filter: TSDL_EventFilter); cdecl; external SDLLibName;
1143 
SDL_ShowCursornull1144 function  SDL_ShowCursor(toggle: LongInt): LongInt; cdecl; external SDLLibName;
1145 procedure SDL_WarpMouse(x, y: Word); inline;
1146 
SDL_GetKeyboardStatenull1147 function  SDL_GetKeyboardState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
1148 
1149 procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask : Byte); cdecl; external SDLLibName;
1150 procedure SDL_WM_SetCaption(title: PChar; icon: PChar); cdecl; external SDLLibName;
SDL_WM_ToggleFullScreennull1151 function  SDL_WM_ToggleFullScreen(surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
1152 
1153 
1154 (* remember to mark the threaded functions as 'cdecl; export;'
1155    (or have fun debugging nil arguments) *)
1156 {$IFDEF WINDOWS}
1157 // SDL uses wrapper in windows
SDL_CreateThreadnull1158 function  SDL_CreateThread(fn: Pointer; name: PChar; data: Pointer; bt: pfnSDL_CurrentBeginThread; et: pfnSDL_CurrentEndThread): PSDL_Thread; cdecl; external SDLLibName;
SDL_CreateThreadnull1159 function  SDL_CreateThread(fn: Pointer; name: PChar; data: Pointer): PSDL_Thread; cdecl; overload;
1160 {$ELSE}
SDL_CreateThreadnull1161 function  SDL_CreateThread(fn: Pointer; name: PChar; data: Pointer): PSDL_Thread; cdecl; external SDLLibName;
1162 {$ENDIF}
1163 procedure SDL_WaitThread(thread: PSDL_Thread; status: PLongInt); cdecl; external SDLLibName;
1164 procedure SDL_DetachThread(thread: PSDL_Thread); cdecl; external SDLLibName;
1165 procedure SDL_KillThread(thread: PSDL_Thread); cdecl; external SDLLibName;
1166 
SDL_CreateMutexnull1167 function  SDL_CreateMutex: PSDL_mutex; cdecl; external SDLLibName;
1168 procedure SDL_DestroyMutex(mutex: PSDL_mutex); cdecl; external SDLLibName;
SDL_LockMutexnull1169 function  SDL_LockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName;
SDL_UnlockMutexnull1170 function  SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName;
1171 
SDL_CreateSemaphorenull1172 function  SDL_CreateSemaphore(initial_value: Longword): PSDL_sem; cdecl; external SDLLibName;
1173 procedure SDL_DestroySemaphore(sem: PSDL_sem); cdecl; external SDLLibName;
SDL_SemWaitnull1174 function  SDL_SemWait(sem: PSDL_sem): LongInt; cdecl; external SDLLibName;
SDL_SemPostnull1175 function  SDL_SemPost(sem: PSDL_sem): LongInt; cdecl; external SDLLibName;
1176 
SDL_GL_SetAttributenull1177 function  SDL_GL_SetAttribute(attr: TSDL_GLattr; value: LongInt): LongInt; cdecl; external SDLLibName;
1178 procedure SDL_GL_SwapBuffers; cdecl; external SDLLibName;
1179 
1180 procedure SDL_LockAudio; cdecl; external SDLLibName;
1181 procedure SDL_UnlockAudio; cdecl; external SDLLibName;
1182 
SDL_NumJoysticksnull1183 function  SDL_NumJoysticks: LongInt; cdecl; external SDLLibName;
SDL_JoystickNameForIndexnull1184 function  SDL_JoystickNameForIndex(idx: LongInt): PChar; cdecl; external SDLLibName;
SDL_JoystickOpennull1185 function  SDL_JoystickOpen(idx: LongInt): PSDL_Joystick; cdecl; external SDLLibName;
SDL_JoystickOpenednull1186 function  SDL_JoystickOpened(idx: LongInt): LongInt; cdecl; external SDLLibName;
SDL_JoystickIndexnull1187 function  SDL_JoystickIndex(joy: PSDL_Joystick): LongInt; cdecl; external SDLLibName;
SDL_JoystickNumAxesnull1188 function  SDL_JoystickNumAxes(joy: PSDL_Joystick): LongInt; cdecl; external SDLLibName;
SDL_JoystickNumBallsnull1189 function  SDL_JoystickNumBalls(joy: PSDL_Joystick): LongInt; cdecl; external SDLLibName;
SDL_JoystickNumHatsnull1190 function  SDL_JoystickNumHats(joy: PSDL_Joystick): LongInt; cdecl; external SDLLibName;
SDL_JoystickNumButtonsnull1191 function  SDL_JoystickNumButtons(joy: PSDL_Joystick): LongInt; cdecl; external SDLLibName;
1192 procedure SDL_JoystickUpdate; cdecl; external SDLLibName;
SDL_JoystickEventStatenull1193 function  SDL_JoystickEventState(state: LongInt): LongInt; cdecl; external SDLLibName;
SDL_JoystickGetAxisnull1194 function  SDL_JoystickGetAxis(joy: PSDL_Joystick; axis: LongInt): LongInt; cdecl; external SDLLibName;
SDL_JoystickGetBallnull1195 function  SDL_JoystickGetBall(joy: PSDL_Joystick; ball: LongInt; dx: PInteger; dy: PInteger): Word; cdecl; external SDLLibName;
SDL_JoystickGetHatnull1196 function  SDL_JoystickGetHat(joy: PSDL_Joystick; hat: LongInt): Byte; cdecl; external SDLLibName;
SDL_JoystickGetButtonnull1197 function  SDL_JoystickGetButton(joy: PSDL_Joystick; button: LongInt): Byte; cdecl; external SDLLibName;
1198 procedure SDL_JoystickClose(joy: PSDL_Joystick); cdecl; external SDLLibName;
1199 
1200 {$IFDEF WINDOWS}
SDL_putenvnull1201 function SDL_putenv(const text: PChar): LongInt; cdecl; external SDLLibName;
SDL_getenvnull1202 function SDL_getenv(const text: PChar): PChar; cdecl; external SDLLibName;
1203 {$ENDIF}
1204 
1205 
1206 (*  SDL_ttf  *)
TTF_Initnull1207 function  TTF_Init: LongInt; cdecl; external SDL_TTFLibName;
1208 procedure TTF_Quit; cdecl; external SDL_TTFLibName;
1209 
TTF_SizeUTF8null1210 function  TTF_SizeUTF8(font: PTTF_Font; const text: PChar; w, h: PLongInt): LongInt; cdecl; external SDL_TTFLibName;
1211 
TTF_RenderUTF8_Solidnull1212 function  TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
TTF_RenderUTF8_Blendednull1213 function  TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
TTF_RenderUTF8_Shadednull1214 function  TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
1215 
TTF_OpenFontRWnull1216 function  TTF_OpenFontRW(src: PSDL_RWops; freesrc: LongBool; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName;
1217 procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName;
1218 procedure TTF_CloseFont(font: PTTF_Font); cdecl; external SDL_TTFLibName;
1219 
1220 (*  SDL_mixer  *)
Mix_Initnull1221 function  Mix_Init(flags: LongInt): LongInt; cdecl; external SDL_MixerLibName;
1222 procedure Mix_Quit; cdecl; external SDL_MixerLibName;
1223 
Mix_OpenAudionull1224 function  Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName;
1225 procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName;
Mix_QuerySpecnull1226 function  Mix_QuerySpec(frequency: PLongInt; format: PWord; channels: PLongInt): LongInt; cdecl; external SDL_MixerLibName;
1227 
Mix_Volumenull1228 function  Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName;
Mix_SetDistancenull1229 function  Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName;
Mix_VolumeMusicnull1230 function  Mix_VolumeMusic(volume: LongInt): LongInt; cdecl; external SDL_MixerLibName;
1231 
Mix_AllocateChannelsnull1232 function  Mix_AllocateChannels(numchans: LongInt): LongInt; cdecl; external SDL_MixerLibName;
1233 procedure Mix_FreeChunk(chunk: PMixChunk); cdecl; external SDL_MixerLibName;
1234 procedure Mix_FreeMusic(music: PMixMusic); cdecl; external SDL_MixerLibName;
1235 
Mix_LoadWAV_RWnull1236 function  Mix_LoadWAV_RW(src: PSDL_RWops; freesrc: LongInt): PMixChunk; cdecl; external SDL_MixerLibName;
Mix_LoadMUS_RWnull1237 function  Mix_LoadMUS_RW(src: PSDL_RWops): PMixMusic; cdecl; external SDL_MixerLibName;
1238 
Mix_Playingnull1239 function  Mix_Playing(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName;
Mix_PlayingMusicnull1240 function  Mix_PlayingMusic: LongInt; cdecl; external SDL_MixerLibName;
Mix_FadeInMusicnull1241 function  Mix_FadeInMusic(music: PMixMusic; loops: LongInt; ms: LongInt): LongInt; cdecl; external SDL_MixerLibName;
1242 
Mix_PlayChannelTimednull1243 function  Mix_PlayChannelTimed(channel: LongInt; chunk: PMixChunk; loops: LongInt; ticks: LongInt): LongInt; cdecl; external SDL_MixerLibName;
Mix_PlayMusicnull1244 function  Mix_PlayMusic(music: PMixMusic; loops: LongInt): LongInt; cdecl; external SDL_MixerLibName;
Mix_PausedMusicnull1245 function  Mix_PausedMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName;
Mix_PauseMusicnull1246 function  Mix_PauseMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName;
Mix_ResumeMusicnull1247 function  Mix_ResumeMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName;
Mix_HaltChannelnull1248 function  Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName;
Mix_HaltMusicnull1249 function  Mix_HaltMusic: LongInt; cdecl; external SDL_MixerLibName;
1250 
Mix_FadeInChannelTimednull1251 function  Mix_FadeInChannelTimed(channel: LongInt; chunk: PMixChunk; loops: LongInt; fadems: LongInt; ticks: LongInt): LongInt; cdecl; external SDL_MixerLibName;
Mix_FadeOutChannelnull1252 function  Mix_FadeOutChannel(channel: LongInt; fadems: LongInt): LongInt; cdecl; external SDL_MixerLibName;
1253 
1254 procedure Mix_SetPostMix( mix_func: TPostMix; arg: Pointer); cdecl; external SDL_MixerLibName;
1255 
1256 (*  SDL_image  *)
IMG_Initnull1257 function  IMG_Init(flags: LongInt): LongInt; cdecl; external SDL_ImageLibName;
1258 procedure IMG_Quit; cdecl; external SDL_ImageLibName;
1259 
IMG_Loadnull1260 function  IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
IMG_Load_RWnull1261 function  IMG_Load_RW(rwop: PSDL_RWops; freesrc: LongBool): PSDL_Surface; cdecl; external SDL_ImageLibName;
IMG_LoadPNG_RWnull1262 function  IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName;
IMG_LoadTyped_RWnull1263 function  IMG_LoadTyped_RW(rwop: PSDL_RWops; freesrc: LongBool; type_: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
IMG_SavePNGnull1264 function IMG_SavePNG(surface: PSDL_Surface; const _file: PChar): LongInt; cdecl; external SDL_ImageLibName;
1265 
1266 (*  SDL_net  *)
SDLNet_Initnull1267 function  SDLNet_Init: LongInt; cdecl; external SDL_NetLibName;
1268 procedure SDLNet_Quit; cdecl; external SDL_NetLibName;
1269 
SDLNet_AllocSocketSetnull1270 function  SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName;
SDLNet_ResolveHostnull1271 function  SDLNet_ResolveHost(var address: TIPaddress; host: PChar; port: Word): LongInt; cdecl; external SDL_NetLibName;
SDLNet_TCP_Acceptnull1272 function  SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName;
SDLNet_TCP_Opennull1273 function  SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName;
SDLNet_TCP_Sendnull1274 function  SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName;
SDLNet_TCP_Recvnull1275 function  SDLNet_TCP_Recv(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName;
1276 procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName;
1277 procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName;
SDLNet_AddSocketnull1278 function  SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName;
SDLNet_CheckSocketsnull1279 function  SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName;
1280 
1281 // SDL 2 clipboard functions
SDL_HasClipboardTextnull1282 function SDL_HasClipboardText(): Boolean; cdecl; external SDLLibName;
1283 // returns nil if memory for clipboard contents copy couldn't be allocated
1284 function SDL_GetClipboardText(): PChar; cdecl; external SDLLibName;
1285 // returns 0 on success or negative error number on failure
1286 function SDL_SetClipboardText(const text: PChar): LongInt; cdecl; external SDLLibName;
1287 
1288 procedure SDLNet_Write16(value: Word; buf: Pointer);
1289 procedure SDLNet_Write32(value: LongWord; buf: Pointer);
1290 function  SDLNet_Read16(buf: Pointer): Word;
1291 function  SDLNet_Read32(buf: Pointer): LongWord;
1292 
1293 implementation
1294 uses uStore;
1295 
1296 // for sdl1.2 we directly call SDL_WarpMouse()
1297 // for sdl2 we provide a SDL_WarpMouse() which calls the right SDL_WarpMouseInWindow() function
1298 // this has the advantage of reducing 'uses' and 'ifdef' statements
1299 // (SDLwindow is a private member of uStore module)
1300 procedure SDL_WarpMouse(x, y: Word); inline;
1301 begin
1302     WarpMouse(x, y);
1303 end;
1304 
1305 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
1306 begin
1307     SDL_MustLock:=
1308         ((surface^.flags and SDL_RLEACCEL) <> 0)
1309 end;
1310 
1311 procedure SDLNet_Write16(value: Word; buf: Pointer);
1312 begin
1313     PByteArray(buf)^[1]:= value;
1314     PByteArray(buf)^[0]:= value shr 8
1315 end;
1316 
1317 procedure SDLNet_Write32(value: LongWord; buf: Pointer);
1318 begin
1319     PByteArray(buf)^[3]:= value;
1320     PByteArray(buf)^[2]:= value shr  8;
1321     PByteArray(buf)^[1]:= value shr 16;
1322     PByteArray(buf)^[0]:= value shr 24
1323 end;
1324 
1325 function SDLNet_Read16(buf: Pointer): Word;
1326 begin
1327     SDLNet_Read16:= PByteArray(buf)^[1] or
1328                  (PByteArray(buf)^[0] shl 8)
1329 end;
1330 
1331 function SDLNet_Read32(buf: Pointer): LongWord;
1332 begin
1333     SDLNet_Read32:=  PByteArray(buf)^[3] or
1334                   (PByteArray(buf)^[2] shl  8) or
1335                   (PByteArray(buf)^[1] shl 16) or
1336                   (PByteArray(buf)^[0] shl 24)
1337 end;
1338 
1339 {$IFDEF WINDOWS}
1340 function  SDL_CreateThread(fn: Pointer; name: PChar; data: Pointer): PSDL_Thread; cdecl;
1341 begin
1342     SDL_CreateThread:= SDL_CreateThread(fn, name, data, nil, nil)
1343 end;
1344 {$ENDIF}
1345 
1346 end.
1347 
1348