-- watch every writer of the created resource's byte8 (generated addresses) local frames = 0 local lastwp, lastptr = "", 0 local dbg = manager.machine.debugger local cpu = manager.machine.devices[":maincpu"] local idstore = 0x3F200000 + 0x67B04*8 dbg:command(string.format("bpset %08X,,{ printf \"IDSTORE id=%%08X obj=%%08X\\n\", d@(a9+0x40), a11 ; g }", idstore)) print("XIE-WPB8 armed 1 breakpoint") emu.register_frame_done(function() frames = frames + 1 local f = io.open("/tmp/opencode/xie_wp2.txt", "r") if f then local txt = f:read("*l"); f:close() if txt and txt ~= lastwp then lastwp = txt local p = tonumber(txt) if p and p ~= 0 and p ~= lastptr then lastptr = p local sp = cpu.spaces['program'] local b8 = sp:read_u8(p + 8*8) print(string.format("XIE-WPB8 installing at %08X (byte8 now %d)", p + 8*8, b8)) dbg:command(string.format("wpset %08X,8,w,1,{ printf \"WPB8 pc=%%08X addr=%%08X val=%%08X\\n\", pc, wpaddr, wpdata ; g }", p + 8*8)) end end end if frames >= 2000000 then machine:exit() end end, "wpb8")