local space = manager.machine.devices[":maincpu"].spaces["program"] local out = io.open("writes.log", "w") local function tap(lo, hi, name) return space:install_write_tap(lo, hi, name, function(offset, data, mask) local t = manager.machine.time out:write(string.format("S %X %X %d.%018d\n", offset, data & 0xff, t.seconds, t.attoseconds)) end) end taps = {} for _, base in ipairs({0x000, 0x100, 0x200, 0x300}) do table.insert(taps, tap(base + 0x15, base + 0x1a, "tia" .. base)) table.insert(taps, tap(base + 0x01, base + 0x01, "ctl" .. base)) end table.insert(taps, tap(0x4000, 0x400f, "pokey4000")) table.insert(taps, space:install_read_tap(0x4000, 0x400f, "pokeyread", function(offset, data, mask) local t = manager.machine.time out:write(string.format("R %X %X %d.%018d\n", offset, data & 0xff, t.seconds, t.attoseconds)) end)) table.insert(taps, tap(0x0450, 0x045f, "pokey450")) table.insert(taps, tap(0x0440, 0x044f, "pokey440")) table.insert(taps, tap(0x0800, 0x080f, "pokey800")) emu.add_machine_stop_notifier(function() out:close() end) local slot = "?" for tag, _ in pairs(manager.machine.devices) do if tag:find("^:cartslot:[^:]+$") then slot = tag:sub(11) end end local log = io.open("slot.txt", "w") log:write(slot .. "\n") log:close() local space2 = manager.machine.devices[":maincpu"].spaces["program"] local scr = manager.machine.screens[":screen"] local nlog = io.open("nmi.log", "w") local dpph, dppl, dumped = 0, 0, "" local function stamp() local t = manager.machine.time return string.format("%d %d.%018d", scr:frame_number(), t.seconds, t.attoseconds) end taps.nmi = space2:install_read_tap(0xfffa, 0xfffa, "nmi", function(offset, data, mask) nlog:write("N " .. stamp() .. "\n") local dpp = dpph * 256 + dppl local parts = {} for i = 0, 191 do parts[#parts + 1] = string.format("%02X", space2:read_u8((dpp + i) & 0xffff)) end local text = string.format("L %04X %s\n", dpp, table.concat(parts, " ")) if text ~= dumped then dumped = text nlog:write(text) end end) taps.irq = space2:install_read_tap(0xfffe, 0xfffe, "irq", function(offset, data, mask) nlog:write("I " .. stamp() .. "\n") end) taps.maria = space2:install_write_tap(0x2c, 0x3f, "maria", function(offset, data, mask) if offset == 0x2c then dpph = data & 0xff elseif offset == 0x30 then dppl = data & 0xff end if offset == 0x2c or offset == 0x30 or offset == 0x3c then nlog:write(string.format("M %X %X ", offset, data & 0xff) .. stamp() .. "\n") end end) emu.add_machine_stop_notifier(function() nlog:close() end)