# The SSG part Three square-wave tone channels, one noise generator, a mixer, fixed or envelope levels, and an on-chip DAC whose three outputs are summed on one analogue pin. Citations as in [registers.md](registers.md). ## Registers - $00-$0D in part I, readable and writable: tone periods A/B/C ($00-$05, 8-bit fine and 4-bit coarse), noise period ($06, 5 bits), mixer ($07), levels ($08-$0A: D4 M, D3-D0 level), envelope period ($0B fine, $0C coarse), shape ($0D: CON ATT ALT HLD). [DOC AM "(a) Read/Write Data (SSG)"] - No I/O ports: the YM2610's map stops at $0D and its pins list none; $07's top two bits (the OPNA's port directions) do nothing here. [DOC AM §5, "(a)"; OPNA p. 38 for the OPNA's] ## Tone and noise - Tone frequency phi M / (64 x TP), TP 12 bits. [DOC OPNA p. 37] The closed box: TP 10 gives a 640-clock cycle, TP 2 128 clocks, and **TP 0 and TP 1 both 64**. [OBSERVED lle:ssg] Duty 50 %. [DOC OPNA p. 37] - Noise frequency phi M / (64 x NP), NP 5 bits. [DOC OPNA p. 37] The noise is a 17-bit shift register fed back from bits 0 and 3, NP 0 acting as 1 [DOC ymfm ymfm_ssg.cpp:146-156]; neither the register nor its rate was measured: **U12**. - Mixer $07: D5-D3 noise off for C, B, A; D2-D0 tone off for C, B, A (0 = enabled). [DOC OPNA p. 38] A channel with both off holds its level: with $07 = $3F the pin shows the level register's value. [OBSERVED lle:ssg] ## Levels - Fixed mode (M = 0): 4-bit level; envelope mode (M = 1): the envelope's level, the 4 bits ignored. [DOC OPNA p. 38] - The DAC is 5-bit and logarithmic; a fixed level n drives code 2n + 1 ("the utmost level is 31 ... all 0 is level 1"); the envelope runs through all 32 codes, of which **0 and 1 give the same level**. [DOC OPNA pp. 38-39, Table 3-1] - The closed box agrees: fixed level n reads the same pin value as envelope code 2n + 1, and codes 0 and 1 both read 0. [OBSERVED lle:ssg] The closed box's pin value per code (one channel; 1.0 = code 31) [OBSERVED lle:ssg, envelope ramp]: | code | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | value | 0 | 0 | 0.0049 | 0.0075 | 0.0105 | 0.0131 | 0.0156 | 0.0183 | | code | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | | value | 0.0228 | 0.0276 | 0.0321 | 0.0367 | 0.0448 | 0.0535 | 0.0626 | 0.0713 | | code | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | | value | 0.0884 | 0.1057 | 0.1225 | 0.1392 | 0.1691 | 0.2013 | 0.2348 | 0.2670 | | code | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | value | 0.3307 | 0.3951 | 0.4573 | 0.5196 | 0.6316 | 0.7528 | 0.8787 | 1.0000 | - Three channels at level 15 read 3.0: the pin is the plain sum. [OBSERVED lle:ssg] The manual: each channel is converted by its own DAC and the three are mixed inside on one pin, a source follower that needs a load resistor; about 1 Vp-p (0.8-1.1) with three channels at full level into 470 ohms. [DOC OPNA p. 39; AM §3(b), §6.3] ### Decision 5: the SSG's analogue table The contract is the 5-bit code per channel; `ssg_mix()` turns codes into a level with a table the board may replace. **The default table is the closed box's 32 values above, tagged OBSERVED (YM2608-LLE 7a2aca7), provisional.** The other candidate decision 5 names, Yamaha's catalogue ladder for the YM2149, is not in the pinned 1990 catalogue (its sound-chip pages cover no SSG part), so it cannot be cited from what is on hand. ymfm's table (from MAME's AY/YM2149 code, "biased so that 0 == 0") [DOC ymfm ymfm_ssg.cpp:175-183] is close but not equal (code 16: 0.081 against 0.088): a YM2149's ladder, not this chip's. ## Envelope - Period EP 16 bits ($0C:$0B); repetition frequency phi M / (1024 x EP) for a full 32-step cycle. [DOC OPNA p. 39] The closed box steps once every **32 x EP** clocks (2048 at EP 64), which is the same. [OBSERVED lle:ssg] - Shapes: the eight of the FM's SSG-EG figure. [DOC OPNA pp. 31, 39] The behaviour of each CON/ATT/ALT/HLD combination, writing $0D restarting the envelope, and EP = 0, follow ymfm [DOC ymfm ymfm_ssg.cpp:158-198, 269-270], provisional until the SSG rung compares all 16 shapes with the closed box (**U12**).