-- hp_trace.lua -- dynamic trace of the level-1 HOST PORT test. -- -- Polls (per frame, via the address map so device side effects apply): -- INTENB/INTPEND (CPU I/O regs) -- DUART1 ISR (window 0x06400000 + reg 5 -> program space 0x06400050) -- DUART1 SRA (reg 1 -> 0x06400010) -- DUART1 CRA read? no (write-only-ish); MR1A read ok (reg 0 -> 0x06400000) -- DO NOT read reg 3 (RHRA) -- it pops the FIFO. -- -- Also breaks at key PCs and logs registers. -- -- HP_FRAMES=900 vt1200 ... -autoboot_script harness/mame/hp_trace.lua local machine = manager.machine local cpu = machine.devices[':maincpu'] local dbg = machine.debugger local prog = cpu.spaces['program'] if not dbg then print("ERROR: no debugger"); machine:exit(); return end local rd = function(a) return prog:read_u16(a) end local maxframes = tonumber(os.getenv("HP_FRAMES") or "900") local n = 0 -- Frame polling: report changes and every 25 frames a compact snapshot. local last = {} local keys = { INTENB = 0xc0000110, INTPEND = 0xc0000120, D1_ISR = 0x06400050, -- reg 5 D1_SRA = 0x06400010, -- reg 1 D1_MR1 = 0x06400000, -- reg 0 } emu.register_frame_done(function() n = n + 1 for name, addr in pairs(keys) do local v = rd(addr) if last[name] ~= v then print(string.format("f%4d %s CHANGED -> %04X", n, name, v)) last[name] = v end end if n >= maxframes then print("done (" .. n .. " frames)") machine:exit() end end, "vt1200-hp") dbg.visible_cpu = cpu dbg.execution_state = 'run'