mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-02-07 02:40:30 -05:00
Implement todo in extract_assets.py (#154)
* Update extract_assets.py * Update extract_assets.py * Update extract_assets.py * Update extract_assets.py * Update extract_assets.py * Update README.md * Update extract_assets.py
This commit is contained in:
parent
ceef4a9453
commit
a01392c40e
@ -1,14 +1,51 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse, json, os, signal, time, sys, shutil
|
# How to use:
|
||||||
|
# Place a rom in this directory then run the script.
|
||||||
|
# If you are using multiple roms, the script will let you choose one.
|
||||||
|
# To choose with a commandline argument:
|
||||||
|
# Python3 extract_assets.py <number>
|
||||||
|
# Invalid input results in the first rom being selected
|
||||||
|
|
||||||
|
import json, os, signal, time, sys, shutil, glob
|
||||||
from multiprocessing import Pool, cpu_count, Event, Manager, ProcessError
|
from multiprocessing import Pool, cpu_count, Event, Manager, ProcessError
|
||||||
|
from enum import Enum
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
def BuildOTR(xmlPath):
|
romVer = "..\\soh\\baserom_non_mq.z64"
|
||||||
|
roms = [];
|
||||||
|
checksums = ["", "", ""];
|
||||||
|
|
||||||
|
class Checksums(Enum):
|
||||||
|
OOT_NTSC_10 = "EC7011B7"
|
||||||
|
OOT_NTSC_11 = "D43DA81F"
|
||||||
|
OOT_NTSC_12 = "693BA2AE"
|
||||||
|
OOT_PAL_10 = "B044B569"
|
||||||
|
OOT_PAL_11 = "B2055FBD"
|
||||||
|
OOT_NTSC_JP_GC_CE = "F7F52DB8"
|
||||||
|
OOT_NTSC_JP_GC = "F611F4BA"
|
||||||
|
OOT_NTSC_US_GC = "F3DD35BA"
|
||||||
|
OOT_PAL_GC = "09465AC3"
|
||||||
|
OOT_NTSC_JP_MQ = "F43B45BA"
|
||||||
|
OOT_NTSC_US_MQ = "F034001A"
|
||||||
|
OOT_PAL_MQ = "1D4136F3"
|
||||||
|
OOT_PAL_GC_DBG1 = "871E1C92"
|
||||||
|
OOT_PAL_GC_DBG2 = "87121EFE"
|
||||||
|
OOT_PAL_GC_MQ_DBG = "917D18F6"
|
||||||
|
OOT_IQUE_TW = "3D81FB3E"
|
||||||
|
OOT_IQUE_CN = "B1E1E07B"
|
||||||
|
OOT_UNKNOWN = "FFFFFFFF"
|
||||||
|
|
||||||
|
CompatibleChecksums = [
|
||||||
|
Checksums.OOT_PAL_GC,
|
||||||
|
Checksums.OOT_PAL_GC_DBG1
|
||||||
|
]
|
||||||
|
|
||||||
|
def BuildOTR(xmlPath, rom):
|
||||||
shutil.copytree("assets", "Extract/assets")
|
shutil.copytree("assets", "Extract/assets")
|
||||||
|
|
||||||
execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out"
|
execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out"
|
||||||
execStr += " ed -i %s -b baserom.z64 -fl CFG\\filelists -o placeholder -osf placeholder -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath)
|
execStr += " ed -i %s -b %s -fl CFG\\filelists -o placeholder -osf placeholder -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath, rom)
|
||||||
|
|
||||||
print(execStr)
|
print(execStr)
|
||||||
exitValue = os.system(execStr)
|
exitValue = os.system(execStr)
|
||||||
@ -18,23 +55,95 @@ def BuildOTR(xmlPath):
|
|||||||
print("Aborting...", file=os.sys.stderr)
|
print("Aborting...", file=os.sys.stderr)
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
def main():
|
def checkChecksum(rom):
|
||||||
parser = argparse.ArgumentParser(description="baserom asset extractor")
|
r = open(rom, "rb")
|
||||||
parser.add_argument("-v", "--version", help="Sets game version.")
|
r.seek(16)
|
||||||
args = parser.parse_args()
|
bytes = r.read(4).hex().upper()
|
||||||
|
r.close()
|
||||||
|
|
||||||
# TODO: Read from makerom file to automatically determine game version
|
for checksum in Checksums:
|
||||||
xmlVer = "GC_NMQ_D"
|
if (checksum.value == bytes):
|
||||||
|
|
||||||
|
for compat in CompatibleChecksums:
|
||||||
|
if (checksum.name == compat.name):
|
||||||
|
print("Compatible rom found!")
|
||||||
|
return checksum
|
||||||
|
print("Valid oot rom found. However, not compatible with SoH.")
|
||||||
|
print("Compatible roms:")
|
||||||
|
for compat in CompatibleChecksums:
|
||||||
|
print(compat.name+" | 0x"+compat.value)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
print("Wrong rom! No valid checksum found")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if (args.version == "gc_pal_nmpq"):
|
def main():
|
||||||
xmlVer = "GC_NMQ_PAL_F"
|
|
||||||
elif (args.version == "dbg_mq"):
|
romToUse = "";
|
||||||
xmlVer = "GC_MQ_D"
|
|
||||||
|
for file in glob.glob("*.z64"):
|
||||||
|
roms.append(file)
|
||||||
|
|
||||||
|
if not (roms):
|
||||||
|
print("Error: No roms located, place one in the OTRExporter directory", file=os.sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if (len(roms) > 1):
|
||||||
|
|
||||||
|
# If commandline args exist
|
||||||
|
if (len(sys.argv) > 1):
|
||||||
|
try:
|
||||||
|
if ((int(sys.argv[1]) - 1) < 1):
|
||||||
|
romToUse = roms[0]
|
||||||
|
|
||||||
|
elif ((int(sys.argv[1]) - 1) > len(roms)):
|
||||||
|
romToUse = roms[len(roms) - 1]
|
||||||
|
|
||||||
|
else:
|
||||||
|
romToUse = roms[int(sys.argv[1]) - 1]
|
||||||
|
except:
|
||||||
|
romToUse = roms[0]
|
||||||
|
|
||||||
|
# No commandline args, select rom using user input
|
||||||
|
else:
|
||||||
|
|
||||||
|
print(str(len(roms))+" roms found, please select one by pressing 1-"+str(len(roms)))
|
||||||
|
|
||||||
|
count = 1
|
||||||
|
for list in range(len(roms)):
|
||||||
|
print(str(count)+". "+roms[list])
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
while(1):
|
||||||
|
try:
|
||||||
|
selection = int(input())
|
||||||
|
except:
|
||||||
|
print("Bad input. Try again with the number keys.")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if (selection < 1 or selection > len(roms)):
|
||||||
|
print("Bad input. Try again.")
|
||||||
|
continue
|
||||||
|
|
||||||
|
else: break
|
||||||
|
|
||||||
|
romToUse = roms[selection - 1]
|
||||||
|
|
||||||
|
else:
|
||||||
|
romToUse = roms[0]
|
||||||
|
|
||||||
|
match checkChecksum(romToUse).name:
|
||||||
|
case Checksums.OOT_PAL_GC:
|
||||||
|
xmlVer = "GC_NMQ_PAL_F"
|
||||||
|
case Checksums.OOT_PAL_GC_DBG1:
|
||||||
|
xmlVer = "GC_MQ_D"
|
||||||
|
case _: # default case
|
||||||
|
xmlVer = "GC_NMQ_D"
|
||||||
|
|
||||||
if (os.path.exists("Extract")):
|
if (os.path.exists("Extract")):
|
||||||
shutil.rmtree("Extract")
|
shutil.rmtree("Extract")
|
||||||
|
|
||||||
BuildOTR("..\\soh\\assets\\xml\\" + xmlVer + "\\")
|
BuildOTR("..\\soh\\assets\\xml\\" + xmlVer + "\\", romToUse)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
28
README.md
28
README.md
@ -55,20 +55,22 @@ Official Discord: https://discord.com/invite/BtBmd55HVH
|
|||||||
2. Install [Visual Studio 2022 Community Edition](https://visualstudio.microsoft.com/vs/community/)
|
2. Install [Visual Studio 2022 Community Edition](https://visualstudio.microsoft.com/vs/community/)
|
||||||
2b. In the Visual Studio Installer, install `MSVC v142 - VS 2019 C++`.
|
2b. In the Visual Studio Installer, install `MSVC v142 - VS 2019 C++`.
|
||||||
4. Clone the Ship of Harkinian repository.
|
4. Clone the Ship of Harkinian repository.
|
||||||
5. Place `oot debug` rom (not Master Quest) in the `soh` folder named `baserom_original_non_mq`.
|
5. Place one or more [compatible](#compatible-roms) roms in the `OTRExporter` directory with namings of your choice.
|
||||||
6. Launch `soh/fixbaserom.py`.
|
6. Run `OTRExporter/OTRExporter.sln`.
|
||||||
7. Launch `soh/extract_baserom.py`.
|
7. Switch the solution to `Release x64`.
|
||||||
8. Copy the `baserom` folder from the `soh` folder into the `OTRExporter` folder.
|
8. Build the solution.
|
||||||
9. Run `OTRExporter/OTRExporter.sln`.
|
9. Launching `OTRExporter/extract_assets.py` will generate an `oot.otr` archive file in `OTRExporter/oot.otr`.
|
||||||
10. Switch the solution to `Release x64`.
|
10. Run `soh/soh.sln`
|
||||||
11. Build the solution.
|
11. Switch the solution to `Release x86`.
|
||||||
12. Launching `OTRExporter/extract_assets.py` will generate an `oot.otr` archive file in `OTRExporter/oot.otr`.
|
12. Build the solution.
|
||||||
13. Run `soh/soh.sln`
|
13. Copy the `OTRExporter/oot.otr` archive file to `soh/Release`.
|
||||||
14. Switch the solution to `Release x86`.
|
14. Launch `soh.exe`.
|
||||||
15. Build the solution.
|
|
||||||
16. Copy the `OTRExporter/oot.otr` archive file to `soh/Release`.
|
|
||||||
17. Launch `soh.exe`.
|
|
||||||
|
|
||||||
|
## Compatible Roms
|
||||||
|
```
|
||||||
|
OOT_PAL_GC checksum 0x09465AC3
|
||||||
|
OOT_PAL_GC_DBG1 checksum 0x871E1C92 (debug non-master quest)
|
||||||
|
```
|
||||||
## Troubleshooting The Exporter
|
## Troubleshooting The Exporter
|
||||||
- Affirm that you have an `/assets` folder filled with XMLs in the same directory as OTRGui.exe
|
- Affirm that you have an `/assets` folder filled with XMLs in the same directory as OTRGui.exe
|
||||||
- Affirm that `zapd.exe` exists in the `/assets/extractor` folder
|
- Affirm that `zapd.exe` exists in the `/assets/extractor` folder
|
||||||
|
Loading…
Reference in New Issue
Block a user