diff options
author | Pixel <pixel@nobis-crew.org> | 2009-10-14 08:03:19 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2009-10-14 08:03:19 -0700 |
commit | e94c37a627ccd242f63bb08fdb99039c2af58289 (patch) | |
tree | 391a3efe42055ba95d324117a8827fd1ac5022a9 /VP-miscwork.lua |
Initial import.
Diffstat (limited to 'VP-miscwork.lua')
-rw-r--r-- | VP-miscwork.lua | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/VP-miscwork.lua b/VP-miscwork.lua new file mode 100644 index 0000000..31f7e92 --- /dev/null +++ b/VP-miscwork.lua @@ -0,0 +1,59 @@ +function process_arcgfx(fname, h, size, ext) + log("Processing " .. fname .. "." .. ext) + if dump_mode then + o = Output(fname .. "." .. ext) + o:copyfrom(h, size) + o:destroy() + h:seek(-size, SEEK_CUR) + end + log("Extracting " .. fname .. " - format 'arcgfx'") + dump_mkdir(fname) + local nfiles = h:readU32() + local extra = h:readU32() + local ret + if dump_mode then + o = Output(fname .. "/--extra.bin") + o:writeU32(extra) + o:destroy() + o = Output(fname .. string.format("/0000-%08X", extra)) + o:writeU32(extra) + o:destroy() + else + ret = Buffer(true) + ret:writeU32(nfiles) + ret:writeU32(extra) + end + + index = {} + for i = 1, nfiles do + index[i] = {} + index[i].extra = h:readU32() + index[i].size = h:readU32() + end + + local tell + local outfile = {} + for i = 1, nfiles do + tell = h:tell() + outfile[i] = process_single_file(fname .. string.format("/%04i-%08X", i, index[i].extra), h, index[i].size, ext) + h:seek(tell + index[i].size) + end + + if not dump_mode then + for i = 1, nfiles do + local alignment_bytes = alignment(outfile[i]:getsize(), 4) + for j = 1, alignment_bytes do + outfile[i]:writeU8(0) + end + ret:writeU32(index[i].extra) + ret:writeU32(outfile[i]:getsize()) + end + for i = 1, nfiles do + ret:copyfrom(outfile[i]) + outfile[i]:destroy() + end + end + +-- return ret +end + |