by the caller.
*/
void gd_drawcave_game(const GdCave *cave,
+ int **element_buffer, int **last_element_buffer,
int **drawing_buffer, int **last_drawing_buffer, int **gfx_buffer,
boolean bonus_life_flash, int animcycle, boolean hate_invisible_outbox)
{
draw += GD_NUM_OF_CELLS;
// set to buffer, with caching
+ if (element_buffer[y][x] != actual)
+ element_buffer[y][x] = actual;
+
if (drawing_buffer[y][x] != map)
drawing_buffer[y][x] = map;
// stop sounds
gd_sound_off();
+ if (game->element_buffer)
+ gd_cave_map_free(game->element_buffer);
+ if (game->last_element_buffer)
+ gd_cave_map_free(game->last_element_buffer);
if (game->drawing_buffer)
gd_cave_map_free(game->drawing_buffer);
if (game->last_drawing_buffer)
{
int x, y;
+ // delete element buffer
+ if (game->element_buffer)
+ gd_cave_map_free(game->element_buffer);
+ game->element_buffer = NULL;
+
+ // delete last element buffer
+ if (game->last_element_buffer)
+ gd_cave_map_free(game->last_element_buffer);
+ game->last_element_buffer = NULL;
+
// delete drawing buffer
if (game->drawing_buffer)
gd_cave_map_free(game->drawing_buffer);
game->cycle_counter = 0;
+ // create new element buffer
+ game->element_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->element_buffer[y][x] = O_NONE;
+
+ // create new last element buffer
+ game->last_element_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->last_element_buffer[y][x] = O_NONE;
+
// create new drawing buffer
game->drawing_buffer = gd_cave_map_new(game->cave, int);
{
for (x = 0; x < game->cave->w; x++)
{
+ game->last_element_buffer[y][x] = game->element_buffer[y][x];
game->last_drawing_buffer[y][x] = game->drawing_buffer[y][x];
game->dir_buffer_from[y][x] = GD_MV_STILL;
game->dir_buffer_to[y][x] = GD_MV_STILL;
// always render the cave to the gfx buffer;
// however it may do nothing if animcycle was not changed.
- if (game->drawing_buffer && game->gfx_buffer)
- gd_drawcave_game(game->cave, game->drawing_buffer, game->last_drawing_buffer, game->gfx_buffer,
+ 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->bonus_life_flash != 0, game->animcycle, setup.bd_show_invisible_outbox);
game->state_counter = counter_next;
// if drawcave was before scrolling, it would draw, scroll would invalidate,
// and then it should be drawn again
// only do the drawing if the cave already exists.
- if (game->cave && game->drawing_buffer && game->gfx_buffer)
+ if (game->cave && game->element_buffer && game->drawing_buffer && game->gfx_buffer)
{
// if fine scrolling, scroll at 50hz. if not, only scroll at every second call, so 25hz.
// do the scrolling. scroll exactly, if player is not yet alive
{
for (x = 0; x < cave->w; x++)
{
+ engine_snapshot_bd.element_buffer[x][y] = game->element_buffer[y][x];
+ engine_snapshot_bd.last_element_buffer[x][y] = game->last_element_buffer[y][x];
engine_snapshot_bd.drawing_buffer[x][y] = game->drawing_buffer[y][x];
engine_snapshot_bd.last_drawing_buffer[x][y] = game->last_drawing_buffer[y][x];
engine_snapshot_bd.dir_buffer_from[x][y] = game->dir_buffer_from[y][x];
engine_snapshot_bd.game.cave = game->cave;
engine_snapshot_bd.game.original_cave = game->original_cave;
+ engine_snapshot_bd.game.element_buffer = game->element_buffer;
+ engine_snapshot_bd.game.last_element_buffer = game->last_element_buffer;
engine_snapshot_bd.game.drawing_buffer = game->drawing_buffer;
engine_snapshot_bd.game.last_drawing_buffer = game->last_drawing_buffer;
engine_snapshot_bd.game.dir_buffer_from = game->dir_buffer_from;
{
for (x = 0; x < cave->w; x++)
{
+ game->element_buffer[y][x] = engine_snapshot_bd.element_buffer[x][y];
+ game->last_element_buffer[y][x] = engine_snapshot_bd.last_element_buffer[x][y];
game->drawing_buffer[y][x] = engine_snapshot_bd.drawing_buffer[x][y];
game->last_drawing_buffer[y][x] = engine_snapshot_bd.last_drawing_buffer[x][y];
game->dir_buffer_from[y][x] = engine_snapshot_bd.dir_buffer_from[x][y];