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