Skip to content

Instantly share code, notes, and snippets.

@feisuzhu
Created April 30, 2013 08:03
Show Gist options
  • Save feisuzhu/5487274 to your computer and use it in GitHub Desktop.
Save feisuzhu/5487274 to your computer and use it in GitHub Desktop.
Arkanoid TVI 'Isles.dat' extractor
import re
import struct
import zlib
import os
def ensure_dir(f):
d = os.path.dirname(f)
if not os.path.exists(d):
os.makedirs(d)
data = open('Isles.dat').read()
locations = [m.start() - 3 for m in re.finditer('\x00\xa0\x20\x14\x00', data)]
for loc in locations:
fnloc, tag, data_till, _ = struct.unpack('<LLLL', data[loc:loc+16])
assert tag == 0x1420a0
fn = data[fnloc:fnloc+30].split('\x00')[0].replace('\\', '/')
print fn
data_start = fnloc + len(fn) + 1
compressed = data[data_start:data_till-1]
content = zlib.decompress(compressed)
ensure_dir(fn)
open(fn, 'wb').write(content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment