diff options
Diffstat (limited to 'parse-brlyt.py')
| -rw-r--r-- | parse-brlyt.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/parse-brlyt.py b/parse-brlyt.py index c737970..ea998ca 100644 --- a/parse-brlyt.py +++ b/parse-brlyt.py @@ -6,8 +6,11 @@ rlyt = f.read() f.close() assert rlyt[0:8] == 'RLYT\xfe\xff\x00\x08' -offs, = struct.unpack('>h', rlyt[0xc:0xe]) +offs, nel = struct.unpack('>hh', rlyt[0xc:0x10]) ch = iff_to_chunks(rlyt[offs:]) + +assert len(ch) == nel + indent = 0 for typ, chunk in ch: print ' ' * indent + typ + ' ' + hex(len(chunk)) @@ -17,13 +20,15 @@ for typ, chunk in ch: assert chunk[:pos] == unparse_data(vars, 'pane') # for testing if typ == 'txt1': vars2, pos = parse_data(chunk[pos:], 'text', '~text') - - txt = chunk[vars2['~text.name_offs'] - 8:] + os = vars2['~text.name_offs'] - 8 + txt = chunk[os:os + vars2['~text.len2']] vars2['~text.text'] = unicode(txt, 'utf_16_be').rstrip('\x00') + vars2['~text.material'] = materials[vars2['~text.mat_off']] vars.update(vars2) + #print vars['~text.cnt2'], len(vars2['~text.text']), len(txt), repr(txt) elif typ == 'pic1': vars2, pos = parse_data(chunk, 'pic', prefix='~pic', start=pos) - + vars2['~pic.material'] = materials[vars2['~pic.mat_off']] vars2['~pic.texcoords'] = [] for n in xrange(vars2['~pic.num_texcoords']): vars2['~pic.texcoords'].append(struct.unpack('>ffffffff', chunk[pos:pos+0x20])) @@ -51,6 +56,7 @@ for typ, chunk in ch: else: offset, unk = struct.unpack('>II', chunk[pos:pos+8]) pos += 8 + name = nullterm(chunk[offset - 8:]) vars[things].append(name if typ == 'mat1' else {'name': name, 'unk': unk}) if typ == 'mat1': @@ -60,6 +66,7 @@ for typ, chunk in ch: elif typ in ('gre1', 'pae1'): indent -= 1 else: + print 'Unhandled type %s' % typ print repr(chunk) if vars: pr_dict(vars, ' ' * indent + ' ') #print hex(len(ch)) |
