local dbg = manager.machine.debugger dbg.visible_cpu = manager.machine.devices[":maincpu"] dbg:command('wpiset e0,20,w,1,{logerror "IW %X %X %d\\n",wpaddr&0xff,wpdata,totalcycles; g}') -- dbg:command('wpiset e0,20,r,1,{logerror "IR %X %X %d\\n",wpaddr&0xff,wpdata,totalcycles; g}') dbg:command("go") local inputs = {{800, 806, ":STD_KEYPAD1", "1 (pad 1)"}, {1000, 1006, ":STD_JOY1", "P1 Button 1"}, {1200, 1206, ":STD_KEYPAD1", "1 (pad 1)"}, {1400, 1406, ":STD_JOY1", "P1 Button 1"}} local last = 1799 local fields = {} for i, inp in ipairs(inputs) do fields[i] = manager.machine.ioport.ports[inp[3]].fields[inp[4]] end local function apply(k) for i, inp in ipairs(inputs) do fields[i]:set_value((inp[1] <= k and k < inp[2]) and 1 or 0) end end frame = 0 apply(0) notifier = emu.add_machine_frame_notifier(function() if frame >= last then manager.machine:exit() end if frame == -1 then dbg:command('trace z80.trace,,noloop,{logerror "%X %X %X %X %X %X %X %X %X %X %X %d %d %d\\n",pc,af,bc,de,hl,ix,iy,sp,af2,i,r,totalcycles,beamy,beamx}') end frame = frame + 1 apply(frame) end)