Make surfaces work again (bad hack though)
[sdlgit/SDL_perl.git] / src / SDL.xs
1 //
2 // SDL.xs
3 //
4 // Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
5 //
6 // ------------------------------------------------------------------------------
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // 
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // Lesser General Public License for more details.
17 // 
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 //
22 // ------------------------------------------------------------------------------
23 //
24 // Please feel free to send questions, suggestions or improvements to:
25 //
26 //      David J. Goehrig
27 //      dgoehrig@cpan.org
28 //
29
30 #include "EXTERN.h"
31 #include "perl.h"
32 #include "XSUB.h"
33
34 #ifndef aTHX_
35 #define aTHX_
36 #endif
37
38 #include <SDL.h>
39
40 #ifdef HAVE_GL
41 #include <gl.h>
42 #endif
43
44 #ifdef HAVE_GLU
45 #include <glu.h>
46 #endif
47
48 #ifdef HAVE_SDL_IMAGE
49 #include <SDL_image.h>
50 #endif 
51
52 #ifdef HAVE_SDL_MIXER
53 #include <SDL_mixer.h>
54 void (*mix_music_finished_cv)();
55 #endif
56
57 #ifdef HAVE_SDL_SOUND
58 #include <SDL_sound.h>
59 #endif
60
61 #ifdef HAVE_SDL_NET
62 #include <SDL_net.h>
63 #endif
64
65 #ifdef HAVE_SDL_TTF
66 #include <SDL_ttf.h>
67 #define TEXT_SOLID      1
68 #define TEXT_SHADED     2
69 #define TEXT_BLENDED    4
70 #define UTF8_SOLID      8
71 #define UTF8_SHADED     16      
72 #define UTF8_BLENDED    32
73 #define UNICODE_SOLID   64
74 #define UNICODE_SHADED  128
75 #define UNICODE_BLENDED 256
76 #endif
77
78 #ifdef HAVE_SMPEG
79 #include <smpeg/smpeg.h>
80 #ifdef HAVE_SDL_MIXER
81 static int sdl_perl_use_smpeg_audio = 0;
82 #endif
83 #endif
84
85 #ifdef HAVE_SDL_GFX
86 #include <SDL_rotozoom.h>
87 #include <SDL_gfxPrimitives.h>
88 #include <SDL_framerate.h>
89 #include <SDL_imageFilter.h>
90 #endif
91
92 #ifdef HAVE_SDL_SVG
93 #include <SDL_svg.h>
94 #endif
95
96 #ifdef USE_THREADS
97 #define HAVE_TLS_CONTEXT
98 #endif
99
100 /* For windows  */
101 #ifndef SDL_PERL_DEFINES_H
102 #define SDL_PERL_DEFINES_H
103
104 #ifdef HAVE_TLS_CONTEXT
105 PerlInterpreter *parent_perl = NULL;
106 extern PerlInterpreter *parent_perl;
107 #define GET_TLS_CONTEXT parent_perl =  PERL_GET_CONTEXT;
108 #define ENTER_TLS_CONTEXT \
109         PerlInterpreter *current_perl = PERL_GET_CONTEXT; \
110                 PERL_SET_CONTEXT(parent_perl); { \
111                                         PerlInterpreter *my_perl = parent_perl;
112 #define LEAVE_TLS_CONTEXT \
113                                                 } PERL_SET_CONTEXT(current_perl);
114 #else
115 #define GET_TLS_CONTEXT         /* TLS context not enabled */
116 #define ENTER_TLS_CONTEXT       /* TLS context not enabled */
117 #define LEAVE_TLS_CONTEXT       /* TLS context not enabled */
118 #endif
119
120 #endif
121
122 Uint32 
123 sdl_perl_timer_callback ( Uint32 interval, void* param )
124 {
125         Uint32 retval;
126         int back;
127         SV* cmd;
128         ENTER_TLS_CONTEXT
129         dSP;
130
131         cmd = (SV*)param;
132
133         ENTER;
134         SAVETMPS;
135         PUSHMARK(SP);
136         XPUSHs(sv_2mortal(newSViv(interval)));
137         PUTBACK;
138
139         if (0 != (back = call_sv(cmd,G_SCALAR))) {
140                 SPAGAIN;
141                 if (back != 1 ) Perl_croak (aTHX_ "Timer Callback failed!");
142                 retval = POPi;  
143         } else {
144                 Perl_croak(aTHX_ "Timer Callback failed!");
145         }
146
147         FREETMPS;
148         LEAVE;
149
150         LEAVE_TLS_CONTEXT
151         
152         return retval;
153 }
154
155 void
156 sdl_perl_audio_callback ( void* data, Uint8 *stream, int len )
157 {
158         SV *cmd;
159         ENTER_TLS_CONTEXT
160         dSP;
161
162         cmd = (SV*)data;
163
164         ENTER;
165         SAVETMPS;
166         PUSHMARK(SP);
167         XPUSHs(sv_2mortal(newSViv(PTR2IV(stream))));
168         XPUSHs(sv_2mortal(newSViv(len)));
169         PUTBACK;
170
171         call_sv(cmd,G_VOID|G_DISCARD);
172         
173         PUTBACK;
174         FREETMPS;
175         LEAVE;
176
177         LEAVE_TLS_CONTEXT       
178 }
179
180 #ifdef HAVE_SDL_MIXER
181
182 void
183 sdl_perl_music_callback ( void ) 
184 {
185         SV *cmd;
186         ENTER_TLS_CONTEXT
187         dSP;
188
189         cmd = (SV*)Mix_GetMusicHookData();
190
191         ENTER;
192         SAVETMPS;
193         PUSHMARK(SP);
194         PUTBACK;
195         
196         call_sv(cmd,G_VOID|G_DISCARD);
197
198         PUTBACK;
199         FREETMPS;
200         LEAVE;
201
202         LEAVE_TLS_CONTEXT
203 }
204
205 void
206 sdl_perl_music_finished_callback ( void )
207 {
208         SV *cmd;
209         ENTER_TLS_CONTEXT
210         dSP;
211
212         cmd = (SV*)mix_music_finished_cv;
213         if ( cmd == NULL ) return;
214
215         ENTER;
216         SAVETMPS;
217         PUSHMARK(SP);
218         PUTBACK;
219         
220         call_sv(cmd,G_VOID|G_DISCARD);
221         
222         PUTBACK;
223         FREETMPS;
224         LEAVE;
225
226         LEAVE_TLS_CONTEXT
227 }
228
229 #endif
230
231 #define INIT_NS_APPLICATION
232 #define QUIT_NS_APPLICATION
233
234
235 void
236 sdl_perl_atexit (void)
237 {
238         QUIT_NS_APPLICATION     
239         SDL_Quit();
240 }
241
242 void boot_SDL();
243 void boot_SDL__OpenGL();
244
245 XS(boot_SDL_perl)
246 {
247         GET_TLS_CONTEXT
248         boot_SDL();
249 }
250
251 MODULE = SDL_perl       PACKAGE = SDL
252 PROTOTYPES : DISABLE
253
254 char *
255 GetError ()
256         CODE:
257                 RETVAL = SDL_GetError();
258         OUTPUT:
259                 RETVAL
260
261 int
262 Init ( flags )
263         Uint32 flags
264         CODE:
265                 INIT_NS_APPLICATION
266                 RETVAL = SDL_Init(flags);
267 #ifdef HAVE_TLS_CONTEXT
268                 Perl_call_atexit(PERL_GET_CONTEXT, (void*)sdl_perl_atexit,0);
269 #else
270                 atexit(sdl_perl_atexit);
271 #endif
272         OUTPUT:
273                 RETVAL
274
275 int
276 InitSubSystem ( flags )
277         Uint32 flags
278         CODE:
279                 RETVAL = SDL_InitSubSystem(flags);
280         OUTPUT:
281                 RETVAL
282
283 void
284 QuitSubSystem ( flags )
285         Uint32 flags
286         CODE:
287                 SDL_QuitSubSystem(flags);
288
289 void
290 Quit ()
291         CODE:
292                 QUIT_NS_APPLICATION
293                 SDL_Quit();
294
295 int
296 WasInit ( flags )
297         Uint32 flags
298         CODE:
299                 RETVAL = SDL_WasInit(flags);
300         OUTPUT:
301                 RETVAL
302
303 void
304 Delay ( ms )
305         int ms
306         CODE:
307                 SDL_Delay(ms);
308
309 Uint32
310 GetTicks ()
311         CODE:
312                 RETVAL = SDL_GetTicks();
313         OUTPUT:
314                 RETVAL
315
316 int
317 SetTimer ( interval, callback )
318         Uint32 interval
319         SDL_TimerCallback callback
320         CODE:
321                 RETVAL = SDL_SetTimer(interval,callback);
322         OUTPUT:
323                 RETVAL
324
325 SDL_TimerID
326 AddTimer ( interval, callback, param )
327         Uint32 interval
328         SDL_NewTimerCallback callback
329         void *param
330         CODE:
331                 RETVAL = SDL_AddTimer(interval,callback,param);
332         OUTPUT:
333                 RETVAL
334
335 SDL_NewTimerCallback
336 PerlTimerCallback ()
337         CODE:
338                 RETVAL = sdl_perl_timer_callback;
339         OUTPUT:
340                 RETVAL  
341
342 SDL_TimerID
343 NewTimer ( interval, cmd )
344         Uint32 interval
345         void *cmd
346         CODE:
347                 RETVAL = SDL_AddTimer(interval,sdl_perl_timer_callback,cmd);
348         OUTPUT:
349                 RETVAL
350
351 Uint32
352 RemoveTimer ( id )
353         SDL_TimerID id
354         CODE:
355                 RETVAL = SDL_RemoveTimer(id);
356         OUTPUT:
357                 RETVAL
358
359 SDL_RWops*
360 RWFromFile ( file, mode )
361         char* file
362         char * mode
363         CODE:
364                 RETVAL = SDL_RWFromFile(file,mode);
365         OUTPUT:
366                 RETVAL
367
368 SDL_RWops*
369 RWFromFP ( fp, autoclose )
370         FILE* fp
371         int autoclose
372         CODE:
373                 RETVAL = SDL_RWFromFP(fp,autoclose);
374         OUTPUT:
375                 RETVAL
376
377 SDL_RWops*
378 RWFromMem ( mem, size )
379         char* mem
380         int size
381         CODE:
382                 RETVAL = SDL_RWFromMem((void*)mem,size);
383         OUTPUT:
384                 RETVAL
385
386 SDL_RWops*
387 RWFromConstMem ( mem, size )
388         const char* mem
389         int size
390         CODE:
391                 RETVAL = SDL_RWFromConstMem((const void*)mem,size);
392         OUTPUT:
393                 RETVAL
394
395 SDL_RWops*
396 AllocRW ()
397         CODE:
398                 RETVAL = SDL_AllocRW();
399         OUTPUT:
400                 RETVAL
401
402 void
403 FreeRW ( rw )
404         SDL_RWops* rw
405         CODE:
406                 SDL_FreeRW(rw);
407
408 int
409 RWseek ( rw, off, whence )
410         SDL_RWops* rw
411         int off
412         int whence
413         CODE:
414                 RETVAL = SDL_RWseek(rw,off,whence);
415         OUTPUT:
416                 RETVAL
417
418 int
419 RWtell ( rw )
420         SDL_RWops* rw
421         CODE:
422                 RETVAL = SDL_RWtell(rw);
423         OUTPUT:
424                 RETVAL
425
426 int
427 RWread ( rw, mem, size, n )
428         SDL_RWops* rw
429         char* mem
430         int size
431         int n
432         CODE:
433                 RETVAL = SDL_RWread(rw,mem,size,n);
434         OUTPUT:
435                 RETVAL
436
437 int
438 RWwrite ( rw, mem, size, n )
439         SDL_RWops* rw
440         char* mem
441         int size
442         int n
443         CODE:
444                 RETVAL = SDL_RWwrite(rw,mem,size,n);
445         OUTPUT:
446                 RETVAL
447
448 int
449 RWclose ( rw )
450         SDL_RWops* rw
451         CODE:
452                 RETVAL = SDL_RWclose(rw);
453         OUTPUT:
454                 RETVAL
455
456 int
457 CDNumDrives ()
458         CODE:
459                 RETVAL = SDL_CDNumDrives();
460         OUTPUT:
461                 RETVAL
462
463 char *
464 CDName ( drive )
465         int drive
466         CODE:
467                 RETVAL = strdup(SDL_CDName(drive));
468         OUTPUT:
469                 RETVAL
470
471 SDL_CD *
472 CDOpen ( drive )
473         int drive
474         CODE:
475                 RETVAL = SDL_CDOpen(drive);
476         OUTPUT:
477                 RETVAL
478
479 Uint8
480 CDTrackId ( track )
481         SDL_CDtrack *track
482         CODE:
483                 RETVAL = track->id;
484         OUTPUT:
485                 RETVAL
486
487 Uint8
488 CDTrackType ( track )
489         SDL_CDtrack *track
490         CODE:
491                 RETVAL = track->type;
492         OUTPUT:
493                 RETVAL
494
495 Uint16
496 CDTrackLength ( track )
497         SDL_CDtrack *track
498         CODE:
499                 RETVAL = track->length;
500         OUTPUT:
501                 RETVAL
502
503 Uint32
504 CDTrackOffset ( track )
505         SDL_CDtrack *track
506         CODE:
507                 RETVAL = track->offset;
508         OUTPUT: 
509                 RETVAL
510
511 Uint32
512 CDStatus ( cd )
513         SDL_CD *cd 
514         CODE:
515                 RETVAL = SDL_CDStatus(cd);
516         OUTPUT:
517                 RETVAL
518
519 int
520 CDPlayTracks ( cd, start_track, ntracks, start_frame, nframes )
521         SDL_CD *cd
522         int start_track
523         int ntracks
524         int start_frame
525         int nframes
526         CODE:
527                 RETVAL = SDL_CDPlayTracks(cd,start_track,start_frame,ntracks,nframes);
528         OUTPUT:
529                 RETVAL
530
531 int
532 CDPlay ( cd, start, length )
533         SDL_CD *cd
534         int start
535         int length
536         CODE:
537                 RETVAL = SDL_CDPlay(cd,start,length);
538         OUTPUT:
539                 RETVAL
540
541 int
542 CDPause ( cd )
543         SDL_CD *cd
544         CODE:
545                 RETVAL = SDL_CDPause(cd);
546         OUTPUT:
547                 RETVAL
548
549 int
550 CDResume ( cd )
551         SDL_CD *cd
552         CODE:
553                 RETVAL = SDL_CDResume(cd);
554         OUTPUT:
555                 RETVAL
556
557 int
558 CDStop ( cd )
559         SDL_CD *cd
560         CODE:
561                 RETVAL = SDL_CDStop(cd);
562         OUTPUT:
563                 RETVAL
564
565 int
566 CDEject ( cd )
567         SDL_CD *cd
568         CODE:
569                 RETVAL = SDL_CDEject(cd);
570         OUTPUT:
571                 RETVAL
572
573 void
574 CDClose ( cd )
575         SDL_CD *cd
576         CODE:
577                 SDL_CDClose(cd);
578         
579 int
580 CDId ( cd )
581         SDL_CD *cd
582         CODE:
583                 RETVAL = cd->id;
584         OUTPUT: 
585                 RETVAL
586
587 int
588 CDNumTracks ( cd )
589         SDL_CD *cd
590         CODE:
591                 RETVAL = cd->numtracks;
592         OUTPUT:
593                 RETVAL
594
595 int
596 CDCurTrack ( cd )
597         SDL_CD *cd
598         CODE:
599                 RETVAL = cd->cur_track;
600         OUTPUT:
601                 RETVAL
602
603 int
604 CDCurFrame ( cd )
605         SDL_CD *cd
606         CODE:
607                 RETVAL = cd->cur_frame;
608         OUTPUT:
609                 RETVAL
610
611 SDL_CDtrack *
612 CDTrack ( cd, number )
613         SDL_CD *cd
614         int number
615         CODE:
616                 RETVAL = (SDL_CDtrack *)(cd->track + number);
617         OUTPUT:
618                 RETVAL
619
620 void
621 PumpEvents ()
622         CODE:
623                 SDL_PumpEvents();
624
625 int
626 PushEvent( e )
627         SDL_Event *e
628         CODE:
629                 RETVAL = SDL_PushEvent( e );
630         OUTPUT:
631                 RETVAL
632
633 SDL_Event *
634 NewEvent ()
635         CODE:   
636                 RETVAL = (SDL_Event *) safemalloc (sizeof(SDL_Event));
637         OUTPUT:
638                 RETVAL
639
640 void
641 FreeEvent ( e )
642         SDL_Event *e
643         CODE:
644                 safefree(e);
645
646 int
647 PollEvent ( e )
648         SDL_Event *e
649         CODE:
650                 RETVAL = SDL_PollEvent(e);
651         OUTPUT:
652                 RETVAL
653
654 int
655 WaitEvent ( e )
656         SDL_Event *e
657         CODE:
658                 RETVAL = SDL_WaitEvent(e);
659         OUTPUT:
660                 RETVAL
661
662 Uint8
663 EventState ( type, state )
664         Uint8 type
665         int state
666         CODE:
667                 RETVAL = SDL_EventState(type,state);
668         OUTPUT:
669                 RETVAL 
670
671 Uint8
672 EventType ( e )
673         SDL_Event *e
674         CODE:
675                 RETVAL = e->type;
676         OUTPUT:
677                 RETVAL
678
679 Uint8
680 SetEventType ( e, type )
681         SDL_Event *e
682         Uint8 type
683         CODE:
684                 RETVAL = e->type;
685                 e->type = type;
686         OUTPUT:
687                 RETVAL
688
689 Uint8
690 ActiveEventGain ( e )
691         SDL_Event *e
692         CODE:
693                 RETVAL = e->active.gain;
694         OUTPUT: 
695                 RETVAL
696
697 Uint8
698 ActiveEventState ( e )
699         SDL_Event *e
700         CODE:
701                 RETVAL = e->active.state;
702         OUTPUT:
703                 RETVAL
704
705 Uint8
706 KeyEventState( e )
707         SDL_Event *e
708         CODE:
709                 RETVAL = e->key.state;
710         OUTPUT:
711                 RETVAL
712
713 int
714 KeyEventSym ( e )
715         SDL_Event *e
716         CODE:
717                 RETVAL = e->key.keysym.sym;
718         OUTPUT:
719                 RETVAL
720
721 int 
722 KeyEventMod ( e )
723         SDL_Event *e
724         CODE:
725                 RETVAL = e->key.keysym.mod;
726         OUTPUT:
727                 RETVAL
728
729 Uint16
730 KeyEventUnicode ( e )
731         SDL_Event *e
732         CODE:
733                 RETVAL = e->key.keysym.unicode;
734         OUTPUT:
735                 RETVAL
736
737 Uint8
738 KeyEventScanCode ( e )
739         SDL_Event *e
740         CODE:
741                 RETVAL = e->key.keysym.scancode;
742         OUTPUT:
743                 RETVAL
744
745 Uint8
746 MouseMotionState ( e )
747         SDL_Event *e
748         CODE:
749                 RETVAL = e->motion.state;
750         OUTPUT: 
751                 RETVAL
752
753 Uint16
754 MouseMotionX ( e )
755         SDL_Event *e
756         CODE:
757                 RETVAL = e->motion.x;
758         OUTPUT:
759                 RETVAL
760
761 Uint16
762 MouseMotionY ( e )
763         SDL_Event *e
764         CODE:
765                 RETVAL = e->motion.y;
766         OUTPUT:
767                 RETVAL
768
769 Sint16
770 MouseMotionXrel( e )
771         SDL_Event *e
772         CODE:
773                 RETVAL = e->motion.xrel;
774         OUTPUT:
775                 RETVAL
776
777 Sint16
778 MouseMotionYrel ( e )
779         SDL_Event *e
780         CODE:
781                 RETVAL = e->motion.yrel;
782         OUTPUT:
783                 RETVAL
784
785 Uint8
786 MouseButtonState ( e )
787         SDL_Event *e
788         CODE:
789                 RETVAL = e->button.state;
790         OUTPUT:
791                 RETVAL
792
793 Uint8
794 MouseButton ( e )
795         SDL_Event *e
796         CODE:
797                 RETVAL = e->button.button;
798         OUTPUT:
799                 RETVAL
800
801 Uint16
802 MouseButtonX ( e )
803         SDL_Event *e
804         CODE:
805                 RETVAL = e->button.x;
806         OUTPUT:
807                 RETVAL
808
809 Uint16
810 MouseButtonY ( e )
811         SDL_Event *e
812         CODE:
813                 RETVAL = e->button.y;
814         OUTPUT:
815                 RETVAL
816
817 SDL_SysWMmsg *
818 SysWMEventMsg ( e )
819         SDL_Event *e
820         CODE:
821                 RETVAL = e->syswm.msg;
822         OUTPUT:
823                 RETVAL
824
825 int
826 EnableUnicode ( enable )
827         int enable
828         CODE:
829                 RETVAL = SDL_EnableUNICODE(enable);
830         OUTPUT:
831                 RETVAL
832
833 void
834 EnableKeyRepeat ( delay, interval )
835         int delay
836         int interval
837         CODE:
838                 SDL_EnableKeyRepeat(delay,interval);
839
840 Uint32
841 GetModState ()
842         CODE:
843                 RETVAL = SDL_GetModState();
844         OUTPUT:
845                 RETVAL
846
847 void
848 SetModState ( state )
849         Uint32 state
850         CODE:
851                 SDL_SetModState(state);
852
853 char *
854 GetKeyName ( sym )
855         int sym
856         CODE:
857                 RETVAL = SDL_GetKeyName(sym);
858         OUTPUT:
859                 RETVAL
860
861 =for comment
862
863 Comment out for now as it does not compile
864
865 SDL_Surface *
866 CreateRGBSurfaceFrom (pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask )
867         char *pixels
868         int width
869         int height
870         int depth
871         int pitch
872         Uint32 Rmask
873         Uint32 Gmask
874         Uint32 Bmask
875         Uint32 Amask
876         CODE:
877                 Uint8* pixeldata;
878                 Uint32 len = pitch * height;
879                 New(0,pixeldata,len,Uint8);
880                 Copy(pixels,pixeldata,len,Uint8);
881                 RETVAL = SDL_CreateRGBSurfaceFrom ( pixeldata, width, height,
882                                 depth, pitch, Rmask, Gmask, Bmask, Amask );
883         OUTPUT: 
884                 RETVAL
885
886 #ifdef HAVE_SDL_IMAGE
887
888 SDL_Surface *
889 IMGLoad ( fname )
890         char *fname
891         CODE:
892                 RETVAL = IMG_Load(fname);
893         OUTPUT:
894                 RETVAL
895
896 #endif
897
898 SDL_Surface*
899 SurfaceCopy ( surface )
900         SDL_Surface *surface
901         CODE:
902                 Uint8* pixels;
903                 Uint32 size = surface->pitch * surface->h;
904                 New(0,pixels,size,Uint8);
905                 Copy(surface->pixels,pixels,size,Uint8);
906                 RETVAL = SDL_CreateRGBSurfaceFrom(pixels,surface->w,surface->h,
907                         surface->format->BitsPerPixel, surface->pitch,
908                         surface->format->Rmask, surface->format->Gmask,
909                         surface->format->Bmask, surface->format->Amask);
910         OUTPUT:
911                 RETVAL
912
913 void
914 FreeSurface ( surface )
915         SDL_Surface *surface
916         CODE:
917                 if (surface) {
918                         Uint8* pixels = surface->pixels;
919                         Uint32 flags = surface->flags;
920                         SDL_FreeSurface(surface);
921                         if (flags & SDL_PREALLOC)
922                                 Safefree(pixels);
923                 }
924         
925 Uint32
926 SurfaceFlags ( surface )
927         SDL_Surface *surface
928         CODE:
929                 RETVAL = surface->flags;
930         OUTPUT:
931                 RETVAL
932
933 SDL_Palette *
934 SurfacePalette ( surface )
935         SDL_Surface *surface
936         CODE:
937                 RETVAL = surface->format->palette;
938         OUTPUT:
939                 RETVAL
940
941 Uint8
942 SurfaceBitsPerPixel ( surface )
943         SDL_Surface *surface
944         CODE:
945                 RETVAL = surface->format->BitsPerPixel;
946         OUTPUT:
947                 RETVAL
948
949 Uint8
950 SurfaceBytesPerPixel ( surface )
951         SDL_Surface *surface
952         CODE:   
953                 RETVAL = surface->format->BytesPerPixel;
954         OUTPUT:
955                 RETVAL
956
957 Uint8
958 SurfaceRshift ( surface )
959         SDL_Surface *surface
960         CODE:
961                 RETVAL = surface->format->Rshift;
962         OUTPUT:
963                 RETVAL
964
965 Uint8
966 SurfaceGshift ( surface )
967         SDL_Surface *surface
968         CODE:
969                 RETVAL = surface->format->Gshift;
970         OUTPUT:
971                 RETVAL
972
973 Uint8
974 SurfaceBshift ( surface )
975         SDL_Surface *surface
976         CODE:
977                 RETVAL = surface->format->Bshift;
978         OUTPUT:
979                 RETVAL
980
981 Uint8
982 SurfaceAshift ( surface )
983         SDL_Surface *surface
984         CODE:
985                 RETVAL = surface->format->Ashift;
986         OUTPUT:
987                 RETVAL
988
989 Uint32
990 SurfaceRmask( surface )
991         SDL_Surface *surface
992         CODE:
993                 RETVAL = surface->format->Rmask;
994         OUTPUT:
995                 RETVAL
996
997 Uint32
998 SurfaceGmask ( surface )
999         SDL_Surface *surface
1000         CODE:
1001                 RETVAL = surface->format->Gmask;
1002         OUTPUT:
1003                 RETVAL
1004
1005 Uint32
1006 SurfaceBmask ( surface )
1007         SDL_Surface *surface
1008         CODE:
1009                 RETVAL = surface->format->Bmask;
1010         OUTPUT:
1011                 RETVAL
1012
1013 Uint32
1014 SurfaceAmask ( surface )
1015         SDL_Surface *surface
1016         CODE:
1017                 RETVAL = surface->format->Amask;
1018         OUTPUT:
1019                 RETVAL
1020
1021 Uint32
1022 SurfaceColorKey ( surface )
1023         SDL_Surface *surface
1024         CODE:
1025                 RETVAL = surface->format->colorkey;
1026         OUTPUT:
1027                 RETVAL
1028
1029 Uint32
1030 SurfaceAlpha( surface )
1031         SDL_Surface *surface
1032         CODE:
1033                 RETVAL = surface->format->alpha;
1034         OUTPUT:
1035                 RETVAL
1036
1037 int
1038 SurfaceW ( surface )
1039         SDL_Surface *surface
1040         CODE:   
1041                 RETVAL = surface->w;
1042         OUTPUT:
1043                 RETVAL
1044
1045 int
1046 SurfaceH ( surface )
1047         SDL_Surface *surface
1048         CODE:   
1049                 RETVAL = surface->h;
1050         OUTPUT:
1051                 RETVAL
1052
1053 Uint16
1054 SurfacePitch ( surface )
1055         SDL_Surface *surface
1056         CODE:   
1057                 RETVAL = surface->pitch;
1058         OUTPUT:
1059                 RETVAL
1060
1061 SV*
1062 SurfacePixels ( surface )
1063         SDL_Surface *surface
1064         CODE:   
1065                 RETVAL = newSVpvn(surface->pixels,surface->pitch*surface->h);
1066         OUTPUT:
1067                 RETVAL
1068
1069 =cut
1070
1071 =for comment
1072
1073 Comment out for now as it does not compile
1074
1075 SDL_Color*
1076 SurfacePixel ( surface, x, y, ... )
1077         SDL_Surface *surface
1078         Sint32 x
1079         Sint32 y
1080         CODE:
1081                 SDL_Color* color;
1082                 int pix,index;
1083                 Uint8 r,g,b,a;
1084                 int bpp = surface->format->BytesPerPixel;
1085                 Uint8* p = (Uint8*)surface->pixels + bpp*x + surface->pitch*y;
1086                 if ( items < 3 || items > 4 ) 
1087                         Perl_croak(aTHX_ "usage: SDL::SurfacePixel(surface,x,y,[color])");
1088                 if ( items == 4) {
1089                         color = (SDL_Color*)SvIV(ST(3));
1090                         pix = SDL_MapRGB(surface->format,color->r,color->g,color->b);
1091                         switch(bpp) {
1092                                 case 1:
1093                                         *(Uint8*)p = pix;
1094                                         break;
1095                                 case 2:
1096                                         *(Uint16*)p = pix;
1097                                         break;
1098                                 case 3:
1099                                         if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
1100                                                 p[0] = (pix >> 16) & 0xff;
1101                                                 p[1] = (pix >> 8) & 0xff;
1102                                                 p[2] = pix & 0xff;
1103                                         } else {
1104                                                 p[0] = pix & 0xff;
1105                                                 p[1] = (pix >> 8) & 0xff;
1106                                                 p[2] = (pix >> 16) & 0xff;
1107                                         }
1108                                         break;
1109                                 case 4:
1110                                         *(Uint32*)p = pix;
1111                                         break;
1112                         }
1113                 }
1114                 RETVAL = (SDL_Color *) safemalloc(sizeof(SDL_Color));
1115                 switch(bpp) {
1116                         case 1:
1117                                 index = *(Uint8*)p;
1118                                 memcpy(RETVAL,&surface->format->palette[index],sizeof(SDL_Color));
1119                                 break;
1120                         case 2:
1121                                 pix = *(Uint16*)p;
1122                                 SDL_GetRGB(pix,surface->format,&r,&g,&b);
1123                                 RETVAL->r = r;
1124                                 RETVAL->g = g;
1125                                 RETVAL->b = b;
1126                                 break;
1127                         case 3:
1128                         case 4:
1129                                 pix = *(Uint32*)p;
1130                                 SDL_GetRGB(pix,surface->format,&r,&g,&b);
1131                                 RETVAL->r = r;
1132                                 RETVAL->g = g;
1133                                 RETVAL->b = b;
1134                                 break;
1135                 }
1136         OUTPUT:
1137                 RETVAL
1138
1139 int
1140 MUSTLOCK ( surface )
1141         SDL_Surface *surface
1142         CODE:
1143                 RETVAL = SDL_MUSTLOCK(surface);
1144         OUTPUT:
1145                 RETVAL          
1146
1147 int
1148 SurfaceLock ( surface )
1149         SDL_Surface *surface
1150         CODE:
1151                 RETVAL = SDL_LockSurface(surface);
1152         OUTPUT:
1153                 RETVAL
1154
1155 void
1156 SurfaceUnlock ( surface )
1157         SDL_Surface *surface
1158         CODE:
1159                 SDL_UnlockSurface(surface);
1160
1161 SDL_Surface *
1162 GetVideoSurface ()
1163         CODE:
1164                 RETVAL = SDL_GetVideoSurface();
1165         OUTPUT:
1166                 RETVAL
1167
1168 =cut
1169
1170 HV *
1171 VideoInfo ()
1172         CODE:
1173                 HV *hv;
1174                 SDL_VideoInfo *info;
1175                 info = (SDL_VideoInfo *) safemalloc ( sizeof(SDL_VideoInfo));
1176                 memcpy(info,SDL_GetVideoInfo(),sizeof(SDL_VideoInfo));
1177                 hv = newHV();
1178                 hv_store(hv,"hw_available",strlen("hw_available"),
1179                         newSViv(info->hw_available),0);
1180                 hv_store(hv,"wm_available",strlen("wm_available"),
1181                         newSViv(info->wm_available),0);
1182                 hv_store(hv,"blit_hw",strlen("blit_hw"),
1183                         newSViv(info->blit_hw),0);
1184                 hv_store(hv,"blit_hw_CC",strlen("blit_hw_CC"),
1185                         newSViv(info->blit_hw_CC),0);
1186                 hv_store(hv,"blit_hw_A",strlen("blit_hw_A"),
1187                         newSViv(info->blit_hw_A),0);
1188                 hv_store(hv,"blit_sw",strlen("blit_sw"),
1189                         newSViv(info->blit_sw),0);
1190                 hv_store(hv,"blit_sw_CC",strlen("blit_sw_CC"),
1191                         newSViv(info->blit_sw_CC),0);
1192                 hv_store(hv,"blit_sw_A",strlen("blit_sw_A"),
1193                         newSViv(info->blit_sw_A),0);
1194                 hv_store(hv,"blit_fill",strlen("blit_fill"),
1195                         newSViv(info->blit_fill),0);
1196                 hv_store(hv,"video_mem",strlen("video_mem"),
1197                         newSViv(info->video_mem),0);
1198                 RETVAL = hv;
1199         OUTPUT:
1200                 RETVAL
1201
1202 AV*
1203 ListModes ( format, flags )
1204         Uint32 flags
1205         SDL_PixelFormat *format
1206         CODE:
1207                 SDL_Rect **mode;
1208                 RETVAL = newAV();
1209                 mode = SDL_ListModes(format,flags);
1210                 if (mode == (SDL_Rect**)-1 ) {
1211                         av_push(RETVAL,newSVpv("all",0));
1212                 } else if (! mode ) {
1213                         av_push(RETVAL,newSVpv("none",0));
1214                 } else {
1215                         for (;*mode;mode++) {
1216                                 av_push(RETVAL,newSViv(PTR2IV(*mode)));
1217                         }
1218                 }
1219         OUTPUT:
1220                 RETVAL
1221
1222 SDL_Palette *
1223 NewPalette ( number )
1224         int number
1225         CODE:
1226                 RETVAL = (SDL_Palette *)safemalloc(sizeof(SDL_Palette));
1227                 RETVAL->colors = (SDL_Color *)safemalloc(number * 
1228                                                 sizeof(SDL_Color));
1229                 RETVAL->ncolors = number;
1230         OUTPUT:
1231                 RETVAL
1232
1233 int
1234 PaletteNColors ( palette, ... )
1235         SDL_Palette *palette
1236         CODE:
1237                 if ( items > 1 ) palette->ncolors = SvIV(ST(1));
1238                 RETVAL = palette->ncolors;
1239         OUTPUT:
1240                 RETVAL
1241
1242 SDL_Surface *
1243 SetVideoMode ( CLASS, width, height, bpp, flags )
1244         char* CLASS
1245         int width
1246         int height
1247         int bpp
1248         Uint32 flags
1249
1250         CODE:
1251                 RETVAL = SDL_SetVideoMode(width,height,bpp,flags);
1252         OUTPUT:
1253                 RETVAL
1254
1255 int
1256 Flip ( surface )
1257         SDL_Surface *surface
1258         CODE:
1259                 RETVAL = SDL_Flip(surface);
1260         OUTPUT:
1261                 RETVAL
1262
1263
1264 =for comment
1265
1266 Comment out for now as it does not compile
1267
1268 SDL_Color *
1269 PaletteColors ( palette, index, ... )
1270         SDL_Palette *palette
1271         int index
1272         CODE:
1273                 if ( items > 2 ) {
1274                         palette->colors[index].r = SvUV(ST(2)); 
1275                         palette->colors[index].g = SvUV(ST(3)); 
1276                         palette->colors[index].b = SvUV(ST(4)); 
1277                 }
1278                 RETVAL = (SDL_Color *)(palette->colors + index);
1279         OUTPUT:
1280                 RETVAL
1281
1282
1283
1284 int
1285 VideoModeOK ( width, height, bpp, flags )
1286         int width
1287         int height
1288         int bpp
1289         Uint32 flags
1290         CODE:
1291                 RETVAL = SDL_VideoModeOK(width,height,bpp,flags);
1292         OUTPUT:
1293                 RETVAL
1294
1295 SDL_Surface *
1296 SetVideoMode ( width, height, bpp, flags )
1297         int width
1298         int height
1299         int bpp
1300         Uint32 flags
1301         CODE:
1302                 RETVAL = SDL_SetVideoMode(width,height,bpp,flags);
1303         OUTPUT:
1304                 RETVAL
1305
1306 void
1307 UpdateRect ( surface, x, y, w ,h )
1308         SDL_Surface *surface
1309         int x
1310         int y
1311         int w
1312         int h
1313         CODE:
1314                 SDL_UpdateRect(surface,x,y,w,h);
1315
1316 void
1317 UpdateRects ( surface, ... )
1318         SDL_Surface *surface
1319         CODE:
1320                 SDL_Rect *rects, *temp;
1321                 int num_rects,i;
1322                 if ( items < 2 ) return;
1323                 num_rects = items - 1;
1324                 SDL_UpdateRects(surface,num_rects,rects);                       
1325                 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
1326                 for(i=0;i<num_rects;i++) {
1327                         temp = (SDL_Rect *)SvIV(ST(i+1));
1328                         rects[i].x = temp->x;
1329                         rects[i].y = temp->y;
1330                         rects[i].w = temp->w;
1331                         rects[i].h = temp->h;
1332                 } 
1333                 SDL_UpdateRects(surface,num_rects,rects);
1334                 safefree(rects);
1335
1336 int
1337 Flip ( surface )
1338         SDL_Surface *surface
1339         CODE:
1340                 RETVAL = SDL_Flip(surface);
1341         OUTPUT:
1342                 RETVAL
1343
1344 int
1345 SetColors ( surface, start, ... )
1346         SDL_Surface *surface
1347         int start
1348         CODE:
1349                 SDL_Color *colors,*temp;
1350                 int i, length;
1351                 if ( items < 3 ) { RETVAL = 0;  goto all_done; }
1352                 length = items - 2;
1353                 colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1));
1354                 for ( i = 0; i < length ; i++ ) {
1355                         temp = (SDL_Color *)SvIV(ST(i+2));
1356                         colors[i].r = temp->r;
1357                         colors[i].g = temp->g;
1358                         colors[i].b = temp->b;
1359                 }
1360                 RETVAL = SDL_SetColors(surface, colors, start, length );
1361                 safefree(colors);
1362 all_done:
1363         OUTPUT: 
1364                 RETVAL
1365
1366 Uint32
1367 MapRGB ( surface, r, g, b )
1368         SDL_Surface *surface
1369         Uint8 r
1370         Uint8 g
1371         Uint8 b
1372         CODE:
1373                 RETVAL = SDL_MapRGB(surface->format,r,g,b);
1374         OUTPUT:
1375                 RETVAL
1376
1377 Uint32
1378 MapRGBA ( surface, r, g, b, a )
1379         SDL_Surface *surface
1380         Uint8 r
1381         Uint8 g
1382         Uint8 b
1383         Uint8 a
1384         CODE:
1385                 RETVAL = SDL_MapRGBA(surface->format,r,g,b,a);
1386         OUTPUT:
1387                 RETVAL
1388
1389 AV *
1390 GetRGB ( surface, pixel )
1391         SDL_Surface *surface
1392         Uint32 pixel
1393         CODE:
1394                 Uint8 r,g,b;
1395                 SDL_GetRGB(pixel,surface->format,&r,&g,&b);
1396                 RETVAL = newAV();
1397                 av_push(RETVAL,newSViv(r));
1398                 av_push(RETVAL,newSViv(g));
1399                 av_push(RETVAL,newSViv(b));
1400         OUTPUT:
1401                 RETVAL
1402
1403 AV *
1404 GetRGBA ( surface, pixel )
1405         SDL_Surface *surface
1406         Uint32 pixel
1407         CODE:
1408                 Uint8 r,g,b,a;
1409                 SDL_GetRGBA(pixel,surface->format,&r,&g,&b,&a);
1410                 RETVAL = newAV();
1411                 av_push(RETVAL,newSViv(r));
1412                 av_push(RETVAL,newSViv(g));
1413                 av_push(RETVAL,newSViv(b));
1414                 av_push(RETVAL,newSViv(a));
1415         OUTPUT:
1416                 RETVAL
1417
1418 int
1419 SaveBMP ( surface, filename )
1420         SDL_Surface *surface
1421         char *filename
1422         CODE:
1423                 RETVAL = SDL_SaveBMP(surface,filename);
1424         OUTPUT:
1425                 RETVAL  
1426
1427 int
1428 SetColorKey ( surface, flag, key )
1429         SDL_Surface *surface
1430         Uint32 flag
1431         SDL_Color *key
1432         CODE:
1433                 Uint32 pixel = SDL_MapRGB(surface->format,key->r,key->g,key->b);
1434                 RETVAL = SDL_SetColorKey(surface,flag,pixel);
1435         OUTPUT:
1436                 RETVAL
1437
1438 int
1439 SetAlpha ( surface, flag, alpha )
1440         SDL_Surface *surface
1441         Uint32 flag
1442         Uint8 alpha
1443         CODE:
1444                 RETVAL = SDL_SetAlpha(surface,flag,alpha);
1445         OUTPUT:
1446                 RETVAL
1447
1448 SDL_Surface *
1449 DisplayFormat ( surface )
1450         SDL_Surface *surface
1451         CODE:
1452                 RETVAL = SDL_DisplayFormat(surface);
1453         OUTPUT:
1454                 RETVAL
1455
1456 SDL_Surface*
1457 DisplayFormatAlpha ( surface )
1458         SDL_Surface *surface
1459         CODE:
1460                 RETVAL = SDL_DisplayFormatAlpha(surface);
1461         OUTPUT:
1462                 RETVAL
1463
1464 SDL_Surface*
1465 ConvertRGB ( surface )
1466         SDL_Surface * surface
1467         CODE:
1468                 SDL_PixelFormat fmt;
1469                 fmt.palette = NULL;
1470                 fmt.BitsPerPixel = 24;
1471                 fmt.BytesPerPixel = 3;
1472                 fmt.Rmask = 0x000000ff;
1473                 fmt.Gmask = 0x0000ff00;
1474                 fmt.Bmask = 0x00ff0000;
1475                 fmt.Amask = 0x00000000;
1476                 fmt.Rloss = 0;
1477                 fmt.Gloss = 0;
1478                 fmt.Bloss = 0;
1479                 fmt.Aloss = 0;
1480                 fmt.Rshift = 0;
1481                 fmt.Gshift = 8;
1482                 fmt.Bshift = 16;
1483                 fmt.Ashift = 24;
1484                 fmt.colorkey = 0;
1485                 fmt.alpha = 0;
1486                 RETVAL = SDL_ConvertSurface(surface,&fmt,surface->flags);
1487         OUTPUT:
1488                 RETVAL
1489
1490 SDL_Surface* 
1491 ConvertRGBA ( surface )
1492         SDL_Surface * surface
1493         CODE:
1494                 SDL_PixelFormat fmt;
1495                 fmt.palette = NULL;
1496                 fmt.BitsPerPixel = 32;
1497                 fmt.BytesPerPixel = 4;
1498                 fmt.Rmask = 0x000000ff;
1499                 fmt.Gmask = 0x0000ff00;
1500                 fmt.Bmask = 0x00ff0000;
1501                 fmt.Amask = 0xff000000;
1502                 fmt.Rloss = 0;
1503                 fmt.Gloss = 0;
1504                 fmt.Bloss = 0;
1505                 fmt.Aloss = 0;
1506                 fmt.Rshift = 0;
1507                 fmt.Gshift = 8;
1508                 fmt.Bshift = 16;
1509                 fmt.Ashift = 24;
1510                 fmt.colorkey = 0;
1511                 fmt.alpha = 0;
1512                 RETVAL = SDL_ConvertSurface(surface,&fmt,surface->flags);
1513         OUTPUT:
1514                 RETVAL
1515
1516 int
1517 BlitSurface ( src, src_rect, dest, dest_rect )
1518         SDL_Surface *src
1519
1520         SDL_Surface *dest
1521
1522         SDL_Rect *src_rect
1523
1524         SDL_Rect *dest_rect
1525         CODE:
1526                 RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect);
1527         OUTPUT:
1528                 RETVAL
1529
1530 =cut
1531
1532 int
1533 FillRect ( dest, dest_rect, color )
1534         SDL_Surface *dest
1535         
1536         SDL_Color *color
1537         
1538         SDL_Rect *dest_rect
1539
1540         CODE:
1541                 Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b);
1542                 RETVAL = SDL_FillRect(dest,dest_rect,pixel);
1543         OUTPUT:
1544                 RETVAL
1545
1546 Uint8
1547 GetAppState ()
1548         CODE:
1549                 RETVAL = SDL_GetAppState();
1550         OUTPUT:
1551                 RETVAL
1552
1553
1554 void
1555 WMSetCaption ( title, icon )
1556         char *title
1557         char *icon
1558         CODE:
1559                 SDL_WM_SetCaption(title,icon);
1560
1561 AV *
1562 WMGetCaption ()
1563         CODE:
1564                 char *title,*icon;
1565                 SDL_WM_GetCaption(&title,&icon);
1566                 RETVAL = newAV();
1567                 av_push(RETVAL,newSVpv(title,0));
1568                 av_push(RETVAL,newSVpv(icon,0));
1569         OUTPUT:
1570                 RETVAL
1571
1572 void
1573 WMSetIcon ( icon )
1574         SDL_Surface *icon
1575         CODE:
1576                 SDL_WM_SetIcon(icon,NULL);
1577
1578 void
1579 WarpMouse ( x, y )
1580         Uint16 x
1581         Uint16 y
1582         CODE:
1583                 SDL_WarpMouse(x,y);
1584
1585 AV*
1586 GetMouseState ()
1587         CODE:
1588                 Uint8 mask;
1589                 int x;
1590                 int y;
1591                 mask = SDL_GetMouseState(&x,&y);
1592                 RETVAL = newAV();
1593                 av_push(RETVAL,newSViv(mask));
1594                 av_push(RETVAL,newSViv(x));
1595                 av_push(RETVAL,newSViv(y));
1596         OUTPUT:
1597                 RETVAL  
1598
1599 AV*
1600 GetRelativeMouseState ()
1601         CODE:
1602                 Uint8 mask;
1603                 int x;
1604                 int y;
1605                 mask = SDL_GetRelativeMouseState(&x,&y);
1606                 RETVAL = newAV();
1607                 av_push(RETVAL,newSViv(mask));
1608                 av_push(RETVAL,newSViv(x));
1609                 av_push(RETVAL,newSViv(y));
1610         OUTPUT:
1611                 RETVAL  
1612
1613 SDL_Cursor *
1614 NewCursor ( data, mask, x ,y )
1615         SDL_Surface *data
1616         SDL_Surface *mask
1617         int x
1618         int y
1619         CODE:
1620                 RETVAL = SDL_CreateCursor((Uint8*)data->pixels,
1621                                 (Uint8*)mask->pixels,data->w,data->h,x,y);
1622         OUTPUT:
1623                 RETVAL
1624
1625 void
1626 FreeCursor ( cursor )
1627         SDL_Cursor *cursor
1628         CODE:
1629                 SDL_FreeCursor(cursor);
1630
1631 void
1632 SetCursor ( cursor )
1633         SDL_Cursor *cursor
1634         CODE:
1635                 SDL_SetCursor(cursor);
1636
1637 SDL_Cursor *
1638 GetCursor ()
1639         CODE:
1640                 RETVAL = SDL_GetCursor();
1641         OUTPUT:
1642                 RETVAL
1643
1644 int
1645 ShowCursor ( toggle )
1646         int toggle
1647         CODE:
1648                 RETVAL = SDL_ShowCursor(toggle);
1649         OUTPUT: 
1650                 RETVAL
1651
1652 SDL_AudioSpec *
1653 NewAudioSpec ( freq, format, channels, samples )
1654         int freq
1655         Uint16 format
1656         Uint8 channels
1657         Uint16 samples
1658         CODE:
1659                 RETVAL = (SDL_AudioSpec *)safemalloc(sizeof(SDL_AudioSpec));
1660                 RETVAL->freq = freq;
1661                 RETVAL->format = format;
1662                 RETVAL->channels = channels;
1663                 RETVAL->samples = samples;
1664         OUTPUT:
1665                 RETVAL
1666
1667 void
1668 FreeAudioSpec ( spec )
1669         SDL_AudioSpec *spec
1670         CODE:
1671                 safefree(spec);
1672
1673 SDL_AudioCVT *
1674 NewAudioCVT ( src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate)
1675         Uint16 src_format
1676         Uint8 src_channels
1677         int src_rate
1678         Uint16 dst_format
1679         Uint8 dst_channels
1680         int dst_rate
1681         CODE:
1682                 RETVAL = (SDL_AudioCVT *)safemalloc(sizeof(SDL_AudioCVT));
1683                 if (SDL_BuildAudioCVT(RETVAL,src_format, src_channels, src_rate,
1684                         dst_format, dst_channels, dst_rate)) { 
1685                         safefree(RETVAL); RETVAL = NULL; }
1686         OUTPUT:
1687                 RETVAL
1688
1689 void
1690 FreeAudioCVT ( cvt )
1691         SDL_AudioCVT *cvt
1692         CODE:
1693                 safefree(cvt);
1694
1695 int
1696 ConvertAudioData ( cvt, data, len )
1697         SDL_AudioCVT *cvt
1698         Uint8 *data
1699         int len
1700         CODE:
1701                 cvt->len = len;
1702                 cvt->buf = (Uint8*) safemalloc(cvt->len*cvt->len_mult);
1703                 memcpy(cvt->buf,data,cvt->len);
1704                 RETVAL = SDL_ConvertAudio(cvt);
1705         OUTPUT:
1706                 RETVAL                  
1707
1708 int
1709 OpenAudio ( spec, callback )
1710         SDL_AudioSpec *spec
1711         SV* callback
1712         CODE:
1713                 spec->userdata = (void*)callback;
1714                 spec->callback = sdl_perl_audio_callback;
1715                 RETVAL = SDL_OpenAudio(spec,NULL);
1716         OUTPUT:
1717                 RETVAL
1718
1719 Uint32
1720 GetAudioStatus ()
1721         CODE:
1722                 RETVAL = SDL_GetAudioStatus ();
1723         OUTPUT:
1724                 RETVAL
1725
1726 void
1727 PauseAudio ( p_on )
1728         int p_on
1729         CODE:
1730                 SDL_PauseAudio(p_on);
1731         
1732 void
1733 LockAudio ()
1734         CODE:
1735                 SDL_LockAudio();
1736
1737 void
1738 UnlockAudio ()
1739         CODE:
1740                 SDL_UnlockAudio();
1741
1742 void
1743 CloseAudio ()
1744         CODE:
1745                 SDL_CloseAudio();
1746
1747 void
1748 FreeWAV ( buf )
1749         Uint8 *buf
1750         CODE:
1751                 SDL_FreeWAV(buf);
1752
1753 AV *
1754 LoadWAV ( filename, spec )
1755         char *filename
1756         SDL_AudioSpec *spec
1757         CODE:
1758                 SDL_AudioSpec *temp;
1759                 Uint8 *buf;
1760                 Uint32 len;
1761
1762                 RETVAL = newAV();
1763                 temp = SDL_LoadWAV(filename,spec,&buf,&len);
1764                 if ( ! temp ) goto error;
1765                 av_push(RETVAL,newSViv(PTR2IV(temp)));
1766                 av_push(RETVAL,newSViv(PTR2IV(buf)));
1767                 av_push(RETVAL,newSViv(len));
1768 error:
1769         OUTPUT:
1770                 RETVAL
1771         
1772 #ifdef HAVE_SDL_MIXER
1773
1774 void
1775 MixAudio ( dst, src, len, volume )
1776         Uint8 *dst
1777         Uint8 *src
1778         Uint32 len
1779         int volume
1780         CODE:
1781                 SDL_MixAudio(dst,src,len,volume);
1782
1783 int
1784 MixOpenAudio ( frequency, format, channels, chunksize )
1785         int frequency
1786         Uint16 format
1787         int channels
1788         int chunksize   
1789         CODE:
1790                 RETVAL = Mix_OpenAudio(frequency, format, channels, chunksize);
1791         OUTPUT:
1792                 RETVAL
1793
1794 int
1795 MixAllocateChannels ( number )
1796         int number
1797         CODE:
1798                 RETVAL = Mix_AllocateChannels(number);
1799         OUTPUT:
1800                 RETVAL
1801
1802 AV *
1803 MixQuerySpec ()
1804         CODE:
1805                 int freq, channels, status;
1806                 Uint16 format;
1807                 status = Mix_QuerySpec(&freq,&format,&channels);
1808                 RETVAL = newAV();
1809                 av_push(RETVAL,newSViv(status));
1810                 av_push(RETVAL,newSViv(freq));
1811                 av_push(RETVAL,newSViv(format));
1812                 av_push(RETVAL,newSViv(channels));
1813         OUTPUT:
1814                 RETVAL
1815
1816 Mix_Chunk *
1817 MixLoadWAV ( filename )
1818         char *filename
1819         CODE:
1820                 RETVAL = Mix_LoadWAV(filename);
1821         OUTPUT:
1822                 RETVAL
1823
1824 Mix_Music *
1825 MixLoadMusic ( filename )
1826         char *filename
1827         CODE:
1828                 RETVAL = Mix_LoadMUS(filename);
1829         OUTPUT:
1830                 RETVAL
1831
1832 Mix_Chunk *
1833 MixQuickLoadWAV ( buf )
1834         Uint8 *buf
1835         CODE:
1836                 RETVAL = Mix_QuickLoad_WAV(buf);
1837         OUTPUT:
1838                 RETVAL
1839
1840 void
1841 MixFreeChunk( chunk )
1842         Mix_Chunk *chunk
1843         CODE:
1844                 Mix_FreeChunk(chunk);
1845
1846 void
1847 MixFreeMusic ( music )
1848         Mix_Music *music
1849         CODE:
1850                 Mix_FreeMusic(music);
1851
1852 void
1853 MixSetPostMixCallback ( func, arg )
1854         void *func
1855         void *arg
1856         CODE:
1857                 Mix_SetPostMix(func,arg);
1858
1859 void*
1860 PerlMixMusicHook ()
1861         CODE:
1862                 RETVAL = sdl_perl_music_callback;
1863         OUTPUT:
1864                 RETVAL
1865
1866 void
1867 MixSetMusicHook ( func, arg )
1868         void *func
1869         void *arg
1870         CODE:
1871                 Mix_HookMusic(func,arg);
1872
1873 void
1874 MixSetMusicFinishedHook ( func )
1875         void *func
1876         CODE:
1877                 mix_music_finished_cv = func;
1878                 Mix_HookMusicFinished(sdl_perl_music_finished_callback);
1879
1880 void *
1881 MixGetMusicHookData ()
1882         CODE:
1883                 RETVAL = Mix_GetMusicHookData();
1884         OUTPUT:
1885                 RETVAL
1886
1887 int
1888 MixReverseChannels ( number )
1889         int number
1890         CODE:
1891                 RETVAL = Mix_ReserveChannels ( number );
1892         OUTPUT:
1893                 RETVAL
1894
1895 int
1896 MixGroupChannel ( which, tag )
1897         int which
1898         int tag
1899         CODE:
1900                 RETVAL = Mix_GroupChannel(which,tag);
1901         OUTPUT:
1902                 RETVAL
1903
1904 int
1905 MixGroupChannels ( from, to, tag )
1906         int from
1907         int to
1908         int tag
1909         CODE:
1910                 RETVAL = Mix_GroupChannels(from,to,tag);
1911         OUTPUT:
1912                 RETVAL
1913
1914 int
1915 MixGroupAvailable ( tag )
1916         int tag
1917         CODE:
1918                 RETVAL = Mix_GroupAvailable(tag);
1919         OUTPUT:
1920                 RETVAL
1921
1922 int
1923 MixGroupCount ( tag )
1924         int tag
1925         CODE:
1926                 RETVAL = Mix_GroupCount(tag);
1927         OUTPUT:
1928                 RETVAL
1929
1930 int
1931 MixGroupOldest ( tag )
1932         int tag
1933         CODE:
1934                 RETVAL = Mix_GroupOldest(tag);
1935         OUTPUT:
1936                 RETVAL
1937
1938 int
1939 MixGroupNewer ( tag )
1940         int tag
1941         CODE:
1942                 RETVAL = Mix_GroupNewer(tag);
1943         OUTPUT:
1944                 RETVAL
1945
1946 int
1947 MixPlayChannel ( channel, chunk, loops )
1948         int channel
1949         Mix_Chunk *chunk
1950         int loops
1951         CODE:
1952                 RETVAL = Mix_PlayChannel(channel,chunk,loops);
1953         OUTPUT:
1954                 RETVAL
1955
1956 int
1957 MixPlayChannelTimed ( channel, chunk, loops, ticks )
1958         int channel
1959         Mix_Chunk *chunk
1960         int loops
1961         int ticks
1962         CODE:
1963                 RETVAL = Mix_PlayChannelTimed(channel,chunk,loops,ticks);
1964         OUTPUT:
1965                 RETVAL
1966
1967 int
1968 MixPlayMusic ( music, loops )
1969         Mix_Music *music
1970         int loops
1971         CODE:
1972                 RETVAL = Mix_PlayMusic(music,loops);
1973         OUTPUT:
1974                 RETVAL
1975
1976 int
1977 MixFadeInChannel ( channel, chunk, loops, ms )
1978         int channel
1979         Mix_Chunk *chunk
1980         int loops
1981         int ms
1982         CODE:
1983                 RETVAL = Mix_FadeInChannel(channel,chunk,loops,ms);
1984         OUTPUT:
1985                 RETVAL
1986
1987 int
1988 MixFadeInChannelTimed ( channel, chunk, loops, ms, ticks )
1989         int channel
1990         Mix_Chunk *chunk
1991         int loops
1992         int ticks
1993         int ms
1994         CODE:
1995                 RETVAL = Mix_FadeInChannelTimed(channel,chunk,loops,ms,ticks);
1996         OUTPUT:
1997                 RETVAL
1998
1999 int
2000 MixFadeInMusic ( music, loops, ms )
2001         Mix_Music *music
2002         int loops
2003         int ms
2004         CODE:
2005                 RETVAL = Mix_FadeInMusic(music,loops,ms);
2006         OUTPUT:
2007                 RETVAL
2008
2009 int
2010 MixVolume ( channel, volume )
2011         int channel
2012         int volume
2013         CODE:   
2014                 RETVAL = Mix_Volume(channel,volume);
2015         OUTPUT:
2016                 RETVAL
2017
2018 int
2019 MixVolumeChunk ( chunk, volume )
2020         Mix_Chunk *chunk
2021         int volume
2022         CODE:
2023                 RETVAL = Mix_VolumeChunk(chunk,volume);
2024         OUTPUT:
2025                 RETVAL
2026
2027 int
2028 MixVolumeMusic ( volume )
2029         int volume
2030         CODE:
2031                 RETVAL = Mix_VolumeMusic(volume);
2032         OUTPUT:
2033                 RETVAL
2034
2035 int
2036 MixHaltChannel ( channel )
2037         int channel
2038         CODE:
2039                 RETVAL = Mix_HaltChannel(channel);
2040         OUTPUT:
2041                 RETVAL
2042
2043 int
2044 MixHaltGroup ( tag )
2045         int tag
2046         CODE:
2047                 RETVAL = Mix_HaltGroup(tag);
2048         OUTPUT:
2049                 RETVAL
2050
2051 int
2052 MixHaltMusic ()
2053         CODE:
2054                 RETVAL = Mix_HaltMusic();
2055         OUTPUT:
2056                 RETVAL
2057
2058 int
2059 MixExpireChannel ( channel, ticks )
2060         int channel
2061         int ticks
2062         CODE:
2063                 RETVAL = Mix_ExpireChannel ( channel,ticks);
2064         OUTPUT:
2065                 RETVAL
2066
2067 int
2068 MixFadeOutChannel ( which, ms )
2069         int which
2070         int ms
2071         CODE:
2072                 RETVAL = Mix_FadeOutChannel(which,ms);
2073         OUTPUT:
2074                 RETVAL
2075
2076 int
2077 MixFadeOutGroup ( which, ms )
2078         int which
2079         int ms
2080         CODE:
2081                 RETVAL = Mix_FadeOutGroup(which,ms);
2082         OUTPUT:
2083                 RETVAL
2084
2085 int
2086 MixFadeOutMusic ( ms )
2087         int ms
2088         CODE:
2089                 RETVAL = Mix_FadeOutMusic(ms);
2090         OUTPUT:
2091                 RETVAL
2092
2093 Mix_Fading
2094 MixFadingMusic()
2095         CODE:
2096                 RETVAL = Mix_FadingMusic();
2097         OUTPUT:
2098                 RETVAL
2099
2100 Mix_Fading
2101 MixFadingChannel( which )
2102         int which
2103         CODE:
2104                 RETVAL = Mix_FadingChannel(which);
2105         OUTPUT:
2106                 RETVAL
2107
2108 void
2109 MixPause ( channel )
2110         int channel
2111         CODE:
2112                 Mix_Pause(channel);
2113
2114 void
2115 MixResume ( channel )
2116         int channel
2117         CODE:
2118                 Mix_Resume(channel);
2119
2120 int
2121 MixPaused ( channel )
2122         int channel
2123         CODE:
2124                 RETVAL = Mix_Paused(channel);
2125         OUTPUT:
2126                 RETVAL
2127
2128 void
2129 MixPauseMusic ()
2130         CODE:
2131                 Mix_PauseMusic();
2132
2133 void
2134 MixResumeMusic ()
2135         CODE:
2136                 Mix_ResumeMusic();
2137
2138 void
2139 MixRewindMusic ()
2140         CODE:
2141                 Mix_RewindMusic();
2142
2143 int
2144 MixPausedMusic ()
2145         CODE:
2146                 RETVAL = Mix_PausedMusic();
2147         OUTPUT:
2148                 RETVAL
2149
2150 int
2151 MixPlaying( channel )
2152         int channel     
2153         CODE:
2154                 RETVAL = Mix_Playing(channel);
2155         OUTPUT:
2156                 RETVAL
2157
2158 int
2159 MixPlayingMusic()
2160         CODE:
2161                 RETVAL = Mix_PlayingMusic();
2162         OUTPUT:
2163                 RETVAL
2164
2165 int
2166 MixSetPanning ( channel, left, right )
2167         int channel
2168         int left
2169         int right
2170         CODE:
2171                 RETVAL = Mix_SetPanning(channel, left, right);
2172         OUTPUT:
2173                 RETVAL
2174
2175 void
2176 MixCloseAudio ()
2177         CODE:
2178                 Mix_CloseAudio();
2179
2180 #endif
2181
2182 int
2183 GLLoadLibrary ( path )
2184         char *path
2185         CODE:
2186                 RETVAL = SDL_GL_LoadLibrary(path);
2187         OUTPUT:
2188                 RETVAL
2189
2190 void*
2191 GLGetProcAddress ( proc )
2192         char *proc
2193         CODE:
2194                 RETVAL = SDL_GL_GetProcAddress(proc);
2195         OUTPUT:
2196                 RETVAL
2197
2198 int
2199 GLSetAttribute ( attr,  value )
2200         int        attr
2201         int        value
2202         CODE:
2203                 RETVAL = SDL_GL_SetAttribute(attr, value);
2204         OUTPUT:
2205                 RETVAL
2206
2207 AV *
2208 GLGetAttribute ( attr )
2209         int        attr
2210         CODE:
2211                 int value;
2212                 RETVAL = newAV();
2213                 av_push(RETVAL,newSViv(SDL_GL_GetAttribute(attr, &value)));
2214                 av_push(RETVAL,newSViv(value));
2215         OUTPUT:
2216                 RETVAL
2217
2218 void
2219 GLSwapBuffers ()
2220         CODE:
2221                 SDL_GL_SwapBuffers ();
2222
2223
2224 int
2225 BigEndian ()
2226         CODE:
2227                 RETVAL = (SDL_BYTEORDER == SDL_BIG_ENDIAN);
2228         OUTPUT:
2229                 RETVAL
2230
2231 int
2232 NumJoysticks ()
2233         CODE:
2234                 RETVAL = SDL_NumJoysticks();
2235         OUTPUT:
2236                 RETVAL
2237
2238 char *
2239 JoystickName ( index )
2240         int index
2241         CODE:
2242                 RETVAL = (char*)SDL_JoystickName(index);
2243         OUTPUT:
2244                 RETVAL
2245
2246 SDL_Joystick *
2247 JoystickOpen ( index ) 
2248         int index
2249         CODE:
2250                 RETVAL = SDL_JoystickOpen(index);
2251         OUTPUT:
2252                 RETVAL
2253
2254 int
2255 JoystickOpened ( index )
2256         int index
2257         CODE:
2258                 RETVAL = SDL_JoystickOpened(index);
2259         OUTPUT:
2260                 RETVAL
2261
2262 int
2263 JoystickIndex ( joystick )
2264         SDL_Joystick *joystick
2265         CODE:
2266                 RETVAL = SDL_JoystickIndex(joystick);
2267         OUTPUT:
2268                 RETVAL
2269
2270 int
2271 JoystickNumAxes ( joystick )
2272         SDL_Joystick *joystick
2273         CODE:
2274                 RETVAL = SDL_JoystickNumAxes(joystick);
2275         OUTPUT:
2276                 RETVAL
2277
2278 int
2279 JoystickNumBalls ( joystick )
2280         SDL_Joystick *joystick
2281         CODE:
2282                 RETVAL = SDL_JoystickNumBalls(joystick);
2283         OUTPUT:
2284                 RETVAL
2285
2286 int
2287 JoystickNumHats ( joystick )
2288         SDL_Joystick *joystick
2289         CODE:
2290                 RETVAL = SDL_JoystickNumHats(joystick);
2291         OUTPUT:
2292                 RETVAL
2293
2294 int
2295 JoystickNumButtons ( joystick )
2296         SDL_Joystick *joystick
2297         CODE:
2298                 RETVAL = SDL_JoystickNumButtons(joystick);
2299         OUTPUT:
2300                 RETVAL
2301
2302 void
2303 JoystickUpdate ()
2304         CODE:
2305                 SDL_JoystickUpdate();
2306
2307 Sint16
2308 JoystickGetAxis ( joystick, axis )
2309         SDL_Joystick *joystick
2310         int axis
2311         CODE:
2312                 RETVAL = SDL_JoystickGetAxis(joystick,axis);
2313         OUTPUT:
2314                 RETVAL
2315
2316 Uint8
2317 JoystickGetHat ( joystick, hat )
2318         SDL_Joystick *joystick
2319         int hat 
2320         CODE:
2321                 RETVAL = SDL_JoystickGetHat(joystick,hat);
2322         OUTPUT:
2323                 RETVAL
2324
2325 Uint8
2326 JoystickGetButton ( joystick, button)
2327         SDL_Joystick *joystick
2328         int button 
2329         CODE:
2330                 RETVAL = SDL_JoystickGetButton(joystick,button);
2331         OUTPUT:
2332                 RETVAL
2333
2334 AV *
2335 JoystickGetBall ( joystick, ball )
2336         SDL_Joystick *joystick
2337         int ball 
2338         CODE:
2339                 int success,dx,dy;
2340                 success = SDL_JoystickGetBall(joystick,ball,&dx,&dy);
2341                 RETVAL = newAV();
2342                 av_push(RETVAL,newSViv(success));
2343                 av_push(RETVAL,newSViv(dx));
2344                 av_push(RETVAL,newSViv(dy));
2345         OUTPUT:
2346                 RETVAL  
2347
2348 void
2349 JoystickClose ( joystick )
2350         SDL_Joystick *joystick
2351         CODE:
2352                 SDL_JoystickClose(joystick);
2353
2354 Sint16
2355 JoyAxisEventWhich ( e )
2356         SDL_Event *e
2357         CODE:
2358                 RETVAL = e->jaxis.which;
2359         OUTPUT:
2360                 RETVAL
2361
2362 Uint8
2363 JoyAxisEventAxis ( e )
2364         SDL_Event *e
2365         CODE:
2366                 RETVAL = e->jaxis.axis;
2367         OUTPUT:
2368                 RETVAL
2369
2370 Sint16
2371 JoyAxisEventValue ( e )
2372         SDL_Event *e
2373         CODE:
2374                 RETVAL = e->jaxis.value;
2375         OUTPUT:
2376                 RETVAL
2377
2378 Uint8
2379 JoyButtonEventWhich ( e )
2380         SDL_Event *e
2381         CODE:
2382                 RETVAL = e->jbutton.which;
2383         OUTPUT:
2384                 RETVAL
2385
2386 Uint8
2387 JoyButtonEventButton ( e )
2388         SDL_Event *e
2389         CODE:
2390                 RETVAL = e->jbutton.button;
2391         OUTPUT:
2392                 RETVAL
2393
2394 Uint8
2395 JoyButtonEventState ( e )
2396         SDL_Event *e
2397         CODE:
2398                 RETVAL = e->jbutton.state;
2399         OUTPUT:
2400                 RETVAL
2401         
2402 Uint8
2403 JoyHatEventWhich ( e )
2404         SDL_Event *e
2405         CODE:
2406                 RETVAL = e->jhat.which;
2407         OUTPUT:
2408                 RETVAL
2409
2410 Uint8
2411 JoyHatEventHat ( e )
2412         SDL_Event *e
2413         CODE:
2414                 RETVAL = e->jhat.hat;
2415         OUTPUT:
2416                 RETVAL
2417
2418 Uint8
2419 JoyHatEventValue ( e )
2420         SDL_Event *e
2421         CODE:
2422                 RETVAL = e->jhat.value;
2423         OUTPUT:
2424                 RETVAL
2425
2426 Uint8
2427 JoyBallEventWhich ( e )
2428         SDL_Event *e
2429         CODE: 
2430                 RETVAL = e->jball.which;
2431         OUTPUT:
2432                 RETVAL
2433
2434 Uint8
2435 JoyBallEventBall ( e )
2436         SDL_Event *e
2437         CODE:
2438                 RETVAL = e->jball.ball;
2439         OUTPUT:
2440                 RETVAL
2441
2442 Sint16
2443 JoyBallEventXrel ( e )
2444         SDL_Event *e
2445         CODE:
2446                 RETVAL = e->jball.xrel;
2447         OUTPUT:
2448                 RETVAL
2449
2450 Sint16
2451 JoyBallEventYrel ( e )
2452         SDL_Event *e
2453         CODE:
2454                 RETVAL = e->jball.yrel;
2455         OUTPUT:
2456                 RETVAL
2457
2458 void
2459 SetClipRect ( surface, rect )
2460         SDL_Surface *surface
2461         SDL_Rect *rect
2462         CODE:
2463                 SDL_SetClipRect(surface,rect);
2464         
2465 void
2466 GetClipRect ( surface, rect )
2467         SDL_Surface *surface
2468         SDL_Rect *rect;
2469         CODE:
2470                 SDL_GetClipRect(surface, rect);
2471
2472
2473 #ifdef HAVE_SDL_NET
2474
2475 int
2476 NetInit ()
2477         CODE:
2478                 RETVAL = SDLNet_Init();
2479         OUTPUT:
2480                 RETVAL
2481
2482 void
2483 NetQuit ()
2484         CODE:
2485                 SDLNet_Quit();
2486
2487 IPaddress*
2488 NetNewIPaddress ( host, port )
2489         Uint32 host
2490         Uint16 port
2491         CODE:
2492                 RETVAL = (IPaddress*) safemalloc(sizeof(IPaddress));
2493                 RETVAL->host = host;
2494                 RETVAL->port = port;
2495         OUTPUT:
2496                 RETVAL
2497
2498 Uint32
2499 NetIPaddressHost ( ip )
2500         IPaddress *ip
2501         CODE:
2502                 RETVAL = ip->host;
2503         OUTPUT:
2504                 RETVAL
2505
2506 Uint16
2507 NetIPaddressPort ( ip )
2508         IPaddress *ip
2509         CODE:
2510                 RETVAL = ip->port;
2511         OUTPUT:
2512                 RETVAL
2513
2514 void
2515 NetFreeIPaddress ( ip )
2516         IPaddress *ip
2517         CODE:
2518                 safefree(ip);
2519
2520 const char*
2521 NetResolveIP ( address )
2522         IPaddress *address
2523         CODE:
2524                 RETVAL = SDLNet_ResolveIP(address);
2525         OUTPUT:
2526                 RETVAL
2527
2528 int
2529 NetResolveHost ( address, host, port )
2530         IPaddress *address
2531         const char *host
2532         Uint16 port
2533         CODE:
2534                 RETVAL = SDLNet_ResolveHost(address,host,port);
2535         OUTPUT:
2536                 RETVAL
2537         
2538 TCPsocket
2539 NetTCPOpen ( ip )
2540         IPaddress *ip
2541         CODE:
2542                 RETVAL = SDLNet_TCP_Open(ip);
2543         OUTPUT:
2544                 RETVAL
2545
2546 TCPsocket
2547 NetTCPAccept ( server )
2548         TCPsocket server
2549         CODE:
2550                 RETVAL = SDLNet_TCP_Accept(server);
2551         OUTPUT:
2552                 RETVAL
2553
2554 IPaddress*
2555 NetTCPGetPeerAddress ( sock )
2556         TCPsocket sock
2557         CODE:
2558                 RETVAL = SDLNet_TCP_GetPeerAddress(sock);
2559         OUTPUT:
2560                 RETVAL
2561
2562 int
2563 NetTCPSend ( sock, data, len  )
2564         TCPsocket sock
2565         void *data
2566         int len
2567         CODE:
2568                 RETVAL = SDLNet_TCP_Send(sock,data,len);
2569         OUTPUT:
2570                 RETVAL
2571
2572 AV*
2573 NetTCPRecv ( sock, maxlen )
2574         TCPsocket sock
2575         int maxlen
2576         CODE:
2577                 int status;
2578                 void *buffer;
2579                 buffer = safemalloc(maxlen);
2580                 RETVAL = newAV();
2581                 status = SDLNet_TCP_Recv(sock,buffer,maxlen);
2582                 av_push(RETVAL,newSViv(status));
2583                 av_push(RETVAL,newSVpvn((char*)buffer,maxlen));
2584         OUTPUT:
2585                 RETVAL  
2586         
2587 void
2588 NetTCPClose ( sock )
2589         TCPsocket sock
2590         CODE:
2591                 SDLNet_TCP_Close(sock);
2592
2593 UDPpacket*
2594 NetAllocPacket ( size )
2595         int size
2596         CODE:
2597                 RETVAL = SDLNet_AllocPacket(size);
2598         OUTPUT:
2599                 RETVAL
2600
2601 UDPpacket**
2602 NetAllocPacketV ( howmany, size )
2603         int howmany
2604         int size
2605         CODE:
2606                 RETVAL = SDLNet_AllocPacketV(howmany,size);
2607         OUTPUT:
2608                 RETVAL
2609
2610 int
2611 NetResizePacket ( packet, newsize )
2612         UDPpacket *packet
2613         int newsize
2614         CODE:
2615                 RETVAL = SDLNet_ResizePacket(packet,newsize);
2616         OUTPUT:
2617                 RETVAL
2618
2619 void
2620 NetFreePacket ( packet )
2621         UDPpacket *packet
2622         CODE:
2623                 SDLNet_FreePacket(packet);
2624
2625 void
2626 NetFreePacketV ( packet )
2627         UDPpacket **packet
2628         CODE:
2629                 SDLNet_FreePacketV(packet);
2630
2631 UDPsocket
2632 NetUDPOpen ( port )
2633         Uint16 port
2634         CODE:
2635                 RETVAL = SDLNet_UDP_Open(port);
2636         OUTPUT:
2637                 RETVAL
2638
2639 int
2640 NetUDPBind ( sock, channel, address )
2641         UDPsocket sock
2642         int channel
2643         IPaddress *address
2644         CODE:
2645                 RETVAL = SDLNet_UDP_Bind(sock,channel,address);
2646         OUTPUT:
2647                 RETVAL
2648
2649 void
2650 NetUDPUnbind ( sock, channel )
2651         UDPsocket sock
2652         int channel
2653         CODE:
2654                 SDLNet_UDP_Unbind(sock,channel);
2655
2656 IPaddress*
2657 NetUDPGetPeerAddress ( sock, channel )
2658         UDPsocket sock
2659         int channel
2660         CODE:
2661                 RETVAL = SDLNet_UDP_GetPeerAddress(sock,channel);
2662         OUTPUT:
2663                 RETVAL
2664
2665 int
2666 NetUDPSendV ( sock, packets, npackets )
2667         UDPsocket sock
2668         UDPpacket **packets
2669         int npackets
2670         CODE:
2671                 RETVAL = SDLNet_UDP_SendV(sock,packets,npackets);
2672         OUTPUT:
2673                 RETVAL
2674
2675 int
2676 NetUDPSend ( sock, channel, packet )
2677         UDPsocket sock
2678         int channel
2679         UDPpacket *packet 
2680         CODE:
2681                 RETVAL = SDLNet_UDP_Send(sock,channel,packet);
2682         OUTPUT:
2683                 RETVAL
2684
2685 int
2686 NetUDPRecvV ( sock, packets )
2687         UDPsocket sock
2688         UDPpacket **packets
2689         CODE:
2690                 RETVAL = SDLNet_UDP_RecvV(sock,packets);
2691         OUTPUT:
2692                 RETVAL
2693
2694 int
2695 NetUDPRecv ( sock, packet )
2696         UDPsocket sock
2697         UDPpacket *packet
2698         CODE:
2699                 RETVAL = SDLNet_UDP_Recv(sock,packet);
2700         OUTPUT:
2701                 RETVAL
2702
2703 void
2704 NetUDPClose ( sock )
2705         UDPsocket sock
2706         CODE:
2707                 SDLNet_UDP_Close(sock);
2708
2709 SDLNet_SocketSet
2710 NetAllocSocketSet ( maxsockets )
2711         int maxsockets
2712         CODE:
2713                 RETVAL = SDLNet_AllocSocketSet(maxsockets);
2714         OUTPUT:
2715                 RETVAL
2716
2717 int
2718 NetTCP_AddSocket ( set, sock )
2719         SDLNet_SocketSet set
2720         TCPsocket sock
2721         CODE:
2722                 RETVAL = SDLNet_TCP_AddSocket(set,sock);
2723         OUTPUT:
2724                 RETVAL
2725
2726 int
2727 NetUDP_AddSocket ( set, sock )
2728         SDLNet_SocketSet set
2729         UDPsocket sock
2730         CODE:
2731                 RETVAL = SDLNet_UDP_AddSocket(set,sock);
2732         OUTPUT:
2733                 RETVAL
2734
2735 int
2736 NetTCP_DelSocket ( set, sock )
2737         SDLNet_SocketSet set
2738         TCPsocket sock
2739         CODE:
2740                 RETVAL = SDLNet_TCP_DelSocket(set,sock);
2741         OUTPUT:
2742                 RETVAL
2743
2744 int
2745 NetUDP_DelSocket ( set, sock )
2746         SDLNet_SocketSet set
2747         UDPsocket sock
2748         CODE:
2749                 RETVAL = SDLNet_UDP_DelSocket(set,sock);
2750         OUTPUT:
2751                 RETVAL
2752
2753 int
2754 NetCheckSockets ( set, timeout )
2755         SDLNet_SocketSet set
2756         Uint32 timeout
2757         CODE:
2758                 RETVAL = SDLNet_CheckSockets(set,timeout);
2759         OUTPUT:
2760                 RETVAL
2761
2762 int
2763 NetSocketReady ( sock )
2764         SDLNet_GenericSocket sock
2765         CODE:
2766                 RETVAL = SDLNet_SocketReady(sock);
2767         OUTPUT:
2768                 RETVAL
2769
2770 void
2771 NetFreeSocketSet ( set )
2772         SDLNet_SocketSet set
2773         CODE:
2774                 SDLNet_FreeSocketSet(set);
2775
2776 void
2777 NetWrite16 ( value, area )
2778         Uint16 value
2779         void *area
2780         CODE:
2781                 SDLNet_Write16(value,area);
2782
2783 void
2784 NetWrite32 ( value, area )
2785         Uint32 value
2786         void *area
2787         CODE:
2788                 SDLNet_Write32(value,area);
2789         
2790 Uint16
2791 NetRead16 ( area )
2792         void *area
2793         CODE:
2794                 RETVAL = SDLNet_Read16(area);
2795         OUTPUT:
2796                 RETVAL
2797
2798 Uint32
2799 NetRead32 ( area )
2800         void *area
2801         CODE:
2802                 RETVAL = SDLNet_Read32(area);
2803         OUTPUT:
2804                 RETVAL
2805
2806 #endif 
2807
2808 #ifdef HAVE_SDL_TTF
2809
2810 int
2811 TTFInit ()
2812         CODE:
2813                 RETVAL = TTF_Init();
2814         OUTPUT:
2815                 RETVAL
2816
2817 void
2818 TTFQuit ()
2819         CODE:
2820                 TTF_Quit();
2821
2822 TTF_Font*
2823 TTFOpenFont ( file, ptsize )
2824         char *file
2825         int ptsize
2826         CODE:
2827                 RETVAL = TTF_OpenFont(file,ptsize);
2828         OUTPUT:
2829                 RETVAL
2830
2831 int
2832 TTFGetFontStyle ( font )
2833         TTF_Font *font
2834         CODE:
2835                 RETVAL = TTF_GetFontStyle(font);
2836         OUTPUT:
2837                 RETVAL
2838
2839 void
2840 TTFSetFontStyle ( font, style )
2841         TTF_Font *font
2842         int style
2843         CODE:
2844                 TTF_SetFontStyle(font,style);
2845         
2846 int
2847 TTFFontHeight ( font )
2848         TTF_Font *font
2849         CODE:
2850                 RETVAL = TTF_FontHeight(font);
2851         OUTPUT:
2852                 RETVAL
2853
2854 int
2855 TTFFontAscent ( font )
2856         TTF_Font *font
2857         CODE:
2858                 RETVAL = TTF_FontAscent(font);
2859         OUTPUT:
2860                 RETVAL
2861
2862 int
2863 TTFFontDescent ( font )
2864         TTF_Font *font
2865         CODE:
2866                 RETVAL = TTF_FontDescent(font);
2867         OUTPUT:
2868                 RETVAL
2869
2870 int
2871 TTFFontLineSkip ( font )
2872         TTF_Font *font
2873         CODE:
2874                 RETVAL = TTF_FontLineSkip(font);
2875         OUTPUT:
2876                 RETVAL
2877
2878 AV*
2879 TTFGlyphMetrics ( font, ch )
2880         TTF_Font *font
2881         Uint16 ch
2882         CODE:
2883                 int minx, miny, maxx, maxy, advance;
2884                 RETVAL = newAV();
2885                 TTF_GlyphMetrics(font, ch, &minx, &miny, &maxx, &maxy, &advance);
2886                 av_push(RETVAL,newSViv(minx));
2887                 av_push(RETVAL,newSViv(miny));
2888                 av_push(RETVAL,newSViv(maxx));
2889                 av_push(RETVAL,newSViv(maxy));
2890                 av_push(RETVAL,newSViv(advance));
2891         OUTPUT:
2892                 RETVAL
2893
2894 AV*
2895 TTFSizeText ( font, text )
2896         TTF_Font *font
2897         char *text
2898         CODE:
2899                 int w,h;
2900                 RETVAL = newAV();
2901                 if(TTF_SizeText(font,text,&w,&h))
2902                 {
2903                         printf("TTF error at TTFSizeText: %s \n", TTF_GetError());
2904                         Perl_croak (aTHX_ "TTF error \n");
2905                 }
2906                 else
2907                 {
2908                         av_push(RETVAL,newSViv(w));
2909                         av_push(RETVAL,newSViv(h));
2910                         sv_2mortal((SV*)RETVAL);
2911                 }
2912                 
2913         
2914         OUTPUT:
2915                 RETVAL
2916
2917 AV*
2918 TTFSizeUTF8 ( font, text )
2919         TTF_Font *font
2920         char *text
2921         CODE:
2922                 int w,h;
2923                 RETVAL = newAV();
2924                 if(TTF_SizeUTF8(font,text,&w,&h))
2925                 {
2926                         av_push(RETVAL,newSViv(w));
2927                         av_push(RETVAL,newSViv(h));
2928                         sv_2mortal((SV*)RETVAL);
2929
2930                 }
2931                 else
2932                 {
2933                         printf("TTF error at TTFSizeUTF8 with : %s \n", TTF_GetError());
2934                         Perl_croak (aTHX_ "TTF error \n");
2935                 }
2936                 
2937         OUTPUT:
2938                 RETVAL
2939
2940 AV*
2941 TTFSizeUNICODE ( font, text )
2942         TTF_Font *font
2943         const Uint16 *text
2944         CODE:
2945                 int w,h;
2946                 RETVAL = newAV();
2947                 if(TTF_SizeUNICODE(font,text,&w,&h))
2948                 {
2949                         av_push(RETVAL,newSViv(w));
2950                         av_push(RETVAL,newSViv(h));
2951                         sv_2mortal((SV*)RETVAL);
2952
2953                 }
2954                 else
2955                 {
2956                         printf("TTF error at TTFSizeUNICODE : %s \n", TTF_GetError()); 
2957                         Perl_croak (aTHX_ "TTF error \n");
2958                 }
2959
2960         OUTPUT:
2961                 RETVAL
2962
2963 =for comment
2964
2965 SDL_Surface*
2966 TTFRenderTextSolid ( font, text, fg )
2967         TTF_Font *font
2968         char *text
2969         SDL_Color *fg
2970         CODE:
2971                 RETVAL = TTF_RenderText_Solid(font,text,*fg);
2972         OUTPUT:
2973                 RETVAL
2974
2975 SDL_Surface*
2976 TTFRenderUTF8Solid ( font, text, fg )
2977         TTF_Font *font
2978         char *text
2979         SDL_Color *fg
2980         CODE:
2981                 RETVAL = TTF_RenderUTF8_Solid(font,text,*fg);
2982         OUTPUT:
2983                 RETVAL
2984
2985 SDL_Surface*
2986 TTFRenderUNICODESolid ( font, text, fg )
2987         TTF_Font *font
2988         const Uint16 *text
2989         SDL_Color *fg
2990         CODE:
2991                 RETVAL = TTF_RenderUNICODE_Solid(font,text,*fg);
2992         OUTPUT:
2993                 RETVAL
2994
2995 SDL_Surface*
2996 TTFRenderGlyphSolid ( font, ch, fg )
2997         TTF_Font *font
2998         Uint16 ch
2999         SDL_Color *fg
3000         CODE:
3001                 RETVAL = TTF_RenderGlyph_Solid(font,ch,*fg);
3002         OUTPUT:
3003                 RETVAL
3004
3005 SDL_Surface*
3006 TTFRenderTextShaded ( font, text, fg, bg )
3007         TTF_Font *font
3008         char *text
3009         SDL_Color *fg
3010         SDL_Color *bg
3011         CODE:
3012                 RETVAL = TTF_RenderText_Shaded(font,text,*fg,*bg);
3013         OUTPUT:
3014                 RETVAL
3015
3016 SDL_Surface*
3017 TTFRenderUTF8Shaded( font, text, fg, bg )
3018         TTF_Font *font
3019         char *text
3020         SDL_Color *fg
3021         SDL_Color *bg
3022         CODE:
3023                 RETVAL = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
3024         OUTPUT:
3025                 RETVAL
3026
3027 SDL_Surface*
3028 TTFRenderUNICODEShaded( font, text, fg, bg )
3029         TTF_Font *font
3030         const Uint16 *text
3031         SDL_Color *fg
3032         SDL_Color *bg
3033         CODE:
3034                 RETVAL = TTF_RenderUNICODE_Shaded(font,text,*fg,*bg);
3035         OUTPUT:
3036                 RETVAL
3037
3038 SDL_Surface*
3039 TTFRenderGlyphShaded ( font, ch, fg, bg )
3040         TTF_Font *font
3041         Uint16 ch
3042         SDL_Color *fg
3043         SDL_Color *bg
3044         CODE:
3045                 RETVAL = TTF_RenderGlyph_Shaded(font,ch,*fg,*bg);
3046         OUTPUT:
3047                 RETVAL
3048
3049 SDL_Surface*
3050 TTFRenderTextBlended( font, text, fg )
3051         TTF_Font *font
3052         char *text
3053         SDL_Color *fg
3054         CODE:
3055                 RETVAL = TTF_RenderText_Blended(font,text,*fg);
3056         OUTPUT:
3057                 RETVAL
3058
3059 SDL_Surface*
3060 TTFRenderUTF8Blended( font, text, fg )
3061         TTF_Font *font
3062         char *text
3063         SDL_Color *fg
3064         CODE:
3065                 RETVAL = TTF_RenderUTF8_Blended(font,text,*fg);
3066         OUTPUT:
3067                 RETVAL
3068
3069 SDL_Surface*
3070 TTFRenderUNICODEBlended( font, text, fg )
3071         TTF_Font *font
3072         const Uint16 *text
3073         SDL_Color *fg
3074         CODE:
3075                 RETVAL = TTF_RenderUNICODE_Blended(font,text,*fg);
3076         OUTPUT:
3077                 RETVAL
3078
3079 SDL_Surface*
3080 TTFRenderGlyphBlended( font, ch, fg )
3081         TTF_Font *font
3082         Uint16 ch
3083         SDL_Color *fg
3084         CODE:
3085                 RETVAL = TTF_RenderGlyph_Blended(font,ch,*fg);
3086         OUTPUT:
3087                 RETVAL
3088
3089 void
3090 TTFCloseFont ( font )
3091         TTF_Font *font
3092         CODE:
3093                 TTF_CloseFont(font);
3094                 font=NULL; //to be safe http://sdl.beuc.net/sdl.wiki/SDL_ttf_copy_Functions_Management_TTF_CloseFont
3095
3096 SDL_Surface*
3097 TTFPutString ( font, mode, surface, x, y, fg, bg, text )
3098         TTF_Font *font
3099         int mode
3100         SDL_Surface *surface
3101         int x
3102         int y
3103         SDL_Color *fg
3104         SDL_Color *bg
3105         char *text
3106         CODE:
3107                 SDL_Surface *img;
3108                 SDL_Rect dest;
3109                 int w,h;
3110                 dest.x = x;
3111                 dest.y = y;
3112                 RETVAL = NULL;
3113                 switch (mode) {
3114                         case TEXT_SOLID:
3115                                 img = TTF_RenderText_Solid(font,text,*fg);
3116                                 TTF_SizeText(font,text,&w,&h);
3117                                 dest.w = w;
3118                                 dest.h = h;
3119                                 break;
3120                         case TEXT_SHADED:
3121                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3122                                 TTF_SizeText(font,text,&w,&h);
3123                                 dest.w = w;
3124                                 dest.h = h;
3125                                 break;
3126                         case TEXT_BLENDED:
3127                                 img = TTF_RenderText_Blended(font,text,*fg);
3128                                 TTF_SizeText(font,text,&w,&h);
3129                                 dest.w = w;
3130                                 dest.h = h;
3131                                 break;
3132                         case UTF8_SOLID:
3133                                 img = TTF_RenderUTF8_Solid(font,text,*fg);
3134                                 TTF_SizeUTF8(font,text,&w,&h);
3135                                 dest.w = w;
3136                                 dest.h = h;
3137                                 break;
3138                         case UTF8_SHADED:
3139                                 img = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
3140                                 TTF_SizeUTF8(font,text,&w,&h);
3141                                 dest.w = w;
3142                                 dest.h = h;
3143                                 break;
3144                         case UTF8_BLENDED:
3145                                 img = TTF_RenderUTF8_Blended(font,text,*fg);
3146                                 TTF_SizeUTF8(font,text,&w,&h);
3147                                 dest.w = w;
3148                                 dest.h = h;
3149                                 break;
3150                         case UNICODE_SOLID:
3151                                 img = TTF_RenderUNICODE_Solid(font,(Uint16*)text,*fg);
3152                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3153                                 dest.w = w;
3154                                 dest.h = h;
3155                                 break;
3156                         case UNICODE_SHADED:
3157                                 img = TTF_RenderUNICODE_Shaded(font,(Uint16*)text,*fg,*bg);
3158                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3159                                 dest.w = w;
3160                                 dest.h = h;
3161                                 break;
3162                         case UNICODE_BLENDED:
3163                                 img = TTF_RenderUNICODE_Blended(font,(Uint16*)text,*fg);
3164                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3165                                 dest.w = w;
3166                                 dest.h = h;
3167                                 break;
3168                         default:
3169                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3170                                 TTF_SizeText(font,text,&w,&h);
3171                                 dest.w = w;
3172                                 dest.h = h;
3173                 }
3174                 if ( img && img->format && img->format->palette ) {
3175                         SDL_Color *c = &img->format->palette->colors[0];
3176                         Uint32 key = SDL_MapRGB( img->format, c->r, c->g, c->b );
3177                         SDL_SetColorKey(img,SDL_SRCCOLORKEY,key );
3178                         if (0 > SDL_BlitSurface(img,NULL,surface,&dest)) {
3179                                 SDL_FreeSurface(img);
3180                                 RETVAL = NULL;  
3181                         } else {
3182                                 RETVAL = img;
3183                         }
3184                 }
3185         OUTPUT:
3186                 RETVAL
3187
3188 =cut
3189
3190 #endif
3191
3192 SDL_Overlay*
3193 CreateYUVOverlay ( width, height, format, display )
3194         int width
3195         int height
3196         Uint32 format
3197         SDL_Surface *display
3198         CODE:
3199                 RETVAL = SDL_CreateYUVOverlay ( width, height, format, display );
3200         OUTPUT:
3201                 RETVAL
3202
3203 int
3204 LockYUVOverlay ( overlay )
3205         SDL_Overlay *overlay
3206         CODE:
3207                 RETVAL = SDL_LockYUVOverlay(overlay);
3208         OUTPUT:
3209                 RETVAL
3210
3211 void
3212 UnlockYUVOverlay ( overlay )
3213         SDL_Overlay *overlay
3214         CODE:
3215                 SDL_UnlockYUVOverlay(overlay);
3216
3217 int
3218 DisplayYUVOverlay ( overlay, dstrect )
3219         SDL_Overlay *overlay
3220         SDL_Rect *dstrect
3221         CODE:
3222                 RETVAL = SDL_DisplayYUVOverlay ( overlay, dstrect );
3223         OUTPUT:
3224                 RETVAL
3225
3226 void
3227 FreeYUVOverlay ( overlay )
3228         SDL_Overlay *overlay
3229         CODE:
3230                 SDL_FreeYUVOverlay ( overlay );
3231
3232 Uint32
3233 OverlayFormat ( overlay, ... )
3234         SDL_Overlay *overlay
3235         CODE:
3236                 if ( items > 1 ) 
3237                         overlay->format = SvIV(ST(1));
3238                 RETVAL = overlay->format;
3239         OUTPUT:
3240                 RETVAL
3241
3242 int 
3243 OverlayW ( overlay, ... )
3244         SDL_Overlay *overlay
3245         CODE:
3246                 if ( items > 1 ) 
3247                         overlay->w = SvIV(ST(1));
3248                 RETVAL = overlay->w;
3249         OUTPUT:
3250                 RETVAL
3251
3252 int
3253 OverlayH ( overlay, ... )
3254         SDL_Overlay *overlay
3255         CODE:
3256                 if ( items > 1 )
3257                         overlay->h = SvIV(ST(1));
3258                 RETVAL = overlay->h;
3259         OUTPUT:
3260                 RETVAL 
3261
3262 int
3263 OverlayPlanes ( overlay, ... )
3264         SDL_Overlay *overlay
3265         CODE:
3266                 if ( items > 1 )
3267                         overlay->planes = SvIV(ST(1));
3268                 RETVAL = overlay->planes;
3269         OUTPUT:
3270                 RETVAL
3271
3272 Uint32
3273 OverlayHW ( overlay )
3274         SDL_Overlay *overlay
3275         CODE:
3276                 RETVAL = overlay->hw_overlay;
3277         OUTPUT:
3278                 RETVAL
3279
3280 Uint16*
3281 OverlayPitches ( overlay )
3282         SDL_Overlay *overlay
3283         CODE:
3284                 RETVAL = overlay->pitches;
3285         OUTPUT:
3286                 RETVAL
3287
3288 Uint8**
3289 OverlayPixels ( overlay )
3290         SDL_Overlay *overlay
3291         CODE:
3292                 RETVAL = overlay->pixels;
3293         OUTPUT:
3294                 RETVAL
3295
3296 int
3297 WMToggleFullScreen ( surface )
3298         SDL_Surface *surface
3299         CODE:
3300                 RETVAL = SDL_WM_ToggleFullScreen(surface);
3301         OUTPUT:
3302                 RETVAL
3303
3304 Uint32
3305 WMGrabInput ( mode )
3306         Uint32 mode
3307         CODE:
3308                 RETVAL = SDL_WM_GrabInput(mode);
3309         OUTPUT:
3310                 RETVAL
3311
3312 int
3313 WMIconifyWindow ()
3314         CODE:
3315                 RETVAL = SDL_WM_IconifyWindow();
3316         OUTPUT:
3317                 RETVAL
3318
3319 int
3320 ResizeEventW ( e )
3321         SDL_Event *e
3322         CODE:
3323                 RETVAL = e->resize.w;
3324         OUTPUT:
3325                 RETVAL
3326
3327 int
3328 ResizeEventH ( e )
3329         SDL_Event *e
3330         CODE:
3331                 RETVAL = e->resize.h;
3332         OUTPUT:
3333                 RETVAL
3334
3335 char*
3336 AudioDriverName ()
3337         CODE:
3338                 char name[32];
3339                 RETVAL = SDL_AudioDriverName(name,32);
3340         OUTPUT:
3341                 RETVAL
3342
3343 Uint32
3344 GetKeyState ( k )
3345         SDLKey k
3346         CODE:
3347                 if (k >= SDLK_LAST) Perl_croak (aTHX_ "Key out of range");      
3348                 RETVAL = SDL_GetKeyState(NULL)[k];
3349         OUTPUT:
3350                 RETVAL
3351
3352 #ifdef HAVE_SMPEG
3353
3354 SMPEG_Info *
3355 NewSMPEGInfo()
3356         CODE:   
3357                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3358         OUTPUT:
3359                 RETVAL
3360
3361 void
3362 FreeSMPEGInfo ( info )
3363         SMPEG_Info *info
3364         CODE:   
3365                 safefree(info);
3366
3367 int
3368 SMPEGInfoHasAudio ( info )
3369         SMPEG_Info* info
3370         CODE:
3371                 RETVAL = info->has_audio;
3372         OUTPUT:
3373                 RETVAL
3374
3375 int
3376 SMPEGInfoHasVideo ( info )
3377         SMPEG_Info* info
3378         CODE:
3379                 RETVAL = info->has_video;
3380         OUTPUT:
3381                 RETVAL
3382
3383 int
3384 SMPEGInfoWidth ( info )
3385         SMPEG_Info* info
3386         CODE:
3387                 RETVAL = info->width;
3388         OUTPUT:
3389                 RETVAL
3390
3391 int
3392 SMPEGInfoHeight ( info )
3393         SMPEG_Info* info
3394         CODE:
3395                 RETVAL = info->height;
3396         OUTPUT:
3397                 RETVAL
3398
3399 int
3400 SMPEGInfoCurrentFrame ( info )
3401         SMPEG_Info* info
3402         CODE:
3403                 RETVAL = info->current_frame;
3404         OUTPUT:
3405                 RETVAL
3406
3407 double
3408 SMPEGInfoCurrentFPS ( info )
3409         SMPEG_Info* info
3410         CODE:
3411                 RETVAL = info->current_fps;
3412         OUTPUT:
3413                 RETVAL
3414
3415 int
3416 SMPEGInfoCurrentAudioFrame ( info )
3417         SMPEG_Info* info
3418         CODE:
3419                 RETVAL = info->audio_current_frame;
3420         OUTPUT:
3421                 RETVAL
3422
3423 int
3424 SMPEGInfoCurrentOffset ( info )
3425         SMPEG_Info* info
3426         CODE:
3427                 RETVAL = info->current_offset;
3428         OUTPUT:
3429                 RETVAL
3430
3431 int
3432 SMPEGInfoTotalSize ( info )
3433         SMPEG_Info* info
3434         CODE:
3435                 RETVAL = info->total_size;
3436         OUTPUT:
3437                 RETVAL
3438
3439 double
3440 SMPEGInfoCurrentTime ( info )
3441         SMPEG_Info* info
3442         CODE:
3443                 RETVAL = info->current_time;
3444         OUTPUT:
3445                 RETVAL
3446
3447 double
3448 SMPEGInfoTotalTime ( info )
3449         SMPEG_Info* info
3450         CODE:
3451                 RETVAL = info->total_time;
3452         OUTPUT:
3453                 RETVAL
3454
3455 char *
3456 SMPEGError ( mpeg )
3457         SMPEG* mpeg
3458         CODE:   
3459                 RETVAL = SMPEG_error(mpeg);
3460         OUTPUT:
3461                 RETVAL
3462
3463 SMPEG*
3464 NewSMPEG ( filename, info, use_audio )
3465         char* filename
3466         SMPEG_Info* info
3467         int use_audio
3468         CODE:   
3469 #ifdef HAVE_SDL_MIXER
3470                 RETVAL = SMPEG_new(filename,info,0);
3471 #else
3472                 RETVAL = SMPEG_new(filename,info,use_audio);
3473 #endif
3474         OUTPUT:
3475                 RETVAL
3476
3477 void
3478 FreeSMPEG ( mpeg )
3479         SMPEG* mpeg
3480         CODE:
3481                 SMPEG_delete(mpeg);
3482
3483 void
3484 SMPEGEnableAudio ( mpeg , flag )
3485         SMPEG* mpeg
3486         int flag
3487         CODE:   
3488                 SMPEG_enableaudio(mpeg,flag);
3489 #ifdef HAVE_SDL_MIXER
3490                 sdl_perl_use_smpeg_audio = flag;
3491 #endif
3492
3493 void
3494 SMPEGEnableVideo ( mpeg , flag )
3495         SMPEG* mpeg
3496         int flag
3497         CODE:   
3498                 SMPEG_enablevideo(mpeg,flag);
3499
3500 void
3501 SMPEGSetVolume ( mpeg , volume )
3502         SMPEG* mpeg
3503         int volume
3504         CODE:   
3505                 SMPEG_setvolume(mpeg,volume);
3506
3507 void
3508 SMPEGSetDisplay ( mpeg, dest, surfLock )
3509         SMPEG* mpeg
3510         SDL_Surface* dest
3511         SDL_mutex*  surfLock
3512         CODE:
3513                 SMPEG_setdisplay(mpeg,dest,surfLock,NULL);
3514
3515 void
3516 SMPEGScaleXY ( mpeg, w, h)
3517         SMPEG* mpeg
3518         int w
3519         int h
3520         CODE:
3521                 SMPEG_scaleXY(mpeg,w,h);
3522
3523 void
3524 SMPEGScale ( mpeg, scale )
3525         SMPEG* mpeg
3526         int scale
3527         CODE:
3528                 SMPEG_scale(mpeg,scale);
3529
3530 void
3531 SMPEGPlay ( mpeg )
3532         SMPEG* mpeg
3533         CODE:
3534                 SDL_AudioSpec audiofmt;
3535                 Uint16 format;
3536                 int freq, channels;
3537 #ifdef HAVE_SDL_MIXER
3538                 if  (sdl_perl_use_smpeg_audio ) {
3539                         SMPEG_enableaudio(mpeg, 0);
3540                         Mix_QuerySpec(&freq, &format, &channels);
3541                         audiofmt.format = format;
3542                         audiofmt.freq = freq;
3543                         audiofmt.channels = channels;
3544                         SMPEG_actualSpec(mpeg, &audiofmt);
3545                         Mix_HookMusic(SMPEG_playAudioSDL, mpeg);
3546                         SMPEG_enableaudio(mpeg, 1);
3547                 }
3548 #endif
3549                 SMPEG_play(mpeg);
3550
3551 SMPEGstatus
3552 SMPEGStatus ( mpeg )
3553         SMPEG* mpeg
3554         CODE:
3555                 RETVAL = SMPEG_status(mpeg);
3556         OUTPUT:
3557                 RETVAL
3558
3559 void
3560 SMPEGPause ( mpeg )
3561         SMPEG* mpeg
3562         CODE:
3563                 SMPEG_pause(mpeg);
3564
3565 void
3566 SMPEGLoop ( mpeg, repeat )
3567         SMPEG* mpeg
3568         int repeat
3569         CODE:
3570                 SMPEG_loop(mpeg,repeat);
3571
3572 void
3573 SMPEGStop ( mpeg )
3574         SMPEG* mpeg
3575         CODE:
3576                 SMPEG_stop(mpeg);
3577 #ifdef HAVE_SDL_MIXER
3578                 Mix_HookMusic(NULL, NULL);
3579 #endif
3580
3581 void
3582 SMPEGRewind ( mpeg )
3583         SMPEG* mpeg
3584         CODE:
3585                 SMPEG_rewind(mpeg);
3586
3587 void
3588 SMPEGSeek ( mpeg, bytes )
3589         SMPEG* mpeg
3590         int bytes
3591         CODE:
3592                 SMPEG_seek(mpeg,bytes);
3593
3594 void
3595 SMPEGSkip ( mpeg, seconds )
3596         SMPEG* mpeg
3597         float seconds
3598         CODE:
3599                 SMPEG_skip(mpeg,seconds);
3600
3601 void
3602 SMPEGSetDisplayRegion ( mpeg, rect )
3603         SMPEG* mpeg
3604         SDL_Rect* rect
3605         CODE:
3606                 SMPEG_setdisplayregion(mpeg,rect->x,rect->y,rect->w,rect->h);
3607
3608 void
3609 SMPEGRenderFrame ( mpeg, frame )
3610         SMPEG* mpeg
3611         int frame
3612         CODE:
3613                 SMPEG_renderFrame(mpeg,frame);
3614
3615 SMPEG_Info *
3616 SMPEGGetInfo ( mpeg )
3617         SMPEG* mpeg
3618         CODE:
3619                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3620                 SMPEG_getinfo(mpeg,RETVAL);
3621         OUTPUT:
3622                 RETVAL
3623         
3624
3625 #endif
3626
3627 #ifdef HAVE_SDL_GFX
3628
3629 =cut
3630
3631 SDL_Surface *
3632 GFXRotoZoom ( src, angle, zoom, smooth)
3633         SDL_Surface * src
3634         double angle
3635         double zoom
3636         int smooth
3637         CODE:
3638                 RETVAL = rotozoomSurface( src, angle, zoom, smooth);
3639         OUTPUT:
3640                 RETVAL
3641
3642 SDL_Surface *
3643 GFXZoom ( src, zoomx, zoomy, smooth)
3644         SDL_Surface *src
3645         double zoomx
3646         double zoomy
3647         int smooth
3648         CODE:
3649                 RETVAL = zoomSurface( src, zoomx, zoomy, smooth);
3650         OUTPUT:
3651                 RETVAL
3652
3653 =cut
3654
3655 int
3656 GFXPixelColor ( dst, x, y, color )
3657         SDL_Surface* dst
3658         Sint16 x
3659         Sint16 y
3660         Uint32 color
3661         CODE:
3662                 RETVAL = pixelColor( dst, x, y, color);
3663         OUTPUT:
3664                 RETVAL
3665
3666 int
3667 GFXPixelRGBA ( dst, x, y, r, g, b, a )
3668         SDL_Surface* dst
3669         Sint16 x
3670         Sint16 y
3671         Uint8 r
3672         Uint8 g
3673         Uint8 b
3674         Uint8 a
3675         CODE:
3676                 RETVAL = pixelRGBA( dst, x, y, r, g, b, a );
3677         OUTPUT:
3678                 RETVAL
3679
3680 int
3681 GFXHlineColor ( dst, x1, x2, y, color )
3682         SDL_Surface* dst
3683         Sint16 x1
3684         Sint16 x2
3685         Sint16 y
3686         Uint32 color
3687         CODE:
3688                 RETVAL = hlineColor( dst, x1, x2, y, color );
3689         OUTPUT:
3690                 RETVAL
3691
3692 int
3693 GFXHlineRGBA ( dst, x1, x2, y, r, g, b, a )
3694         SDL_Surface* dst
3695         Sint16 x1
3696         Sint16 x2
3697         Sint16 y
3698         Uint8 r
3699         Uint8 g
3700         Uint8 b
3701         Uint8 a
3702         CODE:
3703                 RETVAL = hlineRGBA( dst, x1, x2, y, r, g, b, a );
3704         OUTPUT:
3705                 RETVAL
3706
3707 int
3708 GFXVlineColor ( dst, x, y1, y2, color )
3709         SDL_Surface* dst
3710         Sint16 x
3711         Sint16 y1
3712         Sint16 y2
3713         Uint32 color
3714         CODE:
3715                 RETVAL = vlineColor( dst, x, y1, y2, color );
3716         OUTPUT:
3717                 RETVAL
3718
3719 int
3720 GFXVlineRGBA ( dst, x, y1, y2, r, g, b, a )
3721         SDL_Surface* dst
3722         Sint16 x
3723         Sint16 y1
3724         Sint16 y2
3725         Uint8 r
3726         Uint8 g
3727         Uint8 b
3728         Uint8 a
3729         CODE:
3730                 RETVAL = vlineRGBA( dst, x, y1, y2, r, g, b, a );
3731         OUTPUT:
3732                 RETVAL
3733
3734 int
3735 GFXRectangleColor ( dst, x1, y1, x2, y2, color )
3736         SDL_Surface* dst
3737         Sint16 x1
3738         Sint16 y1
3739         Sint16 x2
3740         Sint16 y2
3741         Uint32 color
3742         CODE:
3743                 RETVAL = rectangleColor( dst, x1, y1, x2, y2, color );
3744         OUTPUT:
3745                 RETVAL
3746
3747 int
3748 GFXRectangleRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3749         SDL_Surface* dst
3750         Sint16 x1
3751         Sint16 y1
3752         Sint16 x2
3753         Sint16 y2
3754         Uint8 r
3755         Uint8 g
3756         Uint8 b
3757         Uint8 a
3758         CODE:
3759                 RETVAL = rectangleRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3760         OUTPUT:
3761                 RETVAL
3762
3763 int
3764 GFXBoxColor ( dst, x1, y1, x2, y2, color )
3765         SDL_Surface* dst
3766         Sint16 x1
3767         Sint16 y1
3768         Sint16 x2
3769         Sint16 y2
3770         Uint32 color
3771         CODE:
3772                 RETVAL = boxColor( dst, x1, y1, x2, y2, color );
3773         OUTPUT:
3774                 RETVAL
3775
3776 int
3777 GFXBoxRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3778         SDL_Surface* dst;
3779         Sint16 x1
3780         Sint16 y1
3781         Sint16 x2
3782         Sint16 y2
3783         Uint8 r
3784         Uint8 g
3785         Uint8 b
3786         Uint8 a
3787         CODE:
3788                 RETVAL = boxRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3789         OUTPUT:
3790                 RETVAL
3791
3792 int
3793 GFXLineColor ( dst, x1, y1, x2, y2, color )
3794         SDL_Surface* dst
3795         Sint16 x1
3796         Sint16 y1
3797         Sint16 x2
3798         Sint16 y2
3799         Uint32 color
3800         CODE:
3801                 RETVAL = lineColor( dst, x1, y1, x2, y2, color );
3802         OUTPUT:
3803                 RETVAL
3804
3805 int
3806 GFXLineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3807         SDL_Surface* dst
3808         Sint16 x1
3809         Sint16 y1
3810         Sint16 x2
3811         Sint16 y2
3812         Uint8 r
3813         Uint8 g
3814         Uint8 b
3815         Uint8 a
3816         CODE:
3817                 RETVAL = lineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3818         OUTPUT:
3819                 RETVAL
3820
3821 int
3822 GFXAalineColor ( dst, x1, y1, x2, y2, color )
3823         SDL_Surface* dst
3824         Sint16 x1
3825         Sint16 y1
3826         Sint16 x2
3827         Sint16 y2
3828         Uint32 color
3829         CODE:
3830                 RETVAL = aalineColor( dst, x1, y1, x2, y2, color );
3831         OUTPUT:
3832                 RETVAL
3833
3834 int
3835 GFXAalineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3836         SDL_Surface* dst
3837         Sint16 x1
3838         Sint16 y1
3839         Sint16 x2
3840         Sint16 y2
3841         Uint8 r
3842         Uint8 g
3843         Uint8 b
3844         Uint8 a
3845         CODE:
3846                 RETVAL = aalineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3847         OUTPUT:
3848                 RETVAL
3849
3850 int
3851 GFXCircleColor ( dst, x, y, r, color )
3852         SDL_Surface* dst
3853         Sint16 x
3854         Sint16 y
3855         Sint16 r
3856         Uint32 color
3857         CODE:
3858                 RETVAL = circleColor( dst, x, y, r, color );
3859         OUTPUT:
3860                 RETVAL
3861
3862 int
3863 GFXCircleRGBA ( dst, x, y, rad, r, g, b, a )
3864         SDL_Surface* dst
3865         Sint16 x
3866         Sint16 y
3867         Sint16 rad
3868         Uint8 r
3869         Uint8 g
3870         Uint8 b
3871         Uint8 a
3872         CODE:
3873                 RETVAL = circleRGBA( dst, x, y, rad, r, g, b, a );
3874         OUTPUT:
3875                 RETVAL
3876
3877 int
3878 GFXAacircleColor ( dst, x, y, r, color )
3879         SDL_Surface* dst
3880         Sint16 x
3881         Sint16 y
3882         Sint16 r
3883         Uint32 color
3884         CODE:
3885                 RETVAL = aacircleColor( dst, x, y, r, color );
3886         OUTPUT:
3887                 RETVAL
3888
3889 int
3890 GFXAacircleRGBA ( dst, x, y, rad, r, g, b, a )
3891         SDL_Surface* dst
3892         Sint16 x
3893         Sint16 y
3894         Sint16 rad
3895         Uint8 r
3896         Uint8 g
3897         Uint8 b
3898         Uint8 a
3899         CODE:
3900                 RETVAL = aacircleRGBA( dst, x, y, rad, r, g, b, a );
3901         OUTPUT:
3902                 RETVAL
3903
3904 int
3905 GFXFilledCircleColor ( dst, x, y, r, color )
3906         SDL_Surface* dst
3907         Sint16 x
3908         Sint16 y
3909         Sint16 r
3910         Uint32 color
3911         CODE:
3912                 RETVAL = filledCircleColor( dst, x, y, r, color );
3913         OUTPUT:
3914                 RETVAL
3915
3916 int
3917 GFXFilledCircleRGBA ( dst, x, y, rad, r, g, b, a )
3918         SDL_Surface* dst
3919         Sint16 x
3920         Sint16 y
3921         Sint16 rad
3922         Uint8 r
3923         Uint8 g
3924         Uint8 b
3925         Uint8 a
3926         CODE:
3927                 RETVAL = filledCircleRGBA( dst, x, y, rad, r, g, b, a );
3928         OUTPUT:
3929                 RETVAL
3930
3931 int
3932 GFXEllipseColor ( dst, x, y, rx, ry, color )
3933         SDL_Surface* dst
3934         Sint16 x
3935         Sint16 y
3936         Sint16 rx
3937         Sint16 ry
3938         Uint32 color
3939         CODE:
3940                 RETVAL = ellipseColor( dst, x, y, rx, ry, color );
3941         OUTPUT:
3942                 RETVAL
3943
3944 int
3945 GFXEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
3946         SDL_Surface* dst
3947         Sint16 x
3948         Sint16 y
3949         Sint16  rx
3950         Sint16 ry
3951         Uint8 r
3952         Uint8 g
3953         Uint8 b
3954         Uint8 a
3955         CODE:
3956                 RETVAL = ellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
3957         OUTPUT:
3958                 RETVAL
3959
3960 int
3961 GFXAaellipseColor ( dst, xc, yc, rx, ry, color )
3962         SDL_Surface* dst
3963         Sint16 xc
3964         Sint16 yc
3965         Sint16 rx
3966         Sint16 ry
3967         Uint32 color
3968         CODE:
3969                 RETVAL = aaellipseColor( dst, xc, yc, rx, ry, color );
3970         OUTPUT:
3971                 RETVAL
3972
3973 int
3974 GFXAaellipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
3975         SDL_Surface* dst
3976         Sint16 x
3977         Sint16 y
3978         Sint16 rx
3979         Sint16 ry
3980         Uint8 r
3981         Uint8 g
3982         Uint8 b
3983         Uint8 a
3984         CODE:
3985                 RETVAL = aaellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
3986         OUTPUT:
3987                 RETVAL
3988
3989 int
3990 GFXFilledEllipseColor ( dst, x, y, rx, ry, color )
3991         SDL_Surface* dst
3992         Sint16 x
3993         Sint16 y
3994         Sint16 rx
3995         Sint16 ry
3996         Uint32 color
3997         CODE:
3998                 RETVAL = filledEllipseColor( dst, x, y, rx, ry, color );
3999         OUTPUT:
4000                 RETVAL
4001
4002 int
4003 GFXFilledEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
4004         SDL_Surface* dst
4005         Sint16 x
4006         Sint16 y
4007         Sint16 rx
4008         Sint16 ry
4009         Uint8 r
4010         Uint8 g
4011         Uint8 b
4012         Uint8 a
4013         CODE:
4014                 RETVAL = filledEllipseRGBA( dst, x, y, rx, ry, r, g, b, a );
4015         OUTPUT:
4016                 RETVAL
4017
4018 int
4019 GFXFilledPieColor ( dst, x, y, rad, start, end, color )
4020         SDL_Surface* dst
4021         Sint16 x
4022         Sint16 y
4023         Sint16 rad
4024         Sint16 start
4025         Sint16 end
4026         Uint32 color
4027         CODE:
4028                 RETVAL = filledPieColor( dst, x, y, rad, start, end, color );
4029         OUTPUT:
4030                 RETVAL
4031
4032 int
4033 GFXFilledPieRGBA ( dst, x, y, rad, start, end, r, g, b, a )
4034         SDL_Surface* dst
4035         Sint16 x
4036         Sint16 y
4037         Sint16 rad
4038         Sint16 start
4039         Sint16 end
4040         Uint8 r
4041         Uint8 g
4042         Uint8 b
4043         Uint8 a
4044         CODE:
4045                 RETVAL = filledPieRGBA( dst, x, y, rad, start, end, r, g, b, a );
4046         OUTPUT:
4047                 RETVAL
4048
4049 int
4050 GFXPolygonColor ( dst, vx, vy, n, color )
4051         SDL_Surface* dst
4052         Sint16* vx
4053         Sint16* vy
4054         int n
4055         Uint32 color;
4056         CODE:
4057                 RETVAL = polygonColor( dst, vx, vy, n, color );
4058         OUTPUT:
4059                 RETVAL
4060
4061 int
4062 GFXPolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4063         SDL_Surface* dst
4064         Sint16* vx
4065         Sint16* vy
4066         int n
4067         Uint8 r
4068         Uint8 g
4069         Uint8 b
4070         Uint8 a
4071         CODE:
4072                 RETVAL = polygonRGBA( dst, vx, vy, n, r, g, b, a );
4073         OUTPUT:
4074                 RETVAL
4075
4076 int
4077 GFXAapolygonColor ( dst, vx, vy, n, color )
4078         SDL_Surface* dst
4079         Sint16* vx
4080         Sint16* vy
4081         int n
4082         Uint32 color
4083         CODE:
4084                 RETVAL = aapolygonColor( dst, vx, vy, n, color );
4085         OUTPUT:
4086                 RETVAL
4087
4088 int
4089 GFXAapolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4090         SDL_Surface* dst
4091         Sint16* vx
4092         Sint16* vy
4093         int n
4094         Uint8 r
4095         Uint8 g
4096         Uint8 b
4097         Uint8 a
4098         CODE:
4099                 RETVAL = aapolygonRGBA( dst, vx, vy, n, r, g, b, a );
4100         OUTPUT:
4101                 RETVAL
4102
4103 int
4104 GFXFilledPolygonColor ( dst, vx, vy, n, color )
4105         SDL_Surface* dst
4106         Sint16* vx
4107         Sint16* vy
4108         int n
4109         int color
4110         CODE:
4111                 RETVAL = filledPolygonColor( dst, vx, vy, n, color );
4112         OUTPUT:
4113                 RETVAL
4114
4115 int
4116 GFXFilledPolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4117         SDL_Surface* dst
4118         Sint16* vx
4119         Sint16* vy
4120         int n
4121         Uint8 r
4122         Uint8 g
4123         Uint8 b
4124         Uint8 a
4125         CODE:
4126                 RETVAL = filledPolygonRGBA( dst, vx, vy, n, r, g, b, a );
4127         OUTPUT:
4128                 RETVAL
4129
4130 int
4131 GFXCharacterColor ( dst, x, y, c, color )
4132         SDL_Surface* dst
4133         Sint16 x
4134         Sint16 y
4135         char c
4136         Uint32 color
4137         CODE:
4138                 RETVAL = characterColor( dst, x, y, c, color );
4139         OUTPUT:
4140                 RETVAL
4141
4142 int
4143 GFXCharacterRGBA ( dst, x, y, c, r, g, b, a )
4144         SDL_Surface* dst
4145         Sint16 x
4146         Sint16 y
4147         char c
4148         Uint8 r
4149         Uint8 g
4150         Uint8 b
4151         Uint8 a
4152         CODE:
4153                 RETVAL = characterRGBA( dst, x, y, c, r, g, b, a );
4154         OUTPUT:
4155                 RETVAL
4156
4157 int
4158 GFXStringColor ( dst, x, y, c, color )
4159         SDL_Surface* dst
4160         Sint16 x
4161         Sint16 y
4162         char* c
4163         Uint32 color
4164         CODE:
4165                 RETVAL = stringColor( dst, x, y, c, color );
4166         OUTPUT:
4167                 RETVAL
4168
4169 int
4170 GFXStringRGBA ( dst, x, y, c, r, g, b, a )
4171         SDL_Surface* dst
4172         Sint16 x
4173         Sint16 y
4174         char* c
4175         Uint8 r
4176         Uint8 g
4177         Uint8 b
4178         Uint8 a
4179         CODE:
4180                 RETVAL = stringRGBA( dst, x, y, c, r, g, b, a );
4181         OUTPUT:
4182                 RETVAL
4183
4184 #endif
4185
4186
4187 #ifdef HAVE_SDL_SVG
4188
4189 SDL_svg_context *
4190 SVG_Load ( filename )
4191         char* filename
4192         CODE:
4193                 RETVAL = SVG_Load(filename);
4194         OUTPUT:
4195                 RETVAL
4196
4197 SDL_svg_context *
4198 SVG_LoadBuffer ( data, len )
4199         char* data
4200         int len
4201         CODE:
4202                 RETVAL = SVG_LoadBuffer(data,len);
4203         OUTPUT:
4204                 RETVAL
4205
4206 int
4207 SVG_SetOffset ( source, xoff, yoff )
4208         SDL_svg_context* source
4209         double xoff
4210         double yoff
4211         CODE:
4212                 RETVAL = SVG_SetOffset(source,xoff,yoff);
4213         OUTPUT:
4214                 RETVAL
4215
4216 int
4217 SVG_SetScale ( source, xscale, yscale )
4218         SDL_svg_context* source
4219         double xscale
4220         double yscale
4221         CODE:
4222                 RETVAL = SVG_SetScale(source,xscale,yscale);
4223         OUTPUT:
4224                 RETVAL
4225
4226 int
4227 SVG_RenderToSurface ( source, x, y, dest )
4228         SDL_svg_context* source
4229         int x
4230         int y
4231         SDL_Surface* dest;
4232         CODE:
4233                 RETVAL = SVG_RenderToSurface(source,x,y,dest);
4234         OUTPUT:
4235                 RETVAL
4236
4237 void
4238 SVG_Free ( source )
4239         SDL_svg_context* source
4240         CODE:
4241                 SVG_Free(source);       
4242
4243 void
4244 SVG_Set_Flags ( source, flags )
4245         SDL_svg_context* source
4246         Uint32 flags
4247         CODE:
4248                 SVG_Set_Flags(source,flags);
4249
4250 float
4251 SVG_Width ( source )
4252         SDL_svg_context* source
4253         CODE:
4254                 RETVAL = SVG_Width(source);
4255         OUTPUT:
4256                 RETVAL
4257
4258 float
4259 SVG_HEIGHT ( source )
4260         SDL_svg_context* source
4261         CODE:
4262                 RETVAL = SVG_Height(source);
4263         OUTPUT:
4264                 RETVAL
4265
4266 void
4267 SVG_SetClipping ( source, minx, miny, maxx, maxy )
4268         SDL_svg_context* source
4269         int minx
4270         int miny
4271         int maxx
4272         int maxy
4273         CODE:
4274                 SVG_SetClipping(source,minx,miny,maxx,maxy);
4275
4276 int
4277 SVG_Version ( )
4278         CODE:
4279                 RETVAL = SVG_Version();
4280         OUTPUT:
4281                 RETVAL
4282
4283
4284 #endif
4285
4286 #ifdef HAVE_SDL_SOUND
4287
4288 Uint16
4289 SoundAudioInfoFormat ( audioinfo )
4290         Sound_AudioInfo* audioinfo
4291         CODE:
4292                 RETVAL = audioinfo->format;
4293         OUTPUT:
4294                 RETVAL
4295
4296 Uint8
4297 SoundAudioInfoChannels ( audioinfo )
4298         Sound_AudioInfo* audioinfo
4299         CODE:
4300                 RETVAL = audioinfo->channels;
4301         OUTPUT:
4302                 RETVAL
4303
4304 Uint32
4305 SoundAudioInforate ( audioinfo )
4306         Sound_AudioInfo* audioinfo
4307         CODE:
4308                 RETVAL = audioinfo->rate;
4309         OUTPUT:
4310                 RETVAL
4311
4312 AV*
4313 SoundDecoderInfoExtensions ( decoderinfo )
4314         Sound_DecoderInfo* decoderinfo
4315         CODE:
4316                 const char **ext;
4317                 for ( ext = decoderinfo->extensions; *ext != NULL; ext++ ){
4318                         av_push(RETVAL,newSVpv(*ext,0));
4319                 }
4320         OUTPUT:
4321                 RETVAL
4322
4323 const char*
4324 SoundDecoderInfoDescription ( decoderinfo )
4325         Sound_DecoderInfo* decoderinfo
4326         CODE:
4327                 RETVAL = decoderinfo->description;
4328         OUTPUT:
4329                 RETVAL
4330
4331 const char*
4332 SoundDecoderInfoAuthor ( decoderinfo )
4333         Sound_DecoderInfo* decoderinfo
4334         CODE:
4335                 RETVAL = decoderinfo->author;
4336         OUTPUT:
4337                 RETVAL
4338
4339 const char*
4340 SoundDecoderInfoUrl ( decoderinfo )
4341         Sound_DecoderInfo* decoderinfo
4342         CODE:
4343                 RETVAL = decoderinfo->url;
4344         OUTPUT:
4345                 RETVAL
4346
4347 const Sound_DecoderInfo*
4348 SoundSampleDecoder ( sample ) 
4349         Sound_Sample* sample
4350         CODE:
4351                 RETVAL = sample->decoder;
4352         OUTPUT:
4353                 RETVAL
4354
4355 Sound_AudioInfo* 
4356 SoundSampleDesired ( sample )
4357         Sound_Sample* sample
4358         CODE:
4359                 RETVAL = &sample->desired;
4360         OUTPUT:
4361                 RETVAL
4362
4363 Sound_AudioInfo*
4364 SoundSampleAcutal ( sample )
4365         Sound_Sample* sample
4366         CODE:
4367                 RETVAL = &sample->actual;
4368         OUTPUT:
4369                 RETVAL
4370
4371 char*
4372 SoundSampleBuffer ( sample )
4373         Sound_Sample* sample
4374         CODE:
4375                 RETVAL = sample->buffer;
4376         OUTPUT:
4377                 RETVAL
4378
4379 Uint32
4380 SoundSampleBufferSize ( sample )
4381         Sound_Sample* sample
4382         CODE:
4383                 RETVAL = sample->buffer_size;
4384         OUTPUT:
4385                 RETVAL
4386
4387 Uint32
4388 SoundSampleFlags ( sample )
4389         Sound_Sample* sample
4390         CODE:
4391                 RETVAL = (Uint32)sample->flags;
4392         OUTPUT:
4393                 RETVAL
4394
4395 int
4396 Sound_Init ( )
4397         CODE:
4398                 RETVAL = Sound_Init();
4399         OUTPUT:
4400                 RETVAL
4401
4402 int
4403 Sound_Quit ( )
4404         CODE:
4405                 RETVAL = Sound_Quit();
4406         OUTPUT:
4407                 RETVAL
4408
4409 AV*
4410 Sound_AvailableDecoders ( )
4411         CODE:
4412                 RETVAL = newAV();
4413                 const Sound_DecoderInfo** sdi;
4414                 sdi = Sound_AvailableDecoders();
4415                 if (sdi != NULL)  {
4416                         for (;*sdi != NULL; ++sdi) {
4417                                 av_push(RETVAL,sv_2mortal(newSViv(PTR2IV(*sdi))));
4418                         }
4419                 }
4420         OUTPUT:
4421                 RETVAL
4422
4423 const char*
4424 Sound_GetError ( )
4425         CODE:
4426                 RETVAL = Sound_GetError();
4427         OUTPUT:
4428                 RETVAL
4429
4430 void
4431 Sound_ClearError ( )
4432         CODE:
4433                 Sound_ClearError();
4434
4435 Sound_Sample*
4436 Sound_NewSample ( rw, ext, desired, buffsize )
4437         SDL_RWops* rw
4438         const char* ext
4439         Sound_AudioInfo* desired
4440         Uint32 buffsize
4441         CODE:
4442                 RETVAL = Sound_NewSample(rw,ext,desired,buffsize);
4443         OUTPUT:
4444                 RETVAL
4445
4446 Sound_Sample*
4447 Sound_NewSampleFromMem ( data, size, ext, desired, buffsize )
4448         const Uint8 *data
4449         Uint32 size
4450         const char* ext
4451         Sound_AudioInfo* desired
4452         Uint32 buffsize
4453         CODE:
4454                 RETVAL = Sound_NewSampleFromMem(data,size,ext,desired,buffsize);
4455         OUTPUT:
4456                 RETVAL
4457
4458 Sound_Sample*
4459 Sound_NewSampleFromFile ( fname, desired, buffsize )
4460         const char* fname
4461         Sound_AudioInfo* desired
4462         Uint32 buffsize
4463         CODE:
4464                 RETVAL = Sound_NewSampleFromFile(fname,desired,buffsize);
4465         OUTPUT:
4466                 RETVAL
4467
4468 void
4469 Sound_FreeSample ( sample )
4470         Sound_Sample* sample
4471         CODE:
4472                 Sound_FreeSample(sample);
4473
4474 Sint32
4475 Sound_GetDuration ( sample )
4476         Sound_Sample* sample
4477         CODE:
4478                 RETVAL = Sound_GetDuration(sample);
4479         OUTPUT:
4480                 RETVAL
4481
4482 int
4483 Sound_SetBufferSize ( sample, size )
4484         Sound_Sample* sample
4485         Uint32 size
4486         CODE:
4487                 RETVAL = Sound_SetBufferSize(sample,size);
4488         OUTPUT:
4489                 RETVAL
4490
4491 Uint32
4492 Sound_Decode ( sample )
4493         Sound_Sample* sample
4494         CODE:
4495                 RETVAL = Sound_Decode(sample);
4496         OUTPUT:
4497                 RETVAL
4498
4499 Uint32
4500 Sound_DecodeAll ( sample ) 
4501         Sound_Sample* sample
4502         CODE:
4503                 RETVAL = Sound_DecodeAll(sample);
4504         OUTPUT:
4505                 RETVAL
4506
4507 int
4508 Sound_Rewind ( sample )
4509         Sound_Sample* sample
4510         CODE:
4511                 RETVAL = Sound_Rewind(sample);
4512         OUTPUT:
4513                 RETVAL
4514
4515 int
4516 Sound_Seek ( sample, ms )
4517         Sound_Sample* sample
4518         Uint32 ms
4519         CODE:
4520                 RETVAL = Sound_Seek(sample,ms);
4521         OUTPUT:
4522                 RETVAL
4523
4524 #endif
4525
4526 MODULE = SDL            PACKAGE = SDL
4527 PROTOTYPES : DISABLE
4528
4529