DEADSOFTWARE

al: fix 16bit wav sounds on big endian with sdl 1.2
[d2df-sdl.git] / src / lib / sdl / sdl.pas
1 unit sdl;
2 {
3 $Id: sdl.pas,v 1.31 2007/05/29 21:30:48 savage Exp $
5 }
6 {******************************************************************************}
7 { }
8 { JEDI-SDL : Pascal units for SDL - Simple DirectMedia Layer }
9 { Conversion of the Simple DirectMedia Layer Headers }
10 { }
11 { Portions created by Sam Lantinga <slouken@devolution.com> are }
12 { Copyright (C) 1997-2004 Sam Lantinga }
13 { 5635-34 Springhouse Dr. }
14 { Pleasanton, CA 94588 (USA) }
15 { }
16 { All Rights Reserved. }
17 { }
18 { The original files are : SDL.h }
19 { SDL_main.h }
20 { SDL_types.h }
21 { SDL_rwops.h }
22 { SDL_timer.h }
23 { SDL_audio.h }
24 { SDL_cdrom.h }
25 { SDL_joystick.h }
26 { SDL_mouse.h }
27 { SDL_keyboard.h }
28 { SDL_events.h }
29 { SDL_video.h }
30 { SDL_byteorder.h }
31 { SDL_version.h }
32 { SDL_active.h }
33 { SDL_thread.h }
34 { SDL_mutex .h }
35 { SDL_getenv.h }
36 { SDL_loadso.h }
37 { }
38 { The initial developer of this Pascal code was : }
39 { Dominique Louis <Dominique@SavageSoftware.com.au> }
40 { }
41 { Portions created by Dominique Louis are }
42 { Copyright (C) 2000 - 2004 Dominique Louis. }
43 { }
44 { }
45 { Contributor(s) }
46 { -------------- }
47 { Tom Jones <tigertomjones@gmx.de> His Project inspired this conversion }
48 { Matthias Thoma <ma.thoma@gmx.de> }
49 { }
50 { Obtained through: }
51 { Joint Endeavour of Delphi Innovators ( Project JEDI ) }
52 { }
53 { You may retrieve the latest version of this file at the Project }
54 { JEDI home page, located at http://delphi-jedi.org }
55 { }
56 { The contents of this file are used with permission, subject to }
57 { the Mozilla Public License Version 1.1 (the "License"); you may }
58 { not use this file except in compliance with the License. You may }
59 { obtain a copy of the License at }
60 { http://www.mozilla.org/MPL/MPL-1.1.html }
61 { }
62 { Software distributed under the License is distributed on an }
63 { "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
64 { implied. See the License for the specific language governing }
65 { rights and limitations under the License. }
66 { }
67 { Description }
68 { ----------- }
69 { }
70 { }
71 { }
72 { }
73 { }
74 { }
75 { }
76 { Requires }
77 { -------- }
78 { The SDL Runtime libraris on Win32 : SDL.dll on Linux : libSDL.so }
79 { They are available from... }
80 { http://www.libsdl.org . }
81 { }
82 { Programming Notes }
83 { ----------------- }
84 { }
85 { }
86 { }
87 { }
88 { Revision History }
89 { ---------------- }
90 { May 08 2001 - DL : Added Keyboard State Array ( See demos for how to }
91 { use ) }
92 { PKeyStateArr = ^TKeyStateArr; }
93 { TKeyStateArr = array[0..65000] of UInt8; }
94 { As most games will need it. }
95 { }
96 { April 02 2001 - DL : Added SDL_getenv.h definitions and tested version }
97 { 1.2.0 compatability. }
98 { }
99 { March 13 2001 - MT : Added Linux compatibility. }
100 { }
101 { March 10 2001 - MT : Added externalsyms for DEFINES }
102 { Changed the license header }
103 { }
104 { March 09 2001 - MT : Added Kylix Ifdefs/Deleted the uses mmsystem }
105 { }
106 { March 01 2001 - DL : Update conversion of version 1.1.8 }
107 { }
108 { July 22 2001 - DL : Added TUInt8Array and PUIntArray after suggestions }
109 { from Matthias Thoma and Eric Grange. }
110 { }
111 { October 12 2001 - DL : Various changes as suggested by Matthias Thoma and }
112 { David Acklam }
113 { }
114 { October 24 2001 - DL : Added FreePascal support as per suggestions from }
115 { Dean Ellis. }
116 { }
117 { October 27 2001 - DL : Added SDL_BUTTON macro }
118 { }
119 { November 08 2001 - DL : Bug fix as pointed out by Puthoon. }
120 { }
121 { November 29 2001 - DL : Bug fix of SDL_SetGammaRamp as pointed out by Simon}
122 { Rushton. }
123 { }
124 { November 30 2001 - DL : SDL_NOFRAME added as pointed out by Simon Rushton. }
125 { }
126 { December 11 2001 - DL : Added $WEAKPACKAGEUNIT ON to facilitate useage in }
127 { Components }
128 { }
129 { January 05 2002 - DL : Added SDL_Swap32 function as suggested by Matthias }
130 { Thoma and also made sure the _getenv from }
131 { MSVCRT.DLL uses the right calling convention }
132 { }
133 { January 25 2002 - DL : Updated conversion of SDL_AddTimer & }
134 { SDL_RemoveTimer as per suggestions from Matthias }
135 { Thoma. }
136 { }
137 { January 27 2002 - DL : Commented out exported function putenv and getenv }
138 { So that developers get used to using SDL_putenv }
139 { SDL_getenv, as they are more portable }
140 { }
141 { March 05 2002 - DL : Added FreeAnNil procedure for Delphi 4 users. }
142 { }
143 { October 23 2002 - DL : Added Delphi 3 Define of Win32. }
144 { If you intend to you Delphi 3... }
145 { ( which is officially unsupported ) make sure you }
146 { remove references to $EXTERNALSYM in this and other}
147 { SDL files. }
148 { }
149 { November 29 2002 - DL : Fixed bug in Declaration of SDL_GetRGBA that was }
150 { pointed out by Todd Lang }
151 { }
152 { April 03 2003 - DL : Added jedi-sdl.inc include file to support more }
153 { Pascal compilers. Initial support is now included }
154 { for GnuPascal, VirtualPascal, TMT and obviously }
155 { continue support for Delphi Kylix and FreePascal. }
156 { }
157 { April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support }
158 { }
159 { April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added}
160 { better TMT Pascal support and under instruction }
161 { from Prof. Abimbola Olowofoyeku (The African Chief),}
162 { I have added better Gnu Pascal support }
163 { }
164 { April 30 2003 - DL : under instruction from David Mears AKA }
165 { Jason Siletto, I have added FPC Linux support. }
166 { This was compiled with fpc 1.1, so remember to set }
167 { include file path. ie. -Fi/usr/share/fpcsrc/rtl/* }
168 { }
170 $Log: sdl.pas,v $
171 Revision 1.31 2007/05/29 21:30:48 savage
172 Changes as suggested by Almindor for 64bit compatibility.
174 Revision 1.30 2007/05/29 19:31:03 savage
175 Fix to TSDL_Overlay structure - thanks David Pethes (aka imcold)
177 Revision 1.29 2007/05/20 20:29:11 savage
178 Initial Changes to Handle 64 Bits
180 Revision 1.26 2007/02/11 13:38:04 savage
181 Added Nintendo DS support - Thanks Dean.
183 Revision 1.25 2006/12/02 00:12:52 savage
184 Updated to latest version
186 Revision 1.24 2006/05/18 21:10:04 savage
187 Added 1.2.10 Changes
189 Revision 1.23 2005/12/04 23:17:52 drellis
190 Added declaration of SInt8 and PSInt8
192 Revision 1.22 2005/05/24 21:59:03 savage
193 Re-arranged uses clause to work on Win32 and Linux, Thanks again Michalis.
195 Revision 1.21 2005/05/22 18:42:31 savage
196 Changes as suggested by Michalis Kamburelis. Thanks again.
198 Revision 1.20 2005/04/10 11:48:33 savage
199 Changes as suggested by Michalis, thanks.
201 Revision 1.19 2005/01/05 01:47:06 savage
202 Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively.
204 Revision 1.18 2005/01/04 23:14:41 savage
205 Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively.
207 Revision 1.17 2005/01/03 18:40:59 savage
208 Updated Version number to reflect latest one
210 Revision 1.16 2005/01/01 02:02:06 savage
211 Updated to v1.2.8
213 Revision 1.15 2004/12/24 18:57:11 savage
214 forgot to apply Michalis Kamburelis' patch to the implementation section. now fixed
216 Revision 1.14 2004/12/23 23:42:18 savage
217 Applied Patches supplied by Michalis Kamburelis ( THANKS! ), for greater FreePascal compatability.
219 Revision 1.13 2004/09/30 22:31:59 savage
220 Updated with slightly different header comments
222 Revision 1.12 2004/09/12 21:52:58 savage
223 Slight changes to fix some issues with the sdl classes.
225 Revision 1.11 2004/08/14 22:54:30 savage
226 Updated so that Library name defines are correctly defined for MacOS X.
228 Revision 1.10 2004/07/20 23:57:33 savage
229 Thanks to Paul Toth for spotting an error in the SDL Audio Convertion structures.
230 In TSDL_AudioCVT the filters variable should point to and array of pointers and not what I had there previously.
232 Revision 1.9 2004/07/03 22:07:22 savage
233 Added Bitwise Manipulation Functions for TSDL_VideoInfo struct.
235 Revision 1.8 2004/05/10 14:10:03 savage
236 Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
238 Revision 1.7 2004/04/13 09:32:08 savage
239 Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
241 Revision 1.6 2004/04/01 20:53:23 savage
242 Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
244 Revision 1.5 2004/02/22 15:32:10 savage
245 SDL_GetEnv Fix so it also works on FPC/Linux. Thanks to Rodrigo for pointing this out.
247 Revision 1.4 2004/02/21 23:24:29 savage
248 SDL_GetEnv Fix so that it is not define twice for FPC. Thanks to Rene Hugentobler for pointing out this bug,
250 Revision 1.3 2004/02/18 22:35:51 savage
251 Brought sdl.pas up to 1.2.7 compatability
252 Thus...
253 Added SDL_GL_STEREO,
254 SDL_GL_MULTISAMPLEBUFFERS,
255 SDL_GL_MULTISAMPLESAMPLES
257 Add DLL/Shared object functions
258 function SDL_LoadObject( const sofile : PChar ) : Pointer;
260 function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer;
262 procedure SDL_UnloadObject( handle : Pointer );
264 Added function to create RWops from const memory: SDL_RWFromConstMem()
265 function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops;
267 Ported SDL_cpuinfo.h so Now you can test for Specific CPU types.
269 Revision 1.2 2004/02/17 21:37:12 savage
270 Tidying up of units
272 Revision 1.1 2004/02/05 00:08:20 savage
273 Module 1.0 release
276 {******************************************************************************}
278 {$I jedi-sdl.inc}
280 interface
282 uses
283 {$IFDEF __GPC__}
284 system,
285 {$IFDEF WINDOWS}
286 wintypes,
287 {$ELSE}
288 {$ENDIF}
289 gpc;
290 {$ENDIF}
292 {$IFDEF HAS_TYPES}
293 Types{$IFNDEF NDS},{$ELSE};{$ENDIF}
294 {$ENDIF}
296 {$IFDEF WINDOWS}
297 Windows;
298 {$ENDIF}
300 {$IFDEF OS2}
301 doscalls;
302 {$ENDIF OS2}
304 {$IFDEF UNIX}
305 {$IFDEF FPC}
306 pthreads,
307 unixtype,
308 baseunix,
309 {$IFNDEF GP2X}
310 unix,
311 {$ELSE}
312 unix;
313 {$ENDIF}
314 {$IFNDEF GP2X}
315 x,
316 xlib;
317 {$ENDIF}
318 {$ELSE}
319 Libc,
320 Xlib;
321 {$ENDIF}
322 {$ENDIF}
324 {$IFDEF __MACH__}
325 GPCMacOSAll;
326 {$ENDIF}
328 {$IFDEF MORPHOS}
329 exec;
330 {$ENDIF}
332 const
333 {$IFDEF WINDOWS}
334 SDLLibName = 'SDL.dll';
335 {$ENDIF}
337 {$IFDEF OS2}
338 SDLLibName = 'SDL12.dll';
339 {$ENDIF OS2}
341 {$IFDEF UNIX}
342 {$IFDEF DARWIN}
343 SDLLibName = 'libSDL-1.2.0.dylib';
344 {$linklib libSDL-1.2.0}
345 {$linklib SDLmain}
346 {$linkframework Cocoa}
347 {$PASCALMAINNAME SDL_main}
348 {$ELSE}
349 {$IFDEF FPC}
350 SDLLibName = 'libSDL.so';
351 {$ELSE}
352 SDLLibName = 'libSDL-1.2.so.0';
353 {$ENDIF}
354 {$ENDIF}
355 {$ENDIF}
357 {$IFDEF MACOS}
358 SDLLibName = 'SDL';
359 {$ENDIF}
361 {$IFDEF NDS}
362 SDLLibName = 'libSDL.a';
363 {$linklib libSDL.a}
364 {$linklib libnds9.a}
365 {$linklib libc.a}
366 {$linklib libgcc.a}
367 {$linklib libsysbase.a}
368 {$ENDIF}
370 {$IFDEF MORPHOS}
371 SDLLibName = 'powersdl.library';
372 {$ENDIF}
374 // SDL_verion.h constants
375 // Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
376 SDL_MAJOR_VERSION = 1;
377 {$EXTERNALSYM SDL_MAJOR_VERSION}
378 SDL_MINOR_VERSION = 2;
379 {$EXTERNALSYM SDL_MINOR_VERSION}
380 SDL_PATCHLEVEL = 11;
381 {$EXTERNALSYM SDL_PATCHLEVEL}
383 // SDL.h constants
384 SDL_INIT_TIMER = $00000001;
385 {$EXTERNALSYM SDL_INIT_TIMER}
386 SDL_INIT_AUDIO = $00000010;
387 {$EXTERNALSYM SDL_INIT_AUDIO}
388 SDL_INIT_VIDEO = $00000020;
389 {$EXTERNALSYM SDL_INIT_VIDEO}
390 SDL_INIT_CDROM = $00000100;
391 {$EXTERNALSYM SDL_INIT_CDROM}
392 SDL_INIT_JOYSTICK = $00000200;
393 {$EXTERNALSYM SDL_INIT_JOYSTICK}
394 SDL_INIT_NOPARACHUTE = $00100000; // Don't catch fatal signals
395 {$EXTERNALSYM SDL_INIT_NOPARACHUTE}
396 SDL_INIT_EVENTTHREAD = $01000000; // Not supported on all OS's
397 {$EXTERNALSYM SDL_INIT_EVENTTHREAD}
398 SDL_INIT_EVERYTHING = $0000FFFF;
399 {$EXTERNALSYM SDL_INIT_EVERYTHING}
401 // SDL_error.h constants
402 ERR_MAX_STRLEN = 128;
403 {$EXTERNALSYM ERR_MAX_STRLEN}
404 ERR_MAX_ARGS = 5;
405 {$EXTERNALSYM ERR_MAX_ARGS}
407 // SDL_types.h constants
408 SDL_PRESSED = $01;
409 {$EXTERNALSYM SDL_PRESSED}
410 SDL_RELEASED = $00;
411 {$EXTERNALSYM SDL_RELEASED}
413 // SDL_timer.h constants
414 // This is the OS scheduler timeslice, in milliseconds
415 SDL_TIMESLICE = 10;
416 {$EXTERNALSYM SDL_TIMESLICE}
417 // This is the maximum resolution of the SDL timer on all platforms
418 TIMER_RESOLUTION = 10; // Experimentally determined
419 {$EXTERNALSYM TIMER_RESOLUTION}
421 // SDL_audio.h constants
422 AUDIO_U8 = $0008; // Unsigned 8-bit samples
423 {$EXTERNALSYM AUDIO_U8}
424 AUDIO_S8 = $8008; // Signed 8-bit samples
425 {$EXTERNALSYM AUDIO_S8}
426 AUDIO_U16LSB = $0010; // Unsigned 16-bit samples
427 {$EXTERNALSYM AUDIO_U16LSB}
428 AUDIO_S16LSB = $8010; // Signed 16-bit samples
429 {$EXTERNALSYM AUDIO_S16LSB}
430 AUDIO_U16MSB = $1010; // As above, but big-endian byte order
431 {$EXTERNALSYM AUDIO_U16MSB}
432 AUDIO_S16MSB = $9010; // As above, but big-endian byte order
433 {$EXTERNALSYM AUDIO_S16MSB}
434 AUDIO_U16 = AUDIO_U16LSB;
435 {$EXTERNALSYM AUDIO_U16}
436 AUDIO_S16 = AUDIO_S16LSB;
437 {$EXTERNALSYM AUDIO_S16}
440 // SDL_cdrom.h constants
441 // The maximum number of CD-ROM tracks on a disk
442 SDL_MAX_TRACKS = 99;
443 {$EXTERNALSYM SDL_MAX_TRACKS}
444 // The types of CD-ROM track possible
445 SDL_AUDIO_TRACK = $00;
446 {$EXTERNALSYM SDL_AUDIO_TRACK}
447 SDL_DATA_TRACK = $04;
448 {$EXTERNALSYM SDL_DATA_TRACK}
450 // Conversion functions from frames to Minute/Second/Frames and vice versa
451 CD_FPS = 75;
452 {$EXTERNALSYM CD_FPS}
453 // SDL_byteorder.h constants
454 // The two types of endianness
455 SDL_LIL_ENDIAN = 1234;
456 {$EXTERNALSYM SDL_LIL_ENDIAN}
457 SDL_BIG_ENDIAN = 4321;
458 {$EXTERNALSYM SDL_BIG_ENDIAN}
460 {$IFDEF FPC_LITTLE_ENDIAN}
461 SDL_BYTEORDER = SDL_LIL_ENDIAN;
462 {$ELSE}
463 SDL_BYTEORDER = SDL_BIG_ENDIAN;
464 {$ENDIF}
465 {$EXTERNALSYM SDL_BYTEORDER}
467 // Native audio byte ordering
468 {$IFDEF FPC_LITTLE_ENDIAN}
469 SDL_BYTEORDER = SDL_LIL_ENDIAN;
470 AUDIO_U16SYS = AUDIO_U16LSB;
471 AUDIO_S16SYS = AUDIO_S16LSB;
472 {$ELSE}
473 AUDIO_U16SYS = AUDIO_U16MSB;
474 AUDIO_S16SYS = AUDIO_S16MSB;
475 {$ENDIF}
476 {$EXTERNALSYM AUDIO_U16SYS}
477 {$EXTERNALSYM AUDIO_S16SYS}
479 SDL_MIX_MAXVOLUME = 128;
480 {$EXTERNALSYM SDL_MIX_MAXVOLUME}
482 // SDL_joystick.h constants
483 MAX_JOYSTICKS = 2; // only 2 are supported in the multimedia API
484 {$EXTERNALSYM MAX_JOYSTICKS}
485 MAX_AXES = 6; // each joystick can have up to 6 axes
486 {$EXTERNALSYM MAX_AXES}
487 MAX_BUTTONS = 32; // and 32 buttons
488 {$EXTERNALSYM MAX_BUTTONS}
489 AXIS_MIN = -32768; // minimum value for axis coordinate
490 {$EXTERNALSYM AXIS_MIN}
491 AXIS_MAX = 32767; // maximum value for axis coordinate
492 {$EXTERNALSYM AXIS_MAX}
493 JOY_AXIS_THRESHOLD = (((AXIS_MAX) - (AXIS_MIN)) / 100); // 1% motion
494 {$EXTERNALSYM JOY_AXIS_THRESHOLD}
495 //JOY_BUTTON_FLAG(n) (1<<n)
496 // array to hold joystick ID values
497 //static UInt SYS_JoystickID[MAX_JOYSTICKS];
498 //static JOYCAPS SYS_Joystick[MAX_JOYSTICKS];
500 { Get the current state of a POV hat on a joystick
501 The return value is one of the following positions: }
502 SDL_HAT_CENTERED = $00;
503 {$EXTERNALSYM SDL_HAT_CENTERED}
504 SDL_HAT_UP = $01;
505 {$EXTERNALSYM SDL_HAT_UP}
506 SDL_HAT_RIGHT = $02;
507 {$EXTERNALSYM SDL_HAT_RIGHT}
508 SDL_HAT_DOWN = $04;
509 {$EXTERNALSYM SDL_HAT_DOWN}
510 SDL_HAT_LEFT = $08;
511 {$EXTERNALSYM SDL_HAT_LEFT}
512 SDL_HAT_RIGHTUP = SDL_HAT_RIGHT or SDL_HAT_UP;
513 {$EXTERNALSYM SDL_HAT_RIGHTUP}
514 SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN;
515 {$EXTERNALSYM SDL_HAT_RIGHTDOWN}
516 SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP;
517 {$EXTERNALSYM SDL_HAT_LEFTUP}
518 SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN;
519 {$EXTERNALSYM SDL_HAT_LEFTDOWN}
521 // SDL_events.h constants
522 SDL_NOEVENT = 0; // Unused (do not remove)
523 {$EXTERNALSYM SDL_NOEVENT}
524 SDL_ACTIVEEVENT = 1; // Application loses/gains visibility
525 {$EXTERNALSYM SDL_ACTIVEEVENT}
526 SDL_KEYDOWN = 2; // Keys pressed
527 {$EXTERNALSYM SDL_KEYDOWN}
528 SDL_KEYUP = 3; // Keys released
529 {$EXTERNALSYM SDL_KEYUP}
530 SDL_MOUSEMOTION = 4; // Mouse moved
531 {$EXTERNALSYM SDL_MOUSEMOTION}
532 SDL_MOUSEBUTTONDOWN = 5; // Mouse button pressed
533 {$EXTERNALSYM SDL_MOUSEBUTTONDOWN}
534 SDL_MOUSEBUTTONUP = 6; // Mouse button released
535 {$EXTERNALSYM SDL_MOUSEBUTTONUP}
536 SDL_JOYAXISMOTION = 7; // Joystick axis motion
537 {$EXTERNALSYM SDL_JOYAXISMOTION}
538 SDL_JOYBALLMOTION = 8; // Joystick trackball motion
539 {$EXTERNALSYM SDL_JOYBALLMOTION}
540 SDL_JOYHATMOTION = 9; // Joystick hat position change
541 {$EXTERNALSYM SDL_JOYHATMOTION}
542 SDL_JOYBUTTONDOWN = 10; // Joystick button pressed
543 {$EXTERNALSYM SDL_JOYBUTTONDOWN}
544 SDL_JOYBUTTONUP = 11; // Joystick button released
545 {$EXTERNALSYM SDL_JOYBUTTONUP}
546 SDL_QUITEV = 12; // User-requested quit ( Changed due to procedure conflict )
547 {$EXTERNALSYM SDL_QUIT}
548 SDL_SYSWMEVENT = 13; // System specific event
549 {$EXTERNALSYM SDL_SYSWMEVENT}
550 SDL_EVENT_RESERVEDA = 14; // Reserved for future use..
551 {$EXTERNALSYM SDL_EVENT_RESERVEDA}
552 SDL_EVENT_RESERVED = 15; // Reserved for future use..
553 {$EXTERNALSYM SDL_EVENT_RESERVED}
554 SDL_VIDEORESIZE = 16; // User resized video mode
555 {$EXTERNALSYM SDL_VIDEORESIZE}
556 SDL_VIDEOEXPOSE = 17; // Screen needs to be redrawn
557 {$EXTERNALSYM SDL_VIDEOEXPOSE}
558 SDL_EVENT_RESERVED2 = 18; // Reserved for future use..
559 {$EXTERNALSYM SDL_EVENT_RESERVED2}
560 SDL_EVENT_RESERVED3 = 19; // Reserved for future use..
561 {$EXTERNALSYM SDL_EVENT_RESERVED3}
562 SDL_EVENT_RESERVED4 = 20; // Reserved for future use..
563 {$EXTERNALSYM SDL_EVENT_RESERVED4}
564 SDL_EVENT_RESERVED5 = 21; // Reserved for future use..
565 {$EXTERNALSYM SDL_EVENT_RESERVED5}
566 SDL_EVENT_RESERVED6 = 22; // Reserved for future use..
567 {$EXTERNALSYM SDL_EVENT_RESERVED6}
568 SDL_EVENT_RESERVED7 = 23; // Reserved for future use..
569 {$EXTERNALSYM SDL_EVENT_RESERVED7}
570 // Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use
571 SDL_USEREVENT = 24;
572 {$EXTERNALSYM SDL_USEREVENT}
573 // This last event is only for bounding internal arrays
574 // It is the number of bits in the event mask datatype -- UInt32
575 SDL_NUMEVENTS = 32;
576 {$EXTERNALSYM SDL_NUMEVENTS}
578 SDL_ALLEVENTS = $FFFFFFFF;
579 {$EXTERNALSYM SDL_ALLEVENTS}
581 SDL_ACTIVEEVENTMASK = 1 shl SDL_ACTIVEEVENT;
582 {$EXTERNALSYM SDL_ACTIVEEVENTMASK}
583 SDL_KEYDOWNMASK = 1 shl SDL_KEYDOWN;
584 {$EXTERNALSYM SDL_KEYDOWNMASK}
585 SDL_KEYUPMASK = 1 shl SDL_KEYUP;
586 {$EXTERNALSYM SDL_KEYUPMASK}
587 SDL_MOUSEMOTIONMASK = 1 shl SDL_MOUSEMOTION;
588 {$EXTERNALSYM SDL_MOUSEMOTIONMASK}
589 SDL_MOUSEBUTTONDOWNMASK = 1 shl SDL_MOUSEBUTTONDOWN;
590 {$EXTERNALSYM SDL_MOUSEBUTTONDOWNMASK}
591 SDL_MOUSEBUTTONUPMASK = 1 shl SDL_MOUSEBUTTONUP;
592 {$EXTERNALSYM SDL_MOUSEBUTTONUPMASK}
593 SDL_MOUSEEVENTMASK = 1 shl SDL_MOUSEMOTION or
594 1 shl SDL_MOUSEBUTTONDOWN or
595 1 shl SDL_MOUSEBUTTONUP;
596 {$EXTERNALSYM SDL_MOUSEEVENTMASK}
597 SDL_JOYAXISMOTIONMASK = 1 shl SDL_JOYAXISMOTION;
598 {$EXTERNALSYM SDL_JOYAXISMOTIONMASK}
599 SDL_JOYBALLMOTIONMASK = 1 shl SDL_JOYBALLMOTION;
600 {$EXTERNALSYM SDL_JOYBALLMOTIONMASK}
601 SDL_JOYHATMOTIONMASK = 1 shl SDL_JOYHATMOTION;
602 {$EXTERNALSYM SDL_JOYHATMOTIONMASK}
603 SDL_JOYBUTTONDOWNMASK = 1 shl SDL_JOYBUTTONDOWN;
604 {$EXTERNALSYM SDL_JOYBUTTONDOWNMASK}
605 SDL_JOYBUTTONUPMASK = 1 shl SDL_JOYBUTTONUP;
606 {$EXTERNALSYM SDL_JOYBUTTONUPMASK}
607 SDL_JOYEVENTMASK = 1 shl SDL_JOYAXISMOTION or
608 1 shl SDL_JOYBALLMOTION or
609 1 shl SDL_JOYHATMOTION or
610 1 shl SDL_JOYBUTTONDOWN or
611 1 shl SDL_JOYBUTTONUP;
612 {$EXTERNALSYM SDL_JOYEVENTMASK}
613 SDL_VIDEORESIZEMASK = 1 shl SDL_VIDEORESIZE;
614 {$EXTERNALSYM SDL_VIDEORESIZEMASK}
615 SDL_QUITMASK = 1 shl SDL_QUITEV;
616 {$EXTERNALSYM SDL_QUITMASK}
617 SDL_SYSWMEVENTMASK = 1 shl SDL_SYSWMEVENT;
618 {$EXTERNALSYM SDL_SYSWMEVENTMASK}
620 { This function allows you to set the state of processing certain events.
621 If 'state' is set to SDL_IGNORE, that event will be automatically dropped
622 from the event queue and will not event be filtered.
623 If 'state' is set to SDL_ENABLE, that event will be processed normally.
624 If 'state' is set to SDL_QUERY, SDL_EventState() will return the
625 current processing state of the specified event. }
627 SDL_QUERY = -1;
628 {$EXTERNALSYM SDL_QUERY}
629 SDL_IGNORE = 0;
630 {$EXTERNALSYM SDL_IGNORE}
631 SDL_DISABLE = 0;
632 {$EXTERNALSYM SDL_DISABLE}
633 SDL_ENABLE = 1;
634 {$EXTERNALSYM SDL_ENABLE}
636 //SDL_keyboard.h constants
637 // This is the mask which refers to all hotkey bindings
638 SDL_ALL_HOTKEYS = $FFFFFFFF;
639 {$EXTERNALSYM SDL_ALL_HOTKEYS}
641 { Enable/Disable keyboard repeat. Keyboard repeat defaults to off.
642 'delay' is the initial delay in ms between the time when a key is
643 pressed, and keyboard repeat begins.
644 'interval' is the time in ms between keyboard repeat events. }
646 SDL_DEFAULT_REPEAT_DELAY = 500;
647 {$EXTERNALSYM SDL_DEFAULT_REPEAT_DELAY}
648 SDL_DEFAULT_REPEAT_INTERVAL = 30;
649 {$EXTERNALSYM SDL_DEFAULT_REPEAT_INTERVAL}
651 // The keyboard syms have been cleverly chosen to map to ASCII
652 SDLK_UNKNOWN = 0;
653 {$EXTERNALSYM SDLK_UNKNOWN}
654 SDLK_FIRST = 0;
655 {$EXTERNALSYM SDLK_FIRST}
656 SDLK_BACKSPACE = 8;
657 {$EXTERNALSYM SDLK_BACKSPACE}
658 SDLK_TAB = 9;
659 {$EXTERNALSYM SDLK_TAB}
660 SDLK_CLEAR = 12;
661 {$EXTERNALSYM SDLK_CLEAR}
662 SDLK_RETURN = 13;
663 {$EXTERNALSYM SDLK_RETURN}
664 SDLK_PAUSE = 19;
665 {$EXTERNALSYM SDLK_PAUSE}
666 SDLK_ESCAPE = 27;
667 {$EXTERNALSYM SDLK_ESCAPE}
668 SDLK_SPACE = 32;
669 {$EXTERNALSYM SDLK_SPACE}
670 SDLK_EXCLAIM = 33;
671 {$EXTERNALSYM SDLK_EXCLAIM}
672 SDLK_QUOTEDBL = 34;
673 {$EXTERNALSYM SDLK_QUOTEDBL}
674 SDLK_HASH = 35;
675 {$EXTERNALSYM SDLK_HASH}
676 SDLK_DOLLAR = 36;
677 {$EXTERNALSYM SDLK_DOLLAR}
678 SDLK_AMPERSAND = 38;
679 {$EXTERNALSYM SDLK_AMPERSAND}
680 SDLK_QUOTE = 39;
681 {$EXTERNALSYM SDLK_QUOTE}
682 SDLK_LEFTPAREN = 40;
683 {$EXTERNALSYM SDLK_LEFTPAREN}
684 SDLK_RIGHTPAREN = 41;
685 {$EXTERNALSYM SDLK_RIGHTPAREN}
686 SDLK_ASTERISK = 42;
687 {$EXTERNALSYM SDLK_ASTERISK}
688 SDLK_PLUS = 43;
689 {$EXTERNALSYM SDLK_PLUS}
690 SDLK_COMMA = 44;
691 {$EXTERNALSYM SDLK_COMMA}
692 SDLK_MINUS = 45;
693 {$EXTERNALSYM SDLK_MINUS}
694 SDLK_PERIOD = 46;
695 {$EXTERNALSYM SDLK_PERIOD}
696 SDLK_SLASH = 47;
697 {$EXTERNALSYM SDLK_SLASH}
698 SDLK_0 = 48;
699 {$EXTERNALSYM SDLK_0}
700 SDLK_1 = 49;
701 {$EXTERNALSYM SDLK_1}
702 SDLK_2 = 50;
703 {$EXTERNALSYM SDLK_2}
704 SDLK_3 = 51;
705 {$EXTERNALSYM SDLK_3}
706 SDLK_4 = 52;
707 {$EXTERNALSYM SDLK_4}
708 SDLK_5 = 53;
709 {$EXTERNALSYM SDLK_5}
710 SDLK_6 = 54;
711 {$EXTERNALSYM SDLK_6}
712 SDLK_7 = 55;
713 {$EXTERNALSYM SDLK_7}
714 SDLK_8 = 56;
715 {$EXTERNALSYM SDLK_8}
716 SDLK_9 = 57;
717 {$EXTERNALSYM SDLK_9}
718 SDLK_COLON = 58;
719 {$EXTERNALSYM SDLK_COLON}
720 SDLK_SEMICOLON = 59;
721 {$EXTERNALSYM SDLK_SEMICOLON}
722 SDLK_LESS = 60;
723 {$EXTERNALSYM SDLK_LESS}
724 SDLK_EQUALS = 61;
725 {$EXTERNALSYM SDLK_EQUALS}
726 SDLK_GREATER = 62;
727 {$EXTERNALSYM SDLK_GREATER}
728 SDLK_QUESTION = 63;
729 {$EXTERNALSYM SDLK_QUESTION}
730 SDLK_AT = 64;
731 {$EXTERNALSYM SDLK_AT}
733 { Skip uppercase letters }
735 SDLK_LEFTBRACKET = 91;
736 {$EXTERNALSYM SDLK_LEFTBRACKET}
737 SDLK_BACKSLASH = 92;
738 {$EXTERNALSYM SDLK_BACKSLASH}
739 SDLK_RIGHTBRACKET = 93;
740 {$EXTERNALSYM SDLK_RIGHTBRACKET}
741 SDLK_CARET = 94;
742 {$EXTERNALSYM SDLK_CARET}
743 SDLK_UNDERSCORE = 95;
744 {$EXTERNALSYM SDLK_UNDERSCORE}
745 SDLK_BACKQUOTE = 96;
746 {$EXTERNALSYM SDLK_BACKQUOTE}
747 SDLK_a = 97;
748 {$EXTERNALSYM SDLK_a}
749 SDLK_b = 98;
750 {$EXTERNALSYM SDLK_b}
751 SDLK_c = 99;
752 {$EXTERNALSYM SDLK_c}
753 SDLK_d = 100;
754 {$EXTERNALSYM SDLK_d}
755 SDLK_e = 101;
756 {$EXTERNALSYM SDLK_e}
757 SDLK_f = 102;
758 {$EXTERNALSYM SDLK_f}
759 SDLK_g = 103;
760 {$EXTERNALSYM SDLK_g}
761 SDLK_h = 104;
762 {$EXTERNALSYM SDLK_h}
763 SDLK_i = 105;
764 {$EXTERNALSYM SDLK_i}
765 SDLK_j = 106;
766 {$EXTERNALSYM SDLK_j}
767 SDLK_k = 107;
768 {$EXTERNALSYM SDLK_k}
769 SDLK_l = 108;
770 {$EXTERNALSYM SDLK_l}
771 SDLK_m = 109;
772 {$EXTERNALSYM SDLK_m}
773 SDLK_n = 110;
774 {$EXTERNALSYM SDLK_n}
775 SDLK_o = 111;
776 {$EXTERNALSYM SDLK_o}
777 SDLK_p = 112;
778 {$EXTERNALSYM SDLK_p}
779 SDLK_q = 113;
780 {$EXTERNALSYM SDLK_q}
781 SDLK_r = 114;
782 {$EXTERNALSYM SDLK_r}
783 SDLK_s = 115;
784 {$EXTERNALSYM SDLK_s}
785 SDLK_t = 116;
786 {$EXTERNALSYM SDLK_t}
787 SDLK_u = 117;
788 {$EXTERNALSYM SDLK_u}
789 SDLK_v = 118;
790 {$EXTERNALSYM SDLK_v}
791 SDLK_w = 119;
792 {$EXTERNALSYM SDLK_w}
793 SDLK_x = 120;
794 {$EXTERNALSYM SDLK_x}
795 SDLK_y = 121;
796 {$EXTERNALSYM SDLK_y}
797 SDLK_z = 122;
798 {$EXTERNALSYM SDLK_z}
799 SDLK_DELETE = 127;
800 {$EXTERNALSYM SDLK_DELETE}
801 // End of ASCII mapped keysyms
803 // International keyboard syms
804 SDLK_WORLD_0 = 160; // 0xA0
805 {$EXTERNALSYM SDLK_WORLD_0}
806 SDLK_WORLD_1 = 161;
807 {$EXTERNALSYM SDLK_WORLD_1}
808 SDLK_WORLD_2 = 162;
809 {$EXTERNALSYM SDLK_WORLD_2}
810 SDLK_WORLD_3 = 163;
811 {$EXTERNALSYM SDLK_WORLD_3}
812 SDLK_WORLD_4 = 164;
813 {$EXTERNALSYM SDLK_WORLD_4}
814 SDLK_WORLD_5 = 165;
815 {$EXTERNALSYM SDLK_WORLD_5}
816 SDLK_WORLD_6 = 166;
817 {$EXTERNALSYM SDLK_WORLD_6}
818 SDLK_WORLD_7 = 167;
819 {$EXTERNALSYM SDLK_WORLD_7}
820 SDLK_WORLD_8 = 168;
821 {$EXTERNALSYM SDLK_WORLD_8}
822 SDLK_WORLD_9 = 169;
823 {$EXTERNALSYM SDLK_WORLD_9}
824 SDLK_WORLD_10 = 170;
825 {$EXTERNALSYM SDLK_WORLD_10}
826 SDLK_WORLD_11 = 171;
827 {$EXTERNALSYM SDLK_WORLD_11}
828 SDLK_WORLD_12 = 172;
829 {$EXTERNALSYM SDLK_WORLD_12}
830 SDLK_WORLD_13 = 173;
831 {$EXTERNALSYM SDLK_WORLD_13}
832 SDLK_WORLD_14 = 174;
833 {$EXTERNALSYM SDLK_WORLD_14}
834 SDLK_WORLD_15 = 175;
835 {$EXTERNALSYM SDLK_WORLD_15}
836 SDLK_WORLD_16 = 176;
837 {$EXTERNALSYM SDLK_WORLD_16}
838 SDLK_WORLD_17 = 177;
839 {$EXTERNALSYM SDLK_WORLD_17}
840 SDLK_WORLD_18 = 178;
841 {$EXTERNALSYM SDLK_WORLD_18}
842 SDLK_WORLD_19 = 179;
843 {$EXTERNALSYM SDLK_WORLD_19}
844 SDLK_WORLD_20 = 180;
845 {$EXTERNALSYM SDLK_WORLD_20}
846 SDLK_WORLD_21 = 181;
847 {$EXTERNALSYM SDLK_WORLD_21}
848 SDLK_WORLD_22 = 182;
849 {$EXTERNALSYM SDLK_WORLD_22}
850 SDLK_WORLD_23 = 183;
851 {$EXTERNALSYM SDLK_WORLD_23}
852 SDLK_WORLD_24 = 184;
853 {$EXTERNALSYM SDLK_WORLD_24}
854 SDLK_WORLD_25 = 185;
855 {$EXTERNALSYM SDLK_WORLD_25}
856 SDLK_WORLD_26 = 186;
857 {$EXTERNALSYM SDLK_WORLD_26}
858 SDLK_WORLD_27 = 187;
859 {$EXTERNALSYM SDLK_WORLD_27}
860 SDLK_WORLD_28 = 188;
861 {$EXTERNALSYM SDLK_WORLD_28}
862 SDLK_WORLD_29 = 189;
863 {$EXTERNALSYM SDLK_WORLD_29}
864 SDLK_WORLD_30 = 190;
865 {$EXTERNALSYM SDLK_WORLD_30}
866 SDLK_WORLD_31 = 191;
867 {$EXTERNALSYM SDLK_WORLD_31}
868 SDLK_WORLD_32 = 192;
869 {$EXTERNALSYM SDLK_WORLD_32}
870 SDLK_WORLD_33 = 193;
871 {$EXTERNALSYM SDLK_WORLD_33}
872 SDLK_WORLD_34 = 194;
873 {$EXTERNALSYM SDLK_WORLD_34}
874 SDLK_WORLD_35 = 195;
875 {$EXTERNALSYM SDLK_WORLD_35}
876 SDLK_WORLD_36 = 196;
877 {$EXTERNALSYM SDLK_WORLD_36}
878 SDLK_WORLD_37 = 197;
879 {$EXTERNALSYM SDLK_WORLD_37}
880 SDLK_WORLD_38 = 198;
881 {$EXTERNALSYM SDLK_WORLD_38}
882 SDLK_WORLD_39 = 199;
883 {$EXTERNALSYM SDLK_WORLD_39}
884 SDLK_WORLD_40 = 200;
885 {$EXTERNALSYM SDLK_WORLD_40}
886 SDLK_WORLD_41 = 201;
887 {$EXTERNALSYM SDLK_WORLD_41}
888 SDLK_WORLD_42 = 202;
889 {$EXTERNALSYM SDLK_WORLD_42}
890 SDLK_WORLD_43 = 203;
891 {$EXTERNALSYM SDLK_WORLD_43}
892 SDLK_WORLD_44 = 204;
893 {$EXTERNALSYM SDLK_WORLD_44}
894 SDLK_WORLD_45 = 205;
895 {$EXTERNALSYM SDLK_WORLD_45}
896 SDLK_WORLD_46 = 206;
897 {$EXTERNALSYM SDLK_WORLD_46}
898 SDLK_WORLD_47 = 207;
899 {$EXTERNALSYM SDLK_WORLD_47}
900 SDLK_WORLD_48 = 208;
901 {$EXTERNALSYM SDLK_WORLD_48}
902 SDLK_WORLD_49 = 209;
903 {$EXTERNALSYM SDLK_WORLD_49}
904 SDLK_WORLD_50 = 210;
905 {$EXTERNALSYM SDLK_WORLD_50}
906 SDLK_WORLD_51 = 211;
907 {$EXTERNALSYM SDLK_WORLD_51}
908 SDLK_WORLD_52 = 212;
909 {$EXTERNALSYM SDLK_WORLD_52}
910 SDLK_WORLD_53 = 213;
911 {$EXTERNALSYM SDLK_WORLD_53}
912 SDLK_WORLD_54 = 214;
913 {$EXTERNALSYM SDLK_WORLD_54}
914 SDLK_WORLD_55 = 215;
915 {$EXTERNALSYM SDLK_WORLD_55}
916 SDLK_WORLD_56 = 216;
917 {$EXTERNALSYM SDLK_WORLD_56}
918 SDLK_WORLD_57 = 217;
919 {$EXTERNALSYM SDLK_WORLD_57}
920 SDLK_WORLD_58 = 218;
921 {$EXTERNALSYM SDLK_WORLD_58}
922 SDLK_WORLD_59 = 219;
923 {$EXTERNALSYM SDLK_WORLD_59}
924 SDLK_WORLD_60 = 220;
925 {$EXTERNALSYM SDLK_WORLD_60}
926 SDLK_WORLD_61 = 221;
927 {$EXTERNALSYM SDLK_WORLD_61}
928 SDLK_WORLD_62 = 222;
929 {$EXTERNALSYM SDLK_WORLD_62}
930 SDLK_WORLD_63 = 223;
931 {$EXTERNALSYM SDLK_WORLD_63}
932 SDLK_WORLD_64 = 224;
933 {$EXTERNALSYM SDLK_WORLD_64}
934 SDLK_WORLD_65 = 225;
935 {$EXTERNALSYM SDLK_WORLD_65}
936 SDLK_WORLD_66 = 226;
937 {$EXTERNALSYM SDLK_WORLD_66}
938 SDLK_WORLD_67 = 227;
939 {$EXTERNALSYM SDLK_WORLD_67}
940 SDLK_WORLD_68 = 228;
941 {$EXTERNALSYM SDLK_WORLD_68}
942 SDLK_WORLD_69 = 229;
943 {$EXTERNALSYM SDLK_WORLD_69}
944 SDLK_WORLD_70 = 230;
945 {$EXTERNALSYM SDLK_WORLD_70}
946 SDLK_WORLD_71 = 231;
947 {$EXTERNALSYM SDLK_WORLD_71}
948 SDLK_WORLD_72 = 232;
949 {$EXTERNALSYM SDLK_WORLD_72}
950 SDLK_WORLD_73 = 233;
951 {$EXTERNALSYM SDLK_WORLD_73}
952 SDLK_WORLD_74 = 234;
953 {$EXTERNALSYM SDLK_WORLD_74}
954 SDLK_WORLD_75 = 235;
955 {$EXTERNALSYM SDLK_WORLD_75}
956 SDLK_WORLD_76 = 236;
957 {$EXTERNALSYM SDLK_WORLD_76}
958 SDLK_WORLD_77 = 237;
959 {$EXTERNALSYM SDLK_WORLD_77}
960 SDLK_WORLD_78 = 238;
961 {$EXTERNALSYM SDLK_WORLD_78}
962 SDLK_WORLD_79 = 239;
963 {$EXTERNALSYM SDLK_WORLD_79}
964 SDLK_WORLD_80 = 240;
965 {$EXTERNALSYM SDLK_WORLD_80}
966 SDLK_WORLD_81 = 241;
967 {$EXTERNALSYM SDLK_WORLD_81}
968 SDLK_WORLD_82 = 242;
969 {$EXTERNALSYM SDLK_WORLD_82}
970 SDLK_WORLD_83 = 243;
971 {$EXTERNALSYM SDLK_WORLD_83}
972 SDLK_WORLD_84 = 244;
973 {$EXTERNALSYM SDLK_WORLD_84}
974 SDLK_WORLD_85 = 245;
975 {$EXTERNALSYM SDLK_WORLD_85}
976 SDLK_WORLD_86 = 246;
977 {$EXTERNALSYM SDLK_WORLD_86}
978 SDLK_WORLD_87 = 247;
979 {$EXTERNALSYM SDLK_WORLD_87}
980 SDLK_WORLD_88 = 248;
981 {$EXTERNALSYM SDLK_WORLD_88}
982 SDLK_WORLD_89 = 249;
983 {$EXTERNALSYM SDLK_WORLD_89}
984 SDLK_WORLD_90 = 250;
985 {$EXTERNALSYM SDLK_WORLD_90}
986 SDLK_WORLD_91 = 251;
987 {$EXTERNALSYM SDLK_WORLD_91}
988 SDLK_WORLD_92 = 252;
989 {$EXTERNALSYM SDLK_WORLD_92}
990 SDLK_WORLD_93 = 253;
991 {$EXTERNALSYM SDLK_WORLD_93}
992 SDLK_WORLD_94 = 254;
993 {$EXTERNALSYM SDLK_WORLD_94}
994 SDLK_WORLD_95 = 255; // 0xFF
995 {$EXTERNALSYM SDLK_WORLD_95}
997 // Numeric keypad
998 SDLK_KP0 = 256;
999 {$EXTERNALSYM SDLK_KP0}
1000 SDLK_KP1 = 257;
1001 {$EXTERNALSYM SDLK_KP1}
1002 SDLK_KP2 = 258;
1003 {$EXTERNALSYM SDLK_KP2}
1004 SDLK_KP3 = 259;
1005 {$EXTERNALSYM SDLK_KP3}
1006 SDLK_KP4 = 260;
1007 {$EXTERNALSYM SDLK_KP4}
1008 SDLK_KP5 = 261;
1009 {$EXTERNALSYM SDLK_KP5}
1010 SDLK_KP6 = 262;
1011 {$EXTERNALSYM SDLK_KP6}
1012 SDLK_KP7 = 263;
1013 {$EXTERNALSYM SDLK_KP7}
1014 SDLK_KP8 = 264;
1015 {$EXTERNALSYM SDLK_KP8}
1016 SDLK_KP9 = 265;
1017 {$EXTERNALSYM SDLK_KP9}
1018 SDLK_KP_PERIOD = 266;
1019 {$EXTERNALSYM SDLK_KP_PERIOD}
1020 SDLK_KP_DIVIDE = 267;
1021 {$EXTERNALSYM SDLK_KP_DIVIDE}
1022 SDLK_KP_MULTIPLY = 268;
1023 {$EXTERNALSYM SDLK_KP_MULTIPLY}
1024 SDLK_KP_MINUS = 269;
1025 {$EXTERNALSYM SDLK_KP_MINUS}
1026 SDLK_KP_PLUS = 270;
1027 {$EXTERNALSYM SDLK_KP_PLUS}
1028 SDLK_KP_ENTER = 271;
1029 {$EXTERNALSYM SDLK_KP_ENTER}
1030 SDLK_KP_EQUALS = 272;
1031 {$EXTERNALSYM SDLK_KP_EQUALS}
1033 // Arrows + Home/End pad
1034 SDLK_UP = 273;
1035 {$EXTERNALSYM SDLK_UP}
1036 SDLK_DOWN = 274;
1037 {$EXTERNALSYM SDLK_DOWN}
1038 SDLK_RIGHT = 275;
1039 {$EXTERNALSYM SDLK_RIGHT}
1040 SDLK_LEFT = 276;
1041 {$EXTERNALSYM SDLK_LEFT}
1042 SDLK_INSERT = 277;
1043 {$EXTERNALSYM SDLK_INSERT}
1044 SDLK_HOME = 278;
1045 {$EXTERNALSYM SDLK_HOME}
1046 SDLK_END = 279;
1047 {$EXTERNALSYM SDLK_END}
1048 SDLK_PAGEUP = 280;
1049 {$EXTERNALSYM SDLK_PAGEUP}
1050 SDLK_PAGEDOWN = 281;
1051 {$EXTERNALSYM SDLK_PAGEDOWN}
1053 // Function keys
1054 SDLK_F1 = 282;
1055 {$EXTERNALSYM SDLK_F1}
1056 SDLK_F2 = 283;
1057 {$EXTERNALSYM SDLK_F2}
1058 SDLK_F3 = 284;
1059 {$EXTERNALSYM SDLK_F3}
1060 SDLK_F4 = 285;
1061 {$EXTERNALSYM SDLK_F4}
1062 SDLK_F5 = 286;
1063 {$EXTERNALSYM SDLK_F5}
1064 SDLK_F6 = 287;
1065 {$EXTERNALSYM SDLK_F6}
1066 SDLK_F7 = 288;
1067 {$EXTERNALSYM SDLK_F7}
1068 SDLK_F8 = 289;
1069 {$EXTERNALSYM SDLK_F8}
1070 SDLK_F9 = 290;
1071 {$EXTERNALSYM SDLK_F9}
1072 SDLK_F10 = 291;
1073 {$EXTERNALSYM SDLK_F10}
1074 SDLK_F11 = 292;
1075 {$EXTERNALSYM SDLK_F11}
1076 SDLK_F12 = 293;
1077 {$EXTERNALSYM SDLK_F12}
1078 SDLK_F13 = 294;
1079 {$EXTERNALSYM SDLK_F13}
1080 SDLK_F14 = 295;
1081 {$EXTERNALSYM SDLK_F14}
1082 SDLK_F15 = 296;
1083 {$EXTERNALSYM SDLK_F15}
1085 // Key state modifier keys
1086 SDLK_NUMLOCK = 300;
1087 {$EXTERNALSYM SDLK_NUMLOCK}
1088 SDLK_CAPSLOCK = 301;
1089 {$EXTERNALSYM SDLK_CAPSLOCK}
1090 SDLK_SCROLLOCK = 302;
1091 {$EXTERNALSYM SDLK_SCROLLOCK}
1092 SDLK_RSHIFT = 303;
1093 {$EXTERNALSYM SDLK_RSHIFT}
1094 SDLK_LSHIFT = 304;
1095 {$EXTERNALSYM SDLK_LSHIFT}
1096 SDLK_RCTRL = 305;
1097 {$EXTERNALSYM SDLK_RCTRL}
1098 SDLK_LCTRL = 306;
1099 {$EXTERNALSYM SDLK_LCTRL}
1100 SDLK_RALT = 307;
1101 {$EXTERNALSYM SDLK_RALT}
1102 SDLK_LALT = 308;
1103 {$EXTERNALSYM SDLK_LALT}
1104 SDLK_RMETA = 309;
1105 {$EXTERNALSYM SDLK_RMETA}
1106 SDLK_LMETA = 310;
1107 {$EXTERNALSYM SDLK_LMETA}
1108 SDLK_LSUPER = 311; // Left "Windows" key
1109 {$EXTERNALSYM SDLK_LSUPER}
1110 SDLK_RSUPER = 312; // Right "Windows" key
1111 {$EXTERNALSYM SDLK_RSUPER}
1112 SDLK_MODE = 313; // "Alt Gr" key
1113 {$EXTERNALSYM SDLK_MODE}
1114 SDLK_COMPOSE = 314; // Multi-key compose key
1115 {$EXTERNALSYM SDLK_COMPOSE}
1117 // Miscellaneous function keys
1118 SDLK_HELP = 315;
1119 {$EXTERNALSYM SDLK_HELP}
1120 SDLK_PRINT = 316;
1121 {$EXTERNALSYM SDLK_PRINT}
1122 SDLK_SYSREQ = 317;
1123 {$EXTERNALSYM SDLK_SYSREQ}
1124 SDLK_BREAK = 318;
1125 {$EXTERNALSYM SDLK_BREAK}
1126 SDLK_MENU = 319;
1127 {$EXTERNALSYM SDLK_MENU}
1128 SDLK_POWER = 320; // Power Macintosh power key
1129 {$EXTERNALSYM SDLK_POWER}
1130 SDLK_EURO = 321; // Some european keyboards
1131 {$EXTERNALSYM SDLK_EURO}
1133 {$IFDEF GP2X}
1134 SDLK_GP2X_UP = 0;
1135 {$EXTERNALSYM SDLK_GP2X_UP}
1136 SDLK_GP2X_UPLEFT = 1;
1137 {$EXTERNALSYM SDLK_GP2X_UPLEFT}
1138 SDLK_GP2X_LEFT = 2;
1139 {$EXTERNALSYM SDLK_GP2X_LEFT}
1140 SDLK_GP2X_DOWNLEFT = 3;
1141 {$EXTERNALSYM SDLK_GP2X_DOWNLEFT}
1142 SDLK_GP2X_DOWN = 4;
1143 {$EXTERNALSYM SDLK_GP2X_DOWN}
1144 SDLK_GP2X_DOWNRIGHT = 5;
1145 {$EXTERNALSYM SDLK_GP2X_DOWNRIGHT}
1146 SDLK_GP2X_RIGHT = 6;
1147 {$EXTERNALSYM SDLK_GP2X_RIGHT}
1148 SDLK_GP2X_UPRIGHT = 7;
1149 {$EXTERNALSYM SDLK_GP2X_UPRIGHT}
1150 SDLK_GP2X_START = 8;
1151 {$EXTERNALSYM SDLK_GP2X_START}
1152 SDLK_GP2X_SELECT = 9;
1153 {$EXTERNALSYM SDLK_GP2X_SELECT}
1154 SDLK_GP2X_L = 10;
1155 {$EXTERNALSYM SDLK_GP2X_L}
1156 SDLK_GP2X_R = 11;
1157 {$EXTERNALSYM SDLK_GP2X_R}
1158 SDLK_GP2X_A = 12;
1159 {$EXTERNALSYM SDLK_GP2X_A}
1160 SDLK_GP2X_B = 13;
1161 {$EXTERNALSYM SDLK_GP2X_B}
1162 SDLK_GP2X_Y = 14;
1163 {$EXTERNALSYM SDLK_GP2X_Y}
1164 SDLK_GP2X_X = 15;
1165 {$EXTERNALSYM SDLK_GP2X_X}
1166 SDLK_GP2X_VOLUP = 16;
1167 {$EXTERNALSYM SDLK_GP2X_VOLUP}
1168 SDLK_GP2X_VOLDOWN = 17;
1169 {$EXTERNALSYM SDLK_GP2X_VOLDOWN}
1170 SDLK_GP2X_CLICK = 18;
1171 {$EXTERNALSYM SDLK_GP2X_CLICK}
1172 {$ENDIF}
1174 // Enumeration of valid key mods (possibly OR'd together)
1175 KMOD_NONE = $0000;
1176 {$EXTERNALSYM KMOD_NONE}
1177 KMOD_LSHIFT = $0001;
1178 {$EXTERNALSYM KMOD_LSHIFT}
1179 KMOD_RSHIFT = $0002;
1180 {$EXTERNALSYM KMOD_RSHIFT}
1181 KMOD_LCTRL = $0040;
1182 {$EXTERNALSYM KMOD_LCTRL}
1183 KMOD_RCTRL = $0080;
1184 {$EXTERNALSYM KMOD_RCTRL}
1185 KMOD_LALT = $0100;
1186 {$EXTERNALSYM KMOD_LALT}
1187 KMOD_RALT = $0200;
1188 {$EXTERNALSYM KMOD_RALT}
1189 KMOD_LMETA = $0400;
1190 {$EXTERNALSYM KMOD_LMETA}
1191 KMOD_RMETA = $0800;
1192 {$EXTERNALSYM KMOD_RMETA}
1193 KMOD_NUM = $1000;
1194 {$EXTERNALSYM KMOD_NUM}
1195 KMOD_CAPS = $2000;
1196 {$EXTERNALSYM KMOD_CAPS}
1197 KMOD_MODE = 44000;
1198 {$EXTERNALSYM KMOD_MODE}
1199 KMOD_RESERVED = $8000;
1200 {$EXTERNALSYM KMOD_RESERVED}
1202 KMOD_CTRL = (KMOD_LCTRL or KMOD_RCTRL);
1203 {$EXTERNALSYM KMOD_CTRL}
1204 KMOD_SHIFT = (KMOD_LSHIFT or KMOD_RSHIFT);
1205 {$EXTERNALSYM KMOD_SHIFT}
1206 KMOD_ALT = (KMOD_LALT or KMOD_RALT);
1207 {$EXTERNALSYM KMOD_ALT}
1208 KMOD_META = (KMOD_LMETA or KMOD_RMETA);
1209 {$EXTERNALSYM KMOD_META}
1211 //SDL_video.h constants
1212 // Transparency definitions: These define alpha as the opacity of a surface */
1213 SDL_ALPHA_OPAQUE = 255;
1214 {$EXTERNALSYM SDL_ALPHA_OPAQUE}
1215 SDL_ALPHA_TRANSPARENT = 0;
1216 {$EXTERNALSYM SDL_ALPHA_TRANSPARENT}
1218 // These are the currently supported flags for the SDL_surface
1219 // Available for SDL_CreateRGBSurface() or SDL_SetVideoMode()
1220 SDL_SWSURFACE = $00000000; // Surface is in system memory
1221 {$EXTERNALSYM SDL_SWSURFACE}
1222 SDL_HWSURFACE = $00000001; // Surface is in video memory
1223 {$EXTERNALSYM SDL_HWSURFACE}
1224 SDL_ASYNCBLIT = $00000004; // Use asynchronous blits if possible
1225 {$EXTERNALSYM SDL_ASYNCBLIT}
1226 // Available for SDL_SetVideoMode()
1227 SDL_ANYFORMAT = $10000000; // Allow any video depth/pixel-format
1228 {$EXTERNALSYM SDL_ANYFORMAT}
1229 SDL_HWPALETTE = $20000000; // Surface has exclusive palette
1230 {$EXTERNALSYM SDL_HWPALETTE}
1231 SDL_DOUBLEBUF = $40000000; // Set up double-buffered video mode
1232 {$EXTERNALSYM SDL_DOUBLEBUF}
1233 SDL_FULLSCREEN = $80000000; // Surface is a full screen display
1234 {$EXTERNALSYM SDL_FULLSCREEN}
1235 SDL_OPENGL = $00000002; // Create an OpenGL rendering context
1236 {$EXTERNALSYM SDL_OPENGL}
1237 SDL_OPENGLBLIT = $00000002; // Create an OpenGL rendering context
1238 {$EXTERNALSYM SDL_OPENGLBLIT}
1239 SDL_RESIZABLE = $00000010; // This video mode may be resized
1240 {$EXTERNALSYM SDL_RESIZABLE}
1241 SDL_NOFRAME = $00000020; // No window caption or edge frame
1242 {$EXTERNALSYM SDL_NOFRAME}
1243 // Used internally (read-only)
1244 SDL_HWACCEL = $00000100; // Blit uses hardware acceleration
1245 {$EXTERNALSYM SDL_HWACCEL}
1246 SDL_SRCCOLORKEY = $00001000; // Blit uses a source color key
1247 {$EXTERNALSYM SDL_SRCCOLORKEY}
1248 SDL_RLEACCELOK = $00002000; // Private flag
1249 {$EXTERNALSYM SDL_RLEACCELOK}
1250 SDL_RLEACCEL = $00004000; // Colorkey blit is RLE accelerated
1251 {$EXTERNALSYM SDL_RLEACCEL}
1252 SDL_SRCALPHA = $00010000; // Blit uses source alpha blending
1253 {$EXTERNALSYM SDL_SRCALPHA}
1254 SDL_SRCCLIPPING = $00100000; // Blit uses source clipping
1255 {$EXTERNALSYM SDL_SRCCLIPPING}
1256 SDL_PREALLOC = $01000000; // Surface uses preallocated memory
1257 {$EXTERNALSYM SDL_PREALLOC}
1259 { The most common video overlay formats.
1260 For an explanation of these pixel formats, see:
1261 http://www.webartz.com/fourcc/indexyuv.htm
1263 For information on the relationship between color spaces, see:
1264 http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html }
1266 SDL_YV12_OVERLAY = $32315659; // Planar mode: Y + V + U (3 planes)
1267 {$EXTERNALSYM SDL_YV12_OVERLAY}
1268 SDL_IYUV_OVERLAY = $56555949; // Planar mode: Y + U + V (3 planes)
1269 {$EXTERNALSYM SDL_IYUV_OVERLAY}
1270 SDL_YUY2_OVERLAY = $32595559; // Packed mode: Y0+U0+Y1+V0 (1 plane)
1271 {$EXTERNALSYM SDL_YUY2_OVERLAY}
1272 SDL_UYVY_OVERLAY = $59565955; // Packed mode: U0+Y0+V0+Y1 (1 plane)
1273 {$EXTERNALSYM SDL_UYVY_OVERLAY}
1274 SDL_YVYU_OVERLAY = $55595659; // Packed mode: Y0+V0+Y1+U0 (1 plane)
1275 {$EXTERNALSYM SDL_YVYU_OVERLAY}
1277 // flags for SDL_SetPalette()
1278 SDL_LOGPAL = $01;
1279 {$EXTERNALSYM SDL_LOGPAL}
1280 SDL_PHYSPAL = $02;
1281 {$EXTERNALSYM SDL_PHYSPAL}
1283 //SDL_mouse.h constants
1284 { Used as a mask when testing buttons in buttonstate
1285 Button 1: Left mouse button
1286 Button 2: Middle mouse button
1287 Button 3: Right mouse button
1288 Button 4: Mouse Wheel Up
1289 Button 5: Mouse Wheel Down
1291 SDL_BUTTON_LEFT = 1;
1292 {$EXTERNALSYM SDL_BUTTON_LEFT}
1293 SDL_BUTTON_MIDDLE = 2;
1294 {$EXTERNALSYM SDL_BUTTON_MIDDLE}
1295 SDL_BUTTON_RIGHT = 3;
1296 {$EXTERNALSYM SDL_BUTTON_RIGHT}
1297 SDL_BUTTON_WHEELUP = 4;
1298 {$EXTERNALSYM SDL_BUTTON_WHEELUP}
1299 SDL_BUTTON_WHEELDOWN = 5;
1300 {$EXTERNALSYM SDL_BUTTON_WHEELDOWN}
1301 SDL_BUTTON_LMASK = SDL_PRESSED shl (SDL_BUTTON_LEFT - 1);
1302 {$EXTERNALSYM SDL_BUTTON_LMASK}
1303 SDL_BUTTON_MMASK = SDL_PRESSED shl (SDL_BUTTON_MIDDLE - 1);
1304 {$EXTERNALSYM SDL_BUTTON_MMASK}
1305 SDL_BUTTON_RMask = SDL_PRESSED shl (SDL_BUTTON_RIGHT - 1);
1306 {$EXTERNALSYM SDL_BUTTON_RMask}
1308 // SDL_active.h constants
1309 // The available application states
1310 SDL_APPMOUSEFOCUS = $01; // The app has mouse coverage
1311 {$EXTERNALSYM SDL_APPMOUSEFOCUS}
1312 SDL_APPINPUTFOCUS = $02; // The app has input focus
1313 {$EXTERNALSYM SDL_APPINPUTFOCUS}
1314 SDL_APPACTIVE = $04; // The application is active
1315 {$EXTERNALSYM SDL_APPACTIVE}
1317 // SDL_mutex.h constants
1318 // Synchronization functions which can time out return this value
1319 // they time out.
1321 SDL_MUTEX_TIMEDOUT = 1;
1322 {$EXTERNALSYM SDL_MUTEX_TIMEDOUT}
1324 // This is the timeout value which corresponds to never time out
1325 SDL_MUTEX_MAXWAIT = not Cardinal(0);
1326 {$EXTERNALSYM SDL_MUTEX_MAXWAIT}
1328 {TSDL_GrabMode = (
1329 SDL_GRAB_QUERY,
1330 SDL_GRAB_OFF,
1331 SDL_GRAB_ON,
1332 SDL_GRAB_FULLSCREEN ); // Used internally}
1333 SDL_GRAB_QUERY = -1;
1334 SDL_GRAB_OFF = 0;
1335 SDL_GRAB_ON = 1;
1336 //SDL_GRAB_FULLSCREEN // Used internally
1338 type
1339 THandle = Cardinal;
1340 //SDL_types.h types
1341 // Basic data types
1343 SDL_Bool = (SDL_FALSE, SDL_TRUE);
1344 TSDL_Bool = SDL_Bool;
1346 PUInt8Array = ^TUInt8Array;
1347 PUInt8 = ^UInt8;
1348 PPUInt8 = ^PUInt8;
1349 UInt8 = Byte;
1350 {$EXTERNALSYM UInt8}
1351 TUInt8Array = array [0..MAXINT shr 1] of UInt8;
1353 PUInt16 = ^UInt16;
1354 UInt16 = word;
1355 {$EXTERNALSYM UInt16}
1357 PSInt8 = ^SInt8;
1358 SInt8 = Shortint;
1359 {$EXTERNALSYM SInt8}
1361 PSInt16 = ^SInt16;
1362 SInt16 = smallint;
1363 {$EXTERNALSYM SInt16}
1365 PUInt32 = ^UInt32;
1366 UInt32 = Cardinal;
1367 {$EXTERNALSYM UInt32}
1369 SInt32 = Integer;
1370 {$EXTERNALSYM SInt32}
1372 PInt = ^Integer;
1374 PShortInt = ^ShortInt;
1376 PUInt64 = ^UInt64;
1377 UInt64 = record
1378 hi: UInt32;
1379 lo: UInt32;
1380 end;
1381 {$EXTERNALSYM UInt64}
1383 PSInt64 = ^SInt64;
1384 SInt64 = record
1385 hi: UInt32;
1386 lo: UInt32;
1387 end;
1388 {$EXTERNALSYM SInt64}
1390 TSDL_GrabMode = Integer;
1392 // SDL_error.h types
1393 TSDL_errorcode = (
1394 SDL_ENOMEM,
1395 SDL_EFREAD,
1396 SDL_EFWRITE,
1397 SDL_EFSEEK,
1398 SDL_LASTERROR);
1400 SDL_errorcode = TSDL_errorcode;
1401 {$EXTERNALSYM SDL_errorcode}
1403 TArg = record
1404 case Byte of
1405 0: (value_ptr: Pointer);
1406 (* #if 0 means: never
1407 1 : ( value_c : Byte );
1408 *)
1409 2: (value_i: Integer);
1410 3: (value_f: double);
1411 4: (buf: array[0..ERR_MAX_STRLEN - 1] of Byte);
1412 end;
1414 PSDL_error = ^TSDL_error;
1415 TSDL_error = record
1416 { This is a numeric value corresponding to the current error }
1417 error: Integer;
1419 { This is a key used to index into a language hashtable containing
1420 internationalized versions of the SDL error messages. If the key
1421 is not in the hashtable, or no hashtable is available, the key is
1422 used directly as an error message format string. }
1423 key: array[0..ERR_MAX_STRLEN - 1] of Byte;
1425 { These are the arguments for the error functions }
1426 argc: Integer;
1427 args: array[0..ERR_MAX_ARGS - 1] of TArg;
1428 end;
1430 // SDL_rwops.h types
1431 // This is the read/write operation structure -- very basic
1432 // some helper types to handle the unions
1433 // "packed" is only guessed
1435 TStdio = record
1436 autoclose: Integer;
1437 // FILE * is only defined in Kylix so we use a simple Pointer
1438 fp: Pointer;
1439 end;
1441 TMem = record
1442 base: PUInt8;
1443 here: PUInt8;
1444 stop: PUInt8;
1445 end;
1447 TUnknown = record
1448 data1: Pointer;
1449 end;
1451 // first declare the pointer type
1452 PSDL_RWops = ^TSDL_RWops;
1453 // now the pointer to function types
1454 {$IFNDEF __GPC__}
1455 TSeek = function( context: PSDL_RWops; offset: Integer; whence: Integer ): Integer; cdecl;
1456 TRead = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; maxnum : Integer ): Integer; cdecl;
1457 TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; num: Integer ): Integer; cdecl;
1458 TClose = function( context: PSDL_RWops ): Integer; cdecl;
1459 {$ELSE}
1460 TSeek = function( context: PSDL_RWops; offset: Integer; whence: Integer ): Integer;
1461 TRead = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; maxnum : Integer ): Integer;
1462 TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: Integer; num: Integer ): Integer;
1463 TClose = function( context: PSDL_RWops ): Integer;
1464 {$ENDIF}
1465 // the variant record itself
1466 TSDL_RWops = record
1467 seek: TSeek;
1468 read: TRead;
1469 write: TWrite;
1470 close: TClose;
1471 // a keyword as name is not allowed
1472 type_: UInt32;
1473 // be warned! structure alignment may arise at this point
1474 case Integer of
1475 0: (stdio: TStdio);
1476 1: (mem: TMem);
1477 2: (unknown: TUnknown);
1478 end;
1480 SDL_RWops = TSDL_RWops;
1481 {$EXTERNALSYM SDL_RWops}
1484 // SDL_timer.h types
1485 // Function prototype for the timer callback function
1486 {$IFNDEF __GPC__}
1487 TSDL_TimerCallback = function( interval: UInt32 ): UInt32; cdecl;
1488 {$ELSE}
1489 TSDL_TimerCallback = function( interval: UInt32 ): UInt32;
1490 {$ENDIF}
1492 { New timer API, supports multiple timers
1493 Written by Stephane Peter <megastep@lokigames.com> }
1495 { Function prototype for the new timer callback function.
1496 The callback function is passed the current timer interval and returns
1497 the next timer interval. If the returned value is the same as the one
1498 passed in, the periodic alarm continues, otherwise a new alarm is
1499 scheduled. If the callback returns 0, the periodic alarm is cancelled. }
1500 {$IFNDEF __GPC__}
1501 TSDL_NewTimerCallback = function( interval: UInt32; param: Pointer ): UInt32; cdecl;
1502 {$ELSE}
1503 TSDL_NewTimerCallback = function( interval: UInt32; param: Pointer ): UInt32;
1504 {$ENDIF}
1506 // Definition of the timer ID type
1507 PSDL_TimerID = ^TSDL_TimerID;
1508 TSDL_TimerID = record
1509 interval: UInt32;
1510 callback: TSDL_NewTimerCallback;
1511 param: Pointer;
1512 last_alarm: UInt32;
1513 next: PSDL_TimerID;
1514 end;
1516 {$IFNDEF __GPC__}
1517 TSDL_AudioSpecCallback = procedure( userdata: Pointer; stream: PUInt8; len: Integer ); cdecl;
1518 {$ELSE}
1519 TSDL_AudioSpecCallback = procedure( userdata: Pointer; stream: PUInt8; len: Integer );
1520 {$ENDIF}
1522 // SDL_audio.h types
1523 // The calculated values in this structure are calculated by SDL_OpenAudio()
1524 PSDL_AudioSpec = ^TSDL_AudioSpec;
1525 TSDL_AudioSpec = record
1526 freq: Integer; // DSP frequency -- samples per second
1527 format: UInt16; // Audio data format
1528 channels: UInt8; // Number of channels: 1 mono, 2 stereo
1529 silence: UInt8; // Audio buffer silence value (calculated)
1530 samples: UInt16; // Audio buffer size in samples
1531 padding: UInt16; // Necessary for some compile environments
1532 size: UInt32; // Audio buffer size in bytes (calculated)
1533 { This function is called when the audio device needs more data.
1534 'stream' is a pointer to the audio data buffer
1535 'len' is the length of that buffer in bytes.
1536 Once the callback returns, the buffer will no longer be valid.
1537 Stereo samples are stored in a LRLRLR ordering.}
1538 callback: TSDL_AudioSpecCallback;
1539 userdata: Pointer;
1540 end;
1542 // A structure to hold a set of audio conversion filters and buffers
1543 PSDL_AudioCVT = ^TSDL_AudioCVT;
1545 PSDL_AudioCVTFilter = ^TSDL_AudioCVTFilter;
1546 TSDL_AudioCVTFilter = record
1547 cvt: PSDL_AudioCVT;
1548 format: UInt16;
1549 end;
1551 PSDL_AudioCVTFilterArray = ^TSDL_AudioCVTFilterArray;
1552 TSDL_AudioCVTFilterArray = array[0..9] of PSDL_AudioCVTFilter;
1554 TSDL_AudioCVT = record
1555 needed: Integer; // Set to 1 if conversion possible
1556 src_format: UInt16; // Source audio format
1557 dst_format: UInt16; // Target audio format
1558 rate_incr: double; // Rate conversion increment
1559 buf: PUInt8; // Buffer to hold entire audio data
1560 len: Integer; // Length of original audio buffer
1561 len_cvt: Integer; // Length of converted audio buffer
1562 len_mult: Integer; // buffer must be len*len_mult big
1563 len_ratio: double; // Given len, final size is len*len_ratio
1564 filters: TSDL_AudioCVTFilterArray;
1565 filter_index: Integer; // Current audio conversion function
1566 end;
1568 TSDL_Audiostatus = (
1569 SDL_AUDIO_STOPPED,
1570 SDL_AUDIO_PLAYING,
1571 SDL_AUDIO_PAUSED
1572 );
1574 // SDL_cdrom.h types
1575 TSDL_CDStatus = (
1576 CD_ERROR,
1577 CD_TRAYEMPTY,
1578 CD_STOPPED,
1579 CD_PLAYING,
1580 CD_PAUSED );
1582 PSDL_CDTrack = ^TSDL_CDTrack;
1583 TSDL_CDTrack = record
1584 id: UInt8; // Track number
1585 type_: UInt8; // Data or audio track
1586 unused: UInt16;
1587 length: UInt32; // Length, in frames, of this track
1588 offset: UInt32; // Offset, in frames, from start of disk
1589 end;
1591 // This structure is only current as of the last call to SDL_CDStatus()
1592 PSDL_CD = ^TSDL_CD;
1593 TSDL_CD = record
1594 id: Integer; // Private drive identifier
1595 status: TSDL_CDStatus; // Current drive status
1597 // The rest of this structure is only valid if there's a CD in drive
1598 numtracks: Integer; // Number of tracks on disk
1599 cur_track: Integer; // Current track position
1600 cur_frame: Integer; // Current frame offset within current track
1601 track: array[0..SDL_MAX_TRACKS] of TSDL_CDTrack;
1602 end;
1604 //SDL_joystick.h types
1605 PTransAxis = ^TTransAxis;
1606 TTransAxis = record
1607 offset: Integer;
1608 scale: single;
1609 end;
1611 // The private structure used to keep track of a joystick
1612 PJoystick_hwdata = ^TJoystick_hwdata;
1613 TJoystick_hwdata = record
1614 // joystick ID
1615 id: Integer;
1616 // values used to translate device-specific coordinates into SDL-standard ranges
1617 transaxis: array[0..5] of TTransAxis;
1618 end;
1620 PBallDelta = ^TBallDelta;
1621 TBallDelta = record
1622 dx: Integer;
1623 dy: Integer;
1624 end; // Current ball motion deltas
1626 // The SDL joystick structure
1627 PSDL_Joystick = ^TSDL_Joystick;
1628 TSDL_Joystick = record
1629 index: UInt8; // Device index
1630 name: PChar; // Joystick name - system dependent
1632 naxes: Integer; // Number of axis controls on the joystick
1633 axes: PUInt16; // Current axis states
1635 nhats: Integer; // Number of hats on the joystick
1636 hats: PUInt8; // Current hat states
1638 nballs: Integer; // Number of trackballs on the joystick
1639 balls: PBallDelta; // Current ball motion deltas
1641 nbuttons: Integer; // Number of buttons on the joystick
1642 buttons: PUInt8; // Current button states
1644 hwdata: PJoystick_hwdata; // Driver dependent information
1646 ref_count: Integer; // Reference count for multiple opens
1647 end;
1649 // SDL_verion.h types
1650 PSDL_version = ^TSDL_version;
1651 TSDL_version = record
1652 major: UInt8;
1653 minor: UInt8;
1654 patch: UInt8;
1655 end;
1657 // SDL_keyboard.h types
1658 TSDLKey = LongWord;
1660 TSDLMod = LongWord;
1662 PSDL_KeySym = ^TSDL_KeySym;
1663 TSDL_KeySym = record
1664 scancode: UInt8; // hardware specific scancode
1665 sym: TSDLKey; // SDL virtual keysym
1666 modifier: TSDLMod; // current key modifiers
1667 unicode: UInt16; // translated character
1668 end;
1670 // SDL_events.h types
1671 {Checks the event queue for messages and optionally returns them.
1672 If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
1673 the back of the event queue.
1674 If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
1675 of the event queue, matching 'mask', will be returned and will not
1676 be removed from the queue.
1677 If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
1678 of the event queue, matching 'mask', will be returned and will be
1679 removed from the queue.
1680 This function returns the number of events actually stored, or -1
1681 if there was an error. This function is thread-safe. }
1683 TSDL_EventAction = (SDL_ADDEVENT, SDL_PEEKEVENT, SDL_GETEVENT);
1685 // Application visibility event structure
1686 TSDL_ActiveEvent = record
1687 type_: UInt8; // SDL_ACTIVEEVENT
1688 gain: UInt8; // Whether given states were gained or lost (1/0)
1689 state: UInt8; // A mask of the focus states
1690 end;
1692 // Keyboard event structure
1693 TSDL_KeyboardEvent = record
1694 type_: UInt8; // SDL_KEYDOWN or SDL_KEYUP
1695 which: UInt8; // The keyboard device index
1696 state: UInt8; // SDL_PRESSED or SDL_RELEASED
1697 keysym: TSDL_KeySym;
1698 end;
1700 // Mouse motion event structure
1701 TSDL_MouseMotionEvent = record
1702 type_: UInt8; // SDL_MOUSEMOTION
1703 which: UInt8; // The mouse device index
1704 state: UInt8; // The current button state
1705 x, y: UInt16; // The X/Y coordinates of the mouse
1706 xrel: SInt16; // The relative motion in the X direction
1707 yrel: SInt16; // The relative motion in the Y direction
1708 end;
1710 // Mouse button event structure
1711 TSDL_MouseButtonEvent = record
1712 type_: UInt8; // SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
1713 which: UInt8; // The mouse device index
1714 button: UInt8; // The mouse button index
1715 state: UInt8; // SDL_PRESSED or SDL_RELEASED
1716 x: UInt16; // The X coordinates of the mouse at press time
1717 y: UInt16; // The Y coordinates of the mouse at press time
1718 end;
1720 // Joystick axis motion event structure
1721 TSDL_JoyAxisEvent = record
1722 type_: UInt8; // SDL_JOYAXISMOTION
1723 which: UInt8; // The joystick device index
1724 axis: UInt8; // The joystick axis index
1725 value: SInt16; // The axis value (range: -32768 to 32767)
1726 end;
1728 // Joystick trackball motion event structure
1729 TSDL_JoyBallEvent = record
1730 type_: UInt8; // SDL_JOYAVBALLMOTION
1731 which: UInt8; // The joystick device index
1732 ball: UInt8; // The joystick trackball index
1733 xrel: SInt16; // The relative motion in the X direction
1734 yrel: SInt16; // The relative motion in the Y direction
1735 end;
1737 // Joystick hat position change event structure
1738 TSDL_JoyHatEvent = record
1739 type_: UInt8; // SDL_JOYHATMOTION */
1740 which: UInt8; // The joystick device index */
1741 hat: UInt8; // The joystick hat index */
1742 value: UInt8; { The hat position value:
1743 8 1 2
1744 7 0 3
1745 6 5 4
1747 Note that zero means the POV is centered. }
1749 end;
1751 // Joystick button event structure
1752 TSDL_JoyButtonEvent = record
1753 type_: UInt8; // SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
1754 which: UInt8; // The joystick device index
1755 button: UInt8; // The joystick button index
1756 state: UInt8; // SDL_PRESSED or SDL_RELEASED
1757 end;
1759 { The "window resized" event
1760 When you get this event, you are responsible for setting a new video
1761 mode with the new width and height. }
1762 TSDL_ResizeEvent = record
1763 type_: UInt8; // SDL_VIDEORESIZE
1764 w: Integer; // New width
1765 h: Integer; // New height
1766 end;
1768 // The "quit requested" event
1769 PSDL_QuitEvent = ^TSDL_QuitEvent;
1770 TSDL_QuitEvent = record
1771 type_: UInt8;
1772 end;
1774 // A user-defined event type
1775 PSDL_UserEvent = ^TSDL_UserEvent;
1776 TSDL_UserEvent = record
1777 type_: UInt8; // SDL_USEREVENT through SDL_NUMEVENTS-1
1778 code: Integer; // User defined event code */
1779 data1: Pointer; // User defined data pointer */
1780 data2: Pointer; // User defined data pointer */
1781 end;
1783 // The "screen redraw" event
1784 PSDL_ExposeEvent = ^TSDL_ExposeEvent;
1785 TSDL_ExposeEvent = record
1786 type_ : Uint8; // SDL_VIDEOEXPOSE
1787 end;
1789 {$IFDEF Unix}
1790 //These are the various supported subsystems under UNIX
1791 TSDL_SysWm = ( SDL_SYSWM_X11 ) ;
1792 {$ENDIF}
1794 // The windows custom event structure
1795 {$IFDEF WINDOWS}
1796 PSDL_SysWMmsg = ^TSDL_SysWMmsg;
1797 TSDL_SysWMmsg = record
1798 version: TSDL_version;
1799 h_wnd: HWND; // The window for the message
1800 msg: UInt; // The type of message
1801 w_Param: WPARAM; // WORD message parameter
1802 lParam: LPARAM; // LONG message parameter
1803 end;
1804 {$ELSE}
1806 {$IFDEF Unix}
1807 { The Linux custom event structure }
1808 PSDL_SysWMmsg = ^TSDL_SysWMmsg;
1809 TSDL_SysWMmsg = record
1810 version : TSDL_version;
1811 subsystem : TSDL_SysWm;
1812 {$IFDEF FPC}
1813 {$IFNDEF GP2X}
1814 event : TXEvent;
1815 {$ENDIF}
1816 {$ELSE}
1817 event : XEvent;
1818 {$ENDIF}
1819 end;
1820 {$ELSE}
1821 { The generic custom event structure }
1822 PSDL_SysWMmsg = ^TSDL_SysWMmsg;
1823 TSDL_SysWMmsg = record
1824 version: TSDL_version;
1825 data: Integer;
1826 end;
1827 {$ENDIF}
1829 {$ENDIF}
1831 // The Windows custom window manager information structure
1832 {$IFDEF WINDOWS}
1833 PSDL_SysWMinfo = ^TSDL_SysWMinfo;
1834 TSDL_SysWMinfo = record
1835 version : TSDL_version;
1836 window : HWnd; // The display window
1837 end;
1838 {$ELSE}
1840 // The Linux custom window manager information structure
1841 {$IFDEF Unix}
1842 {$IFNDEF GP2X}
1843 TX11 = record
1844 display : PDisplay; // The X11 display
1845 window : TWindow ; // The X11 display window */
1846 {* These locking functions should be called around
1847 any X11 functions using the display variable.
1848 They lock the event thread, so should not be
1849 called around event functions or from event filters.
1850 *}
1851 lock_func : Pointer;
1852 unlock_func : Pointer;
1854 // Introduced in SDL 1.0.2
1855 fswindow : TWindow ; // The X11 fullscreen window */
1856 wmwindow : TWindow ; // The X11 managed input window */
1857 end;
1858 {$ENDIF}
1860 PSDL_SysWMinfo = ^TSDL_SysWMinfo;
1861 TSDL_SysWMinfo = record
1862 version : TSDL_version ;
1863 subsystem : TSDL_SysWm;
1864 {$IFNDEF GP2X}
1865 X11 : TX11;
1866 {$ENDIF}
1867 end;
1868 {$ELSE}
1869 // The generic custom window manager information structure
1870 PSDL_SysWMinfo = ^TSDL_SysWMinfo;
1871 TSDL_SysWMinfo = record
1872 version : TSDL_version ;
1873 data : integer;
1874 end;
1875 {$ENDIF}
1877 {$ENDIF}
1879 PSDL_SysWMEvent = ^TSDL_SysWMEvent;
1880 TSDL_SysWMEvent = record
1881 type_: UInt8;
1882 msg: PSDL_SysWMmsg;
1883 end;
1885 PSDL_Event = ^TSDL_Event;
1886 TSDL_Event = record
1887 case UInt8 of
1888 SDL_NOEVENT: (type_: byte);
1889 SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
1890 SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent);
1891 SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
1892 SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent );
1893 SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent );
1894 SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent );
1895 SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent );
1896 SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent );
1897 SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent );
1898 SDL_QUITEV: (quit: TSDL_QuitEvent );
1899 SDL_USEREVENT : ( user : TSDL_UserEvent );
1900 SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent );
1901 end;
1904 { This function sets up a filter to process all events before they
1905 change internal state and are posted to the internal event queue.
1907 The filter is protypted as: }
1908 {$IFNDEF __GPC__}
1909 TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl;
1910 {$ELSE}
1911 TSDL_EventFilter = function( event : PSDL_Event ): Integer;
1912 {$ENDIF}
1914 // SDL_video.h types
1915 // Useful data types
1916 PPSDL_Rect = ^PSDL_Rect;
1917 PSDL_Rect = ^TSDL_Rect;
1918 TSDL_Rect = record
1919 x, y: SInt16;
1920 w, h: UInt16;
1921 end;
1923 SDL_Rect = TSDL_Rect;
1924 {$EXTERNALSYM SDL_Rect}
1926 PSDL_Color = ^TSDL_Color;
1927 TSDL_Color = record
1928 r: UInt8;
1929 g: UInt8;
1930 b: UInt8;
1931 unused: UInt8;
1932 end;
1934 PSDL_ColorArray = ^TSDL_ColorArray;
1935 TSDL_ColorArray = array[0..65000] of TSDL_Color;
1937 PSDL_Palette = ^TSDL_Palette;
1938 TSDL_Palette = record
1939 ncolors: Integer;
1940 colors: PSDL_ColorArray;
1941 end;
1943 // Everything in the pixel format structure is read-only
1944 PSDL_PixelFormat = ^TSDL_PixelFormat;
1945 TSDL_PixelFormat = record
1946 palette: PSDL_Palette;
1947 BitsPerPixel: UInt8;
1948 BytesPerPixel: UInt8;
1949 Rloss: UInt8;
1950 Gloss: UInt8;
1951 Bloss: UInt8;
1952 Aloss: UInt8;
1953 Rshift: UInt8;
1954 Gshift: UInt8;
1955 Bshift: UInt8;
1956 Ashift: UInt8;
1957 RMask: UInt32;
1958 GMask: UInt32;
1959 BMask: UInt32;
1960 AMask: UInt32;
1961 colorkey: UInt32; // RGB color key information
1962 alpha: UInt8; // Alpha value information (per-surface alpha)
1963 end;
1965 {$IFDEF WINDOWS}
1966 {PPrivate_hwdata = ^TPrivate_hwdata;
1967 TPrivate_hwdata = record
1968 dd_surface : IDIRECTDRAWSURFACE3;
1969 dd_writebuf : IDIRECTDRAWSURFACE3;
1970 end;}
1971 {ELSE}
1972 {$ENDIF}
1974 // The structure passed to the low level blit functions
1975 PSDL_BlitInfo = ^TSDL_BlitInfo;
1976 TSDL_BlitInfo = record
1977 s_pixels: PUInt8;
1978 s_width: Integer;
1979 s_height: Integer;
1980 s_skip: Integer;
1981 d_pixels: PUInt8;
1982 d_width: Integer;
1983 d_height: Integer;
1984 d_skip: Integer;
1985 aux_data: Pointer;
1986 src: PSDL_PixelFormat;
1987 table: PUInt8;
1988 dst: PSDL_PixelFormat;
1989 end;
1991 // typedef for private surface blitting functions
1992 PSDL_Surface = ^TSDL_Surface;
1994 {$IFNDEF __GPC__}
1995 TSDL_Blit = function( src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect ): Integer; cdecl;
1996 {$ELSE}
1997 TSDL_Blit = function( src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect ): Integer;
1998 {$ENDIF}
2000 // The type definition for the low level blit functions
2001 //TSDL_LoBlit = procedure( info : PSDL_BlitInfo ); cdecl;
2003 // This is the private info structure for software accelerated blits
2004 {PPrivate_swaccel = ^TPrivate_swaccel;
2005 TPrivate_swaccel = record
2006 blit : TSDL_LoBlit;
2007 aux_data : Pointer;
2008 end;}
2010 // Blit mapping definition
2011 {PSDL_BlitMap = ^TSDL_BlitMap;
2012 TSDL_BlitMap = record
2013 dst : PSDL_Surface;
2014 identity : Integer;
2015 table : PUInt8;
2016 hw_blit : TSDL_Blit;
2017 sw_blit : TSDL_Blit;
2018 hw_data : PPrivate_hwaccel;
2019 sw_data : PPrivate_swaccel;
2021 // the version count matches the destination; mismatch indicates an invalid mapping
2022 format_version : Cardinal;
2023 end;}
2025 TSDL_Surface = record
2026 flags: UInt32; // Read-only
2027 format: PSDL_PixelFormat; // Read-only
2028 w, h: Integer; // Read-only
2029 pitch: UInt16; // Read-only
2030 pixels: Pointer; // Read-write
2031 offset: Integer; // Private
2032 hwdata: Pointer; //TPrivate_hwdata; Hardware-specific surface info
2034 // clipping information:
2035 clip_rect: TSDL_Rect; // Read-only
2036 unused1: UInt32; // for binary compatibility
2037 // Allow recursive locks
2038 locked: UInt32; // Private
2039 // info for fast blit mapping to other surfaces
2040 Blitmap: Pointer; // PSDL_BlitMap; // Private
2041 // format version, bumped at every change to invalidate blit maps
2042 format_version: Cardinal; // Private
2043 refcount: Integer;
2044 end;
2046 // Useful for determining the video hardware capabilities
2047 PSDL_VideoInfo = ^TSDL_VideoInfo;
2048 TSDL_VideoInfo = record
2049 hw_available: UInt8; // Hardware and WindowManager flags in first 2 bits ( see below )
2050 {hw_available: 1; // Can you create hardware surfaces
2051 wm_available: 1; // Can you talk to a window manager?
2052 UnusedBits1: 6;}
2053 blit_hw: UInt8; // Blit Hardware flags. See below for which bits do what
2054 {UnusedBits2: 1;
2055 blit_hw: 1; // Flag:UInt32 Accelerated blits HW --> HW
2056 blit_hw_CC: 1; // Flag:UInt32 Accelerated blits with Colorkey
2057 blit_hw_A: 1; // Flag:UInt32 Accelerated blits with Alpha
2058 blit_sw: 1; // Flag:UInt32 Accelerated blits SW --> HW
2059 blit_sw_CC: 1; // Flag:UInt32 Accelerated blits with Colorkey
2060 blit_sw_A: 1; // Flag:UInt32 Accelerated blits with Alpha
2061 blit_fill: 1; // Flag:UInt32 Accelerated color fill}
2062 UnusedBits3: UInt8; // Unused at this point
2063 video_mem: UInt32; // The total amount of video memory (in K)
2064 vfmt: PSDL_PixelFormat; // Value: The format of the video surface
2065 current_w : SInt32; // Value: The current video mode width
2066 current_h : SInt32; // Value: The current video mode height
2067 end;
2069 // The YUV hardware video overlay
2070 PSDL_Overlay = ^TSDL_Overlay;
2071 TSDL_Overlay = record
2072 format: UInt32; // Overlay format
2073 w, h: Integer; // Width and height of overlay
2074 planes: Integer; // Number of planes in the overlay. Usually either 1 or 3
2075 pitches: PUInt16;
2076 // An array of pitches, one for each plane. Pitch is the length of a row in bytes.
2077 pixels: PPUInt8;
2078 // An array of pointers to the data of each plane. The overlay should be locked before these pointers are used.
2079 hw_overlay: UInt32;
2080 // This will be set to 1 if the overlay is hardware accelerated.
2081 end;
2083 // Public enumeration for setting the OpenGL window attributes.
2084 TSDL_GLAttr = (
2085 SDL_GL_RED_SIZE,
2086 SDL_GL_GREEN_SIZE,
2087 SDL_GL_BLUE_SIZE,
2088 SDL_GL_ALPHA_SIZE,
2089 SDL_GL_BUFFER_SIZE,
2090 SDL_GL_DOUBLEBUFFER,
2091 SDL_GL_DEPTH_SIZE,
2092 SDL_GL_STENCIL_SIZE,
2093 SDL_GL_ACCUM_RED_SIZE,
2094 SDL_GL_ACCUM_GREEN_SIZE,
2095 SDL_GL_ACCUM_BLUE_SIZE,
2096 SDL_GL_ACCUM_ALPHA_SIZE,
2097 SDL_GL_STEREO,
2098 SDL_GL_MULTISAMPLEBUFFERS,
2099 SDL_GL_MULTISAMPLESAMPLES,
2100 SDL_GL_ACCELERATED_VISUAL,
2101 SDL_GL_SWAP_CONTROL);
2105 PSDL_Cursor = ^TSDL_Cursor;
2106 TSDL_Cursor = record
2107 area: TSDL_Rect; // The area of the mouse cursor
2108 hot_x, hot_y: SInt16; // The "tip" of the cursor
2109 data: PUInt8; // B/W cursor data
2110 mask: PUInt8; // B/W cursor mask
2111 save: array[1..2] of PUInt8; // Place to save cursor area
2112 wm_cursor: Pointer; // Window-manager cursor
2113 end;
2115 // SDL_mutex.h types
2117 {$IFDEF WINDOWS}
2118 PSDL_Mutex = ^TSDL_Mutex;
2119 TSDL_Mutex = record
2120 id: THANDLE;
2121 end;
2122 {$ENDIF}
2124 {$IFDEF Unix}
2125 PSDL_Mutex = ^TSDL_Mutex;
2126 TSDL_mutex = record
2127 id: pthread_mutex_t;
2128 {$IFDEF PTHREAD_NO_RECURSIVE_MUTEX}
2129 recursive: Integer;
2130 owner: pthread_t;
2131 {$ENDIF}
2132 end;
2133 {$ENDIF}
2135 {$IFDEF NDS}
2136 PSDL_mutex = ^TSDL_Mutex;
2137 TSDL_Mutex = record
2138 recursive: Integer;
2139 Owner: UInt32;
2140 sem: PSDL_sem;
2141 end;
2142 {$ENDIF}
2144 {$IFDEF MORPHOS}
2145 PSDL_Mutex = ^TSDL_Mutex;
2146 TSDL_Mutex = record
2147 {$WARNING FIXME!!}
2148 dummy: longint;
2149 end;
2150 {$ENDIF}
2152 {$IFDEF __MACH__}
2153 {$define USE_NAMED_SEMAPHORES}
2154 // Broken sem_getvalue() in MacOS X Public Beta */
2155 {$define BROKEN_SEMGETVALUE}
2156 {$ENDIF}
2158 PSDL_semaphore = ^TSDL_semaphore;
2159 {$IFDEF WINDOWS}
2160 // WINDOWS or Machintosh
2161 TSDL_semaphore = record
2162 id: THANDLE;
2163 count: UInt32;
2164 end;
2165 {$ELSE}
2166 {$IFDEF FPC}
2167 // This should be semaphore.h
2168 __sem_lock_t = {packed} record { Not in header file - anonymous }
2169 status: Longint;
2170 spinlock: Integer;
2171 end;
2173 sem_t = {packed} record
2174 __sem_lock: __sem_lock_t;
2175 __sem_value: Integer;
2176 __sem_waiting: longint ; {_pthread_queue;}
2177 end;
2178 {$ENDIF}
2180 TSDL_semaphore = record
2181 sem: Pointer; //PSem_t;
2182 {$IFNDEF USE_NAMED_SEMAPHORES}
2183 sem_data: Sem_t;
2184 {$ENDIF}
2186 {$IFDEF BROKEN_SEMGETVALUE}
2187 { This is a little hack for MacOS X -
2188 It's not thread-safe, but it's better than nothing }
2189 sem_value: Integer;
2190 {$ENDIF}
2191 end;
2192 {$ENDIF}
2194 PSDL_Sem = ^TSDL_Sem;
2195 TSDL_Sem = TSDL_Semaphore;
2197 PSDL_Cond = ^TSDL_Cond;
2198 TSDL_Cond = record
2199 {$IFDEF Unix}
2200 cond: pthread_cond_t;
2201 {$ELSE}
2202 // Generic Cond structure
2203 lock: PSDL_mutex;
2204 waiting: Integer;
2205 signals: Integer;
2206 wait_sem: PSDL_Sem;
2207 wait_done: PSDL_Sem;
2208 {$ENDIF}
2209 end;
2211 // SDL_thread.h types
2212 {$IFDEF WINDOWS}
2213 TSYS_ThreadHandle = THandle;
2214 {$ENDIF}
2216 {$IFDEF Unix}
2217 TSYS_ThreadHandle = pthread_t;
2218 {$ENDIF}
2220 {$IFDEF NDS}
2221 TSYS_ThreadHandle = Integer;
2222 {$ENDIF}
2224 {$IFDEF MORPHOS}
2225 TSYS_ThreadHandle = Pointer;
2226 {$ENDIF}
2228 { This is the system-independent thread info structure }
2229 PSDL_Thread = ^TSDL_Thread;
2230 TSDL_Thread = record
2231 threadid: UInt32;
2232 handle: TSYS_ThreadHandle;
2233 status: Integer;
2234 errbuf: TSDL_Error;
2235 data: Pointer;
2236 end;
2238 // Helper Types
2240 // Keyboard State Array ( See demos for how to use )
2241 PKeyStateArr = ^TKeyStateArr;
2242 TKeyStateArr = array[0..65000] of UInt8;
2244 // Types required so we don't need to use Windows.pas
2245 PInteger = ^Integer;
2246 PByte = ^Byte;
2247 PWord = ^Word;
2248 PLongWord = ^Longword;
2250 // General arrays
2251 PByteArray = ^TByteArray;
2252 TByteArray = array[0..32767] of Byte;
2254 PWordArray = ^TWordArray;
2255 TWordArray = array[0..16383] of Word;
2257 PPoint = ^TPoint;
2258 {$IFDEF HAS_TYPES}
2259 TPoint = Types.TPoint;
2260 {$ELSE}
2261 {$IFDEF WINDOWS}
2262 {$IFDEF __GPC__}
2263 TPoint = wintypes.TPoint;
2264 {$ELSE}
2265 TPoint = Windows.TPoint;
2266 {$ENDIF}
2267 {$ELSE}
2268 //Can't define TPoint : neither Types nor Windows unit available.
2269 {$ENDIF}
2270 {$ENDIF}
2272 PRect = ^TRect;
2273 {$IFDEF HAS_TYPES}
2274 TRect = Types.TRect;
2275 {$ELSE}
2276 {$IFDEF WINDOWS}
2277 {$IFDEF __GPC__}
2278 TRect = wintypes.TRect;
2279 {$ELSE}
2280 TRect = Windows.TRect;
2281 {$ENDIF}
2282 {$ELSE}
2283 //Can't define TRect: neither Types nor Windows unit available.
2284 {$ENDIF}
2285 {$ENDIF}
2287 { Generic procedure pointer }
2288 TProcedure = procedure;
2290 {------------------------------------------------------------------------------}
2291 { initialization }
2292 {------------------------------------------------------------------------------}
2294 { This function loads the SDL dynamically linked library and initializes
2295 the subsystems specified by 'flags' (and those satisfying dependencies)
2296 Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
2297 signal handlers for some commonly ignored fatal signals (like SIGSEGV) }
2299 {$IFDEF MORPHOS}
2300 {$I powersdl.inc}
2301 {$ELSE}
2302 function SDL_Init( flags : UInt32 ) : Integer;
2303 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2304 {$EXTERNALSYM SDL_Init}
2306 // This function initializes specific SDL subsystems
2307 function SDL_InitSubSystem( flags : UInt32 ) : Integer;
2308 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_InitSubSystem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2309 {$EXTERNALSYM SDL_InitSubSystem}
2311 // This function cleans up specific SDL subsystems
2312 procedure SDL_QuitSubSystem( flags : UInt32 );
2313 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_QuitSubSystem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2314 {$EXTERNALSYM SDL_QuitSubSystem}
2316 { This function returns mask of the specified subsystems which have
2317 been initialized.
2318 If 'flags' is 0, it returns a mask of all initialized subsystems. }
2320 function SDL_WasInit( flags : UInt32 ): UInt32;
2321 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WasInit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2322 {$EXTERNALSYM SDL_WasInit}
2324 { This function cleans up all initialized subsystems and unloads the
2325 dynamically linked library. You should call it upon all exit conditions. }
2326 procedure SDL_Quit;
2327 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Quit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2328 {$EXTERNALSYM SDL_Quit}
2330 {$IFDEF WINDOWS}
2331 // This should be called from your WinMain() function, if any
2332 function SDL_RegisterApp(name: PChar; style: UInt32; h_Inst: Pointer): Integer;
2333 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RegisterApp'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2334 {$EXTERNALSYM SDL_RegisterApp}
2335 {$ENDIF}
2337 {$IFDEF __MACH__}
2338 // This should be called from your main() function, if any
2339 procedure SDL_InitQuickDraw( the_qd: QDGlobals );
2340 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_InitQuickDraw'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2341 {$EXTERNALSYM SDL_InitQuickDraw}
2342 {$ENDIF}
2345 {------------------------------------------------------------------------------}
2346 { types }
2347 {------------------------------------------------------------------------------}
2348 // The number of elements in a table
2349 function SDL_TableSize( table: PChar ): Integer;
2350 {$EXTERNALSYM SDL_TABLESIZE}
2353 {------------------------------------------------------------------------------}
2354 { error-handling }
2355 {------------------------------------------------------------------------------}
2356 // Public functions
2357 function SDL_GetError: PChar;
2358 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetError'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2359 {$EXTERNALSYM SDL_GetError}
2360 procedure SDL_SetError(fmt: PChar);
2361 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetError'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2362 {$EXTERNALSYM SDL_SetError}
2363 procedure SDL_ClearError;
2364 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ClearError'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2365 {$EXTERNALSYM SDL_ClearError}
2367 {$IFNDEF WINDOWS}
2368 procedure SDL_Error(Code: TSDL_errorcode);
2369 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Error'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2370 {$EXTERNALSYM SDL_Error}
2371 {$ENDIF}
2373 // Private error message function - used internally
2374 procedure SDL_OutOfMemory;
2376 {------------------------------------------------------------------------------}
2377 { io handling }
2378 {------------------------------------------------------------------------------}
2379 // Functions to create SDL_RWops structures from various data sources
2381 function SDL_RWFromFile(filename, mode: PChar): PSDL_RWops;
2382 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromFile'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2383 {$EXTERNALSYM SDL_RWFromFile}
2384 procedure SDL_FreeRW(area: PSDL_RWops);
2385 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeRW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2386 {$EXTERNALSYM SDL_FreeRW}
2388 //fp is FILE *fp ???
2389 function SDL_RWFromFP(fp: Pointer; autoclose: Integer): PSDL_RWops;
2390 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromFP'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2391 {$EXTERNALSYM SDL_RWFromFP}
2392 function SDL_RWFromMem(mem: Pointer; size: Integer): PSDL_RWops;
2393 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromMem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2394 {$EXTERNALSYM SDL_RWFromMem}
2395 function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops;
2396 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromConstMem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2397 {$EXTERNALSYM SDL_RWFromConstMem}
2398 function SDL_AllocRW: PSDL_RWops;
2399 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AllocRW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2400 {$EXTERNALSYM SDL_AllocRW}
2402 function SDL_RWSeek(context: PSDL_RWops; offset: Integer; whence: Integer) : Integer;
2403 {$EXTERNALSYM SDL_RWSeek}
2404 function SDL_RWTell(context: PSDL_RWops): Integer;
2405 {$EXTERNALSYM SDL_RWTell}
2406 function SDL_RWRead(context: PSDL_RWops; ptr: Pointer; size: Integer; n : Integer): Integer;
2407 {$EXTERNALSYM SDL_RWRead}
2408 function SDL_RWWrite(context: PSDL_RWops; ptr: Pointer; size: Integer; n : Integer): Integer;
2409 {$EXTERNALSYM SDL_RWWrite}
2410 function SDL_RWClose(context: PSDL_RWops): Integer;
2411 {$EXTERNALSYM SDL_RWClose}
2413 {------------------------------------------------------------------------------}
2414 { time-handling }
2415 {------------------------------------------------------------------------------}
2417 { Get the number of milliseconds since the SDL library initialization. }
2418 { Note that this value wraps if the program runs for more than ~49 days. }
2419 function SDL_GetTicks: UInt32;
2420 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetTicks'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2421 {$EXTERNALSYM SDL_GetTicks}
2423 // Wait a specified number of milliseconds before returning
2424 procedure SDL_Delay(msec: UInt32);
2425 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Delay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2426 {$EXTERNALSYM SDL_Delay}
2428 { Add a new timer to the pool of timers already running. }
2429 { Returns a timer ID, or NULL when an error occurs. }
2430 function SDL_AddTimer(interval: UInt32; callback: TSDL_NewTimerCallback; param : Pointer): PSDL_TimerID;
2431 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AddTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2432 {$EXTERNALSYM SDL_AddTimer}
2434 { Remove one of the multiple timers knowing its ID. }
2435 { Returns a boolean value indicating success. }
2436 function SDL_RemoveTimer(t: PSDL_TimerID): TSDL_Bool;
2437 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RemoveTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2438 {$EXTERNALSYM SDL_RemoveTimer}
2440 function SDL_SetTimer(interval: UInt32; callback: TSDL_TimerCallback): Integer;
2441 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2442 {$EXTERNALSYM SDL_SetTimer}
2444 {------------------------------------------------------------------------------}
2445 { audio-routines }
2446 {------------------------------------------------------------------------------}
2448 { These functions are used internally, and should not be used unless you
2449 have a specific need to specify the audio driver you want to use.
2450 You should normally use SDL_Init() or SDL_InitSubSystem(). }
2452 function SDL_AudioInit(driver_name: PChar): Integer;
2453 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AudioInit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2454 {$EXTERNALSYM SDL_AudioInit}
2455 procedure SDL_AudioQuit;
2456 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AudioQuit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2457 {$EXTERNALSYM SDL_AudioQuit}
2459 { This function fills the given character buffer with the name of the
2460 current audio driver, and returns a Pointer to it if the audio driver has
2461 been initialized. It returns NULL if no driver has been initialized. }
2463 function SDL_AudioDriverName(namebuf: PChar; maxlen: Integer): PChar;
2464 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AudioDriverName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2465 {$EXTERNALSYM SDL_AudioDriverName}
2467 { This function opens the audio device with the desired parameters, and
2468 returns 0 if successful, placing the actual hardware parameters in the
2469 structure pointed to by 'obtained'. If 'obtained' is NULL, the audio
2470 data passed to the callback function will be guaranteed to be in the
2471 requested format, and will be automatically converted to the hardware
2472 audio format if necessary. This function returns -1 if it failed
2473 to open the audio device, or couldn't set up the audio thread.
2475 When filling in the desired audio spec structure,
2476 'desired->freq' should be the desired audio frequency in samples-per-second.
2477 'desired->format' should be the desired audio format.
2478 'desired->samples' is the desired size of the audio buffer, in samples.
2479 This number should be a power of two, and may be adjusted by the audio
2480 driver to a value more suitable for the hardware. Good values seem to
2481 range between 512 and 8096 inclusive, depending on the application and
2482 CPU speed. Smaller values yield faster response time, but can lead
2483 to underflow if the application is doing heavy processing and cannot
2484 fill the audio buffer in time. A stereo sample consists of both right
2485 and left channels in LR ordering.
2486 Note that the number of samples is directly related to time by the
2487 following formula: ms = (samples*1000)/freq
2488 'desired->size' is the size in bytes of the audio buffer, and is
2489 calculated by SDL_OpenAudio().
2490 'desired->silence' is the value used to set the buffer to silence,
2491 and is calculated by SDL_OpenAudio().
2492 'desired->callback' should be set to a function that will be called
2493 when the audio device is ready for more data. It is passed a pointer
2494 to the audio buffer, and the length in bytes of the audio buffer.
2495 This function usually runs in a separate thread, and so you should
2496 protect data structures that it accesses by calling SDL_LockAudio()
2497 and SDL_UnlockAudio() in your code.
2498 'desired->userdata' is passed as the first parameter to your callback
2499 function.
2501 The audio device starts out playing silence when it's opened, and should
2502 be enabled for playing by calling SDL_PauseAudio(0) when you are ready
2503 for your audio callback function to be called. Since the audio driver
2504 may modify the requested size of the audio buffer, you should allocate
2505 any local mixing buffers after you open the audio device. }
2507 function SDL_OpenAudio(desired, obtained: PSDL_AudioSpec): Integer;
2508 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_OpenAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2509 {$EXTERNALSYM SDL_OpenAudio}
2511 { Get the current audio state: }
2512 function SDL_GetAudioStatus: TSDL_Audiostatus;
2513 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetAudioStatus'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2514 {$EXTERNALSYM SDL_GetAudioStatus}
2516 { This function pauses and unpauses the audio callback processing.
2517 It should be called with a parameter of 0 after opening the audio
2518 device to start playing sound. This is so you can safely initialize
2519 data for your callback function after opening the audio device.
2520 Silence will be written to the audio device during the pause. }
2522 procedure SDL_PauseAudio(pause_on: Integer);
2523 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PauseAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2524 {$EXTERNALSYM SDL_PauseAudio}
2526 { This function loads a WAVE from the data source, automatically freeing
2527 that source if 'freesrc' is non-zero. For example, to load a WAVE file,
2528 you could do:
2529 SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
2531 If this function succeeds, it returns the given SDL_AudioSpec,
2532 filled with the audio data format of the wave data, and sets
2533 'audio_buf' to a malloc()'d buffer containing the audio data,
2534 and sets 'audio_len' to the length of that audio buffer, in bytes.
2535 You need to free the audio buffer with SDL_FreeWAV() when you are
2536 done with it.
2538 This function returns NULL and sets the SDL error message if the
2539 wave file cannot be opened, uses an unknown data format, or is
2540 corrupt. Currently raw and MS-ADPCM WAVE files are supported. }
2542 function SDL_LoadWAV_RW(src: PSDL_RWops; freesrc: Integer; spec:
2543 PSDL_AudioSpec; audio_buf: PUInt8; audiolen: PUInt32): PSDL_AudioSpec;
2544 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadWAV_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2545 {$EXTERNALSYM SDL_LoadWAV_RW}
2547 // Compatibility convenience function -- loads a WAV from a file
2548 function SDL_LoadWAV(filename: PChar; spec: PSDL_AudioSpec; audio_buf:
2549 PUInt8; audiolen: PUInt32): PSDL_AudioSpec;
2550 {$EXTERNALSYM SDL_LoadWAV}
2552 { This function frees data previously allocated with SDL_LoadWAV_RW() }
2554 procedure SDL_FreeWAV(audio_buf: PUInt8);
2555 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeWAV'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2556 {$EXTERNALSYM SDL_FreeWAV}
2558 { This function takes a source format and rate and a destination format
2559 and rate, and initializes the 'cvt' structure with information needed
2560 by SDL_ConvertAudio() to convert a buffer of audio data from one format
2561 to the other.
2562 This function returns 0, or -1 if there was an error. }
2563 function SDL_BuildAudioCVT(cvt: PSDL_AudioCVT; src_format: UInt16;
2564 src_channels: UInt8; src_rate: Integer; dst_format: UInt16; dst_channels: UInt8;
2565 dst_rate: Integer): Integer;
2566 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_BuildAudioCVT'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2567 {$EXTERNALSYM SDL_BuildAudioCVT}
2569 { Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
2570 created an audio buffer cvt->buf, and filled it with cvt->len bytes of
2571 audio data in the source format, this function will convert it in-place
2572 to the desired format.
2573 The data conversion may expand the size of the audio data, so the buffer
2574 cvt->buf should be allocated after the cvt structure is initialized by
2575 SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. }
2576 function SDL_ConvertAudio(cvt: PSDL_AudioCVT): Integer;
2577 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ConvertAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2578 {$EXTERNALSYM SDL_ConvertAudio}
2580 { This takes two audio buffers of the playing audio format and mixes
2581 them, performing addition, volume adjustment, and overflow clipping.
2582 The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
2583 for full audio volume. Note this does not change hardware volume.
2584 This is provided for convenience -- you can mix your own audio data. }
2586 procedure SDL_MixAudio(dst, src: PUInt8; len: UInt32; volume: Integer);
2587 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_MixAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2588 {$EXTERNALSYM SDL_MixAudio}
2590 { The lock manipulated by these functions protects the callback function.
2591 During a LockAudio/UnlockAudio pair, you can be guaranteed that the
2592 callback function is not running. Do not call these from the callback
2593 function or you will cause deadlock. }
2594 procedure SDL_LockAudio;
2595 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LockAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2596 {$EXTERNALSYM SDL_LockAudio}
2597 procedure SDL_UnlockAudio;
2598 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnlockAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2599 {$EXTERNALSYM SDL_UnlockAudio}
2601 { This function shuts down audio processing and closes the audio device. }
2603 procedure SDL_CloseAudio;
2604 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CloseAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2605 {$EXTERNALSYM SDL_CloseAudio}
2607 {------------------------------------------------------------------------------}
2608 { CD-routines }
2609 {------------------------------------------------------------------------------}
2611 { Returns the number of CD-ROM drives on the system, or -1 if
2612 SDL_Init() has not been called with the SDL_INIT_CDROM flag. }
2614 function SDL_CDNumDrives: Integer;
2615 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDNumDrives'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2616 {$EXTERNALSYM SDL_CDNumDrives}
2618 { Returns a human-readable, system-dependent identifier for the CD-ROM.
2619 Example:
2620 "/dev/cdrom"
2621 "E:"
2622 "/dev/disk/ide/1/master" }
2624 function SDL_CDName(drive: Integer): PChar;
2625 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2626 {$EXTERNALSYM SDL_CDName}
2628 { Opens a CD-ROM drive for access. It returns a drive handle on success,
2629 or NULL if the drive was invalid or busy. This newly opened CD-ROM
2630 becomes the default CD used when other CD functions are passed a NULL
2631 CD-ROM handle.
2632 Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. }
2634 function SDL_CDOpen(drive: Integer): PSDL_CD;
2635 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDOpen'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2636 {$EXTERNALSYM SDL_CDOpen}
2638 { This function returns the current status of the given drive.
2639 If the drive has a CD in it, the table of contents of the CD and current
2640 play position of the CD will be stored in the SDL_CD structure. }
2642 function SDL_CDStatus(cdrom: PSDL_CD): TSDL_CDStatus;
2643 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDStatus'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2644 {$EXTERNALSYM SDL_CDStatus}
2646 { Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
2647 tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play
2648 until the end of the CD. This function will skip data tracks.
2649 This function should only be called after calling SDL_CDStatus() to
2650 get track information about the CD.
2652 For example:
2653 // Play entire CD:
2654 if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
2655 SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
2656 // Play last track:
2657 if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) then
2658 begin
2659 SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
2660 end;
2662 // Play first and second track and 10 seconds of third track:
2663 if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
2664 SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
2666 This function returns 0, or -1 if there was an error. }
2668 function SDL_CDPlayTracks(cdrom: PSDL_CD; start_track: Integer; start_frame:
2669 Integer; ntracks: Integer; nframes: Integer): Integer;
2670 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDPlayTracks'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2671 {$EXTERNALSYM SDL_CDPlayTracks}
2674 { Play the given CD starting at 'start' frame for 'length' frames.
2675 It returns 0, or -1 if there was an error. }
2677 function SDL_CDPlay(cdrom: PSDL_CD; start: Integer; length: Integer): Integer;
2678 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDPlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2679 {$EXTERNALSYM SDL_CDPlay}
2681 // Pause play -- returns 0, or -1 on error
2682 function SDL_CDPause(cdrom: PSDL_CD): Integer;
2683 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDPause'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2684 {$EXTERNALSYM SDL_CDPause}
2686 // Resume play -- returns 0, or -1 on error
2687 function SDL_CDResume(cdrom: PSDL_CD): Integer;
2688 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDResume'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2689 {$EXTERNALSYM SDL_CDResume}
2691 // Stop play -- returns 0, or -1 on error
2692 function SDL_CDStop(cdrom: PSDL_CD): Integer;
2693 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDStop'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2694 {$EXTERNALSYM SDL_CDStop}
2696 // Eject CD-ROM -- returns 0, or -1 on error
2697 function SDL_CDEject(cdrom: PSDL_CD): Integer;
2698 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDEject'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2699 {$EXTERNALSYM SDL_CDEject}
2701 // Closes the handle for the CD-ROM drive
2702 procedure SDL_CDClose(cdrom: PSDL_CD);
2703 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDClose'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2704 {$EXTERNALSYM SDL_CDClose}
2706 // Given a status, returns true if there's a disk in the drive
2707 function SDL_CDInDrive( status : TSDL_CDStatus ) : LongBool;
2708 {$EXTERNALSYM SDL_CDInDrive}
2710 // Conversion functions from frames to Minute/Second/Frames and vice versa
2711 procedure FRAMES_TO_MSF(frames: Integer; var M: Integer; var S: Integer; var
2712 F: Integer);
2713 {$EXTERNALSYM FRAMES_TO_MSF}
2714 function MSF_TO_FRAMES(M: Integer; S: Integer; F: Integer): Integer;
2715 {$EXTERNALSYM MSF_TO_FRAMES}
2717 {------------------------------------------------------------------------------}
2718 { JoyStick-routines }
2719 {------------------------------------------------------------------------------}
2721 { Count the number of joysticks attached to the system }
2722 function SDL_NumJoysticks: Integer;
2723 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_NumJoysticks'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2724 {$EXTERNALSYM SDL_NumJoysticks}
2726 { Get the implementation dependent name of a joystick.
2727 This can be called before any joysticks are opened.
2728 If no name can be found, this function returns NULL. }
2729 function SDL_JoystickName(index: Integer): PChar;
2730 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2731 {$EXTERNALSYM SDL_JoystickName}
2733 { Open a joystick for use - the index passed as an argument refers to
2734 the N'th joystick on the system. This index is the value which will
2735 identify this joystick in future joystick events.
2737 This function returns a joystick identifier, or NULL if an error occurred. }
2738 function SDL_JoystickOpen(index: Integer): PSDL_Joystick;
2739 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickOpen'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2740 {$EXTERNALSYM SDL_JoystickOpen}
2742 { Returns 1 if the joystick has been opened, or 0 if it has not. }
2743 function SDL_JoystickOpened(index: Integer): Integer;
2744 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickOpened'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2745 {$EXTERNALSYM SDL_JoystickOpened}
2747 { Get the device index of an opened joystick. }
2748 function SDL_JoystickIndex(joystick: PSDL_Joystick): Integer;
2749 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickIndex'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2750 {$EXTERNALSYM SDL_JoystickIndex}
2752 { Get the number of general axis controls on a joystick }
2753 function SDL_JoystickNumAxes(joystick: PSDL_Joystick): Integer;
2754 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumAxes'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2755 {$EXTERNALSYM SDL_JoystickNumAxes}
2757 { Get the number of trackballs on a joystick
2758 Joystick trackballs have only relative motion events associated
2759 with them and their state cannot be polled. }
2760 function SDL_JoystickNumBalls(joystick: PSDL_Joystick): Integer;
2761 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumBalls'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2762 {$EXTERNALSYM SDL_JoystickNumBalls}
2765 { Get the number of POV hats on a joystick }
2766 function SDL_JoystickNumHats(joystick: PSDL_Joystick): Integer;
2767 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumHats'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2768 {$EXTERNALSYM SDL_JoystickNumHats}
2770 { Get the number of buttons on a joystick }
2771 function SDL_JoystickNumButtons(joystick: PSDL_Joystick): Integer;
2772 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumButtons'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2773 {$EXTERNALSYM SDL_JoystickNumButtons}
2775 { Update the current state of the open joysticks.
2776 This is called automatically by the event loop if any joystick
2777 events are enabled. }
2779 procedure SDL_JoystickUpdate;
2780 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickUpdate'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2781 {$EXTERNALSYM SDL_JoystickUpdate;}
2783 { Enable/disable joystick event polling.
2784 If joystick events are disabled, you must call SDL_JoystickUpdate()
2785 yourself and check the state of the joystick when you want joystick
2786 information.
2787 The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. }
2789 function SDL_JoystickEventState(state: Integer): Integer;
2790 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickEventState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2791 {$EXTERNALSYM SDL_JoystickEventState}
2793 { Get the current state of an axis control on a joystick
2794 The state is a value ranging from -32768 to 32767.
2795 The axis indices start at index 0. }
2797 function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: Integer) : SInt16;
2798 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetAxis'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2799 {$EXTERNALSYM SDL_JoystickGetAxis}
2801 { The hat indices start at index 0. }
2803 function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: Integer): UInt8;
2804 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetHat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2805 {$EXTERNALSYM SDL_JoystickGetHat}
2807 { Get the ball axis change since the last poll
2808 This returns 0, or -1 if you passed it invalid parameters.
2809 The ball indices start at index 0. }
2811 function SDL_JoystickGetBall(joystick: PSDL_Joystick; ball: Integer; var dx: Integer; var dy: Integer): Integer;
2812 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetBall'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2813 {$EXTERNALSYM SDL_JoystickGetBall}
2815 { Get the current state of a button on a joystick
2816 The button indices start at index 0. }
2817 function SDL_JoystickGetButton( joystick: PSDL_Joystick; Button: Integer): UInt8;
2818 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetButton'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2819 {$EXTERNALSYM SDL_JoystickGetButton}
2821 { Close a joystick previously opened with SDL_JoystickOpen() }
2822 procedure SDL_JoystickClose(joystick: PSDL_Joystick);
2823 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickClose'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2824 {$EXTERNALSYM SDL_JoystickClose}
2826 {------------------------------------------------------------------------------}
2827 { event-handling }
2828 {------------------------------------------------------------------------------}
2830 { Pumps the event loop, gathering events from the input devices.
2831 This function updates the event queue and internal input device state.
2832 This should only be run in the thread that sets the video mode. }
2834 procedure SDL_PumpEvents;
2835 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PumpEvents'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2836 {$EXTERNALSYM SDL_PumpEvents;}
2838 { Checks the event queue for messages and optionally returns them.
2839 If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
2840 the back of the event queue.
2841 If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
2842 of the event queue, matching 'mask', will be returned and will not
2843 be removed from the queue.
2844 If 'action' is SDL_GETEVENT, up to 'numevents' events at the front
2845 of the event queue, matching 'mask', will be returned and will be
2846 removed from the queue.
2847 This function returns the number of events actually stored, or -1
2848 if there was an error. This function is thread-safe. }
2850 function SDL_PeepEvents(events: PSDL_Event; numevents: Integer; action: TSDL_eventaction; mask: UInt32): Integer;
2851 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PeepEvents'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2852 {$EXTERNALSYM SDL_PeepEvents}
2854 { Polls for currently pending events, and returns 1 if there are any pending
2855 events, or 0 if there are none available. If 'event' is not NULL, the next
2856 event is removed from the queue and stored in that area. }
2858 function SDL_PollEvent(event: PSDL_Event): Integer;
2859 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PollEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2860 {$EXTERNALSYM SDL_PollEvent}
2862 { Waits indefinitely for the next available event, returning 1, or 0 if there
2863 was an error while waiting for events. If 'event' is not NULL, the next
2864 event is removed from the queue and stored in that area. }
2866 function SDL_WaitEvent(event: PSDL_Event): Integer;
2867 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WaitEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2868 {$EXTERNALSYM SDL_WaitEvent}
2870 function SDL_PushEvent( event : PSDL_Event ) : Integer;
2871 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PushEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2872 {$EXTERNALSYM SDL_PushEvent}
2874 { If the filter returns 1, then the event will be added to the internal queue.
2875 If it returns 0, then the event will be dropped from the queue, but the
2876 internal state will still be updated. This allows selective filtering of
2877 dynamically arriving events.
2879 WARNING: Be very careful of what you do in the event filter function, as
2880 it may run in a different thread!
2882 There is one caveat when dealing with the SDL_QUITEVENT event type. The
2883 event filter is only called when the window manager desires to close the
2884 application window. If the event filter returns 1, then the window will
2885 be closed, otherwise the window will remain open if possible.
2886 If the quit event is generated by an interrupt signal, it will bypass the
2887 internal queue and be delivered to the application at the next event poll. }
2888 procedure SDL_SetEventFilter( filter : TSDL_EventFilter );
2889 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetEventFilter'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2890 {$EXTERNALSYM SDL_SetEventFilter}
2892 { Return the current event filter - can be used to "chain" filters.
2893 If there is no event filter set, this function returns NULL. }
2895 function SDL_GetEventFilter: TSDL_EventFilter;
2896 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetEventFilter'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2897 {$EXTERNALSYM SDL_GetEventFilter}
2899 { This function allows you to set the state of processing certain events.
2900 If 'state' is set to SDL_IGNORE, that event will be automatically dropped
2901 from the event queue and will not event be filtered.
2902 If 'state' is set to SDL_ENABLE, that event will be processed normally.
2903 If 'state' is set to SDL_QUERY, SDL_EventState() will return the
2904 current processing state of the specified event. }
2906 function SDL_EventState(type_: UInt8; state: Integer): UInt8;
2907 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_EventState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2908 {$EXTERNALSYM SDL_EventState}
2910 {------------------------------------------------------------------------------}
2911 { Version Routines }
2912 {------------------------------------------------------------------------------}
2914 { This macro can be used to fill a version structure with the compile-time
2915 version of the SDL library. }
2916 procedure SDL_VERSION(var X: TSDL_Version);
2917 {$EXTERNALSYM SDL_VERSION}
2919 { This macro turns the version numbers into a numeric value:
2920 (1,2,3) -> (1203)
2921 This assumes that there will never be more than 100 patchlevels }
2923 function SDL_VERSIONNUM(X, Y, Z: Integer): Integer;
2924 {$EXTERNALSYM SDL_VERSIONNUM}
2926 // This is the version number macro for the current SDL version
2927 function SDL_COMPILEDVERSION: Integer;
2928 {$EXTERNALSYM SDL_COMPILEDVERSION}
2930 // This macro will evaluate to true if compiled with SDL at least X.Y.Z
2931 function SDL_VERSION_ATLEAST(X: Integer; Y: Integer; Z: Integer) : LongBool;
2932 {$EXTERNALSYM SDL_VERSION_ATLEAST}
2934 { This function gets the version of the dynamically linked SDL library.
2935 it should NOT be used to fill a version structure, instead you should
2936 use the SDL_Version() macro. }
2938 function SDL_Linked_Version: PSDL_version;
2939 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Linked_Version'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2940 {$EXTERNALSYM SDL_Linked_Version}
2942 {------------------------------------------------------------------------------}
2943 { video }
2944 {------------------------------------------------------------------------------}
2946 { These functions are used internally, and should not be used unless you
2947 have a specific need to specify the video driver you want to use.
2948 You should normally use SDL_Init() or SDL_InitSubSystem().
2950 SDL_VideoInit() initializes the video subsystem -- sets up a connection
2951 to the window manager, etc, and determines the current video mode and
2952 pixel format, but does not initialize a window or graphics mode.
2953 Note that event handling is activated by this routine.
2955 If you use both sound and video in your application, you need to call
2956 SDL_Init() before opening the sound device, otherwise under Win32 DirectX,
2957 you won't be able to set full-screen display modes. }
2959 function SDL_VideoInit(driver_name: PChar; flags: UInt32): Integer;
2960 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoInit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2961 {$EXTERNALSYM SDL_VideoInit}
2962 procedure SDL_VideoQuit;
2963 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoQuit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2964 {$EXTERNALSYM SDL_VideoQuit}
2966 { This function fills the given character buffer with the name of the
2967 video driver, and returns a pointer to it if the video driver has
2968 been initialized. It returns NULL if no driver has been initialized. }
2970 function SDL_VideoDriverName(namebuf: PChar; maxlen: Integer): PChar;
2971 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoDriverName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2972 {$EXTERNALSYM SDL_VideoDriverName}
2974 { This function returns a pointer to the current display surface.
2975 If SDL is doing format conversion on the display surface, this
2976 function returns the publicly visible surface, not the real video
2977 surface. }
2979 function SDL_GetVideoSurface: PSDL_Surface;
2980 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetVideoSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2981 {$EXTERNALSYM SDL_GetVideoSurface}
2983 { This function returns a read-only pointer to information about the
2984 video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt'
2985 member of the returned structure will contain the pixel format of the
2986 "best" video mode. }
2987 function SDL_GetVideoInfo: PSDL_VideoInfo;
2988 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetVideoInfo'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
2989 {$EXTERNALSYM SDL_GetVideoInfo}
2991 { Check to see if a particular video mode is supported.
2992 It returns 0 if the requested mode is not supported under any bit depth,
2993 or returns the bits-per-pixel of the closest available mode with the
2994 given width and height. If this bits-per-pixel is different from the
2995 one used when setting the video mode, SDL_SetVideoMode() will succeed,
2996 but will emulate the requested bits-per-pixel with a shadow surface.
2998 The arguments to SDL_VideoModeOK() are the same ones you would pass to
2999 SDL_SetVideoMode() }
3001 function SDL_VideoModeOK(width, height, bpp: Integer; flags: UInt32): Integer;
3002 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoModeOK'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3003 {$EXTERNALSYM SDL_VideoModeOK}
3005 { Return a pointer to an array of available screen dimensions for the
3006 given format and video flags, sorted largest to smallest. Returns
3007 NULL if there are no dimensions available for a particular format,
3008 or (SDL_Rect **)-1 if any dimension is okay for the given format.
3010 if 'format' is NULL, the mode list will be for the format given
3011 by SDL_GetVideoInfo( ) - > vfmt }
3013 function SDL_ListModes(format: PSDL_PixelFormat; flags: UInt32): PPSDL_Rect;
3014 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ListModes'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3015 {$EXTERNALSYM SDL_ListModes}
3018 { Set up a video mode with the specified width, height and bits-per-pixel.
3020 If 'bpp' is 0, it is treated as the current display bits per pixel.
3022 If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the
3023 requested bits-per-pixel, but will return whatever video pixel format is
3024 available. The default is to emulate the requested pixel format if it
3025 is not natively available.
3027 If SDL_HWSURFACE is set in 'flags', the video surface will be placed in
3028 video memory, if possible, and you may have to call SDL_LockSurface()
3029 in order to access the raw framebuffer. Otherwise, the video surface
3030 will be created in system memory.
3032 If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle
3033 updates asynchronously, but you must always lock before accessing pixels.
3034 SDL will wait for updates to complete before returning from the lock.
3036 If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee
3037 that the colors set by SDL_SetColors() will be the colors you get.
3038 Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all
3039 of the colors exactly the way they are requested, and you should look
3040 at the video surface structure to determine the actual palette.
3041 If SDL cannot guarantee that the colors you request can be set,
3042 i.e. if the colormap is shared, then the video surface may be created
3043 under emulation in system memory, overriding the SDL_HWSURFACE flag.
3045 If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set
3046 a fullscreen video mode. The default is to create a windowed mode
3047 if the current graphics system has a window manager.
3048 If the SDL library is able to set a fullscreen video mode, this flag
3049 will be set in the surface that is returned.
3051 If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up
3052 two surfaces in video memory and swap between them when you call
3053 SDL_Flip(). This is usually slower than the normal single-buffering
3054 scheme, but prevents "tearing" artifacts caused by modifying video
3055 memory while the monitor is refreshing. It should only be used by
3056 applications that redraw the entire screen on every update.
3058 This function returns the video framebuffer surface, or NULL if it fails. }
3060 function SDL_SetVideoMode(width, height, bpp: Integer; flags: UInt32): PSDL_Surface;
3061 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetVideoMode'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3062 {$EXTERNALSYM SDL_SetVideoMode}
3065 { Makes sure the given list of rectangles is updated on the given screen.
3066 If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
3067 screen.
3068 These functions should not be called while 'screen' is locked. }
3070 procedure SDL_UpdateRects(screen: PSDL_Surface; numrects: Integer; rects: PSDL_Rect);
3071 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UpdateRects'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3072 {$EXTERNALSYM SDL_UpdateRects}
3073 procedure SDL_UpdateRect(screen: PSDL_Surface; x, y: SInt32; w, h: UInt32);
3074 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UpdateRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3075 {$EXTERNALSYM SDL_UpdateRect}
3078 { On hardware that supports double-buffering, this function sets up a flip
3079 and returns. The hardware will wait for vertical retrace, and then swap
3080 video buffers before the next video surface blit or lock will return.
3081 On hardware that doesn not support double-buffering, this is equivalent
3082 to calling SDL_UpdateRect(screen, 0, 0, 0, 0);
3083 The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when
3084 setting the video mode for this function to perform hardware flipping.
3085 This function returns 0 if successful, or -1 if there was an error.}
3087 function SDL_Flip(screen: PSDL_Surface): Integer;
3088 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Flip'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3089 {$EXTERNALSYM SDL_Flip}
3091 { Set the gamma correction for each of the color channels.
3092 The gamma values range (approximately) between 0.1 and 10.0
3094 If this function isn't supported directly by the hardware, it will
3095 be emulated using gamma ramps, if available. If successful, this
3096 function returns 0, otherwise it returns -1. }
3098 function SDL_SetGamma(redgamma: single; greengamma: single; bluegamma: single ): Integer;
3099 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetGamma'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3100 {$EXTERNALSYM SDL_SetGamma}
3102 { Set the gamma translation table for the red, green, and blue channels
3103 of the video hardware. Each table is an array of 256 16-bit quantities,
3104 representing a mapping between the input and output for that channel.
3105 The input is the index into the array, and the output is the 16-bit
3106 gamma value at that index, scaled to the output color precision.
3108 You may pass NULL for any of the channels to leave it unchanged.
3109 If the call succeeds, it will return 0. If the display driver or
3110 hardware does not support gamma translation, or otherwise fails,
3111 this function will return -1. }
3113 function SDL_SetGammaRamp( redtable: PUInt16; greentable: PUInt16; bluetable: PUInt16): Integer;
3114 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetGammaRamp'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3115 {$EXTERNALSYM SDL_SetGammaRamp}
3117 { Retrieve the current values of the gamma translation tables.
3119 You must pass in valid pointers to arrays of 256 16-bit quantities.
3120 Any of the pointers may be NULL to ignore that channel.
3121 If the call succeeds, it will return 0. If the display driver or
3122 hardware does not support gamma translation, or otherwise fails,
3123 this function will return -1. }
3125 function SDL_GetGammaRamp( redtable: PUInt16; greentable: PUInt16; bluetable: PUInt16): Integer;
3126 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetGammaRamp'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3127 {$EXTERNALSYM SDL_GetGammaRamp}
3129 { Sets a portion of the colormap for the given 8-bit surface. If 'surface'
3130 is not a palettized surface, this function does nothing, returning 0.
3131 If all of the colors were set as passed to SDL_SetColors(), it will
3132 return 1. If not all the color entries were set exactly as given,
3133 it will return 0, and you should look at the surface palette to
3134 determine the actual color palette.
3136 When 'surface' is the surface associated with the current display, the
3137 display colormap will be updated with the requested colors. If
3138 SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors()
3139 will always return 1, and the palette is guaranteed to be set the way
3140 you desire, even if the window colormap has to be warped or run under
3141 emulation. }
3144 function SDL_SetColors(surface: PSDL_Surface; colors: PSDL_Color; firstcolor : Integer; ncolors: Integer) : Integer;
3145 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetColors'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3146 {$EXTERNALSYM SDL_SetColors}
3148 { Sets a portion of the colormap for a given 8-bit surface.
3149 'flags' is one or both of:
3150 SDL_LOGPAL -- set logical palette, which controls how blits are mapped
3151 to/from the surface,
3152 SDL_PHYSPAL -- set physical palette, which controls how pixels look on
3153 the screen
3154 Only screens have physical palettes. Separate change of physical/logical
3155 palettes is only possible if the screen has SDL_HWPALETTE set.
3157 The return value is 1 if all colours could be set as requested, and 0
3158 otherwise.
3160 SDL_SetColors() is equivalent to calling this function with
3161 flags = (SDL_LOGPAL or SDL_PHYSPAL). }
3163 function SDL_SetPalette(surface: PSDL_Surface; flags: Integer; colors: PSDL_Color; firstcolor: Integer; ncolors: Integer): Integer;
3164 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetPalette'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3165 {$EXTERNALSYM SDL_SetPalette}
3167 { Maps an RGB triple to an opaque pixel value for a given pixel format }
3168 function SDL_MapRGB(format: PSDL_PixelFormat; r: UInt8; g: UInt8; b: UInt8) : UInt32;
3169 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_MapRGB'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3170 {$EXTERNALSYM SDL_MapRGB}
3172 { Maps an RGBA quadruple to a pixel value for a given pixel format }
3173 function SDL_MapRGBA(format: PSDL_PixelFormat; r: UInt8; g: UInt8; b: UInt8; a: UInt8): UInt32;
3174 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_MapRGBA'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3175 {$EXTERNALSYM SDL_MapRGBA}
3177 { Maps a pixel value into the RGB components for a given pixel format }
3178 procedure SDL_GetRGB(pixel: UInt32; fmt: PSDL_PixelFormat; r: PUInt8; g: PUInt8; b: PUInt8);
3179 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetRGB'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3180 {$EXTERNALSYM SDL_GetRGB}
3182 { Maps a pixel value into the RGBA components for a given pixel format }
3183 procedure SDL_GetRGBA(pixel: UInt32; fmt: PSDL_PixelFormat; r: PUInt8; g: PUInt8; b: PUInt8; a: PUInt8);
3184 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetRGBA'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3185 {$EXTERNALSYM SDL_GetRGBA}
3187 { Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
3188 If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
3189 If the depth is greater than 8 bits, the pixel format is set using the
3190 flags '[RGB]mask'.
3191 If the function runs out of memory, it will return NULL.
3193 The 'flags' tell what kind of surface to create.
3194 SDL_SWSURFACE means that the surface should be created in system memory.
3195 SDL_HWSURFACE means that the surface should be created in video memory,
3196 with the same format as the display surface. This is useful for surfaces
3197 that will not change much, to take advantage of hardware acceleration
3198 when being blitted to the display surface.
3199 SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with
3200 this surface, but you must always lock it before accessing the pixels.
3201 SDL will wait for current blits to finish before returning from the lock.
3202 SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
3203 If the hardware supports acceleration of colorkey blits between
3204 two surfaces in video memory, SDL will try to place the surface in
3205 video memory. If this isn't possible or if there is no hardware
3206 acceleration available, the surface will be placed in system memory.
3207 SDL_SRCALPHA means that the surface will be used for alpha blits and
3208 if the hardware supports hardware acceleration of alpha blits between
3209 two surfaces in video memory, to place the surface in video memory
3210 if possible, otherwise it will be placed in system memory.
3211 If the surface is created in video memory, blits will be _much_ faster,
3212 but the surface format must be identical to the video surface format,
3213 and the only way to access the pixels member of the surface is to use
3214 the SDL_LockSurface() and SDL_UnlockSurface() calls.
3215 If the requested surface actually resides in video memory, SDL_HWSURFACE
3216 will be set in the flags member of the returned surface. If for some
3217 reason the surface could not be placed in video memory, it will not have
3218 the SDL_HWSURFACE flag set, and will be created in system memory instead. }
3220 function SDL_AllocSurface(flags: UInt32; width, height, depth: Integer;
3221 RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
3222 {$EXTERNALSYM SDL_AllocSurface}
3224 function SDL_CreateRGBSurface(flags: UInt32; width, height, depth: Integer; RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
3225 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateRGBSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3226 {$EXTERNALSYM SDL_CreateRGBSurface}
3228 function SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch
3229 : Integer; RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
3230 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateRGBSurfaceFrom'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3231 {$EXTERNALSYM SDL_CreateRGBSurfaceFrom}
3233 procedure SDL_FreeSurface(surface: PSDL_Surface);
3234 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3235 {$EXTERNALSYM SDL_FreeSurface}
3237 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
3238 {$EXTERNALSYM SDL_MustLock}
3239 { SDL_LockSurface() sets up a surface for directly accessing the pixels.
3240 Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
3241 to and read from 'surface->pixels', using the pixel format stored in
3242 'surface->format'. Once you are done accessing the surface, you should
3243 use SDL_UnlockSurface() to release it.
3245 Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
3246 to 0, then you can read and write to the surface at any time, and the
3247 pixel format of the surface will not change. In particular, if the
3248 SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
3249 will not need to lock the display surface before accessing it.
3251 No operating system or library calls should be made between lock/unlock
3252 pairs, as critical system locks may be held during this time.
3254 SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. }
3255 function SDL_LockSurface(surface: PSDL_Surface): Integer;
3256 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LockSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3257 {$EXTERNALSYM SDL_LockSurface}
3259 procedure SDL_UnlockSurface(surface: PSDL_Surface);
3260 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnlockSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3261 {$EXTERNALSYM SDL_UnlockSurface}
3263 { Load a surface from a seekable SDL data source (memory or file.)
3264 If 'freesrc' is non-zero, the source will be closed after being read.
3265 Returns the new surface, or NULL if there was an error.
3266 The new surface should be freed with SDL_FreeSurface(). }
3267 function SDL_LoadBMP_RW(src: PSDL_RWops; freesrc: Integer): PSDL_Surface;
3268 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadBMP_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3269 {$EXTERNALSYM SDL_LoadBMP_RW}
3271 // Convenience macro -- load a surface from a file
3272 function SDL_LoadBMP(filename: PChar): PSDL_Surface;
3273 {$EXTERNALSYM SDL_LoadBMP}
3275 { Save a surface to a seekable SDL data source (memory or file.)
3276 If 'freedst' is non-zero, the source will be closed after being written.
3277 Returns 0 if successful or -1 if there was an error. }
3279 function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: Integer): Integer;
3280 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SaveBMP_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3281 {$EXTERNALSYM SDL_SaveBMP_RW}
3283 // Convenience macro -- save a surface to a file
3284 function SDL_SaveBMP(surface: PSDL_Surface; filename: PChar): Integer;
3285 {$EXTERNALSYM SDL_SaveBMP}
3287 { Sets the color key (transparent pixel) in a blittable surface.
3288 If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
3289 'key' will be the transparent pixel in the source image of a blit.
3290 SDL_RLEACCEL requests RLE acceleration for the surface if present,
3291 and removes RLE acceleration if absent.
3292 If 'flag' is 0, this function clears any current color key.
3293 This function returns 0, or -1 if there was an error. }
3295 function SDL_SetColorKey(surface: PSDL_Surface; flag, key: UInt32) : Integer;
3296 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetColorKey'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3297 {$EXTERNALSYM SDL_SetColorKey}
3299 { This function sets the alpha value for the entire surface, as opposed to
3300 using the alpha component of each pixel. This value measures the range
3301 of transparency of the surface, 0 being completely transparent to 255
3302 being completely opaque. An 'alpha' value of 255 causes blits to be
3303 opaque, the source pixels copied to the destination (the default). Note
3304 that per-surface alpha can be combined with colorkey transparency.
3306 If 'flag' is 0, alpha blending is disabled for the surface.
3307 If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface.
3308 OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the
3309 surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. }
3312 function SDL_SetAlpha(surface: PSDL_Surface; flag: UInt32; alpha: UInt8): Integer;
3313 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetAlpha'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3314 {$EXTERNALSYM SDL_SetAlpha}
3316 { Sets the clipping rectangle for the destination surface in a blit.
3318 If the clip rectangle is NULL, clipping will be disabled.
3319 If the clip rectangle doesn't intersect the surface, the function will
3320 return SDL_FALSE and blits will be completely clipped. Otherwise the
3321 function returns SDL_TRUE and blits to the surface will be clipped to
3322 the intersection of the surface area and the clipping rectangle.
3324 Note that blits are automatically clipped to the edges of the source
3325 and destination surfaces. }
3326 procedure SDL_SetClipRect(surface: PSDL_Surface; rect: PSDL_Rect); cdecl;
3327 external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetClipRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3328 {$EXTERNALSYM SDL_SetClipRect}
3330 { Gets the clipping rectangle for the destination surface in a blit.
3331 'rect' must be a pointer to a valid rectangle which will be filled
3332 with the correct values. }
3333 procedure SDL_GetClipRect(surface: PSDL_Surface; rect: PSDL_Rect); cdecl;
3334 external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetClipRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3335 {$EXTERNALSYM SDL_GetClipRect}
3337 { Creates a new surface of the specified format, and then copies and maps
3338 the given surface to it so the blit of the converted surface will be as
3339 fast as possible. If this function fails, it returns NULL.
3341 The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those
3342 semantics. You can also pass SDL_RLEACCEL in the flags parameter and
3343 SDL will try to RLE accelerate colorkey and alpha blits in the resulting
3344 surface.
3346 This function is used internally by SDL_DisplayFormat(). }
3348 function SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: UInt32): PSDL_Surface;
3349 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ConvertSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3350 {$EXTERNALSYM SDL_ConvertSurface}
3353 This performs a fast blit from the source surface to the destination
3354 surface. It assumes that the source and destination rectangles are
3355 the same size. If either 'srcrect' or 'dstrect' are NULL, the entire
3356 surface (src or dst) is copied. The final blit rectangles are saved
3357 in 'srcrect' and 'dstrect' after all clipping is performed.
3358 If the blit is successful, it returns 0, otherwise it returns -1.
3360 The blit function should not be called on a locked surface.
3362 The blit semantics for surfaces with and without alpha and colorkey
3363 are defined as follows:
3365 RGBA->RGB:
3366 SDL_SRCALPHA set:
3367 alpha-blend (using alpha-channel).
3368 SDL_SRCCOLORKEY ignored.
3369 SDL_SRCALPHA not set:
3370 copy RGB.
3371 if SDL_SRCCOLORKEY set, only copy the pixels matching the
3372 RGB values of the source colour key, ignoring alpha in the
3373 comparison.
3375 RGB->RGBA:
3376 SDL_SRCALPHA set:
3377 alpha-blend (using the source per-surface alpha value);
3378 set destination alpha to opaque.
3379 SDL_SRCALPHA not set:
3380 copy RGB, set destination alpha to opaque.
3381 both:
3382 if SDL_SRCCOLORKEY set, only copy the pixels matching the
3383 source colour key.
3385 RGBA->RGBA:
3386 SDL_SRCALPHA set:
3387 alpha-blend (using the source alpha channel) the RGB values;
3388 leave destination alpha untouched. [Note: is this correct?]
3389 SDL_SRCCOLORKEY ignored.
3390 SDL_SRCALPHA not set:
3391 copy all of RGBA to the destination.
3392 if SDL_SRCCOLORKEY set, only copy the pixels matching the
3393 RGB values of the source colour key, ignoring alpha in the
3394 comparison.
3396 RGB->RGB:
3397 SDL_SRCALPHA set:
3398 alpha-blend (using the source per-surface alpha value).
3399 SDL_SRCALPHA not set:
3400 copy RGB.
3401 both:
3402 if SDL_SRCCOLORKEY set, only copy the pixels matching the
3403 source colour key.
3405 If either of the surfaces were in video memory, and the blit returns -2,
3406 the video memory was lost, so it should be reloaded with artwork and
3407 re-blitted:
3408 while ( SDL_BlitSurface(image, imgrect, screen, dstrect) = -2 ) do
3409 begin
3410 while ( SDL_LockSurface(image) < 0 ) do
3411 Sleep(10);
3412 -- Write image pixels to image->pixels --
3413 SDL_UnlockSurface(image);
3414 end;
3416 This happens under DirectX 5.0 when the system switches away from your
3417 fullscreen application. The lock will also fail until you have access
3418 to the video memory again. }
3420 { You should call SDL_BlitSurface() unless you know exactly how SDL
3421 blitting works internally and how to use the other blit functions. }
3423 function SDL_BlitSurface(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): Integer;
3424 {$EXTERNALSYM SDL_BlitSurface}
3426 { This is the public blit function, SDL_BlitSurface(), and it performs
3427 rectangle validation and clipping before passing it to SDL_LowerBlit() }
3428 function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): Integer;
3429 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UpperBlit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3430 {$EXTERNALSYM SDL_UpperBlit}
3432 { This is a semi-private blit function and it performs low-level surface
3433 blitting only. }
3434 function SDL_LowerBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): Integer;
3435 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LowerBlit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3436 {$EXTERNALSYM SDL_LowerBlit}
3438 { This function performs a fast fill of the given rectangle with 'color'
3439 The given rectangle is clipped to the destination surface clip area
3440 and the final fill rectangle is saved in the passed in pointer.
3441 If 'dstrect' is NULL, the whole surface will be filled with 'color'
3442 The color should be a pixel of the format used by the surface, and
3443 can be generated by the SDL_MapRGB() function.
3444 This function returns 0 on success, or -1 on error. }
3446 function SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: UInt32) : Integer;
3447 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FillRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3448 {$EXTERNALSYM SDL_FillRect}
3450 { This function takes a surface and copies it to a new surface of the
3451 pixel format and colors of the video framebuffer, suitable for fast
3452 blitting onto the display surface. It calls SDL_ConvertSurface()
3454 If you want to take advantage of hardware colorkey or alpha blit
3455 acceleration, you should set the colorkey and alpha value before
3456 calling this function.
3458 If the conversion fails or runs out of memory, it returns NULL }
3460 function SDL_DisplayFormat(surface: PSDL_Surface): PSDL_Surface; cdecl;
3461 external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DisplayFormat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3462 {$EXTERNALSYM SDL_DisplayFormat}
3464 { This function takes a surface and copies it to a new surface of the
3465 pixel format and colors of the video framebuffer (if possible),
3466 suitable for fast alpha blitting onto the display surface.
3467 The new surface will always have an alpha channel.
3469 If you want to take advantage of hardware colorkey or alpha blit
3470 acceleration, you should set the colorkey and alpha value before
3471 calling this function.
3473 If the conversion fails or runs out of memory, it returns NULL }
3476 function SDL_DisplayFormatAlpha(surface: PSDL_Surface): PSDL_Surface; cdecl;
3477 external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DisplayFormatAlpha'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3478 {$EXTERNALSYM SDL_DisplayFormatAlpha}
3480 //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
3481 //* YUV video surface overlay functions */
3482 //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
3484 { This function creates a video output overlay
3485 Calling the returned surface an overlay is something of a misnomer because
3486 the contents of the display surface underneath the area where the overlay
3487 is shown is undefined - it may be overwritten with the converted YUV data. }
3489 function SDL_CreateYUVOverlay(width: Integer; height: Integer; format: UInt32; display: PSDL_Surface): PSDL_Overlay;
3490 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3491 {$EXTERNALSYM SDL_CreateYUVOverlay}
3493 // Lock an overlay for direct access, and unlock it when you are done
3494 function SDL_LockYUVOverlay(Overlay: PSDL_Overlay): Integer;
3495 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LockYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3496 {$EXTERNALSYM SDL_LockYUVOverlay}
3498 procedure SDL_UnlockYUVOverlay(Overlay: PSDL_Overlay); cdecl;
3499 external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnlockYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3500 {$EXTERNALSYM SDL_UnlockYUVOverlay}
3503 { Blit a video overlay to the display surface.
3504 The contents of the video surface underneath the blit destination are
3505 not defined.
3506 The width and height of the destination rectangle may be different from
3507 that of the overlay, but currently only 2x scaling is supported. }
3509 function SDL_DisplayYUVOverlay(Overlay: PSDL_Overlay; dstrect: PSDL_Rect) : Integer;
3510 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DisplayYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3511 {$EXTERNALSYM SDL_DisplayYUVOverlay}
3513 // Free a video overlay
3514 procedure SDL_FreeYUVOverlay(Overlay: PSDL_Overlay);
3515 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3516 {$EXTERNALSYM SDL_FreeYUVOverlay}
3518 {------------------------------------------------------------------------------}
3519 { OpenGL Routines }
3520 {------------------------------------------------------------------------------}
3522 { Dynamically load a GL driver, if SDL is built with dynamic GL.
3524 SDL links normally with the OpenGL library on your system by default,
3525 but you can compile it to dynamically load the GL driver at runtime.
3526 If you do this, you need to retrieve all of the GL functions used in
3527 your program from the dynamic library using SDL_GL_GetProcAddress().
3529 This is disabled in default builds of SDL. }
3532 function SDL_GL_LoadLibrary(filename: PChar): Integer;
3533 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_LoadLibrary'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3534 {$EXTERNALSYM SDL_GL_LoadLibrary}
3536 { Get the address of a GL function (for extension functions) }
3537 function SDL_GL_GetProcAddress(procname: PChar) : Pointer;
3538 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_GetProcAddress'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3539 {$EXTERNALSYM SDL_GL_GetProcAddress}
3541 { Set an attribute of the OpenGL subsystem before intialization. }
3542 function SDL_GL_SetAttribute(attr: TSDL_GLAttr; value: Integer) : Integer;
3543 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_SetAttribute'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3544 {$EXTERNALSYM SDL_GL_SetAttribute}
3546 { Get an attribute of the OpenGL subsystem from the windowing
3547 interface, such as glX. This is of course different from getting
3548 the values from SDL's internal OpenGL subsystem, which only
3549 stores the values you request before initialization.
3551 Developers should track the values they pass into SDL_GL_SetAttribute
3552 themselves if they want to retrieve these values. }
3554 function SDL_GL_GetAttribute(attr: TSDL_GLAttr; var value: Integer): Integer;
3555 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_GetAttribute'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3556 {$EXTERNALSYM SDL_GL_GetAttribute}
3558 { Swap the OpenGL buffers, if double-buffering is supported. }
3560 procedure SDL_GL_SwapBuffers;
3561 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_SwapBuffers'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3562 {$EXTERNALSYM SDL_GL_SwapBuffers;}
3564 { Internal functions that should not be called unless you have read
3565 and understood the source code for these functions. }
3567 procedure SDL_GL_UpdateRects(numrects: Integer; rects: PSDL_Rect);
3568 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_UpdateRects'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3569 {$EXTERNALSYM SDL_GL_UpdateRects}
3570 procedure SDL_GL_Lock;
3571 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_Lock'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3572 {$EXTERNALSYM SDL_GL_Lock;}
3573 procedure SDL_GL_Unlock;
3574 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_Unlock'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3575 {$EXTERNALSYM SDL_GL_Unlock;}
3577 {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
3578 {* These functions allow interaction with the window manager, if any. *}
3579 {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
3581 { Sets/Gets the title and icon text of the display window }
3582 procedure SDL_WM_GetCaption(var title : PChar; var icon : PChar);
3583 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_GetCaption'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3584 {$EXTERNALSYM SDL_WM_GetCaption}
3585 procedure SDL_WM_SetCaption( const title : PChar; const icon : PChar);
3586 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_SetCaption'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3587 {$EXTERNALSYM SDL_WM_SetCaption}
3589 { Sets the icon for the display window.
3590 This function must be called before the first call to SDL_SetVideoMode().
3591 It takes an icon surface, and a mask in MSB format.
3592 If 'mask' is NULL, the entire icon surface will be used as the icon. }
3593 procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask: PUInt8);
3594 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_SetIcon'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3595 {$EXTERNALSYM SDL_WM_SetIcon}
3597 { This function iconifies the window, and returns 1 if it succeeded.
3598 If the function succeeds, it generates an SDL_APPACTIVE loss event.
3599 This function is a noop and returns 0 in non-windowed environments. }
3601 function SDL_WM_IconifyWindow: Integer;
3602 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_IconifyWindow'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3603 {$EXTERNALSYM SDL_WM_IconifyWindow}
3605 { Toggle fullscreen mode without changing the contents of the screen.
3606 If the display surface does not require locking before accessing
3607 the pixel information, then the memory pointers will not change.
3609 If this function was able to toggle fullscreen mode (change from
3610 running in a window to fullscreen, or vice-versa), it will return 1.
3611 If it is not implemented, or fails, it returns 0.
3613 The next call to SDL_SetVideoMode() will set the mode fullscreen
3614 attribute based on the flags parameter - if SDL_FULLSCREEN is not
3615 set, then the display will be windowed by default where supported.
3617 This is currently only implemented in the X11 video driver. }
3619 function SDL_WM_ToggleFullScreen(surface: PSDL_Surface): Integer;
3620 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_ToggleFullScreen'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3621 {$EXTERNALSYM SDL_WM_ToggleFullScreen}
3623 { Grabbing means that the mouse is confined to the application window,
3624 and nearly all keyboard input is passed directly to the application,
3625 and not interpreted by a window manager, if any. }
3627 function SDL_WM_GrabInput(mode: TSDL_GrabMode): TSDL_GrabMode;
3628 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_GrabInput'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3629 {$EXTERNALSYM SDL_WM_GrabInput}
3631 {------------------------------------------------------------------------------}
3632 { mouse-routines }
3633 {------------------------------------------------------------------------------}
3635 { Retrieve the current state of the mouse.
3636 The current button state is returned as a button bitmask, which can
3637 be tested using the SDL_BUTTON(X) macros, and x and y are set to the
3638 current mouse cursor position. You can pass NULL for either x or y. }
3640 function SDL_GetMouseState(var x: Integer; var y: Integer): UInt8;
3641 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetMouseState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3642 {$EXTERNALSYM SDL_GetMouseState}
3644 { Retrieve the current state of the mouse.
3645 The current button state is returned as a button bitmask, which can
3646 be tested using the SDL_BUTTON(X) macros, and x and y are set to the
3647 mouse deltas since the last call to SDL_GetRelativeMouseState(). }
3648 function SDL_GetRelativeMouseState(var x: Integer; var y: Integer): UInt8;
3649 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetRelativeMouseState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3650 {$EXTERNALSYM SDL_GetRelativeMouseState}
3652 { Set the position of the mouse cursor (generates a mouse motion event) }
3653 procedure SDL_WarpMouse(x, y: UInt16);
3654 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WarpMouse'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3655 {$EXTERNALSYM SDL_WarpMouse}
3657 { Create a cursor using the specified data and mask (in MSB format).
3658 The cursor width must be a multiple of 8 bits.
3660 The cursor is created in black and white according to the following:
3661 data mask resulting pixel on screen
3662 0 1 White
3663 1 1 Black
3664 0 0 Transparent
3665 1 0 Inverted color if possible, black if not.
3667 Cursors created with this function must be freed with SDL_FreeCursor(). }
3668 function SDL_CreateCursor(data, mask: PUInt8; w, h, hot_x, hot_y: Integer): PSDL_Cursor;
3669 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3670 {$EXTERNALSYM SDL_CreateCursor}
3672 { Set the currently active cursor to the specified one.
3673 If the cursor is currently visible, the change will be immediately
3674 represented on the display. }
3675 procedure SDL_SetCursor(cursor: PSDL_Cursor);
3676 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3677 {$EXTERNALSYM SDL_SetCursor}
3679 { Returns the currently active cursor. }
3680 function SDL_GetCursor: PSDL_Cursor;
3681 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3682 {$EXTERNALSYM SDL_GetCursor}
3684 { Deallocates a cursor created with SDL_CreateCursor(). }
3685 procedure SDL_FreeCursor(cursor: PSDL_Cursor);
3686 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3687 {$EXTERNALSYM SDL_FreeCursor}
3689 { Toggle whether or not the cursor is shown on the screen.
3690 The cursor start off displayed, but can be turned off.
3691 SDL_ShowCursor() returns 1 if the cursor was being displayed
3692 before the call, or 0 if it was not. You can query the current
3693 state by passing a 'toggle' value of -1. }
3694 function SDL_ShowCursor(toggle: Integer): Integer;
3695 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ShowCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3696 {$EXTERNALSYM SDL_ShowCursor}
3698 function SDL_BUTTON( Button : Integer ) : Integer;
3700 {------------------------------------------------------------------------------}
3701 { Keyboard-routines }
3702 {------------------------------------------------------------------------------}
3704 { Enable/Disable UNICODE translation of keyboard input.
3705 This translation has some overhead, so translation defaults off.
3706 If 'enable' is 1, translation is enabled.
3707 If 'enable' is 0, translation is disabled.
3708 If 'enable' is -1, the translation state is not changed.
3709 It returns the previous state of keyboard translation. }
3710 function SDL_EnableUNICODE(enable: Integer): Integer;
3711 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_EnableUNICODE'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3712 {$EXTERNALSYM SDL_EnableUNICODE}
3714 { If 'delay' is set to 0, keyboard repeat is disabled. }
3715 function SDL_EnableKeyRepeat(delay: Integer; interval: Integer): Integer;
3716 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_EnableKeyRepeat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3717 {$EXTERNALSYM SDL_EnableKeyRepeat}
3719 procedure SDL_GetKeyRepeat(delay : PInteger; interval: PInteger);
3720 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetKeyRepeat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3721 {$EXTERNALSYM SDL_GetKeyRepeat}
3723 { Get a snapshot of the current state of the keyboard.
3724 Returns an array of keystates, indexed by the SDLK_* syms.
3725 Used:
3727 UInt8 *keystate = SDL_GetKeyState(NULL);
3728 if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed }
3730 function SDL_GetKeyState(numkeys: PInt): PUInt8;
3731 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetKeyState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3732 {$EXTERNALSYM SDL_GetKeyState}
3734 { Get the current key modifier state }
3735 function SDL_GetModState: TSDLMod;
3736 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetModState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3737 {$EXTERNALSYM SDL_GetModState}
3739 { Set the current key modifier state
3740 This does not change the keyboard state, only the key modifier flags. }
3741 procedure SDL_SetModState(modstate: TSDLMod);
3742 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetModState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3743 {$EXTERNALSYM SDL_SetModState}
3745 { Get the name of an SDL virtual keysym }
3746 function SDL_GetKeyName(key: TSDLKey): PChar;
3747 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetKeyName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3748 {$EXTERNALSYM SDL_GetKeyName}
3750 {------------------------------------------------------------------------------}
3751 { Active Routines }
3752 {------------------------------------------------------------------------------}
3754 { This function returns the current state of the application, which is a
3755 bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and
3756 SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to
3757 see your application, otherwise it has been iconified or disabled. }
3759 function SDL_GetAppState: UInt8;
3760 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetAppState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3761 {$EXTERNALSYM SDL_GetAppState}
3764 { Mutex functions }
3766 { Create a mutex, initialized unlocked }
3768 function SDL_CreateMutex: PSDL_Mutex;
3769 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateMutex'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3770 {$EXTERNALSYM SDL_CreateMutex}
3772 { Lock the mutex (Returns 0, or -1 on error) }
3774 function SDL_mutexP(mutex: PSDL_mutex): Integer;
3775 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_mutexP'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3776 { $ EXTERNALSYM SDL_mutexP}
3778 function SDL_LockMutex(mutex: PSDL_mutex): Integer;
3779 {$EXTERNALSYM SDL_LockMutex}
3781 { Unlock the mutex (Returns 0, or -1 on error) }
3782 function SDL_mutexV(mutex: PSDL_mutex): Integer;
3783 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_mutexV'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3784 {$EXTERNALSYM SDL_mutexV}
3786 function SDL_UnlockMutex(mutex: PSDL_mutex): Integer;
3787 {$EXTERNALSYM SDL_UnlockMutex}
3789 { Destroy a mutex }
3790 procedure SDL_DestroyMutex(mutex: PSDL_mutex);
3791 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DestroyMutex'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3792 {$EXTERNALSYM SDL_DestroyMutex}
3794 { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
3795 { Semaphore functions }
3796 { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
3797 { Create a semaphore, initialized with value, returns NULL on failure. }
3798 function SDL_CreateSemaphore(initial_value: UInt32): PSDL_Sem;
3799 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateSemaphore'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3800 {$EXTERNALSYM SDL_CreateSemaphore}
3803 { Destroy a semaphore }
3804 procedure SDL_DestroySemaphore(sem: PSDL_sem);
3805 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DestroySemaphore'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3806 {$EXTERNALSYM SDL_DestroySemaphore}
3808 { This function suspends the calling thread until the semaphore pointed
3809 to by sem has a positive count. It then atomically decreases the semaphore
3810 count. }
3812 function SDL_SemWait(sem: PSDL_sem): Integer;
3813 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemWait'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3814 {$EXTERNALSYM SDL_SemWait}
3816 { Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds,
3817 SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. }
3819 function SDL_SemTryWait(sem: PSDL_sem): Integer;
3820 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemTryWait'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3821 {$EXTERNALSYM SDL_SemTryWait}
3823 { Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if
3824 the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in
3825 the allotted time, and -1 on error.
3826 On some platforms this function is implemented by looping with a delay
3827 of 1 ms, and so should be avoided if possible. }
3829 function SDL_SemWaitTimeout(sem: PSDL_sem; ms: UInt32): Integer;
3830 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemWaitTimeout'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3831 {$EXTERNALSYM SDL_SemTryWait}
3833 { Atomically increases the semaphore's count (not blocking), returns 0,
3834 or -1 on error. }
3836 function SDL_SemPost(sem: PSDL_sem): Integer;
3837 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemPost'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3838 {$EXTERNALSYM SDL_SemTryWait}
3840 { Returns the current count of the semaphore }
3842 function SDL_SemValue(sem: PSDL_sem): UInt32;
3843 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemValue'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3844 {$EXTERNALSYM SDL_SemValue}
3846 { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
3847 { Condition variable functions }
3848 { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
3849 { Create a condition variable }
3850 function SDL_CreateCond: PSDL_Cond;
3851 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateCond'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3852 {$EXTERNALSYM SDL_CreateCond}
3854 { Destroy a condition variable }
3855 procedure SDL_DestroyCond(cond: PSDL_Cond);
3856 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DestroyCond'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3857 {$EXTERNALSYM SDL_DestroyCond}
3859 { Restart one of the threads that are waiting on the condition variable,
3860 returns 0 or -1 on error. }
3862 function SDL_CondSignal(cond: PSDL_cond): Integer;
3863 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondSignal'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3864 {$EXTERNALSYM SDL_CondSignal}
3866 { Restart all threads that are waiting on the condition variable,
3867 returns 0 or -1 on error. }
3869 function SDL_CondBroadcast(cond: PSDL_cond): Integer;
3870 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondBroadcast'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3871 {$EXTERNALSYM SDL_CondBroadcast}
3874 { Wait on the condition variable, unlocking the provided mutex.
3875 The mutex must be locked before entering this function!
3876 Returns 0 when it is signaled, or -1 on error. }
3878 function SDL_CondWait(cond: PSDL_cond; mut: PSDL_mutex): Integer;
3879 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondWait'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3880 {$EXTERNALSYM SDL_CondWait}
3882 { Waits for at most 'ms' milliseconds, and returns 0 if the condition
3883 variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
3884 signaled in the allotted time, and -1 on error.
3885 On some platforms this function is implemented by looping with a delay
3886 of 1 ms, and so should be avoided if possible. }
3888 function SDL_CondWaitTimeout(cond: PSDL_cond; mut: PSDL_mutex; ms: UInt32) : Integer;
3889 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondWaitTimeout'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3890 {$EXTERNALSYM SDL_CondWaitTimeout}
3892 { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
3893 { Condition variable functions }
3894 { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
3896 { Create a thread }
3897 function SDL_CreateThread(fn: PInt; data: Pointer): PSDL_Thread;
3898 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateThread'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3899 {$EXTERNALSYM SDL_CreateThread}
3901 { Get the 32-bit thread identifier for the current thread }
3902 function SDL_ThreadID: UInt32;
3903 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ThreadID'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3904 {$EXTERNALSYM SDL_ThreadID}
3906 { Get the 32-bit thread identifier for the specified thread,
3907 equivalent to SDL_ThreadID() if the specified thread is NULL. }
3908 function SDL_GetThreadID(thread: PSDL_Thread): UInt32;
3909 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetThreadID'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3910 {$EXTERNALSYM SDL_GetThreadID}
3912 { Wait for a thread to finish.
3913 The return code for the thread function is placed in the area
3914 pointed to by 'status', if 'status' is not NULL. }
3916 procedure SDL_WaitThread(thread: PSDL_Thread; var status: Integer);
3917 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WaitThread'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3918 {$EXTERNALSYM SDL_WaitThread}
3920 { Forcefully kill a thread without worrying about its state }
3921 procedure SDL_KillThread(thread: PSDL_Thread);
3922 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_KillThread'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3923 {$EXTERNALSYM SDL_KillThread}
3925 {------------------------------------------------------------------------------}
3926 { Get Environment Routines }
3927 {------------------------------------------------------------------------------}
3928 {$IFDEF WINDOWS}
3929 function _putenv( const variable : Pchar ): integer;
3930 cdecl;
3931 {$ENDIF}
3933 {$IFDEF Unix}
3934 {$IFDEF FPC}
3935 function _putenv( const variable : Pchar ): integer;
3936 cdecl; external 'libc.so' name 'putenv';
3937 {$ENDIF}
3938 {$ENDIF}
3940 { Put a variable of the form "name=value" into the environment }
3941 //function SDL_putenv(const variable: PChar): integer; cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}SDLLibName name '';
3942 function SDL_putenv(const variable: PChar): integer;
3943 {$EXTERNALSYM SDL_putenv}
3945 // The following function has been commented out to encourage developers to use
3946 // SDL_putenv as it it more portable
3947 //function putenv(const variable: PChar): integer;
3948 //{$EXTERNALSYM putenv}
3950 {$IFDEF WINDOWS}
3951 {$IFNDEF __GPC__}
3952 function getenv( const name : Pchar ): PChar; cdecl;
3953 {$ENDIF}
3954 {$ENDIF}
3956 {* Retrieve a variable named "name" from the environment }
3957 //function SDL_getenv(const name: PChar): PChar; cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}SDLLibName name '';
3958 function SDL_getenv(const name: PChar): PChar;
3959 {$EXTERNALSYM SDL_getenv}
3961 // The following function has been commented out to encourage developers to use
3962 // SDL_getenv as it it more portable
3963 //function getenv(const name: PChar): PChar;
3964 //{$EXTERNALSYM getenv}
3966 {*
3967 * This function gives you custom hooks into the window manager information.
3968 * It fills the structure pointed to by 'info' with custom information and
3969 * returns 1 if the function is implemented. If it's not implemented, or
3970 * the version member of the 'info' structure is invalid, it returns 0.
3971 *}
3972 function SDL_GetWMInfo(info : PSDL_SysWMinfo) : integer;
3973 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetWMInfo'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3974 {$EXTERNALSYM SDL_GetWMInfo}
3976 {------------------------------------------------------------------------------}
3978 //SDL_loadso.h
3979 {* This function dynamically loads a shared object and returns a pointer
3980 * to the object handle (or NULL if there was an error).
3981 * The 'sofile' parameter is a system dependent name of the object file.
3982 *}
3983 function SDL_LoadObject( const sofile : PChar ) : Pointer;
3984 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadObject'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3985 {$EXTERNALSYM SDL_LoadObject}
3987 {* Given an object handle, this function looks up the address of the
3988 * named function in the shared object and returns it. This address
3989 * is no longer valid after calling SDL_UnloadObject().
3990 *}
3991 function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer;
3992 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadFunction'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3993 {$EXTERNALSYM SDL_LoadFunction}
3995 {* Unload a shared object from memory *}
3996 procedure SDL_UnloadObject( handle : Pointer );
3997 cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnloadObject'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF};
3998 {$EXTERNALSYM SDL_UnloadObject}
4002 {------------------------------------------------------------------------------}
4004 function SDL_Swap32(D: Uint32): Uint32;
4005 {$EXTERNALSYM SDL_Swap32}
4007 {$ENDIF MORPHOS}
4009 { FreeAndNil frees the given TObject instance and sets the variable reference
4010 to nil. Be careful to only pass TObjects to this routine. }
4011 procedure FreeAndNil(var Obj);
4013 { Exit procedure handling }
4015 { AddExitProc adds the given procedure to the run-time library's exit
4016 procedure list. When an application terminates, its exit procedures are
4017 executed in reverse order of definition, i.e. the last procedure passed
4018 to AddExitProc is the first one to get executed upon termination. }
4019 procedure AddExitProc(Proc: TProcedure);
4021 // Bitwise Checking functions
4022 function IsBitOn( value : integer; bit : Byte ) : boolean;
4024 function TurnBitOn( value : integer; bit : Byte ) : integer;
4026 function TurnBitOff( value : integer; bit : Byte ) : integer;
4028 implementation
4030 {$IFDEF __GPC__}
4031 {$L 'sdl'} { link sdl.dll.a or libsdl.so or libsdl.a }
4032 {$ENDIF}
4034 function SDL_TABLESIZE(table: PChar): Integer;
4035 begin
4036 Result := SizeOf(table) div SizeOf(table[0]);
4037 end;
4039 procedure SDL_OutOfMemory;
4040 begin
4041 {$IFNDEF WINDOWS}
4042 SDL_Error(SDL_ENOMEM);
4043 {$ENDIF}
4044 end;
4046 function SDL_RWSeek(context: PSDL_RWops; offset: Integer; whence: Integer) : Integer;
4047 begin
4048 Result := context^.seek(context, offset, whence);
4049 end;
4051 function SDL_RWTell(context: PSDL_RWops): Integer;
4052 begin
4053 Result := context^.seek(context, 0, 1);
4054 end;
4056 function SDL_RWRead(context: PSDL_RWops; ptr: Pointer; size: Integer; n: Integer): Integer;
4057 begin
4058 Result := context^.read(context, ptr, size, n);
4059 end;
4061 function SDL_RWWrite(context: PSDL_RWops; ptr: Pointer; size: Integer; n: Integer): Integer;
4062 begin
4063 Result := context^.write(context, ptr, size, n);
4064 end;
4066 function SDL_RWClose(context: PSDL_RWops): Integer;
4067 begin
4068 Result := context^.close(context);
4069 end;
4071 function SDL_LoadWAV(filename: PChar; spec: PSDL_AudioSpec; audio_buf: PUInt8; audiolen: PUInt32): PSDL_AudioSpec;
4072 begin
4073 Result := SDL_LoadWAV_RW(SDL_RWFromFile(filename, 'rb'), 1, spec, audio_buf, audiolen);
4074 end;
4076 function SDL_CDInDrive( status : TSDL_CDStatus ): LongBool;
4077 begin
4078 Result := ord( status ) > ord( CD_ERROR );
4079 end;
4081 procedure FRAMES_TO_MSF(frames: Integer; var M: Integer; var S: Integer; var
4082 F: Integer);
4083 var
4084 value: Integer;
4085 begin
4086 value := frames;
4087 F := value mod CD_FPS;
4088 value := value div CD_FPS;
4089 S := value mod 60;
4090 value := value div 60;
4091 M := value;
4092 end;
4094 function MSF_TO_FRAMES(M: Integer; S: Integer; F: Integer): Integer;
4095 begin
4096 Result := M * 60 * CD_FPS + S * CD_FPS + F;
4097 end;
4099 procedure SDL_VERSION(var X: TSDL_Version);
4100 begin
4101 X.major := SDL_MAJOR_VERSION;
4102 X.minor := SDL_MINOR_VERSION;
4103 X.patch := SDL_PATCHLEVEL;
4104 end;
4106 function SDL_VERSIONNUM(X, Y, Z: Integer): Integer;
4107 begin
4108 Result := X * 1000 + Y * 100 + Z;
4109 end;
4111 function SDL_COMPILEDVERSION: Integer;
4112 begin
4113 Result := SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL
4114 );
4115 end;
4117 function SDL_VERSION_ATLEAST(X, Y, Z: Integer): LongBool;
4118 begin
4119 Result := (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z));
4120 end;
4122 function SDL_LoadBMP(filename: PChar): PSDL_Surface;
4123 begin
4124 Result := SDL_LoadBMP_RW(SDL_RWFromFile(filename, 'rb'), 1);
4125 end;
4127 function SDL_SaveBMP(surface: PSDL_Surface; filename: PChar): Integer;
4128 begin
4129 Result := SDL_SaveBMP_RW(surface, SDL_RWFromFile(filename, 'wb'), 1);
4130 end;
4132 function SDL_BlitSurface(src: PSDL_Surface; srcrect: PSDL_Rect; dst:
4133 PSDL_Surface;
4134 dstrect: PSDL_Rect): Integer;
4135 begin
4136 Result := SDL_UpperBlit(src, srcrect, dst, dstrect);
4137 end;
4139 function SDL_AllocSurface(flags: UInt32; width, height, depth: Integer;
4140 RMask, GMask, BMask, AMask: UInt32): PSDL_Surface;
4141 begin
4142 Result := SDL_CreateRGBSurface(flags, width, height, depth, RMask, GMask,
4143 BMask, AMask);
4144 end;
4146 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
4147 begin
4148 Result := ( ( surface^.offset <> 0 ) or
4149 ( ( surface^.flags and ( SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL ) ) <> 0 ) );
4150 end;
4152 function SDL_LockMutex(mutex: PSDL_mutex): Integer;
4153 begin
4154 Result := SDL_mutexP(mutex);
4155 end;
4157 function SDL_UnlockMutex(mutex: PSDL_mutex): Integer;
4158 begin
4159 Result := SDL_mutexV(mutex);
4160 end;
4162 {$IFDEF WINDOWS}
4163 function _putenv( const variable : Pchar ): Integer;
4164 cdecl; external {$IFDEF __GPC__}name '_putenv'{$ELSE} 'MSVCRT.DLL'{$ENDIF __GPC__};
4165 {$ENDIF}
4168 function SDL_putenv(const variable: PChar): Integer;
4169 begin
4170 {$IFDEF WINDOWS}
4171 Result := _putenv(variable);
4172 {$ENDIF}
4174 {$IFDEF UNIX}
4175 {$IFDEF FPC}
4176 Result := _putenv(variable);
4177 {$ELSE}
4178 Result := libc.putenv(variable);
4179 {$ENDIF}
4180 {$ENDIF}
4181 end;
4183 {$IFDEF WINDOWS}
4184 {$IFNDEF __GPC__}
4185 function getenv( const name : Pchar ): PChar;
4186 cdecl; external {$IFDEF __GPC__}name 'getenv'{$ELSE} 'MSVCRT.DLL'{$ENDIF};
4187 {$ENDIF}
4188 {$ENDIF}
4190 function SDL_getenv(const name: PChar): PChar;
4191 begin
4192 {$IFDEF WINDOWS}
4194 {$IFDEF __GPC__}
4195 Result := getenv( string( name ) );
4196 {$ELSE}
4197 Result := getenv( name );
4198 {$ENDIF}
4200 {$ELSE}
4202 {$IFDEF UNIX}
4204 {$IFDEF FPC}
4205 Result := fpgetenv(name);
4206 {$ELSE}
4207 Result := libc.getenv(name);
4208 {$ENDIF}
4210 {$ELSE UNIX}
4211 {$IFDEF OS2}
4212 DosScanEnv (Name, Result);
4213 {$ENDIF OS2}
4214 {$ENDIF}
4216 {$ENDIF}
4217 end;
4219 function SDL_BUTTON( Button : Integer ) : Integer;
4220 begin
4221 Result := SDL_PRESSED shl ( Button - 1 );
4222 end;
4224 function SDL_Swap32(D: Uint32): Uint32;
4225 begin
4226 Result := ((D shl 24) or ((D shl 8) and $00FF0000) or ((D shr 8) and $0000FF00) or (D shr 24));
4227 end;
4229 procedure FreeAndNil(var Obj);
4230 {$IFNDEF __GPC__}
4231 {$IFNDEF __TMT__}
4232 var
4233 Temp: TObject;
4234 {$ENDIF}
4235 {$ENDIF}
4236 begin
4237 {$IFNDEF __GPC__}
4238 {$IFNDEF __TMT__}
4239 Temp := TObject(Obj);
4240 Pointer(Obj) := nil;
4241 Temp.Free;
4242 {$ENDIF}
4243 {$ENDIF}
4244 end;
4246 { Exit procedure handling }
4247 type
4248 PExitProcInfo = ^TExitProcInfo;
4249 TExitProcInfo = record
4250 Next: PExitProcInfo;
4251 SaveExit: Pointer;
4252 Proc: TProcedure;
4253 end;
4255 var
4256 ExitProcList: PExitProcInfo = nil;
4258 procedure DoExitProc;
4259 var
4260 P: PExitProcInfo;
4261 Proc: TProcedure;
4262 begin
4263 P := ExitProcList;
4264 ExitProcList := P^.Next;
4265 ExitProc := P^.SaveExit;
4266 Proc := P^.Proc;
4267 Dispose(P);
4268 Proc;
4269 end;
4271 procedure AddExitProc(Proc: TProcedure);
4272 var
4273 P: PExitProcInfo;
4274 begin
4275 New(P);
4276 P^.Next := ExitProcList;
4277 P^.SaveExit := ExitProc;
4278 P^.Proc := Proc;
4279 ExitProcList := P;
4280 ExitProc := @DoExitProc;
4281 end;
4283 function IsBitOn( value : integer; bit : Byte ) : boolean;
4284 begin
4285 result := ( ( value and ( 1 shl bit ) ) <> 0 );
4286 end;
4288 function TurnBitOn( value : integer; bit : Byte ) : integer;
4289 begin
4290 result := ( value or ( 1 shl bit ) );
4291 end;
4293 function TurnBitOff( value : integer; bit : Byte ) : integer;
4294 begin
4295 result := ( value and not ( 1 shl bit ) );
4296 end;
4298 end.