From b235ad16c588a7d79035035035467b70bc77ac76 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Thu, 3 Oct 2024 17:33:43 +0200 Subject: [PATCH] removed obsolete code for old BD style color template support --- src/conf_gfx.c | 3 -- src/game_bd/bd_graphics.c | 78 ++------------------------------------- src/game_bd/bd_graphics.h | 4 -- src/game_bd/export_bd.h | 6 --- src/game_bd/main_bd.c | 36 ------------------ src/main.c | 5 --- src/main.h | 3 +- src/tools.c | 55 --------------------------- 8 files changed, 5 insertions(+), 185 deletions(-) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index cf373278..6671e7fe 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -6950,9 +6950,6 @@ struct ConfigInfo image_config[] = { "graphic_7", UNDEFINED_FILENAME }, { "graphic_8", UNDEFINED_FILENAME }, - // game graphics template for level-specific colors for native BD levels - { "bdx_game_graphics_color_template", UNDEFINED_FILENAME }, - #include "conf_chr.c" // include auto-generated data structure definitions #include "conf_cus.c" // include auto-generated data structure definitions #include "conf_grp.c" // include auto-generated data structure definitions diff --git a/src/game_bd/bd_graphics.c b/src/game_bd/bd_graphics.c index 873efad8..6824328d 100644 --- a/src/game_bd/bd_graphics.c +++ b/src/game_bd/bd_graphics.c @@ -39,11 +39,6 @@ #define GD_KEY_CHAR 12 #define GD_COMMENT_CHAR 13 -// pointer to tile bitmap (which may be prepared with level-specific colors) -static Bitmap *gd_tile_bitmap = NULL; -// pointer to reference tile bitmap (without level-specific colors) -static Bitmap *gd_tile_bitmap_reference = NULL; - // optional title screen bitmaps (foreground and background) static Bitmap *gd_title_screen_bitmaps[2] = { NULL, NULL }; @@ -62,8 +57,6 @@ static int cell_size = 0; // graphic info for game objects/frames and players/actions/frames struct GraphicInfo_BD graphic_info_bd_object[O_MAX_ALL][8]; -// graphic info for game graphics template for level-specific colors -struct GraphicInfo_BD graphic_info_bd_color_template; static inline int c64_png_colors(int r, int g, int b, int a) { @@ -368,11 +361,6 @@ static boolean surface_has_c64_colors(SDL_Surface *surface) return has_c64_colors; } -boolean gd_bitmap_has_c64_colors(Bitmap *bitmap) -{ - return surface_has_c64_colors(bitmap->surface); -} - // sets one of the colors in the indexed palette of an sdl surface to a GdColor. static void set_surface_palette_color(SDL_Surface *surface, int index, GdColor col) { @@ -488,60 +476,6 @@ static Bitmap *get_tile_bitmap_c64(GdCave *cave, SDL_Surface *surface) return tile_bitmap_c64; } -void gd_prepare_tile_bitmap(GdCave *cave, Bitmap *bitmap, int scale_down_factor) -{ - static SDL_Surface *tile_surface_c64 = NULL; - static Bitmap *gd_tile_bitmap_original = NULL; - static int scale_down_factor_last = -1; - - if (program.headless) - return; - - // check if tile bitmap has changed (different artwork or tile size selected) - if (bitmap != gd_tile_bitmap_original || scale_down_factor != scale_down_factor_last) - { - // check if tile bitmap has limited C64 style colors - tile_surface_c64 = get_tile_surface_c64(bitmap->surface, scale_down_factor); - - // store original tile bitmap from current artwork set and scaling factor - gd_tile_bitmap_original = bitmap; - scale_down_factor_last = scale_down_factor; - - // store reference tile bitmap from current artwork set (may be changed later) - gd_tile_bitmap_reference = bitmap; - } - - // check if tile bitmap should be colored for next game - if (tile_surface_c64 != NULL) - { - // set tile bitmap to bitmap with level-specific colors - gd_tile_bitmap = get_tile_bitmap_c64(cave, tile_surface_c64); - } - else - { - // no special tile bitmap available for this artwork set - gd_tile_bitmap = NULL; - } -} - -void gd_set_tile_bitmap_reference(Bitmap *bitmap) -{ - gd_tile_bitmap_reference = bitmap; -} - -Bitmap *gd_get_tile_bitmap(Bitmap *bitmap) -{ - // if no special tile bitmap available, keep using default tile bitmap - if (gd_tile_bitmap == NULL) - return bitmap; - - // if default bitmap refers to tile bitmap, use special tile bitmap - if (bitmap == gd_tile_bitmap_reference) - return gd_tile_bitmap; - - return bitmap; -} - Bitmap *gd_get_colored_bitmap_from_template(Bitmap *template_bitmap) { SDL_Surface *template_surface = get_tile_surface_c64(template_bitmap->surface, 1); @@ -795,9 +729,8 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d if (!is_moving || !use_smooth_movements) { struct GraphicInfo_BD *g = &graphic_info_bd_object[draw][frame]; - Bitmap *tile_bitmap = gd_get_tile_bitmap(g->bitmap); - blit_bitmap(tile_bitmap, dest, g->src_x, g->src_y, cell_size, cell_size, sx, sy); + blit_bitmap(g->bitmap, dest, g->src_x, g->src_y, cell_size, cell_size, sx, sy); return; } @@ -812,9 +745,8 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d boolean digging_tile = ((el_can_dig(tile) || tile == O_SPACE) && el_diggable(tile_last)); int draw_back = (!is_moving_to ? draw : digging_tile ? draw_last : O_SPACE); struct GraphicInfo_BD *g = &graphic_info_bd_object[draw_back][frame]; - Bitmap *tile_bitmap = gd_get_tile_bitmap(g->bitmap); - blit_bitmap(tile_bitmap, dest, g->src_x, g->src_y, cell_size, cell_size, sx, sy); + blit_bitmap(g->bitmap, dest, g->src_x, g->src_y, cell_size, cell_size, sx, sy); } // get shifted position between cave fields the game element is moving from/to @@ -826,7 +758,6 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d if (is_moving_from && !is_diagonal_movement_from) // skip if source moving diagonally { struct GraphicInfo_BD *g = &graphic_info_bd_object[draw_from][frame]; - Bitmap *tile_bitmap = gd_get_tile_bitmap(g->bitmap); int xsize = (dx_from != 0 ? shift : cell_size); int ysize = (dy_from != 0 ? shift : cell_size); int gx = g->src_x + (dx_from < 0 ? cell_size - shift : 0); @@ -837,7 +768,7 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d if (!el_diggable(tile)) blit_bitmap = BlitBitmapMasked; - blit_bitmap(tile_bitmap, dest, gx, gy, xsize, ysize, tx, ty); + blit_bitmap(g->bitmap, dest, gx, gy, xsize, ysize, tx, ty); // when using dynamic scheduling (mainly BD1 levels), redraw tile in next frame game->gfx_buffer[y][x] |= GD_REDRAW; @@ -851,7 +782,6 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d dx_to = dy_to = 0; struct GraphicInfo_BD *g = &graphic_info_bd_object[draw_to][frame]; - Bitmap *tile_bitmap = gd_get_tile_bitmap(g->bitmap); int xsize = (dx_to != 0 ? cell_size - shift : cell_size); int ysize = (dy_to != 0 ? cell_size - shift : cell_size); int gx = g->src_x + (dx_to > 0 ? shift : 0); @@ -870,7 +800,7 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d gy = (dy_to != 0 ? shift - gy : gy); } - blit_bitmap(tile_bitmap, dest, gx, gy, xsize, ysize, tx, ty); + blit_bitmap(g->bitmap, dest, gx, gy, xsize, ysize, tx, ty); // when using dynamic scheduling (mainly BD1 levels), redraw tile in next frame game->gfx_buffer[y][x] |= GD_REDRAW; diff --git a/src/game_bd/bd_graphics.h b/src/game_bd/bd_graphics.h index 0799b6c7..9b1bf540 100644 --- a/src/game_bd/bd_graphics.h +++ b/src/game_bd/bd_graphics.h @@ -33,10 +33,6 @@ int get_play_area_h(void); void gd_init_play_area(void); -boolean gd_bitmap_has_c64_colors(Bitmap *bitmap); -void gd_prepare_tile_bitmap(GdCave *cave, Bitmap *bitmap, int scale_down_factor); -void gd_set_tile_bitmap_reference(Bitmap *bitmap); -Bitmap *gd_get_tile_bitmap(Bitmap *bitmap); Bitmap *gd_get_colored_bitmap_from_template(Bitmap *template_bitmap); int gd_drawcave(Bitmap *dest, GdGame *gameplay, boolean); diff --git a/src/game_bd/export_bd.h b/src/game_bd/export_bd.h index 65a06c95..5bf81e61 100644 --- a/src/game_bd/export_bd.h +++ b/src/game_bd/export_bd.h @@ -105,7 +105,6 @@ struct EngineSnapshotInfo_BD extern struct GameInfo_BD game_bd; extern struct LevelInfo_BD native_bd_level; extern struct GraphicInfo_BD graphic_info_bd_object[O_MAX_ALL][8]; -extern struct GraphicInfo_BD graphic_info_bd_color_template; extern struct EngineSnapshotInfo_BD engine_snapshot_bd; void bd_open_all(void); @@ -130,9 +129,6 @@ boolean LoadNativeLevel_BD(char *, int, boolean); boolean SaveNativeLevel_BD(char *); void DumpLevelset_BD(void); -void PreparePreviewTileBitmap_BD(Bitmap *, int); -void SetPreviewTileBitmapReference_BD(Bitmap *); -Bitmap *GetPreviewTileBitmap_BD(Bitmap *); Bitmap *GetColoredBitmapFromTemplate_BD(Bitmap *); unsigned int InitEngineRandom_BD(int); @@ -145,8 +141,6 @@ boolean use_bd_pushing_graphics(void); boolean use_bd_up_down_graphics(void); boolean use_bd_falling_sounds(void); -boolean hasColorTemplate_BD(void); - Bitmap **GetTitleScreenBitmaps_BD(void); void CoverScreen_BD(void); diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index 0912b417..336a9424 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -286,34 +286,6 @@ static void UpdateGameDoorValues_BD(void) } } -static void PrepareGameTileBitmap_BD(void) -{ - struct GraphicInfo_BD *g_template = &graphic_info_bd_color_template; - struct GraphicInfo_BD *g_default = &graphic_info_bd_object[O_STONE][0]; - - // prepare bitmap using cave ready for playing (may have changed colors) - gd_prepare_tile_bitmap(game_bd.game->cave, g_template->bitmap, 1); - - // set reference bitmap which should be replaced with prepared bitmap - gd_set_tile_bitmap_reference(g_default->bitmap); -} - -void PreparePreviewTileBitmap_BD(Bitmap *bitmap, int scale_down_factor) -{ - // prepare bitmap using cave from file (with originally defined colors) - gd_prepare_tile_bitmap(native_bd_level.cave, bitmap, scale_down_factor); -} - -void SetPreviewTileBitmapReference_BD(Bitmap *bitmap) -{ - gd_set_tile_bitmap_reference(bitmap); -} - -Bitmap *GetPreviewTileBitmap_BD(Bitmap *bitmap) -{ - return gd_get_tile_bitmap(bitmap); -} - Bitmap *GetColoredBitmapFromTemplate_BD(Bitmap *bitmap) { return gd_get_colored_bitmap_from_template(bitmap); @@ -367,9 +339,6 @@ void InitGameEngine_BD(void) // first iteration loads and prepares the cave (may change colors) play_game_func(game_bd.game, 0); - // prepare tile bitmap with level-specific colors, if available - PrepareGameTileBitmap_BD(); - // fast-forward game engine to selected state (covered or uncovered) while (game_bd.game->state_counter < next_state) play_game_func(game_bd.game, 0); @@ -507,11 +476,6 @@ boolean use_bd_falling_sounds(void) (setup.bd_falling_sounds == STATE_AUTO && game.use_native_bd_sound_engine)); } -boolean hasColorTemplate_BD(void) -{ - return gd_bitmap_has_c64_colors(graphic_info_bd_color_template.bitmap); -} - Bitmap **GetTitleScreenBitmaps_BD(void) { Bitmap **title_screen_bitmaps = gd_get_title_screen_bitmaps(); diff --git a/src/main.c b/src/main.c index ea86e5d7..693553e8 100644 --- a/src/main.c +++ b/src/main.c @@ -8883,11 +8883,6 @@ struct ElementNameInfo element_name_info[MAX_NUM_ELEMENTS + 1] = "graphic", "-" }, - { - "bdx_game_graphics_color_template", - "-", - "-" - }, { "internal_clipboard_custom", "internal", diff --git a/src/main.h b/src/main.h index 129373f6..5a5e89fd 100644 --- a/src/main.h +++ b/src/main.h @@ -2604,10 +2604,9 @@ #define EL_GRAPHIC_6 (EL_FIRST_DUMMY + 35) #define EL_GRAPHIC_7 (EL_FIRST_DUMMY + 36) #define EL_GRAPHIC_8 (EL_FIRST_DUMMY + 37) -#define EL_BDX_GAME_GRAPHICS_COLOR_TEMPLATE (EL_FIRST_DUMMY + 38) // internal elements (only used for internal purposes like copying) -#define EL_FIRST_INTERNAL (EL_FIRST_DUMMY + 39) +#define EL_FIRST_INTERNAL (EL_FIRST_DUMMY + 38) #define EL_INTERNAL_CLIPBOARD_CUSTOM (EL_FIRST_INTERNAL + 0) #define EL_INTERNAL_CLIPBOARD_CHANGE (EL_FIRST_INTERNAL + 1) diff --git a/src/tools.c b/src/tools.c index 626f7dc8..460bf148 100644 --- a/src/tools.c +++ b/src/tools.c @@ -3398,14 +3398,6 @@ static void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) game.envelope_active = FALSE; } -static Bitmap *GetPreviewTileBitmap(Bitmap *bitmap) -{ - if (level.game_engine_type == GAME_ENGINE_TYPE_BD) - return GetPreviewTileBitmap_BD(bitmap); - - return bitmap; -} - static void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize) { if (IS_MM_WALL(element)) @@ -3420,9 +3412,6 @@ static void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize) getSizedGraphicSource(graphic, 0, tilesize, &src_bitmap, &src_x, &src_y); - // for BD style levels, maybe use bitmap with level-specific colors - src_bitmap = GetPreviewTileBitmap(src_bitmap); - BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize, tilesize, dst_x, dst_y); } @@ -3845,35 +3834,8 @@ void DrawPreviewPlayers(void) } } -static void PreparePreviewTileBitmap(void) -{ - // check if special preview bitmap with level-specific colors should be created - if (level.game_engine_type != GAME_ENGINE_TYPE_BD) - return; - - // use original sized bitmap (else reduced color palette is lost by downscaling) - int original_tilesize = MAX(MINI_TILESIZE, preview.tile_size); - int scale_down_factor = original_tilesize / preview.tile_size; - Bitmap *src_bitmap; - int src_x, src_y; - int element_template = EL_BDX_GAME_GRAPHICS_COLOR_TEMPLATE; - int graphic_template = el2preimg(element_template); - int element_default = EL_BDX_ROCK; - int graphic_default = el2preimg(element_default); - - // create special preview bitmap and scale it down to preview tile size - getSizedGraphicSource(graphic_template, 0, original_tilesize, &src_bitmap, &src_x, &src_y); - PreparePreviewTileBitmap_BD(src_bitmap, scale_down_factor); - - // force using special preview bitmap to replace original preview bitmap - getSizedGraphicSource(graphic_default, 0, preview.tile_size, &src_bitmap, &src_x, &src_y); - SetPreviewTileBitmapReference_BD(src_bitmap); -} - void DrawPreviewLevelInitial(void) { - PreparePreviewTileBitmap(); // only needed for native BD style levels - DrawPreviewLevelExt(TRUE); DrawPreviewPlayers(); } @@ -11146,23 +11108,6 @@ void InitGraphicInfo_BD(void) g_bd->frame = frame; } } - - // game graphics template for level-specific colors for native BD levels - int graphic = IMG_BDX_GAME_GRAPHICS_COLOR_TEMPLATE; - struct GraphicInfo_BD *g_bd = &graphic_info_bd_color_template; - Bitmap *src_bitmap; - int src_x, src_y; - - getGraphicSourceExt(graphic, 0, &src_bitmap, &src_x, &src_y, FALSE); - - g_bd->bitmap = src_bitmap; - g_bd->src_x = src_x; - g_bd->src_y = src_y; - g_bd->width = TILEX; - g_bd->height = TILEY; - - g_bd->graphic = graphic; - g_bd->frame = 0; } void InitGraphicInfo_EM(void) -- 2.34.1