Files
Sprinter-SDCC/applications/Volkov/tests/mame_p7_select.lua
T
snark13 8e389c03f8 Volkov: добавить Sprinter Commander
Реализовать двухпанельный Commander от платформенного PoC до этапов P6-P20: EMM-каталог, сортировку и выбор, операции с файлами и деревьями, транзакционное копирование, метаданные, политику конфликтов и предварительную проверку свободного места.

Добавить проектную документацию, HDD/MAME-сценарии и проверенные артефакты. Расширить libc операцией bank_write_page, исправлением режима O_RDONLY и связанными регрессионными проверками.
2026-09-10 10:45:30 +03:00

149 lines
4.5 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 0.2/P7: Insert, invert, перенос flags через sort и сброс на refresh.
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 = {
b={"P1.5",0x10}, c={"P1.4",0x08}, d={"P1.4",0x04},
e={"P1.4",0x20}, i={"P1.4",0x01}, l={"P2.2",0x08},
m={"P2.0",0x10}, n={"P2.0",0x08}, p={"P2.3",0x20},
r={"P1.5",0x01}, s={"P1.2",0x08}, t={"P1.5",0x20},
x={"P1.2",0x10}, [" "]={"P2.4",0x80}, ["."]={"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
end
type_text(8.0, "d:\n")
type_text(9.0, "SELRT.EXE\n")
type_text(12.0, "SPRCMD.EXE\n")
key(18.0, "P2.1", 0x10) -- left -> SELECT.
key(21.0, "P2.6", 0x01) -- Insert на `..`: запрещён.
key(23.0, "P2.3", 0x10) -- Down -> ADIR.
key(24.0, "P2.6", 0x01) -- выбрать ADIR, cursor -> ZDIR.
key(26.0, "P2.6", 0x01) -- выбрать ZDIR, cursor -> A.BIN.
key(28.0, "P2.6", 0x01) -- выбрать A.BIN, cursor -> B.BIN.
chord(32.0, "P1.1", 0x02, "P2.6", 0x40) -- Ctrl+F3: N-.
chord(36.0, "P1.7", 0x02, "P1.4", 0x80) -- Shift+8 = `*`.
chord(40.0, "P1.1", 0x02, "P1.5", 0x01) -- Ctrl+R: выбор сброшен.
chord(43.0, "P1.7", 0x02, "P2.1", 0x01) -- Shift+=: `+`.
key(44.0, "P2.1", 0x20) -- стереть default `*.*`.
key(44.3, "P2.1", 0x20)
key(44.6, "P2.1", 0x20)
chord(45.0, "P1.7", 0x02, "P1.4", 0x80) -- `*`.
key(45.3, "P2.2", 0x10) -- `.`.
type_text(45.6, "bin")
key(46.4, "P2.1", 0x10) -- apply `*.bin`.
key(50.0, "P2.2", 0x20) -- `-`.
key(51.0, "P2.1", 0x20) -- стереть default `*.*`.
key(51.3, "P2.1", 0x20)
key(51.6, "P2.1", 0x20)
type_text(52.0, "b.bin")
key(53.0, "P2.1", 0x10) -- unselect B.BIN.
chord(56.0, "P1.7", 0x02, "P2.1", 0x01) -- `+`, затем cancel.
key(57.0, "P1.6", 0x40) -- Esc.
key(60.0, "P2.3", 0x80) -- F10.
key(62.0, "P2.1", 0x10) -- Enter: cleanup.
table.sort(events, function(a, b) return a[1] < b[1] end)
local snap_times = {
20.0, -- исходный список;
22.0, -- `..` не выбран;
29.5, -- два каталога и A.BIN выбраны, sel=10/003;
33.5, -- sort N- сохранил flags и текущий B.BIN;
37.5, -- invert оставил каталоги и B.BIN/C.BIN, sel=50/004;
41.5, -- refresh сбросил выбор, N- сохранён;
43.5, -- mask dialog с default `*.*`;
46.1, -- отредактировано `*.bin`;
48.0, -- маска выбрала три BIN, sel=60/003;
54.5, -- `- b.bin` оставил A/C, sel=40/002;
58.0, -- cancel следующего `+` сохранил выбор;
64.0 -- чистый DSS prompt.
}
local snaps_done = {}
local start_time = nil
local ports = nil
local index = 1
local field_cache = {}
local function now()
local t = manager.machine.time
return t.seconds + t.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("[p7-select] snapshot t=" .. elapsed)
end
end
if elapsed >= 66.0 then
print("[p7-select] exit t=" .. elapsed)
manager.machine:exit()
end
end)