diff --git a/.make_hackeroot.mk b/.make_hackeroot.mk index cd7247dde..530d530a3 100644 --- a/.make_hackeroot.mk +++ b/.make_hackeroot.mk @@ -1,29 +1,195 @@ -# Set prefix to mips binutils binaries (mips-linux-gnu-ld => 'mips-linux-gnu-') - Change at your own risk! -# In nearly all cases, not having 'mips-linux-gnu-*' binaries on the PATH is indicative of missing dependencies +#### Compiling #### # Returns the path to the command $(1) if exists. Otherwise returns an empty string. find-command = $(shell which $(1) 2>/dev/null) +# Set prefix to mips binutils binaries (mips-linux-gnu-ld => 'mips-linux-gnu-') - Change at your own risk! +# In nearly all cases, not having 'mips-linux-gnu-*' binaries on the PATH is indicative of missing dependencies ifneq ($(call find-command,mips-n64-ld),) - MIPS_BINUTILS_PREFIX := mips-n64- + MIPS_BINUTILS_PREFIX := mips-n64- else ifneq ($(call find-command,mips64-ld),) - MIPS_BINUTILS_PREFIX := mips64- + MIPS_BINUTILS_PREFIX := mips64- else ifneq ($(call find-command,mips-linux-gnu-ld),) - MIPS_BINUTILS_PREFIX := mips-linux-gnu- + MIPS_BINUTILS_PREFIX := mips-linux-gnu- else ifneq ($(call find-command,mips64-linux-gnu-ld),) - MIPS_BINUTILS_PREFIX := mips64-linux-gnu- + MIPS_BINUTILS_PREFIX := mips64-linux-gnu- else ifneq ($(call find-command,mips-ld),) - MIPS_BINUTILS_PREFIX := mips- + MIPS_BINUTILS_PREFIX := mips- else ifneq ($(call find-command,mips64-elf-ld),) - MIPS_BINUTILS_PREFIX := mips64-elf- + MIPS_BINUTILS_PREFIX := mips64-elf- else - $(error Unable to detect a suitable MIPS toolchain installed) + $(error Unable to detect a suitable MIPS toolchain installed) +endif + +# Enable optimization flags to use GDB on Ares +# Default value: `0` +ARES_GDB := 0 + +# Toggle release or debug mode. 1=Release, 0=Debug +# Default value: `0` +RELEASE := 0 + +# Compression algorithm. Valid algorithms are 'yaz', 'lzo' and 'aplib' +# Default value: `yaz` +COMPRESSION ?= yaz +COMPRESSION_TYPE ?= $(shell echo $(COMPRESSION) | tr '[:lower:]' '[:upper:]') + +# Platform compatibility flags +# Default value: (nothing) +TARGET ?= +ifeq ($(TARGET),wad) +CFLAGS := -fno-reorder-blocks -fno-optimize-sibling-calls +CPP_DEFINES := -DCONSOLE_WIIVC +else ifeq ($(TARGET),iso) +CFLAGS := -fno-reorder-blocks -fno-optimize-sibling-calls +CPP_DEFINES := -DCONSOLE_GC +endif + +# Set PACKAGE_VERSION define for printing commit hash +ifeq ($(origin PACKAGE_VERSION), undefined) + PACKAGE_VERSION := $(shell git log -1 --pretty=%h | tr -d '\n') + ifeq ('$(PACKAGE_VERSION)', '') + PACKAGE_VERSION = Unknown version + endif +endif + +# Define author and package version for every OoT version +CPP_DEFINES += -DPACKAGE_VERSION='$(PACKAGE_VERSION)' -DCOMPRESS_$(COMPRESSION_TYPE)=1 +OPTFLAGS += -ffast-math -fno-unsafe-math-optimizations + +# Override optimization flags if using GDB +ifeq ($(ARES_GDB),1) + OPTFLAGS := -Og -ggdb3 +endif + +#### Tools #### + +FLIPS := tools/Flips/flips +GZINJECT := tools/gzinject/gzinject + +# Temporary measure to avoid issues on ISO builds (same for `CFLAGS_IDO`). +# The real fix would be having the proper fixes in the N64 emulator itself +# but this requires some time to figure it out. +CC_IDO := tools/ido_recomp/linux/5.3/cc + +#### Files #### + +# Config file used for building ISOs. +DMA_CONFIG_FILE := dma_config.txt + +# Baserom to use when creating BPS patches +BASEROM_PATCH ?= baseroms/$(VERSION)/baserom.z64 + +#### Build Rules #### + +# Build the codebase to inject in a WAD file (for Wii VC) +# Steps: +# - check if there's the common-key.bin file +# - build and compress the rom +# - inject the binary in the wad file (and apply patches) +# - remove temporary folders +wad: + $(call print,Patching WAD...) +ifeq ("$(wildcard baseroms/$(VERSION)/common-key.bin)", "") + $(error Please provide the common-key.bin file.) endif + $(V)$(MAKE) compress TARGET=wad + $(V)$(GZINJECT) -a inject -r 1 -k baseroms/$(VERSION)/common-key.bin -w baseroms/$(VERSION)/basewad.wad -m $(ROMC) -o $(WAD) -t "HackerOoT" -i NHOE -p tools/gzinject/patches/NACE.gzi -p tools/gzinject/patches/gz_default_remap.gzi + $(V)$(RM) -r wadextract/ + $(call print,Success!) + +# Build the codebase to inject in a ISO file (for GameCube) +# Steps: +# - build and compress the rom +# - create the dma config file +# - extract the iso +# - copy the rom and dma config file to the extracted iso folder +# - remove any unnecessary files +# - apply the modifications on the emulator binary +# - pack the iso +# - remove temporary folders +iso: + $(V)$(MAKE) compress TARGET=iso + $(call print,Patching ISO...) + $(V)$(PYTHON) tools/gc_utility.py -v $(VERSION) -c $(COMPRESSION) + $(V)$(GZINJECT) -a extract -s baseroms/$(VERSION)/baseiso.iso + $(V)cp $(BUILD_DIR)/$(DMA_CONFIG_FILE) isoextract/zlj_f.tgc/$(DMA_CONFIG_FILE) + $(V)cp $(ROMC) isoextract/zlj_f.tgc/zlj_f.n64 + $(V)$(RM) -r isoextract/S_*.tgc/ isoextract/zlj_f.tgc/*.thp + $(V)$(FLIPS) --apply tools/gamecube.bps isoextract/zlj_f.tgc/main.dol isoextract/zlj_f.tgc/main.dol + $(V)$(GZINJECT) -a pack -s $(ISO) + $(V)$(RM) -r isoextract/ + $(call print,Success!) + +# Create a BPS patch for the built rom +# Steps: +# - run Flips and create the patch +# TODO: add compressed rom support. +patch: + $(call print,Creating BPS patch...) + $(V)$(FLIPS) --create --bps $(BASEROM_PATCH) $(ROM) $(BPS) + $(call print,Success!) + +# Create F3DEX3 bps patches +# Steps: +# - run Flips and create the patches +create_f3dex3_patches: F3DEX3/f3dzex2.code F3DEX3/f3dzex2.data + $(call print,Creating F3DEX3 patches...) + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW.code F3DEX3/F3DEX3_BrW.code.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW.data F3DEX3/F3DEX3_BrW.data.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_PA.code F3DEX3/F3DEX3_BrW_PA.code.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_PA.data F3DEX3/F3DEX3_BrW_PA.data.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_PB.code F3DEX3/F3DEX3_BrW_PB.code.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_PB.data F3DEX3/F3DEX3_BrW_PB.data.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_PC.code F3DEX3/F3DEX3_BrW_PC.code.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_PC.data F3DEX3/F3DEX3_BrW_PC.data.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_NOC.code F3DEX3/F3DEX3_BrW_NOC.code.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_NOC.data F3DEX3/F3DEX3_BrW_NOC.data.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_NOC_PA.code F3DEX3/F3DEX3_BrW_NOC_PA.code.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_NOC_PA.data F3DEX3/F3DEX3_BrW_NOC_PA.data.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_NOC_PB.code F3DEX3/F3DEX3_BrW_NOC_PB.code.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_NOC_PB.data F3DEX3/F3DEX3_BrW_NOC_PB.data.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_NOC_PC.code F3DEX3/F3DEX3_BrW_NOC_PC.code.bps + $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_NOC_PC.data F3DEX3/F3DEX3_BrW_NOC_PC.data.bps + $(call print,Success!) + +# Build the rom and print its checksum (using md5) +# Steps: +# - run `make clean` +# - build the rom +# - show the checksum +verify: + $(V)$(MAKE) clean + $(V)$(MAKE) rom + @md5sum $(ROM) + +.PHONY: wad iso patch create_f3dex3_patches verify + +F3DEX3/f3dzex2.code: + $(V)dd bs=1 if=$(BASEROM_DIR)/baserom-decompressed.z64 of=$@ skip=12374256 count=5680 status=none + +F3DEX3/f3dzex2.data: + $(V)dd bs=1 if=$(BASEROM_DIR)/baserom-decompressed.z64 of=$@ skip=12379936 count=1056 status=none + +F3DEX3/F3DEX3%.code: F3DEX3/F3DEX3%.code.bps F3DEX3/f3dzex2.code + $(V)$(FLIPS) --apply F3DEX3/F3DEX3$*.code.bps F3DEX3/f3dzex2.code $@ + +F3DEX3/F3DEX3%.data: F3DEX3/F3DEX3%.data.bps F3DEX3/f3dzex2.data + $(V)$(FLIPS) --apply F3DEX3/F3DEX3$*.data.bps F3DEX3/f3dzex2.data $@ + +.PRECIOUS: $(UCODE_FILES) + +$(BUILD_DIR)/F3DEX3/%.o: F3DEX3/% + $(call print,Wrapping binary to ELF:,$<,$@) + $(V)mkdir -p $(BUILD_DIR)/F3DEX3 + $(V)$(OBJCOPY) -I binary -O elf32-big $< $@ + +#### Output #### # Verbose toggle V := @ ifeq (VERBOSE, 1) - V= + V= endif # Colors @@ -37,27 +203,5 @@ PRINT := printf # Generic print function for make rules define print - $(V)echo -e "$(GREEN)$(1) $(YELLOW)$(2)$(GREEN) -> $(BLUE)$(3)$(NO_COL)" + $(V)echo -e "$(GREEN)$(1) $(YELLOW)$(2)$(GREEN) -> $(BLUE)$(3)$(NO_COL)" endef - -# Enable optimization flags to use GDB on Ares -ARES_GDB := 1 - -# Toggle release or debug mode. 1=Release, 0=Debug -# Note: currently only used for HackerOoT -RELEASE := 0 - -# Valid compression algorithms are 'yaz', 'lzo' and 'aplib' -COMPRESSION ?= yaz -COMPRESSION_TYPE ?= $(shell echo $(COMPRESSION) | tr '[:lower:]' '[:upper:]') - -# Platform compatibility flags -TARGET ?= - -ifeq ($(TARGET),wad) -CFLAGS := -DCONSOLE_WIIVC -fno-reorder-blocks -fno-optimize-sibling-calls -CPPFLAGS := -DCONSOLE_WIIVC -else ifeq ($(TARGET),iso) -CFLAGS := -DCONSOLE_GC -fno-reorder-blocks -fno-optimize-sibling-calls -CPPFLAGS := -DCONSOLE_GC -endif diff --git a/Makefile b/Makefile index 44ed14fa1..0267d87f0 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,6 @@ SHELL = /bin/bash -include .make_options.mk -# HackerOoT options --include .make_hackeroot.mk - COMPILER ?= gcc # Target game version. Ensure the corresponding input ROM is placed in baseroms/$(VERSION)/baserom.z64. @@ -54,6 +51,16 @@ N64_EMULATOR ?= # of the debug ROM for better emulator compatibility, or to build US versions of NTSC N64 ROMs. # REGION ?= US +PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) +BUILD_DIR := build/$(VERSION) +EXPECTED_DIR := expected/$(BUILD_DIR) +BASEROM_DIR := baseroms/$(VERSION) +EXTRACTED_DIR := extracted/$(VERSION) +VENV := .venv + +# Add HackerOoT options +-include .make_hackeroot.mk + CFLAGS ?= CPPFLAGS ?= CFLAGS_IDO ?= @@ -121,43 +128,20 @@ else ifeq ($(VERSION),gc-jp-ce) else ifeq ($(VERSION),hackeroot-mq) REGION := NULL PLATFORM := GC - PAL := 1 - MQ := 1 DEBUG := 1 else $(error Unsupported version $(VERSION)) endif -ifeq ($(VERSION),hackeroot-mq) - HACKEROOT := 1 -else - HACKEROOT := 0 -endif - ifeq ($(COMPILER),gcc) CPP_DEFINES += -DCOMPILER_GCC -DNON_MATCHING -DAVOID_UB -std=gnu11 else $(error Unsupported compiler. Please use gcc as the COMPILER variable.) endif -PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) -BUILD_DIR := build/$(VERSION) -EXPECTED_DIR := expected/$(BUILD_DIR) -BASEROM_DIR := baseroms/$(VERSION) -EXTRACTED_DIR := extracted/$(VERSION) -VENV := .venv - MAKE = make CPPFLAGS += -P -xc -fno-dollars-in-identifiers -# Set PACKAGE_VERSION define for printing commit hash -ifeq ($(origin PACKAGE_VERSION), undefined) - PACKAGE_VERSION := $(shell git log -1 --pretty=%h | tr -d '\n') - ifeq ('$(PACKAGE_VERSION)', '') - PACKAGE_VERSION = Unknown version - endif -endif - # Converts e.g. ntsc-1.0 to NTSC_1_0 ifeq ($(VERSION),hackeroot-mq) CPP_DEFINES += -DOOT_VERSION=GC_EU_MQ_DBG @@ -176,7 +160,6 @@ else endif ifeq ($(VERSION),hackeroot-mq) - CPP_DEFINES += -DENABLE_HACKEROOT=1 OPTFLAGS := -Os ifeq ($(RELEASE),1) @@ -193,22 +176,8 @@ else CPP_DEFINES += -DNDEBUG -DOOT_DEBUG=0 OPTFLAGS := -O2 -g3 endif - - CPP_DEFINES += -DENABLE_HACKEROOT=0 -endif - -# Override optimization flags if using GDB -ifeq ($(ARES_GDB),1) - OPTFLAGS := -Og -ggdb3 endif -# Define author and package version for every OoT version -# Note: this won't be used if not using HackerOoT -CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)' -DCOMPRESS_$(COMPRESSION_TYPE)=1 -CPPFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)' -DCOMPRESS_$(COMPRESSION_TYPE)=1 -CFLAGS_IDO += -DPACKAGE_VERSION='$(PACKAGE_VERSION)' -DCOMPRESS_$(COMPRESSION_TYPE)=1 -OPTFLAGS += -ffast-math -fno-unsafe-math-optimizations - ifeq ($(OS),Windows_NT) DETECTED_OS=windows else @@ -255,9 +224,6 @@ ELF2ROM := tools/elf2rom ZAPD := tools/ZAPD/ZAPD.out FADO := tools/fado/fado.elf PYTHON ?= $(VENV)/bin/python3 -FLIPS := tools/Flips/flips -GZINJECT := tools/gzinject/gzinject -CC_IDO := tools/ido_recomp/linux/5.3/cc # Command to replace $(BUILD_DIR) in some files with the build path. # We can't use the C preprocessor for this because it won't substitute inside string literals. @@ -310,18 +276,19 @@ else ROM := $(BUILD_DIR)/oot-$(VERSION).z64 endif ROMC := $(ROM:.z64=-compressed-$(COMPRESSION).z64) -WAD := $(ROM:.z64=.wad) -ISO := $(ROM:.z64=.iso) -BPS := $(ROM:.z64=.bps) ELF := $(ROM:.z64=.elf) MAP := $(ROM:.z64=.map) LDSCRIPT := $(ROM:.z64=.ld) -DMA_CONFIG_FILE := dma_config.txt # description of ROM segments SPEC := spec -# Baserom to use when creating BPS patches -BASEROM_PATCH ?= baseroms/$(VERSION)/baserom.z64 +# HackerOoT files +WAD := $(ROM:.z64=.wad) +ISO := $(ROM:.z64=.iso) +BPS := $(ROM:.z64=.bps) +UCODE_PATCHES := $(wildcard F3DEX3/*.bps) +UCODE_FILES := $(foreach f,$(UCODE_PATCHES:.bps=),$f) +UCODE_O_FILES := $(foreach f,$(UCODE_FILES),$(BUILD_DIR)/$f.o) ifeq ($(COMPILER),gcc) SRC_DIRS := $(shell find src -type d) @@ -420,10 +387,6 @@ O_FILES := $(foreach f,$(S_FILES:.s=.o),$(BUILD_DIR)/$f) \ $(foreach f,$(BASEROM_BIN_FILES),$(BUILD_DIR)/baserom/$(notdir $f).o) \ $(BUILD_DIR)/src/code/z_message_z_game_over.o -UCODE_PATCHES := $(wildcard F3DEX3/*.bps) -UCODE_FILES := $(foreach f,$(UCODE_PATCHES:.bps=),$f) -UCODE_O_FILES := $(foreach f,$(UCODE_FILES),$(BUILD_DIR)/$f.o) - OVL_RELOC_FILES := $(shell $(CPP) $(CPPFLAGS) $(SPEC) | $(BUILD_DIR_REPLACE) | grep -o '[^"]*_reloc.o' ) # Automatic dependency files @@ -469,12 +432,14 @@ ifeq ($(COMPILER),gcc) $(BUILD_DIR)/src/libultra/libc/ll.o: OPTFLAGS := -Ofast $(BUILD_DIR)/src/overlays/%.o: CFLAGS += -fno-merge-constants -mno-explicit-relocs -mno-split-addresses +## HackerOoT overrides ## + $(BUILD_DIR)/src/overlays/actors/ovl_Item_Shield/%.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/overlays/actors/ovl_En_Part/%.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/overlays/actors/ovl_Item_B_Heart/%.o: OPTFLAGS := -O0 $(BUILD_DIR)/src/overlays/actors/ovl_Bg_Mori_Hineri/%.o: OPTFLAGS := -O0 -# library overrides for Gamecube +# library overrides ifeq ($(TARGET),iso) MIPS_VERSION_IDO := -mips2 CFLAGS_IDO += -G 0 -non_shared -fullwarn -verbose -Xcpluscomm $(INC) -Wab,-r4300_mul -woff 516,609,649,838,712 @@ -503,6 +468,7 @@ ifeq ($(TARGET),iso) $(BUILD_DIR)/src/libultra/os/aisetnextbuf.o: CFLAGS := $(CFLAGS_IDO) $(BUILD_DIR)/src/libultra/os/aisetnextbuf.o: CC := $(CC_IDO) endif + endif #### Main Targets ### @@ -522,29 +488,6 @@ compress: $(V)$(MAKE) $(ROMC) $(call print,Success!) -wad: - $(call print,Patching WAD...) -ifeq ("$(wildcard baseroms/$(VERSION)/common-key.bin)", "") - $(error Please provide the common-key.bin file.) -endif - $(V)$(MAKE) compress TARGET=wad - $(V)$(GZINJECT) -a inject -r 1 -k baseroms/$(VERSION)/common-key.bin -w baseroms/$(VERSION)/basewad.wad -m $(ROMC) -o $(WAD) -t "HackerOoT" -i NHOE -p tools/gzinject/patches/NACE.gzi -p tools/gzinject/patches/gz_default_remap.gzi - $(V)$(RM) -r wadextract/ - $(call print,Success!) - -iso: - $(V)$(MAKE) compress TARGET=iso - $(call print,Patching ISO...) - $(V)$(PYTHON) tools/gc_utility.py -v $(VERSION) -c $(COMPRESSION) - $(V)$(GZINJECT) -a extract -s baseroms/$(VERSION)/baseiso.iso - $(V)cp $(BUILD_DIR)/$(DMA_CONFIG_FILE) isoextract/zlj_f.tgc/$(DMA_CONFIG_FILE) - $(V)cp $(ROMC) isoextract/zlj_f.tgc/zlj_f.n64 - $(V)$(RM) -r isoextract/S_*.tgc/ isoextract/zlj_f.tgc/*.thp - $(V)$(FLIPS) --apply tools/gamecube.bps isoextract/zlj_f.tgc/main.dol isoextract/zlj_f.tgc/main.dol - $(V)$(GZINJECT) -a pack -s $(ISO) - $(V)$(RM) -r isoextract/ - $(call print,Success!) - clean: $(V)$(RM) -r $(BUILD_DIR) $(call print,Success!) @@ -592,38 +535,7 @@ ifeq ($(N64_EMULATOR),) endif $(N64_EMULATOR) $(ROM) -patch: - $(call print,Creating BPS patch...) - $(V)$(FLIPS) --create --bps $(BASEROM_PATCH) $(ROM) $(BPS) - $(call print,Success!) - -create_f3dex3_patches: F3DEX3/f3dzex2.code F3DEX3/f3dzex2.data - $(call print,Creating F3DEX3 patches...) - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW.code F3DEX3/F3DEX3_BrW.code.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW.data F3DEX3/F3DEX3_BrW.data.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_PA.code F3DEX3/F3DEX3_BrW_PA.code.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_PA.data F3DEX3/F3DEX3_BrW_PA.data.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_PB.code F3DEX3/F3DEX3_BrW_PB.code.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_PB.data F3DEX3/F3DEX3_BrW_PB.data.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_PC.code F3DEX3/F3DEX3_BrW_PC.code.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_PC.data F3DEX3/F3DEX3_BrW_PC.data.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_NOC.code F3DEX3/F3DEX3_BrW_NOC.code.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_NOC.data F3DEX3/F3DEX3_BrW_NOC.data.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_NOC_PA.code F3DEX3/F3DEX3_BrW_NOC_PA.code.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_NOC_PA.data F3DEX3/F3DEX3_BrW_NOC_PA.data.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_NOC_PB.code F3DEX3/F3DEX3_BrW_NOC_PB.code.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_NOC_PB.data F3DEX3/F3DEX3_BrW_NOC_PB.data.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_NOC_PC.code F3DEX3/F3DEX3_BrW_NOC_PC.code.bps - $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_NOC_PC.data F3DEX3/F3DEX3_BrW_NOC_PC.data.bps - $(call print,Success!) - -verify: - $(V)$(MAKE) clean - $(V)$(MAKE) rom - @md5sum $(ROM) - -.PHONY: all rom compress clean assetclean distclean venv setup run wad iso patch create_f3dex3_patches verify - +.PHONY: all rom compress clean assetclean distclean venv setup run .DEFAULT_GOAL := rom #### Various Recipes #### @@ -676,11 +588,6 @@ $(BUILD_DIR)/undefined_syms.txt: undefined_syms.txt $(BUILD_DIR)/baserom/%.o: $(EXTRACTED_DIR)/baserom/% $(call print,Wrapping binary to ELF:,$<,$@) $(V)$(OBJCOPY) -I binary -O elf32-big $< $@ - -$(BUILD_DIR)/F3DEX3/%.o: F3DEX3/% - $(call print,Wrapping binary to ELF:,$<,$@) - $(V)mkdir -p $(BUILD_DIR)/F3DEX3 - $(V)$(OBJCOPY) -I binary -O elf32-big $< $@ $(BUILD_DIR)/data/%.o: data/%.s $(call print,Assembling:,$<,$@) @@ -793,20 +700,6 @@ $(BUILD_DIR)/assets/%.jpg.inc.c: assets/%.jpg $(BUILD_DIR)/assets/%.jpg.inc.c: $(EXTRACTED_DIR)/assets/%.jpg $(V)$(ZAPD) bren -eh -i $< -o $@ -F3DEX3/f3dzex2.code: - $(V)$(PYTHON) tools/data_extractor.py --start 0xBCD0F0 --size 0x1630 --input $(BASEROM_DIR)/baserom-decompressed.z64 --output $@ - -F3DEX3/f3dzex2.data: - $(V)$(PYTHON) tools/data_extractor.py --start 0xBCE720 --size 0x420 --input $(BASEROM_DIR)/baserom-decompressed.z64 --output $@ - -F3DEX3/F3DEX3%.code: F3DEX3/F3DEX3%.code.bps F3DEX3/f3dzex2.code - $(V)$(FLIPS) --apply F3DEX3/F3DEX3$*.code.bps F3DEX3/f3dzex2.code $@ - -F3DEX3/F3DEX3%.data: F3DEX3/F3DEX3%.data.bps F3DEX3/f3dzex2.data - $(V)$(FLIPS) --apply F3DEX3/F3DEX3$*.data.bps F3DEX3/f3dzex2.data $@ - -.PRECIOUS: $(UCODE_FILES) - # Audio AUDIO_BUILD_DEBUG ?= 0 diff --git a/include/config/config_safeguards.h b/include/config/config_safeguards.h index cdc7f38fb..780637ada 100644 --- a/include/config/config_safeguards.h +++ b/include/config/config_safeguards.h @@ -146,68 +146,10 @@ #define ENABLE_F3DEX3 false #endif - -/** - * Default settings if not using HackerOoT mode -*/ -#if !ENABLE_HACKEROOT - #undef SKIP_N64_BOOT_LOGO - #undef BOOT_TO_SCENE - #undef BOOT_TO_SCENE_NEW_GAME_ONLY - #undef BOOT_TO_FILE_SELECT - #undef DISABLE_DEBUG_FEATURES - #undef SHOW_CS_INFOS - #undef SHOW_INPUT_DISPLAY - #undef SHOW_TIME_INFOS - #undef INCLUDE_TEST_SCENES - #undef ENABLE_NO_CLIP - #undef ENABLE_CS_CONTROL - #undef ENABLE_FRAMERATE_OPTIONS - #undef ENABLE_MAP_SELECT - #undef ENABLE_INV_EDITOR - #undef ENABLE_EVENT_EDITOR - #undef ENABLE_REG_EDITOR - #undef ENABLE_CAMERA_DEBUGGER - #undef ENABLE_AUDIO_DEBUGGER - #undef ENABLE_ACTOR_DEBUGGER - #undef ENABLE_MSG_DEBUGGER - #undef ENABLE_DEBUG_SAVE - #undef MAP_SELECT_ON_FILE_1 - #undef ENABLE_MOTION_BLUR_DEBUG - - #define SKIP_N64_BOOT_LOGO true - #define BOOT_TO_SCENE false - #define BOOT_TO_SCENE_NEW_GAME_ONLY false - #define BOOT_TO_FILE_SELECT false - #define DISABLE_DEBUG_FEATURES false - #define SHOW_CS_INFOS false - #define SHOW_INPUT_DISPLAY false - #define SHOW_TIME_INFOS false - #define INCLUDE_TEST_SCENES true - #define ENABLE_NO_CLIP false - #define ENABLE_CS_CONTROL false - #define ENABLE_FRAMERATE_OPTIONS false - #define ENABLE_MAP_SELECT true - #define ENABLE_INV_EDITOR false - #define ENABLE_EVENT_EDITOR false - #define ENABLE_REG_EDITOR false - #define ENABLE_CAMERA_DEBUGGER true - #define ENABLE_AUDIO_DEBUGGER false - #define ENABLE_ACTOR_DEBUGGER false - #define ENABLE_MSG_DEBUGGER false - #define ENABLE_DEBUG_SAVE false - #define MAP_SELECT_ON_FILE_1 true - #define ENABLE_MOTION_BLUR_DEBUG false -#endif - /** * Used in if statements */ -#if ENABLE_HACKEROOT #define IS_DEBUG (OOT_DEBUG && !DISABLE_DEBUG_FEATURES) -#else -#define IS_DEBUG OOT_DEBUG -#endif #if ENABLE_PROFILER && !ENABLE_HACKER_DEBUG #error "ENABLE_PROFILER requires ENABLE_HACKER_DEBUG" @@ -216,7 +158,7 @@ /** * Game */ -#define IS_MOTION_BLUR_ENABLED (ENABLE_HACKEROOT && ENABLE_MOTION_BLUR) +#define IS_MOTION_BLUR_ENABLED (ENABLE_MOTION_BLUR) /** * Debug diff --git a/spec b/spec index adcb297a7..7af1d2fa6 100644 --- a/spec +++ b/spec @@ -19644,106 +19644,6 @@ beginseg endseg #endif -#if !ENABLE_HACKEROOT -beginseg - name "bump_texture_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/bump_texture_static.o" -endseg - -beginseg - name "anime_model_1_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_model_1_static.o" -endseg - -beginseg - name "anime_model_2_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_model_2_static.o" -endseg - -beginseg - name "anime_model_3_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_model_3_static.o" -endseg - -beginseg - name "anime_model_4_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_model_4_static.o" -endseg - -beginseg - name "anime_model_5_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_model_5_static.o" -endseg - -beginseg - name "anime_model_6_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_model_6_static.o" -endseg - -beginseg - name "anime_texture_1_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_texture_1_static.o" -endseg - -beginseg - name "anime_texture_2_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_texture_2_static.o" -endseg - -beginseg - name "anime_texture_3_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_texture_3_static.o" -endseg - -beginseg - name "anime_texture_4_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_texture_4_static.o" -endseg - -beginseg - name "anime_texture_5_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_texture_5_static.o" -endseg - -beginseg - name "anime_texture_6_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/anime_texture_6_static.o" -endseg - -beginseg - name "softsprite_matrix_static" - compress - romalign 0x1000 - include "$(BUILD_DIR)/baserom/softsprite_matrix_static.o" -endseg -#endif - #if INCLUDE_EXAMPLE_SCENE beginseg name "example_scene" diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 949e4c9d7..72cad51d0 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -62,27 +62,8 @@ void Object_InitContext(PlayState* play, ObjectContext* objectCtx) { u32 spaceSize; s32 i; -#if ENABLE_HACKEROOT + // HackerOoT change: set a fixed allocation for the object heap spaceSize = OBJECT_BANK_SIZE; -#else - if (play2->sceneId == SCENE_HYRULE_FIELD) { - spaceSize = 1000 * 1024 - OBJECT_SPACE_ADJUSTMENT; - } else if (play2->sceneId == SCENE_GANON_BOSS) { - if (gSaveContext.sceneLayer != 4) { - spaceSize = 1150 * 1024 - OBJECT_SPACE_ADJUSTMENT; - } else { - spaceSize = 1000 * 1024 - OBJECT_SPACE_ADJUSTMENT; - } - } else if (play2->sceneId == SCENE_SPIRIT_TEMPLE_BOSS) { - spaceSize = 1050 * 1024 - OBJECT_SPACE_ADJUSTMENT; - } else if (play2->sceneId == SCENE_CHAMBER_OF_THE_SAGES) { - spaceSize = 1050 * 1024 - OBJECT_SPACE_ADJUSTMENT; - } else if (play2->sceneId == SCENE_GANONDORF_BOSS) { - spaceSize = 1050 * 1024 - OBJECT_SPACE_ADJUSTMENT; - } else { - spaceSize = 1000 * 1024 - OBJECT_SPACE_ADJUSTMENT; - } -#endif objectCtx->numEntries = objectCtx->numPersistentEntries = 0; objectCtx->mainKeepSlot = objectCtx->subKeepSlot = 0; diff --git a/tools/data_extractor.py b/tools/data_extractor.py deleted file mode 100644 index 997ad52a6..000000000 --- a/tools/data_extractor.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/python3 - -import argparse - - -def extract(start: int, size: int, input: str, output: str): - """Extracts ``size`` bytes from ``input``, at offset ``start``, and writes it to ``output`` - - Parameters: - - ``start``: int, defines where to start reading the file - - ``size``: int, how many bytes to read from the file - - ``input``: str, path to the file to read - - ``output``: str, path to the file to write - """ - - with open(input, "rb") as file: - file.seek(start) - data = file.read(size) - - with open(output, "wb") as file: - file.write(data) - - -def main(): - parser = argparse.ArgumentParser(description="Extracts data from a file for HackerOoT.") - - parser.add_argument( - "--start", - dest="start", - help="Offset to the data (uses hex)", - required=True, - ) - - parser.add_argument( - "--size", - dest="size", - help="How much to read (uses hex)", - required=True, - ) - - parser.add_argument( - "--input", - dest="input", - help="Input file", - required=True, - ) - - parser.add_argument( - "--output", - dest="output", - help="Output file", - required=True, - ) - - args = parser.parse_args() - extract(int(args.start, 16), int(args.size, 16), args.input, args.output) - print("Data extracted successfully!") - - -if __name__ == "__main__": - main()