def OnSubmit(self, *args): sel = self.OFFSETS.GetSelection() offset = self.MANUAL.GetValue() new_offset = None if self.num == None: try: self.num = int(self.New_Move_Num.GetValue(), 0) except: return if offset != "": if len(offset) > 6: check = offset[-7:-6] if check == "1" or check == "9": check = "1" else: check = "" offset = check+offset[-6:].zfill(6) new_offset = offset.zfill(6) self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.NEW_LEARNED_OFFSET = new_offset self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.LEARNED_OFFSET.SetLabel("0x"+new_offset) self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.NEW_NUMBER_OF_MOVES = self.num self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.UPDATE_FRACTION() elif sel != -1: new_offset = self.OFFSETS.GetString(sel)[2:] self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.NEW_LEARNED_OFFSET = new_offset self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.LEARNED_OFFSET.SetLabel("0x"+new_offset) self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.NEW_NUMBER_OF_MOVES = self.num self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.UPDATE_FRACTION() if new_offset != None: learned_moves_pointer = int(Globals.INI.get(Globals.OpenRomID, "LearnedMoves"), 0) int_offset = int(new_offset,16)+int("8000000",16) offset = hex(int_offset)[2:].zfill(8) pointer = make_pointer(offset) pointer = get_hex_from_string(pointer) global poke_num offset_of_pointer = learned_moves_pointer+(poke_num)*4 with open(Globals.OpenRomName, "r+b") as rom: rom.seek(offset_of_pointer) rom.write(pointer) rom.seek(int(new_offset,16)) Jambo51HackCheck = Globals.INI.get(Globals.OpenRomID, "Jambo51LearnedMoveHack") if Jambo51HackCheck == "False": learnedmoveslength = int(Globals.INI.get(Globals.OpenRomID, "learnedmoveslength"), 0) amount_of_bytes = self.num*learnedmoveslength for n in range(int(amount_of_bytes/2)): rom.write("\x00\xCA") rom.write("\xff\xff\xfe\xfe") else: amount_of_bytes = self.num*3 for n in range(int(amount_of_bytes/2)): rom.write("\x00\xCA") rom.write("\xff\xff\xff\xfe") self.OnClose()
def OnSubmit(self, *args): sel = self.OFFSETS.GetSelection() offset = self.MANUAL.GetValue() new_offset = None if self.num == None: try: self.num = int(self.New_Move_Num.GetValue(), 0) except: return if offset != "": if len(offset) > 6: check = offset[-7:-6] if check == "1" or check == "9": check = "1" else: check = "" offset = check + offset[-6:].zfill(6) new_offset = offset.zfill(6) self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.NEW_LEARNED_OFFSET = new_offset self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.LEARNED_OFFSET.SetLabel( "0x" + new_offset) self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.NEW_NUMBER_OF_MOVES = self.num self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.UPDATE_FRACTION( ) elif sel != -1: new_offset = self.OFFSETS.GetString(sel)[2:] self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.NEW_LEARNED_OFFSET = new_offset self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.LEARNED_OFFSET.SetLabel( "0x" + new_offset) self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.NEW_NUMBER_OF_MOVES = self.num self.frame.tabbed_area.PokeDataTab.tabbed_area.moves.UPDATE_FRACTION( ) if new_offset != None: learned_moves_pointer = int( Globals.INI.get(Globals.OpenRomID, "LearnedMoves"), 0) int_offset = int(new_offset, 16) + int("8000000", 16) offset = hex(int_offset)[2:].zfill(8) pointer = make_pointer(offset) pointer = get_hex_from_string(pointer) global poke_num offset_of_pointer = learned_moves_pointer + (poke_num) * 4 with open(Globals.OpenRomName, "r+b") as rom: rom.seek(offset_of_pointer) rom.write(pointer) rom.seek(int(new_offset, 16)) Jambo51HackCheck = Globals.INI.get(Globals.OpenRomID, "Jambo51LearnedMoveHack") if Jambo51HackCheck == "False": learnedmoveslength = int( Globals.INI.get(Globals.OpenRomID, "learnedmoveslength"), 0) amount_of_bytes = self.num * learnedmoveslength for n in range(int(amount_of_bytes / 2)): rom.write("\x00\xCA") rom.write("\xff\xff\xfe\xfe") else: amount_of_bytes = self.num * 3 for n in range(int(amount_of_bytes / 2)): rom.write("\x00\xCA") rom.write("\xff\xff\xff\xfe") self.OnClose()
def OnSubmit(self, *args): sel = self.OFFSETS.GetSelection() _offset_ = self.MANUAL.GetValue() new_number = self.NewNumberChoices.GetSelection() new_number = int(self.choices[new_number]) EvolutionsPerPoke = int(Globals.INI.get(Globals.OpenRomID, "EvolutionsPerPoke"), 0) if new_number == EvolutionsPerPoke: ComeOn = wx.MessageDialog(self, "Look, you are supposed to change the number of evolutions. Haha, everyone makes mistakes. I would pick a different number.", "What's the purpose?", wx.OK) ComeOn.ShowModal() return if _offset_ != "": if len(_offset_) > 6: check = _offset_[-7:-6] if check == "1" or check == "9": check = "1" else: check = "" _offset_ = check+_offset_[-6:].zfill(6) elif sel != -1: _offset_ = self.OFFSETS.GetString(sel)[2:] else: return ##copy table LengthOfOneEntry = int(Globals.INI.get(Globals.OpenRomID, "LengthOfOneEntry"), 0) EvolutionTable = int(Globals.INI.get(Globals.OpenRomID, "EvolutionTable"), 0) numberofpokes = int(Globals.INI.get(Globals.OpenRomID, "numberofpokes"), 0) readlength = EvolutionsPerPoke*LengthOfOneEntry*numberofpokes with open(Globals.OpenRomName, "r+b") as rom: rom.seek(EvolutionTable) entiretable = rom.read(readlength) table = [] if new_number < EvolutionsPerPoke: while entiretable != "": split = entiretable[:LengthOfOneEntry*EvolutionsPerPoke] split = split[:new_number*LengthOfOneEntry] table.append(split) entiretable = entiretable[LengthOfOneEntry*EvolutionsPerPoke:] else: while entiretable != "": split = entiretable[:LengthOfOneEntry*EvolutionsPerPoke] split += "\x00"*(LengthOfOneEntry)*(new_number-EvolutionsPerPoke) table.append(split) entiretable = entiretable[LengthOfOneEntry*EvolutionsPerPoke:] int_offset = int(_offset_, 16) rom.seek(int_offset) for entry in table: rom.write(entry) ##write new pointers. EvolutionTablePointers = [] list_pointers = Globals.INI.get(Globals.OpenRomID, "EvolutionTablePointers").split(",") for offset in list_pointers: EvolutionTablePointers.append(int(offset, 0)) _offset_ = int(_offset_,16)+0x8000000 _offset_ = hex(_offset_).lstrip("0x").rstrip("L").zfill(8) pointer = make_pointer(_offset_) pointer = get_hex_from_string(pointer) with open(Globals.OpenRomName, "r+b") as rom: for offset in EvolutionTablePointers: rom.seek(offset) rom.write(pointer) ##Ammend the ini _offset_ = int(_offset_,16)-0x8000000 _offset_ = hex(_offset_).rstrip("L") Globals.INI.set(Globals.OpenRomID, "EvolutionTable", _offset_) Globals.INI.set(Globals.OpenRomID, "EvolutionsPerPoke", str(new_number)) with open("PokeRoms.ini", "w") as PokeRomsIni: Globals.INI.write(PokeRomsIni) ##fill table with FF with open(Globals.OpenRomName, "r+b") as rom: rom.seek(EvolutionTable) for n in range(readlength): rom.write("\xFF") ##Adjust the rom for the new table change1 = [] #-> lsl r0, r6, #0x1 (70 00) tmp = Globals.INI.get(Globals.OpenRomID, "OffsetsToChangeTolslr0r60x1").split(",") for offset in tmp: change1.append(int(offset, 0)) if new_number == 4: write = "3000" elif new_number == 8: write = "7000" elif new_number == 16: write = "B000" elif new_number == 32: write = "F000" else: write = "F019" change1write = unhexlify(write) with open(Globals.OpenRomName, "r+b") as rom: for offset in change1: rom.seek(offset, 0) rom.write(change1write) change2 = [] #04 -> 07 tmp = Globals.INI.get(Globals.OpenRomID, "OffsetsToChangeToNewMinus1").split(",") for offset in tmp: change2.append(int(offset, 0)) change2write = get_hex_from_string(str(hex(new_number-1)[2:])) with open(Globals.OpenRomName, "r+b") as rom: for offset in change2: rom.seek(offset, 0) rom.write(change2write) TheShedinjaFix = int(Globals.INI.get(Globals.OpenRomID, "LengthOfOneEntry"), 0) code = Globals.INI.get(Globals.OpenRomID, "gamecode") if code != "AXVE" and code != "AXPE": if new_number == 4: write = "0000" elif new_number == 8: write = "4000" elif new_number == 16: write = "8000" elif new_number == 32: write = "C000" else: write = "5044" else: if new_number == 4: write = "B90089460000" elif new_number == 8: write = "F90089460000" elif new_number == 16: write = "390189460000" elif new_number == 32: write = "790189460000" else: write = "B9008946C819" TheShedinjaFixWrite = unhexlify(write) with open(Globals.OpenRomName, "r+b") as rom: rom.seek(TheShedinjaFix, 0) rom.write(TheShedinjaFixWrite) change3 = [] tmp = Globals.INI.get(Globals.OpenRomID, "ChangeToNewNumberTimes8").split(",") for offset in tmp: change3.append(int(offset, 0)) change3write = get_hex_from_string(str(hex(new_number*8)[2:])) with open(Globals.OpenRomName, "r+b") as rom: for offset in change3: rom.seek(offset, 0) rom.write(change3write) ##Tell the user it worked, close, and reload data. #Small fix for some weird bytes that get written. Shhh, don't tell anyone..... rom.seek(8) rom.write("\x69\x9A") self.OnClose() DONE = wx.MessageDialog(None, "Table has been moved, ini has been ammended,\nand evolutions have been changed.:)\n\n\nReloading 'MON Data.", "Done!", wx.OK) DONE.ShowModal() self.frame.tabbed_area.PokeDataTab.tabbed_area.reload_tab_data()
def OnSubmit(self, *args): sel = self.OFFSETS.GetSelection() _offset_ = self.MANUAL.GetValue() new_number = self.NewNumberChoices.GetSelection() new_number = int(self.choices[new_number]) EvolutionsPerPoke = int( Globals.INI.get(Globals.OpenRomID, "EvolutionsPerPoke"), 0) if new_number == EvolutionsPerPoke: ComeOn = wx.MessageDialog( self, "Look, you are supposed to change the number of evolutions. Haha, everyone makes mistakes. I would pick a different number.", "What's the purpose?", wx.OK) ComeOn.ShowModal() return if _offset_ != "": if len(_offset_) > 6: check = _offset_[-7:-6] if check == "1" or check == "9": check = "1" else: check = "" _offset_ = check + _offset_[-6:].zfill(6) elif sel != -1: _offset_ = self.OFFSETS.GetString(sel)[2:] else: return ##copy table LengthOfOneEntry = int( Globals.INI.get(Globals.OpenRomID, "LengthOfOneEntry"), 0) EvolutionTable = int( Globals.INI.get(Globals.OpenRomID, "EvolutionTable"), 0) numberofpokes = int( Globals.INI.get(Globals.OpenRomID, "numberofpokes"), 0) readlength = EvolutionsPerPoke * LengthOfOneEntry * numberofpokes with open(Globals.OpenRomName, "r+b") as rom: rom.seek(EvolutionTable) entiretable = rom.read(readlength) table = [] if new_number < EvolutionsPerPoke: while entiretable != "": split = entiretable[:LengthOfOneEntry * EvolutionsPerPoke] split = split[:new_number * LengthOfOneEntry] table.append(split) entiretable = entiretable[LengthOfOneEntry * EvolutionsPerPoke:] else: while entiretable != "": split = entiretable[:LengthOfOneEntry * EvolutionsPerPoke] split += "\x00" * (LengthOfOneEntry) * (new_number - EvolutionsPerPoke) table.append(split) entiretable = entiretable[LengthOfOneEntry * EvolutionsPerPoke:] int_offset = int(_offset_, 16) rom.seek(int_offset) for entry in table: rom.write(entry) ##write new pointers. EvolutionTablePointers = [] list_pointers = Globals.INI.get(Globals.OpenRomID, "EvolutionTablePointers").split(",") for offset in list_pointers: EvolutionTablePointers.append(int(offset, 0)) _offset_ = int(_offset_, 16) + 0x8000000 _offset_ = hex(_offset_).lstrip("0x").rstrip("L").zfill(8) pointer = make_pointer(_offset_) pointer = get_hex_from_string(pointer) with open(Globals.OpenRomName, "r+b") as rom: for offset in EvolutionTablePointers: rom.seek(offset) rom.write(pointer) ##Ammend the ini _offset_ = int(_offset_, 16) - 0x8000000 _offset_ = hex(_offset_).rstrip("L") Globals.INI.set(Globals.OpenRomID, "EvolutionTable", _offset_) Globals.INI.set(Globals.OpenRomID, "EvolutionsPerPoke", str(new_number)) with open("PokeRoms.ini", "w") as PokeRomsIni: Globals.INI.write(PokeRomsIni) ##fill table with FF with open(Globals.OpenRomName, "r+b") as rom: rom.seek(EvolutionTable) for n in range(readlength): rom.write("\xFF") ##Adjust the rom for the new table change1 = [] #-> lsl r0, r6, #0x1 (70 00) tmp = Globals.INI.get(Globals.OpenRomID, "OffsetsToChangeTolslr0r60x1").split(",") for offset in tmp: change1.append(int(offset, 0)) if new_number == 4: write = "3000" elif new_number == 8: write = "7000" elif new_number == 16: write = "B000" elif new_number == 32: write = "F000" else: write = "F019" change1write = unhexlify(write) with open(Globals.OpenRomName, "r+b") as rom: for offset in change1: rom.seek(offset, 0) rom.write(change1write) change2 = [] #04 -> 07 tmp = Globals.INI.get(Globals.OpenRomID, "OffsetsToChangeToNewMinus1").split(",") for offset in tmp: change2.append(int(offset, 0)) change2write = get_hex_from_string(str(hex(new_number - 1)[2:])) with open(Globals.OpenRomName, "r+b") as rom: for offset in change2: rom.seek(offset, 0) rom.write(change2write) TheShedinjaFix = int( Globals.INI.get(Globals.OpenRomID, "LengthOfOneEntry"), 0) code = Globals.INI.get(Globals.OpenRomID, "gamecode") if code != "AXVE" and code != "AXPE": if new_number == 4: write = "0000" elif new_number == 8: write = "4000" elif new_number == 16: write = "8000" elif new_number == 32: write = "C000" else: write = "5044" else: if new_number == 4: write = "B90089460000" elif new_number == 8: write = "F90089460000" elif new_number == 16: write = "390189460000" elif new_number == 32: write = "790189460000" else: write = "B9008946C819" TheShedinjaFixWrite = unhexlify(write) with open(Globals.OpenRomName, "r+b") as rom: rom.seek(TheShedinjaFix, 0) rom.write(TheShedinjaFixWrite) change3 = [] tmp = Globals.INI.get(Globals.OpenRomID, "ChangeToNewNumberTimes8").split(",") for offset in tmp: change3.append(int(offset, 0)) change3write = get_hex_from_string(str(hex(new_number * 8)[2:])) with open(Globals.OpenRomName, "r+b") as rom: for offset in change3: rom.seek(offset, 0) rom.write(change3write) ##Tell the user it worked, close, and reload data. #Small fix for some weird bytes that get written. Shhh, don't tell anyone..... rom.seek(8) rom.write("\x69\x9A") self.OnClose() DONE = wx.MessageDialog( None, "Table has been moved, ini has been ammended,\nand evolutions have been changed.:)\n\n\nReloading 'MON Data.", "Done!", wx.OK) DONE.ShowModal() self.frame.tabbed_area.PokeDataTab.tabbed_area.reload_tab_data()