local cpu=manager.machine.devices[":maincpu"]; local sp=cpu.spaces["program"]; local dbg=manager.machine.debugger; local fr=0; local seen=0; local inst=false local lf=io.open("fz.txt","w"); local hist={} emu.register_frame_done(function() fr=fr+1 if fr>1900 then for i=0,11 do if i~=5 and i~=11 then local a=0xffb04a+i*0x80+0x74; local v=sp:read_u8(a); hist[v]=(hist[v] or 0)+1; sp:write_u8(a,0x1f) end end end if fr==1500 and not inst then inst=true cpu.debug:bpset(0x2004CA,"1",'printf "FIGHT" ; go'); cpu.debug:bpset(0x2004F0,"1",'printf "FSTART" ; go') end if inst 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("^F") then lf:write(fr," ",l,"\n"); lf:flush(); manager.machine.video:snapshot() end end; seen=#log if fr==20000 then local s="" for v,c in pairs(hist) do s=s..v..":"..c.." " end lf:write("hist ",s,"\n"); lf:close(); manager.machine:exit() end end)