diff options
Diffstat (limited to 'VP-isowork.lua')
-rw-r--r-- | VP-isowork.lua | 112 |
1 files changed, 82 insertions, 30 deletions
diff --git a/VP-isowork.lua b/VP-isowork.lua index 4b9efb2..ace75af 100644 --- a/VP-isowork.lua +++ b/VP-isowork.lua @@ -11,33 +11,54 @@ function apply_hacks(hacks, file) end function prepare_out(file_out) + local iso_file if got_psp then local x = Output "VP-FR.iso" x:destroy() - globals[3] = dvdabstract(file_out or "VP-FR.iso", true) + iso_file = dvdabstract(file_out or "VP-FR.iso", true) else - globals[3] = Output(file_out or "VP-FR.bin") + iso_file = Output(file_out or "VP-FR.bin") end - local iso = isobuilder(globals[3]) + local iso = isobuilder(iso_file) + iso.iso_file = iso_file return iso end -function startup(file_in, file_in2, iso_out) +function startup(file_in, file_in2, iso_out, file_in3, file_in4) + local cdutil, cdutil2, cdutil3, cdutil4 if not loadmodule then error("This can only be used with lua-interface...") end loadmodule "lualibs" loadmodule "luahandle" loadmodule "luacd" - loadmodule "luaslz" + pcall(loadmodule, "luaslz") loadmodule "luahttp" loadmodule "luaxml" --- globals[1] = cdabstract(file_in or "VP-SQUISH.bin") - globals[1] = dvdabstract(file_in or "VP-PSP-EUR.iso") - local cdutil = cdutils(globals[1]) + local r, v + r, v = pcall(cdabstract, file_in or "VP-SQUISH.bin") + if not r then + v = dvdabstract(file_in or "VP-PSP-EUR.iso") + end + cdutil = cdutils(v) + cdutil.iso_in = v if file_in2 then - globals[2] = cdabstract(file_in2) - local cdutil2 = cdutils(globals[2]) + v = cdabstract(file_in2) + cdutil2 = cdutils(v) + cdutil2.iso_in = v + end + if file_in3 then + r, v = pcall(cdabstract, file_in3) + if not r then + v = dvdabstract(file_in3) + end + cdutil3 = cdutils(v) + cdutil3.iso_in = v + end + if file_in4 then + v = cdabstract(file_in4) + cdutil4 = cdutils(v) + cdutil4.iso_in = v end - return cdutil, cdutil2, iso_out + return cdutil, cdutil2, iso_out, cdutil3, cdutil4 end anti_cd_swap_hack = { @@ -47,56 +68,85 @@ anti_cd_swap_hack = { [0x2820] = { 0x00, 0x00, 0x00, 0x00 }, } -function iso_identify(cdutil) +function iso_identify(cdutil, additionnal) local slusdirentuscd1 = cdutil:findpath "/SLUS_011.56;1" local slusdirentuscd2 = cdutil:findpath "/SLUS_011.79;1" - local slusdirentjpcd1 = cdutil:findpath "/SLPM_863_79;1" - local slusdirentjpcd2 = cdutil:findpath "/SLPM_863_80;1" + local slusdirentjpcd1 = cdutil:findpath "/SLPM_863.79;1" + local slusdirentjpcd2 = cdutil:findpath "/SLPM_863.80;1" local slusdirentsquished = cdutil:findpath "/VALKYRIE.EXE;1" local pspdata = cdutil:findpath "/UMD_DATA.BIN" if pspdata then local pspdataf = cdutil:cdfile(pspdata) local umddata = pspdataf:read() if umddata == "ULUS-10107|400F6E7A41D6C586|0001|G" then - got_us = true + if not additionnal then got_us = true else got_add_us = true end elseif umddata == "ULES-00724|2A9CD5DEEA986357|0001|G" then - got_eu = true + if not additionnal then got_eu = true else got_add_eu = true end elseif umddata == "ULJM-05101|7862BF3F2632E5B5|0001|G" then - got_jp = true + if not additionnal then got_jp = true else got_add_jp = true end else error "Wrong PSP iso." end - got_psp = true + if not additionnal then + got_psp = true + got_cd1 = true + got_cd2 = true + else + got_add_psp = true + got_add_cd1 = true + got_add_cd2 = true + end end - if slusdirentuscd1 and got_cd1 then error "Got twice CD1." end - if slusdirentuscd2 and got_cd2 then error "Got twice CD2." end + if (slusdirentuscd1 or slusdirentjpcd1) and got_cd1 and not additionnal then error "Got twice CD1." end + if (slusdirentuscd2 or slusdirentjpcd2) and got_cd2 and not additionnal then error "Got twice CD2." end + if (slusdirentuscd1 or slusdirentjpcd1) and got_add_cd1 and additionnal then error "Got twice CD1." end + if (slusdirentuscd2 or slusdirentjpcd2) and got_add_cd2 and additionnal then error "Got twice CD2." end + + if (slusdirentuscd1 or slusdirentuscd2) and not additionnal then got_us = true end + if (slusdirentjpcd1 or slusdirentjpcd2) and not additionnal then got_jp = true end + if (slusdirentuscd1 or slusdirentjpcd1) and not additionnal then got_cd1 = true end + if (slusdirentuscd2 or slusdirentjpcd2) and not additionnal then got_cd2 = true end - if slusdirentuscd1 or slusdirentuscd2 then got_us = true end - if slusdirentjpcd1 or slusdirentjpcd2 then got_jp = true end - if slusdirentuscd1 or slusdirentjpcd1 then got_cd1 = true end - if slusdirentuscd2 or slusdirentjpcd2 then got_cd2 = true end + if (slusdirentuscd1 or slusdirentuscd2) and additionnal then got_add_us = true end + if (slusdirentjpcd1 or slusdirentjpcd2) and additionnal then got_add_jp = true end + if (slusdirentuscd1 or slusdirentjpcd1) and additionnal then got_add_cd1 = true end + if (slusdirentuscd2 or slusdirentjpcd2) and additionnal then got_add_cd2 = true end - if slusdirentsquished then + if slusdirentsquished and not additionnal then got_cd1 = true got_cd2 = true -- let's fallback... got_us = true end - if not slusent then - slusent = slusdirentuscd1 or slusdirentuscd2 or slusdirentjpcd1 or slusdirentjpcd2 or slusdirentsquished + if slusdirentsquished and additionnal then + got_add_cd1 = true + got_add_cd2 = true + -- let's fallback... + got_add_jp = true + end + + if not slusdirent then + slusdirent = slusdirentuscd1 or slusdirentuscd2 or slusdirentjpcd1 or slusdirentjpcd2 or slusdirentsquished end if got_us and got_jp then error "2 isos must from the same version of the game." end + if got_add_us and got_add_jp then error "2 isos must from the same version of the game." end + + if got_us and got_add_jp and got_cd1 and got_cd2 and got_add_cd1 and got_add_cd2 then + jp_in_us = true + end + + -- should check for PSP / PSX mixup... end function build_basic(iso, cdutil, iso_full) local cp = function(path, name, dirtree) copyfile(path, name, dirtree, iso, cdutil) end iso:foreword(cdutil) local pvd = createpvd(cdutil) - pvd.volid = "VP-FR" + pvd.volid = jp_in_us and "VP-JP-US" or "VP-FR" local root = iso:setbasics(pvd) dirent = cdutil:findpath "/" root:setbasicsxa() @@ -136,7 +186,8 @@ function build_basic(iso, cdutil, iso_full) psp_dirtrees.PSPVAL1:setbasicsxa() dummy:destroy() else - local systemcnfstring = "BOOT=cdrom:\\VP-FR.EXE;1\r\nTCB=4\r\nEVENT=16\r\nSTACK=801fff00\r\n" + local systemcnfstring + systemcnfstring = jp_in_us and "BOOT=cdrom:\\VP-JP-US.EXE;1\r\nTCB=4\r\nEVENT=16\r\nSTACK=801fff00\r\n" or "BOOT=cdrom:\\VP-FR.EXE;1\r\nTCB=4\r\nEVENT=16\r\nSTACK=801fff00\r\n" local systemcnf = Buffer() local slus = Buffer(true) slus:copyfrom(cdutil:cdfile(slusdirent)) @@ -149,7 +200,7 @@ function build_basic(iso, cdutil, iso_full) end apply_hacks(slz3_patch, slus) slus:seek(0) - iso:createfile(root, "VP-FR.EXE", slus, slusdirent):setbasicsxa() + iso:createfile(root, jp_in_us and "VP-JP-US.EXE" or "VP-FR.EXE", slus, slusdirent):setbasicsxa() slus:seek(0) local readme = Buffer() readme:write("Readme...") @@ -161,3 +212,4 @@ function build_basic(iso, cdutil, iso_full) end end end + |