summaryrefslogtreecommitdiff
path: root/VP-process.lua
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2010-06-10 15:30:25 -0700
committerPixel <pixel@nobis-crew.org>2010-06-10 15:30:25 -0700
commitdd86dcc28629225881de61f63394132eb0cb0e2a (patch)
tree26bcfb8c0e64117e9a4489c308adf9ca7940319f /VP-process.lua
parentc07307cb655e8449bb05052ec28993857ac27836 (diff)
parentbb7745a988db1c4be68e4b12b51e16a7e5a21f8e (diff)
Merge branch 'master' of ssh+git://git.grumpycoder.net/pub/repo.git/VP-hack
Diffstat (limited to 'VP-process.lua')
-rw-r--r--VP-process.lua66
1 files changed, 51 insertions, 15 deletions
diff --git a/VP-process.lua b/VP-process.lua
index c4f65e2..c85cfc5 100644
--- a/VP-process.lua
+++ b/VP-process.lua
@@ -6,29 +6,37 @@ load "VP-fontwork.lua"
load "VP-roomwork.lua"
load "VP-miscwork.lua"
load "VP-textwork.lua"
+load "VP-jp-in-us.lua"
-restrict = {
+--restrict = {
-- [3610] = true,
-- [3611] = true,
-- [3612] = true,
-- [3613] = true,
-- [3614] = true,
-- [3615] = true,
- [3610 + 125] = true,
-}
+-- [3610 + 125] = true,
+--}
--dump_glyph = true
---dump_mode = true
+dump_mode = true
activate_debug_room = true
-slusent = nil
+slusdirent = nil
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,33 @@ 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
+ if jp_in_us then dump_mode = false end
local iso, cindex
if not dump_mode then
iso = prepare_out(iso_out)
@@ -277,7 +312,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 +338,4 @@ function main(...)
log("Biggest pad = " .. biggest_pad)
log_file:destroy()
end
+