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