Move display format and display format alpha out of Surface.xs
[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 #ifdef HAVE_SDL_IMAGE
862
863 SDL_Surface *
864 IMG_Load ( filename )
865         char *filename
866         CODE:
867                 char* CLASS = "SDL::Surface";
868                 RETVAL = IMG_Load(filename);
869         OUTPUT:
870                 RETVAL
871
872 #endif
873
874 =for comment
875
876 Comment out for now as it does not compile
877
878 SDL_Surface *
879 CreateRGBSurfaceFrom (pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask )
880         char *pixels
881         int width
882         int height
883         int depth
884         int pitch
885         Uint32 Rmask
886         Uint32 Gmask
887         Uint32 Bmask
888         Uint32 Amask
889         CODE:
890                 Uint8* pixeldata;
891                 Uint32 len = pitch * height;
892                 New(0,pixeldata,len,Uint8);
893                 Copy(pixels,pixeldata,len,Uint8);
894                 RETVAL = SDL_CreateRGBSurfaceFrom ( pixeldata, width, height,
895                                 depth, pitch, Rmask, Gmask, Bmask, Amask );
896         OUTPUT: 
897                 RETVAL
898
899 SDL_Surface*
900 SurfaceCopy ( surface )
901         SDL_Surface *surface
902         CODE:
903                 Uint8* pixels;
904                 Uint32 size = surface->pitch * surface->h;
905                 New(0,pixels,size,Uint8);
906                 Copy(surface->pixels,pixels,size,Uint8);
907                 RETVAL = SDL_CreateRGBSurfaceFrom(pixels,surface->w,surface->h,
908                         surface->format->BitsPerPixel, surface->pitch,
909                         surface->format->Rmask, surface->format->Gmask,
910                         surface->format->Bmask, surface->format->Amask);
911         OUTPUT:
912                 RETVAL
913
914 void
915 FreeSurface ( surface )
916         SDL_Surface *surface
917         CODE:
918                 if (surface) {
919                         Uint8* pixels = surface->pixels;
920                         Uint32 flags = surface->flags;
921                         SDL_FreeSurface(surface);
922                         if (flags & SDL_PREALLOC)
923                                 Safefree(pixels);
924                 }
925         
926 Uint32
927 SurfaceFlags ( surface )
928         SDL_Surface *surface
929         CODE:
930                 RETVAL = surface->flags;
931         OUTPUT:
932                 RETVAL
933
934 SDL_Palette *
935 SurfacePalette ( surface )
936         SDL_Surface *surface
937         CODE:
938                 RETVAL = surface->format->palette;
939         OUTPUT:
940                 RETVAL
941
942 Uint8
943 SurfaceBitsPerPixel ( surface )
944         SDL_Surface *surface
945         CODE:
946                 RETVAL = surface->format->BitsPerPixel;
947         OUTPUT:
948                 RETVAL
949
950 Uint8
951 SurfaceBytesPerPixel ( surface )
952         SDL_Surface *surface
953         CODE:   
954                 RETVAL = surface->format->BytesPerPixel;
955         OUTPUT:
956                 RETVAL
957
958 Uint8
959 SurfaceRshift ( surface )
960         SDL_Surface *surface
961         CODE:
962                 RETVAL = surface->format->Rshift;
963         OUTPUT:
964                 RETVAL
965
966 Uint8
967 SurfaceGshift ( surface )
968         SDL_Surface *surface
969         CODE:
970                 RETVAL = surface->format->Gshift;
971         OUTPUT:
972                 RETVAL
973
974 Uint8
975 SurfaceBshift ( surface )
976         SDL_Surface *surface
977         CODE:
978                 RETVAL = surface->format->Bshift;
979         OUTPUT:
980                 RETVAL
981
982 Uint8
983 SurfaceAshift ( surface )
984         SDL_Surface *surface
985         CODE:
986                 RETVAL = surface->format->Ashift;
987         OUTPUT:
988                 RETVAL
989
990 Uint32
991 SurfaceRmask( surface )
992         SDL_Surface *surface
993         CODE:
994                 RETVAL = surface->format->Rmask;
995         OUTPUT:
996                 RETVAL
997
998 Uint32
999 SurfaceGmask ( surface )
1000         SDL_Surface *surface
1001         CODE:
1002                 RETVAL = surface->format->Gmask;
1003         OUTPUT:
1004                 RETVAL
1005
1006 Uint32
1007 SurfaceBmask ( surface )
1008         SDL_Surface *surface
1009         CODE:
1010                 RETVAL = surface->format->Bmask;
1011         OUTPUT:
1012                 RETVAL
1013
1014 Uint32
1015 SurfaceAmask ( surface )
1016         SDL_Surface *surface
1017         CODE:
1018                 RETVAL = surface->format->Amask;
1019         OUTPUT:
1020                 RETVAL
1021
1022 Uint32
1023 SurfaceColorKey ( surface )
1024         SDL_Surface *surface
1025         CODE:
1026                 RETVAL = surface->format->colorkey;
1027         OUTPUT:
1028                 RETVAL
1029
1030 Uint32
1031 SurfaceAlpha( surface )
1032         SDL_Surface *surface
1033         CODE:
1034                 RETVAL = surface->format->alpha;
1035         OUTPUT:
1036                 RETVAL
1037
1038 int
1039 SurfaceW ( surface )
1040         SDL_Surface *surface
1041         CODE:   
1042                 RETVAL = surface->w;
1043         OUTPUT:
1044                 RETVAL
1045
1046 int
1047 SurfaceH ( surface )
1048         SDL_Surface *surface
1049         CODE:   
1050                 RETVAL = surface->h;
1051         OUTPUT:
1052                 RETVAL
1053
1054 Uint16
1055 SurfacePitch ( surface )
1056         SDL_Surface *surface
1057         CODE:   
1058                 RETVAL = surface->pitch;
1059         OUTPUT:
1060                 RETVAL
1061
1062 SV*
1063 SurfacePixels ( surface )
1064         SDL_Surface *surface
1065         CODE:   
1066                 RETVAL = newSVpvn(surface->pixels,surface->pitch*surface->h);
1067         OUTPUT:
1068                 RETVAL
1069
1070 =cut
1071
1072 =for comment
1073
1074 Comment out for now as it does not compile
1075
1076 SDL_Color*
1077 SurfacePixel ( surface, x, y, ... )
1078         SDL_Surface *surface
1079         Sint32 x
1080         Sint32 y
1081         CODE:
1082                 SDL_Color* color;
1083                 int pix,index;
1084                 Uint8 r,g,b,a;
1085                 int bpp = surface->format->BytesPerPixel;
1086                 Uint8* p = (Uint8*)surface->pixels + bpp*x + surface->pitch*y;
1087                 if ( items < 3 || items > 4 ) 
1088                         Perl_croak(aTHX_ "usage: SDL::SurfacePixel(surface,x,y,[color])");
1089                 if ( items == 4) {
1090                         color = (SDL_Color*)SvIV(ST(3));
1091                         pix = SDL_MapRGB(surface->format,color->r,color->g,color->b);
1092                         switch(bpp) {
1093                                 case 1:
1094                                         *(Uint8*)p = pix;
1095                                         break;
1096                                 case 2:
1097                                         *(Uint16*)p = pix;
1098                                         break;
1099                                 case 3:
1100                                         if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
1101                                                 p[0] = (pix >> 16) & 0xff;
1102                                                 p[1] = (pix >> 8) & 0xff;
1103                                                 p[2] = pix & 0xff;
1104                                         } else {
1105                                                 p[0] = pix & 0xff;
1106                                                 p[1] = (pix >> 8) & 0xff;
1107                                                 p[2] = (pix >> 16) & 0xff;
1108                                         }
1109                                         break;
1110                                 case 4:
1111                                         *(Uint32*)p = pix;
1112                                         break;
1113                         }
1114                 }
1115                 RETVAL = (SDL_Color *) safemalloc(sizeof(SDL_Color));
1116                 switch(bpp) {
1117                         case 1:
1118                                 index = *(Uint8*)p;
1119                                 memcpy(RETVAL,&surface->format->palette[index],sizeof(SDL_Color));
1120                                 break;
1121                         case 2:
1122                                 pix = *(Uint16*)p;
1123                                 SDL_GetRGB(pix,surface->format,&r,&g,&b);
1124                                 RETVAL->r = r;
1125                                 RETVAL->g = g;
1126                                 RETVAL->b = b;
1127                                 break;
1128                         case 3:
1129                         case 4:
1130                                 pix = *(Uint32*)p;
1131                                 SDL_GetRGB(pix,surface->format,&r,&g,&b);
1132                                 RETVAL->r = r;
1133                                 RETVAL->g = g;
1134                                 RETVAL->b = b;
1135                                 break;
1136                 }
1137         OUTPUT:
1138                 RETVAL
1139
1140 int
1141 MUSTLOCK ( surface )
1142         SDL_Surface *surface
1143         CODE:
1144                 RETVAL = SDL_MUSTLOCK(surface);
1145         OUTPUT:
1146                 RETVAL          
1147
1148 int
1149 SurfaceLock ( surface )
1150         SDL_Surface *surface
1151         CODE:
1152                 RETVAL = SDL_LockSurface(surface);
1153         OUTPUT:
1154                 RETVAL
1155
1156 void
1157 SurfaceUnlock ( surface )
1158         SDL_Surface *surface
1159         CODE:
1160                 SDL_UnlockSurface(surface);
1161
1162 SDL_Surface *
1163 GetVideoSurface ()
1164         CODE:
1165                 RETVAL = SDL_GetVideoSurface();
1166         OUTPUT:
1167                 RETVAL
1168
1169 =cut
1170
1171 HV *
1172 VideoInfo ()
1173         CODE:
1174                 HV *hv;
1175                 SDL_VideoInfo *info;
1176                 info = (SDL_VideoInfo *) safemalloc ( sizeof(SDL_VideoInfo));
1177                 memcpy(info,SDL_GetVideoInfo(),sizeof(SDL_VideoInfo));
1178                 hv = newHV();
1179                 hv_store(hv,"hw_available",strlen("hw_available"),
1180                         newSViv(info->hw_available),0);
1181                 hv_store(hv,"wm_available",strlen("wm_available"),
1182                         newSViv(info->wm_available),0);
1183                 hv_store(hv,"blit_hw",strlen("blit_hw"),
1184                         newSViv(info->blit_hw),0);
1185                 hv_store(hv,"blit_hw_CC",strlen("blit_hw_CC"),
1186                         newSViv(info->blit_hw_CC),0);
1187                 hv_store(hv,"blit_hw_A",strlen("blit_hw_A"),
1188                         newSViv(info->blit_hw_A),0);
1189                 hv_store(hv,"blit_sw",strlen("blit_sw"),
1190                         newSViv(info->blit_sw),0);
1191                 hv_store(hv,"blit_sw_CC",strlen("blit_sw_CC"),
1192                         newSViv(info->blit_sw_CC),0);
1193                 hv_store(hv,"blit_sw_A",strlen("blit_sw_A"),
1194                         newSViv(info->blit_sw_A),0);
1195                 hv_store(hv,"blit_fill",strlen("blit_fill"),
1196                         newSViv(info->blit_fill),0);
1197                 hv_store(hv,"video_mem",strlen("video_mem"),
1198                         newSViv(info->video_mem),0);
1199                 RETVAL = hv;
1200         OUTPUT:
1201                 RETVAL
1202
1203 AV*
1204 ListModes ( format, flags )
1205         Uint32 flags
1206         SDL_PixelFormat *format
1207         CODE:
1208                 SDL_Rect **mode;
1209                 RETVAL = newAV();
1210                 mode = SDL_ListModes(format,flags);
1211                 if (mode == (SDL_Rect**)-1 ) {
1212                         av_push(RETVAL,newSVpv("all",0));
1213                 } else if (! mode ) {
1214                         av_push(RETVAL,newSVpv("none",0));
1215                 } else {
1216                         for (;*mode;mode++) {
1217                                 av_push(RETVAL,newSViv(PTR2IV(*mode)));
1218                         }
1219                 }
1220         OUTPUT:
1221                 RETVAL
1222
1223 SDL_Palette *
1224 NewPalette ( number )
1225         int number
1226         CODE:
1227                 RETVAL = (SDL_Palette *)safemalloc(sizeof(SDL_Palette));
1228                 RETVAL->colors = (SDL_Color *)safemalloc(number * 
1229                                                 sizeof(SDL_Color));
1230                 RETVAL->ncolors = number;
1231         OUTPUT:
1232                 RETVAL
1233
1234 int
1235 PaletteNColors ( palette, ... )
1236         SDL_Palette *palette
1237         CODE:
1238                 if ( items > 1 ) palette->ncolors = SvIV(ST(1));
1239                 RETVAL = palette->ncolors;
1240         OUTPUT:
1241                 RETVAL
1242
1243 SDL_Surface *
1244 SetVideoMode ( width, height, bpp, flags )
1245
1246         int width
1247         int height
1248         int bpp
1249         Uint32 flags
1250
1251         CODE:
1252                 char *CLASS = "SDL::Surface";
1253                 RETVAL = SDL_SetVideoMode(width,height,bpp,flags);
1254         OUTPUT:
1255                 RETVAL
1256
1257 int
1258 Flip ( surface )
1259         SDL_Surface *surface
1260         CODE:
1261                 RETVAL = SDL_Flip(surface);
1262         OUTPUT:
1263                 RETVAL
1264
1265 int
1266 BlitSurface ( src, src_rect, dest, dest_rect )
1267         SDL_Surface *src
1268         SDL_Surface *dest
1269         SDL_Rect *src_rect
1270         SDL_Rect *dest_rect
1271         CODE:
1272                 RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect);
1273         OUTPUT:
1274                 RETVAL
1275
1276 Uint32
1277 MapRGB ( pixel_format, r, g, b )
1278         SDL_PixelFormat *pixel_format
1279         Uint8 r
1280         Uint8 g
1281         Uint8 b
1282         CODE:
1283                 RETVAL = SDL_MapRGB(pixel_format,r,g,b);
1284         OUTPUT:
1285                 RETVAL
1286
1287 void
1288 UpdateRect ( surface, x, y, w ,h )
1289         SDL_Surface *surface
1290         int x
1291         int y
1292         int w
1293         int h
1294         CODE:
1295                 SDL_UpdateRect(surface,x,y,w,h);
1296
1297 SDL_Surface *
1298 DisplayFormat ( surface )
1299         SDL_Surface *surface
1300         CODE:
1301                 char* CLASS = "SDL::Surface";
1302                 RETVAL = SDL_DisplayFormat(surface);
1303         OUTPUT:
1304                 RETVAL
1305
1306 SDL_Surface *
1307 DisplayFormatAlpha ( surface )
1308         SDL_Surface *surface
1309         CODE:
1310                 char* CLASS = "SDL::Surface";
1311                 RETVAL = SDL_DisplayFormatAlpha(surface);
1312         OUTPUT:
1313                 RETVAL
1314
1315 =for comment
1316
1317 Comment out for now as it does not compile
1318
1319 SDL_Color *
1320 PaletteColors ( palette, index, ... )
1321         SDL_Palette *palette
1322         int index
1323         CODE:
1324                 if ( items > 2 ) {
1325                         palette->colors[index].r = SvUV(ST(2)); 
1326                         palette->colors[index].g = SvUV(ST(3)); 
1327                         palette->colors[index].b = SvUV(ST(4)); 
1328                 }
1329                 RETVAL = (SDL_Color *)(palette->colors + index);
1330         OUTPUT:
1331                 RETVAL
1332
1333
1334
1335 int
1336 VideoModeOK ( width, height, bpp, flags )
1337         int width
1338         int height
1339         int bpp
1340         Uint32 flags
1341         CODE:
1342                 RETVAL = SDL_VideoModeOK(width,height,bpp,flags);
1343         OUTPUT:
1344                 RETVAL
1345
1346 SDL_Surface *
1347 SetVideoMode ( width, height, bpp, flags )
1348         int width
1349         int height
1350         int bpp
1351         Uint32 flags
1352         CODE:
1353                 RETVAL = SDL_SetVideoMode(width,height,bpp,flags);
1354         OUTPUT:
1355                 RETVAL
1356
1357 void
1358 UpdateRects ( surface, ... )
1359         SDL_Surface *surface
1360         CODE:
1361                 SDL_Rect *rects, *temp;
1362                 int num_rects,i;
1363                 if ( items < 2 ) return;
1364                 num_rects = items - 1;
1365                 SDL_UpdateRects(surface,num_rects,rects);                       
1366                 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
1367                 for(i=0;i<num_rects;i++) {
1368                         temp = (SDL_Rect *)SvIV(ST(i+1));
1369                         rects[i].x = temp->x;
1370                         rects[i].y = temp->y;
1371                         rects[i].w = temp->w;
1372                         rects[i].h = temp->h;
1373                 } 
1374                 SDL_UpdateRects(surface,num_rects,rects);
1375                 safefree(rects);
1376
1377 int
1378 Flip ( surface )
1379         SDL_Surface *surface
1380         CODE:
1381                 RETVAL = SDL_Flip(surface);
1382         OUTPUT:
1383                 RETVAL
1384
1385 int
1386 SetColors ( surface, start, ... )
1387         SDL_Surface *surface
1388         int start
1389         CODE:
1390                 SDL_Color *colors,*temp;
1391                 int i, length;
1392                 if ( items < 3 ) { RETVAL = 0;  goto all_done; }
1393                 length = items - 2;
1394                 colors = (SDL_Color *)safemalloc(sizeof(SDL_Color)*(length+1));
1395                 for ( i = 0; i < length ; i++ ) {
1396                         temp = (SDL_Color *)SvIV(ST(i+2));
1397                         colors[i].r = temp->r;
1398                         colors[i].g = temp->g;
1399                         colors[i].b = temp->b;
1400                 }
1401                 RETVAL = SDL_SetColors(surface, colors, start, length );
1402                 safefree(colors);
1403 all_done:
1404         OUTPUT: 
1405                 RETVAL
1406
1407 Uint32
1408 MapRGBA ( surface, r, g, b, a )
1409         SDL_Surface *surface
1410         Uint8 r
1411         Uint8 g
1412         Uint8 b
1413         Uint8 a
1414         CODE:
1415                 RETVAL = SDL_MapRGBA(surface->format,r,g,b,a);
1416         OUTPUT:
1417                 RETVAL
1418
1419 AV *
1420 GetRGB ( surface, pixel )
1421         SDL_Surface *surface
1422         Uint32 pixel
1423         CODE:
1424                 Uint8 r,g,b;
1425                 SDL_GetRGB(pixel,surface->format,&r,&g,&b);
1426                 RETVAL = newAV();
1427                 av_push(RETVAL,newSViv(r));
1428                 av_push(RETVAL,newSViv(g));
1429                 av_push(RETVAL,newSViv(b));
1430         OUTPUT:
1431                 RETVAL
1432
1433 AV *
1434 GetRGBA ( surface, pixel )
1435         SDL_Surface *surface
1436         Uint32 pixel
1437         CODE:
1438                 Uint8 r,g,b,a;
1439                 SDL_GetRGBA(pixel,surface->format,&r,&g,&b,&a);
1440                 RETVAL = newAV();
1441                 av_push(RETVAL,newSViv(r));
1442                 av_push(RETVAL,newSViv(g));
1443                 av_push(RETVAL,newSViv(b));
1444                 av_push(RETVAL,newSViv(a));
1445         OUTPUT:
1446                 RETVAL
1447
1448 int
1449 SaveBMP ( surface, filename )
1450         SDL_Surface *surface
1451         char *filename
1452         CODE:
1453                 RETVAL = SDL_SaveBMP(surface,filename);
1454         OUTPUT:
1455                 RETVAL  
1456
1457 int
1458 SetColorKey ( surface, flag, key )
1459         SDL_Surface *surface
1460         Uint32 flag
1461         SDL_Color *key
1462         CODE:
1463                 Uint32 pixel = SDL_MapRGB(surface->format,key->r,key->g,key->b);
1464                 RETVAL = SDL_SetColorKey(surface,flag,pixel);
1465         OUTPUT:
1466                 RETVAL
1467
1468 int
1469 SetAlpha ( surface, flag, alpha )
1470         SDL_Surface *surface
1471         Uint32 flag
1472         Uint8 alpha
1473         CODE:
1474                 RETVAL = SDL_SetAlpha(surface,flag,alpha);
1475         OUTPUT:
1476                 RETVAL
1477
1478 SDL_Surface*
1479 ConvertRGB ( surface )
1480         SDL_Surface * surface
1481         CODE:
1482                 SDL_PixelFormat fmt;
1483                 fmt.palette = NULL;
1484                 fmt.BitsPerPixel = 24;
1485                 fmt.BytesPerPixel = 3;
1486                 fmt.Rmask = 0x000000ff;
1487                 fmt.Gmask = 0x0000ff00;
1488                 fmt.Bmask = 0x00ff0000;
1489                 fmt.Amask = 0x00000000;
1490                 fmt.Rloss = 0;
1491                 fmt.Gloss = 0;
1492                 fmt.Bloss = 0;
1493                 fmt.Aloss = 0;
1494                 fmt.Rshift = 0;
1495                 fmt.Gshift = 8;
1496                 fmt.Bshift = 16;
1497                 fmt.Ashift = 24;
1498                 fmt.colorkey = 0;
1499                 fmt.alpha = 0;
1500                 RETVAL = SDL_ConvertSurface(surface,&fmt,surface->flags);
1501         OUTPUT:
1502                 RETVAL
1503
1504 SDL_Surface* 
1505 ConvertRGBA ( surface )
1506         SDL_Surface * surface
1507         CODE:
1508                 SDL_PixelFormat fmt;
1509                 fmt.palette = NULL;
1510                 fmt.BitsPerPixel = 32;
1511                 fmt.BytesPerPixel = 4;
1512                 fmt.Rmask = 0x000000ff;
1513                 fmt.Gmask = 0x0000ff00;
1514                 fmt.Bmask = 0x00ff0000;
1515                 fmt.Amask = 0xff000000;
1516                 fmt.Rloss = 0;
1517                 fmt.Gloss = 0;
1518                 fmt.Bloss = 0;
1519                 fmt.Aloss = 0;
1520                 fmt.Rshift = 0;
1521                 fmt.Gshift = 8;
1522                 fmt.Bshift = 16;
1523                 fmt.Ashift = 24;
1524                 fmt.colorkey = 0;
1525                 fmt.alpha = 0;
1526                 RETVAL = SDL_ConvertSurface(surface,&fmt,surface->flags);
1527         OUTPUT:
1528                 RETVAL
1529
1530 =cut
1531
1532 int
1533 FillRect ( dest, dest_rect, pixel )
1534         SDL_Surface *dest
1535         SDL_Rect *dest_rect
1536         Uint32 pixel
1537         CODE:
1538                 RETVAL = SDL_FillRect(dest,dest_rect,pixel);
1539         OUTPUT:
1540                 RETVAL
1541
1542 Uint8
1543 GetAppState ()
1544         CODE:
1545                 RETVAL = SDL_GetAppState();
1546         OUTPUT:
1547                 RETVAL
1548
1549
1550 void
1551 WMSetCaption ( title, icon )
1552         char *title
1553         char *icon
1554         CODE:
1555                 SDL_WM_SetCaption(title,icon);
1556
1557 AV *
1558 WMGetCaption ()
1559         CODE:
1560                 char *title,*icon;
1561                 SDL_WM_GetCaption(&title,&icon);
1562                 RETVAL = newAV();
1563                 av_push(RETVAL,newSVpv(title,0));
1564                 av_push(RETVAL,newSVpv(icon,0));
1565         OUTPUT:
1566                 RETVAL
1567
1568 void
1569 WMSetIcon ( icon )
1570         SDL_Surface *icon
1571         CODE:
1572                 SDL_WM_SetIcon(icon,NULL);
1573
1574 void
1575 WarpMouse ( x, y )
1576         Uint16 x
1577         Uint16 y
1578         CODE:
1579                 SDL_WarpMouse(x,y);
1580
1581 AV*
1582 GetMouseState ()
1583         CODE:
1584                 Uint8 mask;
1585                 int x;
1586                 int y;
1587                 mask = SDL_GetMouseState(&x,&y);
1588                 RETVAL = newAV();
1589                 av_push(RETVAL,newSViv(mask));
1590                 av_push(RETVAL,newSViv(x));
1591                 av_push(RETVAL,newSViv(y));
1592         OUTPUT:
1593                 RETVAL  
1594
1595 AV*
1596 GetRelativeMouseState ()
1597         CODE:
1598                 Uint8 mask;
1599                 int x;
1600                 int y;
1601                 mask = SDL_GetRelativeMouseState(&x,&y);
1602                 RETVAL = newAV();
1603                 av_push(RETVAL,newSViv(mask));
1604                 av_push(RETVAL,newSViv(x));
1605                 av_push(RETVAL,newSViv(y));
1606         OUTPUT:
1607                 RETVAL  
1608
1609 SDL_Cursor *
1610 NewCursor ( data, mask, x ,y )
1611         SDL_Surface *data
1612         SDL_Surface *mask
1613         int x
1614         int y
1615         CODE:
1616                 RETVAL = SDL_CreateCursor((Uint8*)data->pixels,
1617                                 (Uint8*)mask->pixels,data->w,data->h,x,y);
1618         OUTPUT:
1619                 RETVAL
1620
1621 void
1622 FreeCursor ( cursor )
1623         SDL_Cursor *cursor
1624         CODE:
1625                 SDL_FreeCursor(cursor);
1626
1627 void
1628 SetCursor ( cursor )
1629         SDL_Cursor *cursor
1630         CODE:
1631                 SDL_SetCursor(cursor);
1632
1633 SDL_Cursor *
1634 GetCursor ()
1635         CODE:
1636                 RETVAL = SDL_GetCursor();
1637         OUTPUT:
1638                 RETVAL
1639
1640 int
1641 ShowCursor ( toggle )
1642         int toggle
1643         CODE:
1644                 RETVAL = SDL_ShowCursor(toggle);
1645         OUTPUT: 
1646                 RETVAL
1647
1648 SDL_AudioSpec *
1649 NewAudioSpec ( freq, format, channels, samples )
1650         int freq
1651         Uint16 format
1652         Uint8 channels
1653         Uint16 samples
1654         CODE:
1655                 RETVAL = (SDL_AudioSpec *)safemalloc(sizeof(SDL_AudioSpec));
1656                 RETVAL->freq = freq;
1657                 RETVAL->format = format;
1658                 RETVAL->channels = channels;
1659                 RETVAL->samples = samples;
1660         OUTPUT:
1661                 RETVAL
1662
1663 void
1664 FreeAudioSpec ( spec )
1665         SDL_AudioSpec *spec
1666         CODE:
1667                 safefree(spec);
1668
1669 SDL_AudioCVT *
1670 NewAudioCVT ( src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate)
1671         Uint16 src_format
1672         Uint8 src_channels
1673         int src_rate
1674         Uint16 dst_format
1675         Uint8 dst_channels
1676         int dst_rate
1677         CODE:
1678                 RETVAL = (SDL_AudioCVT *)safemalloc(sizeof(SDL_AudioCVT));
1679                 if (SDL_BuildAudioCVT(RETVAL,src_format, src_channels, src_rate,
1680                         dst_format, dst_channels, dst_rate)) { 
1681                         safefree(RETVAL); RETVAL = NULL; }
1682         OUTPUT:
1683                 RETVAL
1684
1685 void
1686 FreeAudioCVT ( cvt )
1687         SDL_AudioCVT *cvt
1688         CODE:
1689                 safefree(cvt);
1690
1691 int
1692 ConvertAudioData ( cvt, data, len )
1693         SDL_AudioCVT *cvt
1694         Uint8 *data
1695         int len
1696         CODE:
1697                 cvt->len = len;
1698                 cvt->buf = (Uint8*) safemalloc(cvt->len*cvt->len_mult);
1699                 memcpy(cvt->buf,data,cvt->len);
1700                 RETVAL = SDL_ConvertAudio(cvt);
1701         OUTPUT:
1702                 RETVAL                  
1703
1704 int
1705 OpenAudio ( spec, callback )
1706         SDL_AudioSpec *spec
1707         SV* callback
1708         CODE:
1709                 spec->userdata = (void*)callback;
1710                 spec->callback = sdl_perl_audio_callback;
1711                 RETVAL = SDL_OpenAudio(spec,NULL);
1712         OUTPUT:
1713                 RETVAL
1714
1715 Uint32
1716 GetAudioStatus ()
1717         CODE:
1718                 RETVAL = SDL_GetAudioStatus ();
1719         OUTPUT:
1720                 RETVAL
1721
1722 void
1723 PauseAudio ( p_on )
1724         int p_on
1725         CODE:
1726                 SDL_PauseAudio(p_on);
1727         
1728 void
1729 LockAudio ()
1730         CODE:
1731                 SDL_LockAudio();
1732
1733 void
1734 UnlockAudio ()
1735         CODE:
1736                 SDL_UnlockAudio();
1737
1738 void
1739 CloseAudio ()
1740         CODE:
1741                 SDL_CloseAudio();
1742
1743 void
1744 FreeWAV ( buf )
1745         Uint8 *buf
1746         CODE:
1747                 SDL_FreeWAV(buf);
1748
1749 AV *
1750 LoadWAV ( filename, spec )
1751         char *filename
1752         SDL_AudioSpec *spec
1753         CODE:
1754                 SDL_AudioSpec *temp;
1755                 Uint8 *buf;
1756                 Uint32 len;
1757
1758                 RETVAL = newAV();
1759                 temp = SDL_LoadWAV(filename,spec,&buf,&len);
1760                 if ( ! temp ) goto error;
1761                 av_push(RETVAL,newSViv(PTR2IV(temp)));
1762                 av_push(RETVAL,newSViv(PTR2IV(buf)));
1763                 av_push(RETVAL,newSViv(len));
1764 error:
1765         OUTPUT:
1766                 RETVAL
1767         
1768 #ifdef HAVE_SDL_MIXER
1769
1770 void
1771 MixAudio ( dst, src, len, volume )
1772         Uint8 *dst
1773         Uint8 *src
1774         Uint32 len
1775         int volume
1776         CODE:
1777                 SDL_MixAudio(dst,src,len,volume);
1778
1779 int
1780 MixOpenAudio ( frequency, format, channels, chunksize )
1781         int frequency
1782         Uint16 format
1783         int channels
1784         int chunksize   
1785         CODE:
1786                 RETVAL = Mix_OpenAudio(frequency, format, channels, chunksize);
1787         OUTPUT:
1788                 RETVAL
1789
1790 int
1791 MixAllocateChannels ( number )
1792         int number
1793         CODE:
1794                 RETVAL = Mix_AllocateChannels(number);
1795         OUTPUT:
1796                 RETVAL
1797
1798 AV *
1799 MixQuerySpec ()
1800         CODE:
1801                 int freq, channels, status;
1802                 Uint16 format;
1803                 status = Mix_QuerySpec(&freq,&format,&channels);
1804                 RETVAL = newAV();
1805                 av_push(RETVAL,newSViv(status));
1806                 av_push(RETVAL,newSViv(freq));
1807                 av_push(RETVAL,newSViv(format));
1808                 av_push(RETVAL,newSViv(channels));
1809         OUTPUT:
1810                 RETVAL
1811
1812 Mix_Chunk *
1813 MixLoadWAV ( filename )
1814         char *filename
1815         CODE:
1816                 RETVAL = Mix_LoadWAV(filename);
1817         OUTPUT:
1818                 RETVAL
1819
1820 Mix_Music *
1821 MixLoadMusic ( filename )
1822         char *filename
1823         CODE:
1824                 RETVAL = Mix_LoadMUS(filename);
1825         OUTPUT:
1826                 RETVAL
1827
1828 Mix_Chunk *
1829 MixQuickLoadWAV ( buf )
1830         Uint8 *buf
1831         CODE:
1832                 RETVAL = Mix_QuickLoad_WAV(buf);
1833         OUTPUT:
1834                 RETVAL
1835
1836 void
1837 MixFreeChunk( chunk )
1838         Mix_Chunk *chunk
1839         CODE:
1840                 Mix_FreeChunk(chunk);
1841
1842 void
1843 MixFreeMusic ( music )
1844         Mix_Music *music
1845         CODE:
1846                 Mix_FreeMusic(music);
1847
1848 void
1849 MixSetPostMixCallback ( func, arg )
1850         void *func
1851         void *arg
1852         CODE:
1853                 Mix_SetPostMix(func,arg);
1854
1855 void*
1856 PerlMixMusicHook ()
1857         CODE:
1858                 RETVAL = sdl_perl_music_callback;
1859         OUTPUT:
1860                 RETVAL
1861
1862 void
1863 MixSetMusicHook ( func, arg )
1864         void *func
1865         void *arg
1866         CODE:
1867                 Mix_HookMusic(func,arg);
1868
1869 void
1870 MixSetMusicFinishedHook ( func )
1871         void *func
1872         CODE:
1873                 mix_music_finished_cv = func;
1874                 Mix_HookMusicFinished(sdl_perl_music_finished_callback);
1875
1876 void *
1877 MixGetMusicHookData ()
1878         CODE:
1879                 RETVAL = Mix_GetMusicHookData();
1880         OUTPUT:
1881                 RETVAL
1882
1883 int
1884 MixReverseChannels ( number )
1885         int number
1886         CODE:
1887                 RETVAL = Mix_ReserveChannels ( number );
1888         OUTPUT:
1889                 RETVAL
1890
1891 int
1892 MixGroupChannel ( which, tag )
1893         int which
1894         int tag
1895         CODE:
1896                 RETVAL = Mix_GroupChannel(which,tag);
1897         OUTPUT:
1898                 RETVAL
1899
1900 int
1901 MixGroupChannels ( from, to, tag )
1902         int from
1903         int to
1904         int tag
1905         CODE:
1906                 RETVAL = Mix_GroupChannels(from,to,tag);
1907         OUTPUT:
1908                 RETVAL
1909
1910 int
1911 MixGroupAvailable ( tag )
1912         int tag
1913         CODE:
1914                 RETVAL = Mix_GroupAvailable(tag);
1915         OUTPUT:
1916                 RETVAL
1917
1918 int
1919 MixGroupCount ( tag )
1920         int tag
1921         CODE:
1922                 RETVAL = Mix_GroupCount(tag);
1923         OUTPUT:
1924                 RETVAL
1925
1926 int
1927 MixGroupOldest ( tag )
1928         int tag
1929         CODE:
1930                 RETVAL = Mix_GroupOldest(tag);
1931         OUTPUT:
1932                 RETVAL
1933
1934 int
1935 MixGroupNewer ( tag )
1936         int tag
1937         CODE:
1938                 RETVAL = Mix_GroupNewer(tag);
1939         OUTPUT:
1940                 RETVAL
1941
1942 int
1943 MixPlayChannel ( channel, chunk, loops )
1944         int channel
1945         Mix_Chunk *chunk
1946         int loops
1947         CODE:
1948                 RETVAL = Mix_PlayChannel(channel,chunk,loops);
1949         OUTPUT:
1950                 RETVAL
1951
1952 int
1953 MixPlayChannelTimed ( channel, chunk, loops, ticks )
1954         int channel
1955         Mix_Chunk *chunk
1956         int loops
1957         int ticks
1958         CODE:
1959                 RETVAL = Mix_PlayChannelTimed(channel,chunk,loops,ticks);
1960         OUTPUT:
1961                 RETVAL
1962
1963 int
1964 MixPlayMusic ( music, loops )
1965         Mix_Music *music
1966         int loops
1967         CODE:
1968                 RETVAL = Mix_PlayMusic(music,loops);
1969         OUTPUT:
1970                 RETVAL
1971
1972 int
1973 MixFadeInChannel ( channel, chunk, loops, ms )
1974         int channel
1975         Mix_Chunk *chunk
1976         int loops
1977         int ms
1978         CODE:
1979                 RETVAL = Mix_FadeInChannel(channel,chunk,loops,ms);
1980         OUTPUT:
1981                 RETVAL
1982
1983 int
1984 MixFadeInChannelTimed ( channel, chunk, loops, ms, ticks )
1985         int channel
1986         Mix_Chunk *chunk
1987         int loops
1988         int ticks
1989         int ms
1990         CODE:
1991                 RETVAL = Mix_FadeInChannelTimed(channel,chunk,loops,ms,ticks);
1992         OUTPUT:
1993                 RETVAL
1994
1995 int
1996 MixFadeInMusic ( music, loops, ms )
1997         Mix_Music *music
1998         int loops
1999         int ms
2000         CODE:
2001                 RETVAL = Mix_FadeInMusic(music,loops,ms);
2002         OUTPUT:
2003                 RETVAL
2004
2005 int
2006 MixVolume ( channel, volume )
2007         int channel
2008         int volume
2009         CODE:   
2010                 RETVAL = Mix_Volume(channel,volume);
2011         OUTPUT:
2012                 RETVAL
2013
2014 int
2015 MixVolumeChunk ( chunk, volume )
2016         Mix_Chunk *chunk
2017         int volume
2018         CODE:
2019                 RETVAL = Mix_VolumeChunk(chunk,volume);
2020         OUTPUT:
2021                 RETVAL
2022
2023 int
2024 MixVolumeMusic ( volume )
2025         int volume
2026         CODE:
2027                 RETVAL = Mix_VolumeMusic(volume);
2028         OUTPUT:
2029                 RETVAL
2030
2031 int
2032 MixHaltChannel ( channel )
2033         int channel
2034         CODE:
2035                 RETVAL = Mix_HaltChannel(channel);
2036         OUTPUT:
2037                 RETVAL
2038
2039 int
2040 MixHaltGroup ( tag )
2041         int tag
2042         CODE:
2043                 RETVAL = Mix_HaltGroup(tag);
2044         OUTPUT:
2045                 RETVAL
2046
2047 int
2048 MixHaltMusic ()
2049         CODE:
2050                 RETVAL = Mix_HaltMusic();
2051         OUTPUT:
2052                 RETVAL
2053
2054 int
2055 MixExpireChannel ( channel, ticks )
2056         int channel
2057         int ticks
2058         CODE:
2059                 RETVAL = Mix_ExpireChannel ( channel,ticks);
2060         OUTPUT:
2061                 RETVAL
2062
2063 int
2064 MixFadeOutChannel ( which, ms )
2065         int which
2066         int ms
2067         CODE:
2068                 RETVAL = Mix_FadeOutChannel(which,ms);
2069         OUTPUT:
2070                 RETVAL
2071
2072 int
2073 MixFadeOutGroup ( which, ms )
2074         int which
2075         int ms
2076         CODE:
2077                 RETVAL = Mix_FadeOutGroup(which,ms);
2078         OUTPUT:
2079                 RETVAL
2080
2081 int
2082 MixFadeOutMusic ( ms )
2083         int ms
2084         CODE:
2085                 RETVAL = Mix_FadeOutMusic(ms);
2086         OUTPUT:
2087                 RETVAL
2088
2089 Mix_Fading
2090 MixFadingMusic()
2091         CODE:
2092                 RETVAL = Mix_FadingMusic();
2093         OUTPUT:
2094                 RETVAL
2095
2096 Mix_Fading
2097 MixFadingChannel( which )
2098         int which
2099         CODE:
2100                 RETVAL = Mix_FadingChannel(which);
2101         OUTPUT:
2102                 RETVAL
2103
2104 void
2105 MixPause ( channel )
2106         int channel
2107         CODE:
2108                 Mix_Pause(channel);
2109
2110 void
2111 MixResume ( channel )
2112         int channel
2113         CODE:
2114                 Mix_Resume(channel);
2115
2116 int
2117 MixPaused ( channel )
2118         int channel
2119         CODE:
2120                 RETVAL = Mix_Paused(channel);
2121         OUTPUT:
2122                 RETVAL
2123
2124 void
2125 MixPauseMusic ()
2126         CODE:
2127                 Mix_PauseMusic();
2128
2129 void
2130 MixResumeMusic ()
2131         CODE:
2132                 Mix_ResumeMusic();
2133
2134 void
2135 MixRewindMusic ()
2136         CODE:
2137                 Mix_RewindMusic();
2138
2139 int
2140 MixPausedMusic ()
2141         CODE:
2142                 RETVAL = Mix_PausedMusic();
2143         OUTPUT:
2144                 RETVAL
2145
2146 int
2147 MixPlaying( channel )
2148         int channel     
2149         CODE:
2150                 RETVAL = Mix_Playing(channel);
2151         OUTPUT:
2152                 RETVAL
2153
2154 int
2155 MixPlayingMusic()
2156         CODE:
2157                 RETVAL = Mix_PlayingMusic();
2158         OUTPUT:
2159                 RETVAL
2160
2161 int
2162 MixSetPanning ( channel, left, right )
2163         int channel
2164         int left
2165         int right
2166         CODE:
2167                 RETVAL = Mix_SetPanning(channel, left, right);
2168         OUTPUT:
2169                 RETVAL
2170
2171 void
2172 MixCloseAudio ()
2173         CODE:
2174                 Mix_CloseAudio();
2175
2176 #endif
2177
2178 int
2179 GLLoadLibrary ( path )
2180         char *path
2181         CODE:
2182                 RETVAL = SDL_GL_LoadLibrary(path);
2183         OUTPUT:
2184                 RETVAL
2185
2186 void*
2187 GLGetProcAddress ( proc )
2188         char *proc
2189         CODE:
2190                 RETVAL = SDL_GL_GetProcAddress(proc);
2191         OUTPUT:
2192                 RETVAL
2193
2194 int
2195 GLSetAttribute ( attr,  value )
2196         int        attr
2197         int        value
2198         CODE:
2199                 RETVAL = SDL_GL_SetAttribute(attr, value);
2200         OUTPUT:
2201                 RETVAL
2202
2203 AV *
2204 GLGetAttribute ( attr )
2205         int        attr
2206         CODE:
2207                 int value;
2208                 RETVAL = newAV();
2209                 av_push(RETVAL,newSViv(SDL_GL_GetAttribute(attr, &value)));
2210                 av_push(RETVAL,newSViv(value));
2211         OUTPUT:
2212                 RETVAL
2213
2214 void
2215 GLSwapBuffers ()
2216         CODE:
2217                 SDL_GL_SwapBuffers ();
2218
2219
2220 int
2221 BigEndian ()
2222         CODE:
2223                 RETVAL = (SDL_BYTEORDER == SDL_BIG_ENDIAN);
2224         OUTPUT:
2225                 RETVAL
2226
2227 int
2228 NumJoysticks ()
2229         CODE:
2230                 RETVAL = SDL_NumJoysticks();
2231         OUTPUT:
2232                 RETVAL
2233
2234 char *
2235 JoystickName ( index )
2236         int index
2237         CODE:
2238                 RETVAL = (char*)SDL_JoystickName(index);
2239         OUTPUT:
2240                 RETVAL
2241
2242 SDL_Joystick *
2243 JoystickOpen ( index ) 
2244         int index
2245         CODE:
2246                 RETVAL = SDL_JoystickOpen(index);
2247         OUTPUT:
2248                 RETVAL
2249
2250 int
2251 JoystickOpened ( index )
2252         int index
2253         CODE:
2254                 RETVAL = SDL_JoystickOpened(index);
2255         OUTPUT:
2256                 RETVAL
2257
2258 int
2259 JoystickIndex ( joystick )
2260         SDL_Joystick *joystick
2261         CODE:
2262                 RETVAL = SDL_JoystickIndex(joystick);
2263         OUTPUT:
2264                 RETVAL
2265
2266 int
2267 JoystickNumAxes ( joystick )
2268         SDL_Joystick *joystick
2269         CODE:
2270                 RETVAL = SDL_JoystickNumAxes(joystick);
2271         OUTPUT:
2272                 RETVAL
2273
2274 int
2275 JoystickNumBalls ( joystick )
2276         SDL_Joystick *joystick
2277         CODE:
2278                 RETVAL = SDL_JoystickNumBalls(joystick);
2279         OUTPUT:
2280                 RETVAL
2281
2282 int
2283 JoystickNumHats ( joystick )
2284         SDL_Joystick *joystick
2285         CODE:
2286                 RETVAL = SDL_JoystickNumHats(joystick);
2287         OUTPUT:
2288                 RETVAL
2289
2290 int
2291 JoystickNumButtons ( joystick )
2292         SDL_Joystick *joystick
2293         CODE:
2294                 RETVAL = SDL_JoystickNumButtons(joystick);
2295         OUTPUT:
2296                 RETVAL
2297
2298 void
2299 JoystickUpdate ()
2300         CODE:
2301                 SDL_JoystickUpdate();
2302
2303 Sint16
2304 JoystickGetAxis ( joystick, axis )
2305         SDL_Joystick *joystick
2306         int axis
2307         CODE:
2308                 RETVAL = SDL_JoystickGetAxis(joystick,axis);
2309         OUTPUT:
2310                 RETVAL
2311
2312 Uint8
2313 JoystickGetHat ( joystick, hat )
2314         SDL_Joystick *joystick
2315         int hat 
2316         CODE:
2317                 RETVAL = SDL_JoystickGetHat(joystick,hat);
2318         OUTPUT:
2319                 RETVAL
2320
2321 Uint8
2322 JoystickGetButton ( joystick, button)
2323         SDL_Joystick *joystick
2324         int button 
2325         CODE:
2326                 RETVAL = SDL_JoystickGetButton(joystick,button);
2327         OUTPUT:
2328                 RETVAL
2329
2330 AV *
2331 JoystickGetBall ( joystick, ball )
2332         SDL_Joystick *joystick
2333         int ball 
2334         CODE:
2335                 int success,dx,dy;
2336                 success = SDL_JoystickGetBall(joystick,ball,&dx,&dy);
2337                 RETVAL = newAV();
2338                 av_push(RETVAL,newSViv(success));
2339                 av_push(RETVAL,newSViv(dx));
2340                 av_push(RETVAL,newSViv(dy));
2341         OUTPUT:
2342                 RETVAL  
2343
2344 void
2345 JoystickClose ( joystick )
2346         SDL_Joystick *joystick
2347         CODE:
2348                 SDL_JoystickClose(joystick);
2349
2350 Sint16
2351 JoyAxisEventWhich ( e )
2352         SDL_Event *e
2353         CODE:
2354                 RETVAL = e->jaxis.which;
2355         OUTPUT:
2356                 RETVAL
2357
2358 Uint8
2359 JoyAxisEventAxis ( e )
2360         SDL_Event *e
2361         CODE:
2362                 RETVAL = e->jaxis.axis;
2363         OUTPUT:
2364                 RETVAL
2365
2366 Sint16
2367 JoyAxisEventValue ( e )
2368         SDL_Event *e
2369         CODE:
2370                 RETVAL = e->jaxis.value;
2371         OUTPUT:
2372                 RETVAL
2373
2374 Uint8
2375 JoyButtonEventWhich ( e )
2376         SDL_Event *e
2377         CODE:
2378                 RETVAL = e->jbutton.which;
2379         OUTPUT:
2380                 RETVAL
2381
2382 Uint8
2383 JoyButtonEventButton ( e )
2384         SDL_Event *e
2385         CODE:
2386                 RETVAL = e->jbutton.button;
2387         OUTPUT:
2388                 RETVAL
2389
2390 Uint8
2391 JoyButtonEventState ( e )
2392         SDL_Event *e
2393         CODE:
2394                 RETVAL = e->jbutton.state;
2395         OUTPUT:
2396                 RETVAL
2397         
2398 Uint8
2399 JoyHatEventWhich ( e )
2400         SDL_Event *e
2401         CODE:
2402                 RETVAL = e->jhat.which;
2403         OUTPUT:
2404                 RETVAL
2405
2406 Uint8
2407 JoyHatEventHat ( e )
2408         SDL_Event *e
2409         CODE:
2410                 RETVAL = e->jhat.hat;
2411         OUTPUT:
2412                 RETVAL
2413
2414 Uint8
2415 JoyHatEventValue ( e )
2416         SDL_Event *e
2417         CODE:
2418                 RETVAL = e->jhat.value;
2419         OUTPUT:
2420                 RETVAL
2421
2422 Uint8
2423 JoyBallEventWhich ( e )
2424         SDL_Event *e
2425         CODE: 
2426                 RETVAL = e->jball.which;
2427         OUTPUT:
2428                 RETVAL
2429
2430 Uint8
2431 JoyBallEventBall ( e )
2432         SDL_Event *e
2433         CODE:
2434                 RETVAL = e->jball.ball;
2435         OUTPUT:
2436                 RETVAL
2437
2438 Sint16
2439 JoyBallEventXrel ( e )
2440         SDL_Event *e
2441         CODE:
2442                 RETVAL = e->jball.xrel;
2443         OUTPUT:
2444                 RETVAL
2445
2446 Sint16
2447 JoyBallEventYrel ( e )
2448         SDL_Event *e
2449         CODE:
2450                 RETVAL = e->jball.yrel;
2451         OUTPUT:
2452                 RETVAL
2453
2454 void
2455 SetClipRect ( surface, rect )
2456         SDL_Surface *surface
2457         SDL_Rect *rect
2458         CODE:
2459                 SDL_SetClipRect(surface,rect);
2460         
2461 void
2462 GetClipRect ( surface, rect )
2463         SDL_Surface *surface
2464         SDL_Rect *rect;
2465         CODE:
2466                 SDL_GetClipRect(surface, rect);
2467
2468
2469 #ifdef HAVE_SDL_NET
2470
2471 int
2472 NetInit ()
2473         CODE:
2474                 RETVAL = SDLNet_Init();
2475         OUTPUT:
2476                 RETVAL
2477
2478 void
2479 NetQuit ()
2480         CODE:
2481                 SDLNet_Quit();
2482
2483 IPaddress*
2484 NetNewIPaddress ( host, port )
2485         Uint32 host
2486         Uint16 port
2487         CODE:
2488                 RETVAL = (IPaddress*) safemalloc(sizeof(IPaddress));
2489                 RETVAL->host = host;
2490                 RETVAL->port = port;
2491         OUTPUT:
2492                 RETVAL
2493
2494 Uint32
2495 NetIPaddressHost ( ip )
2496         IPaddress *ip
2497         CODE:
2498                 RETVAL = ip->host;
2499         OUTPUT:
2500                 RETVAL
2501
2502 Uint16
2503 NetIPaddressPort ( ip )
2504         IPaddress *ip
2505         CODE:
2506                 RETVAL = ip->port;
2507         OUTPUT:
2508                 RETVAL
2509
2510 void
2511 NetFreeIPaddress ( ip )
2512         IPaddress *ip
2513         CODE:
2514                 safefree(ip);
2515
2516 const char*
2517 NetResolveIP ( address )
2518         IPaddress *address
2519         CODE:
2520                 RETVAL = SDLNet_ResolveIP(address);
2521         OUTPUT:
2522                 RETVAL
2523
2524 int
2525 NetResolveHost ( address, host, port )
2526         IPaddress *address
2527         const char *host
2528         Uint16 port
2529         CODE:
2530                 RETVAL = SDLNet_ResolveHost(address,host,port);
2531         OUTPUT:
2532                 RETVAL
2533         
2534 TCPsocket
2535 NetTCPOpen ( ip )
2536         IPaddress *ip
2537         CODE:
2538                 RETVAL = SDLNet_TCP_Open(ip);
2539         OUTPUT:
2540                 RETVAL
2541
2542 TCPsocket
2543 NetTCPAccept ( server )
2544         TCPsocket server
2545         CODE:
2546                 RETVAL = SDLNet_TCP_Accept(server);
2547         OUTPUT:
2548                 RETVAL
2549
2550 IPaddress*
2551 NetTCPGetPeerAddress ( sock )
2552         TCPsocket sock
2553         CODE:
2554                 RETVAL = SDLNet_TCP_GetPeerAddress(sock);
2555         OUTPUT:
2556                 RETVAL
2557
2558 int
2559 NetTCPSend ( sock, data, len  )
2560         TCPsocket sock
2561         void *data
2562         int len
2563         CODE:
2564                 RETVAL = SDLNet_TCP_Send(sock,data,len);
2565         OUTPUT:
2566                 RETVAL
2567
2568 AV*
2569 NetTCPRecv ( sock, maxlen )
2570         TCPsocket sock
2571         int maxlen
2572         CODE:
2573                 int status;
2574                 void *buffer;
2575                 buffer = safemalloc(maxlen);
2576                 RETVAL = newAV();
2577                 status = SDLNet_TCP_Recv(sock,buffer,maxlen);
2578                 av_push(RETVAL,newSViv(status));
2579                 av_push(RETVAL,newSVpvn((char*)buffer,maxlen));
2580         OUTPUT:
2581                 RETVAL  
2582         
2583 void
2584 NetTCPClose ( sock )
2585         TCPsocket sock
2586         CODE:
2587                 SDLNet_TCP_Close(sock);
2588
2589 UDPpacket*
2590 NetAllocPacket ( size )
2591         int size
2592         CODE:
2593                 RETVAL = SDLNet_AllocPacket(size);
2594         OUTPUT:
2595                 RETVAL
2596
2597 UDPpacket**
2598 NetAllocPacketV ( howmany, size )
2599         int howmany
2600         int size
2601         CODE:
2602                 RETVAL = SDLNet_AllocPacketV(howmany,size);
2603         OUTPUT:
2604                 RETVAL
2605
2606 int
2607 NetResizePacket ( packet, newsize )
2608         UDPpacket *packet
2609         int newsize
2610         CODE:
2611                 RETVAL = SDLNet_ResizePacket(packet,newsize);
2612         OUTPUT:
2613                 RETVAL
2614
2615 void
2616 NetFreePacket ( packet )
2617         UDPpacket *packet
2618         CODE:
2619                 SDLNet_FreePacket(packet);
2620
2621 void
2622 NetFreePacketV ( packet )
2623         UDPpacket **packet
2624         CODE:
2625                 SDLNet_FreePacketV(packet);
2626
2627 UDPsocket
2628 NetUDPOpen ( port )
2629         Uint16 port
2630         CODE:
2631                 RETVAL = SDLNet_UDP_Open(port);
2632         OUTPUT:
2633                 RETVAL
2634
2635 int
2636 NetUDPBind ( sock, channel, address )
2637         UDPsocket sock
2638         int channel
2639         IPaddress *address
2640         CODE:
2641                 RETVAL = SDLNet_UDP_Bind(sock,channel,address);
2642         OUTPUT:
2643                 RETVAL
2644
2645 void
2646 NetUDPUnbind ( sock, channel )
2647         UDPsocket sock
2648         int channel
2649         CODE:
2650                 SDLNet_UDP_Unbind(sock,channel);
2651
2652 IPaddress*
2653 NetUDPGetPeerAddress ( sock, channel )
2654         UDPsocket sock
2655         int channel
2656         CODE:
2657                 RETVAL = SDLNet_UDP_GetPeerAddress(sock,channel);
2658         OUTPUT:
2659                 RETVAL
2660
2661 int
2662 NetUDPSendV ( sock, packets, npackets )
2663         UDPsocket sock
2664         UDPpacket **packets
2665         int npackets
2666         CODE:
2667                 RETVAL = SDLNet_UDP_SendV(sock,packets,npackets);
2668         OUTPUT:
2669                 RETVAL
2670
2671 int
2672 NetUDPSend ( sock, channel, packet )
2673         UDPsocket sock
2674         int channel
2675         UDPpacket *packet 
2676         CODE:
2677                 RETVAL = SDLNet_UDP_Send(sock,channel,packet);
2678         OUTPUT:
2679                 RETVAL
2680
2681 int
2682 NetUDPRecvV ( sock, packets )
2683         UDPsocket sock
2684         UDPpacket **packets
2685         CODE:
2686                 RETVAL = SDLNet_UDP_RecvV(sock,packets);
2687         OUTPUT:
2688                 RETVAL
2689
2690 int
2691 NetUDPRecv ( sock, packet )
2692         UDPsocket sock
2693         UDPpacket *packet
2694         CODE:
2695                 RETVAL = SDLNet_UDP_Recv(sock,packet);
2696         OUTPUT:
2697                 RETVAL
2698
2699 void
2700 NetUDPClose ( sock )
2701         UDPsocket sock
2702         CODE:
2703                 SDLNet_UDP_Close(sock);
2704
2705 SDLNet_SocketSet
2706 NetAllocSocketSet ( maxsockets )
2707         int maxsockets
2708         CODE:
2709                 RETVAL = SDLNet_AllocSocketSet(maxsockets);
2710         OUTPUT:
2711                 RETVAL
2712
2713 int
2714 NetTCP_AddSocket ( set, sock )
2715         SDLNet_SocketSet set
2716         TCPsocket sock
2717         CODE:
2718                 RETVAL = SDLNet_TCP_AddSocket(set,sock);
2719         OUTPUT:
2720                 RETVAL
2721
2722 int
2723 NetUDP_AddSocket ( set, sock )
2724         SDLNet_SocketSet set
2725         UDPsocket sock
2726         CODE:
2727                 RETVAL = SDLNet_UDP_AddSocket(set,sock);
2728         OUTPUT:
2729                 RETVAL
2730
2731 int
2732 NetTCP_DelSocket ( set, sock )
2733         SDLNet_SocketSet set
2734         TCPsocket sock
2735         CODE:
2736                 RETVAL = SDLNet_TCP_DelSocket(set,sock);
2737         OUTPUT:
2738                 RETVAL
2739
2740 int
2741 NetUDP_DelSocket ( set, sock )
2742         SDLNet_SocketSet set
2743         UDPsocket sock
2744         CODE:
2745                 RETVAL = SDLNet_UDP_DelSocket(set,sock);
2746         OUTPUT:
2747                 RETVAL
2748
2749 int
2750 NetCheckSockets ( set, timeout )
2751         SDLNet_SocketSet set
2752         Uint32 timeout
2753         CODE:
2754                 RETVAL = SDLNet_CheckSockets(set,timeout);
2755         OUTPUT:
2756                 RETVAL
2757
2758 int
2759 NetSocketReady ( sock )
2760         SDLNet_GenericSocket sock
2761         CODE:
2762                 RETVAL = SDLNet_SocketReady(sock);
2763         OUTPUT:
2764                 RETVAL
2765
2766 void
2767 NetFreeSocketSet ( set )
2768         SDLNet_SocketSet set
2769         CODE:
2770                 SDLNet_FreeSocketSet(set);
2771
2772 void
2773 NetWrite16 ( value, area )
2774         Uint16 value
2775         void *area
2776         CODE:
2777                 SDLNet_Write16(value,area);
2778
2779 void
2780 NetWrite32 ( value, area )
2781         Uint32 value
2782         void *area
2783         CODE:
2784                 SDLNet_Write32(value,area);
2785         
2786 Uint16
2787 NetRead16 ( area )
2788         void *area
2789         CODE:
2790                 RETVAL = SDLNet_Read16(area);
2791         OUTPUT:
2792                 RETVAL
2793
2794 Uint32
2795 NetRead32 ( area )
2796         void *area
2797         CODE:
2798                 RETVAL = SDLNet_Read32(area);
2799         OUTPUT:
2800                 RETVAL
2801
2802 #endif 
2803
2804 #ifdef HAVE_SDL_TTF
2805
2806 int
2807 TTFInit ()
2808         CODE:
2809                 RETVAL = TTF_Init();
2810         OUTPUT:
2811                 RETVAL
2812
2813 void
2814 TTFQuit ()
2815         CODE:
2816                 TTF_Quit();
2817
2818 TTF_Font*
2819 TTFOpenFont ( file, ptsize )
2820         char *file
2821         int ptsize
2822         CODE:
2823                 RETVAL = TTF_OpenFont(file,ptsize);
2824         OUTPUT:
2825                 RETVAL
2826
2827 int
2828 TTFGetFontStyle ( font )
2829         TTF_Font *font
2830         CODE:
2831                 RETVAL = TTF_GetFontStyle(font);
2832         OUTPUT:
2833                 RETVAL
2834
2835 void
2836 TTFSetFontStyle ( font, style )
2837         TTF_Font *font
2838         int style
2839         CODE:
2840                 TTF_SetFontStyle(font,style);
2841         
2842 int
2843 TTFFontHeight ( font )
2844         TTF_Font *font
2845         CODE:
2846                 RETVAL = TTF_FontHeight(font);
2847         OUTPUT:
2848                 RETVAL
2849
2850 int
2851 TTFFontAscent ( font )
2852         TTF_Font *font
2853         CODE:
2854                 RETVAL = TTF_FontAscent(font);
2855         OUTPUT:
2856                 RETVAL
2857
2858 int
2859 TTFFontDescent ( font )
2860         TTF_Font *font
2861         CODE:
2862                 RETVAL = TTF_FontDescent(font);
2863         OUTPUT:
2864                 RETVAL
2865
2866 int
2867 TTFFontLineSkip ( font )
2868         TTF_Font *font
2869         CODE:
2870                 RETVAL = TTF_FontLineSkip(font);
2871         OUTPUT:
2872                 RETVAL
2873
2874 AV*
2875 TTFGlyphMetrics ( font, ch )
2876         TTF_Font *font
2877         Uint16 ch
2878         CODE:
2879                 int minx, miny, maxx, maxy, advance;
2880                 RETVAL = newAV();
2881                 TTF_GlyphMetrics(font, ch, &minx, &miny, &maxx, &maxy, &advance);
2882                 av_push(RETVAL,newSViv(minx));
2883                 av_push(RETVAL,newSViv(miny));
2884                 av_push(RETVAL,newSViv(maxx));
2885                 av_push(RETVAL,newSViv(maxy));
2886                 av_push(RETVAL,newSViv(advance));
2887         OUTPUT:
2888                 RETVAL
2889
2890 AV*
2891 TTFSizeText ( font, text )
2892         TTF_Font *font
2893         char *text
2894         CODE:
2895                 int w,h;
2896                 RETVAL = newAV();
2897                 if(TTF_SizeText(font,text,&w,&h))
2898                 {
2899                         printf("TTF error at TTFSizeText: %s \n", TTF_GetError());
2900                         Perl_croak (aTHX_ "TTF error \n");
2901                 }
2902                 else
2903                 {
2904                         av_push(RETVAL,newSViv(w));
2905                         av_push(RETVAL,newSViv(h));
2906                         sv_2mortal((SV*)RETVAL);
2907                 }
2908                 
2909         
2910         OUTPUT:
2911                 RETVAL
2912
2913 AV*
2914 TTFSizeUTF8 ( font, text )
2915         TTF_Font *font
2916         char *text
2917         CODE:
2918                 int w,h;
2919                 RETVAL = newAV();
2920                 if(TTF_SizeUTF8(font,text,&w,&h))
2921                 {
2922                         av_push(RETVAL,newSViv(w));
2923                         av_push(RETVAL,newSViv(h));
2924                         sv_2mortal((SV*)RETVAL);
2925
2926                 }
2927                 else
2928                 {
2929                         printf("TTF error at TTFSizeUTF8 with : %s \n", TTF_GetError());
2930                         Perl_croak (aTHX_ "TTF error \n");
2931                 }
2932                 
2933         OUTPUT:
2934                 RETVAL
2935
2936 AV*
2937 TTFSizeUNICODE ( font, text )
2938         TTF_Font *font
2939         const Uint16 *text
2940         CODE:
2941                 int w,h;
2942                 RETVAL = newAV();
2943                 if(TTF_SizeUNICODE(font,text,&w,&h))
2944                 {
2945                         av_push(RETVAL,newSViv(w));
2946                         av_push(RETVAL,newSViv(h));
2947                         sv_2mortal((SV*)RETVAL);
2948
2949                 }
2950                 else
2951                 {
2952                         printf("TTF error at TTFSizeUNICODE : %s \n", TTF_GetError()); 
2953                         Perl_croak (aTHX_ "TTF error \n");
2954                 }
2955
2956         OUTPUT:
2957                 RETVAL
2958
2959 =for comment
2960
2961 SDL_Surface*
2962 TTFRenderTextSolid ( font, text, fg )
2963         TTF_Font *font
2964         char *text
2965         SDL_Color *fg
2966         CODE:
2967                 RETVAL = TTF_RenderText_Solid(font,text,*fg);
2968         OUTPUT:
2969                 RETVAL
2970
2971 SDL_Surface*
2972 TTFRenderUTF8Solid ( font, text, fg )
2973         TTF_Font *font
2974         char *text
2975         SDL_Color *fg
2976         CODE:
2977                 RETVAL = TTF_RenderUTF8_Solid(font,text,*fg);
2978         OUTPUT:
2979                 RETVAL
2980
2981 SDL_Surface*
2982 TTFRenderUNICODESolid ( font, text, fg )
2983         TTF_Font *font
2984         const Uint16 *text
2985         SDL_Color *fg
2986         CODE:
2987                 RETVAL = TTF_RenderUNICODE_Solid(font,text,*fg);
2988         OUTPUT:
2989                 RETVAL
2990
2991 SDL_Surface*
2992 TTFRenderGlyphSolid ( font, ch, fg )
2993         TTF_Font *font
2994         Uint16 ch
2995         SDL_Color *fg
2996         CODE:
2997                 RETVAL = TTF_RenderGlyph_Solid(font,ch,*fg);
2998         OUTPUT:
2999                 RETVAL
3000
3001 SDL_Surface*
3002 TTFRenderTextShaded ( font, text, fg, bg )
3003         TTF_Font *font
3004         char *text
3005         SDL_Color *fg
3006         SDL_Color *bg
3007         CODE:
3008                 RETVAL = TTF_RenderText_Shaded(font,text,*fg,*bg);
3009         OUTPUT:
3010                 RETVAL
3011
3012 SDL_Surface*
3013 TTFRenderUTF8Shaded( font, text, fg, bg )
3014         TTF_Font *font
3015         char *text
3016         SDL_Color *fg
3017         SDL_Color *bg
3018         CODE:
3019                 RETVAL = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
3020         OUTPUT:
3021                 RETVAL
3022
3023 SDL_Surface*
3024 TTFRenderUNICODEShaded( font, text, fg, bg )
3025         TTF_Font *font
3026         const Uint16 *text
3027         SDL_Color *fg
3028         SDL_Color *bg
3029         CODE:
3030                 RETVAL = TTF_RenderUNICODE_Shaded(font,text,*fg,*bg);
3031         OUTPUT:
3032                 RETVAL
3033
3034 SDL_Surface*
3035 TTFRenderGlyphShaded ( font, ch, fg, bg )
3036         TTF_Font *font
3037         Uint16 ch
3038         SDL_Color *fg
3039         SDL_Color *bg
3040         CODE:
3041                 RETVAL = TTF_RenderGlyph_Shaded(font,ch,*fg,*bg);
3042         OUTPUT:
3043                 RETVAL
3044
3045 SDL_Surface*
3046 TTFRenderTextBlended( font, text, fg )
3047         TTF_Font *font
3048         char *text
3049         SDL_Color *fg
3050         CODE:
3051                 RETVAL = TTF_RenderText_Blended(font,text,*fg);
3052         OUTPUT:
3053                 RETVAL
3054
3055 SDL_Surface*
3056 TTFRenderUTF8Blended( font, text, fg )
3057         TTF_Font *font
3058         char *text
3059         SDL_Color *fg
3060         CODE:
3061                 RETVAL = TTF_RenderUTF8_Blended(font,text,*fg);
3062         OUTPUT:
3063                 RETVAL
3064
3065 SDL_Surface*
3066 TTFRenderUNICODEBlended( font, text, fg )
3067         TTF_Font *font
3068         const Uint16 *text
3069         SDL_Color *fg
3070         CODE:
3071                 RETVAL = TTF_RenderUNICODE_Blended(font,text,*fg);
3072         OUTPUT:
3073                 RETVAL
3074
3075 SDL_Surface*
3076 TTFRenderGlyphBlended( font, ch, fg )
3077         TTF_Font *font
3078         Uint16 ch
3079         SDL_Color *fg
3080         CODE:
3081                 RETVAL = TTF_RenderGlyph_Blended(font,ch,*fg);
3082         OUTPUT:
3083                 RETVAL
3084
3085 void
3086 TTFCloseFont ( font )
3087         TTF_Font *font
3088         CODE:
3089                 TTF_CloseFont(font);
3090                 font=NULL; //to be safe http://sdl.beuc.net/sdl.wiki/SDL_ttf_copy_Functions_Management_TTF_CloseFont
3091
3092 SDL_Surface*
3093 TTFPutString ( font, mode, surface, x, y, fg, bg, text )
3094         TTF_Font *font
3095         int mode
3096         SDL_Surface *surface
3097         int x
3098         int y
3099         SDL_Color *fg
3100         SDL_Color *bg
3101         char *text
3102         CODE:
3103                 SDL_Surface *img;
3104                 SDL_Rect dest;
3105                 int w,h;
3106                 dest.x = x;
3107                 dest.y = y;
3108                 RETVAL = NULL;
3109                 switch (mode) {
3110                         case TEXT_SOLID:
3111                                 img = TTF_RenderText_Solid(font,text,*fg);
3112                                 TTF_SizeText(font,text,&w,&h);
3113                                 dest.w = w;
3114                                 dest.h = h;
3115                                 break;
3116                         case TEXT_SHADED:
3117                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3118                                 TTF_SizeText(font,text,&w,&h);
3119                                 dest.w = w;
3120                                 dest.h = h;
3121                                 break;
3122                         case TEXT_BLENDED:
3123                                 img = TTF_RenderText_Blended(font,text,*fg);
3124                                 TTF_SizeText(font,text,&w,&h);
3125                                 dest.w = w;
3126                                 dest.h = h;
3127                                 break;
3128                         case UTF8_SOLID:
3129                                 img = TTF_RenderUTF8_Solid(font,text,*fg);
3130                                 TTF_SizeUTF8(font,text,&w,&h);
3131                                 dest.w = w;
3132                                 dest.h = h;
3133                                 break;
3134                         case UTF8_SHADED:
3135                                 img = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
3136                                 TTF_SizeUTF8(font,text,&w,&h);
3137                                 dest.w = w;
3138                                 dest.h = h;
3139                                 break;
3140                         case UTF8_BLENDED:
3141                                 img = TTF_RenderUTF8_Blended(font,text,*fg);
3142                                 TTF_SizeUTF8(font,text,&w,&h);
3143                                 dest.w = w;
3144                                 dest.h = h;
3145                                 break;
3146                         case UNICODE_SOLID:
3147                                 img = TTF_RenderUNICODE_Solid(font,(Uint16*)text,*fg);
3148                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3149                                 dest.w = w;
3150                                 dest.h = h;
3151                                 break;
3152                         case UNICODE_SHADED:
3153                                 img = TTF_RenderUNICODE_Shaded(font,(Uint16*)text,*fg,*bg);
3154                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3155                                 dest.w = w;
3156                                 dest.h = h;
3157                                 break;
3158                         case UNICODE_BLENDED:
3159                                 img = TTF_RenderUNICODE_Blended(font,(Uint16*)text,*fg);
3160                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3161                                 dest.w = w;
3162                                 dest.h = h;
3163                                 break;
3164                         default:
3165                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3166                                 TTF_SizeText(font,text,&w,&h);
3167                                 dest.w = w;
3168                                 dest.h = h;
3169                 }
3170                 if ( img && img->format && img->format->palette ) {
3171                         SDL_Color *c = &img->format->palette->colors[0];
3172                         Uint32 key = SDL_MapRGB( img->format, c->r, c->g, c->b );
3173                         SDL_SetColorKey(img,SDL_SRCCOLORKEY,key );
3174                         if (0 > SDL_BlitSurface(img,NULL,surface,&dest)) {
3175                                 SDL_FreeSurface(img);
3176                                 RETVAL = NULL;  
3177                         } else {
3178                                 RETVAL = img;
3179                         }
3180                 }
3181         OUTPUT:
3182                 RETVAL
3183
3184 =cut
3185
3186 #endif
3187
3188 SDL_Overlay*
3189 CreateYUVOverlay ( width, height, format, display )
3190         int width
3191         int height
3192         Uint32 format
3193         SDL_Surface *display
3194         CODE:
3195                 RETVAL = SDL_CreateYUVOverlay ( width, height, format, display );
3196         OUTPUT:
3197                 RETVAL
3198
3199 int
3200 LockYUVOverlay ( overlay )
3201         SDL_Overlay *overlay
3202         CODE:
3203                 RETVAL = SDL_LockYUVOverlay(overlay);
3204         OUTPUT:
3205                 RETVAL
3206
3207 void
3208 UnlockYUVOverlay ( overlay )
3209         SDL_Overlay *overlay
3210         CODE:
3211                 SDL_UnlockYUVOverlay(overlay);
3212
3213 int
3214 DisplayYUVOverlay ( overlay, dstrect )
3215         SDL_Overlay *overlay
3216         SDL_Rect *dstrect
3217         CODE:
3218                 RETVAL = SDL_DisplayYUVOverlay ( overlay, dstrect );
3219         OUTPUT:
3220                 RETVAL
3221
3222 void
3223 FreeYUVOverlay ( overlay )
3224         SDL_Overlay *overlay
3225         CODE:
3226                 SDL_FreeYUVOverlay ( overlay );
3227
3228 Uint32
3229 OverlayFormat ( overlay, ... )
3230         SDL_Overlay *overlay
3231         CODE:
3232                 if ( items > 1 ) 
3233                         overlay->format = SvIV(ST(1));
3234                 RETVAL = overlay->format;
3235         OUTPUT:
3236                 RETVAL
3237
3238 int 
3239 OverlayW ( overlay, ... )
3240         SDL_Overlay *overlay
3241         CODE:
3242                 if ( items > 1 ) 
3243                         overlay->w = SvIV(ST(1));
3244                 RETVAL = overlay->w;
3245         OUTPUT:
3246                 RETVAL
3247
3248 int
3249 OverlayH ( overlay, ... )
3250         SDL_Overlay *overlay
3251         CODE:
3252                 if ( items > 1 )
3253                         overlay->h = SvIV(ST(1));
3254                 RETVAL = overlay->h;
3255         OUTPUT:
3256                 RETVAL 
3257
3258 int
3259 OverlayPlanes ( overlay, ... )
3260         SDL_Overlay *overlay
3261         CODE:
3262                 if ( items > 1 )
3263                         overlay->planes = SvIV(ST(1));
3264                 RETVAL = overlay->planes;
3265         OUTPUT:
3266                 RETVAL
3267
3268 Uint32
3269 OverlayHW ( overlay )
3270         SDL_Overlay *overlay
3271         CODE:
3272                 RETVAL = overlay->hw_overlay;
3273         OUTPUT:
3274                 RETVAL
3275
3276 Uint16*
3277 OverlayPitches ( overlay )
3278         SDL_Overlay *overlay
3279         CODE:
3280                 RETVAL = overlay->pitches;
3281         OUTPUT:
3282                 RETVAL
3283
3284 Uint8**
3285 OverlayPixels ( overlay )
3286         SDL_Overlay *overlay
3287         CODE:
3288                 RETVAL = overlay->pixels;
3289         OUTPUT:
3290                 RETVAL
3291
3292 int
3293 WMToggleFullScreen ( surface )
3294         SDL_Surface *surface
3295         CODE:
3296                 RETVAL = SDL_WM_ToggleFullScreen(surface);
3297         OUTPUT:
3298                 RETVAL
3299
3300 Uint32
3301 WMGrabInput ( mode )
3302         Uint32 mode
3303         CODE:
3304                 RETVAL = SDL_WM_GrabInput(mode);
3305         OUTPUT:
3306                 RETVAL
3307
3308 int
3309 WMIconifyWindow ()
3310         CODE:
3311                 RETVAL = SDL_WM_IconifyWindow();
3312         OUTPUT:
3313                 RETVAL
3314
3315 int
3316 ResizeEventW ( e )
3317         SDL_Event *e
3318         CODE:
3319                 RETVAL = e->resize.w;
3320         OUTPUT:
3321                 RETVAL
3322
3323 int
3324 ResizeEventH ( e )
3325         SDL_Event *e
3326         CODE:
3327                 RETVAL = e->resize.h;
3328         OUTPUT:
3329                 RETVAL
3330
3331 char*
3332 AudioDriverName ()
3333         CODE:
3334                 char name[32];
3335                 RETVAL = SDL_AudioDriverName(name,32);
3336         OUTPUT:
3337                 RETVAL
3338
3339 Uint32
3340 GetKeyState ( k )
3341         SDLKey k
3342         CODE:
3343                 if (k >= SDLK_LAST) Perl_croak (aTHX_ "Key out of range");      
3344                 RETVAL = SDL_GetKeyState(NULL)[k];
3345         OUTPUT:
3346                 RETVAL
3347
3348 #ifdef HAVE_SMPEG
3349
3350 SMPEG_Info *
3351 NewSMPEGInfo()
3352         CODE:   
3353                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3354         OUTPUT:
3355                 RETVAL
3356
3357 void
3358 FreeSMPEGInfo ( info )
3359         SMPEG_Info *info
3360         CODE:   
3361                 safefree(info);
3362
3363 int
3364 SMPEGInfoHasAudio ( info )
3365         SMPEG_Info* info
3366         CODE:
3367                 RETVAL = info->has_audio;
3368         OUTPUT:
3369                 RETVAL
3370
3371 int
3372 SMPEGInfoHasVideo ( info )
3373         SMPEG_Info* info
3374         CODE:
3375                 RETVAL = info->has_video;
3376         OUTPUT:
3377                 RETVAL
3378
3379 int
3380 SMPEGInfoWidth ( info )
3381         SMPEG_Info* info
3382         CODE:
3383                 RETVAL = info->width;
3384         OUTPUT:
3385                 RETVAL
3386
3387 int
3388 SMPEGInfoHeight ( info )
3389         SMPEG_Info* info
3390         CODE:
3391                 RETVAL = info->height;
3392         OUTPUT:
3393                 RETVAL
3394
3395 int
3396 SMPEGInfoCurrentFrame ( info )
3397         SMPEG_Info* info
3398         CODE:
3399                 RETVAL = info->current_frame;
3400         OUTPUT:
3401                 RETVAL
3402
3403 double
3404 SMPEGInfoCurrentFPS ( info )
3405         SMPEG_Info* info
3406         CODE:
3407                 RETVAL = info->current_fps;
3408         OUTPUT:
3409                 RETVAL
3410
3411 int
3412 SMPEGInfoCurrentAudioFrame ( info )
3413         SMPEG_Info* info
3414         CODE:
3415                 RETVAL = info->audio_current_frame;
3416         OUTPUT:
3417                 RETVAL
3418
3419 int
3420 SMPEGInfoCurrentOffset ( info )
3421         SMPEG_Info* info
3422         CODE:
3423                 RETVAL = info->current_offset;
3424         OUTPUT:
3425                 RETVAL
3426
3427 int
3428 SMPEGInfoTotalSize ( info )
3429         SMPEG_Info* info
3430         CODE:
3431                 RETVAL = info->total_size;
3432         OUTPUT:
3433                 RETVAL
3434
3435 double
3436 SMPEGInfoCurrentTime ( info )
3437         SMPEG_Info* info
3438         CODE:
3439                 RETVAL = info->current_time;
3440         OUTPUT:
3441                 RETVAL
3442
3443 double
3444 SMPEGInfoTotalTime ( info )
3445         SMPEG_Info* info
3446         CODE:
3447                 RETVAL = info->total_time;
3448         OUTPUT:
3449                 RETVAL
3450
3451 char *
3452 SMPEGError ( mpeg )
3453         SMPEG* mpeg
3454         CODE:   
3455                 RETVAL = SMPEG_error(mpeg);
3456         OUTPUT:
3457                 RETVAL
3458
3459 SMPEG*
3460 NewSMPEG ( filename, info, use_audio )
3461         char* filename
3462         SMPEG_Info* info
3463         int use_audio
3464         CODE:   
3465 #ifdef HAVE_SDL_MIXER
3466                 RETVAL = SMPEG_new(filename,info,0);
3467 #else
3468                 RETVAL = SMPEG_new(filename,info,use_audio);
3469 #endif
3470         OUTPUT:
3471                 RETVAL
3472
3473 void
3474 FreeSMPEG ( mpeg )
3475         SMPEG* mpeg
3476         CODE:
3477                 SMPEG_delete(mpeg);
3478
3479 void
3480 SMPEGEnableAudio ( mpeg , flag )
3481         SMPEG* mpeg
3482         int flag
3483         CODE:   
3484                 SMPEG_enableaudio(mpeg,flag);
3485 #ifdef HAVE_SDL_MIXER
3486                 sdl_perl_use_smpeg_audio = flag;
3487 #endif
3488
3489 void
3490 SMPEGEnableVideo ( mpeg , flag )
3491         SMPEG* mpeg
3492         int flag
3493         CODE:   
3494                 SMPEG_enablevideo(mpeg,flag);
3495
3496 void
3497 SMPEGSetVolume ( mpeg , volume )
3498         SMPEG* mpeg
3499         int volume
3500         CODE:   
3501                 SMPEG_setvolume(mpeg,volume);
3502
3503 void
3504 SMPEGSetDisplay ( mpeg, dest, surfLock )
3505         SMPEG* mpeg
3506         SDL_Surface* dest
3507         SDL_mutex*  surfLock
3508         CODE:
3509                 SMPEG_setdisplay(mpeg,dest,surfLock,NULL);
3510
3511 void
3512 SMPEGScaleXY ( mpeg, w, h)
3513         SMPEG* mpeg
3514         int w
3515         int h
3516         CODE:
3517                 SMPEG_scaleXY(mpeg,w,h);
3518
3519 void
3520 SMPEGScale ( mpeg, scale )
3521         SMPEG* mpeg
3522         int scale
3523         CODE:
3524                 SMPEG_scale(mpeg,scale);
3525
3526 void
3527 SMPEGPlay ( mpeg )
3528         SMPEG* mpeg
3529         CODE:
3530                 SDL_AudioSpec audiofmt;
3531                 Uint16 format;
3532                 int freq, channels;
3533 #ifdef HAVE_SDL_MIXER
3534                 if  (sdl_perl_use_smpeg_audio ) {
3535                         SMPEG_enableaudio(mpeg, 0);
3536                         Mix_QuerySpec(&freq, &format, &channels);
3537                         audiofmt.format = format;
3538                         audiofmt.freq = freq;
3539                         audiofmt.channels = channels;
3540                         SMPEG_actualSpec(mpeg, &audiofmt);
3541                         Mix_HookMusic(SMPEG_playAudioSDL, mpeg);
3542                         SMPEG_enableaudio(mpeg, 1);
3543                 }
3544 #endif
3545                 SMPEG_play(mpeg);
3546
3547 SMPEGstatus
3548 SMPEGStatus ( mpeg )
3549         SMPEG* mpeg
3550         CODE:
3551                 RETVAL = SMPEG_status(mpeg);
3552         OUTPUT:
3553                 RETVAL
3554
3555 void
3556 SMPEGPause ( mpeg )
3557         SMPEG* mpeg
3558         CODE:
3559                 SMPEG_pause(mpeg);
3560
3561 void
3562 SMPEGLoop ( mpeg, repeat )
3563         SMPEG* mpeg
3564         int repeat
3565         CODE:
3566                 SMPEG_loop(mpeg,repeat);
3567
3568 void
3569 SMPEGStop ( mpeg )
3570         SMPEG* mpeg
3571         CODE:
3572                 SMPEG_stop(mpeg);
3573 #ifdef HAVE_SDL_MIXER
3574                 Mix_HookMusic(NULL, NULL);
3575 #endif
3576
3577 void
3578 SMPEGRewind ( mpeg )
3579         SMPEG* mpeg
3580         CODE:
3581                 SMPEG_rewind(mpeg);
3582
3583 void
3584 SMPEGSeek ( mpeg, bytes )
3585         SMPEG* mpeg
3586         int bytes
3587         CODE:
3588                 SMPEG_seek(mpeg,bytes);
3589
3590 void
3591 SMPEGSkip ( mpeg, seconds )
3592         SMPEG* mpeg
3593         float seconds
3594         CODE:
3595                 SMPEG_skip(mpeg,seconds);
3596
3597 void
3598 SMPEGSetDisplayRegion ( mpeg, rect )
3599         SMPEG* mpeg
3600         SDL_Rect* rect
3601         CODE:
3602                 SMPEG_setdisplayregion(mpeg,rect->x,rect->y,rect->w,rect->h);
3603
3604 void
3605 SMPEGRenderFrame ( mpeg, frame )
3606         SMPEG* mpeg
3607         int frame
3608         CODE:
3609                 SMPEG_renderFrame(mpeg,frame);
3610
3611 SMPEG_Info *
3612 SMPEGGetInfo ( mpeg )
3613         SMPEG* mpeg
3614         CODE:
3615                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3616                 SMPEG_getinfo(mpeg,RETVAL);
3617         OUTPUT:
3618                 RETVAL
3619         
3620
3621 #endif
3622
3623 #ifdef HAVE_SDL_GFX
3624
3625 =cut
3626
3627 SDL_Surface *
3628 GFXRotoZoom ( src, angle, zoom, smooth)
3629         SDL_Surface * src
3630         double angle
3631         double zoom
3632         int smooth
3633         CODE:
3634                 RETVAL = rotozoomSurface( src, angle, zoom, smooth);
3635         OUTPUT:
3636                 RETVAL
3637
3638 SDL_Surface *
3639 GFXZoom ( src, zoomx, zoomy, smooth)
3640         SDL_Surface *src
3641         double zoomx
3642         double zoomy
3643         int smooth
3644         CODE:
3645                 RETVAL = zoomSurface( src, zoomx, zoomy, smooth);
3646         OUTPUT:
3647                 RETVAL
3648
3649 =cut
3650
3651 int
3652 GFXPixelColor ( dst, x, y, color )
3653         SDL_Surface* dst
3654         Sint16 x
3655         Sint16 y
3656         Uint32 color
3657         CODE:
3658                 RETVAL = pixelColor( dst, x, y, color);
3659         OUTPUT:
3660                 RETVAL
3661
3662 int
3663 GFXPixelRGBA ( dst, x, y, r, g, b, a )
3664         SDL_Surface* dst
3665         Sint16 x
3666         Sint16 y
3667         Uint8 r
3668         Uint8 g
3669         Uint8 b
3670         Uint8 a
3671         CODE:
3672                 RETVAL = pixelRGBA( dst, x, y, r, g, b, a );
3673         OUTPUT:
3674                 RETVAL
3675
3676 int
3677 GFXHlineColor ( dst, x1, x2, y, color )
3678         SDL_Surface* dst
3679         Sint16 x1
3680         Sint16 x2
3681         Sint16 y
3682         Uint32 color
3683         CODE:
3684                 RETVAL = hlineColor( dst, x1, x2, y, color );
3685         OUTPUT:
3686                 RETVAL
3687
3688 int
3689 GFXHlineRGBA ( dst, x1, x2, y, r, g, b, a )
3690         SDL_Surface* dst
3691         Sint16 x1
3692         Sint16 x2
3693         Sint16 y
3694         Uint8 r
3695         Uint8 g
3696         Uint8 b
3697         Uint8 a
3698         CODE:
3699                 RETVAL = hlineRGBA( dst, x1, x2, y, r, g, b, a );
3700         OUTPUT:
3701                 RETVAL
3702
3703 int
3704 GFXVlineColor ( dst, x, y1, y2, color )
3705         SDL_Surface* dst
3706         Sint16 x
3707         Sint16 y1
3708         Sint16 y2
3709         Uint32 color
3710         CODE:
3711                 RETVAL = vlineColor( dst, x, y1, y2, color );
3712         OUTPUT:
3713                 RETVAL
3714
3715 int
3716 GFXVlineRGBA ( dst, x, y1, y2, r, g, b, a )
3717         SDL_Surface* dst
3718         Sint16 x
3719         Sint16 y1
3720         Sint16 y2
3721         Uint8 r
3722         Uint8 g
3723         Uint8 b
3724         Uint8 a
3725         CODE:
3726                 RETVAL = vlineRGBA( dst, x, y1, y2, r, g, b, a );
3727         OUTPUT:
3728                 RETVAL
3729
3730 int
3731 GFXRectangleColor ( dst, x1, y1, x2, y2, color )
3732         SDL_Surface* dst
3733         Sint16 x1
3734         Sint16 y1
3735         Sint16 x2
3736         Sint16 y2
3737         Uint32 color
3738         CODE:
3739                 RETVAL = rectangleColor( dst, x1, y1, x2, y2, color );
3740         OUTPUT:
3741                 RETVAL
3742
3743 int
3744 GFXRectangleRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3745         SDL_Surface* dst
3746         Sint16 x1
3747         Sint16 y1
3748         Sint16 x2
3749         Sint16 y2
3750         Uint8 r
3751         Uint8 g
3752         Uint8 b
3753         Uint8 a
3754         CODE:
3755                 RETVAL = rectangleRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3756         OUTPUT:
3757                 RETVAL
3758
3759 int
3760 GFXBoxColor ( dst, x1, y1, x2, y2, color )
3761         SDL_Surface* dst
3762         Sint16 x1
3763         Sint16 y1
3764         Sint16 x2
3765         Sint16 y2
3766         Uint32 color
3767         CODE:
3768                 RETVAL = boxColor( dst, x1, y1, x2, y2, color );
3769         OUTPUT:
3770                 RETVAL
3771
3772 int
3773 GFXBoxRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3774         SDL_Surface* dst;
3775         Sint16 x1
3776         Sint16 y1
3777         Sint16 x2
3778         Sint16 y2
3779         Uint8 r
3780         Uint8 g
3781         Uint8 b
3782         Uint8 a
3783         CODE:
3784                 RETVAL = boxRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3785         OUTPUT:
3786                 RETVAL
3787
3788 int
3789 GFXLineColor ( dst, x1, y1, x2, y2, color )
3790         SDL_Surface* dst
3791         Sint16 x1
3792         Sint16 y1
3793         Sint16 x2
3794         Sint16 y2
3795         Uint32 color
3796         CODE:
3797                 RETVAL = lineColor( dst, x1, y1, x2, y2, color );
3798         OUTPUT:
3799                 RETVAL
3800
3801 int
3802 GFXLineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3803         SDL_Surface* dst
3804         Sint16 x1
3805         Sint16 y1
3806         Sint16 x2
3807         Sint16 y2
3808         Uint8 r
3809         Uint8 g
3810         Uint8 b
3811         Uint8 a
3812         CODE:
3813                 RETVAL = lineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3814         OUTPUT:
3815                 RETVAL
3816
3817 int
3818 GFXAalineColor ( dst, x1, y1, x2, y2, color )
3819         SDL_Surface* dst
3820         Sint16 x1
3821         Sint16 y1
3822         Sint16 x2
3823         Sint16 y2
3824         Uint32 color
3825         CODE:
3826                 RETVAL = aalineColor( dst, x1, y1, x2, y2, color );
3827         OUTPUT:
3828                 RETVAL
3829
3830 int
3831 GFXAalineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3832         SDL_Surface* dst
3833         Sint16 x1
3834         Sint16 y1
3835         Sint16 x2
3836         Sint16 y2
3837         Uint8 r
3838         Uint8 g
3839         Uint8 b
3840         Uint8 a
3841         CODE:
3842                 RETVAL = aalineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3843         OUTPUT:
3844                 RETVAL
3845
3846 int
3847 GFXCircleColor ( dst, x, y, r, color )
3848         SDL_Surface* dst
3849         Sint16 x
3850         Sint16 y
3851         Sint16 r
3852         Uint32 color
3853         CODE:
3854                 RETVAL = circleColor( dst, x, y, r, color );
3855         OUTPUT:
3856                 RETVAL
3857
3858 int
3859 GFXCircleRGBA ( dst, x, y, rad, r, g, b, a )
3860         SDL_Surface* dst
3861         Sint16 x
3862         Sint16 y
3863         Sint16 rad
3864         Uint8 r
3865         Uint8 g
3866         Uint8 b
3867         Uint8 a
3868         CODE:
3869                 RETVAL = circleRGBA( dst, x, y, rad, r, g, b, a );
3870         OUTPUT:
3871                 RETVAL
3872
3873 int
3874 GFXAacircleColor ( dst, x, y, r, color )
3875         SDL_Surface* dst
3876         Sint16 x
3877         Sint16 y
3878         Sint16 r
3879         Uint32 color
3880         CODE:
3881                 RETVAL = aacircleColor( dst, x, y, r, color );
3882         OUTPUT:
3883                 RETVAL
3884
3885 int
3886 GFXAacircleRGBA ( dst, x, y, rad, r, g, b, a )
3887         SDL_Surface* dst
3888         Sint16 x
3889         Sint16 y
3890         Sint16 rad
3891         Uint8 r
3892         Uint8 g
3893         Uint8 b
3894         Uint8 a
3895         CODE:
3896                 RETVAL = aacircleRGBA( dst, x, y, rad, r, g, b, a );
3897         OUTPUT:
3898                 RETVAL
3899
3900 int
3901 GFXFilledCircleColor ( dst, x, y, r, color )
3902         SDL_Surface* dst
3903         Sint16 x
3904         Sint16 y
3905         Sint16 r
3906         Uint32 color
3907         CODE:
3908                 RETVAL = filledCircleColor( dst, x, y, r, color );
3909         OUTPUT:
3910                 RETVAL
3911
3912 int
3913 GFXFilledCircleRGBA ( dst, x, y, rad, r, g, b, a )
3914         SDL_Surface* dst
3915         Sint16 x
3916         Sint16 y
3917         Sint16 rad
3918         Uint8 r
3919         Uint8 g
3920         Uint8 b
3921         Uint8 a
3922         CODE:
3923                 RETVAL = filledCircleRGBA( dst, x, y, rad, r, g, b, a );
3924         OUTPUT:
3925                 RETVAL
3926
3927 int
3928 GFXEllipseColor ( dst, x, y, rx, ry, color )
3929         SDL_Surface* dst
3930         Sint16 x
3931         Sint16 y
3932         Sint16 rx
3933         Sint16 ry
3934         Uint32 color
3935         CODE:
3936                 RETVAL = ellipseColor( dst, x, y, rx, ry, color );
3937         OUTPUT:
3938                 RETVAL
3939
3940 int
3941 GFXEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
3942         SDL_Surface* dst
3943         Sint16 x
3944         Sint16 y
3945         Sint16  rx
3946         Sint16 ry
3947         Uint8 r
3948         Uint8 g
3949         Uint8 b
3950         Uint8 a
3951         CODE:
3952                 RETVAL = ellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
3953         OUTPUT:
3954                 RETVAL
3955
3956 int
3957 GFXAaellipseColor ( dst, xc, yc, rx, ry, color )
3958         SDL_Surface* dst
3959         Sint16 xc
3960         Sint16 yc
3961         Sint16 rx
3962         Sint16 ry
3963         Uint32 color
3964         CODE:
3965                 RETVAL = aaellipseColor( dst, xc, yc, rx, ry, color );
3966         OUTPUT:
3967                 RETVAL
3968
3969 int
3970 GFXAaellipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
3971         SDL_Surface* dst
3972         Sint16 x
3973         Sint16 y
3974         Sint16 rx
3975         Sint16 ry
3976         Uint8 r
3977         Uint8 g
3978         Uint8 b
3979         Uint8 a
3980         CODE:
3981                 RETVAL = aaellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
3982         OUTPUT:
3983                 RETVAL
3984
3985 int
3986 GFXFilledEllipseColor ( dst, x, y, rx, ry, color )
3987         SDL_Surface* dst
3988         Sint16 x
3989         Sint16 y
3990         Sint16 rx
3991         Sint16 ry
3992         Uint32 color
3993         CODE:
3994                 RETVAL = filledEllipseColor( dst, x, y, rx, ry, color );
3995         OUTPUT:
3996                 RETVAL
3997
3998 int
3999 GFXFilledEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
4000         SDL_Surface* dst
4001         Sint16 x
4002         Sint16 y
4003         Sint16 rx
4004         Sint16 ry
4005         Uint8 r
4006         Uint8 g
4007         Uint8 b
4008         Uint8 a
4009         CODE:
4010                 RETVAL = filledEllipseRGBA( dst, x, y, rx, ry, r, g, b, a );
4011         OUTPUT:
4012                 RETVAL
4013
4014 int
4015 GFXFilledPieColor ( dst, x, y, rad, start, end, color )
4016         SDL_Surface* dst
4017         Sint16 x
4018         Sint16 y
4019         Sint16 rad
4020         Sint16 start
4021         Sint16 end
4022         Uint32 color
4023         CODE:
4024                 RETVAL = filledPieColor( dst, x, y, rad, start, end, color );
4025         OUTPUT:
4026                 RETVAL
4027
4028 int
4029 GFXFilledPieRGBA ( dst, x, y, rad, start, end, r, g, b, a )
4030         SDL_Surface* dst
4031         Sint16 x
4032         Sint16 y
4033         Sint16 rad
4034         Sint16 start
4035         Sint16 end
4036         Uint8 r
4037         Uint8 g
4038         Uint8 b
4039         Uint8 a
4040         CODE:
4041                 RETVAL = filledPieRGBA( dst, x, y, rad, start, end, r, g, b, a );
4042         OUTPUT:
4043                 RETVAL
4044
4045 int
4046 GFXPolygonColor ( dst, vx, vy, n, color )
4047         SDL_Surface* dst
4048         Sint16* vx
4049         Sint16* vy
4050         int n
4051         Uint32 color;
4052         CODE:
4053                 RETVAL = polygonColor( dst, vx, vy, n, color );
4054         OUTPUT:
4055                 RETVAL
4056
4057 int
4058 GFXPolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4059         SDL_Surface* dst
4060         Sint16* vx
4061         Sint16* vy
4062         int n
4063         Uint8 r
4064         Uint8 g
4065         Uint8 b
4066         Uint8 a
4067         CODE:
4068                 RETVAL = polygonRGBA( dst, vx, vy, n, r, g, b, a );
4069         OUTPUT:
4070                 RETVAL
4071
4072 int
4073 GFXAapolygonColor ( dst, vx, vy, n, color )
4074         SDL_Surface* dst
4075         Sint16* vx
4076         Sint16* vy
4077         int n
4078         Uint32 color
4079         CODE:
4080                 RETVAL = aapolygonColor( dst, vx, vy, n, color );
4081         OUTPUT:
4082                 RETVAL
4083
4084 int
4085 GFXAapolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4086         SDL_Surface* dst
4087         Sint16* vx
4088         Sint16* vy
4089         int n
4090         Uint8 r
4091         Uint8 g
4092         Uint8 b
4093         Uint8 a
4094         CODE:
4095                 RETVAL = aapolygonRGBA( dst, vx, vy, n, r, g, b, a );
4096         OUTPUT:
4097                 RETVAL
4098
4099 int
4100 GFXFilledPolygonColor ( dst, vx, vy, n, color )
4101         SDL_Surface* dst
4102         Sint16* vx
4103         Sint16* vy
4104         int n
4105         int color
4106         CODE:
4107                 RETVAL = filledPolygonColor( dst, vx, vy, n, color );
4108         OUTPUT:
4109                 RETVAL
4110
4111 int
4112 GFXFilledPolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4113         SDL_Surface* dst
4114         Sint16* vx
4115         Sint16* vy
4116         int n
4117         Uint8 r
4118         Uint8 g
4119         Uint8 b
4120         Uint8 a
4121         CODE:
4122                 RETVAL = filledPolygonRGBA( dst, vx, vy, n, r, g, b, a );
4123         OUTPUT:
4124                 RETVAL
4125
4126 int
4127 GFXCharacterColor ( dst, x, y, c, color )
4128         SDL_Surface* dst
4129         Sint16 x
4130         Sint16 y
4131         char c
4132         Uint32 color
4133         CODE:
4134                 RETVAL = characterColor( dst, x, y, c, color );
4135         OUTPUT:
4136                 RETVAL
4137
4138 int
4139 GFXCharacterRGBA ( dst, x, y, c, r, g, b, a )
4140         SDL_Surface* dst
4141         Sint16 x
4142         Sint16 y
4143         char c
4144         Uint8 r
4145         Uint8 g
4146         Uint8 b
4147         Uint8 a
4148         CODE:
4149                 RETVAL = characterRGBA( dst, x, y, c, r, g, b, a );
4150         OUTPUT:
4151                 RETVAL
4152
4153 int
4154 GFXStringColor ( dst, x, y, c, color )
4155         SDL_Surface* dst
4156         Sint16 x
4157         Sint16 y
4158         char* c
4159         Uint32 color
4160         CODE:
4161                 RETVAL = stringColor( dst, x, y, c, color );
4162         OUTPUT:
4163                 RETVAL
4164
4165 int
4166 GFXStringRGBA ( dst, x, y, c, r, g, b, a )
4167         SDL_Surface* dst
4168         Sint16 x
4169         Sint16 y
4170         char* c
4171         Uint8 r
4172         Uint8 g
4173         Uint8 b
4174         Uint8 a
4175         CODE:
4176                 RETVAL = stringRGBA( dst, x, y, c, r, g, b, a );
4177         OUTPUT:
4178                 RETVAL
4179
4180 #endif
4181
4182
4183 #ifdef HAVE_SDL_SVG
4184
4185 SDL_svg_context *
4186 SVG_Load ( filename )
4187         char* filename
4188         CODE:
4189                 RETVAL = SVG_Load(filename);
4190         OUTPUT:
4191                 RETVAL
4192
4193 SDL_svg_context *
4194 SVG_LoadBuffer ( data, len )
4195         char* data
4196         int len
4197         CODE:
4198                 RETVAL = SVG_LoadBuffer(data,len);
4199         OUTPUT:
4200                 RETVAL
4201
4202 int
4203 SVG_SetOffset ( source, xoff, yoff )
4204         SDL_svg_context* source
4205         double xoff
4206         double yoff
4207         CODE:
4208                 RETVAL = SVG_SetOffset(source,xoff,yoff);
4209         OUTPUT:
4210                 RETVAL
4211
4212 int
4213 SVG_SetScale ( source, xscale, yscale )
4214         SDL_svg_context* source
4215         double xscale
4216         double yscale
4217         CODE:
4218                 RETVAL = SVG_SetScale(source,xscale,yscale);
4219         OUTPUT:
4220                 RETVAL
4221
4222 int
4223 SVG_RenderToSurface ( source, x, y, dest )
4224         SDL_svg_context* source
4225         int x
4226         int y
4227         SDL_Surface* dest;
4228         CODE:
4229                 RETVAL = SVG_RenderToSurface(source,x,y,dest);
4230         OUTPUT:
4231                 RETVAL
4232
4233 void
4234 SVG_Free ( source )
4235         SDL_svg_context* source
4236         CODE:
4237                 SVG_Free(source);       
4238
4239 void
4240 SVG_Set_Flags ( source, flags )
4241         SDL_svg_context* source
4242         Uint32 flags
4243         CODE:
4244                 SVG_Set_Flags(source,flags);
4245
4246 float
4247 SVG_Width ( source )
4248         SDL_svg_context* source
4249         CODE:
4250                 RETVAL = SVG_Width(source);
4251         OUTPUT:
4252                 RETVAL
4253
4254 float
4255 SVG_HEIGHT ( source )
4256         SDL_svg_context* source
4257         CODE:
4258                 RETVAL = SVG_Height(source);
4259         OUTPUT:
4260                 RETVAL
4261
4262 void
4263 SVG_SetClipping ( source, minx, miny, maxx, maxy )
4264         SDL_svg_context* source
4265         int minx
4266         int miny
4267         int maxx
4268         int maxy
4269         CODE:
4270                 SVG_SetClipping(source,minx,miny,maxx,maxy);
4271
4272 int
4273 SVG_Version ( )
4274         CODE:
4275                 RETVAL = SVG_Version();
4276         OUTPUT:
4277                 RETVAL
4278
4279
4280 #endif
4281
4282 #ifdef HAVE_SDL_SOUND
4283
4284 Uint16
4285 SoundAudioInfoFormat ( audioinfo )
4286         Sound_AudioInfo* audioinfo
4287         CODE:
4288                 RETVAL = audioinfo->format;
4289         OUTPUT:
4290                 RETVAL
4291
4292 Uint8
4293 SoundAudioInfoChannels ( audioinfo )
4294         Sound_AudioInfo* audioinfo
4295         CODE:
4296                 RETVAL = audioinfo->channels;
4297         OUTPUT:
4298                 RETVAL
4299
4300 Uint32
4301 SoundAudioInforate ( audioinfo )
4302         Sound_AudioInfo* audioinfo
4303         CODE:
4304                 RETVAL = audioinfo->rate;
4305         OUTPUT:
4306                 RETVAL
4307
4308 AV*
4309 SoundDecoderInfoExtensions ( decoderinfo )
4310         Sound_DecoderInfo* decoderinfo
4311         CODE:
4312                 const char **ext;
4313                 for ( ext = decoderinfo->extensions; *ext != NULL; ext++ ){
4314                         av_push(RETVAL,newSVpv(*ext,0));
4315                 }
4316         OUTPUT:
4317                 RETVAL
4318
4319 const char*
4320 SoundDecoderInfoDescription ( decoderinfo )
4321         Sound_DecoderInfo* decoderinfo
4322         CODE:
4323                 RETVAL = decoderinfo->description;
4324         OUTPUT:
4325                 RETVAL
4326
4327 const char*
4328 SoundDecoderInfoAuthor ( decoderinfo )
4329         Sound_DecoderInfo* decoderinfo
4330         CODE:
4331                 RETVAL = decoderinfo->author;
4332         OUTPUT:
4333                 RETVAL
4334
4335 const char*
4336 SoundDecoderInfoUrl ( decoderinfo )
4337         Sound_DecoderInfo* decoderinfo
4338         CODE:
4339                 RETVAL = decoderinfo->url;
4340         OUTPUT:
4341                 RETVAL
4342
4343 const Sound_DecoderInfo*
4344 SoundSampleDecoder ( sample ) 
4345         Sound_Sample* sample
4346         CODE:
4347                 RETVAL = sample->decoder;
4348         OUTPUT:
4349                 RETVAL
4350
4351 Sound_AudioInfo* 
4352 SoundSampleDesired ( sample )
4353         Sound_Sample* sample
4354         CODE:
4355                 RETVAL = &sample->desired;
4356         OUTPUT:
4357                 RETVAL
4358
4359 Sound_AudioInfo*
4360 SoundSampleAcutal ( sample )
4361         Sound_Sample* sample
4362         CODE:
4363                 RETVAL = &sample->actual;
4364         OUTPUT:
4365                 RETVAL
4366
4367 char*
4368 SoundSampleBuffer ( sample )
4369         Sound_Sample* sample
4370         CODE:
4371                 RETVAL = sample->buffer;
4372         OUTPUT:
4373                 RETVAL
4374
4375 Uint32
4376 SoundSampleBufferSize ( sample )
4377         Sound_Sample* sample
4378         CODE:
4379                 RETVAL = sample->buffer_size;
4380         OUTPUT:
4381                 RETVAL
4382
4383 Uint32
4384 SoundSampleFlags ( sample )
4385         Sound_Sample* sample
4386         CODE:
4387                 RETVAL = (Uint32)sample->flags;
4388         OUTPUT:
4389                 RETVAL
4390
4391 int
4392 Sound_Init ( )
4393         CODE:
4394                 RETVAL = Sound_Init();
4395         OUTPUT:
4396                 RETVAL
4397
4398 int
4399 Sound_Quit ( )
4400         CODE:
4401                 RETVAL = Sound_Quit();
4402         OUTPUT:
4403                 RETVAL
4404
4405 AV*
4406 Sound_AvailableDecoders ( )
4407         CODE:
4408                 RETVAL = newAV();
4409                 const Sound_DecoderInfo** sdi;
4410                 sdi = Sound_AvailableDecoders();
4411                 if (sdi != NULL)  {
4412                         for (;*sdi != NULL; ++sdi) {
4413                                 av_push(RETVAL,sv_2mortal(newSViv(PTR2IV(*sdi))));
4414                         }
4415                 }
4416         OUTPUT:
4417                 RETVAL
4418
4419 const char*
4420 Sound_GetError ( )
4421         CODE:
4422                 RETVAL = Sound_GetError();
4423         OUTPUT:
4424                 RETVAL
4425
4426 void
4427 Sound_ClearError ( )
4428         CODE:
4429                 Sound_ClearError();
4430
4431 Sound_Sample*
4432 Sound_NewSample ( rw, ext, desired, buffsize )
4433         SDL_RWops* rw
4434         const char* ext
4435         Sound_AudioInfo* desired
4436         Uint32 buffsize
4437         CODE:
4438                 RETVAL = Sound_NewSample(rw,ext,desired,buffsize);
4439         OUTPUT:
4440                 RETVAL
4441
4442 Sound_Sample*
4443 Sound_NewSampleFromMem ( data, size, ext, desired, buffsize )
4444         const Uint8 *data
4445         Uint32 size
4446         const char* ext
4447         Sound_AudioInfo* desired
4448         Uint32 buffsize
4449         CODE:
4450                 RETVAL = Sound_NewSampleFromMem(data,size,ext,desired,buffsize);
4451         OUTPUT:
4452                 RETVAL
4453
4454 Sound_Sample*
4455 Sound_NewSampleFromFile ( fname, desired, buffsize )
4456         const char* fname
4457         Sound_AudioInfo* desired
4458         Uint32 buffsize
4459         CODE:
4460                 RETVAL = Sound_NewSampleFromFile(fname,desired,buffsize);
4461         OUTPUT:
4462                 RETVAL
4463
4464 void
4465 Sound_FreeSample ( sample )
4466         Sound_Sample* sample
4467         CODE:
4468                 Sound_FreeSample(sample);
4469
4470 Sint32
4471 Sound_GetDuration ( sample )
4472         Sound_Sample* sample
4473         CODE:
4474                 RETVAL = Sound_GetDuration(sample);
4475         OUTPUT:
4476                 RETVAL
4477
4478 int
4479 Sound_SetBufferSize ( sample, size )
4480         Sound_Sample* sample
4481         Uint32 size
4482         CODE:
4483                 RETVAL = Sound_SetBufferSize(sample,size);
4484         OUTPUT:
4485                 RETVAL
4486
4487 Uint32
4488 Sound_Decode ( sample )
4489         Sound_Sample* sample
4490         CODE:
4491                 RETVAL = Sound_Decode(sample);
4492         OUTPUT:
4493                 RETVAL
4494
4495 Uint32
4496 Sound_DecodeAll ( sample ) 
4497         Sound_Sample* sample
4498         CODE:
4499                 RETVAL = Sound_DecodeAll(sample);
4500         OUTPUT:
4501                 RETVAL
4502
4503 int
4504 Sound_Rewind ( sample )
4505         Sound_Sample* sample
4506         CODE:
4507                 RETVAL = Sound_Rewind(sample);
4508         OUTPUT:
4509                 RETVAL
4510
4511 int
4512 Sound_Seek ( sample, ms )
4513         Sound_Sample* sample
4514         Uint32 ms
4515         CODE:
4516                 RETVAL = Sound_Seek(sample,ms);
4517         OUTPUT:
4518                 RETVAL
4519
4520 #endif
4521
4522 MODULE = SDL            PACKAGE = SDL
4523 PROTOTYPES : DISABLE
4524
4525