vanilla = sys.argv[1] ipsToReverse = sys.argv[2:] rom = RealROM(vanilla) for ips in ipsToReverse: if ips not in common_patches.patches: ipsPath = os.path.abspath(ips) destDir, destFile = os.path.split(ipsPath) patch = IPS_Patch.load(ips) patchDict = patch.toDict() else: patchDict = common_patches.patches[ips] destDir = sys.path[0] + "/../patches/common/ips" destFile = ips + ".ips" destFile = "remove_" + destFile destPath = os.path.join(destDir, destFile) reversePatchDict = {} for addr, bytez in patchDict.items(): sz = len(bytez) origBytes = [] rom.seek(addr) for i in range(sz): origBytes.append(rom.readByte()) assert len(origBytes) == sz reversePatchDict[addr] = origBytes reversePatch = IPS_Patch(reversePatchDict) reversePatch.save(destPath) rom.close()
def updateTable(dataId, rTrack, vTrack): expected_nspc = os.path.join(baseDir, allTracks[rTrack]['nspc_path']) if dataId in expected_table and expected_nspc != expected_table[dataId]: print("Inconsistent music table!") print("dataId=$%02x, vTrack=%s, rTrack=%s, previous=%s" % (dataId, vTrack, rTrack, expected_table[dataId])) expected_table[dataId] = expected_nspc print("Data $%02x, expected data from track %s" % (dataId, rTrack)) # custom tracks for vTrack, rTrack in playlist.items(): vTrackData = getVanillaTrackData(vTrack) addr = vTrackData['pc_addresses'][0] dataId = rom.readByte(addr) updateTable(dataId, rTrack, vTrack) # preserved tracks for vTrack in preserved: vTrackData = getVanillaTrackData(vTrack) dataId = (vTrackData['data_index'] + 1) * 3 updateTable(dataId, vTrack, vTrack) minAddr, maxAddr = (0xffffffff, 0x0) # compare nspc data and dump if different than expected for dataId, expected_nspc in expected_table.items(): with open(expected_nspc, 'rb') as f: expected_music_data = f.read() sz = len(expected_music_data)
print("") print("updated bts behind vanilla ship bottom") vlevelData.displaySubScreen(vShipScreen, hShipBottom.spritemap.boundingRect) print("") if not fixEscape: vlevelData.write() for name, addrRange in addresses.items(): print("check {} at {}".format(name, hex(addrRange["vanilla"][0]))) diffFound = False for addrV, addrH in zip( range(addrRange["vanilla"][0], addrRange["vanilla"][1]), range(addrRange["hack"][0], addrRange["hack"][1])): hByte = hackRom.readByte(addrH) vByte = vanillaRom.readByte(addrV) if hByte != vByte: print("difference between vanilla and hack detected") diffFound = True break if name not in ["enemySet", "enemyHeader"]: needCopy[name] = diffFound if diffFound and addrRange["vanilla"][1] - addrRange["vanilla"][0] < 256: hBytes = [] vBytes = [] for addrV, addrH in zip( range(addrRange["vanilla"][0], addrRange["vanilla"][1]), range(addrRange["hack"][0], addrRange["hack"][1])): hBytes.append(hackRom.readByte(addrH)) vBytes.append(vanillaRom.readByte(addrV))
return (c) def RGB_15_to_24(SNESColor): R = ((SNESColor) % 32) * 8 G = ((SNESColor // 32) % 32) * 8 B = ((SNESColor // 1024) % 32) * 8 return (R, G, B) variapal.seek(0x00) vanillarom.seek(palAddr) final = [] for i in range(16): r = variapal.readByte() g = variapal.readByte() b = variapal.readByte() final.append([r, g, b]) color = RGB_24_to_15((r, g, b)) vanillarom.writeWord(color) # update logo fadein palettes final.pop(0) # first color is not updated by the fadein fadeinPaletteAddr = 0x6C6BE for i in range(15): steps = [ int(final[i][0] / 8) + 1, int(final[i][1] / 8) + 1, int(final[i][2] / 8) + 1 ]