X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fgacela_SDL.c;h=79774444e00acb4caef88de9e842d4057e036b16;hb=afd5b9c3d8e3e5ce81893771c7cac53f6469aa07;hp=ce2f2cc9f0f94166c2d09565ded2754176af2dd9;hpb=2fe7e96d7e06b93fa953d3b722a25517d5adb31f;p=gacela.git diff --git a/src/gacela_SDL.c b/src/gacela_SDL.c index ce2f2cc..7977444 100644 --- a/src/gacela_SDL.c +++ b/src/gacela_SDL.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "gacela_SDL.h" struct surface @@ -59,6 +60,16 @@ get_surface_address (SCM surface_smob) return surface->surface_address; } +SCM +get_surface_filename (SCM surface_smob) +{ + struct surface *surface; + + scm_assert_smob_type (surface_tag, surface_smob); + surface = (struct surface *) SCM_SMOB_DATA (surface_smob); + return surface->filename; +} + SCM get_surface_width (SCM surface_smob) { @@ -153,6 +164,12 @@ gacela_SDL_SetVideoMode (SCM width, SCM height, SCM bpp, SCM flags) } } +SCM +gacela_SDL_FreeSurface (SCM surface) +{ + return scm_from_int (free_surface (surface)); +} + SCM gacela_SDL_WM_SetCaption (SCM title, SCM icon) { @@ -278,6 +295,19 @@ gacela_SDL_EnableKeyRepeat (SCM delay, SCM interval) return scm_from_int (SDL_EnableKeyRepeat (scm_to_int (delay), scm_to_int (interval))); } +SCM +gacela_zoomSurface (SCM src, SCM zoomx, SCM zoomy, SCM smooth) +{ + SDL_Surface *image = zoomSurface (get_surface_address (src), scm_to_double (zoomx), scm_to_double (zoomy), scm_to_int (smooth)); + + if (image) { + return make_surface (get_surface_filename (src), image); + } + else { + return SCM_BOOL_F; + } +} + SCM gacela_Mix_OpenAudio (SCM frequency, SCM format, SCM channels, SCM chunksize) { @@ -369,6 +399,7 @@ SDL_register_functions (void* data) scm_set_smob_mark (surface_tag, mark_surface); scm_set_smob_free (surface_tag, free_surface); scm_set_smob_print (surface_tag, print_surface); + scm_c_define_gsubr ("surface-file", 1, 0, 0, get_surface_filename); scm_c_define_gsubr ("surface-w", 1, 0, 0, get_surface_width); scm_c_define_gsubr ("surface-h", 1, 0, 0, get_surface_height); scm_c_define_gsubr ("surface-pixels", 1, 0, 0, get_surface_pixels); @@ -440,6 +471,7 @@ SDL_register_functions (void* data) scm_c_define_gsubr ("SDL_Init", 1, 0, 0, gacela_SDL_Init); scm_c_define_gsubr ("SDL_Quit", 0, 0, 0, gacela_SDL_Quit); scm_c_define_gsubr ("SDL_SetVideoMode", 4, 0, 0, gacela_SDL_SetVideoMode); + scm_c_define_gsubr ("SDL_FreeSurface", 1, 0, 0, gacela_SDL_FreeSurface); scm_c_define_gsubr ("SDL_WM_SetCaption", 2, 0, 0, gacela_SDL_WM_SetCaption); scm_c_define_gsubr ("SDL_Flip", 1, 0, 0, gacela_SDL_Flip); scm_c_define_gsubr ("SDL_Delay", 1, 0, 0, gacela_SDL_Delay); @@ -454,6 +486,7 @@ SDL_register_functions (void* data) scm_c_define_gsubr ("SDL_PollEvent", 0, 0, 0, gacela_SDL_PollEvent); scm_c_define_gsubr ("SDL_GL_SwapBuffers", 0, 0, 0, gacela_SDL_GL_SwapBuffers); scm_c_define_gsubr ("SDL_EnableKeyRepeat", 2, 0, 0, gacela_SDL_EnableKeyRepeat); + scm_c_define_gsubr ("zoomSurface", 4, 0, 0, gacela_zoomSurface); scm_c_define_gsubr ("Mix_OpenAudio", 4, 0, 0, gacela_Mix_OpenAudio); scm_c_define_gsubr ("Mix_LoadMUS", 1, 0, 0, gacela_Mix_LoadMUS); scm_c_define_gsubr ("Mix_LoadWAV", 1, 0, 0, gacela_Mix_LoadWAV);