From 6e022fe74edcab8e9b6be32bcfdd7006f478e2ab Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 28 Dec 2013 23:19:55 +0100 Subject: [PATCH] rnd-20131228-1-src * fixed graphical bugs when using renderer/texture based graphics * fixed playing certain sounds (menu navigation sound and counting score sound after solving a level) when "normal sounds" are disabled --- ChangeLog | 7 +++++++ Makefile | 2 +- src/conftime.h | 2 +- src/libgame/misc.c | 10 +++++---- src/libgame/misc.h | 3 +-- src/libgame/sdl.c | 49 +++++++++++++++++++++++++++++++++++++++------ src/libgame/sound.c | 12 +++++++++++ src/tools.c | 2 ++ 8 files changed, 73 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3b6490b..1ae9adc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-12-28 + * fixed graphical bugs when using renderer/texture based graphics + +2013-12-23 + * fixed playing certain sounds (menu navigation sound and counting + score sound after solving a level) when "normal sounds" are disabled + 2013-12-16 * continued porting Rocks'n'Diamonds to Android (levels now playable) diff --git a/Makefile b/Makefile index 96e63039..e24743a5 100644 --- a/Makefile +++ b/Makefile @@ -167,7 +167,7 @@ dist-clean: @$(MAKE_CMD) dist-clean dist-build-unix: - @BUILD_DIST=TRUE $(MAKE) x11 + @BUILD_DIST=TRUE $(MAKE) dist-build-msdos: @BUILD_DIST=TRUE $(MAKE) cross-msdos diff --git a/src/conftime.h b/src/conftime.h index ee032df2..bb577629 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2013-12-17 18:30" +#define COMPILE_DATE_STRING "2013-12-28 23:17" diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 710917a3..d2b7b4e7 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1568,8 +1568,10 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode) { KSYM_Page_Up, "XK_Page_Up", "page up" }, { KSYM_Page_Down, "XK_Page_Down", "page down" }, +#if defined(TARGET_SDL2) { KSYM_Menu, "XK_Menu", "menu" }, /* menu key */ { KSYM_Back, "XK_Back", "back" }, /* back key */ +#endif /* ASCII 0x20 to 0x40 keys (except numbers) */ { KSYM_space, "XK_space", "space" }, @@ -2055,7 +2057,7 @@ int closeFile(File *file) if (file == NULL) return -1; - int result; + int result = 0; #if defined(PLATFORM_ANDROID) if (file->asset_file) @@ -2215,7 +2217,7 @@ int closeDirectory(Directory *dir) if (dir == NULL) return -1; - int result; + int result = 0; #if defined(PLATFORM_ANDROID) if (dir->asset_toc_file) @@ -3782,6 +3784,8 @@ void debug_print_parent_only(char *format, ...) } } +#endif /* DEBUG */ + void print_timestamp_ext(char *message, char *mode) { #if DEBUG_PRINT_INIT_TIMESTAMPS @@ -3845,5 +3849,3 @@ void print_timestamp_done(char *message) { print_timestamp_ext(message, "DONE"); } - -#endif /* DEBUG */ diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 465d30eb..b2d84573 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -297,11 +297,10 @@ void NotifyUserAboutErrorFile(); #if DEBUG void debug_print_timestamp(int, char *); +#endif void print_timestamp_init(char *); void print_timestamp_time(char *); void print_timestamp_done(char *); -#endif /* DEBUG */ - #endif /* MISC_H */ diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index f02264d9..a72bdcc0 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -29,6 +29,8 @@ static SDL_Window *sdl_window = NULL; static SDL_Renderer *sdl_renderer = NULL; static SDL_Texture *sdl_texture = NULL; + +#define USE_RENDERER 1 #endif /* stuff needed to work around SDL/Windows fullscreen drawing bug */ @@ -42,12 +44,29 @@ static int video_yoffset; /* functions from SGE library */ void sge_Line(SDL_Surface *, Sint16, Sint16, Sint16, Sint16, Uint32); +#if defined(TARGET_SDL2) static void UpdateScreen(SDL_Rect *rect) { -#if 1 +#if USE_RENDERER SDL_Surface *screen = backbuffer->surface; +#if 1 + if (rect) + { + int bytes_x = screen->pitch / video.width; + int bytes_y = screen->pitch; + + SDL_UpdateTexture(sdl_texture, rect, + screen->pixels + rect->x * bytes_x + rect->y * bytes_y, + screen->pitch); + } + else + { + SDL_UpdateTexture(sdl_texture, NULL, screen->pixels, screen->pitch); + } +#else SDL_UpdateTexture(sdl_texture, NULL, screen->pixels, screen->pitch); +#endif SDL_RenderClear(sdl_renderer); SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL); SDL_RenderPresent(sdl_renderer); @@ -58,6 +77,7 @@ static void UpdateScreen(SDL_Rect *rect) SDL_UpdateWindowSurface(sdl_window); #endif } +#endif static void setFullscreenParameters(char *fullscreen_mode_string) { @@ -343,7 +363,7 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) new_surface = SDL_GetWindowSurface(sdl_window); // SDL_UpdateWindowSurface(sdl_window); // immediately map window - UpdateScreen(NULL); // immediately map window + // UpdateScreen(NULL); // immediately map window } #else new_surface = SDL_SetVideoMode(fullscreen_width, fullscreen_height, @@ -379,8 +399,8 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) /* switch display to window mode */ #if defined(TARGET_SDL2) -#if 1 - float scale_factor = 1; +#if USE_RENDERER + float scale_factor = 1.2; int test_fullscreen = 0; int surface_flags = (test_fullscreen ? surface_flags_fullscreen : surface_flags_window); @@ -408,11 +428,23 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) if (sdl_texture != NULL) { +#if 1 + // (do not use alpha channel) + new_surface = SDL_CreateRGBSurface(0, video.width, video.height, 32, + 0x00FF0000, + 0x0000FF00, + 0x000000FF, + 0x00000000); +#else + // (this uses an alpha channel, which we don't want here) new_surface = SDL_CreateRGBSurface(0, video.width, video.height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); +#endif + + printf("::: pitch == %d\n", new_surface->pitch); if (new_surface == NULL) Error(ERR_WARN, "SDL_CreateRGBSurface() failed: %s", @@ -444,7 +476,7 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) new_surface = SDL_GetWindowSurface(sdl_window); // SDL_UpdateWindowSurface(sdl_window); // immediately map window - UpdateScreen(NULL); // immediately map window + // UpdateScreen(NULL); // immediately map window } #endif @@ -470,6 +502,10 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) } } +#if defined(TARGET_SDL2) + UpdateScreen(NULL); // map window +#endif + #if 1 SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); @@ -549,7 +585,8 @@ void SDLCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, dst_rect.w = width; dst_rect.h = height; - if (src_bitmap != backbuffer || dst_bitmap != window) + // if (src_bitmap != backbuffer || dst_bitmap != window) + if (!(src_bitmap == backbuffer && dst_bitmap == window)) SDL_BlitSurface((mask_mode == BLIT_MASKED ? src_bitmap->surface_masked : src_bitmap->surface), &src_rect, real_dst_bitmap->surface, &dst_rect); diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 83abf606..adfb8147 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -2190,21 +2190,33 @@ void PlayMusic(int nr) void PlaySound(int nr) { + if (!setup.sound_simple) + return; + PlaySoundExt(nr, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_SOUND); } void PlaySoundStereo(int nr, int stereo_position) { + if (!setup.sound_simple) + return; + PlaySoundExt(nr, SOUND_MAX_VOLUME, stereo_position, SND_CTRL_PLAY_SOUND); } void PlaySoundLoop(int nr) { + if (!setup.sound_loops) + return; + PlaySoundExt(nr, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_LOOP); } void PlaySoundMusic(int nr) { + if (!setup.sound_music) + return; + PlaySoundExt(nr, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_MUSIC); } diff --git a/src/tools.c b/src/tools.c index abde1cc7..bd71d0c5 100644 --- a/src/tools.c +++ b/src/tools.c @@ -4172,7 +4172,9 @@ boolean Request(char *text, unsigned int req_state) break; case KSYM_Escape: +#if defined(TARGET_SDL2) case KSYM_Back: +#endif result = 0; break; -- 2.34.1