From b76889239e7041c1e59577af20be502bc135d242 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 18 Jan 2025 11:45:59 +0100 Subject: [PATCH] replaced single level color variables with arrays --- src/editor.c | 78 ++++++---------- src/files.c | 108 ++++++++-------------- src/game_bd/bd_bdcff.c | 78 ++++++++-------- src/game_bd/bd_c64import.c | 178 ++++++++++++++++++------------------- src/game_bd/bd_cave.c | 63 ++++++------- src/game_bd/bd_cave.h | 15 +--- src/game_bd/bd_cavedb.c | 32 +++---- src/game_bd/bd_caveset.c | 18 ++-- src/game_bd/bd_graphics.c | 30 +++---- src/libgame/system.h | 3 + src/main.h | 18 +--- 11 files changed, 271 insertions(+), 350 deletions(-) diff --git a/src/editor.c b/src/editor.c index fbca3f64..ac538008 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1810,7 +1810,7 @@ static boolean levelset_use_levelset_artwork = FALSE; static boolean levelset_copy_level_template = FALSE; static int levelset_save_mode = LEVELSET_SAVE_MODE_UPDATE; -#define MAX_BD_COLORS 8 +#define MAX_BD_COLORS MAX_LEVEL_COLORS #define MAX_BD_COLOR_TEXT_LEN 12 #define MAX_BD_RGB_COLOR_TEXT_LEN 7 @@ -1822,25 +1822,25 @@ static char bd_base_color_text[MAX_BD_COLORS][MAX_BD_RGB_COLOR_TEXT_LEN + 1]; static int bd_color_default[MAX_BD_COLORS]; static int *bd_color[MAX_BD_COLORS] = { - &level.bd_color_0, - &level.bd_color_1, - &level.bd_color_2, - &level.bd_color_3, - &level.bd_color_4, - &level.bd_color_5, - &level.bd_color_6, - &level.bd_color_7, + &level.bd_color[0], + &level.bd_color[1], + &level.bd_color[2], + &level.bd_color[3], + &level.bd_color[4], + &level.bd_color[5], + &level.bd_color[6], + &level.bd_color[7], }; static int *bd_base_color[MAX_BD_COLORS] = { - &level.bd_base_color_0, - &level.bd_base_color_1, - &level.bd_base_color_2, - &level.bd_base_color_3, - &level.bd_base_color_4, - &level.bd_base_color_5, - &level.bd_base_color_6, - &level.bd_base_color_7, + &level.bd_base_color[0], + &level.bd_base_color[1], + &level.bd_base_color[2], + &level.bd_base_color[3], + &level.bd_base_color[4], + &level.bd_base_color[5], + &level.bd_base_color[6], + &level.bd_base_color[7], }; static struct @@ -12321,50 +12321,30 @@ void SetCurrentLevelColors_BD(void) { struct LevelInfo_BD *level_bd = level.native_bd_level; GdCave *cave = level_bd->cave; + int i; - cave->color0 = level.bd_color_0; - cave->color1 = level.bd_color_1; - cave->color2 = level.bd_color_2; - cave->color3 = level.bd_color_3; - cave->color4 = level.bd_color_4; - cave->color5 = level.bd_color_5; - cave->color6 = level.bd_color_6; - cave->color7 = level.bd_color_7; - cave->base_color0 = level.bd_base_color_0; - cave->base_color1 = level.bd_base_color_1; - cave->base_color2 = level.bd_base_color_2; - cave->base_color3 = level.bd_base_color_3; - cave->base_color4 = level.bd_base_color_4; - cave->base_color5 = level.bd_base_color_5; - cave->base_color6 = level.bd_base_color_6; - cave->base_color7 = level.bd_base_color_7; + for (i = 0; i < MAX_LEVEL_COLORS; i++) + { + cave->color[i] = level.bd_color[i]; + cave->base_color[i] = level.bd_base_color[i]; + } } void SetRandomLevelColors_BD(int bd_color_type) { struct LevelInfo_BD *level_bd = level.native_bd_level; GdCave *cave = level_bd->cave; + int i; // create random cave colors gd_cave_set_random_colors(cave, bd_color_type); // copy colors to level editor - level.bd_color_0 = cave->color0; - level.bd_color_1 = cave->color1; - level.bd_color_2 = cave->color2; - level.bd_color_3 = cave->color3; - level.bd_color_4 = cave->color4; - level.bd_color_5 = cave->color5; - level.bd_color_6 = cave->color6; - level.bd_color_7 = cave->color7; - level.bd_base_color_0 = cave->base_color0; - level.bd_base_color_1 = cave->base_color1; - level.bd_base_color_2 = cave->base_color2; - level.bd_base_color_3 = cave->base_color3; - level.bd_base_color_4 = cave->base_color4; - level.bd_base_color_5 = cave->base_color5; - level.bd_base_color_6 = cave->base_color6; - level.bd_base_color_7 = cave->base_color7; + for (i = 0; i < MAX_LEVEL_COLORS; i++) + { + level.bd_color[i] = cave->color[i]; + level.bd_base_color[i] = cave->base_color[i]; + } } static void DrawColorBox_BD(int type_id) diff --git a/src/files.c b/src/files.c index 020d7492..fdcd8e9a 100644 --- a/src/files.c +++ b/src/files.c @@ -330,82 +330,82 @@ static struct LevelFileConfigInfo chunk_config_INFO[] = { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(4), - &li.bd_color_0, GD_C64_COLOR_BLACK + &li.bd_color[0], GD_C64_COLOR_BLACK }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(5), - &li.bd_color_1, GD_C64_COLOR_ORANGE + &li.bd_color[1], GD_C64_COLOR_ORANGE }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(6), - &li.bd_color_2, GD_C64_COLOR_GRAY1 + &li.bd_color[2], GD_C64_COLOR_GRAY1 }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(7), - &li.bd_color_3, GD_C64_COLOR_WHITE + &li.bd_color[3], GD_C64_COLOR_WHITE }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(8), - &li.bd_color_4, GD_C64_COLOR_GREEN + &li.bd_color[4], GD_C64_COLOR_GREEN }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(9), - &li.bd_color_5, GD_C64_COLOR_BLUE + &li.bd_color[5], GD_C64_COLOR_BLUE }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(10), - &li.bd_color_6, GD_C64_COLOR_GRAY2 + &li.bd_color[6], GD_C64_COLOR_GRAY2 }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(11), - &li.bd_color_7, GD_C64_COLOR_WHITE + &li.bd_color[7], GD_C64_COLOR_WHITE }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(12), - &li.bd_base_color_0, GD_C64_COLOR_BLACK + &li.bd_base_color[0], GD_C64_COLOR_BLACK }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(13), - &li.bd_base_color_1, GD_C64_COLOR_BLACK + &li.bd_base_color[1], GD_C64_COLOR_BLACK }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(14), - &li.bd_base_color_2, GD_C64_COLOR_BLACK + &li.bd_base_color[2], GD_C64_COLOR_BLACK }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(15), - &li.bd_base_color_3, GD_C64_COLOR_BLACK + &li.bd_base_color[3], GD_C64_COLOR_BLACK }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(16), - &li.bd_base_color_4, GD_C64_COLOR_BLACK + &li.bd_base_color[4], GD_C64_COLOR_BLACK }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(17), - &li.bd_base_color_5, GD_C64_COLOR_BLACK + &li.bd_base_color[5], GD_C64_COLOR_BLACK }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(18), - &li.bd_base_color_6, GD_C64_COLOR_BLACK + &li.bd_base_color[6], GD_C64_COLOR_BLACK }, { -1, -1, TYPE_INTEGER, CONF_VALUE_32_BIT(19), - &li.bd_base_color_7, GD_C64_COLOR_BLACK + &li.bd_base_color[7], GD_C64_COLOR_BLACK }, { @@ -4379,7 +4379,7 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level) GdCave *cave = NULL; // will be changed below int cave_w = MIN(level->fieldx, MAX_PLAYFIELD_WIDTH); int cave_h = MIN(level->fieldy, MAX_PLAYFIELD_HEIGHT); - int x, y; + int i, x, y; setLevelInfoToDefaults_BD_Ext(cave_w, cave_h); @@ -4545,23 +4545,13 @@ static void CopyNativeLevel_RND_to_BD(struct LevelInfo *level) cave->explosion_effect = LEVEL_TO_CAVE(level->bd_explosion_turns_to); cave->explosion_3_effect = LEVEL_TO_CAVE(level->bd_explosion_3_turns_to); - cave->colorb = level->bd_color_b; - cave->color0 = level->bd_color_0; - cave->color1 = level->bd_color_1; - cave->color2 = level->bd_color_2; - cave->color3 = level->bd_color_3; - cave->color4 = level->bd_color_4; - cave->color5 = level->bd_color_5; - cave->color6 = level->bd_color_6; - cave->color7 = level->bd_color_7; - cave->base_color0 = level->bd_base_color_0; - cave->base_color1 = level->bd_base_color_1; - cave->base_color2 = level->bd_base_color_2; - cave->base_color3 = level->bd_base_color_3; - cave->base_color4 = level->bd_base_color_4; - cave->base_color5 = level->bd_base_color_5; - cave->base_color6 = level->bd_base_color_6; - cave->base_color7 = level->bd_base_color_7; + cave->color_b = level->bd_color_b; + + for (i = 0; i < MAX_LEVEL_COLORS; i++) + { + cave->color[i] = level->bd_color[i]; + cave->base_color[i] = level->bd_base_color[i]; + } // level name strncpy(cave->name, level->name, sizeof(GdString)); @@ -4578,7 +4568,7 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level) struct LevelInfo_BD *level_bd = level->native_bd_level; GdCave *cave = level_bd->cave; int bd_level_nr = level_bd->level_nr; - int x, y; + int i, x, y; level->fieldx = MIN(cave->w, MAX_LEV_FIELDX); level->fieldy = MIN(cave->h, MAX_LEV_FIELDY); @@ -4743,23 +4733,13 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level) level->bd_explosion_turns_to = CAVE_TO_LEVEL(cave->explosion_effect); level->bd_explosion_3_turns_to = CAVE_TO_LEVEL(cave->explosion_3_effect); - level->bd_color_b = cave->colorb; - level->bd_color_0 = cave->color0; - level->bd_color_1 = cave->color1; - level->bd_color_2 = cave->color2; - level->bd_color_3 = cave->color3; - level->bd_color_4 = cave->color4; - level->bd_color_5 = cave->color5; - level->bd_color_6 = cave->color6; - level->bd_color_7 = cave->color7; - level->bd_base_color_0 = cave->base_color0; - level->bd_base_color_1 = cave->base_color1; - level->bd_base_color_2 = cave->base_color2; - level->bd_base_color_3 = cave->base_color3; - level->bd_base_color_4 = cave->base_color4; - level->bd_base_color_5 = cave->base_color5; - level->bd_base_color_6 = cave->base_color6; - level->bd_base_color_7 = cave->base_color7; + level->bd_color_b = cave->color_b; + + for (i = 0; i < MAX_LEVEL_COLORS; i++) + { + level->bd_color[i] = cave->color[i]; + level->bd_base_color[i] = cave->base_color[i]; + } // set default template coloring type for BD style level colors level->bd_coloring_type = GD_COLORING_TYPE_SINGLE; @@ -7967,26 +7947,16 @@ static void LoadLevel_InitSettings_SB(struct LevelInfo *level) static void LoadLevel_InitColorSettings(struct LevelInfo *level) { GdCave *cave = level->native_bd_level->cave; + int i; // copy level colors to native BD level // (this workaround is needed as long as color template handling is still BD specific) - cave->colorb = level->bd_color_b; - cave->color0 = level->bd_color_0; - cave->color1 = level->bd_color_1; - cave->color2 = level->bd_color_2; - cave->color3 = level->bd_color_3; - cave->color4 = level->bd_color_4; - cave->color5 = level->bd_color_5; - cave->color6 = level->bd_color_6; - cave->color7 = level->bd_color_7; - cave->base_color0 = level->bd_base_color_0; - cave->base_color1 = level->bd_base_color_1; - cave->base_color2 = level->bd_base_color_2; - cave->base_color3 = level->bd_base_color_3; - cave->base_color4 = level->bd_base_color_4; - cave->base_color5 = level->bd_base_color_5; - cave->base_color6 = level->bd_base_color_6; - cave->base_color7 = level->bd_base_color_7; + cave->color_b = level->bd_color_b; + for (i = 0; i < MAX_LEVEL_COLORS; i++) + { + cave->color[i] = level->bd_color[i]; + cave->base_color[i] = level->bd_base_color[i]; + } // set default color type and colors for BD style level colors SetDefaultLevelColorType_BD(); diff --git a/src/game_bd/bd_bdcff.c b/src/game_bd/bd_bdcff.c index 09b14f26..56ab2790 100644 --- a/src/game_bd/bd_bdcff.c +++ b/src/game_bd/bd_bdcff.c @@ -475,42 +475,42 @@ static boolean cave_process_tags_func(const char *attrib, const char *param, GdC if (paramcount == 3) { - // only color1,2,3 - cave->colorb = gd_c64_color(0); // border - black - cave->color0 = gd_c64_color(0); // background - black - cave->color1 = gd_color_get_from_string(params[0]); - cave->color2 = gd_color_get_from_string(params[1]); - cave->color3 = gd_color_get_from_string(params[2]); - cave->color4 = cave->color3; // amoeba - cave->color5 = cave->color1; // slime - cave->color6 = gd_c64_color(12); // extra color 1 - gray - cave->color7 = gd_c64_color(1); // extra color 2 - white + // only colors 1,2,3 + cave->color_b = gd_c64_color(0); // border - black + cave->color[0] = gd_c64_color(0); // background - black + cave->color[1] = gd_color_get_from_string(params[0]); + cave->color[2] = gd_color_get_from_string(params[1]); + cave->color[3] = gd_color_get_from_string(params[2]); + cave->color[4] = cave->color[3]; // amoeba + cave->color[5] = cave->color[1]; // slime + cave->color[6] = gd_c64_color(12); // extra color 1 - gray + cave->color[7] = gd_c64_color(1); // extra color 2 - white } else if (paramcount == 5) { - // bg,color0,1,2,3 - cave->colorb = gd_color_get_from_string(params[0]); - cave->color0 = gd_color_get_from_string(params[1]); - cave->color1 = gd_color_get_from_string(params[2]); - cave->color2 = gd_color_get_from_string(params[3]); - cave->color3 = gd_color_get_from_string(params[4]); - cave->color4 = cave->color3; // amoeba - cave->color5 = cave->color1; // slime - cave->color6 = gd_c64_color(12); // extra color 1 - gray - cave->color7 = gd_c64_color(1); // extra color 2 - white + // bg, color 0,1,2,3 + cave->color_b = gd_color_get_from_string(params[0]); + cave->color[0] = gd_color_get_from_string(params[1]); + cave->color[1] = gd_color_get_from_string(params[2]); + cave->color[2] = gd_color_get_from_string(params[3]); + cave->color[3] = gd_color_get_from_string(params[4]); + cave->color[4] = cave->color[3]; // amoeba + cave->color[5] = cave->color[1]; // slime + cave->color[6] = gd_c64_color(12); // extra color 1 - gray + cave->color[7] = gd_c64_color(1); // extra color 2 - white } else if (paramcount == 7) { - // bg,color0,1,2,3,amoeba,slime - cave->colorb = gd_color_get_from_string(params[0]); - cave->color0 = gd_color_get_from_string(params[1]); - cave->color1 = gd_color_get_from_string(params[2]); - cave->color2 = gd_color_get_from_string(params[3]); - cave->color3 = gd_color_get_from_string(params[4]); - cave->color4 = gd_color_get_from_string(params[5]); // amoeba - cave->color5 = gd_color_get_from_string(params[6]); // slime - cave->color6 = gd_c64_color(12); // extra color 1 - gray - cave->color7 = gd_c64_color(1); // extra color 2 - white + // bg, color 0,1,2,3, amoeba, slime + cave->color_b = gd_color_get_from_string(params[0]); + cave->color[0] = gd_color_get_from_string(params[1]); + cave->color[1] = gd_color_get_from_string(params[2]); + cave->color[2] = gd_color_get_from_string(params[3]); + cave->color[3] = gd_color_get_from_string(params[4]); + cave->color[4] = gd_color_get_from_string(params[5]); // amoeba + cave->color[5] = gd_color_get_from_string(params[6]); // slime + cave->color[6] = gd_c64_color(12); // extra color 1 - gray + cave->color[7] = gd_c64_color(1); // extra color 2 - white } else { @@ -521,15 +521,15 @@ static boolean cave_process_tags_func(const char *attrib, const char *param, GdC // now check and maybe make up some new. if (!ok || - gd_color_is_unknown(cave->colorb) || - gd_color_is_unknown(cave->color0) || - gd_color_is_unknown(cave->color1) || - gd_color_is_unknown(cave->color2) || - gd_color_is_unknown(cave->color3) || - gd_color_is_unknown(cave->color4) || - gd_color_is_unknown(cave->color5) || - gd_color_is_unknown(cave->color6) || - gd_color_is_unknown(cave->color7)) + gd_color_is_unknown(cave->color_b) || + gd_color_is_unknown(cave->color[0]) || + gd_color_is_unknown(cave->color[1]) || + gd_color_is_unknown(cave->color[2]) || + gd_color_is_unknown(cave->color[3]) || + gd_color_is_unknown(cave->color[4]) || + gd_color_is_unknown(cave->color[5]) || + gd_color_is_unknown(cave->color[6]) || + gd_color_is_unknown(cave->color[7])) { Warn("created a new C64 color scheme."); diff --git a/src/game_bd/bd_c64import.c b/src/game_bd/bd_c64import.c index 988f3108..de0a10c8 100644 --- a/src/game_bd/bd_c64import.c +++ b/src/game_bd/bd_c64import.c @@ -823,28 +823,28 @@ static int cave_copy_from_bd1(GdCave *cave, const byte *data, int remaining_byte if (format == GD_FORMAT_BD1_ATARI) { // atari colors - cave->color1 = gd_atari_color(data[0x13]); - cave->color2 = gd_atari_color(data[0x14]); - cave->color3 = gd_atari_color(data[0x15]); - cave->color4 = gd_atari_color(data[0x16]); // in atari, amoeba was green - cave->color5 = gd_atari_color(data[0x16]); // in atari, slime was green - cave->colorb = gd_atari_color(data[0x17]); // border = background - cave->color0 = gd_atari_color(data[0x17]); // background - cave->color6 = gd_atari_color(8); // extra color 1 - gray - cave->color7 = gd_atari_color(15); // extra color 2 - white + cave->color[1] = gd_atari_color(data[0x13]); + cave->color[2] = gd_atari_color(data[0x14]); + cave->color[3] = gd_atari_color(data[0x15]); + cave->color[4] = gd_atari_color(data[0x16]); // in atari, amoeba was green + cave->color[5] = gd_atari_color(data[0x16]); // in atari, slime was green + cave->color_b = gd_atari_color(data[0x17]); // border = background + cave->color[0] = gd_atari_color(data[0x17]); // background + cave->color[6] = gd_atari_color(8); // extra color 1 - gray + cave->color[7] = gd_atari_color(15); // extra color 2 - white } else { // c64 colors - cave->colorb = gd_c64_color(0); // border = background, fixed color - cave->color0 = gd_c64_color(0); // background, fixed color - cave->color1 = gd_c64_color(data[0x13] & 0xf); - cave->color2 = gd_c64_color(data[0x14] & 0xf); - cave->color3 = gd_c64_color(data[0x15] & 0x7); // lower 3 bits only (vic-ii worked this way) - cave->color4 = cave->color3; // in bd1, amoeba was color3 - cave->color5 = cave->color3; // no slime, but let it be color 3 - cave->color6 = gd_c64_color(12); // extra color 1 - gray - cave->color7 = gd_c64_color(1); // extra color 2 - white + cave->color_b = gd_c64_color(0); // border = background, fixed color + cave->color[0] = gd_c64_color(0); // background, fixed color + cave->color[1] = gd_c64_color(data[0x13] & 0xf); + cave->color[2] = gd_c64_color(data[0x14] & 0xf); + cave->color[3] = gd_c64_color(data[0x15] & 0x7); // lower 3 bits only (vic-ii worked this way) + cave->color[4] = cave->color[3]; // in bd1, amoeba was color[3] + cave->color[5] = cave->color[3]; // no slime, but let it be color 3 + cave->color[6] = gd_c64_color(12); // extra color 1 - gray + cave->color[7] = gd_c64_color(1); // extra color 2 - white } // random fill @@ -1375,28 +1375,28 @@ static int cave_copy_from_bd2(GdCave *cave, const byte *data, int remaining_byte if (format == GD_FORMAT_BD2) { // c64 colors - cave->color0 = gd_c64_color(0); - cave->color1 = gd_c64_color(data[index + 0] & 0xf); - cave->color2 = gd_c64_color(data[index + 1] & 0xf); - cave->color3 = gd_c64_color(data[index + 2] & 0x7); // lower 3 bits only! - cave->color4 = cave->color1; // in bd2, amoeba was color1 - cave->color5 = cave->color1; // slime too - cave->color6 = gd_c64_color(12); // extra color 1 - gray - cave->color7 = gd_c64_color(1); // extra color 2 - white + cave->color[0] = gd_c64_color(0); + cave->color[1] = gd_c64_color(data[index + 0] & 0xf); + cave->color[2] = gd_c64_color(data[index + 1] & 0xf); + cave->color[3] = gd_c64_color(data[index + 2] & 0x7); // lower 3 bits only! + cave->color[4] = cave->color[1]; // in bd2, amoeba was color[1] + cave->color[5] = cave->color[1]; // slime too + cave->color[6] = gd_c64_color(12); // extra color 1 - gray + cave->color[7] = gd_c64_color(1); // extra color 2 - white index += 3; } else { // atari colors - cave->color1 = gd_atari_color(data[index + 0]); - cave->color2 = gd_atari_color(data[index + 1]); - cave->color3 = gd_atari_color(data[index + 2]); - cave->color4 = gd_atari_color(data[index + 3]); // amoeba and slime - cave->color5 = gd_atari_color(data[index + 3]); - cave->colorb = gd_atari_color(data[index + 4]); // background and border - cave->color0 = gd_atari_color(data[index + 4]); - cave->color6 = gd_atari_color(8); // extra color 1 - gray - cave->color7 = gd_atari_color(15); // extra color 2 - white + cave->color[1] = gd_atari_color(data[index + 0]); + cave->color[2] = gd_atari_color(data[index + 1]); + cave->color[3] = gd_atari_color(data[index + 2]); + cave->color[4] = gd_atari_color(data[index + 3]); // amoeba and slime + cave->color[5] = gd_atari_color(data[index + 3]); + cave->color_b = gd_atari_color(data[index + 4]); // background and border + cave->color[0] = gd_atari_color(data[index + 4]); + cave->color[6] = gd_atari_color(8); // extra color 1 - gray + cave->color[7] = gd_atari_color(15); // extra color 2 - white index += 5; } @@ -1526,38 +1526,38 @@ static int cave_copy_from_plck(GdCave *cave, const byte *data, if (format == GD_FORMAT_PLC_ATARI) { // use atari colors - cave->colorb = gd_atari_color(0); // border + cave->color_b = gd_atari_color(0); // border // indexes in data are not the same order as on c64!!! - cave->color0 = gd_atari_color(data[0x1e3]); // background - cave->color1 = gd_atari_color(data[0x1db]); - cave->color2 = gd_atari_color(data[0x1dd]); - cave->color3 = gd_atari_color(data[0x1df]); + cave->color[0] = gd_atari_color(data[0x1e3]); // background + cave->color[1] = gd_atari_color(data[0x1db]); + cave->color[2] = gd_atari_color(data[0x1dd]); + cave->color[3] = gd_atari_color(data[0x1df]); // in atari plck, slime and amoeba could not coexist in the same cave. // if amoeba was used, the graphics turned to green, and data at 0x1e1 was set to 0xd4. // if slime was used, graphics to blue, and data at 0x1e1 was set to 0x72. // these two colors could not be changed in the editor at all. // (maybe they could have been changed in a hex editor) - cave->color4 = gd_atari_color(data[0x1e1]); - cave->color5 = gd_atari_color(data[0x1e1]); + cave->color[4] = gd_atari_color(data[0x1e1]); + cave->color[5] = gd_atari_color(data[0x1e1]); // extra colors - cave->color6 = gd_atari_color(8); // extra color 1 - gray - cave->color7 = gd_atari_color(15); // extra color 2 - white + cave->color[6] = gd_atari_color(8); // extra color 1 - gray + cave->color[7] = gd_atari_color(15); // extra color 2 - white } else { // use c64 colors - cave->colorb = gd_c64_color(data[0x1db] & 0xf); // border - cave->color0 = gd_c64_color(data[0x1dd] & 0xf); - cave->color1 = gd_c64_color(data[0x1df] & 0xf); - cave->color2 = gd_c64_color(data[0x1e1] & 0xf); - cave->color3 = gd_c64_color(data[0x1e3] & 0x7); // lower 3 bits only! - cave->color4 = cave->color3; // in plck, amoeba was color3 - cave->color5 = cave->color3; // same for slime - cave->color6 = gd_c64_color(12); // extra color 1 - gray - cave->color7 = gd_c64_color(1); // extra color 2 - white + cave->color_b = gd_c64_color(data[0x1db] & 0xf); // border + cave->color[0] = gd_c64_color(data[0x1dd] & 0xf); + cave->color[1] = gd_c64_color(data[0x1df] & 0xf); + cave->color[2] = gd_c64_color(data[0x1e1] & 0xf); + cave->color[3] = gd_c64_color(data[0x1e3] & 0x7); // lower 3 bits only! + cave->color[4] = cave->color[3]; // in plck, amoeba was color[3] + cave->color[5] = cave->color[3]; // same for slime + cave->color[6] = gd_c64_color(12); // extra color 1 - gray + cave->color[7] = gd_c64_color(1); // extra color 2 - white } // ... the cave is stored like a map. @@ -1661,15 +1661,15 @@ static int cave_copy_from_dlb(GdCave *cave, const byte *data, int remaining_byte cave->extra_diamond_value = data[4]; // then 5 color bytes follow - cave->colorb = gd_c64_color(data[8] & 0xf); // border - cave->color0 = gd_c64_color(data[9] & 0xf); - cave->color1 = gd_c64_color(data[10] & 0xf); - cave->color2 = gd_c64_color(data[11] & 0xf); - cave->color3 = gd_c64_color(data[12] & 0x7); // lower 3 bits only! - cave->color4 = cave->color3; // in plck, amoeba was color3 - cave->color5 = cave->color3; // same for slime - cave->color6 = gd_c64_color(12); // extra color 1 - gray - cave->color7 = gd_c64_color(1); // extra color 2 - white + cave->color_b = gd_c64_color(data[8] & 0xf); // border + cave->color[0] = gd_c64_color(data[9] & 0xf); + cave->color[1] = gd_c64_color(data[10] & 0xf); + cave->color[2] = gd_c64_color(data[11] & 0xf); + cave->color[3] = gd_c64_color(data[12] & 0x7); // lower 3 bits only! + cave->color[4] = cave->color[3]; // in plck, amoeba was color[3] + cave->color[5] = cave->color[3]; // same for slime + cave->color[6] = gd_c64_color(12); // extra color 1 - gray + cave->color[7] = gd_c64_color(1); // extra color 2 - white // cave map is compressed. // employ a state machine to decompress data. @@ -1919,15 +1919,15 @@ static int cave_copy_from_1stb(GdCave *cave, const byte *data, int remaining_byt // also has no random data... - cave->colorb = gd_c64_color(data[0x384] & 0xf); // border - cave->color0 = gd_c64_color(data[0x385] & 0xf); - cave->color1 = gd_c64_color(data[0x386] & 0xf); - cave->color2 = gd_c64_color(data[0x387] & 0xf); - cave->color3 = gd_c64_color(data[0x388] & 0x7); // lower 3 bits only! - cave->color4 = cave->color1; - cave->color5 = cave->color1; - cave->color6 = gd_c64_color(12); // extra color 1 - gray - cave->color7 = gd_c64_color(1); // extra color 2 - white + cave->color_b = gd_c64_color(data[0x384] & 0xf); // border + cave->color[0] = gd_c64_color(data[0x385] & 0xf); + cave->color[1] = gd_c64_color(data[0x386] & 0xf); + cave->color[2] = gd_c64_color(data[0x387] & 0xf); + cave->color[3] = gd_c64_color(data[0x388] & 0x7); // lower 3 bits only! + cave->color[4] = cave->color[1]; + cave->color[5] = cave->color[1]; + cave->color[6] = gd_c64_color(12); // extra color 1 - gray + cave->color[7] = gd_c64_color(1); // extra color 2 - white cave->amoeba_growth_prob = amoeba_probability(data[0x382]); cave->amoeba_fast_growth_prob = amoeba_probability(data[0x383]); @@ -2040,15 +2040,15 @@ static int cave_copy_from_crdr_7(GdCave *cave, const byte *data, int remaining_b if (data[0x10]) cave->creatures_direction_auto_change_time = data[0x11]; - cave->colorb = gd_c64_color(data[0x14] & 0xf); // border - cave->color0 = gd_c64_color(data[0x15] & 0xf); - cave->color1 = gd_c64_color(data[0x16] & 0xf); - cave->color2 = gd_c64_color(data[0x17] & 0xf); - cave->color3 = gd_c64_color(data[0x18] & 0x7); // lower 3 bits only! - cave->color4 = cave->color3; - cave->color5 = cave->color1; - cave->color6 = gd_c64_color(12); // extra color 1 - gray - cave->color7 = gd_c64_color(1); // extra color 2 - white + cave->color_b = gd_c64_color(data[0x14] & 0xf); // border + cave->color[0] = gd_c64_color(data[0x15] & 0xf); + cave->color[1] = gd_c64_color(data[0x16] & 0xf); + cave->color[2] = gd_c64_color(data[0x17] & 0xf); + cave->color[3] = gd_c64_color(data[0x18] & 0x7); // lower 3 bits only! + cave->color[4] = cave->color[3]; + cave->color[5] = cave->color[1]; + cave->color[6] = gd_c64_color(12); // extra color 1 - gray + cave->color[7] = gd_c64_color(1); // extra color 2 - white cave->intermission = (data[0x19] != 0); @@ -2513,15 +2513,15 @@ static int cave_copy_from_crli(GdCave *cave, const byte *data, int remaining_byt if (uncompressed[0x380]) cave->creatures_direction_auto_change_time = uncompressed[0x381]; - cave->colorb = gd_c64_color(uncompressed[0x384] & 0xf); // border - cave->color0 = gd_c64_color(uncompressed[0x385] & 0xf); - cave->color1 = gd_c64_color(uncompressed[0x386] & 0xf); - cave->color2 = gd_c64_color(uncompressed[0x387] & 0xf); - cave->color3 = gd_c64_color(uncompressed[0x388] & 0x7); // lower 3 bits only! - cave->color4 = cave->color3; - cave->color5 = cave->color1; - cave->color6 = gd_c64_color(12); // extra color 1 - gray - cave->color7 = gd_c64_color(1); // extra color 2 - white + cave->color_b = gd_c64_color(uncompressed[0x384] & 0xf); // border + cave->color[0] = gd_c64_color(uncompressed[0x385] & 0xf); + cave->color[1] = gd_c64_color(uncompressed[0x386] & 0xf); + cave->color[2] = gd_c64_color(uncompressed[0x387] & 0xf); + cave->color[3] = gd_c64_color(uncompressed[0x388] & 0x7); // lower 3 bits only! + cave->color[4] = cave->color[3]; + cave->color[5] = cave->color[1]; + cave->color[6] = gd_c64_color(12); // extra color 1 - gray + cave->color[7] = gd_c64_color(1); // extra color 2 - white cave->intermission = (uncompressed[0x389] != 0); diff --git a/src/game_bd/bd_cave.c b/src/game_bd/bd_cave.c index 490894d8..5061a8b6 100644 --- a/src/game_bd/bd_cave.c +++ b/src/game_bd/bd_cave.c @@ -811,34 +811,35 @@ void gd_cave_set_random_c64_colors(GdCave *cave) }; // always black - cave->colorb = gd_c64_color(GD_COLOR_INDEX_BLACK); - cave->color0 = gd_c64_color(GD_COLOR_INDEX_BLACK); + cave->color_b = gd_c64_color(GD_COLOR_INDEX_BLACK); + cave->color[0] = gd_c64_color(GD_COLOR_INDEX_BLACK); // choose some bright color for brick - cave->color3 = gd_c64_color(bright_colors[gd_random_int_range(0, ARRAY_SIZE(bright_colors))]); + cave->color[3] = gd_c64_color(bright_colors[gd_random_int_range(0, ARRAY_SIZE(bright_colors))]); // choose a dark color for dirt, but should not be == color of brick do { - cave->color1 = gd_c64_color(dark_colors[gd_random_int_range(0, ARRAY_SIZE(dark_colors))]); + cave->color[1] = gd_c64_color(dark_colors[gd_random_int_range(0, ARRAY_SIZE(dark_colors))]); } - while (cave->color1 == cave->color3); // so it is not the same as color 1 + while (cave->color[1] == cave->color[3]); // so it is not the same as color 1 // choose any but black for steel wall, but should not be == brick or dirt do { // between 1 and 15 - do not use black for this. - cave->color2 = gd_c64_color(gd_random_int_range(1, 16)); + cave->color[2] = gd_c64_color(gd_random_int_range(1, 16)); } - while (cave->color1 == cave->color2 || cave->color2 == cave->color3); // so colors are not the same + while (cave->color[1] == cave->color[2] || + cave->color[2] == cave->color[3]); // so colors are not the same // copy amoeba and slime color - cave->color4 = cave->color3; - cave->color5 = cave->color1; + cave->color[4] = cave->color[3]; + cave->color[5] = cave->color[1]; // extra colors - cave->color6 = gd_c64_color(gray_colors[gd_random_int_range(0, ARRAY_SIZE(gray_colors))]); - cave->color7 = gd_c64_color(GD_COLOR_INDEX_WHITE); + cave->color[6] = gd_c64_color(gray_colors[gd_random_int_range(0, ARRAY_SIZE(gray_colors))]); + cave->color[7] = gd_c64_color(GD_COLOR_INDEX_WHITE); } static void cave_set_random_indexed_colors(GdCave *cave, GdColor (*color_indexer_func) (int, int)) @@ -847,7 +848,7 @@ static void cave_set_random_indexed_colors(GdCave *cave, GdColor (*color_indexer int hue_spread = gd_random_int_range(1, 6); // 1..5 // we only use 0..6, as saturation 15 is too bright (almost always white) - // also, saturation 0..1..2 is too dark. the color0=black is there for dark. + // also, saturation 0..1..2 is too dark. the color[0] = black is there for dark. // so this is also 1..5. when hue spread is low, brightness spread is high int bri_spread = 6 - hue_spread; int bri1 = 8, bri2 = 8 - bri_spread, bri3 = 8 + bri_spread; @@ -867,20 +868,20 @@ static void cave_set_random_indexed_colors(GdCave *cave, GdColor (*color_indexer if (gd_random_boolean()) swap(&col2, &col3); if (gd_random_boolean()) swap(&col1, &col3); - cave->colorb = color_indexer_func(0, 0); - cave->color0 = color_indexer_func(0, 0); - cave->color1 = color_indexer_func(col1 + 1, bri1); - cave->color2 = color_indexer_func(col2 + 1, bri2); - cave->color3 = color_indexer_func(col3 + 1, bri3); + cave->color_b = color_indexer_func(0, 0); + cave->color[0] = color_indexer_func(0, 0); + cave->color[1] = color_indexer_func(col1 + 1, bri1); + cave->color[2] = color_indexer_func(col2 + 1, bri2); + cave->color[3] = color_indexer_func(col3 + 1, bri3); // amoeba and slime are different // some green thing - cave->color4 = color_indexer_func(gd_random_int_range(11, 13), gd_random_int_range(6, 12)); + cave->color[4] = color_indexer_func(gd_random_int_range(11, 13), gd_random_int_range(6, 12)); // some blueish thing - cave->color5 = color_indexer_func(gd_random_int_range(7, 10), gd_random_int_range(0, 6)); + cave->color[5] = color_indexer_func(gd_random_int_range(7, 10), gd_random_int_range(0, 6)); // extra colors - cave->color6 = color_indexer_func(0, bri1); - cave->color7 = color_indexer_func(0, 15); + cave->color[6] = color_indexer_func(0, bri1); + cave->color[7] = color_indexer_func(0, 15); } static void gd_cave_set_random_atari_colors(GdCave *cave) @@ -939,7 +940,7 @@ static void gd_cave_set_random_rgb_colors(GdCave *cave) s3 = 0.9; } - // randomly change values, but do not touch v3, as cave->color3 should be a bright color + // randomly change values, but do not touch v3, as cave->color[3] should be a bright color if (gd_random_boolean()) swapd(&v1, &v2); // randomly change hues and saturations @@ -954,19 +955,19 @@ static void gd_cave_set_random_rgb_colors(GdCave *cave) h2 *= 360.0; h3 *= 360.0; - cave->colorb = gd_color_get_from_hsv(0, 0, 0); - cave->color0 = gd_color_get_from_hsv(0, 0, 0); // black for background - cave->color1 = gd_color_get_from_hsv(h1, s1, v1); // dirt - cave->color2 = gd_color_get_from_hsv(h2, s2, v2); // steel - cave->color3 = gd_color_get_from_hsv(h3, s3, v3); // brick + cave->color_b = gd_color_get_from_hsv(0, 0, 0); + cave->color[0] = gd_color_get_from_hsv(0, 0, 0); // black for background + cave->color[1] = gd_color_get_from_hsv(h1, s1, v1); // dirt + cave->color[2] = gd_color_get_from_hsv(h2, s2, v2); // steel + cave->color[3] = gd_color_get_from_hsv(h3, s3, v3); // brick // green(120+-20) with the saturation and brightness of brick - cave->color4 = gd_color_get_from_hsv(gd_random_int_range(100, 140), s2, v2); + cave->color[4] = gd_color_get_from_hsv(gd_random_int_range(100, 140), s2, v2); // blue(240+-20) with saturation and brightness of dirt - cave->color5 = gd_color_get_from_hsv(gd_random_int_range(220, 260), s1, v1); + cave->color[5] = gd_color_get_from_hsv(gd_random_int_range(220, 260), s1, v1); // extra colors - cave->color6 = gd_color_get_from_hsv(0, 0, v1); // gray with brightness of dirt - cave->color7 = gd_color_get_from_hsv(0, 0, 1); // white + cave->color[6] = gd_color_get_from_hsv(0, 0, v1); // gray with brightness of dirt + cave->color[7] = gd_color_get_from_hsv(0, 0, 1); // white } void gd_cave_set_random_colors(GdCave *cave, GdColorType type) diff --git a/src/game_bd/bd_cave.h b/src/game_bd/bd_cave.h index b46443af..3034f524 100644 --- a/src/game_bd/bd_cave.h +++ b/src/game_bd/bd_cave.h @@ -400,18 +400,9 @@ typedef struct _gd_cave int w, h; // Sizes of cave, width and height. int x1,y1,x2,y2; // Visible part of the cave - GdColor colorb; // border color - GdColor color0, color1, color2, color3, color4, color5; // c64-style colors; - // color 4 and 5 are amoeba and slime. - GdColor color6, color7; // extra colors - GdColor base_color0; // base color for color gradient - GdColor base_color1; // base color for color gradient - GdColor base_color2; // base color for color gradient - GdColor base_color3; // base color for color gradient - GdColor base_color4; // base color for color gradient - GdColor base_color5; // base color for color gradient - GdColor base_color6; // base color for color gradient - GdColor base_color7; // base color for color gradient + GdColor color_b; // border color + GdColor color[MAX_LEVEL_COLORS]; // c64-style colors; color 4 and 5 are amoeba and slime. + GdColor base_color[MAX_LEVEL_COLORS]; // base colors for color gradients int diamond_value; // Score for a diamond. int extra_diamond_value; // Score for a diamond, when gate is open. diff --git a/src/game_bd/bd_cavedb.c b/src/game_bd/bd_cavedb.c index 7adf35f6..350ca196 100644 --- a/src/game_bd/bd_cavedb.c +++ b/src/game_bd/bd_cavedb.c @@ -2283,47 +2283,47 @@ const GdStructDescriptor gd_cave_properties[] = }, { "Colors", GD_TYPE_COLOR, GD_ALWAYS_SAVE, - N_("Border color"), STRUCT_OFFSET(GdCave, colorb), 1, + N_("Border color"), STRUCT_OFFSET(GdCave, color_b), 1, N_("Border color for C64 graphics. Only for compatibility, not used by GDash.") }, { "Colors", GD_TYPE_COLOR, GD_ALWAYS_SAVE, - N_("Background color"), STRUCT_OFFSET(GdCave, color0), 1, + N_("Background color"), STRUCT_OFFSET(GdCave, color[0]), 1, N_("Background color for C64 graphics") }, { "Colors", GD_TYPE_COLOR, GD_ALWAYS_SAVE, - N_("Color 1 (dirt)"), STRUCT_OFFSET(GdCave, color1), 1, + N_("Color 1 (dirt)"), STRUCT_OFFSET(GdCave, color[1]), 1, N_("Foreground color 1 for C64 graphics") }, { "Colors", GD_TYPE_COLOR, GD_ALWAYS_SAVE, - N_("Color 2 (steel wall)"), STRUCT_OFFSET(GdCave, color2), 1, + N_("Color 2 (steel wall)"), STRUCT_OFFSET(GdCave, color[2]), 1, N_("Foreground color 2 for C64 graphics") }, { "Colors", GD_TYPE_COLOR, GD_ALWAYS_SAVE, - N_("Color 3 (brick wall)"), STRUCT_OFFSET(GdCave, color3), 1, + N_("Color 3 (brick wall)"), STRUCT_OFFSET(GdCave, color[3]), 1, N_("Foreground color 3 for C64 graphics") }, { "Colors", GD_TYPE_COLOR, GD_ALWAYS_SAVE, - N_("Amoeba color"), STRUCT_OFFSET(GdCave, color4), 1, + N_("Amoeba color"), STRUCT_OFFSET(GdCave, color[4]), 1, N_("Amoeba color for C64 graphics") }, { "Colors", GD_TYPE_COLOR, GD_ALWAYS_SAVE, - N_("Slime color"), STRUCT_OFFSET(GdCave, color5), 1, + N_("Slime color"), STRUCT_OFFSET(GdCave, color[5]), 1, N_("Slime color for C64 graphics") }, { "Colors", GD_TYPE_COLOR, GD_ALWAYS_SAVE, - N_("Extra color 1"), STRUCT_OFFSET(GdCave, color6), 1, + N_("Extra color 1"), STRUCT_OFFSET(GdCave, color[6]), 1, N_("Extra color 1 for C64 graphics") }, { "Colors", GD_TYPE_COLOR, GD_ALWAYS_SAVE, - N_("Extra color 2"), STRUCT_OFFSET(GdCave, color7), 1, + N_("Extra color 2"), STRUCT_OFFSET(GdCave, color[7]), 1, N_("Extra color 2 for C64 graphics") }, @@ -3323,13 +3323,13 @@ GdPropertyDefault gd_cave_defaults_gdash[] = { CAVE_OFFSET(y1), 0 }, { CAVE_OFFSET(x2), 39 }, { CAVE_OFFSET(y2), 21 }, - { CAVE_OFFSET(colorb), 0 }, - { CAVE_OFFSET(color0), 0 }, - { CAVE_OFFSET(color1), 8 }, - { CAVE_OFFSET(color2), 11 }, - { CAVE_OFFSET(color3), 1 }, - { CAVE_OFFSET(color4), 5 }, - { CAVE_OFFSET(color5), 6 }, + { CAVE_OFFSET(color_b), 0 }, + { CAVE_OFFSET(color[0]), 0 }, + { CAVE_OFFSET(color[1]), 8 }, + { CAVE_OFFSET(color[2]), 11 }, + { CAVE_OFFSET(color[3]), 1 }, + { CAVE_OFFSET(color[4]), 5 }, + { CAVE_OFFSET(color[5]), 6 }, // difficulty { CAVE_OFFSET(level_diamonds[0]), 10 }, diff --git a/src/game_bd/bd_caveset.c b/src/game_bd/bd_caveset.c index 33d2515c..37bdd547 100644 --- a/src/game_bd/bd_caveset.c +++ b/src/game_bd/bd_caveset.c @@ -502,15 +502,15 @@ static void brc_import(byte *data) // colors colind = data[31 * c + datapos] % ARRAY_SIZE(brc_color_table); - cave->colorb = 0x000000; // fixed rgb black - cave->color0 = 0x000000; // fixed rgb black - cave->color1 = brc_color_table[colind]; // brc specified dirt color - cave->color2 = brc_color_table_comp[colind]; // complement - cave->color3 = 0xffffff; // white for brick - cave->color4 = 0xe5ad23; // fixed for amoeba - cave->color5 = 0x8af713; // fixed for slime - cave->color6 = 0x888888; // extra color 1 - gray - cave->color7 = 0xffffff; // extra color 2 - white + cave->color_b = 0x000000; // fixed rgb black + cave->color[0] = 0x000000; // fixed rgb black + cave->color[1] = brc_color_table[colind]; // brc specified dirt color + cave->color[2] = brc_color_table_comp[colind]; // complement + cave->color[3] = 0xffffff; // white for brick + cave->color[4] = 0xe5ad23; // fixed for amoeba + cave->color[5] = 0x8af713; // fixed for slime + cave->color[6] = 0x888888; // extra color 1 - gray + cave->color[7] = 0xffffff; // extra color 2 - white if (import_effect) { diff --git a/src/game_bd/bd_graphics.c b/src/game_bd/bd_graphics.c index 1106eb21..eb6da621 100644 --- a/src/game_bd/bd_graphics.c +++ b/src/game_bd/bd_graphics.c @@ -322,13 +322,14 @@ static SDL_Surface *get_colored_surface_from_template(GdCave *cave, SDL_Surface static SDL_Surface *new_surface = NULL; static unsigned int *pixels = NULL; SDL_PixelFormat *format = surface->format; - SDL_Color color[8]; - SDL_Color base_color[8]; + SDL_Color color[MAX_LEVEL_COLORS]; + SDL_Color base_color[MAX_LEVEL_COLORS]; + int color_mapping[MAX_LEVEL_COLORS] = { 0, 1, 4, 3, 5, 2, 6, 7 }; int width = surface->w; int height = surface->h; int bytes_per_pixel = 4; int out = 0; - int x, y; + int i, x, y; if (format->BytesPerPixel != bytes_per_pixel) Fail("Color template bitmap has wrong color depth -- should not happen"); @@ -343,22 +344,11 @@ static SDL_Surface *get_colored_surface_from_template(GdCave *cave, SDL_Surface SDL_LockSurface(surface); // set surface color palette to cave colors - color[0] = get_template_color(cave->color0); // replace black - color[1] = get_template_color(cave->color1); // replace red - color[2] = get_template_color(cave->color4); // replace green - color[3] = get_template_color(cave->color3); // replace yellow - color[4] = get_template_color(cave->color5); // replace blue - color[5] = get_template_color(cave->color2); // replace purple - color[6] = get_template_color(cave->color6); // replace cyan - color[7] = get_template_color(cave->color7); // replace white - base_color[0] = get_template_color(cave->base_color0); // replace black - base_color[1] = get_template_color(cave->base_color1); // replace red - base_color[2] = get_template_color(cave->base_color4); // replace green - base_color[3] = get_template_color(cave->base_color3); // replace yellow - base_color[4] = get_template_color(cave->base_color5); // replace blue - base_color[5] = get_template_color(cave->base_color2); // replace purple - base_color[6] = get_template_color(cave->base_color6); // replace cyan - base_color[7] = get_template_color(cave->base_color7); // replace white + for (i = 0; i < MAX_LEVEL_COLORS; i++) + { + color[i] = get_template_color(cave->color[color_mapping[i]]); + base_color[i] = get_template_color(cave->base_color[color_mapping[i]]); + } for (y = 0; y < height; y++) { @@ -426,7 +416,7 @@ static Bitmap *get_masked_bitmap_from_surface(GdCave *cave, SDL_Surface *surface FreeBitmap(bitmap); // set background color to be transparent for masked bitmap - int color = gd_color_get_rgb(cave->color0); + int color = gd_color_get_rgb(cave->color[0]); int r = gd_color_get_r(color); int g = gd_color_get_g(color); int b = gd_color_get_b(color); diff --git a/src/libgame/system.h b/src/libgame/system.h index e07c553b..c588a879 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -574,6 +574,9 @@ #define MAX_GLOBAL_ANIMS 32 #define MAX_GLOBAL_ANIM_PARTS 32 +// maximum number of level specific colors in color template +#define MAX_LEVEL_COLORS 8 + // minimum/maximum/default x/y grid size for virtual buttons #define MIN_GRID_XSIZE 3 #define MIN_GRID_YSIZE 3 diff --git a/src/main.h b/src/main.h index d00a597e..b6d7d7c0 100644 --- a/src/main.h +++ b/src/main.h @@ -3947,22 +3947,8 @@ struct LevelInfo int bd_explosion_turns_to; // BD other explosions change to specified element int bd_explosion_3_turns_to; // BD other explosions change to specified element, stage 3 int bd_color_b; // BD engine C64-style cave color (border) - int bd_color_0; // BD engine C64-style cave color (background) - int bd_color_1; // BD engine C64-style cave color (sand) - int bd_color_2; // BD engine C64-style cave color (steel wall) - int bd_color_3; // BD engine C64-style cave color (wall) - int bd_color_4; // BD engine C64-style cave color (amoeba) - int bd_color_5; // BD engine C64-style cave color (slime) - int bd_color_6; // BD engine C64-style cave color (extra color 1) - int bd_color_7; // BD engine C64-style cave color (extra color 2) - int bd_base_color_0; // BD engine C64-style cave base color (background) - int bd_base_color_1; // BD engine C64-style cave base color (sand) - int bd_base_color_2; // BD engine C64-style cave base color (steel wall) - int bd_base_color_3; // BD engine C64-style cave base color (wall) - int bd_base_color_4; // BD engine C64-style cave base color (amoeba) - int bd_base_color_5; // BD engine C64-style cave base color (slime) - int bd_base_color_6; // BD engine C64-style cave base color (extra color 1) - int bd_base_color_7; // BD engine C64-style cave base color (extra color 2) + int bd_color[MAX_LEVEL_COLORS]; // BD engine C64-style cave colors + int bd_base_color[MAX_LEVEL_COLORS]; // BD engine C64-style cave base colors (for gradients) boolean em_slippery_gems; // EM style "gems slip from wall" behaviour boolean em_explodes_by_fire; // EM style chain explosion behaviour -- 2.34.1