local cpu=manager.machine.devices[":maincpu"]; local sp=cpu.spaces["program"]; local dbg=manager.machine.debugger; local fr=0; local seen=0 local lf=io.open(os.getenv("POUT"),"w"); local A=tonumber(os.getenv("WA"),16); local N=tonumber(os.getenv("WN") or "2") emu.register_frame_done(function() fr=fr+1 if fr==tonumber(os.getenv("WSTART") or "1200") then cpu.debug:wpset(sp,"r",A,N,"1",'printf "R pc=%x a0=%x a1=%x d7=%x s=%x %x %x %x %x %x %x %x %x %x %x %x",pc,a0,a1,d7,w@(sp),w@(sp+2),w@(sp+4),w@(sp+6),w@(sp+8),w@(sp+a),w@(sp+c),w@(sp+e),w@(sp+10),w@(sp+12),w@(sp+14),w@(sp+16) ; go') end if fr>tonumber(os.getenv("WSTART") or "1200") and dbg.execution_state~="run" then dbg.execution_state="run" end local log=dbg.consolelog; for k=seen+1,#log do local l=log[k]; if l:match("^R ") then lf:write(fr," ",l,"\n"); lf:flush() end end; seen=#log end)