Files
gen1recomp/tests/drivers/crystal_intro_shots.lua
T
bryanthaboi ca4d3d283c Add Pokemon Crystal as a sixth supported version
Crystal boots from a user-supplied ROM, imports a full cache and is playable:
copyright, the Crystal intro movie, the animated title, gender select, Oak,
and out into Johto. 122 of the cart's 169 script specials are implemented.

Import and data
- tools/make_crystal_manifest.py derives the manifest by importing
  make_gold_manifest as a library, with three additive keyword seams. Gold and
  Silver still regenerate byte-identical, which is the standing requirement for
  touching that generator.
- crystal_symbol_deltas.py and crystal_movie_symbols.py carry the symbol delta:
  Crystal renames the credits mons, splits the trainer card, Pokegear and
  pack-pal blocks by gender, and replaces the intro and title outright.
- Crystal-only manifest keys: engineFlagOrder (162 flags to Gold's 93, so the
  badge block sits one higher) and unownCharmap (the main charmap parser stops
  at the first newcharmap so the two cannot contaminate each other).

Extractor
- RomExtractorGen2 becomes three-edition. Crystal corrections: PAL_MAP_BANK
  0x13, a flat PICS_FIX pic bank, audio bank 0x5e, the mapSongs id-100 hole,
  seven NPC trades, a TradeTexts stride of 8, the five Crystal tileset anim
  steps with per-row degrade, and the column-major trainer card portraits.
- New: animated front sprites (frames, bitmasks, play and idle scripts), the
  Battle Tower roster, Kris assets, Mobile System GB art, and the Crystal
  intro and title via src/import/CrystalMovie.lua.

Engine
- GameVersion gains engine(id) and fixes(id). Gold and Silver keep their
  original bugs where the bug is not hardware dependent; Crystal gets the fixes
  Crystal shipped: Lucky Number boxes 10-14, surfing onto an NPC, and the
  Reflect and Light Screen defence overflow.
- Crystal story: Suicune and Eusine, Celebi behind the GS Ball flag, the Ruins
  of Alph chambers, Buena, the Move Tutor, the Poke Seer, and the Battle Tower
  including the wInBattleTowerBattle badge-boost guard.
- Kris and the gender flag, animated fronts in battle and the summary screen,
  and mon caught data.

Verification
- Every extracted asset is pixel-compared against pret's own source PNGs.
- Gold caches are byte-identical before and after, file for file.
- New Crystal suites plus a T2 Gen 2 tier; the full suite passes.
2026-08-23 12:10:28 -04:00

118 lines
3.6 KiB
Lua

local U = require("tests.drivers.util")
local CrystalIntro = require("src.ui.gen2.CrystalIntro")
local TitleState = require("src.ui.gen2.TitleState")
local INTERVAL = 20
local LIMIT = 4000
return function(game)
local out = os.getenv("POKEPORT_SHOT_DIR") or "/tmp/crystal-intro"
local interval = tonumber(os.getenv("POKEPORT_SHOT_INTERVAL") or "")
or INTERVAL
U.wait(30)
local assets = game.data and game.data.gen2Intro
if not (assets and assets.acts) then
U.log("SKIP no crystal intro acts in this cache -- re-import crystal")
return
end
local finished = false
local intro = CrystalIntro.new(game, {
onDone = function() finished = true end,
})
game.stack:clear()
game.stack:push(intro)
local shots, scene = 0, 0
while not finished and intro.frames < LIMIT do
U.wait(interval)
if intro.scene ~= scene then
scene = intro.scene
U.log(("scene %d at frame %d (scx=%02x scy=%02x)")
:format(scene, intro.frames, intro.scx % 256, intro.scy % 256))
end
if not finished then
U.shot(game, ("%s/intro-%04d-scene%02d.png")
:format(out, intro.frames, intro.scene))
shots = shots + 1
end
end
assert(finished,
"the movie never reached IntroScene28 (frame " .. intro.frames .. ")")
U.log(("movie done: %d shots over %d frames"):format(shots, intro.frames))
local skipped = false
local intro2 = CrystalIntro.new(game, {
onDone = function() skipped = true end,
})
game.stack:clear()
game.stack:push(intro2)
U.wait(45)
U.tap(game, "b")
U.wait(3)
assert(skipped and intro2.skipped, "a button did not skip the intro")
U.log("skip via B verified at frame " .. intro2.frames)
game:showTitle()
U.wait(1)
local title = game.stack:top()
assert(getmetatable(title) == TitleState,
"showTitle left " .. tostring(title) .. " on the stack")
assert(#title.suicuneColor == 4,
"title.lua has no 4-frame Suicune set -- stale cache?")
assert(title.entrance, "title.lua has no entrance block -- stale cache?")
assert(title.suicuneX == 48 and title.suicuneY == 96,
("Suicune is at (%s, %s), expected (48, 96)")
:format(tostring(title.suicuneX), tostring(title.suicuneY)))
for i = 1, 4 do
U.shot(game, ("%s/title-entrance-%d.png"):format(out, i))
U.wait(4)
end
for _ = 1, 90 do
if title.entranceScx == 0 then break end
U.wait(1)
end
assert(title.entranceScx == 0, "the entrance never landed")
assert(title.gemY == title.gemRestY,
("gem y %s did not land at %s with the entrance")
:format(tostring(title.gemY), tostring(title.gemRestY)))
U.wait(2)
for i = 1, 5 do
U.shot(game, ("%s/title-suicune-%d.png"):format(out, i))
U.wait(6)
end
if love.window and love.window.setMode then
for _, shape in ipairs({ { 1280, 720 }, { 1920, 500 }, { 480, 800 } }) do
love.window.setMode(shape[1], shape[2], { resizable = true })
U.wait(3)
U.shot(game, ("%s/title-wide-%dx%d.png"):format(out, shape[1], shape[2]))
end
love.window.setMode(1280, 720, { resizable = true })
end
local intro3 = CrystalIntro.new(game, {})
game.stack:clear()
game.stack:push(intro3)
local function runTo(target, extra)
for _ = 1, LIMIT do
if intro3.scene >= target then break end
U.wait(5)
end
assert(intro3.scene >= target,
"widescreen pass never reached scene " .. target)
U.wait(extra)
end
runTo(4, 40)
U.shot(game, out .. "/intro-wide-scene04.png")
runTo(10, 60)
U.shot(game, out .. "/intro-wide-scene10.png")
runTo(18, 20)
U.shot(game, out .. "/intro-wide-scene18.png")
intro3:skip()
U.log(("PASS crystal intro + title shots in %s"):format(out))
end