423 function SDL_iPhoneKeyboardIsShown(windowID: LongInt): boolean; cdecl; external SDLLibName; |
424 function SDL_iPhoneKeyboardIsShown(windowID: LongInt): boolean; cdecl; external SDLLibName; |
424 function SDL_iPhoneKeyboardToggle(windowID: LongInt): LongInt; cdecl; external SDLLibName; |
425 function SDL_iPhoneKeyboardToggle(windowID: LongInt): LongInt; cdecl; external SDLLibName; |
425 {$ENDIF} |
426 {$ENDIF} |
426 {$ENDIF} |
427 {$ENDIF} |
427 |
428 |
428 (* TTF *) |
429 |
429 |
|
430 const {$IFDEF WIN32} |
|
431 SDL_TTFLibName = 'SDL_ttf.dll'; |
|
432 {$ENDIF} |
|
433 {$IFDEF UNIX} |
|
434 {$IFDEF DARWIN} |
|
435 SDL_TTFLibName = 'SDL_ttf'; |
|
436 {$ELSE} |
|
437 SDL_TTFLibName = 'libSDL_ttf.so'; |
|
438 {$ENDIF} |
|
439 {$ENDIF} |
|
440 TTF_STYLE_NORMAL = 0; |
|
441 TTF_STYLE_BOLD = 1; |
|
442 TTF_STYLE_ITALIC = 2; |
|
443 |
|
444 type PTTF_Font = ^TTTF_font; |
|
445 TTTF_Font = record |
|
446 end; |
|
447 |
|
448 function TTF_Init: LongInt; cdecl; external SDL_TTFLibName; |
|
449 procedure TTF_Quit; cdecl; external SDL_TTFLibName; |
|
450 |
|
451 |
|
452 function TTF_SizeUTF8(font: PTTF_Font; const text: PChar; var w, h: LongInt): LongInt; cdecl; external SDL_TTFLibName; |
|
453 (* TSDL_Color -> Longword conversion is workaround over freepascal bug. |
|
454 See http://www.freepascal.org/mantis/view.php?id=7613 for details *) |
|
455 function TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
|
456 function TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
|
457 function TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
|
458 |
|
459 function TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName; |
|
460 procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName; |
|
461 |
|
462 |
|
463 (* SDL_image *) |
|
464 |
|
465 const {$IFDEF WIN32} |
|
466 SDL_ImageLibName = 'SDL_image.dll'; |
|
467 {$ENDIF} |
|
468 {$IFDEF UNIX} |
|
469 {$IFDEF DARWIN} |
|
470 SDL_ImageLibName = 'SDL_image'; |
|
471 {$ELSE} |
|
472 SDL_ImageLibName = 'libSDL_image.so'; |
|
473 {$ENDIF} |
|
474 {$ENDIF} |
|
475 |
|
476 function IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName; |
|
477 |
|
478 (* SDL_net *) |
|
479 |
|
480 const {$IFDEF WIN32} |
|
481 SDL_NetLibName = 'SDL_net.dll'; |
|
482 {$ENDIF} |
|
483 {$IFDEF UNIX} |
|
484 {$IFDEF DARWIN} |
|
485 SDL_NetLibName = 'SDL_net'; |
|
486 {$ELSE} |
|
487 SDL_NetLibName = 'libSDL_net.so'; |
|
488 {$ENDIF} |
|
489 {$ENDIF} |
|
490 |
|
491 type TIPAddress = record |
|
492 host: Longword; |
|
493 port: Word; |
|
494 end; |
|
495 |
|
496 PTCPSocket = ^TTCPSocket; |
|
497 TTCPSocket = record |
|
498 ready: LongInt; |
|
499 channel: LongInt; |
|
500 remoteAddress: TIPaddress; |
|
501 localAddress: TIPaddress; |
|
502 sflag: LongInt; |
|
503 end; |
|
504 PSDLNet_SocketSet = ^TSDLNet_SocketSet; |
|
505 TSDLNet_SocketSet = record |
|
506 numsockets, |
|
507 maxsockets: LongInt; |
|
508 sockets: PTCPSocket; |
|
509 end; |
|
510 |
|
511 function SDLNet_Init: LongInt; cdecl; external SDL_NetLibName; |
|
512 procedure SDLNet_Quit; cdecl; external SDL_NetLibName; |
|
513 |
|
514 function SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName; |
|
515 function SDLNet_ResolveHost(var address: TIPaddress; host: PCHar; port: Word): LongInt; cdecl; external SDL_NetLibName; |
|
516 function SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName; |
|
517 function SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName; |
|
518 function SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
519 function SDLNet_TCP_Recv(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
520 procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName; |
|
521 procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName; |
|
522 function SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName; |
|
523 function SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
524 |
|
525 procedure SDLNet_Write16(value: Word; buf: pointer); |
|
526 procedure SDLNet_Write32(value: LongWord; buf: pointer); |
|
527 function SDLNet_Read16(buf: pointer): Word; |
|
528 function SDLNet_Read32(buf: pointer): LongWord; |
|
529 |
430 |
530 // Joystick/Controller support |
431 // Joystick/Controller support |
531 type PSDLJoystick = ^TSDLJoystick; |
432 type PSDLJoystick = ^TSDLJoystick; |
532 TSDLJoystick = record |
433 TSDLJoystick = record |
533 end; |
434 end; |
556 function SDL_JoystickGetBall(joy: PSDLJoystick; ball: LongInt; dx: PInteger; dy: PInteger): Word; cdecl; external SDLLibName; |
457 function SDL_JoystickGetBall(joy: PSDLJoystick; ball: LongInt; dx: PInteger; dy: PInteger): Word; cdecl; external SDLLibName; |
557 function SDL_JoystickGetHat(joy: PSDLJoystick; hat: LongInt): Byte; cdecl; external SDLLibName; |
458 function SDL_JoystickGetHat(joy: PSDLJoystick; hat: LongInt): Byte; cdecl; external SDLLibName; |
558 function SDL_JoystickGetButton(joy: PSDLJoystick; button: LongInt): Byte; cdecl; external SDLLibName; |
459 function SDL_JoystickGetButton(joy: PSDLJoystick; button: LongInt): Byte; cdecl; external SDLLibName; |
559 procedure SDL_JoystickClose(joy: PSDLJoystick); cdecl; external SDLLibName; |
460 procedure SDL_JoystickClose(joy: PSDLJoystick); cdecl; external SDLLibName; |
560 |
461 |
|
462 (* TTF *) |
|
463 |
|
464 const {$IFDEF WIN32} |
|
465 SDL_TTFLibName = 'SDL_ttf.dll'; |
|
466 {$ENDIF} |
|
467 {$IFDEF UNIX} |
|
468 {$IFDEF DARWIN} |
|
469 SDL_TTFLibName = 'SDL_ttf'; |
|
470 {$ELSE} |
|
471 SDL_TTFLibName = 'libSDL_ttf.so'; |
|
472 {$ENDIF} |
|
473 {$ENDIF} |
|
474 TTF_STYLE_NORMAL = 0; |
|
475 TTF_STYLE_BOLD = 1; |
|
476 TTF_STYLE_ITALIC = 2; |
|
477 |
|
478 type PTTF_Font = ^TTTF_font; |
|
479 TTTF_Font = record |
|
480 end; |
|
481 |
|
482 function TTF_Init: LongInt; cdecl; external SDL_TTFLibName; |
|
483 procedure TTF_Quit; cdecl; external SDL_TTFLibName; |
|
484 |
|
485 |
|
486 function TTF_SizeUTF8(font: PTTF_Font; const text: PChar; var w, h: LongInt): LongInt; cdecl; external SDL_TTFLibName; |
|
487 (* TSDL_Color -> Longword conversion is workaround over freepascal bug. |
|
488 See http://www.freepascal.org/mantis/view.php?id=7613 for details *) |
|
489 function TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
|
490 function TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
|
491 function TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
|
492 |
|
493 function TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName; |
|
494 procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName; |
|
495 |
|
496 (* SDL_mixer *) |
|
497 |
|
498 const {$IFDEF WIN32} |
|
499 SDL_MixerLibName = 'SDL_mixer.dll'; |
|
500 {$ENDIF} |
|
501 {$IFDEF UNIX} |
|
502 {$IFDEF DARWIN} |
|
503 SDL_MixerLibName = 'SDL_mixer'; |
|
504 {$ELSE} |
|
505 SDL_MixerLibName = 'libSDL_mixer.so'; |
|
506 {$ENDIF} |
|
507 {$ENDIF} |
|
508 |
|
509 const MIX_MAX_VOLUME = 128; |
|
510 |
|
511 type PMixChunk = ^TMixChunk; |
|
512 TMixChunk = record |
|
513 allocated: Longword; |
|
514 abuf : PByte; |
|
515 alen : Longword; |
|
516 volume : PByte; |
|
517 end; |
|
518 TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3); |
|
519 TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN); |
|
520 |
|
521 TMidiSong = record |
|
522 samples : LongInt; |
|
523 events : pointer; |
|
524 end; |
|
525 |
|
526 TMusicUnion = record |
|
527 case Byte of |
|
528 0: ( midi : TMidiSong ); |
|
529 1: ( ogg : pointer); |
|
530 end; |
|
531 |
|
532 PMixMusic = ^TMixMusic; |
|
533 TMixMusic = record |
|
534 end; |
|
535 |
|
536 function Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
537 procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName; |
|
538 |
|
539 function Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
540 function Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName; |
|
541 function Mix_VolumeMusic(volume: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
542 |
|
543 function Mix_AllocateChannels(numchans: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
544 procedure Mix_FreeChunk(chunk: PMixChunk); cdecl; external SDL_MixerLibName; |
|
545 procedure Mix_FreeMusic(music: PMixMusic); cdecl; external SDL_MixerLibName; |
|
546 |
|
547 function Mix_LoadWAV_RW(src: PSDL_RWops; freesrc: LongInt): PMixChunk; cdecl; external SDL_MixerLibName; |
|
548 function Mix_LoadMUS(const filename: PChar): PMixMusic; cdecl; external SDL_MixerLibName; |
|
549 |
|
550 function Mix_Playing(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
551 function Mix_PlayingMusic: LongInt; cdecl; external SDL_MixerLibName; |
|
552 function Mix_FadeInMusic(music: PMixMusic; loops: LongInt; ms: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
553 |
|
554 function Mix_PlayChannelTimed(channel: LongInt; chunk: PMixChunk; loops: LongInt; ticks: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
555 function Mix_PlayMusic(music: PMixMusic; loops: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
556 function Mix_PausedMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName; |
|
557 function Mix_PauseMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName; |
|
558 function Mix_ResumeMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName; |
|
559 function Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
|
560 |
|
561 (* SDL_image *) |
|
562 |
|
563 const {$IFDEF WIN32} |
|
564 SDL_ImageLibName = 'SDL_image.dll'; |
|
565 {$ENDIF} |
|
566 {$IFDEF UNIX} |
|
567 {$IFDEF DARWIN} |
|
568 SDL_ImageLibName = 'SDL_image'; |
|
569 {$ELSE} |
|
570 SDL_ImageLibName = 'libSDL_image.so'; |
|
571 {$ENDIF} |
|
572 {$ENDIF} |
|
573 |
|
574 function IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName; |
|
575 |
|
576 (* SDL_net *) |
|
577 |
|
578 const {$IFDEF WIN32} |
|
579 SDL_NetLibName = 'SDL_net.dll'; |
|
580 {$ENDIF} |
|
581 {$IFDEF UNIX} |
|
582 {$IFDEF DARWIN} |
|
583 SDL_NetLibName = 'SDL_net'; |
|
584 {$ELSE} |
|
585 SDL_NetLibName = 'libSDL_net.so'; |
|
586 {$ENDIF} |
|
587 {$ENDIF} |
|
588 |
|
589 type TIPAddress = record |
|
590 host: Longword; |
|
591 port: Word; |
|
592 end; |
|
593 |
|
594 PTCPSocket = ^TTCPSocket; |
|
595 TTCPSocket = record |
|
596 ready: LongInt; |
|
597 channel: LongInt; |
|
598 remoteAddress: TIPaddress; |
|
599 localAddress: TIPaddress; |
|
600 sflag: LongInt; |
|
601 end; |
|
602 PSDLNet_SocketSet = ^TSDLNet_SocketSet; |
|
603 TSDLNet_SocketSet = record |
|
604 numsockets, |
|
605 maxsockets: LongInt; |
|
606 sockets: PTCPSocket; |
|
607 end; |
|
608 |
|
609 function SDLNet_Init: LongInt; cdecl; external SDL_NetLibName; |
|
610 procedure SDLNet_Quit; cdecl; external SDL_NetLibName; |
|
611 |
|
612 function SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName; |
|
613 function SDLNet_ResolveHost(var address: TIPaddress; host: PCHar; port: Word): LongInt; cdecl; external SDL_NetLibName; |
|
614 function SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName; |
|
615 function SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName; |
|
616 function SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
617 function SDLNet_TCP_Recv(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
618 procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName; |
|
619 procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName; |
|
620 function SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName; |
|
621 function SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
622 |
|
623 procedure SDLNet_Write16(value: Word; buf: pointer); |
|
624 procedure SDLNet_Write32(value: LongWord; buf: pointer); |
|
625 function SDLNet_Read16(buf: pointer): Word; |
|
626 function SDLNet_Read32(buf: pointer): LongWord; |
|
627 |
561 implementation |
628 implementation |
562 |
629 |
563 function SDL_MustLock(Surface: PSDL_Surface): Boolean; |
630 function SDL_MustLock(Surface: PSDL_Surface): Boolean; |
564 begin |
631 begin |
565 SDL_MustLock:= ( surface^.offset <> 0 ) |
632 SDL_MustLock:= ( surface^.offset <> 0 ) |