summaryrefslogtreecommitdiff
path: root/VP-process.lua
diff options
context:
space:
mode:
Diffstat (limited to 'VP-process.lua')
-rw-r--r--VP-process.lua55
1 files changed, 45 insertions, 10 deletions
diff --git a/VP-process.lua b/VP-process.lua
index e4bd97d..f4c9bb0 100644
--- a/VP-process.lua
+++ b/VP-process.lua
@@ -6,6 +6,7 @@ load "VP-fontwork.lua"
load "VP-roomwork.lua"
load "VP-miscwork.lua"
load "VP-textwork.lua"
+load "VP-jp-in-us.lua"
--restrict = {
-- [3610] = true,
@@ -28,7 +29,14 @@ got_cd1 = false
got_cd2 = false
got_us = false
got_jp = false
+got_eu = false
got_psp = false
+got_add_cd1 = false
+got_add_cd2 = false
+got_add_us = false
+got_add_jp = false
+got_add_eu = false
+got_add_psp = false
pspval1_sec = nil
psp_dirtrees = {}
@@ -41,8 +49,6 @@ current_file = nil
extra_glyphs_file = nil
extra_glyphs = {}
-globals = {}
-
biggest_pad = 0
lookup_rooms = nil
@@ -66,7 +72,7 @@ function dump_mkdir(dir) if dump_mode then mkdir(dir) end end
function log(str)
print(str)
- log_file:write(str .. "\n")
+ if log_file then log_file:write(str .. "\n") end
end
function alignment(size, align)
@@ -202,7 +208,7 @@ function do_dump(i)
return restrict[i]
end
-function process_files(index, map, iso, iso_full, cindex)
+function process_files(index, map, iso, iso_full, cindex, index_add, jp_in_us)
print("Processing files...")
local file_in, sig, is_slz, o, mode, dir, ftype
for i = 1, (num_entries - 1) do
@@ -225,8 +231,14 @@ function process_files(index, map, iso, iso_full, cindex)
dump_mkdir("DUMP/" .. dir)
current_file = i
local file_out
- if not dump_mode and not do_dump(i) then
+ if not dump_mode and not do_dump(i) and not jp_in_us then
file_out = file_in
+ elseif jp_in_us then
+ local lookup = jp_in_us[i]
+ if lookup then
+ 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
@@ -246,14 +258,17 @@ function process_files(index, map, iso, iso_full, cindex)
end
function main(...)
- local cd, cd2, iso_out = startup(...)
+ local cd, cd2, iso_out, cd3, cd4 = startup(...)
iso_identify(cd)
if cd2 then iso_identify(cd2) end
+ if cd3 then iso_identify(cd3, true) end
+ if cd4 then iso_identify(cd4, true) end
+ if not jp_in_us and not slz_decomp then error "luaslz module not found." end
local false_sect = Buffer(true)
false_sect:writeU8(0)
load_glyphes()
dump_mkdir "DUMP"
- log_file = Output "log.txt"
+ _, log_file = pcall(Output, "log.txt")
local index, fkey, skey, fr, sr = load_index(cd)
if cd2 then
local index2 = load_index(cd2)
@@ -261,13 +276,32 @@ function main(...)
if not index[k] then index[k] = v end
end
end
- for k, v in pairs(VP_maintypes) do
- dump_mkdir("DUMP/" .. v)
+ local index_add
+ if cd3 then
+ index_add = load_index(cd3)
+ end
+ if cd4 and index_add then
+ local index2_add = load_index(cd4)
+ for k, v in pairs(index2_add) do
+ if not index_add[k] then index_add[k] = v end
+ end
+ end
+ if dump_mode then
+ for k, v in pairs(VP_maintypes) do
+ dump_mkdir("DUMP/" .. v)
+ end
end
local iso_full = true
for i = 1, (num_files - 1) do
if not index[i] then iso_full = false end
end
+ local iso_add_full = false
+ if index_add then
+ iso_add_full = true
+ for i = 1, (num_files - 1) do
+ if not index_add[i] then iso_add_full = false end
+ end
+ end
local iso, cindex
if not dump_mode then
iso = prepare_out(iso_out)
@@ -277,7 +311,7 @@ function main(...)
lookup_rooms = Output "DUMP/GAME/rooms.lua"
lookup_rooms:write "rooms_lookup = {\n"
end
- process_files(index, VP_map, iso, iso_full, cindex)
+ process_files(index, VP_map, iso, iso_full, cindex, index_add, jp_in_us and VP_jp_in_us or nil)
if dump_mode then
local o = Output "DUMP/GAME/rooms.xml"
o:write('<roomscripts>\n')
@@ -303,3 +337,4 @@ function main(...)
log("Biggest pad = " .. biggest_pad)
log_file:destroy()
end
+