hedgewars/SDLh.pas
changeset 2671 7e0f88013fe8
parent 2669 4eec706e86b0
child 2674 2fce032f2f95
equal deleted inserted replaced
2670:1b327b7515ed 2671:7e0f88013fe8
    14  * You should have received a copy of the GNU General Public License
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  *)
    17  *)
    18 
    18 
    19 {$INCLUDE "options.inc"}
    19 {$I "options.inc"}
    20 
    20 
    21 unit SDLh;
    21 unit SDLh;
    22 interface
    22 interface
    23 
    23 
    24 {$IFDEF LINUX}
    24 {$IFDEF LINUX}
   175 	AMask = $000000FF;
   175 	AMask = $000000FF;
   176 {$ENDIF}
   176 {$ENDIF}
   177 
   177 
   178 	{* SDL_mixer *}
   178 	{* SDL_mixer *}
   179 	MIX_MAX_VOLUME = 128;
   179 	MIX_MAX_VOLUME = 128;
   180 
   180 	MIX_INIT_FLAC = $00000001;
       
   181 	MIX_INIT_MOD  = $00000002;
       
   182 	MIX_INIT_MP3  = $00000004;
       
   183 	MIX_INIT_OGG  = $00000008;
       
   184 	
   181 	{* SDL_TTF *}
   185 	{* SDL_TTF *}
   182 	TTF_STYLE_NORMAL = 0;
   186 	TTF_STYLE_NORMAL = 0;
   183 	TTF_STYLE_BOLD   = 1;
   187 	TTF_STYLE_BOLD   = 1;
   184 	TTF_STYLE_ITALIC = 2;
   188 	TTF_STYLE_ITALIC = 2;
   185 
   189 
   566 
   570 
   567 
   571 
   568 {* SDL *}
   572 {* SDL *}
   569 function  SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName;
   573 function  SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName;
   570 procedure SDL_Quit; cdecl; external SDLLibName;
   574 procedure SDL_Quit; cdecl; external SDLLibName;
       
   575 
   571 function  SDL_VideoDriverName(var namebuf; maxlen: LongInt): PChar; cdecl; external SDLLibName;
   576 function  SDL_VideoDriverName(var namebuf; maxlen: LongInt): PChar; cdecl; external SDLLibName;
   572 procedure SDL_EnableUNICODE(enable: LongInt); cdecl; external SDLLibName;
   577 procedure SDL_EnableUNICODE(enable: LongInt); cdecl; external SDLLibName;
   573 
   578 
   574 procedure SDL_Delay(msec: Longword); cdecl; external SDLLibName;
   579 procedure SDL_Delay(msec: Longword); cdecl; external SDLLibName;
   575 function  SDL_GetTicks: Longword; cdecl; external SDLLibName;
   580 function  SDL_GetTicks: Longword; cdecl; external SDLLibName;
   603 function  SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; cdecl; external SDLLibName;
   608 function  SDL_RWFromFile(filename, mode: PChar): PSDL_RWops; cdecl; external SDLLibName;
   604 function  SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName;
   609 function  SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName;
   605 
   610 
   606 {$IFDEF SDL13}
   611 {$IFDEF SDL13}
   607 function  SDL_GetKeyboardState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
   612 function  SDL_GetKeyboardState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
   608 function  SDL_GetMouseState(index: LongInt; x, y: PLongInt): Byte; cdecl; external SDLLibName;
       
   609 function  SDL_SelectMouse(index: LongInt): LongInt; cdecl; external SDLLibName;
   613 function  SDL_SelectMouse(index: LongInt): LongInt; cdecl; external SDLLibName;
   610 function  SDL_GetRelativeMouseState(index: LongInt; x, y: PLongInt): Byte; cdecl; external SDLLibName;
   614 function  SDL_GetRelativeMouseState(index: LongInt; x, y: PLongInt): Byte; cdecl; external SDLLibName;
   611 function  SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
   615 function  SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
   612 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
   616 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
   613 {$ELSE}
   617 {$ELSE}
   614 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
   618 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName;
       
   619 {$ENDIF}
   615 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
   620 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
   616 {$ENDIF}
       
   617 function  SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName;
   621 function  SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName;
   618 procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName;
   622 procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName;
   619 
   623 
   620 procedure SDL_PumpEvents; cdecl; external SDLLibName;
   624 procedure SDL_PumpEvents; cdecl; external SDLLibName;
   621 function  SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
   625 function  SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName;
   658 procedure SDL_JoystickClose(joy: PSDL_Joystick); cdecl; external SDLLibName;
   662 procedure SDL_JoystickClose(joy: PSDL_Joystick); cdecl; external SDLLibName;
   659 
   663 
   660 (*  SDL_TTF  *)
   664 (*  SDL_TTF  *)
   661 function  TTF_Init: LongInt; cdecl; external SDL_TTFLibName;
   665 function  TTF_Init: LongInt; cdecl; external SDL_TTFLibName;
   662 procedure TTF_Quit; cdecl; external SDL_TTFLibName;
   666 procedure TTF_Quit; cdecl; external SDL_TTFLibName;
       
   667 
   663 function  TTF_SizeUTF8(font: PTTF_Font; const text: PChar; var w, h: LongInt): LongInt; cdecl; external SDL_TTFLibName;
   668 function  TTF_SizeUTF8(font: PTTF_Font; const text: PChar; var w, h: LongInt): LongInt; cdecl; external SDL_TTFLibName;
   664 
   669 
   665 function  TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   670 function  TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   666 function  TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   671 function  TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   667 function  TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   672 function  TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
   668 
   673 
   669 function  TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName;
   674 function  TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName;
   670 procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName;
   675 procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName;
   671 
   676 
   672 (*  SDL_mixer  *)
   677 (*  SDL_mixer  *)
       
   678 function  Mix_Init(flags: LongInt): LongInt; cdecl; external SDL_MixerLibName;
       
   679 procedure Mix_Quit; cdecl; external SDL_MixerLibName;
       
   680 
   673 function  Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName;
   681 function  Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName;
   674 procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName;
   682 procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName;
   675 
   683 
   676 function  Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName;
   684 function  Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName;
   677 function  Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName;
   685 function  Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName;
   695 function  Mix_ResumeMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName;
   703 function  Mix_ResumeMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName;
   696 function  Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName;
   704 function  Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName;
   697 
   705 
   698 (*  SDL_image  *)
   706 (*  SDL_image  *)
   699 function  IMG_Init(flags: LongInt): LongInt; cdecl; external SDL_ImageLibName;
   707 function  IMG_Init(flags: LongInt): LongInt; cdecl; external SDL_ImageLibName;
       
   708 procedure IMG_Quit; cdecl; external SDL_ImageLibName;
       
   709 
   700 function  IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
   710 function  IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName;
   701 function  IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName;
   711 function  IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName;
   702 procedure IMG_Quit; cdecl; external SDL_ImageLibName;
       
   703 
   712 
   704 (*  SDL_net  *)
   713 (*  SDL_net  *)
   705 function  SDLNet_Init: LongInt; cdecl; external SDL_NetLibName;
   714 function  SDLNet_Init: LongInt; cdecl; external SDL_NetLibName;
   706 procedure SDLNet_Quit; cdecl; external SDL_NetLibName;
   715 procedure SDLNet_Quit; cdecl; external SDL_NetLibName;
   707 
   716 
   708 function  SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName;
   717 function  SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName;
   709 function  SDLNet_ResolveHost(var address: TIPaddress; host: PCHar; port: Word): LongInt; cdecl; external SDL_NetLibName;
   718 function  SDLNet_ResolveHost(var address: TIPaddress; host: PChar; port: Word): LongInt; cdecl; external SDL_NetLibName;
   710 function  SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName;
   719 function  SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName;
   711 function  SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName;
   720 function  SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName;
   712 function  SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName;
   721 function  SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName;
   713 function  SDLNet_TCP_Recv(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName;
   722 function  SDLNet_TCP_Recv(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName;
   714 procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName;
   723 procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName;
   720 procedure SDLNet_Write16(value: Word; buf: pointer);
   729 procedure SDLNet_Write16(value: Word; buf: pointer);
   721 procedure SDLNet_Write32(value: LongWord; buf: pointer);
   730 procedure SDLNet_Write32(value: LongWord; buf: pointer);
   722 function  SDLNet_Read16(buf: pointer): Word;
   731 function  SDLNet_Read16(buf: pointer): Word;
   723 function  SDLNet_Read32(buf: pointer): LongWord;
   732 function  SDLNet_Read32(buf: pointer): LongWord;
   724 
   733 
       
   734 {$IFDEF IPHONEOS}
       
   735 function get_documents_path: PChar; cdecl; external 'hwutils';
       
   736 {$ENDIF}
       
   737 
   725 implementation
   738 implementation
   726 
   739 
   727 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
   740 function SDL_MustLock(Surface: PSDL_Surface): Boolean;
   728 begin
   741 begin
   729 	SDL_MustLock:= ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0)
   742 	SDL_MustLock:= ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0)