Skip to content

Commit a7c423c

Browse files
author
n64
committed
Refresh 3
1 parent 6b8bc9b commit a7c423c

File tree

4,603 files changed

+475512
-437713
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,603 files changed

+475512
-437713
lines changed

CHANGES

+27
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
Refresh #3
2+
1.) Small bits of sound sample labelling
3+
2.) Append 'b' to fopen calls in n64graphics to satisfy Windows
4+
3.) Document synthesis.c and abi.h
5+
4.) Remove gbi_old.h and use gbi.h instead for F3D_OLD
6+
5.) Fix and change most values used by f3d commands
7+
6.) Convert actors to C
8+
7.) Make extract_assets.py fail on bad baserom
9+
8.) Fix some (pragma-ignored) warnings
10+
9.) Convert trig tables and data/ buffers into C
11+
10.) Document intro behaviors and some of camera.c
12+
11.) Match dma_sample_data
13+
12.) Convert levels, bin, text, goddard_tex_dl to C
14+
13.) Remove .bss size hardcoding
15+
14.) Add mips64 fallback and alt dump option to diff.sh
16+
15.) Convert behavior_data to C
17+
16.) Get rid of the enum in behavior_data.
18+
17.) Change more values used by f3d commands
19+
18.) Document game/skybox.c
20+
19.) Actors levels fixup
21+
20.) Convert Mario animations to C (kind of)
22+
22.) generate skybox data from 248x248 images
23+
23.) 64-bit fixes
24+
24.) Move demo data to C
25+
25.) Change uintptr_t to GeoLayout for actors
26+
26.) Move libc includes to include/libc/
27+
128
Refresh #2a (hotfix)
229
Changes from Refresh #2:
330

Makefile

+51-35
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,15 @@ LIBULTRA := $(BUILD_DIR)/libultra.a
125125
ROM := $(BUILD_DIR)/$(TARGET).z64
126126
ELF := $(BUILD_DIR)/$(TARGET).elf
127127
LD_SCRIPT := sm64.ld
128-
MIO0_DIR := $(BUILD_DIR)/mio0
128+
MIO0_DIR := $(BUILD_DIR)/bin
129129
SOUND_BIN_DIR := $(BUILD_DIR)/sound
130130
TEXTURE_DIR := textures
131131
ACTOR_DIR := actors
132+
LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h)))
132133

133134
# Directories containing source files
134-
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers
135-
ASM_DIRS := asm actors lib data levels assets sound text
135+
SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels text bin data assets
136+
ASM_DIRS := asm lib sound
136137
BIN_DIRS := bin bin/$(VERSION)
137138

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

142143
GODDARD_SRC_DIRS := src/goddard src/goddard/dynlists
143144

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

146146
MIPSISET := -mips2 -32
147147

@@ -155,12 +155,13 @@ endif
155155
include Makefile.split
156156

157157
# Source code files
158-
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
158+
LEVEL_C_FILES := $(wildcard levels/*/leveldata.c) $(wildcard levels/*/script.c) $(wildcard levels/*/geo.c)
159+
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) $(LEVEL_C_FILES)
159160
S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s))
160161
ULTRA_C_FILES := $(foreach dir,$(ULTRA_SRC_DIRS),$(wildcard $(dir)/*.c))
161162
GODDARD_C_FILES := $(foreach dir,$(GODDARD_SRC_DIRS),$(wildcard $(dir)/*.c))
162163
ULTRA_S_FILES := $(foreach dir,$(ULTRA_ASM_DIRS),$(wildcard $(dir)/*.s))
163-
LEVEL_S_FILES := $(addsuffix header.s,$(addprefix bin/,$(LEVEL_DIRS)))
164+
GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c
164165

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

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

228+
INCLUDE_CFLAGS := -I include -I include/libc -I $(BUILD_DIR) -I $(BUILD_DIR)/include -I src -I .
229+
227230
# Check code syntax with host compiler
228-
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)
231+
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
229232

230233
ASFLAGS := -march=vr4300 -mabi=32 -I include -I $(BUILD_DIR) $(VERSION_ASFLAGS) $(GRUCODE_ASFLAGS)
231-
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)
234+
CFLAGS = -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -Xfullwarn $(OPT_FLAGS) -signed $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(MIPSISET) $(GRUCODE_CFLAGS) -DTARGET_N64
232235
OBJCOPYFLAGS := --pad-to=0x800000 --gap-fill=0xFF
233236
SYMBOL_LINKING_FLAGS := $(addprefix -R ,$(SEG_FILES))
234237
LDFLAGS := -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(SYMBOL_LINKING_FLAGS)
@@ -253,6 +256,8 @@ TEXTCONV = $(TOOLS_DIR)/textconv
253256
IPLFONTUTIL = $(TOOLS_DIR)/iplfontutil
254257
AIFF_EXTRACT_CODEBOOK = $(TOOLS_DIR)/aiff_extract_codebook
255258
VADPCM_ENC = $(TOOLS_DIR)/vadpcm_enc
259+
EXTRACT_DATA_FOR_MIO = $(TOOLS_DIR)/extract_data_for_mio
260+
SKYCONV = $(TOOLS_DIR)/skyconv
256261
EMULATOR = mupen64plus
257262
EMU_FLAGS = --noosd
258263
LOADER = loader64
@@ -301,21 +306,21 @@ $(BUILD_DIR)/include/text_strings.h: include/text_strings.h.in
301306
$(BUILD_DIR)/include/text_menu_strings.h: include/text_menu_strings.h.in
302307
$(TEXTCONV) charmap_menu.txt $< $@
303308

304-
$(BUILD_DIR)/text/%.s: text/$(VERSION)/%.s.in
309+
$(BUILD_DIR)/text/%.inc.c: text/$(VERSION)/%.c.in
305310
$(TEXTCONV) charmap.txt $< $@
306311

307312
ifeq ($(VERSION),eu)
308-
ASM_DIRS += text/de text/en text/fr
313+
SRC_DIRS += text/de text/en text/fr
309314
# EU encoded text inserted into individual segment 0x19 files
310-
$(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
311-
$(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
312-
$(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
315+
$(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
316+
$(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
317+
$(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
313318
else
314319
# non-EU encoded text inserted into segment 0x02
315-
$(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
320+
$(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
316321
endif
317322

318-
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)
323+
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)
319324

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

341+
$(BUILD_DIR)/%.inc.c: $(BUILD_DIR)/% %.png
342+
hexdump -v -e '1/1 "0x%X,"' $< > $@
343+
echo >> $@
344+
336345
# Color Index CI8
337346
$(BUILD_DIR)/%.ci8: %.ci8.png
338347
$(N64GRAPHICS_CI) -i $@ -g $< -f ci8
@@ -344,38 +353,35 @@ $(BUILD_DIR)/%.ci4: %.ci4.png
344353
################################################################
345354

346355
# compressed segment generation
347-
$(BUILD_DIR)/bin/%.o: bin/%.s
348-
$(AS) $(ASFLAGS) --no-pad-sections -o $@ $<
349-
350-
# compressed segment generation (actors)
351-
$(BUILD_DIR)/bin/%.o: actors/%.s
352-
$(AS) $(ASFLAGS) --no-pad-sections -o $@ $<
353-
354-
$(BUILD_DIR)/bin/%/leveldata.o: levels/%/leveldata.s
355-
$(AS) $(ASFLAGS) --no-pad-sections -o $@ $<
356-
357-
$(BUILD_DIR)/bin/%/header.o: levels/%/header.s $(MIO0_DIR)/%/leveldata.mio0 levels/%/script.s
358-
$(AS) $(ASFLAGS) --no-pad-sections -o $@ $<
359356

360357
# TODO: ideally this would be `-Trodata-segment=0x07000000` but that doesn't set the address
358+
361359
$(BUILD_DIR)/bin/%.elf: $(BUILD_DIR)/bin/%.o
362360
$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map -o $@ $<
361+
$(BUILD_DIR)/actors/%.elf: $(BUILD_DIR)/actors/%.o
362+
$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map -o $@ $<
363363

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

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

372-
$(MIO0_DIR)/%.mio0: $(BUILD_DIR)/bin/%.bin
372+
$(BUILD_DIR)/actors/%.bin: $(BUILD_DIR)/actors/%.elf
373+
$(EXTRACT_DATA_FOR_MIO) $< $@
374+
375+
$(BUILD_DIR)/levels/%/leveldata.bin: $(BUILD_DIR)/levels/%/leveldata.elf
376+
$(EXTRACT_DATA_FOR_MIO) $< $@
377+
378+
$(BUILD_DIR)/%.mio0: $(BUILD_DIR)/%.bin
373379
$(MIO0TOOL) $< $@
374380

375-
$(MIO0_DIR)/%.mio0.o: $(MIO0_DIR)/%.mio0.s
381+
$(BUILD_DIR)/%.mio0.o: $(BUILD_DIR)/%.mio0.s
376382
$(AS) $(ASFLAGS) -o $@ $<
377383

378-
$(MIO0_DIR)/%.mio0.s: $(MIO0_DIR)/%.mio0
384+
$(BUILD_DIR)/%.mio0.s: $(BUILD_DIR)/%.mio0
379385
printf ".section .data\n\n.incbin \"$<\"\n" > $@
380386

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

414+
$(BUILD_DIR)/assets/mario_anim_data.c: $(wildcard assets/anims/*.inc.c)
415+
$(PYTHON) tools/mario_anims_converter.py > $@
416+
417+
$(BUILD_DIR)/assets/demo_data.c: assets/demo_data.json $(wildcard assets/demos/*.bin)
418+
$(PYTHON) tools/demo_data_converter.py assets/demo_data.json $(VERSION_CFLAGS) > $@
419+
408420
# Source code
409421
$(BUILD_DIR)/src/goddard/%.o: OPT_FLAGS := -g
410422
$(BUILD_DIR)/src/goddard/%.o: MIPSISET := -mips1
@@ -442,7 +454,11 @@ $(BUILD_DIR)/%.o: %.c
442454
$(CC) -c $(CFLAGS) -o $@ $<
443455

444456

445-
$(BUILD_DIR)/%.o: %.s $(MIO0_FILES)
457+
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c
458+
@$(CC_CHECK) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
459+
$(CC) -c $(CFLAGS) -o $@ $<
460+
461+
$(BUILD_DIR)/%.o: %.s
446462
$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $<
447463

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

468484

469485
.PHONY: all clean distclean default diff test load libultra
470-
.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
486+
.PRECIOUS: $(BUILD_DIR)/bin/%.elf $(SOUND_BIN_DIR)/%.ctl $(SOUND_BIN_DIR)/%.tbl $(SOUND_SAMPLE_TABLES) $(SOUND_BIN_DIR)/%.s $(BUILD_DIR)/%
471487
.DELETE_ON_ERROR:
472488

473489
# Remove built-in rules, to improve performance

0 commit comments

Comments
 (0)