summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VP-map.lua1
-rw-r--r--VP-roomwork.lua99
2 files changed, 92 insertions, 8 deletions
diff --git a/VP-map.lua b/VP-map.lua
index df096b9..e3fa3c2 100644
--- a/VP-map.lua
+++ b/VP-map.lua
@@ -66,6 +66,7 @@ VP_map = {
[ 3] = { dir = "MISC", ext = "txt" },
[ 4] = { dir = "MAIN/SOUNDS", ext = "wag" },
[ 5] = { dir = "MAIN/GFX" },
+ [ 6] = { dir = "MAIN/MISC", ext = "main", ftype = "arcroom" },
[ 618] = { dir = "SOUNDS/MISC", ext = "wag" },
[1021] = { dir = "SOUNDS/MISC", ext = "wag" },
diff --git a/VP-roomwork.lua b/VP-roomwork.lua
index d1eabfe..ac0a958 100644
--- a/VP-roomwork.lua
+++ b/VP-roomwork.lua
@@ -120,7 +120,7 @@ function process_arcroom(fname, h, size, ext)
o:destroy()
h:seek(-size, SEEK_CUR)
end
- log("Processing " .. fname .. " - format 'arcroom'")
+ log("Processing " .. fname .. " - format 'arcroom' - " .. ext)
dump_mkdir(fname)
local nfiles = h:readU32()
@@ -157,23 +157,23 @@ function process_arcroom(fname, h, size, ext)
tell = h:tell()
local handler = nil
local counter = 1
- if dump_mode and index[i].ftype == 4 then
+ if dump_mode and ext == "room" and index[i].ftype == 4 then
log("Preparing to dump script...")
- script = Buffer(true)
- font = Buffer(true)
handler = function(fname, h, size, ext)
if counter == 1 then
log("Taking script...")
+ script = Buffer(true)
script:copyfrom(h)
elseif counter == 2 then
log("Taking font...")
+ font = Buffer(true)
font:copyfrom(h)
else
error("Too many files.")
end
counter = counter + 1
end
- elseif index[i].ftype == 4 and script and font then
+ elseif not dump_mode and ext == "room" and index[i].ftype == 4 and script and font then
old_script = Buffer(true)
handler = function(fname, h, size, ext)
local ret
@@ -190,15 +190,46 @@ function process_arcroom(fname, h, size, ext)
counter = counter + 1
return ret
end
+ elseif dump_mode and ext == "main" and index[i].ftype == 4 then
+ if script then error "Can't have two scripts in these..." end
+ handler = function(fname, h, size, ext)
+ if counter == 1 then
+ log("Taking text...")
+ script = Buffer(true)
+ script:copyfrom(h)
+ else
+ error("Too many files")
+ end
+ counter = counter + 1
+ end
+ elseif dump_mode and ext == "main" and index[i].ftype == 7 then
+ if font then error "Can't have two fonts in these..." 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 ext == "main" and index[i].ftype == 4 then
+ error "Not written yet"
+ elseif not dump_mode and ext == "main" and index[i].ftype == 7 then
+ error "Not written yet"
end
outfile[i] = process_single_file(fname .. string.format("/%04i-%08X", i, index[i].ftype), h, index[i].size, "room", handler)
- if handler then
- if counter ~= 3 then error("Didn't get enough files; got " .. (counter - 1) .. " instead of 2.") end
- if dump_mode then
+ if handler and script and font then
+ if dump_mode and counter == 3 then
extract_room_script(fname .. string.format("/%04i", i), script, font)
+ else
+ 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
@@ -497,3 +528,55 @@ function extract_room_script(fname, script, font)
o:destroy()
end
+
+function extract_simple_script(fname, script, font)
+ log("Processing script " .. fname)
+ dump_mkdir(fname)
+ local font = extract_font(fname .. "/FONT", font)
+ local lookup = resolve_font(font)
+ local n_ptrs = 1
+ local script_begin = script:readU32()
+
+ local ptrs = {}
+ local unks = {}
+ local ptr_start = 1
+ local tell = script:tell()
+
+ while tell < script_begin do
+ unks[n_ptrs] = script:readU32()
+ ptrs[n_ptrs] = script:readU32()
+ tell = script:tell()
+ n_ptrs = n_ptrs + 1
+ end
+ ptrs[n_ptrs] = script:getsize() - script_begin
+ n_ptrs = n_ptrs - 1
+
+ local ptrs_contents, ptrs_raws = {}, {}
+ ptr_start = 1
+ for i = ptr_start, n_ptrs do
+ ptrs_contents[i] = ""
+ ptrs_raws[i] = ""
+
+-- if tell + ptrs[i] ~= script:tell() then print("Script consistancy failure for pointer " .. i .. " - we're at " .. script:tell() .. " and " .. (tell + ptrs[i]) .. " was expected.") end
+
+ script:seek(script_begin + ptrs[i])
+ while script:tell() ~= (script_begin + ptrs[i + 1]) do
+ local r, rr = extract_char(script, lookup)
+ if r then
+ ptrs_contents[i] = ptrs_contents[i] .. r
+ ptrs_raws[i] = ptrs_raws[i] .. rr
+ elseif script:tell() ~= (script_begin + ptrs[i + 1]) then
+ ptrs_contents[i] = ptrs_contents[i] .. "<ZERO>"
+ end
+ end
+ end
+
+ local o = Output(fname .. "-script.txt")
+ for i = ptr_start, n_ptrs do
+ o:write("<ptr " .. i .. " - " .. unks[i] .. ">\n")
+ o:write(ptrs_contents[i])
+ o:write("\n")
+ end
+
+ o:destroy()
+end