Files
Sprinter-SDCC/applications/Volkov/tests/mame_p3_stress.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

138 lines
4.2 KiB
Lua

-- P3 stress: пустой каталог, 40 строк и явный маркер предела DSS.
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 = {
c={"P1.4",0x08}, d={"P1.4",0x04},
e={"P1.4",0x20}, m={"P2.0",0x10}, p={"P2.3",0x20},
r={"P1.5",0x01}, s={"P1.2",0x08}, x={"P1.2",0x10},
[" "]={"P2.4",0x80}, ["."]={"P2.2",0x10},
["\\"]={"P2.1",0x04}, ["\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]
local shifted = false
if not def then
local lower = ch:lower()
def = chars[lower]
shifted = ch ~= lower
else
shifted = def[3] or false
end
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, "SPRCMD .EXE\n")
-- Root order: BIGDIR, EMPTY, MANY, TESTDIR, P3ROOT, SPRCMD, ZETA.
key(17.0, "P2.3", 0x10) -- EMPTY.
key(18.0, "P2.1", 0x10) -- Enter EMPTY.
key(24.0, "P2.1", 0x10) -- Enter `..`.
key(27.0, "P2.3", 0x10) -- EMPTY.
key(28.0, "P2.3", 0x10) -- MANY.
key(29.0, "P2.1", 0x10) -- Enter MANY.
key(36.0, "P1.2", 0x20) -- PgDn -> cursor 27/top 1.
key(38.0, "P2.3", 0x10) -- Down -> cursor 28/top 2.
chord(43.0, "P1.1", 0x02, "P1.2", 0x01) -- Ctrl+PgUp -> root.
key(46.0, "P2.1", 0x10) -- Enter BIGDIR (index 0).
-- BIGDIR scan может быть долгим; последующие события намеренно отнесены.
key(76.0, "P2.5", 0x20) -- End: красный `>>> MORE...`.
key(81.0, "P2.1", 0x10) -- Enter: пояснение, без перехода.
key(86.0, "P2.3", 0x80) -- F10.
key(90.0, "P2.1", 0x10) -- cleanup.
table.sort(events, function(a, b) return a[1] < b[1] end)
local snap_times = {
15.0, -- root count=7, dirs before files;
21.0, -- EMPTY: only synthetic `..`, count=1;
32.0, -- MANY: count=41;
40.0, -- real list cursor=28/top=2;
73.0, -- BIGDIR: частичный список и признак усечения DSS;
79.0, -- End: выбран красный виртуальный `>>> MORE...`;
84.0, -- Enter: статус о недоступном остатке, каталог не меняется;
88.0, -- quit dialog over intact screen;
93.0 -- DSS after cleanup.
}
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("[p3-stress] snapshot t=" .. elapsed)
end
end
if elapsed >= 95.0 then
print("[p3-stress] exit t=" .. elapsed)
manager.machine:exit()
end
end)