-- P19 UI: overwrite-all, readonly re-prompt, skip-all, rename и cancel. local KB = ":kbd:ms_naturl:" local HOLD = 0.06 local events = {} local function add(t, tag, mask, value) events[#events + 1] = {t, KB .. tag, mask, value} end local function key(t, tag, mask) add(t, tag, mask, 1) add(t + HOLD, tag, mask, 0) end local function chord(t, mod_tag, mod_mask, key_tag, key_mask) add(t, mod_tag, mod_mask, 1) add(t + 0.02, key_tag, key_mask, 1) add(t + 0.08, key_tag, key_mask, 0) add(t + 0.10, mod_tag, mod_mask, 0) end local chars = { a={"P1.6",0x04}, b={"P1.5",0x10}, c={"P1.4",0x08}, d={"P1.4",0x04}, e={"P1.4",0x20}, i={"P1.4",0x01}, m={"P2.0",0x10}, n={"P2.0",0x08}, o={"P2.2",0x02}, p={"P2.3",0x20}, r={"P1.5",0x01}, s={"P1.2",0x08}, t={"P1.5",0x20}, x={"P1.2",0x10}, ["."]={"P2.2",0x10}, ["\n"]={"P2.1",0x10}, [":"]={"P2.3",0x02,true} } local function type_text(t, value) for i = 1, #value do local ch = value:sub(i, i) local def = chars[ch] or chars[ch:lower()] local shifted = def[3] or ch ~= ch:lower() if shifted then chord(t, "P1.7", 0x02, def[1], def[2]) else key(t, def[1], def[2]) end t = t + 0.14 end return t end type_text(8.0, "d:\n") type_text(10.0, "SPRCMD.EXE\n") key(16.0, "P1.6", 0x20) -- right root. key(17.0, "P2.1", 0x10) -- enter P19DST. key(18.0, "P1.6", 0x20) -- left root. key(19.0, "P2.3", 0x10) -- P19DST -> P19SRC. key(20.0, "P2.1", 0x10) -- enter P19SRC. key(22.0, "P2.3", 0x10) -- AONE. key(23.0, "P2.6", 0x01) -- select AONE -> ATWO. key(24.0, "P2.6", 0x01) -- select ATWO -> CANCEL. key(25.0, "P2.3", 0x10) -- REN. key(26.0, "P2.3", 0x10) -- RONLY. key(27.0, "P2.6", 0x01) -- select RONLY -> SONE. key(30.0, "P2.1", 0x40) -- group F5. key(33.0, "P1.6", 0x04) -- A = overwrite all. key(40.0, "P2.2", 0x02) -- O = explicit readonly overwrite. chord(47.0, "P1.1", 0x02, "P1.5", 0x01) -- refresh/reset selection. key(49.0, "P2.6", 0x01) -- select SONE -> STWO. key(50.0, "P2.6", 0x01) -- select STWO. key(52.0, "P2.1", 0x40) -- group F5. key(56.0, "P2.0", 0x08) -- N = skip all. chord(60.0, "P1.1", 0x02, "P1.5", 0x01) key(62.0, "P2.5", 0x01) -- Home -> `..`. key(63.0, "P2.3", 0x10) -- AONE. key(64.0, "P2.3", 0x10) -- ATWO. key(65.0, "P2.3", 0x10) -- CANCEL. key(66.0, "P2.3", 0x10) -- REN. key(68.0, "P2.1", 0x40) -- single F5. key(72.0, "P1.5", 0x01) -- R = rename. type_text(74.0, "NEXT.BIN\n") key(80.0, "P2.5", 0x01) -- Home -> `..`. key(80.5, "P2.3", 0x10) -- AONE. key(81.0, "P2.3", 0x10) -- ATWO. key(81.5, "P2.3", 0x10) -- CANCEL. key(83.0, "P2.1", 0x40) key(87.0, "P1.6", 0x40) -- Esc conflict. key(90.0, "P1.6", 0x20) -- inspect target. key(95.0, "P2.3", 0x80) -- F10. key(97.0, "P2.1", 0x10) -- Запас на I/O MAME 0.287: ответ readonly должен идти после двух копий. for _, event in ipairs(events) do if event[1] >= 40.0 then event[1] = event[1] + 20.0 end end table.sort(events, function(left, right) return left[1] < right[1] end) local snap_times = {31.5, 38.0, 44.0, 54.0, 58.0, 70.0, 76.0, 85.0, 89.0, 92.0, 99.0} for i, t in ipairs(snap_times) do if t >= 40.0 then snap_times[i] = t + 20.0 end end local snaps_done = {} local start_time = nil local ports = nil local index = 1 local field_cache = {} local function now() local value = manager.machine.time return value.seconds + value.attoseconds / 1e18 end local function field(tag, mask) local cache_key = tag .. "/" .. mask if field_cache[cache_key] then return field_cache[cache_key] end for _, candidate in pairs(ports[tag].fields) do if candidate.mask == mask then field_cache[cache_key] = candidate return candidate end end error("Не найдено поле " .. cache_key) end emu.add_machine_reset_notifier(function() start_time = now() end) emu.register_periodic(function() if not start_time then return end if not ports then ports = manager.machine.ioport.ports end local elapsed = now() - start_time while index <= #events and elapsed >= events[index][1] do local event = events[index] field(event[2], event[3]):set_value(event[4]) index = index + 1 end for _, snap_time in ipairs(snap_times) do if not snaps_done[snap_time] and elapsed >= snap_time then snaps_done[snap_time] = true manager.machine.video:snapshot() print("[p19-policy] snapshot t=" .. elapsed) end end if elapsed >= 121.0 then manager.machine:exit() end end)