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