Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kirby 64 Filesystem 2 (WIP) #53

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
build/*
tools/GeoFromBin*
tools/level_settings/convert
tools/filesystem_build/__pycache__/*
assets/**/*
!assets/*.txt
*.z64
textures/*
bin/*
Expand Down
45 changes: 16 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Makefile to rebuild Kirby 64 split image


################ Target Executable and Sources ###############

# BUILD_DIR is location where all build artifacts are placed
BUILD_DIR_BASE = build
VERSION = us
BUILD_DIR = $(BUILD_DIR_BASE)/$(VERSION)

-include assets.mk

GRUCODE := F3DEX2_2.04H

VERBOSE := 1
Expand Down Expand Up @@ -69,12 +72,6 @@ LOADER = loader64
LOADER_FLAGS = -vwf
FixPath = $(subst /,/,$1)

ASSET_DIRS := $(wildcard assets/geo/bank_0/**) \
$(wildcard assets/geo/bank_1/**) \
$(wildcard assets/geo/bank_2/**) \
$(wildcard assets/geo/bank_7/**) \
$(wildcard assets/geo/bank_3/**)

ASM_DIRS := asm data $(wildcard asm/ovl*) asm/ovl0/lib \
asm/data asm/banks $(wildcard data/ovl*)

Expand All @@ -85,10 +82,6 @@ BIN_DIRS := bin/geo bin/image bin/misc bin/anim
DATA_DIRS := actors
DATA_FILES := $(foreach dir,$(DATA_DIRS),$(wildcard $(dir)/*.c))

LEVEL_DIRS = $(wildcard assets/misc/bank_7/*)
LEVEL_FILES = $(foreach dir, $(LEVEL_DIRS), $(wildcard $(dir)/level.bin))
LEVEL_S_FILES = $(foreach file, $(LEVEL_FILES), $(file:.bin=.s))
LEVEL_O_FILES = $(foreach file, $(LEVEL_S_FILES), $(BUILD_DIR)/$(file:.s=.o))

TEXTURES_DIR = textures

Expand All @@ -101,8 +94,6 @@ S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
S_FILES += $(LEVEL_S_FILES)
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))

MODEL_FILES := $(foreach dir,$(ASSET_DIRS),$(wildcard $(dir)/geo.bin))
MODEL_C_FILES := $(foreach file,$(MODEL_FILES),$(file:.bin=.c))


UCODE_BASE_DIR := ucode
Expand Down Expand Up @@ -145,8 +136,14 @@ CC_TEST := gcc -Wall
NOEXTRACT ?= 0


ALL_DIRS = $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(LEVEL_DIRS) $(ASSET_DIRS) $(SRC_DIRS) $(INCLUDE_DIRS) $(ASM_DIRS) $(TEXTURES_DIR)/raw $(TEXTURES_DIR)/standalone $(UCODE_DIRS))
ALL_DIRS = $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(LEVEL_DIRS) \
$(ASSET_DIRS) \
$(SRC_DIRS) \
$(INCLUDE_DIRS) \
$(ASM_DIRS) \
$(UCODE_DIRS))
DUMMY != mkdir -p $(ALL_DIRS)
DUMMY != python3 tools/filesystem_build/descriptor_parser.py

# Checking if submodules exist
DUMMY != ls libreultra >/dev/null || echo FAIL
Expand Down Expand Up @@ -205,9 +202,8 @@ $(BUILD_DIR)/src/ovl3/ovl3_1.o: OPT_FLAGS = -O2 -Wo,-loopunroll

# $(BUILD_DIR)/src/ovl1/save_file.o: OPT_FLAGS += -Wo,-loopunroll,0


$(BUILD_DIR):
mkdir $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS))
mkdir -p $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS))

assets/misc/%.s: assets/misc/%.bin
python3 tools/level_settings/helper.py $<
Expand All @@ -234,19 +230,9 @@ $(BUILD_DIR)/data/%.o: data/%.c
# $(CC_TEST) -c $(INCLUDE_CFLAGS) -o $@ $<
$(GCC) -c $(GCC_CFLAGS) -D__sgi -o $@ $<

assets/geo/%.c: assets/geo/%.bin
python3 tools/decompile_geos.py $<

$(BUILD_DIR)/assets/geo/%.o: assets/geo/%.c
$(GCC) -c $(GCC_CFLAGS) -D__sgi -o $@ $<

$(BUILD_DIR)/assets/geo/%.o: assets/geo/%.s
$(AS) -c $(ASFLAGS) -o $@ $<

$(BUILD_DIR)/assets/misc/%.o: assets/misc/%.s
$(AS) $(ASFLAGS) -o $@ $<
$(BUILD_DIR)/data/kirby.066630.o: $(ASSET_HEADERS)

$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c $(LEVEL_S_FILES) $(ASSET_HEADERS)
@$(CC_CHECK) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
$(CC) -c $(CFLAGS) -o $@ $<

Expand All @@ -257,7 +243,7 @@ $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) $(UCODE_LD) undefined_syms.txt
$(CPP) $(VERSION_CFLAGS) -MMD -MP -MT $@ -MF [email protected] -o $@ $< \
-DBUILD_DIR=$(BUILD_DIR)

$(BUILD_DIR)/$(TARGET).elf: $(LEVEL_S_FILES) $(ASSET_O_FILES) $(MODEL_C_FILES) $(O_FILES) $(BUILD_DIR)/$(LD_SCRIPT) $(BUILD_DIR)/libultra.a $(BUILD_DIR)/libn_audio.a $(UCODE_TEXT_O_FILES) $(UCODE_DATA_O_FILES)
$(BUILD_DIR)/$(TARGET).elf: $(ASSET_TABLE_OFILES) $(O_FILES) $(BUILD_DIR)/$(LD_SCRIPT) $(BUILD_DIR)/libultra.a $(BUILD_DIR)/libn_audio.a $(UCODE_TEXT_O_FILES) $(UCODE_DATA_O_FILES)
$(V)$(LD) -L $(BUILD_DIR) $(LDFLAGS) -o $@ $(LIBS) -lultra -ln_audio

# final z64 updates checksum
Expand All @@ -283,12 +269,13 @@ test-pj64: $(BUILD_DIR)/$(TARGET).z64
load: $(BUILD_DIR)/$(TARGET).z64
$(LOADER) $(LOADER_FLAGS) $<

setup: $(MODEL_C_FILES)
setup:
make -C libreultra -j4
make -C libreultra naudio -j4
make -C tools -j4
make -C f3dex2 VERSION=2.04H ARMIPS=../tools/armips
tools/extract_assets $(VERSION)
mkdir -p $(ALL_DIRS)

.PHONY: all clean default diff test distclean

Expand Down
Loading