Guest User

PGEinidump

a guest
Apr 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sys
  4. import argparse
  5.  
  6. # Parse arguments
  7. parser = argparse.ArgumentParser()
  8. parser.add_argument('--romfile', metavar='file',
  9. help='ROM to read', default='test.gba')
  10. parser.add_argument('--oldini', metavar='file',
  11. help='Old INI to change', default='roms.ini')
  12. parser.add_argument('--newini', metavar='file',
  13. help='New INI to use', default='test.ini')
  14. args = parser.parse_args()
  15.  
  16. def getpointer(rom,offset):
  17. rom.seek(offset)
  18. byte=rom.read(3);
  19. rom.seek(offset+3);
  20. page=rom.read(1);
  21. p=page[0]-8;
  22. byte+=bytes(p.to_bytes(1,'little'));
  23. ps=''.join(format(x, '02x') for x in reversed(byte))
  24. return (ps.upper()+'\n')
  25.  
  26. #The variables named table below are actually a dictionary structure
  27. table={}
  28. table['AbilityNames']=0x1C0
  29. table['AbilityDescriptionTable']=0x1C4
  30. table['AttackNames']=0x148
  31. table['AttackDescriptionTable']=0x1C3EFC
  32. table['AttackData']=0x1CC
  33. table['AttackAnimationTable']=0xA3A44
  34. table['ContestMoveData']=0xD85F0
  35. table['PokemonAttackTable']=0x06930C
  36.  
  37. table2={}
  38. table2['NumberOfAttacks']=1024
  39. table2['NumberOfAbilities']=256
  40.  
  41.  
  42. with open(args.romfile, 'rb+') as rom:
  43. #Get ability name pointer
  44. wflag=0
  45. with open(args.oldini, 'r') as oldlines:
  46. fout=open(args.newini, 'w')
  47. for line in oldlines:
  48. if wflag is 1:
  49. for key in table.keys():
  50. if line.strip().startswith(str(key)):
  51. line=str(key)+'='+getpointer(rom,table[key])
  52. for key in table2.keys():
  53. if line.strip().startswith(str(key)):
  54. line=str(key)+'='+str(table2[key])+'\n'
  55. if line.strip().startswith('[BPEE]'):
  56. wflag=1
  57. if line.strip().startswith('[AXVF]'):
  58. wflag=0
  59. fout.write(line)
  60. if line.strip().startswith('PokedexTypeTable'):
  61. if wflag is 1:
  62. fout.write('MoveTableHack=True\n')
Add Comment
Please, Sign In to add comment