From: Holger Schemel Date: Sat, 11 May 2024 11:47:14 +0000 (+0200) Subject: fixed cave flashing on open outbox for non-black cave background color X-Git-Tag: 4.4.0.0-test-2~25 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=a3edb6437b8864290bab53bfc3bd1da9595879c1;p=rocksndiamonds.git fixed cave flashing on open outbox for non-black cave background color --- diff --git a/src/game_bd/bd_graphics.c b/src/game_bd/bd_graphics.c index aa091ba1..96e9b20c 100644 --- a/src/game_bd/bd_graphics.c +++ b/src/game_bd/bd_graphics.c @@ -466,8 +466,14 @@ static Bitmap *get_tile_bitmap_c64(GdCave *cave, SDL_Surface *surface) set_surface_palette_color(surface, 7, 0); set_surface_palette_color(surface, 8, 0); + // set background color to be transparent for masked tile bitmap + int bg_color = gd_color_get_rgb(cave->color0); + int bg_r = gd_color_get_r(bg_color); + int bg_g = gd_color_get_g(bg_color); + int bg_b = gd_color_get_b(bg_color); + // create bitmap from C64 surface - tile_bitmap_c64 = SDLGetBitmapFromSurface(surface); + tile_bitmap_c64 = SDLGetBitmapFromSurface_WithMaskedColor(surface, bg_r, bg_g, bg_b); return tile_bitmap_c64; } diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index a19defa3..d664eecc 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -502,7 +502,7 @@ SDL_Surface *SDLCreateNativeSurface(int width, int height, int depth) return surface; } -Bitmap *SDLGetBitmapFromSurface(SDL_Surface *surface) +Bitmap *SDLGetBitmapFromSurface_WithMaskedColor(SDL_Surface *surface, int r, int g, int b) { int width = surface->w; int height = surface->h; @@ -522,11 +522,16 @@ Bitmap *SDLGetBitmapFromSurface(SDL_Surface *surface) if (!SDLHasAlpha(bitmap->surface_masked) && !SDLHasColorKey(bitmap->surface_masked)) SDL_SetColorKey(bitmap->surface_masked, SET_TRANSPARENT_PIXEL, - SDL_MapRGB(bitmap->surface_masked->format, 0x00, 0x00, 0x00)); + SDL_MapRGB(bitmap->surface_masked->format, r, g, b)); return bitmap; } +Bitmap *SDLGetBitmapFromSurface(SDL_Surface *surface) +{ + return SDLGetBitmapFromSurface_WithMaskedColor(surface, 0x00, 0x00, 0x00); +} + static SDL_Texture *SDLCreateTextureFromSurface(SDL_Surface *surface) { if (program.headless) diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index bbbaa767..1545f686 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -400,6 +400,7 @@ const char *SDLGetRendererName(void); boolean SDLSetNativeSurface(SDL_Surface **); SDL_Surface *SDLGetNativeSurface(SDL_Surface *); SDL_Surface *SDLCreateNativeSurface(int, int, int); +Bitmap *SDLGetBitmapFromSurface_WithMaskedColor(SDL_Surface *, int, int, int); Bitmap *SDLGetBitmapFromSurface(SDL_Surface *); void SDLCreateBitmapTextures(Bitmap *); void SDLFreeBitmapTextures(Bitmap *);