Offset | Size | Description |
0 | char[4] | MAGIC- "SSAM" |
4 | uint | Entries count |
8 + (EntryID*40) | 40 bytes | Entry |
8 + (EntriesCount*40) | Varies | FILE_data |
Offset | Size | Description |
0 | uint | File Pointer + (EntryCount*40+8) |
4 | uint | File size |
8 | char[32] | File name |
# Final Fantasy IV - .DAT Container unpacker 0.1
# By MaKiPL 21-06-2017
# Python 2.7
import struct
import os.path
mypath = r'FILEPATHHERE' #TYPE FILE PATH
f = open(mypath, 'r+b')
magic = f.read(4)
if magic!= 'SSAM':
print('This is not FFIV DAT container file!')
exit
count = struct.unpack('<I', f.read(4))[0]
pointers = [0]
sizes = [0]
names = ['0']
_index = 0
while _index < count:
pointers[_index] = struct.unpack('<I', f.read(4))[0]
sizes[_index] = struct.unpack('<I', f.read(4))[0]
names[_index] = f.read(32)
print(pointers[_index])
print(sizes[_index])
print(names[_index])
pointers.append(0)
sizes.append(0)
names.append('0')
_index += 1
relativeFiles = count*40+8
OutputDir = os.path.dirname(mypath) + '\\' + os.path.basename(mypath)
if not os.path.exists(OutputDir[:-4] + 'dec'):
os.mkdir(OutputDir[:-4] + 'dec')
_index = 0
while _index < count:
f.seek(relativeFiles+pointers[_index], 0)
buff = f.read(sizes[_index])
temppath = OutputDir[:-4] + 'dec\\' + names[_index]
if os.path.exists(temppath):
os.remove(temppath)
ff = open(temppath, 'w+b')
ff.write(buff)
ff.close()
_index += 1
f.close()
# Final Fantasy IV - .DAT Container unpacker 0.2
# By MaKiPL 21-06-2017
# Python 2.7
import struct
import os.path
mypath = r'D:\FINAL FANTASY IV\EXTRACTED_DATA\files\STAGEMNG_f00.dat' #TYPE FILE PATH
f = open(mypath, 'r+b')
magic = f.read(4)
if magic!= 'SSAM':
print('This is not FFIV DAT container file!')
exit
count = struct.unpack('<I', f.read(4))[0]
pointers = [0]
sizes = [0]
names = ['0']
_index = 0
while _index < count:
pointers[_index] = struct.unpack('<I', f.read(4))[0]
sizes[_index] = struct.unpack('<I', f.read(4))[0]
names[_index] = f.read(32).rstrip('\0')
print(pointers[_index])
print(sizes[_index])
print(names[_index])
pointers.append(0)
sizes.append(0)
names.append('0')
_index += 1
relativeFiles = count*40+8
OutputDir = os.path.dirname(mypath) + '\\' + os.path.basename(mypath)
if not os.path.exists(OutputDir[:-4] + 'dec'):
os.mkdir(OutputDir[:-4] + 'dec')
_index = 0
while _index < count:
f.seek(relativeFiles+pointers[_index], 0)
buff = f.read(sizes[_index])
temppath = OutputDir[:-4] + 'dec\\' + names[_index]
if os.path.exists(temppath):
os.remove(temppath)
ff = open(temppath, 'w+b')
ff.write(buff)
ff.close()
_index += 1
f.close()
>>> python.exe _ffiv.py
File "<stdin>", line 1
python.exe _ffiv.py
^
SyntaxError: invalid syntax
So I've setup Python and I can see that it works when I use cmd and type python I get the >>>
From there I use python.exe _ffiv.py and I get this error message:Code: [Select]>>> python.exe _ffiv.py
File "<stdin>", line 1
python.exe _ffiv.py
^
SyntaxError: invalid syntax
I changed your filepath so it matches mine. Am I missing something?
It works!
How can I test the LZ77Decompress you posted, Maki. Or should I wait for your C Version?
Sorry, I'm a noob when it comes down to such things. ^^
I tried it and you guess: Epic fail (or almost)...
At least I could decompress the dat's, that worked. The files in the folder can't be decompressed though. It says "Not LZ77 compressed file; Header is wrong!"