diff options
Diffstat (limited to 'VP-miscwork.lua')
-rw-r--r-- | VP-miscwork.lua | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/VP-miscwork.lua b/VP-miscwork.lua index 31f7e92..cb111f3 100644 --- a/VP-miscwork.lua +++ b/VP-miscwork.lua @@ -31,11 +31,54 @@ function process_arcgfx(fname, h, size, ext) index[i].size = h:readU32() end - local tell local outfile = {} + local script = nil + local font = nil 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) + local tell = h:tell() + local handler = nil + local counter = 1 + local f1 = andB(index[i].extra, 0xffffff00) + if dump_mode and f1 == 0x00300900 then + if script then error "Can't have two scripts" end + handler = function(fname, h, size, ext) + if counter == 1 then + log "taking script" + script = Buffer(true) + script:copyfrom(h) + else + error "Too many files" + end + counter = counter + 1 + end + elseif dump_mode and f1 == 0x00300800 then + if font then error "Can't have two fonts" end + handler = function(fname, h, size, ext) + if counter == 1 then + log "taking font" + font = Buffer(true) + font:copyfrom(h) + else + error "Too many files" + end + counter = counter + 1 + end + elseif not dump_mode and f1 == 0x00300900 then + error "Not written yet" + elseif not dump_mode and f1 == 0x00300800 then + error "Not written yet" + end + outfile[i] = process_single_file(fname .. string.format("/%04i-%08X", i, index[i].extra), h, index[i].size, ext, handler) + + if handler and script and font then + if dump_mode then + extract_simple_script(fname .. string.format("/%04i", i), script, font) + end + script:destroy() + font:destroy() + script = nil + font = nil + end h:seek(tell + index[i].size) end |