local snaps = {[899] = true, [1500] = true} local inputs = {} local last = 1500 local fields = {} for i, inp in ipairs(inputs) do local port = manager.machine.ioport.ports[inp[3]] fields[i] = port.fields[inp[4]] if fields[i] == nil then print("NO FIELD", inp[3], inp[4]) end end local function apply(k) for i, inp in ipairs(inputs) do if fields[i] ~= nil then fields[i]:set_value((inp[1] <= k and k < inp[2]) and 1 or 0) end end end frame = 0 apply(0) taken = {} notifier = emu.add_machine_frame_notifier(function() if snaps[frame] then manager.machine.video:snapshot() taken[#taken + 1] = frame print("SNAP", frame) end if frame >= last then manager.machine:exit() end frame = frame + 1 apply(frame) end)