local machine = manager.machine local dbg = machine.debugger local screen = machine.screens[":screen"] local facts = io.open("facts.txt", "w") facts:write("machine " .. machine.system.name .. "\n") for tag, device in pairs(machine.devices) do facts:write("device " .. tag .. " | " .. device.shortname .. " | " .. device.name .. "\n") end facts:write(string.format("screen %dx%d refresh %.6f Hz (attoseconds %s)\n", screen.width, screen.height, screen.refresh, tostring(screen.refresh_attoseconds))) for _, tag in ipairs({":maincpu", ":audiocpu"}) do local names = {} for name, _ in pairs(machine.devices[tag].state) do names[#names + 1] = name end table.sort(names) facts:write("symbols " .. tag .. ": " .. table.concat(names, " ") .. "\n") end facts:flush() dbg.visible_cpu = machine.devices[":audiocpu"] dbg:command('trace cpu.trace,:audiocpu,noloop,{logerror "Z %04X %04X %04X %04X %04X %04X %04X %04X %d\\n",pc,af,bc,de,hl,ix,iy,sp,totalcycles}') dbg:command('wpset f000,10,w,1,{logerror "YW %04X %02X %d\\n",wpaddr,wpdata,totalcycles; g}') dbg:command('wpset f000,10,r,1,{logerror "YR %04X %02X %d\\n",wpaddr,wpdata,totalcycles; g}') dbg:command("go") local trace_frames = 2 local last = 180 frame_sub = emu.add_machine_frame_notifier(function() local frame = screen:frame_number() if frame == trace_frames then dbg:command('trace off,:audiocpu') end if frame == last then screen:snapshot("final.png") facts:write(string.format("frames %d emulated_time %s\n", frame, tostring(machine.time))) facts:close() machine:exit() end end)