chore: spin off Pokémon ROM-hack material to standalone repo
The Pokémon catalog + pipeline are moved out of this infra repo. The catalog
notes now live in the self-hosted Obsidian vault (Pokémon ROM Hacks/); the
acquisition/patching scripts live in their own repo at Documents\pokemon.
homelabstack stays focused on the homelab.
- rm pokemon-romhack-vault/ (75 hack notes + Index/Types/README/Platforms)
- rm scripts/{build-romhack-vault,romhack-import,romhack-fetch,romhack-apply}.py
- rm pokemon-romhacks-wanted.md
- .gitignore: drop the now-dead pokemon/ drop-folder rule
- .claude/skills/vault/SKILL.md: condense the Pokemon-vault subtree to a one-line pointer
RomM stack (stacks/roms) and the general igir library scripts stay.
This commit is contained in:
@@ -1,471 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate an Obsidian vault documenting the Pokémon ROM-hacks in the library.
|
||||
|
||||
Emits, under pokemon-romhack-vault/ :
|
||||
- Hacks/<Name>.md one note per hack (YAML frontmatter + tags + summary)
|
||||
- Index.md directory MOC (Dataview query + static fallback table)
|
||||
- Types.md the type taxonomy
|
||||
- Platforms/*.md per-platform MOCs (Dataview)
|
||||
- README.md how to use the vault
|
||||
|
||||
The dataset below is the single source of truth — add a row and re-run to extend.
|
||||
Frontmatter uses Obsidian "properties" so Dataview / Bases plugins work; tags
|
||||
(#platform/.. #type/.. #status/.. #base/..) make it usable with zero plugins too.
|
||||
|
||||
Run from the repo root: python scripts/build-romhack-vault.py
|
||||
"""
|
||||
import os, re, urllib.parse
|
||||
|
||||
VAULT = os.path.join(os.path.dirname(__file__), "..", "pokemon-romhack-vault")
|
||||
ADDED = "2026-06-06"
|
||||
|
||||
# Type taxonomy (keep in sync with Types.md generation below)
|
||||
TYPES = {
|
||||
"Vanilla+": "Official game enhanced — QoL, all species obtainable, light rebalance; same region/story.",
|
||||
"QoL": "Primarily quality-of-life conveniences over an official base.",
|
||||
"Difficulty": "Built to be hard — boosted AI/teams, kaizo, or competitive rulesets.",
|
||||
"Expansion": "Built on a decomp + expansion: many generations, modern mechanics, new abilities/moves.",
|
||||
"New Experience": "New region, story, and/or Pokédex — a fresh adventure, not the official game.",
|
||||
"Demake": "Recreates a later-generation game on older hardware.",
|
||||
"Roguelite": "Run-based, randomized, permadeath-flavored structure.",
|
||||
"Cosmetic": "Visual/audio overhaul (e.g. Moemon sprites, tilesets, music) over an existing game.",
|
||||
}
|
||||
|
||||
# base ROM display -> tag slug
|
||||
def base_tag(b):
|
||||
return re.sub(r"[^a-z0-9]+", "", b.lower()) if b and b != "—" else "unknown"
|
||||
|
||||
# Each: (title, platform, base, version, status, [types], gen, url, summary)
|
||||
# base "—" = not confidently known. url = canonical source if known else "".
|
||||
HACKS = [
|
||||
# ---------------- GB ----------------
|
||||
("Pokémon Brown", "gb", "Red", "1.1", "Complete", ["New Experience"], "Gen 1+",
|
||||
"https://www.pokecommunity.com/threads/pokemon-brown.27915/",
|
||||
"One of the oldest and most influential hacks. A brand-new Rijon region with new towns, gyms, and a custom dex built on Gen 1, by Koolboyman (who later made Prism)."),
|
||||
# ---------------- GBC ----------------
|
||||
("Pokémon Ambrosia", "gbc", "Crystal", "2.4.0", "Ongoing", ["New Experience"], "Gen 2 style",
|
||||
"https://www.pokecommunity.com/",
|
||||
"An ambitious Crystal-engine hack with a new region, expanded dex, and modernized features pushed onto Gen 2 hardware."),
|
||||
("Pokémon Crystal Clear", "gbc", "Crystal", "2.5.7", "Complete", ["New Experience", "QoL"], "Gen 1–2",
|
||||
"https://www.pokecommunity.com/threads/pokemon-crystal-clear.382197/",
|
||||
"Open-world Crystal — pick any starter, tackle gyms in any order, roam Johto+Kanto freely. A landmark open-world take on Gen 2 by ShockSlayer."),
|
||||
("Pokémon Crystal Inheritance", "gbc", "Crystal", "1.0.3", "Complete", ["New Experience"], "Gen 2+",
|
||||
"",
|
||||
"A Crystal-based adventure with a new story and updated rosters/mechanics within the Gen 2 framework."),
|
||||
("Pokémon Crystal Kaizo", "gbc", "Crystal", "1.0", "Complete", ["Difficulty"], "Gen 2",
|
||||
"",
|
||||
"The definitive Gen 2 kaizo: every trainer is a brutal, fully-EV'd gauntlet. Companion to the Gold/Silver Kaizo line."),
|
||||
("Pokémon Low Budget Crystal", "gbc", "Crystal", "—", "Complete", ["Vanilla+", "QoL"], "Gen 2",
|
||||
"",
|
||||
"A light, faithful Crystal enhancement — quality-of-life tweaks and availability fixes without changing the core game."),
|
||||
("Pokémon Orange", "gbc", "Crystal", "—", "Complete", ["New Experience"], "Gen 2 style",
|
||||
"",
|
||||
"Set in the anime's Orange Islands / Orange League. This is the modern Suloku-patched build with bug fixes and PSS-era touches."),
|
||||
("Pokémon Peridot", "gbc", "Crystal", "2.2.3", "Ongoing", ["New Experience"], "Gen 2 style",
|
||||
"",
|
||||
"A from-scratch new region on the Gen 2 engine with an original dex and story."),
|
||||
("Pokémon Polished Crystal", "gbc", "Crystal", "3.2.3", "Complete", ["Vanilla+", "QoL", "Expansion"], "Gen 1–7 mons",
|
||||
"https://github.com/Rangi42/polishedcrystal",
|
||||
"The gold standard Crystal enhancement: physical/special split, ~Gen 7 movesets/species availability, faithful or modern modes, tons of QoL. Open-source decomp."),
|
||||
("Pokémon Prism", "gbc", "Crystal", "1.0", "Complete", ["New Experience"], "Gen 2+",
|
||||
"https://www.pokecommunity.com/threads/pokemon-prism.379413/",
|
||||
"Koolboyman's acclaimed new Naljo region — new types, side games, huge custom dex. Famously C&D'd then completed; a Gen 2 magnum opus."),
|
||||
# ---------------- GBA ----------------
|
||||
("Pokémon Adventure - Red Chapter", "gba", "FireRed", "Beta 15", "Complete (beta)", ["New Experience"], "Gen 1–6 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-adventure-red-chapter.331313/",
|
||||
"Based on the Pokémon Adventures (Pokémon Special) manga — play through Red's story with manga events. Beta 15 is the full, finished beta."),
|
||||
("Pokémon Aesthetic Red", "gba", "FireRed", "1.1", "Complete", ["Cosmetic", "Vanilla+"], "Gen 1",
|
||||
"",
|
||||
"A visual + musical overhaul of FireRed — restyled tiles, sprites, and soundtrack while keeping vanilla gameplay."),
|
||||
("Pokémon Amethyst", "gba", "Emerald", "1.2.0", "Ongoing", ["Expansion", "New Experience"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/pokemon-amethyst",
|
||||
"A pokeemerald-expansion adventure with a new region/story and modern mechanics."),
|
||||
("Pokémon Crystal Advance Redux", "gba", "Emerald", "2026-05-06", "Ongoing", ["Demake", "Vanilla+"], "Gen 2 on GBA",
|
||||
"",
|
||||
"Pokémon Crystal rebuilt on the GBA (pokeemerald) with Gen-3+ engine conveniences — Johto with modern QoL."),
|
||||
("Pokémon Dark Rising", "gba", "FireRed", "1 (Origins)", "Complete", ["New Experience", "Difficulty"], "Multi-gen + fakemon",
|
||||
"https://www.pokecommunity.com/threads/pokemon-dark-rising-series.341667/",
|
||||
"Notoriously hard story-driven hack with a dark plot, fakemon, and multi-gen mons. The Origins build is the remastered DR1."),
|
||||
("Pokémon Dark Rising 2", "gba", "FireRed", "Complete", "Complete", ["New Experience", "Difficulty"], "Multi-gen + fakemon",
|
||||
"https://www.pokecommunity.com/threads/pokemon-dark-rising-series.341667/",
|
||||
"Sequel to Dark Rising — bigger story, more fakemon, same punishing difficulty."),
|
||||
("Pokémon Dark Rising - Order Destroyed", "gba", "FireRed", "Complete", "Complete", ["New Experience", "Difficulty"], "Multi-gen",
|
||||
"https://www.pokecommunity.com/threads/pokemon-dark-rising-series.341667/",
|
||||
"A spin-off entry in the Dark Rising saga."),
|
||||
("Pokémon Elite Redux", "gba", "Emerald", "2.65.3b", "Ongoing", ["Expansion", "Difficulty"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/elite-redux",
|
||||
"A theorycrafter's playground: every species gets multiple abilities, a vastly expanded movepool, and brutal fights. Deep team-building over story."),
|
||||
("Pokémon Emerald Azure", "gba", "Emerald", "0.5.3", "Beta", ["New Experience", "Expansion"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/pokemon-emerald-azure",
|
||||
"An in-development new-region Emerald-expansion hack (early/beta)."),
|
||||
("Pokémon Emerald Extended Cut", "gba", "Emerald", "Classic+ 1.3", "Complete", ["Vanilla+", "QoL"], "Gen 3",
|
||||
"",
|
||||
"Emerald with restored/expanded content and QoL while staying close to the original Hoenn experience."),
|
||||
("Pokémon Emerald Imperium", "gba", "Emerald", "1.3.1", "Complete", ["Expansion", "Difficulty"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/emerald-imperium",
|
||||
"A content- and postgame-heavy Emerald-expansion hack with challenging fights and lots of endgame."),
|
||||
("Pokémon Emerald Kaizo", "gba", "Emerald", "—", "Complete", ["Difficulty"], "Gen 3",
|
||||
"",
|
||||
"The classic Emerald kaizo — every gym/E4 team is maxed-out and merciless."),
|
||||
("Pokémon Emerald Rogue", "gba", "Emerald", "2.1.2 EX", "Ongoing", ["Roguelite", "Expansion"], "Multi-gen",
|
||||
"https://github.com/Pokabbie/pokeemerald-rogue",
|
||||
"A roguelite take on Emerald: run-based, procedurally routed, escalating difficulty toward the Champion. EX edition uses the modern expansion."),
|
||||
("Pokémon Emerald Seaglass", "gba", "Emerald", "3.0", "Complete", ["Vanilla+", "QoL", "Expansion"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/pokemon-emerald-seaglass",
|
||||
"Emerald modernized via the expansion — physical/special split, new species/forms, and heavy QoL while keeping Hoenn's story."),
|
||||
("Pokémon Emerald Squared", "gba", "Emerald", "2.6.2", "Complete", ["Difficulty", "Vanilla+"], "Gen 3",
|
||||
"",
|
||||
"An enhanced, harder Emerald — rebalanced trainers and availability for a tougher Hoenn run."),
|
||||
("Pokémon Fire of Sky", "gba", "—", "1.0.3", "Complete", ["New Experience"], "Multi-gen",
|
||||
"",
|
||||
"A story-focused new-adventure hack."),
|
||||
("Pokémon FireRed Deluxe", "gba", "FireRed", "20.5", "Ongoing", ["Vanilla+", "Expansion", "QoL"], "Multi-gen",
|
||||
"",
|
||||
"FireRed loaded with all obtainable species, modern mechanics, and QoL — a 'complete dex' enhanced Kanto."),
|
||||
("Pokémon Fire Red Extended", "gba", "FireRed", "3.5.6", "Ongoing", ["Vanilla+", "Expansion"], "Multi-gen",
|
||||
"",
|
||||
"FireRed extended with later-gen species and mechanics while preserving the Kanto journey."),
|
||||
("Pokémon FireRed & LeafGreen+ (FRLG+)", "gba", "FireRed", "1.5.1", "Ongoing", ["Vanilla+", "QoL"], "Gen 1–3",
|
||||
"",
|
||||
"A faithful 'plus' enhancement of FR/LG — availability fixes, split, and QoL with minimal change to the feel."),
|
||||
("Pokémon FireRed Reignited", "gba", "FireRed", "1.55", "Ongoing", ["Vanilla+", "QoL"], "Gen 1+",
|
||||
"",
|
||||
"A modern QoL remaster of FireRed."),
|
||||
("Pokémon Flora Sky", "gba", "Emerald", "Complete", "Complete", ["New Experience"], "Gen 3–4 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-flora-sky.179365/",
|
||||
"A classic complete Emerald hack with a new region, Gen 4 additions, and a sky/Distortion-World-flavored plot."),
|
||||
("Pokémon Gaia", "gba", "FireRed", "3.2", "Complete", ["New Experience"], "Gen 1–6 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-gaia.336982/",
|
||||
"Widely considered one of the best hacks ever: the Orbtus region, Gen 6 mechanics/Fairy type, an archaeology mystery, and Nintendo-grade polish."),
|
||||
("Pokémon Glazed", "gba", "Emerald", "9.2.0", "Complete", ["New Experience"], "Gen 1–6 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-glazed.291376/",
|
||||
"A long-beloved new region (Tunod) crossing into Johto, with multiple starters incl. later gens. This is the polished modern build."),
|
||||
("Pokémon GS Chronicles", "gba", "FireRed", "2.7.6", "Complete", ["New Experience", "Demake"], "Gen 1–7 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-gs-chronicles.346730/",
|
||||
"A HeartGold/SoulSilver-style Johto remake on GBA with modern mechanics and a rich postgame."),
|
||||
("Pokémon Heart and Soul", "gba", "FireRed", "1.2.1", "Ongoing", ["New Experience", "Demake"], "Johto",
|
||||
"",
|
||||
"A Johto-focused adventure inspired by the Gen 2/HGSS games."),
|
||||
("Pokémon Hearth", "gba", "Emerald", "0.1.27", "Beta", ["New Experience", "Expansion"], "Multi-gen",
|
||||
"",
|
||||
"An early-beta new-region expansion hack."),
|
||||
("Pokémon Hoenn's Last Wish", "gba", "Emerald", "0.4.7", "Beta", ["New Experience", "Expansion"], "Multi-gen",
|
||||
"",
|
||||
"An in-development Hoenn-set adventure on the Emerald expansion (early/beta)."),
|
||||
("Pokémon Inclement Emerald", "gba", "Emerald", "—", "Complete", ["Difficulty", "Expansion"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/inclement-emerald",
|
||||
"Emerald-expansion difficulty hack with all 8 gens obtainable, configurable hardcore modes, and smart AI. A modern favorite."),
|
||||
("Pokémon Inkwell", "gba", "Emerald", "1.04", "Ongoing", ["New Experience", "Expansion"], "Multi-gen",
|
||||
"",
|
||||
"A new-adventure hack built on the Emerald expansion."),
|
||||
("Pokémon Lazarus", "gba", "Emerald (TrashMan)", "v2", "Ongoing", ["New Experience", "Expansion"], "Multi-gen",
|
||||
"https://ko-fi.com/nemo622",
|
||||
"The Ilios region — a story-rich expansion hack by Nemo622 with new mechanics and detailed documentation."),
|
||||
("Pokémon Light Platinum", "gba", "Ruby", "1.1", "Complete", ["New Experience"], "Gen 1–4 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-light-platinum.171377/",
|
||||
"A classic: the Zhery region with two leagues, Gen 4 mons, and a globe-trotting plot. Hugely popular older hack."),
|
||||
("Pokémon Liquid Crystal", "gba", "FireRed", "3.3", "Complete", ["New Experience", "Demake"], "Gen 1–4 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-liquid-crystal.158473/",
|
||||
"A Johto (Crystal) remake on GBA with the Orange Islands postgame and modern conveniences."),
|
||||
("Pokémon Mega Power", "gba", "Ruby", "5.62", "Complete", ["New Experience"], "Gen 1–6 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-mega-power.330510/",
|
||||
"By the Light Platinum-adjacent team — a new region with Mega Evolution, custom villains, and a 'build the strongest Pokémon' plot."),
|
||||
("Pokémon Modern Emerald", "gba", "Emerald", "3.3.1", "Complete", ["Vanilla+", "QoL", "Expansion"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/modern-emerald",
|
||||
"Emerald modernized end-to-end — all gens, modern mechanics, and a deep QoL/settings menu, while keeping Hoenn's story."),
|
||||
("Pokémon Moemon Mega FireRed", "gba", "FireRed", "1.4c", "Complete", ["Cosmetic"], "Gen 1",
|
||||
"",
|
||||
"A Moemon hack — Pokémon replaced with anthropomorphic 'moe' character sprites — over an enhanced FireRed."),
|
||||
("Pokémon Moemon Star Emerald", "gba", "Emerald", "1.1c", "Complete", ["Cosmetic"], "Gen 3",
|
||||
"",
|
||||
"A Moemon reskin of an enhanced Emerald (Star Emerald), with moe sprites throughout."),
|
||||
("Pokémon Odyssey", "gba", "FireRed", "4.1.1", "Complete", ["New Experience"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/pokemon-odyssey",
|
||||
"A highly-praised, atmospheric original adventure with a custom region, strong writing, and bespoke pixel art."),
|
||||
("Pokémon Omega Ruby Origins", "gba", "Emerald", "1.4.8.7", "Ongoing", ["Demake", "New Experience"], "Gen 6 on GBA",
|
||||
"",
|
||||
"An ORAS-style demake bringing the 3DS Hoenn remakes' features back to the GBA."),
|
||||
("Pokémon Phoenix Red", "gba", "FireRed", "1.2", "Complete", ["Difficulty", "Expansion"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/pokemon-phoenix-red",
|
||||
"An enhanced, harder FireRed with all 8 gens obtainable, Megas, and tough fights."),
|
||||
("Pokémon Pisces", "gba", "—", "1.5.4", "Complete", ["New Experience"], "Multi-gen",
|
||||
"",
|
||||
"An original-region adventure hack."),
|
||||
("Pokémon Project Nova", "gba", "Emerald", "2.7.0", "Ongoing", ["New Experience", "Expansion"], "Multi-gen",
|
||||
"",
|
||||
"A new-experience hack on the Emerald expansion."),
|
||||
("Pokémon Radical Red", "gba", "FireRed", "4.10", "Ongoing", ["Difficulty", "Expansion"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/radical-red",
|
||||
"The flagship modern difficulty hack: complete National Dex, Gen-9 mechanics, smart held-item/switching AI, and toggle modes from casual to brutal."),
|
||||
("Pokémon Recordkeepers", "gba", "Emerald", "1.2.1", "Ongoing", ["New Experience", "Expansion"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/recordkeepers",
|
||||
"A narrative-driven Emerald-expansion hack."),
|
||||
("Pokémon Resolute", "gba", "Ruby", "2.97", "Complete", ["New Experience"], "Gen 1–6 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-resolute.330577/",
|
||||
"A story-heavy new region (Sun-Moon-era mons added) with a difficulty mode; from the Mega Power/Light Platinum lineage."),
|
||||
("Pokémon R.O.W.E.", "gba", "Emerald", "2.1.1", "Ongoing", ["New Experience", "QoL", "Expansion"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/pokemon-rowe",
|
||||
"Open-world Emerald — level scaling, ride-anywhere, nuzlocke-friendly settings, and all gens. The 'Mega Update' build."),
|
||||
("Pokémon Saiph", "gba", "FireRed", "2020", "Complete", ["New Experience"], "Multi-gen",
|
||||
"https://www.pokecommunity.com/threads/pokemon-saiph.412313/",
|
||||
"A complete original-region story hack with a darker tone."),
|
||||
("Pokémon Saiph 2", "gba", "FireRed", "1.4.0", "Complete", ["New Experience"], "Multi-gen",
|
||||
"https://www.pokecommunity.com/threads/pokemon-saiph-2.456789/",
|
||||
"Sequel to Saiph — a larger, polished original adventure (full release v1.4.0)."),
|
||||
("Pokémon Snakewood", "gba", "Ruby", "—", "Complete", ["New Experience"], "Gen 3 + fakemon",
|
||||
"https://www.pokecommunity.com/threads/pokemon-snakewood.146749/",
|
||||
"A cult-classic zombie-apocalypse reimagining of Hoenn — surreal, dark-comedic, and famously weird. Largely complete."),
|
||||
("Pokémon Sors", "gba", "FireRed", "1.3", "Complete", ["New Experience"], "Multi-gen",
|
||||
"https://www.pokecommunity.com/threads/pokemon-sors.420576/",
|
||||
"A complete story-driven hack with a full new region and extensive item/guide documentation."),
|
||||
("Pokémon Sovereign of the Skies", "gba", "FireRed", "2.1.2", "Complete", ["New Experience"], "Multi-gen",
|
||||
"https://www.pokecommunity.com/threads/pokemon-sovereign-of-the-skies.349500/",
|
||||
"A complete new region with custom dex and a sky-themed plot."),
|
||||
("Pokémon Super Mariomon", "gba", "Emerald", "1.5.2", "Complete", ["New Experience", "Cosmetic"], "Crossover",
|
||||
"",
|
||||
"A Mario × Pokémon crossover: catch and battle Mario-universe characters as 'Mariomon'. A complete novelty hack."),
|
||||
("Pokémon Sword and Shield Ultimate Plus", "gba", "FireRed", "1.2.1.2", "Ongoing", ["Demake", "New Experience"], "Gen 8 on GBA",
|
||||
"",
|
||||
"A Galar (Sword/Shield) demake bringing Gen 8's region, Pokémon, and Dynamax-era content to the GBA."),
|
||||
("Pokémon The Pit", "gba", "Emerald", "2.5.1", "Ongoing", ["Roguelite", "Difficulty", "Expansion"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/the-pit",
|
||||
"A roguelite/battle-focused descent: climb floors, draft a team, and fight escalating encounters. Built on the Emerald expansion."),
|
||||
("Pokémon Theta Emerald EX", "gba", "Emerald", "EX", "Complete", ["Expansion", "Vanilla+"], "Gen 1–6 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-theta-emerald-ex.366617/",
|
||||
"Classic 'all 800+ mons in Emerald' hack — Megas, Fairy type, and the full dex obtainable within Hoenn's story."),
|
||||
("Pokémon Tourmaline", "gba", "Emerald", "1.1.1", "Ongoing", ["New Experience", "Expansion"], "Multi-gen",
|
||||
"",
|
||||
"A new-region adventure on the Emerald expansion."),
|
||||
("Pokémon Valiant", "gba", "Emerald", "4.2.3", "Ongoing", ["New Experience", "Expansion"], "Multi-gen",
|
||||
"https://www.hackdex.app/hack/pokemon-valiant",
|
||||
"An original-region story hack on the Emerald expansion with custom characters and content."),
|
||||
("Pokémon WaveBlue", "gba", "FireRed", "1.7.5", "Ongoing", ["New Experience"], "Multi-gen",
|
||||
"",
|
||||
"A new-region adventure built on FireRed."),
|
||||
# ---------------- NDS ----------------
|
||||
("Pokémon Blaze Black", "nds", "Black", "—", "Complete", ["Vanilla+", "Difficulty"], "Gen 1–5 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-blaze-black-volt-white.252355/",
|
||||
"Drayano's Black overhaul — every species catchable in-game, boosted gym/E4 teams, and QoL. Pairs with Volt White."),
|
||||
("Pokémon Blaze Black 2 Redux", "nds", "Black 2", "1.3.0", "Complete", ["Vanilla+", "Difficulty", "Expansion"], "Gen 1–5 mons",
|
||||
"https://www.pokecommunity.com/",
|
||||
"A community 'Redux' fork of Drayano's Blaze Black 2 — expanded availability, rebalanced difficulty, and extra content."),
|
||||
("Pokémon Following Renegade Platinum", "nds", "Platinum", "2.0", "Complete", ["Difficulty", "Vanilla+", "QoL"], "Gen 1–4 mons",
|
||||
"https://www.reddit.com/r/PokemonROMhacks/comments/s4fbhi/",
|
||||
"Renegade Platinum with following Pokémon added — the acclaimed enhanced Sinnoh plus an HGSS-style walking partner."),
|
||||
("Pokémon Renegade Platinum", "nds", "Platinum", "1.3.0", "Complete", ["Difficulty", "Vanilla+"], "Gen 1–4 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-renegade-platinum.347531/",
|
||||
"Drayano's definitive enhanced Platinum — full availability, much harder fights, and QoL. A community favorite Sinnoh run."),
|
||||
("Pokémon Sacred Gold", "nds", "HeartGold", "1.05", "Complete", ["Vanilla+", "Difficulty"], "Gen 1–4 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-sacred-gold-storm-silver.165088/",
|
||||
"Drayano's enhanced HeartGold — all species obtainable, boosted teams, fixed movesets. Pairs with Storm Silver."),
|
||||
("Pokémon Storm Silver", "nds", "SoulSilver", "1.05", "Complete", ["Vanilla+", "Difficulty"], "Gen 1–4 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-sacred-gold-storm-silver.165088/",
|
||||
"Drayano's enhanced SoulSilver — the SoulSilver counterpart to Sacred Gold."),
|
||||
("Pokémon Volt White", "nds", "White", "—", "Complete", ["Vanilla+", "Difficulty"], "Gen 1–5 mons",
|
||||
"https://www.pokecommunity.com/threads/pokemon-blaze-black-volt-white.252355/",
|
||||
"Drayano's White overhaul — full availability and boosted difficulty. The White counterpart to Blaze Black."),
|
||||
("Pokémon Volt White 2 Redux", "nds", "White 2", "1.4.1", "Complete", ["Vanilla+", "Difficulty", "Expansion"], "Gen 1–5 mons",
|
||||
"https://www.pokecommunity.com/",
|
||||
"A community 'Redux' fork of Drayano's Volt White 2 — expanded availability and rebalanced difficulty."),
|
||||
]
|
||||
|
||||
PLAT_NAME = {"gb": "Game Boy", "gbc": "Game Boy Color", "gba": "Game Boy Advance", "nds": "Nintendo DS"}
|
||||
|
||||
|
||||
def slugify_filename(title):
|
||||
# note filename: drop the "Pokémon " prefix for tidiness, keep the rest
|
||||
name = re.sub(r"^Pok[ée]mon\s+", "", title)
|
||||
return name.replace("/", "-")
|
||||
|
||||
|
||||
def yaml_list(items):
|
||||
return "[" + ", ".join(f'"{i}"' for i in items) + "]"
|
||||
|
||||
|
||||
def lookup_url(title):
|
||||
q = urllib.parse.quote(f"{title} rom hack")
|
||||
return f"https://duckduckgo.com/?q={q}"
|
||||
|
||||
|
||||
def write(path, content):
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
|
||||
|
||||
def gen_hack_note(h):
|
||||
title, plat, base, ver, status, types, gen, url, summary = h
|
||||
fname = slugify_filename(title)
|
||||
libname = "Pokemon - " + re.sub(r"^Pok[ée]mon\s+", "", title).replace("é", "e").replace("É", "E") + f" (Hack).{plat}"
|
||||
tags = [f"hack", f"platform/{plat}", f"base/{base_tag(base)}",
|
||||
f"status/{re.sub(r'[^a-z0-9]+','',status.lower())}"]
|
||||
tags += [f"type/{re.sub(r'[^a-z0-9+]+','',t.lower())}" for t in types]
|
||||
fm = [
|
||||
"---",
|
||||
f'title: "{title}"',
|
||||
f"platform: {plat.upper()}",
|
||||
f'base: "{base}"',
|
||||
f'version: "{ver}"',
|
||||
f'status: "{status}"',
|
||||
f"type: {yaml_list(types)}",
|
||||
f'generation: "{gen}"',
|
||||
f'library_path: "roms/{plat}/Hacks/{libname}"',
|
||||
f'source: "{url or lookup_url(title)}"',
|
||||
f"added: {ADDED}",
|
||||
f"tags: {yaml_list(tags)}",
|
||||
"---",
|
||||
"",
|
||||
]
|
||||
body = [
|
||||
f"# {title}",
|
||||
"",
|
||||
f"> [!info] {' · '.join(types)} — **{status}**",
|
||||
f"> {PLAT_NAME[plat]} · base **{base}** · version **{ver}** · {gen}",
|
||||
"",
|
||||
"## Summary",
|
||||
summary,
|
||||
"",
|
||||
"## Type",
|
||||
" ".join(f"[[Types#{t}|{t}]]" for t in types),
|
||||
"",
|
||||
"## Links",
|
||||
f"- Source / info: {url}" if url else "- Source: _(not catalogued — see lookup)_",
|
||||
f"- Lookup: {lookup_url(title)}",
|
||||
"",
|
||||
"## In the library",
|
||||
f"- `roms/{plat}/Hacks/{libname}` on valhalla",
|
||||
f"- Patch/source artifact archived under `/storage1/igir/romhacks/patches/`",
|
||||
"",
|
||||
"[[Index|← back to directory]]",
|
||||
"",
|
||||
]
|
||||
return "\n".join(fm) + "\n".join(body)
|
||||
|
||||
|
||||
def slug_libpath(title):
|
||||
name = re.sub(r"^Pok[ée]mon\s+", "", title)
|
||||
name = name.replace("é", "e").replace("É", "E")
|
||||
# match the on-disk naming: "Pokemon - <name> (Hack).<ext>"
|
||||
ext = {"gb": "gb", "gbc": "gbc", "gba": "gba", "nds": "nds"}
|
||||
return f"Pokemon - {name} (Hack)" # ext appended by reader; on disk has platform ext
|
||||
|
||||
|
||||
def gen_index():
|
||||
rows = []
|
||||
for h in sorted(HACKS, key=lambda x: (x[1], x[0])):
|
||||
title, plat, base, ver, status, types, gen, url, summary = h
|
||||
link = f"[[{slugify_filename(title)}]]"
|
||||
rows.append(f"| {link} | {plat.upper()} | {base} | {ver} | {status} | {', '.join(types)} |")
|
||||
static = "\n".join(rows)
|
||||
dv = (
|
||||
"```dataview\n"
|
||||
"TABLE platform AS Platform, base AS Base, version AS Version, status AS Status, type AS Type\n"
|
||||
'FROM "Hacks"\n'
|
||||
"SORT platform ASC, file.name ASC\n"
|
||||
"```\n"
|
||||
)
|
||||
counts = {}
|
||||
for h in HACKS:
|
||||
counts[h[1]] = counts.get(h[1], 0) + 1
|
||||
countline = " · ".join(f"**{PLAT_NAME[p]}**: {counts.get(p,0)}" for p in ["gb","gbc","gba","nds"])
|
||||
return f"""# Pokémon ROM-Hack Library — Index
|
||||
|
||||
A knowledge base for the **{len(HACKS)}** Pokémon ROM-hacks installed in the valhalla
|
||||
library (`roms/<platform>/Hacks/`). One note per hack — see [[Types]] for the tag
|
||||
taxonomy and the [[#Platforms]] section for per-system views.
|
||||
|
||||
{countline}
|
||||
|
||||
## Directory (Dataview)
|
||||
|
||||
> Requires the Dataview plugin. If you don't use it, the static table below mirrors it.
|
||||
|
||||
{dv}
|
||||
|
||||
## Directory (static)
|
||||
|
||||
| Hack | Platform | Base | Version | Status | Type |
|
||||
|---|---|---|---|---|---|
|
||||
{static}
|
||||
|
||||
## Platforms
|
||||
|
||||
- [[GBA]] · [[GBC]] · [[GB]] · [[NDS]]
|
||||
|
||||
## By type
|
||||
|
||||
{chr(10).join(f"- [[Types#{t}|{t}]] — {d}" for t, d in TYPES.items())}
|
||||
|
||||
---
|
||||
*Generated by `scripts/build-romhack-vault.py` — edit the dataset there and re-run to update.*
|
||||
"""
|
||||
|
||||
|
||||
def gen_types():
|
||||
body = ["# Type Taxonomy", "",
|
||||
"Each hack is tagged with one or more of these. Tags are also queryable as `#type/...`.", ""]
|
||||
for t, d in TYPES.items():
|
||||
members = [slugify_filename(h[0]) for h in sorted(HACKS) if t in h[5]]
|
||||
body.append(f"## {t}")
|
||||
body.append(d)
|
||||
body.append("")
|
||||
body.append(f"`#type/{re.sub(r'[^a-z0-9+]+','',t.lower())}` — {len(members)} hacks")
|
||||
body.append("")
|
||||
body += [f"- [[{m}]]" for m in members]
|
||||
body.append("")
|
||||
body.append("[[Index|← back to directory]]")
|
||||
return "\n".join(body)
|
||||
|
||||
|
||||
def gen_platform(plat):
|
||||
members = [h for h in sorted(HACKS) if h[1] == plat]
|
||||
rows = [f"| [[{slugify_filename(h[0])}]] | {h[2]} | {h[3]} | {h[4]} | {', '.join(h[5])} |" for h in members]
|
||||
dv = ("```dataview\nTABLE base, version, status, type\n"
|
||||
f'FROM "Hacks"\nWHERE platform = "{plat.upper()}"\nSORT file.name ASC\n```\n')
|
||||
return (f"# {PLAT_NAME[plat]} ({plat.upper()}) — {len(members)} hacks\n\n{dv}\n"
|
||||
"## Static\n\n| Hack | Base | Version | Status | Type |\n|---|---|---|---|---|\n"
|
||||
+ "\n".join(rows) + "\n\n[[Index|← back to directory]]\n")
|
||||
|
||||
|
||||
def gen_readme():
|
||||
return f"""# Pokémon ROM-Hack Vault
|
||||
|
||||
An [Obsidian](https://obsidian.md) vault documenting the **{len(HACKS)}** Pokémon ROM-hacks
|
||||
in the valhalla library. Open *this folder* as a vault (or copy it into an existing one).
|
||||
|
||||
## Layout
|
||||
- **[[Index]]** — the master directory (Dataview + static table).
|
||||
- **[[Types]]** — the type taxonomy (QoL, Vanilla+, Difficulty, Expansion, New Experience, Demake, Roguelite, Cosmetic).
|
||||
- **Hacks/** — one note per hack with frontmatter properties + tags.
|
||||
- **Platforms/** — per-system maps of content (GBA / GBC / GB / NDS).
|
||||
|
||||
## Conventions
|
||||
- Frontmatter uses Obsidian **properties** (`platform`, `base`, `version`, `status`, `type`, `generation`, `source`) so the **Dataview** and **Bases** plugins work.
|
||||
- Every note also carries **tags** (`#platform/gba`, `#type/difficulty`, `#status/complete`, `#base/firered`) so search/graph work with **zero plugins**.
|
||||
- `library_path` points at the file under `roms/<platform>/Hacks/` on valhalla.
|
||||
|
||||
## Recommended plugins
|
||||
- **Dataview** (the Index/Platform tables) and optionally **Bases** (Obsidian's native DB view).
|
||||
|
||||
## Caveats
|
||||
- `base`, `version`, and `type` are best-effort from the import metadata + general knowledge; a few obscure hacks show `base: —` where the source wasn't certain. Correct any in `scripts/build-romhack-vault.py` and re-run.
|
||||
|
||||
*Generated by `scripts/build-romhack-vault.py`.*
|
||||
"""
|
||||
|
||||
|
||||
def main():
|
||||
# clean Hacks dir to avoid stale notes, then regenerate
|
||||
for h in HACKS:
|
||||
write(os.path.join(VAULT, "Hacks", slugify_filename(h[0]) + ".md"), gen_hack_note(h))
|
||||
write(os.path.join(VAULT, "Index.md"), gen_index())
|
||||
write(os.path.join(VAULT, "Types.md"), gen_types())
|
||||
write(os.path.join(VAULT, "README.md"), gen_readme())
|
||||
for p in ["gb", "gbc", "gba", "nds"]:
|
||||
write(os.path.join(VAULT, "Platforms", PLAT_NAME[p].split()[0] if False else p.upper() + ".md"),
|
||||
gen_platform(p))
|
||||
print(f"vault written to {os.path.normpath(VAULT)} — {len(HACKS)} hack notes + Index/Types/README + 4 platform MOCs")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,135 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Apply a Pokémon ROM-hack patch to a base ROM (IPS / BPS / UPS).
|
||||
|
||||
Format is auto-detected by magic bytes. BPS embeds source+target CRC32, so a
|
||||
wrong base ROM (or a buggy apply) fails loudly here rather than producing a
|
||||
silently-corrupt ROM — that is the correctness guarantee for the whole pipeline.
|
||||
|
||||
Usage: romhack-apply.py <patch> <base_rom> <out_rom>
|
||||
Exit: 0 ok; 2 bad/mismatched input; 3 unsupported format.
|
||||
xdelta patches are handled by the caller via the `xdelta3` binary, not here.
|
||||
"""
|
||||
import sys, zlib, struct
|
||||
|
||||
def die(code, msg):
|
||||
sys.stderr.write(msg + "\n"); sys.exit(code)
|
||||
|
||||
def read(p):
|
||||
with open(p, "rb") as f: return f.read()
|
||||
|
||||
# ---------- IPS ----------
|
||||
def apply_ips(patch, base):
|
||||
if patch[:5] != b"PATCH": die(2, "IPS: bad header")
|
||||
out = bytearray(base)
|
||||
i = 5
|
||||
while True:
|
||||
rec = patch[i:i+3]
|
||||
if rec == b"EOF": break
|
||||
if len(rec) < 3: die(2, "IPS: truncated")
|
||||
off = (rec[0] << 16) | (rec[1] << 8) | rec[2]; i += 3
|
||||
size = (patch[i] << 8) | patch[i+1]; i += 2
|
||||
if size == 0: # RLE run
|
||||
rle = (patch[i] << 8) | patch[i+1]; i += 2
|
||||
val = patch[i:i+1]; i += 1
|
||||
chunk = val * rle
|
||||
off2 = off + rle
|
||||
else:
|
||||
chunk = patch[i:i+size]; i += size
|
||||
off2 = off + size
|
||||
if off2 > len(out): out.extend(b"\x00" * (off2 - len(out)))
|
||||
out[off:off2] = chunk
|
||||
# optional truncate extension (3-byte length after EOF)
|
||||
tail = patch[i+3:i+6] if patch[i:i+3] == b"EOF" else b""
|
||||
if len(tail) == 3:
|
||||
newlen = (tail[0] << 16) | (tail[1] << 8) | tail[2]
|
||||
out = out[:newlen]
|
||||
return bytes(out)
|
||||
|
||||
# ---------- UPS ----------
|
||||
def _ups_num(buf, i):
|
||||
val = 0; shift = 1
|
||||
while True:
|
||||
x = buf[i]; i += 1
|
||||
val += (x & 0x7f) * shift
|
||||
if x & 0x80: break
|
||||
shift <<= 7; val += shift
|
||||
return val, i
|
||||
|
||||
def apply_ups(patch, base):
|
||||
if patch[:4] != b"UPS1": die(2, "UPS: bad header")
|
||||
i = 4
|
||||
src_size, i = _ups_num(patch, i)
|
||||
dst_size, i = _ups_num(patch, i)
|
||||
if len(base) != src_size:
|
||||
sys.stderr.write(f"UPS: base size {len(base)} != expected {src_size} (continuing)\n")
|
||||
out = bytearray(base) + b"\x00" * max(0, dst_size - len(base))
|
||||
out = out[:dst_size] if dst_size < len(out) else out
|
||||
pos = 0
|
||||
body_end = len(patch) - 12 # trailing 3 CRC32s (src,dst,patch)
|
||||
while i < body_end:
|
||||
rel, i = _ups_num(patch, i)
|
||||
pos += rel
|
||||
while True:
|
||||
b = patch[i]; i += 1
|
||||
if pos < len(out): out[pos] ^= b
|
||||
pos += 1
|
||||
if b == 0: break
|
||||
src_crc, dst_crc, _ = struct.unpack("<III", patch[-12:])
|
||||
if zlib.crc32(base) & 0xffffffff != src_crc:
|
||||
sys.stderr.write("UPS: WARNING source CRC mismatch (wrong base ROM?)\n")
|
||||
got = zlib.crc32(bytes(out)) & 0xffffffff
|
||||
if got != dst_crc:
|
||||
die(2, f"UPS: output CRC {got:08x} != expected {dst_crc:08x}")
|
||||
return bytes(out)
|
||||
|
||||
# ---------- BPS ----------
|
||||
def apply_bps(patch, base):
|
||||
if patch[:4] != b"BPS1": die(2, "BPS: bad header")
|
||||
i = 4
|
||||
src_size, i = _ups_num(patch, i)
|
||||
dst_size, i = _ups_num(patch, i)
|
||||
meta_size, i = _ups_num(patch, i)
|
||||
i += meta_size
|
||||
src_crc, dst_crc, patch_crc = struct.unpack("<III", patch[-12:])
|
||||
if zlib.crc32(base) & 0xffffffff != src_crc:
|
||||
die(2, f"BPS: source CRC mismatch — wrong base ROM (have {zlib.crc32(base)&0xffffffff:08x}, need {src_crc:08x})")
|
||||
out = bytearray(dst_size)
|
||||
out_pos = 0; src_rel = 0; dst_rel = 0
|
||||
body_end = len(patch) - 12
|
||||
while i < body_end:
|
||||
data, i = _ups_num(patch, i)
|
||||
action = data & 3; length = (data >> 2) + 1
|
||||
if action == 0: # SourceRead
|
||||
out[out_pos:out_pos+length] = base[out_pos:out_pos+length]; out_pos += length
|
||||
elif action == 1: # TargetRead
|
||||
out[out_pos:out_pos+length] = patch[i:i+length]; i += length; out_pos += length
|
||||
elif action == 2: # SourceCopy
|
||||
off, i = _ups_num(patch, i)
|
||||
src_rel += (-(off >> 1) if (off & 1) else (off >> 1))
|
||||
for _ in range(length):
|
||||
out[out_pos] = base[src_rel]; out_pos += 1; src_rel += 1
|
||||
else: # TargetCopy
|
||||
off, i = _ups_num(patch, i)
|
||||
dst_rel += (-(off >> 1) if (off & 1) else (off >> 1))
|
||||
for _ in range(length):
|
||||
out[out_pos] = out[dst_rel]; out_pos += 1; dst_rel += 1
|
||||
got = zlib.crc32(bytes(out)) & 0xffffffff
|
||||
if got != dst_crc:
|
||||
die(2, f"BPS: output CRC {got:08x} != expected {dst_crc:08x}")
|
||||
return bytes(out)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
die(2, "usage: romhack-apply.py <patch> <base_rom> <out_rom>")
|
||||
patch, base_path, out_path = sys.argv[1], sys.argv[2], sys.argv[3]
|
||||
pb = read(patch); base = read(base_path)
|
||||
magic = pb[:5]
|
||||
if magic[:4] == b"BPS1": out = apply_bps(pb, base)
|
||||
elif magic[:4] == b"UPS1": out = apply_ups(pb, base)
|
||||
elif magic == b"PATCH": out = apply_ips(pb, base)
|
||||
else: die(3, f"unsupported patch magic {magic!r}")
|
||||
with open(out_path, "wb") as f: f.write(out)
|
||||
print(f"OK {out_path} ({len(out)} bytes, crc32={zlib.crc32(out)&0xffffffff:08x})")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,260 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Acquire, patch, validate, and place worthwhile Pokémon ROM-hacks into the
|
||||
EmuDeck library at /storage1/Emulation/roms/<platform>/Hacks/ on valhalla.
|
||||
|
||||
Each hack is one MANIFEST entry naming its source. Two source kinds:
|
||||
- "rom": a pre-patched full ROM is downloaded and placed as-is (validated).
|
||||
- "patch": a patch (BPS/UPS/IPS) is downloaded and applied to a base ROM the
|
||||
user already owns; BPS/UPS self-verify via embedded CRC32.
|
||||
|
||||
Sources are direct, no-anti-bot URLs only (GitHub release assets, archive.org).
|
||||
hackdex/Discord/Drive-gated hacks are intentionally NOT here — they are reported
|
||||
as identify-only because their hosts gate or token-protect downloads.
|
||||
|
||||
Output names follow the chosen scheme: "Pokemon - <Hack> (Hack).<ext>"
|
||||
(parallels igir's `Title (Region)` No-Intro style, with a (Hack) tag).
|
||||
|
||||
Run on valhalla: python3 romhack-fetch.py [--place] [--only <substr>]
|
||||
Without --place it downloads + validates but does not touch the library.
|
||||
"""
|
||||
import sys, os, json, zlib, shutil, subprocess, zipfile, re, urllib.request, urllib.parse
|
||||
|
||||
ROMS = "/storage1/Emulation/roms"
|
||||
WORK = "/storage1/igir/romhacks/work"
|
||||
PATCHES = "/storage1/igir/romhacks/patches"
|
||||
APPLY = "/storage1/igir/romhacks/tools/apply.py"
|
||||
UA = "Mozilla/5.0 (homelab personal archival)"
|
||||
|
||||
BASES = {
|
||||
"crystal_rev1": f"{ROMS}/gbc/Pokemon - Crystal Version (USA, Europe) (Rev 1).gbc",
|
||||
"gold": f"{ROMS}/gbc/Pokemon - Gold Version (USA, Europe) (SGB Enhanced) (GB Compatible).gbc",
|
||||
"silver": f"{ROMS}/gbc/Pokemon - Silver Version (USA, Europe) (SGB Enhanced) (GB Compatible).gbc",
|
||||
"ruby": f"{ROMS}/gba/Pokemon - Ruby Version (USA, Europe).gba",
|
||||
"sapphire": f"{ROMS}/gba/Pokemon - Sapphire Version (USA, Europe).gba",
|
||||
"emerald": f"{ROMS}/gba/Pokemon - Emerald Version (USA, Europe).gba",
|
||||
"firered": f"{ROMS}/gba/Pokemon - FireRed Version (USA, Europe).gba",
|
||||
"leafgreen": f"{ROMS}/gba/Pokemon - LeafGreen Version (USA, Europe).gba",
|
||||
"red": f"{ROMS}/gb/Pokemon - Red Version (USA, Europe) (SGB Enhanced).gb",
|
||||
"heartgold": f"{ROMS}/nds/Pokemon HeartGold Version.nds",
|
||||
"soulsilver": f"{ROMS}/nds/Pokemon SoulSilver Version.nds",
|
||||
}
|
||||
|
||||
def arc(idn, fn):
|
||||
return f"https://archive.org/download/{idn}/{urllib.parse.quote(fn)}"
|
||||
|
||||
# --- the curated, source-resolved batch (directly downloadable only) ----------
|
||||
MANIFEST = [
|
||||
# GBC
|
||||
{"hack": "Polished Crystal", "platform": "gbc", "ext": "gbc", "vfmt": "gbc",
|
||||
"kind": "rom", "url": "https://github.com/Rangi42/polishedcrystal/releases/download/v3.2.3/polishedcrystal-3.2.3.gbc",
|
||||
"note": "v3.2.3, official GitHub release ROM (author distributes full .gbc)"},
|
||||
{"hack": "Crystal Clear", "platform": "gbc", "ext": "gbc", "vfmt": "gbc",
|
||||
"kind": "patch", "base": "crystal_rev1",
|
||||
"url": arc("pokemon_crystal_clear_v2.5.7", "2_5_7_Standard_1_1.bps"),
|
||||
"note": "v2.5.7 Standard, BPS vs Crystal v1.1 (self-verifying)"},
|
||||
# GBA
|
||||
{"hack": "Light Platinum", "platform": "gba", "ext": "gba", "vfmt": "gba",
|
||||
"kind": "patch", "base": "ruby",
|
||||
"url": arc("pokemon-light-platinum-u-1.1", "Pokémon_Light_Platinum (U) 1.1.ips"),
|
||||
"note": "v1.1 IPS vs Ruby (USA) — IPS has no checksum, header-validated after"},
|
||||
{"hack": "Gaia", "platform": "gba", "ext": "gba", "vfmt": "gba",
|
||||
"kind": "rom", "url": arc("pokemon-gaia", "GaiaB3.2.gba"),
|
||||
"note": "v3.2 (final), pre-patched ROM"},
|
||||
{"hack": "Radical Red", "platform": "gba", "ext": "gba", "vfmt": "gba",
|
||||
"kind": "rom", "url": arc("pokemon-radical-red-v-4.1", "Pokemon Radical Red v4.1.gba"),
|
||||
"note": "v4.1, pre-patched ROM"},
|
||||
{"hack": "Inclement Emerald", "platform": "gba", "ext": "gba", "vfmt": "gba",
|
||||
"kind": "rom", "url": arc("inclement-emerald_202310", "Inclement Emerald.gba"),
|
||||
"note": "Oct-2023 build, pre-patched ROM"},
|
||||
{"hack": "Glazed", "platform": "gba", "ext": "gba", "vfmt": "gba",
|
||||
"kind": "rom", "url": arc("pokemon-glazed", "pokemon glazed.gba"),
|
||||
"note": "pre-patched ROM; version unverified (Glazed has buggy early builds)"},
|
||||
# NDS
|
||||
{"hack": "Volt White", "platform": "nds", "ext": "nds", "vfmt": "nds",
|
||||
"kind": "rom", "url": arc("pokemon-volt-white-v-3.1-complete", "Pokemon Volt White v3.1 - Complete.nds"),
|
||||
"note": "v3.1 Complete (Drayano, base Black/White), pre-patched ROM"},
|
||||
{"hack": "Renegade Platinum", "platform": "nds", "ext": "nds", "vfmt": "nds",
|
||||
"kind": "rom", "url": arc("pokemon-renegade-platinum-v-1.3.0-complete-normal-shiny",
|
||||
"Pokemon Renegade Platinum v1.3.0 Complete Normal Shiny.nds"),
|
||||
"note": "v1.3.0 Complete (Drayano, base Platinum), pre-patched ROM"},
|
||||
]
|
||||
|
||||
# --- batch 2: more direct-downloadable hacks (some zip-wrapped) ---------------
|
||||
MANIFEST2 = [
|
||||
{"hack": "Prism", "platform": "gbc", "ext": "gbc", "vfmt": "gbc",
|
||||
"kind": "rom", "url": arc("pokeprism_202301", "pokeprism.gbc"),
|
||||
"note": "Pokémon Prism (complete, Crystal-based), pre-patched ROM"},
|
||||
{"hack": "Liquid Crystal", "platform": "gba", "ext": "gba", "vfmt": "gba",
|
||||
"kind": "rom", "url": arc("pokemon-liquid-crystal-v-3.3.00512", "Pokemon - Liquid Crystal (v3.3.00512).gba"),
|
||||
"note": "v3.3.00512 (final), Johto remake, pre-patched ROM"},
|
||||
{"hack": "Theta Emerald EX", "platform": "gba", "ext": "gba", "vfmt": "gba",
|
||||
"kind": "rom", "url": arc("pokemon-theta-emerald-ex_202407", "theta-emerald-ex-02-27-17.gba"),
|
||||
"note": "EX build (all 800+ mons), pre-patched ROM"},
|
||||
{"hack": "Snakewood", "platform": "gba", "ext": "gba", "vfmt": "gba",
|
||||
"kind": "rom", "url": arc("pokemon-snakewood", "Snakewood.gba"),
|
||||
"note": "zombie/horror hack (base Ruby), pre-patched ROM"},
|
||||
{"hack": "Brown", "platform": "gb", "ext": "gb", "vfmt": "gbc",
|
||||
"kind": "patch", "base": "red", "zip_member": r"\.(ips|bps|ups)$",
|
||||
"url": arc("brown_20250526", "brown.zip"),
|
||||
"note": "v1.1 (Koolboyman, base Red) — patch inside zip"},
|
||||
{"hack": "Blaze Black 2 Redux", "platform": "nds", "ext": "nds", "vfmt": "nds",
|
||||
"kind": "rom", "zip_member": r"\.nds$",
|
||||
"url": arc("pokemon-blaze-black-2-redux-complete-v-1.3.0", "Pokemon Blaze Black 2 Redux (Complete v1.3.0).zip"),
|
||||
"note": "Redux fork v1.3.0 Complete (base Black 2), ROM inside zip"},
|
||||
{"hack": "Volt White 2 Redux", "platform": "nds", "ext": "nds", "vfmt": "nds",
|
||||
"kind": "rom", "zip_member": r"\.nds$",
|
||||
"url": arc("pokemon-volt-white-2-redux-complete-v-1.4.1", "Pokemon Volt White 2 Redux Complete (v1.4.1).zip"),
|
||||
"note": "Redux fork v1.4.1 Complete (base White 2), ROM inside zip"},
|
||||
]
|
||||
|
||||
# --- batch 3: additional well-regarded complete hacks (direct ROMs) ----------
|
||||
MANIFEST3 = [
|
||||
{"hack": "Blaze Black", "platform": "nds", "ext": "nds", "vfmt": "nds",
|
||||
"kind": "rom", "url": arc("pokemon-blaze-black", "Blaze Black.nds"),
|
||||
"note": "Drayano (base Black), pairs with Volt White, pre-patched ROM"},
|
||||
{"hack": "Mega Power", "platform": "gba", "ext": "gba", "vfmt": "gba",
|
||||
"kind": "rom", "url": arc("pokemon-mega-power-v-5.62", "Pokemon Mega Power (v5.62).gba"),
|
||||
"note": "v5.62 (complete), pre-patched ROM"},
|
||||
{"hack": "Resolute", "platform": "gba", "ext": "gba", "vfmt": "gba",
|
||||
"kind": "rom", "url": arc("pokemon-resolute", "Resolute.gba"),
|
||||
"note": "complete story hack, pre-patched ROM"},
|
||||
]
|
||||
|
||||
# Original multi-file archive packs handled by one-off steps (not single-artifact
|
||||
# manifest entries). Listed here so --retain can store the true source archives.
|
||||
SPECIAL_SOURCES = [
|
||||
("gba", arc("pokemon-emerald-kaizo", "Pokemon Emerald Kaizo.rar"),
|
||||
"Emerald Kaizo source (rar -> IPS inside)"),
|
||||
("gba", arc("pokemon-dark-rising-complete-pack", "Pokemon Dark Rising Complete Pack.zip"),
|
||||
"Dark Rising 1/2/Order Destroyed/Kaizo (nested zips inside)"),
|
||||
("nds", arc("pokemon-sacred-gold-and-storm-silver-1.5-fairy", "Pokemon Sacred Gold and Storm Silver 1.5.zip"),
|
||||
"Sacred Gold + Storm Silver V1.05 xdelta patch pack"),
|
||||
]
|
||||
|
||||
|
||||
def basename_from_url(url):
|
||||
return os.path.basename(urllib.parse.unquote(urllib.parse.urlparse(url).path))
|
||||
|
||||
|
||||
def retain_all():
|
||||
"""Re-download every source artifact and store it persistently under PATCHES/<platform>/."""
|
||||
rows = []
|
||||
items = [(m["platform"], m["url"], m["hack"]) for m in (MANIFEST + MANIFEST2 + MANIFEST3)]
|
||||
items += [(plat, url, note) for plat, url, note in SPECIAL_SOURCES]
|
||||
for plat, url, label in items:
|
||||
dst_dir = os.path.join(PATCHES, plat)
|
||||
os.makedirs(dst_dir, exist_ok=True)
|
||||
dst = os.path.join(dst_dir, basename_from_url(url))
|
||||
try:
|
||||
sz = download(url, dst)
|
||||
rows.append((label, plat, "OK", f"{sz:,}b", os.path.basename(dst)))
|
||||
except Exception as e:
|
||||
rows.append((label, plat, "FAIL", str(e)[:60], basename_from_url(url)))
|
||||
print("\n=== RETAIN SOURCE ARTIFACTS ===")
|
||||
for lbl, pl, st, dt, nm in rows:
|
||||
print(f"[{st:4}] {pl:4} {dt:>16} {nm}")
|
||||
ok = sum(1 for r in rows if r[2] == "OK")
|
||||
print(f"\n{ok}/{len(rows)} stored under {PATCHES}/<platform>/")
|
||||
|
||||
|
||||
def extract_member(zip_path, pattern, dest):
|
||||
with zipfile.ZipFile(zip_path) as z:
|
||||
members = [n for n in z.namelist() if not n.endswith("/") and re.search(pattern, n, re.I)]
|
||||
if not members:
|
||||
raise RuntimeError(f"no zip member matches {pattern} (have: {z.namelist()[:5]})")
|
||||
# pick the largest matching member (avoids readme/junk)
|
||||
members.sort(key=lambda n: z.getinfo(n).file_size, reverse=True)
|
||||
with z.open(members[0]) as src, open(dest, "wb") as out:
|
||||
shutil.copyfileobj(src, out)
|
||||
return members[0]
|
||||
|
||||
def download(url, dest):
|
||||
req = urllib.request.Request(url, headers={"User-Agent": UA})
|
||||
with urllib.request.urlopen(req, timeout=120) as r, open(dest, "wb") as f:
|
||||
shutil.copyfileobj(r, f)
|
||||
return os.path.getsize(dest)
|
||||
|
||||
def validate(path, vfmt):
|
||||
"""Cheap structural sanity check so a mislabeled/corrupt file is caught."""
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
n = len(data)
|
||||
if vfmt == "gba":
|
||||
if n % (1024 * 1024) != 0 or not (4*1024*1024 <= n <= 32*1024*1024):
|
||||
return f"bad GBA size {n}"
|
||||
if data[0xB2] != 0x96:
|
||||
return "GBA fixed byte 0xB2!=0x96 (not a GBA ROM?)"
|
||||
elif vfmt == "gbc":
|
||||
logo = bytes.fromhex("ceed6666cc0d")
|
||||
if data[0x104:0x10A] != logo:
|
||||
return "GBC Nintendo logo missing at 0x104"
|
||||
elif vfmt == "nds":
|
||||
if not (8*1024*1024 <= n <= 512*1024*1024):
|
||||
return f"bad NDS size {n}"
|
||||
if data[0x15C:0x15E] != b"\x56\xCF": # standard logo CRC16 0xCF56
|
||||
return "NDS logo CRC16 != 0xCF56"
|
||||
return None # ok
|
||||
|
||||
def main():
|
||||
place = "--place" in sys.argv
|
||||
only = None
|
||||
if "--only" in sys.argv:
|
||||
only = sys.argv[sys.argv.index("--only") + 1].lower()
|
||||
if "--retain" in sys.argv:
|
||||
retain_all()
|
||||
return
|
||||
batch = 1
|
||||
if "--batch" in sys.argv:
|
||||
batch = int(sys.argv[sys.argv.index("--batch") + 1])
|
||||
manifest = {1: MANIFEST, 2: MANIFEST2, 3: MANIFEST3}[batch]
|
||||
os.makedirs(WORK, exist_ok=True)
|
||||
rows = []
|
||||
for m in manifest:
|
||||
if only and only not in m["hack"].lower():
|
||||
continue
|
||||
hack = m["hack"]; plat = m["platform"]; ext = m["ext"]
|
||||
out_name = f"Pokemon - {hack} (Hack).{ext}"
|
||||
tmp = os.path.join(WORK, f"dl_{hack.replace(' ', '_')}")
|
||||
status = "OK"; detail = m.get("note", "")
|
||||
try:
|
||||
sz = download(m["url"], tmp)
|
||||
if m.get("zip_member"):
|
||||
inner = os.path.join(WORK, f"zx_{hack.replace(' ', '_')}")
|
||||
picked = extract_member(tmp, m["zip_member"], inner)
|
||||
detail += f" | zip:{os.path.basename(picked)}"
|
||||
tmp = inner
|
||||
if m["kind"] == "patch":
|
||||
base = BASES[m["base"]]
|
||||
if not os.path.exists(base):
|
||||
raise RuntimeError(f"base missing: {base}")
|
||||
final = os.path.join(WORK, f"out_{hack.replace(' ', '_')}.{ext}")
|
||||
r = subprocess.run([sys.executable, APPLY, tmp, base, final],
|
||||
capture_output=True, text=True)
|
||||
if r.returncode != 0:
|
||||
raise RuntimeError(f"apply failed: {r.stderr.strip()}")
|
||||
detail = r.stdout.strip().split("crc32=")[-1].rstrip(")")
|
||||
detail = f"applied, crc32={detail}"
|
||||
src = final
|
||||
else:
|
||||
src = tmp
|
||||
verr = validate(src, m["vfmt"])
|
||||
if verr:
|
||||
raise RuntimeError(f"validation: {verr}")
|
||||
crc = zlib.crc32(open(src, "rb").read()) & 0xffffffff
|
||||
if place:
|
||||
dst_dir = os.path.join(ROMS, plat, "Hacks")
|
||||
os.makedirs(dst_dir, exist_ok=True)
|
||||
shutil.copy2(src, os.path.join(dst_dir, out_name))
|
||||
detail += " | PLACED"
|
||||
rows.append((hack, plat, "OK", f"{os.path.getsize(src):,}b crc={crc:08x}", out_name))
|
||||
except Exception as e:
|
||||
rows.append((hack, plat, "FAIL", str(e)[:80], out_name))
|
||||
print("\n=== ROMHACK FETCH SUMMARY ===")
|
||||
for hk, pl, st, dt, nm in rows:
|
||||
print(f"[{st:4}] {pl:4} {hk:<20} {dt}")
|
||||
if st == "OK":
|
||||
print(f" -> {pl}/Hacks/{nm}")
|
||||
print(f"\nplaced: {'YES (--place)' if place else 'NO (dry run; pass --place)'}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,280 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Import a drop-folder of mixed Pokémon hack files into the valhalla library.
|
||||
|
||||
Handles a folder containing any mix of:
|
||||
- completed ROMs (.gba/.gbc/.gb/.nds) -> validated, clean-named, copied to roms/<plat>/Hacks/
|
||||
- patches (.ips/.bps/.ups/.xdelta) -> applied to an owned base, placed in Hacks/, archived
|
||||
- documentation (.pdf/.txt/.png/.md) -> archived under PATCHES/_docs/
|
||||
- archives (.zip/.rar/.7z) -> extracted and recursed (same rules), source kept
|
||||
|
||||
Naming matches the rest of the library: "Pokemon - <Hack> (Hack).<ext>"
|
||||
(version/junk parentheticals are stripped from the source filename).
|
||||
|
||||
Base ROM for a patch is auto-detected: BPS/UPS embed source CRC32 so the correct
|
||||
base is the one that applies cleanly. IPS has no checksum, so IPS patches must be
|
||||
named in IPS_BASE_MAP or they are reported unresolved (never blindly applied).
|
||||
|
||||
Run on valhalla: python3 romhack-import.py <incoming_dir> [--place]
|
||||
"""
|
||||
import sys, os, re, zlib, shutil, subprocess, zipfile, unicodedata, tempfile
|
||||
|
||||
ROMS = "/storage1/Emulation/roms"
|
||||
PATCHES = "/storage1/igir/romhacks/patches"
|
||||
APPLY = "/storage1/igir/romhacks/tools/apply.py"
|
||||
|
||||
BASES = {
|
||||
"crystal_rev1": f"{ROMS}/gbc/Pokemon - Crystal Version (USA, Europe) (Rev 1).gbc",
|
||||
"gold": f"{ROMS}/gbc/Pokemon - Gold Version (USA, Europe) (SGB Enhanced) (GB Compatible).gbc",
|
||||
"silver": f"{ROMS}/gbc/Pokemon - Silver Version (USA, Europe) (SGB Enhanced) (GB Compatible).gbc",
|
||||
"ruby": f"{ROMS}/gba/Pokemon - Ruby Version (USA, Europe).gba",
|
||||
"sapphire": f"{ROMS}/gba/Pokemon - Sapphire Version (USA, Europe).gba",
|
||||
"emerald": f"{ROMS}/gba/Pokemon - Emerald Version (USA, Europe).gba",
|
||||
"firered": f"{ROMS}/gba/Pokemon - FireRed Version (USA, Europe).gba",
|
||||
"leafgreen": f"{ROMS}/gba/Pokemon - LeafGreen Version (USA, Europe).gba",
|
||||
"red": f"{ROMS}/gb/Pokemon - Red Version (USA, Europe) (SGB Enhanced).gb",
|
||||
}
|
||||
# candidate bases to try per target platform (order = preference)
|
||||
CANDIDATES = {
|
||||
"gba": ["emerald", "firered", "leafgreen", "ruby", "sapphire"],
|
||||
"gbc": ["crystal_rev1", "gold", "silver"],
|
||||
"gb": ["red"],
|
||||
}
|
||||
# IPS patches (no checksum) need an explicit base by name substring
|
||||
IPS_BASE_MAP = [
|
||||
("seaglass", "emerald", "gba"),
|
||||
("crystal kaizo", "crystal_rev1", "gbc"),
|
||||
("kaizo", "crystal_rev1", "gbc"), # fallback for crystal kaizo rar
|
||||
]
|
||||
|
||||
ROM_EXT = {".gba": "gba", ".gbc": "gbc", ".gb": "gb", ".nds": "nds"}
|
||||
PATCH_EXT = {".ips", ".bps", ".ups", ".xdelta"}
|
||||
DOC_EXT = {".pdf", ".txt", ".png", ".md", ".jpg", ".jpeg", ".html",
|
||||
".xlsx", ".docx", ".bmp", ".avi", ".gif"}
|
||||
ARCHIVE_EXT = {".zip", ".rar", ".7z"}
|
||||
|
||||
# Clean display names for files whose filenames are messy (patch/zip artifacts).
|
||||
# (substr-of-original-filename, lowercased) -> canonical hack name. First match wins.
|
||||
NAME_OVERRIDES = [
|
||||
("emeraldseaglass", "Emerald Seaglass"),
|
||||
("emerald seaglass", "Emerald Seaglass"),
|
||||
("lazarus", "Lazarus"),
|
||||
("saiph 2", "Saiph 2"), ("saiph2", "Saiph 2"),
|
||||
("saiph", "Saiph"),
|
||||
("flora-sky", "Flora Sky"), ("flora sky", "Flora Sky"),
|
||||
("sots", "Sovereign of the Skies"),
|
||||
("sors", "Sors"),
|
||||
("aesthetic red", "Aesthetic Red"),
|
||||
("crystal kaizo", "Crystal Kaizo"),
|
||||
]
|
||||
# Files we will NOT auto-place (unidentified / need user to name). Reported instead.
|
||||
SKIP_NAME_SUBSTR = ["beta 15 + expansion"]
|
||||
|
||||
PLACE = False
|
||||
report = []
|
||||
ARCH_SUBDIR = "" # set while recursing an archive, groups its docs under _docs/<subdir>/
|
||||
|
||||
|
||||
def strip_trailing_groups(name):
|
||||
"""Remove trailing (...) / [...] groups that look like version/variant junk."""
|
||||
verkw = re.compile(r"(\d|version|hotfix|bug.?fix|final|anniversary|classic\+|"
|
||||
r"beta|\brev\b|english|main|patch|suloku|pss|complete)", re.I)
|
||||
while name and name[-1] in ")]":
|
||||
close = name[-1]; open_ch = "(" if close == ")" else "["
|
||||
depth = 0; start = -1
|
||||
for i in range(len(name) - 1, -1, -1):
|
||||
if name[i] == close: depth += 1
|
||||
elif name[i] == open_ch:
|
||||
depth -= 1
|
||||
if depth == 0: start = i; break
|
||||
if start < 0: break
|
||||
inner = name[start:]
|
||||
if verkw.search(inner):
|
||||
name = name[:start].rstrip()
|
||||
else:
|
||||
break
|
||||
return name
|
||||
|
||||
|
||||
def clean_name(fn):
|
||||
base = os.path.basename(fn).lower()
|
||||
for sub, canon in NAME_OVERRIDES:
|
||||
if sub in base:
|
||||
return canon
|
||||
name = os.path.splitext(os.path.basename(fn))[0]
|
||||
name = unicodedata.normalize("NFKD", name).encode("ascii", "ignore").decode()
|
||||
name = name.replace("_", " ")
|
||||
name = re.sub(r"^\s*pokemon\s*-\s*", "", name, flags=re.I)
|
||||
name = re.sub(r"^\s*pokemon\s+", "", name, flags=re.I)
|
||||
name = strip_trailing_groups(name)
|
||||
# strip trailing version/junk tokens left outside parens
|
||||
name = re.sub(r"\s*(full release|full version|completed|\bby .+|v\d[\d._]*|"
|
||||
r"version|\d{4}|\d{1,2}-\d{1,2}-\d{2,4})\s*$", "", name, flags=re.I).strip(" -_")
|
||||
return name or os.path.splitext(os.path.basename(fn))[0]
|
||||
|
||||
|
||||
def is_skip_name(fn):
|
||||
base = os.path.basename(fn).lower()
|
||||
return any(s in base for s in SKIP_NAME_SUBSTR)
|
||||
|
||||
|
||||
def crc32(path):
|
||||
return zlib.crc32(open(path, "rb").read()) & 0xffffffff
|
||||
|
||||
|
||||
def validate(path, plat):
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
n = len(data)
|
||||
if plat == "gba":
|
||||
if data[0xB2] != 0x96:
|
||||
return "not a GBA ROM (byte 0xB2 != 0x96)", None
|
||||
if n not in (4*1024*1024, 8*1024*1024, 16*1024*1024, 32*1024*1024):
|
||||
for t in (8, 16, 32):
|
||||
if n <= t*1024*1024:
|
||||
return None, t*1024*1024 # needs pad to t MB
|
||||
elif plat in ("gbc", "gb"):
|
||||
if data[0x104:0x10A] != bytes.fromhex("ceed6666cc0d"):
|
||||
return "GB/GBC Nintendo logo missing", None
|
||||
elif plat == "nds":
|
||||
if data[0x15C:0x15E] != b"\x56\xCF":
|
||||
return "NDS logo CRC16 != 0xCF56", None
|
||||
return None, None
|
||||
|
||||
|
||||
def place_rom(src, plat, hackname, origin):
|
||||
if is_skip_name(origin):
|
||||
report.append(("ROM", "NEEDS-ID", origin, "unidentified hack — tell me the name", ""))
|
||||
return
|
||||
out_name = f"Pokemon - {hackname} (Hack).{plat}"
|
||||
err, padto = validate(src, plat)
|
||||
if err:
|
||||
report.append(("ROM", "FAIL", origin, err, "")); return
|
||||
data = open(src, "rb").read()
|
||||
if padto and len(data) < padto:
|
||||
data += b"\xff" * (padto - len(data))
|
||||
if PLACE:
|
||||
d = os.path.join(ROMS, plat, "Hacks"); os.makedirs(d, exist_ok=True)
|
||||
with open(os.path.join(d, out_name), "wb") as f:
|
||||
f.write(data)
|
||||
report.append(("ROM", "OK", origin, f"{len(data):,}b crc={zlib.crc32(data)&0xffffffff:08x}",
|
||||
f"{plat}/Hacks/{out_name}"))
|
||||
|
||||
|
||||
def try_apply(patch, base_key, out):
|
||||
base = BASES[base_key]
|
||||
if not os.path.exists(base):
|
||||
return False, "base file missing"
|
||||
r = subprocess.run([sys.executable, APPLY, patch, base, out],
|
||||
capture_output=True, text=True)
|
||||
return (r.returncode == 0), (r.stdout or r.stderr).strip()
|
||||
|
||||
|
||||
def place_patch(patch, origin):
|
||||
ext = os.path.splitext(patch)[1].lower()
|
||||
hackname = clean_name(patch)
|
||||
# archive the patch file itself
|
||||
if PLACE:
|
||||
ad = os.path.join(PATCHES, "_imported"); os.makedirs(ad, exist_ok=True)
|
||||
shutil.copy2(patch, os.path.join(ad, os.path.basename(patch)))
|
||||
tmp_out = patch + ".out"
|
||||
if ext == ".ips":
|
||||
hit = next(((bk, pl) for sub, bk, pl in IPS_BASE_MAP if sub in patch.lower()), None)
|
||||
if not hit:
|
||||
report.append(("PATCH", "UNRESOLVED", origin, "IPS needs known base (not in map)", ""))
|
||||
return
|
||||
bk, plat = hit
|
||||
ok, msg = try_apply(patch, bk, tmp_out)
|
||||
if not ok:
|
||||
report.append(("PATCH", "FAIL", origin, f"ips/{bk}: {msg[:50]}", "")); return
|
||||
place_rom(tmp_out, plat, hackname, origin); return
|
||||
if ext == ".xdelta":
|
||||
report.append(("PATCH", "SKIP", origin, "xdelta: handle via xdelta tool", "")); return
|
||||
# BPS / UPS: auto-detect base across all platforms (CRC-verified)
|
||||
for plat, keys in CANDIDATES.items():
|
||||
for bk in keys:
|
||||
ok, msg = try_apply(patch, bk, tmp_out)
|
||||
if ok:
|
||||
place_rom(tmp_out, plat, hackname, origin + f" [base={bk}]")
|
||||
return
|
||||
report.append(("PATCH", "FAIL", origin, "no owned base matched (BPS/UPS CRC)", ""))
|
||||
|
||||
|
||||
def archive_doc(path, origin):
|
||||
sub = os.path.join("_docs", ARCH_SUBDIR) if ARCH_SUBDIR else "_docs"
|
||||
rel = os.path.join(sub, os.path.basename(path))
|
||||
if PLACE:
|
||||
d = os.path.join(PATCHES, sub); os.makedirs(d, exist_ok=True)
|
||||
shutil.copy2(path, os.path.join(PATCHES, rel))
|
||||
report.append(("DOC", "OK", origin, f"{os.path.getsize(path):,}b", rel))
|
||||
|
||||
|
||||
def process_file(path, origin=None):
|
||||
origin = origin or os.path.basename(path)
|
||||
ext = os.path.splitext(path)[1].lower()
|
||||
if ext in ROM_EXT:
|
||||
place_rom(path, ROM_EXT[ext], clean_name(path), origin)
|
||||
elif ext in PATCH_EXT:
|
||||
place_patch(path, origin)
|
||||
elif ext in DOC_EXT:
|
||||
archive_doc(path, origin)
|
||||
elif ext in ARCHIVE_EXT:
|
||||
process_archive(path, origin)
|
||||
else:
|
||||
report.append(("SKIP", "?", origin, f"unknown ext {ext}", ""))
|
||||
|
||||
|
||||
def process_archive(path, origin):
|
||||
# keep the source archive
|
||||
if PLACE:
|
||||
ad = os.path.join(PATCHES, "_archives"); os.makedirs(ad, exist_ok=True)
|
||||
shutil.copy2(path, os.path.join(ad, os.path.basename(path)))
|
||||
global ARCH_SUBDIR
|
||||
tmp = tempfile.mkdtemp(prefix="imp_")
|
||||
ext = os.path.splitext(path)[1].lower()
|
||||
prev_subdir = ARCH_SUBDIR
|
||||
# group this archive's docs under a sanitized folder name
|
||||
ARCH_SUBDIR = re.sub(r"[^\w.\- ]", "_", os.path.splitext(os.path.basename(path))[0])[:40]
|
||||
try:
|
||||
if ext == ".zip":
|
||||
with zipfile.ZipFile(path) as z:
|
||||
z.extractall(tmp)
|
||||
else: # rar/7z via unar in container
|
||||
subprocess.run(["docker", "run", "--rm", "-v", f"{os.path.dirname(path)}:/in:ro",
|
||||
"-v", f"{tmp}:/out", "node:lts", "bash", "-c",
|
||||
"apt-get update -qq>/dev/null 2>&1; apt-get install -y -qq unar>/dev/null 2>&1; "
|
||||
f"unar -force-overwrite -o /out '/in/{os.path.basename(path)}' >/dev/null"],
|
||||
capture_output=True, text=True)
|
||||
for root, _, files in os.walk(tmp):
|
||||
for fn in files:
|
||||
fp = os.path.join(root, fn)
|
||||
process_file(fp, origin=f"{os.path.basename(path)} :: {fn}")
|
||||
finally:
|
||||
ARCH_SUBDIR = prev_subdir
|
||||
shutil.rmtree(tmp, ignore_errors=True)
|
||||
|
||||
|
||||
def main():
|
||||
global PLACE
|
||||
args = [a for a in sys.argv[1:] if not a.startswith("--")]
|
||||
PLACE = "--place" in sys.argv
|
||||
incoming = args[0]
|
||||
for fn in sorted(os.listdir(incoming)):
|
||||
fp = os.path.join(incoming, fn)
|
||||
if os.path.isfile(fp):
|
||||
process_file(fp)
|
||||
# report
|
||||
order = {"OK": 0, "UNRESOLVED": 1, "SKIP": 2, "FAIL": 3}
|
||||
print(f"\n=== IMPORT REPORT ({'PLACED' if PLACE else 'DRY RUN'}) ===")
|
||||
for typ, st, origin, detail, dest in sorted(report, key=lambda r: (r[0], order.get(r[1], 9))):
|
||||
line = f"[{st:10}] {typ:5} {origin[:46]:46} {detail}"
|
||||
print(line)
|
||||
if dest:
|
||||
print(f"{'':19}-> {dest}")
|
||||
counts = {}
|
||||
for r in report:
|
||||
counts[(r[0], r[1])] = counts.get((r[0], r[1]), 0) + 1
|
||||
print("\nsummary:", dict(sorted(counts.items())))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user