# Sound and the hand controllers: the AY-3-8914 PSG The Programmable Sound Generator makes all of the Master Component's sound and is also the only input device: its two 8-bit ports read the hand controllers. By the chip rule it is **not** in this board: the AY-3-891x family is `../ay8910-python` (public core, used by famicom-python's Sunsoft 5B), and the 8914 joins it as data plus one engine change (below). This page says exactly what that core must gain. Sources (tiers in [validation.md](validation.md)): - **[gi78]** GI catalogue 1978, section 7, pages 7-100 to 7-105: an "AY-3-8910 PRELIMINARY INFORMATION" sheet that describes the **AY-3-8914** (register numbering, 6-bit volume registers, CS0-CS2 pins). MAME's `ay8910.cpp` (lines 296-299, 448) identifies it so; the register table matches the Intellivision's map exactly (tier 2). Page images and OCR: `reference/docs/gi_micro/page_7_100.png`..`105.png`, `ocr/`. - **[die]** siliconpr0n's AY-3-8914 die photograph (John McMaster, metal layer, 11,411 x 10,338 pixels), pinned by SHA-256 through its Wayback Machine capture; markings "90-32022" and "(C) 1978 G.I. CORP" read here (tier 1 raw material; no schematic or netlist of the 8914 exists that was found). - **[parts78]** Mattel parts list 1978: IC6 "AY-3-8910 PSG" (the 1978 name of the part). - **[jz-psg]** jzIntv `doc/programming/psg.txt` (tier 3). **[wiki]** Intellivision Wiki *PSG* (tier 3). - **[mame]** MAME 0.285 `src/devices/sound/ay8910.cpp`, `.h` (tier 5; its read-back masks are marked "Tested and confirmed on hardware"). - **[hw26]** `openFPGA-Intellivision` `docs/PSG_NOTES.md` (a model checked against MAME's register logs and streams on eight games; no console audio recording yet; tier 5). ## The part on this board | Fact | Value | Source | | --- | --- | --- | | Address | `$01F0-$01FF`, 16 registers, one per word; an 8-bit device (the upper byte reads 0) | [jz-psg], [wiki], [mame] | | Bus interface | the CP1600's own phases: BDIR, BC1, BC2 decoded inside the chip; the address is latched on **BAR or ADAR**, data moves on DTB (read) and DW + DWS (write) | [gi78] p.7-103 timing diagrams, p.7-105 Fig. 7 | | Clock | master / 2: 1,789,772.5 Hz NTSC, 2,000,000 Hz PAL; tone frequency = master / (32 P) | [jz-psg], [gi78] ("2 MHz TTL clock"), [wiki] | | Ports | `$01FE` = port A = **right** controller, `$01FF` = port B = **left**, both inputs | [jz-psg], [mame] `intv.cpp` | | Outputs | A, B and C tied together into the audio stage; the cartridge's AUDIO input is mixed in | [hw26] citing the Service Manual Fig. 7-2; cartridge connector [bus.md](bus.md) | | Other PSG parts in the family | AY-3-8916 in "certain later Intellivision II systems" ([mame] notes; [jz-psg]: "the PSGs used in later units"); AY-3-8917 in the ECS at `$00F0-$00FF` | [mame], [jz-psg], [wiki] | ## How the AY-3-8914 differs from the AY-3-8910 1. **Register order.** Bus address 0-15 selects AY-3-8910 register `0, 2, 4, 11, 1, 3, 5, 12, 7, 6, 13, 8, 9, 10, 14, 15`: the three tone fine periods, the envelope fine period, the three coarse periods, the envelope coarse period, the enable register, the noise period, the envelope shape, the three volumes, port A, port B. GI's octal table R0-R17 [gi78 p.7-101], [jz-psg] and MAME's `mapping8914to8910` agree. 2. **Volume registers are 6 bits.** Bits 5-4 (GI's C1 C0): `00` the fixed level in bits 3-0; `01` the envelope shifted right by 2; `10` shifted right by 1; `11` the envelope itself. GI's table, [jz-psg] and [mame] (`env_volume >> (3 - tone_envelope)`) agree. The 8910 has one select bit (bit 4) and no shift. **This is an engine change, not only data**: ay8910-python's mixer reads bit 4 as "envelope". 3. **Read-back.** As the 8910 (unimplemented bits read 0) except the three volumes keep 6 bits (`$3F`): MAME, "tested and confirmed on hardware". In 8914 address order the kept bits are `FF FF FF FF 0F 0F 0F FF FF 1F 0F 3F 3F 3F FF FF`. The wiki calls the shape register write-only (reads 0) where MAME keeps 4 bits (C9). 4. **Chip select.** The 8914's DA0-DA7 carry the low address byte; [mame]'s pin notes say A7-A4 must match a mask-programmed value, "0000 for the part shipped with the Intellivision" and "1111" for the ECS's 8917, with pins 24-26 as /A9, A8 and TEST2 (CS0-CS2 on GI's sheet) as further enables. But the Master Component's PSG answers at `$01F0` and the ECS's at `$00F0`, whose bits 7-4 are both `1111` (C8). This board decodes the PSG's range itself and hands the core only the register number, so the contradiction does not block the board; it matters to the core's `select()` rule. 5. **Port direction bits.** Register 7 (8910 numbering) bit 6 = port A, bit 7 = port B, 1 = output [gi78 p.7-101]; ay8910-python already does this. jzIntv's `psg.txt` says b7 = port A, b6 = port B, but in its section copied from an AY-3-8912 sheet; MAME and [hw26] (whose ECS keyboard scan drives port A with bit 6) follow GI. **C4 is settled for GI**. On the Master Component both ports stay inputs. 6. **Period 0.** The AY-3-8910 die (ay8910-python's judge) and MAME: a period of 0 acts as 1. The wiki's PSG page: a tone period of 0 "actually indicates a period of $1000" and an envelope period of 0 a true period of `$20000` (C7). No 8914 measurement is known; the die photograph is the route (U8). 7. **The DAC.** GI's 1978 sheet draws an "ideal logarithmic output" (Fig. 2) and says "4 bits of logarithmic D/A conversion"; no measurement of the 8914's levels exists. Default: ay8910-python's measured AY-3-8910 table, labelled as borrowed. Unknown (U8): whether the 8914's tone, noise (17-bit LFSR taps), envelope and period-0 machinery equal the 8910 die's. The two dies carry different numbers ("90-32022" here, 1978); a gate-level comparison of the pinned 8914 photograph with deathsoft's 8910 schematic (ay8910-python's judge) would settle it. Until then the 8914 runs the 8910 engine **on trust**, and that is stated in every claim about its sound. ## What `ay8910-python` must gain Raised on the core as an issue or pull request, by that core's session (sibling repos are read-only from here). In the core's own terms (`PSGVariant` fields, `docs/contract.md`): | # | Change | Kind | From | | --- | --- | --- | --- | | 1 | `AY8914 = PSGVariant("AY-3-8914", ...)`, exported with the others and in `VARIANTS` | data | this page | | 2 | A field `register_order: tuple[int, ...]` (bus address to internal register), identity for the existing parts, the permutation above for the 8914, applied by `select()` / `write_register()` / `read_register()` | data + a lookup in three methods | [gi78] | | 3 | A field `envelope_select_bits: int` (1 on every existing part, **2** on the 8914): the volume register keeps bits 5-4 and the level is `envelope >> (3 - c)` for c = 1, 2, 3, the fixed level for c = 0 | **engine**: the mixer and `levels()` | [gi78], [jz-psg], [mame] | | 4 | `register_masks` for the 8914: volumes `$3F` (8910 numbering registers 8, 9, 10) | data | [mame] | | 5 | A field for the chip-select high nibble (today "the high four must be 0"): 0 for every existing part; the 8914's and 8917's value per C8, or a host that passes only the register number | data | [mame] notes, C8 | | 6 | `clock_divider` 1, `ports` "AB", `envelope_steps` 16, `dac` the AY's measured table | data (existing fields) | [gi78], [jz-psg] | | 7 | Later: `AY8916` and `AY8917` as data (one envelope-select bit, the 8914's register order per [wiki]'s ECS table; "inaccessible bits mirror one of the I/O ports, needs further testing" [mame]) | data, then a read-back rule | [mame], [wiki] | | 8 | Tests: the 8914's register permutation, the four envelope shifts, the read-back masks; a conformance stream with all four selects | tests | | The judge for item 3 is weaker than the rest of that core: no die model of the 8914 exists, so the shift is tier 2 (GI's table) with three agreeing documents, not a die comparison. ## Clocking and bus timing on this board - One `tick()` of the PSG per CPU clock (two per microcycle), from the board's master-clock timeline. - A write lands at the DWS microcycle of the writing instruction; the board brings the PSG up to that microcycle first (ay8910-python's contract: "a write is an instant between two input clocks"). - The CPU's read of `$01FE`/`$01FF` returns the port pins (controller lines, active low, below) in bits 7-0 and 0 above. ## Hand controllers (on the PSG's ports) Each controller is 8 lines into one port, **active low**: the byte read is the complement of the code below. Codes as MAME's `handctrl.cpp` tables and the wiki's *Hand Controller* page (its two worked examples agree with MAME's table): | Input | Code | | --- | --- | | keypad 1 2 3 | `$81 $41 $21` | | keypad 4 5 6 | `$82 $42 $22` | | keypad 7 8 9 | `$84 $44 $24` | | clear, 0, enter | `$88 $48 $28` | | side buttons: top, lower left, lower right | `$A0 $60 $C0` | | disc N, E, S, W | `$04 $02 $01 $08`, with 16 directions using bit 4 | Several inputs at once OR their codes on the wire (the keypad is a matrix: some combinations alias). The controllers are on the cartridge side of nothing: they connect to the console directly, and the Intellivoice's address trap at `$01FE-$01FF` exists for the Keyboard Component ([addons.md](addons.md)).