X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;ds=inline;f=gacela_SDL.lisp;h=47a8a27f01570fe2075788ffcc9967207fafb248;hb=90b112bd017851a29a00bcba04eb23216c642214;hp=810908045b5c24503f72c314fd82068513446973;hpb=27b9bb922e43e418305b28d8139408634d4be1a3;p=gacela.git
diff --git a/gacela_SDL.lisp b/gacela_SDL.lisp
index 8109080..47a8a27 100644
--- a/gacela_SDL.lisp
+++ b/gacela_SDL.lisp
@@ -15,56 +15,58 @@
;;; 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)
-
-;;; Keyboard
-(defconstant SDL_DEFAULT_REPEAT_DELAY 500)
-(defconstant SDL_DEFAULT_REPEAT_INTERVAL 30)
-
-;;; The two types of endianness
-(defconstant SDL_LIL_ENDIAN 1234)
-(defconstant SDL_BIG_ENDIAN 4321)
+(mapcconst int "int" "SDL_DEFAULT_REPEAT_DELAY")
+(mapcconst int "int" "SDL_DEFAULT_REPEAT_INTERVAL")
+(mapcconst int "int" "SDL_LIL_ENDIAN")
+(mapcconst int "int" "SDL_BIG_ENDIAN")
;;; SDL Functions
(defcfun "int gacela_SDL_Init (int flags)" 0
@@ -139,9 +141,6 @@
(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;")
@@ -184,7 +183,6 @@
;(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"))
;;; C-Gacela Functions
@@ -210,7 +208,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"))