# Unknowns and contradictions Every behaviour the sources leave open (U1..) and every place two sources disagree (C1..). Tiers as in [validation.md](validation.md): 1 hardware, 2 manufacturer (the AT&T Information Manual of January 1989, the 1988 data sheet), 3 hardware-traced community work (Loïc Petit's CPS-2 schematics, superctr's register notes), 4 HDL (jtdsp16), 5 emulators (MAME). A low tier is a detector, never a judge. "The program" is `dl-1425.bin`, the QSound firmware. Statements about what jtdsp16, jtcores or FinalBurn Neo do were read from their source under the old rule; those programs are closed boxes from 2026-11-19, and no default here rests on them alone (docs/provenance.md). The build session keeps this file current: every deviation from a source in the code gets an entry here, and the code cites the number on the line. ## Contradictions ### C1. The sample period: 1,245 or 1,248 machine cycles | Source | Says | Tier | | --- | --- | --- | | MAME `qsound.cpp` header ("Sample pairs are loaded every 1,248 machine cycles, giving a sample rate of 24.03846 kHz") and its stream rate `clock() / 2 / 1248` | 1,248 | 5 (a comment) | | MAME `qsoundhle.cpp` ("DSP program uses 1248 machine cycles per iteration"), libvgm `qsound_ctr.c`, FinalBurn Neo (divider 2,496 from 60 MHz; HYPOTHESIS, read under the old rule), jtdsp16's copy of MAME's `qsound.cpp` | 1,248 | 5, all one lineage | | MAME before 2018 (`qsound.cpp` 0.170-0.195: `clock() / 166`, "/166 clock divider?", at a 4 MHz nominal clock) | 24,096 Hz | 5 | | MAME 0.285's own low-level core running the program, measured here | **1,245** (24,096.39 Hz) | 5 | | The manual's timing rules (table 3-3, section 3.8.1, the 4-6 worked example) applied instruction by instruction to the path the program takes | **1,245** | 2, applied to a path recorded by a tier-5 run | How it was measured (2026-11-12, `scripts/cycle_audit.py` on two traces from `scripts/mame_lle_trace.py`): 402,704 instruction executions (idle host) and 402,627 (a host write every ~35 samples, 11 interrupts in the window) were each charged by the manual's rules and compared with MAME's `totalcycles`. **Zero instructions differ**, cache passes, branches, conditional branches and the interrupt entry included. Every one of the 401 sample periods in each window is 1,245 cycles, with and without host commands: the program opens the INT window for one instruction (`pioc = 0x3820` at 0x0540, `pioc = 0x3800` at 0x0543) and pads the no-command path (0x0549 onwards) so both paths take the same time. So the measurement method and a start-up transient are ruled out (the windows start one second in and are constant), and so is a MAME timing slip against the manual: by the manufacturer's own rules **the program's loop is 1,245 cycles**. The figure 1,248 traces to one comment, repeated by everything copied from it. 1,248 = 13 x 96 (96 cycles is one 16-bit serial word at CKI/12) is a numerical coincidence; the program does not wait on the serial port. What is still open: no hardware measurement of the rate exists (U18); the second operating mode (state 0x061A, `update_loop_2` at 0x06B2) was not traced (U17). **Recommendation: the core charges the manual's cycles and nothing else; the board takes its output samples from the serial port, so the rate follows from the program.** The detectors' 1,248 is named as a difference whenever the LLE and HLE are compared (validation.md, rung 4). ### C2. Which voice a bank register belongs to superctr's gist (tier 3) says register 0x00 sets voice 15's bank and 0x08 voice 0's. His HLE code (`qsoundhle.cpp`, `qsound_ctr.c`) and MAME's LLE header say register `n*8` sets the bank of voice `n + 1` (0x78 sets voice 0's). The program decides (rung 4 shows which); MAME's LLE runs the program, so the LLE header's reading is the one the program implies. ### C3. ALIGN = 10 with `aD = p` The manual (2-10) says the two low bits "are not changed ... since 00 is added to or copied into" them. Read literally, `aD = p` (a copy) would leave the old bits 1-0 of `aD`. MAME (`dau_get_p_aligned`) shifts `p` left two and copies, clearing them. Tier 2 is ambiguous; MAME is a detector. Directed test owed (rung 1); the program sets ALIGN = 10 (`auc = 0x02`) in places, so rung 4 exercises it. ### C4. How the DAC's word select is made MAME's LLE derives the channel from PSEL when OSE falls and marks it `FIXME`; it does not implement `srta`/SADD. jotego's glue (tier 4, written with logic analyser captures, tier 1) and Loïc Petit's traced CPS-2 A-board schematic (`93646A.pdf` sheet 16, tier 3) agree: **WS is PSEL latched by a 74LS74 on the rising edge of inverted SADD (the falling edge of SADD), the bit clock is OCK, and DO is re-latched on inverted OCK.** SADD falls at the start of each word because `srta = 0x00FF` sends an all-ones transmit address active low (5-3, 5-13). Resolved by tier 3 over tier 5. ### C5. What the `pdx1` writes are for MAME's header guesses the volume chip. The schematic (tier 3) shows PSEL going only to the WS flip-flop, PODS clocking the sample-address latch, and the TC9185P volume chip driven from the cabinet buttons on a separate sheet. So `pdx1 = 0` before the right word (0x05D5) sets PSEL = 1 for the next serial word, and every `pdx0`/`pdx1` write also strobes PODS and latches the bus into the sample address. MAME's own code comment ("keep PSEL steady") agrees. Resolved by tier 3. ### C6. Program ROM size: 4,096 or 12,288 words The data sheet (1988, page 1 and "on-chip memory": "4096 x 16-bit words of ROM ... When the internal ROM is selected by the EXM pin and a memory location outside the 4K of internal ROM is accessed, the external memory interface is automatically selected") and the manual (1-2, 7-13) say 4,096. `dl-1425.bin` is 24,576 bytes = 12,288 words; words 0x1000-0x2FFF are all zero. MAME's commit `08d07f5917` (2017-04-26, Lord Nightmare: "update ROM and comments with corrections from recent decap [Lord Nightmare, Siliconpr0n, superctr, Quench]") replaced an older 8 KB `qsound.bin` marked `BAD_DUMP` with this file and said the die "clearly shows 3x as much ROM". MAME 0.285 declares a 0x2000-byte region and `ROM_IGNORE(0x4000)`: it loads the 4,096 documented words and skips the rest. Both are true of different things: **the die carries a 12K-word array, the documented address map exposes 4K, and the program only uses 0x0000-0x0FCF and external space at 0x8000 up.** How (or whether) the other 8K is addressable is U14. The core maps 4K internal words, as the data sheet says. ### C7. Executing from external memory The manual allows it (EXM high: all 64K external; EXM low: external above 0x0FFF, 7-13). jtdsp16's README says external memory can only be read through `pt`. Not relevant to QSound (EXM is tied low and the program never jumps outside 0x0000-0x0FFF); the core follows the manual and fetches through the same external-read callback. ### C8. DSP16A RAM size MAME's 2017 comment says "As originally released, the DSP16A had 1024 words of internal RAM, but this was expanded to 2048 words in the DL-1425 decap." The 1988 advance data sheet already says "2048 x 16-bit words of RAM". Tier 2 wins: 2,048 words, no expansion. ### C9. Where ALIGN acts Table 2-2 (2-10) and table D-1 write ALIGN as `p <- (x*y) / 4` and `p <- (x*y) * 4`, as if the product register itself were shifted. Figures 2-7 to 2-9 show the alignment between `p` and the accumulators. MAME shifts at the ALU input. The two differ only if `auc` changes between forming a product and using it; `p` is not readable as a register. The program changes `auc` between sections; whether a product crosses a change is checked at rung 4. Default: at the ALU input (the figures), tier 2 ambiguous. ### C10. Sample ROM bank lines on the CPS-2 A-board Sheet 19 of `93646A.pdf` (tier 3) appears to latch the DSP's AB0-AB7 into sample address lines in a permuted order (AB7..AB4 to A16..A19, AB0..AB2 to A20..A22, AB3 unused), and the B-board's QSound ROM sheet (`93646B.pdf` sheet 9) wires A1-A21 straight. MAME and jtcores treat the bank as straight. MAME plays the games correctly, so either the reading of the scan is wrong or the permutation is undone elsewhere (a connector, the ROM order in the dumps). **A board question for cps2-python, not a core question**; recorded so it is not rediscovered. ## Unknowns | # | What | Sources | Default for the core | | --- | --- | --- | --- | | U1 | `psw` bits 9 and 4, "accumulator overflow" (D-2): when set, sticky or not, how cleared | manual names them only; MAME: TODO, never sets them | readable and writable storage; set when an ALU result into that accumulator overflows 32 bits (LMV), cleared by a `psw` write. Named class attribute | | U2 | `aD = rnd(aS)` (F2 1011): "rounded to 16 bits, and the sign-extended result is placed in aD[35-16] with zeros in aD[15-0]" (3-14): the rounding rule (add 0x8000? ties?), overflow, flags | manual, one sentence; MAME FIXME | MAME's reading, flagged; the program uses it 4 times, so rung 4 checks it against the LLE | | U3 | `heads`/`tails`: the "10-state pseudorandom sequence generator" (3-5), its sequence and reset by a `pi` write | manual (2-5 footnote, 3-5); AN88-18 (the noise note) never mentions the conditions: it builds its generators in software; MAME not implemented | raise on use (`NotImplementedError` naming U3); the program never uses it | | U4 | `aD = -aS` of the most negative 36-bit value; flags | MAME FIXME | two's complement wrap, LLV set | | U5 | does `y = aT` (the transfer in T 11001/11011) saturate | manual silent; MAME FIXME, does not | does not (MAME), flagged | | U6 | guard bits 35-32 after `&`, `|`, `^` (described as 32-bit, 3-2) | manual | operate on all 36 bits (MAME), flagged | | U7 | the parallel input register shadowed during an interrupt with PIDS active (6-9) | manual; MAME not implemented | implement as the manual says; unobservable with the program (its main loop never reads `pdx`) | | U8 | does `*rN++j` with `j = 1` take the modulo wrap | manual 4-5 says "+1 postincrement"; jtdsp16 asks the same | no wrap (only the +1 forms), flagged | | U9 | RAM addresses 0x0800-0xFFFF on the DSP16A | manual silent | mask to 11 bits (MAME), flagged | | U10 | reset state of everything except `pc`, `re`, `pioc`, `sioc`, `tdms` (and `auc` and `srta`, documented as unaffected) | 7-14, 5-4, 5-12, 6-4 | zero, with a host-settable power-on state; the program initialises what it uses (it clears all 2K of RAM at 0x0288) | | U11 | INT latched or sampled; held for 4 CKI periods (2-16) | MAME samples before interruptible instructions (TODO) | sampled level before each interruptible instruction, as MAME; the QSound glue holds INT until the DSP's first `pdx0` read, so both agree for the program | | U12 | the cache across an interrupt (a service routine's `do` destroys the block a later `redo` uses) | follows from the manual; not stated | as follows from the manual: one cache, no save | | U13 | `do` with K < 2, a block containing a forbidden instruction, `redo` before any `do`, interrupts inside a `do` block | MAME asserts | raise (programming error), flagged | | U14 | how the 8K words of die ROM above the documented 4K are addressed, if at all | MAME header, decap; C6 | not mapped | | U15 | the sample ROM's low data byte | CPS-2 A-board schematic (tier 3): RB0-RB7 tied to ground; CPS-1.5 (Dino, Punisher, Warriors of Fate, Slam Masters, Muscle Bomber) and ZN not traced here | a board matter: the core returns what the callback returns | | U16 | is the host's address/data latch double-buffered (MAME comment in `set_cmd`) | schematic sheet 19: three 74LS374 latches, loaded by the host's writes, read by the DSP's PIDS strobes | a board matter | | U17 | the sample period in the second mode (state 0x061A, `update_loop_2`) | not traced | measure at rung 4 | | U18 | real-silicon timing against the manual (no capture of the DAC word rate exists; jotego's screenshots show bit timing only: OCK 200 ns, SADD low for 8 bits) | none | the manual's rules | | U19 | what AB shows between external accesses | jotego README: "measurements on QSound chips show that AB keeps its value after an external access" (tier 1, as reported); the schematic clocks AB0-7 into a latch on every CKO | AB holds the last external address; the core exposes it (the QSound bank latency depends on it: qsound.md) | | U20 | `ifc c1ge`/`ifc c1lt`: the manual (3-12, 3-38) says `c1` is incremented first, then the condition tested, and "`c1` is incremented once" (and `ifc c0ge`/`c0lt` does not increment `c0`); whether the `c1` test sees the old or the new value is not said | manual | the new value (MAME), flagged; not used by the program | | U21 | with active OLD free-running every 16 bit times, what DO and SADD do in a frame when no word was loaded (OSE high): the manual says zeros are shifted and OSE stays high (5-6) and that SADD "transmits simultaneously with DO" (5-3), not whether SADD's address goes out in an empty frame. It decides whether the QSound WS latch sees a SADD edge in empty frames | manual; jotego's captures show SADD with loaded words only | SADD only with a loaded word; the board's capture rule (qsound.md) does not depend on it if it takes words from the core's word event | No item here is decided by a tier-1 or tier-2 source. Rung 4 (the program against MAME's LLE) settles nothing either; it only shows where this core and MAME part. When they part, the entry here says which reading the core chose and why.