Avoid blanking when opening and closing the sidebar
This commit is contained in:
4 files changed
+115
-6
No files matched your search
+87
-2
@@ -95,8 +95,8 @@ static void check_highlight_redraw(void)
|
||||
for (int from = SAVE_MENU_CLOSED; from <= SAVE_MENU_BAG; ++from)
|
||||
for (int to = SAVE_MENU_CLOSED; to <= SAVE_MENU_BAG; ++to)
|
||||
assert(menu_redraw_is_panel((enum SaveMenuPhase)from, (enum SaveMenuPhase)to) ==
|
||||
(from >= SAVE_MENU_OPTIONS && from <= SAVE_MENU_FAILED &&
|
||||
to >= SAVE_MENU_OPTIONS && to <= SAVE_MENU_FAILED));
|
||||
(from <= SAVE_MENU_FAILED && to <= SAVE_MENU_FAILED &&
|
||||
(from != SAVE_MENU_CLOSED || to != SAVE_MENU_CLOSED)));
|
||||
for (int room = OUTSIDE; room < ROOM_COUNT; ++room) {
|
||||
current_room = (enum Room)room;
|
||||
for (int up = 0; up < 2; ++up) {
|
||||
@@ -136,6 +136,90 @@ static void check_highlight_redraw(void)
|
||||
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
|
||||
}
|
||||
|
||||
static void check_panel_underlay(void)
|
||||
{
|
||||
static u16 expected[WIDTH * HEIGHT], visible[WIDTH * HEIGHT];
|
||||
unsigned char saved[sizeof(test_save)];
|
||||
memcpy(saved, test_save, sizeof(saved));
|
||||
partner_owned = caught_count = 1; active_member = 0;
|
||||
caught_species[0] = TIDEFIN;
|
||||
for (int room = OUTSIDE; room < ROOM_COUNT; ++room)
|
||||
for (int facing = FACING_DOWN; facing <= FACING_RIGHT; ++facing) {
|
||||
current_room = (enum Room)room;
|
||||
player_facing = (enum Facing)facing;
|
||||
int x = indoors() ? 200 : room == ROUTE ? 207 : 210;
|
||||
int y = room == BEACH ? 85 : 119;
|
||||
reset_follower(x - 14, y);
|
||||
render_scene(x, y);
|
||||
memcpy(expected, SCREEN, sizeof(expected));
|
||||
copy_pending_rows(visible);
|
||||
int fx = follower_x, fy = follower_y, head = trail_head;
|
||||
for (int phase = SAVE_MENU_OPTIONS; phase <= SAVE_MENU_FAILED; ++phase) {
|
||||
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
|
||||
if (room == OUTSIDE && facing == FACING_DOWN && phase == SAVE_MENU_OPTIONS)
|
||||
write_preview("build/panel-before-preview.ppm");
|
||||
press(START);
|
||||
assert(menu_redraw_is_panel(SAVE_MENU_CLOSED, save_menu.phase));
|
||||
draw_menu_panel(SAVE_MENU_CLOSED);
|
||||
assert(pending_pixels() == SAVE_MENU_W * SAVE_MENU_H);
|
||||
copy_pending_rows(visible);
|
||||
assert(!menu_input(START, 1));
|
||||
for (int py = 0; py < HEIGHT; ++py)
|
||||
for (int px = 0; px < WIDTH; ++px)
|
||||
if (px < SAVE_MENU_X || px >= SAVE_MENU_X + SAVE_MENU_W ||
|
||||
py < SAVE_MENU_Y || py >= SAVE_MENU_Y + SAVE_MENU_H)
|
||||
assert(SCREEN[py * WIDTH + px] == expected[py * WIDTH + px]);
|
||||
save_menu.phase = (enum SaveMenuPhase)phase;
|
||||
draw_menu_panel(SAVE_MENU_OPTIONS);
|
||||
assert(pending_pixels() == SAVE_MENU_W * SAVE_MENU_H);
|
||||
copy_pending_rows(visible);
|
||||
if (room == OUTSIDE && facing == FACING_DOWN && phase == SAVE_MENU_OPTIONS)
|
||||
write_preview("build/panel-open-preview.ppm");
|
||||
unsigned close = phase == SAVE_MENU_OPTIONS ? B : phase == SAVE_MENU_SAVED ? A : START;
|
||||
press(close);
|
||||
assert(save_menu.phase == SAVE_MENU_CLOSED);
|
||||
assert(menu_redraw_is_panel((enum SaveMenuPhase)phase, save_menu.phase));
|
||||
draw_menu_panel((enum SaveMenuPhase)phase);
|
||||
assert(pending_pixels() == SAVE_MENU_W * SAVE_MENU_H);
|
||||
assert(memcmp(expected, SCREEN, sizeof(expected)) == 0);
|
||||
copy_pending_rows(visible);
|
||||
assert(memcmp(expected, visible, sizeof(expected)) == 0);
|
||||
assert(!menu_input(close, 1));
|
||||
if (room == OUTSIDE && facing == FACING_DOWN && phase == SAVE_MENU_OPTIONS)
|
||||
write_preview("build/panel-closed-preview.ppm");
|
||||
}
|
||||
assert(player_facing == (enum Facing)facing && follower_x == fx && follower_y == fy && trail_head == head);
|
||||
/* A partner change on a fullscreen page must replace, not reuse, old underlay. */
|
||||
press(START); draw_menu_panel(SAVE_MENU_CLOSED);
|
||||
press(A); assert(save_menu.phase == SAVE_MENU_TEAM); draw_menu_scene(x, y);
|
||||
press(RIGHT); release_keys();
|
||||
const struct Location here = {room, x, y, facing};
|
||||
assert(save_menu_input(A, 1, &here));
|
||||
assert(active_member == 1 && save_menu.phase == SAVE_MENU_OPTIONS);
|
||||
render_scene(x, y); memcpy(expected, SCREEN, sizeof(expected));
|
||||
draw_menu_scene(x, y); copy_pending_rows(visible);
|
||||
press(B); draw_menu_panel(SAVE_MENU_OPTIONS);
|
||||
assert(pending_pixels() == SAVE_MENU_W * SAVE_MENU_H);
|
||||
assert(memcmp(expected, SCREEN, sizeof(expected)) == 0);
|
||||
copy_pending_rows(visible);
|
||||
assert(memcmp(expected, visible, sizeof(expected)) == 0);
|
||||
press(START); draw_menu_panel(SAVE_MENU_CLOSED);
|
||||
press(DOWN); press(A); assert(save_menu.phase == SAVE_MENU_BAG);
|
||||
draw_menu_scene(x, y);
|
||||
press(B); draw_menu_scene(x, y); copy_pending_rows(visible);
|
||||
press(B); draw_menu_panel(SAVE_MENU_OPTIONS);
|
||||
assert(pending_pixels() == SAVE_MENU_W * SAVE_MENU_H);
|
||||
assert(memcmp(expected, SCREEN, sizeof(expected)) == 0);
|
||||
copy_pending_rows(visible);
|
||||
assert(memcmp(expected, visible, sizeof(expected)) == 0);
|
||||
active_member = 0;
|
||||
assert(test_pixels[0] == 0xbeef && test_pixels[WIDTH * HEIGHT + 1] == 0xbeef);
|
||||
}
|
||||
assert(memcmp(saved, test_save, sizeof(saved)) == 0);
|
||||
load_progress();
|
||||
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
|
||||
}
|
||||
|
||||
void check_save_menu(void)
|
||||
{
|
||||
unsigned char saved[sizeof(test_save)];
|
||||
@@ -236,5 +320,6 @@ void check_save_menu(void)
|
||||
current_room = old_room;
|
||||
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
|
||||
check_highlight_redraw();
|
||||
check_panel_underlay();
|
||||
check_submenus();
|
||||
}
|
||||
Reference in new issue
Block a user