garu++ for stupid free
[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
2205 void
2206 MixCloseAudio ()
2207         CODE:
2208                 Mix_CloseAudio();
2209
2210 #endif
2211
2212 int
2213 GLLoadLibrary ( path )
2214         char *path
2215         CODE:
2216                 RETVAL = SDL_GL_LoadLibrary(path);
2217         OUTPUT:
2218                 RETVAL
2219
2220 void*
2221 GLGetProcAddress ( proc )
2222         char *proc
2223         CODE:
2224                 RETVAL = SDL_GL_GetProcAddress(proc);
2225         OUTPUT:
2226                 RETVAL
2227
2228 int
2229 GLSetAttribute ( attr,  value )
2230         int        attr
2231         int        value
2232         CODE:
2233                 RETVAL = SDL_GL_SetAttribute(attr, value);
2234         OUTPUT:
2235                 RETVAL
2236
2237 AV *
2238 GLGetAttribute ( attr )
2239         int        attr
2240         CODE:
2241                 int value;
2242                 RETVAL = newAV();
2243                 av_push(RETVAL,newSViv(SDL_GL_GetAttribute(attr, &value)));
2244                 av_push(RETVAL,newSViv(value));
2245         OUTPUT:
2246                 RETVAL
2247
2248 void
2249 GLSwapBuffers ()
2250         CODE:
2251                 SDL_GL_SwapBuffers ();
2252
2253
2254 int
2255 BigEndian ()
2256         CODE:
2257                 RETVAL = (SDL_BYTEORDER == SDL_BIG_ENDIAN);
2258         OUTPUT:
2259                 RETVAL
2260
2261 int
2262 NumJoysticks ()
2263         CODE:
2264                 RETVAL = SDL_NumJoysticks();
2265         OUTPUT:
2266                 RETVAL
2267
2268 char *
2269 JoystickName ( index )
2270         int index
2271         CODE:
2272                 RETVAL = (char*)SDL_JoystickName(index);
2273         OUTPUT:
2274                 RETVAL
2275
2276 SDL_Joystick *
2277 JoystickOpen ( index ) 
2278         int index
2279         CODE:
2280                 RETVAL = SDL_JoystickOpen(index);
2281         OUTPUT:
2282                 RETVAL
2283
2284 int
2285 JoystickOpened ( index )
2286         int index
2287         CODE:
2288                 RETVAL = SDL_JoystickOpened(index);
2289         OUTPUT:
2290                 RETVAL
2291
2292 int
2293 JoystickIndex ( joystick )
2294         SDL_Joystick *joystick
2295         CODE:
2296                 RETVAL = SDL_JoystickIndex(joystick);
2297         OUTPUT:
2298                 RETVAL
2299
2300 int
2301 JoystickNumAxes ( joystick )
2302         SDL_Joystick *joystick
2303         CODE:
2304                 RETVAL = SDL_JoystickNumAxes(joystick);
2305         OUTPUT:
2306                 RETVAL
2307
2308 int
2309 JoystickNumBalls ( joystick )
2310         SDL_Joystick *joystick
2311         CODE:
2312                 RETVAL = SDL_JoystickNumBalls(joystick);
2313         OUTPUT:
2314                 RETVAL
2315
2316 int
2317 JoystickNumHats ( joystick )
2318         SDL_Joystick *joystick
2319         CODE:
2320                 RETVAL = SDL_JoystickNumHats(joystick);
2321         OUTPUT:
2322                 RETVAL
2323
2324 int
2325 JoystickNumButtons ( joystick )
2326         SDL_Joystick *joystick
2327         CODE:
2328                 RETVAL = SDL_JoystickNumButtons(joystick);
2329         OUTPUT:
2330                 RETVAL
2331
2332 void
2333 JoystickUpdate ()
2334         CODE:
2335                 SDL_JoystickUpdate();
2336
2337 Sint16
2338 JoystickGetAxis ( joystick, axis )
2339         SDL_Joystick *joystick
2340         int axis
2341         CODE:
2342                 RETVAL = SDL_JoystickGetAxis(joystick,axis);
2343         OUTPUT:
2344                 RETVAL
2345
2346 Uint8
2347 JoystickGetHat ( joystick, hat )
2348         SDL_Joystick *joystick
2349         int hat 
2350         CODE:
2351                 RETVAL = SDL_JoystickGetHat(joystick,hat);
2352         OUTPUT:
2353                 RETVAL
2354
2355 Uint8
2356 JoystickGetButton ( joystick, button)
2357         SDL_Joystick *joystick
2358         int button 
2359         CODE:
2360                 RETVAL = SDL_JoystickGetButton(joystick,button);
2361         OUTPUT:
2362                 RETVAL
2363
2364 AV *
2365 JoystickGetBall ( joystick, ball )
2366         SDL_Joystick *joystick
2367         int ball 
2368         CODE:
2369                 int success,dx,dy;
2370                 success = SDL_JoystickGetBall(joystick,ball,&dx,&dy);
2371                 RETVAL = newAV();
2372                 av_push(RETVAL,newSViv(success));
2373                 av_push(RETVAL,newSViv(dx));
2374                 av_push(RETVAL,newSViv(dy));
2375         OUTPUT:
2376                 RETVAL  
2377
2378 void
2379 JoystickClose ( joystick )
2380         SDL_Joystick *joystick
2381         CODE:
2382                 SDL_JoystickClose(joystick);
2383
2384 Sint16
2385 JoyAxisEventWhich ( e )
2386         SDL_Event *e
2387         CODE:
2388                 RETVAL = e->jaxis.which;
2389         OUTPUT:
2390                 RETVAL
2391
2392 Uint8
2393 JoyAxisEventAxis ( e )
2394         SDL_Event *e
2395         CODE:
2396                 RETVAL = e->jaxis.axis;
2397         OUTPUT:
2398                 RETVAL
2399
2400 Sint16
2401 JoyAxisEventValue ( e )
2402         SDL_Event *e
2403         CODE:
2404                 RETVAL = e->jaxis.value;
2405         OUTPUT:
2406                 RETVAL
2407
2408 Uint8
2409 JoyButtonEventWhich ( e )
2410         SDL_Event *e
2411         CODE:
2412                 RETVAL = e->jbutton.which;
2413         OUTPUT:
2414                 RETVAL
2415
2416 Uint8
2417 JoyButtonEventButton ( e )
2418         SDL_Event *e
2419         CODE:
2420                 RETVAL = e->jbutton.button;
2421         OUTPUT:
2422                 RETVAL
2423
2424 Uint8
2425 JoyButtonEventState ( e )
2426         SDL_Event *e
2427         CODE:
2428                 RETVAL = e->jbutton.state;
2429         OUTPUT:
2430                 RETVAL
2431         
2432 Uint8
2433 JoyHatEventWhich ( e )
2434         SDL_Event *e
2435         CODE:
2436                 RETVAL = e->jhat.which;
2437         OUTPUT:
2438                 RETVAL
2439
2440 Uint8
2441 JoyHatEventHat ( e )
2442         SDL_Event *e
2443         CODE:
2444                 RETVAL = e->jhat.hat;
2445         OUTPUT:
2446                 RETVAL
2447
2448 Uint8
2449 JoyHatEventValue ( e )
2450         SDL_Event *e
2451         CODE:
2452                 RETVAL = e->jhat.value;
2453         OUTPUT:
2454                 RETVAL
2455
2456 Uint8
2457 JoyBallEventWhich ( e )
2458         SDL_Event *e
2459         CODE: 
2460                 RETVAL = e->jball.which;
2461         OUTPUT:
2462                 RETVAL
2463
2464 Uint8
2465 JoyBallEventBall ( e )
2466         SDL_Event *e
2467         CODE:
2468                 RETVAL = e->jball.ball;
2469         OUTPUT:
2470                 RETVAL
2471
2472 Sint16
2473 JoyBallEventXrel ( e )
2474         SDL_Event *e
2475         CODE:
2476                 RETVAL = e->jball.xrel;
2477         OUTPUT:
2478                 RETVAL
2479
2480 Sint16
2481 JoyBallEventYrel ( e )
2482         SDL_Event *e
2483         CODE:
2484                 RETVAL = e->jball.yrel;
2485         OUTPUT:
2486                 RETVAL
2487
2488 void
2489 SetClipRect ( surface, rect )
2490         SDL_Surface *surface
2491         SDL_Rect *rect
2492         CODE:
2493                 SDL_SetClipRect(surface,rect);
2494         
2495 void
2496 GetClipRect ( surface, rect )
2497         SDL_Surface *surface
2498         SDL_Rect *rect;
2499         CODE:
2500                 SDL_GetClipRect(surface, rect);
2501
2502
2503 #ifdef HAVE_SDL_NET
2504
2505 int
2506 NetInit ()
2507         CODE:
2508                 RETVAL = SDLNet_Init();
2509         OUTPUT:
2510                 RETVAL
2511
2512 void
2513 NetQuit ()
2514         CODE:
2515                 SDLNet_Quit();
2516
2517 IPaddress*
2518 NetNewIPaddress ( host, port )
2519         Uint32 host
2520         Uint16 port
2521         CODE:
2522                 RETVAL = (IPaddress*) safemalloc(sizeof(IPaddress));
2523                 RETVAL->host = host;
2524                 RETVAL->port = port;
2525         OUTPUT:
2526                 RETVAL
2527
2528 Uint32
2529 NetIPaddressHost ( ip )
2530         IPaddress *ip
2531         CODE:
2532                 RETVAL = ip->host;
2533         OUTPUT:
2534                 RETVAL
2535
2536 Uint16
2537 NetIPaddressPort ( ip )
2538         IPaddress *ip
2539         CODE:
2540                 RETVAL = ip->port;
2541         OUTPUT:
2542                 RETVAL
2543
2544 void
2545 NetFreeIPaddress ( ip )
2546         IPaddress *ip
2547         CODE:
2548                 safefree(ip);
2549
2550 const char*
2551 NetResolveIP ( address )
2552         IPaddress *address
2553         CODE:
2554                 RETVAL = SDLNet_ResolveIP(address);
2555         OUTPUT:
2556                 RETVAL
2557
2558 int
2559 NetResolveHost ( address, host, port )
2560         IPaddress *address
2561         const char *host
2562         Uint16 port
2563         CODE:
2564                 RETVAL = SDLNet_ResolveHost(address,host,port);
2565         OUTPUT:
2566                 RETVAL
2567         
2568 TCPsocket
2569 NetTCPOpen ( ip )
2570         IPaddress *ip
2571         CODE:
2572                 RETVAL = SDLNet_TCP_Open(ip);
2573         OUTPUT:
2574                 RETVAL
2575
2576 TCPsocket
2577 NetTCPAccept ( server )
2578         TCPsocket server
2579         CODE:
2580                 RETVAL = SDLNet_TCP_Accept(server);
2581         OUTPUT:
2582                 RETVAL
2583
2584 IPaddress*
2585 NetTCPGetPeerAddress ( sock )
2586         TCPsocket sock
2587         CODE:
2588                 RETVAL = SDLNet_TCP_GetPeerAddress(sock);
2589         OUTPUT:
2590                 RETVAL
2591
2592 int
2593 NetTCPSend ( sock, data, len  )
2594         TCPsocket sock
2595         void *data
2596         int len
2597         CODE:
2598                 RETVAL = SDLNet_TCP_Send(sock,data,len);
2599         OUTPUT:
2600                 RETVAL
2601
2602 AV*
2603 NetTCPRecv ( sock, maxlen )
2604         TCPsocket sock
2605         int maxlen
2606         CODE:
2607                 int status;
2608                 void *buffer;
2609                 buffer = safemalloc(maxlen);
2610                 RETVAL = newAV();
2611                 status = SDLNet_TCP_Recv(sock,buffer,maxlen);
2612                 av_push(RETVAL,newSViv(status));
2613                 av_push(RETVAL,newSVpvn((char*)buffer,maxlen));
2614         OUTPUT:
2615                 RETVAL  
2616         
2617 void
2618 NetTCPClose ( sock )
2619         TCPsocket sock
2620         CODE:
2621                 SDLNet_TCP_Close(sock);
2622
2623 UDPpacket*
2624 NetAllocPacket ( size )
2625         int size
2626         CODE:
2627                 RETVAL = SDLNet_AllocPacket(size);
2628         OUTPUT:
2629                 RETVAL
2630
2631 UDPpacket**
2632 NetAllocPacketV ( howmany, size )
2633         int howmany
2634         int size
2635         CODE:
2636                 RETVAL = SDLNet_AllocPacketV(howmany,size);
2637         OUTPUT:
2638                 RETVAL
2639
2640 int
2641 NetResizePacket ( packet, newsize )
2642         UDPpacket *packet
2643         int newsize
2644         CODE:
2645                 RETVAL = SDLNet_ResizePacket(packet,newsize);
2646         OUTPUT:
2647                 RETVAL
2648
2649 void
2650 NetFreePacket ( packet )
2651         UDPpacket *packet
2652         CODE:
2653                 SDLNet_FreePacket(packet);
2654
2655 void
2656 NetFreePacketV ( packet )
2657         UDPpacket **packet
2658         CODE:
2659                 SDLNet_FreePacketV(packet);
2660
2661 UDPsocket
2662 NetUDPOpen ( port )
2663         Uint16 port
2664         CODE:
2665                 RETVAL = SDLNet_UDP_Open(port);
2666         OUTPUT:
2667                 RETVAL
2668
2669 int
2670 NetUDPBind ( sock, channel, address )
2671         UDPsocket sock
2672         int channel
2673         IPaddress *address
2674         CODE:
2675                 RETVAL = SDLNet_UDP_Bind(sock,channel,address);
2676         OUTPUT:
2677                 RETVAL
2678
2679 void
2680 NetUDPUnbind ( sock, channel )
2681         UDPsocket sock
2682         int channel
2683         CODE:
2684                 SDLNet_UDP_Unbind(sock,channel);
2685
2686 IPaddress*
2687 NetUDPGetPeerAddress ( sock, channel )
2688         UDPsocket sock
2689         int channel
2690         CODE:
2691                 RETVAL = SDLNet_UDP_GetPeerAddress(sock,channel);
2692         OUTPUT:
2693                 RETVAL
2694
2695 int
2696 NetUDPSendV ( sock, packets, npackets )
2697         UDPsocket sock
2698         UDPpacket **packets
2699         int npackets
2700         CODE:
2701                 RETVAL = SDLNet_UDP_SendV(sock,packets,npackets);
2702         OUTPUT:
2703                 RETVAL
2704
2705 int
2706 NetUDPSend ( sock, channel, packet )
2707         UDPsocket sock
2708         int channel
2709         UDPpacket *packet 
2710         CODE:
2711                 RETVAL = SDLNet_UDP_Send(sock,channel,packet);
2712         OUTPUT:
2713                 RETVAL
2714
2715 int
2716 NetUDPRecvV ( sock, packets )
2717         UDPsocket sock
2718         UDPpacket **packets
2719         CODE:
2720                 RETVAL = SDLNet_UDP_RecvV(sock,packets);
2721         OUTPUT:
2722                 RETVAL
2723
2724 int
2725 NetUDPRecv ( sock, packet )
2726         UDPsocket sock
2727         UDPpacket *packet
2728         CODE:
2729                 RETVAL = SDLNet_UDP_Recv(sock,packet);
2730         OUTPUT:
2731                 RETVAL
2732
2733 void
2734 NetUDPClose ( sock )
2735         UDPsocket sock
2736         CODE:
2737                 SDLNet_UDP_Close(sock);
2738
2739 SDLNet_SocketSet
2740 NetAllocSocketSet ( maxsockets )
2741         int maxsockets
2742         CODE:
2743                 RETVAL = SDLNet_AllocSocketSet(maxsockets);
2744         OUTPUT:
2745                 RETVAL
2746
2747 int
2748 NetTCP_AddSocket ( set, sock )
2749         SDLNet_SocketSet set
2750         TCPsocket sock
2751         CODE:
2752                 RETVAL = SDLNet_TCP_AddSocket(set,sock);
2753         OUTPUT:
2754                 RETVAL
2755
2756 int
2757 NetUDP_AddSocket ( set, sock )
2758         SDLNet_SocketSet set
2759         UDPsocket sock
2760         CODE:
2761                 RETVAL = SDLNet_UDP_AddSocket(set,sock);
2762         OUTPUT:
2763                 RETVAL
2764
2765 int
2766 NetTCP_DelSocket ( set, sock )
2767         SDLNet_SocketSet set
2768         TCPsocket sock
2769         CODE:
2770                 RETVAL = SDLNet_TCP_DelSocket(set,sock);
2771         OUTPUT:
2772                 RETVAL
2773
2774 int
2775 NetUDP_DelSocket ( set, sock )
2776         SDLNet_SocketSet set
2777         UDPsocket sock
2778         CODE:
2779                 RETVAL = SDLNet_UDP_DelSocket(set,sock);
2780         OUTPUT:
2781                 RETVAL
2782
2783 int
2784 NetCheckSockets ( set, timeout )
2785         SDLNet_SocketSet set
2786         Uint32 timeout
2787         CODE:
2788                 RETVAL = SDLNet_CheckSockets(set,timeout);
2789         OUTPUT:
2790                 RETVAL
2791
2792 int
2793 NetSocketReady ( sock )
2794         SDLNet_GenericSocket sock
2795         CODE:
2796                 RETVAL = SDLNet_SocketReady(sock);
2797         OUTPUT:
2798                 RETVAL
2799
2800 void
2801 NetFreeSocketSet ( set )
2802         SDLNet_SocketSet set
2803         CODE:
2804                 SDLNet_FreeSocketSet(set);
2805
2806 void
2807 NetWrite16 ( value, area )
2808         Uint16 value
2809         void *area
2810         CODE:
2811                 SDLNet_Write16(value,area);
2812
2813 void
2814 NetWrite32 ( value, area )
2815         Uint32 value
2816         void *area
2817         CODE:
2818                 SDLNet_Write32(value,area);
2819         
2820 Uint16
2821 NetRead16 ( area )
2822         void *area
2823         CODE:
2824                 RETVAL = SDLNet_Read16(area);
2825         OUTPUT:
2826                 RETVAL
2827
2828 Uint32
2829 NetRead32 ( area )
2830         void *area
2831         CODE:
2832                 RETVAL = SDLNet_Read32(area);
2833         OUTPUT:
2834                 RETVAL
2835
2836 #endif 
2837
2838 #ifdef HAVE_SDL_TTF
2839
2840 int
2841 TTFInit ()
2842         CODE:
2843                 RETVAL = TTF_Init();
2844         OUTPUT:
2845                 RETVAL
2846
2847 void
2848 TTFQuit ()
2849         CODE:
2850                 TTF_Quit();
2851
2852 TTF_Font*
2853 TTFOpenFont ( file, ptsize )
2854         char *file
2855         int ptsize
2856         CODE:
2857                 RETVAL = TTF_OpenFont(file,ptsize);
2858         OUTPUT:
2859                 RETVAL
2860
2861 int
2862 TTFGetFontStyle ( font )
2863         TTF_Font *font
2864         CODE:
2865                 RETVAL = TTF_GetFontStyle(font);
2866         OUTPUT:
2867                 RETVAL
2868
2869 void
2870 TTFSetFontStyle ( font, style )
2871         TTF_Font *font
2872         int style
2873         CODE:
2874                 TTF_SetFontStyle(font,style);
2875         
2876 int
2877 TTFFontHeight ( font )
2878         TTF_Font *font
2879         CODE:
2880                 RETVAL = TTF_FontHeight(font);
2881         OUTPUT:
2882                 RETVAL
2883
2884 int
2885 TTFFontAscent ( font )
2886         TTF_Font *font
2887         CODE:
2888                 RETVAL = TTF_FontAscent(font);
2889         OUTPUT:
2890                 RETVAL
2891
2892 int
2893 TTFFontDescent ( font )
2894         TTF_Font *font
2895         CODE:
2896                 RETVAL = TTF_FontDescent(font);
2897         OUTPUT:
2898                 RETVAL
2899
2900 int
2901 TTFFontLineSkip ( font )
2902         TTF_Font *font
2903         CODE:
2904                 RETVAL = TTF_FontLineSkip(font);
2905         OUTPUT:
2906                 RETVAL
2907
2908 AV*
2909 TTFGlyphMetrics ( font, ch )
2910         TTF_Font *font
2911         Uint16 ch
2912         CODE:
2913                 int minx, miny, maxx, maxy, advance;
2914                 RETVAL = newAV();
2915                 TTF_GlyphMetrics(font, ch, &minx, &miny, &maxx, &maxy, &advance);
2916                 av_push(RETVAL,newSViv(minx));
2917                 av_push(RETVAL,newSViv(miny));
2918                 av_push(RETVAL,newSViv(maxx));
2919                 av_push(RETVAL,newSViv(maxy));
2920                 av_push(RETVAL,newSViv(advance));
2921         OUTPUT:
2922                 RETVAL
2923
2924 AV*
2925 TTFSizeText ( font, text )
2926         TTF_Font *font
2927         char *text
2928         CODE:
2929                 int w,h;
2930                 RETVAL = newAV();
2931                 if(TTF_SizeText(font,text,&w,&h))
2932                 {
2933                         av_push(RETVAL,newSViv(w));
2934                         av_push(RETVAL,newSViv(h));
2935                         sv_2mortal((SV*)RETVAL);
2936                 }
2937                 else
2938                 {
2939                          printf("TTF error at TTFSizeText: %s \n", TTF_GetError()); 
2940                          Perl_croak (aTHX_ "TTF error \n");     
2941         
2942                 }
2943                 
2944         
2945         OUTPUT:
2946                 RETVAL
2947
2948 AV*
2949 TTFSizeUTF8 ( font, text )
2950         TTF_Font *font
2951         char *text
2952         CODE:
2953                 int w,h;
2954                 RETVAL = newAV();
2955                 if(TTF_SizeUTF8(font,text,&w,&h))
2956                 {
2957                         av_push(RETVAL,newSViv(w));
2958                         av_push(RETVAL,newSViv(h));
2959                         sv_2mortal((SV*)RETVAL);
2960
2961                 }
2962                 else
2963                 {
2964                         printf("TTF error at TTFSizeUTF8 with : %s \n", TTF_GetError());
2965                         Perl_croak (aTHX_ "TTF error \n");
2966                 }
2967                 
2968         OUTPUT:
2969                 RETVAL
2970
2971 AV*
2972 TTFSizeUNICODE ( font, text )
2973         TTF_Font *font
2974         const Uint16 *text
2975         CODE:
2976                 int w,h;
2977                 RETVAL = newAV();
2978                 if(TTF_SizeUNICODE(font,text,&w,&h))
2979                 {
2980                         av_push(RETVAL,newSViv(w));
2981                         av_push(RETVAL,newSViv(h));
2982                         sv_2mortal((SV*)RETVAL);
2983
2984                 }
2985                 else
2986                 {
2987                         printf("TTF error at TTFSizeUNICODE : %s \n", TTF_GetError()); 
2988                         Perl_croak (aTHX_ "TTF error \n");
2989                 }
2990
2991         OUTPUT:
2992                 RETVAL
2993
2994 SDL_Surface*
2995 TTFRenderTextSolid ( font, text, fg )
2996         TTF_Font *font
2997         char *text
2998         SDL_Color *fg
2999         CODE:
3000                 RETVAL = TTF_RenderText_Solid(font,text,*fg);
3001         OUTPUT:
3002                 RETVAL
3003
3004 SDL_Surface*
3005 TTFRenderUTF8Solid ( font, text, fg )
3006         TTF_Font *font
3007         char *text
3008         SDL_Color *fg
3009         CODE:
3010                 RETVAL = TTF_RenderUTF8_Solid(font,text,*fg);
3011         OUTPUT:
3012                 RETVAL
3013
3014 SDL_Surface*
3015 TTFRenderUNICODESolid ( font, text, fg )
3016         TTF_Font *font
3017         const Uint16 *text
3018         SDL_Color *fg
3019         CODE:
3020                 RETVAL = TTF_RenderUNICODE_Solid(font,text,*fg);
3021         OUTPUT:
3022                 RETVAL
3023
3024 SDL_Surface*
3025 TTFRenderGlyphSolid ( font, ch, fg )
3026         TTF_Font *font
3027         Uint16 ch
3028         SDL_Color *fg
3029         CODE:
3030                 RETVAL = TTF_RenderGlyph_Solid(font,ch,*fg);
3031         OUTPUT:
3032                 RETVAL
3033
3034 SDL_Surface*
3035 TTFRenderTextShaded ( font, text, fg, bg )
3036         TTF_Font *font
3037         char *text
3038         SDL_Color *fg
3039         SDL_Color *bg
3040         CODE:
3041                 RETVAL = TTF_RenderText_Shaded(font,text,*fg,*bg);
3042         OUTPUT:
3043                 RETVAL
3044
3045 SDL_Surface*
3046 TTFRenderUTF8Shaded( font, text, fg, bg )
3047         TTF_Font *font
3048         char *text
3049         SDL_Color *fg
3050         SDL_Color *bg
3051         CODE:
3052                 RETVAL = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
3053         OUTPUT:
3054                 RETVAL
3055
3056 SDL_Surface*
3057 TTFRenderUNICODEShaded( font, text, fg, bg )
3058         TTF_Font *font
3059         const Uint16 *text
3060         SDL_Color *fg
3061         SDL_Color *bg
3062         CODE:
3063                 RETVAL = TTF_RenderUNICODE_Shaded(font,text,*fg,*bg);
3064         OUTPUT:
3065                 RETVAL
3066
3067 SDL_Surface*
3068 TTFRenderGlyphShaded ( font, ch, fg, bg )
3069         TTF_Font *font
3070         Uint16 ch
3071         SDL_Color *fg
3072         SDL_Color *bg
3073         CODE:
3074                 RETVAL = TTF_RenderGlyph_Shaded(font,ch,*fg,*bg);
3075         OUTPUT:
3076                 RETVAL
3077
3078 SDL_Surface*
3079 TTFRenderTextBlended( font, text, fg )
3080         TTF_Font *font
3081         char *text
3082         SDL_Color *fg
3083         CODE:
3084                 RETVAL = TTF_RenderText_Blended(font,text,*fg);
3085         OUTPUT:
3086                 RETVAL
3087
3088 SDL_Surface*
3089 TTFRenderUTF8Blended( font, text, fg )
3090         TTF_Font *font
3091         char *text
3092         SDL_Color *fg
3093         CODE:
3094                 RETVAL = TTF_RenderUTF8_Blended(font,text,*fg);
3095         OUTPUT:
3096                 RETVAL
3097
3098 SDL_Surface*
3099 TTFRenderUNICODEBlended( font, text, fg )
3100         TTF_Font *font
3101         const Uint16 *text
3102         SDL_Color *fg
3103         CODE:
3104                 RETVAL = TTF_RenderUNICODE_Blended(font,text,*fg);
3105         OUTPUT:
3106                 RETVAL
3107
3108 SDL_Surface*
3109 TTFRenderGlyphBlended( font, ch, fg )
3110         TTF_Font *font
3111         Uint16 ch
3112         SDL_Color *fg
3113         CODE:
3114                 RETVAL = TTF_RenderGlyph_Blended(font,ch,*fg);
3115         OUTPUT:
3116                 RETVAL
3117
3118 void
3119 TTFCloseFont ( font )
3120         TTF_Font *font
3121         CODE:
3122                 TTF_CloseFont(font);
3123                 font=NULL; //to be safe http://sdl.beuc.net/sdl.wiki/SDL_ttf_copy_Functions_Management_TTF_CloseFont
3124
3125 SDL_Surface*
3126 TTFPutString ( font, mode, surface, x, y, fg, bg, text )
3127         TTF_Font *font
3128         int mode
3129         SDL_Surface *surface
3130         int x
3131         int y
3132         SDL_Color *fg
3133         SDL_Color *bg
3134         char *text
3135         CODE:
3136                 SDL_Surface *img;
3137                 SDL_Rect dest;
3138                 int w,h;
3139                 dest.x = x;
3140                 dest.y = y;
3141                 RETVAL = NULL;
3142                 switch (mode) {
3143                         case TEXT_SOLID:
3144                                 img = TTF_RenderText_Solid(font,text,*fg);
3145                                 TTF_SizeText(font,text,&w,&h);
3146                                 dest.w = w;
3147                                 dest.h = h;
3148                                 break;
3149                         case TEXT_SHADED:
3150                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3151                                 TTF_SizeText(font,text,&w,&h);
3152                                 dest.w = w;
3153                                 dest.h = h;
3154                                 break;
3155                         case TEXT_BLENDED:
3156                                 img = TTF_RenderText_Blended(font,text,*fg);
3157                                 TTF_SizeText(font,text,&w,&h);
3158                                 dest.w = w;
3159                                 dest.h = h;
3160                                 break;
3161                         case UTF8_SOLID:
3162                                 img = TTF_RenderUTF8_Solid(font,text,*fg);
3163                                 TTF_SizeUTF8(font,text,&w,&h);
3164                                 dest.w = w;
3165                                 dest.h = h;
3166                                 break;
3167                         case UTF8_SHADED:
3168                                 img = TTF_RenderUTF8_Shaded(font,text,*fg,*bg);
3169                                 TTF_SizeUTF8(font,text,&w,&h);
3170                                 dest.w = w;
3171                                 dest.h = h;
3172                                 break;
3173                         case UTF8_BLENDED:
3174                                 img = TTF_RenderUTF8_Blended(font,text,*fg);
3175                                 TTF_SizeUTF8(font,text,&w,&h);
3176                                 dest.w = w;
3177                                 dest.h = h;
3178                                 break;
3179                         case UNICODE_SOLID:
3180                                 img = TTF_RenderUNICODE_Solid(font,(Uint16*)text,*fg);
3181                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3182                                 dest.w = w;
3183                                 dest.h = h;
3184                                 break;
3185                         case UNICODE_SHADED:
3186                                 img = TTF_RenderUNICODE_Shaded(font,(Uint16*)text,*fg,*bg);
3187                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3188                                 dest.w = w;
3189                                 dest.h = h;
3190                                 break;
3191                         case UNICODE_BLENDED:
3192                                 img = TTF_RenderUNICODE_Blended(font,(Uint16*)text,*fg);
3193                                 TTF_SizeUNICODE(font,(Uint16*)text,&w,&h);
3194                                 dest.w = w;
3195                                 dest.h = h;
3196                                 break;
3197                         default:
3198                                 img = TTF_RenderText_Shaded(font,text,*fg,*bg);
3199                                 TTF_SizeText(font,text,&w,&h);
3200                                 dest.w = w;
3201                                 dest.h = h;
3202                 }
3203                 if ( img && img->format && img->format->palette ) {
3204                         SDL_Color *c = &img->format->palette->colors[0];
3205                         Uint32 key = SDL_MapRGB( img->format, c->r, c->g, c->b );
3206                         SDL_SetColorKey(img,SDL_SRCCOLORKEY,key );
3207                         if (0 > SDL_BlitSurface(img,NULL,surface,&dest)) {
3208                                 SDL_FreeSurface(img);
3209                                 RETVAL = NULL;  
3210                         } else {
3211                                 RETVAL = img;
3212                         }
3213                 }
3214         OUTPUT:
3215                 RETVAL
3216
3217 #endif
3218
3219 SDL_Overlay*
3220 CreateYUVOverlay ( width, height, format, display )
3221         int width
3222         int height
3223         Uint32 format
3224         SDL_Surface *display
3225         CODE:
3226                 RETVAL = SDL_CreateYUVOverlay ( width, height, format, display );
3227         OUTPUT:
3228                 RETVAL
3229
3230 int
3231 LockYUVOverlay ( overlay )
3232         SDL_Overlay *overlay
3233         CODE:
3234                 RETVAL = SDL_LockYUVOverlay(overlay);
3235         OUTPUT:
3236                 RETVAL
3237
3238 void
3239 UnlockYUVOverlay ( overlay )
3240         SDL_Overlay *overlay
3241         CODE:
3242                 SDL_UnlockYUVOverlay(overlay);
3243
3244 int
3245 DisplayYUVOverlay ( overlay, dstrect )
3246         SDL_Overlay *overlay
3247         SDL_Rect *dstrect
3248         CODE:
3249                 RETVAL = SDL_DisplayYUVOverlay ( overlay, dstrect );
3250         OUTPUT:
3251                 RETVAL
3252
3253 void
3254 FreeYUVOverlay ( overlay )
3255         SDL_Overlay *overlay
3256         CODE:
3257                 SDL_FreeYUVOverlay ( overlay );
3258
3259 Uint32
3260 OverlayFormat ( overlay, ... )
3261         SDL_Overlay *overlay
3262         CODE:
3263                 if ( items > 1 ) 
3264                         overlay->format = SvIV(ST(1));
3265                 RETVAL = overlay->format;
3266         OUTPUT:
3267                 RETVAL
3268
3269 int 
3270 OverlayW ( overlay, ... )
3271         SDL_Overlay *overlay
3272         CODE:
3273                 if ( items > 1 ) 
3274                         overlay->w = SvIV(ST(1));
3275                 RETVAL = overlay->w;
3276         OUTPUT:
3277                 RETVAL
3278
3279 int
3280 OverlayH ( overlay, ... )
3281         SDL_Overlay *overlay
3282         CODE:
3283                 if ( items > 1 )
3284                         overlay->h = SvIV(ST(1));
3285                 RETVAL = overlay->h;
3286         OUTPUT:
3287                 RETVAL 
3288
3289 int
3290 OverlayPlanes ( overlay, ... )
3291         SDL_Overlay *overlay
3292         CODE:
3293                 if ( items > 1 )
3294                         overlay->planes = SvIV(ST(1));
3295                 RETVAL = overlay->planes;
3296         OUTPUT:
3297                 RETVAL
3298
3299 Uint32
3300 OverlayHW ( overlay )
3301         SDL_Overlay *overlay
3302         CODE:
3303                 RETVAL = overlay->hw_overlay;
3304         OUTPUT:
3305                 RETVAL
3306
3307 Uint16*
3308 OverlayPitches ( overlay )
3309         SDL_Overlay *overlay
3310         CODE:
3311                 RETVAL = overlay->pitches;
3312         OUTPUT:
3313                 RETVAL
3314
3315 Uint8**
3316 OverlayPixels ( overlay )
3317         SDL_Overlay *overlay
3318         CODE:
3319                 RETVAL = overlay->pixels;
3320         OUTPUT:
3321                 RETVAL
3322
3323 int
3324 WMToggleFullScreen ( surface )
3325         SDL_Surface *surface
3326         CODE:
3327                 RETVAL = SDL_WM_ToggleFullScreen(surface);
3328         OUTPUT:
3329                 RETVAL
3330
3331 Uint32
3332 WMGrabInput ( mode )
3333         Uint32 mode
3334         CODE:
3335                 RETVAL = SDL_WM_GrabInput(mode);
3336         OUTPUT:
3337                 RETVAL
3338
3339 int
3340 WMIconifyWindow ()
3341         CODE:
3342                 RETVAL = SDL_WM_IconifyWindow();
3343         OUTPUT:
3344                 RETVAL
3345
3346 int
3347 ResizeEventW ( e )
3348         SDL_Event *e
3349         CODE:
3350                 RETVAL = e->resize.w;
3351         OUTPUT:
3352                 RETVAL
3353
3354 int
3355 ResizeEventH ( e )
3356         SDL_Event *e
3357         CODE:
3358                 RETVAL = e->resize.h;
3359         OUTPUT:
3360                 RETVAL
3361
3362 char*
3363 AudioDriverName ()
3364         CODE:
3365                 char name[32];
3366                 RETVAL = SDL_AudioDriverName(name,32);
3367         OUTPUT:
3368                 RETVAL
3369
3370 Uint32
3371 GetKeyState ( k )
3372         SDLKey k
3373         CODE:
3374                 if (k >= SDLK_LAST) Perl_croak (aTHX_ "Key out of range");      
3375                 RETVAL = SDL_GetKeyState(NULL)[k];
3376         OUTPUT:
3377                 RETVAL
3378
3379 #ifdef HAVE_SMPEG
3380
3381 SMPEG_Info *
3382 NewSMPEGInfo()
3383         CODE:   
3384                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3385         OUTPUT:
3386                 RETVAL
3387
3388 void
3389 FreeSMPEGInfo ( info )
3390         SMPEG_Info *info
3391         CODE:   
3392                 safefree(info);
3393
3394 int
3395 SMPEGInfoHasAudio ( info )
3396         SMPEG_Info* info
3397         CODE:
3398                 RETVAL = info->has_audio;
3399         OUTPUT:
3400                 RETVAL
3401
3402 int
3403 SMPEGInfoHasVideo ( info )
3404         SMPEG_Info* info
3405         CODE:
3406                 RETVAL = info->has_video;
3407         OUTPUT:
3408                 RETVAL
3409
3410 int
3411 SMPEGInfoWidth ( info )
3412         SMPEG_Info* info
3413         CODE:
3414                 RETVAL = info->width;
3415         OUTPUT:
3416                 RETVAL
3417
3418 int
3419 SMPEGInfoHeight ( info )
3420         SMPEG_Info* info
3421         CODE:
3422                 RETVAL = info->height;
3423         OUTPUT:
3424                 RETVAL
3425
3426 int
3427 SMPEGInfoCurrentFrame ( info )
3428         SMPEG_Info* info
3429         CODE:
3430                 RETVAL = info->current_frame;
3431         OUTPUT:
3432                 RETVAL
3433
3434 double
3435 SMPEGInfoCurrentFPS ( info )
3436         SMPEG_Info* info
3437         CODE:
3438                 RETVAL = info->current_fps;
3439         OUTPUT:
3440                 RETVAL
3441
3442 int
3443 SMPEGInfoCurrentAudioFrame ( info )
3444         SMPEG_Info* info
3445         CODE:
3446                 RETVAL = info->audio_current_frame;
3447         OUTPUT:
3448                 RETVAL
3449
3450 int
3451 SMPEGInfoCurrentOffset ( info )
3452         SMPEG_Info* info
3453         CODE:
3454                 RETVAL = info->current_offset;
3455         OUTPUT:
3456                 RETVAL
3457
3458 int
3459 SMPEGInfoTotalSize ( info )
3460         SMPEG_Info* info
3461         CODE:
3462                 RETVAL = info->total_size;
3463         OUTPUT:
3464                 RETVAL
3465
3466 double
3467 SMPEGInfoCurrentTime ( info )
3468         SMPEG_Info* info
3469         CODE:
3470                 RETVAL = info->current_time;
3471         OUTPUT:
3472                 RETVAL
3473
3474 double
3475 SMPEGInfoTotalTime ( info )
3476         SMPEG_Info* info
3477         CODE:
3478                 RETVAL = info->total_time;
3479         OUTPUT:
3480                 RETVAL
3481
3482 char *
3483 SMPEGError ( mpeg )
3484         SMPEG* mpeg
3485         CODE:   
3486                 RETVAL = SMPEG_error(mpeg);
3487         OUTPUT:
3488                 RETVAL
3489
3490 SMPEG*
3491 NewSMPEG ( filename, info, use_audio )
3492         char* filename
3493         SMPEG_Info* info
3494         int use_audio
3495         CODE:   
3496 #ifdef HAVE_SDL_MIXER
3497                 RETVAL = SMPEG_new(filename,info,0);
3498 #else
3499                 RETVAL = SMPEG_new(filename,info,use_audio);
3500 #endif
3501         OUTPUT:
3502                 RETVAL
3503
3504 void
3505 FreeSMPEG ( mpeg )
3506         SMPEG* mpeg
3507         CODE:
3508                 SMPEG_delete(mpeg);
3509
3510 void
3511 SMPEGEnableAudio ( mpeg , flag )
3512         SMPEG* mpeg
3513         int flag
3514         CODE:   
3515                 SMPEG_enableaudio(mpeg,flag);
3516 #ifdef HAVE_SDL_MIXER
3517                 sdl_perl_use_smpeg_audio = flag;
3518 #endif
3519
3520 void
3521 SMPEGEnableVideo ( mpeg , flag )
3522         SMPEG* mpeg
3523         int flag
3524         CODE:   
3525                 SMPEG_enablevideo(mpeg,flag);
3526
3527 void
3528 SMPEGSetVolume ( mpeg , volume )
3529         SMPEG* mpeg
3530         int volume
3531         CODE:   
3532                 SMPEG_setvolume(mpeg,volume);
3533
3534 void
3535 SMPEGSetDisplay ( mpeg, dest, surfLock )
3536         SMPEG* mpeg
3537         SDL_Surface* dest
3538         SDL_mutex*  surfLock
3539         CODE:
3540                 SMPEG_setdisplay(mpeg,dest,surfLock,NULL);
3541
3542 void
3543 SMPEGScaleXY ( mpeg, w, h)
3544         SMPEG* mpeg
3545         int w
3546         int h
3547         CODE:
3548                 SMPEG_scaleXY(mpeg,w,h);
3549
3550 void
3551 SMPEGScale ( mpeg, scale )
3552         SMPEG* mpeg
3553         int scale
3554         CODE:
3555                 SMPEG_scale(mpeg,scale);
3556
3557 void
3558 SMPEGPlay ( mpeg )
3559         SMPEG* mpeg
3560         CODE:
3561                 SDL_AudioSpec audiofmt;
3562                 Uint16 format;
3563                 int freq, channels;
3564 #ifdef HAVE_SDL_MIXER
3565                 if  (sdl_perl_use_smpeg_audio ) {
3566                         SMPEG_enableaudio(mpeg, 0);
3567                         Mix_QuerySpec(&freq, &format, &channels);
3568                         audiofmt.format = format;
3569                         audiofmt.freq = freq;
3570                         audiofmt.channels = channels;
3571                         SMPEG_actualSpec(mpeg, &audiofmt);
3572                         Mix_HookMusic(SMPEG_playAudioSDL, mpeg);
3573                         SMPEG_enableaudio(mpeg, 1);
3574                 }
3575 #endif
3576                 SMPEG_play(mpeg);
3577
3578 SMPEGstatus
3579 SMPEGStatus ( mpeg )
3580         SMPEG* mpeg
3581         CODE:
3582                 RETVAL = SMPEG_status(mpeg);
3583         OUTPUT:
3584                 RETVAL
3585
3586 void
3587 SMPEGPause ( mpeg )
3588         SMPEG* mpeg
3589         CODE:
3590                 SMPEG_pause(mpeg);
3591
3592 void
3593 SMPEGLoop ( mpeg, repeat )
3594         SMPEG* mpeg
3595         int repeat
3596         CODE:
3597                 SMPEG_loop(mpeg,repeat);
3598
3599 void
3600 SMPEGStop ( mpeg )
3601         SMPEG* mpeg
3602         CODE:
3603                 SMPEG_stop(mpeg);
3604 #ifdef HAVE_SDL_MIXER
3605                 Mix_HookMusic(NULL, NULL);
3606 #endif
3607
3608 void
3609 SMPEGRewind ( mpeg )
3610         SMPEG* mpeg
3611         CODE:
3612                 SMPEG_rewind(mpeg);
3613
3614 void
3615 SMPEGSeek ( mpeg, bytes )
3616         SMPEG* mpeg
3617         int bytes
3618         CODE:
3619                 SMPEG_seek(mpeg,bytes);
3620
3621 void
3622 SMPEGSkip ( mpeg, seconds )
3623         SMPEG* mpeg
3624         float seconds
3625         CODE:
3626                 SMPEG_skip(mpeg,seconds);
3627
3628 void
3629 SMPEGSetDisplayRegion ( mpeg, rect )
3630         SMPEG* mpeg
3631         SDL_Rect* rect
3632         CODE:
3633                 SMPEG_setdisplayregion(mpeg,rect->x,rect->y,rect->w,rect->h);
3634
3635 void
3636 SMPEGRenderFrame ( mpeg, frame )
3637         SMPEG* mpeg
3638         int frame
3639         CODE:
3640                 SMPEG_renderFrame(mpeg,frame);
3641
3642 SMPEG_Info *
3643 SMPEGGetInfo ( mpeg )
3644         SMPEG* mpeg
3645         CODE:
3646                 RETVAL = (SMPEG_Info *) safemalloc (sizeof(SMPEG_Info));
3647                 SMPEG_getinfo(mpeg,RETVAL);
3648         OUTPUT:
3649                 RETVAL
3650         
3651
3652 #endif
3653
3654 #ifdef HAVE_SDL_GFX
3655
3656 SDL_Surface *
3657 GFXRotoZoom ( src, angle, zoom, smooth)
3658         SDL_Surface * src
3659         double angle
3660         double zoom
3661         int smooth
3662         CODE:
3663                 RETVAL = rotozoomSurface( src, angle, zoom, smooth);
3664         OUTPUT:
3665                 RETVAL
3666
3667 SDL_Surface *
3668 GFXZoom ( src, zoomx, zoomy, smooth)
3669         SDL_Surface *src
3670         double zoomx
3671         double zoomy
3672         int smooth
3673         CODE:
3674                 RETVAL = zoomSurface( src, zoomx, zoomy, smooth);
3675         OUTPUT:
3676                 RETVAL
3677
3678 int
3679 GFXPixelColor ( dst, x, y, color )
3680         SDL_Surface* dst
3681         Sint16 x
3682         Sint16 y
3683         Uint32 color
3684         CODE:
3685                 RETVAL = pixelColor( dst, x, y, color);
3686         OUTPUT:
3687                 RETVAL
3688
3689 int
3690 GFXPixelRGBA ( dst, x, y, r, g, b, a )
3691         SDL_Surface* dst
3692         Sint16 x
3693         Sint16 y
3694         Uint8 r
3695         Uint8 g
3696         Uint8 b
3697         Uint8 a
3698         CODE:
3699                 RETVAL = pixelRGBA( dst, x, y, r, g, b, a );
3700         OUTPUT:
3701                 RETVAL
3702
3703 int
3704 GFXHlineColor ( dst, x1, x2, y, color )
3705         SDL_Surface* dst
3706         Sint16 x1
3707         Sint16 x2
3708         Sint16 y
3709         Uint32 color
3710         CODE:
3711                 RETVAL = hlineColor( dst, x1, x2, y, color );
3712         OUTPUT:
3713                 RETVAL
3714
3715 int
3716 GFXHlineRGBA ( dst, x1, x2, y, r, g, b, a )
3717         SDL_Surface* dst
3718         Sint16 x1
3719         Sint16 x2
3720         Sint16 y
3721         Uint8 r
3722         Uint8 g
3723         Uint8 b
3724         Uint8 a
3725         CODE:
3726                 RETVAL = hlineRGBA( dst, x1, x2, y, r, g, b, a );
3727         OUTPUT:
3728                 RETVAL
3729
3730 int
3731 GFXVlineColor ( dst, x, y1, y2, color )
3732         SDL_Surface* dst
3733         Sint16 x
3734         Sint16 y1
3735         Sint16 y2
3736         Uint32 color
3737         CODE:
3738                 RETVAL = vlineColor( dst, x, y1, y2, color );
3739         OUTPUT:
3740                 RETVAL
3741
3742 int
3743 GFXVlineRGBA ( dst, x, y1, y2, r, g, b, a )
3744         SDL_Surface* dst
3745         Sint16 x
3746         Sint16 y1
3747         Sint16 y2
3748         Uint8 r
3749         Uint8 g
3750         Uint8 b
3751         Uint8 a
3752         CODE:
3753                 RETVAL = vlineRGBA( dst, x, y1, y2, r, g, b, a );
3754         OUTPUT:
3755                 RETVAL
3756
3757 int
3758 GFXRectangleColor ( dst, x1, y1, x2, y2, color )
3759         SDL_Surface* dst
3760         Sint16 x1
3761         Sint16 y1
3762         Sint16 x2
3763         Sint16 y2
3764         Uint32 color
3765         CODE:
3766                 RETVAL = rectangleColor( dst, x1, y1, x2, y2, color );
3767         OUTPUT:
3768                 RETVAL
3769
3770 int
3771 GFXRectangleRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3772         SDL_Surface* dst
3773         Sint16 x1
3774         Sint16 y1
3775         Sint16 x2
3776         Sint16 y2
3777         Uint8 r
3778         Uint8 g
3779         Uint8 b
3780         Uint8 a
3781         CODE:
3782                 RETVAL = rectangleRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3783         OUTPUT:
3784                 RETVAL
3785
3786 int
3787 GFXBoxColor ( dst, x1, y1, x2, y2, color )
3788         SDL_Surface* dst
3789         Sint16 x1
3790         Sint16 y1
3791         Sint16 x2
3792         Sint16 y2
3793         Uint32 color
3794         CODE:
3795                 RETVAL = boxColor( dst, x1, y1, x2, y2, color );
3796         OUTPUT:
3797                 RETVAL
3798
3799 int
3800 GFXBoxRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3801         SDL_Surface* dst;
3802         Sint16 x1
3803         Sint16 y1
3804         Sint16 x2
3805         Sint16 y2
3806         Uint8 r
3807         Uint8 g
3808         Uint8 b
3809         Uint8 a
3810         CODE:
3811                 RETVAL = boxRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3812         OUTPUT:
3813                 RETVAL
3814
3815 int
3816 GFXLineColor ( dst, x1, y1, x2, y2, color )
3817         SDL_Surface* dst
3818         Sint16 x1
3819         Sint16 y1
3820         Sint16 x2
3821         Sint16 y2
3822         Uint32 color
3823         CODE:
3824                 RETVAL = lineColor( dst, x1, y1, x2, y2, color );
3825         OUTPUT:
3826                 RETVAL
3827
3828 int
3829 GFXLineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3830         SDL_Surface* dst
3831         Sint16 x1
3832         Sint16 y1
3833         Sint16 x2
3834         Sint16 y2
3835         Uint8 r
3836         Uint8 g
3837         Uint8 b
3838         Uint8 a
3839         CODE:
3840                 RETVAL = lineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3841         OUTPUT:
3842                 RETVAL
3843
3844 int
3845 GFXAalineColor ( dst, x1, y1, x2, y2, color )
3846         SDL_Surface* dst
3847         Sint16 x1
3848         Sint16 y1
3849         Sint16 x2
3850         Sint16 y2
3851         Uint32 color
3852         CODE:
3853                 RETVAL = aalineColor( dst, x1, y1, x2, y2, color );
3854         OUTPUT:
3855                 RETVAL
3856
3857 int
3858 GFXAalineRGBA ( dst, x1, y1, x2, y2, r, g, b, a )
3859         SDL_Surface* dst
3860         Sint16 x1
3861         Sint16 y1
3862         Sint16 x2
3863         Sint16 y2
3864         Uint8 r
3865         Uint8 g
3866         Uint8 b
3867         Uint8 a
3868         CODE:
3869                 RETVAL = aalineRGBA( dst, x1, y1, x2, y2, r, g, b, a );
3870         OUTPUT:
3871                 RETVAL
3872
3873 int
3874 GFXCircleColor ( dst, x, y, r, color )
3875         SDL_Surface* dst
3876         Sint16 x
3877         Sint16 y
3878         Sint16 r
3879         Uint32 color
3880         CODE:
3881                 RETVAL = circleColor( dst, x, y, r, color );
3882         OUTPUT:
3883                 RETVAL
3884
3885 int
3886 GFXCircleRGBA ( dst, x, y, rad, r, g, b, a )
3887         SDL_Surface* dst
3888         Sint16 x
3889         Sint16 y
3890         Sint16 rad
3891         Uint8 r
3892         Uint8 g
3893         Uint8 b
3894         Uint8 a
3895         CODE:
3896                 RETVAL = circleRGBA( dst, x, y, rad, r, g, b, a );
3897         OUTPUT:
3898                 RETVAL
3899
3900 int
3901 GFXAacircleColor ( dst, x, y, r, color )
3902         SDL_Surface* dst
3903         Sint16 x
3904         Sint16 y
3905         Sint16 r
3906         Uint32 color
3907         CODE:
3908                 RETVAL = aacircleColor( dst, x, y, r, color );
3909         OUTPUT:
3910                 RETVAL
3911
3912 int
3913 GFXAacircleRGBA ( dst, x, y, rad, r, g, b, a )
3914         SDL_Surface* dst
3915         Sint16 x
3916         Sint16 y
3917         Sint16 rad
3918         Uint8 r
3919         Uint8 g
3920         Uint8 b
3921         Uint8 a
3922         CODE:
3923                 RETVAL = aacircleRGBA( dst, x, y, rad, r, g, b, a );
3924         OUTPUT:
3925                 RETVAL
3926
3927 int
3928 GFXFilledCircleColor ( dst, x, y, r, color )
3929         SDL_Surface* dst
3930         Sint16 x
3931         Sint16 y
3932         Sint16 r
3933         Uint32 color
3934         CODE:
3935                 RETVAL = filledCircleColor( dst, x, y, r, color );
3936         OUTPUT:
3937                 RETVAL
3938
3939 int
3940 GFXFilledCircleRGBA ( dst, x, y, rad, r, g, b, a )
3941         SDL_Surface* dst
3942         Sint16 x
3943         Sint16 y
3944         Sint16 rad
3945         Uint8 r
3946         Uint8 g
3947         Uint8 b
3948         Uint8 a
3949         CODE:
3950                 RETVAL = filledCircleRGBA( dst, x, y, rad, r, g, b, a );
3951         OUTPUT:
3952                 RETVAL
3953
3954 int
3955 GFXEllipseColor ( dst, x, y, rx, ry, color )
3956         SDL_Surface* dst
3957         Sint16 x
3958         Sint16 y
3959         Sint16 rx
3960         Sint16 ry
3961         Uint32 color
3962         CODE:
3963                 RETVAL = ellipseColor( dst, x, y, rx, ry, color );
3964         OUTPUT:
3965                 RETVAL
3966
3967 int
3968 GFXEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
3969         SDL_Surface* dst
3970         Sint16 x
3971         Sint16 y
3972         Sint16  rx
3973         Sint16 ry
3974         Uint8 r
3975         Uint8 g
3976         Uint8 b
3977         Uint8 a
3978         CODE:
3979                 RETVAL = ellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
3980         OUTPUT:
3981                 RETVAL
3982
3983 int
3984 GFXAaellipseColor ( dst, xc, yc, rx, ry, color )
3985         SDL_Surface* dst
3986         Sint16 xc
3987         Sint16 yc
3988         Sint16 rx
3989         Sint16 ry
3990         Uint32 color
3991         CODE:
3992                 RETVAL = aaellipseColor( dst, xc, yc, rx, ry, color );
3993         OUTPUT:
3994                 RETVAL
3995
3996 int
3997 GFXAaellipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
3998         SDL_Surface* dst
3999         Sint16 x
4000         Sint16 y
4001         Sint16 rx
4002         Sint16 ry
4003         Uint8 r
4004         Uint8 g
4005         Uint8 b
4006         Uint8 a
4007         CODE:
4008                 RETVAL = aaellipseRGBA( dst, x, y, rx, ry, r, g, b, a );
4009         OUTPUT:
4010                 RETVAL
4011
4012 int
4013 GFXFilledEllipseColor ( dst, x, y, rx, ry, color )
4014         SDL_Surface* dst
4015         Sint16 x
4016         Sint16 y
4017         Sint16 rx
4018         Sint16 ry
4019         Uint32 color
4020         CODE:
4021                 RETVAL = filledEllipseColor( dst, x, y, rx, ry, color );
4022         OUTPUT:
4023                 RETVAL
4024
4025 int
4026 GFXFilledEllipseRGBA ( dst, x, y, rx, ry, r, g, b, a )
4027         SDL_Surface* dst
4028         Sint16 x
4029         Sint16 y
4030         Sint16 rx
4031         Sint16 ry
4032         Uint8 r
4033         Uint8 g
4034         Uint8 b
4035         Uint8 a
4036         CODE:
4037                 RETVAL = filledEllipseRGBA( dst, x, y, rx, ry, r, g, b, a );
4038         OUTPUT:
4039                 RETVAL
4040
4041 int
4042 GFXFilledPieColor ( dst, x, y, rad, start, end, color )
4043         SDL_Surface* dst
4044         Sint16 x
4045         Sint16 y
4046         Sint16 rad
4047         Sint16 start
4048         Sint16 end
4049         Uint32 color
4050         CODE:
4051                 RETVAL = filledPieColor( dst, x, y, rad, start, end, color );
4052         OUTPUT:
4053                 RETVAL
4054
4055 int
4056 GFXFilledPieRGBA ( dst, x, y, rad, start, end, r, g, b, a )
4057         SDL_Surface* dst
4058         Sint16 x
4059         Sint16 y
4060         Sint16 rad
4061         Sint16 start
4062         Sint16 end
4063         Uint8 r
4064         Uint8 g
4065         Uint8 b
4066         Uint8 a
4067         CODE:
4068                 RETVAL = filledPieRGBA( dst, x, y, rad, start, end, r, g, b, a );
4069         OUTPUT:
4070                 RETVAL
4071
4072 int
4073 GFXPolygonColor ( dst, vx, vy, n, color )
4074         SDL_Surface* dst
4075         Sint16* vx
4076         Sint16* vy
4077         int n
4078         Uint32 color;
4079         CODE:
4080                 RETVAL = polygonColor( dst, vx, vy, n, color );
4081         OUTPUT:
4082                 RETVAL
4083
4084 int
4085 GFXPolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4086         SDL_Surface* dst
4087         Sint16* vx
4088         Sint16* vy
4089         int n
4090         Uint8 r
4091         Uint8 g
4092         Uint8 b
4093         Uint8 a
4094         CODE:
4095                 RETVAL = polygonRGBA( dst, vx, vy, n, r, g, b, a );
4096         OUTPUT:
4097                 RETVAL
4098
4099 int
4100 GFXAapolygonColor ( dst, vx, vy, n, color )
4101         SDL_Surface* dst
4102         Sint16* vx
4103         Sint16* vy
4104         int n
4105         Uint32 color
4106         CODE:
4107                 RETVAL = aapolygonColor( dst, vx, vy, n, color );
4108         OUTPUT:
4109                 RETVAL
4110
4111 int
4112 GFXAapolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4113         SDL_Surface* dst
4114         Sint16* vx
4115         Sint16* vy
4116         int n
4117         Uint8 r
4118         Uint8 g
4119         Uint8 b
4120         Uint8 a
4121         CODE:
4122                 RETVAL = aapolygonRGBA( dst, vx, vy, n, r, g, b, a );
4123         OUTPUT:
4124                 RETVAL
4125
4126 int
4127 GFXFilledPolygonColor ( dst, vx, vy, n, color )
4128         SDL_Surface* dst
4129         Sint16* vx
4130         Sint16* vy
4131         int n
4132         int color
4133         CODE:
4134                 RETVAL = filledPolygonColor( dst, vx, vy, n, color );
4135         OUTPUT:
4136                 RETVAL
4137
4138 int
4139 GFXFilledPolygonRGBA ( dst, vx, vy, n, r, g, b, a )
4140         SDL_Surface* dst
4141         Sint16* vx
4142         Sint16* vy
4143         int n
4144         Uint8 r
4145         Uint8 g
4146         Uint8 b
4147         Uint8 a
4148         CODE:
4149                 RETVAL = filledPolygonRGBA( dst, vx, vy, n, r, g, b, a );
4150         OUTPUT:
4151                 RETVAL
4152
4153 int
4154 GFXCharacterColor ( dst, x, y, c, color )
4155         SDL_Surface* dst
4156         Sint16 x
4157         Sint16 y
4158         char c
4159         Uint32 color
4160         CODE:
4161                 RETVAL = characterColor( dst, x, y, c, color );
4162         OUTPUT:
4163                 RETVAL
4164
4165 int
4166 GFXCharacterRGBA ( dst, x, y, c, r, g, b, a )
4167         SDL_Surface* dst
4168         Sint16 x
4169         Sint16 y
4170         char c
4171         Uint8 r
4172         Uint8 g
4173         Uint8 b
4174         Uint8 a
4175         CODE:
4176                 RETVAL = characterRGBA( dst, x, y, c, r, g, b, a );
4177         OUTPUT:
4178                 RETVAL
4179
4180 int
4181 GFXStringColor ( dst, x, y, c, color )
4182         SDL_Surface* dst
4183         Sint16 x
4184         Sint16 y
4185         char* c
4186         Uint32 color
4187         CODE:
4188                 RETVAL = stringColor( dst, x, y, c, color );
4189         OUTPUT:
4190                 RETVAL
4191
4192 int
4193 GFXStringRGBA ( dst, x, y, c, r, g, b, a )
4194         SDL_Surface* dst
4195         Sint16 x
4196         Sint16 y
4197         char* c
4198         Uint8 r
4199         Uint8 g
4200         Uint8 b
4201         Uint8 a
4202         CODE:
4203                 RETVAL = stringRGBA( dst, x, y, c, r, g, b, a );
4204         OUTPUT:
4205                 RETVAL
4206
4207 #endif
4208
4209
4210 #ifdef HAVE_SDL_SVG
4211
4212 SDL_svg_context *
4213 SVG_Load ( filename )
4214         char* filename
4215         CODE:
4216                 RETVAL = SVG_Load(filename);
4217         OUTPUT:
4218                 RETVAL
4219
4220 SDL_svg_context *
4221 SVG_LoadBuffer ( data, len )
4222         char* data
4223         int len
4224         CODE:
4225                 RETVAL = SVG_LoadBuffer(data,len);
4226         OUTPUT:
4227                 RETVAL
4228
4229 int
4230 SVG_SetOffset ( source, xoff, yoff )
4231         SDL_svg_context* source
4232         double xoff
4233         double yoff
4234         CODE:
4235                 RETVAL = SVG_SetOffset(source,xoff,yoff);
4236         OUTPUT:
4237                 RETVAL
4238
4239 int
4240 SVG_SetScale ( source, xscale, yscale )
4241         SDL_svg_context* source
4242         double xscale
4243         double yscale
4244         CODE:
4245                 RETVAL = SVG_SetScale(source,xscale,yscale);
4246         OUTPUT:
4247                 RETVAL
4248
4249 int
4250 SVG_RenderToSurface ( source, x, y, dest )
4251         SDL_svg_context* source
4252         int x
4253         int y
4254         SDL_Surface* dest;
4255         CODE:
4256                 RETVAL = SVG_RenderToSurface(source,x,y,dest);
4257         OUTPUT:
4258                 RETVAL
4259
4260 void
4261 SVG_Free ( source )
4262         SDL_svg_context* source
4263         CODE:
4264                 SVG_Free(source);       
4265
4266 void
4267 SVG_Set_Flags ( source, flags )
4268         SDL_svg_context* source
4269         Uint32 flags
4270         CODE:
4271                 SVG_Set_Flags(source,flags);
4272
4273 float
4274 SVG_Width ( source )
4275         SDL_svg_context* source
4276         CODE:
4277                 RETVAL = SVG_Width(source);
4278         OUTPUT:
4279                 RETVAL
4280
4281 float
4282 SVG_HEIGHT ( source )
4283         SDL_svg_context* source
4284         CODE:
4285                 RETVAL = SVG_Height(source);
4286         OUTPUT:
4287                 RETVAL
4288
4289 void
4290 SVG_SetClipping ( source, minx, miny, maxx, maxy )
4291         SDL_svg_context* source
4292         int minx
4293         int miny
4294         int maxx
4295         int maxy
4296         CODE:
4297                 SVG_SetClipping(source,minx,miny,maxx,maxy);
4298
4299 int
4300 SVG_Version ( )
4301         CODE:
4302                 RETVAL = SVG_Version();
4303         OUTPUT:
4304                 RETVAL
4305
4306
4307 #endif
4308
4309 #ifdef HAVE_SDL_SOUND
4310
4311 Uint16
4312 SoundAudioInfoFormat ( audioinfo )
4313         Sound_AudioInfo* audioinfo
4314         CODE:
4315                 RETVAL = audioinfo->format;
4316         OUTPUT:
4317                 RETVAL
4318
4319 Uint8
4320 SoundAudioInfoChannels ( audioinfo )
4321         Sound_AudioInfo* audioinfo
4322         CODE:
4323                 RETVAL = audioinfo->channels;
4324         OUTPUT:
4325                 RETVAL
4326
4327 Uint32
4328 SoundAudioInforate ( audioinfo )
4329         Sound_AudioInfo* audioinfo
4330         CODE:
4331                 RETVAL = audioinfo->rate;
4332         OUTPUT:
4333                 RETVAL
4334
4335 AV*
4336 SoundDecoderInfoExtensions ( decoderinfo )
4337         Sound_DecoderInfo* decoderinfo
4338         CODE:
4339                 const char **ext;
4340                 for ( ext = decoderinfo->extensions; *ext != NULL; ext++ ){
4341                         av_push(RETVAL,newSVpv(*ext,0));
4342                 }
4343         OUTPUT:
4344                 RETVAL
4345
4346 const char*
4347 SoundDecoderInfoDescription ( decoderinfo )
4348         Sound_DecoderInfo* decoderinfo
4349         CODE:
4350                 RETVAL = decoderinfo->description;
4351         OUTPUT:
4352                 RETVAL
4353
4354 const char*
4355 SoundDecoderInfoAuthor ( decoderinfo )
4356         Sound_DecoderInfo* decoderinfo
4357         CODE:
4358                 RETVAL = decoderinfo->author;
4359         OUTPUT:
4360                 RETVAL
4361
4362 const char*
4363 SoundDecoderInfoUrl ( decoderinfo )
4364         Sound_DecoderInfo* decoderinfo
4365         CODE:
4366                 RETVAL = decoderinfo->url;
4367         OUTPUT:
4368                 RETVAL
4369
4370 const Sound_DecoderInfo*
4371 SoundSampleDecoder ( sample ) 
4372         Sound_Sample* sample
4373         CODE:
4374                 RETVAL = sample->decoder;
4375         OUTPUT:
4376                 RETVAL
4377
4378 Sound_AudioInfo* 
4379 SoundSampleDesired ( sample )
4380         Sound_Sample* sample
4381         CODE:
4382                 RETVAL = &sample->desired;
4383         OUTPUT:
4384                 RETVAL
4385
4386 Sound_AudioInfo*
4387 SoundSampleAcutal ( sample )
4388         Sound_Sample* sample
4389         CODE:
4390                 RETVAL = &sample->actual;
4391         OUTPUT:
4392                 RETVAL
4393
4394 char*
4395 SoundSampleBuffer ( sample )
4396         Sound_Sample* sample
4397         CODE:
4398                 RETVAL = sample->buffer;
4399         OUTPUT:
4400                 RETVAL
4401
4402 Uint32
4403 SoundSampleBufferSize ( sample )
4404         Sound_Sample* sample
4405         CODE:
4406                 RETVAL = sample->buffer_size;
4407         OUTPUT:
4408                 RETVAL
4409
4410 Uint32
4411 SoundSampleFlags ( sample )
4412         Sound_Sample* sample
4413         CODE:
4414                 RETVAL = (Uint32)sample->flags;
4415         OUTPUT:
4416                 RETVAL
4417
4418 int
4419 Sound_Init ( )
4420         CODE:
4421                 RETVAL = Sound_Init();
4422         OUTPUT:
4423                 RETVAL
4424
4425 int
4426 Sound_Quit ( )
4427         CODE:
4428                 RETVAL = Sound_Quit();
4429         OUTPUT:
4430                 RETVAL
4431
4432 AV*
4433 Sound_AvailableDecoders ( )
4434         CODE:
4435                 RETVAL = newAV();
4436                 const Sound_DecoderInfo** sdi;
4437                 sdi = Sound_AvailableDecoders();
4438                 if (sdi != NULL)  {
4439                         for (;*sdi != NULL; ++sdi) {
4440                                 av_push(RETVAL,sv_2mortal(newSViv(PTR2IV(*sdi))));
4441                         }
4442                 }
4443         OUTPUT:
4444                 RETVAL
4445
4446 const char*
4447 Sound_GetError ( )
4448         CODE:
4449                 RETVAL = Sound_GetError();
4450         OUTPUT:
4451                 RETVAL
4452
4453 void
4454 Sound_ClearError ( )
4455         CODE:
4456                 Sound_ClearError();
4457
4458 Sound_Sample*
4459 Sound_NewSample ( rw, ext, desired, buffsize )
4460         SDL_RWops* rw
4461         const char* ext
4462         Sound_AudioInfo* desired
4463         Uint32 buffsize
4464         CODE:
4465                 RETVAL = Sound_NewSample(rw,ext,desired,buffsize);
4466         OUTPUT:
4467                 RETVAL
4468
4469 Sound_Sample*
4470 Sound_NewSampleFromMem ( data, size, ext, desired, buffsize )
4471         const Uint8 *data
4472         Uint32 size
4473         const char* ext
4474         Sound_AudioInfo* desired
4475         Uint32 buffsize
4476         CODE:
4477                 RETVAL = Sound_NewSampleFromMem(data,size,ext,desired,buffsize);
4478         OUTPUT:
4479                 RETVAL
4480
4481 Sound_Sample*
4482 Sound_NewSampleFromFile ( fname, desired, buffsize )
4483         const char* fname
4484         Sound_AudioInfo* desired
4485         Uint32 buffsize
4486         CODE:
4487                 RETVAL = Sound_NewSampleFromFile(fname,desired,buffsize);
4488         OUTPUT:
4489                 RETVAL
4490
4491 void
4492 Sound_FreeSample ( sample )
4493         Sound_Sample* sample
4494         CODE:
4495                 Sound_FreeSample(sample);
4496
4497 Sint32
4498 Sound_GetDuration ( sample )
4499         Sound_Sample* sample
4500         CODE:
4501                 RETVAL = Sound_GetDuration(sample);
4502         OUTPUT:
4503                 RETVAL
4504
4505 int
4506 Sound_SetBufferSize ( sample, size )
4507         Sound_Sample* sample
4508         Uint32 size
4509         CODE:
4510                 RETVAL = Sound_SetBufferSize(sample,size);
4511         OUTPUT:
4512                 RETVAL
4513
4514 Uint32
4515 Sound_Decode ( sample )
4516         Sound_Sample* sample
4517         CODE:
4518                 RETVAL = Sound_Decode(sample);
4519         OUTPUT:
4520                 RETVAL
4521
4522 Uint32
4523 Sound_DecodeAll ( sample ) 
4524         Sound_Sample* sample
4525         CODE:
4526                 RETVAL = Sound_DecodeAll(sample);
4527         OUTPUT:
4528                 RETVAL
4529
4530 int
4531 Sound_Rewind ( sample )
4532         Sound_Sample* sample
4533         CODE:
4534                 RETVAL = Sound_Rewind(sample);
4535         OUTPUT:
4536                 RETVAL
4537
4538 int
4539 Sound_Seek ( sample, ms )
4540         Sound_Sample* sample
4541         Uint32 ms
4542         CODE:
4543                 RETVAL = Sound_Seek(sample,ms);
4544         OUTPUT:
4545                 RETVAL
4546
4547 #endif
4548
4549 MODULE = SDL            PACKAGE = SDL
4550 PROTOTYPES : DISABLE
4551
4552