Avoid blanking the display for menu highlight changes

This commit is contained in:
LyokoAgents committed 2026-10-29 00:37:08 +00:00
1 parent 79a27ccbae
commit 4bc31ea1fc
4 files changed
+65 -5

No files matched your search

+51
View File
@@ -86,6 +86,56 @@ static void check_submenus(void)
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
}
static void check_highlight_redraw(void)
{
static u16 before[WIDTH * HEIGHT], visible[WIDTH * HEIGHT];
unsigned char saved[sizeof(test_save)];
memcpy(saved, test_save, sizeof(saved));
enum Room old_room = current_room;
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));
for (int room = OUTSIDE; room < ROOM_COUNT; ++room) {
current_room = (enum Room)room;
for (int up = 0; up < 2; ++up) {
save_menu = (struct SaveMenuState){SAVE_MENU_OPTIONS, 0, 0};
draw_menu_scene(108, 103);
copy_pending_rows(visible);
for (int step = 0; step < MENU_COUNT; ++step) {
memcpy(before, SCREEN, sizeof(before));
enum SaveMenuPhase previous = save_menu.phase;
press(up ? UP : DOWN);
assert(save_menu.selection == (up ? (MENU_COUNT - step - 1) % MENU_COUNT : (step + 1) % MENU_COUNT));
assert(menu_redraw_is_panel(previous, save_menu.phase));
assert(!menu_input(up ? UP : DOWN, 1));
reset_dirty_rows();
test_pixels[0] = test_pixels[WIDTH * HEIGHT + 1] = 0xbeef;
draw_save_menu();
assert(pending_pixels() == SAVE_MENU_W * SAVE_MENU_H);
for (int y = 0; y < HEIGHT; ++y)
for (int x = 0; x < WIDTH; ++x)
if (x < SAVE_MENU_X || x >= SAVE_MENU_X + SAVE_MENU_W ||
y < SAVE_MENU_Y || y >= SAVE_MENU_Y + SAVE_MENU_H)
assert(SCREEN[y * WIDTH + x] == before[y * WIDTH + x]);
assert(memcmp(before, SCREEN, sizeof(before)) != 0);
assert(test_pixels[0] == 0xbeef && test_pixels[WIDTH * HEIGHT + 1] == 0xbeef);
copy_pending_rows(visible);
assert(memcmp(visible, SCREEN, sizeof(visible)) == 0);
if (room == OUTSIDE && !up) {
const char *paths[] = {"build/highlight-team-preview.ppm", "build/highlight-bag-preview.ppm",
"build/highlight-save-preview.ppm", "build/highlight-close-preview.ppm"};
write_preview(paths[save_menu.selection]);
}
}
}
}
assert(memcmp(saved, test_save, sizeof(saved)) == 0);
current_room = old_room;
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
}
void check_save_menu(void)
{
unsigned char saved[sizeof(test_save)];
@@ -185,5 +235,6 @@ void check_save_menu(void)
assert(random_state == rng && grass_steps == grass && door_open == door);
current_room = old_room;
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
check_highlight_redraw();
check_submenus();
}