-- menu_keys.lua -- drive the level-0 diagnostics menu with the modelled LK401 -- keyboard, to run a selected test through the firmware's own test map. -- -- MENU_KEYS=C,Z MENU_AT=300 MENU_DUMP=200,800 \ -- vt1200 ... -video none -nothrottle -debug -debugger none \ -- -autoboot_script harness/mame/menu_keys.lua -- -- MENU_KEYS is a comma list of single characters (LK401 keycaps). Each is -- pressed for MENU_HOLD frames (default 6), MENU_GAP frames apart (default 30). local machine = manager.machine local ports = machine.ioport.ports -- LK401 port index by character (VT1200_LK401_KEY_LIST order). local KEY = { ["C"] = ":lk401:K40", ["Z"] = ":lk401:K38", ["M"] = ":lk401:K44", ["O"] = ":lk401:K21", ["Q"] = ":lk401:K13", ["X"] = ":lk401:K39", } local keys = {} for k in string.gmatch(os.getenv("MENU_KEYS") or "C,Z", "([^,]+)") do keys[#keys + 1] = k end local at = tonumber(os.getenv("MENU_AT") or "300") local hold = tonumber(os.getenv("MENU_HOLD") or "6") local gap = tonumber(os.getenv("MENU_GAP") or "30") local last = tonumber(os.getenv("MENU_LAST") or "1500") -- schedule: key i pressed at at + i*gap local frame = 0 local function set_key(k, v) local tag = KEY[k] if not tag then print("MENU unknown key " .. k); return end local port = ports[tag] local f for _, field in pairs(port.fields) do f = field end if f then f:set_value(v) end end emu.register_frame_done(function() frame = frame + 1 for i, k in ipairs(keys) do local t = at + (i - 1) * gap if frame == t then set_key(k, 1) print(string.format("MENU frame=%d press %s", frame, k)) elseif frame == t + hold then set_key(k, 0) end end if frame >= last then machine:exit() end end, "vt1200-menu-keys") local dbg = machine.debugger if dbg then dbg.visible_cpu = machine.devices[':maincpu'] dbg.execution_state = 'run' end