Skip to content

Commit

Permalink
Merge pull request #67 from boingoing/skip_walls_clear
Browse files Browse the repository at this point in the history
Skip the first and last set of contiguous wall tiles when updating uncleared playfield tiles
  • Loading branch information
boingoing authored Aug 22, 2023
2 parents 382cc24 + fa1c725 commit 6554ee4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/jeznes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,10 @@ void set_playfield_tile(unsigned int tile_index,
playfield_index_pixel_coord_y(tile_index)));
}

// Use these to skip scanning the first and last blocks of continuous wall playfield tiles.
#define FIRST_NON_WALL_PLAYFIELD_TILE_INDEX 34
#define LAST_NON_WALL_PLAYFIELD_TILE_INDEX 670

// Update uncleared, unmarked playfield tiles to be cleared. Returns TRUE when
// all uncleared tiles have been updated. Note: This function can potentially
// queue more vram updates than are allowed during the next v-blank.
Expand All @@ -1513,7 +1517,7 @@ unsigned char update_cleared_playfield_tiles(void) {
// counters.
if (get_should_initialize_clear_sweep() == TRUE) {
// Keep pointer to the playfield in-memory structure.
set_temp_ptr(playfield);
set_temp_ptr(playfield + FIRST_NON_WALL_PLAYFIELD_TILE_INDEX);
// First ppu address of the playfield tiles.
set_temp_ppu_address(get_ppu_addr(0, playfield_pixel_coord_x[0],
playfield_pixel_coord_y[0]));
Expand All @@ -1527,7 +1531,7 @@ unsigned char update_cleared_playfield_tiles(void) {
// Look over all tiles in the playfield and for each uncleared, unmarked tile
// change it to cleared.
for (; get_temp_ptr(unsigned char) !=
(unsigned char*)(playfield + PLAYFIELD_WIDTH * PLAYFIELD_HEIGHT);
(unsigned char*)(playfield + LAST_NON_WALL_PLAYFIELD_TILE_INDEX);
++temp_ptr_1) {
set_playfield_tile_value(*get_temp_ptr(unsigned char));

Expand Down

0 comments on commit 6554ee4

Please sign in to comment.