-- Idle both pads; log owner changes; save state when our goalie (5) gets puck local sp=manager.machine.devices[":maincpu"].spaces["program"] 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("gk1.txt","w"); local fr=0; local last=-99; local saved=0 emu.register_frame_done(function() fr=fr+1; if fr<450 then return end local own=w(0xffb7aa) if own~=last then last=own lf:write(string.format("fr=%d own=%d c1=%d c2=%d puck=(%d,%d) g5=(%d,%d) g11=(%d,%d)\n",fr,own,w(0xffc320),w(0xffc322),w(0xffb74a),w(0xffb75e),w(0xffb04a+5*0x80),w(0xffb04a+5*0x80+0x14),w(0xffb04a+11*0x80),w(0xffb04a+11*0x80+0x14))); lf:flush() if own==5 and saved<10 then saved=saved+1; manager.machine:save("gkp"..saved) end end end)