Add Team and Bag pages to the Start menu #13
No files matched your search
@@ -130,6 +130,7 @@ int save_menu_input(unsigned keys, int can_open, const struct Location *location
|
|||||||
void draw_save_menu(void);
|
void draw_save_menu(void);
|
||||||
void draw_menu_scene(int x, int y);
|
void draw_menu_scene(int x, int y);
|
||||||
int menu_redraw_is_panel(enum SaveMenuPhase before, enum SaveMenuPhase after);
|
int menu_redraw_is_panel(enum SaveMenuPhase before, enum SaveMenuPhase after);
|
||||||
|
void draw_menu_panel(enum SaveMenuPhase before);
|
||||||
void draw_bag(void);
|
void draw_bag(void);
|
||||||
int has_caught(enum Species kind);
|
int has_caught(enum Species kind);
|
||||||
int near_npc(int x, int y);
|
int near_npc(int x, int y);
|
||||||
|
|||||||
+1
-1
@@ -95,7 +95,7 @@ int main(void)
|
|||||||
if (menu_changed) {
|
if (menu_changed) {
|
||||||
int panel_only = menu_redraw_is_panel(menu_before, save_menu.phase);
|
int panel_only = menu_redraw_is_panel(menu_before, save_menu.phase);
|
||||||
if (!panel_only) DISPLAY = 0x0080;
|
if (!panel_only) DISPLAY = 0x0080;
|
||||||
if (panel_only) draw_save_menu();
|
if (panel_only) draw_menu_panel(menu_before);
|
||||||
else draw_menu_scene(x, y);
|
else draw_menu_scene(x, y);
|
||||||
present_frame();
|
present_frame();
|
||||||
if (!panel_only) DISPLAY = 0x0403;
|
if (!panel_only) DISPLAY = 0x0403;
|
||||||
|
|||||||
+26
-3
@@ -2,6 +2,26 @@
|
|||||||
|
|
||||||
struct SaveMenuState save_menu;
|
struct SaveMenuState save_menu;
|
||||||
static int team_member, team_parent;
|
static int team_member, team_parent;
|
||||||
|
static u16 panel_underlay[SAVE_MENU_H][SAVE_MENU_W];
|
||||||
|
|
||||||
|
static void copy_panel_underlay(int restoring)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < SAVE_MENU_H; ++y)
|
||||||
|
for (int x = 0; x < SAVE_MENU_W; ++x) {
|
||||||
|
int pixel = (SAVE_MENU_Y + y) * WIDTH + SAVE_MENU_X + x;
|
||||||
|
if (restoring) SCREEN[pixel] = panel_underlay[y][x];
|
||||||
|
else panel_underlay[y][x] = SCREEN[pixel];
|
||||||
|
}
|
||||||
|
if (restoring) mark_dirty(SAVE_MENU_X, SAVE_MENU_Y, SAVE_MENU_W, SAVE_MENU_H);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_menu_panel(enum SaveMenuPhase before)
|
||||||
|
{
|
||||||
|
/* World stays paused; fullscreen returns recapture after rebuilding actors/HUD. */
|
||||||
|
if (before == SAVE_MENU_CLOSED) copy_panel_underlay(0);
|
||||||
|
if (save_menu.phase == SAVE_MENU_CLOSED) copy_panel_underlay(1);
|
||||||
|
else draw_save_menu();
|
||||||
|
}
|
||||||
|
|
||||||
int save_menu_input(unsigned keys, int can_open, const struct Location *location)
|
int save_menu_input(unsigned keys, int can_open, const struct Location *location)
|
||||||
{
|
{
|
||||||
@@ -70,14 +90,17 @@ void draw_menu_scene(int x, int y)
|
|||||||
else if (save_menu.phase == SAVE_MENU_BAG) draw_bag();
|
else if (save_menu.phase == SAVE_MENU_BAG) draw_bag();
|
||||||
else {
|
else {
|
||||||
draw_scene(x, y);
|
draw_scene(x, y);
|
||||||
if (save_menu.phase != SAVE_MENU_CLOSED) draw_save_menu();
|
if (save_menu.phase != SAVE_MENU_CLOSED) {
|
||||||
|
copy_panel_underlay(0);
|
||||||
|
draw_save_menu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int menu_redraw_is_panel(enum SaveMenuPhase before, enum SaveMenuPhase after)
|
int menu_redraw_is_panel(enum SaveMenuPhase before, enum SaveMenuPhase after)
|
||||||
{
|
{
|
||||||
return before >= SAVE_MENU_OPTIONS && before <= SAVE_MENU_FAILED &&
|
return before <= SAVE_MENU_FAILED && after <= SAVE_MENU_FAILED &&
|
||||||
after >= SAVE_MENU_OPTIONS && after <= SAVE_MENU_FAILED;
|
(before != SAVE_MENU_CLOSED || after != SAVE_MENU_CLOSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_save_menu(void)
|
void draw_save_menu(void)
|
||||||
|
|||||||
+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 from = SAVE_MENU_CLOSED; from <= SAVE_MENU_BAG; ++from)
|
||||||
for (int to = SAVE_MENU_CLOSED; to <= SAVE_MENU_BAG; ++to)
|
for (int to = SAVE_MENU_CLOSED; to <= SAVE_MENU_BAG; ++to)
|
||||||
assert(menu_redraw_is_panel((enum SaveMenuPhase)from, (enum SaveMenuPhase)to) ==
|
assert(menu_redraw_is_panel((enum SaveMenuPhase)from, (enum SaveMenuPhase)to) ==
|
||||||
(from >= SAVE_MENU_OPTIONS && from <= SAVE_MENU_FAILED &&
|
(from <= SAVE_MENU_FAILED && to <= SAVE_MENU_FAILED &&
|
||||||
to >= SAVE_MENU_OPTIONS && to <= SAVE_MENU_FAILED));
|
(from != SAVE_MENU_CLOSED || to != SAVE_MENU_CLOSED)));
|
||||||
for (int room = OUTSIDE; room < ROOM_COUNT; ++room) {
|
for (int room = OUTSIDE; room < ROOM_COUNT; ++room) {
|
||||||
current_room = (enum Room)room;
|
current_room = (enum Room)room;
|
||||||
for (int up = 0; up < 2; ++up) {
|
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};
|
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)
|
void check_save_menu(void)
|
||||||
{
|
{
|
||||||
unsigned char saved[sizeof(test_save)];
|
unsigned char saved[sizeof(test_save)];
|
||||||
@@ -236,5 +320,6 @@ void check_save_menu(void)
|
|||||||
current_room = old_room;
|
current_room = old_room;
|
||||||
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
|
save_menu = (struct SaveMenuState){SAVE_MENU_CLOSED, 0, 0};
|
||||||
check_highlight_redraw();
|
check_highlight_redraw();
|
||||||
|
check_panel_underlay();
|
||||||
check_submenus();
|
check_submenus();
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user