Browse Source
* Initial Linux/GCC support commit * Add instructins for linux in the README * apply suggestions by @Erotemic and @Emill * Fix python 3.10 symlink line * Fix func_80041E80 type mismatch (#3) Type mismatch functions.h:664 * Makefile: clean OTRExporter/libultraship/ZAPDTR with distclean and fix CXX_FILES * Makefile: find C/CXX_FILES automatically * Makefile: remove ugly conditions in find commands * cleanup _MSC_VER usage * fix Windows build * cleanup extraction scripts * fix Windows build * Fix Windows path separator issue * fix rumble support for linux * use glew-cmake in dockerfile * add pulseaudio backend * fix ZAPDTR linkage * Check for "soh.elf" in directory (#6) hide second button if `soh.exe` or `soh.elf` is present * Fix hardcoded segment addresses (#5) * fix condition * hack lus -> soh dep for ZAPDTR Co-authored-by: sholdee <102821812+sholdee@users.noreply.github.com> Co-authored-by: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com> Co-authored-by: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com>pull/282/head


116 changed files with 1403 additions and 4054 deletions
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
|
||||
|
||||
FROM ubuntu:21.04 as build |
||||
|
||||
ENV LANG C.UTF-8 |
||||
ARG DEBIAN_FRONTEND=noninteractive |
||||
|
||||
RUN dpkg --add-architecture i386 && \ |
||||
apt-get update && \ |
||||
apt-get upgrade -y && \ |
||||
apt-get install -y \ |
||||
binutils:i386 \ |
||||
gcc-10:i386 \ |
||||
g++-10:i386 \ |
||||
python3.10 \ |
||||
python \ |
||||
make \ |
||||
cmake \ |
||||
git \ |
||||
lld \ |
||||
libsdl2-dev:i386 \ |
||||
zlib1g-dev:i386 \ |
||||
libbz2-dev:i386 \ |
||||
libpng-dev:i386 \ |
||||
libgles2-mesa-dev && \ |
||||
ln -sf /usr/bin/python3.10 /usr/bin/python3 && \ |
||||
ln -s /usr/bin/gcc-10 /usr/bin/gcc && \ |
||||
ln -s /usr/bin/gcc-10 /usr/bin/cc && \ |
||||
ln -s /usr/bin/g++-10 /usr/bin/g++ && \ |
||||
ln -s /usr/bin/g++-10 /usr/bin/c++ |
||||
|
||||
RUN git clone https://github.com/Perlmint/glew-cmake.git && \ |
||||
cmake glew-cmake && \ |
||||
make -j$(nproc) && \ |
||||
make install ARCH64=false |
||||
|
||||
RUN mkdir /soh |
||||
WORKDIR /soh |
@ -1,125 +0,0 @@
@@ -1,125 +0,0 @@
|
||||
#!/usr/bin/env python3 |
||||
|
||||
import argparse, json, os, signal, time, sys, shutil |
||||
from multiprocessing import Pool, cpu_count, Event, Manager, ProcessError |
||||
import shutil |
||||
|
||||
def SignalHandler(sig, frame): |
||||
print(f'Signal {sig} received. Aborting...') |
||||
mainAbort.set() |
||||
# Don't exit immediately to update the extracted assets file. |
||||
|
||||
def BuildOTR(): |
||||
shutil.copyfile("baserom/Audiobank", "Extract/Audiobank") |
||||
shutil.copyfile("baserom/Audioseq", "Extract/Audioseq") |
||||
shutil.copyfile("baserom/Audiotable", "Extract/Audiotable") |
||||
|
||||
shutil.copytree("assets", "Extract/assets") |
||||
|
||||
execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out" |
||||
|
||||
execStr += " botr -se OTR" |
||||
|
||||
print(execStr) |
||||
exitValue = os.system(execStr) |
||||
if exitValue != 0: |
||||
print("\n") |
||||
print("Error when building the OTR file...", file=os.sys.stderr) |
||||
print("Aborting...", file=os.sys.stderr) |
||||
print("\n") |
||||
|
||||
def ExtractFile(xmlPath, outputPath, outputSourcePath): |
||||
execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPD/ZAPD.out" |
||||
execStr += " e -eh -i %s -b baserom/ -o %s -osf %s -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath, outputPath, outputSourcePath) |
||||
|
||||
if "overlays" in xmlPath: |
||||
execStr += " --static" |
||||
|
||||
print(execStr) |
||||
exitValue = os.system(execStr) |
||||
#exitValue = 0 |
||||
if exitValue != 0: |
||||
print("\n") |
||||
print("Error when extracting from file " + xmlPath, file=os.sys.stderr) |
||||
print("Aborting...", file=os.sys.stderr) |
||||
print("\n") |
||||
|
||||
def ExtractFunc(fullPath): |
||||
*pathList, xmlName = fullPath.split(os.sep) |
||||
objectName = os.path.splitext(xmlName)[0] |
||||
|
||||
outPath = os.path.join("..\\soh\\assets\\", *pathList[5:], objectName) |
||||
os.makedirs(outPath, exist_ok=True) |
||||
outSourcePath = outPath |
||||
|
||||
ExtractFile(fullPath, outPath, outSourcePath) |
||||
|
||||
def initializeWorker(abort, test): |
||||
global globalAbort |
||||
globalAbort = abort |
||||
|
||||
|
||||
def main(): |
||||
parser = argparse.ArgumentParser(description="baserom asset extractor") |
||||
parser.add_argument("-s", "--single", help="asset path relative to assets/, e.g. objects/gameplay_keep") |
||||
parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones.", action="store_true") |
||||
parser.add_argument("-u", "--unaccounted", help="Enables ZAPD unaccounted detector warning system.", action="store_true") |
||||
parser.add_argument("-v", "--version", help="Sets game version.") |
||||
args = parser.parse_args() |
||||
|
||||
global mainAbort |
||||
mainAbort = Event() |
||||
manager = Manager() |
||||
signal.signal(signal.SIGINT, SignalHandler) |
||||
|
||||
extractedAssetsTracker = manager.dict() |
||||
|
||||
xmlVer = "GC_NMQ_D" |
||||
|
||||
if (args.version == "gc_pal_nmpq"): |
||||
xmlVer = "GC_NMQ_PAL_F" |
||||
elif (args.version == "dbg_mq"): |
||||
xmlVer = "GC_MQ_D" |
||||
|
||||
asset_path = args.single |
||||
if asset_path is not None: |
||||
fullPath = os.path.join("..\\soh\\assets", "xml", asset_path + ".xml") |
||||
if not os.path.exists(fullPath): |
||||
print(f"Error. File {fullPath} doesn't exists.", file=os.sys.stderr) |
||||
exit(1) |
||||
|
||||
ExtractFunc(fullPath) |
||||
else: |
||||
extract_text_path = "assets/text/message_data.h" |
||||
if os.path.isfile(extract_text_path): |
||||
extract_text_path = None |
||||
extract_staff_text_path = "assets/text/message_data_staff.h" |
||||
if os.path.isfile(extract_staff_text_path): |
||||
extract_staff_text_path = None |
||||
|
||||
xmlFiles = [] |
||||
for currentPath, _, files in os.walk(os.path.join("..\\soh\\assets\\xml\\", xmlVer)): |
||||
for file in files: |
||||
fullPath = os.path.join(currentPath, file) |
||||
if file.endswith(".xml"): |
||||
xmlFiles.append(fullPath) |
||||
|
||||
try: |
||||
numCores = 2 |
||||
print("Extracting assets with " + str(numCores) + " CPU cores.") |
||||
with Pool(numCores, initializer=initializeWorker, initargs=(mainAbort, 0)) as p: |
||||
p.map(ExtractFunc, xmlFiles) |
||||
except Exception as e: |
||||
print("Warning: Multiprocessing exception ocurred.", file=os.sys.stderr) |
||||
print("Disabling mutliprocessing.", file=os.sys.stderr) |
||||
|
||||
initializeWorker(mainAbort, 0) |
||||
for singlePath in xmlFiles: |
||||
ExtractFunc(singlePath) |
||||
|
||||
|
||||
BuildOTR() |
||||
shutil.rmtree("Extract") |
||||
|
||||
if __name__ == "__main__": |
||||
main() |
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/python3 |
||||
|
||||
import os |
||||
import sys |
||||
import struct |
||||
from multiprocessing import Pool, cpu_count |
||||
from rom_info import Z64Rom |
||||
import rom_chooser |
||||
|
||||
|
||||
rom = None |
||||
|
||||
def initialize_worker(input_rom): |
||||
global rom |
||||
rom = input_rom |
||||
|
||||
def ExtractFunc(i): |
||||
|
||||
dma_file = rom.getDmaEntryByIndex(i) |
||||
dma_data = rom.readDmaEntry(dma_file) |
||||
|
||||
filename = '../soh/baserom/' + rom.version.file_table[i] |
||||
print('extracting ' + filename + " (0x%08X, 0x%08X)" % (dma_file.virtStart, dma_file.virtEnd)) |
||||
|
||||
try: |
||||
with open(filename, 'wb') as f: |
||||
f.write(dma_data) |
||||
except IOError: |
||||
print('failed to write file ' + filename) |
||||
|
||||
# TODO: handle this better |
||||
if dma_file.compressed: |
||||
os.system('tools/yaz0 -d ' + filename + ' ' + filename) |
||||
|
||||
##################################################################### |
||||
|
||||
def main(): |
||||
try: |
||||
os.mkdir('../soh/baserom') |
||||
except: |
||||
pass |
||||
|
||||
rom_path = rom_chooser.chooseROM() |
||||
input_rom = Z64Rom(rom_path) |
||||
|
||||
# extract files |
||||
num_cores = cpu_count() |
||||
print("Extracting baserom with " + str(num_cores) + " CPU cores.") |
||||
with Pool(num_cores, initialize_worker, (input_rom,)) as p: |
||||
p.map(ExtractFunc, range(len(input_rom.version.file_table))) |
||||
|
||||
if __name__ == "__main__": |
||||
main() |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
import os, sys, glob |
||||
|
||||
from rom_info import Z64Rom |
||||
|
||||
def chooseROM(): |
||||
roms = [] |
||||
|
||||
for file in glob.glob("*.z64"): |
||||
if Z64Rom.isValidRom(file): |
||||
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): |
||||
return roms[0] |
||||
|
||||
print(str(len(roms))+ " roms found, please select one by pressing 1-"+str(len(roms))) |
||||
|
||||
for i in range(len(roms)): |
||||
print(str(i+1)+ ". " + roms[i]) |
||||
|
||||
while(1): |
||||
try: |
||||
selection = int(input()) |
||||
except: |
||||