Fix LuaSF big endian output..?
This commit is contained in:
parent
0829fd982e
commit
7dacdd7849
46
run.py
46
run.py
|
@ -79,12 +79,14 @@ def fchunkPack(fch,fchOut,pf = "pc"):
|
||||||
if pf == "x360":
|
if pf == "x360":
|
||||||
callTool([p("LuaSF","LuaSF"),"--big","--compile",wp(fch),wp(fchOutDir)],cwd=p(sp,"bin","windows","LuaSF")) # ugly hack
|
callTool([p("LuaSF","LuaSF"),"--big","--compile",wp(fch),wp(fchOutDir)],cwd=p(sp,"bin","windows","LuaSF")) # ugly hack
|
||||||
os.replace(fchOutLsfName,fchOut + ".decomp")
|
os.replace(fchOutLsfName,fchOut + ".decomp")
|
||||||
|
fchunkFixBig(fchOut + ".decomp")
|
||||||
callTool([p("xbcompression","xbcompress"),"/F",wp(fchOut + ".decomp"),wp(fchOut)])
|
callTool([p("xbcompression","xbcompress"),"/F",wp(fchOut + ".decomp"),wp(fchOut)])
|
||||||
os.remove(fchOut + ".decomp")
|
os.remove(fchOut + ".decomp")
|
||||||
return
|
return
|
||||||
|
|
||||||
if pf == "ps3":
|
if pf == "ps3":
|
||||||
callTool([p("LuaSF","LuaSF"),"--big","--compile",wp(fch),wp(fchOutDir)])
|
callTool([p("LuaSF","LuaSF"),"--big","--compile",wp(fch),wp(fchOutDir)])
|
||||||
|
fchunkFixBig(fchOutLsfName)
|
||||||
|
|
||||||
if pf == "pc":
|
if pf == "pc":
|
||||||
callTool([p("LuaSF","LuaSF"),"--compile",wp(fch),wp(fchOutDir)])
|
callTool([p("LuaSF","LuaSF"),"--compile",wp(fch),wp(fchOutDir)])
|
||||||
|
@ -93,6 +95,50 @@ def fchunkPack(fch,fchOut,pf = "pc"):
|
||||||
os.replace(fchOutLsfName,fchOut)
|
os.replace(fchOutLsfName,fchOut)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def fchunkFixBig(fchunk): # Fix SCRH (Script Package Header) and SCRC (Script Package Lookup) -- Thanks miru97 for the help!
|
||||||
|
fh = open(fchunk,"r+b")
|
||||||
|
|
||||||
|
# Find pointers
|
||||||
|
pointers = {}
|
||||||
|
fh.seek(0x810)
|
||||||
|
headerName = fh.read(4).decode("ascii")
|
||||||
|
pointers[headerName] = [0,0,0]
|
||||||
|
pointers[headerName][0] = int.from_bytes(fh.read(4),"little") # address
|
||||||
|
pointers[headerName][1] = int.from_bytes(fh.read(4),"little") # unknown
|
||||||
|
pointers[headerName][2] = int.from_bytes(fh.read(4),"little") # size
|
||||||
|
|
||||||
|
headerName = fh.read(4).decode("ascii")
|
||||||
|
pointers[headerName] = [0,0,0]
|
||||||
|
pointers[headerName][0] = int.from_bytes(fh.read(4),"little") # address
|
||||||
|
pointers[headerName][1] = int.from_bytes(fh.read(4),"little") # unknown
|
||||||
|
pointers[headerName][2] = int.from_bytes(fh.read(4),"little") # size
|
||||||
|
|
||||||
|
#headerName = fh.read(4).decode("ascii")
|
||||||
|
#pointers[headerName] = [0,0,0]
|
||||||
|
#pointers[headerName][0] = int.from_bytes(fh.read(4),"big") # address
|
||||||
|
#pointers[headerName][1] = int.from_bytes(fh.read(4),"big") # unknown
|
||||||
|
#pointers[headerName][2] = int.from_bytes(fh.read(4),"big") # size
|
||||||
|
|
||||||
|
# normalize addresses
|
||||||
|
pointers["SCRC"][0] = pointers["SCRH"][0] + pointers["SCRC"][0]
|
||||||
|
#pointers["SCRS"][0] = pointers["SCRC"][0] + pointers["SCRS"][0] # TODO: check if correct
|
||||||
|
|
||||||
|
for space in pointers:
|
||||||
|
cursor = pointers[space][0]
|
||||||
|
end = cursor + pointers[space][2]
|
||||||
|
fh.seek(cursor)
|
||||||
|
while cursor < end:
|
||||||
|
# invert bytes
|
||||||
|
data = fh.read(1)
|
||||||
|
data = fh.read(1) + data
|
||||||
|
data = fh.read(1) + data
|
||||||
|
data = fh.read(1) + data
|
||||||
|
fh.seek(cursor)
|
||||||
|
fh.write(data)
|
||||||
|
cursor += 4
|
||||||
|
|
||||||
|
fh.close()
|
||||||
|
|
||||||
def createPatchFromDir(dir1,dir2,output):
|
def createPatchFromDir(dir1,dir2,output):
|
||||||
proc = popen(["diff","-crB",dir1,dir2],stdout=subprocess.PIPE)
|
proc = popen(["diff","-crB",dir1,dir2],stdout=subprocess.PIPE)
|
||||||
with open(output,"w",encoding="utf-8") as fh:
|
with open(output,"w",encoding="utf-8") as fh:
|
||||||
|
|
Loading…
Reference in New Issue