X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=gacela_SDL.lisp;h=3ced5c31ad7c96ccfb2a2aa9543b4e570be9942a;hb=6a3d1ffb69036e6d4f1c239fd7d52f9bfc48d50c;hp=fe743493c6d44866f2440a122c6a5a02db25eab4;hpb=b1bda2479eebac341086054f217e20faadb7f7a7;p=gacela.git diff --git a/gacela_SDL.lisp b/gacela_SDL.lisp index fe74349..3ced5c3 100644 --- a/gacela_SDL.lisp +++ b/gacela_SDL.lisp @@ -15,51 +15,60 @@ ;;; along with this program. If not, see . -(in-package :gacela) +(eval-when (compile load eval) + (when (not (find-package 'gacela)) (make-package 'gacela :nicknames '(gg) :use '(lisp))) + (in-package 'gacela :nicknames '(gg) :use '(lisp))) + + +(defmacro mapcconst (type c-type name) + (let ((c-header (concatenate 'string c-type " gacela_" name " (void)")) + (c-body (concatenate 'string "return " name ";")) + (c-name (concatenate 'string "gacela_" name)) + (lisp-name (intern (string-upcase name)))) + `(progn + (defcfun ,c-header 0 ,c-body) + (defentry ,lisp-name () (,type ,c-name)) + (eval-when (load) (defconstant ,lisp-name (,lisp-name)))))) (clines "#include ") (clines "#include ") -(clines "#include ") (clines "#include ") -(clines "#include ") - -(defmacro defcconst (type name) - `(let ((header (concatenate 'string "(defcfun \" ;;; SDL constants as functions -(defcfun "int gacela_SDL_INIT_TIMER (void)" 0 "return SDL_INIT_TIMER;") -(defcfun "int gacela_SDL_INIT_AUDIO (void)" 0 "return SDL_INIT_AUDIO;") -(defcfun "int gacela_SDL_INIT_VIDEO (void)" 0 "return SDL_INIT_VIDEO;") -(defcfun "int gacela_SDL_INIT_CDROM (void)" 0 "return SDL_INIT_CDROM;") -(defcfun "int gacela_SDL_INIT_JOYSTICK (void)" 0 "return SDL_INIT_JOYSTICK;") -(defcfun "int gacela_SDL_INIT_NOPARACHUTE (void)" 0 "return SDL_INIT_NOPARACHUTE;") -(defcfun "int gacela_SDL_INIT_EVENTTHREAD (void)" 0 "return SDL_INIT_EVENTTHREAD;") -(defcfun "int gacela_SDL_INIT_EVERYTHING (void)" 0 "return SDL_INIT_EVERYTHING;") +(mapcconst int "int" "SDL_INIT_TIMER") +(mapcconst int "int" "SDL_INIT_AUDIO") +(mapcconst int "int" "SDL_INIT_VIDEO") +(mapcconst int "int" "SDL_INIT_CDROM") +(mapcconst int "int" "SDL_INIT_JOYSTICK") +(mapcconst int "int" "SDL_INIT_NOPARACHUTE") +(mapcconst int "int" "SDL_INIT_EVENTTHREAD") +(mapcconst int "int" "SDL_INIT_EVERYTHING") -(defcfun "int gacela_SDL_SWSURFACE (void)" 0 "return SDL_SWSURFACE;") -(defcfun "int gacela_SDL_HWSURFACE (void)" 0 "return SDL_HWSURFACE;") -(defcfun "int gacela_SDL_ASYNCBLIT (void)" 0 "return SDL_ASYNCBLIT;") +(mapcconst int "int" "SDL_SWSURFACE") +(mapcconst int "int" "SDL_HWSURFACE") +(mapcconst int "int" "SDL_ASYNCBLIT") -(defcfun "int gacela_SDL_ANYFORMAT (void)" 0 "return SDL_ANYFORMAT;") -(defcfun "int gacela_SDL_HWPALETTE (void)" 0 "return SDL_HWPALETTE;") -(defcfun "int gacela_SDL_DOUBLEBUF (void)" 0 "return SDL_DOUBLEBUF;") -(defcfun "int gacela_SDL_FULLSCREEN (void)" 0 "return SDL_FULLSCREEN;") -(defcfun "int gacela_SDL_OPENGL (void)" 0 "return SDL_OPENGL;") -(defcfun "int gacela_SDL_OPENGLBLIT (void)" 0 "return SDL_OPENGLBLIT;") -(defcfun "int gacela_SDL_RESIZABLE (void)" 0 "return SDL_RESIZABLE;") -(defcfun "int gacela_SDL_NOFRAME (void)" 0 "return SDL_NOFRAME;") +(mapcconst int "int" "SDL_ANYFORMAT") +(mapcconst int "int" "SDL_HWPALETTE") +(mapcconst int "int" "SDL_DOUBLEBUF") +(mapcconst int "int" "SDL_FULLSCREEN") +(mapcconst int "int" "SDL_OPENGL") +(mapcconst int "int" "SDL_OPENGLBLIT") +(mapcconst int "int" "SDL_RESIZABLE") +(mapcconst int "int" "SDL_NOFRAME") -(defcfun "int gacela_SDL_HWACCEL (void)" 0 "return SDL_HWACCEL;") -(defcfun "int gacela_SDL_SRCCOLORKEY (void)" 0 "return SDL_SRCCOLORKEY;") +(mapcconst int "int" "SDL_HWACCEL") +(mapcconst int "int" "SDL_SRCCOLORKEY") -(defcfun "int gacela_SDL_GL_DOUBLEBUFFER (void)" 0 "return SDL_GL_DOUBLEBUFFER;") +(mapcconst int "int" "SDL_GL_DOUBLEBUFFER") -(defcfun "int gacela_SDL_DEFAULT_REPEAT_DELAY (void)" 0 "return DEFAULT_REPEAT_DELAY;") -(defcfun "int gacela_SDL_DEFAULT_REPEAT_INTERVAL (void)" 0 "return DEFAULT_REPEAT_INTERVAL;") +(mapcconst int "int" "SDL_DEFAULT_REPEAT_DELAY") +(mapcconst int "int" "SDL_DEFAULT_REPEAT_INTERVAL") -(defcfun "int gacela_SDL_LIL_ENDIAN (void)" 0 "return SDL_LIL_ENDIAN;") -(defcfun "int gacela_SDL_BIG_ENDIAN (void)" 0 "return SDL_BIG_ENDIAN;") +(mapcconst int "int" "SDL_LIL_ENDIAN") +(mapcconst int "int" "SDL_BIG_ENDIAN") +(mapcconst int "int" "MIX_DEFAULT_FORMAT") ;;; SDL Functions (defcfun "int gacela_SDL_Init (int flags)" 0 @@ -69,6 +78,7 @@ "SDL_Quit ();") (defcfun "int gacela_SDL_SetVideoMode (int width, int height, int bpp, int flags)" 0 + "close(2);" "return SDL_SetVideoMode (width, height, bpp, flags);") (defcfun "void gacela_SDL_WM_SetCaption (char *title, char *icon)" 0 @@ -134,12 +144,51 @@ (defcfun "int gacela_SDL_EnableKeyRepeat (int delay, int interval)" 0 "return SDL_EnableKeyRepeat (delay, interval);") -(defcfun "int gacela_zoomSurface (int src, float zoomx, float zoomy, int smooth)" 0 - "return zoomSurface (src, zoomx, zoomy, smooth);") - (defcfun "int gacela_SDL_ByteOrder (void)" 0 "return SDL_BYTEORDER;") +(defcfun "int gacela_zoomSurface (int src, double zoomx, double zoomy, int smooth)" 0 + "return zoomSurface (src, zoomx, zoomy, smooth);") + +(defcfun "int gacela_Mix_OpenAudio (int frequency, int format, int channels, int chunksize)" 0 + "return Mix_OpenAudio (frequency, format, channels, chunksize);") + +(defcfun "int gacela_Mix_LoadMUS (char *file)" 0 + "return Mix_LoadMUS (file);") + +(defcfun "int gacela_Mix_LoadWAV (char *file)" 0 + "return Mix_LoadWAV (file);") + +(defcfun "int gacela_Mix_PlayChannel (int channel, int chunk, int loops)" 0 + "return Mix_PlayChannel (channel, chunk, loops);") + +(defcfun "int gacela_Mix_PlayMusic (int music, int loops)" 0 + "return Mix_PlayMusic (music, loops);") + +(defcfun "int gacela_Mix_PlayingMusic (void)" 0 + "return Mix_PlayingMusic ();") + +(defcfun "int gacela_Mix_PausedMusic (void)" 0 + "return Mix_PausedMusic ();") + +(defcfun "void gacela_Mix_PauseMusic (void)" 0 + "Mix_PauseMusic ();") + +(defcfun "void gacela_Mix_ResumeMusic (void)" 0 + "Mix_ResumeMusic ();") + +(defcfun "int gacela_Mix_HaltMusic (void)" 0 + "return Mix_HaltMusic ();") + +(defcfun "void gacela_Mix_FreeMusic (int music)" 0 + "Mix_FreeMusic (music);") + +(defcfun "void gacela_Mix_FreeChunk (int chunk)" 0 + "Mix_FreeChunk (chunk);") + +(defcfun "void gacela_Mix_CloseAudio (void)" 0 + "Mix_CloseAudio ();") + (defentry SDL_Init (int) (int "gacela_SDL_Init")) (defentry SDL_Quit () (void "gacela_SDL_Quit")) (defentry SDL_SetVideoMode (int int int int) (int "gacela_SDL_SetVideoMode")) @@ -163,24 +212,24 @@ ;(defentry TTF_OpenFont (string int) (int "gacela_TTF_OpenFont")) ;(defentry TTF_CloseFont (int) (void "gacela_TTF_CloseFont")) ;(defentry TTF_Quit () (void "gacela_TTF_Quit")) -;(defentry Mix_OpenAudio (int int int) (int "gacela_Mix_OpenAudio")) -;(defentry Mix_LoadMUS (string) (int "gacela_Mix_LoadMUS")) -;(defentry Mix_LoadWAV (string) (int "gacela_Mix_LoadWAV")) -;(defentry Mix_PlayChannel (int int int) (int "gacela_Mix_PlayChannel")) -;(defentry Mix_PlayMusic (int int) (int "gacela_Mix_PlayMusic")) -;(defentry Mix_PlayingMusic () (int "gacela_Mix_PlayingMusic")) -;(defentry Mix_PausedMusic () (int "gacela_Mix_PausedMusic")) -;(defentry Mix_PauseMusic () (void "gacela_Mix_PauseMusic")) -;(defentry Mix_ResumeMusic () (void "gacela_Mix_ResumeMusic")) -;(defentry Mix_HaltMusic () (int "gacela_Mix_HaltMusic")) -;(defentry Mix_FreeMusic (int) (void "gacela_Mix_FreeMusic")) -;(defentry Mix_FreeChunk (int) (void "gacela_Mix_FreeChunk")) -;(defentry Mix_CloseAudio () (void "gacela_Mix_CloseAudio")) +(defentry Mix_OpenAudio (int int int int) (int "gacela_Mix_OpenAudio")) +(defentry Mix_LoadMUS (string) (int "gacela_Mix_LoadMUS")) +(defentry Mix_LoadWAV (string) (int "gacela_Mix_LoadWAV")) +(defentry Mix_PlayChannel (int int int) (int "gacela_Mix_PlayChannel")) +(defentry Mix_PlayMusic (int int) (int "gacela_Mix_PlayMusic")) +(defentry Mix_PlayingMusic () (int "gacela_Mix_PlayingMusic")) +(defentry Mix_PausedMusic () (int "gacela_Mix_PausedMusic")) +(defentry Mix_PauseMusic () (void "gacela_Mix_PauseMusic")) +(defentry Mix_ResumeMusic () (void "gacela_Mix_ResumeMusic")) +(defentry Mix_HaltMusic () (int "gacela_Mix_HaltMusic")) +(defentry Mix_FreeMusic (int) (void "gacela_Mix_FreeMusic")) +(defentry Mix_FreeChunk (int) (void "gacela_Mix_FreeChunk")) +(defentry Mix_CloseAudio () (void "gacela_Mix_CloseAudio")) ;(defentry free (int) (void "gacela_free")) (defentry SDL_GL_SwapBuffers () (void "gacela_SDL_GL_SwapBuffers")) (defentry SDL_EnableKeyRepeat (int int) (int "gacela_SDL_EnableKeyRepeat")) -(defentry zoomSurface (int float float int) (int "gacela_zoomSurface")) (defentry SDL_ByteOrder () (int "gacela_SDL_ByteOrder")) +(defentry zoomSurface (int double double int) (int "gacela_zoomSurface")) ;;; C-Gacela Functions (defcfun "int gacela_surface_format (int surface)" 0 @@ -205,7 +254,6 @@ ;(defentry apply-surface2 (int int int int int int int int int) (void "apply_surface")) ;(defentry render-text2 (int string int int int) (int "render_text")) -;(defentry fill-surface (int int int int) (void "fill_surface")) ;(defentry box-collision (int int int int int int) (int "box_collision")) ;(defentry create-SDL_Surface (int int int int int int) (int "create_SDL_Surface")) ;(defentry copy-SDL_Surface (int) (int "copy_SDL_Surface"))