# SPDX-License-Identifier: MIT """The BIOS image: the player's own dump, or Cult-of-GBA's free BIOS. Owner's decision (docs/handoff-brief.md): the retail BIOS is the player's dump, read in place (``--bios``, a .bin or a No-Intro .zip), never committed or fetched; Cult-of-GBA's BIOS (MIT, pinned by scripts/pinned_repos.json, built image never committed) is the default for runs without one. The board runs whichever image it is given as ordinary ARM code (no HLE: docs/README.md "What the BIOS does that the board must not"). """ from __future__ import annotations from pathlib import Path from gba_python.files import read_image BIOS_SIZE = 0x4000 # 16 KB (GBATEK §GBA Memory Map; DOC) ROOT = Path(__file__).resolve().parents[2] FREE_BIOS = ROOT / "reference" / "src" / "bios-cult-of-gba" / "bios.bin" def load_bios(choice: str | Path | None = None) -> bytes: """``None`` or ``"free"``: Cult-of-GBA's image; otherwise a path (.bin or .zip).""" path = FREE_BIOS if choice in (None, "free") else Path(choice) data = read_image(path, (".bin", ".gba", ".rom")) if len(data) != BIOS_SIZE: raise ValueError(f"{path}: a GBA BIOS is {BIOS_SIZE} bytes, this is {len(data)}") return data