"""Development only: testpico's image with its reset vector sent to a stub that does x32x_enable from RAM and waits for M_OK and S_OK.""" import sys, time from megadrive_python.cartridge import Cartridge from sega32x_python.console import build def stub_rom(path): rom = bytearray(open(path, "rb").read()) ram = bytes.fromhex( "33fc000100a15100" "303c0010" "51c8fffe" "33fc000300a15100" "0c794d5f00a15120" "66f6" "0c79535f00a15124" "66f6" "08f9000000a15107" "4e75") ram += b"\x4e\x71" * (((-len(ram)) % 4) // 2) code = bytearray() for i in range(0, len(ram), 4): code += bytes.fromhex("23fc") + ram[i:i+4] + (0xFF0000 + i).to_bytes(4, "big") code += bytes.fromhex("4eb900ff0000") + bytes.fromhex("60fe") at = 0x204 assert all(b in (0x4A, 0xFC) for b in rom[at:at + len(code)]) # testpico's ILLEGAL fill rom[at:at + len(code)] = code rom[4:8] = at.to_bytes(4, "big") return bytes(rom) if __name__ == "__main__": frames = int(sys.argv[2]) system, dev = build("genesis", Cartridge.from_image(stub_rom(sys.argv[1])), "/data/emu/images/x55/bios") system.board.fm.enabled = False t0 = time.time() for f in range(frames): system.run_frame() sh2 = dev.sh2 comm = bytes(b for w in dev.comm for b in (w >> 8, w & 0xFF)) print(f, f"{time.time()-t0:.1f}s", "run", sh2.running, "pc", [hex(c.pc) for c in sh2.chips], "sleep", [c.sleeping for c in sh2.chips], "instr", sh2.instructions, "comm", comm, "unmapped", len(sh2.unmapped), sh2.unmapped[:2], "68k", hex(system.m68k.PC), flush=True)