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