mirror of https://github.com/zeldaret/tp.git
Add option to use oead and copy map files (#294)
This commit is contained in:
parent
3acf288950
commit
d024075910
34
Makefile
34
Makefile
|
|
@ -175,34 +175,52 @@ $(ELF_SHIFT): $(DOL)
|
|||
@echo $(O_FILES) > build/o_files
|
||||
@$(PYTHON) tools/lcf.py dol_shift --output $(LDSCRIPT)
|
||||
$(LD) -application $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) @build/o_files $(LIBS)
|
||||
@cp -v $(ELF_SHIFT) $(ELF)
|
||||
|
||||
$(DOL_SHIFT): $(ELF_SHIFT) | tools
|
||||
$(ELF2DOL) $< $@ $(SDATA_PDHR) $(SBSS_PDHR) $(TARGET_COL)
|
||||
@cp -v $(DOL_SHIFT) $(DOL)
|
||||
|
||||
shift: dirs $(DOL_SHIFT)
|
||||
|
||||
game: shift
|
||||
$(MAKE) rels
|
||||
shiftedrels: shift
|
||||
@echo generating shifted RELs from .plf
|
||||
@echo $(RELS) > build/plf_files
|
||||
$(PYTHON) $(MAKEREL) build --string-table $(BUILD_DIR)/frameworkF.str @build/plf_files $(ELF_SHIFT)
|
||||
|
||||
game: shiftedrels
|
||||
@mkdir -p game
|
||||
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) copyCode
|
||||
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) copyCode native
|
||||
|
||||
game-fast: shiftedrels
|
||||
@mkdir -p game
|
||||
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) copyCode oead
|
||||
|
||||
game-nocompile:
|
||||
@mkdir -p game
|
||||
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) noCopyCode
|
||||
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) noCopyCode native
|
||||
|
||||
game-nocompile-fast:
|
||||
@mkdir -p game
|
||||
@$(PYTHON) tools/package_game_assets.py ./game $(BUILD_PATH) noCopyCode oead
|
||||
|
||||
rungame-nocompile: game-nocompile
|
||||
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
|
||||
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
|
||||
|
||||
iso: game
|
||||
@$(PYTHON) tools/packageISO.py $(BUILD_DIR)/game/ $(TARGET_ISO)
|
||||
rungame-nocompile-fast: game-nocompile-fast
|
||||
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
|
||||
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
|
||||
|
||||
rungame-fast: game-fast
|
||||
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
|
||||
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
|
||||
|
||||
rungame: game
|
||||
@echo If you are playing on a shifted game make sure Hyrule Field Speed hack is disabled in dolphin!
|
||||
dolphin-emu $(BUILD_DIR)/game/sys/main.dol
|
||||
|
||||
iso: game
|
||||
@$(PYTHON) tools/packageISO.py $(BUILD_DIR)/game/ $(TARGET_ISO)
|
||||
|
||||
#
|
||||
$(BUILD_DIR)/%.o: %.c $(BUILD_DIR)/%.d
|
||||
@mkdir -p $(@D)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ dolInfoPosition = 0x420
|
|||
|
||||
numFileEntries = 0
|
||||
|
||||
yaz0DecompressFunction = libyaz0.decompress
|
||||
|
||||
"""
|
||||
Returns the offset address and size of fst.bin
|
||||
"""
|
||||
|
|
@ -229,7 +231,14 @@ def getDolInfo(disc):
|
|||
return dolOffset, dolSize
|
||||
|
||||
|
||||
def extract(path):
|
||||
def extract(path,yaz0Encoder):
|
||||
if yaz0Encoder == "oead":
|
||||
try:
|
||||
from oead import yaz0
|
||||
global yaz0DecompressFunction
|
||||
yaz0DecompressFunction = yaz0.decompress
|
||||
except:
|
||||
print("Extract: oead isn't installed, falling back to native yaz0")
|
||||
with open(path, "rb") as f:
|
||||
# Seek to fst offset information and retrieve it
|
||||
f.seek(fstInfoPosition)
|
||||
|
|
@ -266,7 +275,7 @@ def extract(path):
|
|||
|
||||
|
||||
def main():
|
||||
extract(sys.argv[1])
|
||||
extract(sys.argv[1],"native")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ convertDefinitions = [
|
|||
}
|
||||
]
|
||||
|
||||
yaz0CompressFunction = libyaz0.compress
|
||||
|
||||
def convertEntry(file, path, destPath, returnData):
|
||||
split = os.path.splitext(file)
|
||||
|
|
@ -69,7 +70,7 @@ def convertEntry(file, path, destPath, returnData):
|
|||
if mustBeCompressed == True:
|
||||
if data == None:
|
||||
data = open(path / file, "rb").read()
|
||||
data = libyaz0.compress(data)
|
||||
data = yaz0CompressFunction(data)
|
||||
if returnData == True:
|
||||
if data == None and returnData == True:
|
||||
data = open(path / file, "rb").read()
|
||||
|
|
@ -254,7 +255,7 @@ def copyRelFiles(gamePath, buildPath, aMemList, mMemList):
|
|||
relSource = open(fullPath, "rb")
|
||||
data = relSource.read()
|
||||
relSource.close()
|
||||
data = libyaz0.compress(data)
|
||||
data = yaz0CompressFunction(data)
|
||||
relNew = open(
|
||||
buildPath / "dolzel2/game/files/rel/Final/Release" / file, "wb"
|
||||
)
|
||||
|
|
@ -285,14 +286,14 @@ def copyRelFiles(gamePath, buildPath, aMemList, mMemList):
|
|||
if str(rel).find(rel2) != -1:
|
||||
sourceRel = open(rel, "rb").read()
|
||||
open(buildPath / "RELS.arc/rels/amem/" / rel2.lower(), "wb").write(
|
||||
libyaz0.compress(sourceRel)
|
||||
yaz0CompressFunction(sourceRel)
|
||||
)
|
||||
break
|
||||
for rel2 in mMemRels.splitlines():
|
||||
if str(rel).find(rel2) != -1:
|
||||
sourceRel = open(rel, "rb").read()
|
||||
open(buildPath / "RELS.arc/rels/mmem/" / rel2.lower(), "wb").write(
|
||||
libyaz0.compress(sourceRel)
|
||||
yaz0CompressFunction(sourceRel)
|
||||
)
|
||||
break
|
||||
|
||||
|
|
@ -301,8 +302,36 @@ def copyRelFiles(gamePath, buildPath, aMemList, mMemList):
|
|||
libarc.convert_dir_to_arc(buildPath / "RELS.arc", convertEntry)
|
||||
)
|
||||
|
||||
def postprocessMapFile(inputMapString):
|
||||
outputMap = ""
|
||||
textFound = False
|
||||
for line in inputMapString.splitlines():
|
||||
if len(line)==0:
|
||||
continue
|
||||
elif textFound == True and line[0:3] == " 0" and line[39] != '.':
|
||||
split = line.split(" ")
|
||||
outputMap += ' '.join(split[0:5])+' '+' '.join(split[6:])+'\n'
|
||||
elif line[0]=='.':
|
||||
if line == '.text section layout' or textFound == True:
|
||||
textFound = True
|
||||
outputMap += line+'\n'
|
||||
return outputMap
|
||||
|
||||
def copyMapFiles(buildPath):
|
||||
open(buildPath/"dolzel2/game/files/map/Final/Release/frameworkF.map","w").write(postprocessMapFile(open(buildPath/"dolzel2/dolzel2.map","r").read()))
|
||||
for map in (buildPath/"dolzel2/rel/").rglob("*.map"):
|
||||
open(buildPath/"dolzel2/game/files/map/Final/Release/"/map.name,"w").write(postprocessMapFile(open(map,"r").read()))
|
||||
|
||||
def main(gamePath, buildPath, copyCode, yaz0Encoding):
|
||||
if yaz0Encoding == "oead":
|
||||
try:
|
||||
from oead import yaz0
|
||||
global yaz0CompressFunction
|
||||
yaz0CompressFunction = yaz0.compress
|
||||
except:
|
||||
print("Package: oead isn't installed, falling back to native yaz0")
|
||||
|
||||
|
||||
def main(gamePath, buildPath, copyCode):
|
||||
if not gamePath.exists():
|
||||
gamePath.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
|
@ -315,7 +344,7 @@ def main(gamePath, buildPath, copyCode):
|
|||
print("ISO is not extracted; extracting...")
|
||||
previousDir = os.getcwd()
|
||||
os.chdir(str(gamePath.absolute()))
|
||||
extract_game_assets.extract("../" + str(iso))
|
||||
extract_game_assets.extract("../" + str(iso),yaz0Encoding)
|
||||
os.chdir(previousDir)
|
||||
|
||||
print("Copying game files...")
|
||||
|
|
@ -339,12 +368,12 @@ def main(gamePath, buildPath, copyCode):
|
|||
copyRelFiles(gamePath, buildPath, aMemRels.splitlines(), mMemRels.splitlines())
|
||||
|
||||
shutil.copy(buildPath/"dolzel2/frameworkF.str",buildPath/"dolzel2/game/files/str/Final/Release/frameworkF.str")
|
||||
|
||||
copyMapFiles(buildPath)
|
||||
|
||||
now = datetime.now()
|
||||
copydate = str(now.year)+"/"+str(now.month).zfill(2)+"/"+str(now.day).zfill(2)+" "+str(now.hour).zfill(2)+":"+str(now.minute).zfill(2)+"\n"
|
||||
open(buildPath/"dolzel2/game/files/str/Final/Release/COPYDATE","w").write(copydate)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
main(Path(sys.argv[1]), Path(sys.argv[2]), sys.argv[3])
|
||||
main(Path(sys.argv[1]), Path(sys.argv[2]), sys.argv[3], sys.argv[4])
|
||||
|
|
|
|||
Loading…
Reference in New Issue