Skip to content

Commit

Permalink
Refresh 3
Browse files Browse the repository at this point in the history
  • Loading branch information
n64 committed Nov 3, 2019
1 parent 6b8bc9b commit a7c423c
Show file tree
Hide file tree
Showing 4,603 changed files with 475,512 additions and 437,713 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
27 changes: 27 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
Refresh #3
1.) Small bits of sound sample labelling
2.) Append 'b' to fopen calls in n64graphics to satisfy Windows
3.) Document synthesis.c and abi.h
4.) Remove gbi_old.h and use gbi.h instead for F3D_OLD
5.) Fix and change most values used by f3d commands
6.) Convert actors to C
7.) Make extract_assets.py fail on bad baserom
8.) Fix some (pragma-ignored) warnings
9.) Convert trig tables and data/ buffers into C
10.) Document intro behaviors and some of camera.c
11.) Match dma_sample_data
12.) Convert levels, bin, text, goddard_tex_dl to C
13.) Remove .bss size hardcoding
14.) Add mips64 fallback and alt dump option to diff.sh
15.) Convert behavior_data to C
16.) Get rid of the enum in behavior_data.
17.) Change more values used by f3d commands
18.) Document game/skybox.c
19.) Actors levels fixup
20.) Convert Mario animations to C (kind of)
22.) generate skybox data from 248x248 images
23.) 64-bit fixes
24.) Move demo data to C
25.) Change uintptr_t to GeoLayout for actors
26.) Move libc includes to include/libc/

Refresh #2a (hotfix)
Changes from Refresh #2:

Expand Down
86 changes: 51 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ LIBULTRA := $(BUILD_DIR)/libultra.a
ROM := $(BUILD_DIR)/$(TARGET).z64
ELF := $(BUILD_DIR)/$(TARGET).elf
LD_SCRIPT := sm64.ld
MIO0_DIR := $(BUILD_DIR)/mio0
MIO0_DIR := $(BUILD_DIR)/bin
SOUND_BIN_DIR := $(BUILD_DIR)/sound
TEXTURE_DIR := textures
ACTOR_DIR := actors
LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h)))

# Directories containing source files
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers
ASM_DIRS := asm actors lib data levels assets sound text
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels text bin data assets
ASM_DIRS := asm lib sound
BIN_DIRS := bin bin/$(VERSION)

ULTRA_SRC_DIRS := lib/src lib/src/math
Expand All @@ -141,7 +142,6 @@ ULTRA_BIN_DIRS := lib/bin

GODDARD_SRC_DIRS := src/goddard src/goddard/dynlists

LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.s)))

MIPSISET := -mips2 -32

Expand All @@ -155,12 +155,13 @@ endif
include Makefile.split

# Source code files
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
LEVEL_C_FILES := $(wildcard levels/*/leveldata.c) $(wildcard levels/*/script.c) $(wildcard levels/*/geo.c)
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) $(LEVEL_C_FILES)
S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
ULTRA_C_FILES := $(foreach dir,$(ULTRA_SRC_DIRS),$(wildcard $(dir)/*.c))
GODDARD_C_FILES := $(foreach dir,$(GODDARD_SRC_DIRS),$(wildcard $(dir)/*.c))
ULTRA_S_FILES := $(foreach dir,$(ULTRA_ASM_DIRS),$(wildcard $(dir)/*.s))
LEVEL_S_FILES := $(addsuffix header.s,$(addprefix bin/,$(LEVEL_DIRS)))
GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c

SOUND_BANK_FILES := $(wildcard sound/sound_banks/*.json)
SOUND_SEQUENCE_FILES := $(wildcard sound/sequences/$(VERSION)/*.m64) \
Expand All @@ -180,7 +181,7 @@ SOUND_OBJ_FILES := $(SOUND_BIN_DIR)/sound_data.ctl.o \
# Object files
O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \
$(foreach file,$(S_FILES),$(BUILD_DIR)/$(file:.s=.o)) \
$(foreach file,$(LEVEL_S_FILES),$(BUILD_DIR)/$(file:.s=.o))
$(foreach file,$(GENERATED_C_FILES),$(file:.c=.o))

ULTRA_O_FILES := $(foreach file,$(ULTRA_S_FILES),$(BUILD_DIR)/$(file:.s=.o)) \
$(foreach file,$(ULTRA_C_FILES),$(BUILD_DIR)/$(file:.c=.o))
Expand Down Expand Up @@ -224,11 +225,13 @@ OBJDUMP := $(CROSS)objdump
OBJCOPY := $(CROSS)objcopy
PYTHON := python3

INCLUDE_CFLAGS := -I include -I include/libc -I $(BUILD_DIR) -I $(BUILD_DIR)/include -I src -I .

# Check code syntax with host compiler
CC_CHECK := gcc -fsyntax-only -fsigned-char -nostdinc -fno-builtin -I include -I $(BUILD_DIR)/include -I src -std=gnu90 -Wall -Wextra -Wno-format-security -D_LANGUAGE_C $(VERSION_CFLAGS) $(GRUCODE_CFLAGS)
CC_CHECK := gcc -fsyntax-only -fsigned-char -nostdinc -fno-builtin $(INCLUDE_CFLAGS) -std=gnu90 -Wall -Wextra -Wno-format-security -DNON_MATCHING $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -DTARGET_N64

ASFLAGS := -march=vr4300 -mabi=32 -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS) $(GRUCODE_ASFLAGS)
CFLAGS = -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -Xfullwarn $(OPT_FLAGS) -signed -I include -I $(BUILD_DIR)/include -I src -D_LANGUAGE_C $(VERSION_CFLAGS) $(MIPSISET) $(GRUCODE_CFLAGS)
CFLAGS = -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -Xfullwarn $(OPT_FLAGS) -signed $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(MIPSISET) $(GRUCODE_CFLAGS) -DTARGET_N64
OBJCOPYFLAGS := --pad-to=0x800000 --gap-fill=0xFF
SYMBOL_LINKING_FLAGS := $(addprefix -R ,$(SEG_FILES))
LDFLAGS := -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(SYMBOL_LINKING_FLAGS)
Expand All @@ -253,6 +256,8 @@ TEXTCONV = $(TOOLS_DIR)/textconv
IPLFONTUTIL = $(TOOLS_DIR)/iplfontutil
AIFF_EXTRACT_CODEBOOK = $(TOOLS_DIR)/aiff_extract_codebook
VADPCM_ENC = $(TOOLS_DIR)/vadpcm_enc
EXTRACT_DATA_FOR_MIO = $(TOOLS_DIR)/extract_data_for_mio
SKYCONV = $(TOOLS_DIR)/skyconv
EMULATOR = mupen64plus
EMU_FLAGS = --noosd
LOADER = loader64
Expand Down Expand Up @@ -301,21 +306,21 @@ $(BUILD_DIR)/include/text_strings.h: include/text_strings.h.in
$(BUILD_DIR)/include/text_menu_strings.h: include/text_menu_strings.h.in
$(TEXTCONV) charmap_menu.txt $< $@

$(BUILD_DIR)/text/%.s: text/$(VERSION)/%.s.in
$(BUILD_DIR)/text/%.inc.c: text/$(VERSION)/%.c.in
$(TEXTCONV) charmap.txt $< $@

ifeq ($(VERSION),eu)
ASM_DIRS += text/de text/en text/fr
SRC_DIRS += text/de text/en text/fr
# EU encoded text inserted into individual segment 0x19 files
$(BUILD_DIR)/bin/$(VERSION)/translation_de.o: $(BUILD_DIR)/text/de/dialog.s $(BUILD_DIR)/text/de/level.s $(BUILD_DIR)/text/de/star.s
$(BUILD_DIR)/bin/$(VERSION)/translation_en.o: $(BUILD_DIR)/text/en/dialog.s $(BUILD_DIR)/text/en/level.s $(BUILD_DIR)/text/en/star.s
$(BUILD_DIR)/bin/$(VERSION)/translation_fr.o: $(BUILD_DIR)/text/fr/dialog.s $(BUILD_DIR)/text/fr/level.s $(BUILD_DIR)/text/fr/star.s
$(BUILD_DIR)/bin/$(VERSION)/translation_de.o: $(BUILD_DIR)/text/de/dialog.inc.c $(BUILD_DIR)/text/de/level.inc.c $(BUILD_DIR)/text/de/star.inc.c
$(BUILD_DIR)/bin/$(VERSION)/translation_en.o: $(BUILD_DIR)/text/en/dialog.inc.c $(BUILD_DIR)/text/en/level.inc.c $(BUILD_DIR)/text/en/star.inc.c
$(BUILD_DIR)/bin/$(VERSION)/translation_fr.o: $(BUILD_DIR)/text/fr/dialog.inc.c $(BUILD_DIR)/text/fr/level.inc.c $(BUILD_DIR)/text/fr/star.inc.c
else
# non-EU encoded text inserted into segment 0x02
$(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/debug.s $(BUILD_DIR)/text/dialog.s $(BUILD_DIR)/text/level.s $(BUILD_DIR)/text/star.s
$(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/debug.inc.c $(BUILD_DIR)/text/dialog.inc.c $(BUILD_DIR)/text/level.inc.c $(BUILD_DIR)/text/star.inc.c
endif

ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS) $(GODDARD_SRC_DIRS) $(ULTRA_SRC_DIRS) $(ULTRA_ASM_DIRS) $(ULTRA_BIN_DIRS) $(BIN_DIRS) $(TEXTURE_DIRS) $(SOUND_SAMPLE_DIRS) $(addprefix levels/,$(LEVEL_DIRS)) $(addprefix bin/,$(LEVEL_DIRS)) include) $(MIO0_DIR) $(addprefix $(MIO0_DIR)/,$(LEVEL_DIRS)) $(addprefix $(MIO0_DIR)/,$(VERSION)) $(SOUND_BIN_DIR) $(SOUND_BIN_DIR)/sequences/$(VERSION)
ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS) $(GODDARD_SRC_DIRS) $(ULTRA_SRC_DIRS) $(ULTRA_ASM_DIRS) $(ULTRA_BIN_DIRS) $(BIN_DIRS) $(TEXTURE_DIRS) $(SOUND_SAMPLE_DIRS) $(addprefix levels/,$(LEVEL_DIRS)) include) $(MIO0_DIR) $(addprefix $(MIO0_DIR)/,$(VERSION)) $(SOUND_BIN_DIR) $(SOUND_BIN_DIR)/sequences/$(VERSION)

# Make sure build directory exists before compiling anything
DUMMY != mkdir -p $(ALL_DIRS)
Expand All @@ -333,6 +338,10 @@ $(BUILD_DIR)/src/game/ingame_menu.o: $(BUILD_DIR)/include/text_strings.h
$(BUILD_DIR)/%: %.png
$(N64GRAPHICS) -i $@ -g $< -f $(lastword $(subst ., ,$@))

$(BUILD_DIR)/%.inc.c: $(BUILD_DIR)/% %.png
hexdump -v -e '1/1 "0x%X,"' $< > $@
echo >> $@

# Color Index CI8
$(BUILD_DIR)/%.ci8: %.ci8.png
$(N64GRAPHICS_CI) -i $@ -g $< -f ci8
Expand All @@ -344,38 +353,35 @@ $(BUILD_DIR)/%.ci4: %.ci4.png
################################################################

# compressed segment generation
$(BUILD_DIR)/bin/%.o: bin/%.s
$(AS) $(ASFLAGS) --no-pad-sections -o $@ $<

# compressed segment generation (actors)
$(BUILD_DIR)/bin/%.o: actors/%.s
$(AS) $(ASFLAGS) --no-pad-sections -o $@ $<

$(BUILD_DIR)/bin/%/leveldata.o: levels/%/leveldata.s
$(AS) $(ASFLAGS) --no-pad-sections -o $@ $<

$(BUILD_DIR)/bin/%/header.o: levels/%/header.s $(MIO0_DIR)/%/leveldata.mio0 levels/%/script.s
$(AS) $(ASFLAGS) --no-pad-sections -o $@ $<

# TODO: ideally this would be `-Trodata-segment=0x07000000` but that doesn't set the address

$(BUILD_DIR)/bin/%.elf: $(BUILD_DIR)/bin/%.o
$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map -o $@ $<
$(BUILD_DIR)/actors/%.elf: $(BUILD_DIR)/actors/%.o
$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map -o $@ $<

# Override for level.elf, which otherwise matches the above pattern
.SECONDEXPANSION:
$(BUILD_DIR)/bin/%/leveldata.elf: $(BUILD_DIR)/bin/%/leveldata.o $(BUILD_DIR)/bin/$$(TEXTURE_BIN).elf
$(BUILD_DIR)/levels/%/leveldata.elf: $(BUILD_DIR)/levels/%/leveldata.o $(BUILD_DIR)/bin/$$(TEXTURE_BIN).elf
$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map --just-symbols=$(BUILD_DIR)/bin/$(TEXTURE_BIN).elf -o $@ $<

$(BUILD_DIR)/bin/%.bin: $(BUILD_DIR)/bin/%.elf
$(OBJCOPY) -j .rodata $< -O binary $@
$(EXTRACT_DATA_FOR_MIO) $< $@

$(MIO0_DIR)/%.mio0: $(BUILD_DIR)/bin/%.bin
$(BUILD_DIR)/actors/%.bin: $(BUILD_DIR)/actors/%.elf
$(EXTRACT_DATA_FOR_MIO) $< $@

$(BUILD_DIR)/levels/%/leveldata.bin: $(BUILD_DIR)/levels/%/leveldata.elf
$(EXTRACT_DATA_FOR_MIO) $< $@

$(BUILD_DIR)/%.mio0: $(BUILD_DIR)/%.bin
$(MIO0TOOL) $< $@

$(MIO0_DIR)/%.mio0.o: $(MIO0_DIR)/%.mio0.s
$(BUILD_DIR)/%.mio0.o: $(BUILD_DIR)/%.mio0.s
$(AS) $(ASFLAGS) -o $@ $<

$(MIO0_DIR)/%.mio0.s: $(MIO0_DIR)/%.mio0
$(BUILD_DIR)/%.mio0.s: $(BUILD_DIR)/%.mio0
printf ".section .data\n\n.incbin \"$<\"\n" > $@

$(BUILD_DIR)/%.table: %.aiff
Expand Down Expand Up @@ -405,6 +411,12 @@ $(SOUND_BIN_DIR)/%.o: $(SOUND_BIN_DIR)/%.s
$(SOUND_BIN_DIR)/%.s: $(SOUND_BIN_DIR)/%
printf ".section .data\n\n.incbin \"$<\"\n" > $@

$(BUILD_DIR)/assets/mario_anim_data.c: $(wildcard assets/anims/*.inc.c)
$(PYTHON) tools/mario_anims_converter.py > $@

$(BUILD_DIR)/assets/demo_data.c: assets/demo_data.json $(wildcard assets/demos/*.bin)
$(PYTHON) tools/demo_data_converter.py assets/demo_data.json $(VERSION_CFLAGS) > $@

# Source code
$(BUILD_DIR)/src/goddard/%.o: OPT_FLAGS := -g
$(BUILD_DIR)/src/goddard/%.o: MIPSISET := -mips1
Expand Down Expand Up @@ -442,7 +454,11 @@ $(BUILD_DIR)/%.o: %.c
$(CC) -c $(CFLAGS) -o $@ $<


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

$(BUILD_DIR)/%.o: %.s
$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $<

$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT)
Expand All @@ -467,7 +483,7 @@ $(BUILD_DIR)/$(TARGET).objdump: $(ELF)


.PHONY: all clean distclean default diff test load libultra
.PRECIOUS: $(MIO0_DIR)/%.mio0 $(MIO0_DIR)/%.mio0.s $(BUILD_DIR)/bin/%.elf $(SOUND_BIN_DIR)/%.ctl $(SOUND_BIN_DIR)/%.tbl $(SOUND_SAMPLE_TABLES) $(SOUND_BIN_DIR)/%.s
.PRECIOUS: $(BUILD_DIR)/bin/%.elf $(SOUND_BIN_DIR)/%.ctl $(SOUND_BIN_DIR)/%.tbl $(SOUND_SAMPLE_TABLES) $(SOUND_BIN_DIR)/%.s $(BUILD_DIR)/%
.DELETE_ON_ERROR:

# Remove built-in rules, to improve performance
Expand Down
Loading

0 comments on commit a7c423c

Please sign in to comment.