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

160 lines
4.4 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.
-- P5 на HDD D: 20 copy, 100 refresh и три полных cleanup-цикла.
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 function refresh_chord(t)
add(t, "P1.1", 0x02, 1)
add(t + 0.03, "P1.5", 0x01, 1)
add(t + 0.20, "P1.5", 0x01, 0)
add(t + 0.23, "P1.1", 0x02, 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}, ["\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")
key(15.0, "P2.1", 0x10) -- левая -> SOURCE.
key(17.0, "P1.6", 0x20) -- Tab.
key(18.0, "P2.3", 0x10) -- TARGET.
key(19.0, "P2.1", 0x10) -- правая -> TARGET.
key(21.0, "P1.6", 0x20) -- Tab влево.
-- В SOURCE: `..`, затем F00.BIN..F19.BIN. Copy не меняет active selection.
-- Интервалы растут вместе с числом 4-КБ блоков: ввод во время синхронного
-- copy не буферизуется и не должен считаться выполненной командой.
local copy_times = {
22.0, 24.0, 26.0, 28.0, 30.0, 34.0, 38.0, 40.0, 42.0, 44.0,
46.0, 48.0, 50.0, 52.0, 54.0, 57.0, 60.0, 64.0, 68.0, 75.0
}
for i = 0, 19 do
local t = copy_times[i + 1]
key(t, "P2.3", 0x10) -- Down.
key(t + 0.25, "P2.1", 0x40) -- F5.
end
-- Последний файл больше 1 МБ; оставляем запас до refresh.
for i = 0, 99 do
refresh_chord(105.0 + i * 0.50)
end
key(160.0, "P2.3", 0x80) -- F10 первого запуска.
key(161.5, "P2.1", 0x10)
type_text(167.0, "SPRCMD .EXE\n")
key(173.0, "P2.3", 0x80)
key(174.5, "P2.1", 0x10)
type_text(180.0, "SPRCMD .EXE\n")
key(186.0, "P2.3", 0x80)
key(187.5, "P2.1", 0x10)
table.sort(events, function(a, b) return a[1] < b[1] end)
local snap_times = {
14.0, -- root D:;
20.5, -- SOURCE/TARGET;
80.0, -- прогресс последнего файла больше 1 МБ;
100.0, -- 20 файлов показаны в TARGET;
157.0, -- состояние после 100 refresh;
164.0, -- первый cleanup, чистый prompt;
177.0, -- второй cleanup;
190.0 -- третий 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("[p5-stability] snapshot t=" .. elapsed)
end
end
if elapsed >= 192.0 then
print("[p5-stability] exit t=" .. elapsed)
manager.machine:exit()
end
end)