DEADSOFTWARE

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