mirror of
https://github.com/Xeeynamo/sotn-decomp.git
synced 2024-11-22 20:49:50 +00:00
Use allegrex assembler for PSP (#1424)
I moved *some* of the PSX-specific stuff out of the common `Makefile` and into the `Makefile.psx.mk` -- there is still more that could be done here, but this should be enough to have the correct rules for PSX and PSP with the desired assembler. Also threw in a bonus feature where I've removed the `move` macro from `macro.inc` because `maspsx` does this automagically for you now.
This commit is contained in:
parent
6d727283f1
commit
20c3370f4f
24
Makefile
24
Makefile
@ -14,8 +14,7 @@ CC := $(CC1PSX)
|
||||
LD := $(CROSS)ld
|
||||
CPP := $(CROSS)cpp
|
||||
OBJCOPY := $(CROSS)objcopy
|
||||
AS_FLAGS += -Iinclude -march=r3000 -mtune=r3000 -no-pad-sections -O1 -G0
|
||||
PSXCC_FLAGS := -quiet -mcpu=3000 -fgnu-linker -mgas -gcoff
|
||||
|
||||
CC_FLAGS += -G0 -w -O2 -funsigned-char -fpeephole -ffunction-cse -fpcc-struct-return -fcommon -fverbose-asm -msoft-float -g
|
||||
CPP_FLAGS += -Iinclude -Iinclude/psxsdk -undef -Wall -fno-builtin
|
||||
CPP_FLAGS += -Dmips -D__GNUC__=2 -D__OPTIMIZE__ -D__mips__ -D__mips -Dpsx -D__psx__ -D__psx -D_PSYQ -D__EXTENSIONS__ -D_MIPSEL -D_LANGUAGE_C -DLANGUAGE_C -DNO_LOGS -DHACKS -DUSE_INCLUDE_ASM
|
||||
@ -24,6 +23,7 @@ LD_FLAGS := -nostdlib --no-check-sections
|
||||
|
||||
# Directories
|
||||
ASM_DIR := asm/$(VERSION)
|
||||
BIN_DIR := bin
|
||||
SRC_DIR := src
|
||||
ASSETS_DIR := assets
|
||||
INCLUDE_DIR := include
|
||||
@ -254,8 +254,6 @@ $(BUILD_DIR)/F_NZ0.BIN:
|
||||
sel: $(BUILD_DIR)/SEL.BIN
|
||||
$(BUILD_DIR)/SEL.BIN: $(BUILD_DIR)/stsel.elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
$(BUILD_DIR)/src/st/sel/%.c.o: src/st/sel/%.c $(MASPSX_APP) $(CC1PSX) src/st/sel/sel.h | stsel_dirs
|
||||
$(CPP) $(CPP_FLAGS) -lang-c $< | $(SOTNSTR) | $(ICONV) | $(CC) $(CC_FLAGS) $(PSXCC_FLAGS) | $(MASPSX) | $(AS) $(AS_FLAGS) -o $@
|
||||
|
||||
st0: $(BUILD_DIR)/ST0.BIN $(BUILD_DIR)/F_ST0.BIN
|
||||
$(BUILD_DIR)/ST0.BIN: $(BUILD_DIR)/stst0.elf
|
||||
@ -356,12 +354,6 @@ $(BUILD_DIR)/weapon/f1_%.elf: $(BUILD_DIR)/$(ASSETS_DIR)/weapon/f_%.o
|
||||
$(LD) -r -b binary -o $@ $<
|
||||
$(BUILD_DIR)/$(ASSETS_DIR)/weapon/%.o: $(ASSETS_DIR)/weapon/%.png
|
||||
./tools/png2bin.py $< $@
|
||||
$(BUILD_DIR)/$(ASSETS_DIR)/weapon/%_1.animset.o: $(ASSETS_DIR)/weapon/%_1.animset.json
|
||||
./tools/splat_ext/animset.py gen-asm $< $(BUILD_DIR)/$(ASSETS_DIR)/weapon/$*_1.animset.s -s g_Animset
|
||||
$(AS) $(AS_FLAGS) -o $@ $(BUILD_DIR)/$(ASSETS_DIR)/weapon/$*_1.animset.s
|
||||
$(BUILD_DIR)/$(ASSETS_DIR)/weapon/%_2.animset.o: $(ASSETS_DIR)/weapon/%_2.animset.json
|
||||
./tools/splat_ext/animset.py gen-asm $< $(BUILD_DIR)/$(ASSETS_DIR)/weapon/$*_2.animset.s -s g_Animset2
|
||||
$(AS) $(AS_FLAGS) -o $@ $(BUILD_DIR)/$(ASSETS_DIR)/weapon/$*_2.animset.s
|
||||
|
||||
extract: extract_$(VERSION)
|
||||
|
||||
@ -439,7 +431,7 @@ extract_disk_psp%:
|
||||
mkdir -p disks/psp$*
|
||||
7z x -y disks/sotn.psp$*.iso -odisks/psp$*/
|
||||
|
||||
update-dependencies: $(ASMDIFFER_APP) $(M2CTX_APP) $(M2C_APP) $(MASPSX_APP) $(SATURN_SPLITTER_APP) $(GO)
|
||||
update-dependencies: $(ASMDIFFER_APP) $(M2CTX_APP) $(M2C_APP) $(MASPSX_APP) $(SATURN_SPLITTER_APP) $(GO) $(ALLEGREX_AS)
|
||||
cd $(SATURN_SPLITTER_DIR)/rust-dis && cargo build --release
|
||||
cd $(SATURN_SPLITTER_DIR)/adpcm-extract && cargo build --release
|
||||
pip3 install -r $(TOOLS_DIR)/requirements-python.txt
|
||||
@ -475,16 +467,6 @@ $(SOTNDISK): $(GO) $(SOTNDISK_SOURCES)
|
||||
$(SOTNASSETS): $(GO) $(SOTNASSETS_SOURCES)
|
||||
cd tools/sotn-assets; $(GO) install
|
||||
|
||||
$(BUILD_DIR)/%.s.o: %.s
|
||||
mkdir -p $(dir $@)
|
||||
$(AS) $(AS_FLAGS) -o $@ $<
|
||||
$(BUILD_DIR)/%.c.o: %.c $(MASPSX_APP) $(CC1PSX)
|
||||
mkdir -p $(dir $@)
|
||||
$(CPP) $(CPP_FLAGS) -lang-c $< | $(SOTNSTR) | $(ICONV) | $(CC) $(CC_FLAGS) $(PSXCC_FLAGS) | $(MASPSX) | $(AS) $(AS_FLAGS) -o $@
|
||||
|
||||
$(BUILD_DIR)/$(SRC_DIR)/main/psxsdk/libgpu/sys.c.o: $(SRC_DIR)/main/psxsdk/libgpu/sys.c $(MASPSX_APP) $(CC1PSX)
|
||||
$(CPP) $(CPP_FLAGS) -lang-c $< | $(SOTNSTR) | $(ICONV) | $(CC) $(CC_FLAGS) $(PSXCC_FLAGS) | $(MASPSX_21) | $(AS) $(AS_FLAGS) -o $@
|
||||
|
||||
# Handles assets
|
||||
$(BUILD_DIR)/$(ASSETS_DIR)/%.spritesheet.json.o: $(ASSETS_DIR)/%.spritesheet.json
|
||||
./tools/splat_ext/spritesheet.py encode $< $(BUILD_DIR)/$(ASSETS_DIR)/$*.s
|
||||
|
@ -1,25 +1,29 @@
|
||||
WIBO := bin/wibo
|
||||
MWCCPSP := bin/mwccpsp.exe
|
||||
# Configuration
|
||||
BUILD_DIR := build/pspeu
|
||||
PSP_EU_TARGETS := stwrp tt_000
|
||||
|
||||
GNUASPSP := mipsel-linux-gnu-as -I include/ -G0 -march=r6000 -mabi=eabi
|
||||
MWASPSP := $(WIBO) bin/asm_psp_elf.exe -gnu
|
||||
ASPSP := $(GNUASPSP)
|
||||
# Flags
|
||||
AS_FLAGS += -EL -I include/ -G0 -march=allegrex -mabi=eabi
|
||||
MWCCPSP_FLAGS := -gccinc -Iinclude -D_internal_version_$(VERSION) -Op -c -lang c -sdatathreshold 0 -char unsigned
|
||||
MWLDPSP_FLAGS := -partial -nostdlib -msgstyle gcc -sym full,elf -g
|
||||
|
||||
GNULDPSP := mipsel-linux-gnu-ld
|
||||
MWLDPSP := $(WIBO) bin/mwldpsp.exe -partial -nostdlib -msgstyle gcc -sym full,elf -g
|
||||
LDPSP := $(GNULDPSP)
|
||||
# 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)
|
||||
|
||||
PSP_BUILD_DIR := build/pspeu
|
||||
CCPSP := MWCIncludes=bin/ $(WIBO) $(MWCCPSP)
|
||||
PSP_EU_TARGETS := stwrp tt_000
|
||||
SPLAT_PIP := splat split
|
||||
|
||||
MWCCPSP_FLAGS := -gccinc -Iinclude -D_internal_version_$(VERSION) -Op -c -lang c -sdatathreshold 0 -char unsigned
|
||||
|
||||
# Helper Functions
|
||||
define list_src_files_psp
|
||||
$(foreach dir,$(ASM_DIR)/$(1),$(wildcard $(dir)/**.s))
|
||||
$(foreach dir,$(ASM_DIR)/$(1)/data,$(wildcard $(dir)/**.s))
|
||||
@ -28,52 +32,52 @@ define list_src_files_psp
|
||||
endef
|
||||
|
||||
define list_o_files_psp
|
||||
$(foreach file,$(call list_src_files_psp,$(1)),$(PSP_BUILD_DIR)/$(file).o)
|
||||
$(foreach file,$(call list_src_files_psp,$(1)),$(BUILD_DIR)/$(file).o)
|
||||
endef
|
||||
|
||||
# Targets
|
||||
build_pspeu: $(addsuffix _psp,$(PSP_EU_TARGETS))
|
||||
|
||||
extract_pspeu: $(addprefix $(PSP_BUILD_DIR)/,$(addsuffix .ld,$(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/mwccpsp_219
|
||||
$(MWCCPSP): $(WIBO) $(BIN_DIR)/mwccpsp_219
|
||||
|
||||
$(MWCCGAP_APP):
|
||||
git submodule init $(MWCCGAP_DIR)
|
||||
git submodule update $(MWCCGAP_DIR)
|
||||
|
||||
$(PSP_BUILD_DIR)/%.c.o: %.c $(MWCCPSP) $(MWCCGAP_APP)
|
||||
mkdir -p $(dir $@)
|
||||
$(MWCCGAP) $< $@ --mwcc-path $(MWCCPSP) --use-wibo --wibo-path $(WIBO) --asm-dir-prefix asm/pspeu $(MWCCPSP_FLAGS)
|
||||
tt_000_psp: $(BUILD_DIR)/tt_000.bin
|
||||
stwrp_psp: $(BUILD_DIR)/wrp.bin
|
||||
|
||||
|
||||
$(PSP_BUILD_DIR)/asm/psp%.s.o: asm/psp%.s
|
||||
mkdir -p $(dir $@)
|
||||
$(ASPSP) -o $@ $<
|
||||
|
||||
|
||||
$(PSP_BUILD_DIR)/assets/%/mwo_header.bin.o: assets/%/mwo_header.bin
|
||||
mkdir -p $(dir $@)
|
||||
mipsel-linux-gnu-ld -r -b binary -o $@ $<
|
||||
|
||||
tt_000_psp: $(PSP_BUILD_DIR)/tt_000.bin
|
||||
stwrp_psp: $(PSP_BUILD_DIR)/wrp.bin
|
||||
|
||||
$(PSP_BUILD_DIR)/%.bin: $(PSP_BUILD_DIR)/%.elf
|
||||
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
$(PSP_BUILD_DIR)/wrp.bin: $(PSP_BUILD_DIR)/stwrp.elf
|
||||
$(BUILD_DIR)/wrp.bin: $(BUILD_DIR)/stwrp.elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
$(PSP_BUILD_DIR)/st%.ld: $(CONFIG_DIR)/splat.pspeu.st%.yaml $(PSX_BASE_SYMS) $(CONFIG_DIR)/symbols.pspeu.st%.txt
|
||||
$(BUILD_DIR)/st%.ld: $(CONFIG_DIR)/splat.pspeu.st%.yaml $(PSX_BASE_SYMS) $(CONFIG_DIR)/symbols.pspeu.st%.txt
|
||||
$(SPLAT_PIP) $<
|
||||
$(PSP_BUILD_DIR)/tt_%.ld: $(CONFIG_DIR)/splat.pspeu.tt_%.yaml $(PSX_BASE_SYMS) $(CONFIG_DIR)/symbols.pspeu.tt_%.txt
|
||||
$(BUILD_DIR)/tt_%.ld: $(CONFIG_DIR)/splat.pspeu.tt_%.yaml $(PSX_BASE_SYMS) $(CONFIG_DIR)/symbols.pspeu.tt_%.txt
|
||||
$(SPLAT_PIP) $<
|
||||
$(PSP_BUILD_DIR)/tt_%.elf: $(PSP_BUILD_DIR)/tt_%.ld $$(call list_o_files_psp,servant/tt_$$*) $(PSP_BUILD_DIR)/assets/servant/tt_%/mwo_header.bin.o
|
||||
$(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
|
||||
$(PSP_BUILD_DIR)/stwrp.elf: $(PSP_BUILD_DIR)/stwrp.ld $(addprefix $(PSP_BUILD_DIR)/src/st/wrp/,$(addsuffix .c.o,$(ST_WRP_MERGE))) $$(call list_o_files_psp,st/wrp_psp) $(PSP_BUILD_DIR)/assets/st/wrp/mwo_header.bin.o
|
||||
$(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 $@ $<
|
||||
|
||||
$(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)
|
||||
|
||||
$(BUILD_DIR)/assets/%/mwo_header.bin.o: assets/%/mwo_header.bin
|
||||
@mkdir -p $(dir $@)
|
||||
$(LD) -r -b binary -o $@ $<
|
||||
|
@ -1,3 +1,7 @@
|
||||
# flags
|
||||
AS_FLAGS += -Iinclude -march=r3000 -mtune=r3000 -no-pad-sections -O1 -G0
|
||||
PSXCC_FLAGS := -quiet -mcpu=3000 -fgnu-linker -mgas -gcoff
|
||||
|
||||
# configuration
|
||||
PSX_OVLS := dra ric weapon
|
||||
PSX_KSTAGES := cen dre mad no3 np3 nz0 sel st0 wrp
|
||||
@ -53,6 +57,28 @@ $(BUILD_DIR)/weapon.ld: $(CONFIG_DIR)/splat.$(VERSION).weapon.yaml $(PSX_BASE_SY
|
||||
$(SPLAT) $<
|
||||
touch $@
|
||||
|
||||
$(BUILD_DIR)/src/st/sel/%.c.o: src/st/sel/%.c $(MASPSX_APP) $(CC1PSX) src/st/sel/sel.h | stsel_dirs
|
||||
$(CPP) $(CPP_FLAGS) -lang-c $< | $(SOTNSTR) | $(ICONV) | $(CC) $(CC_FLAGS) $(PSXCC_FLAGS) | $(MASPSX) | $(AS) $(AS_FLAGS) -o $@
|
||||
|
||||
$(BUILD_DIR)/$(ASSETS_DIR)/weapon/%_1.animset.o: $(ASSETS_DIR)/weapon/%_1.animset.json
|
||||
./tools/splat_ext/animset.py gen-asm $< $(BUILD_DIR)/$(ASSETS_DIR)/weapon/$*_1.animset.s -s g_Animset
|
||||
$(AS) $(AS_FLAGS) -o $@ $(BUILD_DIR)/$(ASSETS_DIR)/weapon/$*_1.animset.s
|
||||
$(BUILD_DIR)/$(ASSETS_DIR)/weapon/%_2.animset.o: $(ASSETS_DIR)/weapon/%_2.animset.json
|
||||
./tools/splat_ext/animset.py gen-asm $< $(BUILD_DIR)/$(ASSETS_DIR)/weapon/$*_2.animset.s -s g_Animset2
|
||||
$(AS) $(AS_FLAGS) -o $@ $(BUILD_DIR)/$(ASSETS_DIR)/weapon/$*_2.animset.s
|
||||
|
||||
# assembly and c files
|
||||
$(BUILD_DIR)/%.s.o: %.s
|
||||
mkdir -p $(dir $@)
|
||||
$(AS) $(AS_FLAGS) -o $@ $<
|
||||
|
||||
$(BUILD_DIR)/%.c.o: %.c $(MASPSX_APP) $(CC1PSX)
|
||||
mkdir -p $(dir $@)
|
||||
$(CPP) $(CPP_FLAGS) -lang-c $< | $(SOTNSTR) | $(ICONV) | $(CC) $(CC_FLAGS) $(PSXCC_FLAGS) | $(MASPSX) | $(AS) $(AS_FLAGS) -o $@
|
||||
|
||||
$(BUILD_DIR)/$(SRC_DIR)/main/psxsdk/libgpu/sys.c.o: $(SRC_DIR)/main/psxsdk/libgpu/sys.c $(MASPSX_APP) $(CC1PSX)
|
||||
$(CPP) $(CPP_FLAGS) -lang-c $< | $(SOTNSTR) | $(ICONV) | $(CC) $(CC_FLAGS) $(PSXCC_FLAGS) | $(MASPSX_21) | $(AS) $(AS_FLAGS) -o $@
|
||||
|
||||
extract_assets: $(SOTNASSETS)
|
||||
$(SOTNASSETS) extract -stage_ovl disks/$(VERSION)/ST/CEN/CEN.BIN -o assets/st/cen
|
||||
$(SOTNASSETS) extract -stage_ovl disks/$(VERSION)/ST/DRE/DRE.BIN -o assets/st/dre
|
||||
|
1
bin/allegrex-as.tar.gz.sha256
Normal file
1
bin/allegrex-as.tar.gz.sha256
Normal file
@ -0,0 +1 @@
|
||||
7408cc6c02664497a5058f61c275d60d208a0e9492d295330daf59fa1ea5b80f bin/allegrex-as.tar.gz
|
@ -10,8 +10,5 @@
|
||||
.macro .def #
|
||||
.endm
|
||||
|
||||
.macro move a, b
|
||||
addu \a, \b, $zero
|
||||
.endm
|
||||
|
||||
.include "gte.inc"
|
||||
|
Loading…
Reference in New Issue
Block a user