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.
147 lines
4.2 KiB
Lua
147 lines
4.2 KiB
Lua
local Catalog = {}
|
|
|
|
local function sortedKeys(t)
|
|
local keys = {}
|
|
for k in pairs(t) do
|
|
table.insert(keys, k)
|
|
end
|
|
table.sort(keys)
|
|
return keys
|
|
end
|
|
|
|
-- Gen 2's generated tables carry provenance scalars (generation, source)
|
|
-- beside the id-keyed records, so a wheel built from every key would offer
|
|
-- them as pickable entries. #1466
|
|
local function sortedRecordKeys(t)
|
|
local keys = {}
|
|
for k, v in pairs(t or {}) do
|
|
if type(v) == "table" then table.insert(keys, k) end
|
|
end
|
|
table.sort(keys)
|
|
return keys
|
|
end
|
|
|
|
function Catalog.build(data)
|
|
return {
|
|
species = sortedRecordKeys(data.pokemon),
|
|
items = sortedRecordKeys(data.items),
|
|
moves = sortedRecordKeys(data.moves),
|
|
}
|
|
end
|
|
|
|
-- Directory listing / file reading go through love.filesystem when it is
|
|
-- available, and only fall back to shelling out. That is what makes the
|
|
-- Events tab work in a packaged build: data/scripts is inside the .love
|
|
-- archive, data/generated is mounted from the save directory, and mods live
|
|
-- under the save directory too -- none of which io.open can reach by relative
|
|
-- path. The io.popen path stays for headless runs (tests/, plain lua) where
|
|
-- love.filesystem does not exist.
|
|
-- nil means "love.filesystem cannot see this directory", which is the signal
|
|
-- to fall through to the shell -- headless runs mount a stub filesystem that
|
|
-- knows nothing about the checkout, but their io.* can still read it.
|
|
local function loveListLua(dir)
|
|
local fs = love and love.filesystem
|
|
if not (fs and fs.getDirectoryItems and fs.getInfo) then return nil end
|
|
if not fs.getInfo(dir) then return nil end
|
|
local out = {}
|
|
for _, name in ipairs(fs.getDirectoryItems(dir)) do
|
|
if name:sub(-4) == ".lua" then out[#out + 1] = dir .. "/" .. name end
|
|
end
|
|
return out
|
|
end
|
|
|
|
local function shellListLua(dir)
|
|
local out = {}
|
|
if not (io and io.popen) then return out end
|
|
if package.config:sub(1, 1) == "\\" then
|
|
-- cmd has no ls; dir /b prints bare names, so re-attach the directory
|
|
local ok, p = pcall(io.popen, string.format('dir /b "%s\\*.lua" 2>nul', dir))
|
|
if ok and p then
|
|
for line in p:lines() do
|
|
if line ~= "" then table.insert(out, dir .. "/" .. line) end
|
|
end
|
|
p:close()
|
|
end
|
|
return out
|
|
end
|
|
local ok, p = pcall(io.popen, string.format('ls "%s"/*.lua 2>/dev/null', dir))
|
|
if ok and p then
|
|
for line in p:lines() do
|
|
table.insert(out, line)
|
|
end
|
|
p:close()
|
|
end
|
|
return out
|
|
end
|
|
|
|
local function readText(path)
|
|
local fs = love and love.filesystem
|
|
if fs and fs.read and fs.getInfo and fs.getInfo(path) then
|
|
local ok, body = pcall(fs.read, path)
|
|
if ok and body then return body end
|
|
end
|
|
local f = io.open(path, "r")
|
|
if not f then return nil end
|
|
local body = f:read("*a")
|
|
f:close()
|
|
return body
|
|
end
|
|
|
|
-- extraDirs: loaded mods' roots, so MOD_-prefixed flags defined in mod
|
|
-- scripts show up beside the vanilla EVENT_ ones
|
|
function Catalog.scrapeEvents(scriptDir, headerPath, listFiles, extraDirs)
|
|
listFiles = listFiles or function(dir)
|
|
return loveListLua(dir) or shellListLua(dir) or {}
|
|
end
|
|
|
|
local found = {}
|
|
local function eat(text)
|
|
for name in text:gmatch("EVENT_[A-Z0-9_]+") do
|
|
found[name] = true
|
|
end
|
|
for name in text:gmatch("MOD_[A-Z0-9_]+") do
|
|
found[name] = true
|
|
end
|
|
end
|
|
|
|
local dirs = {}
|
|
if scriptDir then dirs[#dirs + 1] = scriptDir end
|
|
for _, dir in ipairs(extraDirs or {}) do
|
|
dirs[#dirs + 1] = dir
|
|
end
|
|
for _, dir in ipairs(dirs) do
|
|
local files = listFiles(dir) or {}
|
|
for _, path in ipairs(files) do
|
|
local body = readText(path)
|
|
if body then eat(body) end
|
|
end
|
|
end
|
|
|
|
if headerPath then
|
|
local body = readText(headerPath)
|
|
if body then eat(body) end
|
|
end
|
|
|
|
return sortedKeys(found)
|
|
end
|
|
|
|
function Catalog.gen2EventList(engine, extraDirs)
|
|
local names = require("Gen2Flags").names(engine)
|
|
local modFlags = Catalog.scrapeEvents(nil, nil, nil, extraDirs)
|
|
local seen = {}
|
|
for _, name in ipairs(names) do seen[name] = true end
|
|
for _, name in ipairs(modFlags) do
|
|
if not seen[name] then
|
|
names[#names + 1] = name
|
|
seen[name] = true
|
|
end
|
|
end
|
|
return names
|
|
end
|
|
|
|
function Catalog.goldEventList(extraDirs)
|
|
return Catalog.gen2EventList("gs", extraDirs)
|
|
end
|
|
|
|
return Catalog
|