Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from operator import itemgetter
- import struct
- def portHabitats(rom, pokemon, text) :
- freespace = 0xF001A0
- i = 0
- category = 0
- while i < len(text) :
- line = text[i].split(',')
- numpages = int(line[1])
- print(numpages)
- page = 0
- categoryaddr = freespace
- freespace += (0x8 * numpages)
- rom.seek(0x452C4C + (category * 0x8), 0)
- rom.write((0x8000000 + categoryaddr).to_bytes(4, 'little'))
- rom.write(numpages.to_bytes(4, 'little'))
- while page < numpages :
- page += 1
- i += 1
- line = text[i].split(',')
- numpokes = 0
- rom.seek(freespace, 0)
- j = 0
- while j < len(line) :
- if line[j] != '' :
- rom.write(pokemon.index(line[j]).to_bytes(2, 'little'))
- numpokes += 1
- j += 1
- rom.seek(categoryaddr, 0)
- rom.write((0x8000000 + freespace).to_bytes(4, 'little'))
- rom.write(numpokes.to_bytes(4, 'little'))
- categoryaddr += 0x8
- freespace += 0x8
- i += 1
- category += 1
- romname = "yafrh.gba"
- pokemon = []
- moves = []
- csv = []
- with open("pokemon.txt", 'r') as f :
- s = f.read()
- badpokemon = s.split("\n")
- for p in badpokemon :
- pokemon += [p.strip()]
- with open("Yafrh Data - Habitats.csv", 'r') as file :
- csv = file.read()
- csv = csv.split('\n')
- with open(romname, 'r+b') as file :
- portHabitats(file, pokemon, csv)
Add Comment
Please, Sign In to add comment