-- VT1200 firmware execution harness (headless, Lua debugger API). -- -- Run: -- vt1200 -rompath harness/mame/roms \ -- -video none -sound none -nothrottle \ -- -debug -debugger none \ -- -autoboot_script harness/mame/trace.lua -autoboot_delay 0 -- -- Proves the firmware executes from the reset vector and writes an -- instruction trace of the first frames. 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'] local prog = cpu.spaces['program'] if not dbg then print("ERROR: debugger not enabled; pass -debug") machine:exit() return end local base = "/home/arti/code/k-space/vt1200/harness/mame/" local tracepath = base .. "vt1200-reset.trace" print(string.format("[space] program shift=%d data_width=%d", prog.shift, prog.data_width)) print(string.format("PC at harness start = %s (expect 3F200040)", hex(pc.value))) dbg.visible_cpu = cpu dbg:command("trace " .. tracepath .. ",maincpu,noloop") dbg:command("dasm " .. base .. "reset.dasm,3f200000,200,1") -- Let the machine run; stop after a couple of frames. local frames = 0 emu.register_frame_done(function() frames = frames + 1 if frames >= 2 then dbg:command("trace off") print(string.format("after %d frames: PC=%s", frames, hex(pc.value))) machine:exit() end end, "vt1200-harness") -- The debugger stops the machine at the reset vector; release it. dbg.execution_state = 'run'