-- Logs every shot (via patch hook $2FF32A) and goal ($14828) in a demo game. local cpu=manager.machine.devices[":maincpu"]; local sp=cpu.spaces["program"]; local dbg=manager.machine.debugger local function w(a) local v=sp:read_u16(a); if v>=0x8000 then v=v-0x10000 end return v end local lf=io.open(os.getenv("EDMOUT") or "edm.txt","w") local fr=0; local inst=false; local seen=0; local pending=nil local START=tonumber(os.getenv("LOGFROM") or "1500") emu.register_frame_done(function() fr=fr+1 if fr==START and not inst then inst=true cpu.debug:bpset(0x2FF32A,"1",'printf "SHOT idx=%d jer=%x tm=%x d3=%d soft=%d px=%d py=%d h=%d a=%d",w@(a3+52),b@(a3+6f),b@(a3+62),d3,b@fff002,w@ffb74a,w@ffb75e,b@ffc331,b@ffc333 ; go') cpu.debug:bpset(0x14828,"1",'printf "GOAL f000=%d soft=%d beda=%d h=%d a=%d",w@fff000,b@fff002,w@ffbeda,b@ffc331,b@ffc333 ; 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("^SHOT") then lf:write(fr," ",l,"\n") elseif l:match("^GOAL") then lf:write(fr," ",l,"\n") end end seen=#log if fr%3000==0 then lf:flush() end if os.getenv("SNAPEVERY") and fr%tonumber(os.getenv("SNAPEVERY"))==0 then manager.machine.video:snapshot() end end)