Compare commits

..
4 Commits
8 changed files with 364 additions and 67 deletions

No files matched your search

+3 -3
View File
@@ -27,14 +27,14 @@ The game file is **game.gba**. You can also open it directly in mGBA without reb
- **Go fishing:** talk to **Fisher Coral**, the red-haired person in turquoise on the right side of Seashell Beach. Press X again to receive a reusable **Poké Rod** in your bag; choose Save from the Start menu to keep it after restarting. Bring Sprout, walk to the water's edge, face down toward the sea, and press **X** to hook **Tidefin**, an original Water-type fish. Weaken it and press **Backspace** to throw a Poké Ball. Catching still requires balls from Ranger Finn and space on your team. Older saves keep their gifts and catches. - **Go fishing:** talk to **Fisher Coral**, the red-haired person in turquoise on the right side of Seashell Beach. Press X again to receive a reusable **Poké Rod** in your bag; choose Save from the Start menu to keep it after restarting. Bring Sprout, walk to the water's edge, face down toward the sea, and press **X** to hook **Tidefin**, an original Water-type fish. Weaken it and press **Backspace** to throw a Poké Ball. Catching still requires balls from Ranger Finn and space on your team. Older saves keep their gifts and catches.
- **Get your first partner:** talk to Professor Mellon and press X to advance her conversation. She gives you **Sprout**, an original Grass-type partner at level five. This is a one-time gift; later conversations check on Sprout instead. - **Get your first partner:** talk to Professor Mellon and press X to advance her conversation. She gives you **Sprout**, an original Grass-type partner at level five. This is a one-time gift; later conversations check on Sprout instead.
- **Character artwork:** the player and Ranger Finn use boy sprites; Mila and Professor Mellon use distinct long-haired girl sprites. Mellon keeps her white coat and gray hair. Both styles have front, back, and side views. - **Character artwork:** the player and Ranger Finn use boy sprites; Mila and Professor Mellon use distinct long-haired girl sprites. Mellon keeps her white coat and gray hair. Both styles have front, back, and side views.
- **Backspace (GBA Select button):** open your team. Use Left/Right to browse Sprout and your caught creatures, then press **X (A)** to choose the displayed creature as your following and battling partner. Backspace or Z (B) returns without changing your choice. Choose Save from the Start menu to retain your selection. Movement pauses while the team screen is open. - **Backspace (GBA Select button):** open your team directly while exploring. Use Left/Right to browse Sprout and your caught creatures, then press **X (A)** to choose the displayed creature as your following and battling partner and return. Backspace or Z (B) returns without changing your choice. Team opened directly returns to the world; Team opened from Start returns to the sidebar. Choose Save from the Start menu to retain your selection.
- **Your partner follows you:** Sprout or your selected caught creature follows your path and travels through doors and map exits with you. Each uses its own artwork. Choose Sprout again from the team screen whenever you like. - **Your partner follows you:** Sprout or your selected caught creature follows your path and travels through doors and map exits with you. Each uses its own artwork. Choose Sprout again from the team screen whenever you like.
- **Battle the golden creature:** with Sprout on your team, walk close to the golden creature in Greenleaf Village and press X. Use Left/Right to choose **Tackle** or **Leaf Tap**, then X to attack. The golden creature responds with Bump. Press Z (B) to run away. At the result screen, press X or Z to return to the map. Sprout recovers fully after each battle. - **Battle the golden creature:** with Sprout on your team, walk close to the golden creature in Greenleaf Village and press X. Use Left/Right to choose **Tackle** or **Leaf Tap**, then X to attack. The golden creature responds with Bump. Press Z (B) to run away. At the result screen, press X or Z to return to the map. Sprout recovers fully after each battle.
- **Wild encounters:** with Sprout, walk around either tall-grass patch on Sunpetal Trail. **Fernfox** (Grass), **Emberwing** (Fire), or **Pebblit** (Rock) can appear automatically. Each has its own original 24×24 sprite, palette, health, and attack. Encounters only happen while moving in grass, with a short breather between battles. Leaf Tap is stronger against Pebblit and weaker against Emberwing. Fighting and running use the same keys as the golden-creature battle. - **Wild encounters:** with Sprout, walk around either tall-grass patch on Sunpetal Trail. **Fernfox** (Grass), **Emberwing** (Fire), or **Pebblit** (Rock) can appear automatically. Each has its own original 24×24 sprite, palette, health, and attack. Encounters only happen while moving in grass, with a short breather between battles. Leaf Tap is stronger against Pebblit and weaker against Emberwing. Fighting and running use the same keys as the golden-creature battle.
- **Get Poké Balls:** talk to **Ranger Finn**, the person in orange just left of Sunpetal Trail's central path. Press X again to receive **five Poké Balls**. This gift is given once. Press Backspace to see the count on the team screen, even if you do not have Sprout yet. - **Get Poké Balls:** talk to **Ranger Finn**, the person in orange just left of Sunpetal Trail's central path. Press X again to receive **five Poké Balls**. This gift is given once. Press Backspace to see the count on the team screen, even if you do not have Sprout yet.
- **Catch a creature:** press **Backspace during a battle** to throw one Poké Ball. Lower health improves the chance; at one-quarter health or less, the catch is guaranteed. A failed throw still uses the ball and lets the creature attack. You cannot catch a fainted creature. Successful catches join your saved team, with room for Sprout plus five catches (duplicates are allowed). A full team does not waste a ball. The village's golden creature disappears from the map once caught. Press X after the catch result, then Backspace and Left/Right to view your new friend. Press X to make it your partner. - **Catch a creature:** press **Backspace during a battle** to throw one Poké Ball. Lower health improves the chance; at one-quarter health or less, the catch is guaranteed. A failed throw still uses the ball and lets the creature attack. You cannot catch a fainted creature. Successful catches join your saved team, with room for Sprout plus five catches (duplicates are allowed). A full team does not waste a ball. The village's golden creature disappears from the map once caught. Press X after the catch result, then Backspace and Left/Right to view your new friend. Press X to make it your partner.
- **Battle with caught creatures:** your selected partner fights in both land and fishing battles, using its own maximum health, Tackle, and a second move: Golden's Bump, Fernfox's Leaf Tap, Emberwing's Spark, Pebblit's Roll, or Tidefin's Water Jet. Partners recover fully after battles. Choose partners outside battle, not during a turn. - **Battle with caught creatures:** your selected partner fights in both land and fishing battles, using its own maximum health, Tackle, and a second move: Golden's Bump, Fernfox's Leaf Tap, Emberwing's Spark, Pebblit's Roll, or Tidefin's Water Jet. Partners recover fully after battles. Choose partners outside battle, not during a turn.
- **Return (GBA Start button):** open the **Save / Close** right sidebar while exploring. The world stays visible and paused. Up/Down chooses an option, X (A) activates it, and Z (B) or Return closes it. Saved/failed messages wait for a fresh X, Z, or Return press. Start no longer resets your position; the menu cannot open during conversations, battles, or the team screen. Music and S (R) mute continue working while it is open. - **Return (GBA Start button):** open the **Team / Bag / Save / Close** right sidebar while exploring. Up/Down wraps through the four options and X (A) activates one. Team uses the same screen as Select. Bag shows your Poké Ball count (including zero) and rod ownership; it is read-only, with X or Z returning to the sidebar. Z (B) closes the sidebar or returns from a submenu; Return closes the entire menu from any page. Saved/failed messages wait for a fresh X, Z, or Return press. All menu pages pause walking and encounters; closing restores the same scene and position. Start no longer resets your position, and menus cannot open during conversations or battles. Music and S (R) mute continue working while menus are open.
- **S (GBA R shoulder button):** mute or unmute the music, including during battles and menus. This setting lasts until you restart the ROM. - **S (GBA R shoulder button):** mute or unmute the music, including during battles and menus. This setting lasts until you restart the ROM.
If those keys do not match your emulator settings, check mGBA's keyboard input settings. If those keys do not match your emulator settings, check mGBA's keyboard input settings.
@@ -62,7 +62,7 @@ Those numbers mean red, green, and blue, each from 0 to 31. Try `RGB(29, 6, 6)`
- `source/story.c`: conversations and gifts. - `source/story.c`: conversations and gifts.
- `source/save.c`: versioned cartridge SRAM records and validation. - `source/save.c`: versioned cartridge SRAM records and validation.
- `source/hud.c`: map status, scene drawing, and the team screen. - `source/hud.c`: map status, scene drawing, and the team screen.
- `source/menu.c`: Save / Close sidebar input and drawing. - `source/menu.c`: Team / Bag / Save / Close menu input and drawing, including the Select shortcut.
- `source/audio.c` and `source/audio.h`: original chiptune scores and the GBA sound-channel sequencer. - `source/audio.c` and `source/audio.h`: original chiptune scores and the GBA sound-channel sequencer.
- `source/wild_creatures.h`: original wild-creature sprites and palettes. - `source/wild_creatures.h`: original wild-creature sprites and palettes.
- `source/start.s`: code that starts the GBA hardware. - `source/start.s`: code that starts the GBA hardware.
+7 -1
View File
@@ -116,7 +116,9 @@ void draw_battle(void);
void load_progress(void); void load_progress(void);
void saved_location(struct Location *out); void saved_location(struct Location *out);
int save_progress(const struct Location *location); int save_progress(const struct Location *location);
enum SaveMenuPhase { SAVE_MENU_CLOSED, SAVE_MENU_OPTIONS, SAVE_MENU_SAVED, SAVE_MENU_FAILED }; enum SaveMenuPhase { SAVE_MENU_CLOSED, SAVE_MENU_OPTIONS, SAVE_MENU_SAVED, SAVE_MENU_FAILED,
SAVE_MENU_TEAM, SAVE_MENU_BAG };
enum { MENU_TEAM, MENU_BAG, MENU_SAVE, MENU_CLOSE, MENU_COUNT };
enum { SAVE_MENU_X = 160, SAVE_MENU_Y = 6, SAVE_MENU_W = 74, SAVE_MENU_H = 148 }; enum { SAVE_MENU_X = 160, SAVE_MENU_Y = 6, SAVE_MENU_W = 74, SAVE_MENU_H = 148 };
struct SaveMenuState { struct SaveMenuState {
enum SaveMenuPhase phase; enum SaveMenuPhase phase;
@@ -126,6 +128,10 @@ struct SaveMenuState {
extern struct SaveMenuState save_menu; extern struct SaveMenuState 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);
void draw_save_menu(void); void draw_save_menu(void);
void draw_menu_scene(int x, int y);
int menu_redraw_is_panel(enum SaveMenuPhase before, enum SaveMenuPhase after);
void draw_menu_panel(enum SaveMenuPhase before);
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);
int begin_conversation(int x, int y); int begin_conversation(int x, int y);
+23 -2
View File
@@ -1,4 +1,5 @@
#include "game.h" #include "game.h"
static void draw_bag_summary(void);
void status(const char *message) void status(const char *message)
{ {
@@ -81,7 +82,14 @@ void draw_team_member(int member)
large_text(28, 76, "VISIT PROFESSOR MELLON", ink); large_text(28, 76, "VISIT PROFESSOR MELLON", ink);
text(28, 96, "HER HOUSE IS EAST OF GREENLEAF VILLAGE", ink); text(28, 96, "HER HOUSE IS EAST OF GREENLEAF VILLAGE", ink);
} }
/* A small bag summary is visible even before you receive Sprout. */ draw_bag_summary();
rectangle(0, 142, WIDTH, 18, cream);
text(8, 148, "LEFT RIGHT TEAM A CHOOSE B SELECT BACK", ink);
}
static void draw_bag_summary(void)
{
u16 ink = RGB(5, 8, 11);
rectangle(24, 118, 8, 8, ink); rectangle(24, 118, 8, 8, ink);
rectangle(25, 119, 6, 3, RGB(29, 8, 9)); rectangle(25, 119, 6, 3, RGB(29, 8, 9));
rectangle(25, 122, 6, 3, RGB(31, 31, 28)); rectangle(25, 122, 6, 3, RGB(31, 31, 28));
@@ -94,6 +102,19 @@ void draw_team_member(int member)
count_text[count_index] = 0; count_text[count_index] = 0;
text(88, 119, count_text, ink); text(88, 119, count_text, ink);
if (rod_owned) text(133, 119, "POKE ROD", ink); if (rod_owned) text(133, 119, "POKE ROD", ink);
}
void draw_bag(void)
{
u16 ink = RGB(5, 8, 11), cream = RGB(30, 30, 26);
rectangle(0, 0, WIDTH, HEIGHT, RGB(15, 24, 20));
status("YOUR BAG");
rectangle(8, 25, 224, 112, ink);
rectangle(10, 27, 220, 108, cream);
large_text(24, 45, "ITEMS", ink);
text(24, 66, "POKE BALLS ARE USED DURING BATTLE", ink);
text(24, 80, "THIS SCREEN IS READ ONLY", ink);
draw_bag_summary();
rectangle(0, 142, WIDTH, 18, cream); rectangle(0, 142, WIDTH, 18, cream);
text(8, 148, "ARROWS TEAM A CHOOSE PARTNER B BACK", ink); text(8, 148, "A B BACK START CLOSE", ink);
} }
+9 -46
View File
@@ -66,8 +66,6 @@ int main(void)
DISPLAY = 0x0080; /* Hide the screen until the scene is drawn. */ DISPLAY = 0x0080; /* Hide the screen until the scene is drawn. */
int x = 108, y = 103, frame = 0, greeting = 0; int x = 108, y = 103, frame = 0, greeting = 0;
int dialogue_page = -1; /* -1 means we are not talking. */ int dialogue_page = -1; /* -1 means we are not talking. */
int team_open = 0;
int team_member = 0;
unsigned previous = 0; unsigned previous = 0;
start_movement_timer(); start_movement_timer();
load_progress(); load_progress();
@@ -88,54 +86,29 @@ int main(void)
unsigned now = movement_time(); unsigned now = movement_time();
music_update(now); music_update(now);
if (pressed & R_BUTTON) music_toggle_mute(); if (pressed & R_BUTTON) music_toggle_mute();
int menu_was_open = save_menu.phase != SAVE_MENU_CLOSED; enum SaveMenuPhase menu_before = save_menu.phase;
const struct Location here = {current_room, x, y, player_facing}; const struct Location here = {current_room, x, y, player_facing};
int menu_changed = save_menu_input(keys, int menu_changed = save_menu_input(keys,
!team_open && battle.phase == BATTLE_OFF && dialogue_page < 0, &here); battle.phase == BATTLE_OFF && dialogue_page < 0, &here);
if (menu_was_open || save_menu.phase != SAVE_MENU_CLOSED) { if (menu_before != SAVE_MENU_CLOSED || save_menu.phase != SAVE_MENU_CLOSED) {
pause_movement_at(now); pause_movement_at(now);
if (menu_changed) { if (menu_changed) {
if (save_menu.phase == SAVE_MENU_CLOSED) { int panel_only = menu_redraw_is_panel(menu_before, save_menu.phase);
DISPLAY = 0x0080; if (!panel_only) DISPLAY = 0x0080;
draw_scene(x, y); if (panel_only) draw_menu_panel(menu_before);
else draw_menu_scene(x, y);
present_frame(); present_frame();
DISPLAY = 0x0403; if (!panel_only) DISPLAY = 0x0403;
} else {
draw_save_menu();
present_frame();
}
pause_movement_at(movement_time()); pause_movement_at(movement_time());
} else present_frame(); } else present_frame();
continue; continue;
} }
int movement_ticks = 0; int movement_ticks = 0;
if (team_open || battle.phase != BATTLE_OFF || dialogue_page >= 0) if (battle.phase != BATTLE_OFF || dialogue_page >= 0)
pause_movement_at(now); pause_movement_at(now);
else else
movement_ticks = movement_ticks_at(now); movement_ticks = movement_ticks_at(now);
random_state += 0x9e3779b9u; /* Mix in how long the player waits. */ random_state += 0x9e3779b9u; /* Mix in how long the player waits. */
if (team_open) {
if (partner_owned && (pressed & (LEFT | RIGHT))) {
int members = caught_count + 1;
team_member = (team_member + ((pressed & RIGHT) ? 1 : members - 1)) % members;
DISPLAY = 0x0080;
draw_team_member(team_member);
present_frame();
DISPLAY = 0x0403;
pause_movement_at(movement_time());
} else if (pressed & (SELECT | A | B)) {
if ((pressed & A) && choose_partner(team_member)) reset_follower(x, y);
team_open = 0;
DISPLAY = 0x0080;
draw_scene(x, y);
present_frame();
DISPLAY = 0x0403;
pause_movement_at(movement_time());
} else {
present_frame();
}
continue;
}
if (battle.phase != BATTLE_OFF) { if (battle.phase != BATTLE_OFF) {
if (battle_input(pressed)) { if (battle_input(pressed)) {
if (battle.phase == BATTLE_OFF) { if (battle.phase == BATTLE_OFF) {
@@ -177,16 +150,6 @@ int main(void)
present_frame(); present_frame();
continue; continue;
} }
if (pressed & SELECT) {
team_open = 1;
team_member = 0;
DISPLAY = 0x0080;
draw_team();
present_frame();
DISPLAY = 0x0403;
pause_movement_at(movement_time());
continue;
}
int old_x = x, old_y = y; int old_x = x, old_y = y;
int old_follower_x = follower_x, old_follower_y = follower_y; int old_follower_x = follower_x, old_follower_y = follower_y;
enum Facing old_facing = player_facing; enum Facing old_facing = player_facing;
+82 -13
View File
@@ -1,18 +1,62 @@
#include "game.h" #include "game.h"
struct SaveMenuState save_menu; struct SaveMenuState save_menu;
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)
{ {
unsigned pressed = keys & ~save_menu.previous; unsigned pressed = keys & ~save_menu.previous;
save_menu.previous = keys; save_menu.previous = keys;
if (save_menu.phase == SAVE_MENU_CLOSED) { if (save_menu.phase == SAVE_MENU_CLOSED) {
if (!can_open || !(pressed & START)) return 0; if (!can_open || !(pressed & (START | SELECT))) return 0;
save_menu.phase = SAVE_MENU_OPTIONS; save_menu.phase = pressed & START ? SAVE_MENU_OPTIONS : SAVE_MENU_TEAM;
team_parent = 0;
team_member = 0;
save_menu.selection = 0; save_menu.selection = 0;
return 1; return 1;
} }
if (pressed & (B | START)) { if (pressed & START) {
save_menu.phase = SAVE_MENU_CLOSED;
return 1;
}
if (save_menu.phase == SAVE_MENU_TEAM || save_menu.phase == SAVE_MENU_BAG) {
if (pressed & (B | SELECT | A)) {
if (save_menu.phase == SAVE_MENU_TEAM && (pressed & A) &&
!(pressed & (B | SELECT)) && choose_partner(team_member))
reset_follower(location->x, location->y);
save_menu.phase = team_parent ? SAVE_MENU_OPTIONS : SAVE_MENU_CLOSED;
return 1;
}
unsigned direction = pressed & (LEFT | RIGHT);
if (save_menu.phase == SAVE_MENU_TEAM && partner_owned &&
(direction == LEFT || direction == RIGHT)) {
int members = caught_count + 1;
team_member = (team_member + (direction == RIGHT ? 1 : members - 1)) % members;
return 1;
}
return 0;
}
if (pressed & B) {
save_menu.phase = SAVE_MENU_CLOSED; save_menu.phase = SAVE_MENU_CLOSED;
return 1; return 1;
} }
@@ -22,18 +66,43 @@ int save_menu_input(unsigned keys, int can_open, const struct Location *location
return 1; return 1;
} }
if (pressed & A) { if (pressed & A) {
if (save_menu.selection) save_menu.phase = SAVE_MENU_CLOSED; if (save_menu.selection == MENU_CLOSE) save_menu.phase = SAVE_MENU_CLOSED;
else save_menu.phase = save_progress(location) ? SAVE_MENU_SAVED : SAVE_MENU_FAILED; else if (save_menu.selection == MENU_SAVE)
save_menu.phase = save_progress(location) ? SAVE_MENU_SAVED : SAVE_MENU_FAILED;
else {
team_parent = 1;
team_member = 0;
save_menu.phase = save_menu.selection == MENU_TEAM ? SAVE_MENU_TEAM : SAVE_MENU_BAG;
}
return 1; return 1;
} }
unsigned direction = pressed & (UP | DOWN); unsigned direction = pressed & (UP | DOWN);
if (direction == UP || direction == DOWN) { if (direction == UP || direction == DOWN) {
save_menu.selection ^= 1; save_menu.selection = (save_menu.selection + (direction == DOWN ? 1 : MENU_COUNT - 1)) % MENU_COUNT;
return 1; return 1;
} }
return 0; return 0;
} }
void draw_menu_scene(int x, int y)
{
if (save_menu.phase == SAVE_MENU_TEAM) draw_team_member(team_member);
else if (save_menu.phase == SAVE_MENU_BAG) draw_bag();
else {
draw_scene(x, y);
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)
{
return before <= SAVE_MENU_FAILED && after <= SAVE_MENU_FAILED &&
(before != SAVE_MENU_CLOSED || after != SAVE_MENU_CLOSED);
}
void draw_save_menu(void) void draw_save_menu(void)
{ {
u16 ink = RGB(5, 8, 11), cream = RGB(30, 30, 26); u16 ink = RGB(5, 8, 11), cream = RGB(30, 30, 26);
@@ -42,18 +111,18 @@ void draw_save_menu(void)
rectangle(x + 2, y + 2, SAVE_MENU_W - 4, SAVE_MENU_H - 4, cream); rectangle(x + 2, y + 2, SAVE_MENU_W - 4, SAVE_MENU_H - 4, cream);
large_text(x + 16, y + 10, "MENU", ink); large_text(x + 16, y + 10, "MENU", ink);
rectangle(x + 6, y + 23, SAVE_MENU_W - 12, 1, RGB(15, 24, 20)); rectangle(x + 6, y + 23, SAVE_MENU_W - 12, 1, RGB(15, 24, 20));
text(x + 8, y + 85, "SAVES TEAM", ink); text(x + 8, y + 99, "SAVES TEAM", ink);
text(x + 8, y + 95, "ITEMS AND", ink); text(x + 8, y + 108, "ITEMS AND", ink);
text(x + 8, y + 105, "LOCATION", ink); text(x + 8, y + 117, "LOCATION", ink);
if (save_menu.phase == SAVE_MENU_OPTIONS) { if (save_menu.phase == SAVE_MENU_OPTIONS) {
int selected_y = y + 32 + save_menu.selection * 20; int selected_y = y + 28 + save_menu.selection * 16;
rectangle(x + 6, selected_y, SAVE_MENU_W - 12, 16, RGB(23, 28, 21)); rectangle(x + 6, selected_y, SAVE_MENU_W - 12, 16, RGB(23, 28, 21));
rectangle(x + 10, selected_y + 5, 1, 5, ink); rectangle(x + 10, selected_y + 5, 1, 5, ink);
rectangle(x + 11, selected_y + 6, 1, 3, ink); rectangle(x + 11, selected_y + 6, 1, 3, ink);
rectangle(x + 12, selected_y + 7, 1, 1, ink); rectangle(x + 12, selected_y + 7, 1, 1, ink);
large_text(x + 20, y + 37, "SAVE", ink); static const char *const labels[] = {"TEAM", "BAG", "SAVE", "CLOSE"};
large_text(x + 20, y + 57, "CLOSE", ink); for (int i = 0; i < MENU_COUNT; ++i) large_text(x + 20, y + 33 + i * 16, labels[i], ink);
text(x + 8, y + 124, "UP DOWN", ink); text(x + 8, y + 126, "UP DOWN", ink);
text(x + 8, y + 133, "A SELECT", ink); text(x + 8, y + 133, "A SELECT", ink);
text(x + 8, y + 142, "B START CLOSE", ink); text(x + 8, y + 142, "B START CLOSE", ink);
} else { } else {
+232 -2
View File
@@ -2,6 +2,224 @@
static void release_keys(void) { assert(!menu_input(0, 1)); } static void release_keys(void) { assert(!menu_input(0, 1)); }
static void press(unsigned keys)
{
release_keys();
assert(menu_input(keys, 1));
}
static void check_submenus(void)
{
unsigned char saved[sizeof(test_save)];
memcpy(saved, test_save, sizeof(saved));
static u16 expected[WIDTH * HEIGHT], zero[WIDTH * HEIGHT];
current_room = OUTSIDE;
int x = 108, y = 103;
player_facing = FACING_UP;
partner_owned = caught_count = active_member = ball_count = rod_owned = 0;
for (int owned = 0; owned < 2; ++owned) {
partner_owned = owned;
caught_count = owned ? 2 : 0;
caught_species[0] = FERNFOX; caught_species[1] = TIDEFIN;
for (int parent = 0; parent < 2; ++parent) {
press(parent ? START : SELECT);
if (parent) press(A);
assert(save_menu.phase == SAVE_MENU_TEAM);
assert(!menu_input(parent ? A : SELECT, 1));
draw_menu_scene(x, y);
write_preview(owned ? "build/menu-team-owned-preview.ppm" : "build/menu-team-empty-preview.ppm");
if (owned) {
press(LEFT); assert(!menu_input(LEFT, 1));
press(RIGHT); press(LEFT);
draw_menu_scene(x, y);
write_preview("build/menu-team-caught-preview.ppm");
press(A);
assert(active_member == 2);
} else {
int fx = follower_x, fy = follower_y, head = trail_head;
press(B);
assert(follower_x == fx && follower_y == fy && trail_head == head);
}
assert(save_menu.phase == (parent ? SAVE_MENU_OPTIONS : SAVE_MENU_CLOSED));
assert(!menu_input(owned ? A : B, 1));
if (parent) {
render_scene(x, y); draw_save_menu();
memcpy(expected, SCREEN, sizeof(expected));
draw_team(); draw_menu_scene(x, y);
assert(memcmp(expected, SCREEN, sizeof(expected)) == 0);
press(A); press(SELECT);
assert(save_menu.phase == SAVE_MENU_OPTIONS);
press(B);
}
render_scene(x, y); memcpy(expected, SCREEN, sizeof(expected));
draw_bag(); draw_menu_scene(x, y);
assert(memcmp(expected, SCREEN, sizeof(expected)) == 0);
}
}
press(START);
for (int i = 1; i <= MENU_COUNT; ++i) {
press(DOWN); assert(save_menu.selection == i % MENU_COUNT);
assert(!menu_input(DOWN, 1));
}
press(DOWN); press(A);
assert(save_menu.phase == SAVE_MENU_BAG);
assert(!menu_input(A, 1));
for (int full = 0; full < 2; ++full) {
ball_count = full ? 99 : 0; rod_owned = full;
test_pixels[0] = test_pixels[WIDTH * HEIGHT + 1] = 0xbeef;
reset_dirty_rows(); draw_menu_scene(x, y);
assert(pending_pixels() == WIDTH * HEIGHT);
assert(test_pixels[0] == 0xbeef && test_pixels[WIDTH * HEIGHT + 1] == 0xbeef);
write_preview(full ? "build/bag-full-preview.ppm" : "build/bag-zero-preview.ppm");
if (!full) memcpy(zero, SCREEN, sizeof(zero));
else assert(memcmp(zero, SCREEN, sizeof(zero)) != 0);
}
press(B); assert(save_menu.phase == SAVE_MENU_OPTIONS);
assert(!menu_input(B, 1));
press(A); press(START);
assert(save_menu.phase == SAVE_MENU_CLOSED && !menu_input(START, 1));
press(SELECT); press(START);
assert(save_menu.phase == SAVE_MENU_CLOSED);
assert(x == 108 && y == 103 && player_facing == FACING_UP && current_room == OUTSIDE);
assert(memcmp(saved, test_save, sizeof(saved)) == 0);
load_progress();
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_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) {
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};
}
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)];
@@ -24,7 +242,7 @@ void check_save_menu(void)
release_keys(); release_keys();
assert(menu_input(UP, 1) && save_menu.selection == 0); assert(menu_input(UP, 1) && save_menu.selection == 0);
release_keys(); release_keys();
assert(menu_input(UP, 1) && save_menu.selection == 1); assert(menu_input(UP, 1) && save_menu.selection == MENU_CLOSE);
release_keys(); release_keys();
assert(menu_input(A, 1) && save_menu.phase == SAVE_MENU_CLOSED); assert(menu_input(A, 1) && save_menu.phase == SAVE_MENU_CLOSED);
const unsigned cancel[] = {B, START}; const unsigned cancel[] = {B, START};
@@ -38,6 +256,10 @@ void check_save_menu(void)
assert(memcmp(saved, test_save, sizeof(saved)) == 0); assert(memcmp(saved, test_save, sizeof(saved)) == 0);
release_keys(); release_keys();
assert(menu_input(START, 1)); assert(menu_input(START, 1));
for (int i = 0; i < MENU_SAVE; ++i) {
release_keys();
assert(menu_input(DOWN, 1));
}
release_keys(); release_keys();
assert(menu_input(A, 1) && save_menu.phase == SAVE_MENU_SAVED); assert(menu_input(A, 1) && save_menu.phase == SAVE_MENU_SAVED);
test_save[0] = 0; test_save[0] = 0;
@@ -61,7 +283,7 @@ void check_save_menu(void)
memcpy(expected, SCREEN, sizeof(expected)); memcpy(expected, SCREEN, sizeof(expected));
for (int phase = SAVE_MENU_OPTIONS; phase <= SAVE_MENU_FAILED; ++phase) { for (int phase = SAVE_MENU_OPTIONS; phase <= SAVE_MENU_FAILED; ++phase) {
save_menu.phase = (enum SaveMenuPhase)phase; save_menu.phase = (enum SaveMenuPhase)phase;
for (int choice = 0; choice < 2; ++choice) { for (int choice = 0; choice < MENU_COUNT; ++choice) {
save_menu.selection = choice; save_menu.selection = choice;
test_pixels[0] = test_pixels[WIDTH * HEIGHT + 1] = 0xbeef; test_pixels[0] = test_pixels[WIDTH * HEIGHT + 1] = 0xbeef;
reset_dirty_rows(); reset_dirty_rows();
@@ -83,6 +305,11 @@ void check_save_menu(void)
"build/game-saved-preview.ppm", "build/save-failed-preview.ppm"}; "build/game-saved-preview.ppm", "build/save-failed-preview.ppm"};
write_preview(paths[phase - SAVE_MENU_OPTIONS]); write_preview(paths[phase - SAVE_MENU_OPTIONS]);
} }
if (room == OUTSIDE && phase == SAVE_MENU_OPTIONS) {
const char *paths[] = {"build/menu-team-preview.ppm", "build/menu-bag-preview.ppm",
"build/menu-save-preview.ppm", "build/menu-close-preview.ppm"};
write_preview(paths[choice]);
}
} }
render_scene(108, 103); render_scene(108, 103);
assert(memcmp(expected, SCREEN, sizeof(expected)) == 0); assert(memcmp(expected, SCREEN, sizeof(expected)) == 0);
@@ -92,4 +319,7 @@ void check_save_menu(void)
assert(random_state == rng && grass_steps == grass && door_open == door); assert(random_state == rng && grass_steps == grass && door_open == door);
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_panel_underlay();
check_submenus();
} }
+4
View File
@@ -56,6 +56,10 @@ void check_progress(void)
memcpy(kinds, caught_species, sizeof(kinds)); memcpy(kinds, caught_species, sizeof(kinds));
assert(!menu_input(0, 1)); assert(!menu_input(0, 1));
assert(menu_input(START, 1)); assert(menu_input(START, 1));
for (int i = 0; i < MENU_SAVE; ++i) {
assert(!menu_input(0, 1));
assert(menu_input(DOWN, 1));
}
assert(!menu_input(0, 1)); assert(!menu_input(0, 1));
assert(menu_input(A, 1) && save_menu.phase == SAVE_MENU_FAILED); assert(menu_input(A, 1) && save_menu.phase == SAVE_MENU_FAILED);
int after[] = {partner_owned, balls_given, rod_owned, ball_count, caught_count, active_member}; int after[] = {partner_owned, balls_given, rod_owned, ball_count, caught_count, active_member};
+4
View File
@@ -21,6 +21,10 @@ void save_at_menu(const struct Location *location, enum SaveMenuPhase expected)
{ {
assert(!save_menu_input(0, 1, location)); assert(!save_menu_input(0, 1, location));
assert(save_menu_input(START, 1, location) && save_menu.phase == SAVE_MENU_OPTIONS); assert(save_menu_input(START, 1, location) && save_menu.phase == SAVE_MENU_OPTIONS);
for (int i = 0; i < MENU_SAVE; ++i) {
assert(!save_menu_input(0, 1, location));
assert(save_menu_input(DOWN, 1, location));
}
assert(!save_menu_input(0, 1, location)); assert(!save_menu_input(0, 1, location));
assert(save_menu_input(A, 1, location) && save_menu.phase == expected); assert(save_menu_input(A, 1, location) && save_menu.phase == expected);
assert(!save_menu_input(0, 1, location)); assert(!save_menu_input(0, 1, location));