Moved object file output to built-in build

This commit is contained in:
Sauraen
2024-11-18 21:44:58 -08:00
parent a10d3dbe06
commit c92b734037
4 changed files with 57 additions and 58 deletions

View File

@@ -1,6 +1,5 @@
# To build, run something like `make F3DEX3_BrZ` or
# `make F3DEX3_BrW_LVP_NOC_PA_dbgN`. For an explanation of what all the suffixes
# mean, see README.md.
# To build, run something like `make F3DEX3_BrZ` or`make F3DEX3_BrW_LVP_NOC_PA`.
# For an explanation of what all the suffixes mean, see README.md.
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
@@ -31,6 +30,22 @@ ifeq ($(PARENT_OUTPUT_DIR),.)
# but here than to support only building here.
endif
# Find the N64 toolchain, for creating object files.
ifneq (, $(shell which mips64-linux-gnu-as))
AS := mips64-linux-gnu-as
else
ifneq (, $(shell which mips64-ultra-elf-as))
AS := mips64-ultra-elf-as
else
ifneq (, $(shell which mips64-as))
AS := mips64-as
else
$(warning Could not find N64 linker, not building object files)
AS :=
endif
endif
endif
NO_COL := \033[0m
RED := \033[0;31m
GREEN := \033[0;32m
@@ -52,6 +67,11 @@ ALL_UCODES :=
ALL_UCODES_WITH_MD5S :=
ALL_OUTPUT_DIRS :=
ifneq (, $(AS))
%.o: %.s
@$(AS) -march=vr4300 -mabi=32 -I . $< -o $@
endif
define reset_vars
NAME :=
DESCRIPTION :=
@@ -75,6 +95,8 @@ define ucode_rule
DATA_FILE := $$(UCODE_OUTPUT_DIR)/$(NAME).data
SYM_FILE := $$(UCODE_OUTPUT_DIR)/$(NAME).sym
TEMP_FILE := $$(UCODE_OUTPUT_DIR)/$(NAME).tmp.s
S_FILE := $$(UCODE_OUTPUT_DIR)/gsp$(NAME).fifo.s
O_FILE := $$(UCODE_OUTPUT_DIR)/gsp$(NAME).fifo.o
ALL_UCODES += $(NAME)
ifneq ($(MD5_CODE),)
ALL_UCODES_WITH_MD5S += $(NAME)
@@ -96,6 +118,9 @@ define ucode_rule
# Microcode target
.PHONY: $(NAME)
$(NAME): $$(CODE_FILE)
ifneq (, $(AS))
$(NAME): $$(O_FILE)
endif
# Directory target variables, see below.
$$(UCODE_OUTPUT_DIR): UCODE_OUTPUT_DIR:=$$(UCODE_OUTPUT_DIR)
# Directory target recipe
@@ -117,6 +142,8 @@ define ucode_rule
$$(CODE_FILE): ARMIPS_CMDLINE:=$$(ARMIPS_CMDLINE)
$$(CODE_FILE): CODE_FILE:=$$(CODE_FILE)
$$(CODE_FILE): DATA_FILE:=$$(DATA_FILE)
$$(S_FILE): S_FILE:=$$(S_FILE)
$$(S_FILE): NAME:=$$(NAME)
# Target recipe
$$(CODE_FILE): ./f3dex3.s ./rsp/* $(EXTRA_DEPS) | $$(UCODE_OUTPUT_DIR)
@printf "$(INFO)Building microcode: $(NAME): $(DESCRIPTION)$(NO_COL)\n"
@@ -125,6 +152,10 @@ define ucode_rule
@(printf "$(MD5_CODE) *$$(CODE_FILE)" | md5sum --status -c -) && printf " $(SUCCESS)$(NAME) code matches$(NO_COL)\n" || printf " $(FAILURE)$(NAME) code differs$(NO_COL)\n"
@(printf "$(MD5_DATA) *$$(DATA_FILE)" | md5sum --status -c -) && printf " $(SUCCESS)$(NAME) data matches$(NO_COL)\n" || printf " $(FAILURE)$(NAME) data differs$(NO_COL)\n"
endif
ifneq (, $(AS))
$$(S_FILE): $$(CODE_FILE)
@sed "s|XXX|$(NAME)|g" ./template.fifo.s > $$(S_FILE)
endif
$$(eval $$(call reset_vars))
endef

View File

@@ -1,6 +1,7 @@
/*
This is a bit outdated but still generally okay. A full implementation is
present in HackerOoT, see src/code/occlusionplanes.c and related files.
present in HackerOoT, including the dynamic choice of occlusion plane, see
src/code/occlusionplanes.c and related files.
This is a working demo implementation of the occlusion plane, set up in an
OoT scene render function. Here are some rough guidelines on how to properly

View File

@@ -1,54 +0,0 @@
#!/bin/bash
# Create object files
UCODES=(
F3DEX3_BrW
F3DEX3_BrW_PA
F3DEX3_BrW_PB
F3DEX3_BrW_PC
F3DEX3_BrW_NOC
F3DEX3_BrW_NOC_PA
F3DEX3_BrW_NOC_PB
F3DEX3_BrW_NOC_PC
F3DEX3_BrW_LVP
F3DEX3_BrW_LVP_PA
F3DEX3_BrW_LVP_PB
F3DEX3_BrW_LVP_PC
F3DEX3_BrW_LVP_NOC
F3DEX3_BrW_LVP_NOC_PA
F3DEX3_BrW_LVP_NOC_PB
F3DEX3_BrW_LVP_NOC_PC
)
mkdir -p build/objects
for ucode in "${UCODES[@]}"; do
make $ucode
echo .macro glabel label > object.s
echo .global \\label >> object.s
echo .balign 4 >> object.s
echo \\label: >> object.s
echo .endm >> object.s
echo >> object.s
echo .section .text >> object.s
echo >> object.s
echo .balign 16 >> object.s
echo glabel gsp$ucode\_fifoTextStart >> object.s
echo .incbin \"build/$ucode/$ucode.code\" >> object.s
echo .balign 16 >> object.s
echo glabel gsp$ucode\_fifoTextEnd >> object.s
echo >> object.s
echo .section .data >> object.s
echo >> object.s
echo .balign 16 >> object.s >> object.s
echo glabel gsp$ucode\_fifoDataStart >> object.s
echo .incbin \"build/$ucode/$ucode.data\" >> object.s
echo .balign 16 >> object.s
echo glabel gsp$ucode\_fifoDataEnd >> object.s
echo >> object.s
OUTNAME=${ucode//_/.}
mips64-linux-gnu-as -march=vr4300 -mabi=32 -I . object.s -o build/objects/gsp$OUTNAME.fifo.o
done
rm object.s

21
template.fifo.s Normal file
View File

@@ -0,0 +1,21 @@
.macro glabel label
.global \label
.balign 4
\label:
.endm
.section .text
.balign 16
glabel gspXXX_fifoTextStart
.incbin "build/XXX/XXX.code"
.balign 16
glabel gspXXX_fifoTextEnd
.section .data
.balign 16
glabel gspXXX_fifoDataStart
.incbin "build/XXX/XXX.data"
.balign 16
glabel gspXXX_fifoDataEnd