From: Holger Schemel Date: Sun, 18 Aug 2024 11:25:56 +0000 (+0200) Subject: added separate buffer for playfield (un)covering in BD engine X-Git-Tag: 4.4.0.0-test-4~301 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=b2734ca23ed6edea041e38930160b6639c8d8ac5;p=rocksndiamonds.git added separate buffer for playfield (un)covering in BD engine --- diff --git a/src/game_bd/bd_cave.c b/src/game_bd/bd_cave.c index 1a40351a..d050c520 100644 --- a/src/game_bd/bd_cave.c +++ b/src/game_bd/bd_cave.c @@ -1317,6 +1317,7 @@ void gd_cave_count_diamonds(GdCave *cave) void gd_drawcave_game(const GdCave *cave, int **element_buffer, int **last_element_buffer, int **drawing_buffer, int **last_drawing_buffer, int **gfx_buffer, + int **covered_buffer, boolean bonus_life_flash, int animcycle, boolean hate_invisible_outbox) { static int player_blinking = 0; @@ -1538,13 +1539,13 @@ void gd_drawcave_game(const GdCave *cave, GdElement actual = cave->map[y][x]; // if covered, real element is not important - if (actual & COVERED) + if (covered_buffer[y][x]) map = O_COVERED; else map = elemmapping[actual]; // if covered, real element is not important - if (actual & COVERED) + if (covered_buffer[y][x]) draw = gd_element_properties[O_COVERED].image_game; else draw = elemdrawing[actual]; diff --git a/src/game_bd/bd_cave.h b/src/game_bd/bd_cave.h index 3b8d2833..190b23d2 100644 --- a/src/game_bd/bd_cave.h +++ b/src/game_bd/bd_cave.h @@ -716,6 +716,7 @@ GdScheduling gd_scheduling_from_string(const char *str); void gd_drawcave_game(const GdCave *cave, int **element_buffer, int **last_element_buffer, int **drawing_buffer, int **last_drawing_buffer, int **gfx_buffer, + int **covered_buffer, boolean bonus_life_flash, int animcycle, boolean hate_invisible_outbox); // function to copy a GdString diff --git a/src/game_bd/bd_elements.h b/src/game_bd/bd_elements.h index 2843b795..99bfa717 100644 --- a/src/game_bd/bd_elements.h +++ b/src/game_bd/bd_elements.h @@ -408,10 +408,9 @@ typedef enum _element O_MAX_ALL, SCANNED = 0x400, - COVERED = 0x800, // binary AND this to elements to get rid of properties above. - O_MASK = ~(SCANNED | COVERED) + O_MASK = ~SCANNED } GdElement; typedef enum _sound diff --git a/src/game_bd/bd_gameplay.c b/src/game_bd/bd_gameplay.c index b157bdf0..629e0362 100644 --- a/src/game_bd/bd_gameplay.c +++ b/src/game_bd/bd_gameplay.c @@ -36,6 +36,8 @@ void gd_game_free(GdGame *game) gd_cave_map_free(game->dir_buffer_to); if (game->gfx_buffer) gd_cave_map_free(game->gfx_buffer); + if (game->covered_buffer) + gd_cave_map_free(game->covered_buffer); game->player_lives = 0; @@ -120,6 +122,11 @@ static void load_cave(GdGame *game) gd_cave_map_free(game->gfx_buffer); game->gfx_buffer = NULL; + // delete covered buffer + if (game->covered_buffer) + gd_cave_map_free(game->covered_buffer); + game->covered_buffer = NULL; + // load the cave game->cave_score = 0; @@ -193,6 +200,13 @@ static void load_cave(GdGame *game) for (y = 0; y < game->cave->h; y++) for (x = 0; x < game->cave->w; x++) game->gfx_buffer[y][x] = -1; // fill with "invalid" + + // create new covered buffer + game->covered_buffer = gd_cave_map_new(game->cave, int); + + for (y = 0; y < game->cave->h; y++) + for (x = 0; x < game->cave->w; x++) + game->covered_buffer[y][x] = FALSE; } GdCave *gd_create_snapshot(GdGame *game) @@ -347,7 +361,7 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean // cover all cells of cave for (y = 0; y < game->cave->h; y++) for (x = 0; x < game->cave->w; x++) - game->cave->map[y][x] |= COVERED; + game->covered_buffer[y][x] = TRUE; counter_next = game->state_counter + 1; @@ -378,7 +392,7 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean y = gd_random_int_range(0, game->cave->h); x = gd_random_int_range(0, game->cave->w); - game->cave->map[y][x] &= ~COVERED; + game->covered_buffer[y][x] = FALSE; } counter_next++; // as we did something, advance the counter. @@ -391,7 +405,7 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean // time to uncover the whole cave. for (y = 0; y < game->cave->h; y++) for (x = 0; x < game->cave->w; x++) - game->cave->map[y][x] &= ~COVERED; + game->covered_buffer[y][x] = FALSE; // to stop uncover sound. gd_cave_clear_sounds(game->cave); @@ -587,7 +601,7 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean // covering eight times faster than uncovering. for (j = 0; j < game->cave->w * game->cave->h * 8 / 40; j++) - game->cave->map[gd_random_int_range(0, game->cave->h)][gd_random_int_range (0, game->cave->w)] |= COVERED; + game->covered_buffer[gd_random_int_range(0, game->cave->h)][gd_random_int_range(0, game->cave->w)] = TRUE; } return_state = GD_GAME_NOTHING; @@ -597,7 +611,7 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean // cover all for (y = 0; y < game->cave->h; y++) for (x = 0; x < game->cave->w; x++) - game->cave->map[y][x] |= COVERED; + game->covered_buffer[y][x] = TRUE; counter_next = game->state_counter + 1; return_state = GD_GAME_NOTHING; @@ -630,6 +644,7 @@ static GdGameState gd_game_main_int(GdGame *game, boolean allow_iterate, boolean if (game->element_buffer && game->drawing_buffer && game->gfx_buffer) gd_drawcave_game(game->cave, game->element_buffer, game->last_element_buffer, game->drawing_buffer, game->last_drawing_buffer, game->gfx_buffer, + game->covered_buffer, game->bonus_life_flash != 0, game->animcycle, setup.bd_show_invisible_outbox); game->state_counter = counter_next; diff --git a/src/game_bd/bd_gameplay.h b/src/game_bd/bd_gameplay.h index fbeeecfc..f54810bc 100644 --- a/src/game_bd/bd_gameplay.h +++ b/src/game_bd/bd_gameplay.h @@ -83,6 +83,7 @@ typedef struct _gd_game int **dir_buffer_to; int **gfx_buffer; // contains the indexes to the cells; // created by *start_level, deleted by *stop_game + int **covered_buffer; int itercycle; int itermax; int itermax_last; diff --git a/src/game_bd/export_bd.h b/src/game_bd/export_bd.h index a50b9e9f..db9a3e8b 100644 --- a/src/game_bd/export_bd.h +++ b/src/game_bd/export_bd.h @@ -88,6 +88,7 @@ struct EngineSnapshotInfo_BD int dir_buffer_from[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT]; int dir_buffer_to[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT]; int gfx_buffer[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT]; + int covered_buffer[MAX_PLAYFIELD_WIDTH][MAX_PLAYFIELD_HEIGHT]; GdCave cave; diff --git a/src/game_bd/main_bd.c b/src/game_bd/main_bd.c index dc92297e..99fdc18e 100644 --- a/src/game_bd/main_bd.c +++ b/src/game_bd/main_bd.c @@ -579,6 +579,7 @@ void SaveEngineSnapshotValues_BD(void) engine_snapshot_bd.dir_buffer_from[x][y] = game->dir_buffer_from[y][x]; engine_snapshot_bd.dir_buffer_to[x][y] = game->dir_buffer_to[y][x]; engine_snapshot_bd.gfx_buffer[x][y] = game->gfx_buffer[y][x]; + engine_snapshot_bd.covered_buffer[x][y] = game->covered_buffer[y][x]; } } @@ -613,6 +614,7 @@ void LoadEngineSnapshotValues_BD(void) engine_snapshot_bd.game.dir_buffer_from = game->dir_buffer_from; engine_snapshot_bd.game.dir_buffer_to = game->dir_buffer_to; engine_snapshot_bd.game.gfx_buffer = game->gfx_buffer; + engine_snapshot_bd.game.covered_buffer = game->covered_buffer; *game = engine_snapshot_bd.game; @@ -627,6 +629,7 @@ void LoadEngineSnapshotValues_BD(void) game->dir_buffer_from[y][x] = engine_snapshot_bd.dir_buffer_from[x][y]; game->dir_buffer_to[y][x] = engine_snapshot_bd.dir_buffer_to[x][y]; game->gfx_buffer[y][x] = engine_snapshot_bd.gfx_buffer[x][y]; + game->covered_buffer[y][x] = engine_snapshot_bd.covered_buffer[x][y]; } }