mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-02 22:14:33 +00:00
Set up disassembly for gc-eu-mq (#1613)
* Disassemble gc-eu-mq
* Add script to report progress with matching
* Fix whitespace
* Change T|None to typing.Optional[T]
* Use typing.List
* More type annotations fixes for old Python versions
* Fix type errors
* More type annotations
* Use typing.Iterator
* Use $(PYTHON) for disassembly
* Don't use grouped targets to support very old Make versions
* Docs: suggest checking MM, mention virtualenv, clarify about expected/
* Update sym_info.py
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
* Sync functions.txt
* Start banned symbol range at 0x10000000
* Also ban symbols from 0xC0000000-0xFFFFFFFF
* Unban IPL symbols
* Fix first_diff.py
* Sync z_collision_check functions.txt
* Ban 0xA0 symbols too
* Touch .disasm sentinel file
* Copy -jN comment in docs
* diff.py flags: remove -3, add -s
* Update docs/retail_versions.md
Co-authored-by: Yanis42 <35189056+Yanis42@users.noreply.github.com>
* Comment that segments are still from the Debug ROM
* Revert "diff.py flags: remove -3, add -s"
This reverts commit bfaae66c1d
.
* Apply suggestions from code review
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
* Remove #ifdef example
* Reformat Python files with black
* Add copyright notice to new Python files
* Add TODOs to Makefile
---------
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
Co-authored-by: Yanis42 <35189056+Yanis42@users.noreply.github.com>
Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
parent
e9a571054c
commit
98a3238822
21 changed files with 15796 additions and 16 deletions
47
Makefile
47
Makefile
|
@ -16,6 +16,8 @@ ORIG_COMPILER := 0
|
|||
COMPILER := ido
|
||||
# Target game version. Currently only the following version is supported:
|
||||
# gc-eu-mq-dbg GameCube Europe/PAL Master Quest Debug (default)
|
||||
# The following versions are work-in-progress and not yet matching:
|
||||
# gc-eu-mq GameCube Europe/PAL Master Quest
|
||||
VERSION := gc-eu-mq-dbg
|
||||
# Number of threads to extract and compress with
|
||||
N_THREADS := $(shell nproc)
|
||||
|
@ -47,7 +49,14 @@ ifeq ($(NON_MATCHING),1)
|
|||
endif
|
||||
|
||||
# Version-specific settings
|
||||
ifeq ($(VERSION),gc-eu-mq-dbg)
|
||||
ifeq ($(VERSION),gc-eu-mq)
|
||||
CFLAGS += -DNON_MATCHING -DNDEBUG
|
||||
CPPFLAGS += -DNON_MATCHING -DNDEBUG
|
||||
OPTFLAGS := -O2 -g3
|
||||
COMPARE := 0
|
||||
else ifeq ($(VERSION),gc-eu-mq-dbg)
|
||||
CFLAGS += -DOOT_DEBUG
|
||||
CPPFLAGS += -DOOT_DEBUG
|
||||
OPTFLAGS := -O2
|
||||
else
|
||||
$(error Unsupported version $(VERSION))
|
||||
|
@ -55,11 +64,11 @@ endif
|
|||
|
||||
PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
BUILD_DIR := build/$(VERSION)
|
||||
EXPECTED_DIR := expected/$(BUILD_DIR)
|
||||
VENV := .venv
|
||||
|
||||
MAKE = make
|
||||
CFLAGS += -DOOT_DEBUG
|
||||
CPPFLAGS += -DOOT_DEBUG -fno-dollars-in-identifiers -P
|
||||
CPPFLAGS += -fno-dollars-in-identifiers -P
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
DETECTED_OS=windows
|
||||
|
@ -161,6 +170,10 @@ endif
|
|||
|
||||
OBJDUMP_FLAGS := -d -r -z -Mreg-names=32
|
||||
|
||||
DISASM_DATA_DIR := tools/disasm/$(VERSION)
|
||||
DISASM_FLAGS += --custom-suffix _unknown --sequential-label-names --no-use-fpccsr --no-cop0-named-registers
|
||||
DISASM_FLAGS += --config-dir $(DISASM_DATA_DIR) --symbol-addrs $(DISASM_DATA_DIR)/functions.txt --symbol-addrs $(DISASM_DATA_DIR)/variables.txt
|
||||
|
||||
#### Files ####
|
||||
|
||||
# ROM image
|
||||
|
@ -185,16 +198,24 @@ ASSET_FILES_OUT := $(foreach f,$(ASSET_FILES_XML:.xml=.c),$f) \
|
|||
|
||||
UNDECOMPILED_DATA_DIRS := $(shell find data -type d)
|
||||
|
||||
# TODO: for now, ROM segments are still taken from the Debug ROM even when building other versions
|
||||
BASEROM_SEGMENTS_DIR := baseroms/gc-eu-mq-dbg/segments
|
||||
BASEROM_BIN_FILES := $(wildcard $(BASEROM_SEGMENTS_DIR)/*)
|
||||
|
||||
# source files
|
||||
C_FILES := $(filter-out %.inc.c,$(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS),$(wildcard $(dir)/*.c)))
|
||||
S_FILES := $(foreach dir,$(SRC_DIRS) $(UNDECOMPILED_DATA_DIRS),$(wildcard $(dir)/*.s))
|
||||
BASEROM_BIN_FILES := $(wildcard baseroms/$(VERSION)/segments/*)
|
||||
O_FILES := $(foreach f,$(S_FILES:.s=.o),$(BUILD_DIR)/$f) \
|
||||
$(foreach f,$(C_FILES:.c=.o),$(BUILD_DIR)/$f) \
|
||||
$(foreach f,$(BASEROM_BIN_FILES),$(BUILD_DIR)/baserom/$(notdir $f).o)
|
||||
|
||||
OVL_RELOC_FILES := $(shell $(CPP) $(CPPFLAGS) $(SPEC) | $(SPEC_REPLACE_VARS) | grep -o '[^"]*_reloc.o' )
|
||||
|
||||
DISASM_BASEROM := baseroms/$(VERSION)/baserom-decompressed.z64
|
||||
DISASM_DATA_FILES := $(wildcard $(DISASM_DATA_DIR)/*.csv) $(wildcard $(DISASM_DATA_DIR)/*.txt)
|
||||
DISASM_S_FILES := $(shell test -e $(PYTHON) && $(PYTHON) tools/disasm/list_generated_files.py -o $(EXPECTED_DIR) --config-dir $(DISASM_DATA_DIR))
|
||||
DISASM_O_FILES := $(DISASM_S_FILES:.s=.o)
|
||||
|
||||
# Automatic dependency files
|
||||
# (Only asm_processor dependencies and reloc dependencies are handled for now)
|
||||
DEP_FILES := $(O_FILES:.o=.asmproc.d) $(OVL_RELOC_FILES:.o=.d)
|
||||
|
@ -287,7 +308,7 @@ assetclean:
|
|||
$(RM) -r .extracted-assets.json
|
||||
|
||||
distclean: clean assetclean
|
||||
$(RM) -r baseroms/$(VERSION)/segments
|
||||
$(RM) -r $(BASEROM_SEGMENTS_DIR)
|
||||
$(MAKE) -C tools distclean
|
||||
|
||||
venv:
|
||||
|
@ -300,8 +321,13 @@ venv:
|
|||
setup: venv
|
||||
$(MAKE) -C tools
|
||||
$(PYTHON) tools/decompress_baserom.py $(VERSION)
|
||||
# TODO: for now, we only extract ROM segments and assets from the Debug ROM
|
||||
ifeq ($(VERSION),gc-eu-mq-dbg)
|
||||
$(PYTHON) extract_baserom.py
|
||||
$(PYTHON) extract_assets.py -j$(N_THREADS)
|
||||
endif
|
||||
|
||||
disasm: $(DISASM_O_FILES)
|
||||
|
||||
run: $(ROM)
|
||||
ifeq ($(N64_EMULATOR),)
|
||||
|
@ -310,7 +336,7 @@ endif
|
|||
$(N64_EMULATOR) $<
|
||||
|
||||
|
||||
.PHONY: all rom compress clean assetclean distclean venv setup run
|
||||
.PHONY: all rom compress clean assetclean distclean venv setup disasm run
|
||||
.DEFAULT_GOAL := rom
|
||||
|
||||
#### Various Recipes ####
|
||||
|
@ -347,7 +373,7 @@ $(BUILD_DIR)/ldscript.txt: $(BUILD_DIR)/$(SPEC)
|
|||
$(BUILD_DIR)/undefined_syms.txt: undefined_syms.txt
|
||||
$(CPP) $(CPPFLAGS) $< > $@
|
||||
|
||||
$(BUILD_DIR)/baserom/%.o: baseroms/$(VERSION)/segments/%
|
||||
$(BUILD_DIR)/baserom/%.o: $(BASEROM_SEGMENTS_DIR)/%
|
||||
$(OBJCOPY) -I binary -O elf32-big $< $@
|
||||
|
||||
$(BUILD_DIR)/data/%.o: data/%.s
|
||||
|
@ -418,6 +444,13 @@ $(BUILD_DIR)/assets/%.bin.inc.c: assets/%.bin
|
|||
$(BUILD_DIR)/assets/%.jpg.inc.c: assets/%.jpg
|
||||
$(ZAPD) bren -eh -i $< -o $@
|
||||
|
||||
$(EXPECTED_DIR)/.disasm: $(DISASM_DATA_FILES)
|
||||
$(PYTHON) tools/disasm/disasm.py $(DISASM_FLAGS) $(DISASM_BASEROM) -o $(EXPECTED_DIR) --split-functions $(EXPECTED_DIR)/functions
|
||||
touch $@
|
||||
|
||||
$(EXPECTED_DIR)/%.o: $(EXPECTED_DIR)/.disasm
|
||||
$(AS) $(ASFLAGS) $(@:.o=.s) -o $@
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
# Print target for debugging
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue