From e9f6873c0ebaa4ecfd368a4b3a932f3a63ba374a Mon Sep 17 00:00:00 2001 From: Pixel Date: Thu, 25 Oct 2012 01:45:53 -0700 Subject: Adding preliminary work on non-room scripts (menus ?) --- VP-map.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'VP-map.lua') 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" }, -- cgit v1.2.3 From 911936a303001d2fb2f2e94c7228374656d1b88b Mon Sep 17 00:00:00 2001 From: Pixel Date: Thu, 25 Oct 2012 09:32:15 -0700 Subject: A bit more on the menus. --- VP-map.lua | 7 ++++++- VP-roomwork.lua | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'VP-map.lua') diff --git a/VP-map.lua b/VP-map.lua index e3fa3c2..f18249a 100644 --- a/VP-map.lua +++ b/VP-map.lua @@ -49,6 +49,9 @@ VP_map_spans = { { idx_s = 2096, idx_e = 2097, data = { dir = "SOUNDS/UNKNOWN03", ext = "wag", }, }, { idx_s = 2098, idx_e = 2172, data = { dir = "SOUNDS/VICTORY", ext = "wag", }, }, + + { idx_s = 2175, idx_e = 2186, data = { dir = "MISC/MENUS", ext = "sarc", ftype = "arcroom", }, }, + { idx_s = 2187, idx_e = 2211, data = { dir = "GFX/STATUSPIC" }, }, { idx_s = 2296, idx_e = 2319, data = { dir = "GFX/UNKNOWN06" }, }, { idx_s = 3299, idx_e = 3505, data = { dir = "GFX/FACE" }, }, @@ -66,7 +69,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" }, + [ 6] = { dir = "MAIN/MISC", ext = "sarc", ftype = "arcroom" }, [ 618] = { dir = "SOUNDS/MISC", ext = "wag" }, [1021] = { dir = "SOUNDS/MISC", ext = "wag" }, @@ -88,6 +91,8 @@ VP_map = { [1983] = { dir = "GFX/MAGIC12", ext = "agx", ftype = "arcgfx", }, [1986] = { dir = "GFX/MAGIC13", ext = "agx", ftype = "arcgfx", }, + [2173] = { dir = "MISC/GFX", ext = "agx", ftype = "arcgfx", }, + -- -- Videos -- diff --git a/VP-roomwork.lua b/VP-roomwork.lua index ac0a958..4349ca4 100644 --- a/VP-roomwork.lua +++ b/VP-roomwork.lua @@ -190,7 +190,7 @@ 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 + elseif dump_mode and ext == "sarc" 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 @@ -202,7 +202,7 @@ function process_arcroom(fname, h, size, ext) end counter = counter + 1 end - elseif dump_mode and ext == "main" and index[i].ftype == 7 then + elseif dump_mode and ext == "sarc" 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 @@ -214,9 +214,9 @@ function process_arcroom(fname, h, size, ext) end counter = counter + 1 end - elseif not dump_mode and ext == "main" and index[i].ftype == 4 then + elseif not dump_mode and ext == "sarc" and index[i].ftype == 4 then error "Not written yet" - elseif not dump_mode and ext == "main" and index[i].ftype == 7 then + elseif not dump_mode and ext == "sarc" 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) -- cgit v1.2.3 From 6f37a8a7c34fbbfa62df139bfc904288e319d140 Mon Sep 17 00:00:00 2001 From: Pixel Date: Fri, 26 Oct 2012 09:06:13 -0700 Subject: And still more script types. --- VP-map.lua | 3 +++ VP-miscwork.lua | 30 ++++++++++++++++++++++++++++++ VP-process.lua | 12 +++++------- 3 files changed, 38 insertions(+), 7 deletions(-) (limited to 'VP-map.lua') diff --git a/VP-map.lua b/VP-map.lua index f18249a..795e2e7 100644 --- a/VP-map.lua +++ b/VP-map.lua @@ -4,6 +4,7 @@ VP_maintypes = { "GFX", "MAIN", "GAME", + "MISC", } VP_map = { } @@ -93,6 +94,8 @@ VP_map = { [2173] = { dir = "MISC/GFX", ext = "agx", ftype = "arcgfx", }, + [2294] = { dir = "MISC/SCRIPT", ext = "script", ftype = "cscript", }, + -- -- Videos -- diff --git a/VP-miscwork.lua b/VP-miscwork.lua index cb111f3..1818b30 100644 --- a/VP-miscwork.lua +++ b/VP-miscwork.lua @@ -100,3 +100,33 @@ function process_arcgfx(fname, h, size, ext) -- return ret end +function process_cscript(fname, h, size, ext) + log("Processing " .. fname .. ".slz") + log("Extracting " .. fname .. " - format 'cscript'") + local counter = 1 + local script + local font + local 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 + + process_single_file(fname, h, h:getsize(), ext, handler) + + if not script or not font then error "Not enough files" end + if dump_mode then + extract_simple_script(fname, script, font) + end + script:destroy() + font:destroy() +end diff --git a/VP-process.lua b/VP-process.lua index c85cfc5..2861d4e 100644 --- a/VP-process.lua +++ b/VP-process.lua @@ -239,14 +239,12 @@ function process_files(index, map, iso, iso_full, cindex, index_add, jp_in_us) log("JP-in-US: replacing file " .. i .. " by file " .. lookup) file_out = index_add[lookup].cd:cdfile(index_add[lookup].sector, index_add[lookup].size * sec_sizes[mode]) end - elseif not ftype then - file_out = process_single_file("DUMP/" .. dir .. string.format("/%04i", i), file_in, file_in:getsize(), ext) - elseif ftype == "arcgfx" then - file_out = process_arcgfx("DUMP/" .. dir .. string.format("/%04i", i), file_in, file_in:getsize(), ext) - elseif ftype == "arcroom" then - file_out = process_arcroom("DUMP/" .. dir .. string.format("/%04i", i), file_in, file_in:getsize(), ext) + elseif ftype then + local handler = _G["process_" .. ftype] + if not handler then error("Unknown ftype: " .. ftype) end + file_out = handler("DUMP/" .. dir .. string.format("/%04i", i), file_in, file_in:getsize(), ext) else - error("Unknow ftype: " .. ftype) + file_out = process_single_file("DUMP/" .. dir .. string.format("/%04i", i), file_in, file_in:getsize(), ext) end if not file_out then file_out = file_in end file_in:seek(0) -- cgit v1.2.3 From d8321af9f135590e303ea6d5f08253f432eaa726 Mon Sep 17 00:00:00 2001 From: Pixel Date: Fri, 26 Oct 2012 09:33:27 -0700 Subject: Small tweaks for yet another kind of script. --- VP-map.lua | 2 ++ VP-roomwork.lua | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'VP-map.lua') diff --git a/VP-map.lua b/VP-map.lua index 795e2e7..334f7c7 100644 --- a/VP-map.lua +++ b/VP-map.lua @@ -96,6 +96,8 @@ VP_map = { [2294] = { dir = "MISC/SCRIPT", ext = "script", ftype = "cscript", }, + [4734] = { dir = "MISC/SCRIPT", ext = "sarc", ftype = "arcroom", }, + -- -- Videos -- diff --git a/VP-roomwork.lua b/VP-roomwork.lua index b4724f4..6aacfcf 100644 --- a/VP-roomwork.lua +++ b/VP-roomwork.lua @@ -191,12 +191,17 @@ function process_arcroom(fname, h, size, ext) return ret end elseif dump_mode and ext == "sarc" 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 + if script then error "Can't have two scripts in these..." end log("Taking text...") script = Buffer(true) script:copyfrom(h) + elseif counter == 2 then + if font then error "Can't have two fonts in these..." end + log("Taking font...") + font = Buffer(true) + font:copyfrom(h) else error("Too many files") end @@ -221,7 +226,7 @@ function process_arcroom(fname, h, size, ext) end outfile[i] = process_single_file(fname .. string.format("/%04i-%08X", i, index[i].ftype), h, index[i].size, "room", handler) if handler and script and font then - if dump_mode and counter == 3 then + if dump_mode and ext == "room" then extract_room_script(fname .. string.format("/%04i", i), script, font) elseif dump_mode then extract_simple_script(fname .. string.format("/%04i", i), script, font) -- cgit v1.2.3 From 17c81623a7845c47d29cd29b80edb6a8200ecae1 Mon Sep 17 00:00:00 2001 From: Pixel Date: Fri, 26 Oct 2012 20:33:39 -0700 Subject: Adding one more script type; one with a brand new action table. --- VP-map.lua | 5 +++ VP-miscwork.lua | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ VP-textwork.lua | 38 +++++++++++++++++--- 3 files changed, 145 insertions(+), 4 deletions(-) (limited to 'VP-map.lua') diff --git a/VP-map.lua b/VP-map.lua index 334f7c7..54a382e 100644 --- a/VP-map.lua +++ b/VP-map.lua @@ -98,6 +98,11 @@ VP_map = { [4734] = { dir = "MISC/SCRIPT", ext = "sarc", ftype = "arcroom", }, + [4797] = { dir = "MISC/UNKNOWN", ext = "carc", ftype = "carc", }, + [4798] = { dir = "MISC/UNKNOWN", ext = "carc", ftype = "carc", }, + [4799] = { dir = "MISC/UNKNOWN", ext = "carc", ftype = "carc", }, + [4807] = { dir = "MISC/UNKNOWN", ext = "carc", ftype = "carc", }, + -- -- Videos -- diff --git a/VP-miscwork.lua b/VP-miscwork.lua index 1818b30..1a5bc14 100644 --- a/VP-miscwork.lua +++ b/VP-miscwork.lua @@ -130,3 +130,109 @@ function process_cscript(fname, h, size, ext) script:destroy() font:destroy() end + +function process_carc(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 'carc'") + dump_mkdir(fname) + local nfiles = h:readU32() + local ret + if not dump_mode then + ret = Buffer(true) + ret:writeU32(nfiles) + end + + local index = {} + for i = 1, nfiles do + index[i] = {} + local offset = h:readU32() + index[i].extra = shr(offset, 24) + index[i].offset = andB(offset, 0xffffff) + end + + index[nfiles + 1] = {} + index[nfiles + 1].extra = 0 + index[nfiles + 1].offset = size + + local outfile = {} + local script = nil + local font = nil + for i = 1, nfiles do + local tell = h:tell() + local handler = nil + local counter = 1 + if index[i].extra == 3 then + handler = function(fname, h, size, ext) + if counter ~= 1 then error "Too many files" end + counter = counter + 1 + return process_carc(fname, h, size, ext) + end + elseif dump_mode and index[i].extra == 2 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 index[i].extra == 1 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 index[i].extra == 2 then + error "Not written yet" + elseif not dump_mode and index[i].extra == 1 then + error "Not written yet" + end + local fsize = index[i + 1].offset - index[i].offset + outfile[i] = process_single_file(fname .. string.format("/%04i-%08X", i, index[i].extra), h, fsize, ext, handler) + + if handler and script and font then + if dump_mode then + second_style_script = true + extract_simple_script(fname .. string.format("/%04i", i), script, font) + second_style_script = false + end + script:destroy() + font:destroy() + script = nil + font = nil + end + h:seek(tell + fsize) + 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 diff --git a/VP-textwork.lua b/VP-textwork.lua index 2d3f56c..c7bc9af 100644 --- a/VP-textwork.lua +++ b/VP-textwork.lua @@ -1,3 +1,9 @@ +function get_next_char(script) + local c = script:readU8() + if c >= 0x80 then c = (c - 0x80) + (script:readU8() * 128) end + return c +end + function get_next_utf8(str) local ret = "" local n @@ -86,14 +92,38 @@ function dump_special(script, code) error "Should not end up there" end +function dump_special2(script, code) + if code == 0 then + return "\n", "\n" + elseif code == 1 then + return "\n\n", "\n" + else + local a1, a2 + if code == 3 or code == 5 or code == 7 or code == 8 or code == 9 or code == 12 or code == 13 or code == 14 or code == 15 or code == 21 then + a1 = script:readU8() + return '', "" + elseif code == 20 then + a1 = script:readU8() + a2 = script:readU8() + return '', "" + else + return '', "" + end + end + error "Should not end up there" +end + function extract_char(script, lookup) - local - c = script:readU8() + local c = get_next_char(script) if c == 0 then return nil end - if c >= 0x80 then c = (c - 0x80) + (script:readU8() * 128) end if c >= 0x4000 then - return dump_special(script, c - 0x4000) + local code = c - 0x4000 + if second_style_script then + return dump_special2(script, code) + else + return dump_special(script, code) + end else local l = lookup[c] if not l and not sloppy_extract then error("Lookup failed for character " .. c) end -- cgit v1.2.3