Added SDL::Mixer::mix_set_panning support
[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 MixSetPanning ( channel, left, right )
1942         int channel
1943         Uint8 left
1944         Uint8 right
1945         CODE:
1946                 RETVAL = Mix_SetPanning(channel,left, right);
1947         OUTPUT:
1948                 RETVAL
1949
1950
1951 int
1952 MixPlayChannelTimed ( channel, chunk, loops, ticks )
1953         int channel
1954         Mix_Chunk *chunk
1955         int loops
1956         int ticks
1957         CODE:
1958                 RETVAL = Mix_PlayChannelTimed(channel,chunk,loops,ticks);
1959         OUTPUT:
1960                 RETVAL
1961
1962 int
1963 MixPlayMusic ( music, loops )
1964         Mix_Music *music
1965         int loops
1966         CODE:
1967                 RETVAL = Mix_PlayMusic(music,loops);
1968         OUTPUT:
1969                 RETVAL
1970
1971 int
1972 MixFadeInChannel ( channel, chunk, loops, ms )
1973         int channel
1974         Mix_Chunk *chunk
1975         int loops
1976         int ms
1977         CODE:
1978                 RETVAL = Mix_FadeInChannel(channel,chunk,loops,ms);
1979         OUTPUT:
1980                 RETVAL
1981
1982 int
1983 MixFadeInChannelTimed ( channel, chunk, loops, ms, ticks )
1984         int channel
1985         Mix_Chunk *chunk
1986         int loops
1987         int ticks
1988         int ms
1989         CODE:
1990                 RETVAL = Mix_FadeInChannelTimed(channel,chunk,loops,ms,ticks);
1991         OUTPUT:
1992                 RETVAL
1993
1994 int
1995 MixFadeInMusic ( music, loops, ms )
1996         Mix_Music *music
1997         int loops
1998         int ms
1999         CODE:
2000                 RETVAL = Mix_FadeInMusic(music,loops,ms);
2001         OUTPUT:
2002                 RETVAL
2003
2004 int
2005 MixVolume ( channel, volume )
2006         int channel
2007         int volume
2008         CODE:   
2009                 RETVAL = Mix_Volume(channel,volume);
2010         OUTPUT:
2011                 RETVAL
2012
2013 int
2014 MixVolumeChunk ( chunk, volume )
2015         Mix_Chunk *chunk
2016         int volume
2017         CODE:
2018                 RETVAL = Mix_VolumeChunk(chunk,volume);
2019         OUTPUT:
2020                 RETVAL
2021
2022 int
2023 MixVolumeMusic ( volume )
2024         int volume
2025         CODE:
2026                 RETVAL = Mix_VolumeMusic(volume);
2027         OUTPUT:
2028                 RETVAL
2029
2030 int
2031 MixHaltChannel ( channel )
2032         int channel
2033         CODE:
2034                 RETVAL = Mix_HaltChannel(channel);
2035         OUTPUT:
2036                 RETVAL
2037
2038 int
2039 MixHaltGroup ( tag )
2040         int tag
2041         CODE:
2042                 RETVAL = Mix_HaltGroup(tag);
2043         OUTPUT:
2044                 RETVAL
2045
2046 int
2047 MixHaltMusic ()
2048         CODE:
2049                 RETVAL = Mix_HaltMusic();
2050         OUTPUT:
2051                 RETVAL
2052
2053 int
2054 MixExpireChannel ( channel, ticks )
2055         int channel
2056         int ticks
2057         CODE:
2058                 RETVAL = Mix_ExpireChannel ( channel,ticks);
2059         OUTPUT:
2060                 RETVAL
2061
2062 int
2063 MixFadeOutChannel ( which, ms )
2064         int which
2065         int ms
2066         CODE:
2067                 RETVAL = Mix_FadeOutChannel(which,ms);
2068         OUTPUT:
2069                 RETVAL
2070
2071 int
2072 MixFadeOutGroup ( which, ms )
2073         int which
2074         int ms
2075         CODE:
2076                 RETVAL = Mix_FadeOutGroup(which,ms);
2077         OUTPUT:
2078                 RETVAL
2079
2080 int
2081 MixFadeOutMusic ( ms )
2082         int ms
2083         CODE:
2084                 RETVAL = Mix_FadeOutMusic(ms);
2085         OUTPUT:
2086                 RETVAL
2087
2088 Mix_Fading
2089 MixFadingMusic()
2090         CODE:
2091                 RETVAL = Mix_FadingMusic();
2092         OUTPUT:
2093                 RETVAL
2094
2095 Mix_Fading
2096 MixFadingChannel( which )
2097         int which
2098         CODE:
2099                 RETVAL = Mix_FadingChannel(which);
2100         OUTPUT:
2101                 RETVAL
2102
2103 void
2104 MixPause ( channel )
2105         int channel
2106         CODE:
2107                 Mix_Pause(channel);
2108
2109 void
2110 MixResume ( channel )
2111         int channel
2112         CODE:
2113                 Mix_Resume(channel);
2114
2115 int
2116 MixPaused ( channel )
2117         int channel
2118         CODE:
2119                 RETVAL = Mix_Paused(channel);
2120         OUTPUT:
2121                 RETVAL
2122
2123 void
2124 MixPauseMusic ()
2125         CODE:
2126                 Mix_PauseMusic();
2127
2128 void
2129 MixResumeMusic ()
2130         CODE:
2131                 Mix_ResumeMusic();
2132
2133 void
2134 MixRewindMusic ()
2135         CODE:
2136                 Mix_RewindMusic();
2137
2138 int
2139 MixPausedMusic ()
2140         CODE:
2141                 RETVAL = Mix_PausedMusic();
2142         OUTPUT:
2143                 RETVAL
2144
2145 int
2146 MixPlaying( channel )
2147         int channel     
2148         CODE:
2149                 RETVAL = Mix_Playing(channel);
2150         OUTPUT:
2151                 RETVAL
2152
2153 int
2154 MixPlayingMusic()
2155         CODE:
2156                 RETVAL = Mix_PlayingMusic();
2157         OUTPUT:
2158                 RETVAL
2159
2160
2161 void
2162 MixCloseAudio ()
2163         CODE:
2164                 Mix_CloseAudio();
2165
2166 #endif
2167
2168 int
2169 GLLoadLibrary ( path )
2170         char *path
2171         CODE:
2172                 RETVAL = SDL_GL_LoadLibrary(path);
2173         OUTPUT:
2174                 RETVAL
2175
2176 void*
2177 GLGetProcAddress ( proc )
2178         char *proc
2179         CODE:
2180                 RETVAL = SDL_GL_GetProcAddress(proc);
2181         OUTPUT:
2182                 RETVAL
2183
2184 int
2185 GLSetAttribute ( attr,  value )
2186         int        attr
2187         int        value
2188         CODE:
2189                 RETVAL = SDL_GL_SetAttribute(attr, value);
2190         OUTPUT:
2191                 RETVAL
2192
2193 AV *
2194 GLGetAttribute ( attr )
2195         int        attr
2196         CODE:
2197                 int value;
2198                 RETVAL = newAV();
2199                 av_push(RETVAL,newSViv(SDL_GL_GetAttribute(attr, &value)));
2200                 av_push(RETVAL,newSViv(value));
2201         OUTPUT:
2202                 RETVAL
2203
2204 void
2205 GLSwapBuffers ()
2206         CODE:
2207                 SDL_GL_SwapBuffers ();
2208
2209
2210 int
2211 BigEndian ()
2212         CODE:
2213                 RETVAL = (SDL_BYTEORDER == SDL_BIG_ENDIAN);
2214         OUTPUT:
2215                 RETVAL
2216
2217 int
2218 NumJoysticks ()
2219         CODE:
2220                 RETVAL = SDL_NumJoysticks();
2221         OUTPUT:
2222                 RETVAL
2223
2224 char *
2225 JoystickName ( index )
2226         int index
2227         CODE:
2228                 RETVAL = (char*)SDL_JoystickName(index);
2229         OUTPUT:
2230                 RETVAL
2231
2232 SDL_Joystick *
2233 JoystickOpen ( index ) 
2234         int index
2235         CODE:
2236                 RETVAL = SDL_JoystickOpen(index);
2237         OUTPUT:
2238                 RETVAL
2239
2240 int
2241 JoystickOpened ( index )
2242         int index
2243         CODE:
2244                 RETVAL = SDL_JoystickOpened(index);
2245         OUTPUT:
2246                 RETVAL
2247
2248 int
2249 JoystickIndex ( joystick )
2250         SDL_Joystick *joystick
2251         CODE:
2252                 RETVAL = SDL_JoystickIndex(joystick);
2253         OUTPUT:
2254                 RETVAL
2255
2256 int
2257 JoystickNumAxes ( joystick )
2258         SDL_Joystick *joystick
2259         CODE:
2260                 RETVAL = SDL_JoystickNumAxes(joystick);
2261         OUTPUT:
2262                 RETVAL
2263
2264 int
2265 JoystickNumBalls ( joystick )
2266         SDL_Joystick *joystick
2267         CODE:
2268                 RETVAL = SDL_JoystickNumBalls(joystick);
2269         OUTPUT:
2270                 RETVAL
2271
2272 int
2273 JoystickNumHats ( joystick )
2274         SDL_Joystick *joystick
2275         CODE:
2276                 RETVAL = SDL_JoystickNumHats(joystick);
2277         OUTPUT:
2278                 RETVAL
2279
2280 int
2281 JoystickNumButtons ( joystick )
2282         SDL_Joystick *joystick
2283         CODE:
2284                 RETVAL = SDL_JoystickNumButtons(joystick);
2285         OUTPUT:
2286                 RETVAL
2287
2288 void
2289 JoystickUpdate ()
2290         CODE:
2291                 SDL_JoystickUpdate();
2292
2293 Sint16
2294 JoystickGetAxis ( joystick, axis )
2295         SDL_Joystick *joystick
2296         int axis
2297         CODE:
2298                 RETVAL = SDL_JoystickGetAxis(joystick,axis);
2299         OUTPUT:
2300                 RETVAL
2301
2302 Uint8
2303 JoystickGetHat ( joystick, hat )
2304         SDL_Joystick *joystick
2305         int hat 
2306         CODE:
2307                 RETVAL = SDL_JoystickGetHat(joystick,hat);
2308         OUTPUT:
2309                 RETVAL
2310
2311 Uint8
2312 JoystickGetButton ( joystick, button)
2313         SDL_Joystick *joystick
2314         int button 
2315         CODE:
2316                 RETVAL = SDL_JoystickGetButton(joystick,button);
2317         OUTPUT:
2318                 RETVAL
2319
2320 AV *
2321 JoystickGetBall ( joystick, ball )
2322         SDL_Joystick *joystick
2323         int ball 
2324         CODE:
2325                 int success,dx,dy;
2326                 success = SDL_JoystickGetBall(joystick,ball,&dx,&dy);
2327                 RETVAL = newAV();
2328                 av_push(RETVAL,newSViv(success));
2329                 av_push(RETVAL,newSViv(dx));
2330                 av_push(RETVAL,newSViv(dy));
2331         OUTPUT:
2332                 RETVAL  
2333
2334 void
2335 JoystickClose ( joystick )
2336         SDL_Joystick *joystick
2337         CODE:
2338                 SDL_JoystickClose(joystick);
2339
2340 Sint16
2341 JoyAxisEventWhich ( e )
2342         SDL_Event *e
2343         CODE:
2344                 RETVAL = e->jaxis.which;
2345         OUTPUT:
2346                 RETVAL
2347
2348 Uint8
2349 JoyAxisEventAxis ( e )
2350         SDL_Event *e
2351         CODE:
2352                 RETVAL = e->jaxis.axis;
2353         OUTPUT:
2354                 RETVAL
2355
2356 Uint8
2357 JoyAxisEventValue ( e )
2358         SDL_Event *e
2359         CODE:
2360                 RETVAL = e->jaxis.value;
2361         OUTPUT:
2362                 RETVAL
2363
2364 Sint16
2365 JoyButtonEventWhich ( e )
2366         SDL_Event *e
2367         CODE:
2368                 RETVAL = e->jbutton.which;
2369         OUTPUT:
2370                 RETVAL
2371
2372 Uint8
2373 JoyButtonEventButton ( e )
2374         SDL_Event *e
2375         CODE:
2376                 RETVAL = e->jbutton.button;
2377         OUTPUT:
2378                 RETVAL
2379
2380 Uint8
2381 JoyButtonEventState ( e )
2382         SDL_Event *e
2383         CODE:
2384                 RETVAL = e->jbutton.state;
2385         OUTPUT:
2386                 RETVAL
2387         
2388 Uint8
2389 JoyHatEventWhich ( e )
2390         SDL_Event *e
2391         CODE:
2392                 RETVAL = e->jhat.which;
2393         OUTPUT:
2394                 RETVAL
2395
2396 Uint8
2397 JoyHatEventHat ( e )
2398         SDL_Event *e
2399         CODE:
2400                 RETVAL = e->jhat.hat;
2401         OUTPUT:
2402                 RETVAL
2403
2404 Uint8
2405 JoyHatEventValue ( e )
2406         SDL_Event *e
2407         CODE:
2408                 RETVAL = e->jhat.value;
2409         OUTPUT:
2410                 RETVAL
2411
2412 Uint8
2413 JoyBallEventWhich ( e )
2414         SDL_Event *e
2415         CODE: 
2416                 RETVAL = e->jball.which;
2417         OUTPUT:
2418                 RETVAL
2419
2420 Uint8
2421 JoyBallEventBall ( e )
2422         SDL_Event *e
2423         CODE:
2424                 RETVAL = e->jball.ball;
2425         OUTPUT:
2426                 RETVAL
2427
2428 Sint16
2429 JoyBallEventXrel ( e )
2430         SDL_Event *e
2431         CODE:
2432                 RETVAL = e->jball.xrel;
2433         OUTPUT:
2434                 RETVAL
2435
2436 Sint16
2437 JoyBallEventYrel ( e )
2438         SDL_Event *e
2439         CODE:
2440                 RETVAL = e->jball.yrel;
2441         OUTPUT:
2442                 RETVAL
2443
2444 void
2445 SetClipRect ( surface, rect )
2446         SDL_Surface *surface
2447         SDL_Rect *rect
2448         CODE:
2449                 SDL_SetClipRect(surface,rect);
2450         
2451 SDL_Rect*
2452 GetClipRect ( surface )
2453         SDL_Surface *surface
2454         CODE:
2455                 RETVAL = (SDL_Rect*) safemalloc(sizeof(SDL_Rect));
2456                 SDL_GetClipRect(surface,RETVAL);
2457         OUTPUT:
2458                 RETVAL
2459
2460
2461 #ifdef HAVE_SDL_NET
2462
2463 int
2464 NetInit ()
2465         CODE:
2466                 RETVAL = SDLNet_Init();
2467         OUTPUT:
2468                 RETVAL
2469
2470 void
2471 NetQuit ()
2472         CODE:
2473                 SDLNet_Quit();
2474
2475 IPaddress*
2476 NetNewIPaddress ( host, port )
2477         Uint32 host
2478         Uint16 port
2479         CODE:
2480                 RETVAL = (IPaddress*) safemalloc(sizeof(IPaddress));
2481                 RETVAL->host = host;
2482                 RETVAL->port = port;
2483         OUTPUT:
2484                 RETVAL
2485
2486 Uint32
2487 NetIPaddressHost ( ip )
2488         IPaddress *ip
2489         CODE:
2490                 RETVAL = ip->host;
2491         OUTPUT:
2492                 RETVAL
2493
2494 Uint16
2495 NetIPaddressPort ( ip )
2496         IPaddress *ip
2497         CODE:
2498                 RETVAL = ip->port;
2499         OUTPUT:
2500                 RETVAL
2501
2502 void
2503 NetFreeIPaddress ( ip )
2504         IPaddress *ip
2505         CODE:
2506                 safefree(ip);
2507
2508 const char*
2509 NetResolveIP ( address )
2510         IPaddress *address
2511         CODE:
2512                 RETVAL = SDLNet_ResolveIP(address);
2513         OUTPUT:
2514                 RETVAL
2515
2516 int
2517 NetResolveHost ( address, host, port )
2518         IPaddress *address
2519         char *host
2520         Uint16 port
2521         CODE:
2522                 RETVAL = SDLNet_ResolveHost(address,host,port);
2523         OUTPUT:
2524                 RETVAL
2525         
2526 TCPsocket
2527 NetTCPOpen ( ip )
2528         IPaddress *ip
2529         CODE:
2530                 RETVAL = SDLNet_TCP_Open(ip);
2531         OUTPUT:
2532                 RETVAL
2533
2534 TCPsocket
2535 NetTCPAccept ( server )
2536         TCPsocket server
2537         CODE:
2538                 RETVAL = SDLNet_TCP_Accept(server);
2539         OUTPUT:
2540                 RETVAL
2541
2542 IPaddress*
2543 NetTCPGetPeerAddress ( sock )
2544         TCPsocket sock
2545         CODE:
2546                 RETVAL = SDLNet_TCP_GetPeerAddress(sock);
2547         OUTPUT:
2548                 RETVAL
2549
2550 int
2551 NetTCPSend ( sock, data, len  )
2552         TCPsocket sock
2553         void *data
2554         int len
2555         CODE:
2556                 RETVAL = SDLNet_TCP_Send(sock,data,len);
2557         OUTPUT:
2558                 RETVAL
2559
2560 AV*
2561 NetTCPRecv ( sock, maxlen )
2562         TCPsocket sock
2563         int maxlen
2564         CODE:
2565                 int status;
2566                 void *buffer;
2567                 buffer = safemalloc(maxlen);
2568                 RETVAL = newAV();
2569                 status = SDLNet_TCP_Recv(sock,buffer,maxlen);
2570                 av_push(RETVAL,newSViv(status));
2571                 av_push(RETVAL,newSVpvn((char*)buffer,maxlen));
2572         OUTPUT:
2573                 RETVAL  
2574         
2575 void
2576 NetTCPClose ( sock )
2577         TCPsocket sock
2578         CODE:
2579                 SDLNet_TCP_Close(sock);
2580
2581 UDPpacket*
2582 NetAllocPacket ( size )
2583         int size
2584         CODE:
2585                 RETVAL = SDLNet_AllocPacket(size);
2586         OUTPUT:
2587                 RETVAL
2588
2589 UDPpacket**
2590 NetAllocPacketV ( howmany, size )
2591         int howmany
2592         int size
2593         CODE:
2594                 RETVAL = SDLNet_AllocPacketV(howmany,size);
2595         OUTPUT:
2596                 RETVAL
2597
2598 int
2599 NetResizePacket ( packet, newsize )
2600         UDPpacket *packet
2601         int newsize
2602         CODE:
2603                 RETVAL = SDLNet_ResizePacket(packet,newsize);
2604         OUTPUT:
2605                 RETVAL
2606
2607 void
2608 NetFreePacket ( packet )
2609         UDPpacket *packet
2610         CODE:
2611                 SDLNet_FreePacket(packet);
2612
2613 void
2614 NetFreePacketV ( packet )
2615         UDPpacket **packet
2616         CODE:
2617                 SDLNet_FreePacketV(packet);
2618
2619 UDPsocket
2620 NetUDPOpen ( port )
2621         Uint16 port
2622         CODE:
2623                 RETVAL = SDLNet_UDP_Open(port);
2624         OUTPUT:
2625                 RETVAL
2626
2627 int
2628 NetUDPBind ( sock, channel, address )
2629         UDPsocket sock
2630         int channel
2631         IPaddress *address
2632         CODE:
2633                 RETVAL = SDLNet_UDP_Bind(sock,channel,address);
2634         OUTPUT:
2635                 RETVAL
2636
2637 void
2638 NetUDPUnbind ( sock, channel )
2639         UDPsocket sock
2640         int channel
2641         CODE:
2642                 SDLNet_UDP_Unbind(sock,channel);
2643
2644 IPaddress*
2645 NetUDPGetPeerAddress ( sock, channel )
2646         UDPsocket sock
2647         int channel
2648         CODE:
2649                 RETVAL = SDLNet_UDP_GetPeerAddress(sock,channel);
2650         OUTPUT:
2651                 RETVAL
2652
2653 int
2654 NetUDPSendV ( sock, packets, npackets )
2655         UDPsocket sock
2656         UDPpacket **packets
2657         int npackets
2658         CODE:
2659                 RETVAL = SDLNet_UDP_SendV(sock,packets,npackets);
2660         OUTPUT:
2661                 RETVAL
2662
2663 int
2664 NetUDPSend ( sock, channel, packet )
2665         UDPsocket sock
2666         int channel
2667         UDPpacket *packet 
2668         CODE:
2669                 RETVAL = SDLNet_UDP_Send(sock,channel,packet);
2670         OUTPUT:
2671                 RETVAL
2672
2673 int
2674 NetUDPRecvV ( sock, packets )
2675         UDPsocket sock
2676         UDPpacket **packets
2677         CODE:
2678                 RETVAL = SDLNet_UDP_RecvV(sock,packets);
2679         OUTPUT:
2680                 RETVAL
2681
2682 int
2683 NetUDPRecv ( sock, packet )
2684         UDPsocket sock
2685         UDPpacket *packet
2686         CODE:
2687                 RETVAL = SDLNet_UDP_Recv(sock,packet);
2688         OUTPUT:
2689                 RETVAL
2690
2691 void
2692 NetUDPClose ( sock )
2693         UDPsocket sock
2694         CODE:
2695                 SDLNet_UDP_Close(sock);
2696
2697 SDLNet_SocketSet
2698 NetAllocSocketSet ( maxsockets )
2699         int maxsockets
2700         CODE:
2701                 RETVAL = SDLNet_AllocSocketSet(maxsockets);
2702         OUTPUT:
2703                 RETVAL
2704
2705 int
2706 NetTCP_AddSocket ( set, sock )
2707         SDLNet_SocketSet set
2708         TCPsocket sock
2709         CODE:
2710                 RETVAL = SDLNet_TCP_AddSocket(set,sock);
2711         OUTPUT:
2712                 RETVAL
2713
2714 int
2715 NetUDP_AddSocket ( set, sock )
2716         SDLNet_SocketSet set
2717         UDPsocket sock
2718         CODE:
2719                 RETVAL = SDLNet_UDP_AddSocket(set,sock);
2720         OUTPUT:
2721                 RETVAL
2722
2723 int
2724 NetTCP_DelSocket ( set, sock )
2725         SDLNet_SocketSet set
2726         TCPsocket sock
2727         CODE:
2728                 RETVAL = SDLNet_TCP_DelSocket(set,sock);
2729         OUTPUT:
2730                 RETVAL
2731
2732 int
2733 NetUDP_DelSocket ( set, sock )
2734         SDLNet_SocketSet set
2735         UDPsocket sock
2736         CODE:
2737                 RETVAL = SDLNet_UDP_DelSocket(set,sock);
2738         OUTPUT:
2739                 RETVAL
2740
2741 int
2742 NetCheckSockets ( set, timeout )
2743         SDLNet_SocketSet set
2744         Uint32 timeout
2745         CODE:
2746                 RETVAL = SDLNet_CheckSockets(set,timeout);
2747         OUTPUT:
2748                 RETVAL
2749
2750 int
2751 NetSocketReady ( sock )
2752         SDLNet_GenericSocket sock
2753         CODE:
2754                 RETVAL = SDLNet_SocketReady(sock);
2755         OUTPUT:
2756                 RETVAL
2757
2758 void
2759 NetFreeSocketSet ( set )
2760         SDLNet_SocketSet set
2761         CODE:
2762                 SDLNet_FreeSocketSet(set);
2763
2764 void
2765 NetWrite16 ( value, area )
2766         Uint16 value
2767         void *area
2768         CODE:
2769                 SDLNet_Write16(value,area);
2770
2771 void
2772 NetWrite32 ( value, area )
2773         Uint32 value
2774         void *area
2775         CODE:
2776                 SDLNet_Write32(value,area);
2777         
2778 Uint16
2779 NetRead16 ( area )
2780         void *area
2781         CODE:
2782                 RETVAL = SDLNet_Read16(area);
2783         OUTPUT:
2784                 RETVAL
2785
2786 Uint32
2787 NetRead32 ( area )
2788         void *area
2789         CODE:
2790                 RETVAL = SDLNet_Read32(area);
2791         OUTPUT:
2792                 RETVAL
2793
2794 #endif 
2795
2796 #ifdef HAVE_SDL_TTF
2797
2798 int
2799 TTFInit ()
2800         CODE:
2801                 RETVAL = TTF_Init();
2802         OUTPUT:
2803                 RETVAL
2804
2805 void
2806 TTFQuit ()
2807         CODE:
2808                 TTF_Quit();
2809
2810 TTF_Font*
2811 TTFOpenFont ( file, ptsize )
2812         char *file
2813         int ptsize
2814         CODE:
2815                 RETVAL = TTF_OpenFont(file,ptsize);
2816         OUTPUT:
2817                 RETVAL
2818
2819 int
2820 TTFGetFontStyle ( font )
2821         TTF_Font *font
2822         CODE:
2823                 RETVAL = TTF_GetFontStyle(font);
2824         OUTPUT:
2825                 RETVAL
2826
2827 void
2828 TTFSetFontStyle ( font, style )
2829         TTF_Font *font
2830         int style
2831         CODE:
2832                 TTF_SetFontStyle(font,style);
2833         
2834 int
2835 TTFFontHeight ( font )
2836         TTF_Font *font
2837         CODE:
2838                 RETVAL = TTF_FontHeight(font);
2839         OUTPUT:
2840                 RETVAL
2841
2842 int
2843 TTFFontAscent ( font )
2844         TTF_Font *font
2845         CODE:
2846                 RETVAL = TTF_FontAscent(font);
2847         OUTPUT:
2848                 RETVAL
2849
2850 int
2851 TTFFontDescent ( font )
2852         TTF_Font *font
2853         CODE:
2854                 RETVAL = TTF_FontDescent(font);
2855         OUTPUT:
2856                 RETVAL
2857
2858 int
2859 TTFFontLineSkip ( font )
2860         TTF_Font *font
2861         CODE:
2862                 RETVAL = TTF_FontLineSkip(font);
2863         OUTPUT:
2864                 RETVAL
2865
2866 AV*
2867 TTFGlyphMetrics ( font, ch )
2868         TTF_Font *font
2869         Uint16 ch
2870         CODE:
2871                 int minx, miny, maxx, maxy, advance;
2872                 RETVAL = newAV();
2873                 TTF_GlyphMetrics(font, ch, &minx, &miny, &maxx, &maxy, &advance);
2874                 av_push(RETVAL,newSViv(minx));
2875                 av_push(RETVAL,newSViv(miny));
2876                 av_push(RETVAL,newSViv(maxx));
2877                 av_push(RETVAL,newSViv(maxy));
2878                 av_push(RETVAL,newSViv(advance));
2879         OUTPUT:
2880                 RETVAL
2881
2882 AV*
2883 TTFSizeText ( font, text )
2884         TTF_Font *font
2885         char *text
2886         CODE:
2887                 int w,h;
2888                 RETVAL = newAV();
2889                 TTF_SizeText(font,text,&w,&h);
2890                 av_push(RETVAL,newSViv(w));
2891                 av_push(RETVAL,newSViv(h));
2892         OUTPUT:
2893                 RETVAL
2894
2895 AV*
2896 TTFSizeUTF8 ( font, text )
2897         TTF_Font *font
2898         char *text
2899         CODE:
2900                 int w,h;
2901                 RETVAL = newAV();
2902                 TTF_SizeUTF8(font,text,&w,&h);
2903                 av_push(RETVAL,newSViv(w));
2904                 av_push(RETVAL,newSViv(h));
2905         OUTPUT:
2906                 RETVAL
2907
2908 AV*
2909 TTFSizeUNICODE ( font, text )
2910         TTF_Font *font
2911         const Uint16 *text
2912         CODE:
2913                 int w,h;
2914                 RETVAL = newAV();
2915                 TTF_SizeUNICODE(font,text,&w,&h);
2916                 av_push(RETVAL,newSViv(w));
2917                 av_push(RETVAL,newSViv(h));
2918         OUTPUT:
2919                 RETVAL
2920
2921 SDL_Surface*
2922 TTFRenderTextSolid ( font, text, fg )
2923         TTF_Font *font
2924         char *text
2925         SDL_Color *fg
2926         CODE:
2927                 RETVAL = TTF_RenderText_Solid(font,text,*fg);
2928         OUTPUT:
2929                 RETVAL
2930
2931 SDL_Surface*
2932 TTFRenderUTF8Solid ( font, text, fg )
2933         TTF_Font *font
2934         char *text
2935         SDL_Color *fg
2936         CODE:
2937                 RETVAL = TTF_RenderUTF8_Solid(font,text,*fg);
2938         OUTPUT:
2939                 RETVAL
2940
2941 SDL_Surface*
2942 TTFRenderUNICODESolid ( font, text, fg )
2943         TTF_Font *font
2944         const Uint16 *text
2945         SDL_Color *fg
2946         CODE:
2947                 RETVAL = TTF_RenderUNICODE_Solid(font,text,*fg);
2948         OUTPUT:
2949                 RETVAL
2950
2951 SDL_Surface*
2952 TTFRenderGlyphSolid ( font, ch, fg )
2953         TTF_Font *font
2954         Uint16 ch
2955         SDL_Color *fg
2956         CODE:
2957                 RETVAL = TTF_RenderGlyph_Solid(font,ch,*fg);
2958         OUTPUT:
2959                 RETVAL
2960
2961 SDL_Surface*
2962 TTFRenderTextShaded ( font, text, fg, bg )
2963         TTF_Font *font
2964         char *text
2965         SDL_Color *fg
2966         SDL_Color *bg
2967         CODE:
2968                 RETVAL = TTF_RenderText_Shaded(font,text,*fg,*bg);
2969         OUTPUT:
2970                 RETVAL
2971
2972 SDL_Surface*
2973 TTFRenderUTF8Shaded( font, text, fg, bg )
2974         TTF_Font *font
2975         char *text
2976         SDL_Color *fg
2977         SDL_Color *bg
2978         CODE:
2979                 RETVAL = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
2980         OUTPUT:
2981                 RETVAL
2982
2983 SDL_Surface*
2984 TTFRenderUNICODEShaded( font, text, fg, bg )
2985         TTF_Font *font
2986         const Uint16 *text
2987         SDL_Color *fg
2988         SDL_Color *bg
2989         CODE:
2990                 RETVAL = TTF_RenderUNICODE_Shaded(font,text,*fg,*bg);
2991         OUTPUT:
2992                 RETVAL
2993
2994 SDL_Surface*
2995 TTFRenderGlyphShaded ( font, ch, fg, bg )
2996         TTF_Font *font
2997         Uint16 ch
2998         SDL_Color *fg
2999         SDL_Color *bg
3000         CODE:
3001                 RETVAL = TTF_RenderGlyph_Shaded(font,ch,*fg,*bg);
3002         OUTPUT:
3003                 RETVAL
3004
3005 SDL_Surface*
3006 TTFRenderTextBlended( font, text, fg )
3007         TTF_Font *font
3008         char *text
3009         SDL_Color *fg
3010         CODE:
3011                 RETVAL = TTF_RenderText_Blended(font,text,*fg);
3012         OUTPUT:
3013                 RETVAL
3014
3015 SDL_Surface*
3016 TTFRenderUTF8Blended( font, text, fg )
3017         TTF_Font *font
3018         char *text
3019         SDL_Color *fg
3020         CODE:
3021                 RETVAL = TTF_RenderUTF8_Blended(font,text,*fg);
3022         OUTPUT:
3023                 RETVAL
3024
3025 SDL_Surface*
3026 TTFRenderUNICODEBlended( font, text, fg )
3027         TTF_Font *font
3028         const Uint16 *text
3029         SDL_Color *fg
3030         CODE:
3031                 RETVAL = TTF_RenderUNICODE_Blended(font,text,*fg);
3032         OUTPUT:
3033                 RETVAL
3034
3035 SDL_Surface*
3036 TTFRenderGlyphBlended( font, ch, fg )
3037         TTF_Font *font
3038         Uint16 ch
3039         SDL_Color *fg
3040         CODE:
3041                 RETVAL = TTF_RenderGlyph_Blended(font,ch,*fg);
3042         OUTPUT:
3043                 RETVAL
3044
3045 void
3046 TTFCloseFont ( font )
3047         TTF_Font *font
3048         CODE:
3049                 TTF_CloseFont(font);
3050
3051 SDL_Surface*
3052 TTFPutString ( font, mode, surface, x, y, fg, bg, text )
3053         TTF_Font *font
3054         int mode
3055         SDL_Surface *surface
3056         int x
3057         int y
3058         SDL_Color *fg
3059         SDL_Color *bg
3060         char *text
3061         CODE:
3062                 SDL_Surface *img;
3063                 SDL_Rect dest;
3064                 int w,h;
3065                 dest.x = x;
3066                 dest.y = y;
3067                 RETVAL = NULL;
3068                 switch (mode) {
3069                         case TEXT_SOLID:
3070                                 img = TTF_RenderText_Solid(font,text,*fg);
3071                                 TTF_SizeText(font,text,&w,&h);
3072                                 dest.w = w;
3073                                 dest.h = h;
3074                                 break;
3075                         case TEXT_SHADED:
3076                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3077                                 TTF_SizeText(font,text,&w,&h);
3078                                 dest.w = w;
3079                                 dest.h = h;
3080                                 break;
3081                         case TEXT_BLENDED:
3082                                 img = TTF_RenderText_Blended(font,text,*fg);
3083                                 TTF_SizeText(font,text,&w,&h);
3084                                 dest.w = w;
3085                                 dest.h = h;
3086                                 break;
3087                         case UTF8_SOLID:
3088                                 img = TTF_RenderUTF8_Solid(font,text,*fg);
3089                                 TTF_SizeUTF8(font,text,&w,&h);
3090                                 dest.w = w;
3091                                 dest.h = h;
3092                                 break;
3093                         case UTF8_SHADED:
3094                                 img = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
3095                                 TTF_SizeUTF8(font,text,&w,&h);
3096                                 dest.w = w;
3097                                 dest.h = h;
3098                                 break;
3099                         case UTF8_BLENDED:
3100                                 img = TTF_RenderUTF8_Blended(font,text,*fg);
3101                                 TTF_SizeUTF8(font,text,&w,&h);
3102                                 dest.w = w;
3103                                 dest.h = h;
3104                                 break;
3105                         case UNICODE_SOLID:
3106                                 img = TTF_RenderUNICODE_Solid(font,(Uint16*)text,*fg);
3107                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3108                                 dest.w = w;
3109                                 dest.h = h;
3110                                 break;
3111                         case UNICODE_SHADED:
3112                                 img = TTF_RenderUNICODE_Shaded(font,(Uint16*)text,*fg,*bg);
3113                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3114                                 dest.w = w;
3115                                 dest.h = h;
3116                                 break;
3117                         case UNICODE_BLENDED:
3118                                 img = TTF_RenderUNICODE_Blended(font,(Uint16*)text,*fg);
3119                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3120                                 dest.w = w;
3121                                 dest.h = h;
3122                                 break;
3123                         default:
3124                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3125                                 TTF_SizeText(font,text,&w,&h);
3126                                 dest.w = w;
3127                                 dest.h = h;
3128                 }
3129                 if ( img && img->format && img->format->palette ) {
3130                         SDL_Color *c = &img->format->palette->colors[0];
3131                         Uint32 key = SDL_MapRGB( img->format, c->r, c->g, c->b );
3132                         SDL_SetColorKey(img,SDL_SRCCOLORKEY,key );
3133                         if (0 > SDL_BlitSurface(img,NULL,surface,&dest)) {
3134                                 SDL_FreeSurface(img);
3135                                 RETVAL = NULL;  
3136                         } else {
3137                                 RETVAL = img;
3138                         }
3139                 }
3140         OUTPUT:
3141                 RETVAL
3142
3143 #endif
3144
3145 SDL_Overlay*
3146 CreateYUVOverlay ( width, height, format, display )
3147         int width
3148         int height
3149         Uint32 format
3150         SDL_Surface *display
3151         CODE:
3152                 RETVAL = SDL_CreateYUVOverlay ( width, height, format, display );
3153         OUTPUT:
3154                 RETVAL
3155
3156 int
3157 LockYUVOverlay ( overlay )
3158         SDL_Overlay *overlay
3159         CODE:
3160                 RETVAL = SDL_LockYUVOverlay(overlay);
3161         OUTPUT:
3162                 RETVAL
3163
3164 void
3165 UnlockYUVOverlay ( overlay )
3166         SDL_Overlay *overlay
3167         CODE:
3168                 SDL_UnlockYUVOverlay(overlay);
3169
3170 int
3171 DisplayYUVOverlay ( overlay, dstrect )
3172         SDL_Overlay *overlay
3173         SDL_Rect *dstrect
3174         CODE:
3175                 RETVAL = SDL_DisplayYUVOverlay ( overlay, dstrect );
3176         OUTPUT:
3177                 RETVAL
3178
3179 void
3180 FreeYUVOverlay ( overlay )
3181         SDL_Overlay *overlay
3182         CODE:
3183                 SDL_FreeYUVOverlay ( overlay );
3184
3185 Uint32
3186 OverlayFormat ( overlay, ... )
3187         SDL_Overlay *overlay
3188         CODE:
3189                 if ( items > 1 ) 
3190                         overlay->format = SvIV(ST(1));
3191                 RETVAL = overlay->format;
3192         OUTPUT:
3193                 RETVAL
3194
3195 int 
3196 OverlayW ( overlay, ... )
3197         SDL_Overlay *overlay
3198         CODE:
3199                 if ( items > 1 ) 
3200                         overlay->w = SvIV(ST(1));
3201                 RETVAL = overlay->w;
3202         OUTPUT:
3203                 RETVAL
3204
3205 int
3206 OverlayH ( overlay, ... )
3207         SDL_Overlay *overlay
3208         CODE:
3209                 if ( items > 1 )
3210                         overlay->h = SvIV(ST(1));
3211                 RETVAL = overlay->h;
3212         OUTPUT:
3213                 RETVAL 
3214
3215 int
3216 OverlayPlanes ( overlay, ... )
3217         SDL_Overlay *overlay
3218         CODE:
3219                 if ( items > 1 )
3220                         overlay->planes = SvIV(ST(1));
3221                 RETVAL = overlay->planes;
3222         OUTPUT:
3223                 RETVAL
3224
3225 Uint32
3226 OverlayHW ( overlay )
3227         SDL_Overlay *overlay
3228         CODE:
3229                 RETVAL = overlay->hw_overlay;
3230         OUTPUT:
3231                 RETVAL
3232
3233 Uint16*
3234 OverlayPitches ( overlay )
3235         SDL_Overlay *overlay
3236         CODE:
3237                 RETVAL = overlay->pitches;
3238         OUTPUT:
3239                 RETVAL
3240
3241 Uint8**
3242 OverlayPixels ( overlay )
3243         SDL_Overlay *overlay
3244         CODE:
3245                 RETVAL = overlay->pixels;
3246         OUTPUT:
3247                 RETVAL
3248
3249 int
3250 WMToggleFullScreen ( surface )
3251         SDL_Surface *surface
3252         CODE:
3253                 RETVAL = SDL_WM_ToggleFullScreen(surface);
3254         OUTPUT:
3255                 RETVAL
3256
3257 Uint32
3258 WMGrabInput ( mode )
3259         Uint32 mode
3260         CODE:
3261                 RETVAL = SDL_WM_GrabInput(mode);
3262         OUTPUT:
3263                 RETVAL
3264
3265 int
3266 WMIconifyWindow ()
3267         CODE:
3268                 RETVAL = SDL_WM_IconifyWindow();
3269         OUTPUT:
3270                 RETVAL
3271
3272 int
3273 ResizeEventW ( e )
3274         SDL_Event *e
3275         CODE:
3276                 RETVAL = e->resize.w;
3277         OUTPUT:
3278                 RETVAL
3279
3280 int
3281 ResizeEventH ( e )
3282         SDL_Event *e
3283         CODE:
3284                 RETVAL = e->resize.h;
3285         OUTPUT:
3286                 RETVAL
3287
3288 char*
3289 AudioDriverName ()
3290         CODE:
3291                 char name[32];
3292                 RETVAL = SDL_AudioDriverName(name,32);
3293         OUTPUT:
3294                 RETVAL
3295
3296 Uint32
3297 GetKeyState ( k )
3298         SDLKey k
3299         CODE:
3300                 if (k >= SDLK_LAST) Perl_croak (aTHX_ "Key out of range");      
3301                 RETVAL = SDL_GetKeyState(NULL)[k];
3302         OUTPUT:
3303                 RETVAL
3304
3305 #ifdef HAVE_SMPEG
3306
3307 SMPEG_Info *
3308 NewSMPEGInfo()
3309         CODE:   
3310                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3311         OUTPUT:
3312                 RETVAL
3313
3314 void
3315 FreeSMPEGInfo ( info )
3316         SMPEG_Info *info;
3317         CODE:   
3318                 safefree(info);
3319
3320 int
3321 SMPEGInfoHasAudio ( info )
3322         SMPEG_Info* info;
3323         CODE:
3324                 RETVAL = info->has_audio;
3325         OUTPUT:
3326                 RETVAL
3327
3328 int
3329 SMPEGInfoHasVideo ( info )
3330         SMPEG_Info* info;
3331         CODE:
3332                 RETVAL = info->has_video;
3333         OUTPUT:
3334                 RETVAL
3335
3336 int
3337 SMPEGInfoWidth ( info )
3338         SMPEG_Info* info;
3339         CODE:
3340                 RETVAL = info->width;
3341         OUTPUT:
3342                 RETVAL
3343
3344 int
3345 SMPEGInfoHeight ( info )
3346         SMPEG_Info* info;
3347         CODE:
3348                 RETVAL = info->height;
3349         OUTPUT:
3350                 RETVAL
3351
3352 int
3353 SMPEGInfoCurrentFrame ( info )
3354         SMPEG_Info* info;
3355         CODE:
3356                 RETVAL = info->current_frame;
3357         OUTPUT:
3358                 RETVAL
3359
3360 double
3361 SMPEGInfoCurrentFPS ( info )
3362         SMPEG_Info* info;
3363         CODE:
3364                 RETVAL = info->current_fps;
3365         OUTPUT:
3366                 RETVAL
3367
3368 int
3369 SMPEGInfoCurrentAudioFrame ( info )
3370         SMPEG_Info* info;
3371         CODE:
3372                 RETVAL = info->audio_current_frame;
3373         OUTPUT:
3374                 RETVAL
3375
3376 int
3377 SMPEGInfoCurrentOffset ( info )
3378         SMPEG_Info* info;
3379         CODE:
3380                 RETVAL = info->current_offset;
3381         OUTPUT:
3382                 RETVAL
3383
3384 int
3385 SMPEGInfoTotalSize ( info )
3386         SMPEG_Info* info;
3387         CODE:
3388                 RETVAL = info->total_size;
3389         OUTPUT:
3390                 RETVAL
3391
3392 double
3393 SMPEGInfoCurrentTime ( info )
3394         SMPEG_Info* info;
3395         CODE:
3396                 RETVAL = info->current_time;
3397         OUTPUT:
3398                 RETVAL
3399
3400 double
3401 SMPEGInfoTotalTime ( info )
3402         SMPEG_Info* info;
3403         CODE:
3404                 RETVAL = info->total_time;
3405         OUTPUT:
3406                 RETVAL
3407
3408 char *
3409 SMPEGError ( mpeg )
3410         SMPEG* mpeg ;
3411         CODE:   
3412                 RETVAL = SMPEG_error(mpeg);
3413         OUTPUT:
3414                 RETVAL
3415
3416 SMPEG*
3417 NewSMPEG ( filename, info, use_audio )
3418         char* filename;
3419         SMPEG_Info* info;
3420         int use_audio
3421         CODE:   
3422 #ifdef HAVE_SDL_MIXER
3423                 RETVAL = SMPEG_new(filename,info,0);
3424 #else
3425                 RETVAL = SMPEG_new(filename,info,use_audio);
3426 #endif
3427         OUTPUT:
3428                 RETVAL
3429
3430 void
3431 FreeSMPEG ( mpeg )
3432         SMPEG* mpeg;
3433         CODE:
3434                 SMPEG_delete(mpeg);
3435
3436 void
3437 SMPEGEnableAudio ( mpeg , flag )
3438         SMPEG* mpeg ;
3439         int flag;
3440         CODE:   
3441                 SMPEG_enableaudio(mpeg,flag);
3442 #ifdef HAVE_SDL_MIXER
3443                 sdl_perl_use_smpeg_audio = flag;
3444 #endif
3445
3446 void
3447 SMPEGEnableVideo ( mpeg , flag )
3448         SMPEG* mpeg ;
3449         int flag;
3450         CODE:   
3451                 SMPEG_enablevideo(mpeg,flag);
3452
3453 void
3454 SMPEGSetVolume ( mpeg , volume )
3455         SMPEG* mpeg ;
3456         int volume;
3457         CODE:   
3458                 SMPEG_setvolume(mpeg,volume);
3459
3460 void
3461 SMPEGSetDisplay ( mpeg, dest, surfLock )
3462         SMPEG* mpeg;
3463         SDL_Surface* dest;
3464         SDL_mutex*  surfLock;     
3465         CODE:
3466                 SMPEG_setdisplay(mpeg,dest,surfLock,NULL);
3467
3468 void
3469 SMPEGScaleXY ( mpeg, w, h)
3470         SMPEG* mpeg;
3471         int w;
3472         int h;
3473         CODE:
3474                 SMPEG_scaleXY(mpeg,w,h);
3475
3476 void
3477 SMPEGScale ( mpeg, scale )
3478         SMPEG* mpeg;
3479         int scale
3480         CODE:
3481                 SMPEG_scale(mpeg,scale);
3482
3483 void
3484 SMPEGPlay ( mpeg )
3485         SMPEG* mpeg;
3486         CODE:
3487                 SDL_AudioSpec audiofmt;
3488                 Uint16 format;
3489                 int freq, channels;
3490 #ifdef HAVE_SDL_MIXER
3491                 if  (sdl_perl_use_smpeg_audio ) {
3492                         SMPEG_enableaudio(mpeg, 0);
3493                         Mix_QuerySpec(&freq, &format, &channels);
3494                         audiofmt.format = format;
3495                         audiofmt.freq = freq;
3496                         audiofmt.channels = channels;
3497                         SMPEG_actualSpec(mpeg, &audiofmt);
3498                         Mix_HookMusic(SMPEG_playAudioSDL, mpeg);
3499                         SMPEG_enableaudio(mpeg, 1);
3500                 }
3501 #endif
3502                 SMPEG_play(mpeg);
3503
3504 SMPEGstatus
3505 SMPEGStatus ( mpeg )
3506         SMPEG* mpeg;
3507         CODE:
3508                 RETVAL = SMPEG_status(mpeg);
3509         OUTPUT:
3510                 RETVAL
3511
3512 void
3513 SMPEGPause ( mpeg )
3514         SMPEG* mpeg;
3515         CODE:
3516                 SMPEG_pause(mpeg);
3517
3518 void
3519 SMPEGLoop ( mpeg, repeat )
3520         SMPEG* mpeg;
3521         int repeat
3522         CODE:
3523                 SMPEG_loop(mpeg,repeat);
3524
3525 void
3526 SMPEGStop ( mpeg )
3527         SMPEG* mpeg;
3528         CODE:
3529                 SMPEG_stop(mpeg);
3530 #ifdef HAVE_SDL_MIXER
3531                 Mix_HookMusic(NULL, NULL);
3532 #endif
3533
3534 void
3535 SMPEGRewind ( mpeg )
3536         SMPEG* mpeg;
3537         CODE:
3538                 SMPEG_rewind(mpeg);
3539
3540 void
3541 SMPEGSeek ( mpeg, bytes )
3542         SMPEG* mpeg;
3543         int bytes;
3544         CODE:
3545                 SMPEG_seek(mpeg,bytes);
3546
3547 void
3548 SMPEGSkip ( mpeg, seconds )
3549         SMPEG* mpeg;
3550         float seconds;
3551         CODE:
3552                 SMPEG_skip(mpeg,seconds);
3553
3554 void
3555 SMPEGSetDisplayRegion ( mpeg, rect )
3556         SMPEG* mpeg;
3557         SDL_Rect* rect;
3558         CODE:
3559                 SMPEG_setdisplayregion(mpeg,rect->x,rect->y,rect->w,rect->h);
3560
3561 void
3562 SMPEGRenderFrame ( mpeg, frame )
3563         SMPEG* mpeg;
3564         int frame;
3565         CODE:
3566                 SMPEG_renderFrame(mpeg,frame);
3567
3568 SMPEG_Info *
3569 SMPEGGetInfo ( mpeg )
3570         SMPEG* mpeg;
3571         CODE:
3572                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3573                 SMPEG_getinfo(mpeg,RETVAL);
3574         OUTPUT:
3575                 RETVAL
3576         
3577
3578 #endif
3579
3580 #ifdef HAVE_SDL_GFX
3581
3582 SDL_Surface *
3583 GFXRotoZoom ( src, angle, zoom, smooth)
3584      SDL_Surface * src;
3585      double angle;
3586      double zoom;
3587      int smooth;
3588      CODE:
3589                  RETVAL = rotozoomSurface( src, angle, zoom, smooth);
3590      OUTPUT:
3591                  RETVAL
3592
3593 SDL_Surface *
3594 GFXZoom ( src, zoomx, zoomy, smooth)
3595      SDL_Surface *src;
3596      double zoomx;
3597      double zoomy;
3598      int smooth;
3599      CODE:
3600                  RETVAL = zoomSurface( src, zoomx, zoomy, smooth);
3601      OUTPUT:
3602                  RETVAL
3603
3604
3605 int
3606 GFXPixelColor ( dst, x, y, color )
3607     SDL_Surface* dst;
3608     Sint16 x;
3609     Sint16 y;
3610     Uint32 color;
3611 CODE:
3612      RETVAL = pixelColor( dst, x, y, color);
3613 OUTPUT:
3614      RETVAL
3615
3616 int
3617 GFXPixelRGBA ( dst, x, y, r, g, b, a )
3618     SDL_Surface* dst;
3619     Sint16 x;
3620     Sint16 y;
3621     Uint8 r;
3622     Uint8 g;
3623     Uint8 b;
3624     Uint8 a;
3625 CODE:
3626      RETVAL = pixelRGBA( dst, x, y, r, g, b, a );
3627 OUTPUT:
3628      RETVAL
3629
3630 int
3631 GFXHlineColor ( dst, x1, x2, y, color )
3632     SDL_Surface* dst;
3633     Sint16 x1;
3634     Sint16 x2;
3635     Sint16 y;
3636     Uint32 color;
3637 CODE:
3638      RETVAL = hlineColor( dst, x1, x2, y, color );
3639 OUTPUT:
3640      RETVAL
3641
3642 int
3643 GFXHlineRGBA ( dst, x1, x2, y, r, g, b, a )
3644     SDL_Surface* dst;
3645     Sint16 x1;
3646     Sint16 x2;
3647     Sint16 y;
3648     Uint8 r;
3649     Uint8 g;
3650     Uint8 b;
3651     Uint8 a;
3652 CODE:
3653      RETVAL = hlineRGBA( dst, x1, x2, y, r, g, b, a );
3654 OUTPUT:
3655      RETVAL
3656
3657 int
3658 GFXVlineColor ( dst, x, y1, y2, color )
3659     SDL_Surface* dst;
3660     Sint16 x;
3661     Sint16 y1;
3662     Sint16 y2;
3663     Uint32 color;
3664 CODE:
3665      RETVAL = vlineColor( dst, x, y1, y2, color );
3666 OUTPUT:
3667      RETVAL
3668
3669 int
3670 GFXVlineRGBA ( dst, x, y1, y2, r, g, b, a )
3671     SDL_Surface* dst;
3672     Sint16 x;
3673     Sint16 y1;
3674     Sint16 y2;
3675     Uint8 r;
3676     Uint8 g;
3677     Uint8 b;
3678     Uint8 a;
3679 CODE:
3680      RETVAL = vlineRGBA( dst, x, y1, y2, r, g, b, a );
3681 OUTPUT:
3682      RETVAL
3683
3684 int
3685 GFXRectangleColor ( dst, x1, y1, x2, y2, color )
3686     SDL_Surface* dst;
3687     Sint16 x1;
3688     Sint16 y1;
3689     Sint16 x2;
3690     Sint16 y2;
3691     Uint32 color;
3692 CODE:
3693      RETVAL = rectangleColor( dst, x1, y1, x2, y2, color );
3694 OUTPUT:
3695      RETVAL
3696
3697 int
3698 GFXRectangleRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3699     SDL_Surface* dst;
3700     Sint16 x1;
3701     Sint16 y1;
3702     Sint16 x2;
3703     Sint16 y2;
3704     Uint8 r;
3705     Uint8 g;
3706     Uint8 b;
3707     Uint8 a;
3708 CODE:
3709      RETVAL = rectangleRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3710 OUTPUT:
3711      RETVAL
3712
3713 int
3714 GFXBoxColor ( dst, x1, y1, x2, y2, color )
3715     SDL_Surface* dst;
3716     Sint16 x1;
3717     Sint16 y1;
3718     Sint16 x2;
3719     Sint16 y2;
3720     Uint32 color;
3721 CODE:
3722      RETVAL = boxColor( dst, x1, y1, x2, y2, color );
3723 OUTPUT:
3724      RETVAL
3725
3726 int
3727 GFXBoxRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3728     SDL_Surface* dst;
3729     Sint16 x1;
3730     Sint16 y1;
3731     Sint16 x2;
3732     Sint16 y2;
3733     Uint8 r;
3734     Uint8 g;
3735     Uint8 b;
3736     Uint8 a;
3737 CODE:
3738      RETVAL = boxRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3739 OUTPUT:
3740      RETVAL
3741
3742 int
3743 GFXLineColor ( dst, x1, y1, x2, y2, color )
3744     SDL_Surface* dst;
3745     Sint16 x1;
3746     Sint16 y1;
3747     Sint16 x2;
3748     Sint16 y2;
3749     Uint32 color;
3750 CODE:
3751      RETVAL = lineColor( dst, x1, y1, x2, y2, color );
3752 OUTPUT:
3753      RETVAL
3754
3755 int
3756 GFXLineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3757     SDL_Surface* dst;
3758     Sint16 x1;
3759     Sint16 y1;
3760     Sint16 x2;
3761     Sint16 y2;
3762     Uint8 r;
3763     Uint8 g;
3764     Uint8 b;
3765     Uint8 a;
3766 CODE:
3767      RETVAL = lineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3768 OUTPUT:
3769      RETVAL
3770
3771 int
3772 GFXAalineColor ( dst, x1, y1, x2, y2, color )
3773     SDL_Surface* dst;
3774     Sint16 x1;
3775     Sint16 y1;
3776     Sint16 x2;
3777     Sint16 y2;
3778     Uint32 color;
3779 CODE:
3780      RETVAL = aalineColor( dst, x1, y1, x2, y2, color );
3781 OUTPUT:
3782      RETVAL
3783
3784 int
3785 GFXAalineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3786     SDL_Surface* dst;
3787     Sint16 x1;
3788     Sint16 y1;
3789     Sint16 x2;
3790     Sint16 y2;
3791     Uint8 r;
3792     Uint8 g;
3793     Uint8 b;
3794     Uint8 a;
3795 CODE:
3796      RETVAL = aalineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3797 OUTPUT:
3798      RETVAL
3799
3800 int
3801 GFXCircleColor ( dst, x, y, r, color )
3802     SDL_Surface* dst;
3803     Sint16 x;
3804     Sint16 y;
3805     Sint16 r;
3806     Uint32 color;
3807 CODE:
3808      RETVAL = circleColor( dst, x, y, r, color );
3809 OUTPUT:
3810      RETVAL
3811
3812 int
3813 GFXCircleRGBA ( dst, x, y, rad, r, g, b, a )
3814     SDL_Surface* dst;
3815     Sint16 x;
3816     Sint16 y;
3817     Sint16 rad;
3818     Uint8 r;
3819     Uint8 g;
3820     Uint8 b;
3821     Uint8 a;
3822 CODE:
3823      RETVAL = circleRGBA( dst, x, y, rad, r, g, b, a );
3824 OUTPUT:
3825      RETVAL
3826
3827 int
3828 GFXAacircleColor ( dst, x, y, r, color )
3829     SDL_Surface* dst;
3830     Sint16 x;
3831     Sint16 y;
3832     Sint16 r;
3833     Uint32 color;
3834 CODE:
3835      RETVAL = aacircleColor( dst, x, y, r, color );
3836 OUTPUT:
3837      RETVAL
3838
3839 int
3840 GFXAacircleRGBA ( dst, x, y, rad, r, g, b, a )
3841     SDL_Surface* dst;
3842     Sint16 x;
3843     Sint16 y;
3844     Sint16 rad;
3845     Uint8 r;
3846     Uint8 g;
3847     Uint8 b;
3848     Uint8 a;
3849 CODE:
3850      RETVAL = aacircleRGBA( dst, x, y, rad, r, g, b, a );
3851 OUTPUT:
3852      RETVAL
3853
3854 int
3855 GFXFilledCircleColor ( dst, x, y, r, color )
3856     SDL_Surface* dst;
3857     Sint16 x;
3858     Sint16 y;
3859     Sint16 r;
3860     Uint32 color;
3861 CODE:
3862      RETVAL = filledCircleColor( dst, x, y, r, color );
3863 OUTPUT:
3864      RETVAL
3865
3866 int
3867 GFXFilledCircleRGBA ( dst, x, y, rad, r, g, b, a )
3868     SDL_Surface* dst;
3869     Sint16 x;
3870     Sint16 y;
3871     Sint16 rad;
3872     Uint8 r;
3873     Uint8 g;
3874     Uint8 b;
3875     Uint8 a;
3876 CODE:
3877      RETVAL = filledCircleRGBA( dst, x, y, rad, r, g, b, a );
3878 OUTPUT:
3879      RETVAL
3880
3881 int
3882 GFXEllipseColor ( dst, x, y, rx, ry, color )
3883     SDL_Surface* dst;
3884     Sint16 x;
3885     Sint16 y;
3886     Sint16 rx;
3887     Sint16 ry;
3888     Uint32 color;
3889 CODE:
3890      RETVAL = ellipseColor( dst, x, y, rx, ry, color );
3891 OUTPUT:
3892      RETVAL
3893
3894 int
3895 GFXEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
3896     SDL_Surface* dst;
3897     Sint16 x;
3898     Sint16 y;
3899     Sint16 rx;
3900     Sint16 ry;
3901     Uint8 r;
3902     Uint8 g;
3903     Uint8 b;
3904     Uint8 a;
3905 CODE:
3906      RETVAL = ellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
3907 OUTPUT:
3908      RETVAL
3909
3910 int
3911 GFXAaellipseColor ( dst, xc, yc, rx, ry, color )
3912     SDL_Surface* dst;
3913     Sint16 xc;
3914     Sint16 yc;
3915     Sint16 rx;
3916     Sint16 ry;
3917     Uint32 color;
3918 CODE:
3919      RETVAL = aaellipseColor( dst, xc, yc, rx, ry, color );
3920 OUTPUT:
3921      RETVAL
3922
3923 int
3924 GFXAaellipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
3925     SDL_Surface* dst;
3926     Sint16 x;
3927     Sint16 y;
3928     Sint16 rx;
3929     Sint16 ry;
3930     Uint8 r;
3931     Uint8 g;
3932     Uint8 b;
3933     Uint8 a;
3934 CODE:
3935      RETVAL = aaellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
3936 OUTPUT:
3937      RETVAL
3938
3939 int
3940 GFXFilledEllipseColor ( dst, x, y, rx, ry, color )
3941     SDL_Surface* dst;
3942     Sint16 x;
3943     Sint16 y;
3944     Sint16 rx;
3945     Sint16 ry;
3946     Uint32 color;
3947 CODE:
3948      RETVAL = filledEllipseColor( dst, x, y, rx, ry, color );
3949 OUTPUT:
3950      RETVAL
3951
3952 int
3953 GFXFilledEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
3954     SDL_Surface* dst;
3955     Sint16 x;
3956     Sint16 y;
3957     Sint16 rx;
3958     Sint16 ry;
3959     Uint8 r;
3960     Uint8 g;
3961     Uint8 b;
3962     Uint8 a;
3963 CODE:
3964      RETVAL = filledEllipseRGBA( dst, x, y, rx, ry, r, g, b, a );
3965 OUTPUT:
3966      RETVAL
3967
3968 int
3969 GFXFilledPieColor ( dst, x, y, rad, start, end, color )
3970     SDL_Surface* dst;
3971     Sint16 x;
3972     Sint16 y;
3973     Sint16 rad;
3974     Sint16 start;
3975     Sint16 end;
3976     Uint32 color;
3977 CODE:
3978      RETVAL = filledPieColor( dst, x, y, rad, start, end, color );
3979 OUTPUT:
3980      RETVAL
3981
3982 int
3983 GFXFilledPieRGBA ( dst, x, y, rad, start, end, r, g, b, a )
3984     SDL_Surface* dst;
3985     Sint16 x;
3986     Sint16 y;
3987     Sint16 rad;
3988     Sint16 start;
3989     Sint16 end;
3990     Uint8 r;
3991     Uint8 g;
3992     Uint8 b;
3993     Uint8 a;
3994 CODE:
3995      RETVAL = filledPieRGBA( dst, x, y, rad, start, end, r, g, b, a );
3996 OUTPUT:
3997      RETVAL
3998
3999 int
4000 GFXPolygonColor ( dst, vx, vy, n, color )
4001     SDL_Surface* dst;
4002     Sint16* vx;
4003     Sint16* vy;
4004     int n;
4005     Uint32 color;
4006 CODE:
4007      RETVAL = polygonColor( dst, vx, vy, n, color );
4008 OUTPUT:
4009      RETVAL
4010
4011 int
4012 GFXPolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4013     SDL_Surface* dst;
4014     Sint16* vx;
4015     Sint16* vy;
4016     int n;
4017     Uint8 r;
4018     Uint8 g;
4019     Uint8 b;
4020     Uint8 a;
4021 CODE:
4022      RETVAL = polygonRGBA( dst, vx, vy, n, r, g, b, a );
4023 OUTPUT:
4024      RETVAL
4025
4026 int
4027 GFXAapolygonColor ( dst, vx, vy, n, color )
4028     SDL_Surface* dst;
4029     Sint16* vx;
4030     Sint16* vy;
4031     int n;
4032     Uint32 color;
4033 CODE:
4034      RETVAL = aapolygonColor( dst, vx, vy, n, color );
4035 OUTPUT:
4036      RETVAL
4037
4038 int
4039 GFXAapolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4040     SDL_Surface* dst;
4041     Sint16* vx;
4042     Sint16* vy;
4043     int n;
4044     Uint8 r;
4045     Uint8 g;
4046     Uint8 b;
4047     Uint8 a;
4048 CODE:
4049      RETVAL = aapolygonRGBA( dst, vx, vy, n, r, g, b, a );
4050 OUTPUT:
4051      RETVAL
4052
4053 int
4054 GFXFilledPolygonColor ( dst, vx, vy, n, color )
4055     SDL_Surface* dst;
4056     Sint16* vx;
4057     Sint16* vy;
4058     int n;
4059     int color;
4060 CODE:
4061      RETVAL = filledPolygonColor( dst, vx, vy, n, color );
4062 OUTPUT:
4063      RETVAL
4064
4065 int
4066 GFXFilledPolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4067     SDL_Surface* dst;
4068     Sint16* vx;
4069     Sint16* vy;
4070     int n;
4071     Uint8 r;
4072     Uint8 g;
4073     Uint8 b;
4074     Uint8 a;
4075 CODE:
4076      RETVAL = filledPolygonRGBA( dst, vx, vy, n, r, g, b, a );
4077 OUTPUT:
4078      RETVAL
4079
4080 int
4081 GFXCharacterColor ( dst, x, y, c, color )
4082     SDL_Surface* dst;
4083     Sint16 x;
4084     Sint16 y;
4085     char c;
4086     Uint32 color;
4087 CODE:
4088      RETVAL = characterColor( dst, x, y, c, color );
4089 OUTPUT:
4090      RETVAL
4091
4092 int
4093 GFXCharacterRGBA ( dst, x, y, c, r, g, b, a )
4094     SDL_Surface* dst;
4095     Sint16 x;
4096     Sint16 y;
4097     char c;
4098     Uint8 r;
4099     Uint8 g;
4100     Uint8 b;
4101     Uint8 a;
4102 CODE:
4103      RETVAL = characterRGBA( dst, x, y, c, r, g, b, a );
4104 OUTPUT:
4105      RETVAL
4106
4107 int
4108 GFXStringColor ( dst, x, y, c, color )
4109     SDL_Surface* dst;
4110     Sint16 x;
4111     Sint16 y;
4112     char* c;
4113     Uint32 color;
4114 CODE:
4115      RETVAL = stringColor( dst, x, y, c, color );
4116 OUTPUT:
4117      RETVAL
4118
4119 int
4120 GFXStringRGBA ( dst, x, y, c, r, g, b, a )
4121     SDL_Surface* dst;
4122     Sint16 x;
4123     Sint16 y;
4124     char* c;
4125     Uint8 r;
4126     Uint8 g;
4127     Uint8 b;
4128     Uint8 a;
4129 CODE:
4130      RETVAL = stringRGBA( dst, x, y, c, r, g, b, a );
4131 OUTPUT:
4132      RETVAL
4133
4134 #endif
4135
4136 #ifdef HAVE_SDL_SOUND
4137
4138 Uint16
4139 SoundAudioInfoFormat ( audioinfo )
4140         Sound_AudioInfo* audioinfo
4141         CODE:
4142                 RETVAL = audioinfo->format;
4143         OUTPUT:
4144                 RETVAL
4145
4146 Uint8
4147 SoundAudioInfoChannels ( audioinfo )
4148         Sound_AudioInfo* audioinfo
4149         CODE:
4150                 RETVAL = audioinfo->channels;
4151         OUTPUT:
4152                 RETVAL
4153
4154 Uint32
4155 SoundAudioInforate ( audioinfo )
4156         Sound_AudioInfo* audioinfo
4157         CODE:
4158                 RETVAL = audioinfo->rate;
4159         OUTPUT:
4160                 RETVAL
4161
4162 AV*
4163 SoundDecoderInfoExtensions ( decoderinfo )
4164         Sound_DecoderInfo* decoderinfo
4165         CODE:
4166                 char **ext;
4167                 for ( ext = decoderinfo->extensions; *ext != NULL; ext++ ){
4168                         av_push(RETVAL,sv_2mortal(newSVpv(*ext,0)));
4169                 }
4170         OUTPUT:
4171                 RETVAL
4172
4173 char*
4174 SoundDecoderInfoDescription ( decoderinfo )
4175         Sound_DecoderInfo* decoderinfo
4176         CODE:
4177                 RETVAL = decoderinfo->description;
4178         OUTPUT:
4179                 RETVAL
4180
4181 char*
4182 SoundDecoderInfoAuthor ( decoderinfo )
4183         Sound_DecoderInfo* decoderinfo
4184         CODE:
4185                 RETVAL = decoderinfo->author;
4186         OUTPUT:
4187                 RETVAL
4188
4189 char*
4190 SoundDecoderInfoUrl ( decoderinfo )
4191         Sound_DecoderInfo* decoderinfo
4192         CODE:
4193                 RETVAL = decoderinfo->url;
4194         OUTPUT:
4195                 RETVAL
4196
4197 const Sound_DecoderInfo*
4198 SoundSampleDecoder ( sample ) 
4199         Sound_Sample* sample
4200         CODE:
4201                 RETVAL = sample->decoder;
4202         OUTPUT:
4203                 RETVAL
4204
4205 Sound_AudioInfo* 
4206 SoundSampleDesired ( sample )
4207         Sound_Sample* sample
4208         CODE:
4209                 RETVAL = &sample->desired;
4210         OUTPUT:
4211                 RETVAL
4212
4213 Sound_AudioInfo*
4214 SoundSampleAcutal ( sample )
4215         Sound_Sample* sample
4216         CODE:
4217                 RETVAL = &sample->actual;
4218         OUTPUT:
4219                 RETVAL
4220
4221 char*
4222 SoundSampleBuffer ( sample )
4223         Sound_Sample* sample
4224         CODE:
4225                 RETVAL = sample->buffer;
4226         OUTPUT:
4227                 RETVAL
4228
4229 Uint32
4230 SoundSampleBufferSize ( sample )
4231         Sound_Sample* sample
4232         CODE:
4233                 RETVAL = sample->buffer;
4234         OUTPUT:
4235                 RETVAL
4236
4237 Uint32
4238 SoundSampleFlags ( sample )
4239         Sound_Sample* sample
4240         CODE:
4241                 RETVAL = (Uint32)sample->flags;
4242         OUTPUT:
4243                 RETVAL
4244
4245
4246
4247 #endif
4248
4249 MODULE = SDL            PACKAGE = SDL
4250 PROTOTYPES : DISABLE
4251
4252