DEADSOFTWARE

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