Files
Dragon-s-Lair-X68k/tools/bench/probe_adpcm4.lua
T
prosolis 6dd3fb3597 Ask the chip which decoder it is, and find four wrong axes where one was expected
ROADMAP P6a, on the machine. 68000 code programs HD63450 channel 3 with the
IPL ROM's own ADPCM bytes -- dual address, 8-bit port, cycle steal, external
request -- and feeds the MSM6258 a designed 1,678-nibble stream at the chip's
own pace: 839 B in 0.1074 s = 7,811.4 B/s against the format's 7,812.5, CER=$00.
That transport is P6b's, not scaffolding.

Sixteen candidate decoder models, three capture decimations and a searched
prologue are fitted to MAME's capture. Exactly one reproduces it sample-exact
over all 1,678 samples, and every axis carries a negative control: flip it
alone and the closest survivor disagrees on 826, 1,504, 156 and 1,522 samples.

The chip runs 'terms', takes the LOW nibble of a byte first, clamps the
accumulator at 10 bits and starts it at -2. tools/encoder/adpcm.py defaulted to
the opposite of all four, and 65.2 named the wrong axis as the risk: the delta
formula is worth -2.88 dB and the NIBBLE ORDER is worth -25.74 dB. 65.1's "high
first, measured" was a measurement of ffmpeg, i.e. of the VOX file convention,
which is a different question from what a chip does with a byte in its data
register.

The 10-bit clamp is free on the Singe window and only because that window peaks
at 435 of 511 -- 1.4 dB of headroom on a -13.4 dBFS passage, 12.1 dB below where
the encoder was clamping, and inside the recursion. So the audio level is an
open choice again, downward, and the loudest passage on the disc is unmeasured.

Session 33's silence had two ordinary causes: the PPI's port C is an input until
control word $92 says otherwise, and $01 is COMMAND_STOP. And a rig fact worth
the space: the 8 MHz ADPCM clock is CT1 in the YM2151's $1B, delivered on the
sound system's schedule rather than at the store, so a transfer started in the
same breath as the setup plays its first ~17 ms at the old clock and no model
fits a stream that changed rate part way through.

Name the layer: this is MAME 0.277's okim6258 device model measured end to end
through the machine's real transport. It settles the rig and not the silicon.
Also struck: 64.4's "no MAME source tree is on this machine" -- there is none on
disk, but the machine has network and the upstream tag fetches.

check.sh ALL GREEN before (tmp/check_s34_start.log) and after
(tmp/check_s34_end.log), with one new stage.

Claude-Session: https://claude.ai/code/session_01194oWYW8DQXK1SZ2DnChW6
2026-08-25 09:50:03 -07:00

34 lines
1.5 KiB
Lua

-- SPIKE (session 34). Not a gate: it exists to find out whether the chip can be
-- driven at all, what scale its samples arrive at in a -wavwrite capture, and
-- where it clamps. It sets EVERY thing session 33's probes left to the IPL:
-- * YM2151 reg $1B bit1 = 0 -> CT1 = 0 -> ADPCM master clock 8 MHz
-- * PPI control $92 -> port C is an OUTPUT (without this the i8255's
-- out_pc_callback never fires and the pan and
-- divider writes go nowhere)
-- * PPI port C $08 -> pan 00 = BOTH, rate 10 = /512 -> 15,625 Hz
-- * ctrl $02 = COMMAND_PLAY -- session 33's probes wrote $01, COMMAND_STOP.
M = manager.machine
local sp = M.devices[":maincpu"].spaces["program"]
local YMA, YMD = 0xE90001, 0xE90003
local PPIC, PPICTL = 0xE9A005, 0xE9A007
local CTRL, DATA = 0xE92001, 0xE92003
local BYTE = tonumber(os.getenv("AD_BYTE") or "0x77")
local n = 0
SUB = emu.add_machine_frame_notifier(function()
n = n + 1
if n == 40 then
sp:write_u8(YMA, 0x1B); sp:write_u8(YMD, 0x00)
elseif n == 60 then
sp:write_u8(YMA, 0x1B); sp:write_u8(YMD, 0x00)
sp:write_u8(PPICTL, 0x92)
sp:write_u8(PPIC, 0x08)
print(string.format("[AD4] portC readback = $%02X", sp:read_u8(PPIC)))
sp:write_u8(CTRL, 0x02)
sp:write_u8(DATA, BYTE)
print(string.format("[AD4] PLAY, data $%02X, status = $%02X",
BYTE, sp:read_u8(CTRL)))
elseif n == 90 then
print("[AD4] done"); M:exit()
end
end)