space = manager.machine.devices[":maincpu"].spaces["program"] counts = {} function bump(key) counts[key] = (counts[key] or 0) + 1 end function block(offset) if offset >= 0x8000 and offset < 0xA000 then return string.format("%04X", offset & 0xFC00) end return string.format("%04X", offset & 0xE000) end armed = false rtap = space:install_read_tap(0x0000, 0xFFFF, "census_r", function(offset, data, mask) if armed then bump("R " .. block(offset)) end end) wtap = space:install_write_tap(0x0000, 0xFFFF, "census_w", function(offset, data, mask) if armed then bump("W " .. block(offset)) end end) frames = 0 t0 = 0 sub = emu.add_machine_frame_notifier(function() frames = frames + 1 if frames == 120 then armed = true; t0 = manager.machine.time:as_double() end if frames == 180 then armed = false print(string.format("WINDOW %.6f s", manager.machine.time:as_double() - t0)) keys = {} for k in pairs(counts) do table.insert(keys, k) end table.sort(keys) for _, k in ipairs(keys) do print(string.format("COUNT %s %d", k, counts[k])) end manager.machine:exit() end end)