-- Log every byte a CPS-1 sound Z80 exchanges with its MSM6295, headless. -- -- Run by scripts/mame_oki_tap.py (or by hand: see docs/mame-oracle.md). The chip -- has no address space of its own to tap, so the taps sit on the sound CPU's -- program space where the board maps the chip: -- $F002 read: status write: command -- $F006 write: bit 0 drives pin 7 (SS) -- One line per access: the machine time in chip clocks (1 MHz on CPS-1, so -- microseconds), the kind (W command, R status, P pin 7) and the byte. -- -- The taps and the output file are held in globals: MAME's Lua collects a tap -- that nothing refers to. local machine = manager.machine local space = machine.devices[":audiocpu"].spaces["program"] local CLOCK = 1000000 oki_log = io.open("oki-tap.log", "w") oki_log:write("# clock kind value\n") local function stamp() return machine.time:as_ticks(CLOCK) end oki_write_tap = space:install_write_tap(0xf002, 0xf006, "oki-w", function(offset, data, mask) if offset == 0xf002 then oki_log:write(string.format("%d W %02X\n", stamp(), data)) elseif offset == 0xf006 then oki_log:write(string.format("%d P %d\n", stamp(), data & 1)) end end) oki_read_tap = space:install_read_tap(0xf002, 0xf002, "oki-r", function(offset, data, mask) oki_log:write(string.format("%d R %02X\n", stamp(), data)) end) -- A coin at frame 240 and player 1's start at frame 360, so the stream holds -- more than the power-on silence. Attract modes on CPS-1 are mostly mute. local frame = 0 oki_frame = emu.add_machine_frame_notifier(function() frame = frame + 1 local in0 = machine.ioport.ports[":IN0"] if in0 == nil then return end local function press(name, from, to) local field = in0.fields[name] if field ~= nil then if frame == from then field:set_value(1) end if frame == to then field:set_value(0) end end end press("Coin 1", 240, 250) press("1 Player Start", 360, 370) -- Then player 1's first button for a fifth of a second in every second: -- it picks a character and afterwards throws punches, which are samples. if frame >= 480 then local field = machine.ioport.ports[":IN1"].fields["P1 Button 1"] if field ~= nil then if frame % 60 == 0 then field:set_value(1) end if frame % 60 == 12 then field:set_value(0) end end end end) oki_stop = emu.add_machine_stop_notifier(function() oki_log:close() end)