def restore(self): self.buffer = copy.copy(self.original.buffer) self.changed_address = {} self.changed_dma = {} self.force_patch = [] self.last_address = None self.write_bytes(0x35, get_version_bytes(__version__)) self.force_patch.extend([0x35, 0x36, 0x37])
def __init__(self, file=None): super().__init__([]) self.original = None self.changed_address = {} self.changed_dma = {} self.force_patch = [] if file is None: return decomp_file = local_path('ZOOTDEC.z64') os.chdir(local_path()) with open(data_path('generated/symbols.json'), 'r') as stream: symbols = json.load(stream) self.symbols = { name: int(addr, 16) for name, addr in symbols.items() } if file == '': # if not specified, try to read from the previously decompressed rom file = decomp_file try: self.read_rom(file) except FileNotFoundError: # could not find the decompressed rom either raise FileNotFoundError('Must specify path to base ROM') else: self.read_rom(file) # decompress rom, or check if it's already decompressed self.decompress_rom_file(file, decomp_file) # Add file to maximum size self.buffer.extend(bytearray([0x00] * (0x4000000 - len(self.buffer)))) self.original = self.copy() # Add version number to header. self.write_bytes(0x35, get_version_bytes(__version__)) self.force_patch.extend([0x35, 0x36, 0x37])
def update_rom_title(self): self.write_bytes(0x35, get_version_bytes(__version__))
def update_header(self): self.write_bytes(0x35, get_version_bytes(__version__)) crc = calculate_crc(self) self.write_int32s(0x10, [crc[0], crc[1]])