1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-14 05:19:36 +00:00
oot/extract_assets.py
Ethan Roseman bda5b83346
MacOS ZAPD fixes (#606)
* Adding -Wno-return-type to GCC check for MacOS

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "0325ec161"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "0325ec161"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "605f6972e"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "605f6972e"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "6e6ad445a"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "6e6ad445a"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* Rewrote func to avoid returns without values
2021-01-10 04:04:36 -05:00

46 lines
1.4 KiB
Python
Executable file

#!/usr/bin/python3
import os
from shutil import copyfile
from multiprocessing import Pool
from multiprocessing import cpu_count
def Extract(xmlPath, outputPath):
ExtractFile(xmlPath, outputPath, 1, 0)
def ExtractScene(xmlPath, outputPath):
ExtractFile(xmlPath, outputPath, 1, 1)
def ExtractFile(xmlPath, outputPath, genSrcFile, incFilePrefix):
execStr = "tools/ZAPD/ZAPD.out e -eh -i %s -b baserom/ -o %s -gsf %i -ifp %i -sm tools/ZAPD/SymbolMap_OoTMqDbg.txt" % (xmlPath, outputPath, genSrcFile, incFilePrefix)
print(execStr)
os.system(execStr)
def ExtractFunc(fullPath):
outPath = ("assets/" + fullPath.split("assets/xml/")[1]).split(".xml")[0]
if (fullPath.startswith("assets/xml/scenes/")):
ExtractScene(fullPath, outPath)
else:
Extract(fullPath, outPath)
def main():
xmlFiles = []
for currentPath, folders, files in os.walk("assets"):
for file in files:
fullPath = os.path.join(currentPath, file)
if file.endswith(".xml") and currentPath.startswith("assets/xml/"):
outPath = ("assets/" + fullPath.split("assets/xml/")[1]).split(".xml")[0]
xmlFiles.append(fullPath)
numCores = cpu_count()
print("Extracting assets with " + str(numCores) + " CPU cores.")
p = Pool(numCores)
p.map(ExtractFunc, xmlFiles)
#os.system("make resources")
if __name__ == "__main__":
main()