Regression coverage for the four Yellow Pallet Town fixes on this
branch:
- tests/parity_J.lua: the old-man-style demo bag shows x1 in Yellow
(SimulatedInputBattleItemList), not just the pre-existing x50
(pokered's OldManItemList) case.
- tests/engine/push_battle_transition.lua: Commands.pushBattle calls
ctx.overworld:pushBattle when available and falls back with a
logged warning otherwise. Logger.warn is spied (pcall-safe, always
restored) rather than read off the shared Logger.history ring
buffer, so the fallback checks don't leave noise behind for
whatever else runs in the same process.
- tests/parity_yellow_pallet_pikachu.lua: drives the real onStep
closure through the real StateStack/OverworldState, with no mocked
battle -- Red never plays Music_MuseumGuy for this escort (Blue
shares the same code path: onStep only branches on
GameVersion.isYellow(), never isBlue(), so a separate Blue run
would exercise nothing new), and Yellow's hold before the Pikachu
battle is armed for exactly 2 frames before handing off to
BattleTransition rather than a bare stack push. Stops there rather
than also driving the demo battle to completion just to assert
Music_MuseumGuy fires in Yellow (that fix's own coverage): the
extra coupling to unrelated battle menu/bag/throw frame budgets
wasn't worth it for one more assertion. That side stays manually
verified. scenario() restores Game/GameVersion and re-inits
StateStack on the way out.
All three pass standalone (luajit tests/<path>). The Yellow E2E test
hits the same pre-existing "Music.playMap is nil" gap three other
map-warping parity tests already hit inside the aggregated
tests/run_tests.lua run (missing data/generated/audio.lua in this dev
environment) -- confirmed by diffing the identical error text against
parity_warp_after_warp_step.lua, which also passes clean standalone.
story2.lua pushed the demo battle straight onto the stack, skipping
the flash + wipe that every other wild battle gets.
InitWildBattle calls DoBattleTransitionAndInitBattleVariables
unconditionally (core.asm:6699) -- there is no BATTLE_TYPE_OLD_MAN or
BATTLE_TYPE_PIKACHU special case -- so the old-man tutorial and Oak's
Pikachu catch get the wipe like any other wild battle, same as every
scripted trainer. Commands.old_man_demo already routed the Viridian
old man's tutorial catch through OverworldState:pushBattle for
exactly this reason; the fallback it used for a pushBattle-less
overworld (ctx.overworld and ctx.overworld.pushBattle then ... else
game.stack:push(battle)) was duplicated verbatim in Commands
.start_battle and would have been a third copy in story2.lua, so it's
pulled into one Commands.pushBattle(ctx, battle) helper instead, used
by all three call sites; the fallback branch now logs a warning
rather than silently dropping the transition and battle-theme start.
Confirmed against pokeyellow's engine/battle/core.asm: the Viridian
old man's demo and Oak's Pikachu catch share the same canned
one-item bag (SimulatedInputBattleItemList), quantity 1 -- pokered's
equivalent (OldManItemList, old man only, no Pikachu battle type) is
quantity 50. The port hardcoded x50 for both versions.
oak.facing was set and the battle pushed in the same synchronous
callback, so the overworld never rendered a frame of Oak already
turned toward the grass before the screen cut to battle.
Traced home/overworld.asm: PalletTownOakGreetsPlayerScript (the turn)
and PalletTownPikachuBattleScript (arming wCurOpponent) are separate
script ticks, one main-loop iteration apart. OverworldLoopLessDelay
burns two DelayFrame calls per iteration, calls RunMapScript (via
JoypadOverworld) first, and only then checks wCurOpponent to jump
into the battle -- so the turn from iteration A is on screen for the
two DelayFrame calls that open iteration B, before that same
iteration's RunMapScript arms wCurOpponent and falls straight into
the battle check. hold(2, ...) restores exactly that beat.
Yellow's Pallet Town intro (professor catches the wild Pikachu, then
walks the player to the lab) played the map's default Pallet Town
theme the whole time instead of the dedicated escort cue. Per
pokeyellow's actual scripts: PlayDefaultMusicFadeOutCurrent (run on
every battle exit) legitimately restores Pallet Town's theme after
the Pikachu demo battle for the Whew.../Come with me lines; the
escort cue (MUSIC_MUSEUM_GUY, the same "led by an NPC" theme Pewter's
museum guide uses) only starts in PalletMovementScript_OakMoveLeft,
the first function of the escort script -- but only in pokeyellow's
copy. pokered's copy of that same shared Red/Yellow function only
sets BIT_NO_MAP_MUSIC and leaves whatever was already playing
(MUSIC_MEET_PROF_OAK) running uninterrupted into the lab.
Start Music_MuseumGuy at the top of escortToLab, gated on Yellow so
Red/Blue keeps its unchanged behavior, and fix the Oak-escort warp's
keepMusic comment to say which song rides the warp in each version.
Expose a non-blocking TLS socket API to mods (WSS clients) without bundling
any game-specific multiworld content.
Co-authored-by: Cursor <cursoragent@cursor.com>