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