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