-- SPDX-License-Identifier: MIT -- Count the main CPU's instructions over a window of frames in MAME 0.285 (closed box): -- the debugger's trace command writes one line per instruction (no "noloop", so loops are -- counted in full) to COUNT_FILE between frames COUNT_FROM and COUNT_TO. Run MAME with -- -debug -debugger none. Count with: wc -l < COUNT_FILE. local from = tonumber(os.getenv("COUNT_FROM") or "2700") local to = tonumber(os.getenv("COUNT_TO") or "2702") local file = os.getenv("COUNT_FILE") or "count.txt" local cpu = os.getenv("COUNT_CPU") or ":maincpu" local dbg = manager.machine.debugger dbg.visible_cpu = manager.machine.devices[cpu] dbg:command("go") local frame = 0 _G.count_frames = emu.add_machine_frame_notifier(function() frame = frame + 1 if frame == from then dbg:command("trace " .. file .. "," .. cpu) end if frame >= to then dbg:command("trace off," .. cpu) manager.machine:exit() end end)