Skip to content

Commit

Permalink
Refresh 14
Browse files Browse the repository at this point in the history
  • Loading branch information
n64 committed Jul 13, 2021
1 parent ecd3d15 commit f9982e0
Show file tree
Hide file tree
Showing 251 changed files with 7,473 additions and 5,734 deletions.
46 changes: 46 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
Refresh 14

1.) Label whomp and some object fields (#1174)
2.) Generate MIO0 object files using binutils `ld` instead of `as` (#1173)
3.) Bowser documentation (#1166)
4.) Fix comment syntax in 00_sound_player.0 (#1172)
5.) Rename in-game menu variables (#1163)
6.) Document double red coin sound and JP sound glitch (#1170)
7.) Document different bug in external.c (#1168)
8.) updated names/types of octagonal platform data (#1164)
9.) Label a number of unnamed variables. (#1169)
10.) Document JP PU sound glitch (#1167)
11.) Set model ids to spawn_triangle_break_particles (#1165)
12.) Fix borders in clear_frame_buffer (#1162)
13.) Fix seq header files for 64-bit (#1161)
14.) Game_init.c remaining doc (#1158)
15.) Label a couple static variables in sound_init.c (#1159)
16.) Properly define dialog values (status, flags, cutscenes) (#1153)
17.) Label all of amp's assets. (#1018)
18.) Split audio/synthesis.c into Shindou/non-Shindou files (#1144)
19.) Avoid CC_CHECK warnings when using gcc (#1157)
20.) level_select_menu.c => title_screen.c (#1152)
21.) Use C preprocessor on assembly files (#1126)
22.) Replace output_level_headers.py with sed equivalent (#1109)
23.) Fix CC_CHECK warnings related to unused symbols and UB (#1155)
24.) Define remaining floor lower limit values (#1147)
25.) use r+b mode for libultra.a patch tool (#1148)
26.) Use proper values for gPrevFrameObjectCount ifs (#1146)
27.) Some minor bowser.inc.c labelling. (#1150)
28.) fix king bob-omb texture pointers (#1145)
29.) Split audio/load.c into Shindou/non-Shindou files (#1143)
30.) Small Shindou audio cleanups (#1142)
31.) Fix endians in ALSeqData (#1141)
32.) Document S8 decoder rsp operation and some more (#1139)
33.) Fix Shindou synthesis_process_note fake match (#1140)
34.) More audio documentation, for the new rsp code and other fixes (#1138)
35.) Build fixes for macOS: cpp, clang, recomp, aiff_extract_codebook (#1135)
36.) Add ENABLE_RUMBLE to config.h (#1122)
37.) Reduce recomp memory consumption by using smaller disassembly blocks (#1128)
38.) Makefile fixes (#1123)
39.) Update README.md
40.) Update README.md
41.) Reflect current decompilation status
42.) Allow both archives and ELF objects to be patched (#1127)
43.) Remove WIP mention in README for sh version.

Refresh 13 2

- No more nonmatchings remain for all builds including Shindou.
Expand Down
68 changes: 29 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,6 @@ else
COPT := $(IDO_ROOT)/copt
endif
endif
# Prefer gcc's cpp if installed on the system
ifneq (,$(call find-command,cpp-10))
CPP := cpp-10
else
CPP := cpp
endif
LD := $(CROSS)ld
AR := $(CROSS)ar
OBJDUMP := $(CROSS)objdump
Expand All @@ -328,6 +322,15 @@ endif
C_DEFINES := $(foreach d,$(DEFINES),-D$(d))
DEF_INC_CFLAGS := $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(C_DEFINES)

# Prefer clang as C preprocessor if installed on the system
ifneq (,$(call find-command,clang))
CPP := clang
CPPFLAGS := -E -P -x c -Wno-trigraphs $(DEF_INC_CFLAGS)
else
CPP := cpp
CPPFLAGS := -P -Wno-trigraphs $(DEF_INC_CFLAGS)
endif

# Check code syntax with host compiler
CC_CHECK := gcc
CC_CHECK_CFLAGS := -fsyntax-only -fsigned-char $(CC_CFLAGS) $(TARGET_CFLAGS) -std=gnu90 -Wall -Wextra -Wno-format-security -Wno-main -DNON_MATCHING -DAVOID_UB $(DEF_INC_CFLAGS)
Expand All @@ -343,9 +346,6 @@ endif
ASFLAGS := -march=vr4300 -mabi=32 $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(foreach d,$(DEFINES),--defsym $(d))
RSPASMFLAGS := $(foreach d,$(DEFINES),-definelabel $(subst =, ,$(d)))

# C preprocessor flags
CPPFLAGS := -P -Wno-trigraphs $(DEF_INC_CFLAGS)

ifeq ($(shell getconf LONG_BIT), 32)
# Work around memory allocation bug in QEMU
export QEMU_GUEST_BASE := 1
Expand Down Expand Up @@ -437,7 +437,7 @@ $(SOUND_BIN_DIR)/sound_data.o: $(SOUND_BIN_DIR)/sound_data.ctl.inc.c $(SO
$(BUILD_DIR)/levels/scripts.o: $(BUILD_DIR)/include/level_headers.h

ifeq ($(VERSION),sh)
$(BUILD_DIR)/src/audio/load.o: $(SOUND_BIN_DIR)/bank_sets.inc.c $(SOUND_BIN_DIR)/sequences_header.inc.c $(SOUND_BIN_DIR)/ctl_header.inc.c $(SOUND_BIN_DIR)/tbl_header.inc.c
$(BUILD_DIR)/src/audio/load_sh.o: $(SOUND_BIN_DIR)/bank_sets.inc.c $(SOUND_BIN_DIR)/sequences_header.inc.c $(SOUND_BIN_DIR)/ctl_header.inc.c $(SOUND_BIN_DIR)/tbl_header.inc.c
endif

$(CRASH_TEXTURE_C_FILES): TEXTURE_ENCODING := u32
Expand Down Expand Up @@ -521,11 +521,11 @@ $(BUILD_DIR)/levels/%/leveldata.elf: $(BUILD_DIR)/levels/%/leveldata.o $(BUILD_D
$(V)$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map --just-symbols=$(BUILD_DIR)/bin/$(TEXTURE_BIN).elf -o $@ $<

$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf
$(call print,Extracting compressionable data from:,$<,$@)
$(call print,Extracting compressible data from:,$<,$@)
$(V)$(EXTRACT_DATA_FOR_MIO) $< $@

$(BUILD_DIR)/levels/%/leveldata.bin: $(BUILD_DIR)/levels/%/leveldata.elf
$(call print,Extracting compressionable data from:,$<,$@)
$(call print,Extracting compressible data from:,$<,$@)
$(V)$(EXTRACT_DATA_FOR_MIO) $< $@

# Compress binary file
Expand All @@ -536,7 +536,7 @@ $(BUILD_DIR)/%.mio0: $(BUILD_DIR)/%.bin
# convert binary mio0 to object file
$(BUILD_DIR)/%.mio0.o: $(BUILD_DIR)/%.mio0
$(call print,Converting MIO0 to ELF:,$<,$@)
$(V)printf ".section .data\n\n.incbin \"$<\"\n" | $(AS) $(ASFLAGS) -o $@
$(V)$(LD) -r -b binary $< -o $@


#==============================================================================#
Expand All @@ -548,16 +548,16 @@ $(BUILD_DIR)/%.table: %.aiff
$(V)$(AIFF_EXTRACT_CODEBOOK) $< >$@

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

$(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 > $@
@$(RM) $@.dummy1
@$(RM) $@.dummy2
$(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"
Expand Down Expand Up @@ -593,7 +593,7 @@ $(SOUND_BIN_DIR)/%.m64: $(SOUND_BIN_DIR)/%.o

# Convert binary file to a comma-separated list of byte values for inclusion in C code
$(BUILD_DIR)/%.inc.c: $(BUILD_DIR)/%
$(call print,Piping:,$<,$@)
$(call print,Converting to C:,$<,$@)
$(V)hexdump -v -e '1/1 "0x%X,"' $< > $@
$(V)echo >> $@

Expand Down Expand Up @@ -624,7 +624,7 @@ $(BUILD_DIR)/text/%/define_text.inc.c: text/define_text.inc.c text/%/courses.h t
# Level headers
$(BUILD_DIR)/include/level_headers.h: levels/level_headers.h.in
$(call print,Preprocessing level headers:,$<,$@)
$(V)$(CPP) $(CPPFLAGS) -I . levels/level_headers.h.in | $(PYTHON) $(TOOLS_DIR)/output_level_headers.py > $(BUILD_DIR)/include/level_headers.h
$(V)$(CPP) $(CPPFLAGS) -I . $< | sed -E 's|(.+)|#include "\1"|' > $@

# Run asm_processor on files that have NON_MATCHING code
ifeq ($(NON_MATCHING),0)
Expand Down Expand Up @@ -667,46 +667,36 @@ ifeq ($(COMPILER),ido)
$(BUILD_DIR)/lib/src/string.o: OPT_FLAGS := -O2
$(BUILD_DIR)/lib/src/gu%.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/al%.o: OPT_FLAGS := -O3
# For the asm-processor, since it doesn't support -O3. Probably not actually compiled with these flags.

ifeq ($(VERSION),sh)
$(BUILD_DIR)/lib/src/unk_shindou_file.o: OPT_FLAGS := -O1
$(BUILD_DIR)/lib/src/func_sh_80304D20.o: OPT_FLAGS := -O1
$(BUILD_DIR)/lib/src/_Printf.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/contramread.o: OPT_FLAGS := -O1
$(BUILD_DIR)/lib/src/osPfsIsPlug.o: OPT_FLAGS := -O1
$(BUILD_DIR)/lib/src/osAiSetFrequency.o: OPT_FLAGS := -O1
$(BUILD_DIR)/lib/src/contramwrite.o: OPT_FLAGS := -O1
$(BUILD_DIR)/lib/src/sprintf.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/_Litob.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/_Ldtob.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/_Ldtob.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/_Litob.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/_Printf.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/sprintf.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/osDriveRomInit.o: OPT_FLAGS := -g
endif
ifeq ($(VERSION),eu)
$(BUILD_DIR)/lib/src/_Litob.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/_Ldtob.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/_Litob.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/_Printf.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/sprintf.o: OPT_FLAGS := -O3

# Enable loop unrolling except for external.c (external.c might also have used
# unrolling, but it makes one loop harder to match).
# For all audio files other than external.c and port_eu.c, put string literals
# in .data. (In Shindou, the port_eu.c string literals also moved to .data.)
$(BUILD_DIR)/src/audio/%.o: OPT_FLAGS := -O2 -use_readwrite_const
$(BUILD_DIR)/src/audio/port_eu.o: OPT_FLAGS := -O2
$(BUILD_DIR)/src/audio/external.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0
endif
ifeq ($(VERSION_JP_US),true)
$(BUILD_DIR)/src/audio/%.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0
$(BUILD_DIR)/src/audio/load.o: OPT_FLAGS := -O2 -framepointer -Wo,-loopunroll,0
endif
ifeq ($(VERSION_JP_US),true)
$(BUILD_DIR)/src/audio/load.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0 -framepointer
# The source-to-source optimizer copt is enabled for audio. This makes it use
# acpp, which needs -Wp,-+ to handle C++-style comments.
# All other files than external.c should really use copt, but only a few have
# been matched so far.
$(BUILD_DIR)/src/audio/effects.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0 -sopt,-inline=sequence_channel_process_sound,-scalaroptimize=1 -Wp,-+
$(BUILD_DIR)/src/audio/synthesis.o: OPT_FLAGS := -O2 -sopt,-scalaroptimize=1 -Wp,-+
$(BUILD_DIR)/src/audio/synthesis.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0 -sopt,-scalaroptimize=1 -Wp,-+
endif
$(BUILD_DIR)/src/audio/external.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0

# Add a target for build/eu/src/audio/*.copt to make it easier to see debug
$(BUILD_DIR)/src/audio/%.acpp: src/audio/%.c
Expand All @@ -720,7 +710,7 @@ endif
# Assemble assembly code
$(BUILD_DIR)/%.o: %.s
$(call print,Assembling:,$<,$@)
$(V)$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $<
$(V)$(CPP) $(CPPFLAGS) $< | $(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@

# Assemble RSP assembly code
$(BUILD_DIR)/rsp/%.bin $(BUILD_DIR)/rsp/%_data.bin: rsp/%.s
Expand All @@ -736,7 +726,7 @@ $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT)
$(BUILD_DIR)/libultra.a: $(ULTRA_O_FILES)
@$(PRINT) "$(GREEN)Linking libultra: $(BLUE)$@ $(NO_COL)\n"
$(V)$(AR) rcs -o $@ $(ULTRA_O_FILES)
$(V)$(TOOLS_DIR)/patch_libultra_math $@
$(V)$(TOOLS_DIR)/patch_elf_32bit $@

# Link libgoddard
$(BUILD_DIR)/libgoddard.a: $(GODDARD_O_FILES)
Expand Down
16 changes: 8 additions & 8 deletions Makefile.split
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ endef
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
$(BUILD_DIR)/level_rules.mk: levels/level_rules.mk levels/level_defines.h
@$(PRINT) "$(GREEN)Preprocessing level make rules: $(BLUE)$@ $(NO_COL)\n"
@$(CPP) $(VERSION_CFLAGS) -I . -o $@ $<
$(call print,Preprocessing level make rules:,$<,$@)
$(V)$(CPP) $(CPPFLAGS) $(VERSION_CFLAGS) -I . -o $@ $<
include $(BUILD_DIR)/level_rules.mk
endif
endif
Expand All @@ -179,11 +179,11 @@ $(eval $(call level_rules,menu,generic)) # Menu (File Select)

# Ending cake textures are generated in a special way
$(BUILD_DIR)/levels/ending/cake_eu.inc.c: levels/ending/cake_eu.png
@$(PRINT) "$(GREEN)Splitting $(YELLOW)$< $(GREEN)to: $(BLUE)$@ $(NO_COL)\n"
@$(SKYCONV) --type cake-eu --split $^ $(BUILD_DIR)/levels/ending
$(call print,Splitting:,$<,$@)
$(V)$(SKYCONV) --type cake-eu --split $^ $(BUILD_DIR)/levels/ending
$(BUILD_DIR)/levels/ending/cake.inc.c: levels/ending/cake.png
@$(PRINT) "$(GREEN)Splitting $(YELLOW)$< $(GREEN)to: $(BLUE)$@ $(NO_COL)\n"
@$(SKYCONV) --type cake --split $^ $(BUILD_DIR)/levels/ending
$(call print,Splitting:,$<,$@)
$(V)$(SKYCONV) --type cake --split $^ $(BUILD_DIR)/levels/ending

# --------------------------------------
# Texture Bin Rules
Expand Down Expand Up @@ -250,8 +250,8 @@ $(BUILD_DIR)/bin/eu/translation_fr.elf: SEGMENT_ADDRESS := 0x19000000
# --------------------------------------

$(BUILD_DIR)/bin/%_skybox.c: textures/skyboxes/%.png
@$(PRINT) "$(GREEN)Splitting $(YELLOW)$< $(GREEN)to: $(BLUE)$@ $(NO_COL)\n"
@$(SKYCONV) --type sky --split $^ $(BUILD_DIR)/bin
$(call print,Splitting:,$<,$@)
$(V)$(SKYCONV) --type sky --split $^ $(BUILD_DIR)/bin

$(BUILD_DIR)/bin/%_skybox.elf: SEGMENT_ADDRESS := 0x0A000000

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ Resulting artifacts can be found in the `build` directory.

The full list of configurable variables are listed below, with the default being the first listed:

* ``VERSION``: ``us``, ``jp``, ``eu``, ``sh`` (WIP)
* ``VERSION``: ``us``, ``jp``, ``eu``, ``sh``
* ``GRUCODE``: ``f3d_old``, ``f3d_new``, ``f3dex``, ``f3dex2``, ``f3dzex``
* ``COMPARE``: ``1`` (compare ROM hash), ``0`` (do not compare ROM hash)
* ``NON_MATCHING``: Use functionally equivalent C implementations for non-matchings (Currently there aren't any non-matchings, but this will apply to Shindou and iQue). Also will avoid instances of undefined behavior.
* ``NON_MATCHING``: Use functionally equivalent C implementations for non-matchings (Currently there aren't any non-matchings, but this will apply to iQue). Also will avoid instances of undefined behavior.
* ``CROSS``: Cross-compiler tool prefix (Example: ``mips64-elf-``).

### macOS
Expand All @@ -111,7 +111,7 @@ With macOS, you may either use Homebrew or [Docker](#docker-installation).
Install [Homebrew](https://brew.sh) and the following dependencies:
```
brew update
brew install capstone coreutils gcc make pkg-config tehzz/n64-dev/mips64-elf-binutils
brew install capstone coreutils make pkg-config tehzz/n64-dev/mips64-elf-binutils
```

#### Step 2: Copy baserom(s) for asset extraction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// 0x08003E30
static const s16 amp_seg8_animvalue_08003E30[] = {
static const s16 dAmpAnimValue[] = {
0x0000, 0x0000, 0x0D79, 0x1AF2, 0x286B, 0x35E4, 0x435D, 0x50D6,
0x5E50, 0x6BC9, 0x7942, 0x86BE, 0x9437, 0xA1B0, 0xAF2A, 0xBCA3,
0xCA1C, 0xD795, 0xE50E, 0xF287, 0x1872, 0x0000, 0x1AF2, 0x35E4,
Expand All @@ -23,8 +22,7 @@ static const s16 amp_seg8_animvalue_08003E30[] = {
0xC001, 0x3FFF,
};

// 0x08003F74
static const u16 amp_seg8_animindex_08003F74[] = {
static const u16 dAmpAnimIndex[] = {
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x0000,
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x00A1,
0x0001, 0x0000, 0x0013, 0x008D, 0x0001, 0x00A0,
Expand All @@ -40,15 +38,14 @@ static const u16 amp_seg8_animindex_08003F74[] = {
0x0001, 0x0000, 0x0001, 0x0000, 0x0001, 0x004E,
};

// 0x0800401C
static const struct Animation amp_seg8_anim_0800401C = {
static const struct Animation dAmpAnimation = {
0,
0,
0,
0,
0x13,
ANIMINDEX_NUMPARTS(amp_seg8_animindex_08003F74),
amp_seg8_animvalue_08003E30,
amp_seg8_animindex_08003F74,
ANIMINDEX_NUMPARTS(dAmpAnimIndex),
dAmpAnimValue,
dAmpAnimIndex,
0,
};
2 changes: 1 addition & 1 deletion actors/amp/anims/data.inc.c
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include "anim_0800401C.inc.c"
#include "animation.inc.c"
5 changes: 2 additions & 3 deletions actors/amp/anims/table.inc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// 0x08004034
const struct Animation *const amp_seg8_anims_08004034[] = {
&amp_seg8_anim_0800401C,
const struct Animation *const dAmpAnimsList[] = {
&dAmpAnimation,
};
Loading

0 comments on commit f9982e0

Please sign in to comment.