mirror of
https://github.com/zeldaret/mm.git
synced 2026-07-11 14:18:39 -04:00
Adds in scene support (#117)
* 1 scene done, Z2_SOUGEN OK * All scenes OK * Makefile improvements * Use WIP ZAPD branch as submodule * Add spawn rotation flag macro * Fix bad merge * Move scenes to be in their own subfolders * Rename and restructure extracted baserom files * Progress tracking for assets * Add asset progress to csv * Use master ZAPD * Use distclean like in OOT * Fix up a few things with the makefile * Fix scenes not being dumped from ELF Co-authored-by: Rozelette <Uberpanzermensch@gmail.com>
This commit is contained in:
@@ -55,12 +55,14 @@ LD := $(MIPS_BINUTILS_PREFIX)ld
|
||||
OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy
|
||||
OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump
|
||||
|
||||
ZAPD := tools/ZAPD/ZAPD.out
|
||||
|
||||
OPTFLAGS := -O2 -g3
|
||||
ASFLAGS := -march=vr4300 -32
|
||||
MIPS_VERSION := -mips2
|
||||
|
||||
# we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff.
|
||||
CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm -Iinclude -Isrc -Wab,-r4300_mul -woff 649,838
|
||||
CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm -Iinclude -I./ -Isrc -Wab,-r4300_mul -woff 649,838,712
|
||||
|
||||
#### Files ####
|
||||
|
||||
@@ -71,35 +73,34 @@ ROM := $(MM_ROM_NAME).z64
|
||||
UNCOMPRESSED_ROM := $(MM_ROM_NAME)_uncompressed.z64
|
||||
ELF := $(MM_ROM_NAME).elf
|
||||
|
||||
BASEROM_FILES := $(wildcard baserom/*)
|
||||
# Exclude dmadata, it will be generated right before packing the rom
|
||||
BASEROM_FILES := $(subst baserom/dmadata ,,$(BASEROM_FILES))
|
||||
BASEROM_BUILD_FILES := $(BASEROM_FILES:baserom/%=build/baserom/%)
|
||||
|
||||
BASE_DECOMP_FILES := $(wildcard decomp/*)
|
||||
DECOMP_FILES := $(BASE_DECOMP_FILES:decomp/%=build/decomp/%)
|
||||
COMP_FILES := $(DECOMP_FILES:build/decomp/%=build/comp/%.yaz0)
|
||||
|
||||
DMADATA_FILES := $(DECOMP_FILES) $(BASEROM_BUILD_FILES)
|
||||
# Exclude code files, they will be extracted from the file instead
|
||||
DMADATA_FILES := $(subst build/baserom/boot ,,$(DMADATA_FILES))
|
||||
DMADATA_FILES := $(subst build/decomp/code ,,$(DMADATA_FILES))
|
||||
DMADATA_FILES := $(DMADATA_FILES:build/decomp/ovl_%=)
|
||||
|
||||
SRC_DIRS := $(shell find src -type d)
|
||||
BASEROM_DIRS := $(shell find baserom -type d 2>/dev/null)
|
||||
COMP_DIRS := $(BASEROM_DIRS:baserom%=comp%)
|
||||
ASSET_XML_DIRS := $(shell find assets/xml* -type d)
|
||||
ASSET_SRC_DIRS := $(patsubst assets/xml%,assets/src%,$(ASSET_XML_DIRS))
|
||||
ASSET_FILES_XML := $(foreach dir,$(ASSET_XML_DIRS),$(wildcard $(dir)/*.xml))
|
||||
ASSET_FILES_OUT := $(patsubst assets/xml%,assets/src%,$(patsubst %.xml,%.c,$(ASSET_FILES_XML)))
|
||||
|
||||
# Because we may not have disassembled the code files yet, there might not be any assembly files.
|
||||
# Instead, generate a list of assembly files based on what's listed in the linker script.
|
||||
S_FILES := $(shell grep build/asm ./linker_scripts/code_script.txt | sed 's/\s*build\///g; s/\.o(\..*)/\.asm/g')
|
||||
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
|
||||
C_O_FILES := $(C_FILES:src/%.c=build/src/%.o)
|
||||
C_O_FILES := $(C_FILES:%.c=build/%.o)
|
||||
S_O_FILES := $(S_FILES:asm/%.asm=build/asm/%.o)
|
||||
O_FILES := $(C_O_FILES) $(S_O_FILES)
|
||||
ASSET_O_FILES := $(ASSET_FILES_OUT:%.c=build/%.o)
|
||||
O_FILES := $(C_O_FILES) $(S_O_FILES) $(ASSET_O_FILES)
|
||||
ROM_FILES := $(shell cat ./tables/makerom_files.txt)
|
||||
UNCOMPRESSED_ROM_FILES := $(shell cat ./tables/makerom_uncompressed_files.txt)
|
||||
|
||||
# Exclude code and scene files, they will be extracted from the file instead
|
||||
DMADATA_FILES := $(subst build/baserom/boot ,,$(UNCOMPRESSED_ROM_FILES))
|
||||
DMADATA_FILES := $(subst build/baserom/code ,,$(DMADATA_FILES))
|
||||
DMADATA_FILES := $(DMADATA_FILES:build/baserom/overlays/%=)
|
||||
DMADATA_FILES := $(DMADATA_FILES:build/baserom/assets/scenes/%=)
|
||||
DMADATA_FILES := $(DMADATA_FILES:build/uncompressed_dmadata=)
|
||||
|
||||
# create build directories
|
||||
$(shell mkdir -p build/asm build/asm/boot build/asm/code build/asm/overlays build/baserom build/comp build/decomp $(foreach dir,$(SRC_DIRS),$(shell mkdir -p build/$(dir))))
|
||||
$(shell mkdir -p build/linker_scripts build/asm build/asm/boot build/asm/code build/asm/overlays $(foreach dir,$(BASEROM_DIRS) $(COMP_DIRS) $(SRC_DIRS) $(ASSET_SRC_DIRS),$(shell mkdir -p build/$(dir))))
|
||||
|
||||
build/src/libultra/os/%: OPTFLAGS := -O1
|
||||
build/src/libultra/voice/%: OPTFLAGS := -O2
|
||||
@@ -125,7 +126,7 @@ CC := ./tools/preprocess.py $(CC) -- $(AS) $(ASFLAGS) --
|
||||
# disasm is not a file so we must tell make not to check it when evaluating timestamps
|
||||
.INTERMEDIATE: disasm
|
||||
# make will delete any generated assembly files that are not a prerequisite for anything, so keep it from doing so
|
||||
.PRECIOUS: asm/%.asm
|
||||
.PRECIOUS: asm/%.asm $(ASSET_FILES_OUT)
|
||||
|
||||
$(UNCOMPRESSED_ROM): $(UNCOMPRESSED_ROM_FILES)
|
||||
./tools/makerom.py ./tables/dmadata_table.txt $@
|
||||
@@ -143,26 +144,26 @@ endif
|
||||
|
||||
all: $(UNCOMPRESSED_ROM) $(ROM) ;
|
||||
|
||||
build/code.elf: $(O_FILES) linker_scripts/code_script.txt undef.txt linker_scripts/object_script.txt linker_scripts/dmadata_script.txt
|
||||
$(LD) -T linker_scripts/code_script.txt -T undef.txt -T linker_scripts/object_script.txt -T linker_scripts/dmadata_script.txt --no-check-sections --accept-unknown-input-arch -Map build/mm.map -N -o $@
|
||||
build/code.elf: $(O_FILES) build/linker_scripts/code_script.txt undef.txt build/linker_scripts/object_script.txt build/linker_scripts/dmadata_script.txt
|
||||
$(LD) -T build/linker_scripts/code_script.txt -T undef.txt -T build/linker_scripts/object_script.txt -T build/linker_scripts/dmadata_script.txt --no-check-sections --accept-unknown-input-arch -Map build/mm.map -N -o $@
|
||||
|
||||
build/code_pre_dmadata.elf: $(O_FILES) linker_scripts/code_script.txt undef.txt linker_scripts/object_script.txt
|
||||
$(LD) -r -T linker_scripts/code_script.txt -T undef.txt -T linker_scripts/object_script.txt --no-check-sections --accept-unknown-input-arch -N -o $@
|
||||
build/code_pre_dmadata.elf: $(O_FILES) build/linker_scripts/code_script.txt undef.txt build/linker_scripts/object_script.txt
|
||||
$(LD) -r -T build/linker_scripts/code_script.txt -T undef.txt -T build/linker_scripts/object_script.txt --no-check-sections --accept-unknown-input-arch -N -o $@
|
||||
|
||||
linker_scripts/dmadata_script.txt: $(DMADATA_FILES) build/code_pre_dmadata.elf
|
||||
./tools/dmadata.py ./tables/dmadata_table.txt /dev/null -u -l linker_scripts/dmadata_script.txt -e build/code_pre_dmadata.elf
|
||||
|
||||
build/dmadata: $(COMP_FILES) $(DECOMP_FILES) $(BASEROM_BUILD_FILES)
|
||||
build/dmadata: $(ROM_FILES:build/dmadata=)
|
||||
./tools/dmadata.py ./tables/dmadata_table.txt $@
|
||||
|
||||
build/uncompressed_dmadata: $(DECOMP_FILES) $(BASEROM_BUILD_FILES)
|
||||
build/uncompressed_dmadata: $(UNCOMPRESSED_ROM_FILES:build/uncompressed_dmadata=)
|
||||
./tools/dmadata.py ./tables/dmadata_table.txt $@ -u
|
||||
|
||||
build/baserom/boot build/decomp/code: build/code.elf
|
||||
build/baserom/boot build/baserom/code: build/code.elf
|
||||
@$(OBJCOPY) --dump-section $(notdir $@)=$@ $< /dev/null
|
||||
|
||||
build/decomp/ovl_%: build/code.elf
|
||||
@$(OBJCOPY) --dump-section ovl_$*=$@ $< /dev/null
|
||||
build/baserom/assets/scenes/%: build/code.elf
|
||||
@$(OBJCOPY) --dump-section $*=$@ $< /dev/null
|
||||
|
||||
asm/non_matchings/%: asm/%.asm
|
||||
@./tools/split_asm.py $< $@
|
||||
@@ -173,7 +174,10 @@ disasm: tables/files.txt tables/functions.txt tables/objects.txt tables/variable
|
||||
./tools/disasm.py -d ./asm -l ./tables/files.txt -f ./tables/functions.txt -o ./tables/objects.txt -v ./tables/variables.txt -v ./tables/vrom_variables.txt
|
||||
|
||||
clean:
|
||||
rm -f $(ROM) $(UNCOMPRESSED_ROM) -r build asm
|
||||
rm -rf $(ROM) $(UNCOMPRESSED_ROM) build asm
|
||||
|
||||
distclean: clean
|
||||
rm -rf assets/src baserom/
|
||||
|
||||
setup:
|
||||
git submodule update --init --recursive
|
||||
@@ -189,7 +193,7 @@ diff-init: all
|
||||
cp $(ROM) expected/$(ROM)
|
||||
|
||||
init:
|
||||
$(MAKE) clean
|
||||
$(MAKE) distclean
|
||||
$(MAKE) setup
|
||||
$(MAKE) all
|
||||
$(MAKE) diff-init
|
||||
@@ -209,9 +213,15 @@ build/src/overlays/%.o: src/overlays/%.c
|
||||
@./tools/overlay.py $@ build/src/overlays/$*_overlay.s
|
||||
@$(AS) $(ASFLAGS) build/src/overlays/$*_overlay.s -o build/src/overlays/$*_overlay.o
|
||||
|
||||
build/src/%.o: src/%.c
|
||||
build/%.o: %.c
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
|
||||
|
||||
build/assets/src/scenes/%.o: assets/src/scenes/%.c
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
|
||||
find assets/src/scenes/ -path "assets/src/scenes/$*_room*.c" -not -path "*.inc.c" | \
|
||||
sed 's/\(.*\)\.c/\1/' | \
|
||||
xargs -n 1 -r -I'{}' $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o build/'{}'.o '{}'.c
|
||||
|
||||
build/src/libultra/libc/ll.o: src/libultra/libc/ll.c
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
|
||||
@./tools/set_o32abi_bit.py $@
|
||||
@@ -220,16 +230,27 @@ build/src/libultra/libc/llcvt.o: src/libultra/libc/llcvt.c
|
||||
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
|
||||
@./tools/set_o32abi_bit.py $@
|
||||
|
||||
build/decomp/%: decomp/%
|
||||
@cp $< $@
|
||||
|
||||
build/comp/%.yaz0: build/decomp/%
|
||||
build/comp/%.yaz0: build/baserom/%
|
||||
./tools/yaz0 $< $@
|
||||
|
||||
build/src/%.d: src/%.c
|
||||
build/%.d: %.c
|
||||
@./tools/depend.py $< $@
|
||||
@$(GCC) $< -Iinclude -MM -MT 'build/src/$*.o' >> $@
|
||||
@$(GCC) $< -Iinclude -I./ -MM -MT 'build/$*.o' >> $@
|
||||
|
||||
build/linker_scripts/%: linker_scripts/%
|
||||
@$(GCC) -E -CC -x c -Iinclude $< | grep -v '^#' > $@
|
||||
|
||||
build/assets/%.d: assets/%.c
|
||||
@$(GCC) $< -Iinclude -I./ -MM -MT 'build/assets/$*.o' > $@
|
||||
|
||||
assets/src/scenes/%.c: assets/xml/scenes/%.xml
|
||||
$(ZAPD) e -b baserom/assets/scenes -i $< -o $(dir assets/src/scenes/$*)
|
||||
find $(dir assets/src/scenes/$*) -path "assets/src/scenes/$**.png" | \
|
||||
sed 's/\([^\.]*\)\.\([^\.]*\)\.png/$(subst /,\/,$(ZAPD)) btex -tt \2 -i \1.\2.png -o \1.\2.inc.c/' | \
|
||||
bash
|
||||
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
-include $(C_FILES:src/%.c=build/src/%.d)
|
||||
ifneq ($(MAKECMDGOALS), distclean)
|
||||
-include $(C_FILES:%.c=build/%.d)
|
||||
endif
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user