local prog = manager.machine.devices[":maincpu"].spaces["program"] local pad = manager.machine.ioport.ports[":ctrl1:joypad:JOYPAD"] local presses = { {120, "Start", 6} } local frames = 0 local log = io.open("status.txt", "w") status_sub = emu.add_machine_frame_notifier(function() frames = frames + 1 for _, p in ipairs(presses) do if frames == p[1] then pad.fields["P1 " .. p[2]]:set_value(1) end if frames == p[1] + p[3] then pad.fields["P1 " .. p[2]]:clear_value() end end if frames % 60 == 0 then local text = {} for a = 0x6004, 0x6FFF do local c = prog:read_u8(a) if c == 0 then break end text[#text + 1] = string.char(c) end log:write(string.format("frame %d status %02X sig %02X %02X %02X text %s\n", frames, prog:read_u8(0x6000), prog:read_u8(0x6001), prog:read_u8(0x6002), prog:read_u8(0x6003), (table.concat(text):gsub("\n", " / ")))) log:flush() end end)