mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-25 10:52:19 -05:00
7b08f98b8c
* Changes OTR Extraction to have specific mq and nonmq paths. Also updates the game to load resources according to whether or not Master Quest or Vanilla is loaded. * Removes unneeded code from the last commit. * Fixes some weird formatting in ZRom.c * Loads oot-mq.otr and patches oot.otr on top, if both are present. If only one or the other are present, it becomes the only and main OTR. * Adds ImGui Logic for whether or an MQ Checkbox. Checkbox checked only specifies whether new saves should be MQ or not. Checkbox is disabled or force-enabled according to which OTRs are loaded. Also as a necessity includes tracking what game versions have been loaded from the OTRs. * Adds MQ settings logic for Randomizer's ImGui menu. * Writes Master Quest dungeons to the spoiler log * Loads MQ Dungeons from spoiler, persists in save, and loads when appropriate. * Adds logic to prevent loading or creating incompatible rando saves. * Fixdes some linux build issues and new rando save issues * Makes appimage create both vanilla and mq otrs If either rom is present, it makes the corresponding OTR. If both are present, it will make both. If one OTR is present but both roms are present, it will create the missing OTR. * Makes it so a randomized save file will not be marked as MQ. * Refactors to load all OTRs from MainPath or a specific list. Also adds the ability to take a std::unordered_set of hashes to validate each OTR's version file against. * Fixes a syntax error * Makes ExtractAssets output Vanilla and MQ OTRs if both roms are present * Fixes asset generation bug. * Partially working fix for dual OTR extract_assets Currently the cmake ExtractAssets target will return with a 1 if you only end up exporting one type of OTR isntead of both. Haven't found a great way to only attempt to copy a file if it exists from within cmake. It does actually correctly copy the OTR that is generated, despite the error from copying the other one. Pushing as is for now but will keep investigating. * Adds oot-mq.otr to the gitignore. * Makes ExtractAssets not fail on only one rom/OTR. * Removes PatchesPath from the constructors requiring OTRFiles vector. * Renames OOT_UNKNOWN to just UNKNOWN to remove OOT specific reference. * Removes randomizing MQ Dungeons and re-disables MQ rando. Doing this so the PR can get merged quicker with just the Dual OTR support and won't need to wait on rando logic to be updated. That will happen in another PR directly after the merge. * Update mac startup script for dual otr * Update soh/macosx/soh-macos.sh * Update soh/macosx/soh-macos.sh * Update soh/macosx/soh-macos.sh * Implements new BinaryReader to fix Linux build issue. BinaryReader itself comes from https://github.com/Moneyl/BinaryTools I added a wrapper to adapt it to the ABI from ZAPD's Binary Reader and add Endianness checking. I also had to copy a handful of other bits and pieces from ZAPD to make it all function as expected. * A few edits to the updatream BinaryReader to compile it on Linux. * Adds the Endianness to the first byte of the version file. * Fixes Jenkins * Addresses some of Kenix's comments * Renames `ReadNullTerminatedString` to `ReadCString` * Refactors Archive::LoadFile into a private method with more arguments. * Removes BitConverter and extends existing endianness.h instead. * Fixes an endianness issue with the version file. Co-authored-by: Garrett Cox <garrettjcox@gmail.com>
98 lines
3.0 KiB
Python
98 lines
3.0 KiB
Python
from enum import Enum
|
|
from tabnanny import check
|
|
import struct
|
|
|
|
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"
|
|
|
|
@classmethod
|
|
def has_value(self, value):
|
|
return value in self._value2member_map_
|
|
|
|
class RomVersion:
|
|
def __init__(self, file_table_path, file_table_off, xml_ver):
|
|
self.file_table_off = file_table_off
|
|
self.xml_ver = xml_ver
|
|
with open(file_table_path, 'r') as f:
|
|
self.file_table = [line.strip('\n') for line in f]
|
|
|
|
ROM_INFO_TABLE = dict()
|
|
ROM_INFO_TABLE[Checksums.OOT_PAL_GC] = RomVersion("CFG/filelists/gamecube_pal.txt", 0x7170, "GC_NMQ_PAL_F")
|
|
ROM_INFO_TABLE[Checksums.OOT_PAL_GC_DBG1] = RomVersion("CFG/filelists/dbg.txt", 0x12F70, "GC_NMQ_D")
|
|
ROM_INFO_TABLE[Checksums.OOT_PAL_GC_MQ_DBG] = RomVersion("CFG/filelists/dbg.txt", 0x12F70, "GC_MQ_D")
|
|
|
|
class RomDmaEntry:
|
|
def __init__(self, rom, i):
|
|
|
|
off = rom.version.file_table_off + 16 * i
|
|
|
|
(self.virtStart, \
|
|
self.virtEnd, \
|
|
self.physStart, \
|
|
self.physEnd) = struct.unpack('>IIII', rom.rom_data[off:off+4*4])
|
|
|
|
self.compressed = self.physEnd != 0
|
|
self.size = self.physEnd - self.physStart \
|
|
if self.compressed \
|
|
else self.virtEnd - self.virtStart
|
|
self.name = rom.version.file_table[i]
|
|
|
|
|
|
class Z64Rom:
|
|
def __init__(self, file_path):
|
|
self.file_path = file_path
|
|
with open(file_path, 'rb') as f:
|
|
self.rom_data = f.read()
|
|
|
|
self.is_valid = len(self.rom_data) > 20 * 1024 * 1024
|
|
|
|
if not self.is_valid:
|
|
return
|
|
|
|
# get checkum
|
|
checksum_str = self.rom_data[16:16+4].hex().upper()
|
|
self.checksum = Checksums(checksum_str) if Checksums.has_value(checksum_str) else Checksums.OOT_UNKNOWN
|
|
|
|
if self.checksum == Checksums.OOT_UNKNOWN:
|
|
self.is_valid = False
|
|
return
|
|
|
|
if self.checksum in [Checksums.OOT_NTSC_JP_MQ, Checksums.OOT_NTSC_US_MQ, Checksums.OOT_PAL_GC_MQ_DBG, Checksums.OOT_PAL_MQ]:
|
|
self.isMq = True
|
|
else:
|
|
self.isMq = False
|
|
|
|
# get rom version
|
|
self.version = ROM_INFO_TABLE[self.checksum]
|
|
|
|
def getDmaEntryByIndex(self, i):
|
|
return RomDmaEntry(self, i)
|
|
|
|
def readDmaEntry(self, entry):
|
|
return self.rom_data[entry.physStart:entry.physStart + entry.size]
|
|
|
|
@staticmethod
|
|
def isValidRom(rom_path):
|
|
return Z64Rom(rom_path).is_valid
|
|
|
|
@staticmethod
|
|
def isMqRom(rom_path):
|
|
return Z64Rom(rom_path).isMq
|