mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-25 15:01:11 +02:00
ca4d3d283c
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.
159 lines
5.8 KiB
Lua
159 lines
5.8 KiB
Lua
package.path = "./?.lua;./?/init.lua;" .. package.path
|
|
if not _G.love then _G.love = require("tests.love_stub") end
|
|
|
|
local S = require("tests.harness").suite("UWP baseroms discovery")
|
|
local check, eq = S.check, S.eq
|
|
|
|
local GameVersion = require("src.core.GameVersion")
|
|
local Platform = require("src.core.Platform")
|
|
local RomImporter = require("src.import.RomImporter")
|
|
|
|
love.data = love.data or {}
|
|
love.system = love.system or {}
|
|
love.filesystem = love.filesystem or {}
|
|
|
|
local MiB = 1024 * 1024
|
|
local roms = {
|
|
["baseroms/z-red.gb"] = string.rep("R", MiB),
|
|
["baseroms/a-blue.gb"] = string.rep("B", MiB),
|
|
["baseroms/b-yellow.gbc"] = string.rep("Y", MiB),
|
|
["baseroms/small.gb"] = "small",
|
|
["baseroms/unknown.gb"] = string.rep("?", MiB),
|
|
}
|
|
|
|
local saved = {
|
|
hash = love.data.hash,
|
|
encode = love.data.encode,
|
|
getOS = love.system.getOS,
|
|
pickFile = love.system.pickFile,
|
|
getPickedFile = love.system.getPickedFile,
|
|
read = love.filesystem.read,
|
|
getInfo = love.filesystem.getInfo,
|
|
getDirectoryItems = love.filesystem.getDirectoryItems,
|
|
createDirectory = love.filesystem.createDirectory,
|
|
isReady = RomImporter.isReady,
|
|
}
|
|
|
|
love.data.hash = function(_, data) return data:sub(1, 1) end
|
|
love.data.encode = function(_, _, digest)
|
|
if digest == "R" then return GameVersion.info("red").sha1 end
|
|
if digest == "B" then return GameVersion.info("blue").sha1 end
|
|
if digest == "Y" then return GameVersion.info("yellow").sha1 end
|
|
return "0000000000000000000000000000000000000000"
|
|
end
|
|
|
|
local reads, listings, picks = 0, 0, 0
|
|
love.filesystem.read = function(path)
|
|
reads = reads + 1
|
|
return roms[path]
|
|
end
|
|
love.filesystem.getInfo = function(path, filter)
|
|
if path == "baseroms" then
|
|
return filter and nil or { type = "directory" }
|
|
end
|
|
local data = roms[path]
|
|
if data and (not filter or filter == "file") then
|
|
return { type = "file", size = #data }
|
|
end
|
|
return nil
|
|
end
|
|
love.filesystem.getDirectoryItems = function(path)
|
|
if path ~= "baseroms" then return {} end
|
|
listings = listings + 1
|
|
return { "z-red.gb", "small.gb", "unknown.gb", "b-yellow.gbc", "a-blue.gb" }
|
|
end
|
|
love.filesystem.createDirectory = function() return true end
|
|
love.system.pickFile = function()
|
|
picks = picks + 1
|
|
return true
|
|
end
|
|
love.system.getPickedFile = function() return nil end
|
|
|
|
local function importer(ready)
|
|
return setmetatable({
|
|
baseRomDiscovery = true,
|
|
baseRoms = {},
|
|
ready = ready or { red = false, blue = false, yellow = false },
|
|
returning = {},
|
|
workState = nil,
|
|
nativePicker = true,
|
|
isNX = false,
|
|
}, RomImporter)
|
|
end
|
|
|
|
local allReady = importer({ red = true, blue = true, yellow = true, gold = true,
|
|
silver = true, crystal = true })
|
|
allReady:_queueBaseRomScan()
|
|
eq(allReady.baseRomScan.state, "done", "ready launcher skips discovery")
|
|
eq(listings, 0, "ready launcher does not enumerate baseroms")
|
|
|
|
local imp = importer()
|
|
imp:_queueBaseRomScan()
|
|
for _ = 1, 5 do
|
|
local before = reads
|
|
imp:_stepBaseRomScan()
|
|
check(reads - before <= 1, "discovery reads at most one ROM per step")
|
|
end
|
|
eq(listings, 1, "discovery enumerates baseroms once")
|
|
eq(imp.baseRoms.blue.name, "a-blue.gb", "Blue ROM is detected by SHA-1")
|
|
eq(imp.baseRoms.yellow.name, "b-yellow.gbc", "Yellow ROM is detected by SHA-1")
|
|
eq(imp.baseRoms.red.name, "z-red.gb", "Red ROM is detected by SHA-1")
|
|
eq(reads, 4, "wrong-sized files are skipped before reading")
|
|
eq(imp.baseRomScan.state, "done", "discovery stops when every missing ROM is found")
|
|
|
|
local settledReads, settledListings = reads, listings
|
|
for _ = 1, 10 do imp:_stepBaseRomScan() end
|
|
eq(reads, settledReads, "completed discovery does not read again")
|
|
eq(listings, settledListings, "completed discovery does not enumerate again")
|
|
|
|
local detected = importer()
|
|
detected.baseRoms.red = { path = "baseroms/z-red.gb", name = "z-red.gb" }
|
|
detected.startData = function(self, data, name)
|
|
self.started = { data = data, name = name }
|
|
end
|
|
detected:choose("red")
|
|
eq(detected.started.name, "z-red.gb", "detected ROM uses the normal import path")
|
|
eq(picks, 0, "detected ROM does not open the picker")
|
|
check(roms["baseroms/z-red.gb"] ~= nil, "detected ROM remains in baseroms")
|
|
|
|
local missing = importer()
|
|
missing.baseRoms.red = { path = "baseroms/gone.gb", name = "gone.gb" }
|
|
missing:choose("red")
|
|
check(missing.notice ~= nil, "missing detected ROM reports a notice")
|
|
eq(picks, 0, "missing detected ROM does not open the picker unexpectedly")
|
|
missing:choose("red")
|
|
eq(picks, 1, "the next import attempt falls back to the native picker")
|
|
|
|
local rescanned = importer({ red = true, blue = true, yellow = true, gold = true,
|
|
silver = true, crystal = true })
|
|
rescanned.baseRoms.red = { path = "baseroms/z-red.gb", name = "z-red.gb" }
|
|
rescanned:reimport("red")
|
|
check(rescanned.baseRoms.red == nil, "re-import clears the detected ROM")
|
|
eq(rescanned.baseRomScan.state, "queued", "re-import queues one fresh scan")
|
|
|
|
RomImporter.isReady = function() return false end
|
|
love.system.getOS = function() return "UWP" end
|
|
Platform._resetForTests()
|
|
local launcher = RomImporter.new(function() end, { launcher = true })
|
|
check(launcher.baseRomDiscovery, "UWP launcher enables baseroms discovery")
|
|
local importOnly = RomImporter.new(function() end)
|
|
check(not importOnly.baseRomDiscovery, "non-launcher UWP import stays unchanged")
|
|
love.system.getOS = function() return "Windows" end
|
|
Platform._resetForTests()
|
|
local desktop = RomImporter.new(function() end, { launcher = true })
|
|
check(not desktop.baseRomDiscovery, "desktop launcher does not scan baseroms")
|
|
|
|
love.data.hash = saved.hash
|
|
love.data.encode = saved.encode
|
|
love.system.getOS = saved.getOS
|
|
love.system.pickFile = saved.pickFile
|
|
love.system.getPickedFile = saved.getPickedFile
|
|
love.filesystem.read = saved.read
|
|
love.filesystem.getInfo = saved.getInfo
|
|
love.filesystem.getDirectoryItems = saved.getDirectoryItems
|
|
love.filesystem.createDirectory = saved.createDirectory
|
|
RomImporter.isReady = saved.isReady
|
|
Platform._resetForTests()
|
|
|
|
S.finish()
|