"""Build the window-7 mapper test ROM. Needs the project's assembler toolchain (GNU binutils m68k-linux-gnu-as and z80asm, driven through WSL by rrmd/toolchain.py). The assembled ROMs are committed too - the repository ignores *.bin, with an exception for this directory - so the test can be run without reproducing the toolchain. python tools/mapper_test/build.py """ from __future__ import annotations import sys from pathlib import Path HERE = Path(__file__).resolve().parent sys.path.insert(0, str(HERE.parents[1])) from rrmd.toolchain import assemble_68k, assemble_z80 # noqa: E402 def main() -> int: assemble_z80(HERE / "mapper_z80.z80", HERE / "mapper_z80.bin") rom = HERE / "mapper_test.bin" assemble_68k(HERE / "mapper_test.s", rom, listing=HERE / "mapper_test.lst", include_dirs=(HERE,)) blob = rom.read_bytes() assert blob[0x100:0x110] == b"SEGA SSF ", "the SSF signature selects the mapper" assert blob[0x080000] == 0xA1 and blob[0x100000] == 0xB2, "markers not where the test expects" print(f"{rom}: {rom.stat().st_size:,} bytes; markers and SSF signature verified") return 0 if __name__ == "__main__": raise SystemExit(main())