Open Routes 38 to 41, Olivine and Cianwood to the Mineral Badge (#32)
Checks / web (push) Successful in 1m46s
Private ROM checks / private-rom (push) Failing after 39m32s

Enable Route 38 and its Ecruteak gate, Route 39 with the MooMoo farm,
Olivine City and its buildings, the Lighthouse's six floors, Routes 40
and 41, and Cianwood City with its gym, pharmacy, Photo Studio, Mania's
house, the Poke Seer and the Lugia speech house. Olivine's port, the
Battle Tower gate and Whirl Islands stay closed. The story runs from the
rival in Olivine through Jasmine and Amphy, Suicune and Eusine, the
SecretPotion, Chuck's boulders, the STORMBADGE, TM01 and HM02, back to
Amphy's cure, Jasmine, the MINERALBADGE and TM23.

Port GiveShuckle and ReturnShuckie with every return code and Mania's
wrong last-Pokemon speech, PokeSeer with its high-byte-only OT check and
reused caught level, PhotoStudio's no-printer path (Printer Error 2),
and PlaySlowCry. wMooMooBerries joins the saved script bytes.

Port trainer item AI: the 13 healing, status and X items, the
highest-level gate, item use while Mean Look or Wrap prevents
switching, and the original's random and state quirks, checked against
the ROM over 5,632 states. Leaders with items are no longer refused.

Game Corner sprites match the original frame by frame: cursor and reel
positions, Golem's whole-frame flips, frame timing, the frame a removed
sprite is still drawn, and the Golem roll's screen shake. The Burned
Tower rival's garbage trainer header is documented as a boundary: its
seen text dispatches text command $7f into home code before any battle.

The playthrough continues for six stages to Jasmine; its driver can
Surf, fish and travel through floors joined by holes. New tests cover
trainer items, Olivine and Cianwood side content, and reference checks
for trainer items, trainer sight and Game Corner animations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kawaandClaude Opus 5.5 committed 2026-10-13 10:09:47 +02:00
1 parent 7c4e8521d4
commit b5c2b19094
29 files changed
+2708 -139

No files matched your search

+91 -12
View File
@@ -25,6 +25,9 @@ const WARP_EXITS: Partial<Record<number, Direction>> = {
0x7e: "right",
};
/** PLAYER_SURF (constants/wram_constants.asm). */
const PLAYER_SURF = 4;
/** Plays the game through the world's own inputs, as tests/playthrough
* does: scripts, battles and walking, with a seeded Random. A stage's save
* can be dumped (PLAYTHROUGH_SAVES) and resumed with `resume`. */
@@ -107,7 +110,7 @@ export class Playthrough {
const { engine } = battle,
mon = engine.player.mon;
const ball = world.liveState.bag.balls.findIndex(
(slot) => slot.item === C.POKE_BALL,
(slot) => slot.item === C.POKE_BALL || slot.item === C.GREAT_BALL,
);
const potion = world.liveState.bag.items.findIndex(
(slot) => slot.item === C.SUPER_POTION,
@@ -121,7 +124,11 @@ export class Playthrough {
!world.liveState.party.some((member) => member.species === this.wanted) &&
ball >= 0
)
world.battleAction({ action: "item", item: C.POKE_BALL, slot: ball });
world.battleAction({
action: "item",
item: world.liveState.bag.balls[ball].item,
slot: ball,
});
else if (engine.battleMode === C.WILD_BATTLE && mon.hp * 2 < mon.maxHp)
world.battleAction({ action: "run" });
else if (
@@ -213,7 +220,9 @@ export class Playthrough {
if (warp && world.mapId !== map) return;
expect(world.mapId, `walking to ${x},${y}`).toBe(map);
if (world.x === x && world.y === y) return;
for (const direction of findPath(world, x, y)) {
// A surfer crosses water until it steps ashore.
const water = world.state.playerState === PLAYER_SURF;
for (const direction of findPath(world, x, y, { water })) {
const [dx, dy] = STEP[direction];
const from = [world.x, world.y];
if (!world.move(direction)) {
@@ -233,8 +242,41 @@ export class Playthrough {
`Could not reach ${x},${y} on ${map} from ${world.x},${world.y}: ${world.notice}`,
);
};
/** Step across a map connection from the nearest usable edge tile. */
cross = (direction: Direction, target: string) => {
/** Walk and Surf to a tile: where a step leaves the shore, face the
* water and answer AskSurfScript's question with YES. */
sail = (x: number, y: number) => {
const world = this.world,
map = world.mapId;
for (let attempt = 0; attempt < 40; attempt++) {
this.play();
expect(world.mapId, `sailing to ${x},${y}`).toBe(map);
if (world.x === x && world.y === y) return;
for (const direction of findPath(world, x, y, { water: true })) {
const [dx, dy] = STEP[direction];
const from = [world.x, world.y];
const ahead = world.assets.collision(world.map, from[0] + dx, from[1] + dy);
if (world.state.playerState !== PLAYER_SURF && world.assets.permission(ahead) === 1) {
world.move(direction); // only turns to face the water
world.interact();
this.play([1]);
expect(world.state.playerState, "surfing").toBe(PLAYER_SURF);
} else if (!world.move(direction)) {
for (let tick = 0; tick < 64; tick++) world.tick();
break;
} else this.play();
if (
world.mapId !== map ||
world.x !== from[0] + dx ||
world.y !== from[1] + dy
)
break;
}
}
throw new Error(`Could not sail to ${x},${y} on ${map} from ${world.x},${world.y}`);
};
/** Step across a map connection from the nearest usable edge tile;
* `water` lets a player who can Surf reach it over the sea. */
cross = (direction: Direction, target: string, { water = false } = {}) => {
const world = this.world,
map = world.mapId;
const [dx, dy] = STEP[direction];
@@ -246,14 +288,15 @@ export class Playthrough {
: [i, dy < 0 ? 0 : world.map.height - 1],
).flatMap(([x, y]) => {
try {
return [{ x, y, length: findPath(world, x, y).length }];
return [{ x, y, length: findPath(world, x, y, { water }).length }];
} catch {
return [];
}
});
edge.sort((a, b) => a.length - b.length);
for (const { x, y } of edge) {
this.walk(x, y);
if (water) this.sail(x, y);
else this.walk(x, y);
if (world.move(direction)) {
this.play();
if (world.mapId === target) return;
@@ -416,12 +459,45 @@ export class Playthrough {
}
const from = world.mapId;
this.walk(warp.x, warp.y);
const exit = WARP_EXITS[world.assets.collision(world.map, warp.x, warp.y)];
if (world.mapId === from && exit && world.move(exit)) this.play();
if (world.mapId !== from && this.route(target, maps, depth - 1, goal))
return true;
world.restore(here);
}
return false;
};
/** The fewest warps (stairs, holes, doors) among `maps` to `target`:
* breadth first over the places each warp lands, so a maze of floors
* whose holes drop into cut-off corners is solved without looping. */
travel = (target: string, maps: string[]) => {
const world = this.world;
const queue = [world.save()];
const seen = new Set([`${world.mapId} ${world.x},${world.y}`]);
for (let i = 0; i < queue.length && i < 200; i++) {
world.restore(queue[i]);
const from = world.mapId;
for (const warp of world.map.warps) {
if (!maps.includes(warp.targetMap) && warp.targetMap !== target) continue;
world.restore(queue[i]);
try {
findPath(world, warp.x, warp.y);
} catch {
continue;
}
this.walk(warp.x, warp.y);
const exit = WARP_EXITS[world.assets.collision(world.map, warp.x, warp.y)];
if (world.mapId === from && exit && world.move(exit)) this.play();
if (world.mapId === from) continue;
if (world.mapId === target) return;
const key = `${world.mapId} ${world.x},${world.y}`;
if (seen.has(key)) continue;
seen.add(key);
queue.push(world.save());
}
}
throw new Error(`No way to ${target} through ${maps.join(", ")}`);
};
/** Advance to the next menu choice, keeping its pages in the log. */
toChoice = () => {
const world = this.world,
@@ -496,12 +572,13 @@ export class Playthrough {
* the world's own BuyMenu (BuyMenuLoop, SelectQuantityToBuy): BUY, the
* item in the stock list, the quantity, YES, back out of the list,
* then QUIT, as tests/mart.test.ts and tests/goldenrod.test.ts drive the
* martmenu/martlist/martquantity choices directly. */
* martmenu/martlist/martquantity choices directly. A pharmacy
* (MARTTYPE_PHARMACY) opens straight onto its list, with no menu. */
buy = (clerk: number, item: number, quantity: number) => {
const world = this.world;
this.talkTo(clerk);
expect(this.toChoice().kind).toBe("martmenu");
world.choose(0); // BUY
const menu = this.toChoice().kind === "martmenu";
if (menu) world.choose(0); // BUY
const list = this.toChoice();
if (list.kind !== "martlist")
throw new Error(`Expected a mart list, got ${list.kind}`);
@@ -515,8 +592,10 @@ export class Playthrough {
// "Here you are!", then the stock list again (BuyMenuLoop repeats).
expect(this.toChoice().kind).toBe("martlist");
world.choose(-1); // back to the mart's own menu
expect(this.toChoice().kind).toBe("martmenu");
world.choose(2); // QUIT
if (menu) {
expect(this.toChoice().kind).toBe("martmenu");
world.choose(2); // QUIT
}
this.play();
};
/** PACK, the TM/HM pocket's `item`, USE, YES, then party slot `slot`;