Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ expected/*
/music/**/*.m64
/sound/**/*.m64
/sound/**/*.aiff
/sound/**/*.aifc
!/textures/**/*custom*.png
!/textures/**/*custom*/**/*.png
!/sound/**/*custom*.m64
Expand Down
84 changes: 82 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ ASSET_DIR := assets
BIN_DIR := bin
DATA_DIR := data
INCLUDE_DIRS := include
SOUND_BIN_DIR := $(BUILD_DIR)/sound

# Directories containing source files
SRC_ASSETS_DIR := assets/code/ceremony_data assets/code/startup_logo assets/code/data_800E45C0 assets/code/data_segment2 assets/code/data_800E8700 assets/code/common_data
Expand All @@ -242,9 +243,26 @@ COURSE_DIRS := $(shell find courses -mindepth 1 -type d)
TEXTURES_DIR = textures
TEXTURE_DIRS := textures/common

# Sound files
SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
SOUND_SAMPLE_DIRS := $(wildcard sound/samples/*)
SOUND_SAMPLE_AIFFS := $(foreach dir,$(SOUND_SAMPLE_DIRS),$(wildcard $(dir)/*.aiff))
NONMATCHED_SOUND_SAMPLE_AIFFS := $(foreach dir,$(SOUND_SAMPLE_DIRS),$(wildcard $(dir)/*.aifc))

SOUND_SAMPLE_TABLES := $(foreach file,$(SOUND_SAMPLE_AIFFS),$(BUILD_DIR)/$(file:.aiff=.table))
SOUND_SAMPLE_AIFCS := $(foreach file,$(SOUND_SAMPLE_AIFFS),$(BUILD_DIR)/$(file:.aiff=.aifc)) $(foreach file,$(NONMATCHED_SOUND_SAMPLE_AIFFS),$(BUILD_DIR)/$(file))
SOUND_SEQUENCE_DIRS := sound/sequences sound/sequences/$(VERSION)

# all .m64 files in SOUND_SEQUENCE_DIRS, plus all .m64 files that are generated from .s files in SOUND_SEQUENCE_DIRS
SOUND_SEQUENCE_FILES := \
$(foreach dir,$(SOUND_SEQUENCE_DIRS),\
$(wildcard $(dir)/*.m64) \
$(foreach file,$(wildcard $(dir)/*.s),$(BUILD_DIR)/$(file:.s=.m64)) \
)

ALL_DIRS = $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(COURSE_DIRS) include $(ASM_DIRS) $(TEXTURES_DIR)/raw \
$(TEXTURES_DIR)/standalone $(TEXTURES_DIR)/startup_logo $(TEXTURES_DIR)/crash_screen $(TEXTURES_DIR)/trophy $(TEXTURES_DIR)/courses \
$(TEXTURE_DIRS) $(TEXTURE_DIRS)/tlut $(BIN_DIR)) assets/course_metadata
$(TEXTURE_DIRS) $(TEXTURE_DIRS)/tlut $(BIN_DIR) $(SOUND_SAMPLE_DIRS)) assets/course_metadata

# file dependencies generated by splitter
MAKEFILE_SPLIT = Makefile.split
Expand All @@ -259,7 +277,6 @@ S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
# Include source files in courses/course_name/files.c but exclude .inc.c files.
COURSE_FILES := $(foreach dir,$(COURSE_DIRS),$(filter-out %.inc.c,$(wildcard $(dir)/*.c)))


# Object files
O_FILES := \
$(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \
Expand Down Expand Up @@ -389,11 +406,14 @@ MIO0TOOL := $(TOOLS_DIR)/mio0
N64CKSUM := $(TOOLS_DIR)/n64cksum
N64GRAPHICS := $(TOOLS_DIR)/n64graphics
DLPACKER := $(TOOLS_DIR)/displaylist_packer
AIFF_EXTRACT_CODEBOOK := $(TOOLS_DIR)/aiff_extract_codebook
VADPCM_ENC := $(TOOLS_DIR)/vadpcm_enc
BIN2C := $(PYTHON) $(TOOLS_DIR)/bin2c.py
EXTRACT_DATA_FOR_MIO := $(TOOLS_DIR)/extract_data_for_mio
ASSET_EXTRACT := $(PYTHON) $(TOOLS_DIR)/new_extract_assets.py
LINKONLY_GENERATOR := $(PYTHON) $(TOOLS_DIR)/linkonly_generator.py
TORCH := $(TOOLS_DIR)/torch/cmake-build-release/torch
ENDIAN_BITWIDTH := $(BUILD_DIR)/endian-and-bitwidth
EMULATOR = mupen64plus
EMU_FLAGS = --noosd
LOADER = loader64
Expand Down Expand Up @@ -528,6 +548,66 @@ $(BUILD_DIR)/src/crash_screen.o: src/crash_screen.c
$(V)$(CC) -c $(CFLAGS) -o $@ $<
$(V)$(PYTHON) $(TOOLS_DIR)/set_o32abi_bit.py $@



#==============================================================================#
# Sound File Generation #
#==============================================================================#

$(BUILD_DIR)/%.table: %.aiff
$(call print,Extracting codebook:,$<,$@)
$(V)$(AIFF_EXTRACT_CODEBOOK) $< >$@

$(BUILD_DIR)/%.aifc: $(BUILD_DIR)/%.table %.aiff
$(call print,Encoding ADPCM:,$(word 2,$^),$@)
$(V)$(VADPCM_ENC) -c $^ $@

$(BUILD_DIR)/%.aifc: %.aifc
$(call print,Copying unmatched AIFC:,$<,$@)
$(V)cp $< $@

$(ENDIAN_BITWIDTH): $(TOOLS_DIR)/determine-endian-bitwidth.c
@$(PRINT) "$(GREEN)Generating endian-bitwidth $(NO_COL)\n"
$(V)$(CC) -c $(CFLAGS) -o $@.dummy2 $< 2>$@.dummy1; true
$(V)grep -o 'msgbegin --endian .* --bitwidth .* msgend' $@.dummy1 > $@.dummy2
$(V)head -n1 <$@.dummy2 | cut -d' ' -f2-5 > $@
$(V)$(RM) $@.dummy1
$(V)$(RM) $@.dummy2

$(SOUND_BIN_DIR)/sound_data.ctl: sound/sound_banks/ $(SOUND_BANK_FILES) $(SOUND_SAMPLE_AIFCS) $(ENDIAN_BITWIDTH)
@$(PRINT) "$(GREEN)Generating: $(BLUE)$@ $(NO_COL)\n"
$(V)$(PYTHON) $(TOOLS_DIR)/assemble_sound.py $(BUILD_DIR)/sound/samples/ sound/sound_banks/ $(SOUND_BIN_DIR)/sound_data.ctl $(SOUND_BIN_DIR)/ctl_header $(SOUND_BIN_DIR)/sound_data.tbl $(SOUND_BIN_DIR)/tbl_header $(C_DEFINES) $$(cat $(ENDIAN_BITWIDTH))

$(SOUND_BIN_DIR)/sound_data.tbl: $(SOUND_BIN_DIR)/sound_data.ctl
@true

$(BUILD_DIR)/data/sound_data/audiobanks.o: $(SOUND_BIN_DIR)/sound_data.ctl
$(BUILD_DIR)/data/sound_data/audiotables.o: $(SOUND_BIN_DIR)/sound_data.tbl

# TODO: the rest of these rules are currently not used by the build since sequences.json has not been dissambled
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to create a sequences.json. It would be cleaner if we could but I can't see any scripts to do this.


$(SOUND_BIN_DIR)/ctl_header: $(SOUND_BIN_DIR)/sound_data.ctl
@true

$(SOUND_BIN_DIR)/tbl_header: $(SOUND_BIN_DIR)/sound_data.ctl
@true

$(SOUND_BIN_DIR)/sequences.bin: $(SOUND_BANK_FILES) sound/sequences.json $(SOUND_SEQUENCE_DIRS) $(SOUND_SEQUENCE_FILES) $(ENDIAN_BITWIDTH)
@$(PRINT) "$(GREEN)Generating: $(BLUE)$@ $(NO_COL)\n"
$(V)$(PYTHON) $(TOOLS_DIR)/assemble_sound.py --sequences $@ $(SOUND_BIN_DIR)/sequences_header $(SOUND_BIN_DIR)/bank_sets sound/sound_banks/ sound/sequences.json $(SOUND_SEQUENCE_FILES) $(C_DEFINES) $$(cat $(ENDIAN_BITWIDTH))

$(SOUND_BIN_DIR)/bank_sets: $(SOUND_BIN_DIR)/sequences.bin
@true

$(SOUND_BIN_DIR)/sequences_header: $(SOUND_BIN_DIR)/sequences.bin
@true

$(SOUND_BIN_DIR)/%.m64: $(SOUND_BIN_DIR)/%.o
$(call print,Converting to M64:,$<,$@)
$(V)$(OBJCOPY) -j .rodata $< -O binary $@

$(SOUND_BIN_DIR)/sound_data.o: $(SOUND_BIN_DIR)/sound_data.ctl.inc.c $(SOUND_BIN_DIR)/sound_data.tbl.inc.c $(SOUND_BIN_DIR)/sequences.bin.inc.c $(SOUND_BIN_DIR)/bank_sets.inc.c

#==============================================================================#
# Common Textures Segment Generation #
#==============================================================================#
Expand Down
Loading