############################## # Interprete the Pokemon output_pkmns = "" output_pkmns += ".include \"source/macros_asm.s\"\n\n" if format == 0: # normal trainer pkmn output_pkmns += "@ ?, Level, Pkmn, AltForm, PokeballSeal\n" elif format == 1: # unnormal trainer pkmn output_pkmns += "@ ?, Level, Pkmn, AltForm, Move1, Move2, Move3, Move4, PokeballSeal\n" elif format == 2: # unnormal trainer pkmn output_pkmns += "@ ?, Level, Pkmn, AltForm, Item, PokeballSeal\n" elif format == 3: # unnormal trainer pkmn output_pkmns += "@ ?, Level, Pkmn, AltForm, Item, Move1, Move2, Move3, Move4, PokeballSeal\n" if format == 0: # normal trainer pkmn i = 0 while i < (file_pkmns.GetFileSize()/8): unknown1 = file_pkmns.ReadHWord(0+i*8) level = file_pkmns.ReadHWord(2+i*8) species = file_pkmns.ReadHWord(4+i*8) species_altform = (species>>10) & 0x3f if species_altform > 0: print("altform in '" + str(filename_trainer)) species = species & 0x3ff unknown2 = file_pkmns.ReadHWord(6+i*8) output_pkmns += "trainerpoke0 " + str(unknown1) + ", " + str(level) + ", " + str(GetPokemonName(species)) + ", " + str(species_altform) + ", " + str(unknown2) + "\n" i += 1 elif format == 1: # unnormal trainer pkmn i = 0 while i < (file_pkmns.GetFileSize()/16): unknown1 = file_pkmns.ReadHWord(0+i*16)
i += 1 input_file.init(os.path.join(conf.path, filename), 0) output_trainers = "" output_trainers += ".include \"source/macros_asm.s\"\n\n" if format == 1: output_trainers += "@ Pkmn, Move1, Move2, Move3, Move4, EVs, Nature, Item, ?, ?\n" elif format == 3: output_trainers += "@ BTrainer\n" else: output_trainers += "@ ?, ?, Level, ?, Pkmn, ?, ?\n" if format == 0: # normal trainer pkmn i = 0 while i < (input_file.GetFileSize() / 8): unknown1 = input_file.ReadByte(0 + i * 8) unknown2 = input_file.ReadByte(1 + i * 8) level = input_file.ReadByte(2 + i * 8) unknown3 = input_file.ReadByte(3 + i * 8) species = input_file.ReadHWord(4 + i * 8) unknown4 = input_file.ReadByte(6 + i * 8) unknown5 = input_file.ReadByte(7 + i * 8) output_trainers += "trainerpoke " + str(unknown1) + ", " + str( unknown2) + ", " + str( level) + ", " + str(unknown3) + ", " + str( GetPokemonName(species)) + ", " + str( unknown4) + ", " + str(unknown5) + "\n" i += 1 elif format == 1: # battle tower pkmn
def diagnose(self, filename="baserom.nds", filedir="", outfile="", outFileList="", export=0, debug=False): rom = FileHandler() base_address = 0x0 rom.init(filename, base_address) header_output = "" header_output += rom.GetFileName() + "\n" header_output += "FileSize: " + hex(rom.GetFileSize()) + "\n" header_output += "\nGame Code: " + str(rom.ReadString( 0x0, 0x4)) header_output += "\nMaker Code: " + str(rom.ReadString( 0x4, 0x2)) header_output += "\nDVD Magic Word: 0x" + str( rom.ReadHexString(0x1c, 0x4)) header_output += "\nGame Name: " + str( rom.ReadString(0x20, 0x3e0)) if export: rom.WriteSectionInFile(filedir + "boot.bin", 0x0, 0x440) addRomSection("/boot.bin", 0x0, 0x440) if export: rom.WriteSectionInFile(filedir + "bi2.bin", 0x440, 0x2000) addRomSection("/bi2.bin", 0x440, 0x2000) apploader_entry = rom.ReadWord(0x2440 + 0x10) header_output += "\nApploader Entrypoint: " + hex(apploader_entry) appsize = rom.ReadWord(0x2440 + 0x14) # Apploader Size appsize += rom.ReadWord(0x2440 + 0x18) # Trailer Size append = alignAdr(0x2440 + appsize, 0x100) if export: rom.WriteSectionInFile(filedir + "appldr.bin", 0x2440, appsize) addRomSection("/appldr.bin", 0x2440, append - 0x2440) fst_offset = rom.ReadWord(base_address + 0x0 + 0x424) fst_size = rom.ReadWord(base_address + 0x0 + 0x428) if export: rom.WriteSectionInFile(filedir + "fst.bin", fst_offset, fst_size) addRomSection("/fst.bin", fst_offset, fst_size) #addRomSection("dh.bin", rom.ReadWord(base_address+0x0+0x400), 1) dol = DolFS() header_output += dol.diagnose(rom, rom.ReadWord(base_address + 0x0 + 0x420), filedir, export, debug) fs = RomFS() header_output += fs.diagnose(rom, rom.ReadWord(base_address + 0x0 + 0x424), filedir, export, debug) header_output += "\n\n" FileList = getOutputRomMap(rom, filedir, export) + "\n" header_output += FileList header_output += getOutputRomMapFileID() if outFileList != "": outFileList = filedir + outFileList if not os.path.exists(os.path.dirname( outFileList)) and os.path.dirname(outFileList): os.makedirs(os.path.dirname(outFileList)) fFileList = open(outFileList, 'w') fFileList.write(FileList) headerfilename = filedir + outfile if not os.path.exists(os.path.dirname( headerfilename)) and os.path.dirname(headerfilename): os.makedirs(os.path.dirname(headerfilename)) fheader = open(headerfilename, 'w') fheader.write(header_output) output = "" return (output)