import sys assert len(sys.argv) > 2 mem = bytearray(2 ** 15) with open(sys.argv[1], 'rb') as f: l = f.read() for i, a in enumerate(l): mem[i + 0x4000] = a # NMIB mem[0xfffa - 0x8000] = 0x00 mem[0xfffb - 0x8000] = 0xc0 # RESB mem[0xfffc - 0x8000] = 0x00 mem[0xfffd - 0x8000] = 0xc0 # IRQB mem[0xfffe - 0x8000] = 0x02 mem[0xffff - 0x8000] = 0xc0 with open(sys.argv[2], 'wb') as f: f.write(mem)