hedgewars/SDLh.pas
branchhedgeroid
changeset 6328 d14adf1c7721
parent 6224 42b256eca362
parent 6286 835392304f81
child 6330 1bde8940e1bb
equal deleted inserted replaced
6236:1998ff75321a 6328:d14adf1c7721
    81     SDL_TTFLibName = 'SDL_ttf';
    81     SDL_TTFLibName = 'SDL_ttf';
    82     SDL_MixerLibName = 'SDL_mixer';
    82     SDL_MixerLibName = 'SDL_mixer';
    83     SDL_ImageLibName = 'SDL_image';
    83     SDL_ImageLibName = 'SDL_image';
    84     SDL_NetLibName = 'SDL_net';
    84     SDL_NetLibName = 'SDL_net';
    85   {$ELSE}
    85   {$ELSE}
    86     SDLLibName = 'SDL';
    86     SDLLibName = 'libSDL.so';
    87     SDL_TTFLibName = 'libSDL_ttf.so';
    87     SDL_TTFLibName = 'libSDL_ttf.so';
    88     SDL_MixerLibName = 'libSDL_mixer.so';
    88     SDL_MixerLibName = 'libSDL_mixer.so';
    89     SDL_ImageLibName = 'libSDL_image.so';
    89     SDL_ImageLibName = 'libSDL_image.so';
    90     SDL_NetLibName = 'libSDL_net.so';
    90     SDL_NetLibName = 'libSDL_net.so';
    91   {$ENDIF}
    91   {$ENDIF}
   107     SDL_INIT_EVENTTHREAD = $01000000;
   107     SDL_INIT_EVENTTHREAD = $01000000;
   108 {$ENDIF}
   108 {$ENDIF}
   109     SDL_INIT_NOPARACHUTE = $00100000;
   109     SDL_INIT_NOPARACHUTE = $00100000;
   110     SDL_INIT_EVERYTHING  = $0000FFFF;
   110     SDL_INIT_EVERYTHING  = $0000FFFF;
   111 
   111 
       
   112     SDL_ALLEVENTS        = $FFFFFFFF;
   112     SDL_APPINPUTFOCUS    = $02;
   113     SDL_APPINPUTFOCUS    = $02;
   113     SDL_BUTTON_WHEELUP   = 4;
   114     SDL_BUTTON_WHEELUP   = 4;
   114     SDL_BUTTON_WHEELDOWN = 5;
   115     SDL_BUTTON_WHEELDOWN = 5;
   115 
   116 
   116 {$IFDEF SDL13}
   117 {$IFDEF SDL13}
   139     SDL_JOYBUTTONDOWN     = $603;
   140     SDL_JOYBUTTONDOWN     = $603;
   140     SDL_JOYBUTTONUP       = $604;
   141     SDL_JOYBUTTONUP       = $604;
   141     SDL_FINGERDOWN        = $700;
   142     SDL_FINGERDOWN        = $700;
   142     SDL_FINGERUP          = $701;
   143     SDL_FINGERUP          = $701;
   143     SDL_FINGERMOTION      = $702;
   144     SDL_FINGERMOTION      = $702;
   144     //TODO: implement otheer event types
   145     SDL_TOUCHBUTTONDOWN   = $703;
       
   146     SDL_TOUCHBUTTONUP     = $704;
       
   147     SDL_DOLLARGESTURE     = $800;
       
   148     SDL_DOLLARRECORD      = $801;
       
   149     SDL_MULTIGESTURE      = $802;
       
   150     SDL_CLIPBOARDUPDATE   = $900;
   145     SDL_USEREVENT         = $8000;
   151     SDL_USEREVENT         = $8000;
   146     SDL_LASTEVENT         = $FFFF;
   152     SDL_LASTEVENT         = $FFFF;
       
   153     // no compatibility events $7000
   147 
   154 
   148     // SDL_Surface flags
   155     // SDL_Surface flags
   149     SDL_SWSURFACE   = $00000000;  //*< Not used */
   156     SDL_SWSURFACE   = $00000000;  //*< Not used */
   150     SDL_PREALLOC    = $00000001;  //*< Surface uses preallocated memory */
   157     SDL_PREALLOC    = $00000001;  //*< Surface uses preallocated memory */
   151     SDL_RLEACCEL    = $00000002;  //*< Surface is RLE encoded */
   158     SDL_RLEACCEL    = $00000002;  //*< Surface is RLE encoded */
   231     SDL_SRCALPHA    = $00010000;
   238     SDL_SRCALPHA    = $00010000;
   232     SDL_ANYFORMAT   = $00100000;
   239     SDL_ANYFORMAT   = $00100000;
   233     SDL_HWPALETTE   = $20000000;
   240     SDL_HWPALETTE   = $20000000;
   234     SDL_DOUBLEBUF   = $40000000;
   241     SDL_DOUBLEBUF   = $40000000;
   235     SDL_FULLSCREEN  = $80000000;
   242     SDL_FULLSCREEN  = $80000000;
   236 
       
   237     SDL_ALLEVENTS = $FFFFFFFF;
       
   238 {$ENDIF}
   243 {$ENDIF}
   239 
   244 
   240 {$IFDEF ENDIAN_LITTLE}
   245 {$IFDEF ENDIAN_LITTLE}
   241     RMask = $000000FF;
   246     RMask = $000000FF;
   242     GMask = $0000FF00;
   247     GMask = $0000FF00;
   289 
   294 
   290 /////////////////////////////////////////////////////////////////
   295 /////////////////////////////////////////////////////////////////
   291 ///////////////////////  TYPE DEFINITIONS ///////////////////////
   296 ///////////////////////  TYPE DEFINITIONS ///////////////////////
   292 /////////////////////////////////////////////////////////////////
   297 /////////////////////////////////////////////////////////////////
   293 
   298 
       
   299 // two important reference points for the wanderers of this area
       
   300 // http://www.freepascal.org/docs-html/ref/refsu5.html
       
   301 // http://www.freepascal.org/docs-html/prog/progsu144.html
       
   302 
   294 type
   303 type
   295 {$IFDEF SDL13}
   304 {$IFDEF SDL13}
   296     PSDL_Window   = Pointer;
   305     PSDL_Window   = Pointer;
   297     PSDL_Renderer = Pointer;
   306     PSDL_Renderer = Pointer;
   298     PSDL_Texture  = Pointer;
   307     PSDL_Texture  = Pointer;
   314         end;
   323         end;
   315 
   324 
   316     PSDL_PixelFormat = ^TSDL_PixelFormat;
   325     PSDL_PixelFormat = ^TSDL_PixelFormat;
   317     TSDL_PixelFormat = record
   326     TSDL_PixelFormat = record
   318 {$IFDEF SDL13}
   327 {$IFDEF SDL13}
   319         format: Longword;
   328         format: LongWord;
   320         palette: Pointer;   // actually it is a PSDL_Palette
   329         palette: Pointer;
   321         BitsPerPixel : Byte;
   330         BitsPerPixel : Byte;
   322         BytesPerPixel: Byte;
   331         BytesPerPixel: Byte;
   323         padding: array[0..1] of Byte;
   332         padding: array[0..1] of Byte;
   324         RMask : Longword;
   333         RMask : LongWord;
   325         GMask : Longword;
   334         GMask : LongWord;
   326         BMask : Longword;
   335         BMask : LongWord;
   327         AMask : Longword;
   336         AMask : LongWord;
   328         Rloss : Byte;
   337         Rloss : Byte;
   329         Gloss : Byte;
   338         Gloss : Byte;
   330         Bloss : Byte;
   339         Bloss : Byte;
   331         Aloss : Byte;
   340         Aloss : Byte;
   332         Rshift: Byte;
   341         Rshift: Byte;
   345         Aloss : Byte;
   354         Aloss : Byte;
   346         Rshift: Byte;
   355         Rshift: Byte;
   347         Gshift: Byte;
   356         Gshift: Byte;
   348         Bshift: Byte;
   357         Bshift: Byte;
   349         Ashift: Byte;
   358         Ashift: Byte;
   350         RMask : Longword;
   359         RMask : LongWord;
   351         GMask : Longword;
   360         GMask : LongWord;
   352         BMask : Longword;
   361         BMask : LongWord;
   353         AMask : Longword;
   362         AMask : LongWord;
   354         colorkey: Longword;
   363         colorkey: LongWord;
   355         alpha: Byte;
   364         alpha: Byte;
   356 {$ENDIF}
   365 {$ENDIF}
   357         end;
   366         end;
   358 
   367 
   359     SDL_eventaction = (SDL_ADDEVENT = 0, SDL_PEEPEVENT, SDL_GETEVENT);
   368     SDL_eventaction = (SDL_ADDEVENT = 0, SDL_PEEPEVENT, SDL_GETEVENT);
   360 
   369 
   361     PSDL_Surface = ^TSDL_Surface;
   370     PSDL_Surface = ^TSDL_Surface;
   362     TSDL_Surface = record
   371     TSDL_Surface = record
   363         flags : Longword;
   372         flags : LongWord;
   364         format: PSDL_PixelFormat;
   373         format: PSDL_PixelFormat;
   365         w, h  : LongInt;
   374         w, h  : LongInt;
   366         pitch : Word;
   375         pitch : {$IFDEF SDL13}LongInt{$ELSE}Word{$ENDIF};
   367         pixels: Pointer;
   376         pixels: Pointer;
   368         offset: LongInt;
   377         offset: LongInt;
   369 {$IFDEF SDL13}
   378 {$IFDEF SDL13}
   370         userdata: Pointer;
   379         userdata: Pointer;
   371         locked: LongInt;
   380         locked: LongInt;
   377         end;
   386         end;
   378 
   387 
   379 
   388 
   380     PSDL_Color = ^TSDL_Color;
   389     PSDL_Color = ^TSDL_Color;
   381     TSDL_Color = record
   390     TSDL_Color = record
   382         case byte of
   391         case Byte of
   383             0: ( r: Byte;
   392             0: ( r: Byte;
   384                  g: Byte;
   393                  g: Byte;
   385                  b: Byte;
   394                  b: Byte;
   386                  unused: Byte; );
   395                  unused: Byte; );
   387             1: ( value: Longword; );
   396             1: ( value: LongWord; );
   388         end;
   397         end;
   389 
   398 
   390 
   399 
   391     PSDL_RWops = ^TSDL_RWops;
   400     PSDL_RWops = ^TSDL_RWops;
   392     TSeek  = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl;
   401     TSeek  = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl;
   393     TRead  = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt;  cdecl;
   402     TRead  = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt;  cdecl;
   394     TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl;
   403     TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl;
   395     TClose = function( context: PSDL_RWops ): LongInt; cdecl;
   404     TClose = function( context: PSDL_RWops ): LongInt; cdecl;
   396 
   405 
   397     TStdio = record
   406     TStdio = record
   398         autoclose: {$IFDEF SDL13}boolean{$ELSE}LongInt{$ENDIF};
   407         autoclose: {$IFDEF SDL13}Boolean{$ELSE}LongInt{$ENDIF};
   399         fp: pointer;
   408         fp: Pointer;
   400         end;
   409         end;
   401 
   410 
   402     TMem = record
   411     TMem = record
   403         base: PByte;
   412         base: PByte;
   404         here: PByte;
   413         here: PByte;
   412     TSDL_RWops = record
   421     TSDL_RWops = record
   413         seek: TSeek;
   422         seek: TSeek;
   414         read: TRead;
   423         read: TRead;
   415         write: TWrite;
   424         write: TWrite;
   416         close: TClose;
   425         close: TClose;
   417         type_: Longword;
   426         type_: LongWord;
   418         case Byte of
   427         case Byte of
   419             0: (stdio: TStdio);
   428             0: (stdio: TStdio);
   420             1: (mem: TMem);
   429             1: (mem: TMem);
   421             2: (unknown: TUnknown);
   430             2: (unknown: TUnknown);
   422             end;
   431             end;
   426 
   435 
   427 {$IFDEF SDL13}
   436 {$IFDEF SDL13}
   428     TSDL_KeySym = record
   437     TSDL_KeySym = record
   429         scancode: LongInt;
   438         scancode: LongInt;
   430         sym: LongInt;
   439         sym: LongInt;
   431         modifier: Smallint;
   440         modifier: Word;
   432         unicode: LongInt;
   441         unicode: LongWord;
   433         end;
   442         end;
   434 
   443 
   435     TSDL_WindowEvent = record
   444     TSDL_WindowEvent = record
   436         type_: LongInt;
   445         type_: LongWord;
   437         windowID: LongInt;
   446         windowID: LongWord;
   438         event: byte;
   447         event: Byte;
   439         padding1, padding2, padding3: byte;
   448         padding1, padding2, padding3: Byte;
   440         data1, data2: LongInt;
   449         data1, data2: LongInt;
       
   450         end;
       
   451 
       
   452     // available in sdl12 but not exposed
       
   453     TSDL_TextEditingEvent = record
       
   454         type_: LongWord;
       
   455         windowID: LongWord;
       
   456         text: array[0..31] of Byte;
       
   457         start, lenght: LongInt;
       
   458         end;
       
   459 
       
   460     // available in sdl12 but not exposed
       
   461     TSDL_TextInputEvent = record
       
   462         type_: LongWord;
       
   463         windowID: LongWord;
       
   464         text: array[0..31] of Byte;
       
   465         end;
       
   466 
       
   467     TSDL_TouchFingerEvent = record
       
   468         type_: LongWord;
       
   469         windowId: LongWord;
       
   470         touchId: Int64;
       
   471         fingerId: Int64;
       
   472         state, padding1, padding2, padding3: Byte;
       
   473         x, y: Word;
       
   474         dx, dy: SmallInt;
       
   475         pressure: Word;
       
   476         end;
       
   477 
       
   478     TSDL_TouchButtonEvent = record
       
   479         type_: LongWord;
       
   480         windowId: LongWord;
       
   481         touchId: Int64;
       
   482         state, button, padding1, padding2: Byte;
       
   483         end;
       
   484 
       
   485     TSDL_MultiGestureEvent = record
       
   486         type_: LongWord;
       
   487         windowId: LongWord;
       
   488         touchId: Int64;
       
   489         dTheta, dDist, x, y: Single;
       
   490         numFingers, padding: Word;
       
   491         end;
       
   492 
       
   493     TSDL_DollarGestureEvent = record
       
   494         type_: LongWord;
       
   495         windowId: LongWord;
       
   496         touchId: Int64;
       
   497         gesturedId: Int64;
       
   498         numFingers: LongWord;
       
   499         error: Single;
       
   500         end;
       
   501 
       
   502     TSDL_SysWMEvent = record
       
   503         type_: LongWord;
       
   504         msg: Pointer;
   441         end;
   505         end;
   442 {$ELSE}
   506 {$ELSE}
   443     TSDL_KeySym = record
   507     TSDL_KeySym = record
   444         scancode: Byte;
   508         scancode: Byte;
   445         sym: Longword;
   509         sym: LongWord;
   446         modifier: Longword;
   510         modifier: LongWord;
   447         unicode: Word;
   511         unicode: Word;
   448         end;
   512         end;
   449 
   513 
   450     // these two are present in sdl1.3 but only for backward compatibility
       
   451     // and in 1.3 type_ is LongInt, not byte
       
   452     TSDL_ActiveEvent = record
   514     TSDL_ActiveEvent = record
   453         type_: byte;
   515         type_: Byte;
   454         gain: byte;
   516         gain: Byte;
   455         state: byte;
   517         state: Byte;
   456         end;
   518         end;
   457 
   519 
   458     TSDL_ResizeEvent = record
   520     TSDL_ResizeEvent = record
   459         type_: Byte;
   521         type_: Byte;
   460         w, h: LongInt;
   522         w, h: LongInt;
   461         end;
   523         end;
   462 {$ENDIF}
   524 {$ENDIF}
   463 
   525 
   464     TSDL_KeyboardEvent = record
   526     TSDL_KeyboardEvent = record
   465 {$IFDEF SDL13}
   527 {$IFDEF SDL13}
   466         type_: LongInt;
   528         type_: LongWord;
   467         windowID: LongInt;
   529         windowID: LongWord;
   468         state, repeat_, padding2, padding3: byte;
   530         state, repeat_, padding2, padding3: Byte;
   469 {$ELSE}
   531 {$ELSE}
   470         type_: byte;
   532         type_, which, state: Byte;
   471         which: byte;
       
   472         state: byte;
       
   473 {$ENDIF}
   533 {$ENDIF}
   474         keysym: TSDL_KeySym;
   534         keysym: TSDL_KeySym;
   475         end;
   535         end;
   476 
   536 
   477 //TODO: implement SDL_TextEditingEvent + SDL_TextInputEvent for sdl13
       
   478 
       
   479     // this structure is wrong but the correct version makes the game hang
       
   480     TSDL_MouseMotionEvent = record
   537     TSDL_MouseMotionEvent = record
   481         which: byte;
   538 {$IFDEF SDL13}
   482         state: byte;
   539         type_: LongWord;
   483 {$IFDEF SDL13}
   540         windowID: LongWord;
   484         type_: LongInt;
   541         state, padding1, padding2, padding3: Byte;
   485         windowID: LongInt;
       
   486         padding1, padding2: byte;
       
   487         x, y, z, xrel, yrel : LongInt;
   542         x, y, z, xrel, yrel : LongInt;
   488         pressure, pressure_max, pressure_min,
   543 {$ELSE}
   489         rotation, tilt, cursor: LongInt;
   544         type_, which, state: Byte;
   490 {$ELSE}
   545         x, y, xrel, yrel : Word;
   491         type_: byte;
       
   492         x, y, xrel, yrel : word;
       
   493 {$ENDIF}
   546 {$ENDIF}
   494         end;
   547         end;
   495 
   548 
   496     TSDL_MouseButtonEvent = record
   549     TSDL_MouseButtonEvent = record
   497 {$IFDEF SDL13}
   550 {$IFDEF SDL13}
   498         type_: LongInt;
   551         type_: LongWord;
   499         windowID: LongInt;
   552         windowID: LongWord;
       
   553         buttonm, state, padding1, padding2: Byte;
   500         x, y: LongInt;
   554         x, y: LongInt;
   501         padding1: byte;
   555 {$ELSE}
   502 {$ELSE}
   556         type_, which, button, state: Byte;
   503         type_,
   557         x, y: Word;
   504         which,
   558 {$ENDIF}
   505         button,
   559         end;
   506         state: byte;
   560 
   507         x, y: word;
       
   508 {$ENDIF}
       
   509         end;
       
   510 
       
   511 {$IFDEF SDL13}
       
   512     TSDL_MouseWheelEvent = record
   561     TSDL_MouseWheelEvent = record
   513         type_: LongInt;
   562         type_: LongWord;
   514         windowID: LongInt;
   563 {$IFDEF SDL13}
       
   564         windowID: LongWord;
       
   565 {$ELSE}
   515         which: Byte;
   566         which: Byte;
   516         x, y: LongInt;
   567         x, y: LongInt;
   517         end;
   568         end;
   518 
   569 
   519 //TODO: implement SDL_ProximityEvent
       
   520 {$ENDIF}
       
   521 
       
   522     TSDL_JoyAxisEvent = record
   570     TSDL_JoyAxisEvent = record
   523         type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
   571         type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF};
   524         which: Byte;
   572         which: Byte;
   525         axis: Byte;
   573         axis: Byte;
   526 {$IFDEF SDL13}
   574 {$IFDEF SDL13}
   527         padding1, padding2: Byte;
   575         padding1, padding2: Byte;
   528         value: LongInt;
   576         value: LongInt;
   529 {$ELSE}
   577 {$ELSE}
   530         value: Smallint;
   578         value: SmallInt;
   531 {$ENDIF}
   579 {$ENDIF}
   532         end;
   580         end;
   533 
   581 
   534     TSDL_JoyBallEvent = record
   582     TSDL_JoyBallEvent = record
   535         type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
   583         type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF};
   536         which: Byte;
   584         which: Byte;
   537         ball: Byte;
   585         ball: Byte;
   538 {$IFDEF SDL13}
   586 {$IFDEF SDL13}
   539         padding1, padding2: Byte;
   587         padding1, padding2: Byte;
   540         xrel, yrel: LongInt;
   588         xrel, yrel: LongInt;
   541 {$ELSE}
   589 {$ELSE}
   542         xrel, yrel: Smallint;
   590         xrel, yrel: SmallInt;
   543 {$ENDIF}
   591 {$ENDIF}
   544         end;
   592         end;
   545 
   593 
   546     TSDL_JoyHatEvent = record
   594     TSDL_JoyHatEvent = record
   547         type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
   595         type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF};
   548         which: Byte;
   596         which: Byte;
   549         hat: Byte;
   597         hat: Byte;
   550         value: Byte;
   598         value: Byte;
   551 {$IFDEF SDL13}
   599 {$IFDEF SDL13}
   552         padding1: Byte;
   600         padding1: Byte;
   553 {$ENDIF}
   601 {$ENDIF}
   554         end;
   602         end;
   555 
   603 
   556     TSDL_JoyButtonEvent = record
   604     TSDL_JoyButtonEvent = record
   557         type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
   605         type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF};
   558         which: Byte;
   606         which: Byte;
   559         button: Byte;
   607         button: Byte;
   560         state: Byte;
   608         state: Byte;
   561 {$IFDEF SDL13}
   609 {$IFDEF SDL13}
   562         padding1: Byte;
   610         padding1: Byte;
   577         pressure: Word;
   625         pressure: Word;
   578     end;
   626     end;
   579 //TODO: implement SDL_TouchButtonEvent, SDL_MultiGestureEvent, SDL_DollarGestureEvent
   627 //TODO: implement SDL_TouchButtonEvent, SDL_MultiGestureEvent, SDL_DollarGestureEvent
   580 
   628 
   581     TSDL_QuitEvent = record
   629     TSDL_QuitEvent = record
   582         type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
   630         type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF};
   583         end;
   631         end;
   584 
   632 
   585     TSDL_UserEvent = record
   633     TSDL_UserEvent = record
   586 {$IFDEF SDL13}
   634 {$IFDEF SDL13}
   587         type_: LongInt;
   635         type_: LongWord;
   588         windowID: LongInt;
   636         windowID: LongWord;
   589 {$ELSE}
   637 {$ELSE}
   590         type_: Byte;
   638         type_: Byte;
   591 {$ENDIF}
   639 {$ENDIF}
   592         code: LongInt;
   640         code: LongInt;
   593         data1, data2: Pointer;
   641         data1, data2: Pointer;
   599         case LongInt of
   647         case LongInt of
   600             SDL_FIRSTEVENT: (type_: LongInt);
   648             SDL_FIRSTEVENT: (type_: LongInt);
   601             SDL_WINDOWEVENT: (window: TSDL_WindowEvent);
   649             SDL_WINDOWEVENT: (window: TSDL_WindowEvent);
   602             SDL_KEYDOWN,
   650             SDL_KEYDOWN,
   603             SDL_KEYUP: (key: TSDL_KeyboardEvent);
   651             SDL_KEYUP: (key: TSDL_KeyboardEvent);
   604             SDL_TEXTEDITING,
   652             SDL_TEXTEDITING: (edit: TSDL_TextEditingEvent);
   605             SDL_TEXTINPUT: (edit: byte);
   653             SDL_TEXTINPUT: (tedit: TSDL_TextInputEvent);
   606             SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
   654             SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
   607             SDL_MOUSEBUTTONDOWN,
   655             SDL_MOUSEBUTTONDOWN,
   608             SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
   656             SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
   609             SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent);
   657             SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent);
   610             SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
   658             SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
   615             SDL_FINGERMOTION,
   663             SDL_FINGERMOTION,
   616             SDL_FINGERUP,
   664             SDL_FINGERUP,
   617             SDL_FINGERDOWN:(tfinger: TSDL_TouchFingerEvent);
   665             SDL_FINGERDOWN:(tfinger: TSDL_TouchFingerEvent);
   618             SDL_QUITEV: (quit: TSDL_QuitEvent);
   666             SDL_QUITEV: (quit: TSDL_QuitEvent);
   619             SDL_USEREVENT: (user: TSDL_UserEvent);
   667             SDL_USEREVENT: (user: TSDL_UserEvent);
   620             //TODO: implement other events
   668             SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent);
       
   669             SDL_FINGERDOWN,
       
   670             SDL_FINGERUP,
       
   671             SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent);
       
   672             SDL_TOUCHBUTTONUP,
       
   673             SDL_TOUCHBUTTONDOWN: (tbutton: TSDL_TouchButtonEvent);
       
   674             SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent);
       
   675             SDL_DOLLARGESTURE: (dgesture: TSDL_DollarGestureEvent);
       
   676             SDL_ALLEVENTS: (foo: shortstring);
   621 {$ELSE}
   677 {$ELSE}
   622         case Byte of
   678         case Byte of
   623             SDL_NOEVENT: (type_: byte);
   679             SDL_NOEVENT: (type_: Byte);
   624             SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
   680             SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
   625             SDL_KEYDOWN,
   681             SDL_KEYDOWN,
   626             SDL_KEYUP: (key: TSDL_KeyboardEvent);
   682             SDL_KEYUP: (key: TSDL_KeyboardEvent);
   627             SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
   683             SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
   628             SDL_MOUSEBUTTONDOWN,
   684             SDL_MOUSEBUTTONDOWN,
   633             SDL_JOYBUTTONDOWN,
   689             SDL_JOYBUTTONDOWN,
   634             SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
   690             SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
   635             SDL_QUITEV: (quit: TSDL_QuitEvent);
   691             SDL_QUITEV: (quit: TSDL_QuitEvent);
   636             //SDL_SYSWMEVENT,SDL_EVENT_RESERVEDA,SDL_EVENT_RESERVEDB
   692             //SDL_SYSWMEVENT,SDL_EVENT_RESERVEDA,SDL_EVENT_RESERVEDB
   637             SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent);
   693             SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent);
   638 {$ENDIF}
   694             SDL_ALLEVENTS: (foo: shortstring);
   639         end;
   695 {$ENDIF}
   640 
   696         end;
   641 
   697 
   642     TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl;
   698     TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl;
   643 
   699 
   644     
       
   645     PByteArray = ^TByteArray;
   700     PByteArray = ^TByteArray;
   646     TByteArray = array[0..65535] of Byte;
   701     TByteArray = array[0..65535] of Byte;
   647     PLongWordArray = ^TLongWordArray;
   702     PLongWordArray = ^TLongWordArray;
   648     TLongWordArray = array[0..16383] of LongWord;
   703     TLongWordArray = array[0..16383] of LongWord;
   649 
   704 
   675         SDL_GL_SWAP_CONTROL
   730         SDL_GL_SWAP_CONTROL
   676 {$ENDIF}
   731 {$ENDIF}
   677         );
   732         );
   678 
   733 
   679 {$IFDEF SDL13}
   734 {$IFDEF SDL13}
   680     TSDL_ArrayByteOrder = (  // array component order, low byte -> high byte
   735     TSDL_ArrayByteOrder = (  // array component order, low Byte -> high Byte
   681         SDL_ARRAYORDER_NONE,
   736         SDL_ARRAYORDER_NONE,
   682         SDL_ARRAYORDER_RGB,
   737         SDL_ARRAYORDER_RGB,
   683         SDL_ARRAYORDER_RGBA,
   738         SDL_ARRAYORDER_RGBA,
   684         SDL_ARRAYORDER_ARGB,
   739         SDL_ARRAYORDER_ARGB,
   685         SDL_ARRAYORDER_BGR,
   740         SDL_ARRAYORDER_BGR,
   699             end;
   754             end;
   700 
   755 
   701     {* SDL_mixer *}
   756     {* SDL_mixer *}
   702     PMixChunk = ^TMixChunk;
   757     PMixChunk = ^TMixChunk;
   703     TMixChunk = record
   758     TMixChunk = record
   704         allocated: Longword;
   759         allocated: LongWord;
   705         abuf     : PByte;
   760         abuf     : PByte;
   706         alen     : Longword;
   761         alen     : LongWord;
   707         volume   : PByte;
   762         volume   : PByte;
   708         end;
   763         end;
   709     TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3);
   764     TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3);
   710     TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN);
   765     TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN);
   711 
   766 
   712     TMidiSong = record
   767     TMidiSong = record
   713                samples : LongInt;
   768                samples : LongInt;
   714                events  : pointer;
   769                events  : Pointer;
   715                end;
   770                end;
   716 
   771 
   717     TMusicUnion = record
   772     TMusicUnion = record
   718         case Byte of
   773         case Byte of
   719              0: ( midi : TMidiSong );
   774              0: ( midi : TMidiSong );
   720              1: ( ogg  : pointer);
   775              1: ( ogg  : Pointer);
   721              end;
   776              end;
   722 
   777 
   723     PMixMusic = ^TMixMusic;
   778     PMixMusic = ^TMixMusic;
   724     TMixMusic = record
   779     TMixMusic = record
   725                  end;
   780                  end;
   726 
   781 
   727     {* SDL_net *}
   782     {* SDL_net *}
   728     TIPAddress = record
   783     TIPAddress = record
   729                   host: Longword;
   784                   host: LongWord;
   730                   port: Word;
   785                   port: Word;
   731                   end;
   786                   end;
   732 
   787 
   733     PTCPSocket = ^TTCPSocket;
   788     PTCPSocket = ^TTCPSocket;
   734     TTCPSocket = record
   789     TTCPSocket = record
   750 /////////////////////  FUNCTION DEFINITIONS /////////////////////
   805 /////////////////////  FUNCTION DEFINITIONS /////////////////////
   751 /////////////////////////////////////////////////////////////////
   806 /////////////////////////////////////////////////////////////////
   752 
   807 
   753 
   808 
   754 {* SDL *}
   809 {* SDL *}
   755 function  SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName;
   810 function  SDL_Init(flags: LongWord): LongInt; cdecl; external SDLLibName;
   756 function  SDL_InitSubSystem(flags: LongWord): LongInt; cdecl; external SDLLibName;
   811 function  SDL_InitSubSystem(flags: LongWord): LongInt; cdecl; external SDLLibName;
   757 procedure SDL_Quit; cdecl; external SDLLibName;
   812 procedure SDL_Quit; cdecl; external SDLLibName;
   758 
   813 
   759 function  SDL_VideoDriverName(var namebuf; maxlen: LongInt): PChar; cdecl; external SDLLibName;
   814 procedure SDL_Delay(msec: LongWord); cdecl; external SDLLibName;
   760 function  SDL_EnableUNICODE(enable: LongInt): LongInt; cdecl; external SDLLibName;
   815 function  SDL_GetTicks: LongWord; cdecl; external SDLLibName;
   761 function  SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt; cdecl; external SDLLibName;
       
   762 
       
   763 procedure SDL_Delay(msec: Longword); cdecl; external SDLLibName;
       
   764 function  SDL_GetTicks: Longword; cdecl; external SDLLibName;
       
   765 
   816 
   766 function  SDL_MustLock(Surface: PSDL_Surface): Boolean;
   817 function  SDL_MustLock(Surface: PSDL_Surface): Boolean;
   767 function  SDL_LockSurface(Surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
   818 function  SDL_LockSurface(Surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
   768 procedure SDL_UnlockSurface(Surface: PSDL_Surface); cdecl; external SDLLibName;
   819 procedure SDL_UnlockSurface(Surface: PSDL_Surface); cdecl; external SDLLibName;
   769 
   820 
   770 function  SDL_GetError: PChar; cdecl; external SDLLibName;
   821 function  SDL_GetError: PChar; cdecl; external SDLLibName;
   771 
   822 
   772 function  SDL_SetVideoMode(width, height, bpp: LongInt; flags: Longword): PSDL_Surface; cdecl; external SDLLibName;
   823 function  SDL_SetVideoMode(width, height, bpp: LongInt; flags: LongWord): PSDL_Surface; cdecl; external SDLLibName;
   773 function  SDL_CreateRGBSurface(flags: Longword; Width, Height, Depth: LongInt; RMask, GMask, BMask, AMask: Longword): PSDL_Surface; cdecl; external SDLLibName;
   824 function  SDL_CreateRGBSurface(flags: LongWord; Width, Height, Depth: LongInt; RMask, GMask, BMask, AMask: LongWord): PSDL_Surface; cdecl; external SDLLibName;
   774 function  SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch: LongInt; RMask, GMask, BMask, AMask: Longword): PSDL_Surface; cdecl; external SDLLibName;
   825 function  SDL_CreateRGBSurfaceFrom(pixels: Pointer; width, height, depth, pitch: LongInt; RMask, GMask, BMask, AMask: LongWord): PSDL_Surface; cdecl; external SDLLibName;
   775 procedure SDL_FreeSurface(Surface: PSDL_Surface); cdecl; external SDLLibName;
   826 procedure SDL_FreeSurface(Surface: PSDL_Surface); cdecl; external SDLLibName;
   776 function  SDL_SetColorKey(surface: PSDL_Surface; flag, key: Longword): LongInt; cdecl; external SDLLibName;
   827 function  SDL_SetColorKey(surface: PSDL_Surface; flag, key: LongWord): LongInt; cdecl; external SDLLibName;
   777 function  SDL_SetAlpha(surface: PSDL_Surface; flag, key: Longword): LongInt; cdecl; external SDLLibName;
   828 function  SDL_SetAlpha(surface: PSDL_Surface; flag, key: LongWord): LongInt; cdecl; external SDLLibName;
   778 function  SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: LongInt): PSDL_Surface; cdecl; external SDLLibName;
   829 function  SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: LongInt): PSDL_Surface; cdecl; external SDLLibName;
   779 
   830 
   780 function  SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
   831 function  SDL_UpperBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
   781 function  SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: Longword): LongInt; cdecl; external SDLLibName;
   832 function  SDL_FillRect(dst: PSDL_Surface; dstrect: PSDL_Rect; color: LongWord): LongInt; cdecl; external SDLLibName;
   782 procedure SDL_UpdateRect(Screen: PSDL_Surface; x, y: LongInt; w, h: Longword); cdecl; external SDLLibName;
   833 procedure SDL_UpdateRect(Screen: PSDL_Surface; x, y: LongInt; w, h: LongWord); cdecl; external SDLLibName;
   783 function  SDL_Flip(Screen: PSDL_Surface): LongInt; cdecl; external SDLLibName;
   834 function  SDL_Flip(Screen: PSDL_Surface): LongInt; cdecl; external SDLLibName;
   784 
   835 
   785 procedure SDL_GetRGB(pixel: Longword; fmt: PSDL_PixelFormat; r, g, b: PByte); cdecl; external SDLLibName;
   836 procedure SDL_GetRGB(pixel: LongWord; fmt: PSDL_PixelFormat; r, g, b: PByte); cdecl; external SDLLibName;
   786 procedure SDL_GetRGBA(pixel: Longword; fmt: PSDL_PixelFormat; r, g, b, a: PByte); cdecl; external SDLLibName;
   837 procedure SDL_GetRGBA(pixel: LongWord; fmt: PSDL_PixelFormat; r, g, b, a: PByte); cdecl; external SDLLibName;
   787 function  SDL_MapRGB(format: PSDL_PixelFormat; r, g, b: Byte): Longword; cdecl; external SDLLibName;
   838 function  SDL_MapRGB(format: PSDL_PixelFormat; r, g, b: Byte): LongWord; cdecl; external SDLLibName;
   788 function  SDL_MapRGBA(format: PSDL_PixelFormat; r, g, b, a: Byte): Longword; cdecl; external SDLLibName;
   839 function  SDL_MapRGBA(format: PSDL_PixelFormat; r, g, b, a: Byte): LongWord; cdecl; external SDLLibName;
   789 
   840 
   790 function  SDL_DisplayFormat(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName;
   841 function  SDL_DisplayFormat(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName;
   791 function  SDL_DisplayFormatAlpha(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName;
   842 function  SDL_DisplayFormatAlpha(Surface: PSDL_Surface): PSDL_Surface; cdecl; external SDLLibName;
   792 
   843 
   793 function  SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; cdecl; external SDLLibName;
   844 function  SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; cdecl; external SDLLibName;
   794 function  SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName;
   845 function  SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName;
   795 
   846 
   796 {$IFDEF SDL13}
   847 {$IFDEF SDL13}
   797 function  SDL_CreateWindow(title: PChar; x,y,w,h, flags: LongInt): PSDL_Window; cdecl; external SDLLibName;
   848 function  SDL_CreateWindow(title: PChar; x,y,w,h: LongInt; flags: LongWord): PSDL_Window; cdecl; external SDLLibName;
   798 function  SDL_CreateRenderer(window: PSDL_Window; index, flags: LongInt): PSDL_Renderer; cdecl; external SDLLibName;
   849 function  SDL_CreateRenderer(window: PSDL_Window; index: LongInt; flags: LongWord): PSDL_Renderer; cdecl; external SDLLibName;
   799 function  SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
   850 function  SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
   800 function  SDL_DestroyRenderer(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
   851 function  SDL_DestroyRenderer(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
   801 procedure SDL_SetWindowSize(window: PSDL_Window; w, h: LongInt); cdecl; external SDLLibName;
   852 procedure SDL_SetWindowSize(window: PSDL_Window; w, h: LongInt); cdecl; external SDLLibName;
       
   853 function  SDL_GetCurrentVideoDriver:Pchar; cdecl; external SDLLibName;
   802 
   854 
   803 function  SDL_GL_CreateContext(window: PSDL_Window): PSDL_GLContext; cdecl; external SDLLibName;
   855 function  SDL_GL_CreateContext(window: PSDL_Window): PSDL_GLContext; cdecl; external SDLLibName;
   804 procedure SDL_GL_DeleteContext(context: PSDL_GLContext); cdecl; external SDLLibName;
   856 procedure SDL_GL_DeleteContext(context: PSDL_GLContext); cdecl; external SDLLibName;
   805 function  SDL_GL_SwapWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
   857 function  SDL_GL_SwapWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
   806 function  SDL_GL_SetSwapInterval(interval: LongInt): LongInt; cdecl; external SDLLibName;
   858 function  SDL_GL_SetSwapInterval(interval: LongInt): LongInt; cdecl; external SDLLibName;
   807 
   859 
   808 procedure SDL_VideoQuit; cdecl; external SDLLibName;
   860 procedure SDL_VideoQuit; cdecl; external SDLLibName;
   809 function  SDL_GetNumVideoDisplays: LongInt; cdecl; external SDLLibName;
   861 function  SDL_GetNumVideoDisplays: LongInt; cdecl; external SDLLibName;
   810 procedure SDL_ShowWindow(window: PSDL_Window); cdecl; external SDLLibName;
   862 procedure SDL_ShowWindow(window: PSDL_Window); cdecl; external SDLLibName;
   811 
   863 
   812 function  SDL_SetRenderDrawColor(renderer: PSDL_Renderer; r,g,b,a: byte): LongInt; cdecl; external SDLLibName;
   864 function  SDL_SetRenderDrawColor(renderer: PSDL_Renderer; r,g,b,a: Byte): LongInt; cdecl; external SDLLibName;
   813 function  SDL_GetRenderer(window: PSDL_Window): PSDL_Renderer; cdecl; external SDLLibName;
   865 function  SDL_GetRenderer(window: PSDL_Window): PSDL_Renderer; cdecl; external SDLLibName;
   814 function  SDL_RenderFillRect(renderer: PSDL_Renderer; rect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
   866 function  SDL_RenderFillRect(renderer: PSDL_Renderer; rect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
   815 function  SDL_RenderClear(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
   867 function  SDL_RenderClear(renderer: PSDL_Renderer): LongInt; cdecl; external SDLLibName;
   816 procedure SDL_RenderPresent(renderer: PSDL_Renderer); cdecl; external SDLLibName;
   868 procedure SDL_RenderPresent(renderer: PSDL_Renderer); cdecl; external SDLLibName;
   817 function  SDL_RenderReadPixels(renderer: PSDL_Renderer; rect: PSDL_Rect; format: LongInt; pixels: pointer; pitch: LongInt): LongInt; cdecl; external SDLLibName;
   869 function  SDL_RenderReadPixels(renderer: PSDL_Renderer; rect: PSDL_Rect; format: LongInt; pixels: Pointer; pitch: LongInt): LongInt; cdecl; external SDLLibName;
   818 function  SDL_RenderSetViewport(window: PSDL_Window; rect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
   870 function  SDL_RenderSetViewport(window: PSDL_Window; rect: PSDL_Rect): LongInt; cdecl; external SDLLibName;
   819 
   871 
   820 function  SDL_SelectMouse(index: LongInt): LongInt; cdecl; external SDLLibName;
       
   821 function  SDL_GetRelativeMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
   872 function  SDL_GetRelativeMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
   822 function  SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
   873 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): Boolean; cdecl; external SDLLibName;
   823 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
       
   824 
       
   825 
   874 
   826 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
   875 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
   827 function  SDL_SetHint(name, value: PChar): boolean; cdecl; external SDLLibName;
   876 function  SDL_SetHint(name, value: PChar): Boolean; cdecl; external SDLLibName;
   828 
   877 procedure SDL_StartTextInput; cdecl; external SDLLibName;
   829 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; minType, maxType: LongInt): LongInt; cdecl; external SDLLibName;
   878 
   830 {$ELSE}
   879 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; minType, maxType: LongWord): LongInt; cdecl; external SDLLibName;
   831 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; mask: Longword): LongInt; cdecl; external SDLLibName;
   880 {$ELSE}
       
   881 function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; mask: LongWord): LongInt; cdecl; external SDLLibName;
   832 {$ENDIF}
   882 {$ENDIF}
   833 
   883 
   834 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
   884 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
   835 function  SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName;
   885 function  SDL_GetKeyName(key: LongWord): PChar; cdecl; external SDLLibName;
   836 
   886 
   837 procedure SDL_PumpEvents; cdecl; external SDLLibName;
   887 procedure SDL_PumpEvents; cdecl; external SDLLibName;
   838 function  SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
   888 function  SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
   839 function  SDL_WaitEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
   889 function  SDL_WaitEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
   840 procedure SDL_SetEventFilter( filter : TSDL_EventFilter ); cdecl; external SDLLibName;
   890 procedure SDL_SetEventFilter(filter: TSDL_EventFilter); cdecl; external SDLLibName;
   841 
   891 
   842 function  SDL_ShowCursor(toggle: LongInt): LongInt; cdecl; external SDLLibName;
   892 function  SDL_ShowCursor(toggle: LongInt): LongInt; cdecl; external SDLLibName;
   843 
   893 
   844 procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask : byte); cdecl; external SDLLibName;
   894 procedure SDL_WM_SetIcon(icon: PSDL_Surface; mask : Byte); cdecl; external SDLLibName;
   845 procedure SDL_WM_SetCaption(title: PChar; icon: PChar); cdecl; external SDLLibName;
   895 procedure SDL_WM_SetCaption(title: PChar; icon: PChar); cdecl; external SDLLibName;
   846 function  SDL_WM_ToggleFullScreen(surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
   896 function  SDL_WM_ToggleFullScreen(surface: PSDL_Surface): LongInt; cdecl; external SDLLibName;
   847 
   897 
   848 function  SDL_CreateThread(fn: pointer; data: pointer): PSDL_Thread; cdecl; external SDLLibName;
       
   849 procedure SDL_WaitThread(thread: PSDL_Thread; status: PLongInt); cdecl; external SDLLibName;
       
   850 function  SDL_CreateMutex: PSDL_mutex; cdecl; external SDLLibName;
   898 function  SDL_CreateMutex: PSDL_mutex; cdecl; external SDLLibName;
   851 procedure SDL_DestroyMutex(mutex: PSDL_mutex); cdecl; external SDLLibName;
   899 procedure SDL_DestroyMutex(mutex: PSDL_mutex); cdecl; external SDLLibName;
   852 function  SDL_LockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexP';
   900 function  SDL_LockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexP';
   853 function  SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexV';
   901 function  SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexV';
   854 
   902 
   878 {$ENDIF}
   926 {$ENDIF}
   879 
   927 
   880 {* Compatibility between SDL-1.2 and SDL-1.3 *}
   928 {* Compatibility between SDL-1.2 and SDL-1.3 *}
   881 procedure SDL_WarpMouse(x, y: Word); {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   929 procedure SDL_WarpMouse(x, y: Word); {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   882 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
   930 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
   883 function  SDL_AllocFormat(format: Longword): PSDL_PixelFormat; {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   931 function  SDL_AllocFormat(format: LongWord): PSDL_PixelFormat; {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   884 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   932 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
       
   933 function  SDL_VideoDriverName(namebuf: PChar; maxlen: LongInt): PChar; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
       
   934 function  SDL_EnableUNICODE(enable: LongInt): LongInt; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
       
   935 function  SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
   885 
   936 
   886 (*  SDL_ttf  *)
   937 (*  SDL_ttf  *)
   887 function  TTF_Init: LongInt; cdecl; external SDL_TTFLibName;
   938 function  TTF_Init: LongInt; cdecl; external SDL_TTFLibName;
   888 procedure TTF_Quit; cdecl; external SDL_TTFLibName;
   939 procedure TTF_Quit; cdecl; external SDL_TTFLibName;
   889 
   940 
   890 function  TTF_SizeUTF8(font: PTTF_Font; const text: PChar; out w, h: LongInt): LongInt; cdecl; external SDL_TTFLibName;
   941 function  TTF_SizeUTF8(font: PTTF_Font; const text: PChar; w, h: PLongInt): LongInt; cdecl; external SDL_TTFLibName;
   891 
   942 
   892 function  TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   943 function  TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   893 function  TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   944 function  TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   894 function  TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   945 function  TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   895 
   946 
   951 procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName;
  1002 procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName;
   952 function  SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName;
  1003 function  SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName;
   953 function  SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName;
  1004 function  SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName;
   954 
  1005 
   955 
  1006 
   956 procedure SDLNet_Write16(value: Word; buf: pointer);
  1007 procedure SDLNet_Write16(value: Word; buf: Pointer);
   957 procedure SDLNet_Write32(value: LongWord; buf: pointer);
  1008 procedure SDLNet_Write32(value: LongWord; buf: Pointer);
   958 function  SDLNet_Read16(buf: pointer): Word;
  1009 function  SDLNet_Read16(buf: Pointer): Word;
   959 function  SDLNet_Read32(buf: pointer): LongWord;
  1010 function  SDLNet_Read32(buf: Pointer): LongWord;
   960 
  1011 
   961 implementation
  1012 implementation
   962 uses uVariables;
  1013 uses strings, uVariables;
   963 
  1014 
   964 {$IFDEF SDL13}
  1015 {$IFDEF SDL13}
   965 // this needs to be reimplemented because in SDL_compat.c the window is the one created in the SDL_SetVideoMode
  1016 // this needs to be reimplemented because in SDL_compat.c the window is the one created in the SDL_SetVideoMode
   966 // compatible function, but we use SDL_CreateWindow, so the window would be NULL
  1017 // compatible function, but we use SDL_CreateWindow, so the window would be NULL
   967 procedure SDL_WarpMouse(x, y: Word);
  1018 procedure SDL_WarpMouse(x, y: Word);
   968 begin
  1019 begin
   969     SDL_WarpMouseInWindow(SDLwindow, x, y);
  1020     SDL_WarpMouseInWindow(SDLwindow, x, y);
   970 end;
  1021 end;
   971 {$ELSE}
  1022 
   972 function SDL_AllocFormat(format: Longword): PSDL_PixelFormat;
  1023 function SDL_VideoDriverName(namebuf: PChar; maxlen: LongInt): PChar;
       
  1024 var name : PChar = nil;
       
  1025 begin
       
  1026     name:= SDL_GetCurrentVideoDriver();
       
  1027     if (name <> nil) and (namebuf <> nil) then
       
  1028         begin
       
  1029         strlcopy(namebuf, name, maxlen);
       
  1030         exit(namebuf)
       
  1031         end;
       
  1032     exit(name);
       
  1033 end;
       
  1034 
       
  1035 function SDL_EnableUNICODE(enable: LongInt): LongInt;
       
  1036 begin
       
  1037     SDL_StartTextInput();
       
  1038     exit(0);
       
  1039 end;
       
  1040 
       
  1041 function SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt;
       
  1042 begin
       
  1043     exit(0);
       
  1044 end;
       
  1045 {$ELSE}
       
  1046 function SDL_AllocFormat(format: LongWord): PSDL_PixelFormat;
   973 const conversionFormat: TSDL_PixelFormat = (
  1047 const conversionFormat: TSDL_PixelFormat = (
   974         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
  1048         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
   975         Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
  1049         Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
   976         Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift;
  1050         Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift;
   977         RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
  1051         RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
  1017 procedure IMG_Quit;
  1091 procedure IMG_Quit;
  1018 begin
  1092 begin
  1019 end;
  1093 end;
  1020 {$ENDIF}
  1094 {$ENDIF}
  1021 
  1095 
  1022 procedure SDLNet_Write16(value: Word; buf: pointer);
  1096 procedure SDLNet_Write16(value: Word; buf: Pointer);
  1023 begin
  1097 begin
  1024     PByteArray(buf)^[1]:= value;
  1098     PByteArray(buf)^[1]:= value;
  1025     PByteArray(buf)^[0]:= value shr 8
  1099     PByteArray(buf)^[0]:= value shr 8
  1026 end;
  1100 end;
  1027 
  1101 
  1028 procedure SDLNet_Write32(value: LongWord; buf: pointer);
  1102 procedure SDLNet_Write32(value: LongWord; buf: Pointer);
  1029 begin
  1103 begin
  1030     PByteArray(buf)^[3]:= value;
  1104     PByteArray(buf)^[3]:= value;
  1031     PByteArray(buf)^[2]:= value shr  8;
  1105     PByteArray(buf)^[2]:= value shr  8;
  1032     PByteArray(buf)^[1]:= value shr 16;
  1106     PByteArray(buf)^[1]:= value shr 16;
  1033     PByteArray(buf)^[0]:= value shr 24
  1107     PByteArray(buf)^[0]:= value shr 24
  1034 end;
  1108 end;
  1035 
  1109 
  1036 function SDLNet_Read16(buf: pointer): Word;
  1110 function SDLNet_Read16(buf: Pointer): Word;
  1037 begin
  1111 begin
  1038     SDLNet_Read16:= PByteArray(buf)^[1] or
  1112     SDLNet_Read16:= PByteArray(buf)^[1] or
  1039                  (PByteArray(buf)^[0] shl 8)
  1113                  (PByteArray(buf)^[0] shl 8)
  1040 end;
  1114 end;
  1041 
  1115 
  1042 function SDLNet_Read32(buf: pointer): LongWord;
  1116 function SDLNet_Read32(buf: Pointer): LongWord;
  1043 begin
  1117 begin
  1044     SDLNet_Read32:=  PByteArray(buf)^[3] or
  1118     SDLNet_Read32:=  PByteArray(buf)^[3] or
  1045                   (PByteArray(buf)^[2] shl  8) or
  1119                   (PByteArray(buf)^[2] shl  8) or
  1046                   (PByteArray(buf)^[1] shl 16) or
  1120                   (PByteArray(buf)^[1] shl 16) or
  1047                   (PByteArray(buf)^[0] shl 24)
  1121                   (PByteArray(buf)^[0] shl 24)