SHARE
TWEET

[FFVIII - dev] BS header analyze/dumper

MaKiPL Sep 22nd, 2015 (edited) 116 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2. import binascii
  3. '''
  4. 'Python 3.5
  5. 'Final Fantasy VIII Battle stages header analyzer
  6. 'Outputs all 163 battle stages first four bytes to test the unknown
  7. '   first 0x5d4 data section
  8. 'Made by MaKiPL (forums.qhimm.com) - makipol@gmail.com
  9. 'version 0.65 (update: 09-10-2015)
  10. '
  11. '09-10-2015:
  12. 'Added more readable data output with grouping based on byte array
  13. '
  14. '
  15. '''
  16.  
  17. a = 0 #INDEX
  18.  
  19.  
  20. #CONFIG
  21. end = 163 #Change to set file test range
  22. seek = 0x5d4 #Change to test four bytes at specific address
  23. out = 'out.txt' #Change to output to other file
  24. byte = 16 #Change to test more or less than four bytes
  25.  
  26. test1= b'02000800'
  27. test2= b'0000000002000800'
  28. #END OF CONFIG
  29.  
  30.  
  31. OUT1 = "=======5D4=========\n"
  32. OUT2 = "=======5D8=========\n"
  33. OUTER = "=======OUT=========\n"
  34.  
  35.  
  36. def buildpath(a):
  37.     if a > 9 and a < 100:
  38.         return '0' + str(a)
  39.     elif a <= 9:
  40.         return '00' + str(a)
  41.     elif a > 99:
  42.         return str(a)
  43.  
  44. def Append(d):
  45.         global OUT1
  46.         global OUT2
  47.         global OUTER
  48.         if (d.startswith(test1)):
  49.                 OUT1 += str(a) + '\t' + str(d)[2:len(d)-1] + '\n'
  50.         elif (d.startswith(test2)):
  51.                 OUT2 += str(a) + '\t' + str(d)[2:len(d)-1] + '\n'
  52.         else:
  53.                 OUTER += str(a) + '\t' + str(d)[2:len(d)-1] + '\n'
  54.        
  55. w = open(out, 'a')
  56.  
  57.  
  58. while a != end:
  59.         f = open('a0stg' + buildpath(a) + '.x', 'rb')
  60.         print(f)
  61.         f.seek(seek)
  62.         c = f.read(byte)
  63.         d = binascii.hexlify(bytearray(c))
  64.         Append(d)
  65.         a += 1
  66.         f.close()
  67.  
  68. w.write(OUT1)
  69. w.write(OUT2)
  70. w.write(OUTER)
  71. w.close()
  72.  
  73. #EOF
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top