mirror of
https://github.com/Xeeynamo/sotn-decomp.git
synced 2024-11-23 04:59:41 +00:00
f9feecf70b
Decided to tackle this whole file. It mostly matches with the existing DRA, so I've been back-porting the required changes to get the matches. Everything here matches in both. The only issue is the deadstripping, which we still need to figure out. I'm not sure why there's a file split at the end of this PSP file, where there isn't one in the PS1 game. I'll try removing the split once the functions are done on each side of the split. Also adjusted the makefile filter logic so that we only need to give the name of the file, rather than the full path. This makes the file list more concise. If we run into collisions (two files of the same name, in different overlays, which need different optimizations) we can revisit this.
93 lines
3.3 KiB
Makefile
93 lines
3.3 KiB
Makefile
# Configuration
|
|
BUILD_DIR := build/pspeu
|
|
PSP_EU_TARGETS := dra stwrp tt_000
|
|
|
|
# Flags
|
|
AS_FLAGS += -EL -I include/ -G0 -march=allegrex -mabi=eabi
|
|
MWCCPSP_FLAGS := -gccinc -Iinclude -D_internal_version_$(VERSION) -c -lang c -sdatathreshold 0 -char unsigned
|
|
MWLDPSP_FLAGS := -partial -nostdlib -msgstyle gcc -sym full,elf -g
|
|
|
|
# Tools
|
|
ALLEGREX_AS := $(BIN_DIR)/allegrex-as
|
|
AS := $(ALLEGREX_AS)
|
|
WIBO := $(BIN_DIR)/wibo
|
|
MWCCPSP := $(BIN_DIR)/mwccpsp.exe
|
|
CCPSP := MWCIncludes=$(BIN_DIR) $(WIBO) $(MWCCPSP)
|
|
|
|
MWASPSP := $(WIBO) $(BIN_DIR)/asm_psp_elf.exe -gnu
|
|
MWLDPSP := $(WIBO) $(BIN_DIR)/mwldpsp.exe
|
|
|
|
MWCCGAP_DIR := $(TOOLS_DIR)/mwccgap
|
|
MWCCGAP_APP := $(MWCCGAP_DIR)/mwccgap.py
|
|
MWCCGAP := $(PYTHON) $(MWCCGAP_APP)
|
|
|
|
SPLAT_PIP := splat split
|
|
|
|
# Helper Functions
|
|
define list_src_files_psp
|
|
$(foreach dir,$(ASM_DIR)/$(1),$(wildcard $(dir)/**.s))
|
|
$(foreach dir,$(ASM_DIR)/$(1)/data,$(wildcard $(dir)/**.s))
|
|
$(foreach dir,$(SRC_DIR)/$(1),$(wildcard $(dir)/**.c))
|
|
$(foreach dir,$(ASSETS_DIR)/$(1),$(wildcard $(dir)/**))
|
|
endef
|
|
|
|
define list_o_files_psp
|
|
$(foreach file,$(call list_src_files_psp,$(1)),$(BUILD_DIR)/$(file).o)
|
|
endef
|
|
|
|
# Targets
|
|
build_pspeu: $(addsuffix _psp,$(PSP_EU_TARGETS))
|
|
|
|
extract_pspeu: $(addprefix $(BUILD_DIR)/,$(addsuffix .ld,$(PSP_EU_TARGETS)))
|
|
|
|
$(WIBO):
|
|
wget -O $@ https://github.com/decompals/wibo/releases/download/0.6.13/wibo
|
|
sha256sum --check $(WIBO).sha256
|
|
chmod +x $(WIBO)
|
|
$(MWCCPSP): $(WIBO) $(BIN_DIR)/mwccpsp_219
|
|
|
|
$(MWCCGAP_APP):
|
|
git submodule init $(MWCCGAP_DIR)
|
|
git submodule update $(MWCCGAP_DIR)
|
|
|
|
dra_psp: $(BUILD_DIR)/dra.bin
|
|
tt_000_psp: $(BUILD_DIR)/tt_000.bin
|
|
stwrp_psp: $(BUILD_DIR)/wrp.bin
|
|
|
|
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf
|
|
$(OBJCOPY) -O binary $< $@
|
|
$(BUILD_DIR)/wrp.bin: $(BUILD_DIR)/stwrp.elf
|
|
$(OBJCOPY) -O binary $< $@
|
|
|
|
$(BUILD_DIR)/dra.ld: $(CONFIG_DIR)/splat.pspeu.dra.yaml $(PSX_BASE_SYMS) $(CONFIG_DIR)/symbols.pspeu.dra.txt
|
|
$(SPLAT_PIP) $<
|
|
$(BUILD_DIR)/st%.ld: $(CONFIG_DIR)/splat.pspeu.st%.yaml $(PSX_BASE_SYMS) $(CONFIG_DIR)/symbols.pspeu.st%.txt
|
|
$(SPLAT_PIP) $<
|
|
$(BUILD_DIR)/tt_%.ld: $(CONFIG_DIR)/splat.pspeu.tt_%.yaml $(PSX_BASE_SYMS) $(CONFIG_DIR)/symbols.pspeu.tt_%.txt
|
|
$(SPLAT_PIP) $<
|
|
|
|
$(BUILD_DIR)/dra.elf: $(BUILD_DIR)/dra.ld $$(call list_o_files_psp,dra_psp)
|
|
$(call link,dra,$@)
|
|
$(BUILD_DIR)/tt_%.elf: $(BUILD_DIR)/tt_%.ld $$(call list_o_files_psp,servant/tt_$$*) $(BUILD_DIR)/assets/servant/tt_%/mwo_header.bin.o
|
|
$(call link,tt_$*,$@)
|
|
|
|
ST_WRP_MERGE = st_update e_particles e_room_fg st_common st_debug e_breakable popup warp e_red_door
|
|
$(BUILD_DIR)/stwrp.elf: $(BUILD_DIR)/stwrp.ld $(addprefix $(BUILD_DIR)/src/st/wrp/,$(addsuffix .c.o,$(ST_WRP_MERGE))) $$(call list_o_files_psp,st/wrp_psp) $(BUILD_DIR)/assets/st/wrp/mwo_header.bin.o
|
|
$(call link,stwrp,$@)
|
|
|
|
# Recipes
|
|
$(BUILD_DIR)/%.s.o: %.s
|
|
@mkdir -p $(dir $@)
|
|
$(AS) $(AS_FLAGS) -o $@ $<
|
|
|
|
FILES_WITH_O4 = 61F30.c.o 63C90.c.o
|
|
OPTIMIZATION = $(if $(filter $(notdir $@),$(FILES_WITH_O4)), -O4, -Op)
|
|
|
|
$(BUILD_DIR)/%.c.o: %.c $(MWCCPSP) $(MWCCGAP_APP)
|
|
@mkdir -p $(dir $@)
|
|
$(MWCCGAP) $< $@ --mwcc-path $(MWCCPSP) --use-wibo --wibo-path $(WIBO) --as-path $(AS) --asm-dir-prefix asm/pspeu $(OPTIMIZATION) $(MWCCPSP_FLAGS)
|
|
|
|
$(BUILD_DIR)/assets/%/mwo_header.bin.o: assets/%/mwo_header.bin
|
|
@mkdir -p $(dir $@)
|
|
$(LD) -r -b binary -o $@ $<
|