local dbg = manager.machine.debugger dbg.visible_cpu = manager.machine.devices[":maincpu"] dbg:command('trace cpu.trace,,noloop,{logerror "%X %02X%02X %X %X %X %X %X %X %X %X %X %d %d\\n",pc,a,f,b,c,d,e,h,l,sp,ie,if,totalcycles,beamy}') dbg:command('wpset ff00,80,r,1,{logerror "R %X %X %d\\n",wpaddr,wpdata,totalcycles; g}') dbg:command('wpset ff00,80,w,1,{logerror "W %X %X %d\\n",wpaddr,wpdata,totalcycles; g}') dbg:command('wpset ffff,1,rw,1,{logerror "%s %X %X %d\\n",wpaddr,wpdata,totalcycles; g}') dbg:command("go") local cpu = manager.machine.devices[":maincpu"] local prog = cpu.spaces["program"] local frames = 0 local log = io.open("status.txt", "w") status_sub = emu.add_machine_frame_notifier(function() frames = frames + 1 if frames % 60 == 0 then local s = cpu.state local pc = s["PC"].value local text = {} for a = 0xA004, 0xA1FF do local c = prog:read_u8(a) if c == 0 then break end text[#text + 1] = string.char(c) end log:write(string.format( "frame %d pc %04X ops %02X %02X %02X regs %02X %02X %02X %02X %02X %02X a000 %02X sig %02X %02X %02X text %s\n", frames, pc, prog:read_u8(pc - 1), prog:read_u8(pc), prog:read_u8(pc + 1), s["B"].value, s["C"].value, s["D"].value, s["E"].value, s["H"].value, s["L"].value, prog:read_u8(0xA000), prog:read_u8(0xA001), prog:read_u8(0xA002), prog:read_u8(0xA003), (table.concat(text):gsub("\n", " / ")))) log:flush() end end)