54 {$ENDIF} |
54 {$ENDIF} |
55 |
55 |
56 (* SDL *) |
56 (* SDL *) |
57 const |
57 const |
58 {$IFDEF WIN32} |
58 {$IFDEF WIN32} |
59 SDLLibName = 'SDL.dll'; |
59 SDLLibName = 'SDL.dll'; |
60 {$ENDIF} |
60 SDL_TTFLibName = 'SDL_ttf.dll'; |
61 {$IFDEF UNIX} |
61 SDL_MixerLibName = 'SDL_mixer.dll'; |
|
62 SDL_ImageLibName = 'SDL_image.dll'; |
|
63 SDL_NetLibName = 'SDL_net.dll'; |
|
64 {$ELSE} |
62 {$IFDEF DARWIN} |
65 {$IFDEF DARWIN} |
63 SDLLibName = 'SDL'; |
66 SDLLibName = 'SDL'; |
|
67 SDL_TTFLibName = 'SDL_ttf'; |
|
68 SDL_MixerLibName = 'SDL_mixer'; |
|
69 SDL_ImageLibName = 'SDL_image'; |
|
70 SDL_NetLibName = 'SDL_net'; |
64 {$ELSE} |
71 {$ELSE} |
65 SDLLibName = 'libSDL.so'; |
72 SDLLibName = 'libSDL.so'; |
|
73 SDL_TTFLibName = 'libSDL_ttf.so'; |
|
74 SDL_MixerLibName = 'libSDL_mixer.so'; |
|
75 SDL_ImageLibName = 'libSDL_image.so'; |
|
76 SDL_NetLibName = 'libSDL_net.so'; |
66 {$ENDIF} |
77 {$ENDIF} |
67 {$ENDIF} |
78 {$ENDIF} |
|
79 |
|
80 ///////////////////////////////////////////////////////////////// |
|
81 ///////////////////// CONSTANT DEFINITIONS ///////////////////// |
|
82 ///////////////////////////////////////////////////////////////// |
|
83 |
68 SDL_SWSURFACE = $00000000; |
84 SDL_SWSURFACE = $00000000; |
69 SDL_HWSURFACE = $00000001; |
85 SDL_HWSURFACE = $00000001; |
70 SDL_SRCALPHA = $00010000; |
86 SDL_SRCALPHA = $00010000; |
71 SDL_INIT_VIDEO = $00000020; |
87 SDL_INIT_VIDEO = $00000020; |
72 SDL_INIT_AUDIO = $00000010; |
88 SDL_INIT_AUDIO = $00000010; |
208 1: (value: Longword); |
248 1: (value: Longword); |
209 end; |
249 end; |
210 |
250 |
211 |
251 |
212 PSDL_RWops = ^TSDL_RWops; |
252 PSDL_RWops = ^TSDL_RWops; |
|
253 {$IFDEF FPC} |
213 TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl; |
254 TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl; |
214 TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; cdecl; |
255 TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; cdecl; |
215 TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl; |
256 TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl; |
216 TClose = function( context: PSDL_RWops ): LongInt; cdecl; |
257 TClose = function( context: PSDL_RWops ): LongInt; cdecl; |
|
258 {$ELSE} |
|
259 TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; |
|
260 TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; |
|
261 TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; |
|
262 TClose = function( context: PSDL_RWops ): LongInt; |
|
263 |
|
264 PByte = ^Byte; |
|
265 {$ENDIF} |
217 |
266 |
218 TStdio = record |
267 TStdio = record |
219 autoclose: LongInt; |
268 autoclose: LongInt; |
220 fp: pointer; |
269 fp: pointer; |
221 end; |
270 end; |
312 which: Byte; |
361 which: Byte; |
313 x, y: LongInt; |
362 x, y: LongInt; |
314 end; |
363 end; |
315 {$ENDIF} |
364 {$ENDIF} |
316 |
365 |
317 TSDL_JoyAxisEvent = record |
366 TSDL_JoyAxisEvent = record |
318 type_: Byte; |
367 type_: Byte; |
319 which: Byte; |
368 which: Byte; |
320 axis: Byte; |
369 axis: Byte; |
321 {$IFDEF SDL13} |
370 {$IFDEF SDL13} |
322 value: LongInt; |
371 value: LongInt; |
323 {$ELSE} |
372 {$ELSE} |
324 value: word; |
373 value: word; |
325 {$ENDIF} |
374 {$ENDIF} |
326 end; |
375 end; |
327 |
376 |
328 TSDL_JoyBallEvent = record |
377 TSDL_JoyBallEvent = record |
329 type_: Byte; |
378 type_: Byte; |
330 which: Byte; |
379 which: Byte; |
331 ball: Byte; |
380 ball: Byte; |
332 {$IFDEF SDL13} |
381 {$IFDEF SDL13} |
333 xrel, yrel: LongInt; |
382 xrel, yrel: LongInt; |
334 {$ELSE} |
383 {$ELSE} |
335 xrel, yrel: word; |
384 xrel, yrel: word; |
336 {$ENDIF} |
385 {$ENDIF} |
337 end; |
386 end; |
338 |
387 |
339 TSDL_JoyHatEvent = record |
388 TSDL_JoyHatEvent = record |
340 type_: Byte; |
389 type_: Byte; |
341 which: Byte; |
390 which: Byte; |
342 hat: Byte; |
391 hat: Byte; |
343 value: Byte; |
392 value: Byte; |
344 end; |
393 end; |
345 |
394 |
346 TSDL_JoyButtonEvent = record |
395 TSDL_JoyButtonEvent = record |
347 type_: Byte; |
396 type_: Byte; |
348 which: Byte; |
397 which: Byte; |
349 button: Byte; |
398 button: Byte; |
350 state: Byte; |
399 state: Byte; |
351 end; |
400 end; |
352 |
401 |
353 TSDL_QuitEvent = record |
402 TSDL_QuitEvent = record |
354 type_: Byte; |
403 type_: Byte; |
355 end; |
404 end; |
356 |
405 |
357 {$IFNDEF SDL13} |
406 {$IFNDEF SDL13} |
358 TSDL_ResizeEvent = record |
407 TSDL_ResizeEvent = record |
359 type_: Byte; |
408 type_: Byte; |
360 w, h: LongInt; |
409 w, h: LongInt; |
361 end; |
410 end; |
362 {$ENDIF} |
411 {$ENDIF} |
363 |
412 |
364 PSDL_Event = ^TSDL_Event; |
413 PSDL_Event = ^TSDL_Event; |
365 TSDL_Event = record |
414 TSDL_Event = record |
366 case Byte of |
415 case Byte of |
367 SDL_NOEVENT: (type_: byte); |
416 SDL_NOEVENT: (type_: byte); |
368 {$IFDEF SDL13} |
417 {$IFDEF SDL13} |
369 SDL_WINDOWEVENT: (active: TSDL_WindowEvent); |
418 SDL_WINDOWEVENT: (active: TSDL_WindowEvent); |
370 SDL_KEYDOWN, |
419 SDL_KEYDOWN, |
371 SDL_KEYUP: (key: TSDL_KeyboardEvent); |
420 SDL_KEYUP: (key: TSDL_KeyboardEvent); |
372 SDL_TEXTEDITING, |
421 SDL_TEXTEDITING, |
373 SDL_TEXTINPUT: (txtin: byte); |
422 SDL_TEXTINPUT: (txtin: byte); |
374 SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent); |
423 SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent); |
375 SDL_MOUSEBUTTONDOWN, |
424 SDL_MOUSEBUTTONDOWN, |
376 SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent); |
425 SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent); |
377 SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent); |
426 SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent); |
378 SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent); |
427 SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent); |
379 SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent); |
428 SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent); |
380 SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent); |
429 SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent); |
381 SDL_JOYBUTTONDOWN, |
430 SDL_JOYBUTTONDOWN, |
382 SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent); |
431 SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent); |
383 SDL_QUITEV: (quit: TSDL_QuitEvent); |
432 SDL_QUITEV: (quit: TSDL_QuitEvent); |
384 {$ELSE} |
433 {$ELSE} |
385 SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent); |
434 SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent); |
386 SDL_KEYDOWN, |
435 SDL_KEYDOWN, |
387 SDL_KEYUP: (key: TSDL_KeyboardEvent); |
436 SDL_KEYUP: (key: TSDL_KeyboardEvent); |
388 SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent); |
437 SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent); |
389 SDL_MOUSEBUTTONDOWN, |
438 SDL_MOUSEBUTTONDOWN, |
390 SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent); |
439 SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent); |
391 SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent); |
440 SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent); |
392 SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent); |
441 SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent); |
393 SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent); |
442 SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent); |
394 SDL_JOYBUTTONDOWN, |
443 SDL_JOYBUTTONDOWN, |
395 SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent); |
444 SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent); |
396 SDL_QUITEV: (quit: TSDL_QuitEvent); |
445 SDL_QUITEV: (quit: TSDL_QuitEvent); |
397 //SDL_SYSWMEVENT,SDL_EVENT_RESERVEDA,SDL_EVENT_RESERVEDB |
446 //SDL_SYSWMEVENT,SDL_EVENT_RESERVEDA,SDL_EVENT_RESERVEDB |
398 //SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent); |
447 //SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent); |
399 {$ENDIF} |
448 {$ENDIF} |
400 end; |
449 end; |
401 |
450 |
402 PByteArray = ^TByteArray; |
451 PByteArray = ^TByteArray; |
403 TByteArray = array[0..65535] of Byte; |
452 TByteArray = array[0..65535] of Byte; |
404 PLongWordArray = ^TLongWordArray; |
453 PLongWordArray = ^TLongWordArray; |
405 TLongWordArray = array[0..16383] of LongWord; |
454 TLongWordArray = array[0..16383] of LongWord; |
406 |
455 |
407 PSDL_Thread = Pointer; |
456 PSDL_Thread = Pointer; |
408 PSDL_mutex = Pointer; |
457 PSDL_mutex = Pointer; |
409 |
458 |
410 TSDL_GLattr = ( |
459 TSDL_GLattr = ( |
411 SDL_GL_RED_SIZE, |
460 SDL_GL_RED_SIZE, |
412 SDL_GL_GREEN_SIZE, |
461 SDL_GL_GREEN_SIZE, |
413 SDL_GL_BLUE_SIZE, |
462 SDL_GL_BLUE_SIZE, |
439 SDL_ARRAYORDER_BGRA, |
488 SDL_ARRAYORDER_BGRA, |
440 SDL_ARRAYORDER_ABGR |
489 SDL_ARRAYORDER_ABGR |
441 ); |
490 ); |
442 {$ENDIF} |
491 {$ENDIF} |
443 |
492 |
|
493 // Joystick/Controller support |
|
494 PSDL_Joystick = ^TSDL_Joystick; |
|
495 TSDL_Joystick = record |
|
496 end; |
|
497 |
|
498 {* SDL_TTF *} |
|
499 PTTF_Font = ^TTTF_font; |
|
500 TTTF_Font = record |
|
501 end; |
|
502 |
|
503 {* SDL_mixer *} |
|
504 PMixChunk = ^TMixChunk; |
|
505 TMixChunk = record |
|
506 allocated: Longword; |
|
507 abuf : PByte; |
|
508 alen : Longword; |
|
509 volume : PByte; |
|
510 end; |
|
511 TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3); |
|
512 TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN); |
|
513 |
|
514 TMidiSong = record |
|
515 samples : LongInt; |
|
516 events : pointer; |
|
517 end; |
|
518 |
|
519 TMusicUnion = record |
|
520 case Byte of |
|
521 0: ( midi : TMidiSong ); |
|
522 1: ( ogg : pointer); |
|
523 end; |
|
524 |
|
525 PMixMusic = ^TMixMusic; |
|
526 TMixMusic = record |
|
527 end; |
|
528 |
|
529 {* SDL_net *} |
|
530 TIPAddress = record |
|
531 host: Longword; |
|
532 port: Word; |
|
533 end; |
|
534 |
|
535 PTCPSocket = ^TTCPSocket; |
|
536 TTCPSocket = record |
|
537 ready: LongInt; |
|
538 channel: LongInt; |
|
539 remoteAddress: TIPaddress; |
|
540 localAddress: TIPaddress; |
|
541 sflag: LongInt; |
|
542 end; |
|
543 PSDLNet_SocketSet = ^TSDLNet_SocketSet; |
|
544 TSDLNet_SocketSet = record |
|
545 numsockets, |
|
546 maxsockets: LongInt; |
|
547 sockets: PTCPSocket; |
|
548 end; |
|
549 |
|
550 |
|
551 ///////////////////////////////////////////////////////////////// |
|
552 ///////////////////// FUNCTION DEFINITIONS ///////////////////// |
|
553 ///////////////////////////////////////////////////////////////// |
|
554 |
|
555 {$IFDEF FPC} |
|
556 |
|
557 {* SDL *} |
444 function SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName; |
558 function SDL_Init(flags: Longword): LongInt; cdecl; external SDLLibName; |
445 procedure SDL_Quit; cdecl; external SDLLibName; |
559 procedure SDL_Quit; cdecl; external SDLLibName; |
446 function SDL_VideoDriverName(var namebuf; maxlen: LongInt): PChar; cdecl; external SDLLibName; |
560 function SDL_VideoDriverName(var namebuf; maxlen: LongInt): PChar; cdecl; external SDLLibName; |
447 procedure SDL_EnableUNICODE(enable: LongInt); cdecl; external SDLLibName; |
561 procedure SDL_EnableUNICODE(enable: LongInt); cdecl; external SDLLibName; |
448 |
562 |
514 function SDL_iPhoneKeyboardHide(windowID: LongInt): LongInt; cdecl; external SDLLibName; |
628 function SDL_iPhoneKeyboardHide(windowID: LongInt): LongInt; cdecl; external SDLLibName; |
515 function SDL_iPhoneKeyboardIsShown(windowID: LongInt): boolean; cdecl; external SDLLibName; |
629 function SDL_iPhoneKeyboardIsShown(windowID: LongInt): boolean; cdecl; external SDLLibName; |
516 function SDL_iPhoneKeyboardToggle(windowID: LongInt): LongInt; cdecl; external SDLLibName; |
630 function SDL_iPhoneKeyboardToggle(windowID: LongInt): LongInt; cdecl; external SDLLibName; |
517 {$ENDIF} |
631 {$ENDIF} |
518 {$ENDIF} |
632 {$ENDIF} |
519 |
|
520 |
|
521 |
|
522 // Joystick/Controller support |
|
523 type PSDL_Joystick = ^TSDL_Joystick; |
|
524 TSDL_Joystick = record |
|
525 end; |
|
526 |
|
527 const SDL_HAT_CENTERED = $00; |
|
528 SDL_HAT_UP = $01; |
|
529 SDL_HAT_RIGHT = $02; |
|
530 SDL_HAT_DOWN = $04; |
|
531 SDL_HAT_LEFT = $08; |
|
532 SDL_HAT_RIGHTUP = SDL_HAT_RIGHT or SDL_HAT_UP; |
|
533 SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN; |
|
534 SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP; |
|
535 SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN; |
|
536 |
633 |
537 function SDL_NumJoysticks: LongInt; cdecl; external SDLLibName; |
634 function SDL_NumJoysticks: LongInt; cdecl; external SDLLibName; |
538 function SDL_JoystickName(idx: LongInt): PChar; cdecl; external SDLLibName; |
635 function SDL_JoystickName(idx: LongInt): PChar; cdecl; external SDLLibName; |
539 function SDL_JoystickOpen(idx: LongInt): PSDL_Joystick; cdecl; external SDLLibName; |
636 function SDL_JoystickOpen(idx: LongInt): PSDL_Joystick; cdecl; external SDLLibName; |
540 function SDL_JoystickOpened(idx: LongInt): LongInt; cdecl; external SDLLibName; |
637 function SDL_JoystickOpened(idx: LongInt): LongInt; cdecl; external SDLLibName; |
549 function SDL_JoystickGetBall(joy: PSDL_Joystick; ball: LongInt; dx: PInteger; dy: PInteger): Word; cdecl; external SDLLibName; |
646 function SDL_JoystickGetBall(joy: PSDL_Joystick; ball: LongInt; dx: PInteger; dy: PInteger): Word; cdecl; external SDLLibName; |
550 function SDL_JoystickGetHat(joy: PSDL_Joystick; hat: LongInt): Byte; cdecl; external SDLLibName; |
647 function SDL_JoystickGetHat(joy: PSDL_Joystick; hat: LongInt): Byte; cdecl; external SDLLibName; |
551 function SDL_JoystickGetButton(joy: PSDL_Joystick; button: LongInt): Byte; cdecl; external SDLLibName; |
648 function SDL_JoystickGetButton(joy: PSDL_Joystick; button: LongInt): Byte; cdecl; external SDLLibName; |
552 procedure SDL_JoystickClose(joy: PSDL_Joystick); cdecl; external SDLLibName; |
649 procedure SDL_JoystickClose(joy: PSDL_Joystick); cdecl; external SDLLibName; |
553 |
650 |
554 (* TTF *) |
651 (* SDL_TTF *) |
555 |
652 function TTF_Init: LongInt; cdecl; external SDL_TTFLibName; |
556 const {$IFDEF WIN32} |
|
557 SDL_TTFLibName = 'SDL_ttf.dll'; |
|
558 {$ENDIF} |
|
559 {$IFDEF UNIX} |
|
560 {$IFDEF DARWIN} |
|
561 SDL_TTFLibName = 'SDL_ttf'; |
|
562 {$ELSE} |
|
563 SDL_TTFLibName = 'libSDL_ttf.so'; |
|
564 {$ENDIF} |
|
565 {$ENDIF} |
|
566 TTF_STYLE_NORMAL = 0; |
|
567 TTF_STYLE_BOLD = 1; |
|
568 TTF_STYLE_ITALIC = 2; |
|
569 |
|
570 type PTTF_Font = ^TTTF_font; |
|
571 TTTF_Font = record |
|
572 end; |
|
573 |
|
574 function TTF_Init: LongInt; cdecl; external SDL_TTFLibName; |
|
575 procedure TTF_Quit; cdecl; external SDL_TTFLibName; |
653 procedure TTF_Quit; cdecl; external SDL_TTFLibName; |
576 |
654 function TTF_SizeUTF8(font: PTTF_Font; const text: PChar; var w, h: LongInt): LongInt; cdecl; external SDL_TTFLibName; |
577 |
|
578 function TTF_SizeUTF8(font: PTTF_Font; const text: PChar; var w, h: LongInt): LongInt; cdecl; external SDL_TTFLibName; |
|
579 (* TSDL_Color -> Longword conversion is workaround over freepascal bug. |
655 (* TSDL_Color -> Longword conversion is workaround over freepascal bug. |
580 See http://www.freepascal.org/mantis/view.php?id=7613 for details *) |
656 See http://www.freepascal.org/mantis/view.php?id=7613 for details *) |
581 function TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
657 function TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
582 function TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
658 function TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
583 function TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
659 function TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: Longword): PSDL_Surface; cdecl; external SDL_TTFLibName; |
584 |
660 |
585 function TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName; |
661 function TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName; |
586 procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName; |
662 procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName; |
587 |
663 |
588 (* SDL_mixer *) |
664 (* SDL_mixer *) |
589 |
|
590 const {$IFDEF WIN32} |
|
591 SDL_MixerLibName = 'SDL_mixer.dll'; |
|
592 {$ENDIF} |
|
593 {$IFDEF UNIX} |
|
594 {$IFDEF DARWIN} |
|
595 SDL_MixerLibName = 'SDL_mixer'; |
|
596 {$ELSE} |
|
597 SDL_MixerLibName = 'libSDL_mixer.so'; |
|
598 {$ENDIF} |
|
599 {$ENDIF} |
|
600 |
|
601 const MIX_MAX_VOLUME = 128; |
|
602 |
|
603 type PMixChunk = ^TMixChunk; |
|
604 TMixChunk = record |
|
605 allocated: Longword; |
|
606 abuf : PByte; |
|
607 alen : Longword; |
|
608 volume : PByte; |
|
609 end; |
|
610 TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3); |
|
611 TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN); |
|
612 |
|
613 TMidiSong = record |
|
614 samples : LongInt; |
|
615 events : pointer; |
|
616 end; |
|
617 |
|
618 TMusicUnion = record |
|
619 case Byte of |
|
620 0: ( midi : TMidiSong ); |
|
621 1: ( ogg : pointer); |
|
622 end; |
|
623 |
|
624 PMixMusic = ^TMixMusic; |
|
625 TMixMusic = record |
|
626 end; |
|
627 |
|
628 function Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
665 function Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
629 procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName; |
666 procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName; |
630 |
667 |
631 function Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
668 function Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
632 function Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName; |
669 function Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName; |
649 function Mix_PauseMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName; |
686 function Mix_PauseMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName; |
650 function Mix_ResumeMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName; |
687 function Mix_ResumeMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName; |
651 function Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
688 function Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName; |
652 |
689 |
653 (* SDL_image *) |
690 (* SDL_image *) |
654 |
691 function IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName; |
655 const {$IFDEF WIN32} |
692 function IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName; |
656 SDL_ImageLibName = 'SDL_image.dll'; |
|
657 {$ENDIF} |
|
658 {$IFDEF UNIX} |
|
659 {$IFDEF DARWIN} |
|
660 SDL_ImageLibName = 'SDL_image'; |
|
661 {$ELSE} |
|
662 SDL_ImageLibName = 'libSDL_image.so'; |
|
663 {$ENDIF} |
|
664 {$ENDIF} |
|
665 |
|
666 function IMG_Load(const _file: PChar): PSDL_Surface; cdecl; external SDL_ImageLibName; |
|
667 function IMG_LoadPNG_RW(rwop: PSDL_RWops): PSDL_Surface; cdecl; external SDL_ImageLibName; |
|
668 |
693 |
669 (* SDL_net *) |
694 (* SDL_net *) |
670 |
695 function SDLNet_Init: LongInt; cdecl; external SDL_NetLibName; |
671 const {$IFDEF WIN32} |
|
672 SDL_NetLibName = 'SDL_net.dll'; |
|
673 {$ENDIF} |
|
674 {$IFDEF UNIX} |
|
675 {$IFDEF DARWIN} |
|
676 SDL_NetLibName = 'SDL_net'; |
|
677 {$ELSE} |
|
678 SDL_NetLibName = 'libSDL_net.so'; |
|
679 {$ENDIF} |
|
680 {$ENDIF} |
|
681 |
|
682 type TIPAddress = record |
|
683 host: Longword; |
|
684 port: Word; |
|
685 end; |
|
686 |
|
687 PTCPSocket = ^TTCPSocket; |
|
688 TTCPSocket = record |
|
689 ready: LongInt; |
|
690 channel: LongInt; |
|
691 remoteAddress: TIPaddress; |
|
692 localAddress: TIPaddress; |
|
693 sflag: LongInt; |
|
694 end; |
|
695 PSDLNet_SocketSet = ^TSDLNet_SocketSet; |
|
696 TSDLNet_SocketSet = record |
|
697 numsockets, |
|
698 maxsockets: LongInt; |
|
699 sockets: PTCPSocket; |
|
700 end; |
|
701 |
|
702 function SDLNet_Init: LongInt; cdecl; external SDL_NetLibName; |
|
703 procedure SDLNet_Quit; cdecl; external SDL_NetLibName; |
696 procedure SDLNet_Quit; cdecl; external SDL_NetLibName; |
704 |
697 |
705 function SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName; |
698 function SDLNet_AllocSocketSet(maxsockets: LongInt): PSDLNet_SocketSet; cdecl; external SDL_NetLibName; |
706 function SDLNet_ResolveHost(var address: TIPaddress; host: PCHar; port: Word): LongInt; cdecl; external SDL_NetLibName; |
699 function SDLNet_ResolveHost(var address: TIPaddress; host: PCHar; port: Word): LongInt; cdecl; external SDL_NetLibName; |
707 function SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName; |
700 function SDLNet_TCP_Accept(server: PTCPsocket): PTCPSocket; cdecl; external SDL_NetLibName; |
708 function SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName; |
701 function SDLNet_TCP_Open(var ip: TIPaddress): PTCPSocket; cdecl; external SDL_NetLibName; |
709 function SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
702 function SDLNet_TCP_Send(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
710 function SDLNet_TCP_Recv(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
703 function SDLNet_TCP_Recv(sock: PTCPsocket; data: Pointer; len: LongInt): LongInt; cdecl; external SDL_NetLibName; |
711 procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName; |
704 procedure SDLNet_TCP_Close(sock: PTCPsocket); cdecl; external SDL_NetLibName; |
712 procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName; |
705 procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName; |
713 function SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName; |
706 function SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName; |
714 function SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName; |
707 function SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName; |
|
708 {$ELSE}{$ENDIF} |
715 |
709 |
716 procedure SDLNet_Write16(value: Word; buf: pointer); |
710 procedure SDLNet_Write16(value: Word; buf: pointer); |
717 procedure SDLNet_Write32(value: LongWord; buf: pointer); |
711 procedure SDLNet_Write32(value: LongWord; buf: pointer); |
718 function SDLNet_Read16(buf: pointer): Word; |
712 function SDLNet_Read16(buf: pointer): Word; |
719 function SDLNet_Read32(buf: pointer): LongWord; |
713 function SDLNet_Read32(buf: pointer): LongWord; |
720 |
714 |
721 implementation |
715 implementation |
722 |
716 |
723 function SDL_MustLock(Surface: PSDL_Surface): Boolean; |
717 function SDL_MustLock(Surface: PSDL_Surface): Boolean; |
724 begin |
718 begin |
725 SDL_MustLock:= ( surface^.offset <> 0 ) |
719 SDL_MustLock:= ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0) |
726 or(( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0) |
|
727 end; |
720 end; |
728 |
721 |
729 procedure SDLNet_Write16(value: Word; buf: pointer); |
722 procedure SDLNet_Write16(value: Word; buf: pointer); |
730 begin |
723 begin |
731 PByteArray(buf)^[1]:= value; |
724 PByteArray(buf)^[1]:= value; |