# SPDX-License-Identifier: MIT """The five chips as one frozen description (handoff-brief decisions 1, 7, 8). No source documents an instruction-set difference between the Mario Chip 1, GSU-1, GSU-1A, GSU-2 and GSU-2-SP1 (start-here.md). What differs is what the S-CPU reads back (VCR, the register-file mirrors), whether CFGR's high-speed multiplier bit exists, and the memory limits the board decodes. Everything the core does differently for a chip reads one of these fields; there is no second class. """ from __future__ import annotations from dataclasses import dataclass #: Register-file mirror layouts (fullsnes "Full I/O Map with Mirrors"; U12, research tier). MIRRORS_MC1 = "mc1" MIRRORS_GSU2 = "gsu2" @dataclass(frozen=True, slots=True) class Model: """One Super FX chip.""" name: str #: The byte the S-CPU reads at ``$303B`` (U23: 1 on the Black Blob MC1, 4 on the GSU-2; #: the other three are unknown and take the emulators' 4). vcr: int #: True when ``vcr`` is a reported value, False when it is the emulators' guess (U23). vcr_known: bool #: CFGR bit 5 (MS0) selects the high-speed multiplier. fullsnes "CFGR": "it is not #: implemented on Black Blob MC1 (which is always using slow multiply mode)" (U25). ms0_implemented: bool #: Largest ROM and RAM the chip addresses (fullsnes "Memory Map" per chip; U22). The core #: does not enforce them: it masks by the lengths of the buffers the board hands it. rom_limit: int ram_limit: int #: Which of fullsnes' register-file mirror tables the chip answers with (U12). mirrors: str #: The highest S-CPU register-file address the chip decodes (MC1 ``$347F``, the others #: ``$34FF``: fullsnes "Memory Map"); above it the board's open bus answers. io_end: int def __post_init__(self) -> None: if not 0 <= self.vcr <= 0xFF: raise ValueError("vcr must be a byte") if self.mirrors not in (MIRRORS_MC1, MIRRORS_GSU2): raise ValueError("mirrors must be 'mc1' or 'gsu2'") if self.rom_limit <= 0 or self.ram_limit <= 0: raise ValueError("rom_limit and ram_limit must be positive") #: Mario Chip 1 (Star Fox / Starwing): clocked by the SNES master clock (C8). MC1 = Model( name="mc1", vcr=0x01, vcr_known=True, ms0_implemented=False, rom_limit=0x100000, ram_limit=0x10000, mirrors=MIRRORS_MC1, io_end=0x347F, ) #: GSU-1 (Stunt Race FX, Vortex, Dirt Racer, Dirt Trax FX): own 21.4 MHz crystal. GSU1 = Model( name="gsu1", vcr=0x04, vcr_known=False, ms0_implemented=True, rom_limit=0x100000, ram_limit=0x10000, mirrors=MIRRORS_GSU2, io_end=0x34FF, ) #: GSU-1A (the Powerslide prototype board). GSU1A = Model( name="gsu1a", vcr=0x04, vcr_known=False, ms0_implemented=True, rom_limit=0x100000, ram_limit=0x10000, mirrors=MIRRORS_GSU2, io_end=0x34FF, ) #: GSU-2 (Doom, Yoshi's Island early boards, Winter Gold, Star Fox 2): 21.44 MHz crystal. GSU2 = Model( name="gsu2", vcr=0x04, vcr_known=True, ms0_implemented=True, rom_limit=0x200000, ram_limit=0x20000, mirrors=MIRRORS_GSU2, io_end=0x34FF, ) #: GSU-2-SP1 (Yoshi's Island, SHVC-1CB5B-20). GSU2_SP1 = Model( name="gsu2_sp1", vcr=0x04, vcr_known=False, ms0_implemented=True, rom_limit=0x200000, ram_limit=0x20000, mirrors=MIRRORS_GSU2, io_end=0x34FF, ) MODELS = {model.name: model for model in (MC1, GSU1, GSU1A, GSU2, GSU2_SP1)} __all__ = [ "GSU1", "GSU1A", "GSU2", "GSU2_SP1", "MC1", "MIRRORS_GSU2", "MIRRORS_MC1", "MODELS", "Model", ]