local n = 0 local p = manager.machine.ioport.ports[":joyport1:pad:JOY"] local btn = p.fields["P1 Button 1"] local pot = manager.machine.ioport.ports[":joyport1:pad:POTX"].fields["Paddle"] print("pot range", pot.minvalue, pot.maxvalue, pot.defvalue) emu.register_frame_done(function() n = n + 1 btn:set_value((n > 200 and n < 205 or n > 400 and n < 405) and 1 or 0) if n % 300 == 0 then manager.machine.video:snapshot(); print("frame", n) end if n == 1500 then manager.machine:exit() end end, "f")