mirror of
https://github.com/encounter/tp.git
synced 2026-07-11 06:18:46 -07:00
Formatting
This commit is contained in:
@@ -179,7 +179,6 @@ SECTION_SDATA2 static f32 lit_3882 = 1.0f;
|
||||
// matches with literals
|
||||
#ifdef NONMATCHING
|
||||
void dMenuMapCommon_c::initiate(JKRArchive* arc) {
|
||||
// Links the images on the map zoomed out to the ones zoomed in
|
||||
ResTIMG* mp_image;
|
||||
|
||||
mp_image = (ResTIMG*)arc->getResource('TIMG', "tt_map_icon_boss_s_ci8_16_00.bti");
|
||||
@@ -467,6 +466,7 @@ SECTION_SDATA2 static f32 lit_4013 = 180.0f;
|
||||
|
||||
/* 801C38E4-801C3EC4 1BE224 05E0+00 0/0 2/2 0/0 .text drawIcon__16dMenuMapCommon_cFffff
|
||||
*/
|
||||
//unfinished
|
||||
#ifdef NONMATCHING
|
||||
void dMenuMapCommon_c::drawIcon(f32 param_0, f32 param_1, f32 param_2, f32 param_3) {
|
||||
s16 tmp[128];
|
||||
@@ -603,7 +603,7 @@ asm void dMenuMapCommon_c::moveLightDropAnime() {
|
||||
*/
|
||||
#ifdef NONMATCHING
|
||||
float dMenuMapCommon_c::getIconSizeX(u8 index) {
|
||||
for (int i = 0; i<ARRAY_SIZE(map_icon_size); i++) {
|
||||
for (int i = 0; i < ARRAY_SIZE(map_icon_size); i++) {
|
||||
if (map_icon_size[index].mIndex == index) {
|
||||
return map_icon_size[index].mXSize;
|
||||
}
|
||||
@@ -625,7 +625,7 @@ asm float dMenuMapCommon_c::getIconSizeX(u8 param_0) {
|
||||
*/
|
||||
#ifdef NONMATCHING
|
||||
float dMenuMapCommon_c::getIconSizeY(u8 index) {
|
||||
for (int i = 0; i<ARRAY_SIZE(map_icon_size); i++) {
|
||||
for (int i = 0; i < ARRAY_SIZE(map_icon_size); i++) {
|
||||
if (map_icon_size[index].mIndex == index) {
|
||||
return map_icon_size[index].mYSize;
|
||||
}
|
||||
|
||||
@@ -131,13 +131,18 @@ Use the parsed fst.bin contents to write assets to file
|
||||
"""
|
||||
|
||||
convertDefinitions = [
|
||||
{"extension": ".arc", "function": libarc.extract_to_directory, "exceptions": ["archive/dat/speakerse.arc"]}
|
||||
{
|
||||
"extension": ".arc",
|
||||
"function": libarc.extract_to_directory,
|
||||
"exceptions": ["archive/dat/speakerse.arc"],
|
||||
}
|
||||
]
|
||||
|
||||
def writeFile(name,data):
|
||||
if (data[0:4]==bytes("Yaz0","ascii")):
|
||||
|
||||
def writeFile(name, data):
|
||||
if data[0:4] == bytes("Yaz0", "ascii"):
|
||||
splitName = os.path.splitext(name)
|
||||
name = splitName[0]+".c"+splitName[1]
|
||||
name = splitName[0] + ".c" + splitName[1]
|
||||
data = yaz0.decompress(data)
|
||||
|
||||
extractDef = None
|
||||
@@ -148,18 +153,18 @@ def writeFile(name,data):
|
||||
extractDef = extractData
|
||||
if extractData["exceptions"] != None:
|
||||
for exception in extractData["exceptions"]:
|
||||
if str(name)==exception:
|
||||
if str(name) == exception:
|
||||
extractDef = None
|
||||
break
|
||||
|
||||
|
||||
if extractDef == None:
|
||||
file = open(name,"wb")
|
||||
file = open(name, "wb")
|
||||
file.write(data)
|
||||
file.close()
|
||||
else:
|
||||
name = extractDef["function"](name,data,writeFile)
|
||||
name = extractDef["function"](name, data, writeFile)
|
||||
return name
|
||||
|
||||
|
||||
|
||||
def writeAssets(parsedFstBin, handler):
|
||||
# Write the folder structure and files to disc
|
||||
@@ -178,10 +183,13 @@ def writeAssets(parsedFstBin, handler):
|
||||
)
|
||||
else:
|
||||
handler.seek(i["fileOffset"])
|
||||
writeFile(folderStack[-1]["folderName"] + i["fileName"],bytearray(handler.read(i["fileSize"])))
|
||||
#with open(
|
||||
writeFile(
|
||||
folderStack[-1]["folderName"] + i["fileName"],
|
||||
bytearray(handler.read(i["fileSize"])),
|
||||
)
|
||||
# with open(
|
||||
# (folderStack[-1]["folderName"] + i["fileName"]), "wb"
|
||||
#) as currentFile:
|
||||
# ) as currentFile:
|
||||
# currentFile.write(bytearray(handler.read(i["fileSize"])))
|
||||
|
||||
while folderStack[-1]["lastEntryNumber"] == j + 1:
|
||||
@@ -260,5 +268,6 @@ def extract(path):
|
||||
def main():
|
||||
extract(sys.argv[1])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
+250
-99
File diff suppressed because it is too large
Load Diff
@@ -9,25 +9,33 @@ import ctypes
|
||||
import oead
|
||||
import libarc
|
||||
|
||||
|
||||
def getMaxDateFromDir(path):
|
||||
maxTime = 0
|
||||
for root,dirs,files in os.walk(str(path)):
|
||||
for root, dirs, files in os.walk(str(path)):
|
||||
for file in files:
|
||||
time = os.path.getmtime(Path(root+"/"+file))
|
||||
time = os.path.getmtime(Path(root + "/" + file))
|
||||
if time > maxTime:
|
||||
maxTime = time
|
||||
return maxTime
|
||||
|
||||
|
||||
convertDefinitions = [
|
||||
{"sourceExtension" : ".arc", "destExtension" : ".arc", "convertFunction" : libarc.convert_dir_to_arc, "exceptions": ["game/files/res/Object/HomeBtn.c.arc/archive/dat/speakerse.arc"]}
|
||||
{
|
||||
"sourceExtension": ".arc",
|
||||
"destExtension": ".arc",
|
||||
"convertFunction": libarc.convert_dir_to_arc,
|
||||
"exceptions": ["game/files/res/Object/HomeBtn.c.arc/archive/dat/speakerse.arc"],
|
||||
}
|
||||
]
|
||||
|
||||
def convertEntry(file,path,destPath,returnData):
|
||||
|
||||
def convertEntry(file, path, destPath, returnData):
|
||||
split = os.path.splitext(file)
|
||||
mustBeCompressed = False
|
||||
destFileName = file
|
||||
if split[0].split(".")[-1] == "c":
|
||||
destFileName = split[0][0:-2]+split[-1]
|
||||
destFileName = split[0][0:-2] + split[-1]
|
||||
mustBeCompressed = True
|
||||
sourceExtension = split[-1]
|
||||
data = None
|
||||
@@ -38,57 +46,59 @@ def convertEntry(file,path,destPath,returnData):
|
||||
extractDef = extractData
|
||||
if extractData["exceptions"] != None:
|
||||
for exception in extractData["exceptions"]:
|
||||
if str(path/file)==exception:
|
||||
if str(path / file) == exception:
|
||||
extractDef = None
|
||||
break
|
||||
|
||||
|
||||
if extractDef != None:
|
||||
destFileName = os.path.splitext(destFileName)[0]+extractDef["destExtension"]
|
||||
destFileName = os.path.splitext(destFileName)[0] + extractDef["destExtension"]
|
||||
|
||||
targetTime = 0
|
||||
if destPath != None and os.path.exists(destPath/destFileName):
|
||||
targetTime = os.path.getmtime(destPath/destFileName)
|
||||
if destPath != None and os.path.exists(destPath / destFileName):
|
||||
targetTime = os.path.getmtime(destPath / destFileName)
|
||||
sourceTime = 0
|
||||
if targetTime != 0:
|
||||
if os.path.isdir(path/file):
|
||||
sourceTime = getMaxDateFromDir(path/file)
|
||||
if os.path.isdir(path / file):
|
||||
sourceTime = getMaxDateFromDir(path / file)
|
||||
else:
|
||||
sourceTime = os.path.getmtime(path/file)
|
||||
sourceTime = os.path.getmtime(path / file)
|
||||
if returnData == False and sourceTime < targetTime:
|
||||
return destFileName
|
||||
|
||||
|
||||
if extractDef != None:
|
||||
data = extractDef["convertFunction"](path/file,convertEntry)
|
||||
data = extractDef["convertFunction"](path / file, convertEntry)
|
||||
|
||||
if mustBeCompressed == True:
|
||||
if data == None:
|
||||
data = open(path/file,"rb").read()
|
||||
data = open(path / file, "rb").read()
|
||||
data = oead.yaz0.compress(data)
|
||||
if returnData == True:
|
||||
if data == None and returnData == True:
|
||||
data = open(path/file,"rb").read()
|
||||
return destFileName,data
|
||||
data = open(path / file, "rb").read()
|
||||
return destFileName, data
|
||||
else:
|
||||
print(str(path/file)+" -> "+str(destPath/destFileName))
|
||||
print(str(path / file) + " -> " + str(destPath / destFileName))
|
||||
if data != None:
|
||||
open(destPath/destFileName,"wb").write(data)
|
||||
open(destPath / destFileName, "wb").write(data)
|
||||
else:
|
||||
shutil.copy(path/file,destPath/destFileName)
|
||||
shutil.copy(path / file, destPath / destFileName)
|
||||
return destFileName
|
||||
|
||||
|
||||
def copy(path, destPath):
|
||||
for file in os.listdir(path):
|
||||
split = os.path.splitext(file)
|
||||
if len(split[1])==0 and os.path.isdir(path/file):
|
||||
#is a standard directory
|
||||
if not Path(destPath/file).exists():
|
||||
os.mkdir(destPath/file)
|
||||
copy(path/file,destPath/file)
|
||||
if len(split[1]) == 0 and os.path.isdir(path / file):
|
||||
# is a standard directory
|
||||
if not Path(destPath / file).exists():
|
||||
os.mkdir(destPath / file)
|
||||
copy(path / file, destPath / file)
|
||||
else:
|
||||
#either a file or directory that needs to be converted
|
||||
convertEntry(file,path,destPath,False)
|
||||
# either a file or directory that needs to be converted
|
||||
convertEntry(file, path, destPath, False)
|
||||
|
||||
#copy(Path("srcArc"),Path("arcDest"))
|
||||
|
||||
# copy(Path("srcArc"),Path("arcDest"))
|
||||
|
||||
aMemRels = """d_a_alldie.rel
|
||||
d_a_andsw2.rel
|
||||
@@ -258,41 +268,46 @@ def copyRelFiles(gamePath, buildPath, aMemList, mMemList):
|
||||
relNew.close()
|
||||
else:
|
||||
relArcPaths.append(fullPath)
|
||||
|
||||
if os.path.exists(buildPath/"RELS.arc") == False:
|
||||
os.mkdir(buildPath/"RELS.arc")
|
||||
os.mkdir(buildPath/"RELS.arc/rels")
|
||||
os.mkdir(buildPath/"RELS.arc/rels/mmem")
|
||||
os.mkdir(buildPath/"RELS.arc/rels/amem")
|
||||
|
||||
filesTxtData = "Folder:rels/amem/\nFolder:rels/mmem/\nFolder:rels/./\nFolder:rels/../\n"
|
||||
for i,rel in enumerate(aMemRels.splitlines()):
|
||||
filesTxtData = filesTxtData + str(i+4) + ":rels/amem/" + rel + ":0xa500\n"
|
||||
if os.path.exists(buildPath / "RELS.arc") == False:
|
||||
os.mkdir(buildPath / "RELS.arc")
|
||||
os.mkdir(buildPath / "RELS.arc/rels")
|
||||
os.mkdir(buildPath / "RELS.arc/rels/mmem")
|
||||
os.mkdir(buildPath / "RELS.arc/rels/amem")
|
||||
|
||||
filesTxtData = (
|
||||
"Folder:rels/amem/\nFolder:rels/mmem/\nFolder:rels/./\nFolder:rels/../\n"
|
||||
)
|
||||
for i, rel in enumerate(aMemRels.splitlines()):
|
||||
filesTxtData = filesTxtData + str(i + 4) + ":rels/amem/" + rel + ":0xa500\n"
|
||||
filesTxtData = filesTxtData + "Folder:rels/amem/./\nFolder:rels/amem/../\n"
|
||||
for i,rel in enumerate(mMemRels.splitlines()):
|
||||
filesTxtData = filesTxtData + str(i+83) + ":rels/mmem/" + rel + ":0xa500\n"
|
||||
for i, rel in enumerate(mMemRels.splitlines()):
|
||||
filesTxtData = filesTxtData + str(i + 83) + ":rels/mmem/" + rel + ":0xa500\n"
|
||||
filesTxtData = filesTxtData + "Folder:rels/mmem/./\nFolder:rels/mmem/../\n"
|
||||
open(buildPath/"RELS.arc/_files.txt","w").write(filesTxtData)
|
||||
open(buildPath / "RELS.arc/_files.txt", "w").write(filesTxtData)
|
||||
for rel in relArcPaths:
|
||||
for rel2 in aMemRels.splitlines():
|
||||
if str(rel).find(rel2) != -1:
|
||||
sourceRel = open(rel,"rb").read()
|
||||
open(buildPath/"RELS.arc/rels/amem/"/rel2,"wb").write(oead.yaz0.compress(sourceRel))
|
||||
sourceRel = open(rel, "rb").read()
|
||||
open(buildPath / "RELS.arc/rels/amem/" / rel2, "wb").write(
|
||||
oead.yaz0.compress(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,"wb").write(oead.yaz0.compress(sourceRel))
|
||||
sourceRel = open(rel, "rb").read()
|
||||
open(buildPath / "RELS.arc/rels/mmem/" / rel2, "wb").write(
|
||||
oead.yaz0.compress(sourceRel)
|
||||
)
|
||||
break
|
||||
|
||||
print("Creating RELS.arc")
|
||||
open(buildPath/"dolzel2/game/files/RELS.arc","wb").write(libarc.convert_dir_to_arc(buildPath/"RELS.arc",convertEntry))
|
||||
|
||||
open(buildPath / "dolzel2/game/files/RELS.arc", "wb").write(
|
||||
libarc.convert_dir_to_arc(buildPath / "RELS.arc", convertEntry)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
def main(gamePath, buildPath,copyCode):
|
||||
def main(gamePath, buildPath, copyCode):
|
||||
if not gamePath.exists():
|
||||
gamePath.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -309,11 +324,11 @@ def main(gamePath, buildPath,copyCode):
|
||||
os.chdir(previousDir)
|
||||
|
||||
print("Copying game files...")
|
||||
if os.path.exists(buildPath/"dolzel2") == False:
|
||||
os.mkdir(buildPath/"dolzel2")
|
||||
if os.path.exists(buildPath/"dolzel2"/"game") == False:
|
||||
os.mkdir(buildPath/"dolzel2/game")
|
||||
copy(gamePath, Path(buildPath/"dolzel2/game").absolute())
|
||||
if os.path.exists(buildPath / "dolzel2") == False:
|
||||
os.mkdir(buildPath / "dolzel2")
|
||||
if os.path.exists(buildPath / "dolzel2" / "game") == False:
|
||||
os.mkdir(buildPath / "dolzel2/game")
|
||||
copy(gamePath, Path(buildPath / "dolzel2/game").absolute())
|
||||
|
||||
if copyCode != "noCopyCode":
|
||||
print(
|
||||
@@ -321,9 +336,12 @@ def main(gamePath, buildPath,copyCode):
|
||||
+ " -> "
|
||||
+ str(buildPath / "dolzel2/game/sys/main.dol")
|
||||
)
|
||||
shutil.copyfile(buildPath / "dolzel2/main_shift.dol", buildPath / "dolzel2/game/sys/main.dol")
|
||||
shutil.copyfile(
|
||||
buildPath / "dolzel2/main_shift.dol",
|
||||
buildPath / "dolzel2/game/sys/main.dol",
|
||||
)
|
||||
|
||||
copyRelFiles(gamePath,buildPath, aMemRels.splitlines(), mMemRels.splitlines())
|
||||
copyRelFiles(gamePath, buildPath, aMemRels.splitlines(), mMemRels.splitlines())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user