# What the boards need Read off the boards' own code (sms-python `board.py` and `audio.py`; megadrive-python `board.py`), not off the earlier core. A new core that offers this drops in without board changes; where a better shape is found, say so and change the boards with it. ```python from sn76489_python import ( SN76489, PSGVariant, CLOCKS_PER_SAMPLE, SN76489AN, # the discrete TI part: SG-1000, SC-3000 SEGA_VDP_PSG, # inside the Master System's VDP GAME_GEAR_PSG, # the Game Gear's, with stereo YM7101_PSG, # inside the Mega Drive's VDP ) psg = SN76489(SEGA_VDP_PSG) # a variant is a value, not a subclass psg.write(value) # the one write-only port (latch and data bytes) psg.write_stereo(value) # Game Gear port $06 psg.run(cycles) # advance by input clocks (the Z80's clock on these machines) samples = psg.take_samples() # what was produced since the last call psg.stereo # the stereo register, readable by tests ``` - `take_samples()` gives one entry per `CLOCKS_PER_SAMPLE` input clocks, each a `(left, right)` pair of levels from 0.0 to 4.0 (four channels at full volume). The boards resample from there. - megadrive-python also calls `psg.write_test(...)` for the YM7101's test bits. Whether a new core has a source for those is a Phase 0 question. **Answered by the build (decision D7):** `write_test(value)` exists only on `YM7101_PSG`; on the other variants the call raises `AttributeError`. `value` is the VDP's debug register 0 as written, of which the PSG reads bits 11-9. It is provisional and untested (spec section 11). - The variants differ in data: the noise shift register's width and taps, the volume curve, stereo, the power-on state. What each field is and where its value comes from is the spec's job. - sms-python's save states walk the core's objects, so state must be plain attributes (numbers, lists, bytearrays); a frozen dataclass is taken for configuration. Known open questions carried over, each needing a source: the discrete chip's tone register 0 (a period of 1 or of 1024), and the Sega PSG's noise sequence (sms-python `docs/undocumented-behavior.md`, open items 3 and 6). ## Added by the build (2026-11-12) Nothing above changed shape. Three things a board may use and need not: - `SN76489(variant, silent_start=True)` and `psg.reset(silent_start=True)`: start every channel at attenuation 15. The discrete chip is not reset at power-on and otherwise starts sounding, as the hardware did (decision D5). - `variant.volume_table`: sixteen amplitudes, the ideal 2 dB curve by default. A console's measured curve is passed as data: `dataclasses.replace(SEGA_VDP_PSG, volume_table=...)` (decision D11). - `variant.ready_clocks`: 32 on the discrete chip, 0 on Sega's parts. The core does nothing with it; an SC-3000 board that stalls the Z80 on READY reads it. State a save-state walker will meet on an instance: `tone`, `noise`, `volume`, `stereo`, `latched`, `counters`, `outputs`, `noise_counter`, `noise_input`, `lfsr`, `test`, `clock_remainder` (ints and lists of ints), `samples` (a list of `(left, right)` tuples, empty after `take_samples()`), and `variant` (frozen configuration).