hopefully fixed build issues

This commit is contained in:
Yanis42
2024-04-16 14:45:30 +02:00
parent eafdc5db94
commit 3b83e40cc6
5 changed files with 8 additions and 119 deletions

View File

@@ -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),)

View File

@@ -1 +1 @@
f0b7f35375f9cc8ca1b2d59d78e35405 build/gc-eu-mq-dbg/oot-gc-eu-mq-dbg.z64
75e344f41c26ec2ec5ad92caa9e25629 build/hackeroot-mq/baserom.z64

View File

@@ -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"

View File

@@ -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()

View File

@@ -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."