-- 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)