X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=gacela_SDL.lisp;h=3ced5c31ad7c96ccfb2a2aa9543b4e570be9942a;hb=fd0956a0072b3db8808880bd3d4dbf17d941265d;hp=26e9a6fa46d216abb232b6707d73a43dbb6b252f;hpb=e8378a8606adfa0cdb9b4063994a5df25d602f84;p=gacela.git diff --git a/gacela_SDL.lisp b/gacela_SDL.lisp index 26e9a6f..3ced5c3 100644 --- a/gacela_SDL.lisp +++ b/gacela_SDL.lisp @@ -15,52 +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 ") -;;; These are the flags which may be passed to SDL_Init() -(defconstant SDL_INIT_TIMER #x00000001) -(defconstant SDL_INIT_AUDIO #x00000010) -(defconstant SDL_INIT_VIDEO #x00000020) -(defconstant SDL_INIT_CDROM #x00000100) -(defconstant SDL_INIT_JOYSTICK #x00000200) -(defconstant SDL_INIT_NOPARACHUTE #x00100000) -(defconstant SDL_INIT_EVENTTHREAD #x01000000) -(defconstant SDL_INIT_EVERYTHING #x0000FFFF) - +;;; SDL constants as functions +(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") -;;; These are the currently supported flags for the SDL_surface -;;; Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() -(defconstant SDL_SWSURFACE #x00000000) -(defconstant SDL_HWSURFACE #x00000001) -(defconstant SDL_ASYNCBLIT #x00000004) +(mapcconst int "int" "SDL_SWSURFACE") +(mapcconst int "int" "SDL_HWSURFACE") +(mapcconst int "int" "SDL_ASYNCBLIT") +(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") -;;; Available for SDL_SetVideoMode() -(defconstant SDL_ANYFORMAT #x10000000) -(defconstant SDL_HWPALETTE #x20000000) -(defconstant SDL_DOUBLEBUF #x40000000) -(defconstant SDL_FULLSCREEN #x80000000) -(defconstant SDL_OPENGL #x00000002) -(defconstant SDL_OPENGLBLIT #x0000000A) -(defconstant SDL_RESIZABLE #x00000010) -(defconstant SDL_NOFRAME #x00000020) +(mapcconst int "int" "SDL_HWACCEL") +(mapcconst int "int" "SDL_SRCCOLORKEY") -;;; Used internally (read-only) -(defconstant SDL_HWACCEL #x00000100) -(defconstant SDL_SRCCOLORKEY #x00001000) +(mapcconst int "int" "SDL_GL_DOUBLEBUFFER") -;;; For setting the OpenGL window attributes -(defconstant SDL_GL_DOUBLEBUFFER 5) +(mapcconst int "int" "SDL_DEFAULT_REPEAT_DELAY") +(mapcconst int "int" "SDL_DEFAULT_REPEAT_INTERVAL") -;;; Keyboard -(defconstant SDL_DEFAULT_REPEAT_DELAY 500) -(defconstant SDL_DEFAULT_REPEAT_INTERVAL 30) +(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 @@ -70,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 @@ -135,9 +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 +(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")) @@ -161,23 +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 @@ -196,9 +248,12 @@ "const SDL_Surface *s = surface;" "return s->pixels;") +(defcfun "int gacela_surface_format_BytesPerPixel (int surface)" 0 + "const SDL_Surface *s = surface;" + "return s->format->BytesPerPixel;") + ;(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")) @@ -206,3 +261,4 @@ (defentry surface-w (int) (int "gacela_surface_w")) (defentry surface-h (int) (int "gacela_surface_h")) (defentry surface-pixels (int) (int "gacela_surface_pixels")) +(defentry surface-format-BytesPerPixel (int) (int "gacela_surface_format_BytesPerPixel"))