Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Final Fantasy VIII battle stage camera pointers dumper- use for reverse engineering and/or camera modding
import sys
import struct
_5d4 = [4,5,9,12,13,14,15,21,22,23,24,26, 29,32,33,34,35,36,39,40,50,53,55,61,62,63,64,65,66,67,68,69,70, 71,72,73,75,78,82,83,85,86,87,88,89,90,91,94,96,97,98,99,100,105, 106,121,122,123,124,125,126,127,135,138,141,144,145,148,149,150,151,158,160]
_5d8 = [0,1,2,3,6,7,10,11,17,18,25,27,28,38,41,42,43,47,49,57,58,59,60,74,76,77,80,81,84,93,95,101,102,103,104,109,110,111,112,113,114,115,116,117,118,119,120,128,129,130,131,132,133,134,139,140,143,146,152,153,154,155,156,159,161,162]
fd = open(sys.argv[1], 'rb')
stageid = int(sys.argv[1][5:8])
if stageid in _5d4:
fd.seek(0x5d4, 0)
if stageid in _5d8:
fd.seek(0x5d8, 0)
if stageid in [8,48,79]:
fd.seek(0x618,0)
if stageid in [16]:
fd.seek(0x628,0)
if stageid in [19]:
fd.seek(0x644,0)
if stageid in [20]:
fd.seek(0x61c,0)
if stageid in [30,31]:
fd.seek(0x934,0)
if stageid in [37]:
fd.seek(0xcc0,0)
if stageid in [44,45,46]:
fd.seek(0x9A4,0)
if stageid in [51,52,107,108]:
fd.seek(0x600,0)
if stageid in [54,56]:
fd.seek(0x620,0)
if stageid in [92]:
fd.seek(0x83c,0)
if stageid in [136]:
fd.seek(0x5fc,0)
if stageid in [137]:
fd.seek(0xFDC,0)
if stageid in [142]:
fd.seek(0x183C,0)
if stageid in [147]:
fd.seek(0xA0C,0)
if stageid in [157]:
fd.seek(0x638,0)
if struct.unpack('H', fd.read(2))[0] != 0x2:
print('something wrong... there\'s no 0x02 00 at given position')
exit(-1)
fd.seek(2, 1)
fd.seek(struct.unpack('H', fd.read(2))[0]-6, 1)
loc001 = struct.unpack('H', fd.read(2))[0]
loc001_pos = fd.tell()-2
loc001_pointers = []
loc002_pointers = []
for i in range(0,loc001):
loc001_pointers += [struct.unpack('H', fd.read(2))[0]]
for i in range(0,len(loc001_pointers)):
loc002_b = []
fd.seek(loc001_pos + loc001_pointers[i], 0)
for n in range(0, 8):
loc002_b += [struct.unpack('H', fd.read(2))[0]]
loc002_pointers += [loc002_b]
print('Available camera collections: %i. It\'s located at: %i.\n' % (loc001, loc001_pos))
for i in range (0,loc001):
print('Camera collection: %i\tOffset: 0x%04X (0x%04X)' % (i, loc001_pointers[i], loc001_pointers[i]+loc001_pos))
loc002_b = loc002_pointers[i]
for n in range(0,8):
fd.seek(loc001_pos+loc001_pointers[i] + loc002_b[n]*2, 0)
localvar = struct.unpack('>I', fd.read(4))[0]
print('\t\t| Animation: %i Offset: 0x%04X (0x%04X) -> %08X' % (n, loc002_b[n], fd.tell()-4, localvar ))
print('')
fd.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.