From 2986623dba809d6a44c7de68f779e0558d784ffc Mon Sep 17 00:00:00 2001 From: Almindor Date: Sun, 1 Jul 2007 11:17:10 +0000 Subject: [PATCH] * synchronize with JEDI-SDL release git-svn-id: trunk@7899 - --- packages/extra/sdl/jedi-sdl.inc | 282 ++- packages/extra/sdl/logger.pas | 17 +- packages/extra/sdl/moduleloader.pas | 2 +- packages/extra/sdl/sdl.pas | 661 ++++--- packages/extra/sdl/sdl_gfx.pas | 1376 +++++++------- packages/extra/sdl/sdl_image.pas | 630 ++++--- packages/extra/sdl/sdl_mixer.pas | 2194 ++++++++++++----------- packages/extra/sdl/sdl_ttf.pas | 70 +- packages/extra/sdl/sdlgameinterface.pas | 19 +- packages/extra/sdl/sdlinput.pas | 251 ++- packages/extra/sdl/sdlticks.pas | 99 +- packages/extra/sdl/sdltruetypefont.pas | 180 +- packages/extra/sdl/sdlutils.pas | 1057 ++++++----- packages/extra/sdl/sdlwindow.pas | 42 +- 14 files changed, 3950 insertions(+), 2930 deletions(-) diff --git a/packages/extra/sdl/jedi-sdl.inc b/packages/extra/sdl/jedi-sdl.inc index 951f7c4a88..0130ad32cc 100644 --- a/packages/extra/sdl/jedi-sdl.inc +++ b/packages/extra/sdl/jedi-sdl.inc @@ -1,5 +1,5 @@ { - $Id: jedi-sdl.inc,v 1.9 2004/12/23 23:42:17 savage Exp $ + $Id: jedi-sdl.inc,v 1.15 2007/05/29 21:30:48 savage Exp $ } {******************************************************************************} { } @@ -74,6 +74,24 @@ { } (* $Log: jedi-sdl.inc,v $ + Revision 1.15 2007/05/29 21:30:48 savage + Changes as suggested by Almindor for 64bit compatibility. + + Revision 1.14 2007/05/20 20:29:11 savage + Initial Changes to Handle 64 Bits + + Revision 1.13 2007/01/21 15:51:45 savage + Added Delphi 2006 support + + Revision 1.12 2006/11/19 18:41:01 savage + removed THREADING ON flag as it is no longer needed in latest versions of FPC. + + Revision 1.11 2006/01/04 00:52:41 drellis + Updated to include defined for ENDIAN values, SDL_BYTEORDER should now be correctly defined depending onthe platform. Code taken from sdl_mixer + + Revision 1.10 2005/05/22 18:42:31 savage + Changes as suggested by Michalis Kamburelis. Thanks again. + Revision 1.9 2004/12/23 23:42:17 savage Applied Patches supplied by Michalis Kamburelis ( THANKS! ), for greater FreePascal compatability. @@ -103,6 +121,199 @@ {.$define Debug} { uncomment for debugging } +{$IFNDEF FPC} + {$IFDEF __GPC__} + {$I-} + {$W-} // turn off GPC warnings + {$X+} + {$ELSE} {__GPC__} + {$IFDEF Debug} + {$F+,D+,Q-,L+,R+,I-,S+,Y+,A+} + {$ELSE} + {$F+,Q-,R-,S-,I-,A+} + {$ENDIF} + {$ENDIF} {__GPC__} +{$ELSE} {FPC} + //{$M+} +{$ENDIF} {FPC} + +{$IFDEF LINUX} +{$DEFINE UNIX} +{$ENDIF} + +{$IFDEF ver70} + {$IFDEF Windows} + {$DEFINE Win16} + {$ENDIF Windows} + {$IFDEF MSDOS} + {$DEFINE NO_EXPORTS} + {$ENDIF MSDOS} + {$IFDEF DPMI} + {$DEFINE BP_DPMI} + {$ENDIF} + {$DEFINE OS_16_BIT} + {$DEFINE __OS_DOS__} +{$ENDIF ver70} + +{$IFDEF ver80} + {$DEFINE Delphi} {Delphi 1.x} + {$DEFINE Delphi16} + {$DEFINE Win16} + {$DEFINE OS_16_BIT} + {$DEFINE __OS_DOS__} +{$ENDIF ver80} + +{$IFDEF ver90} + {$DEFINE Delphi} {Delphi 2.x} + {$DEFINE Delphi32} + {$DEFINE WIN32} + {$DEFINE WINDOWS} +{$ENDIF ver90} + +{$IFDEF ver100} + {$DEFINE Delphi} {Delphi 3.x} + {$DEFINE Delphi32} + {$DEFINE WIN32} + {$DEFINE WINDOWS} +{$ENDIF ver100} + +{$IFDEF ver93} + {$DEFINE Delphi} {C++ Builder 1.x} + {$DEFINE Delphi32} + {$DEFINE WINDOWS} +{$ENDIF ver93} + +{$IFDEF ver110} + {$DEFINE Delphi} {C++ Builder 3.x} + {$DEFINE Delphi32} + {$DEFINE WINDOWS} +{$ENDIF ver110} + +{$IFDEF ver120} + {$DEFINE Delphi} {Delphi 4.x} + {$DEFINE Delphi32} + {$DEFINE Delphi4UP} + {$DEFINE Has_Int64} + {$DEFINE WINDOWS} +{$ENDIF ver120} + +{$IFDEF ver130} + {$DEFINE Delphi} {Delphi 5.x} + {$DEFINE Delphi32} + {$DEFINE Delphi4UP} + {$DEFINE Delphi5UP} + {$DEFINE Has_Int64} + {$DEFINE WINDOWS} +{$ENDIF ver130} + +{$IFDEF ver140} + {$DEFINE Delphi} {Delphi 6.x} + {$DEFINE Delphi32} + {$DEFINE Delphi4UP} + {$DEFINE Delphi5UP} + {$DEFINE Delphi6UP} + {$DEFINE Has_Int64} + {$DEFINE HAS_TYPES} +{$ENDIF ver140} + +{$IFDEF ver150} + {$DEFINE Delphi} {Delphi 7.x} + {$DEFINE Delphi32} + {$DEFINE Delphi4UP} + {$DEFINE Delphi5UP} + {$DEFINE Delphi6UP} + {$DEFINE Delphi7UP} + {$WARN UNSAFE_TYPE OFF} {Disable warning for unsafe types in Delphi 7} + {$DEFINE Has_Int64} + {$DEFINE HAS_TYPES} +{$ENDIF ver150} + +{$IFDEF ver160} + {$DEFINE Delphi} {Delphi 8} + {$DEFINE Delphi32} + {$DEFINE Delphi4UP} + {$DEFINE Delphi5UP} + {$DEFINE Delphi6UP} + {$DEFINE Delphi7UP} + {$DEFINE Delphi8UP} + {$DEFINE Has_Int64} + {$DEFINE HAS_TYPES} +{$ENDIF ver160} + +{$IFDEF ver170} + {$DEFINE Delphi} {Delphi 2005} + {$DEFINE Delphi32} + {$DEFINE Delphi4UP} + {$DEFINE Delphi5UP} + {$DEFINE Delphi6UP} + {$DEFINE Delphi7UP} + {$DEFINE Delphi8UP} + {$DEFINE Delphi9UP} + {$WARN UNSAFE_TYPE OFF} {Disable warning for unsafe types in Delphi 7} + {$DEFINE Has_Int64} + {$DEFINE HAS_TYPES} +{$ENDIF ver170} + +{$IFDEF ver180} + {$DEFINE Delphi} {Delphi 2006} + {$DEFINE Delphi32} + {$DEFINE Delphi4UP} + {$DEFINE Delphi5UP} + {$DEFINE Delphi6UP} + {$DEFINE Delphi7UP} + {$DEFINE Delphi8UP} + {$DEFINE Delphi9UP} + {$DEFINE Delphi10UP} + {$WARN UNSAFE_TYPE OFF} {Disable warning for unsafe types in Delphi 7} + {$DEFINE Has_Int64} + {$DEFINE HAS_TYPES} +{$ENDIF ver180} + +{$IFDEF ver185} + {$DEFINE Delphi} {Delphi 2007} + {$DEFINE Delphi32} + {$DEFINE Delphi4UP} + {$DEFINE Delphi5UP} + {$DEFINE Delphi6UP} + {$DEFINE Delphi7UP} + {$DEFINE Delphi8UP} + {$DEFINE Delphi9UP} + {$DEFINE Delphi10UP} + {$WARN UNSAFE_TYPE OFF} {Disable warning for unsafe types in Delphi 7} + {$DEFINE Has_Int64} + {$DEFINE HAS_TYPES} +{$ENDIF ver180} + +{$IFDEF UNIX} + {$ifdef VER140} // Kylix 1 & 2 + {$DEFINE KYLIX} + {$DEFINE KYLIX1UP} + {$DEFINE KYLIX2UP} + {$DEFINE HAS_TYPES} + {$endif} + + {$ifdef VER150} // Kylix 3 + {$DEFINE KYLIX} + {$DEFINE KYLIX1UP} + {$DEFINE KYLIX2UP} + {$DEFINE KYLIX3UP} + {$DEFINE HAS_TYPES} + {$endif} +{$ENDIF UNIX} + +{$IFDEF VirtualPascal} { Virtual Pascal 2.x } + {$DEFINE Delphi} { Use Delphi Syntax } + {$DEFINE VP2} + {&Delphi+} +{$ENDIF VirtualPascal} + +{$IFDEF Delphi} + {$DEFINE Windows} + {$DEFINE USE_STDCALL} + //{$ALIGN ON} +{$ENDIF Delphi} + +{$IFDEF FPC} {$MODE Delphi} { use Delphi compatibility mode } {$H+} {$PACKRECORDS C} // Added for record @@ -114,14 +325,20 @@ {$DEFINE NO_EXPORTS} {$DEFINE Has_Int64} {$DEFINE NOCRT} - {$IFDEF unix} + {$IFDEF UNIX} {$DEFINE fpc_unix} {$ELSE} {$DEFINE __OS_DOS__} {$ENDIF} - {$IFDEF windows} + {$IFDEF WIN32} {$DEFINE UseWin} {$ENDIF} + {$DEFINE HAS_TYPES} +{$ENDIF FPC} + +{$IFDEF Win16} + {$K+} {smart callbacks} +{$ENDIF Win16} {$IFDEF OS2} {$UNDEF Windows} @@ -129,13 +346,45 @@ {$DEFINE OS_BigMem} {$ENDIF OS2} -{$IFDEF windows} +{$IFDEF __GPC__} + {$UNDEF UseWin} + {$UNDEF USE_STDCALL} {$DEFINE OS_BigMem} -{$ELSE windows} + {$DEFINE NO_EXPORTS} + {$DEFINE NOCRT} + {$DEFINE cdecl attribute(cdecl)} +{$ENDIF} + +{$IFDEF __TMT__} + {$DEFINE OS_BigMem} + {$DEFINE NO_EXPORTS} + {$DEFINE __OS_DOS__} + {$DEFINE UseAT} + {$IFNDEF MSDOS} + {$DEFINE USE_STDCALL} + {$ENDIF} + + {$IFDEF __WIN32__} + {$DEFINE Win32} + {$DEFINE UseWin} + {$DEFINE NOCRT} + {$DEFINE Win32} + {$IFNDEF __CON__} + {$DEFINE Windows} + {$ENDIF} + {$ENDIF} + + {$A+} // Word alignment data + {$OA+} // Objects and structures align +{$ENDIF} + +{$IFDEF Win32} + {$DEFINE OS_BigMem} +{$ELSE Win32} {$IFDEF ver70} {$DEFINE assembler} {$ENDIF} { use 16-bit assembler! } -{$ENDIF windows} +{$ENDIF Win32} { ************************** dos/dos-like platforms **************} {$IFDEF Windows} @@ -166,3 +415,24 @@ {$DEFINE BY_NAME} {$ENDIF} {$ENDIF} + +{$IFNDEF ver70} + {$UNDEF assembler} +{$ENDIF} + +{*************** define LITTLE ENDIAN platforms ********************} + + +{$IFDEF Delphi} +{$DEFINE IA32} +{$ENDIF} + +{$IFDEF KYLIX} +{$DEFINE IA32} +{$ENDIF} + +{$IFDEF FPC} +{$IFDEF FPC_LITTLE_ENDIAN} +{$DEFINE IA32} +{$ENDIF} +{$ENDIF} diff --git a/packages/extra/sdl/logger.pas b/packages/extra/sdl/logger.pas index 933e91af51..ad9b24e6ab 100644 --- a/packages/extra/sdl/logger.pas +++ b/packages/extra/sdl/logger.pas @@ -1,6 +1,6 @@ unit logger; { - $Id: logger.pas,v 1.1 2004/02/05 00:08:20 savage Exp $ + $Id: logger.pas,v 1.2 2006/11/26 16:58:04 savage Exp $ } {******************************************************************************} @@ -63,6 +63,9 @@ unit logger; {******************************************************************************} { $Log: logger.pas,v $ + Revision 1.2 2006/11/26 16:58:04 savage + Modifed to create separate log files. Therefore each instance running from the same directory will have their own individual log file, prepended with a number. + Revision 1.1 2004/02/05 00:08:20 savage Module 1.0 release @@ -107,10 +110,20 @@ implementation { TLogger } constructor TLogger.Create; +var + FileName : string; + FileNo : integer; begin FApplicationName := ExtractFileName( ParamStr(0) ); FApplicationPath := ExtractFilePath( ParamStr(0) ); - AssignFile( FFileHandle, FApplicationPath + ChangeFileExt( FApplicationName, '.log' ) ); + FileName := FApplicationPath + ChangeFileExt( FApplicationName, '.log' ); + FileNo := 0; + while FileExists( FileName ) do + begin + inc( FileNo ); + FileName := FApplicationPath + IntToStr( FileNo ) + ChangeFileExt( FApplicationName, '.log' ) + end; + AssignFile( FFileHandle, FileName ); ReWrite( FFileHandle ); (*inherited Create( FApplicationPath + ChangeFileExt( FApplicationName, '.log' ), fmCreate {$IFNDEF FPC}or fmShareExclusive{$ENDIF} );*) diff --git a/packages/extra/sdl/moduleloader.pas b/packages/extra/sdl/moduleloader.pas index 3592dc1415..56863ea5c2 100644 --- a/packages/extra/sdl/moduleloader.pas +++ b/packages/extra/sdl/moduleloader.pas @@ -59,7 +59,7 @@ interface // each OS gets its own IFDEFed complete code block to make reading easier -{$IFDEF windows} +{$IFDEF WIN32} uses Windows; diff --git a/packages/extra/sdl/sdl.pas b/packages/extra/sdl/sdl.pas index a9175f1bf8..7b443a55ce 100644 --- a/packages/extra/sdl/sdl.pas +++ b/packages/extra/sdl/sdl.pas @@ -1,6 +1,6 @@ unit sdl; { - $Id: sdl.pas,v 1.17 2005/01/03 18:40:59 savage Exp $ + $Id: sdl.pas,v 1.31 2007/05/29 21:30:48 savage Exp $ } {******************************************************************************} @@ -36,10 +36,10 @@ unit sdl; { SDL_loadso.h } { } { The initial developer of this Pascal code was : } -{ Dominqiue Louis } +{ Dominique Louis } { } -{ Portions created by Dominqiue Louis are } -{ Copyright (C) 2000 - 2004 Dominqiue Louis. } +{ Portions created by Dominique Louis are } +{ Copyright (C) 2000 - 2004 Dominique Louis. } { } { } { Contributor(s) } @@ -168,6 +168,42 @@ unit sdl; { } { $Log: sdl.pas,v $ + Revision 1.31 2007/05/29 21:30:48 savage + Changes as suggested by Almindor for 64bit compatibility. + + Revision 1.30 2007/05/29 19:31:03 savage + Fix to TSDL_Overlay structure - thanks David Pethes (aka imcold) + + Revision 1.29 2007/05/20 20:29:11 savage + Initial Changes to Handle 64 Bits + + Revision 1.26 2007/02/11 13:38:04 savage + Added Nintendo DS support - Thanks Dean. + + Revision 1.25 2006/12/02 00:12:52 savage + Updated to latest version + + Revision 1.24 2006/05/18 21:10:04 savage + Added 1.2.10 Changes + + Revision 1.23 2005/12/04 23:17:52 drellis + Added declaration of SInt8 and PSInt8 + + Revision 1.22 2005/05/24 21:59:03 savage + Re-arranged uses clause to work on Win32 and Linux, Thanks again Michalis. + + Revision 1.21 2005/05/22 18:42:31 savage + Changes as suggested by Michalis Kamburelis. Thanks again. + + Revision 1.20 2005/04/10 11:48:33 savage + Changes as suggested by Michalis, thanks. + + Revision 1.19 2005/01/05 01:47:06 savage + Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively. + + Revision 1.18 2005/01/04 23:14:41 savage + Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively. + Revision 1.17 2005/01/03 18:40:59 savage Updated Version number to reflect latest one @@ -244,20 +280,40 @@ unit sdl; interface uses -{$IFDEF windows} +{$IFDEF __GPC__} + system, + {$IFDEF WINDOWS} + wintypes, + {$ELSE} + {$ENDIF} + gpc; +{$ENDIF} + +{$IFDEF HAS_TYPES} + Types{$IFNDEF NDS},{$ELSE};{$ENDIF} +{$ENDIF} + +{$IFDEF WINDOWS} Windows; {$ENDIF} {$IFDEF UNIX} - {$IFDEF Ver1_0} - linux, - {$ELSE} -// pthreads, - baseunix, - unix, - {$ENDIF} - x, - xlib; + {$IFDEF FPC} + pthreads, + baseunix, + {$IFNDEF GP2X} + unix, + {$ELSE} + unix; + {$ENDIF} + {$IFNDEF GP2X} + x, + xlib; + {$ENDIF} + {$ELSE} + Libc, + Xlib; + {$ENDIF} {$ENDIF} {$IFDEF __MACH__} @@ -265,15 +321,20 @@ uses {$ENDIF} const -{$IFDEF windows} +{$IFDEF WINDOWS} SDLLibName = 'SDL.dll'; {$ENDIF} {$IFDEF UNIX} {$IFDEF DARWIN} - SDLLibName = 'libSDL.dylib'; + SDLLibName = 'libSDL-1.2.0.dylib'; + {$linklib libSDL-1.2.0} {$ELSE} + {$IFDEF FPC} SDLLibName = 'libSDL.so'; + {$ELSE} + SDLLibName = 'libSDL-1.2.so.0'; + {$ENDIF} {$ENDIF} {$ENDIF} @@ -281,6 +342,24 @@ const SDLLibName = 'SDL'; {$ENDIF} +{$IFDEF NDS} + SDLLibName = 'libSDL.a'; + {$linklib libSDL.a} + {$linklib libnds9.a} + {$linklib libc.a} + {$linklib libgcc.a} + {$linklib libsysbase.a} +{$ENDIF} + + // SDL_verion.h constants + // Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL + SDL_MAJOR_VERSION = 1; +{$EXTERNALSYM SDL_MAJOR_VERSION} + SDL_MINOR_VERSION = 2; +{$EXTERNALSYM SDL_MINOR_VERSION} + SDL_PATCHLEVEL = 11; +{$EXTERNALSYM SDL_PATCHLEVEL} + // SDL.h constants SDL_INIT_TIMER = $00000001; {$EXTERNALSYM SDL_INIT_TIMER} @@ -423,15 +502,6 @@ const SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN; {$EXTERNALSYM SDL_HAT_LEFTDOWN} - // SDL_verion.h constants - // Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL - SDL_MAJOR_VERSION = 1; -{$EXTERNALSYM SDL_MAJOR_VERSION} - SDL_MINOR_VERSION = 2; -{$EXTERNALSYM SDL_MINOR_VERSION} - SDL_PATCHLEVEL = 8; -{$EXTERNALSYM SDL_PATCHLEVEL} - // SDL_events.h constants SDL_NOEVENT = 0; // Unused (do not remove) {$EXTERNALSYM SDL_NOEVENT} @@ -1044,6 +1114,47 @@ const SDLK_EURO = 321; // Some european keyboards {$EXTERNALSYM SDLK_EURO} +{$IFDEF GP2X} +SDLK_GP2X_UP = 0; +{$EXTERNALSYM SDLK_GP2X_UP} +SDLK_GP2X_UPLEFT = 1; +{$EXTERNALSYM SDLK_GP2X_UPLEFT} +SDLK_GP2X_LEFT = 2; +{$EXTERNALSYM SDLK_GP2X_LEFT} +SDLK_GP2X_DOWNLEFT = 3; +{$EXTERNALSYM SDLK_GP2X_DOWNLEFT} +SDLK_GP2X_DOWN = 4; +{$EXTERNALSYM SDLK_GP2X_DOWN} +SDLK_GP2X_DOWNRIGHT = 5; +{$EXTERNALSYM SDLK_GP2X_DOWNRIGHT} +SDLK_GP2X_RIGHT = 6; +{$EXTERNALSYM SDLK_GP2X_RIGHT} +SDLK_GP2X_UPRIGHT = 7; +{$EXTERNALSYM SDLK_GP2X_UPRIGHT} +SDLK_GP2X_START = 8; +{$EXTERNALSYM SDLK_GP2X_START} +SDLK_GP2X_SELECT = 9; +{$EXTERNALSYM SDLK_GP2X_SELECT} +SDLK_GP2X_L = 10; +{$EXTERNALSYM SDLK_GP2X_L} +SDLK_GP2X_R = 11; +{$EXTERNALSYM SDLK_GP2X_R} +SDLK_GP2X_A = 12; +{$EXTERNALSYM SDLK_GP2X_A} +SDLK_GP2X_B = 13; +{$EXTERNALSYM SDLK_GP2X_B} +SDLK_GP2X_Y = 14; +{$EXTERNALSYM SDLK_GP2X_Y} +SDLK_GP2X_X = 15; +{$EXTERNALSYM SDLK_GP2X_X} +SDLK_GP2X_VOLUP = 16; +{$EXTERNALSYM SDLK_GP2X_VOLUP} +SDLK_GP2X_VOLDOWN = 17; +{$EXTERNALSYM SDLK_GP2X_VOLDOWN} +SDLK_GP2X_CLICK = 18; +{$EXTERNALSYM SDLK_GP2X_CLICK} +{$ENDIF} + // Enumeration of valid key mods (possibly OR'd together) KMOD_NONE = $0000; {$EXTERNALSYM KMOD_NONE} @@ -1218,6 +1329,7 @@ type PUInt8Array = ^TUInt8Array; PUInt8 = ^UInt8; + PPUInt8 = ^PUInt8; UInt8 = Byte; {$EXTERNALSYM UInt8} TUInt8Array = array [0..MAXINT shr 1] of UInt8; @@ -1226,6 +1338,10 @@ type UInt16 = word; {$EXTERNALSYM UInt16} + PSInt8 = ^SInt8; + SInt8 = Shortint; +{$EXTERNALSYM SInt8} + PSInt16 = ^SInt16; SInt16 = smallint; {$EXTERNALSYM SInt16} @@ -1660,7 +1776,7 @@ type {$ENDIF} // The windows custom event structure -{$IFDEF windows} +{$IFDEF WINDOWS} PSDL_SysWMmsg = ^TSDL_SysWMmsg; TSDL_SysWMmsg = record version: TSDL_version; @@ -1678,7 +1794,9 @@ type version : TSDL_version; subsystem : TSDL_SysWm; {$IFDEF FPC} + {$IFNDEF GP2X} event : TXEvent; + {$ENDIF} {$ELSE} event : XEvent; {$ENDIF} @@ -1695,7 +1813,7 @@ type {$ENDIF} // The Windows custom window manager information structure -{$IFDEF windows} +{$IFDEF WINDOWS} PSDL_SysWMinfo = ^TSDL_SysWMinfo; TSDL_SysWMinfo = record version : TSDL_version; @@ -1705,6 +1823,7 @@ type // The Linux custom window manager information structure {$IFDEF Unix} + {$IFNDEF GP2X} TX11 = record display : PDisplay; // The X11 display window : TWindow ; // The X11 display window */ @@ -1720,12 +1839,15 @@ type fswindow : TWindow ; // The X11 fullscreen window */ wmwindow : TWindow ; // The X11 managed input window */ end; - + {$ENDIF} + PSDL_SysWMinfo = ^TSDL_SysWMinfo; TSDL_SysWMinfo = record version : TSDL_version ; subsystem : TSDL_SysWm; + {$IFNDEF GP2X} X11 : TX11; + {$ENDIF} end; {$ELSE} // The generic custom window manager information structure @@ -1824,7 +1946,7 @@ type alpha: UInt8; // Alpha value information (per-surface alpha) end; -{$IFDEF windows} +{$IFDEF WINDOWS} {PPrivate_hwdata = ^TPrivate_hwdata; TPrivate_hwdata = record dd_surface : IDIRECTDRAWSURFACE3; @@ -1924,8 +2046,8 @@ type UnusedBits3: UInt8; // Unused at this point video_mem: UInt32; // The total amount of video memory (in K) vfmt: PSDL_PixelFormat; // Value: The format of the video surface - current_w: Integer; // Value: The current video mode width - current_h: Integer; // Value: The current video mode height + current_w : SInt32; // Value: The current video mode width + current_h : SInt32; // Value: The current video mode height end; // The YUV hardware video overlay @@ -1936,8 +2058,8 @@ type planes: Integer; // Number of planes in the overlay. Usually either 1 or 3 pitches: PUInt16; // An array of pitches, one for each plane. Pitch is the length of a row in bytes. - pixels: PUInt8; - // An array of pointers to teh data of each plane. The overlay should be locked before these pointers are used. + pixels: PPUInt8; + // An array of pointers to the data of each plane. The overlay should be locked before these pointers are used. hw_overlay: UInt32; // This will be set to 1 if the overlay is hardware accelerated. end; @@ -1976,7 +2098,7 @@ type // SDL_mutex.h types -{$IFDEF windows} +{$IFDEF WINDOWS} PSDL_Mutex = ^TSDL_Mutex; TSDL_Mutex = record id: THANDLE; @@ -1994,6 +2116,15 @@ type end; {$ENDIF} +{$IFDEF NDS} + PSDL_mutex = ^TSDL_Mutex; + TSDL_Mutex = record + recursive: Integer; + Owner: UInt32; + sem: PSDL_sem; + end; +{$ENDIF} + {$IFDEF __MACH__} {$define USE_NAMED_SEMAPHORES} // Broken sem_getvalue() in MacOS X Public Beta */ @@ -2001,8 +2132,8 @@ type {$ENDIF} PSDL_semaphore = ^TSDL_semaphore; -{$IFDEF windows} - // windows or Machintosh +{$IFDEF WINDOWS} + // WINDOWS or Machintosh TSDL_semaphore = record id: THANDLE; count: UInt32; @@ -2054,7 +2185,7 @@ PSDL_semaphore = ^TSDL_semaphore; end; // SDL_thread.h types -{$IFDEF windows} +{$IFDEF WINDOWS} TSYS_ThreadHandle = THandle; {$ENDIF} @@ -2062,6 +2193,10 @@ PSDL_semaphore = ^TSDL_semaphore; TSYS_ThreadHandle = pthread_t; {$ENDIF} +{$IFDEF NDS} + TSYS_ThreadHandle = Integer; +{$ENDIF} + { This is the system-independent thread info structure } PSDL_Thread = ^TSDL_Thread; TSDL_Thread = record @@ -2092,17 +2227,34 @@ PSDL_semaphore = ^TSDL_semaphore; TWordArray = array[0..16383] of Word; PPoint = ^TPoint; - TPoint = record - x: Longint; - y: Longint; - end; + {$IFDEF HAS_TYPES} + TPoint = Types.TPoint; + {$ELSE} + {$IFDEF WINDOWS} + {$IFDEF __GPC__} + TPoint = wintypes.TPoint; + {$ELSE} + TPoint = Windows.TPoint; + {$ENDIF} + {$ELSE} + //Can't define TPoint : neither Types nor Windows unit available. + {$ENDIF} + {$ENDIF} PRect = ^TRect; - TRect = record - case Integer of - 0: (Left, Top, Right, Bottom: Integer); - 1: (TopLeft, BottomRight: TPoint); - end; + {$IFDEF HAS_TYPES} + TRect = Types.TRect; + {$ELSE} + {$IFDEF WINDOWS} + {$IFDEF __GPC__} + TRect = wintypes.TRect; + {$ELSE} + TRect = Windows.TRect; + {$ENDIF} + {$ELSE} + //Can't define TRect: neither Types nor Windows unit available. + {$ENDIF} + {$ENDIF} { Generic procedure pointer } TProcedure = procedure; @@ -2117,17 +2269,17 @@ PSDL_semaphore = ^TSDL_semaphore; signal handlers for some commonly ignored fatal signals (like SIGSEGV) } function SDL_Init( flags : UInt32 ) : Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_Init} // This function initializes specific SDL subsystems function SDL_InitSubSystem( flags : UInt32 ) : Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_InitSubSystem'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_InitSubSystem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_InitSubSystem} // This function cleans up specific SDL subsystems procedure SDL_QuitSubSystem( flags : UInt32 ); -cdecl; external {$IFDEF __GPC__}name 'SDL_QuitSubSystem'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_QuitSubSystem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_QuitSubSystem} { This function returns mask of the specified subsystems which have @@ -2135,26 +2287,26 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_QuitSubSystem'{$ELSE} SDLLibName{$ENDI If 'flags' is 0, it returns a mask of all initialized subsystems. } function SDL_WasInit( flags : UInt32 ): UInt32; -cdecl; external {$IFDEF __GPC__}name 'SDL_WasInit'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WasInit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_WasInit} { This function cleans up all initialized subsystems and unloads the dynamically linked library. You should call it upon all exit conditions. } procedure SDL_Quit; -cdecl; external {$IFDEF __GPC__}name 'SDL_Quit'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Quit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_Quit} -{$IFDEF windows} +{$IFDEF WINDOWS} // This should be called from your WinMain() function, if any function SDL_RegisterApp(name: PChar; style: UInt32; h_Inst: Pointer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_RegisterApp'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RegisterApp'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_RegisterApp} {$ENDIF} {$IFDEF __MACH__} // This should be called from your main() function, if any procedure SDL_InitQuickDraw( the_qd: QDGlobals ); -cdecl; external {$IFDEF __GPC__}name 'SDL_InitQuickDraw'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_InitQuickDraw'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_InitQuickDraw} {$ENDIF} @@ -2172,18 +2324,18 @@ function SDL_TableSize( table: PChar ): Integer; {------------------------------------------------------------------------------} // Public functions function SDL_GetError: PChar; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetError'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetError'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetError} procedure SDL_SetError(fmt: PChar); -cdecl; external {$IFDEF __GPC__}name 'SDL_SetError'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetError'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetError} procedure SDL_ClearError; -cdecl; external {$IFDEF __GPC__}name 'SDL_ClearError'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ClearError'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_ClearError} -{$IFNDEF windows} +{$IFNDEF WINDOWS} procedure SDL_Error(Code: TSDL_errorcode); -cdecl; external {$IFDEF __GPC__}name 'SDL_Error'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Error'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_Error} {$ENDIF} @@ -2196,24 +2348,24 @@ procedure SDL_OutOfMemory; // Functions to create SDL_RWops structures from various data sources function SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; -cdecl; external {$IFDEF __GPC__}name 'SDL_RWFromFile'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromFile'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_RWFromFile} procedure SDL_FreeRW(area: PSDL_RWops); -cdecl; external {$IFDEF __GPC__}name 'SDL_FreeRW'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeRW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_FreeRW} //fp is FILE *fp ??? function SDL_RWFromFP(fp: Pointer; autoclose: Integer): PSDL_RWops; -cdecl; external {$IFDEF __GPC__}name 'SDL_RWFromFP'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromFP'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_RWFromFP} function SDL_RWFromMem(mem: Pointer; size: Integer): PSDL_RWops; -cdecl; external {$IFDEF __GPC__}name 'SDL_RWFromMem'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromMem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_RWFromMem} function SDL_RWFromConstMem(const mem: Pointer; size: Integer) : PSDL_RWops; -cdecl; external {$IFDEF __GPC__}name 'SDL_RWFromConstMem'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RWFromConstMem'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_RWFromConstMem} function SDL_AllocRW: PSDL_RWops; -cdecl; external {$IFDEF __GPC__}name 'SDL_AllocRW'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AllocRW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_AllocRW} function SDL_RWSeek(context: PSDL_RWops; offset: Integer; whence: Integer) : Integer; @@ -2234,28 +2386,28 @@ function SDL_RWClose(context: PSDL_RWops): Integer; { Get the number of milliseconds since the SDL library initialization. } { Note that this value wraps if the program runs for more than ~49 days. } function SDL_GetTicks: UInt32; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetTicks'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetTicks'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetTicks} // Wait a specified number of milliseconds before returning procedure SDL_Delay(msec: UInt32); -cdecl; external {$IFDEF __GPC__}name 'SDL_Delay'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Delay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_Delay} { Add a new timer to the pool of timers already running. } { Returns a timer ID, or NULL when an error occurs. } function SDL_AddTimer(interval: UInt32; callback: TSDL_NewTimerCallback; param : Pointer): PSDL_TimerID; -cdecl; external {$IFDEF __GPC__}name 'SDL_AddTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AddTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_AddTimer} { Remove one of the multiple timers knowing its ID. } { Returns a boolean value indicating success. } function SDL_RemoveTimer(t: PSDL_TimerID): TSDL_Bool; -cdecl; external {$IFDEF __GPC__}name 'SDL_RemoveTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_RemoveTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_RemoveTimer} function SDL_SetTimer(interval: UInt32; callback: TSDL_TimerCallback): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SetTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetTimer'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetTimer} {------------------------------------------------------------------------------} @@ -2267,10 +2419,10 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_SetTimer'{$ELSE} SDLLibName{$ENDIF __G You should normally use SDL_Init() or SDL_InitSubSystem(). } function SDL_AudioInit(driver_name: PChar): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_AudioInit'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AudioInit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_AudioInit} procedure SDL_AudioQuit; -cdecl; external {$IFDEF __GPC__}name 'SDL_AudioQuit'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AudioQuit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_AudioQuit} { This function fills the given character buffer with the name of the @@ -2278,7 +2430,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_AudioQuit'{$ELSE} SDLLibName{$ENDIF __ been initialized. It returns NULL if no driver has been initialized. } function SDL_AudioDriverName(namebuf: PChar; maxlen: Integer): PChar; -cdecl; external {$IFDEF __GPC__}name 'SDL_AudioDriverName'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_AudioDriverName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_AudioDriverName} { This function opens the audio device with the desired parameters, and @@ -2322,12 +2474,12 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_AudioDriverName'{$ELSE} SDLLibName{$EN any local mixing buffers after you open the audio device. } function SDL_OpenAudio(desired, obtained: PSDL_AudioSpec): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_OpenAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_OpenAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_OpenAudio} { Get the current audio state: } function SDL_GetAudioStatus: TSDL_Audiostatus; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetAudioStatus'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetAudioStatus'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetAudioStatus} { This function pauses and unpauses the audio callback processing. @@ -2337,7 +2489,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GetAudioStatus'{$ELSE} SDLLibName{$END Silence will be written to the audio device during the pause. } procedure SDL_PauseAudio(pause_on: Integer); -cdecl; external {$IFDEF __GPC__}name 'SDL_PauseAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PauseAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_PauseAudio} { This function loads a WAVE from the data source, automatically freeing @@ -2358,7 +2510,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_PauseAudio'{$ELSE} SDLLibName{$ENDIF _ function SDL_LoadWAV_RW(src: PSDL_RWops; freesrc: Integer; spec: PSDL_AudioSpec; audio_buf: PUInt8; audiolen: PUInt32): PSDL_AudioSpec; -cdecl; external {$IFDEF __GPC__}name 'SDL_LoadWAV_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadWAV_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_LoadWAV_RW} // Compatibility convenience function -- loads a WAV from a file @@ -2369,7 +2521,7 @@ function SDL_LoadWAV(filename: PChar; spec: PSDL_AudioSpec; audio_buf: { This function frees data previously allocated with SDL_LoadWAV_RW() } procedure SDL_FreeWAV(audio_buf: PUInt8); -cdecl; external {$IFDEF __GPC__}name 'SDL_FreeWAV'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeWAV'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_FreeWAV} { This function takes a source format and rate and a destination format @@ -2380,7 +2532,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_FreeWAV'{$ELSE} SDLLibName{$ENDIF __GP function SDL_BuildAudioCVT(cvt: PSDL_AudioCVT; src_format: UInt16; src_channels: UInt8; src_rate: Integer; dst_format: UInt16; dst_channels: UInt8; dst_rate: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_BuildAudioCVT'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_BuildAudioCVT'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_BuildAudioCVT} { Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), @@ -2391,7 +2543,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_BuildAudioCVT'{$ELSE} SDLLibName{$ENDI cvt->buf should be allocated after the cvt structure is initialized by SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. } function SDL_ConvertAudio(cvt: PSDL_AudioCVT): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_ConvertAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ConvertAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_ConvertAudio} { This takes two audio buffers of the playing audio format and mixes @@ -2401,7 +2553,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_ConvertAudio'{$ELSE} SDLLibName{$ENDIF This is provided for convenience -- you can mix your own audio data. } procedure SDL_MixAudio(dst, src: PUInt8; len: UInt32; volume: Integer); -cdecl; external {$IFDEF __GPC__}name 'SDL_MixAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_MixAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_MixAudio} { The lock manipulated by these functions protects the callback function. @@ -2409,16 +2561,16 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_MixAudio'{$ELSE} SDLLibName{$ENDIF __G callback function is not running. Do not call these from the callback function or you will cause deadlock. } procedure SDL_LockAudio; -cdecl; external {$IFDEF __GPC__}name 'SDL_LockAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LockAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_LockAudio} procedure SDL_UnlockAudio; -cdecl; external {$IFDEF __GPC__}name 'SDL_UnlockAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnlockAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_UnlockAudio} { This function shuts down audio processing and closes the audio device. } procedure SDL_CloseAudio; -cdecl; external {$IFDEF __GPC__}name 'SDL_CloseAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CloseAudio'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CloseAudio} {------------------------------------------------------------------------------} @@ -2429,7 +2581,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_CloseAudio'{$ELSE} SDLLibName{$ENDIF _ SDL_Init() has not been called with the SDL_INIT_CDROM flag. } function SDL_CDNumDrives: Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_CDNumDrives'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDNumDrives'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CDNumDrives} { Returns a human-readable, system-dependent identifier for the CD-ROM. @@ -2439,7 +2591,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_CDNumDrives'{$ELSE} SDLLibName{$ENDIF "/dev/disk/ide/1/master" } function SDL_CDName(drive: Integer): PChar; -cdecl; external {$IFDEF __GPC__}name 'SDL_CDName'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CDName} { Opens a CD-ROM drive for access. It returns a drive handle on success, @@ -2449,7 +2601,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_CDName'{$ELSE} SDLLibName{$ENDIF __GPC Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. } function SDL_CDOpen(drive: Integer): PSDL_CD; -cdecl; external {$IFDEF __GPC__}name 'SDL_CDOpen'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDOpen'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CDOpen} { This function returns the current status of the given drive. @@ -2457,7 +2609,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_CDOpen'{$ELSE} SDLLibName{$ENDIF __GPC play position of the CD will be stored in the SDL_CD structure. } function SDL_CDStatus(cdrom: PSDL_CD): TSDL_CDStatus; -cdecl; external {$IFDEF __GPC__}name 'SDL_CDStatus'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDStatus'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CDStatus} { Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' @@ -2484,7 +2636,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_CDStatus'{$ELSE} SDLLibName{$ENDIF __G function SDL_CDPlayTracks(cdrom: PSDL_CD; start_track: Integer; start_frame: Integer; ntracks: Integer; nframes: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_CDPlayTracks'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDPlayTracks'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CDPlayTracks} @@ -2492,32 +2644,32 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_CDPlayTracks'{$ELSE} SDLLibName{$ENDIF It returns 0, or -1 if there was an error. } function SDL_CDPlay(cdrom: PSDL_CD; start: Integer; length: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_CDPlay'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDPlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CDPlay} // Pause play -- returns 0, or -1 on error function SDL_CDPause(cdrom: PSDL_CD): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_CDPause'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDPause'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CDPause} // Resume play -- returns 0, or -1 on error function SDL_CDResume(cdrom: PSDL_CD): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_CDResume'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDResume'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CDResume} // Stop play -- returns 0, or -1 on error function SDL_CDStop(cdrom: PSDL_CD): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_CDStop'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDStop'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CDStop} // Eject CD-ROM -- returns 0, or -1 on error function SDL_CDEject(cdrom: PSDL_CD): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_CDEject'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDEject'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CDEject} // Closes the handle for the CD-ROM drive procedure SDL_CDClose(cdrom: PSDL_CD); -cdecl; external {$IFDEF __GPC__}name 'SDL_CDClose'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CDClose'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CDClose} // Given a status, returns true if there's a disk in the drive @@ -2537,14 +2689,14 @@ function MSF_TO_FRAMES(M: Integer; S: Integer; F: Integer): Integer; { Count the number of joysticks attached to the system } function SDL_NumJoysticks: Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_NumJoysticks'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_NumJoysticks'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_NumJoysticks} { Get the implementation dependent name of a joystick. This can be called before any joysticks are opened. If no name can be found, this function returns NULL. } function SDL_JoystickName(index: Integer): PChar; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickName'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickName} { Open a joystick for use - the index passed as an argument refers to @@ -2553,40 +2705,40 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickName'{$ELSE} SDLLibName{$ENDIF This function returns a joystick identifier, or NULL if an error occurred. } function SDL_JoystickOpen(index: Integer): PSDL_Joystick; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickOpen'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickOpen'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickOpen} { Returns 1 if the joystick has been opened, or 0 if it has not. } function SDL_JoystickOpened(index: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickOpened'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickOpened'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickOpened} { Get the device index of an opened joystick. } function SDL_JoystickIndex(joystick: PSDL_Joystick): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickIndex'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickIndex'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickIndex} { Get the number of general axis controls on a joystick } function SDL_JoystickNumAxes(joystick: PSDL_Joystick): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickNumAxes'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumAxes'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickNumAxes} { Get the number of trackballs on a joystick Joystick trackballs have only relative motion events associated with them and their state cannot be polled. } function SDL_JoystickNumBalls(joystick: PSDL_Joystick): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickNumBalls'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumBalls'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickNumBalls} { Get the number of POV hats on a joystick } function SDL_JoystickNumHats(joystick: PSDL_Joystick): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickNumHats'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumHats'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickNumHats} { Get the number of buttons on a joystick } function SDL_JoystickNumButtons(joystick: PSDL_Joystick): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickNumButtons'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickNumButtons'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickNumButtons} { Update the current state of the open joysticks. @@ -2594,7 +2746,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickNumButtons'{$ELSE} SDLLibName{ events are enabled. } procedure SDL_JoystickUpdate; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickUpdate'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickUpdate'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickUpdate;} { Enable/disable joystick event polling. @@ -2604,7 +2756,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickUpdate'{$ELSE} SDLLibName{$END The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. } function SDL_JoystickEventState(state: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickEventState'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickEventState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickEventState} { Get the current state of an axis control on a joystick @@ -2612,13 +2764,13 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickEventState'{$ELSE} SDLLibName{ The axis indices start at index 0. } function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: Integer) : SInt16; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickGetAxis'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetAxis'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickGetAxis} { The hat indices start at index 0. } function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: Integer): UInt8; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickGetHat'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetHat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickGetHat} { Get the ball axis change since the last poll @@ -2626,18 +2778,18 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickGetHat'{$ELSE} SDLLibName{$END The ball indices start at index 0. } function SDL_JoystickGetBall(joystick: PSDL_Joystick; ball: Integer; var dx: Integer; var dy: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickGetBall'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetBall'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickGetBall} { Get the current state of a button on a joystick The button indices start at index 0. } function SDL_JoystickGetButton( joystick: PSDL_Joystick; Button: Integer): UInt8; -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickGetButton'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickGetButton'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickGetButton} { Close a joystick previously opened with SDL_JoystickOpen() } procedure SDL_JoystickClose(joystick: PSDL_Joystick); -cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickClose'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_JoystickClose'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_JoystickClose} {------------------------------------------------------------------------------} @@ -2649,7 +2801,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_JoystickClose'{$ELSE} SDLLibName{$ENDI This should only be run in the thread that sets the video mode. } procedure SDL_PumpEvents; -cdecl; external {$IFDEF __GPC__}name 'SDL_PumpEvents'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PumpEvents'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_PumpEvents;} { Checks the event queue for messages and optionally returns them. @@ -2665,7 +2817,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_PumpEvents'{$ELSE} SDLLibName{$ENDIF _ if there was an error. This function is thread-safe. } function SDL_PeepEvents(events: PSDL_Event; numevents: Integer; action: TSDL_eventaction; mask: UInt32): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_PeepEvents'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PeepEvents'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_PeepEvents} { Polls for currently pending events, and returns 1 if there are any pending @@ -2673,7 +2825,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_PeepEvents'{$ELSE} SDLLibName{$ENDIF _ event is removed from the queue and stored in that area. } function SDL_PollEvent(event: PSDL_Event): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_PollEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PollEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_PollEvent} { Waits indefinitely for the next available event, returning 1, or 0 if there @@ -2681,11 +2833,11 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_PollEvent'{$ELSE} SDLLibName{$ENDIF __ event is removed from the queue and stored in that area. } function SDL_WaitEvent(event: PSDL_Event): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_WaitEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WaitEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_WaitEvent} function SDL_PushEvent( event : PSDL_Event ) : Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_PushEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_PushEvent'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_PushEvent} { If the filter returns 1, then the event will be added to the internal queue. @@ -2703,14 +2855,14 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_PushEvent'{$ELSE} SDLLibName{$ENDIF __ If the quit event is generated by an interrupt signal, it will bypass the internal queue and be delivered to the application at the next event poll. } procedure SDL_SetEventFilter( filter : TSDL_EventFilter ); -cdecl; external {$IFDEF __GPC__}name 'SDL_SetEventFilter'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetEventFilter'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetEventFilter} { Return the current event filter - can be used to "chain" filters. If there is no event filter set, this function returns NULL. } function SDL_GetEventFilter: TSDL_EventFilter; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetEventFilter'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetEventFilter'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetEventFilter} { This function allows you to set the state of processing certain events. @@ -2721,7 +2873,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GetEventFilter'{$ELSE} SDLLibName{$END current processing state of the specified event. } function SDL_EventState(type_: UInt8; state: Integer): UInt8; -cdecl; external {$IFDEF __GPC__}name 'SDL_EventState'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_EventState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_EventState} {------------------------------------------------------------------------------} @@ -2753,7 +2905,7 @@ function SDL_VERSION_ATLEAST(X: Integer; Y: Integer; Z: Integer) : LongBool; use the SDL_Version() macro. } function SDL_Linked_Version: PSDL_version; -cdecl; external {$IFDEF __GPC__}name 'SDL_Linked_Version'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Linked_Version'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_Linked_Version} {------------------------------------------------------------------------------} @@ -2770,14 +2922,14 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_Linked_Version'{$ELSE} SDLLibName{$END Note that event handling is activated by this routine. If you use both sound and video in your application, you need to call - SDL_Init() before opening the sound device, otherwise under windows DirectX, + SDL_Init() before opening the sound device, otherwise under Win32 DirectX, you won't be able to set full-screen display modes. } function SDL_VideoInit(driver_name: PChar; flags: UInt32): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_VideoInit'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoInit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_VideoInit} procedure SDL_VideoQuit; -cdecl; external {$IFDEF __GPC__}name 'SDL_VideoQuit'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoQuit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_VideoQuit} { This function fills the given character buffer with the name of the @@ -2785,7 +2937,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_VideoQuit'{$ELSE} SDLLibName{$ENDIF __ been initialized. It returns NULL if no driver has been initialized. } function SDL_VideoDriverName(namebuf: PChar; maxlen: Integer): PChar; -cdecl; external {$IFDEF __GPC__}name 'SDL_VideoDriverName'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoDriverName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_VideoDriverName} { This function returns a pointer to the current display surface. @@ -2794,7 +2946,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_VideoDriverName'{$ELSE} SDLLibName{$EN surface. } function SDL_GetVideoSurface: PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetVideoSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetVideoSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetVideoSurface} { This function returns a read-only pointer to information about the @@ -2802,7 +2954,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GetVideoSurface'{$ELSE} SDLLibName{$EN member of the returned structure will contain the pixel format of the "best" video mode. } function SDL_GetVideoInfo: PSDL_VideoInfo; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetVideoInfo'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetVideoInfo'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetVideoInfo} { Check to see if a particular video mode is supported. @@ -2816,7 +2968,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GetVideoInfo'{$ELSE} SDLLibName{$ENDIF SDL_SetVideoMode() } function SDL_VideoModeOK(width, height, bpp: Integer; flags: UInt32): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_VideoModeOK'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_VideoModeOK'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_VideoModeOK} { Return a pointer to an array of available screen dimensions for the @@ -2828,7 +2980,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_VideoModeOK'{$ELSE} SDLLibName{$ENDIF by SDL_GetVideoInfo( ) - > vfmt } function SDL_ListModes(format: PSDL_PixelFormat; flags: UInt32): PPSDL_Rect; -cdecl; external {$IFDEF __GPC__}name 'SDL_ListModes'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ListModes'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_ListModes} @@ -2875,7 +3027,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_ListModes'{$ELSE} SDLLibName{$ENDIF __ This function returns the video framebuffer surface, or NULL if it fails. } function SDL_SetVideoMode(width, height, bpp: Integer; flags: UInt32): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'SDL_SetVideoMode'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetVideoMode'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetVideoMode} @@ -2885,10 +3037,10 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_SetVideoMode'{$ELSE} SDLLibName{$ENDIF These functions should not be called while 'screen' is locked. } procedure SDL_UpdateRects(screen: PSDL_Surface; numrects: Integer; rects: PSDL_Rect); -cdecl; external {$IFDEF __GPC__}name 'SDL_UpdateRects'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UpdateRects'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_UpdateRects} procedure SDL_UpdateRect(screen: PSDL_Surface; x, y: SInt32; w, h: UInt32); -cdecl; external {$IFDEF __GPC__}name 'SDL_UpdateRect'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UpdateRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_UpdateRect} @@ -2902,7 +3054,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_UpdateRect'{$ELSE} SDLLibName{$ENDIF _ This function returns 0 if successful, or -1 if there was an error.} function SDL_Flip(screen: PSDL_Surface): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_Flip'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Flip'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_Flip} { Set the gamma correction for each of the color channels. @@ -2913,7 +3065,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_Flip'{$ELSE} SDLLibName{$ENDIF __GPC__ function returns 0, otherwise it returns -1. } function SDL_SetGamma(redgamma: single; greengamma: single; bluegamma: single ): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SetGamma'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetGamma'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetGamma} { Set the gamma translation table for the red, green, and blue channels @@ -2928,7 +3080,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_SetGamma'{$ELSE} SDLLibName{$ENDIF __G this function will return -1. } function SDL_SetGammaRamp( redtable: PUInt16; greentable: PUInt16; bluetable: PUInt16): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SetGammaRamp'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetGammaRamp'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetGammaRamp} { Retrieve the current values of the gamma translation tables. @@ -2940,7 +3092,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_SetGammaRamp'{$ELSE} SDLLibName{$ENDIF this function will return -1. } function SDL_GetGammaRamp( redtable: PUInt16; greentable: PUInt16; bluetable: PUInt16): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetGammaRamp'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetGammaRamp'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetGammaRamp} { Sets a portion of the colormap for the given 8-bit surface. If 'surface' @@ -2958,13 +3110,8 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GetGammaRamp'{$ELSE} SDLLibName{$ENDIF emulation. } -function SDL_GetPixel(Surface: PSDL_Surface; const x, y: integer): SInt32; {$ifdef fpc} inline; {$endif} - -procedure SDL_PutPixel(Surface: PSDL_Surface; const x, y: integer; pixel: UInt32); {$ifdef fpc} inline; {$endif} - - function SDL_SetColors(surface: PSDL_Surface; colors: PSDL_Color; firstcolor : Integer; ncolors: Integer) : Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SetColors'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetColors'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetColors} { Sets a portion of the colormap for a given 8-bit surface. @@ -2983,27 +3130,27 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_SetColors'{$ELSE} SDLLibName{$ENDIF __ flags = (SDL_LOGPAL or SDL_PHYSPAL). } function SDL_SetPalette(surface: PSDL_Surface; flags: Integer; colors: PSDL_Color; firstcolor: Integer; ncolors: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SetPalette'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetPalette'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetPalette} { Maps an RGB triple to an opaque pixel value for a given pixel format } function SDL_MapRGB(format: PSDL_PixelFormat; r: UInt8; g: UInt8; b: UInt8) : UInt32; -cdecl; external {$IFDEF __GPC__}name 'SDL_MapRGB'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_MapRGB'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_MapRGB} { Maps an RGBA quadruple to a pixel value for a given pixel format } function SDL_MapRGBA(format: PSDL_PixelFormat; r: UInt8; g: UInt8; b: UInt8; a: UInt8): UInt32; -cdecl; external {$IFDEF __GPC__}name 'SDL_MapRGBA'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_MapRGBA'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_MapRGBA} { Maps a pixel value into the RGB components for a given pixel format } procedure SDL_GetRGB(pixel: UInt32; fmt: PSDL_PixelFormat; r: PUInt8; g: PUInt8; b: PUInt8); -cdecl; external {$IFDEF __GPC__}name 'SDL_GetRGB'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetRGB'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetRGB} { Maps a pixel value into the RGBA components for a given pixel format } procedure SDL_GetRGBA(pixel: UInt32; fmt: PSDL_PixelFormat; r: PUInt8; g: PUInt8; b: PUInt8; a: PUInt8); -cdecl; external {$IFDEF __GPC__}name 'SDL_GetRGBA'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetRGBA'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetRGBA} { Allocate and free an RGB surface (must be called after SDL_SetVideoMode) @@ -3044,16 +3191,16 @@ function SDL_AllocSurface(flags: UInt32; width, height, depth: Integer; {$EXTERNALSYM SDL_AllocSurface} function SDL_CreateRGBSurface(flags: UInt32; width, height, depth: Integer; RMask, GMask, BMask, AMask: UInt32): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'SDL_CreateRGBSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateRGBSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CreateRGBSurface} function SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch : Integer; RMask, GMask, BMask, AMask: UInt32): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'SDL_CreateRGBSurfaceFrom'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateRGBSurfaceFrom'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CreateRGBSurfaceFrom} procedure SDL_FreeSurface(surface: PSDL_Surface); -cdecl; external {$IFDEF __GPC__}name 'SDL_FreeSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_FreeSurface} function SDL_MustLock(Surface: PSDL_Surface): Boolean; @@ -3075,11 +3222,11 @@ function SDL_MustLock(Surface: PSDL_Surface): Boolean; SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. } function SDL_LockSurface(surface: PSDL_Surface): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_LockSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LockSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_LockSurface} procedure SDL_UnlockSurface(surface: PSDL_Surface); -cdecl; external {$IFDEF __GPC__}name 'SDL_UnlockSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnlockSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_UnlockSurface} { Load a surface from a seekable SDL data source (memory or file.) @@ -3087,7 +3234,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_UnlockSurface'{$ELSE} SDLLibName{$ENDI Returns the new surface, or NULL if there was an error. The new surface should be freed with SDL_FreeSurface(). } function SDL_LoadBMP_RW(src: PSDL_RWops; freesrc: Integer): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'SDL_LoadBMP_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadBMP_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_LoadBMP_RW} // Convenience macro -- load a surface from a file @@ -3099,7 +3246,7 @@ function SDL_LoadBMP(filename: PChar): PSDL_Surface; Returns 0 if successful or -1 if there was an error. } function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SaveBMP_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SaveBMP_RW'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SaveBMP_RW} // Convenience macro -- save a surface to a file @@ -3115,7 +3262,7 @@ function SDL_SaveBMP(surface: PSDL_Surface; filename: PChar): Integer; This function returns 0, or -1 if there was an error. } function SDL_SetColorKey(surface: PSDL_Surface; flag, key: UInt32) : Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SetColorKey'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetColorKey'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetColorKey} { This function sets the alpha value for the entire surface, as opposed to @@ -3132,7 +3279,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_SetColorKey'{$ELSE} SDLLibName{$ENDIF function SDL_SetAlpha(surface: PSDL_Surface; flag: UInt32; alpha: UInt8): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SetAlpha'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetAlpha'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetAlpha} { Sets the clipping rectangle for the destination surface in a blit. @@ -3146,14 +3293,14 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_SetAlpha'{$ELSE} SDLLibName{$ENDIF __G Note that blits are automatically clipped to the edges of the source and destination surfaces. } procedure SDL_SetClipRect(surface: PSDL_Surface; rect: PSDL_Rect); cdecl; -external {$IFDEF __GPC__}name 'SDL_SetClipRect'{$ELSE} SDLLibName{$ENDIF __GPC__}; +external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetClipRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetClipRect} { Gets the clipping rectangle for the destination surface in a blit. 'rect' must be a pointer to a valid rectangle which will be filled with the correct values. } procedure SDL_GetClipRect(surface: PSDL_Surface; rect: PSDL_Rect); cdecl; -external {$IFDEF __GPC__}name 'SDL_GetClipRect'{$ELSE} SDLLibName{$ENDIF __GPC__}; +external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetClipRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetClipRect} { Creates a new surface of the specified format, and then copies and maps @@ -3168,7 +3315,7 @@ external {$IFDEF __GPC__}name 'SDL_GetClipRect'{$ELSE} SDLLibName{$ENDIF __GPC__ This function is used internally by SDL_DisplayFormat(). } function SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: UInt32): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'SDL_ConvertSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ConvertSurface'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_ConvertSurface} { @@ -3248,13 +3395,13 @@ function SDL_BlitSurface(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surfac { This is the public blit function, SDL_BlitSurface(), and it performs rectangle validation and clipping before passing it to SDL_LowerBlit() } function SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_UpperBlit'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UpperBlit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_UpperBlit} { This is a semi-private blit function and it performs low-level surface blitting only. } function SDL_LowerBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_LowerBlit'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LowerBlit'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_LowerBlit} { This function performs a fast fill of the given rectangle with 'color' @@ -3266,7 +3413,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_LowerBlit'{$ELSE} SDLLibName{$ENDIF __ This function returns 0 on success, or -1 on error. } function SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: UInt32) : Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_FillRect'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FillRect'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_FillRect} { This function takes a surface and copies it to a new surface of the @@ -3280,7 +3427,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_FillRect'{$ELSE} SDLLibName{$ENDIF __G If the conversion fails or runs out of memory, it returns NULL } function SDL_DisplayFormat(surface: PSDL_Surface): PSDL_Surface; cdecl; -external {$IFDEF __GPC__}name 'SDL_DisplayFormat'{$ELSE} SDLLibName{$ENDIF __GPC__}; +external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DisplayFormat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_DisplayFormat} { This function takes a surface and copies it to a new surface of the @@ -3296,7 +3443,7 @@ external {$IFDEF __GPC__}name 'SDL_DisplayFormat'{$ELSE} SDLLibName{$ENDIF __GPC function SDL_DisplayFormatAlpha(surface: PSDL_Surface): PSDL_Surface; cdecl; -external {$IFDEF __GPC__}name 'SDL_DisplayFormatAlpha'{$ELSE} SDLLibName{$ENDIF __GPC__}; +external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DisplayFormatAlpha'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_DisplayFormatAlpha} //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -3309,16 +3456,16 @@ external {$IFDEF __GPC__}name 'SDL_DisplayFormatAlpha'{$ELSE} SDLLibName{$ENDIF is shown is undefined - it may be overwritten with the converted YUV data. } function SDL_CreateYUVOverlay(width: Integer; height: Integer; format: UInt32; display: PSDL_Surface): PSDL_Overlay; -cdecl; external {$IFDEF __GPC__}name 'SDL_CreateYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CreateYUVOverlay} // Lock an overlay for direct access, and unlock it when you are done function SDL_LockYUVOverlay(Overlay: PSDL_Overlay): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_LockYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LockYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_LockYUVOverlay} procedure SDL_UnlockYUVOverlay(Overlay: PSDL_Overlay); cdecl; -external {$IFDEF __GPC__}name 'SDL_UnlockYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}; +external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnlockYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_UnlockYUVOverlay} @@ -3329,12 +3476,12 @@ external {$IFDEF __GPC__}name 'SDL_UnlockYUVOverlay'{$ELSE} SDLLibName{$ENDIF __ that of the overlay, but currently only 2x scaling is supported. } function SDL_DisplayYUVOverlay(Overlay: PSDL_Overlay; dstrect: PSDL_Rect) : Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_DisplayYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DisplayYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_DisplayYUVOverlay} // Free a video overlay procedure SDL_FreeYUVOverlay(Overlay: PSDL_Overlay); -cdecl; external {$IFDEF __GPC__}name 'SDL_FreeYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeYUVOverlay'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_FreeYUVOverlay} {------------------------------------------------------------------------------} @@ -3352,17 +3499,17 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_FreeYUVOverlay'{$ELSE} SDLLibName{$END function SDL_GL_LoadLibrary(filename: PChar): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_GL_LoadLibrary'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_LoadLibrary'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GL_LoadLibrary} { Get the address of a GL function (for extension functions) } function SDL_GL_GetProcAddress(procname: PChar) : Pointer; -cdecl; external {$IFDEF __GPC__}name 'SDL_GL_GetProcAddress'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_GetProcAddress'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GL_GetProcAddress} { Set an attribute of the OpenGL subsystem before intialization. } function SDL_GL_SetAttribute(attr: TSDL_GLAttr; value: Integer) : Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_GL_SetAttribute'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_SetAttribute'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GL_SetAttribute} { Get an attribute of the OpenGL subsystem from the windowing @@ -3374,26 +3521,26 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GL_SetAttribute'{$ELSE} SDLLibName{$EN themselves if they want to retrieve these values. } function SDL_GL_GetAttribute(attr: TSDL_GLAttr; var value: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_GL_GetAttribute'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_GetAttribute'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GL_GetAttribute} { Swap the OpenGL buffers, if double-buffering is supported. } procedure SDL_GL_SwapBuffers; -cdecl; external {$IFDEF __GPC__}name 'SDL_GL_SwapBuffers'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_SwapBuffers'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GL_SwapBuffers;} { Internal functions that should not be called unless you have read and understood the source code for these functions. } procedure SDL_GL_UpdateRects(numrects: Integer; rects: PSDL_Rect); -cdecl; external {$IFDEF __GPC__}name 'SDL_GL_UpdateRects'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_UpdateRects'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GL_UpdateRects} procedure SDL_GL_Lock; -cdecl; external {$IFDEF __GPC__}name 'SDL_GL_Lock'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_Lock'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GL_Lock;} procedure SDL_GL_Unlock; -cdecl; external {$IFDEF __GPC__}name 'SDL_GL_Unlock'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GL_Unlock'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GL_Unlock;} {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} @@ -3402,10 +3549,10 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GL_Unlock'{$ELSE} SDLLibName{$ENDIF __ { Sets/Gets the title and icon text of the display window } procedure SDL_WM_GetCaption(var title : PChar; var icon : PChar); -cdecl; external {$IFDEF __GPC__}name 'SDL_WM_GetCaption'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_GetCaption'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_WM_GetCaption} procedure SDL_WM_SetCaption( const title : PChar; const icon : PChar); -cdecl; external {$IFDEF __GPC__}name 'SDL_WM_SetCaption'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_SetCaption'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_WM_SetCaption} { Sets the icon for the display window. @@ -3413,7 +3560,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_WM_SetCaption'{$ELSE} SDLLibName{$ENDI It takes an icon surface, and a mask in MSB format. If 'mask' is NULL, the entire icon surface will be used as the icon. } procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask: UInt8); -cdecl; external {$IFDEF __GPC__}name 'SDL_WM_SetIcon'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_SetIcon'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_WM_SetIcon} { This function iconifies the window, and returns 1 if it succeeded. @@ -3421,7 +3568,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_WM_SetIcon'{$ELSE} SDLLibName{$ENDIF _ This function is a noop and returns 0 in non-windowed environments. } function SDL_WM_IconifyWindow: Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_WM_IconifyWindow'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_IconifyWindow'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_WM_IconifyWindow} { Toggle fullscreen mode without changing the contents of the screen. @@ -3439,7 +3586,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_WM_IconifyWindow'{$ELSE} SDLLibName{$E This is currently only implemented in the X11 video driver. } function SDL_WM_ToggleFullScreen(surface: PSDL_Surface): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_WM_ToggleFullScreen'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_ToggleFullScreen'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_WM_ToggleFullScreen} { Grabbing means that the mouse is confined to the application window, @@ -3447,7 +3594,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_WM_ToggleFullScreen'{$ELSE} SDLLibName and not interpreted by a window manager, if any. } function SDL_WM_GrabInput(mode: TSDL_GrabMode): TSDL_GrabMode; -cdecl; external {$IFDEF __GPC__}name 'SDL_WM_GrabInput'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WM_GrabInput'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_WM_GrabInput} {------------------------------------------------------------------------------} @@ -3460,7 +3607,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_WM_GrabInput'{$ELSE} SDLLibName{$ENDIF current mouse cursor position. You can pass NULL for either x or y. } function SDL_GetMouseState(var x: Integer; var y: Integer): UInt8; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetMouseState'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetMouseState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetMouseState} { Retrieve the current state of the mouse. @@ -3468,12 +3615,12 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GetMouseState'{$ELSE} SDLLibName{$ENDI be tested using the SDL_BUTTON(X) macros, and x and y are set to the mouse deltas since the last call to SDL_GetRelativeMouseState(). } function SDL_GetRelativeMouseState(var x: Integer; var y: Integer): UInt8; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetRelativeMouseState'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetRelativeMouseState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetRelativeMouseState} { Set the position of the mouse cursor (generates a mouse motion event) } procedure SDL_WarpMouse(x, y: UInt16); -cdecl; external {$IFDEF __GPC__}name 'SDL_WarpMouse'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WarpMouse'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_WarpMouse} { Create a cursor using the specified data and mask (in MSB format). @@ -3488,24 +3635,24 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_WarpMouse'{$ELSE} SDLLibName{$ENDIF __ Cursors created with this function must be freed with SDL_FreeCursor(). } function SDL_CreateCursor(data, mask: PUInt8; w, h, hot_x, hot_y: Integer): PSDL_Cursor; -cdecl; external {$IFDEF __GPC__}name 'SDL_CreateCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CreateCursor} { Set the currently active cursor to the specified one. If the cursor is currently visible, the change will be immediately represented on the display. } procedure SDL_SetCursor(cursor: PSDL_Cursor); -cdecl; external {$IFDEF __GPC__}name 'SDL_SetCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetCursor} { Returns the currently active cursor. } function SDL_GetCursor: PSDL_Cursor; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetCursor} { Deallocates a cursor created with SDL_CreateCursor(). } procedure SDL_FreeCursor(cursor: PSDL_Cursor); -cdecl; external {$IFDEF __GPC__}name 'SDL_FreeCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_FreeCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_FreeCursor} { Toggle whether or not the cursor is shown on the screen. @@ -3514,7 +3661,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_FreeCursor'{$ELSE} SDLLibName{$ENDIF _ before the call, or 0 if it was not. You can query the current state by passing a 'toggle' value of -1. } function SDL_ShowCursor(toggle: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_ShowCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ShowCursor'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_ShowCursor} function SDL_BUTTON( Button : Integer ) : Integer; @@ -3530,19 +3677,18 @@ function SDL_BUTTON( Button : Integer ) : Integer; If 'enable' is -1, the translation state is not changed. It returns the previous state of keyboard translation. } function SDL_EnableUNICODE(enable: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_EnableUNICODE'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_EnableUNICODE'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_EnableUNICODE} { If 'delay' is set to 0, keyboard repeat is disabled. } function SDL_EnableKeyRepeat(delay: Integer; interval: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_EnableKeyRepeat'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_EnableKeyRepeat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_EnableKeyRepeat} -procedure SDL_GetKeyRepeat(delay: Integer; interval: Integer); -cdecl; external {$IFDEF __GPC__}name 'SDL_GetKeyRepeat'{$ELSE} SDLLibName{$ENDIF __GPC__}; +procedure SDL_GetKeyRepeat(delay : PInteger; interval: PInteger); +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetKeyRepeat'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetKeyRepeat} - { Get a snapshot of the current state of the keyboard. Returns an array of keystates, indexed by the SDLK_* syms. Used: @@ -3551,23 +3697,23 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GetKeyRepeat'{$ELSE} SDLLibName{$ENDIF if ( keystate[SDLK_RETURN] ) ... is pressed } function SDL_GetKeyState(numkeys: PInt): PUInt8; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetKeyState'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetKeyState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetKeyState} { Get the current key modifier state } function SDL_GetModState: TSDLMod; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetModState'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetModState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetModState} { Set the current key modifier state This does not change the keyboard state, only the key modifier flags. } procedure SDL_SetModState(modstate: TSDLMod); -cdecl; external {$IFDEF __GPC__}name 'SDL_SetModState'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SetModState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SetModState} { Get the name of an SDL virtual keysym } function SDL_GetKeyName(key: TSDLKey): PChar; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetKeyName'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetKeyName'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetKeyName} {------------------------------------------------------------------------------} @@ -3580,7 +3726,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GetKeyName'{$ELSE} SDLLibName{$ENDIF _ see your application, otherwise it has been iconified or disabled. } function SDL_GetAppState: UInt8; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetAppState'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetAppState'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetAppState} @@ -3589,13 +3735,13 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GetAppState'{$ELSE} SDLLibName{$ENDIF { Create a mutex, initialized unlocked } function SDL_CreateMutex: PSDL_Mutex; -cdecl; external {$IFDEF __GPC__}name 'SDL_CreateMutex'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateMutex'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CreateMutex} { Lock the mutex (Returns 0, or -1 on error) } function SDL_mutexP(mutex: PSDL_mutex): Integer; - cdecl; external {$IFDEF __GPC__}name 'SDL_mutexP'{$ELSE} SDLLibName{$ENDIF __GPC__}; + cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_mutexP'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; { $ EXTERNALSYM SDL_mutexP} function SDL_LockMutex(mutex: PSDL_mutex): Integer; @@ -3603,7 +3749,7 @@ function SDL_LockMutex(mutex: PSDL_mutex): Integer; { Unlock the mutex (Returns 0, or -1 on error) } function SDL_mutexV(mutex: PSDL_mutex): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_mutexV'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_mutexV'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_mutexV} function SDL_UnlockMutex(mutex: PSDL_mutex): Integer; @@ -3611,7 +3757,7 @@ function SDL_UnlockMutex(mutex: PSDL_mutex): Integer; { Destroy a mutex } procedure SDL_DestroyMutex(mutex: PSDL_mutex); -cdecl; external {$IFDEF __GPC__}name 'SDL_DestroyMutex'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DestroyMutex'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_DestroyMutex} { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * } @@ -3619,13 +3765,13 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_DestroyMutex'{$ELSE} SDLLibName{$ENDIF { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * } { Create a semaphore, initialized with value, returns NULL on failure. } function SDL_CreateSemaphore(initial_value: UInt32): PSDL_Sem; -cdecl; external {$IFDEF __GPC__}name 'SDL_CreateSemaphore'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateSemaphore'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CreateSemaphore} { Destroy a semaphore } procedure SDL_DestroySemaphore(sem: PSDL_sem); -cdecl; external {$IFDEF __GPC__}name 'SDL_DestroySemaphore'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DestroySemaphore'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_DestroySemaphore} { This function suspends the calling thread until the semaphore pointed @@ -3633,14 +3779,14 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_DestroySemaphore'{$ELSE} SDLLibName{$E count. } function SDL_SemWait(sem: PSDL_sem): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SemWait'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemWait'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SemWait} { Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. } function SDL_SemTryWait(sem: PSDL_sem): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SemTryWait'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemTryWait'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SemTryWait} { Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if @@ -3650,20 +3796,20 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_SemTryWait'{$ELSE} SDLLibName{$ENDIF _ of 1 ms, and so should be avoided if possible. } function SDL_SemWaitTimeout(sem: PSDL_sem; ms: UInt32): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SemWaitTimeout'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemWaitTimeout'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SemTryWait} { Atomically increases the semaphore's count (not blocking), returns 0, or -1 on error. } function SDL_SemPost(sem: PSDL_sem): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_SemPost'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemPost'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SemTryWait} { Returns the current count of the semaphore } function SDL_SemValue(sem: PSDL_sem): UInt32; -cdecl; external {$IFDEF __GPC__}name 'SDL_SemValue'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_SemValue'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_SemValue} { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * } @@ -3671,26 +3817,26 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_SemValue'{$ELSE} SDLLibName{$ENDIF __G { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * } { Create a condition variable } function SDL_CreateCond: PSDL_Cond; -cdecl; external {$IFDEF __GPC__}name 'SDL_CreateCond'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateCond'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CreateCond} { Destroy a condition variable } procedure SDL_DestroyCond(cond: PSDL_Cond); -cdecl; external {$IFDEF __GPC__}name 'SDL_DestroyCond'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_DestroyCond'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_DestroyCond} { Restart one of the threads that are waiting on the condition variable, returns 0 or -1 on error. } function SDL_CondSignal(cond: PSDL_cond): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_CondSignal'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondSignal'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CondSignal} { Restart all threads that are waiting on the condition variable, returns 0 or -1 on error. } function SDL_CondBroadcast(cond: PSDL_cond): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_CondBroadcast'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondBroadcast'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CondBroadcast} @@ -3699,7 +3845,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_CondBroadcast'{$ELSE} SDLLibName{$ENDI Returns 0 when it is signaled, or -1 on error. } function SDL_CondWait(cond: PSDL_cond; mut: PSDL_mutex): Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_CondWait'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondWait'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CondWait} { Waits for at most 'ms' milliseconds, and returns 0 if the condition @@ -3709,7 +3855,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_CondWait'{$ELSE} SDLLibName{$ENDIF __G of 1 ms, and so should be avoided if possible. } function SDL_CondWaitTimeout(cond: PSDL_cond; mut: PSDL_mutex; ms: UInt32) : Integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_CondWaitTimeout'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CondWaitTimeout'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CondWaitTimeout} { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * } @@ -3718,18 +3864,18 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_CondWaitTimeout'{$ELSE} SDLLibName{$EN { Create a thread } function SDL_CreateThread(fn: PInt; data: Pointer): PSDL_Thread; -cdecl; external {$IFDEF __GPC__}name 'SDL_CreateThread'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_CreateThread'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_CreateThread} { Get the 32-bit thread identifier for the current thread } function SDL_ThreadID: UInt32; -cdecl; external {$IFDEF __GPC__}name 'SDL_ThreadID'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_ThreadID'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_ThreadID} { Get the 32-bit thread identifier for the specified thread, equivalent to SDL_ThreadID() if the specified thread is NULL. } function SDL_GetThreadID(thread: PSDL_Thread): UInt32; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetThreadID'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetThreadID'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetThreadID} { Wait for a thread to finish. @@ -3737,18 +3883,18 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GetThreadID'{$ELSE} SDLLibName{$ENDIF pointed to by 'status', if 'status' is not NULL. } procedure SDL_WaitThread(thread: PSDL_Thread; var status: Integer); -cdecl; external {$IFDEF __GPC__}name 'SDL_WaitThread'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_WaitThread'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_WaitThread} { Forcefully kill a thread without worrying about its state } procedure SDL_KillThread(thread: PSDL_Thread); -cdecl; external {$IFDEF __GPC__}name 'SDL_KillThread'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_KillThread'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_KillThread} {------------------------------------------------------------------------------} { Get Environment Routines } {------------------------------------------------------------------------------} -{$IFDEF windows} +{$IFDEF WINDOWS} function _putenv( const variable : Pchar ): integer; cdecl; {$ENDIF} @@ -3761,7 +3907,7 @@ cdecl; external 'libc.so' name 'putenv'; {$ENDIF} { Put a variable of the form "name=value" into the environment } -//function SDL_putenv(const variable: PChar): integer; cdecl; external {$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}SDLLibName name ''; +//function SDL_putenv(const variable: PChar): integer; cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}SDLLibName name ''; function SDL_putenv(const variable: PChar): integer; {$EXTERNALSYM SDL_putenv} @@ -3770,14 +3916,14 @@ function SDL_putenv(const variable: PChar): integer; //function putenv(const variable: PChar): integer; //{$EXTERNALSYM putenv} -{$IFDEF windows} +{$IFDEF WINDOWS} {$IFNDEF __GPC__} function getenv( const name : Pchar ): PChar; cdecl; {$ENDIF} {$ENDIF} {* Retrieve a variable named "name" from the environment } -//function SDL_getenv(const name: PChar): PChar; cdecl; external {$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}SDLLibName name ''; +//function SDL_getenv(const name: PChar): PChar; cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_Init'{$ELSE} SDLLibName{$ENDIF __GPC__}SDLLibName name ''; function SDL_getenv(const name: PChar): PChar; {$EXTERNALSYM SDL_getenv} @@ -3793,7 +3939,7 @@ function SDL_getenv(const name: PChar): PChar; * the version member of the 'info' structure is invalid, it returns 0. *} function SDL_GetWMInfo(info : PSDL_SysWMinfo) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_GetWMInfo'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_GetWMInfo'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_GetWMInfo} {------------------------------------------------------------------------------} @@ -3804,7 +3950,7 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_GetWMInfo'{$ELSE} SDLLibName{$ENDIF __ * The 'sofile' parameter is a system dependent name of the object file. *} function SDL_LoadObject( const sofile : PChar ) : Pointer; -cdecl; external {$IFDEF __GPC__}name 'SDL_LoadObject'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadObject'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_LoadObject} {* Given an object handle, this function looks up the address of the @@ -3812,12 +3958,12 @@ cdecl; external {$IFDEF __GPC__}name 'SDL_LoadObject'{$ELSE} SDLLibName{$ENDIF _ * is no longer valid after calling SDL_UnloadObject(). *} function SDL_LoadFunction( handle : Pointer; const name : PChar ) : Pointer; -cdecl; external {$IFDEF __GPC__}name 'SDL_LoadFunction'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_LoadFunction'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_LoadFunction} {* Unload a shared object from memory *} procedure SDL_UnloadObject( handle : Pointer ); -cdecl; external {$IFDEF __GPC__}name 'SDL_UnloadObject'{$ELSE} SDLLibName{$ENDIF __GPC__}; +cdecl; external {$IFNDEF NDS}{$IFDEF __GPC__}name 'SDL_UnloadObject'{$ELSE} SDLLibName{$ENDIF __GPC__}{$ENDIF}; {$EXTERNALSYM SDL_UnloadObject} @@ -3859,56 +4005,11 @@ end; procedure SDL_OutOfMemory; begin - {$IFNDEF windows} + {$IFNDEF WINDOWS} SDL_Error(SDL_ENOMEM); {$ENDIF} end; -function SDL_GetPixel(Surface: PSDL_Surface; const x, y: integer): SInt32;{$ifdef fpc} inline; {$endif} -var bits: PByte; - Bpp: UInt32; - r, g, b: byte; -begin - assert(x>=0); - assert(x=0); - assert(x> N) -function SDL_imageFilterShiftRight(Src1 : PChar; Dest : PChar; length : integer; N : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterShiftRight} - -// SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N) -function SDL_imageFilterShiftRightUint(Src1 : PChar; Dest : PChar; length : integer; N : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftRightUint'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterShiftRightUint} - -// SDL_imageFilterMultByByte: D = saturation255(S * C) -function SDL_imageFilterMultByByte(Src1 : PChar; Dest : PChar; length : integer; C : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMultByByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterMultByByte} - -// SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C) -function SDL_imageFilterShiftRightAndMultByByte(Src1 : PChar; Dest : PChar; length : integer; - N : char; C : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftRightAndMultByByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterShiftRightAndMultByByte} - -// SDL_imageFilterShiftLeftByte: D = (S << N) -function SDL_imageFilterShiftLeftByte(Src1 : PChar; Dest : PChar; length : integer; - N : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftLeftByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterShiftLeftByte} - -// SDL_imageFilterShiftLeftUint: D = ((uint)S << N) -function SDL_imageFilterShiftLeftUint(Src1 : PChar; Dest : PChar; length : integer; - N : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftLeftUint'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterShiftLeftUint} - -// SDL_imageFilterShiftLeft: D = saturation255(S << N) -function SDL_imageFilterShiftLeft(Src1 : PChar; Dest : PChar; length : integer; N : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftLeft'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterShiftLeft} - -// SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0 -function SDL_imageFilterBinarizeUsingThreshold(Src1 : PChar; Dest : PChar; length : integer; - T : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterBinarizeUsingThreshold'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterBinarizeUsingThreshold} - -// SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0 -function SDL_imageFilterClipToRange(Src1 : PChar; Dest : PChar; length : integer; - Tmin : Byte; Tmax : Byte ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterClipToRange'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterClipToRange} - -// SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin) -function SDL_imageFilterNormalizeLinear(Src1 : PChar; Dest : PChar; length : integer; Cmin : integer; - Cmax : integer; Nmin : integer; Nmax : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterClipToRange'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterClipToRange} - -{ !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! } - -// SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... ) -function SDL_imageFilterConvolveKernel3x3Divide(Src : PChar; Dest : PChar; rows : integer; - columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel3x3Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterConvolveKernel3x3Divide} - -// SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... ) -function SDL_imageFilterConvolveKernel5x5Divide(Src : PChar; Dest : PChar; rows : integer; - columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel5x5Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterConvolveKernel5x5Divide} - -// SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... ) -function SDL_imageFilterConvolveKernel7x7Divide(Src : PChar; Dest : PChar; rows : integer; - columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel7x7Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterConvolveKernel7x7Divide} - -// SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... ) -function SDL_imageFilterConvolveKernel9x9Divide(Src : PChar; Dest : PChar; rows : integer; - columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel9x9Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterConvolveKernel9x9Divide} - -// SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... ) -function SDL_imageFilterConvolveKernel3x3ShiftRight(Src : PChar; Dest : PChar; rows : integer; - columns : integer; Kernel : PShortInt; - NRightShift : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel3x3ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterConvolveKernel3x3ShiftRight} - -// SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... ) -function SDL_imageFilterConvolveKernel5x5ShiftRight(Src : PChar; Dest : PChar; rows : integer; - columns : integer; Kernel : PShortInt; - NRightShift : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel5x5ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterConvolveKernel5x5ShiftRight} - -// SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... ) -function SDL_imageFilterConvolveKernel7x7ShiftRight(Src : PChar; Dest : PChar; rows : integer; - columns : integer; Kernel : PShortInt; - NRightShift : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel7x7ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterConvolveKernel7x7ShiftRight} - -// SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... ) -function SDL_imageFilterConvolveKernel9x9ShiftRight(Src : PChar; Dest : PChar; rows : integer; - columns : integer; Kernel : PShortInt; - NRightShift : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel9x9ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterConvolveKernel9x9ShiftRight} - -// SDL_imageFilterSobelX: Dij = saturation255( ... ) -function SDL_imageFilterSobelX(Src : PChar; Dest : PChar; rows : integer; columns : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSobelX'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterSobelX} - -// SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... ) -function SDL_imageFilterSobelXShiftRight(Src : PChar; Dest : PChar; rows : integer; columns : integer; - NRightShift : char ) : integer; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSobelXShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterSobelXShiftRight} - -// Align/restore stack to 32 byte boundary -- Functionality untested! -- -procedure SDL_imageFilterAlignStack; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterAlignStack'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterAlignStack} - -procedure SDL_imageFilterRestoreStack; -cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterRestoreStack'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM SDL_imageFilterRestoreStack} - -{ - - SDL_rotozoom - rotozoomer - - LGPL (c) A. Schiffler - -} - -{ - - rotozoomSurface() - - Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface. - 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1 - then the destination 32bit surface is anti-aliased. If the surface is not 8bit - or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly. - -} - -function rotozoomSurface( src : PSDL_Surface; angle : double; zoom : double; smooth : integer ) : PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'rotozoomSurface'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM rotozoomSurface} - -function rotozoomSurfaceXY( src : PSDL_Surface; angle : double; zoomx : double; zoomy : double; smooth : integer ) : PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'rotozoomSurfaceXY'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM rotozoomSurfaceXY} - -{ Returns the size of the target surface for a rotozoomSurface() call } - -procedure rotozoomSurfaceSize( width : integer; height : integer; angle : double; zoom : double; var dstwidth : integer; - var dstheight : integer ); -cdecl; external {$IFDEF __GPC__}name 'rotozoomSurfaceSize'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM rotozoomSurfaceSize} - -procedure rotozoomSurfaceSizeXY - ( width : integer; height : integer; angle : double; zoomx : double; zoomy : double; - var dstwidth : integer; var dstheight : integer ); -cdecl; external {$IFDEF __GPC__}name 'rotozoomSurfaceSizeXY'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM rotozoomSurfaceSizeXY} - -{ - - zoomSurface() - - Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface. - 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1 - then the destination 32bit surface is anti-aliased. If the surface is not 8bit - or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly. - -} - -function zoomSurface(src : PSDL_Surface; zoomx : double; zoomy : double; smooth : integer ) : PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'zoomSurface'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM zoomSurface} - -{ Returns the size of the target surface for a zoomSurface() call } - -procedure zoomSurfaceSize( width : integer; height : integer; zoomx : double; zoomy : double; var dstwidth : integer; var dstheight : integer ); -cdecl; external {$IFDEF __GPC__}name 'zoomSurfaceSize'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; -{$EXTERNALSYM zoomSurfaceSize} - -implementation - -end. +unit sdl_gfx; +{ + $Id: sdl_gfx.pas,v 1.3 2007/05/29 21:31:04 savage Exp $ + +} +{ + $Log: sdl_gfx.pas,v $ + Revision 1.3 2007/05/29 21:31:04 savage + Changes as suggested by Almindor for 64bit compatibility. + + Revision 1.2 2007/05/20 20:30:18 savage + Initial Changes to Handle 64 Bits + + Revision 1.1 2005/01/03 19:08:32 savage + Header for the SDL_Gfx library. + + + +} + +{$I jedi-sdl.inc} + +interface + +uses + sdl; + +const +{$IFDEF WINDOWS} + SDLgfxLibName = 'SDL_gfx.dll'; +{$ENDIF} + +{$IFDEF UNIX} +{$IFDEF DARWIN} + SDLgfxLibName = 'libSDL_gfx.dylib'; +{$ELSE} + SDLgfxLibName = 'libSDL_gfx.so'; +{$ENDIF} +{$ENDIF} + +{$IFDEF MACOS} + SDLgfxLibName = 'SDL_gfx'; +{$ENDIF} + + // Some rates in Hz + FPS_UPPER_LIMIT = 200; + FPS_LOWER_LIMIT = 1; + FPS_DEFAULT = 30; + +// ---- Defines + + SMOOTHING_OFF = 0; + SMOOTHING_ON = 1; + + + +type + PFPSmanager = ^TFPSmanager; + TFPSmanager = packed record + framecount : Uint32; + rateticks : single; + lastticks : Uint32; + rate : Uint32; + end; + +// ---- Structures + PColorRGBA = ^TColorRGBA; + TColorRGBA = packed record + r : Uint8; + g : Uint8; + b : Uint8; + a : Uint8; + end; + + PColorY = ^TColorY; + TColorY = packed record + y : Uint8; + end; + +{ + + SDL_framerate: framerate manager + + LGPL (c) A. Schiffler + +} + +procedure SDL_initFramerate( manager : PFPSmanager ); +cdecl; external {$IFDEF __GPC__}name 'SDL_initFramerate'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_initFramerate} + +function SDL_setFramerate( manager : PFPSmanager; rate : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_setFramerate'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_setFramerate} + +function SDL_getFramerate( manager : PFPSmanager ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_getFramerate'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_getFramerate} + +procedure SDL_framerateDelay( manager : PFPSmanager ); +cdecl; external {$IFDEF __GPC__}name 'SDL_framerateDelay'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_framerateDelay} + +{ + + SDL_gfxPrimitives: graphics primitives for SDL + + LGPL (c) A. Schiffler + +} + +// Note: all ___Color routines expect the color to be in format 0xRRGGBBAA + +// Pixel + +function pixelColor( dst : PSDL_Surface; x : Sint16; y : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'pixelColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM pixelColor} + +function pixelRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'pixelRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM pixelRGBA} + +// Horizontal line + +function hlineColor( dst : PSDL_Surface; x1: Sint16; x2 : Sint16; y : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'hlineColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM hlineColor} + +function hlineRGBA( dst : PSDL_Surface; x1: Sint16; x2 : Sint16; y : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'hlineRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM hlineRGBA} + +// Vertical line + +function vlineColor( dst : PSDL_Surface; x : Sint16; y1 : Sint16; y2 : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'vlineColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM vlineColor} + +function vlineRGBA( dst : PSDL_Surface; x : Sint16; y1 : Sint16; y2 : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'vlineRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM vlineRGBA} + +// Rectangle + +function rectangleColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'rectangleColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM rectangleColor} + +function rectangleRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; + x2 : Sint16; y2 : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'rectangleRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM rectangleRGBA} + +// Filled rectangle (Box) + +function boxColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'boxColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM boxColor} + +function boxRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; + y2 : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'boxRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM boxRGBA} + +// Line + +function lineColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'lineColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM lineColor} + +function lineRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; + x2 : Sint16; y2 : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'lineRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM lineRGBA} + +// AA Line +function aalineColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'aalineColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM aalineColor} + +function aalineRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; + x2 : Sint16; y2 : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'aalineRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM aalineRGBA} + +// Circle + +function circleColor( dst : PSDL_Surface; x : Sint16; y : Sint16; r : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'circleColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM circleColor} + +function circleRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; rad : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'circleRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM circleRGBA} + +// AA Circle + +function aacircleColor( dst : PSDL_Surface; x : Sint16; y : Sint16; r : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'aacircleColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM aacircleColor} + +function aacircleRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; + rad : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'aacircleRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM aacircleRGBA} + +// Filled Circle + +function filledCircleColor( dst : PSDL_Surface; x : Sint16; y : Sint16; r : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'filledCircleColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM filledCircleColor} + +function filledCircleRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; + rad : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'filledCircleRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM filledCircleRGBA} + +// Ellipse + +function ellipseColor( dst : PSDL_Surface; x : Sint16; y : Sint16; rx : Sint16; ry : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'ellipseColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM ellipseColor} + +function ellipseRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; + rx : Sint16; ry : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'ellipseRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM ellipseRGBA} + +// AA Ellipse + +function aaellipseColor( dst : PSDL_Surface; xc : Sint16; yc : Sint16; rx : Sint16; ry : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'aaellipseColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM aaellipseColor} + +function aaellipseRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; + rx : Sint16; ry : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'aaellipseRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM aaellipseRGBA} + +// Filled Ellipse + +function filledEllipseColor( dst : PSDL_Surface; x : Sint16; y : Sint16; rx : Sint16; ry : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'filledEllipseColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM filledEllipseColor} + +function filledEllipseRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; + rx : Sint16; ry : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'filledEllipseRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM filledEllipseRGBA} + +// Pie + +function pieColor( dst : PSDL_Surface; x : Sint16; y : Sint16; rad : Sint16; + start : Sint16; finish : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'pieColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM pieColor} + +function pieRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; rad : Sint16; + start : Sint16; finish : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'pieRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM pieRGBA} + +// Filled Pie + +function filledPieColor( dst : PSDL_Surface; x : Sint16; y : Sint16; rad : Sint16; + start : Sint16; finish : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'filledPieColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM filledPieColor} + +function filledPieRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; rad : Sint16; + start : Sint16; finish : Sint16; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'filledPieRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM filledPieRGBA} + +// Trigon + +function trigonColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'trigonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM trigonColor} + +function trigonRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16; + r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'trigonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM trigonRGBA} + +// AA-Trigon + +function aatrigonColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'aatrigonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM aatrigonColor} +function aatrigonRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16; + r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'aatrigonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM aatrigonRGBA} + +// Filled Trigon + +function filledTrigonColor( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'filledTrigonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM filledTrigonColor} + +function filledTrigonRGBA( dst : PSDL_Surface; x1 : Sint16; y1 : Sint16; x2 : Sint16; y2 : Sint16; x3 : Sint16; y3 : Sint16; + r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'filledTrigonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM filledTrigonRGBA} + +// Polygon + +function polygonColor( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16; n : integer; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'polygonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM polygonColor} + +function polygonRGBA( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16; + n : integer; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'polygonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM polygonRGBA} + +// AA-Polygon + +function aapolygonColor( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16; n : integer; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'aapolygonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM aapolygonColor} + +function aapolygonRGBA( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16; + n : integer; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'aapolygonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM aapolygonRGBA} + +// Filled Polygon + +function filledPolygonColor( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16; n : integer; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'filledPolygonColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM filledPolygonColor} + +function filledPolygonRGBA( dst : PSDL_Surface; const vx : PSint16; + const vy : PSint16; n : integer; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'filledPolygonRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM filledPolygonRGBA} + +// Bezier +// s = number of steps + +function bezierColor( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16; n : integer; s : integer; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'bezierColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM bezierColor} + +function bezierRGBA( dst : PSDL_Surface; const vx : PSint16; const vy : PSint16; + n : integer; s : integer; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'bezierRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM bezierRGBA} + + +// Characters/Strings + +function characterColor( dst : PSDL_Surface; x : Sint16; y : Sint16; c : char; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'characterColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM characterColor} + +function characterRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; c : char; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'characterRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM characterRGBA} + +function stringColor( dst : PSDL_Surface; x : Sint16; y : Sint16; const c : PChar; color : Uint32 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'stringColor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM stringColor} + +function stringRGBA( dst : PSDL_Surface; x : Sint16; y : Sint16; const c : PChar; r : Uint8; g : Uint8; b : Uint8; a : Uint8 ) : integer; +cdecl; external {$IFDEF __GPC__}name 'stringRGBA'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM stringRGBA} + +procedure gfxPrimitivesSetFont(const fontdata : Pointer; cw : integer; ch : integer ); +cdecl; external {$IFDEF __GPC__}name 'gfxPrimitivesSetFont'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM gfxPrimitivesSetFont} + +{ + + SDL_imageFilter - bytes-image "filter" routines + (uses inline x86 MMX optimizations if available) + + LGPL (c) A. Schiffler + +} + +{ Comments: } +{ 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. } +{ 2.) Data that is not within an 8 byte boundary is processed using the C routine. } +{ 3.) Convolution routines do not have C routines at this time. } + +// Detect MMX capability in CPU +function SDL_imageFilterMMXdetect : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMMXdetect'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterMMXdetect} + +// Force use of MMX off (or turn possible use back on) +procedure SDL_imageFilterMMXoff; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMMXoff'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterMMXoff} + +procedure SDL_imageFilterMMXon; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMMXon'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterMMXon} + +// +// All routines return: +// 0 OK +// -1 Error (internal error, parameter error) +// + +// SDL_imageFilterAdd: D = saturation255(S1 + S2) +function SDL_imageFilterAdd(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imaSDL_imageFilterAddgeFilterMMXon'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterAdd} + +// SDL_imageFilterMean: D = S1/2 + S2/2 +function SDL_imageFilterMean(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMean'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterMean} + +// SDL_imageFilterSub: D = saturation0(S1 - S2) +function SDL_imageFilterSub(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSub'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterSub} + +// SDL_imageFilterAbsDiff: D = | S1 - S2 | +function SDL_imageFilterAbsDiff(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterAbsDiff'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterAbsDiff} + +// SDL_imageFilterMult: D = saturation(S1 * S2) +function SDL_imageFilterMult(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMult'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterMult} + +// SDL_imageFilterMultNor: D = S1 * S2 (non-MMX) +function SDL_imageFilterMultNor(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMultNor'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterMultNor} + +// SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2) +function SDL_imageFilterMultDivby2(Src1 : PChar; Src2 : PChar; Dest : PChar; + length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMultDivby2'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterMultDivby2} + +// SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2) +function SDL_imageFilterMultDivby4(Src1 : PChar; Src2 : PChar; Dest : PChar; + length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMultDivby4'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterMultDivby4} + +// SDL_imageFilterBitAnd: D = S1 & S2 +function SDL_imageFilterBitAnd(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterBitAnd'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterBitAnd} + +// SDL_imageFilterBitOr: D = S1 | S2 +function SDL_imageFilterBitOr(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterBitOr'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterBitOr} + +// SDL_imageFilterDiv: D = S1 / S2 (non-MMX) +function SDL_imageFilterDiv(Src1 : PChar; Src2 : PChar; Dest : PChar; length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterDiv'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterDiv} + +// SDL_imageFilterBitNegation: D = !S +function SDL_imageFilterBitNegation(Src1 : PChar; Dest : PChar; length : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterBitNegation'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterBitNegation} + +// SDL_imageFilterAddByte: D = saturation255(S + C) +function SDL_imageFilterAddByte(Src1 : PChar; Dest : PChar; length : integer; C : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterAddByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterAddByte} + +// SDL_imageFilterAddUint: D = saturation255(S + (uint)C) +function SDL_imageFilterAddUint(Src1 : PChar; Dest : PChar; length : integer; C : Cardinal ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterAddUint'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterAddUint} + +// SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C) +function SDL_imageFilterAddByteToHalf(Src1 : PChar; Dest : PChar; length : integer; + C : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterAddByteToHalf'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterAddByteToHalf} + +// SDL_imageFilterSubByte: D = saturation0(S - C) +function SDL_imageFilterSubByte(Src1 : PChar; Dest : PChar; length : integer; C : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSubByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterSubByte} + +// SDL_imageFilterSubUint: D = saturation0(S - (uint)C) +function SDL_imageFilterSubUint(Src1 : PChar; Dest : PChar; length : integer; C : Cardinal ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSubUint'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterSubUint} + +// SDL_imageFilterShiftRight: D = saturation0(S >> N) +function SDL_imageFilterShiftRight(Src1 : PChar; Dest : PChar; length : integer; N : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterShiftRight} + +// SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N) +function SDL_imageFilterShiftRightUint(Src1 : PChar; Dest : PChar; length : integer; N : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftRightUint'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterShiftRightUint} + +// SDL_imageFilterMultByByte: D = saturation255(S * C) +function SDL_imageFilterMultByByte(Src1 : PChar; Dest : PChar; length : integer; C : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterMultByByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterMultByByte} + +// SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C) +function SDL_imageFilterShiftRightAndMultByByte(Src1 : PChar; Dest : PChar; length : integer; + N : char; C : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftRightAndMultByByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterShiftRightAndMultByByte} + +// SDL_imageFilterShiftLeftByte: D = (S << N) +function SDL_imageFilterShiftLeftByte(Src1 : PChar; Dest : PChar; length : integer; + N : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftLeftByte'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterShiftLeftByte} + +// SDL_imageFilterShiftLeftUint: D = ((uint)S << N) +function SDL_imageFilterShiftLeftUint(Src1 : PChar; Dest : PChar; length : integer; + N : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftLeftUint'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterShiftLeftUint} + +// SDL_imageFilterShiftLeft: D = saturation255(S << N) +function SDL_imageFilterShiftLeft(Src1 : PChar; Dest : PChar; length : integer; N : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterShiftLeft'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterShiftLeft} + +// SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0 +function SDL_imageFilterBinarizeUsingThreshold(Src1 : PChar; Dest : PChar; length : integer; + T : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterBinarizeUsingThreshold'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterBinarizeUsingThreshold} + +// SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0 +function SDL_imageFilterClipToRange(Src1 : PChar; Dest : PChar; length : integer; + Tmin : Byte; Tmax : Byte ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterClipToRange'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterClipToRange} + +// SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin) +function SDL_imageFilterNormalizeLinear(Src1 : PChar; Dest : PChar; length : integer; Cmin : integer; + Cmax : integer; Nmin : integer; Nmax : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterClipToRange'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterClipToRange} + +{ !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! } + +// SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... ) +function SDL_imageFilterConvolveKernel3x3Divide(Src : PChar; Dest : PChar; rows : integer; + columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel3x3Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterConvolveKernel3x3Divide} + +// SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... ) +function SDL_imageFilterConvolveKernel5x5Divide(Src : PChar; Dest : PChar; rows : integer; + columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel5x5Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterConvolveKernel5x5Divide} + +// SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... ) +function SDL_imageFilterConvolveKernel7x7Divide(Src : PChar; Dest : PChar; rows : integer; + columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel7x7Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterConvolveKernel7x7Divide} + +// SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... ) +function SDL_imageFilterConvolveKernel9x9Divide(Src : PChar; Dest : PChar; rows : integer; + columns : integer; Kernel : PShortInt; Divisor : Byte ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel9x9Divide'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterConvolveKernel9x9Divide} + +// SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... ) +function SDL_imageFilterConvolveKernel3x3ShiftRight(Src : PChar; Dest : PChar; rows : integer; + columns : integer; Kernel : PShortInt; + NRightShift : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel3x3ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterConvolveKernel3x3ShiftRight} + +// SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... ) +function SDL_imageFilterConvolveKernel5x5ShiftRight(Src : PChar; Dest : PChar; rows : integer; + columns : integer; Kernel : PShortInt; + NRightShift : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel5x5ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterConvolveKernel5x5ShiftRight} + +// SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... ) +function SDL_imageFilterConvolveKernel7x7ShiftRight(Src : PChar; Dest : PChar; rows : integer; + columns : integer; Kernel : PShortInt; + NRightShift : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel7x7ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterConvolveKernel7x7ShiftRight} + +// SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... ) +function SDL_imageFilterConvolveKernel9x9ShiftRight(Src : PChar; Dest : PChar; rows : integer; + columns : integer; Kernel : PShortInt; + NRightShift : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterConvolveKernel9x9ShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterConvolveKernel9x9ShiftRight} + +// SDL_imageFilterSobelX: Dij = saturation255( ... ) +function SDL_imageFilterSobelX(Src : PChar; Dest : PChar; rows : integer; columns : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSobelX'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterSobelX} + +// SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... ) +function SDL_imageFilterSobelXShiftRight(Src : PChar; Dest : PChar; rows : integer; columns : integer; + NRightShift : char ) : integer; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterSobelXShiftRight'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterSobelXShiftRight} + +// Align/restore stack to 32 byte boundary -- Functionality untested! -- +procedure SDL_imageFilterAlignStack; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterAlignStack'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterAlignStack} + +procedure SDL_imageFilterRestoreStack; +cdecl; external {$IFDEF __GPC__}name 'SDL_imageFilterRestoreStack'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM SDL_imageFilterRestoreStack} + +{ + + SDL_rotozoom - rotozoomer + + LGPL (c) A. Schiffler + +} + +{ + + rotozoomSurface() + + Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface. + 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1 + then the destination 32bit surface is anti-aliased. If the surface is not 8bit + or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly. + +} + +function rotozoomSurface( src : PSDL_Surface; angle : double; zoom : double; smooth : integer ) : PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'rotozoomSurface'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM rotozoomSurface} + +function rotozoomSurfaceXY( src : PSDL_Surface; angle : double; zoomx : double; zoomy : double; smooth : integer ) : PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'rotozoomSurfaceXY'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM rotozoomSurfaceXY} + +{ Returns the size of the target surface for a rotozoomSurface() call } + +procedure rotozoomSurfaceSize( width : integer; height : integer; angle : double; zoom : double; var dstwidth : integer; + var dstheight : integer ); +cdecl; external {$IFDEF __GPC__}name 'rotozoomSurfaceSize'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM rotozoomSurfaceSize} + +procedure rotozoomSurfaceSizeXY + ( width : integer; height : integer; angle : double; zoomx : double; zoomy : double; + var dstwidth : integer; var dstheight : integer ); +cdecl; external {$IFDEF __GPC__}name 'rotozoomSurfaceSizeXY'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM rotozoomSurfaceSizeXY} + +{ + + zoomSurface() + + Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface. + 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1 + then the destination 32bit surface is anti-aliased. If the surface is not 8bit + or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly. + +} + +function zoomSurface(src : PSDL_Surface; zoomx : double; zoomy : double; smooth : integer ) : PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'zoomSurface'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM zoomSurface} + +{ Returns the size of the target surface for a zoomSurface() call } + +procedure zoomSurfaceSize( width : integer; height : integer; zoomx : double; zoomy : double; var dstwidth : integer; var dstheight : integer ); +cdecl; external {$IFDEF __GPC__}name 'zoomSurfaceSize'{$ELSE} SDLgfxLibName{$ENDIF __GPC__}; +{$EXTERNALSYM zoomSurfaceSize} + +implementation + +end. \ No newline at end of file diff --git a/packages/extra/sdl/sdl_image.pas b/packages/extra/sdl/sdl_image.pas index bc26b403c4..276ad2c455 100644 --- a/packages/extra/sdl/sdl_image.pas +++ b/packages/extra/sdl/sdl_image.pas @@ -1,285 +1,345 @@ -unit sdl_image; -{ - $Id: sdl_image.pas,v 1.7 2005/01/01 02:03:12 savage Exp $ - -} -{******************************************************************************} -{ } -{ Borland Delphi SDL_Image - An example image loading library for use } -{ with SDL } -{ Conversion of the Simple DirectMedia Layer Image Headers } -{ } -{ Portions created by Sam Lantinga are } -{ Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga } -{ 5635-34 Springhouse Dr. } -{ Pleasanton, CA 94588 (USA) } -{ } -{ All Rights Reserved. } -{ } -{ The original files are : SDL_image.h } -{ } -{ The initial developer of this Pascal code was : } -{ Matthias Thoma } -{ } -{ Portions created by Matthias Thoma are } -{ Copyright (C) 2000 - 2001 Matthias Thoma. } -{ } -{ } -{ Contributor(s) } -{ -------------- } -{ Dominique Louis } -{ } -{ Obtained through: } -{ Joint Endeavour of Delphi Innovators ( Project JEDI ) } -{ } -{ You may retrieve the latest version of this file at the Project } -{ JEDI home page, located at http://delphi-jedi.org } -{ } -{ The contents of this file are used with permission, subject to } -{ the Mozilla Public License Version 1.1 (the "License"); you may } -{ not use this file except in compliance with the License. You may } -{ obtain a copy of the License at } -{ http://www.mozilla.org/MPL/MPL-1.1.html } -{ } -{ Software distributed under the License is distributed on an } -{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or } -{ implied. See the License for the specific language governing } -{ rights and limitations under the License. } -{ } -{ Description } -{ ----------- } -{ A simple library to load images of various formats as SDL surfaces } -{ } -{ Requires } -{ -------- } -{ SDL.pas in your search path. } -{ } -{ Programming Notes } -{ ----------------- } -{ See the Aliens Demo on how to make use of this libaray } -{ } -{ Revision History } -{ ---------------- } -{ April 02 2001 - MT : Initial Translation } -{ } -{ May 08 2001 - DL : Added ExternalSym derectives and copyright header } -{ } -{ April 03 2003 - DL : Added jedi-sdl.inc include file to support more } -{ Pascal compilers. Initial support is now included } -{ for GnuPascal, VirtualPascal, TMT and obviously } -{ continue support for Delphi Kylix and FreePascal. } -{ } -{ April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support } -{ } -{ April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added} -{ better TMT Pascal support and under instruction } -{ from Prof. Abimbola Olowofoyeku (The African Chief),} -{ I have added better Gnu Pascal support } -{ } -{ April 30 2003 - DL : under instruction from David Mears AKA } -{ Jason Siletto, I have added FPC Linux support. } -{ This was compiled with fpc 1.1, so remember to set } -{ include file path. ie. -Fi/usr/share/fpcsrc/rtl/* } -{ } -{ - $Log: sdl_image.pas,v $ - Revision 1.7 2005/01/01 02:03:12 savage - Updated to v1.2.4 - - Revision 1.6 2004/08/14 22:54:30 savage - Updated so that Library name defines are correctly defined for MacOS X. - - Revision 1.5 2004/05/10 14:10:04 savage - Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ). - - Revision 1.4 2004/04/13 09:32:08 savage - 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. - - Revision 1.3 2004/04/01 20:53:23 savage - Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site. - - Revision 1.2 2004/03/30 20:23:28 savage - Tidied up use of UNIX compiler directive. - - Revision 1.1 2004/02/14 23:35:42 savage - version 1 of sdl_image, sdl_mixer and smpeg. - - -} -{******************************************************************************} - -{$I jedi-sdl.inc} - -interface - -uses -{$IFDEF __GPC__} - gpc, -{$ENDIF} - sdl; - -const -{$IFDEF windows} - SDL_ImageLibName = 'SDL_Image.dll'; -{$ENDIF} - -{$IFDEF UNIX} -{$IFDEF DARWIN} - SDL_ImageLibName = 'libSDL_image.dylib'; -{$ELSE} - SDL_ImageLibName = 'libSDL_image.so'; -{$ENDIF} -{$ENDIF} - -{$IFDEF MACOS} - SDL_ImageLibName = 'SDL_image'; -{$ENDIF} - - // Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL - SDL_IMAGE_MAJOR_VERSION = 1; -{$EXTERNALSYM SDL_IMAGE_MAJOR_VERSION} - SDL_IMAGE_MINOR_VERSION = 2; -{$EXTERNALSYM SDL_IMAGE_MINOR_VERSION} - SDL_IMAGE_PATCHLEVEL = 4; -{$EXTERNALSYM SDL_IMAGE_PATCHLEVEL} - -{ This macro can be used to fill a version structure with the compile-time - version of the SDL_image library. } -procedure SDL_IMAGE_VERSION( var X : TSDL_Version ); -{$EXTERNALSYM SDL_IMAGE_VERSION} - -{ This function gets the version of the dynamically linked SDL_image library. - it should NOT be used to fill a version structure, instead you should - use the SDL_IMAGE_VERSION() macro. - } -function IMG_Linked_Version : PSDL_version; -external {$IFDEF __GPC__}name 'IMG_Linked_Version'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_Linked_Version} - -{ Load an image from an SDL data source. - The 'type' may be one of: "BMP", "GIF", "PNG", etc. - - If the image format supports a transparent pixel, SDL will set the - colorkey for the surface. You can enable RLE acceleration on the - surface afterwards by calling: - SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey); -} -function IMG_LoadTyped_RW(src: PSDL_RWops; freesrc: Integer; _type: PChar): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadTyped_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadTyped_RW} -{ Convenience functions } -function IMG_Load(const _file: PChar): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_Load'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_Load} -function IMG_Load_RW(src: PSDL_RWops; freesrc: Integer): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_Load_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_Load_RW} - -{ Invert the alpha of a surface for use with OpenGL - This function is now a no-op, and only provided for backwards compatibility. } -function IMG_InvertAlpha(_on: Integer): Integer; -cdecl; external {$IFDEF __GPC__}name 'IMG_InvertAlpha'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_InvertAlpha} - -{ Functions to detect a file type, given a seekable source } -function IMG_isBMP(src: PSDL_RWops): Integer; -cdecl; external {$IFDEF __GPC__}name 'IMG_isBMP'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_isBMP} -function IMG_isPNM(src: PSDL_RWops): Integer; -cdecl; external {$IFDEF __GPC__}name 'IMG_isPNM'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_isPNM} -function IMG_isXPM(src: PSDL_RWops): Integer; -cdecl; external {$IFDEF __GPC__}name 'IMG_isXPM'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_isXPM} -function IMG_isXCF(src: PSDL_RWops): Integer; -cdecl; external {$IFDEF __GPC__}name 'IMG_isXCF'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_isXCF} -function IMG_isPCX(src: PSDL_RWops): Integer; -cdecl; external {$IFDEF __GPC__}name 'IMG_isPCX'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_isPCX} -function IMG_isGIF(src: PSDL_RWops): Integer; -cdecl; external {$IFDEF __GPC__}name 'IMG_isGIF'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_isGIF} -function IMG_isJPG(src: PSDL_RWops): Integer; -cdecl; external {$IFDEF __GPC__}name 'IMG_isJPG'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_isJPG} -function IMG_isTIF(src: PSDL_RWops): Integer; -cdecl; external {$IFDEF __GPC__}name 'IMG_isTIF'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_isTIF} -function IMG_isPNG(src: PSDL_RWops): Integer; -cdecl; external {$IFDEF __GPC__}name 'IMG_isPNG'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_isPNG} -function IMG_isLBM(src: PSDL_RWops): Integer; -cdecl; external {$IFDEF __GPC__}name 'IMG_isLBM'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_isLBM} - -{ Individual loading functions } -function IMG_LoadBMP_RW(src: PSDL_RWops): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadBMP_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadBMP_RW} -function IMG_LoadPNM_RW(src: PSDL_RWops): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadPNM_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadPNM_RW} -function IMG_LoadXPM_RW(src: PSDL_RWops): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadXPM_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadXPM_RW} -function IMG_LoadXCF_RW(src: PSDL_RWops): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadXCF_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadXCF_RW} -function IMG_LoadPCX_RW(src: PSDL_RWops): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadPCX_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadPCX_RW} -function IMG_LoadGIF_RW(src: PSDL_RWops): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadGIF_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadGIF_RW} -function IMG_LoadJPG_RW(src: PSDL_RWops): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadJPG_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadJPG_RW} -function IMG_LoadTIF_RW(src: PSDL_RWops): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadTIF_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadTIF_RW} -function IMG_LoadPNG_RW(src: PSDL_RWops): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadPNG_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadPNG_RW} -function IMG_LoadTGA_RW(src: PSDL_RWops): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadTGA_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadTGA_RW} -function IMG_LoadLBM_RW(src: PSDL_RWops): PSDL_Surface; -cdecl; external {$IFDEF __GPC__}name 'IMG_LoadLBM_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -{$EXTERNALSYM IMG_LoadLBM_RW} - -{ used internally, NOT an exported function } -//function IMG_string_equals( const str1 : PChar; const str2 : PChar ) : integer; -//cdecl; external {$IFDEF __GPC__}name 'IMG_string_equals'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; -//{ $ EXTERNALSYM IMG_string_equals} - -{ Error Macros } -{ We'll use SDL for reporting errors } -procedure IMG_SetError( fmt : PChar ); - -function IMG_GetError : PChar; - -implementation - -{$IFDEF __GPC__} - {$L 'sdl_image'} { link sdl_image.dll.a or libsdl_image.so or libsdl_image.a } -{$ENDIF} - -procedure SDL_IMAGE_VERSION( var X : TSDL_Version ); -begin - X.major := SDL_IMAGE_MAJOR_VERSION; - X.minor := SDL_IMAGE_MINOR_VERSION; - X.patch := SDL_IMAGE_PATCHLEVEL; -end; - -procedure IMG_SetError( fmt : PChar ); -begin - SDL_SetError( fmt ); -end; - -function IMG_GetError : PChar; -begin - result := SDL_GetError; -end; - -end. +unit sdl_image; +{ + $Id: sdl_image.pas,v 1.14 2007/05/29 21:31:13 savage Exp $ + +} +{******************************************************************************} +{ } +{ Borland Delphi SDL_Image - An example image loading library for use } +{ with SDL } +{ Conversion of the Simple DirectMedia Layer Image Headers } +{ } +{ Portions created by Sam Lantinga are } +{ Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga } +{ 5635-34 Springhouse Dr. } +{ Pleasanton, CA 94588 (USA) } +{ } +{ All Rights Reserved. } +{ } +{ The original files are : SDL_image.h } +{ } +{ The initial developer of this Pascal code was : } +{ Matthias Thoma } +{ } +{ Portions created by Matthias Thoma are } +{ Copyright (C) 2000 - 2001 Matthias Thoma. } +{ } +{ } +{ Contributor(s) } +{ -------------- } +{ Dominique Louis } +{ } +{ Obtained through: } +{ Joint Endeavour of Delphi Innovators ( Project JEDI ) } +{ } +{ You may retrieve the latest version of this file at the Project } +{ JEDI home page, located at http://delphi-jedi.org } +{ } +{ The contents of this file are used with permission, subject to } +{ the Mozilla Public License Version 1.1 (the "License"); you may } +{ not use this file except in compliance with the License. You may } +{ obtain a copy of the License at } +{ http://www.mozilla.org/MPL/MPL-1.1.html } +{ } +{ Software distributed under the License is distributed on an } +{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or } +{ implied. See the License for the specific language governing } +{ rights and limitations under the License. } +{ } +{ Description } +{ ----------- } +{ A simple library to load images of various formats as SDL surfaces } +{ } +{ Requires } +{ -------- } +{ SDL.pas in your search path. } +{ } +{ Programming Notes } +{ ----------------- } +{ See the Aliens Demo on how to make use of this libaray } +{ } +{ Revision History } +{ ---------------- } +{ April 02 2001 - MT : Initial Translation } +{ } +{ May 08 2001 - DL : Added ExternalSym derectives and copyright header } +{ } +{ April 03 2003 - DL : Added jedi-sdl.inc include file to support more } +{ Pascal compilers. Initial support is now included } +{ for GnuPascal, VirtualPascal, TMT and obviously } +{ continue support for Delphi Kylix and FreePascal. } +{ } +{ April 08 2003 - MK : Aka Mr Kroket - Added Better FPC support } +{ } +{ April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added} +{ better TMT Pascal support and under instruction } +{ from Prof. Abimbola Olowofoyeku (The African Chief),} +{ I have added better Gnu Pascal support } +{ } +{ April 30 2003 - DL : under instruction from David Mears AKA } +{ Jason Siletto, I have added FPC Linux support. } +{ This was compiled with fpc 1.1, so remember to set } +{ include file path. ie. -Fi/usr/share/fpcsrc/rtl/* } +{ } +{ + $Log: sdl_image.pas,v $ + Revision 1.14 2007/05/29 21:31:13 savage + Changes as suggested by Almindor for 64bit compatibility. + + Revision 1.13 2007/05/20 20:30:54 savage + Initial Changes to Handle 64 Bits + + Revision 1.12 2006/12/02 00:14:40 savage + Updated to latest version + + Revision 1.11 2005/04/10 18:22:59 savage + Changes as suggested by Michalis, thanks. + + Revision 1.10 2005/04/10 11:48:33 savage + Changes as suggested by Michalis, thanks. + + Revision 1.9 2005/01/05 01:47:07 savage + Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively. + + Revision 1.8 2005/01/04 23:14:44 savage + Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively. + + Revision 1.7 2005/01/01 02:03:12 savage + Updated to v1.2.4 + + Revision 1.6 2004/08/14 22:54:30 savage + Updated so that Library name defines are correctly defined for MacOS X. + + Revision 1.5 2004/05/10 14:10:04 savage + Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ). + + Revision 1.4 2004/04/13 09:32:08 savage + 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. + + Revision 1.3 2004/04/01 20:53:23 savage + Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site. + + Revision 1.2 2004/03/30 20:23:28 savage + Tidied up use of UNIX compiler directive. + + Revision 1.1 2004/02/14 23:35:42 savage + version 1 of sdl_image, sdl_mixer and smpeg. + + +} +{******************************************************************************} + +{$I jedi-sdl.inc} + +interface + +uses +{$IFDEF __GPC__} + gpc, +{$ENDIF} + sdl; + +const +{$IFDEF WINDOWS} + SDL_ImageLibName = 'SDL_Image.dll'; +{$ENDIF} + +{$IFDEF UNIX} +{$IFDEF DARWIN} + SDL_ImageLibName = 'libSDL_image-1.2.0.dylib'; +{$ELSE} + {$IFDEF FPC} + SDL_ImageLibName = 'libSDL_image.so'; + {$ELSE} + SDL_ImageLibName = 'libSDL_image-1.2.so.0'; + {$ENDIF} +{$ENDIF} +{$ENDIF} + +{$IFDEF MACOS} + SDL_ImageLibName = 'SDL_image'; +{$ENDIF} + + // Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL + SDL_IMAGE_MAJOR_VERSION = 1; +{$EXTERNALSYM SDL_IMAGE_MAJOR_VERSION} + SDL_IMAGE_MINOR_VERSION = 2; +{$EXTERNALSYM SDL_IMAGE_MINOR_VERSION} + SDL_IMAGE_PATCHLEVEL = 5; +{$EXTERNALSYM SDL_IMAGE_PATCHLEVEL} + +{ This macro can be used to fill a version structure with the compile-time + version of the SDL_image library. } +procedure SDL_IMAGE_VERSION( var X : TSDL_Version ); +{$EXTERNALSYM SDL_IMAGE_VERSION} + +{ This function gets the version of the dynamically linked SDL_image library. + it should NOT be used to fill a version structure, instead you should + use the SDL_IMAGE_VERSION() macro. + } +function IMG_Linked_Version : PSDL_version; +external {$IFDEF __GPC__}name 'IMG_Linked_Version'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_Linked_Version} + +{ Load an image from an SDL data source. + The 'type' may be one of: "BMP", "GIF", "PNG", etc. + + If the image format supports a transparent pixel, SDL will set the + colorkey for the surface. You can enable RLE acceleration on the + surface afterwards by calling: + SDL_SetColorKey(image, SDL_RLEACCEL, image.format.colorkey); +} +function IMG_LoadTyped_RW(src: PSDL_RWops; freesrc: Integer; _type: PChar): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadTyped_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadTyped_RW} +{ Convenience functions } +function IMG_Load(const _file: PChar): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_Load'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_Load} +function IMG_Load_RW(src: PSDL_RWops; freesrc: Integer): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_Load_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_Load_RW} + +{ Invert the alpha of a surface for use with OpenGL + This function is now a no-op, and only provided for backwards compatibility. } +function IMG_InvertAlpha(_on: Integer): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_InvertAlpha'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_InvertAlpha} + +{ Functions to detect a file type, given a seekable source } +function IMG_isBMP(src: PSDL_RWops): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_isBMP'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_isBMP} + +function IMG_isGIF(src: PSDL_RWops): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_isGIF'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_isGIF} + +function IMG_isJPG(src: PSDL_RWops): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_isJPG'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_isJPG} + +function IMG_isLBM(src: PSDL_RWops): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_isLBM'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_isLBM} + +function IMG_isPCX(src: PSDL_RWops): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_isPCX'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_isPCX} + +function IMG_isPNG(src: PSDL_RWops): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_isPNG'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_isPNG} + +function IMG_isPNM(src: PSDL_RWops): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_isPNM'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_isPNM} + +function IMG_isTIF(src: PSDL_RWops): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_isTIF'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_isTIF} + +function IMG_isXCF(src: PSDL_RWops): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_isXCF'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_isXCF} + +function IMG_isXPM(src: PSDL_RWops): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_isXPM'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_isXPM} + +function IMG_isXV(src: PSDL_RWops): Integer; +cdecl; external {$IFDEF __GPC__}name 'IMG_isXV'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_isXV} + + +{ Individual loading functions } +function IMG_LoadBMP_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadBMP_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadBMP_RW} + +function IMG_LoadGIF_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadGIF_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadGIF_RW} + +function IMG_LoadJPG_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadJPG_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadJPG_RW} + +function IMG_LoadLBM_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadLBM_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadLBM_RW} + +function IMG_LoadPCX_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadPCX_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadPCX_RW} + +function IMG_LoadPNM_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadPNM_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadPNM_RW} + +function IMG_LoadPNG_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadPNG_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadPNG_RW} + +function IMG_LoadTGA_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadTGA_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadTGA_RW} + +function IMG_LoadTIF_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadTIF_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadTIF_RW} + +function IMG_LoadXCF_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadXCF_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadXCF_RW} + +function IMG_LoadXPM_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadXPM_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadXPM_RW} + +function IMG_LoadXV_RW(src: PSDL_RWops): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_LoadXV_RW'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_LoadXV_RW} + +function IMG_ReadXPMFromArray( xpm : PPChar ): PSDL_Surface; +cdecl; external {$IFDEF __GPC__}name 'IMG_ReadXPMFromArray'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +{$EXTERNALSYM IMG_ReadXPMFromArray} + + + + +{ used internally, NOT an exported function } +//function IMG_string_equals( const str1 : PChar; const str2 : PChar ) : integer; +//cdecl; external {$IFDEF __GPC__}name 'IMG_string_equals'{$ELSE} SDL_ImageLibName{$ENDIF __GPC__}; +//{ $ EXTERNALSYM IMG_string_equals} + +{ Error Macros } +{ We'll use SDL for reporting errors } +procedure IMG_SetError( fmt : PChar ); + +function IMG_GetError : PChar; + +implementation + +{$IFDEF __GPC__} + {$L 'sdl_image'} { link sdl_image.dll.a or libsdl_image.so or libsdl_image.a } +{$ENDIF} + +procedure SDL_IMAGE_VERSION( var X : TSDL_Version ); +begin + X.major := SDL_IMAGE_MAJOR_VERSION; + X.minor := SDL_IMAGE_MINOR_VERSION; + X.patch := SDL_IMAGE_PATCHLEVEL; +end; + +procedure IMG_SetError( fmt : PChar ); +begin + SDL_SetError( fmt ); +end; + +function IMG_GetError : PChar; +begin + result := SDL_GetError; +end; + +end. diff --git a/packages/extra/sdl/sdl_mixer.pas b/packages/extra/sdl/sdl_mixer.pas index 4efbb4f7e4..8ba1f6ae87 100644 --- a/packages/extra/sdl/sdl_mixer.pas +++ b/packages/extra/sdl/sdl_mixer.pas @@ -1,1072 +1,1122 @@ -unit sdl_mixer; -{******************************************************************************} -{ - $Id: sdl_mixer.pas,v 1.11 2005/01/01 02:05:19 savage Exp $ - -} -{ } -{ Borland Delphi SDL_Mixer - Simple DirectMedia Layer Mixer Library } -{ Conversion of the Simple DirectMedia Layer Headers } -{ } -{ Portions created by Sam Lantinga are } -{ Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga } -{ 5635-34 Springhouse Dr. } -{ Pleasanton, CA 94588 (USA) } -{ } -{ All Rights Reserved. } -{ } -{ The original files are : SDL_mixer.h } -{ music_cmd.h } -{ wavestream.h } -{ timidity.h } -{ playmidi.h } -{ music_ogg.h } -{ mikmod.h } -{ } -{ The initial developer of this Pascal code was : } -{ Dominqiue Louis } -{ } -{ Portions created by Dominqiue Louis are } -{ Copyright (C) 2000 - 2001 Dominqiue Louis. } -{ } -{ } -{ Contributor(s) } -{ -------------- } -{ Matthias Thoma } -{ } -{ Obtained through: } -{ Joint Endeavour of Delphi Innovators ( Project JEDI ) } -{ } -{ You may retrieve the latest version of this file at the Project } -{ JEDI home page, located at http://delphi-jedi.org } -{ } -{ The contents of this file are used with permission, subject to } -{ the Mozilla Public License Version 1.1 (the "License"); you may } -{ not use this file except in compliance with the License. You may } -{ obtain a copy of the License at } -{ http://www.mozilla.org/MPL/MPL-1.1.html } -{ } -{ Software distributed under the License is distributed on an } -{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or } -{ implied. See the License for the specific language governing } -{ rights and limitations under the License. } -{ } -{ Description } -{ ----------- } -{ } -{ } -{ } -{ } -{ } -{ } -{ } -{ Requires } -{ -------- } -{ SDL.pas & SMPEG.pas somewhere within your search path. } -{ } -{ Programming Notes } -{ ----------------- } -{ See the Aliens Demo to see how this library is used } -{ } -{ Revision History } -{ ---------------- } -{ April 02 2001 - DL : Initial Translation } -{ } -{ February 02 2002 - DL : Update to version 1.2.1 } -{ } -{ April 03 2003 - DL : Added jedi-sdl.inc include file to support more } -{ Pascal compilers. Initial support is now included } -{ for GnuPascal, VirtualPascal, TMT and obviously } -{ continue support for Delphi Kylix and FreePascal. } -{ } -{ April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added} -{ better TMT Pascal support and under instruction } -{ from Prof. Abimbola Olowofoyeku (The African Chief),} -{ I have added better Gnu Pascal support } -{ } -{ April 30 2003 - DL : under instruction from David Mears AKA } -{ Jason Siletto, I have added FPC Linux support. } -{ This was compiled with fpc 1.1, so remember to set } -{ include file path. ie. -Fi/usr/share/fpcsrc/rtl/* } -{ } -{ - $Log: sdl_mixer.pas,v $ - Revision 1.11 2005/01/01 02:05:19 savage - Updated to v1.2.6 - - Revision 1.10 2004/09/12 21:45:17 savage - Robert Reed spotted that Mix_SetMusicPosition was missing from the conversion, so this has now been added. - - Revision 1.9 2004/08/27 21:48:24 savage - IFDEFed out Smpeg support on MacOS X - - Revision 1.8 2004/08/14 22:54:30 savage - Updated so that Library name defines are correctly defined for MacOS X. - - Revision 1.7 2004/05/10 14:10:04 savage - Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ). - - Revision 1.6 2004/04/13 09:32:08 savage - 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. - - Revision 1.5 2004/04/01 20:53:23 savage - Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site. - - Revision 1.4 2004/03/31 22:20:02 savage - Windows unit not used in this file, so it was removed to keep the code tidy. - - Revision 1.3 2004/03/31 10:05:08 savage - Better defines for Endianess under FreePascal and Borland compilers. - - Revision 1.2 2004/03/30 20:23:28 savage - Tidied up use of UNIX compiler directive. - - Revision 1.1 2004/02/14 23:35:42 savage - version 1 of sdl_image, sdl_mixer and smpeg. - - -} -{******************************************************************************} - -{$I jedi-sdl.inc} - -interface - -{$IFDEF FPC} -{$IFDEF FPC_LITTLE_ENDIAN} -{$DEFINE IA32} -{$ENDIF} -{$ENDIF} - -uses -{$IFNDEF DARWIN} - smpeg, -{$ENDIF} - sdl; - -const -{$IFDEF windows} - SDL_MixerLibName = 'SDL_mixer.dll'; -{$ENDIF} - -{$IFDEF UNIX} -{$IFDEF DARWIN} - SDL_MixerLibName = 'libSDL_mixer.dylib'; -{$ELSE} - SDL_MixerLibName = 'libSDL_mixer.so'; -{$ENDIF} -{$ENDIF} - -{$IFDEF MACOS} - SDL_MixerLibName = 'SDL_mixer'; -{$ENDIF} - - {* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *} - SDL_MIXER_MAJOR_VERSION = 1; -{$EXTERNALSYM MIX_MAJOR_VERSION} - SDL_MIXER_MINOR_VERSION = 2; -{$EXTERNALSYM MIX_MINOR_VERSION} - SDL_MIXER_PATCHLEVEL = 6; -{$EXTERNALSYM MIX_PATCHLEVEL} - - // Backwards compatibility - MIX_MAJOR_VERSION = SDL_MIXER_MAJOR_VERSION; - MIX_MINOR_VERSION = SDL_MIXER_MINOR_VERSION; - MIX_PATCHLEVEL = SDL_MIXER_PATCHLEVEL; - - // SDL_Mixer.h constants - { The default mixer has 8 simultaneous mixing channels } -{$IFNDEF MIX_CHANNELS} - MIX_CHANNELS = 8; -{$ENDIF} -{$EXTERNALSYM MIX_CHANNELS} - { Good default values for a PC soundcard } - MIX_DEFAULT_FREQUENCY = 22050; -{$EXTERNALSYM MIX_DEFAULT_FREQUENCY} - -{$IFDEF IA32} - MIX_DEFAULT_FORMAT = AUDIO_S16LSB; -{$ELSE} - MIX_DEFAULT_FORMAT = AUDIO_S16MSB; -{$ENDIF} -{$EXTERNALSYM MIX_DEFAULT_FORMAT} - - MIX_DEFAULT_CHANNELS = 2; -{$EXTERNALSYM MIX_DEFAULT_CHANNELS} - MIX_MAX_VOLUME = 128; { Volume of a chunk } -{$EXTERNALSYM MIX_MAX_VOLUME} - - PATH_MAX = 255; - - // mikmod.h constants - {* - * Library version - *} - LIBMIKMOD_VERSION_MAJOR = 3; - LIBMIKMOD_VERSION_MINOR = 1; - LIBMIKMOD_REVISION = 8; - LIBMIKMOD_VERSION = ( ( LIBMIKMOD_VERSION_MAJOR shl 16 ) or - ( LIBMIKMOD_VERSION_MINOR shl 8 ) or - ( LIBMIKMOD_REVISION ) ); - -type - //music_cmd.h types - PMusicCMD = ^TMusicCMD; - TMusicCMD = record - filename : array[ 0..PATH_MAX - 1 ] of char; - cmd : array[ 0..PATH_MAX - 1 ] of char; - pid : TSYS_ThreadHandle; - end; - - //wavestream.h types - PWAVStream = ^TWAVStream; - TWAVStream = record - wavefp : Pointer; - start : longint; - stop : longint; - cvt : TSDL_AudioCVT; - end; - - //playmidi.h types - PMidiEvent = ^TMidiEvent; - TMidiEvent = record - time : Longint; - channel : uint8; - type_ : uint8; - a : uint8; - b : uint8; - end; - - PMidiSong = ^TMidiSong; - TMidiSong = record - samples : Longint; - events : PMidiEvent; - end; - - //music_ogg.h types - POGG_Music = ^TOGG_Music; - TOGG_Music = record - playing : integer; - volume : integer; - //vf: OggVorbis_File; - section : integer; - cvt : TSDL_AudioCVT; - len_available : integer; - snd_available : PUint8; - end; - - // mikmod.h types - {* - * Error codes - *} - TErrorEnum = ( - MMERR_OPENING_FILE, - MMERR_OUT_OF_MEMORY, - MMERR_DYNAMIC_LINKING, - MMERR_SAMPLE_TOO_BIG, - MMERR_OUT_OF_HANDLES, - MMERR_UNKNOWN_WAVE_TYPE, - MMERR_LOADING_PATTERN, - MMERR_LOADING_TRACK, - MMERR_LOADING_HEADER, - MMERR_LOADING_SAMPLEINFO, - MMERR_NOT_A_MODULE, - MMERR_NOT_A_STREAM, - MMERR_MED_SYNTHSAMPLES, - MMERR_ITPACK_INVALID_DATA, - MMERR_DETECTING_DEVICE, - MMERR_INVALID_DEVICE, - MMERR_INITIALIZING_MIXER, - MMERR_OPENING_AUDIO, - MMERR_8BIT_ONLY, - MMERR_16BIT_ONLY, - MMERR_STEREO_ONLY, - MMERR_ULAW, - MMERR_NON_BLOCK, - MMERR_AF_AUDIO_PORT, - MMERR_AIX_CONFIG_INIT, - MMERR_AIX_CONFIG_CONTROL, - MMERR_AIX_CONFIG_START, - MMERR_GUS_SETTINGS, - MMERR_GUS_RESET, - MMERR_GUS_TIMER, - MMERR_HP_SETSAMPLESIZE, - MMERR_HP_SETSPEED, - MMERR_HP_CHANNELS, - MMERR_HP_AUDIO_OUTPUT, - MMERR_HP_AUDIO_DESC, - MMERR_HP_BUFFERSIZE, - MMERR_OSS_SETFRAGMENT, - MMERR_OSS_SETSAMPLESIZE, - MMERR_OSS_SETSTEREO, - MMERR_OSS_SETSPEED, - MMERR_SGI_SPEED, - MMERR_SGI_16BIT, - MMERR_SGI_8BIT, - MMERR_SGI_STEREO, - MMERR_SGI_MONO, - MMERR_SUN_INIT, - MMERR_OS2_MIXSETUP, - MMERR_OS2_SEMAPHORE, - MMERR_OS2_TIMER, - MMERR_OS2_THREAD, - MMERR_DS_PRIORITY, - MMERR_DS_BUFFER, - MMERR_DS_FORMAT, - MMERR_DS_NOTIFY, - MMERR_DS_EVENT, - MMERR_DS_THREAD, - MMERR_DS_UPDATE, - MMERR_WINMM_HANDLE, - MMERR_WINMM_ALLOCATED, - MMERR_WINMM_DEVICEID, - MMERR_WINMM_FORMAT, - MMERR_WINMM_UNKNOWN, - MMERR_MAC_SPEED, - MMERR_MAC_START, - MMERR_MAX - ); - - PMODULE = ^TMODULE; - TMODULE = record - (* general module information *) - //CHAR* songname; (* name of the song *) - //CHAR* modtype; (* string type of module loaded *) - //CHAR* comment; (* module comments *) - //UWORD flags; (* See module flags above *) - //UBYTE numchn; (* number of module channels *) - //UBYTE numvoices; (* max # voices used for full NNA playback *) - //UWORD numpos; (* number of positions in this song *) - //UWORD numpat; (* number of patterns in this song *) - //UWORD numins; (* number of instruments *) - //UWORD numsmp; (* number of samples *) - //type = record INSTRUMENT* instruments; (* all instruments *) - //type = record SAMPLE* samples; (* all samples *) - //UBYTE realchn; (* real number of channels used *) - //UBYTE totalchn; (* total number of channels used (incl NNAs) *) - (* playback settings *) - //UWORD reppos; (* restart position *) - //UBYTE initspeed; (* initial song speed *) - //UWORD inittempo; (* initial song tempo *) - //UBYTE initvolume; (* initial global volume (0 - 128) *) - //UWORD panning : array[ 0..64- 1 ] of ; (* 64 panning positions *) - //UBYTE chanvol : array[ 0..64- 1 ] of ; (* 64 channel positions *) - //UWORD bpm; (* current beats-per-minute speed *) - //UWORD sngspd; (* current song speed *) - //SWORD volume; (* song volume (0-128) (or user volume) *) - //BOOL extspd; (* extended speed flag (default enabled) *) - //BOOL panflag; (* panning flag (default enabled) *) - //BOOL wrap; (* wrap module ? (default disabled) *) - //BOOL loop; (* allow module to loop ? (default enabled) *) - //BOOL fadeout; (* volume fade out during last pattern *) - //UWORD patpos; (* current row number *) - //SWORD sngpos; (* current song position *) - //ULONG sngtime; (* current song time in 2^-10 seconds *) - //SWORD relspd; (* relative speed factor *) - (* internal module representation *) - //UWORD numtrk; (* number of tracks *) - //UBYTE** tracks; (* array of numtrk pointers to tracks *) - //UWORD* patterns; (* array of Patterns *) - //UWORD* pattrows; (* array of number of rows for each pattern *) - //UWORD* positions; (* all positions *) - //BOOL forbid; (* if true, no player updatenot *) - //UWORD numrow; (* number of rows on current pattern *) - //UWORD vbtick; (* tick counter (counts from 0 to sngspd) *) - //UWORD sngremainder;(* used for song time computation *) - //type = record MP_CONTROL* control; (* Effects Channel info (size pf.numchn) *) - //type = record MP_VOICE* voice; (* Audio Voice information (size md_numchn) *) - //UBYTE globalslide; (* global volume slide rate *) - //UBYTE pat_repcrazy;(* module has just looped to position -1 *) - //UWORD patbrk; (* position where to start a new pattern *) - //UBYTE patdly; (* patterndelay counter (command memory) *) - //UBYTE patdly2; (* patterndelay counter (real one) *) - //SWORD posjmp; (* flag to indicate a jump is needed... *) - end; - - PUNIMOD = ^TUNIMOD; - TUNIMOD = TMODULE; - - //SDL_mixer.h types - { The internal format for an audio chunk } - PMix_Chunk = ^TMix_Chunk; - TMix_Chunk = record - allocated : integer; - abuf : PUint8; - alen : Uint32; - volume : Uint8; { Per-sample volume, 0-128 } - end; - Mix_Chunk = TMix_Chunk; - - { The different fading types supported } - TMix_Fading = ( - MIX_NO_FADING, - MIX_FADING_OUT, - MIX_FADING_IN - ); - Mix_Fading = TMix_Fading; - - TMusic = ( MUS_CMD, - MUS_WAV, - MUS_MOD, - MUS_MID, - MUS_OGG, - MUS_MP3 - ); - - TMusicUnion = record - case Byte of - 0 : ( cmd : PMusicCMD ); - 1 : ( wave : PWAVStream ); - 2 : ( module : PUNIMOD ); - 3 : ( midi : TMidiSong ); - 4 : ( ogg : POGG_music ); - {$IFNDEF DARWIN} - 5 : ( mp3 : PSMPEG ); - {$ENDIF} - end; - - P_Mix_Music = ^T_Mix_Music; - T_Mix_Music = record - type_ : TMusic; - data : TMusicUnion; - fading : TMix_Fading; - fade_volume : integer; - fade_step : integer; - fade_steps : integer; - error : integer; - end; - - { The internal format for a music chunk interpreted via mikmod } - PMix_Music = ^TMix_Music; - TMix_Music = T_Mix_Music; - - {$IFNDEF __GPC__} - TMixFunction = function( udata : Pointer; stream : PUint8; len : integer ) : Pointer; cdecl; - {$ELSE} - TMixFunction = function( udata : Pointer; stream : PUint8; len : integer ) : Pointer; - {$ENDIF} - -{ This macro can be used to fill a version structure with the compile-time - version of the SDL_mixer library. } -procedure SDL_MIXER_VERSION(var X: TSDL_Version); -{$EXTERNALSYM SDL_MIXER_VERSION} - -{ This function gets the version of the dynamically linked SDL_mixer library. - It should NOT be used to fill a version structure, instead you should use the - SDL_MIXER_VERSION() macro. } -function Mix_Linked_Version : PSDL_version; -cdecl; external {$IFDEF __GPC__}name 'Mix_Linked_Version'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_Linked_Version} - -{ Open the mixer with a certain audio format } -function Mix_OpenAudio( frequency : integer; format : Uint16; channels : - integer; chunksize : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_OpenAudio'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_OpenAudio} - -{ Dynamically change the number of channels managed by the mixer. - If decreasing the number of channels, the upper channels are - stopped. - This function returns the new number of allocated channels. - } -function Mix_AllocateChannels( numchannels : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_AllocateChannels'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_AllocateChannels} - -{ Find out what the actual audio device parameters are. - This function returns 1 if the audio has been opened, 0 otherwise. - } -function Mix_QuerySpec( var frequency : integer; var format : Uint16; var channels : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_QuerySpec'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_QuerySpec} - -{ Load a wave file or a music (.mod .s3m .it .xm) file } -function Mix_LoadWAV_RW( src : PSDL_RWops; freesrc : integer ) : PMix_Chunk; -cdecl; external {$IFDEF __GPC__}name 'Mix_LoadWAV_RW'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_LoadWAV_RW} - -function Mix_LoadWAV( filename : PChar ) : PMix_Chunk; - -function Mix_LoadMUS( const filename : PChar ) : PMix_Music; -cdecl; external {$IFDEF __GPC__}name 'Mix_LoadMUS'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_LoadMUS} - -(*#if 0 { This hasn't been hooked into music.c yet } -{ Load a music file from an SDL_RWop object (MikMod-specific currently) - Matt Campbell (matt@campbellhome.dhs.org) April 2000 } -function Mix_LoadMUS_RW(SDL_RWops *rw) : PMix_Music; cdecl; -#endif*) - -{ Load a wave file of the mixer format from a memory buffer } -function Mix_QuickLoad_WAV( mem : PUint8 ) : PMix_Chunk; -cdecl; external {$IFDEF __GPC__}name 'Mix_QuickLoad_WAV'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_QuickLoad_WAV} - -{ Free an audio chunk previously loaded } -procedure Mix_FreeChunk( chunk : PMix_Chunk ); -cdecl; external {$IFDEF __GPC__}name 'Mix_FreeChunk'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_FreeChunk} - -procedure Mix_FreeMusic( music : PMix_Music ); -cdecl; external {$IFDEF __GPC__}name 'Mix_FreeMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_FreeMusic} - -{ Set a function that is called after all mixing is performed. - This can be used to provide real-time visual display of the audio stream - or add a custom mixer filter for the stream data. -} -procedure Mix_SetPostMix( mix_func : TMixFunction; arg : Pointer ); -cdecl; external {$IFDEF __GPC__}name 'Mix_SetPostMix'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_SetPostMix} - -{ Add your own music player or additional mixer function. - If 'mix_func' is NULL, the default music player is re-enabled. - } -procedure Mix_HookMusic( mix_func : TMixFunction; arg : Pointer ); - cdecl; external {$IFDEF __GPC__}name 'Mix_HookMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_HookMusic} - -{ Add your own callback when the music has finished playing. - } -procedure Mix_HookMusicFinished( music_finished : Pointer ); -cdecl; external {$IFDEF __GPC__}name 'Mix_HookMusicFinished'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_HookMusicFinished} - -{ Get a pointer to the user data for the current music hook } -function Mix_GetMusicHookData : Pointer; -cdecl; external {$IFDEF __GPC__}name 'Mix_GetMusicHookData'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_GetMusicHookData} - -{* Add your own callback when a channel has finished playing. NULL - * to disable callback.*} -type - {$IFNDEF __GPC__} - TChannel_finished = procedure( channel: Integer ); cdecl; - {$ELSE} - TChannel_finished = procedure( channel: Integer ); - {$ENDIF} - -procedure Mix_ChannelFinished( channel_finished : TChannel_finished ); -cdecl; external {$IFDEF __GPC__}name 'Mix_ChannelFinished'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_ChannelFinished} - -const - MIX_CHANNEL_POST = -2; - - {* This is the format of a special effect callback: - * - * myeffect(int chan, void *stream, int len, void *udata); - * - * (chan) is the channel number that your effect is affecting. (stream) is - * the buffer of data to work upon. (len) is the size of (stream), and - * (udata) is a user-defined bit of data, which you pass as the last arg of - * Mix_RegisterEffect(), and is passed back unmolested to your callback. - * Your effect changes the contents of (stream) based on whatever parameters - * are significant, or just leaves it be, if you prefer. You can do whatever - * you like to the buffer, though, and it will continue in its changed state - * down the mixing pipeline, through any other effect functions, then finally - * to be mixed with the rest of the channels and music for the final output - * stream. - *} -type - {$IFNDEF __GPC__} - TMix_EffectFunc = function( chan : integer; stream : Pointer; len : integer; udata : Pointer ) : Pointer; cdecl; - {$ELSE} - TMix_EffectFunc = function( chan : integer; stream : Pointer; len : integer; udata : Pointer ) : Pointer; - {$ENDIF} - {* - * This is a callback that signifies that a channel has finished all its - * loops and has completed playback. This gets called if the buffer - * plays out normally, or if you call Mix_HaltChannel(), implicitly stop - * a channel via Mix_AllocateChannels(), or unregister a callback while - * it's still playing. - *} - {$IFNDEF __GPC__} - TMix_EffectDone = function( chan : integer; udata : Pointer ) : Pointer; cdecl; - {$ELSE} - TMix_EffectDone = function( chan : integer; udata : Pointer ) : Pointer; - {$ENDIF} - {* Register a special effect function. At mixing time, the channel data is - * copied into a buffer and passed through each registered effect function. - * After it passes through all the functions, it is mixed into the final - * output stream. The copy to buffer is performed once, then each effect - * function performs on the output of the previous effect. Understand that - * this extra copy to a buffer is not performed if there are no effects - * registered for a given chunk, which saves CPU cycles, and any given - * effect will be extra cycles, too, so it is crucial that your code run - * fast. Also note that the data that your function is given is in the - * format of the sound device, and not the format you gave to Mix_OpenAudio(), - * although they may in reality be the same. This is an unfortunate but - * necessary speed concern. Use Mix_QuerySpec() to determine if you can - * handle the data before you register your effect, and take appropriate - * actions. - * You may also specify a callback (Mix_EffectDone_t) that is called when - * the channel finishes playing. This gives you a more fine-grained control - * than Mix_ChannelFinished(), in case you need to free effect-specific - * resources, etc. If you don't need this, you can specify NULL. - * You may set the callbacks before or after calling Mix_PlayChannel(). - * Things like Mix_SetPanning() are just internal special effect functions, - * so if you are using that, you've already incurred the overhead of a copy - * to a separate buffer, and that these effects will be in the queue with - * any functions you've registered. The list of registered effects for a - * channel is reset when a chunk finishes playing, so you need to explicitly - * set them with each call to Mix_PlayChannel*(). - * You may also register a special effect function that is to be run after - * final mixing occurs. The rules for these callbacks are identical to those - * in Mix_RegisterEffect, but they are run after all the channels and the - * music have been mixed into a single stream, whereas channel-specific - * effects run on a given channel before any other mixing occurs. These - * global effect callbacks are call "posteffects". Posteffects only have - * their Mix_EffectDone_t function called when they are unregistered (since - * the main output stream is never "done" in the same sense as a channel). - * You must unregister them manually when you've had enough. Your callback - * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the - * processing is considered a posteffect. - * - * After all these effects have finished processing, the callback registered - * through Mix_SetPostMix() runs, and then the stream goes to the audio - * device. - * - * returns zero if error (no such channel), nonzero if added. - * Error messages can be retrieved from Mix_GetError(). - *} -function Mix_RegisterEffect( chan : integer; f : TMix_EffectFunc; d : TMix_EffectDone; arg : Pointer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_RegisterEffect'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_RegisterEffect} - -{* You may not need to call this explicitly, unless you need to stop an - * effect from processing in the middle of a chunk's playback. - * Posteffects are never implicitly unregistered as they are for channels, - * but they may be explicitly unregistered through this function by - * specifying MIX_CHANNEL_POST for a channel. - * returns zero if error (no such channel or effect), nonzero if removed. - * Error messages can be retrieved from Mix_GetError(). - *} -function Mix_UnregisterEffect( channel : integer; f : TMix_EffectFunc ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_UnregisterEffect'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_UnregisterEffect} - - {* You may not need to call this explicitly, unless you need to stop all - * effects from processing in the middle of a chunk's playback. Note that - * this will also shut off some internal effect processing, since - * Mix_SetPanning( ) and others may use this API under the hood.This is - * called internally when a channel completes playback. - * Posteffects are never implicitly unregistered as they are for channels, - * but they may be explicitly unregistered through this function by - * specifying MIX_CHANNEL_POST for a channel. - * returns zero if error( no such channel ), nonzero if all effects removed. - * Error messages can be retrieved from Mix_GetError( ). - *} -function Mix_UnregisterAllEffects( channel : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_UnregisterAllEffects'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_UnregisterAllEffects} - -const - MIX_EFFECTSMAXSPEED = 'MIX_EFFECTSMAXSPEED'; - - {* - * These are the internally - defined mixing effects.They use the same API that - * effects defined in the application use, but are provided here as a - * convenience.Some effects can reduce their quality or use more memory in - * the name of speed; to enable this, make sure the environment variable - * MIX_EFFECTSMAXSPEED( see above ) is defined before you call - * Mix_OpenAudio( ). - * } - - {* set the panning of a channel.The left and right channels are specified - * as integers between 0 and 255, quietest to loudest, respectively. - * - * Technically, this is just individual volume control for a sample with - * two( stereo )channels, so it can be used for more than just panning. - * if you want real panning, call it like this : - * - * Mix_SetPanning( channel, left, 255 - left ); - * - * ...which isn't so hard. - * - * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and - * the panning will be done to the final mixed stream before passing it on - * to the audio device. - * - * This uses the Mix_RegisterEffect( )API internally, and returns without - * registering the effect function if the audio device is not configured - * for stereo output.Setting both( left ) and ( right ) to 255 causes this - * effect to be unregistered, since that is the data's normal state. - * - * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), - * nonzero if panning effect enabled.Note that an audio device in mono - * mode is a no - op, but this call will return successful in that case . - * Error messages can be retrieved from Mix_GetError( ). - * } - function Mix_SetPanning( channel : integer; left : Uint8; right : Uint8 ) : integer; - cdecl; external {$IFDEF __GPC__}name 'Mix_SetPanning'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; - {$EXTERNALSYM Mix_SetPanning} - - { * set the position ofa channel.( angle ) is an integer from 0 to 360, that - * specifies the location of the sound in relation to the listener.( angle ) - * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ). - * Angle 0 is due north, and rotates clockwise as the value increases. - * for efficiency, the precision of this effect may be limited( angles 1 - * through 7 might all produce the same effect, 8 through 15 are equal, etc ). - * ( distance ) is an integer between 0 and 255 that specifies the space - * between the sound and the listener.The larger the number, the further - * away the sound is .Using 255 does not guarantee that the channel will be - * culled from the mixing process or be completely silent.For efficiency, - * the precision of this effect may be limited( distance 0 through 5 might - * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle ) - * and ( distance ) to 0 unregisters this effect, since the data would be - * unchanged. - * - * if you need more precise positional audio, consider using OpenAL for - * spatialized effects instead of SDL_mixer.This is only meant to be a - * basic effect for simple "3D" games. - * - * if the audio device is configured for mono output, then you won't get - * any effectiveness from the angle; however, distance attenuation on the - * channel will still occur.While this effect will function with stereo - * voices, it makes more sense to use voices with only one channel of sound, - * so when they are mixed through this effect, the positioning will sound - * correct.You can convert them to mono through SDL before giving them to - * the mixer in the first place if you like. - * - * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and - * the positioning will be done to the final mixed stream before passing it - * on to the audio device. - * - * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ). - * - * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), - * nonzero if position effect is enabled. - * Error messages can be retrieved from Mix_GetError( ). - * } - function Mix_SetPosition( channel :integer; angle : Sint16; distance : Uint8 ) : integer; - cdecl; external {$IFDEF __GPC__}name 'Mix_SetPosition'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; - {$EXTERNALSYM Mix_SetPosition} - - {* set the "distance" of a channel.( distance ) is an integer from 0 to 255 - * that specifies the location of the sound in relation to the listener. - * Distance 0 is overlapping the listener, and 255 is as far away as possible - * A distance of 255 does not guarantee silence; in such a case , you might - * want to try changing the chunk's volume, or just cull the sample from the - * mixing process with Mix_HaltChannel( ). - * for efficiency, the precision of this effect may be limited( distances 1 - * through 7 might all produce the same effect, 8 through 15 are equal, etc ). - * ( distance ) is an integer between 0 and 255 that specifies the space - * between the sound and the listener.The larger the number, the further - * away the sound is . - * Setting( distance ) to 0 unregisters this effect, since the data would be - * unchanged. - * if you need more precise positional audio, consider using OpenAL for - * spatialized effects instead of SDL_mixer.This is only meant to be a - * basic effect for simple "3D" games. - * - * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and - * the distance attenuation will be done to the final mixed stream before - * passing it on to the audio device. - * - * This uses the Mix_RegisterEffect( )API internally. - * - * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), - * nonzero if position effect is enabled. - * Error messages can be retrieved from Mix_GetError( ). - * } - function Mix_SetDistance( channel : integer; distance : Uint8 ) : integer; - cdecl; external {$IFDEF __GPC__}name 'Mix_SetDistance'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; - {$EXTERNALSYM Mix_SetDistance} - { * - * !!! FIXME : Haven't implemented, since the effect goes past the - * end of the sound buffer.Will have to think about this. - * - -ryan. - * / - { if 0 - { * Causes an echo effect to be mixed into a sound.( echo ) is the amount - * of echo to mix.0 is no echo, 255 is infinite( and probably not - * what you want ). - * - * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and - * the reverbing will be done to the final mixed stream before passing it on - * to the audio device. - * - * This uses the Mix_RegisterEffect( )API internally.If you specify an echo - * of zero, the effect is unregistered, as the data is already in that state. - * - * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), - * nonzero if reversing effect is enabled. - * Error messages can be retrieved from Mix_GetError( ). - * - extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo ); - #E ndif} - { * Causes a channel to reverse its stereo.This is handy if the user has his - * speakers hooked up backwards, or you would like to have a minor bit of - * psychedelia in your sound code. : )Calling this function with ( flip ) - * set to non - zero reverses the chunks's usual channels. If (flip) is zero, - * the effect is unregistered. - * - * This uses the Mix_RegisterEffect( )API internally, and thus is probably - * more CPU intensive than having the user just plug in his speakers - * correctly.Mix_SetReverseStereo( )returns without registering the effect - * function if the audio device is not configured for stereo output. - * - * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used - * on the final mixed stream before sending it on to the audio device( a - * posteffect ). - * - * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), - * nonzero if reversing effect is enabled.Note that an audio device in mono - * mode is a no - op, but this call will return successful in that case . - * Error messages can be retrieved from Mix_GetError( ). - * } - function Mix_SetReverseStereo( channel : integer; flip : integer ) : integer; - cdecl; external {$IFDEF __GPC__}name 'Mix_SetReverseStereo'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; - {$EXTERNALSYM Mix_SetReverseStereo} - { end of effects API. - -ryan. *} - -{ Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate - them dynamically to the next sample if requested with a -1 value below. - Returns the number of reserved channels. - } -function Mix_ReserveChannels( num : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_ReserveChannels'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_ReserveChannels} - -{ Channel grouping functions } - -{ Attach a tag to a channel. A tag can be assigned to several mixer - channels, to form groups of channels. - If 'tag' is -1, the tag is removed (actually -1 is the tag used to - represent the group of all the channels). - Returns true if everything was OK. - } -function Mix_GroupChannel( which : integer; tag : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_GroupChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_GroupChannel} - -{ Assign several consecutive channels to a group } -function Mix_GroupChannels( from : integer; to_ : integer; tag : integer ) : -integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_GroupChannels'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_GroupChannels} - -{ Finds the first available channel in a group of channels } -function Mix_GroupAvailable( tag : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_GroupAvailable'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_GroupAvailable} - -{ Returns the number of channels in a group. This is also a subtle - way to get the total number of channels when 'tag' is -1 - } -function Mix_GroupCount( tag : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_GroupCount'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_GroupCount} - -{ Finds the "oldest" sample playing in a group of channels } -function Mix_GroupOldest( tag : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_GroupOldest'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_GroupOldest} - -{ Finds the "most recent" (i.e. last) sample playing in a group of channels } -function Mix_GroupNewer( tag : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_GroupNewer'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_GroupNewer} - -{ The same as above, but the sound is played at most 'ticks' milliseconds } -function Mix_PlayChannelTimed( channel : integer; chunk : PMix_Chunk; loops : integer; ticks : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_PlayChannelTimed'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_PlayChannelTimed} - -{ Play an audio chunk on a specific channel. - If the specified channel is -1, play on the first free channel. - If 'loops' is greater than zero, loop the sound that many times. - If 'loops' is -1, loop inifinitely (~65000 times). - Returns which channel was used to play the sound. -} -function Mix_PlayChannel( channel : integer; chunk : PMix_Chunk; loops : integer ) : integer; - -function Mix_PlayMusic( music : PMix_Music; loops : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_PlayMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_PlayMusic} - -{ Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions } -function Mix_FadeInMusic( music : PMix_Music; loops : integer; ms : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_FadeInMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_FadeInMusic} - -function Mix_FadeInChannelTimed( channel : integer; chunk : PMix_Chunk; loops : integer; ms : integer; ticks : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_FadeInChannelTimed'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_FadeInChannelTimed} - -function Mix_FadeInChannel( channel : integer; chunk : PMix_Chunk; loops : integer; ms : integer ) : integer; - -{ Set the volume in the range of 0-128 of a specific channel or chunk. - If the specified channel is -1, set volume for all channels. - Returns the original volume. - If the specified volume is -1, just return the current volume. -} -function Mix_Volume( channel : integer; volume : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_Volume'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_Volume} - -function Mix_VolumeChunk( chunk : PMix_Chunk; volume : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_VolumeChunk'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_VolumeChunk} - -function Mix_VolumeMusic( volume : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_VolumeMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_VolumeMusic} - -{ Halt playing of a particular channel } -function Mix_HaltChannel( channel : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_HaltChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_HaltChannel} - -function Mix_HaltGroup( tag : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_HaltGroup'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_HaltGroup} - -function Mix_HaltMusic : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_HaltMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_HaltMusic} - -{ Change the expiration delay for a particular channel. - The sample will stop playing after the 'ticks' milliseconds have elapsed, - or remove the expiration if 'ticks' is -1 -} -function Mix_ExpireChannel( channel : integer; ticks : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_ExpireChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_ExpireChannel} - -{ Halt a channel, fading it out progressively till it's silent - The ms parameter indicates the number of milliseconds the fading - will take. - } -function Mix_FadeOutChannel( which : integer; ms : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_FadeOutChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_FadeOutChannel} -function Mix_FadeOutGroup( tag : integer; ms : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_FadeOutGroup'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_FadeOutGroup} -function Mix_FadeOutMusic( ms : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_FadeOutMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_FadeOutMusic} - -{ Query the fading status of a channel } -function Mix_FadingMusic : TMix_Fading; -cdecl; external {$IFDEF __GPC__}name 'Mix_FadingMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_FadingMusic} - -function Mix_FadingChannel( which : integer ) : TMix_Fading; -cdecl; external {$IFDEF __GPC__}name 'Mix_FadingChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_FadingChannel} - -{ Pause/Resume a particular channel } -procedure Mix_Pause( channel : integer ); -cdecl; external {$IFDEF __GPC__}name 'Mix_Pause'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_Pause} - -procedure Mix_Resume( channel : integer ); -cdecl; external {$IFDEF __GPC__}name 'Mix_Resume'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_Resume} - -function Mix_Paused( channel : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_Paused'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_Paused} - -{ Pause/Resume the music stream } -procedure Mix_PauseMusic; -cdecl; external {$IFDEF __GPC__}name 'Mix_PauseMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_PauseMusic} - -procedure Mix_ResumeMusic; -cdecl; external {$IFDEF __GPC__}name 'Mix_ResumeMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_ResumeMusic} - -procedure Mix_RewindMusic; -cdecl; external {$IFDEF __GPC__}name 'Mix_RewindMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_RewindMusic} - -function Mix_PausedMusic : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_PausedMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_PausedMusic} - -{ Set the current position in the music stream. - This returns 0 if successful, or -1 if it failed or isn't implemented. - This function is only implemented for MOD music formats (set pattern - order number) and for OGG music (set position in seconds), at the - moment. -} -function Mix_SetMusicPosition( position : double ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_SetMusicPosition'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_SetMusicPosition} - -{ Check the status of a specific channel. - If the specified channel is -1, check all channels. -} -function Mix_Playing( channel : integer ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_Playing'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_Playing} - -function Mix_PlayingMusic : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_PlayingMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_PlayingMusic} - -{ Stop music and set external music playback command } -function Mix_SetMusicCMD( const command : PChar ) : integer; -cdecl; external {$IFDEF __GPC__}name 'Mix_SetMusicCMD'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_SetMusicCMD} - -{ Close the mixer, halting all playing audio } -procedure Mix_CloseAudio; -cdecl; external {$IFDEF __GPC__}name 'Mix_CloseAudio'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; -{$EXTERNALSYM Mix_CloseAudio} - -{ We'll use SDL for reporting errors } -procedure Mix_SetError( fmt : PChar ); - -function Mix_GetError : PChar; - -{------------------------------------------------------------------------------} -{ initialization } -{------------------------------------------------------------------------------} - -{------------------------------------------------------------------------------} - -implementation - -{$IFDEF __GPC__} - {$L 'sdl_mixer'} { link sdl_mixer.dll.a or libsdl_mixer.so or libsdl_mixer.a } -{$ENDIF} - -procedure SDL_MIXER_VERSION( var X : TSDL_version ); -begin - X.major := SDL_MIXER_MAJOR_VERSION; - X.minor := SDL_MIXER_MINOR_VERSION; - X.patch := SDL_MIXER_PATCHLEVEL; -end; - -function Mix_LoadWAV( filename : PChar ) : PMix_Chunk; -begin - result := Mix_LoadWAV_RW( SDL_RWFromFile( filename, 'rb' ), 1 ); -end; - -function Mix_PlayChannel( channel : integer; chunk : PMix_Chunk; loops : integer ) : integer; -begin - result := Mix_PlayChannelTimed( channel, chunk, loops, -1 ); -end; - -function Mix_FadeInChannel( channel : integer; chunk : PMix_Chunk; loops : - integer; ms : integer ) : integer; -begin - result := Mix_FadeInChannelTimed( channel, chunk, loops, ms, -1 ); -end; - -procedure Mix_SetError( fmt : PChar ); -begin - SDL_SetError( fmt ); -end; - -function Mix_GetError : PChar; -begin - result := SDL_GetError; -end; - -end. +unit sdl_mixer; +{******************************************************************************} +{ + $Id: sdl_mixer.pas,v 1.18 2007/05/29 21:31:44 savage Exp $ + +} +{ } +{ Borland Delphi SDL_Mixer - Simple DirectMedia Layer Mixer Library } +{ Conversion of the Simple DirectMedia Layer Headers } +{ } +{ Portions created by Sam Lantinga are } +{ Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga } +{ 5635-34 Springhouse Dr. } +{ Pleasanton, CA 94588 (USA) } +{ } +{ All Rights Reserved. } +{ } +{ The original files are : SDL_mixer.h } +{ music_cmd.h } +{ wavestream.h } +{ timidity.h } +{ playmidi.h } +{ music_ogg.h } +{ mikmod.h } +{ } +{ The initial developer of this Pascal code was : } +{ Dominqiue Louis } +{ } +{ Portions created by Dominqiue Louis are } +{ Copyright (C) 2000 - 2001 Dominqiue Louis. } +{ } +{ } +{ Contributor(s) } +{ -------------- } +{ Matthias Thoma } +{ } +{ Obtained through: } +{ Joint Endeavour of Delphi Innovators ( Project JEDI ) } +{ } +{ You may retrieve the latest version of this file at the Project } +{ JEDI home page, located at http://delphi-jedi.org } +{ } +{ The contents of this file are used with permission, subject to } +{ the Mozilla Public License Version 1.1 (the "License"); you may } +{ not use this file except in compliance with the License. You may } +{ obtain a copy of the License at } +{ http://www.mozilla.org/MPL/MPL-1.1.html } +{ } +{ Software distributed under the License is distributed on an } +{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or } +{ implied. See the License for the specific language governing } +{ rights and limitations under the License. } +{ } +{ Description } +{ ----------- } +{ } +{ } +{ } +{ } +{ } +{ } +{ } +{ Requires } +{ -------- } +{ SDL.pas & SMPEG.pas somewhere within your search path. } +{ } +{ Programming Notes } +{ ----------------- } +{ See the Aliens Demo to see how this library is used } +{ } +{ Revision History } +{ ---------------- } +{ April 02 2001 - DL : Initial Translation } +{ } +{ February 02 2002 - DL : Update to version 1.2.1 } +{ } +{ April 03 2003 - DL : Added jedi-sdl.inc include file to support more } +{ Pascal compilers. Initial support is now included } +{ for GnuPascal, VirtualPascal, TMT and obviously } +{ continue support for Delphi Kylix and FreePascal. } +{ } +{ April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added} +{ better TMT Pascal support and under instruction } +{ from Prof. Abimbola Olowofoyeku (The African Chief),} +{ I have added better Gnu Pascal support } +{ } +{ April 30 2003 - DL : under instruction from David Mears AKA } +{ Jason Siletto, I have added FPC Linux support. } +{ This was compiled with fpc 1.1, so remember to set } +{ include file path. ie. -Fi/usr/share/fpcsrc/rtl/* } +{ } +{ + $Log: sdl_mixer.pas,v $ + Revision 1.18 2007/05/29 21:31:44 savage + Changes as suggested by Almindor for 64bit compatibility. + + Revision 1.17 2007/05/20 20:31:17 savage + Initial Changes to Handle 64 Bits + + Revision 1.16 2006/12/02 00:16:17 savage + Updated to latest version + + Revision 1.15 2005/04/10 11:48:33 savage + Changes as suggested by Michalis, thanks. + + Revision 1.14 2005/02/24 20:20:07 savage + Changed definition of MusicType and added GetMusicType function + + Revision 1.13 2005/01/05 01:47:09 savage + Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively. + + Revision 1.12 2005/01/04 23:14:56 savage + Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively. + + Revision 1.11 2005/01/01 02:05:19 savage + Updated to v1.2.6 + + Revision 1.10 2004/09/12 21:45:17 savage + Robert Reed spotted that Mix_SetMusicPosition was missing from the conversion, so this has now been added. + + Revision 1.9 2004/08/27 21:48:24 savage + IFDEFed out Smpeg support on MacOS X + + Revision 1.8 2004/08/14 22:54:30 savage + Updated so that Library name defines are correctly defined for MacOS X. + + Revision 1.7 2004/05/10 14:10:04 savage + Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ). + + Revision 1.6 2004/04/13 09:32:08 savage + 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. + + Revision 1.5 2004/04/01 20:53:23 savage + Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site. + + Revision 1.4 2004/03/31 22:20:02 savage + Windows unit not used in this file, so it was removed to keep the code tidy. + + Revision 1.3 2004/03/31 10:05:08 savage + Better defines for Endianess under FreePascal and Borland compilers. + + Revision 1.2 2004/03/30 20:23:28 savage + Tidied up use of UNIX compiler directive. + + Revision 1.1 2004/02/14 23:35:42 savage + version 1 of sdl_image, sdl_mixer and smpeg. + + +} +{******************************************************************************} + +{$I jedi-sdl.inc} + +interface + +uses +{$IFDEF __GPC__} + gpc, +{$ENDIF} +{$IFNDEF DARWIN} +{$IFNDEF no_smpeg} + smpeg, +{$ENDIF} +{$ENDIF} + sdl; + +const +{$IFDEF WINDOWS} + SDL_MixerLibName = 'SDL_mixer.dll'; +{$ENDIF} + +{$IFDEF UNIX} +{$IFDEF DARWIN} + SDL_MixerLibName = 'libSDL_mixer-1.2.0.dylib'; +{$ELSE} + {$IFDEF FPC} + SDL_MixerLibName = 'libSDL_mixer.so'; + {$ELSE} + SDL_MixerLibName = 'libSDL_mixer-1.2.so.0'; + {$ENDIF} +{$ENDIF} +{$ENDIF} + +{$IFDEF MACOS} + SDL_MixerLibName = 'SDL_mixer'; +{$ENDIF} + + {* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *} + SDL_MIXER_MAJOR_VERSION = 1; +{$EXTERNALSYM MIX_MAJOR_VERSION} + SDL_MIXER_MINOR_VERSION = 2; +{$EXTERNALSYM MIX_MINOR_VERSION} + SDL_MIXER_PATCHLEVEL = 7; +{$EXTERNALSYM MIX_PATCHLEVEL} + + // Backwards compatibility + MIX_MAJOR_VERSION = SDL_MIXER_MAJOR_VERSION; + MIX_MINOR_VERSION = SDL_MIXER_MINOR_VERSION; + MIX_PATCHLEVEL = SDL_MIXER_PATCHLEVEL; + + // SDL_Mixer.h constants + { The default mixer has 8 simultaneous mixing channels } +{$IFNDEF MIX_CHANNELS} + MIX_CHANNELS = 8; +{$ENDIF} +{$EXTERNALSYM MIX_CHANNELS} + { Good default values for a PC soundcard } + MIX_DEFAULT_FREQUENCY = 22050; +{$EXTERNALSYM MIX_DEFAULT_FREQUENCY} + +{$IFDEF IA32} + MIX_DEFAULT_FORMAT = AUDIO_S16LSB; +{$ELSE} + MIX_DEFAULT_FORMAT = AUDIO_S16MSB; +{$ENDIF} +{$EXTERNALSYM MIX_DEFAULT_FORMAT} + + MIX_DEFAULT_CHANNELS = 2; +{$EXTERNALSYM MIX_DEFAULT_CHANNELS} + MIX_MAX_VOLUME = 128; { Volume of a chunk } +{$EXTERNALSYM MIX_MAX_VOLUME} + + PATH_MAX = 255; + + // mikmod.h constants + {* + * Library version + *} + LIBMIKMOD_VERSION_MAJOR = 3; + LIBMIKMOD_VERSION_MINOR = 1; + LIBMIKMOD_REVISION = 8; + LIBMIKMOD_VERSION = ( ( LIBMIKMOD_VERSION_MAJOR shl 16 ) or + ( LIBMIKMOD_VERSION_MINOR shl 8 ) or + ( LIBMIKMOD_REVISION ) ); + +type + //music_cmd.h types + PMusicCMD = ^TMusicCMD; + TMusicCMD = record + filename : array[ 0..PATH_MAX - 1 ] of char; + cmd : array[ 0..PATH_MAX - 1 ] of char; + pid : TSYS_ThreadHandle; + end; + + //wavestream.h types + PWAVStream = ^TWAVStream; + TWAVStream = record + wavefp : Pointer; + start : longint; + stop : longint; + cvt : TSDL_AudioCVT; + end; + + //playmidi.h types + PMidiEvent = ^TMidiEvent; + TMidiEvent = record + time : Longint; + channel : uint8; + type_ : uint8; + a : uint8; + b : uint8; + end; + + PMidiSong = ^TMidiSong; + TMidiSong = record + samples : Longint; + events : PMidiEvent; + end; + + //music_ogg.h types + POGG_Music = ^TOGG_Music; + TOGG_Music = record + playing : integer; + volume : integer; + //vf: OggVorbis_File; + section : integer; + cvt : TSDL_AudioCVT; + len_available : integer; + snd_available : PUint8; + end; + + // mikmod.h types + {* + * Error codes + *} + TErrorEnum = ( + MMERR_OPENING_FILE, + MMERR_OUT_OF_MEMORY, + MMERR_DYNAMIC_LINKING, + MMERR_SAMPLE_TOO_BIG, + MMERR_OUT_OF_HANDLES, + MMERR_UNKNOWN_WAVE_TYPE, + MMERR_LOADING_PATTERN, + MMERR_LOADING_TRACK, + MMERR_LOADING_HEADER, + MMERR_LOADING_SAMPLEINFO, + MMERR_NOT_A_MODULE, + MMERR_NOT_A_STREAM, + MMERR_MED_SYNTHSAMPLES, + MMERR_ITPACK_INVALID_DATA, + MMERR_DETECTING_DEVICE, + MMERR_INVALID_DEVICE, + MMERR_INITIALIZING_MIXER, + MMERR_OPENING_AUDIO, + MMERR_8BIT_ONLY, + MMERR_16BIT_ONLY, + MMERR_STEREO_ONLY, + MMERR_ULAW, + MMERR_NON_BLOCK, + MMERR_AF_AUDIO_PORT, + MMERR_AIX_CONFIG_INIT, + MMERR_AIX_CONFIG_CONTROL, + MMERR_AIX_CONFIG_START, + MMERR_GUS_SETTINGS, + MMERR_GUS_RESET, + MMERR_GUS_TIMER, + MMERR_HP_SETSAMPLESIZE, + MMERR_HP_SETSPEED, + MMERR_HP_CHANNELS, + MMERR_HP_AUDIO_OUTPUT, + MMERR_HP_AUDIO_DESC, + MMERR_HP_BUFFERSIZE, + MMERR_OSS_SETFRAGMENT, + MMERR_OSS_SETSAMPLESIZE, + MMERR_OSS_SETSTEREO, + MMERR_OSS_SETSPEED, + MMERR_SGI_SPEED, + MMERR_SGI_16BIT, + MMERR_SGI_8BIT, + MMERR_SGI_STEREO, + MMERR_SGI_MONO, + MMERR_SUN_INIT, + MMERR_OS2_MIXSETUP, + MMERR_OS2_SEMAPHORE, + MMERR_OS2_TIMER, + MMERR_OS2_THREAD, + MMERR_DS_PRIORITY, + MMERR_DS_BUFFER, + MMERR_DS_FORMAT, + MMERR_DS_NOTIFY, + MMERR_DS_EVENT, + MMERR_DS_THREAD, + MMERR_DS_UPDATE, + MMERR_WINMM_HANDLE, + MMERR_WINMM_ALLOCATED, + MMERR_WINMM_DEVICEID, + MMERR_WINMM_FORMAT, + MMERR_WINMM_UNKNOWN, + MMERR_MAC_SPEED, + MMERR_MAC_START, + MMERR_MAX + ); + + PMODULE = ^TMODULE; + TMODULE = record + (* general module information *) + //CHAR* songname; (* name of the song *) + //CHAR* modtype; (* string type of module loaded *) + //CHAR* comment; (* module comments *) + //UWORD flags; (* See module flags above *) + //UBYTE numchn; (* number of module channels *) + //UBYTE numvoices; (* max # voices used for full NNA playback *) + //UWORD numpos; (* number of positions in this song *) + //UWORD numpat; (* number of patterns in this song *) + //UWORD numins; (* number of instruments *) + //UWORD numsmp; (* number of samples *) + //type = record INSTRUMENT* instruments; (* all instruments *) + //type = record SAMPLE* samples; (* all samples *) + //UBYTE realchn; (* real number of channels used *) + //UBYTE totalchn; (* total number of channels used (incl NNAs) *) + (* playback settings *) + //UWORD reppos; (* restart position *) + //UBYTE initspeed; (* initial song speed *) + //UWORD inittempo; (* initial song tempo *) + //UBYTE initvolume; (* initial global volume (0 - 128) *) + //UWORD panning : array[ 0..64- 1 ] of ; (* 64 panning positions *) + //UBYTE chanvol : array[ 0..64- 1 ] of ; (* 64 channel positions *) + //UWORD bpm; (* current beats-per-minute speed *) + //UWORD sngspd; (* current song speed *) + //SWORD volume; (* song volume (0-128) (or user volume) *) + //BOOL extspd; (* extended speed flag (default enabled) *) + //BOOL panflag; (* panning flag (default enabled) *) + //BOOL wrap; (* wrap module ? (default disabled) *) + //BOOL loop; (* allow module to loop ? (default enabled) *) + //BOOL fadeout; (* volume fade out during last pattern *) + //UWORD patpos; (* current row number *) + //SWORD sngpos; (* current song position *) + //ULONG sngtime; (* current song time in 2^-10 seconds *) + //SWORD relspd; (* relative speed factor *) + (* internal module representation *) + //UWORD numtrk; (* number of tracks *) + //UBYTE** tracks; (* array of numtrk pointers to tracks *) + //UWORD* patterns; (* array of Patterns *) + //UWORD* pattrows; (* array of number of rows for each pattern *) + //UWORD* positions; (* all positions *) + //BOOL forbid; (* if true, no player updatenot *) + //UWORD numrow; (* number of rows on current pattern *) + //UWORD vbtick; (* tick counter (counts from 0 to sngspd) *) + //UWORD sngremainder;(* used for song time computation *) + //type = record MP_CONTROL* control; (* Effects Channel info (size pf.numchn) *) + //type = record MP_VOICE* voice; (* Audio Voice information (size md_numchn) *) + //UBYTE globalslide; (* global volume slide rate *) + //UBYTE pat_repcrazy;(* module has just looped to position -1 *) + //UWORD patbrk; (* position where to start a new pattern *) + //UBYTE patdly; (* patterndelay counter (command memory) *) + //UBYTE patdly2; (* patterndelay counter (real one) *) + //SWORD posjmp; (* flag to indicate a jump is needed... *) + end; + + PUNIMOD = ^TUNIMOD; + TUNIMOD = TMODULE; + + //SDL_mixer.h types + { The internal format for an audio chunk } + PMix_Chunk = ^TMix_Chunk; + TMix_Chunk = record + allocated : integer; + abuf : PUint8; + alen : Uint32; + volume : Uint8; { Per-sample volume, 0-128 } + end; + Mix_Chunk = TMix_Chunk; + + { The different fading types supported } + TMix_Fading = ( + MIX_NO_FADING, + MIX_FADING_OUT, + MIX_FADING_IN + ); + Mix_Fading = TMix_Fading; + + TMix_MusicType = ( + MUS_NONE, + MUS_CMD, + MUS_WAV, + MUS_MOD, + MUS_MID, + MUS_OGG, + MUS_MP3 + ); + Mix_MusicType = TMix_MusicType; + + TMusicUnion = record + case Byte of + 0 : ( cmd : PMusicCMD ); + 1 : ( wave : PWAVStream ); + 2 : ( module : PUNIMOD ); + 3 : ( midi : TMidiSong ); + 4 : ( ogg : POGG_music ); + {$IFNDEF DARWIN} + 5 : ( mp3 : PSMPEG ); + {$ENDIF} + end; + + P_Mix_Music = ^T_Mix_Music; + T_Mix_Music = record + type_ : TMix_MusicType; + data : TMusicUnion; + fading : TMix_Fading; + fade_volume : integer; + fade_step : integer; + fade_steps : integer; + error : integer; + end; + + { The internal format for a music chunk interpreted via mikmod } + PMix_Music = ^TMix_Music; + TMix_Music = T_Mix_Music; + + {$IFNDEF __GPC__} + TMixFunction = function( udata : Pointer; stream : PUint8; len : integer ) : Pointer; cdecl; + {$ELSE} + TMixFunction = function( udata : Pointer; stream : PUint8; len : integer ) : Pointer; + {$ENDIF} + +{ This macro can be used to fill a version structure with the compile-time + version of the SDL_mixer library. } +procedure SDL_MIXER_VERSION(var X: TSDL_Version); +{$EXTERNALSYM SDL_MIXER_VERSION} + +{ This function gets the version of the dynamically linked SDL_mixer library. + It should NOT be used to fill a version structure, instead you should use the + SDL_MIXER_VERSION() macro. } +function Mix_Linked_Version : PSDL_version; +cdecl; external {$IFDEF __GPC__}name 'Mix_Linked_Version'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_Linked_Version} + +{ Open the mixer with a certain audio format } +function Mix_OpenAudio( frequency : integer; format : Uint16; channels : + integer; chunksize : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_OpenAudio'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_OpenAudio} + +{ Dynamically change the number of channels managed by the mixer. + If decreasing the number of channels, the upper channels are + stopped. + This function returns the new number of allocated channels. + } +function Mix_AllocateChannels( numchannels : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_AllocateChannels'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_AllocateChannels} + +{ Find out what the actual audio device parameters are. + This function returns 1 if the audio has been opened, 0 otherwise. + } +function Mix_QuerySpec( var frequency : integer; var format : Uint16; var channels : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_QuerySpec'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_QuerySpec} + +{ Load a wave file or a music (.mod .s3m .it .xm) file } +function Mix_LoadWAV_RW( src : PSDL_RWops; freesrc : integer ) : PMix_Chunk; +cdecl; external {$IFDEF __GPC__}name 'Mix_LoadWAV_RW'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_LoadWAV_RW} + +function Mix_LoadWAV( filename : PChar ) : PMix_Chunk; + +function Mix_LoadMUS( const filename : PChar ) : PMix_Music; +cdecl; external {$IFDEF __GPC__}name 'Mix_LoadMUS'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_LoadMUS} + +(*#if 0 { This hasn't been hooked into music.c yet } +{ Load a music file from an SDL_RWop object (MikMod-specific currently) + Matt Campbell (matt@campbellhome.dhs.org) April 2000 } +function Mix_LoadMUS_RW(SDL_RWops *rw) : PMix_Music; cdecl; +#endif*) + +{ Load a wave file of the mixer format from a memory buffer } +function Mix_QuickLoad_WAV( mem : PUint8 ) : PMix_Chunk; +cdecl; external {$IFDEF __GPC__}name 'Mix_QuickLoad_WAV'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_QuickLoad_WAV} + +{ Free an audio chunk previously loaded } +procedure Mix_FreeChunk( chunk : PMix_Chunk ); +cdecl; external {$IFDEF __GPC__}name 'Mix_FreeChunk'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_FreeChunk} + +procedure Mix_FreeMusic( music : PMix_Music ); +cdecl; external {$IFDEF __GPC__}name 'Mix_FreeMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_FreeMusic} + +{ Find out the music format of a mixer music, or the currently playing + music, if 'music' is NULL.} +function Mix_GetMusicType( music : PMix_Music ) : TMix_MusicType; +cdecl; external {$IFDEF __GPC__}name 'Mix_GetMusicType'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_GetMusicType} + +{ Set a function that is called after all mixing is performed. + This can be used to provide real-time visual display of the audio stream + or add a custom mixer filter for the stream data. +} +procedure Mix_SetPostMix( mix_func : TMixFunction; arg : Pointer ); +cdecl; external {$IFDEF __GPC__}name 'Mix_SetPostMix'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_SetPostMix} + +{ Add your own music player or additional mixer function. + If 'mix_func' is NULL, the default music player is re-enabled. + } +procedure Mix_HookMusic( mix_func : TMixFunction; arg : Pointer ); + cdecl; external {$IFDEF __GPC__}name 'Mix_HookMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_HookMusic} + +{ Add your own callback when the music has finished playing. + } +procedure Mix_HookMusicFinished( music_finished : Pointer ); +cdecl; external {$IFDEF __GPC__}name 'Mix_HookMusicFinished'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_HookMusicFinished} + +{ Get a pointer to the user data for the current music hook } +function Mix_GetMusicHookData : Pointer; +cdecl; external {$IFDEF __GPC__}name 'Mix_GetMusicHookData'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_GetMusicHookData} + +{* Add your own callback when a channel has finished playing. NULL + * to disable callback.*} +type + {$IFNDEF __GPC__} + TChannel_finished = procedure( channel: Integer ); cdecl; + {$ELSE} + TChannel_finished = procedure( channel: Integer ); + {$ENDIF} + +procedure Mix_ChannelFinished( channel_finished : TChannel_finished ); +cdecl; external {$IFDEF __GPC__}name 'Mix_ChannelFinished'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_ChannelFinished} + +const + MIX_CHANNEL_POST = -2; + + {* This is the format of a special effect callback: + * + * myeffect(int chan, void *stream, int len, void *udata); + * + * (chan) is the channel number that your effect is affecting. (stream) is + * the buffer of data to work upon. (len) is the size of (stream), and + * (udata) is a user-defined bit of data, which you pass as the last arg of + * Mix_RegisterEffect(), and is passed back unmolested to your callback. + * Your effect changes the contents of (stream) based on whatever parameters + * are significant, or just leaves it be, if you prefer. You can do whatever + * you like to the buffer, though, and it will continue in its changed state + * down the mixing pipeline, through any other effect functions, then finally + * to be mixed with the rest of the channels and music for the final output + * stream. + *} +type + {$IFNDEF __GPC__} + TMix_EffectFunc = function( chan : integer; stream : Pointer; len : integer; udata : Pointer ) : Pointer; cdecl; + {$ELSE} + TMix_EffectFunc = function( chan : integer; stream : Pointer; len : integer; udata : Pointer ) : Pointer; + {$ENDIF} + {* + * This is a callback that signifies that a channel has finished all its + * loops and has completed playback. This gets called if the buffer + * plays out normally, or if you call Mix_HaltChannel(), implicitly stop + * a channel via Mix_AllocateChannels(), or unregister a callback while + * it's still playing. + *} + {$IFNDEF __GPC__} + TMix_EffectDone = function( chan : integer; udata : Pointer ) : Pointer; cdecl; + {$ELSE} + TMix_EffectDone = function( chan : integer; udata : Pointer ) : Pointer; + {$ENDIF} + {* Register a special effect function. At mixing time, the channel data is + * copied into a buffer and passed through each registered effect function. + * After it passes through all the functions, it is mixed into the final + * output stream. The copy to buffer is performed once, then each effect + * function performs on the output of the previous effect. Understand that + * this extra copy to a buffer is not performed if there are no effects + * registered for a given chunk, which saves CPU cycles, and any given + * effect will be extra cycles, too, so it is crucial that your code run + * fast. Also note that the data that your function is given is in the + * format of the sound device, and not the format you gave to Mix_OpenAudio(), + * although they may in reality be the same. This is an unfortunate but + * necessary speed concern. Use Mix_QuerySpec() to determine if you can + * handle the data before you register your effect, and take appropriate + * actions. + * You may also specify a callback (Mix_EffectDone_t) that is called when + * the channel finishes playing. This gives you a more fine-grained control + * than Mix_ChannelFinished(), in case you need to free effect-specific + * resources, etc. If you don't need this, you can specify NULL. + * You may set the callbacks before or after calling Mix_PlayChannel(). + * Things like Mix_SetPanning() are just internal special effect functions, + * so if you are using that, you've already incurred the overhead of a copy + * to a separate buffer, and that these effects will be in the queue with + * any functions you've registered. The list of registered effects for a + * channel is reset when a chunk finishes playing, so you need to explicitly + * set them with each call to Mix_PlayChannel*(). + * You may also register a special effect function that is to be run after + * final mixing occurs. The rules for these callbacks are identical to those + * in Mix_RegisterEffect, but they are run after all the channels and the + * music have been mixed into a single stream, whereas channel-specific + * effects run on a given channel before any other mixing occurs. These + * global effect callbacks are call "posteffects". Posteffects only have + * their Mix_EffectDone_t function called when they are unregistered (since + * the main output stream is never "done" in the same sense as a channel). + * You must unregister them manually when you've had enough. Your callback + * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the + * processing is considered a posteffect. + * + * After all these effects have finished processing, the callback registered + * through Mix_SetPostMix() runs, and then the stream goes to the audio + * device. + * + * returns zero if error (no such channel), nonzero if added. + * Error messages can be retrieved from Mix_GetError(). + *} +function Mix_RegisterEffect( chan : integer; f : TMix_EffectFunc; d : TMix_EffectDone; arg : Pointer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_RegisterEffect'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_RegisterEffect} + +{* You may not need to call this explicitly, unless you need to stop an + * effect from processing in the middle of a chunk's playback. + * Posteffects are never implicitly unregistered as they are for channels, + * but they may be explicitly unregistered through this function by + * specifying MIX_CHANNEL_POST for a channel. + * returns zero if error (no such channel or effect), nonzero if removed. + * Error messages can be retrieved from Mix_GetError(). + *} +function Mix_UnregisterEffect( channel : integer; f : TMix_EffectFunc ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_UnregisterEffect'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_UnregisterEffect} + + {* You may not need to call this explicitly, unless you need to stop all + * effects from processing in the middle of a chunk's playback. Note that + * this will also shut off some internal effect processing, since + * Mix_SetPanning( ) and others may use this API under the hood.This is + * called internally when a channel completes playback. + * Posteffects are never implicitly unregistered as they are for channels, + * but they may be explicitly unregistered through this function by + * specifying MIX_CHANNEL_POST for a channel. + * returns zero if error( no such channel ), nonzero if all effects removed. + * Error messages can be retrieved from Mix_GetError( ). + *} +function Mix_UnregisterAllEffects( channel : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_UnregisterAllEffects'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_UnregisterAllEffects} + +const + MIX_EFFECTSMAXSPEED = 'MIX_EFFECTSMAXSPEED'; + + {* + * These are the internally - defined mixing effects.They use the same API that + * effects defined in the application use, but are provided here as a + * convenience.Some effects can reduce their quality or use more memory in + * the name of speed; to enable this, make sure the environment variable + * MIX_EFFECTSMAXSPEED( see above ) is defined before you call + * Mix_OpenAudio( ). + * } + + {* set the panning of a channel.The left and right channels are specified + * as integers between 0 and 255, quietest to loudest, respectively. + * + * Technically, this is just individual volume control for a sample with + * two( stereo )channels, so it can be used for more than just panning. + * if you want real panning, call it like this : + * + * Mix_SetPanning( channel, left, 255 - left ); + * + * ...which isn't so hard. + * + * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + * the panning will be done to the final mixed stream before passing it on + * to the audio device. + * + * This uses the Mix_RegisterEffect( )API internally, and returns without + * registering the effect function if the audio device is not configured + * for stereo output.Setting both( left ) and ( right ) to 255 causes this + * effect to be unregistered, since that is the data's normal state. + * + * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + * nonzero if panning effect enabled.Note that an audio device in mono + * mode is a no - op, but this call will return successful in that case . + * Error messages can be retrieved from Mix_GetError( ). + * } + function Mix_SetPanning( channel : integer; left : Uint8; right : Uint8 ) : integer; + cdecl; external {$IFDEF __GPC__}name 'Mix_SetPanning'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; + {$EXTERNALSYM Mix_SetPanning} + + { * set the position ofa channel.( angle ) is an integer from 0 to 360, that + * specifies the location of the sound in relation to the listener.( angle ) + * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ). + * Angle 0 is due north, and rotates clockwise as the value increases. + * for efficiency, the precision of this effect may be limited( angles 1 + * through 7 might all produce the same effect, 8 through 15 are equal, etc ). + * ( distance ) is an integer between 0 and 255 that specifies the space + * between the sound and the listener.The larger the number, the further + * away the sound is .Using 255 does not guarantee that the channel will be + * culled from the mixing process or be completely silent.For efficiency, + * the precision of this effect may be limited( distance 0 through 5 might + * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle ) + * and ( distance ) to 0 unregisters this effect, since the data would be + * unchanged. + * + * if you need more precise positional audio, consider using OpenAL for + * spatialized effects instead of SDL_mixer.This is only meant to be a + * basic effect for simple "3D" games. + * + * if the audio device is configured for mono output, then you won't get + * any effectiveness from the angle; however, distance attenuation on the + * channel will still occur.While this effect will function with stereo + * voices, it makes more sense to use voices with only one channel of sound, + * so when they are mixed through this effect, the positioning will sound + * correct.You can convert them to mono through SDL before giving them to + * the mixer in the first place if you like. + * + * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + * the positioning will be done to the final mixed stream before passing it + * on to the audio device. + * + * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ). + * + * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + * nonzero if position effect is enabled. + * Error messages can be retrieved from Mix_GetError( ). + * } + function Mix_SetPosition( channel :integer; angle : Sint16; distance : Uint8 ) : integer; + cdecl; external {$IFDEF __GPC__}name 'Mix_SetPosition'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; + {$EXTERNALSYM Mix_SetPosition} + + {* set the "distance" of a channel.( distance ) is an integer from 0 to 255 + * that specifies the location of the sound in relation to the listener. + * Distance 0 is overlapping the listener, and 255 is as far away as possible + * A distance of 255 does not guarantee silence; in such a case , you might + * want to try changing the chunk's volume, or just cull the sample from the + * mixing process with Mix_HaltChannel( ). + * for efficiency, the precision of this effect may be limited( distances 1 + * through 7 might all produce the same effect, 8 through 15 are equal, etc ). + * ( distance ) is an integer between 0 and 255 that specifies the space + * between the sound and the listener.The larger the number, the further + * away the sound is . + * Setting( distance ) to 0 unregisters this effect, since the data would be + * unchanged. + * if you need more precise positional audio, consider using OpenAL for + * spatialized effects instead of SDL_mixer.This is only meant to be a + * basic effect for simple "3D" games. + * + * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + * the distance attenuation will be done to the final mixed stream before + * passing it on to the audio device. + * + * This uses the Mix_RegisterEffect( )API internally. + * + * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + * nonzero if position effect is enabled. + * Error messages can be retrieved from Mix_GetError( ). + * } + function Mix_SetDistance( channel : integer; distance : Uint8 ) : integer; + cdecl; external {$IFDEF __GPC__}name 'Mix_SetDistance'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; + {$EXTERNALSYM Mix_SetDistance} + { * + * !!! FIXME : Haven't implemented, since the effect goes past the + * end of the sound buffer.Will have to think about this. + * - -ryan. + * / + { if 0 + { * Causes an echo effect to be mixed into a sound.( echo ) is the amount + * of echo to mix.0 is no echo, 255 is infinite( and probably not + * what you want ). + * + * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and + * the reverbing will be done to the final mixed stream before passing it on + * to the audio device. + * + * This uses the Mix_RegisterEffect( )API internally.If you specify an echo + * of zero, the effect is unregistered, as the data is already in that state. + * + * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + * nonzero if reversing effect is enabled. + * Error messages can be retrieved from Mix_GetError( ). + * + extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo ); + #E ndif} + { * Causes a channel to reverse its stereo.This is handy if the user has his + * speakers hooked up backwards, or you would like to have a minor bit of + * psychedelia in your sound code. : )Calling this function with ( flip ) + * set to non - zero reverses the chunks's usual channels. If (flip) is zero, + * the effect is unregistered. + * + * This uses the Mix_RegisterEffect( )API internally, and thus is probably + * more CPU intensive than having the user just plug in his speakers + * correctly.Mix_SetReverseStereo( )returns without registering the effect + * function if the audio device is not configured for stereo output. + * + * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used + * on the final mixed stream before sending it on to the audio device( a + * posteffect ). + * + * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), + * nonzero if reversing effect is enabled.Note that an audio device in mono + * mode is a no - op, but this call will return successful in that case . + * Error messages can be retrieved from Mix_GetError( ). + * } + function Mix_SetReverseStereo( channel : integer; flip : integer ) : integer; + cdecl; external {$IFDEF __GPC__}name 'Mix_SetReverseStereo'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; + {$EXTERNALSYM Mix_SetReverseStereo} + { end of effects API. - -ryan. *} + +{ Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate + them dynamically to the next sample if requested with a -1 value below. + Returns the number of reserved channels. + } +function Mix_ReserveChannels( num : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_ReserveChannels'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_ReserveChannels} + +{ Channel grouping functions } + +{ Attach a tag to a channel. A tag can be assigned to several mixer + channels, to form groups of channels. + If 'tag' is -1, the tag is removed (actually -1 is the tag used to + represent the group of all the channels). + Returns true if everything was OK. + } +function Mix_GroupChannel( which : integer; tag : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_GroupChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_GroupChannel} + +{ Assign several consecutive channels to a group } +function Mix_GroupChannels( from : integer; to_ : integer; tag : integer ) : +integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_GroupChannels'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_GroupChannels} + +{ Finds the first available channel in a group of channels } +function Mix_GroupAvailable( tag : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_GroupAvailable'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_GroupAvailable} + +{ Returns the number of channels in a group. This is also a subtle + way to get the total number of channels when 'tag' is -1 + } +function Mix_GroupCount( tag : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_GroupCount'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_GroupCount} + +{ Finds the "oldest" sample playing in a group of channels } +function Mix_GroupOldest( tag : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_GroupOldest'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_GroupOldest} + +{ Finds the "most recent" (i.e. last) sample playing in a group of channels } +function Mix_GroupNewer( tag : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_GroupNewer'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_GroupNewer} + +{ The same as above, but the sound is played at most 'ticks' milliseconds } +function Mix_PlayChannelTimed( channel : integer; chunk : PMix_Chunk; loops : integer; ticks : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_PlayChannelTimed'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_PlayChannelTimed} + +{ Play an audio chunk on a specific channel. + If the specified channel is -1, play on the first free channel. + If 'loops' is greater than zero, loop the sound that many times. + If 'loops' is -1, loop inifinitely (~65000 times). + Returns which channel was used to play the sound. +} +function Mix_PlayChannel( channel : integer; chunk : PMix_Chunk; loops : integer ) : integer; + +function Mix_PlayMusic( music : PMix_Music; loops : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_PlayMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_PlayMusic} + +{ Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions } +function Mix_FadeInMusic( music : PMix_Music; loops : integer; ms : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_FadeInMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_FadeInMusic} + +function Mix_FadeInChannelTimed( channel : integer; chunk : PMix_Chunk; loops : integer; ms : integer; ticks : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_FadeInChannelTimed'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_FadeInChannelTimed} + +function Mix_FadeInChannel( channel : integer; chunk : PMix_Chunk; loops : integer; ms : integer ) : integer; + +{ Set the volume in the range of 0-128 of a specific channel or chunk. + If the specified channel is -1, set volume for all channels. + Returns the original volume. + If the specified volume is -1, just return the current volume. +} +function Mix_Volume( channel : integer; volume : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_Volume'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_Volume} + +function Mix_VolumeChunk( chunk : PMix_Chunk; volume : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_VolumeChunk'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_VolumeChunk} + +function Mix_VolumeMusic( volume : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_VolumeMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_VolumeMusic} + +{ Halt playing of a particular channel } +function Mix_HaltChannel( channel : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_HaltChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_HaltChannel} + +function Mix_HaltGroup( tag : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_HaltGroup'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_HaltGroup} + +function Mix_HaltMusic : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_HaltMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_HaltMusic} + +{ Change the expiration delay for a particular channel. + The sample will stop playing after the 'ticks' milliseconds have elapsed, + or remove the expiration if 'ticks' is -1 +} +function Mix_ExpireChannel( channel : integer; ticks : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_ExpireChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_ExpireChannel} + +{ Halt a channel, fading it out progressively till it's silent + The ms parameter indicates the number of milliseconds the fading + will take. + } +function Mix_FadeOutChannel( which : integer; ms : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_FadeOutChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_FadeOutChannel} +function Mix_FadeOutGroup( tag : integer; ms : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_FadeOutGroup'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_FadeOutGroup} +function Mix_FadeOutMusic( ms : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_FadeOutMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_FadeOutMusic} + +{ Query the fading status of a channel } +function Mix_FadingMusic : TMix_Fading; +cdecl; external {$IFDEF __GPC__}name 'Mix_FadingMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_FadingMusic} + +function Mix_FadingChannel( which : integer ) : TMix_Fading; +cdecl; external {$IFDEF __GPC__}name 'Mix_FadingChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_FadingChannel} + +{ Pause/Resume a particular channel } +procedure Mix_Pause( channel : integer ); +cdecl; external {$IFDEF __GPC__}name 'Mix_Pause'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_Pause} + +procedure Mix_Resume( channel : integer ); +cdecl; external {$IFDEF __GPC__}name 'Mix_Resume'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_Resume} + +function Mix_Paused( channel : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_Paused'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_Paused} + +{ Pause/Resume the music stream } +procedure Mix_PauseMusic; +cdecl; external {$IFDEF __GPC__}name 'Mix_PauseMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_PauseMusic} + +procedure Mix_ResumeMusic; +cdecl; external {$IFDEF __GPC__}name 'Mix_ResumeMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_ResumeMusic} + +procedure Mix_RewindMusic; +cdecl; external {$IFDEF __GPC__}name 'Mix_RewindMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_RewindMusic} + +function Mix_PausedMusic : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_PausedMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_PausedMusic} + +{ Set the current position in the music stream. + This returns 0 if successful, or -1 if it failed or isn't implemented. + This function is only implemented for MOD music formats (set pattern + order number) and for OGG music (set position in seconds), at the + moment. +} +function Mix_SetMusicPosition( position : double ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_SetMusicPosition'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_SetMusicPosition} + +{ Check the status of a specific channel. + If the specified channel is -1, check all channels. +} +function Mix_Playing( channel : integer ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_Playing'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_Playing} + +function Mix_PlayingMusic : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_PlayingMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_PlayingMusic} + +{ Stop music and set external music playback command } +function Mix_SetMusicCMD( const command : PChar ) : integer; +cdecl; external {$IFDEF __GPC__}name 'Mix_SetMusicCMD'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_SetMusicCMD} + +{ Synchro value is set by MikMod from modules while playing } +function Mix_SetSynchroValue( value : integer ) : integer; overload; +cdecl; external {$IFDEF __GPC__}name 'Mix_SetSynchroValue'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_SetSynchroValue} + +function Mix_GetSynchroValue : integer; overload; +cdecl; external {$IFDEF __GPC__}name 'Mix_GetSynchroValue'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_SetSynchroValue} + +{ + Get the Mix_Chunk currently associated with a mixer channel + Returns nil if it's an invalid channel, or there's no chunk associated. +} +function Mix_GetChunk( channel : integer ) : PMix_Chunk; +cdecl; external {$IFDEF __GPC__}name 'Mix_GetChunk'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_GetChunk} + +{ Close the mixer, halting all playing audio } +procedure Mix_CloseAudio; +cdecl; external {$IFDEF __GPC__}name 'Mix_CloseAudio'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__}; +{$EXTERNALSYM Mix_CloseAudio} + +{ We'll use SDL for reporting errors } +procedure Mix_SetError( fmt : PChar ); + +function Mix_GetError : PChar; + +{------------------------------------------------------------------------------} +{ initialization } +{------------------------------------------------------------------------------} + +{------------------------------------------------------------------------------} + +implementation + +{$IFDEF __GPC__} + {$L 'sdl_mixer'} { link sdl_mixer.dll.a or libsdl_mixer.so or libsdl_mixer.a } +{$ENDIF} + +procedure SDL_MIXER_VERSION( var X : TSDL_version ); +begin + X.major := SDL_MIXER_MAJOR_VERSION; + X.minor := SDL_MIXER_MINOR_VERSION; + X.patch := SDL_MIXER_PATCHLEVEL; +end; + +function Mix_LoadWAV( filename : PChar ) : PMix_Chunk; +begin + result := Mix_LoadWAV_RW( SDL_RWFromFile( filename, 'rb' ), 1 ); +end; + +function Mix_PlayChannel( channel : integer; chunk : PMix_Chunk; loops : integer ) : integer; +begin + result := Mix_PlayChannelTimed( channel, chunk, loops, -1 ); +end; + +function Mix_FadeInChannel( channel : integer; chunk : PMix_Chunk; loops : + integer; ms : integer ) : integer; +begin + result := Mix_FadeInChannelTimed( channel, chunk, loops, ms, -1 ); +end; + +procedure Mix_SetError( fmt : PChar ); +begin + SDL_SetError( fmt ); +end; + +function Mix_GetError : PChar; +begin + result := SDL_GetError; +end; + +end. \ No newline at end of file diff --git a/packages/extra/sdl/sdl_ttf.pas b/packages/extra/sdl/sdl_ttf.pas index 00bcc0a292..22424944c9 100644 --- a/packages/extra/sdl/sdl_ttf.pas +++ b/packages/extra/sdl/sdl_ttf.pas @@ -1,6 +1,6 @@ unit sdl_ttf; { - $Id: sdl_ttf.pas,v 1.10 2005/01/02 19:07:32 savage Exp $ + $Id: sdl_ttf.pas,v 1.18 2007/06/01 11:16:33 savage Exp $ } {******************************************************************************} @@ -87,6 +87,30 @@ unit sdl_ttf; { } { $Log: sdl_ttf.pas,v $ + Revision 1.18 2007/06/01 11:16:33 savage + Added IFDEF UNIX for Workaround. + + Revision 1.17 2007/06/01 08:38:21 savage + Added TTF_RenderText_Solid workaround as suggested by Michalis Kamburelis + + Revision 1.16 2007/05/29 21:32:14 savage + Changes as suggested by Almindor for 64bit compatibility. + + Revision 1.15 2007/05/20 20:32:45 savage + Initial Changes to Handle 64 Bits + + Revision 1.14 2006/12/02 00:19:01 savage + Updated to latest version + + Revision 1.13 2005/04/10 11:48:33 savage + Changes as suggested by Michalis, thanks. + + Revision 1.12 2005/01/05 01:47:14 savage + Changed LibName to reflect what MacOS X should have. ie libSDL*-1.2.0.dylib respectively. + + Revision 1.11 2005/01/04 23:14:57 savage + Changed LibName to reflect what most Linux distros will have. ie libSDL*-1.2.so.0 respectively. + Revision 1.10 2005/01/02 19:07:32 savage Slight bug fix to use LongInt instead of Long ( Thanks Michalis Kamburelis ) @@ -124,24 +148,46 @@ unit sdl_ttf; {$I jedi-sdl.inc} +{ + Define this to workaround a known bug in some freetype versions. + The error manifests as TTF_RenderGlyph_Solid returning nil (error) + and error message (in SDL_Error) is + "Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable" + See [http://lists.libsdl.org/pipermail/sdl-libsdl.org/2007-March/060459.html] +} +{$IFDEF UNIX} +{$DEFINE Workaround_TTF_RenderText_Solid} +{$ENDIF} + + interface uses -{$IFDEF windows} +{$IFDEF __GPC__} + gpc, +{$ENDIF} + +{$IFDEF WINDOWS} + {$IFNDEF __GPC__} Windows, + {$ENDIF} {$ENDIF} sdl; const -{$IFDEF windows} +{$IFDEF WINDOWS} SDLttfLibName = 'SDL_ttf.dll'; {$ENDIF} {$IFDEF UNIX} {$IFDEF DARWIN} - SDLttfLibName = 'libSDL_ttf.dylib'; + SDLttfLibName = 'libSDL_ttf-2.0.0.dylib'; {$ELSE} - SDLttfLibName = 'libSDL_ttf.so'; + {$IFDEF FPC} + SDLttfLibName = 'libSDL_ttf.so'; + {$ELSE} + SDLttfLibName = 'libSDL_ttf-2.0.so.0'; + {$ENDIF} {$ENDIF} {$ENDIF} @@ -154,7 +200,7 @@ const {$EXTERNALSYM SDL_TTF_MAJOR_VERSION} SDL_TTF_MINOR_VERSION = 0; {$EXTERNALSYM SDL_TTF_MINOR_VERSION} - SDL_TTF_PATCHLEVEL = 7; + SDL_TTF_PATCHLEVEL = 8; {$EXTERNALSYM SDL_TTF_PATCHLEVEL} // Backwards compatibility @@ -306,8 +352,10 @@ cdecl; external {$IFDEF __GPC__}name 'TTF_SizeUNICODE'{$ELSE} SDLttfLibName{$END } function TTF_RenderText_Solid( font : PTTF_Font; const text : PChar; fg : TSDL_Color ): PSDL_Surface; +{$IFNDEF Workaround_TTF_RenderText_Solid} cdecl; external {$IFDEF __GPC__}name 'TTF_RenderText_Solid'{$ELSE} SDLttfLibName{$ENDIF __GPC__}; {$EXTERNALSYM TTF_RenderText_Solid} +{$ENDIF} function TTF_RenderUTF8_Solid( font : PTTF_Font; const text : PChar; fg : TSDL_Color ): PSDL_Surface; @@ -440,4 +488,14 @@ begin result := SDL_GetError; end; +{$IFDEF Workaround_TTF_RenderText_Solid} +function TTF_RenderText_Solid( font : PTTF_Font; + const text : PChar; fg : TSDL_Color ): PSDL_Surface; +const + Black: TSDL_Color = (r: 0; g: 0; b: 0; unused: 0); +begin + Result := TTF_RenderText_Shaded(font, text, fg, Black); +end; +{$ENDIF Workaround_TTF_RenderText_Solid} + end. diff --git a/packages/extra/sdl/sdlgameinterface.pas b/packages/extra/sdl/sdlgameinterface.pas index 2c5fa2b3fa..9a58ff40b1 100644 --- a/packages/extra/sdl/sdlgameinterface.pas +++ b/packages/extra/sdl/sdlgameinterface.pas @@ -1,6 +1,6 @@ unit sdlgameinterface; { - $Id: sdlgameinterface.pas,v 1.3 2004/10/17 18:41:49 savage Exp $ + $Id: sdlgameinterface.pas,v 1.4 2005/08/03 18:57:31 savage Exp $ } {******************************************************************************} @@ -62,6 +62,9 @@ unit sdlgameinterface; { September 23 2004 - DL : Initial Creation } { $Log: sdlgameinterface.pas,v $ + Revision 1.4 2005/08/03 18:57:31 savage + Various updates and additions. Mainly to handle OpenGL 3D Window support and better cursor support for the mouse class + Revision 1.3 2004/10/17 18:41:49 savage Slight Change to allow Reseting of Input Event handlers @@ -97,11 +100,11 @@ type procedure MouseWheelScroll( WheelDelta : Integer; Shift: TSDLMod; MousePos : TPoint ); virtual; procedure KeyDown( var Key: TSDLKey; Shift: TSDLMod; unicode : UInt16 ); virtual; public - MainWindow : TSDL2DWindow; + MainWindow : TSDLCustomWindow; procedure ResetInputManager; procedure LoadSurfaces; virtual; function PointIsInRect( Point : TPoint; x, y, x1, y1 : integer ) : Boolean; - constructor Create( const aMainWindow : TSDL2DWindow ); + constructor Create( const aMainWindow : TSDLCustomWindow ); destructor Destroy; override; property NextGameInterface : TGameInterfaceClass read FNextGameInterface write FNextGameInterface; end; @@ -114,7 +117,7 @@ begin FNextGameInterface := nil; end; -constructor TGameInterface.Create( const aMainWindow : TSDL2DWindow ); +constructor TGameInterface.Create( const aMainWindow : TSDLCustomWindow ); begin inherited Create; MainWindow := aMainWindow; @@ -176,14 +179,18 @@ begin end; procedure TGameInterface.ResetInputManager; +var + temp : TSDLNotifyEvent; begin MainWindow.InputManager.Mouse.OnMouseDown := MouseDown; MainWindow.InputManager.Mouse.OnMouseMove := MouseMove; MainWindow.InputManager.Mouse.OnMouseUp := MouseUp; MainWindow.InputManager.Mouse.OnMouseWheel := MouseWheelScroll; MainWindow.InputManager.KeyBoard.OnKeyDown := KeyDown; - MainWindow.OnRender := Render; - MainWindow.OnClose := Close; + temp := Render; + MainWindow.OnRender := temp; + temp := Close; + MainWindow.OnClose := temp; MainWindow.OnUpdate := Update; end; diff --git a/packages/extra/sdl/sdlinput.pas b/packages/extra/sdl/sdlinput.pas index 5798d0d43c..c58c185137 100644 --- a/packages/extra/sdl/sdlinput.pas +++ b/packages/extra/sdl/sdlinput.pas @@ -1,6 +1,6 @@ unit sdlinput; { - $Id: sdlinput.pas,v 1.7 2004/09/30 22:32:04 savage Exp $ + $Id: sdlinput.pas,v 1.8 2005/08/03 18:57:32 savage Exp $ } {******************************************************************************} @@ -60,6 +60,9 @@ unit sdlinput; { February 02 2004 - DL : Added Custom Cursor Support to the Mouse class } { $Log: sdlinput.pas,v $ + Revision 1.8 2005/08/03 18:57:32 savage + Various updates and additions. Mainly to handle OpenGL 3D Window support and better cursor support for the mouse class + Revision 1.7 2004/09/30 22:32:04 savage Updated with slightly different header comments @@ -187,6 +190,41 @@ type TSDLMouseMoveEvent = procedure ( Shift: TSDLMod; CurrentPos : TPoint; RelativePos : TPoint ) {$IFNDEF NOT_OO}of object{$ENDIF}; TSDLMouseWheelEvent = procedure ( WheelDelta : Integer; Shift: TSDLMod; MousePos : TPoint ) {$IFNDEF NOT_OO}of object{$ENDIF}; + TSDLCustomCursor = class( TObject ) + private + FFileName : string; + FHotPoint: TPoint; + procedure SetFileName(const aValue: string ); + function ScanForChar( str : string; ch : Char; startPos : Integer; lookFor : Boolean ) : Integer; + public + constructor Create( const aFileName : string; aHotPoint: TPoint ); + procedure LoadFromFile( const aFileName : string ); virtual; abstract; + procedure LoadFromStream( aStream : TStream ); virtual; abstract; + procedure Show; virtual; abstract; + property FileName : string read FFileName write SetFileName; + property HotPoint : TPoint read FHotPoint write FHotPoint; + end; + + TSDLXPMCursor = class( TSDLCustomCursor ) + private + FCursor : PSDL_Cursor; + procedure FreeCursor; + public + destructor Destroy; override; + procedure LoadFromFile( const aFileName : string ); override; + procedure LoadFromStream( aStream : TStream ); override; + procedure Show; override; + end; + + TSDLCursorList = class( TStringList ) + protected + function GetObject( aIndex : Integer ): TSDLCustomCursor; reintroduce; + procedure PutObject( aIndex : Integer; AObject : TSDLCustomCursor); reintroduce; + public + constructor Create; + function AddCursor(const aName : string; aObject : TSDLCustomCursor): Integer; virtual; + end; + TSDLMouse = class( TSDLCustomInput ) private FDragging : Boolean; @@ -195,7 +233,7 @@ type FOnMouseDown: TSDLMouseButtonEvent; FOnMouseMove: TSDLMouseMoveEvent; FOnMouseWheel: TSDLMouseWheelEvent; - FCursor : PSDL_Cursor; // Cursor Pointer + FCursorList : TSDLCursorList; // Cursor Pointer procedure DoMouseMove( Event: TSDL_Event ); procedure DoMouseDown( Event: TSDL_Event ); procedure DoMouseUp( Event: TSDL_Event ); @@ -207,7 +245,6 @@ type function UpdateInput( event: TSDL_EVENT ) : Boolean; override; function MouseIsDown( Button : Integer ) : Boolean; function MouseIsUp( Button : Integer ) : Boolean; - procedure SetCursor(data, mask: PUInt8; w, h, hot_x, hot_y: Integer); procedure ShowCursor; procedure HideCursor; property OnMouseDown : TSDLMouseButtonEvent read FOnMouseDown write FOnMouseDown; @@ -215,6 +252,7 @@ type property OnMouseMove : TSDLMouseMoveEvent read FOnMouseMove write FOnMouseMove; property OnMouseWheel : TSDLMouseWheelEvent read FOnMouseWheel write FOnMouseWheel; property MousePosition : TPoint read GetMousePosition write SetMousePosition; + property Cursors : TSDLCursorList read FCursorList write FCursorList; end; TSDLInputManager = class( TObject ) @@ -235,6 +273,9 @@ type implementation +uses + SysUtils; + { TSDLCustomInput } constructor TSDLCustomInput.Create; begin @@ -355,8 +396,7 @@ end; { TSDLMouse } destructor TSDLMouse.Destroy; begin - if FCursor <> nil then - SDL_FreeCursor( FCursor ); + inherited; end; @@ -442,17 +482,6 @@ begin Result := not ( SDL_GetMouseState( FMousePos.X, FMousePos.Y ) and SDL_BUTTON( Button ) = 0 ); end; -procedure TSDLMouse.SetCursor(data, mask: PUInt8; w, h, hot_x, hot_y: Integer); -begin - if FCursor <> nil then - SDL_FreeCursor( FCursor ); - // create the cursor - FCursor := SDL_CreateCursor( data, mask, w, h, hot_x, hot_y ); - - // set the cursor - SDL_SetCursor( FCursor ); -end; - procedure TSDLMouse.SetMousePosition(const Value: TPoint); begin SDL_WarpMouse( Value.x, Value.y ); @@ -689,4 +718,194 @@ begin end; end; +{ TSDLCustomCursor } + +constructor TSDLCustomCursor.Create(const aFileName: string; aHotPoint: TPoint); +begin + inherited Create; + FHotPoint := aHotPoint; + LoadFromFile( aFileName ); +end; + +function TSDLCustomCursor.ScanForChar(str: string; ch: Char; + startPos: Integer; lookFor: Boolean): Integer; +begin + Result := -1; + while ( ( ( str[ startPos ] = ch ) <> lookFor ) and ( startPos < Length( str ) ) ) do + inc( startPos ); + if startPos <> Length( str ) then + Result := startPos; +end; + +procedure TSDLCustomCursor.SetFileName(const aValue: string); +begin + LoadFromFile( aValue ); +end; + +{ TSDLXPMCursor } + +destructor TSDLXPMCursor.Destroy; +begin + FreeCursor; + inherited; +end; + +procedure TSDLXPMCursor.FreeCursor; +begin + if FCursor <> nil then + begin + SDL_FreeCursor( FCursor ); + FFileName := ''; + end; +end; + +procedure TSDLXPMCursor.LoadFromFile(const aFileName: string); +var + xpmFile : Textfile; + step : Integer; + holdPos : Integer; + counter : Integer; + dimensions : array[ 1..3 ] of Integer; + clr, clrNone, clrBlack, clrWhite : Char; + data, mask : array of UInt8; + i, col : Integer; + LineString : string; +begin + FreeCursor; + AssignFile( xpmFile, aFileName ); + Reset( xpmFile ); + step := 0; + i := -1; + clrBlack := 'X'; + clrWhite := ','; + clrNone := ' '; + counter := 0; + while not ( eof( xpmFile ) ) do + begin + Readln( xpmFile, LineString ); + // scan for strings + if LineString[ 1 ] = '"' then + begin + case step of + 0 : // Get dimensions (should be width height number-of-colors ???) + begin + HoldPos := 2; + counter := ScanForChar( LineString, ' ', HoldPos, False ); + counter := ScanForChar( LineString, ' ', counter, True ); + dimensions[ 1 ] := StrToInt( Copy( LineString, HoldPos, counter - HoldPos ) ); + counter := ScanForChar( LineString, ' ', counter, False ); + holdPos := counter; + counter := ScanForChar( LineString, ' ', counter, True ); + dimensions[ 2 ] := StrToInt( Copy( LineString, holdPos, counter - HoldPos ) ); + counter := ScanForChar( LineString, ' ', counter, False ); + holdPos := counter; + counter := ScanForChar( LineString, ' ', counter, True ); + dimensions[ 3 ] := StrToInt( Copy( LineString, holdPos, counter - HoldPos ) ); + step := 1; + SetLength( data, ( dimensions[ 1 ] * dimensions[ 2 ] ) div 8 ); + SetLength( mask, ( dimensions[ 1 ] * dimensions[ 2 ] ) div 8 ); + //Log.LogStatus( 'Length = ' + IntToStr( ( dimensions[ 1 ] * dimensions[ 2 ] ) div 8 ), 'LoadCursorFromFile' ); + end; + 1 : // get the symbols for transparent, black and white + begin + // get the symbol for the color + clr := LineString[ 2 ]; + // look for the 'c' symbol + counter := ScanForChar( LineString, 'c', 3, True ); + inc( counter ); + counter := ScanForChar( LineString, ' ', counter, False ); + if LowerCase( Copy( LineString, counter, 4 ) ) = 'none' then + begin + clrNone := clr; + end; + if LowerCase( Copy( LineString, counter, 7 ) ) = '#ffffff' then + begin + clrWhite := clr; + end; + if LowerCase( Copy( LineString, counter, 7 ) ) = '#000000' then + begin + clrBlack := clr; + end; + dec( dimensions[ 3 ] ); + if dimensions[ 3 ] = 0 then + begin + step := 2; + counter := 0; + end; + end; + 2 : // get cursor information -- modified from the SDL + // documentation of SDL_CreateCursor. + begin + for col := 1 to dimensions[1] do + begin + if ( ( col mod 8 ) <> 1 ) then + begin + data[ i ] := data[ i ] shl 1; + mask[ i ] := mask[ i ] shl 1; + end + else + begin + inc( i ); + data[ i ] := 0; + mask[ i ] := 0; + end; + if LineString[ col ] = clrWhite then + begin + mask[ i ] := mask[ i ] or $01; + end + else if LineString[ col ] = clrBlack then + begin + data[ i ] := data[ i ] or $01; + mask[ i ] := mask[ i ] or $01; + end + else if LineString[ col + 1 ] = clrNone then + begin + // + end; + end; + inc(counter); + if counter = dimensions[2] then + step := 4; + end; + end; + end; + end; + CloseFile( xpmFile ); + FCursor := SDL_CreateCursor( PUInt8( data ), PUInt8( mask ), dimensions[ 1 ], dimensions[ 2 ], FHotPoint.x, FHotPoint.y ); +end; + +procedure TSDLXPMCursor.LoadFromStream(aStream: TStream); +begin + inherited; + +end; + +procedure TSDLXPMCursor.Show; +begin + inherited; + SDL_SetCursor( FCursor ); +end; + +{ TSDLCursorList } +function TSDLCursorList.AddCursor(const aName : string; aObject : TSDLCustomCursor): Integer; +begin + result := inherited AddObject( aName, aObject ); +end; + +constructor TSDLCursorList.Create; +begin + inherited; + Duplicates := dupIgnore; +end; + +function TSDLCursorList.GetObject(aIndex: Integer): TSDLCustomCursor; +begin + result := TSDLCustomCursor( inherited GetObject( aIndex ) ); +end; + +procedure TSDLCursorList.PutObject(aIndex: Integer; aObject: TSDLCustomCursor); +begin + inherited PutObject( aIndex, aObject ); +end; + end. diff --git a/packages/extra/sdl/sdlticks.pas b/packages/extra/sdl/sdlticks.pas index e91c091486..a479b49380 100644 --- a/packages/extra/sdl/sdlticks.pas +++ b/packages/extra/sdl/sdlticks.pas @@ -1,7 +1,7 @@ unit sdlticks; { - $Id: sdlticks.pas,v 1.1 2004/09/30 22:35:47 savage Exp $ - + $Id: sdlticks.pas,v 1.2 2006/11/08 08:22:48 savage Exp $ + } {******************************************************************************} { } @@ -59,10 +59,12 @@ unit sdlticks; { September 23 2004 - DL : Initial Creation } { $Log: sdlticks.pas,v $ + Revision 1.2 2006/11/08 08:22:48 savage + updates tp sdlgameinterface and sdlticks functions. + Revision 1.1 2004/09/30 22:35:47 savage Changes, enhancements and additions as required to get SoAoS working. - } {******************************************************************************} @@ -71,49 +73,50 @@ interface uses sdl; - type TSDLTicks = class private - m_startTime : Int64; - m_ticksPerSecond : Int64; - s_lastTime : Int64; - + FStartTime : UInt32; + FTicksPerSecond : UInt32; + FElapsedLastTime : UInt32; + FFPSLastTime : UInt32; + FLockFPSLastTime : UInt32; public constructor Create; - destructor Destroy; override; // destructor + destructor Destroy; override; // destructor {***************************************************************************** Init - If the hi-res timer is present, the tick rate is stored and the function returns true. Otherwise, the function returns false, and the timer should not be used. *****************************************************************************} function Init : boolean; - function GetElapsedSeconds( elapsedFrames : Cardinal = 1 ) : single; + {*************************************************************************** + GetGetElapsedSeconds + Returns the Elapsed time, since the function was last called. + ***************************************************************************} + function GetElapsedSeconds : Single; {*************************************************************************** GetFPS - - Returns the average frames per second over elapsedFrames, which defaults to - one. If this is not called every frame, the client should track the number + Returns the average frames per second. + If this is not called every frame, the client should track the number of frames itself, and reset the value after this is called. ***************************************************************************} - function GetFPS( elapsedFrames : Cardinal = 1 ) : single; + function GetFPS : single; {*************************************************************************** LockFPS - Used to lock the frame rate to a set amount. This will block until enough time has passed to ensure that the fps won't go over the requested amount. Note that this can only keep the fps from going above the specified level; it can still drop below it. It is assumed that if used, this function will be called every frame. The value returned is the instantaneous fps, which - will be <= targetFPS. + will be less than or equal to the targetFPS. ***************************************************************************} - function LockFPS( targetFPS : Byte ) : single; + procedure LockFPS( targetFPS : Byte ); end; implementation @@ -121,76 +124,74 @@ implementation { TSDLTicks } constructor TSDLTicks.Create; begin - + inherited; + FTicksPerSecond := 1000; end; destructor TSDLTicks.Destroy; begin - inherited; end; -function TSDLTicks.GetElapsedSeconds( elapsedFrames: Cardinal ): single; +function TSDLTicks.GetElapsedSeconds : Single; var - currentTime : Int64; + currentTime : Cardinal; begin - // s_lastTime := m_startTime; - currentTime := SDL_GetTicks; - //QueryPerformanceCounter( currentTime ); - result := (currentTime - s_lastTime) / m_ticksPerSecond; + result := ( currentTime - FElapsedLastTime ) / FTicksPerSecond; // reset the timer - s_lastTime := currentTime; + FElapsedLastTime := currentTime; end; -function TSDLTicks.GetFPS( elapsedFrames: Cardinal ): single; +function TSDLTicks.GetFPS : Single; var - currentTime : integer; - fps : single; + currentTime, FrameTime : UInt32; + fps : single; begin - // s_lastTime := m_startTime; - currentTime := SDL_GetTicks; - fps := elapsedFrames * m_ticksPerSecond / ( currentTime - s_lastTime); + FrameTime := ( currentTime - FFPSLastTime ); + + if FrameTime = 0 then + FrameTime := 1; + + fps := FTicksPerSecond / FrameTime; // reset the timer - s_lastTime := currentTime; - + FFPSLastTime := currentTime; result := fps; end; -function TSDLTicks.Init: boolean; +function TSDLTicks.Init : boolean; begin - m_startTime := SDL_GetTicks; - s_lastTime := m_startTime; - m_ticksPerSecond := 1000; + FStartTime := SDL_GetTicks; + FElapsedLastTime := FStartTime; + FFPSLastTime := FStartTime; + FLockFPSLastTime := FStartTime; result := true; end; -function TSDLTicks.LockFPS(targetFPS: Byte): single; +procedure TSDLTicks.LockFPS( targetFPS : Byte ); var - currentTime : integer; - fps : single; + currentTime : UInt32; + targetTime : single; begin - if (targetFPS = 0) then + if ( targetFPS = 0 ) then targetFPS := 1; - s_lastTime := m_startTime; + targetTime := FTicksPerSecond / targetFPS; // delay to maintain a constant frame rate repeat currentTime := SDL_GetTicks; - fps := m_ticksPerSecond / (currentTime - s_lastTime); - until (fps > targetFPS); + until ( ( currentTime - FLockFPSLastTime ) > targetTime ); // reset the timer - s_lastTime := m_startTime; - - result := fps; + FLockFPSLastTime := currentTime; end; end. + \ No newline at end of file diff --git a/packages/extra/sdl/sdltruetypefont.pas b/packages/extra/sdl/sdltruetypefont.pas index 0d478149cc..a457c1d9c3 100644 --- a/packages/extra/sdl/sdltruetypefont.pas +++ b/packages/extra/sdl/sdltruetypefont.pas @@ -1,6 +1,6 @@ unit sdltruetypefont; { - $Id: sdltruetypefont.pas,v 1.1 2004/09/30 22:39:50 savage Exp $ + $Id: sdltruetypefont.pas,v 1.5 2005/05/26 21:22:28 savage Exp $ } {******************************************************************************} @@ -62,6 +62,21 @@ unit sdltruetypefont; { September 23 2004 - DL : Initial Creation } { $Log: sdltruetypefont.pas,v $ + Revision 1.5 2005/05/26 21:22:28 savage + Update to Input code. + + Revision 1.1 2005/05/25 23:15:42 savage + Latest Changes + + Revision 1.4 2005/05/25 22:55:01 savage + Added InputRect support. + + Revision 1.3 2005/05/13 14:02:49 savage + Made it use UniCode rendering by default. + + Revision 1.2 2005/05/13 11:37:52 savage + Improved wordwrapping algorithm + Revision 1.1 2004/09/30 22:39:50 savage Added a true type font class which contains a wrap text function. Changed the sdl_ttf.pas header to reflect the future of jedi-sdl. @@ -93,6 +108,7 @@ type FFontFile : string; FFontSize : integer; procedure PrepareFont; + protected public @@ -100,6 +116,7 @@ type destructor Destroy; override; function DrawText( aText : WideString ) : PSDL_Surface; overload; function DrawText( aText : WideString; aWidth, aHeight : Integer ) : PSDL_Surface; overload; + function Input(aDestination: PSDL_Surface; aX, aY, aWidth, aHeight: integer; var aText: string; aMaxChars: integer = 10 ): PSDL_Surface; property BackGroundColour : TSDL_Color read FBackGroundColour write FBackGroundColour; property ForeGroundColour : TSDL_Color read FForeGroundColour write FForeGroundColour; property FontFile : string read FFontFile write FFontFile; @@ -131,7 +148,7 @@ begin FForeGroundColour.r := 0; FForeGroundColour.g := 0; FForeGroundColour.b := 0; - FRenderType := rtUTF8; + FRenderType := rtUnicode; if ( TTF_Init >= 0 ) then begin FFontFile := aFontFile; @@ -265,26 +282,31 @@ begin else begin dec( i ); - strChopped := Copy( strChopped, 0, i ); - if TTF_SizeText( FFont, PChar( string( strChopped ) ), textw, texth ) = 0 then + if TTF_SizeText( FFont, PChar( string( Copy( strChopped, 0, i ) ) ), textw, texth ) = 0 then begin if ( textw < aWidth ) - and ( texth < aHeight ) then + and ( texth < aHeight ) then begin SetLength( strlist, Length( strlist ) + 1 ); - strlist[ Length( strlist ) - 1 ] := strChopped; - strChopped := Copy( aText, i + 2, Length( aText ) - ( i - 1 ) ); + strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i ); + strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) ); i := Length( strChopped ); if TTF_SizeText( FFont, PChar( string( strChopped ) ), textw, texth ) = 0 then begin - SetLength( strlist, Length( strlist ) + 1 ); - strlist[ Length( strlist ) - 1 ] := strChopped; - break; + if ( textw < aWidth ) + and ( texth < aHeight ) then + begin + SetLength( strlist, Length( strlist ) + 1 ); + strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i ); + strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) ); + i := Length( strChopped ); + end; end; end; end; end; end; + SetLength( SurfaceList, Length( strlist ) ); for i := Low( strlist ) to High( strlist ) do begin @@ -310,26 +332,31 @@ begin else begin dec( i ); - strChopped := Copy( strChopped, 0, i ); - if TTF_SizeUTF8( FFont, PChar( string( strChopped ) ), textw, texth ) = 0 then + if TTF_SizeUTF8( FFont, PChar( string( Copy( strChopped, 0, i ) ) ), textw, texth ) = 0 then begin if ( textw < aWidth ) - and ( texth < aHeight ) then + and ( texth < aHeight ) then begin SetLength( strlist, Length( strlist ) + 1 ); - strlist[ Length( strlist ) - 1 ] := strChopped; - strChopped := Copy( aText, i + 2, Length( aText ) - ( i - 1 ) ); + strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i ); + strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) ); i := Length( strChopped ); if TTF_SizeUTF8( FFont, PChar( string( strChopped ) ), textw, texth ) = 0 then begin - SetLength( strlist, Length( strlist ) + 1 ); - strlist[ Length( strlist ) - 1 ] := strChopped; - break; + if ( textw < aWidth ) + and ( texth < aHeight ) then + begin + SetLength( strlist, Length( strlist ) + 1 ); + strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i ); + strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) ); + i := Length( strChopped ); + end; end; end; end; end; end; + SetLength( SurfaceList, Length( strlist ) ); for i := Low( strlist ) to High( strlist ) do begin @@ -355,21 +382,25 @@ begin else begin dec( i ); - strChopped := Copy( strChopped, 0, i ); - if TTF_SizeUNICODE( FFont, PUInt16( strChopped ), textw, texth ) = 0 then + if TTF_SizeUNICODE( FFont, PUInt16( Copy( strChopped, 0, i ) ), textw, texth ) = 0 then begin if ( textw < aWidth ) - and ( texth < aHeight ) then + and ( texth < aHeight ) then begin SetLength( strlist, Length( strlist ) + 1 ); - strlist[ Length( strlist ) - 1 ] := strChopped; - strChopped := Copy( aText, i + 2, Length( aText ) - ( i - 1 ) ); + strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i ); + strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) ); i := Length( strChopped ); if TTF_SizeUNICODE( FFont, PUInt16( strChopped ), textw, texth ) = 0 then begin - SetLength( strlist, Length( strlist ) + 1 ); - strlist[ Length( strlist ) - 1 ] := strChopped; - break; + if ( textw < aWidth ) + and ( texth < aHeight ) then + begin + SetLength( strlist, Length( strlist ) + 1 ); + strlist[ Length( strlist ) - 1 ] := Copy( strChopped, 0, i ); + strChopped := Copy( strChopped, i + 2, Length( strChopped ) - ( i - 1 ) ); + i := Length( strChopped ); + end; end; end; end; @@ -411,6 +442,103 @@ begin SetLength( strlist, 0 ); end; +function TTrueTypeFont.Input(aDestination: PSDL_Surface; aX, aY, aWidth: integer; aHeight : integer; var aText : string; aMaxChars: integer): PSDL_Surface; +var + event : TSDL_Event; + ch : integer; + + BackSurface, TextSurface : PSDL_Surface; + rect : SDL_Rect; + textw, texth : integer; + Done : boolean; + PassedInText : string; +begin + PassedInText := aText; + + BackSurface := SDL_AllocSurface( aDestination.flags, + aDestination.w, + aDestination.h, + aDestination.format.BitsPerPixel, + aDestination.format.Rmask, + aDestination.format.Gmask, + aDestination.format.Bmask, 0 ); + + rect.x := aX; + rect.y := aY; + rect.w := aWidth; + rect.h := aHeight; + + SDL_BlitSurface( aDestination, nil, BackSurface, nil ); + SDL_FillRect( BackSurface, @rect, SDL_MapRGB( aDestination.format, 0, 0, 0 ) ); + + TextSurface := DrawText( aText + '|' ); + + // start input + SDL_EnableUNICODE( 1 ); + Done := false; + while ( not Done ) and ( SDL_WaitEvent( @event ) > 0 ) do + begin + if event.type_ = SDL_KEYDOWN then + begin + ch := event.key.keysym.unicode; + case ch of + SDLK_RETURN : + begin + Done := true; + end; + + SDLK_ESCAPE : + begin + aText := PassedInText; + Done := true; + end; + + SDLK_BACKSPACE : + begin + if ( Length( aText ) > 0 ) then + begin + aText := Copy( aText, 0, Length( aText ) - 1 ); + if TextSurface <> nil then + SDL_FreeSurface( TextSurface ); + TextSurface := DrawText( aText + '|' ); + end; + end; + else + begin + if Length( aText ) < aMaxChars then + begin + if ( chr( ch ) <> '' ) then + begin + aText := aText + chr( ch ); + + if ( aText <> '' ) + and ( TTF_SizeUNICODE( FFont, PUInt16( aText ), textw, texth ) = 0 ) then + begin + if ( textw > aWidth ) then + aText := Copy( aText, 0, Length( aText ) - 1 ); + end; + + if TextSurface <> nil then + SDL_FreeSurface( TextSurface ); + TextSurface := DrawText( aText + '|' ); + end; + end; + end; + end; + end; + SDL_BlitSurface( BackSurface, nil, aDestination, nil ); + SDL_BlitSurface( TextSurface, nil, aDestination, @rect ); + SDL_Flip( aDestination ); + end; + + if TextSurface <> nil then + SDL_FreeSurface( TextSurface ); + if aText <> '' then + TextSurface := DrawText( aText ); + SDL_FreeSurface( BackSurface ); + result := TextSurface; +end; + procedure TTrueTypeFont.PrepareFont; var renderstyle : integer; diff --git a/packages/extra/sdl/sdlutils.pas b/packages/extra/sdl/sdlutils.pas index 5a5bd6bcbd..8e03b0cd35 100644 --- a/packages/extra/sdl/sdlutils.pas +++ b/packages/extra/sdl/sdlutils.pas @@ -1,7 +1,7 @@ unit sdlutils; { - $Id: sdlutils.pas,v 1.4 2004/06/02 19:38:53 savage Exp $ - + $Id: sdlutils.pas,v 1.5 2006/11/19 18:56:44 savage Exp $ + } {******************************************************************************} { } @@ -105,6 +105,9 @@ unit sdlutils; {******************************************************************************} { $Log: sdlutils.pas,v $ + Revision 1.5 2006/11/19 18:56:44 savage + Removed Hints and Warnings. + Revision 1.4 2004/06/02 19:38:53 savage Changes to SDL_GradientFillRect as suggested by Ángel Eduardo García Hernández. Many thanks. @@ -119,12 +122,12 @@ unit sdlutils; Revision 1.1 2004/02/05 00:08:20 savage Module 1.0 release - + } interface -{$i jedi-sdl.inc} +{$I jedi-sdl.inc} uses {$IFDEF UNIX} @@ -157,7 +160,7 @@ procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Col cardinal ); overload; procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : - cardinal ; DashLength, DashSpace : byte ); overload; + cardinal; DashLength, DashSpace : byte ); overload; procedure SDL_AddLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : cardinal ); @@ -217,16 +220,16 @@ procedure SDL_FillRectSub( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color procedure SDL_GradientFillRect( DstSurface : PSDL_Surface; const Rect : PSDL_Rect; const StartColor, EndColor : TSDL_Color; const Style : TGradientStyle ); // NOTE for All SDL_2xblit... function : the dest surface must be 2x of the source surface! -procedure SDL_2xBlit(Src, Dest: PSDL_Surface); +procedure SDL_2xBlit( Src, Dest : PSDL_Surface ); -procedure SDL_Scanline2xBlit(Src, Dest: PSDL_Surface); +procedure SDL_Scanline2xBlit( Src, Dest : PSDL_Surface ); -procedure SDL_50Scanline2xBlit(Src, Dest: PSDL_Surface); +procedure SDL_50Scanline2xBlit( Src, Dest : PSDL_Surface ); // function SDL_PixelTestSurfaceVsRect( SrcSurface1 : PSDL_Surface; SrcRect1 : -PSDL_Rect; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : -boolean; + PSDL_Rect; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : + boolean; // Jason's boolean Surface functions procedure SDL_ORSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; @@ -242,7 +245,7 @@ procedure SDL_GTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; procedure SDL_LTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); -function SDL_ClipLine(var x1,y1,x2,y2: Integer; ClipRect: PSDL_Rect) : boolean; +function SDL_ClipLine( var x1, y1, x2, y2 : Integer; ClipRect : PSDL_Rect ) : boolean; implementation @@ -256,13 +259,13 @@ var right1, bottom1 : integer; right2, bottom2 : integer; Scan1Start, Scan2Start, ScanWidth, ScanHeight : cardinal; - Mod1, Mod2 : cardinal; + Mod1, Mod2 : cardinal; Addr1, Addr2 : cardinal; - BPP : cardinal; + BPP : cardinal; Pitch1, Pitch2 : cardinal; TransparentColor1, TransparentColor2 : cardinal; - tx, ty : cardinal; - StartTick : cardinal; + tx, ty : cardinal; + StartTick : cardinal; Color1, Color2 : cardinal; begin Result := false; @@ -438,9 +441,9 @@ end; procedure SDL_AddPixel( DstSurface : PSDL_Surface; x : cardinal; y : cardinal; Color : cardinal ); var - SrcColor : cardinal; - Addr : cardinal; - R, G, B : cardinal; + SrcColor : cardinal; + Addr : cardinal; + R, G, B : cardinal; begin if Color = 0 then exit; @@ -521,9 +524,9 @@ end; procedure SDL_SubPixel( DstSurface : PSDL_Surface; x : cardinal; y : cardinal; Color : cardinal ); var - SrcColor : cardinal; - Addr : cardinal; - R, G, B : cardinal; + SrcColor : cardinal; + Addr : cardinal; + R, G, B : cardinal; begin if Color = 0 then exit; @@ -608,12 +611,12 @@ procedure SDL_AddSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); var R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; - Src, Dest : TSDL_Rect; - Diff : integer; + Src, Dest : TSDL_Rect; + Diff : integer; SrcAddr, DestAddr : cardinal; WorkX, WorkY : word; SrcMod, DestMod : cardinal; - Bits : cardinal; + Bits : cardinal; begin if ( SrcSurface = nil ) or ( DestSurface = nil ) then exit; // Remove this to make it faster @@ -878,13 +881,13 @@ procedure SDL_SubSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); var R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; - Src, Dest : TSDL_Rect; - Diff : integer; + Src, Dest : TSDL_Rect; + Diff : integer; SrcAddr, DestAddr : cardinal; _ebx, _esi, _edi, _esp : cardinal; WorkX, WorkY : word; SrcMod, DestMod : cardinal; - Bits : cardinal; + Bits : cardinal; begin if ( SrcSurface = nil ) or ( DestSurface = nil ) then exit; // Remove this to make it faster @@ -1140,14 +1143,14 @@ end; procedure SDL_MonoSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DestSurface : PSDL_Surface; DestRect : PSDL_Rect; Color : cardinal ); var - Src, Dest : TSDL_Rect; - Diff : integer; + Src, Dest : TSDL_Rect; + Diff : integer; SrcAddr, DestAddr : cardinal; _ebx, _esi, _edi, _esp : cardinal; WorkX, WorkY : word; SrcMod, DestMod : cardinal; TransparentColor, SrcColor : cardinal; - BPP : cardinal; + BPP : cardinal; begin if ( SrcSurface = nil ) or ( DestSurface = nil ) then exit; // Remove this to make it faster @@ -1312,14 +1315,14 @@ procedure SDL_TexturedSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DestSurface : PSDL_Surface; DestRect : PSDL_Rect; Texture : PSDL_Surface; TextureRect : PSDL_Rect ); var - Src, Dest : TSDL_Rect; - Diff : integer; + Src, Dest : TSDL_Rect; + Diff : integer; SrcAddr, DestAddr, TextAddr : cardinal; _ebx, _esi, _edi, _esp : cardinal; WorkX, WorkY : word; SrcMod, DestMod, TextMod : cardinal; SrcColor, TransparentColor, TextureColor : cardinal; - BPP : cardinal; + BPP : cardinal; begin if ( SrcSurface = nil ) or ( DestSurface = nil ) then exit; // Remove this to make it faster @@ -1496,10 +1499,10 @@ end; procedure SDL_ZoomSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; DstRect : PSDL_Rect ); var - xc, yc : cardinal; + xc, yc : cardinal; rx, wx, ry, wy, ry16 : cardinal; - color : cardinal; - modx, mody : cardinal; + color : cardinal; + modx, mody : cardinal; begin // Warning! No checks for surface pointers!!! if srcrect = nil then @@ -1540,13 +1543,13 @@ end; procedure SDL_WarpSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DstSurface : PSDL_Surface; UL, UR, LR, LL : PPoint ); const - SHIFTS = 15; // Extend ints to limit round-off error (try 2 - 20) - THRESH = 1 shl SHIFTS; // Threshold for pixel size value + SHIFTS = 15; // Extend ints to limit round-off error (try 2 - 20) + THRESH = 1 shl SHIFTS; // Threshold for pixel size value procedure CopySourceToDest( UL, UR, LR, LL : TPoint; x1, y1, x2, y2 : cardinal ); var tm, lm, rm, bm, m : TPoint; - mx, my : cardinal; - cr : cardinal; + mx, my : cardinal; + cr : cardinal; begin // Does the destination area specify a single pixel? if ( ( abs( ul.x - ur.x ) < THRESH ) and @@ -1620,6 +1623,7 @@ end; // Draw a line between x1,y1 and x2,y2 to the given surface // NOTE: The surface must be locked before calling this! + procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : cardinal ); var @@ -1673,8 +1677,9 @@ end; // Draw a dashed line between x1,y1 and x2,y2 to the given surface // NOTE: The surface must be locked before calling this! + procedure SDL_DrawLine( DstSurface : PSDL_Surface; x1, y1, x2, y2 : integer; Color : - cardinal ; DashLength, DashSpace : byte ); overload; + cardinal; DashLength, DashSpace : byte ); overload; var dx, dy, sdx, sdy, x, y, px, py, counter : integer; drawdash : boolean; begin @@ -1682,10 +1687,12 @@ begin drawdash := true; //begin line drawing with dash //Avoid invalid user-passed dash parameters - if (DashLength < 1) - then DashLength := 1; - if (DashSpace < 1) - then DashSpace := 0; + if ( DashLength < 1 ) + then + DashLength := 1; + if ( DashSpace < 1 ) + then + DashSpace := 0; dx := x2 - x1; dy := y2 - y1; @@ -1706,28 +1713,28 @@ begin if dx >= dy then begin for x := 0 to dx - 1 do - begin + begin //Alternate drawing dashes, or leaving spaces if drawdash then + begin + SDL_PutPixel( DstSurface, px, py, Color ); + inc( counter ); + if ( counter > DashLength - 1 ) and ( DashSpace > 0 ) then begin - SDL_PutPixel( DstSurface, px, py, Color ); - inc(counter); - if (counter > DashLength-1) and (DashSpace > 0) then - begin - drawdash := false; - counter := 0; - end; - end - else //space - begin - inc(counter); - if counter > DashSpace-1 then - begin - drawdash := true; - counter := 0; - end; + drawdash := false; + counter := 0; end; + end + else //space + begin + inc( counter ); + if counter > DashSpace - 1 then + begin + drawdash := true; + counter := 0; + end; + end; y := y + dy; if y >= dx then @@ -1745,24 +1752,24 @@ begin //Alternate drawing dashes, or leaving spaces if drawdash then + begin + SDL_PutPixel( DstSurface, px, py, Color ); + inc( counter ); + if ( counter > DashLength - 1 ) and ( DashSpace > 0 ) then begin - SDL_PutPixel( DstSurface, px, py, Color ); - inc(counter); - if (counter > DashLength-1) and (DashSpace > 0) then - begin - drawdash := false; - counter := 0; - end; - end - else //space - begin - inc(counter); - if counter > DashSpace-1 then - begin - drawdash := true; - counter := 0; - end; + drawdash := false; + counter := 0; end; + end + else //space + begin + inc( counter ); + if counter > DashSpace - 1 then + begin + drawdash := true; + counter := 0; + end; + end; x := x + dx; if x >= dy then @@ -1878,13 +1885,14 @@ begin end; // flips a rectangle vertically on given surface + procedure SDL_FlipRectV( DstSurface : PSDL_Surface; Rect : PSDL_Rect ); var - TmpRect : TSDL_Rect; - Locked : boolean; + TmpRect : TSDL_Rect; + Locked : boolean; y, FlipLength, RowLength : integer; - Row1, Row2 : Pointer; - OneRow : TByteArray; // Optimize it if you wish + Row1, Row2 : Pointer; + OneRow : TByteArray; // Optimize it if you wish begin if DstSurface <> nil then begin @@ -1920,6 +1928,7 @@ begin end; // flips a rectangle horizontally on given surface + procedure SDL_FlipRectH( DstSurface : PSDL_Surface; Rect : PSDL_Rect ); type T24bit = packed array[ 0..2 ] of byte; @@ -1928,15 +1937,15 @@ type TLongWordArray = array[ 0..8191 ] of LongWord; PLongWordArray = ^TLongWordArray; var - TmpRect : TSDL_Rect; - Row8bit : PByteArray; - Row16bit : PWordArray; - Row24bit : P24bitArray; - Row32bit : PLongWordArray; + TmpRect : TSDL_Rect; + Row8bit : PByteArray; + Row16bit : PWordArray; + Row24bit : P24bitArray; + Row32bit : PLongWordArray; y, x, RightSide, FlipLength : integer; - Pixel : cardinal; - Pixel24 : T24bit; - Locked : boolean; + Pixel : cardinal; + Pixel24 : T24bit; + Locked : boolean; begin if DstSurface <> nil then begin @@ -2030,9 +2039,10 @@ end; // Use with caution! The procedure allocates memory for TSDL_Rect and return with its pointer. // But you MUST free it after you don't need it anymore!!! + function PSDLRect( aLeft, aTop, aWidth, aHeight : integer ) : PSDL_Rect; var - Rect : PSDL_Rect; + Rect : PSDL_Rect; begin New( Rect ); with Rect^ do @@ -2103,10 +2113,11 @@ begin end; // Stretches a part of a surface + function SDL_ScaleSurfaceRect( SrcSurface : PSDL_Surface; SrcX1, SrcY1, SrcW, SrcH, Width, Height : integer ) : PSDL_Surface; var - dst_surface : PSDL_Surface; + dst_surface : PSDL_Surface; dx, dy, e, d, dx2, srcx2, srcy2 : integer; destx1, desty1 : integer; begin @@ -2153,7 +2164,7 @@ end; procedure SDL_MoveLine( Surface : PSDL_Surface; x1, x2, y1, xofs, depth : integer ); var src_pixels, dst_pixels : PUint8; - i : integer; + i : integer; begin src_pixels := PUint8( integer( Surface^.pixels ) + Surface^.w * y1 * depth + x2 * depth ); @@ -2171,8 +2182,8 @@ NOTE: The surface must be locked before calling this! } function SDL_GetPixel( SrcSurface : PSDL_Surface; x : integer; y : integer ) : Uint32; var - bpp : UInt32; - p : PInteger; + bpp : UInt32; + p : PInteger; begin bpp := SrcSurface.format.BytesPerPixel; // Here p is the address to the pixel we want to retrieve @@ -2199,8 +2210,8 @@ end; procedure SDL_PutPixel( DstSurface : PSDL_Surface; x : integer; y : integer; pixel : Uint32 ); var - bpp : UInt32; - p : PInteger; + bpp : UInt32; + p : PInteger; begin bpp := DstSurface.format.BytesPerPixel; p := Pointer( Uint32( DstSurface.pixels ) + UInt32( y ) * DstSurface.pitch + UInt32( x ) @@ -2228,9 +2239,9 @@ end; procedure SDL_ScrollY( DstSurface : PSDL_Surface; DifY : integer ); var - r1, r2 : TSDL_Rect; + r1, r2 : TSDL_Rect; //buffer: PSDL_Surface; - YPos : Integer; + YPos : Integer; begin if ( DstSurface <> nil ) and ( DifY <> 0 ) then begin @@ -2282,8 +2293,8 @@ end;} procedure SDL_ScrollX( DstSurface : PSDL_Surface; DifX : integer ); var - r1, r2 : TSDL_Rect; - buffer : PSDL_Surface; + r1, r2 : TSDL_Rect; + buffer : PSDL_Surface; begin if ( DstSurface <> nil ) and ( DifX <> 0 ) then begin @@ -2310,14 +2321,14 @@ end; procedure SDL_RotateRad( DstSurface, SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DestX, DestY, OffsetX, OffsetY : Integer; Angle : Single ); var - aSin, aCos : Single; + aSin, aCos : Single; MX, MY, DX, DY, NX, NY, SX, SY, OX, OY, Width, Height, TX, TY, RX, RY, ROX, ROY : Integer; Colour, TempTransparentColour : UInt32; - MAXX, MAXY : Integer; + MAXX, MAXY : Integer; begin // Rotate the surface to the target surface. TempTransparentColour := SrcSurface.format.colorkey; - if srcRect.w > srcRect.h then + {if srcRect.w > srcRect.h then begin Width := srcRect.w; Height := srcRect.w; @@ -2326,7 +2337,7 @@ begin begin Width := srcRect.h; Height := srcRect.h; - end; + end; } maxx := DstSurface.w; maxy := DstSurface.h; @@ -2384,8 +2395,8 @@ end; function ValidateSurfaceRect( DstSurface : PSDL_Surface; dstrect : PSDL_Rect ) : TSDL_Rect; var - RealRect : TSDL_Rect; - OutOfRange : Boolean; + RealRect : TSDL_Rect; + OutOfRange : Boolean; begin OutOfRange := false; if dstrect = nil then @@ -2457,9 +2468,9 @@ end; procedure SDL_FillRectAdd( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 ); var - RealRect : TSDL_Rect; - Addr : pointer; - ModX, BPP : cardinal; + RealRect : TSDL_Rect; + Addr : pointer; + ModX, BPP : cardinal; x, y, R, G, B, SrcColor : cardinal; begin RealRect := ValidateSurfaceRect( DstSurface, DstRect ); @@ -2590,9 +2601,9 @@ end; procedure SDL_FillRectSub( DstSurface : PSDL_Surface; dstrect : PSDL_Rect; color : UInt32 ); var - RealRect : TSDL_Rect; - Addr : pointer; - ModX, BPP : cardinal; + RealRect : TSDL_Rect; + Addr : pointer; + ModX, BPP : cardinal; x, y, R, G, B, SrcColor : cardinal; begin RealRect := ValidateSurfaceRect( DstSurface, DstRect ); @@ -2723,13 +2734,13 @@ end; procedure SDL_GradientFillRect( DstSurface : PSDL_Surface; const Rect : PSDL_Rect; const StartColor, EndColor : TSDL_Color; const Style : TGradientStyle ); var - FBC : array[ 0..255 ] of Cardinal; + FBC : array[ 0..255 ] of Cardinal; // temp vars i, YR, YG, YB, SR, SG, SB, DR, DG, DB : Integer; TempStepV, TempStepH : Single; TempLeft, TempTop, TempHeight, TempWidth : integer; - TempRect : TSDL_Rect; + TempRect : TSDL_Rect; begin // calc FBC @@ -2787,328 +2798,328 @@ begin end; end; -procedure SDL_2xBlit(Src, Dest: PSDL_Surface); +procedure SDL_2xBlit( Src, Dest : PSDL_Surface ); var - ReadAddr, WriteAddr, ReadRow, WriteRow: UInt32; - SrcPitch, DestPitch, x, y: UInt32; + ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32; + SrcPitch, DestPitch, x, y : UInt32; begin - if (Src = nil) or (Dest = nil) then + if ( Src = nil ) or ( Dest = nil ) then exit; - if (Src.w shl 1) < Dest.w then + if ( Src.w shl 1 ) < Dest.w then exit; - if (Src.h shl 1) < Dest.h then + if ( Src.h shl 1 ) < Dest.h then exit; - if SDL_MustLock(Src) then - SDL_LockSurface(Src); - if SDL_MustLock(Dest) then - SDL_LockSurface(Dest); + if SDL_MustLock( Src ) then + SDL_LockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_LockSurface( Dest ); - ReadRow := UInt32(Src.Pixels); - WriteRow := UInt32(Dest.Pixels); + ReadRow := UInt32( Src.Pixels ); + WriteRow := UInt32( Dest.Pixels ); SrcPitch := Src.pitch; DestPitch := Dest.pitch; case Src.format.BytesPerPixel of - 1: for y := 1 to Src.h do - begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - PUInt8(WriteAddr)^ := PUInt8(ReadAddr)^; - PUInt8(WriteAddr + 1)^ := PUInt8(ReadAddr)^; - PUInt8(WriteAddr + DestPitch)^ := PUInt8(ReadAddr)^; - PUInt8(WriteAddr + DestPitch + 1)^ := PUInt8(ReadAddr)^; - inc(ReadAddr); - inc(WriteAddr, 2); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); - end; - 2: for y := 1 to Src.h do - begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - PUInt16(WriteAddr)^ := PUInt16(ReadAddr)^; - PUInt16(WriteAddr + 2)^ := PUInt16(ReadAddr)^; - PUInt16(WriteAddr + DestPitch)^ := PUInt16(ReadAddr)^; - PUInt16(WriteAddr + DestPitch + 2)^ := PUInt16(ReadAddr)^; - inc(ReadAddr, 2); - inc(WriteAddr, 4); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); - end; - 3: for y := 1 to Src.h do - begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - PUInt32(WriteAddr)^ := (PUInt32(WriteAddr)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff); - PUInt32(WriteAddr + 3)^ := (PUInt32(WriteAddr + 3)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff); - PUInt32(WriteAddr + DestPitch)^ := (PUInt32(WriteAddr + DestPitch)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff); - PUInt32(WriteAddr + DestPitch + 3)^ := (PUInt32(WriteAddr + DestPitch + 3)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff); - inc(ReadAddr, 3); - inc(WriteAddr, 6); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); - end; - 4: for y := 1 to Src.h do - begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - PUInt32(WriteAddr)^ := PUInt32(ReadAddr)^; - PUInt32(WriteAddr + 4)^ := PUInt32(ReadAddr)^; - PUInt32(WriteAddr + DestPitch)^ := PUInt32(ReadAddr)^; - PUInt32(WriteAddr + DestPitch + 4)^ := PUInt32(ReadAddr)^; - inc(ReadAddr, 4); - inc(WriteAddr, 8); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); - end; + 1 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt8( WriteAddr )^ := PUInt8( ReadAddr )^; + PUInt8( WriteAddr + 1 )^ := PUInt8( ReadAddr )^; + PUInt8( WriteAddr + DestPitch )^ := PUInt8( ReadAddr )^; + PUInt8( WriteAddr + DestPitch + 1 )^ := PUInt8( ReadAddr )^; + inc( ReadAddr ); + inc( WriteAddr, 2 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 2 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt16( WriteAddr )^ := PUInt16( ReadAddr )^; + PUInt16( WriteAddr + 2 )^ := PUInt16( ReadAddr )^; + PUInt16( WriteAddr + DestPitch )^ := PUInt16( ReadAddr )^; + PUInt16( WriteAddr + DestPitch + 2 )^ := PUInt16( ReadAddr )^; + inc( ReadAddr, 2 ); + inc( WriteAddr, 4 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 3 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt32( WriteAddr )^ := ( PUInt32( WriteAddr )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + PUInt32( WriteAddr + 3 )^ := ( PUInt32( WriteAddr + 3 )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + PUInt32( WriteAddr + DestPitch )^ := ( PUInt32( WriteAddr + DestPitch )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + PUInt32( WriteAddr + DestPitch + 3 )^ := ( PUInt32( WriteAddr + DestPitch + 3 )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + inc( ReadAddr, 3 ); + inc( WriteAddr, 6 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 4 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt32( WriteAddr )^ := PUInt32( ReadAddr )^; + PUInt32( WriteAddr + 4 )^ := PUInt32( ReadAddr )^; + PUInt32( WriteAddr + DestPitch )^ := PUInt32( ReadAddr )^; + PUInt32( WriteAddr + DestPitch + 4 )^ := PUInt32( ReadAddr )^; + inc( ReadAddr, 4 ); + inc( WriteAddr, 8 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; end; - if SDL_MustLock(Src) then - SDL_UnlockSurface(Src); - if SDL_MustLock(Dest) then - SDL_UnlockSurface(Dest); + if SDL_MustLock( Src ) then + SDL_UnlockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_UnlockSurface( Dest ); end; -procedure SDL_Scanline2xBlit(Src, Dest: PSDL_Surface); +procedure SDL_Scanline2xBlit( Src, Dest : PSDL_Surface ); var - ReadAddr, WriteAddr, ReadRow, WriteRow: UInt32; - SrcPitch, DestPitch, x, y: UInt32; + ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32; + SrcPitch, DestPitch, x, y : UInt32; begin - if (Src = nil) or (Dest = nil) then + if ( Src = nil ) or ( Dest = nil ) then exit; - if (Src.w shl 1) < Dest.w then + if ( Src.w shl 1 ) < Dest.w then exit; - if (Src.h shl 1) < Dest.h then + if ( Src.h shl 1 ) < Dest.h then exit; - if SDL_MustLock(Src) then - SDL_LockSurface(Src); - if SDL_MustLock(Dest) then - SDL_LockSurface(Dest); + if SDL_MustLock( Src ) then + SDL_LockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_LockSurface( Dest ); - ReadRow := UInt32(Src.Pixels); - WriteRow := UInt32(Dest.Pixels); + ReadRow := UInt32( Src.Pixels ); + WriteRow := UInt32( Dest.Pixels ); SrcPitch := Src.pitch; DestPitch := Dest.pitch; case Src.format.BytesPerPixel of - 1: for y := 1 to Src.h do - begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - PUInt8(WriteAddr)^ := PUInt8(ReadAddr)^; - PUInt8(WriteAddr + 1)^ := PUInt8(ReadAddr)^; - inc(ReadAddr); - inc(WriteAddr, 2); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); - end; - 2: for y := 1 to Src.h do - begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - PUInt16(WriteAddr)^ := PUInt16(ReadAddr)^; - PUInt16(WriteAddr + 2)^ := PUInt16(ReadAddr)^; - inc(ReadAddr, 2); - inc(WriteAddr, 4); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); - end; - 3: for y := 1 to Src.h do - begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - PUInt32(WriteAddr)^ := (PUInt32(WriteAddr)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff); - PUInt32(WriteAddr + 3)^ := (PUInt32(WriteAddr + 3)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff); - inc(ReadAddr, 3); - inc(WriteAddr, 6); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); - end; - 4: for y := 1 to Src.h do - begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - PUInt32(WriteAddr)^ := PUInt32(ReadAddr)^; - PUInt32(WriteAddr + 4)^ := PUInt32(ReadAddr)^; - inc(ReadAddr, 4); - inc(WriteAddr, 8); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); - end; + 1 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt8( WriteAddr )^ := PUInt8( ReadAddr )^; + PUInt8( WriteAddr + 1 )^ := PUInt8( ReadAddr )^; + inc( ReadAddr ); + inc( WriteAddr, 2 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 2 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt16( WriteAddr )^ := PUInt16( ReadAddr )^; + PUInt16( WriteAddr + 2 )^ := PUInt16( ReadAddr )^; + inc( ReadAddr, 2 ); + inc( WriteAddr, 4 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 3 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt32( WriteAddr )^ := ( PUInt32( WriteAddr )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + PUInt32( WriteAddr + 3 )^ := ( PUInt32( WriteAddr + 3 )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + inc( ReadAddr, 3 ); + inc( WriteAddr, 6 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 4 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + PUInt32( WriteAddr )^ := PUInt32( ReadAddr )^; + PUInt32( WriteAddr + 4 )^ := PUInt32( ReadAddr )^; + inc( ReadAddr, 4 ); + inc( WriteAddr, 8 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; end; - if SDL_MustLock(Src) then - SDL_UnlockSurface(Src); - if SDL_MustLock(Dest) then - SDL_UnlockSurface(Dest); + if SDL_MustLock( Src ) then + SDL_UnlockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_UnlockSurface( Dest ); end; -procedure SDL_50Scanline2xBlit(Src, Dest: PSDL_Surface); +procedure SDL_50Scanline2xBlit( Src, Dest : PSDL_Surface ); var - ReadAddr, WriteAddr, ReadRow, WriteRow: UInt32; - SrcPitch, DestPitch, x, y, Color: UInt32; + ReadAddr, WriteAddr, ReadRow, WriteRow : UInt32; + SrcPitch, DestPitch, x, y, Color : UInt32; begin - if (Src = nil) or (Dest = nil) then + if ( Src = nil ) or ( Dest = nil ) then exit; - if (Src.w shl 1) < Dest.w then + if ( Src.w shl 1 ) < Dest.w then exit; - if (Src.h shl 1) < Dest.h then + if ( Src.h shl 1 ) < Dest.h then exit; - if SDL_MustLock(Src) then - SDL_LockSurface(Src); - if SDL_MustLock(Dest) then - SDL_LockSurface(Dest); + if SDL_MustLock( Src ) then + SDL_LockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_LockSurface( Dest ); - ReadRow := UInt32(Src.Pixels); - WriteRow := UInt32(Dest.Pixels); + ReadRow := UInt32( Src.Pixels ); + WriteRow := UInt32( Dest.Pixels ); SrcPitch := Src.pitch; DestPitch := Dest.pitch; case Src.format.BitsPerPixel of - 8: for y := 1 to Src.h do - begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - Color := PUInt8(ReadAddr)^; - PUInt8(WriteAddr)^ := Color; - PUInt8(WriteAddr + 1)^ := Color; - Color := (Color shr 1) and $6d; {%01101101} - PUInt8(WriteAddr + DestPitch)^ := Color; - PUInt8(WriteAddr + DestPitch + 1)^ := Color; - inc(ReadAddr); - inc(WriteAddr, 2); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); - end; - 15: for y := 1 to Src.h do + 8 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - Color := PUInt16(ReadAddr)^; - PUInt16(WriteAddr)^ := Color; - PUInt16(WriteAddr + 2)^ := Color; - Color := (Color shr 1) and $3def; {%0011110111101111} - PUInt16(WriteAddr + DestPitch)^ := Color; - PUInt16(WriteAddr + DestPitch + 2)^ := Color; - inc(ReadAddr, 2); - inc(WriteAddr, 4); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); + Color := PUInt8( ReadAddr )^; + PUInt8( WriteAddr )^ := Color; + PUInt8( WriteAddr + 1 )^ := Color; + Color := ( Color shr 1 ) and $6D; {%01101101} + PUInt8( WriteAddr + DestPitch )^ := Color; + PUInt8( WriteAddr + DestPitch + 1 )^ := Color; + inc( ReadAddr ); + inc( WriteAddr, 2 ); end; - 16: for y := 1 to Src.h do + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 15 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - Color := PUInt16(ReadAddr)^; - PUInt16(WriteAddr)^ := Color; - PUInt16(WriteAddr + 2)^ := Color; - Color := (Color shr 1) and $7bef; {%0111101111101111} - PUInt16(WriteAddr + DestPitch)^ := Color; - PUInt16(WriteAddr + DestPitch + 2)^ := Color; - inc(ReadAddr, 2); - inc(WriteAddr, 4); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); + Color := PUInt16( ReadAddr )^; + PUInt16( WriteAddr )^ := Color; + PUInt16( WriteAddr + 2 )^ := Color; + Color := ( Color shr 1 ) and $3DEF; {%0011110111101111} + PUInt16( WriteAddr + DestPitch )^ := Color; + PUInt16( WriteAddr + DestPitch + 2 )^ := Color; + inc( ReadAddr, 2 ); + inc( WriteAddr, 4 ); end; - 24: for y := 1 to Src.h do + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 16 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - Color := (PUInt32(WriteAddr)^ and $ff000000) or (PUInt32(ReadAddr)^ and $00ffffff); - PUInt32(WriteAddr)^ := Color; - PUInt32(WriteAddr + 3)^ := Color; - Color := (Color shr 1) and $007f7f7f; {%011111110111111101111111} - PUInt32(WriteAddr + DestPitch)^ := Color; - PUInt32(WriteAddr + DestPitch + 3)^ := Color; - inc(ReadAddr, 3); - inc(WriteAddr, 6); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); + Color := PUInt16( ReadAddr )^; + PUInt16( WriteAddr )^ := Color; + PUInt16( WriteAddr + 2 )^ := Color; + Color := ( Color shr 1 ) and $7BEF; {%0111101111101111} + PUInt16( WriteAddr + DestPitch )^ := Color; + PUInt16( WriteAddr + DestPitch + 2 )^ := Color; + inc( ReadAddr, 2 ); + inc( WriteAddr, 4 ); end; - 32: for y := 1 to Src.h do - begin - ReadAddr := ReadRow; - WriteAddr := WriteRow; - for x := 1 to Src.w do - begin - Color := PUInt32(ReadAddr)^; - PUInt32(WriteAddr)^ := Color; - PUInt32(WriteAddr + 4)^ := Color; - Color := (Color shr 1) and $7f7f7f7f; - PUInt32(WriteAddr + DestPitch)^ := Color; - PUInt32(WriteAddr + DestPitch + 4)^ := Color; - inc(ReadAddr, 4); - inc(WriteAddr, 8); - end; - inc(UInt32(ReadRow), SrcPitch); - inc(UInt32(WriteRow), DestPitch * 2); - end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 24 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + Color := ( PUInt32( WriteAddr )^ and $FF000000 ) or ( PUInt32( ReadAddr )^ and $00FFFFFF ); + PUInt32( WriteAddr )^ := Color; + PUInt32( WriteAddr + 3 )^ := Color; + Color := ( Color shr 1 ) and $007F7F7F; {%011111110111111101111111} + PUInt32( WriteAddr + DestPitch )^ := Color; + PUInt32( WriteAddr + DestPitch + 3 )^ := Color; + inc( ReadAddr, 3 ); + inc( WriteAddr, 6 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; + 32 : for y := 1 to Src.h do + begin + ReadAddr := ReadRow; + WriteAddr := WriteRow; + for x := 1 to Src.w do + begin + Color := PUInt32( ReadAddr )^; + PUInt32( WriteAddr )^ := Color; + PUInt32( WriteAddr + 4 )^ := Color; + Color := ( Color shr 1 ) and $7F7F7F7F; + PUInt32( WriteAddr + DestPitch )^ := Color; + PUInt32( WriteAddr + DestPitch + 4 )^ := Color; + inc( ReadAddr, 4 ); + inc( WriteAddr, 8 ); + end; + inc( UInt32( ReadRow ), SrcPitch ); + inc( UInt32( WriteRow ), DestPitch * 2 ); + end; end; - if SDL_MustLock(Src) then - SDL_UnlockSurface(Src); - if SDL_MustLock(Dest) then - SDL_UnlockSurface(Dest); + if SDL_MustLock( Src ) then + SDL_UnlockSurface( Src ); + if SDL_MustLock( Dest ) then + SDL_UnlockSurface( Dest ); end; function SDL_PixelTestSurfaceVsRect( SrcSurface1 : PSDL_Surface; SrcRect1 : -PSDL_Rect; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : -boolean; + PSDL_Rect; SrcRect2 : PSDL_Rect; Left1, Top1, Left2, Top2 : integer ) : + boolean; var Src_Rect1, Src_Rect2 : TSDL_Rect; right1, bottom1 : integer; right2, bottom2 : integer; - Scan1Start, Scan2Start, ScanWidth, ScanHeight : cardinal; - Mod1: cardinal; - Addr1 : cardinal; - BPP : cardinal; - Pitch1 : cardinal; + Scan1Start, {Scan2Start,} ScanWidth, ScanHeight : cardinal; + Mod1 : cardinal; + Addr1 : cardinal; + BPP : cardinal; + Pitch1 : cardinal; TransparentColor1 : cardinal; - tx, ty : cardinal; - StartTick : cardinal; - Color1 : cardinal; + tx, ty : cardinal; + StartTick : cardinal; + Color1 : cardinal; begin Result := false; if SrcRect1 = nil then @@ -3124,7 +3135,7 @@ begin else Src_Rect1 := SrcRect1^; - Src_Rect2 := SrcRect2^; + Src_Rect2 := SrcRect2^; with Src_Rect1 do begin Right1 := Left1 + w; @@ -3135,15 +3146,13 @@ begin Right2 := Left2 + w; Bottom2 := Top2 + h; end; - if ( Left1 >= Right2 ) or ( Right1 <= Left2 ) or ( Top1 >= Bottom2 ) or ( -Bottom1 <= - Top2 ) then + if ( Left1 >= Right2 ) or ( Right1 <= Left2 ) or ( Top1 >= Bottom2 ) or ( Bottom1 <= Top2 ) then exit; if Left1 <= Left2 then begin // 1. left, 2. right Scan1Start := Src_Rect1.x + Left2 - Left1; - Scan2Start := Src_Rect2.x; + //Scan2Start := Src_Rect2.x; ScanWidth := Right1 - Left2; with Src_Rect2 do if ScanWidth > w then @@ -3153,7 +3162,7 @@ Bottom1 <= begin // 1. right, 2. left Scan1Start := Src_Rect1.x; - Scan2Start := Src_Rect2.x + Left1 - Left2; + //Scan2Start := Src_Rect2.x + Left1 - Left2; ScanWidth := Right2 - Left1; with Src_Rect1 do if ScanWidth > w then @@ -3213,7 +3222,7 @@ Bottom1 <= begin for tx := 1 to ScanWidth do begin - if ( PWord( Addr1 )^ <> TransparentColor1 ) then + if ( PWord( Addr1 )^ <> TransparentColor1 ) then begin Result := true; exit; @@ -3248,7 +3257,7 @@ Bottom1 <= begin for tx := 1 to ScanWidth do begin - if ( PLongWord( Addr1 )^ <> TransparentColor1 ) then + if ( PLongWord( Addr1 )^ <> TransparentColor1 ) then begin Result := true; exit; @@ -3266,12 +3275,12 @@ procedure SDL_ORSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); var R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; - Src, Dest : TSDL_Rect; - Diff : integer; + Src, Dest : TSDL_Rect; + Diff : integer; SrcAddr, DestAddr : cardinal; WorkX, WorkY : word; SrcMod, DestMod : cardinal; - Bits : cardinal; + Bits : cardinal; begin if ( SrcSurface = nil ) or ( DestSurface = nil ) then exit; // Remove this to make it faster @@ -3366,7 +3375,7 @@ begin if ( Pixel1 <> TransparentColor ) and ( Pixel1 <> 0 ) then begin Pixel2 := PUInt8( DestAddr )^; - PUInt8( DestAddr )^ := Pixel2 OR Pixel1; + PUInt8( DestAddr )^ := Pixel2 or Pixel1; end; inc( SrcAddr ); inc( DestAddr ); @@ -3387,7 +3396,7 @@ begin begin Pixel2 := PUInt16( DestAddr )^; - PUInt16( DestAddr )^ := Pixel2 OR Pixel1; + PUInt16( DestAddr )^ := Pixel2 or Pixel1; end; inc( SrcAddr, 2 ); @@ -3409,7 +3418,7 @@ begin begin Pixel2 := PUInt16( DestAddr )^; - PUInt16( DestAddr )^ := Pixel2 OR Pixel1; + PUInt16( DestAddr )^ := Pixel2 or Pixel1; end; inc( SrcAddr, 2 ); @@ -3452,7 +3461,7 @@ begin begin Pixel2 := PUInt32( DestAddr )^; - PUInt32( DestAddr )^ := Pixel2 or Pixel1; + PUInt32( DestAddr )^ := Pixel2 or Pixel1; end; inc( SrcAddr, 4 ); inc( DestAddr, 4 ); @@ -3472,12 +3481,12 @@ procedure SDL_ANDSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); var R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; - Src, Dest : TSDL_Rect; - Diff : integer; + Src, Dest : TSDL_Rect; + Diff : integer; SrcAddr, DestAddr : cardinal; WorkX, WorkY : word; SrcMod, DestMod : cardinal; - Bits : cardinal; + Bits : cardinal; begin if ( SrcSurface = nil ) or ( DestSurface = nil ) then exit; // Remove this to make it faster @@ -3615,7 +3624,7 @@ begin begin Pixel2 := PUInt16( DestAddr )^; - PUInt16( DestAddr )^ := Pixel2 and Pixel1; + PUInt16( DestAddr )^ := Pixel2 and Pixel1; end; inc( SrcAddr, 2 ); @@ -3658,7 +3667,7 @@ begin begin Pixel2 := PUInt32( DestAddr )^; - PUInt32( DestAddr )^ := Pixel2 and Pixel1; + PUInt32( DestAddr )^ := Pixel2 and Pixel1; end; inc( SrcAddr, 4 ); inc( DestAddr, 4 ); @@ -3680,12 +3689,12 @@ procedure SDL_GTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); var R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; - Src, Dest : TSDL_Rect; - Diff : integer; + Src, Dest : TSDL_Rect; + Diff : integer; SrcAddr, DestAddr : cardinal; WorkX, WorkY : word; SrcMod, DestMod : cardinal; - Bits : cardinal; + Bits : cardinal; begin if ( SrcSurface = nil ) or ( DestSurface = nil ) then exit; // Remove this to make it faster @@ -3782,9 +3791,18 @@ begin Pixel2 := PUInt8( DestAddr )^; if Pixel2 > 0 then begin - if Pixel2 and $E0 > Pixel1 and $E0 then R := Pixel2 and $E0 else R := Pixel1 and $E0; - if Pixel2 and $1C > Pixel1 and $1C then G := Pixel2 and $1C else G := Pixel1 and $1C; - if Pixel2 and $03 > Pixel1 and $03 then B := Pixel2 and $03 else B := Pixel1 and $03; + if Pixel2 and $E0 > Pixel1 and $E0 then + R := Pixel2 and $E0 + else + R := Pixel1 and $E0; + if Pixel2 and $1C > Pixel1 and $1C then + G := Pixel2 and $1C + else + G := Pixel1 and $1C; + if Pixel2 and $03 > Pixel1 and $03 then + B := Pixel2 and $03 + else + B := Pixel1 and $03; if R > $E0 then R := $E0; @@ -3818,9 +3836,18 @@ begin if Pixel2 > 0 then begin - if Pixel2 and $7C00 > Pixel1 and $7C00 then R := Pixel2 and $7C00 else R := Pixel1 and $7C00; - if Pixel2 and $03E0 > Pixel1 and $03E0 then G := Pixel2 and $03E0 else G := Pixel1 and $03E0; - if Pixel2 and $001F > Pixel1 and $001F then B := Pixel2 and $001F else B := Pixel1 and $001F; + if Pixel2 and $7C00 > Pixel1 and $7C00 then + R := Pixel2 and $7C00 + else + R := Pixel1 and $7C00; + if Pixel2 and $03E0 > Pixel1 and $03E0 then + G := Pixel2 and $03E0 + else + G := Pixel1 and $03E0; + if Pixel2 and $001F > Pixel1 and $001F then + B := Pixel2 and $001F + else + B := Pixel1 and $001F; PUInt16( DestAddr )^ := R or G or B; end @@ -3848,9 +3875,18 @@ begin if Pixel2 > 0 then begin - if Pixel2 and $F800 > Pixel1 and $F800 then R := Pixel2 and $F800 else R := Pixel1 and $F800; - if Pixel2 and $07E0 > Pixel1 and $07E0 then G := Pixel2 and $07E0 else G := Pixel1 and $07E0; - if Pixel2 and $001F > Pixel1 and $001F then B := Pixel2 and $001F else B := Pixel1 and $001F; + if Pixel2 and $F800 > Pixel1 and $F800 then + R := Pixel2 and $F800 + else + R := Pixel1 and $F800; + if Pixel2 and $07E0 > Pixel1 and $07E0 then + G := Pixel2 and $07E0 + else + G := Pixel1 and $07E0; + if Pixel2 and $001F > Pixel1 and $001F then + B := Pixel2 and $001F + else + B := Pixel1 and $001F; PUInt16( DestAddr )^ := R or G or B; end @@ -3878,9 +3914,18 @@ begin if Pixel2 > 0 then begin - if Pixel2 and $FF0000 > Pixel1 and $FF0000 then R := Pixel2 and $FF0000 else R := Pixel1 and $FF0000; - if Pixel2 and $00FF00 > Pixel1 and $00FF00 then G := Pixel2 and $00FF00 else G := Pixel1 and $00FF00; - if Pixel2 and $0000FF > Pixel1 and $0000FF then B := Pixel2 and $0000FF else B := Pixel1 and $0000FF; + if Pixel2 and $FF0000 > Pixel1 and $FF0000 then + R := Pixel2 and $FF0000 + else + R := Pixel1 and $FF0000; + if Pixel2 and $00FF00 > Pixel1 and $00FF00 then + G := Pixel2 and $00FF00 + else + G := Pixel1 and $00FF00; + if Pixel2 and $0000FF > Pixel1 and $0000FF then + B := Pixel2 and $0000FF + else + B := Pixel1 and $0000FF; PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B ); end @@ -3908,9 +3953,18 @@ begin if Pixel2 > 0 then begin - if Pixel2 and $FF0000 > Pixel1 and $FF0000 then R := Pixel2 and $FF0000 else R := Pixel1 and $FF0000; - if Pixel2 and $00FF00 > Pixel1 and $00FF00 then G := Pixel2 and $00FF00 else G := Pixel1 and $00FF00; - if Pixel2 and $0000FF > Pixel1 and $0000FF then B := Pixel2 and $0000FF else B := Pixel1 and $0000FF; + if Pixel2 and $FF0000 > Pixel1 and $FF0000 then + R := Pixel2 and $FF0000 + else + R := Pixel1 and $FF0000; + if Pixel2 and $00FF00 > Pixel1 and $00FF00 then + G := Pixel2 and $00FF00 + else + G := Pixel1 and $00FF00; + if Pixel2 and $0000FF > Pixel1 and $0000FF then + B := Pixel2 and $0000FF + else + B := Pixel1 and $0000FF; PUInt32( DestAddr )^ := R or G or B; end @@ -3936,12 +3990,12 @@ procedure SDL_LTSurface( SrcSurface : PSDL_Surface; SrcRect : PSDL_Rect; DestSurface : PSDL_Surface; DestRect : PSDL_Rect ); var R, G, B, Pixel1, Pixel2, TransparentColor : cardinal; - Src, Dest : TSDL_Rect; - Diff : integer; + Src, Dest : TSDL_Rect; + Diff : integer; SrcAddr, DestAddr : cardinal; WorkX, WorkY : word; SrcMod, DestMod : cardinal; - Bits : cardinal; + Bits : cardinal; begin if ( SrcSurface = nil ) or ( DestSurface = nil ) then exit; // Remove this to make it faster @@ -4038,9 +4092,18 @@ begin Pixel2 := PUInt8( DestAddr )^; if Pixel2 > 0 then begin - if Pixel2 and $E0 < Pixel1 and $E0 then R := Pixel2 and $E0 else R := Pixel1 and $E0; - if Pixel2 and $1C < Pixel1 and $1C then G := Pixel2 and $1C else G := Pixel1 and $1C; - if Pixel2 and $03 < Pixel1 and $03 then B := Pixel2 and $03 else B := Pixel1 and $03; + if Pixel2 and $E0 < Pixel1 and $E0 then + R := Pixel2 and $E0 + else + R := Pixel1 and $E0; + if Pixel2 and $1C < Pixel1 and $1C then + G := Pixel2 and $1C + else + G := Pixel1 and $1C; + if Pixel2 and $03 < Pixel1 and $03 then + B := Pixel2 and $03 + else + B := Pixel1 and $03; if R > $E0 then R := $E0; @@ -4074,9 +4137,18 @@ begin if Pixel2 > 0 then begin - if Pixel2 and $7C00 < Pixel1 and $7C00 then R := Pixel2 and $7C00 else R := Pixel1 and $7C00; - if Pixel2 and $03E0 < Pixel1 and $03E0 then G := Pixel2 and $03E0 else G := Pixel1 and $03E0; - if Pixel2 and $001F < Pixel1 and $001F then B := Pixel2 and $001F else B := Pixel1 and $001F; + if Pixel2 and $7C00 < Pixel1 and $7C00 then + R := Pixel2 and $7C00 + else + R := Pixel1 and $7C00; + if Pixel2 and $03E0 < Pixel1 and $03E0 then + G := Pixel2 and $03E0 + else + G := Pixel1 and $03E0; + if Pixel2 and $001F < Pixel1 and $001F then + B := Pixel2 and $001F + else + B := Pixel1 and $001F; PUInt16( DestAddr )^ := R or G or B; end @@ -4104,9 +4176,18 @@ begin if Pixel2 > 0 then begin - if Pixel2 and $F800 < Pixel1 and $F800 then R := Pixel2 and $F800 else R := Pixel1 and $F800; - if Pixel2 and $07E0 < Pixel1 and $07E0 then G := Pixel2 and $07E0 else G := Pixel1 and $07E0; - if Pixel2 and $001F < Pixel1 and $001F then B := Pixel2 and $001F else B := Pixel1 and $001F; + if Pixel2 and $F800 < Pixel1 and $F800 then + R := Pixel2 and $F800 + else + R := Pixel1 and $F800; + if Pixel2 and $07E0 < Pixel1 and $07E0 then + G := Pixel2 and $07E0 + else + G := Pixel1 and $07E0; + if Pixel2 and $001F < Pixel1 and $001F then + B := Pixel2 and $001F + else + B := Pixel1 and $001F; PUInt16( DestAddr )^ := R or G or B; end @@ -4134,9 +4215,18 @@ begin if Pixel2 > 0 then begin - if Pixel2 and $FF0000 < Pixel1 and $FF0000 then R := Pixel2 and $FF0000 else R := Pixel1 and $FF0000; - if Pixel2 and $00FF00 < Pixel1 and $00FF00 then G := Pixel2 and $00FF00 else G := Pixel1 and $00FF00; - if Pixel2 and $0000FF < Pixel1 and $0000FF then B := Pixel2 and $0000FF else B := Pixel1 and $0000FF; + if Pixel2 and $FF0000 < Pixel1 and $FF0000 then + R := Pixel2 and $FF0000 + else + R := Pixel1 and $FF0000; + if Pixel2 and $00FF00 < Pixel1 and $00FF00 then + G := Pixel2 and $00FF00 + else + G := Pixel1 and $00FF00; + if Pixel2 and $0000FF < Pixel1 and $0000FF then + B := Pixel2 and $0000FF + else + B := Pixel1 and $0000FF; PUInt32( DestAddr )^ := PUInt32( DestAddr )^ and $FF000000 or ( R or G or B ); end @@ -4164,9 +4254,18 @@ begin if Pixel2 > 0 then begin - if Pixel2 and $FF0000 < Pixel1 and $FF0000 then R := Pixel2 and $FF0000 else R := Pixel1 and $FF0000; - if Pixel2 and $00FF00 < Pixel1 and $00FF00 then G := Pixel2 and $00FF00 else G := Pixel1 and $00FF00; - if Pixel2 and $0000FF < Pixel1 and $0000FF then B := Pixel2 and $0000FF else B := Pixel1 and $0000FF; + if Pixel2 and $FF0000 < Pixel1 and $FF0000 then + R := Pixel2 and $FF0000 + else + R := Pixel1 and $FF0000; + if Pixel2 and $00FF00 < Pixel1 and $00FF00 then + G := Pixel2 and $00FF00 + else + G := Pixel1 and $00FF00; + if Pixel2 and $0000FF < Pixel1 and $0000FF then + B := Pixel2 and $0000FF + else + B := Pixel1 and $0000FF; PUInt32( DestAddr )^ := R or G or B; end @@ -4188,69 +4287,75 @@ begin end; // Will clip the x1,x2,y1,x2 params to the ClipRect provided -function SDL_ClipLine(var x1,y1,x2,y2: Integer; ClipRect: PSDL_Rect) : boolean; - var tflag, flag1, flag2: word; - txy, xedge, yedge: Integer; - slope: single; - function ClipCode(x,y: Integer): word; +function SDL_ClipLine( var x1, y1, x2, y2 : Integer; ClipRect : PSDL_Rect ) : boolean; +var + tflag, flag1, flag2 : word; + txy, xedge, yedge : Integer; + slope : single; + + function ClipCode( x, y : Integer ) : word; begin Result := 0; - if x < ClipRect.x then Result := 1; - if x >= ClipRect.w + ClipRect.x then Result := Result or 2; - if y < ClipRect.y then Result := Result or 4; - if y >= ClipRect.h + ClipRect.y then Result := Result or 8; + if x < ClipRect.x then + Result := 1; + if x >= ClipRect.w + ClipRect.x then + Result := Result or 2; + if y < ClipRect.y then + Result := Result or 4; + if y >= ClipRect.h + ClipRect.y then + Result := Result or 8; end; begin - flag1 := ClipCode(x1,y1); - flag2 := ClipCode(x2,y2); + flag1 := ClipCode( x1, y1 ); + flag2 := ClipCode( x2, y2 ); result := true; while true do begin - if (flag1 or flag2) = 0 then Exit; // all in + if ( flag1 or flag2 ) = 0 then + Exit; // all in - if (flag1 and flag2) <> 0 then - begin - result := false; - Exit; // all out - end; + if ( flag1 and flag2 ) <> 0 then + begin + result := false; + Exit; // all out + end; if flag2 = 0 then - begin - txy := x1; x1 := x2; x2 := txy; - txy := y1; y1 := y2; y2 := txy; - tflag := flag1; flag1 := flag2; flag2 := tflag; - end; + begin + txy := x1; x1 := x2; x2 := txy; + txy := y1; y1 := y2; y2 := txy; + tflag := flag1; flag1 := flag2; flag2 := tflag; + end; - if (flag2 and 3) <> 0 then - begin - if (flag2 and 1) <> 0 then - xedge := ClipRect.x - else - xedge := ClipRect.w + ClipRect.x -1; // back 1 pixel otherwise we end up in a loop + if ( flag2 and 3 ) <> 0 then + begin + if ( flag2 and 1 ) <> 0 then + xedge := ClipRect.x + else + xedge := ClipRect.w + ClipRect.x - 1; // back 1 pixel otherwise we end up in a loop - slope := (y2 - y1) / (x2 - x1); - y2 := y1 + Round(slope * (xedge - x1)); - x2 := xedge; - end + slope := ( y2 - y1 ) / ( x2 - x1 ); + y2 := y1 + Round( slope * ( xedge - x1 ) ); + x2 := xedge; + end else - begin - if (flag2 and 4) <> 0 then - yedge := ClipRect.y - else - yedge := ClipRect.h + ClipRect.y -1; // up 1 pixel otherwise we end up in a loop + begin + if ( flag2 and 4 ) <> 0 then + yedge := ClipRect.y + else + yedge := ClipRect.h + ClipRect.y - 1; // up 1 pixel otherwise we end up in a loop - slope := (x2 - x1) / (y2 - y1); - x2 := x1 + Round(slope * (yedge - y1)); - y2 := yedge; - end; + slope := ( x2 - x1 ) / ( y2 - y1 ); + x2 := x1 + Round( slope * ( yedge - y1 ) ); + y2 := yedge; + end; - flag2 := ClipCode(x2, y2); + flag2 := ClipCode( x2, y2 ); end; end; end. - diff --git a/packages/extra/sdl/sdlwindow.pas b/packages/extra/sdl/sdlwindow.pas index 2ff05aebc8..99eea304cf 100644 --- a/packages/extra/sdl/sdlwindow.pas +++ b/packages/extra/sdl/sdlwindow.pas @@ -1,6 +1,6 @@ unit sdlwindow; { - $Id: sdlwindow.pas,v 1.7 2004/09/30 22:35:47 savage Exp $ + $Id: sdlwindow.pas,v 1.9 2006/10/22 18:55:25 savage Exp $ } {******************************************************************************} @@ -59,6 +59,12 @@ unit sdlwindow; { } { $Log: sdlwindow.pas,v $ + Revision 1.9 2006/10/22 18:55:25 savage + Slight Change to handle OpenGL context + + Revision 1.8 2005/08/03 18:57:32 savage + Various updates and additions. Mainly to handle OpenGL 3D Window support and better cursor support for the mouse class + Revision 1.7 2004/09/30 22:35:47 savage Changes, enhancements and additions as required to get SoAoS working. @@ -171,15 +177,8 @@ type function Show : Boolean; virtual; end; - TSDL2DWindow = class( TSDLBaseWindow ) + TSDLCustomWindow = class( TSDLBaseWindow ) public - constructor Create( aWidth : integer; aHeight : integer; aBitDepth : integer; aVideoFlags : Uint32 = SDL_DOUBLEBUF or SDL_SWSURFACE); override; - procedure Render; override; - procedure Update( aElapsedTime : single ); override; - procedure InitialiseObjects; override; - procedure RestoreObjects; override; - procedure DeleteObjects; override; - function Flip : integer; override; property OnCreate; property OnDestroy; property OnClose; @@ -190,7 +189,18 @@ type property DisplaySurface; end; - TSDL3DWindow = class( TSDLBaseWindow ) + TSDL2DWindow = class( TSDLCustomWindow ) + public + constructor Create( aWidth : integer; aHeight : integer; aBitDepth : integer; aVideoFlags : Uint32 = SDL_DOUBLEBUF or SDL_SWSURFACE); override; + procedure Render; override; + procedure Update( aElapsedTime : single ); override; + procedure InitialiseObjects; override; + procedure RestoreObjects; override; + procedure DeleteObjects; override; + function Flip : integer; override; + end; + + TSDL3DWindow = class( TSDLCustomWindow ) public constructor Create( aWidth : integer; aHeight : integer; aBitDepth : integer; aVideoFlags : Uint32 = SDL_OPENGL or SDL_DOUBLEBUF); override; function Flip : integer; override; @@ -199,14 +209,6 @@ type procedure InitialiseObjects; override; procedure RestoreObjects; override; procedure DeleteObjects; override; - property OnCreate; - property OnDestroy; - property OnClose; - property OnShow; - property OnResize; - property OnRender; - property OnUpdate; - property DisplaySurface; end; @@ -226,7 +228,7 @@ begin Log.LogError( Format('Could not set video mode: %s', [SDL_GetError]), 'Main'); exit; end; - + SetCaption( 'Made with JEDI-SDL', 'JEDI-SDL Icon' ); end; @@ -552,7 +554,7 @@ end; procedure TSDL3DWindow.Render; begin inherited; - + end; procedure TSDL3DWindow.RestoreObjects;