# Behaviour specification Written 2026-11-12 from the sources in [phase0.md](phase0.md), in this repository's own words. Source IDs (S1, S6, ...) are that document's. No statement here comes from a GPL or LGPL program or from the withdrawn core. Each statement carries one of three marks: - **documented**: a manufacturer's or community document says so. The source's tier tells how far to trust it. - **measured**: a capture from hardware says so, and the capture or its account was read. "measured here" means the check was run in this phase on data in hand. - **unsettled**: sources disagree, or only an emulator says so, or nothing does. Contradictions are numbered C1 onward, unknowns U1 onward. They are gathered in sections 12 and 13. ## 1. The four variants | Name in `api.md` | Part | Machines | |---|---|---| | `SN76489AN` | The discrete TI chip | SG-1000, SC-3000 (S6, S10) | | `SEGA_VDP_PSG` | The PSG inside the Master System's VDP | Mark III, Master System 1 and 2 (S6, S11) | | `GAME_GEAR_PSG` | The same with a stereo register | Game Gear (S4, S11) | | `YM7101_PSG` | The PSG inside the Mega Drive's VDP | Mega Drive, Genesis (S5, S6, S16) | What is known to differ between them is small, and is data: the length of the noise shift register, its feedback taps, the stereo register, the state at power-on, what a tone value of 0 does, and the Mega Drive's test bits. Everything else below applies to all four unless it says otherwise. No source in hand distinguishes the Master System 1's PSG from the Master System 2's in logic. S6's history says the noise captured from both matched. The Master System 2's flattened volume steps are put down to a resistor on the board, not the chip (S12). ## 2. Registers 1. Eight registers: three 10-bit tone values, one 3-bit noise control, four 4-bit attenuations. **documented** (S1 section 5, S3, S4, S6). 2. They are addressed by a 3-bit field. In the byte as the CPU writes it (bit 7 the most significant): | Bits 6-4 | Register | |---|---| | 000 | tone 0 value | | 001 | tone 0 attenuation | | 010 | tone 1 value | | 011 | tone 1 attenuation | | 100 | tone 2 value | | 101 | tone 2 attenuation | | 110 | noise control | | 111 | noise attenuation | **documented** (S1 Table 4, S3, S4 section 3). TI numbers the bits the other way round (its "bit 0" and "D0" are the most significant) and counts tone generators from 1; this document counts channels from 0 and bits in the usual way. 3. There is nothing to read back. **documented** (S10: "The PSG has no readable registers"; S4 calls the stereo port write-only). ## 3. The write protocol 1. A byte with bit 7 set is a *latch* byte. Bits 6-4 choose the register and stay chosen until the next latch byte. Bits 3-0 are data. **documented** (S1 sections 4 to 6: "The register address is latched on the chip, so the data will continue going into the same register"; S3; S4; S6). 2. A latch byte for a tone register replaces the low 4 bits of the 10-bit value and leaves the high 6. **documented** (S1 section 6; S6, which adds that the value in use changes at once and does not wait for the second byte: tier 3, Master System 2). 3. A latch byte for an attenuation register sets all 4 bits. **documented** (S1, S3, S4). 4. A latch byte for the noise register sets feedback (bit 2) and rate (bits 1-0). Bit 3 is ignored. **documented** (S1 section 6 shows it as "x"; S3; S4). 5. A byte with bit 7 clear is a *data* byte. If a tone register is latched, its bits 5-0 replace the high 6 bits of the value. Bit 6 is ignored. **documented** (S1 section 6, S3, S4). 6. A data byte while an attenuation or the noise register is latched writes its low bits to that register, as a latch byte would. **documented for Sega's part**, tier 3 only (S6: "The data byte is NOT ignored", with two games that sound wrong otherwise; S7 says the tests were on a PAL Master System 2). The manufacturers' documents show only single-byte writes to these registers. On the discrete chip it is **unsettled** (U8): only S19 does the same there. 7. Every write to the noise register, by either kind of byte, restarts the noise shift register (section 6.4). 8. On the discrete chip a write takes about 32 input clocks, during which READY is low. **documented** (S1 section 7, S2). In the SC-3000 READY is wired to the Z80's WAIT (S10), so the CPU stalls: that is the board's business; the core can offer the number. In Sega's part "the data to be sent from the CPU is immediately latched in the PSG, hence there is no need for a wait" (S4, Game Gear). **documented**. 9. The instant a write takes effect within the divide-by-16 cycle is **unsettled** (U9). No source speaks to it. ## 4. Clock and output rate 1. The input clock is divided by 16 to make the chip's own tick. **documented** (S1 section 1: the tone counter "is decremented at a N/16 rate where N is the input clock frequency"; S1's block diagram shows a ÷16 stage; S6). S2 says the divider is a divide-by-eight stage followed by the rest; the split does not matter here. 2. On every Sega machine the input clock is the Z80's clock: 3,579,545 Hz on NTSC machines, 3,546,893 Hz on PAL (S6; S4 gives 3.579545 MHz; S10 for the SC-3000; S15 says the Mega Drive's Z80 and PSG share one clock). **documented**. A tick is therefore 223,721.6 Hz on NTSC. 3. `CLOCKS_PER_SAMPLE = 16`: one output level per tick. This is a **choice** that follows from 4.1: nothing inside the chip changes between ticks. 4. Where the divide-by-16 stands at power-on is **unsettled** (U10). ## 5. Tone generators 1. Each has a 10-bit down counter and an output flip-flop. Once per tick the counter counts down; when it reaches zero the flip-flop toggles and the counter is loaded again from the tone register. **documented** (S1 section 1: "When the tone counter decrements to zero, a borrow signal is produced. This borrow signal toggles the frequency flip-flop and also reloads the tone counter"; S3; S6). 2. So a value n gives a square wave of 2n ticks: f = N / (32 n). **documented** (S1; S4, whose table of 51 notes gives for example n = 254, 440.397 Hz; S6). **measured** on a BBC Micro at n = 25 and 4 MHz, 5,000 Hz (S9). 3. Duty is 50 %. **documented** (S4 section 4). 4. A new tone value is used at the next reload; the running count is not disturbed. This is how S6's counter description reads; no source tests it. **unsettled** (U11). 5. **Tone value 1.** Sources disagree: C1. S4, the manufacturer, says "Maximum frequency is n = 1" and "The upper limit is 3579545/32·1", that is a 111,861 Hz square wave. S6 says "If the register value is zero or one then the output is a constant value of +1", and a few lines later gives $001 as the highest tone at 111,861 Hz. S14 measured a clean square wave near 125 kHz at n = 1 on a BBC Micro's chip (4 MHz clock; read by summary). S19 toggles every tick. This specification takes the square wave: **documented** (S4, tier 2) for Sega's part and **measured** (S14) for a TI chip. 6. **Tone value 0 on Sega's parts.** C2. S6 and S7 say the output is a constant +1. S19 says Sega's chips "act as if the frequency was set to 0" and its model then toggles every tick, the same as value 1; its change log says "Verified on SMS hardware" (Enik and Lord Nightmare, 2011). **unsettled** (U1). An observation of this document, not of any source: a 112 kHz square wave is far above hearing and above any console's output filter, so through the audio path it looks like a steady level at **half** the channel's volume, where a held +1 would be the **full** volume. Both accounts explain why games can play samples by writing volumes with the tone value at 0. They differ by 6 dB in how loud those samples are beside ordinary tones, and that can be measured. 7. **Tone value 0 on the discrete chip.** C3 (sms-python's open item 3). S1 does not say. S19 says "All the TI-made PSG chips act as if the frequency was set to 0x400 if 0 is written to the frequency register", that is n = 1,024, 109.2 Hz on NTSC. That is what a 10-bit down counter loaded with 0 and reloaded on borrow would do, which is how S1 describes the counter. S6 does not speak for the discrete chip. **unsettled** (U2): tier 5 plus an inference from tier 2. This specification proposes 1,024 for `SN76489AN`. 8. What the output flip-flops hold at power-on is **unsettled** (U10). S6: "The initial output value may be arbitrarily set." ## 6. Noise generator ### 6.1 Shift clock 1. Noise control bits 1-0 choose the shift rate: 00 is N/512, 01 is N/1024, 10 is N/2048, 11 is "Tone Generator #3 Output". **documented** (S1 Table 3, whose second row is misprinted as 0 0 in both scans; S2 Table 3 prints 0 1; S3; S4 gives the same as (N/32)/k with k = 16, 32, 64). 2. In ticks: one shift every 32, 64 or 128 ticks. S6 describes this as a counter reloaded with $10, $20 or $40 whose output toggles, with a shift on each rising edge; the two descriptions are the same. 3. At rate 11 the register shifts once for every full cycle of tone 2 (the third tone generator). **documented** (S1's block diagram takes the noise clock from tone generator 3 after its ÷2 stage; S4: "The noise frequency is (frequency TONE 3)/16" in synchronous mode). **measured** on a BBC Micro: S9's capture relied on it ("the tone generator 3 signal and the noise generator signal are synchronous"). 4. C4. S6 words rate 11 as a separate noise counter that is reloaded with the value of the Tone2 register, and the seed and S19 build it that way. That gives the same rate but a noise phase independent of tone 2's. S1, S4 and S9 have the noise clocked by tone 2's output itself. This specification follows the manufacturers: **documented**. Which edge of tone 2's output shifts the register is **unsettled** (U6). 5. What the noise does at rate 11 when tone 2's value is 0 or 1 follows from 5.5 to 5.7 and inherits their doubt. S19's change log says the discrete case (a period of 1,024) was "tested on hardware for noise" (Michael Zapf, 2010). ### 6.2 The shift register 1. Length: **15 stages on the TI chip**. **measured** (S9: the captured sequence repeats after 32,767 bits; measured here: its linear complexity is 15). **16 stages on Sega's parts**. **documented**: S4 (Game Gear, tier 2) says the synchronous noise is "frequency-divided by 16" and draws one clock pulse in sixteen, a 6.25 % duty; S6 says 16 for the Master System 1 and 2, Game Gear and Genesis. 2. "Periodic" noise (feedback bit 0, Sega's manual calls it synchronous): the bit leaving the register is fed back in unchanged, so the register's contents go round: one pulse every 15 shifts on the TI chip, every 16 on Sega's. **documented** (S4, S6); **measured** for the TI chip (S9: "a cycle of 15 clocks"). 3. White noise on the TI chip: the new bit is the exclusive OR of the two stages nearest the output; with the register drawn shifting right and the output at bit 0, bits 0 and 1 feed bit 14. **measured** (S9's rule reproduces S9's capture exactly: checked here). The period is 32,767. 4. White noise on Sega's parts: the exclusive OR of bits 0 and 3 feeds bit 15. **documented**, tier 3 only (S6, from captures by Charles MacDonald of a Master System 1, Game Gear and Genesis and by Maxim of a Master System 2, none published; S19 and S20 follow S6). With these taps the sequence repeats after 57,337 shifts (computed here), which is not the longest a 16-stage register can give. No capture of a Sega part's noise is in hand, and the file S6 offers under that name is BBC Micro data (phase0.md). **unsettled** as a measurement (U3). 5. The channel's output bit is the bit leaving the register. **documented** (S6). 6. S1 says the feedback "has provisions to protect the shift register from being locked in the zero state". With the reset in 6.4 and exclusive-OR feedback the register never reaches all zeros in either mode, so the model needs nothing extra. Whether Sega's part has such a provision is not stated anywhere. 7. S22 (Wikipedia, by summary) describes the TI feedback as an exclusive NOR of bits 12 and 13. S19 says "all chips use a standard XOR, the only inversion is the output itself". An XNOR register is an XOR register with every bit inverted, so the two differ only in polarity (section 8). Noted, not a contradiction of substance. ### 6.3 Variants at a glance | | `SN76489AN` | `SEGA_VDP_PSG`, `GAME_GEAR_PSG`, `YM7101_PSG` | |---|---|---| | Stages | 15 (measured, S9) | 16 (documented, S4 and S6) | | White-noise taps | bits 0, 1 (measured, S9) | bits 0, 3 (documented tier 3, S6) | | White-noise period | 32,767 | 57,337 | | Periodic period | 15 | 16 | S6 lists the SG-1000, SC-3000H and Othello Multivision with the BBC Micro and ColecoVision under the 15-bit, taps 0 and 1 rule. The capture behind the SC-3000H entry is not published; S9's is a BBC Micro. That the Mega Drive belongs in the right-hand column rests on one line of S6's history ("Charles MacDonald sampled GG and Genesis noise for me, it's the same bit pattern as SMS noise") and on S19. ### 6.4 Reset 1. A write to the noise control register clears the shift register and leaves one bit set at the input end (bit 14 of 15, or bit 15 of 16). **documented** (S1: "Whenever the noise control register is changed, the shift register is cleared"; S4: "Each time the noise control register changes, the shift register is cleared"; S6: "all bits are zero except for the highest bit"). **measured** for the TI chip (S9: "The start value of this generator (after further experiments) seems to be the bit sequence 100000000000000"). 2. The reset happens on every write, including one that writes the value already there. **documented**, tier 3 (S6 says "written to"; in S24 Maxim says of a test ROM that "it writes to the PSG registers every frame instead of only when the values change, which affects the noise channel"). The manufacturers say "changed", which can be read either way. 3. C5. How many shifts pass before the set bit reaches the output. A plain register gives 14 on the TI chip and 15 on Sega's. S19's model of the SN76489A carries two more stages between the taps and the output, so the bit arrives two shifts later. S7 notes that in tests "sometimes the initial value seems to be 0x4000 or 0x2000, which is presumably due to the shift register shifting a bit or two while data is being written". **unsettled** (U7). 4. What the output bit is between the reset and the first shift is **unsettled** (U7). The seed keeps the previous bit. 5. Whether the reset also restarts the noise rate counter is **unsettled** (U7). ## 7. Attenuation and mixing 1. Each channel's output bit is scaled by its attenuation: 2 dB a step, value 0 loudest, 14 is 28 dB down, 15 is off whatever the step before it was. **documented** (S1 Table 1: weights of 2, 4, 8 and 16 dB that add, all four set is "OFF"; S3 and S4 print all sixteen rows; S6). 2. A 2 dB step is a voltage ratio of 10^(−0.1) = 0.7943. Relative amplitudes: 1, 0.794, 0.631, 0.501, 0.398, 0.316, 0.251, 0.200, 0.158, 0.126, 0.100, 0.079, 0.063, 0.050, 0.040, 0. (S6's printed integer table has 6568 at step 7 where the rule gives 6538: a misprint in the table.) 3. TI allows each weight a tolerance: 1 to 3 dB for the 2 dB weight, 3 to 5, 7 to 9, 15 to 17 (S1 and S2 electrical tables). The ideal table is therefore a nominal curve, not a measured one. **documented**. 4. C6. S1 says "the maximum attenuation is 28 db"; S2 says 30 dB. Both tables make the all-ones code OFF, so nothing changes; noted. 5. The four scaled outputs are summed. **documented** (S1 section 3: "a conventional operational amplifier summing circuit"). A channel contributes its level when its bit is 1 and nothing when it is 0 (S6; S9: "the output of a sound generator can only be 0 or 1"). The sum runs from 0.0 to 4.0, as `api.md` expects. 6. A measured volume curve for any Sega part is **not in hand** (U4). S12 reports that the Master System 1 and Mega Drive show clean 2 dB steps and the Master System 2 flattens the loudest three or so, and blames a pull-up resistor of the wrong value on that board; one poster's Master System 1 behaved like the 2. No numbers. S16 says the Mega Drive's converter is four identical blocks, each choosing among levels by eight select lines, without values. 7. S6 describes how real outputs sag toward zero when held, and that a tone therefore sounds centred rather than one-sided. S14 found the sag on a BBC Micro to come from the amplifier after the chip, not the chip. Both concern the analogue path after the sum. The core gives the levels; filtering and centring are the board's. **choice**. ## 8. Polarity C7. Whether "bit set" means a higher or a lower voltage at the pin differs by part, and the sources are thin: - S9's rule for a BBC Micro's chip takes the output as the inverse of the register's bit. S14 (by summary) found on a BBC Micro that a silent channel rests at a fixed level and a loud one pulls away from it toward 0 V. - S19 models the SN76489 as inverted and the SN76489A as not, and Sega's parts as inverted with the note "whether output is inverted or not needs to be verified, assumed to be inverted". - S6: "Some systems seem to produce inverted output". The core reports a level from 0.0 to 4.0 per side with "bit set" as the positive sense. Absolute polarity per variant is **unsettled** (U5). It is inaudible for the PSG alone and matters only where a board mixes the PSG with another chip. ## 9. The Game Gear's stereo register 1. Port $06, write only. Bit 7 to bit 0: noise left, tone 2 left, tone 1 left, tone 0 left, noise right, tone 2 right, tone 1 right, tone 0 right. 1 enables. **documented** (S4 `main-4`: "NOSL TN3L TN2L TN1L NOSR TN3R TN2R TN1R", Sega counting tones from 1; S6's GameGearStereo page agrees). 2. After a power-on reset every bit is 1. **documented** (S4 marks the "1" state of each bit with a star, and `main-2` says the star "Indicates the state after a power-on reset"). 3. The register affects the headphone output only. The built-in speaker carries all four channels whatever it holds. **documented** (S4 `sup-1`, S6). The core gives left and right; a mono speaker mix that ignores the register is the board's. 4. On the other three variants there is no such register; `write_stereo` does nothing and both sides carry every channel. **choice** (it is how the seed behaves). ## 10. Power-on 1. **Game Gear**: "The sound output goes OFF in the case of a power-on reset" (S4). **documented**. 2. **Sega's parts generally**: tone and noise registers 0, attenuations 15 (silent). **documented**, tier 3 and hedged (S6: the integrated versions "seem to start initialised with zeroes in the tone/noise registers and ones in the volume registers"; S7 adds that on the Master System 2 "This initialisation may be done by the BIOS"). S3 shows the Mark III's boot code writing $9F, $BF, $DF, $FF, which silences all four channels before any game runs. 3. **The Mega Drive's part**: nothing specific. S19 treats it as any Sega part. **unsettled** (U12). 4. **The discrete chip is not reset.** "The SN76489A is not reset when the SC-3000H is powered on. If you cycle the power to reset the machine, then the PSG plays the same sounds that were last written to it, and from a cold boot the PSG emits a medium volume tone" (S10). **documented**, tier 3, an observation on hardware. S19 agrees ("non-Sega chips output a low-pitch beep at cold boot") and models it as attenuations 0 and a period of 1,024; it credits tests by ValleyBell for the attenuations. The exact values are **unsettled** (U13). The chip has no reset pin (S1's pin list has none). 5. C8. **The register latched at power-on.** S7: "The initially latched register is Tone0". S19 starts Sega's parts with register 3 latched (tone 1's attenuation, in this document's numbering), "based on hardware tests by Nemesis"; its two comments name the register differently ("volume for channel 2", "period reg for 2nd channel") though the code is plain. **unsettled** (U14). It matters only to a program that sends a data byte before any latch byte. 6. Counters, flip-flops, divider and shift register at power-on: **unsettled** (U10). Any values the model starts with are a choice and must be labelled so. ## 11. The Mega Drive's test bits `megadrive-python` calls `psg.write_test(...)`. The only source is S15, quoted in S16's `test.md`: > Debug register 0. Bits 11-9: PSG override. When bit 9 is clear, PSG works as > normal. When it's set, however, all PSG channels get replaced with the volume > level of one of them. Bits 11-10 pick which channel is the source of the volume > level. **documented**, tier 3, with no statement of what hardware it was tried on. What "replaced with the volume level" does to the square waves, and whether the noise keeps running underneath, are **unsettled** (U15). S15 also says a bit of debug register 1 changes the speed of the clock the Z80 and PSG share; that is a clock change the board makes, not a PSG behaviour. ## 12. Contradictions | | Between | About | This spec takes | |---|---|---|---| | C1 | S4, S14, S19 and S6's own tone-range line, against S6's "zero or one" sentence | Tone value 1: a 111.9 kHz square wave, or a constant +1 | the square wave | | C2 | S6 and S7 against S19 | Tone value 0 on Sega's parts: constant +1, or the same as value 1 | nothing yet: U1 | | C3 | S19 against silence in S1 | Tone value 0 on the discrete chip: 1,024 | 1,024, marked unsettled: U2 | | C4 | S1, S4, S9 against S6's wording and S19's model | Noise rate 11: clocked by tone 2's output, or a separate counter loaded from tone 2's value | clocked by the output | | C5 | A plain register (S6, S9) against S19's SN76489A | Shifts between a noise reset and the first output pulse | the plain register, marked unsettled: U7 | | C6 | S1 against S2 | Maximum attenuation 28 dB or 30 dB | no effect | | C7 | S9, S14, S19, S6 | Output polarity per part | unsigned levels; U5 | | C8 | S7 against S19 | Register latched at power-on: tone 0, or tone 1's attenuation | nothing yet: U14 | | C9 | S6's download label against its own text and the data | The file "Sega VDP white noise" is the 15-stage TI sequence | the text; the file is set aside | ## 13. Unknowns | | Unknown | Best lead | What would settle it | |---|---|---|---| | U1 | Tone value 0 on Sega's parts | C2 | A recording from a console: the level of a channel at value 0 against the same channel at value 1 and at a low tone | | U2 | Tone value 0 on the discrete chip | S19: 1,024 | A recording from an SG-1000 or SC-3000, or any SN76489AN on a bench | | U3 | Sega's white-noise sequence | S6: 16 stages, taps 0 and 3 | A capture by Kortink's method (noise at rate 11 over tone 2 as a clock) from any Sega console | | U4 | Sega's volume curve as numbers, per console | S12 | Recording a steady tone at each of the 16 steps | | U5 | Output polarity per variant | C7 | An oscilloscope on the pin; a sound card inverts unpredictably | | U6 | Which edge of tone 2 shifts the noise at rate 11 | none | The same capture as U3 | | U7 | After a noise write: shifts before the first pulse, the output bit meanwhile, whether the rate counter restarts | C5 | The same capture, repeated with the write at different moments | | U8 | A data byte to the attenuation or noise register on the discrete chip | S19 does as S6 | A recording from a discrete chip | | U9 | When a write takes effect within the 16-clock tick | none | Not reachable by recording; a closed-box model can only suggest | | U10 | Counters, flip-flops, divider and shift register at power-on | none | Mostly not observable from outside | | U11 | Whether a new tone value waits for the next reload | S6's wording | A recording of a tone rewritten mid-cycle | | U12 | The Mega Drive part's registers at power-on | S19 | A cartridge that writes nothing, or only attenuations, and a recording | | U13 | The discrete chip's exact state at a cold start | S10, S19 | A recording of an SC-3000 from cold; it may differ from chip to chip | | U14 | The register latched at power-on | C8 | A cartridge whose first write is a data byte, and a recording | | U15 | What the Mega Drive's test bits do to the waveform | S15 | A recording with the override on | Nearly all of these can be answered by recordings from one real console. See decision D8 in [provenance.md](provenance.md). ## 14. The seed against this specification The seed, `seed/psg.py`, is the PSG sms-python carried before it adopted a core (sms-python `db518bd`), written from S6 and S1. It lived in `seed/` during the first build and remains in this repository's history. ### Where the seed already agrees - The whole write protocol of section 3, including data bytes to the attenuation and noise registers and the reset of the shift register on every noise write. - Divide by 16; counters that count down and reload at zero (5.1, 5.2). - Noise rates as reloads of $10, $20 and $40 with a shift on every second reload (6.1.1, 6.1.2). - Shift register lengths and taps for the discrete, Master System and Game Gear parts; periodic noise as bit 0 fed back; reset to the top bit (6.2, 6.4.1). - The 2 dB table with 15 as silence (7.1, 7.2). - The stereo register's bits, its $FF default, and ignoring it off the Game Gear (section 9). - Sega's parts silent at power-on (10.2). - Variant differences held as data on a frozen dataclass, and state as plain attributes, which is what `api.md` asks. ### Where the seed differs 1. **No Mega Drive variant** and no `write_test` (sections 1, 11). 2. **Tone value 1** is held at a constant 1; this specification takes the square wave (5.5, C1). 3. **Tone value 0 on the discrete chip** is held at a constant 1 like Sega's; this specification proposes 1,024 (5.7, C3). 4. **Noise at rate 11** runs its own counter reloaded from tone 2's value; this specification clocks it from tone 2's output (6.1.3, C4). 5. **Output shape**: the seed box-filters to a host sample rate and scales each side to 0.0 to 1.0. `api.md` wants one pair per 16 input clocks at 0.0 to 4.0, and the boards resample (4.3). 6. **Discrete power-on**: `powers_up_silent` exists on the variant but `reset()` never reads it, and all three seed variants set it true. The discrete chip starts silent, which S10 contradicts (10.4). 7. The tests import `sms_python.psg` and look for the noise files in sms-python's tree; they need new paths. ### What the seed does that no source supports These are choices the seed makes silently; each needs a label or a source. - Output flip-flops start at 1, counters at 0, the shift register at its reset value, the cycle remainder at 0 (U10). - Tone 0 is the latched register at power-on (S7 says so, S19 says otherwise: C8). - When a tone value of 0 or 1 is met at a reload the output is forced to 1 at once, whatever it was (S6 gives the constant, not how it is reached). - After a noise write the output bit keeps its old value until the next shift (U7). - At noise rate 11 with tone 2's value at 0, the noise counter reloads with 0 and the register shifts every second tick. - `test_discrete_noise_matches_the_wikis_bit_pattern` is sound and worth keeping: it already says the "Sega VDP" file is the 15-bit sequence. Its better anchor is now S9's own capture, which names its machine. ## 15. What the first build took (2026-11-12) Added with the first build. Sections 1 to 14 stand as Phase 0 wrote them; this records what the code does wherever they left a question, and what was learned. "Provisional" means a decision (D numbers, [provenance.md](provenance.md)) was taken, the value is data on `PSGVariant`, and no source above tier 5 settles it. | | Question | What the code does | Standing | |---|---|---|---| | U1, C2 | Tone value 0 on Sega's parts | the same as value 1 (`tone_zero_period = 1`) | **provisional** (D3) | | U2, C3 | Tone value 0 on the discrete chip | a period of 1,024 (`tone_zero_period = 1024`) | **provisional** (D4) | | U13 | The discrete chip at power-on | attenuations 0, tone values 0, noise control 0; a board may pass `silent_start` | **provisional** (D5) | | U14, C8 | Register latched at power-on | tone 0 (`power_on_latch = 0`) | **provisional** (D6) | | U15 | The Mega Drive's test bits | with bit 9 set, four times the chosen channel's level, held; the generators run on underneath | **provisional**, untested (D7) | | U8 | A data byte to attenuation or noise on the discrete chip | it writes, as on Sega's (`data_byte_reaches_all_registers`) | **provisional** | | U4 | Volume curve | the ideal 2 dB table; a board may pass another (`volume_table`) | documented nominal curve (D11) | | U5, C7 | Polarity | unsigned levels, "bit set" the higher | choice | | U6 | Edge at noise rate 3 | the third tone's output rising (`noise_shift_level = 1`) | choice | | U7, C5 | After a noise write | a plain register (14 or 15 shifts to the first pulse); the output is the register's last stage, so 0 at once; the rate divider is not restarted | choice | | U9 | A write within the tick | it takes effect at the next tick boundary | choice | | U10 | Starting state | counters 0, tone flip-flops set (they fall on the first tick), noise divider about to turn over, shift register as after a noise write | choice (the seed's) | | U11 | A new tone value | waits for the next reload | choice following S6's wording | | none | The fixed-rate noise divider while rate 3 is chosen | stands still, and resumes where it stopped | choice: no source mentions it | | U12 | The Mega Drive's registers at power-on | as Sega's other parts: silent | unsettled, taken from S6 and S19 | Findings of the build, with their evidence in [validation.md](validation.md): 1. **6.2.5 and 6.4.3 read together.** The noise channel's bit is the stage at the output end of the register after each shift (S6's code, S9's rule). That is what gives 14 and 15 shifts in 6.4.3. The seed gave the bit shifted *out*, one shift later; section 14 lists the seed as agreeing here, and in that one detail it does not. 2. **S4's note table (psg-6) was computed from 3,579,550 Hz.** The manual states 3.579545 MHz. The division ratios are unaffected. 3. **Kortink's capture (S9)** is matched bit for bit by the discrete variant, inverted, at rotation 20,863. 4. **The live SMS Power page (D13)** was fetched on 2026-11-12 and its source is byte-identical to the snapshot S6 (SHA-256 `59c0015b...`). 5. **A closed-box detector for the Mega Drive's part** (Nuked-PSG, run and not read) gives opinions on several unknowns. They are a model's opinions, tier 5, and change nothing above: - U1: value 0 behaves as value 1 (as D3). - U14: tone 0 is latched at power-on (as D6). - U3: 16 stages, taps 0 and 3 (as S6). - C5, U7: a plain register's 15 shifts; but the restart lands one tick after the write, and the output keeps its old bit for that tick. - U6: the rising edge, one tick later than the core. - U11: a new tone value governs the half-cycle in progress (against S6's wording and the core). - U4: a curve steeper than 2 dB a step. - U15: one level, not four, with an offset.