hedgewars/SDLh.pas
changeset 5046 fc6639d56799
parent 5041 3dc6ad20cbfe
child 5050 8eb096ee828e
equal deleted inserted replaced
5045:f215eb5d4b75 5046:fc6639d56799
    91 
    91 
    92 /////////////////////////////////////////////////////////////////
    92 /////////////////////////////////////////////////////////////////
    93 /////////////////////  CONSTANT DEFINITIONS /////////////////////
    93 /////////////////////  CONSTANT DEFINITIONS /////////////////////
    94 /////////////////////////////////////////////////////////////////
    94 /////////////////////////////////////////////////////////////////
    95 
    95 
    96     SDL_INIT_TIMER    = $00000001;
    96     // SDL_Init() flags
    97     SDL_INIT_AUDIO    = $00000010;
    97     SDL_INIT_TIMER       = $00000001;
    98     SDL_INIT_VIDEO    = $00000020;
    98     SDL_INIT_AUDIO       = $00000010;
    99     SDL_INIT_JOYSTICK = $00000200;
    99     SDL_INIT_VIDEO       = $00000020;
   100 {$IFDEF SDL13}
   100     SDL_INIT_JOYSTICK    = $00000200;
   101     SDL_INIT_HAPTIC   = $00001000;
   101 {$IFDEF SDL13}
   102 {$ELSE}
   102     SDL_INIT_HAPTIC      = $00001000;
   103     SDL_INIT_CDROM    = $00000100;
   103 {$ELSE}
       
   104     SDL_INIT_CDROM       = $00000100;
       
   105     SDL_INIT_EVENTTHREAD = $01000000;
   104 {$ENDIF}
   106 {$ENDIF}
   105     SDL_INIT_NOPARACHUTE = $00100000;
   107     SDL_INIT_NOPARACHUTE = $00100000;
   106     SDL_INIT_EVENTTHREAD = $01000000;
       
   107     SDL_INIT_EVERYTHING  = $0000FFFF;
   108     SDL_INIT_EVERYTHING  = $0000FFFF;
   108 
   109 
   109     SDL_APPINPUTFOCUS    = 2;
   110     SDL_APPINPUTFOCUS    = $02;
   110     SDL_BUTTON_WHEELUP   = 4;
   111     SDL_BUTTON_WHEELUP   = 4;
   111     SDL_BUTTON_WHEELDOWN = 5;
   112     SDL_BUTTON_WHEELDOWN = 5;
   112 
   113 
   113 {$IFDEF SDL13}
   114 {$IFDEF SDL13}
   114     // SDL_Event types
   115     // SDL_Event types
   115     SDL_FIRSTEVENT      = 0;
   116     SDL_FIRSTEVENT        = 0;
   116     SDL_QUITEV          = $100;
   117     SDL_QUITEV            = $100;
   117     SDL_WINDOWEVENT     = $200;
   118     SDL_WINDOWEVENT       = $200;
   118     SDL_SYSWMEVENT      = $201;
   119     SDL_SYSWMEVENT        = $201;
   119     SDL_KEYDOWN         = $300;
   120     SDL_KEYDOWN           = $300;
   120     SDL_KEYUP           = $301;
   121     SDL_KEYUP             = $301;
   121     SDL_TEXTEDITING     = $302;
   122     SDL_TEXTEDITING       = $302;
   122     SDL_TEXTINPUT       = $303;
   123     SDL_TEXTINPUT         = $303;
   123     SDL_MOUSEMOTION     = $400;
   124     SDL_MOUSEMOTION       = $400;
   124     SDL_MOUSEBUTTONDOWN = $401;
   125     SDL_MOUSEBUTTONDOWN   = $401;
   125     SDL_MOUSEBUTTONUP   = $402;
   126     SDL_MOUSEBUTTONUP     = $402;
   126     SDL_MOUSEWHEEL      = $403;
   127     SDL_MOUSEWHEEL        = $403;
   127     SDL_PROXIMITYIN     = $500;
   128     SDL_INPUTMOTION       = $500;
   128     SDL_PROXIMITYOUT    = $501;
   129     SDL_INPUTBUTTONDOWN   = $501;
   129     SDL_JOYAXISMOTION   = $600;
   130     SDL_INPUTBUTTONUP     = $502;
   130     SDL_JOYBALLMOTION   = $601;
   131     SDL_INPUTWHEEL        = $503;
   131     SDL_JOYHATMOTION    = $602;
   132     SDL_INPUTPROXIMITYIN  = $504;
   132     SDL_JOYBUTTONDOWN   = $603;
   133     SDL_INPUTPROXIMITYOUT = $505;
   133     SDL_JOYBUTTONUP     = $604;
   134     SDL_JOYAXISMOTION     = $600;
   134     SDL_USEREVENT       = $8000;
   135     SDL_JOYBALLMOTION     = $601;
   135     SDL_LASTEVENT       = $FFFF;
   136     SDL_JOYHATMOTION      = $602;
       
   137     SDL_JOYBUTTONDOWN     = $603;
       
   138     SDL_JOYBUTTONUP       = $604;
       
   139     //TODO: implement otheer event types
       
   140     SDL_USEREVENT         = $8000;
       
   141     SDL_LASTEVENT         = $FFFF;
   136 
   142 
   137     // SDL_Surface flags
   143     // SDL_Surface flags
   138     SDL_SWSURFACE   = $00000000;  //*< Not used */
   144     SDL_SWSURFACE   = $00000000;  //*< Not used */
   139     SDL_PREALLOC    = $00000001;  //*< Surface uses preallocated memory */
   145     SDL_PREALLOC    = $00000001;  //*< Surface uses preallocated memory */
   140     SDL_RLEACCEL    = $00000002;  //*< Surface is RLE encoded */
   146     SDL_RLEACCEL    = $00000002;  //*< Surface is RLE encoded */
   151     SDL_HWSURFACE   = $08000001;  //*< Not used */
   157     SDL_HWSURFACE   = $08000001;  //*< Not used */
   152     SDL_ASYNCBLIT   = $08000000;  //*< Not used */
   158     SDL_ASYNCBLIT   = $08000000;  //*< Not used */
   153     SDL_RLEACCELOK  = $08000000;  //*< Not used */
   159     SDL_RLEACCELOK  = $08000000;  //*< Not used */
   154     SDL_HWACCEL     = $08000000;  //*< Not used */
   160     SDL_HWACCEL     = $08000000;  //*< Not used */
   155 
   161 
       
   162     // SDL_Renderer flags
       
   163     SDL_RENDERER_SOFTWARE     = $00000001;     //*< The renderer is a software fallback */
       
   164     SDL_RENDERER_ACCELERATED  = $00000002;     //*< The renderer uses hardware acceleration */
       
   165     SDL_RENDERER_PRESENTVSYNC = $00000004;
       
   166 
   156     // SDL_WindowFlags (enum)
   167     // SDL_WindowFlags (enum)
   157     SDL_WINDOW_FULLSCREEN    = $00000001;      //*< fullscreen window, implies borderless */
   168     SDL_WINDOW_FULLSCREEN    = $00000001;      //*< fullscreen window, implies borderless */
   158     SDL_WINDOW_OPENGL        = $00000002;      //*< window usable with OpenGL context */
   169     SDL_WINDOW_OPENGL        = $00000002;      //*< window usable with OpenGL context */
   159     SDL_WINDOW_SHOWN         = $00000004;      //*< window is visible */
   170     SDL_WINDOW_SHOWN         = $00000004;      //*< window is visible */
   160 //  SDL_WINDOW_HIDDEN        = $00000008;      //*< window is not visible */
   171     SDL_WINDOW_HIDDEN        = $00000008;      //*< window is not visible */
   161     SDL_WINDOW_BORDERLESS    = $00000008;      //*< no window decoration */
   172     SDL_WINDOW_BORDERLESS    = $00000010;      //*< no window decoration */
   162     SDL_WINDOW_RESIZABLE     = $00000010;      //*< window can be resized */
   173     SDL_WINDOW_RESIZABLE     = $00000020;      //*< window can be resized */
   163     SDL_WINDOW_MINIMIZED     = $00000020;      //*< window is minimized */
   174     SDL_WINDOW_MINIMIZED     = $00000040;      //*< window is minimized */
   164     SDL_WINDOW_MAXIMIZED     = $00000040;      //*< window is maximized */
   175     SDL_WINDOW_MAXIMIZED     = $00000080;      //*< window is maximized */
   165     SDL_WINDOW_INPUT_GRABBED = $00000100;      //*< window has grabbed input focus */
   176     SDL_WINDOW_INPUT_GRABBED = $00000100;      //*< window has grabbed input focus */
   166     SDL_WINDOW_INPUT_FOCUS   = $00000200;      //*< window has input focus */
   177     SDL_WINDOW_INPUT_FOCUS   = $00000200;      //*< window has input focus */
   167     SDL_WINDOW_MOUSE_FOCUS   = $00000400;      //*< window has mouse focus */
   178     SDL_WINDOW_MOUSE_FOCUS   = $00000400;      //*< window has mouse focus */
   168     SDL_WINDOW_FOREIGN       = $00000800;      //*< window not created by SDL */
   179     SDL_WINDOW_FOREIGN       = $00000800;      //*< window not created by SDL */
   169 
   180 
   174     SDL_WINDOWEVENT_SHOWN        = 1;    //*< Window has been shown
   185     SDL_WINDOWEVENT_SHOWN        = 1;    //*< Window has been shown
   175     SDL_WINDOWEVENT_HIDDEN       = 2;    //*< Window has been hidden
   186     SDL_WINDOWEVENT_HIDDEN       = 2;    //*< Window has been hidden
   176     SDL_WINDOWEVENT_EXPOSED      = 3;    //*< Window has been exposed and should be redrawn
   187     SDL_WINDOWEVENT_EXPOSED      = 3;    //*< Window has been exposed and should be redrawn
   177     SDL_WINDOWEVENT_MOVED        = 4;    //*< Window has been moved to data1, data2
   188     SDL_WINDOWEVENT_MOVED        = 4;    //*< Window has been moved to data1, data2
   178     SDL_WINDOWEVENT_RESIZED      = 5;    //*< Window size changed to data1xdata2
   189     SDL_WINDOWEVENT_RESIZED      = 5;    //*< Window size changed to data1xdata2
   179     SDL_WINDOWEVENT_MINIMIZED    = 6;    //*< Window has been minimized
   190     SDL_WINDOWEVENT_SIZE_CHANGED = 6;    //*< The window size has changed, [...] */
   180     SDL_WINDOWEVENT_MAXIMIZED    = 7;    //*< Window has been maximized
   191     SDL_WINDOWEVENT_MINIMIZED    = 7;    //*< Window has been minimized
   181     SDL_WINDOWEVENT_RESTORED     = 8;    //*< Window has been restored to normal size and position
   192     SDL_WINDOWEVENT_MAXIMIZED    = 8;    //*< Window has been maximized
   182     SDL_WINDOWEVENT_ENTER        = 9;    //*< Window has gained mouse focus
   193     SDL_WINDOWEVENT_RESTORED     = 9;    //*< Window has been restored to normal size and position
   183     SDL_WINDOWEVENT_LEAVE        = 10;   //*< Window has lost mouse focus
   194     SDL_WINDOWEVENT_ENTER        = 10;   //*< Window has gained mouse focus
   184     SDL_WINDOWEVENT_FOCUS_GAINED = 11;   //*< Window has gained keyboard focus
   195     SDL_WINDOWEVENT_LEAVE        = 11;   //*< Window has lost mouse focus
   185     SDL_WINDOWEVENT_FOCUS_LOST   = 12;   //*< Window has lost keyboard focus
   196     SDL_WINDOWEVENT_FOCUS_GAINED = 12;   //*< Window has gained keyboard focus
   186     SDL_WINDOWEVENT_CLOSE        = 13;   //*< The window manager requests that the window be closed */
   197     SDL_WINDOWEVENT_FOCUS_LOST   = 13;   //*< Window has lost keyboard focus
   187 
   198     SDL_WINDOWEVENT_CLOSE        = 14;   //*< The window manager requests that the window be closed */
   188     SDL_RENDERER_ACCELERATED  = $00000001;   //*< The renderer uses hardware acceleration
       
   189     SDL_RENDERER_PRESENTVSYNC = $00000002;   //*< Present is synchronized with the refresh rate
       
   190 {$ELSE}
   199 {$ELSE}
   191     // SDL_Event types
   200     // SDL_Event types
   192     SDL_NOEVENT         = 0;
   201     SDL_NOEVENT         = 0;
   193     SDL_ACTIVEEVENT     = 1;
   202     SDL_ACTIVEEVENT     = 1;
   194     SDL_KEYDOWN         = 2;
   203     SDL_KEYDOWN         = 2;
   272 /////////////////////////////////////////////////////////////////
   281 /////////////////////////////////////////////////////////////////
   273 ///////////////////////  TYPE DEFINITIONS ///////////////////////
   282 ///////////////////////  TYPE DEFINITIONS ///////////////////////
   274 /////////////////////////////////////////////////////////////////
   283 /////////////////////////////////////////////////////////////////
   275 
   284 
   276 type
   285 type
       
   286 {$IFDEF SDL13}
       
   287     PSDL_Window   = Pointer;
       
   288     PSDL_Renderer = Pointer;
       
   289     PSDL_Texture  = Pointer;
       
   290 {$ENDIF}
       
   291 
   277     PSDL_Rect = ^TSDL_Rect;
   292     PSDL_Rect = ^TSDL_Rect;
   278     TSDL_Rect = record
   293     TSDL_Rect = record
   279 {$IFDEF SDL13}
   294 {$IFDEF SDL13}
   280         x, y, w, h: LongInt;
   295         x, y, w, h: LongInt;
   281 {$ELSE}
   296 {$ELSE}
   283         w, h: Word;
   298         w, h: Word;
   284 {$ENDIF}
   299 {$ENDIF}
   285         end;
   300         end;
   286 
   301 
   287     TPoint = record
   302     TPoint = record
   288         X: LongInt;
   303         X, Y: LongInt;
   289         Y: LongInt;
       
   290         end;
   304         end;
   291 
   305 
   292     PSDL_PixelFormat = ^TSDL_PixelFormat;
   306     PSDL_PixelFormat = ^TSDL_PixelFormat;
   293     TSDL_PixelFormat = record
   307     TSDL_PixelFormat = record
   294 {$IFDEF SDL13}
   308 {$IFDEF SDL13}
   295         format: Longword;
   309         format: Longword;
   296 {$ENDIF}
   310         palette: Pointer;   // actually it is a PSDL_Palette
       
   311         BitsPerPixel : Byte;
       
   312         BytesPerPixel: Byte;
       
   313         padding: array[0..1] of Byte;
       
   314         RMask : Longword;
       
   315         GMask : Longword;
       
   316         BMask : Longword;
       
   317         AMask : Longword;
       
   318         Rloss : Byte;
       
   319         Gloss : Byte;
       
   320         Bloss : Byte;
       
   321         Aloss : Byte;
       
   322         Rshift: Byte;
       
   323         Gshift: Byte;
       
   324         Bshift: Byte;
       
   325         Ashift: Byte;
       
   326         refcount: LongInt;
       
   327         next: PSDL_PixelFormat;
       
   328 {$ELSE}
   297         palette: Pointer;
   329         palette: Pointer;
   298         BitsPerPixel : Byte;
   330         BitsPerPixel : Byte;
   299         BytesPerPixel: Byte;
   331         BytesPerPixel: Byte;
   300         Rloss : Byte;
   332         Rloss : Byte;
   301         Gloss : Byte;
   333         Gloss : Byte;
   307         Ashift: Byte;
   339         Ashift: Byte;
   308         RMask : Longword;
   340         RMask : Longword;
   309         GMask : Longword;
   341         GMask : Longword;
   310         BMask : Longword;
   342         BMask : Longword;
   311         AMask : Longword;
   343         AMask : Longword;
   312 {$IFDEF SDL13}
       
   313         refcount: LongInt;
       
   314         next: Pointer;
       
   315 {$ELSE}
       
   316         colorkey: Longword;
   344         colorkey: Longword;
   317         alpha: Byte;
   345         alpha: Byte;
   318 {$ENDIF}
   346 {$ENDIF}
   319         end;
   347         end;
   320 
   348 
   325         format: PSDL_PixelFormat;
   353         format: PSDL_PixelFormat;
   326         w, h  : LongInt;
   354         w, h  : LongInt;
   327         pitch : Word;
   355         pitch : Word;
   328         pixels: Pointer;
   356         pixels: Pointer;
   329         offset: LongInt;
   357         offset: LongInt;
       
   358 {$IFDEF SDL13}
       
   359         userdata: Pointer;
       
   360         locked: LongInt;
       
   361         lock_data: Pointer;
       
   362         clip_rect: TSDL_Rect;
       
   363         map: Pointer;
       
   364         refcount: LongInt;
       
   365 {$ENDIF}
   330         end;
   366         end;
   331 
   367 
   332 
   368 
   333     PSDL_Color = ^TSDL_Color;
   369     PSDL_Color = ^TSDL_Color;
   334     TSDL_Color = record
   370     TSDL_Color = record
   335         case byte of
   371         case byte of
   336             0: (    r: Byte;
   372             0: ( r: Byte;
   337                 g: Byte;
   373                  g: Byte;
   338                 b: Byte;
   374                  b: Byte;
   339                 unused: Byte;
   375                  unused: Byte; );
   340                );
   376             1: ( value: Longword; );
   341             1: (    value: Longword);
       
   342         end;
   377         end;
   343 
   378 
   344 
   379 
   345     PSDL_RWops = ^TSDL_RWops;
   380     PSDL_RWops = ^TSDL_RWops;
   346     TSeek  = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl;
   381     TSeek  = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl;
   347     TRead  = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt;  cdecl;
   382     TRead  = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt;  cdecl;
   348     TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl;
   383     TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl;
   349     TClose = function( context: PSDL_RWops ): LongInt; cdecl;
   384     TClose = function( context: PSDL_RWops ): LongInt; cdecl;
   350 
   385 
   351     TStdio = record
   386     TStdio = record
   352         autoclose: LongInt;
   387         autoclose: {$IFDEF SDL13}boolean{$ELSE}LongInt{$ENDIF};
   353         fp: pointer;
   388         fp: pointer;
   354         end;
   389         end;
   355 
   390 
   356     TMem = record
   391     TMem = record
   357         base: PByte;
   392         base: PByte;
   377 
   412 
   378 
   413 
   379 {* SDL_Event type definition *}
   414 {* SDL_Event type definition *}
   380 
   415 
   381 {$IFDEF SDL13}
   416 {$IFDEF SDL13}
   382     PSDL_Window = pointer;
   417     TSDL_KeySym = record
   383     PSDL_Renderer = pointer;
   418         scancode: LongInt;
   384     PSDL_Texture = pointer;
   419         sym: LongInt;
       
   420         modifier: Smallint;
       
   421         unicode: LongInt;
       
   422         end;
   385 
   423 
   386     TSDL_WindowEvent = record
   424     TSDL_WindowEvent = record
   387         type_: LongInt;
   425         type_: LongInt;
   388         windowID: LongInt;
   426         windowID: LongInt;
   389         event: byte;
   427         event: byte;
   390         padding1, padding2, padding3: byte;
   428         padding1, padding2, padding3: byte;
   391         data1, data2: LongInt;
   429         data1, data2: LongInt;
   392         end;
   430         end;
   393 
       
   394     TSDL_KeySym = record
       
   395         scancode,
       
   396         sym,
       
   397         modifier,
       
   398         unicode: LongInt;
       
   399         end;
       
   400 
       
   401 // implement SDL_TextEditingEvent + SDL_TextInputEvent for sdl13
       
   402 {$ELSE}
   431 {$ELSE}
   403     TSDL_KeySym = record
   432     TSDL_KeySym = record
   404         scancode: Byte;
   433         scancode: Byte;
   405         sym: Longword;
   434         sym: Longword;
   406         modifier: Longword;
   435         modifier: Longword;
   419         type_: Byte;
   448         type_: Byte;
   420         w, h: LongInt;
   449         w, h: LongInt;
   421         end;
   450         end;
   422 {$ENDIF}
   451 {$ENDIF}
   423 
   452 
       
   453     TSDL_KeyboardEvent = record
       
   454 {$IFDEF SDL13}
       
   455         type_: LongInt;
       
   456         windowID: LongInt;
       
   457         state, repeat_, padding2, padding3: byte;
       
   458 {$ELSE}
       
   459         type_: byte;
       
   460         which: byte;
       
   461         state: byte;
       
   462 {$ENDIF}
       
   463         keysym: TSDL_KeySym;
       
   464         end;
       
   465 
       
   466 //TODO: implement SDL_TextEditingEvent + SDL_TextInputEvent for sdl13
       
   467 
       
   468     // this structure is wrong but the correct version makes the game hang
   424     TSDL_MouseMotionEvent = record
   469     TSDL_MouseMotionEvent = record
   425         which: byte;
   470         which: byte;
   426         state: byte;
   471         state: byte;
   427 {$IFDEF SDL13}
   472 {$IFDEF SDL13}
   428         type_: LongInt;
   473         type_: LongInt;
   435         type_: byte;
   480         type_: byte;
   436         x, y, xrel, yrel : word;
   481         x, y, xrel, yrel : word;
   437 {$ENDIF}
   482 {$ENDIF}
   438         end;
   483         end;
   439 
   484 
   440     TSDL_KeyboardEvent = record
   485     TSDL_MouseButtonEvent = record
   441 {$IFDEF SDL13}
   486 {$IFDEF SDL13}
   442         type_: LongInt;
   487         type_: LongInt;
   443         windowID: LongInt;
       
   444         padding1, padding2: byte;
       
   445 {$ELSE}
       
   446         type_: byte;
       
   447 {$ENDIF}
       
   448         which: byte;
       
   449         state: byte;
       
   450         keysym: TSDL_KeySym;
       
   451         end;
       
   452 
       
   453     TSDL_MouseButtonEvent = record
       
   454 {$IFDEF SDL13}
       
   455         _type: LongInt;
       
   456         windowID: LongInt;
   488         windowID: LongInt;
   457         x, y: LongInt;
   489         x, y: LongInt;
   458         padding1: byte;
   490         padding1: byte;
   459 {$ELSE}
   491 {$ELSE}
   460         _type,
   492         type_,
   461         which,
   493         which,
   462         button,
   494         button,
   463         state: byte;
   495         state: byte;
   464         x, y: word;
   496         x, y: word;
   465 {$ENDIF}
   497 {$ENDIF}
   469     TSDL_MouseWheelEvent = record
   501     TSDL_MouseWheelEvent = record
   470         type_: LongInt;
   502         type_: LongInt;
   471         windowID: LongInt;
   503         windowID: LongInt;
   472         which: Byte;
   504         which: Byte;
   473         x, y: LongInt;
   505         x, y: LongInt;
   474         padding1, padding2, padding3: byte;
   506         end;
   475         end;
   507 
   476 
   508 //TODO: implement SDL_ProximityEvent
   477     // implement SDL_ProximityEvent
       
   478 {$ENDIF}
   509 {$ENDIF}
   479 
   510 
   480     TSDL_JoyAxisEvent = record
   511     TSDL_JoyAxisEvent = record
   481 {$IFDEF SDL13}
   512         type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
   482         type_: LongInt;
       
   483 {$ELSE}
       
   484         type_: Byte;
       
   485 {$ENDIF}
       
   486         which: Byte;
   513         which: Byte;
   487         axis: Byte;
   514         axis: Byte;
   488 {$IFDEF SDL13}
   515 {$IFDEF SDL13}
       
   516         padding1, padding2: Byte;
   489         value: LongInt;
   517         value: LongInt;
   490 {$ELSE}
   518 {$ELSE}
   491         value: Smallint;
   519         value: Smallint;
   492 {$ENDIF}
   520 {$ENDIF}
   493         end;
   521         end;
   494 
   522 
   495     TSDL_JoyBallEvent = record
   523     TSDL_JoyBallEvent = record
       
   524         type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
   496         which: Byte;
   525         which: Byte;
   497         ball: Byte;
   526         ball: Byte;
   498 {$IFDEF SDL13}
   527 {$IFDEF SDL13}
   499         type_: LongInt;
   528         padding1, padding2: Byte;
   500         xrel, yrel: LongInt;
   529         xrel, yrel: LongInt;
   501 {$ELSE}
   530 {$ELSE}
   502         type_: Byte;
       
   503         xrel, yrel: Smallint;
   531         xrel, yrel: Smallint;
   504 {$ENDIF}
   532 {$ENDIF}
   505         end;
   533         end;
   506 
   534 
   507     TSDL_JoyHatEvent = record
   535     TSDL_JoyHatEvent = record
   508 {$IFDEF SDL13}
   536         type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
   509         type_: LongInt;
       
   510 {$ELSE}
       
   511         type_: Byte;
       
   512 {$ENDIF}
       
   513         which: Byte;
   537         which: Byte;
   514         hat: Byte;
   538         hat: Byte;
   515         value: Byte;
   539         value: Byte;
       
   540 {$IFDEF SDL13}
       
   541         padding1: Byte;
       
   542 {$ENDIF}
   516         end;
   543         end;
   517 
   544 
   518     TSDL_JoyButtonEvent = record
   545     TSDL_JoyButtonEvent = record
   519 {$IFDEF SDL13}
   546         type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
   520         type_: LongInt;
       
   521 {$ELSE}
       
   522         type_: Byte;
       
   523 {$ENDIF}
       
   524         which: Byte;
   547         which: Byte;
   525         button: Byte;
   548         button: Byte;
   526         state: Byte;
   549         state: Byte;
   527         end;
   550 {$IFDEF SDL13}
       
   551         padding1: Byte;
       
   552 {$ENDIF}
       
   553         end;
       
   554 
       
   555 //TODO: implement SDL_TouchButtonEvent, SDL_MultiGestureEvent, SDL_DollarGestureEvent
   528 
   556 
   529     TSDL_QuitEvent = record
   557     TSDL_QuitEvent = record
   530 {$IFDEF SDL13}
   558         type_: {$IFDEF SDL13}LongInt{$ELSE}Byte{$ENDIF};
   531         type_: LongInt;
       
   532 {$ELSE}
       
   533         type_: Byte;
       
   534 {$ENDIF}
       
   535         end;
   559         end;
   536 
   560 
   537     TSDL_UserEvent = record
   561     TSDL_UserEvent = record
   538 {$IFDEF SDL13}
   562 {$IFDEF SDL13}
   539         type_: LongInt;
   563         type_: LongInt;
   548     PSDL_Event = ^TSDL_Event;
   572     PSDL_Event = ^TSDL_Event;
   549     TSDL_Event = record
   573     TSDL_Event = record
   550 {$IFDEF SDL13}
   574 {$IFDEF SDL13}
   551         case LongInt of
   575         case LongInt of
   552             SDL_FIRSTEVENT: (type_: LongInt);
   576             SDL_FIRSTEVENT: (type_: LongInt);
   553             SDL_QUITEV: (quit: TSDL_QuitEvent);
       
   554             SDL_WINDOWEVENT: (wevent: TSDL_WindowEvent);
   577             SDL_WINDOWEVENT: (wevent: TSDL_WindowEvent);
   555             SDL_KEYDOWN,
   578             SDL_KEYDOWN,
   556             SDL_KEYUP: (key: TSDL_KeyboardEvent);
   579             SDL_KEYUP: (key: TSDL_KeyboardEvent);
   557             SDL_TEXTEDITING,
   580             SDL_TEXTEDITING,
   558             SDL_TEXTINPUT: (txtin: byte);
   581             SDL_TEXTINPUT: (txtin: byte);
   563             SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
   586             SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
   564             SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
   587             SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
   565             SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
   588             SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
   566             SDL_JOYBUTTONDOWN,
   589             SDL_JOYBUTTONDOWN,
   567             SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
   590             SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
       
   591             SDL_QUITEV: (quit: TSDL_QuitEvent);
   568             SDL_USEREVENT: (user: TSDL_UserEvent);
   592             SDL_USEREVENT: (user: TSDL_UserEvent);
       
   593             //TODO: implement other events
   569 {$ELSE}
   594 {$ELSE}
   570         case Byte of
   595         case Byte of
   571             SDL_NOEVENT: (type_: byte);
   596             SDL_NOEVENT: (type_: byte);
   572             SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
   597             SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
   573             SDL_KEYDOWN,
   598             SDL_KEYDOWN,
   755 function  SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
   780 function  SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
   756 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
   781 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
   757 
   782 
   758 function  SDL_AllocFormat(format: Longword): PSDL_PixelFormat; cdecl; external SDLLibName;
   783 function  SDL_AllocFormat(format: Longword): PSDL_PixelFormat; cdecl; external SDLLibName;
   759 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); cdecl; external SDLLibName;
   784 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); cdecl; external SDLLibName;
       
   785 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
       
   786 
       
   787 procedure SDL_WarpMouse(x, y: Word);
       
   788 {$ELSE}
       
   789 procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName;
       
   790 
       
   791 function  SDL_AllocFormat(format: Longword): PSDL_PixelFormat;
       
   792 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat);
   760 {$ENDIF}
   793 {$ENDIF}
   761 
   794 
   762 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
   795 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
   763 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
   796 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
   764 function  SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName;
   797 function  SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName;
   765 procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName;
       
   766 
   798 
   767 procedure SDL_PumpEvents; cdecl; external SDLLibName;
   799 procedure SDL_PumpEvents; cdecl; external SDLLibName;
   768 function  SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
   800 function  SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
   769 function  SDL_WaitEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
   801 function  SDL_WaitEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
   770 
   802 
   858 procedure IMG_Quit; cdecl; external SDL_ImageLibName;
   890 procedure IMG_Quit; cdecl; external SDL_ImageLibName;
   859 
   891 
   860 function  IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
   892 function  IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
   861 function  IMG_Load_RW(rwop: PSDL_RWops; freesrc: LongInt): PSDL_Surface; cdecl; external SDL_ImageLibName;
   893 function  IMG_Load_RW(rwop: PSDL_RWops; freesrc: LongInt): PSDL_Surface; cdecl; external SDL_ImageLibName;
   862 function  IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName;
   894 function  IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName;
   863 function  IMG_LoadTyped_RW(rwop: PSDL_RWops; freesrc: LongInt; _type: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
   895 function  IMG_LoadTyped_RW(rwop: PSDL_RWops; freesrc: LongInt; type_: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
   864 
   896 
   865 (*  SDL_net  *)
   897 (*  SDL_net  *)
   866 function  SDLNet_Init: LongInt; cdecl; external SDL_NetLibName;
   898 function  SDLNet_Init: LongInt; cdecl; external SDL_NetLibName;
   867 procedure SDLNet_Quit; cdecl; external SDL_NetLibName;
   899 procedure SDLNet_Quit; cdecl; external SDL_NetLibName;
   868 
   900 
   882 procedure SDLNet_Write32(value: LongWord; buf: pointer);
   914 procedure SDLNet_Write32(value: LongWord; buf: pointer);
   883 function  SDLNet_Read16(buf: pointer): Word;
   915 function  SDLNet_Read16(buf: pointer): Word;
   884 function  SDLNet_Read32(buf: pointer): LongWord;
   916 function  SDLNet_Read32(buf: pointer): LongWord;
   885 
   917 
   886 implementation
   918 implementation
       
   919 uses uVariables;
       
   920 
       
   921 {$IFDEF SDL13}
       
   922 procedure SDL_WarpMouse(x, y: Word);
       
   923 begin
       
   924     SDL_WarpMouseInWindow(SDLwindow, x, y);
       
   925 end;
       
   926 {$ELSE}
       
   927 function SDL_AllocFormat(format: Longword): PSDL_PixelFormat;
       
   928 const conversionFormat: TSDL_PixelFormat = (
       
   929         palette: nil; BitsPerPixel: 32; BytesPerPixel: 4;
       
   930         Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0;
       
   931         Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift;
       
   932         RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask;
       
   933         colorkey: 0; alpha: 255);
       
   934 begin
       
   935     format:= format;
       
   936     exit(@conversionFormat);
       
   937 end;
       
   938 
       
   939 procedure SDL_FreeFormat;
       
   940 begin
       
   941     // yay free space
       
   942 end;
       
   943 {$ENDIF}
   887 
   944 
   888 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
   945 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
   889 begin
   946 begin
   890 {$IFDEF SDL13}
   947 {$IFDEF SDL13}
   891     SDL_MustLock:= ((surface^.flags and SDL_RLEACCEL) <> 0)
   948     SDL_MustLock:= ((surface^.flags and SDL_RLEACCEL) <> 0)