# Sound: the AY-3-8912 on the VIA, and the DAC as a fifth voice Source tags as in [start-here.md](start-here.md) and [analog.md](analog.md). ## Wiring | Signal | Source | Use | | --- | --- | --- | | PSG DA0-DA7 | VIA PA0-PA7 | the same eight lines feed the DAC: every PSG byte also reaches the X integrator's input ([analog.md](analog.md) ยง1) [sch] | | BDIR | VIA PB4 | bus control [sch] | | BC1 | VIA PB3 | bus control [sch] | | BC2 | tied high | so BDIR/BC1 alone choose the bus function [sch] | | CLOCK | E, 1.5 MHz | [sch]; MAME `AY8912(config, m_ay8912, 6_MHz_XTAL / 4)` | | IOA0-IOA7 | the eight controller buttons, SW0-SW7 (active low, 680 ohm series, 1 nF to ground each) | register 14 reads the buttons ([controllers.md](controllers.md)) [sch] | | A, B, C outputs | 1k load each, 33k each into a common node, 4.7 uF coupling (C323) | then the volume pot R326 10k and J302 to the amplifier on the power board [sch] | The AY-3-8912 is the 28-pin part: one I/O port (A), and the mask-programmed upper address (A8 high, /A9 low inside) means an address byte whose high nibble is not 0 deselects the chip. `ay8910-python` models exactly that (`select()`: "The high four must be 0; any other byte deselects the chip"); vecx checks the same nibble (`if ((via_ora & 0xf0) == 0x00)`); MAME 0.285 logs "AY-3-8912A PSG upper address mismatch" at reset in every run here (a warning about its own power-on state, not a program's write; not investigated further). ## Bus functions, as the Executive drives them `Sound_Byte_raw` at `$F25B` [bt], with the port B values the MAME run confirms [ran]: | Port B | BDIR (PB4) | BC1 (PB3) | Mux (PB0) | PSG function | | --- | --- | --- | --- | --- | | `$19` | 1 | 1 | off | latch address (port A = register number) | | `$11` | 1 | 0 | off | write (port A = data) | | `$09` | 0 | 1 | off | read: the PSG drives port A (the VIA's DDRA must be `$00`) | | `$01` | 0 | 0 | off | inactive | Sequence: `STA write(PORTA ^ 0x80)` | `held_sound` | not modelled | | after the mux is turned off | 0 V (R330 to ground) | **holds the last value** | **holds** (`held_sound`) | - | | delay | none drawn | none (the DAC write is immediate; the analog copy is delayed) | 12 cycles | - | This is conflict **C6**: the board follows the schematic (no hold); the presets for comparing against MAME or MiSTer audio may hold. ## Mixing and the buzz The board outputs, per E cycle, the PSG's three `levels()` codes and the DAC voice's code (or `None` while the mux is elsewhere); the conversion to one waveform (the 33k/1k network, the coupling capacitor, the volume, the amplifier) belongs to a host-side mixer with named parameters, like the analog model. The famous Vectrex buzz is **not** part of the logic board's sound: the FAQ (7.2, quoting Daniel A. Muntz) attributes it to induction into the audio cable and ground impedance between the boards, noise that "closely follows the video" [faq]. An optional host-side buzz derived from the beam segments is possible; it is out of the board's scope. ## Judges | Oracle | Tier | Decides | | --- | --- | --- | | `ay8910-python` and its own oracles (die-model judge: see its `docs/validation.md`) | per that repo | the PSG itself; the board does not re-certify it | | AY-3-8910/8912 data sheet | 2 | bus states and timing (U12) - not fetched here: `ay8910-python` holds the family's copy | | MAME `ay8910.cpp` (BSD-3), vecx, Vide, the MiSTer core's JT49 (closed boxes; their source not fetched since 2026-11-24) | 5 | detectors for register streams | | Register-write streams from MAME's `via.log` (port B `$19`/`$11` states with the port A value of the cycle) | 5 | exact comparison of what reaches the PSG, cycle by cycle | Exit test for the sound milestone in [handoff-brief.md](handoff-brief.md): the PSG register-write stream reconstructed from the board equals the one reconstructed from MAME's `via.log` over the same boot, and the DAC-voice code stream (port A writes while the mux is on channel 3) equals the one in MAME's `via.log` for a program that uses it, apart from C6.