import struct, re
data = open(r'C:\git\bt411\content\BTL4.RES', 'rb').read()
labOnly, maxID = struct.unpack_from('<ii', data, 4)
offs = struct.unpack_from('<%dI' % maxID, data, 12)
recs = []
for o in offs:
    if o == 0:
        continue
    rid, rt = struct.unpack_from('<ii', data, o)
    nm = data[o + 8:o + 40].split(b'\0')[0].decode('ascii', 'replace')
    recs.append((o, rid, rt, nm))
recs.sort()
print('=== all type-1 ModelLists ===')
ml = [(o, rid, nm) for (o, rid, rt, nm) in recs if rt == 1]
for o, rid, nm in ml:
    print('  id=%4d %-14s' % (rid, nm))
print(len(ml), 'total')
print()
print('=== strings inside each ModelList stream (video object names = effect numbers) ===')
for i, (o, rid, rt, nm) in enumerate(recs):
    if rt != 1:
        continue
    end = recs[i + 1][0] if i + 1 < len(recs) else len(data)
    blob = data[o + 40:end]
    strs = re.findall(rb'[ -~]{1,12}', blob)
    toks = [s.decode() for s in strs if s.strip()]
    print('  id=%4d %-12s -> %s' % (rid, nm, toks[:10]))
