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