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