mirror of
https://git.k-space.ee/arti/vt1200.git
synced 2026-10-30 12:03:54 +02:00
57 lines
1.7 KiB
Lua
57 lines
1.7 KiB
Lua
-- VT1200: how far does the boot get with the current (peripheral-less) driver,
|
|
-- and where does it end up spinning? Samples the PC once per emulated frame and
|
|
-- prints a histogram of the hottest PCs at the end.
|
|
--
|
|
-- <mame> vt1200 -rompath harness/mame/roms -video none -sound none -nothrottle \
|
|
-- -debug -debugger none -debuglog \
|
|
-- -autoboot_script harness/mame/progress.lua -autoboot_delay 0
|
|
--
|
|
-- PROG_FRAMES overrides the frame budget (default 600).
|
|
|
|
local function hex(v) return string.format("%08X", v) end
|
|
|
|
local machine = manager.machine
|
|
local cpu = machine.devices[':maincpu']
|
|
local dbg = machine.debugger
|
|
local pc = cpu.state['PC']
|
|
|
|
if not dbg then
|
|
print("ERROR: debugger not enabled; pass -debug")
|
|
machine:exit()
|
|
return
|
|
end
|
|
|
|
local maxframes = tonumber(os.getenv("PROG_FRAMES") or "600")
|
|
local frames = 0
|
|
local hist = {}
|
|
local first = {}
|
|
|
|
emu.register_frame_done(function()
|
|
frames = frames + 1
|
|
local v = pc.value
|
|
hist[v] = (hist[v] or 0) + 1
|
|
if not first[v] then first[v] = frames end
|
|
if frames % 50 == 0 then
|
|
print(string.format("frame %5d PC=%s", frames, hex(v)))
|
|
end
|
|
if frames >= maxframes then
|
|
print("--- distinct PCs sampled: " .. tostring((function()
|
|
local n = 0
|
|
for _ in pairs(hist) do n = n + 1 end
|
|
return n
|
|
end)()))
|
|
print("--- hottest PCs (one sample per frame) ---")
|
|
local list = {}
|
|
for k, c in pairs(hist) do list[#list + 1] = {k, c} end
|
|
table.sort(list, function(a, b) return a[2] > b[2] end)
|
|
for i = 1, math.min(15, #list) do
|
|
print(string.format(" PC=%s samples=%d first_frame=%d",
|
|
hex(list[i][1]), list[i][2], first[list[i][1]]))
|
|
end
|
|
machine:exit()
|
|
end
|
|
end, "vt1200-progress")
|
|
|
|
dbg.visible_cpu = cpu
|
|
dbg.execution_state = 'run'
|