emu.register_frame(function()
local cpu = manager.machine.devices[":maincpu"]
if not cpu then return end
local mem = cpu.spaces["program"]
local io_in1 = manager.machine.ioport.ports[":IN1"]
local io_in3 = manager.machine.ioport.ports[":IN3"]
local io_wheel = manager.machine.ioport.ports[":WHEEL"]
if not io_in1 or not io_in3 or not io_wheel then return end
local data1 = io_in1:read()
local data3 = io_in3:read()
local data2 = io_wheel:read()
local ret = 0x0000
if (data3 & 0x20) ~= 0 then
ret = ret + 0x0300
end
if (data3 & 0x40) ~= 0 then
ret = ret + 0xf000
end
if (data1 & 0x10) ~= 0 then
ret = ret + 0x0800
end
ret = ret + (data2 & 0x7f)
mem:write_u16(0x070000, ret)
end)

mame rf2b -script 上を保存したファイル名
コンパイルするの面倒だからluaで試してみたけど操作出来たよ