perfect_dark/tools/mktextures

38 lines
745 B
Python
Executable File

#!/usr/bin/env python3
import os
import sys
sys.path.append('src/assets/%s/textures' % os.environ['ROMID'])
from textures import textures
fdd = open('build/%s/assets/texturesdata.bin' % os.environ['ROMID'], 'wb')
fdl = open('build/%s/assets/textureslist.bin' % os.environ['ROMID'], 'wb')
offset = 0
for row in textures:
name = row[0]
flags = row[1]
filename = 'src/assets/%s/textures/%s' % (os.environ['ROMID'], name);
fd = open(filename, 'rb')
data = fd.read()
fd.close()
length = len(data)
fdl.write(flags.to_bytes(1, 'big'))
fdl.write(offset.to_bytes(3, 'big'))
fdl.seek(4, os.SEEK_CUR)
fdd.write(data)
offset += length
fdl.write(offset.to_bytes(4, 'big'))
fdl.close()
fdd.close()