From 3b83e40cc6b03d4d1c4564c208fb60cc5ebe56a2 Mon Sep 17 00:00:00 2001 From: Yanis42 <35189056+Yanis42@users.noreply.github.com> Date: Tue, 16 Apr 2024 14:45:30 +0200 Subject: [PATCH] hopefully fixed build issues --- Makefile | 4 + baseroms/hackeroot-mq/checksum.md5 | 2 +- extract_assets.py | 2 +- tools/csdis_re.py | 115 ----------------------------- tools/decompress_baserom.py | 4 +- 5 files changed, 8 insertions(+), 119 deletions(-) delete mode 100644 tools/csdis_re.py diff --git a/Makefile b/Makefile index 9ce878153..cf09a03f4 100644 --- a/Makefile +++ b/Makefile @@ -317,6 +317,10 @@ ifneq ($(VERSION),gc-eu-mq) $(PYTHON) extract_assets.py -j$(N_THREADS) -v $(VERSION) endif $(MAKE) f3dex3 +ifneq ($(VERSION),hackeroot-mq) +# TODO: proper fix (for .s files) + cp baseroms/hackeroot-mq/baserom-decompressed.z64 baseroms/gc-eu-mq-dbg/baserom-decompressed.z64 +endif run: $(ROM) ifeq ($(N64_EMULATOR),) diff --git a/baseroms/hackeroot-mq/checksum.md5 b/baseroms/hackeroot-mq/checksum.md5 index 55af8fae8..78785e2f0 100644 --- a/baseroms/hackeroot-mq/checksum.md5 +++ b/baseroms/hackeroot-mq/checksum.md5 @@ -1 +1 @@ -f0b7f35375f9cc8ca1b2d59d78e35405 build/gc-eu-mq-dbg/oot-gc-eu-mq-dbg.z64 +75e344f41c26ec2ec5ad92caa9e25629 build/hackeroot-mq/baserom.z64 diff --git a/extract_assets.py b/extract_assets.py index 4d80ef48b..b514cc073 100755 --- a/extract_assets.py +++ b/extract_assets.py @@ -29,7 +29,7 @@ def ExtractFile(xmlPath, outputPath, outputSourcePath): Path(outputPath).mkdir(parents=True, exist_ok=True) Path(outputSourcePath).mkdir(parents=True, exist_ok=True) - execStr = f"{zapdPath} e -eh -i {xmlPath} -b baseroms/{VERSION}/segments -o {outputPath} -osf {outputSourcePath} -gsf 1 -rconf {configPath} --cs-float both {ZAPDArgs}" + execStr = f"{zapdPath} e -eh -i {xmlPath} -b extracted/{VERSION}/baserom -o {outputPath} -osf {outputSourcePath} -gsf 1 -rconf {configPath} --cs-float both {ZAPDArgs}" if "overlays" in xmlPath: execStr += " --static" diff --git a/tools/csdis_re.py b/tools/csdis_re.py deleted file mode 100644 index 7bb284c45..000000000 --- a/tools/csdis_re.py +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: 2024 zeldaret -# SPDX-License-Identifier: CC0-1.0 - -# Re-disassemble cutscene scripts part of the source tree, -# using csdis.py and modifying files in-place - - -import re -from pathlib import Path -import struct - -import mapfile_parser - -import csdis -from overlayhelpers import filemap - - -SRC_ENCODING = "UTF-8" - -MAPFILE_P = Path("build/gc-eu-mq-dbg/oot-gc-eu-mq-dbg.map") -BASEROM_SEGMENTS_P = Path("extracted/gc-eu-mq-dbg/baserom/") - -HARDCODED_SYM_ROM = { - "D_8096C1A4": 0xD25834, - "D_80AF0880": 0xEA6860, - "D_80AF10A4": 0xEA7084, - "D_80AF1728": 0xEA7708, - "D_808BCE20": 0xC8BB20, - "D_808BD2A0": 0xC8BFA0, - "D_808BD520": 0xC8C220, - "D_808BD790": 0xC8C490, - "D_80AB431C": 0xE6A38C, - "D_8098786C": 0xD40EFC, - "D_80B4C5D0": 0xF022D0, - "D_80ABF9D0": 0xE75A40, - "D_80ABFB40": 0xE75BB0, - "D_80AF411C": 0xEAA0FC, - "D_80A88164": 0xE3ED34, - "D_808BB2F0": 0xC89FF0, - "D_808BB7A0": 0xC8A4A0, - "D_808BBD90": 0xC8AA90, - "gChildWarpInCS": 0xD45460, - "gAdultWarpOutToTCS": 0xD45340, - "gChildWarpOutToTCS": 0xD45840, - "gChildWarpInToTCS": 0xD45710, - "gAdultWarpInToTCS": 0xD45230, - "gAdultWarpInCS": 0xD44FA0, - "gChildWarpOutCS": 0xD45590, - "gAdultWarpOutCS": 0xD450B0, - "D_8099010C": 0xD4974C, -} - -mapfile = mapfile_parser.MapFile() -mapfile.readMapFile(MAPFILE_P) - -pat_CutsceneData = re.compile( - r""" - CutsceneData - \s+ - ( [^\s]* ) # symbol name - \s* - \[ \s* \] - \s* = \s* - \{ - (?: [^}]* | \n )* - \} ; - """, - re.VERBOSE, -) - - -def get_sym_rom(sym_name: str): - rom = HARDCODED_SYM_ROM.get(sym_name) - if rom: - return rom - print(f"Trying to find {sym_name} from the map (assuming OK build)") - sym = mapfile.findSymbolByName(sym_name) - print(f'"{sym_name}": 0x{sym.symbol.vrom:X}') - return sym.symbol.vrom - - -def repl(m: re.Match): - sym_name = m.group(1) - sym_rom = get_sym_rom(sym_name) - file_result = filemap.GetFromRom(sym_rom) - assert file_result is not None, (sym_name, sym_rom) - data = (BASEROM_SEGMENTS_P / file_result.name).read_bytes() - cs_data_bytes = data[file_result.offset :] - cs_data = [i[0] for i in struct.iter_unpack(">I", cs_data_bytes)] - return ( - f"CutsceneData {sym_name}[] = " - + "{\n" - + ( - "\n".join( - f" {line}" - for line in csdis.disassemble_cutscene(cs_data).splitlines() - ).rstrip() - ) - + "\n};" - ) - - -def main(): - for file_c in Path("src").glob("**/*.c"): - src = file_c.read_text(encoding=SRC_ENCODING) - src_new = pat_CutsceneData.sub(repl, src) - if src_new != src: - file_c.write_text(src_new, encoding=SRC_ENCODING) - print(file_c) - - -if __name__ == "__main__": - main() diff --git a/tools/decompress_baserom.py b/tools/decompress_baserom.py index 13b57265f..ca6994670 100755 --- a/tools/decompress_baserom.py +++ b/tools/decompress_baserom.py @@ -127,7 +127,7 @@ def byte_swap(file_content: bytearray) -> bytearray: def per_version_fixes(file_content: bytearray, version: str) -> bytearray: - if version == "gc-eu-mq-dbg": + if version in {"gc-eu-mq-dbg", "hackeroot-mq"}: # Strip the overdump, which consists of an area of 0xFF bytes (which may # be erased flash memory) and ROM data from an unrelated game print("Stripping overdump...") @@ -227,7 +227,7 @@ def main(): f"Error: Expected a hash of {correct_str_hash} but got {str_hash}. The baserom has probably been tampered, find a new one" ) - if version == "gc-eu-mq-dbg": + if version in {"gc-eu-mq-dbg", "hackeroot-mq"}: if str_hash == "9fede30e3239558cf3993f12b7ed7458": print( "The provided baserom is a rom which has been edited with ZeldaEdit and is not suitable for use with decomp. Find a new one."