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