Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/bss.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
#include "screens/title.h"
#include "sprites.h"

unsigned char playfield[PLAYFIELD_WIDTH * PLAYFIELD_HEIGHT];
#define PLAYFIELD_BYTES ((PLAYFIELD_WIDTH * PLAYFIELD_HEIGHT) >> 2)

// The state of every tile in the playfield.
unsigned char playfield_tiles[PLAYFIELD_BYTES];

// The line-related flags for each playfield tile.
unsigned char playfield_line_flags[PLAYFIELD_BYTES];

#if ENABLE_CHEATS
unsigned char enable_ball_line_collisions;
Expand Down
7 changes: 0 additions & 7 deletions src/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
#define set_temp_ptr(p) (temp_ptr_1 = (unsigned char*)(p))
#define get_temp_ptr(type) ((type*)temp_ptr_1)

#define get_playfield_index() (temp_int_3)
#define set_playfield_index(a) (temp_int_3 = (a))
#define inc_playfield_index() (++temp_int_3)

#define get_should_initialize_clear_sweep() (temp_byte_6)
#define set_should_initialize_clear_sweep(a) (temp_byte_6 = (a))

Expand Down Expand Up @@ -90,7 +86,4 @@
#define get_y_compare_pixel_coord() (temp_byte_4)
#define set_y_compare_pixel_coord(a) (temp_byte_4 = (a))

#define get_playfield_tile_value() (temp_byte_4)
#define set_playfield_tile_value(a) (temp_byte_4 = (a))

#endif // __JEZNES_DATA_H__
10 changes: 7 additions & 3 deletions src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// These macros enable various debugging features and should probably be turned
// off before release.
#define DEBUG 0
#define DEBUG 1

// DEBUG macro gates all the debug features.
#if DEBUG
Expand All @@ -18,14 +18,18 @@
// screen. The vertical position of this line indicates how much CPU was used
// by the game loop logic.
// ie: A line drawn lower down on the screen consumed more CPU.
#define DRAW_GRAY_LINE 1
#define DRAW_GRAY_LINE 0

// Draw a highlight tile on the playfield at the nearest tile location to each
// ball sprite.
#define DRAW_BALL_NEAREST_TILE_HIGHLIGHT 0

// Enable the use of cheat code input sequences.
#define ENABLE_CHEATS 1
#define ENABLE_CHEATS 0

// Put perf-sensitive code blocks into functions instead of macros.
// Use to enable profiling critical code blocks by isolating them.
#define PUT_CRITICAL_CODE_IN_FUNCTIONS 1

#endif

Expand Down
216 changes: 112 additions & 104 deletions src/flags/playfield.h

Large diffs are not rendered by default.

118 changes: 58 additions & 60 deletions src/flood_fill.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,36 @@ void compute_playfield_mark_bit_one_region(void) {
// If the playfield tile at |get_current_position()| is marked, the region
// containing the tile has already been marked. There's no point in remarking
// the region.
if (!inside(get_current_position())) {
if (!is_current_inside()) {
return;
}

// Set cur-dir to default direction
set_cur_dir(MOVE_DIRECTION_DEFAULT);
// Clear mark and mark2 (set values to null)
set_mark_null(TRUE);
set_mark2_null(TRUE);
set_mark1_null();
set_mark2_null();
// Set backtrack and findloop to false
set_backtrack(FALSE);
set_findloop(FALSE);
unset_backtrack();
unset_findloop();

// Move forward until the playfield tile in front is marked or not uncleared
// (ie: it is not inside).
// Note: This function does not do bounds checking, we assume the playfield
// has a border of wall tiles on all sides.
set_temp_forward_iterator(get_front());
while (inside(get_temp_forward_iterator())) {
set_current_position(get_temp_forward_iterator());
set_temp_forward_iterator(get_front());
while (is_front_inside()) {
move_forward();
}

goto PAINTER_ALGORITHM_START;

while (1) {
move_forward();

if (inside(get_right())) {
if (get_backtrack() == TRUE && get_findloop() == FALSE &&
(inside(get_front()) || inside(get_left()))) {
set_findloop(TRUE);
if (is_right_inside()) {
if (get_backtrack() && !get_findloop() &&
(is_front_inside() || is_left_inside())) {
set_findloop();
}
turn_right();

Expand All @@ -60,101 +58,101 @@ void compute_playfield_mark_bit_one_region(void) {
PAINTER_ALGORITHM_START:
// Count number of non-diagonally adjacent marked playfield tiles.
set_adjacent_marked_tile_count(0);
if (!inside(playfield_index_move_up(get_current_position()))) {
if (!is_above_tile_inside()) {
inc_adjacent_marked_tile_count();
}
if (!inside(playfield_index_move_down(get_current_position()))) {
if (!is_below_tile_inside()) {
inc_adjacent_marked_tile_count();
}
if (!inside(playfield_index_move_left(get_current_position()))) {
if (!is_left_tile_inside()) {
inc_adjacent_marked_tile_count();
}
if (!inside(playfield_index_move_right(get_current_position()))) {
if (!is_right_tile_inside()) {
inc_adjacent_marked_tile_count();
}

if (get_adjacent_marked_tile_count() != 4) {
do {
turn_right();
} while (inside(get_front()));
} while (is_front_inside());
do {
turn_left();
} while (!inside(get_front()));
} while (!is_front_inside());
}

switch (get_adjacent_marked_tile_count()) {
case 1:
if (get_backtrack() == TRUE) {
set_findloop(TRUE);
} else if (get_findloop() == TRUE) {
if (get_mark_null() == TRUE) {
set_mark_null(FALSE);
if (get_backtrack()) {
set_findloop();
} else if (get_findloop()) {
if (get_mark1_null()) {
unset_mark1_null();
}
} else if (inside(get_front_left()) && inside(get_back_left())) {
set_mark_null(TRUE);
set_playfield_is_marked_flag(get_current_position());
} else if (is_front_left_inside() && is_back_left_inside()) {
set_mark1_null();
paint_current_position();
goto PAINTER_ALGORITHM_PAINT;
}
break;
case 2:
if (!inside(get_back())) {
if (inside(get_front_left())) {
set_mark_null(TRUE);
set_playfield_is_marked_flag(get_current_position());
if (!is_back_inside()) {
if (is_front_left_inside()) {
set_mark1_null();
paint_current_position();
goto PAINTER_ALGORITHM_PAINT;
}
} else if (get_mark_null() == TRUE) {
set_mark(get_current_position());
set_mark_null(FALSE);
set_mark_dir(get_cur_dir());
set_mark2_null(TRUE);
set_findloop(FALSE);
set_backtrack(FALSE);
} else if (get_mark1_null()) {
set_mark1(get_current_position());
unset_mark1_null();
set_mark1_dir(get_cur_dir());
set_mark2_null();
unset_findloop();
unset_backtrack();
} else {
if (get_mark2_null() == TRUE) {
if (get_current_position() == get_mark()) {
if (get_cur_dir() == get_mark_dir()) {
set_mark_null(TRUE);
if (get_mark2_null()) {
if (get_current_position() == get_mark1()) {
if (get_cur_dir() == get_mark1_dir()) {
set_mark1_null();
reverse_direction();
set_playfield_is_marked_flag(get_current_position());
paint_current_position();
goto PAINTER_ALGORITHM_PAINT;
} else {
set_backtrack(TRUE);
set_findloop(FALSE);
set_cur_dir(get_mark_dir());
set_backtrack();
unset_findloop();
set_cur_dir(get_mark1_dir());
}
} else if (get_findloop() == TRUE) {
} else if (get_findloop()) {
set_mark2(get_current_position());
set_mark2_null(FALSE);
unset_mark2_null();
set_mark2_dir(get_cur_dir());
}
} else {
if (get_current_position() == get_mark()) {
if (get_current_position() == get_mark1()) {
set_current_position(get_mark2());
set_cur_dir(get_mark2_dir());
set_mark_null(TRUE);
set_mark2_null(TRUE);
set_backtrack(FALSE);
set_mark1_null();
set_mark2_null();
unset_backtrack();
reverse_direction();
set_playfield_is_marked_flag(get_current_position());
paint_current_position();
goto PAINTER_ALGORITHM_PAINT;
} else if (get_current_position() == get_mark2()) {
set_mark(get_current_position());
set_mark_null(FALSE);
set_mark1(get_current_position());
unset_mark1_null();
set_cur_dir(get_mark2_dir());
set_mark_dir(get_mark2_dir());
set_mark2_null(TRUE);
set_mark1_dir(get_mark2_dir());
set_mark2_null();
}
}
}
break;
case 3:
set_mark_null(TRUE);
set_playfield_is_marked_flag(get_current_position());
set_mark1_null();
paint_current_position();
goto PAINTER_ALGORITHM_PAINT;
break;
case 4:
set_playfield_is_marked_flag(get_current_position());
paint_current_position();
return;
}
}
Expand Down
Loading