"""What differs between the parts, as data. Nothing in ``chip.py`` asks which part it is running: it reads these fields. Each field names its spec section (``docs/spec.md``) and how well it is known. """ from __future__ import annotations from dataclasses import dataclass @dataclass(frozen=True) class FMVariant: """One part. A frozen record of plain values.""" #: For messages and save-state labels. name: str #: Whether the output stage is the discrete chip's (spec 15.2). The discrete #: YM2612's converter has a step at mid-scale, measured on several consoles and #: described by Yamaha as a muted channel being "faintly audible"; the YM3438 #: and the ASIC do not show it (spec 15.3, measured). ladder: bool #: Added, in steps of the 9-bit converter, to a slot whose value is zero or #: positive, to a slot whose value is negative, and to a slot whose channel is #: panned away from this side (spec 15.2.5, unknown U12, decision T10). #: PROVISIONAL, emulator tier: +4, -3 and +4 are ymfm's (BSD-3-Clause), which #: gives no source for them. Two hardware reports of the mid-scale step alone #: are smaller (GManiac, "3-4x"; Kabuto, "a jump of 3"). Not measured, not #: fitted to anything. ladder_positive: int ladder_negative: int ladder_idle: int #: Which of the four addresses return the status byte; the others leave the bus #: undriven and ``read`` returns None (spec 12.5, contradiction C4, decision #: T3). PROVISIONAL: sources disagree. The discrete chip: address 0 only #: (Yamaha's YM2612 manual, Sega's Technical Bulletin 11, Eke's measurement on a #: VA4 model 1). The ASIC: all four (Eke's measurement on a VA0 model 2, and one #: game that plays slowly there). Stef measured the reverse in 2023. status_ports: tuple[bool, bool, bool, bool] #: The accumulator's upper limit (spec 14.2, contradiction C8, decision T5). #: PROVISIONAL: +255, a 9-bit signed value. GManiac measured +256, "AFAIR". accumulator_max: int #: The discrete NMOS YM2612 of Mega Drive model 1 boards. YM2612_DISCRETE = FMVariant( name="YM2612", ladder=True, ladder_positive=4, ladder_negative=-3, ladder_idle=4, status_ports=(True, False, False, False), accumulator_max=255, ) #: The YM3438's behaviour, as measured mostly on the FM block of the model 2's #: ASIC (decision T18). It also stands for a discrete YM3438 until a source shows #: the two differ (unknown U20, decision T17). Reported and not measured, so not #: modelled: the ASIC being louder and clipping lower (unknown U13). YM3438_ASIC = FMVariant( name="YM3438", ladder=False, ladder_positive=0, ladder_negative=0, ladder_idle=0, status_ports=(True, True, True, True), accumulator_max=255, )