# SPDX-License-Identifier: MIT """Experimental mapper-559 variants recorded in audit.md. None of these is a working mapper. Set MAPPER559_VARIANT to choose the checkpoint: first bank 13 at $A000, bank 0 at $C000, mapper-330 writes left active bank13 bank 13 at $A000 and $C000, PRG writes ignored, $F800/$5800 ack bank30 bank 30 at $C000, bank 13 at $A000, PRG writes ignored all13 bank 13 in all three windows, PRG writes ignored Install with tools/run_rom.py --install-module . """ from __future__ import annotations import os from famicom_python.cartridge import MAPPERS, Sangokushi330 class First(Sangokushi330): def __init__(self, image, cpu_cycle_ticks): super().__init__(image, cpu_cycle_ticks) self.map_prg(0, 8, 0) self.map_prg(1, 8, 13) self.map_prg(2, 8, 0) class Bank13(Sangokushi330): def __init__(self, image, cpu_cycle_ticks): super().__init__(image, cpu_cycle_ticks) self.map_prg(0, 8, 0) self.map_prg(1, 8, 13) self.map_prg(2, 8, 13) def cpu_write(self, address: int, value: int, t: int) -> None: if address in (0xF800, 0x5800): self.irq = False self.counting = False return if 0xE000 <= address <= 0xF7FF: return super().cpu_write(address, value, t) class Bank30(Bank13): def __init__(self, image, cpu_cycle_ticks): super().__init__(image, cpu_cycle_ticks) self.map_prg(2, 8, 30) class All13(Bank13): def __init__(self, image, cpu_cycle_ticks): super().__init__(image, cpu_cycle_ticks) self.map_prg(0, 8, 13) VARIANTS = {"first": First, "bank13": Bank13, "bank30": Bank30, "all13": All13} def install() -> None: name = os.environ.get("MAPPER559_VARIANT", "bank13") if name not in VARIANTS: raise SystemExit(f"unknown MAPPER559_VARIANT {name!r}; choose {sorted(VARIANTS)}") MAPPERS[559] = VARIANTS[name]