mirror of
https://github.com/Xeeynamo/sotn-decomp.git
synced 2025-02-17 03:30:02 +00:00
![bismurphy](/assets/img/avatar_default.png)
Some checks failed
Format code / format (push) Has been cancelled
Build C code / extract-assets (push) Has been cancelled
Build Saturn version / build-and-test-saturn (push) Has been cancelled
Build Saturn version / function-finder-saturn (push) Has been cancelled
Build Debug Module tool / build (push) Has been cancelled
Build PSX and PSP version / build-and-test (pspeu, hd) (push) Has been cancelled
Build PSX and PSP version / build-and-test (pspeu, pspeu) (push) Has been cancelled
Build PSX and PSP version / build-and-test (us, us) (push) Has been cancelled
Build C code / build-linux (i686, Debug, clang, custom) (push) Has been cancelled
Build C code / build-linux (i686, Debug, clang, lle) (push) Has been cancelled
Build C code / build-linux (i686, Debug, gcc, custom) (push) Has been cancelled
Build C code / build-linux (i686, Debug, gcc, lle) (push) Has been cancelled
Build C code / build-linux (i686, RelWithDebInfo, clang, custom) (push) Has been cancelled
Build C code / build-linux (i686, RelWithDebInfo, clang, lle) (push) Has been cancelled
Build C code / build-linux (i686, RelWithDebInfo, gcc, custom) (push) Has been cancelled
Build C code / build-linux (i686, RelWithDebInfo, gcc, lle) (push) Has been cancelled
Build C code / build-linux (x86_64, Debug, clang, custom) (push) Has been cancelled
Build C code / build-linux (x86_64, Debug, clang, lle) (push) Has been cancelled
Build C code / build-linux (x86_64, Debug, gcc, custom) (push) Has been cancelled
Build C code / build-linux (x86_64, Debug, gcc, lle) (push) Has been cancelled
Build C code / build-linux (x86_64, RelWithDebInfo, clang, custom) (push) Has been cancelled
Build C code / build-linux (x86_64, RelWithDebInfo, clang, lle) (push) Has been cancelled
Build C code / build-linux (x86_64, RelWithDebInfo, gcc, custom) (push) Has been cancelled
Build C code / build-linux (x86_64, RelWithDebInfo, gcc, lle) (push) Has been cancelled
Build C code / build-macos (Debug, custom) (push) Has been cancelled
Build C code / build-macos (Debug, lle) (push) Has been cancelled
Build C code / build-macos (RelWithDebInfo, custom) (push) Has been cancelled
Build C code / build-macos (RelWithDebInfo, lle) (push) Has been cancelled
Build C code / build-windows (Debug, custom) (push) Has been cancelled
Build C code / build-windows (Debug, lle) (push) Has been cancelled
Build C code / build-windows (RelWithDebInfo, custom) (push) Has been cancelled
Build C code / build-windows (RelWithDebInfo, lle) (push) Has been cancelled
Build PSX and PSP version / generate-progress-report (pspeu, hd) (push) Has been cancelled
Build PSX and PSP version / generate-progress-report (pspeu, pspeu) (push) Has been cancelled
Build PSX and PSP version / generate-progress-report (us, us) (push) Has been cancelled
Build PSX and PSP version / generate-duplicates-report (us, us) (push) Has been cancelled
Build PSX and PSP version / generate-duplicates-report-psp (pspeu, pspeu) (push) Has been cancelled
Had to tweak some file splits, but ultimately I managed to decompile all of the functions in a PSP file, and then line up the two DRA codebases so that PSP could pull from the existing one. Of course, some of the functions also needed tweaking to end up matching on PSP. Glad to be able to prove this is possible in DRA!
95 lines
3.5 KiB
Makefile
95 lines
3.5 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) $<
|
|
|
|
ST_DRA_MERGE = 624DC
|
|
$(BUILD_DIR)/dra.elf: $(BUILD_DIR)/dra.ld $(addprefix $(BUILD_DIR)/src/dra/,$(addsuffix .c.o,$(ST_DRA_MERGE))) $$(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 = 624DC.c.o 61F30.c.o 63C90.c.o
|
|
OPT_HIGH = -O4,p #need this because otherwise the comma breaks the filter statement
|
|
OPTIMIZATION = $(if $(filter $(notdir $@),$(FILES_WITH_O4)), $(OPT_HIGH), -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 $(MWCCPSP_FLAGS) $(OPTIMIZATION)
|
|
|
|
$(BUILD_DIR)/assets/%/mwo_header.bin.o: assets/%/mwo_header.bin
|
|
@mkdir -p $(dir $@)
|
|
$(LD) -r -b binary -o $@ $<
|