-- SPDX-License-Identifier: MIT -- Tap every access to a YM2610 from the CPU that drives it, under MAME. -- -- YM2610_TAP_OUT=nam1975.tap mame nam1975 -autoboot_script scripts/mame_ym2610_tap.lua ... -- -- (the full command line is in docs/mame-oracle.md). One line per access: -- -- W a write; port is A1 A0 (0 = address I, 1 = data I, -- R 2 = address II, 3 = data II); a read likewise -- -- counts the chip's input clock (8 MHz) since power-on, from MAME's -- machine time, so it is as fine as MAME's CPU timing: the Z80 instruction. -- Values are hexadecimal, the clock decimal. -- -- The defaults fit the Neo Geo (Z80 I/O ports $04-$07, mirrored over the high -- address byte). Another board sets YM2610_TAP_CPU, YM2610_TAP_SPACE, -- YM2610_TAP_BASE and YM2610_TAP_MASK. local cpu_tag = os.getenv("YM2610_TAP_CPU") or ":audiocpu" local space_name = os.getenv("YM2610_TAP_SPACE") or "io" local base = tonumber(os.getenv("YM2610_TAP_BASE") or "0x04") local mask = tonumber(os.getenv("YM2610_TAP_MASK") or "0xff") local chip_clock = tonumber(os.getenv("YM2610_TAP_CLOCK") or "8000000") local out_path = os.getenv("YM2610_TAP_OUT") or "ym2610.tap" local machine = manager.machine local space = machine.devices[cpu_tag].spaces[space_name] local out = assert(io.open(out_path, "w")) out:write(string.format("# ym2610 tap: %s, cpu %s, space %s, ports %02X-%02X, clock %d Hz\n", emu.romname(), cpu_tag, space_name, base, base + 3, chip_clock)) local function log(kind, offset, data) local port = (offset & mask) - base if port >= 0 and port <= 3 then out:write(string.format("%s %d %d %02X\n", kind, machine.time:as_ticks(chip_clock), port, data & 0xff)) end end -- Held in globals: a tap that is garbage-collected stops firing. ym2610_write_tap = space:install_write_tap(0x0000, 0xffff, "ym2610 writes", function(offset, data) log("W", offset, data) end) ym2610_read_tap = space:install_read_tap(0x0000, 0xffff, "ym2610 reads", function(offset, data) log("R", offset, data) end) ym2610_stop = emu.add_machine_stop_notifier(function() out:close() end)