diff --git a/CHANGES b/CHANGES index 2feccbba..b584050a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,58 @@ +Refresh #10 +1.) GCC 9 noreturn UB fixes (#961) +2.) List supported binutils variants in README.md (#960) +3.) fix fly guy's possible values for target roll +4.) clarify that 1 is an exclusive bound in random_float (#962) +5.) replace unkB8 with prevNumStarsForDialog (#963) +6.) Replace "BulletBillUnkF8" with "BulletBillInitialMoveYaw" (#966) +7.) Renamed more warp behaviors and spawn types (#949) +8.) EU bss cleanups (#965) +9.) Add -fno-zero-initialized-in-bss to GCC CFLAGS (#968) +10.) Use empty .SECONDARY target instead of .PRECIOUS (#964) +11.) Match EU seq_channel_layer_process_script (#969) +12.) Fix version variable overwriting bug for non-matching compilations (#974) +13.) small bhv_collect_star_init labeling (#972) +14.) Align SI DMA command buffers, add more names to osCont code (#973) +15.) Minor for loop fix in playback.c (#976) +16.) Add Docker config (Public #36) +17.) Fix usage output crash for skyconv (#977) +18.) Cleanup tools and their build flags (#978) +19.) Print more detailed file reading error messages in extract_assets (#982) +20.) Remove asmdiff (#983) +21.) Fixed tabledesign makefile bug (#985) +22.) Improve first-diff.py (#987) +23.) Bring in some enhancements such as widescreen enhancements (#981) +24.) Fix background shadow border if widescreen in shade_screen (#988) +25.) Merge common EU sections in osExceptionPreamble (#990) +26.) Introduce the NO_SEGMENTED_MEMORY define (#989) +27.) NO_SEGMENTED_MEMORY comments (#992) +28.) Introduce f3dex2e and a GBI_FLOATS setting (#993) +29.) Audio uses signed 16-bit integers as samples, not unsigned (#995) +30.) Assemble RSP ucode with armips (#970) +31.) Label Mr. Blizzard, Yoshi, Whomp, Wiggler, Wood Piece oFields. (#996) +32.) update crash enhancement (#1003) +33.) Update README.md to use new public Discord server invite +34.) Label variables in act_idle. (#1005) +35.) Fix a typo in camera.h (#1009) +36.) Fixed up profiler.c (#1010) +37.) Add -d to first-diff.py (#1012) +38.) Fix typo in first-diff.py (#1013) +39.) Remove binutils 2.27 dependency check (#1015) +40.) Update armips to v0.11.0 tag and add generator script (#1004) +41.) Extract IPL3 font from ROM (#1011) +42.) Documented audio playback flags (#1021) +43.) Change RSP register notation to dollar-prefixed numbers (#1022) +44.) Only check for QEMU_IRIX in Makefile when compiling with IDO (#1023) +45.) Clean up header files and update function prototypes (#1000) +46.) Named local variables in geo_update_layer_transparency (#1019) +47.) Extract crash screen font textures from EU and SH ROMs (#1025) +48.) Use ACTIVE_FLAG defines where appropriate (#1026) +49.) Changed type of actor collision from s16 to Collision (#1024) +50.) Implement sqrtf in assembly file (#1028) +51.) Rename Struct8032FCE8 as OpenableGrill and identify data members (#1029) +52.) Fix some mistakes in the abi doc (#1031) +53.) The README.md PR (#979) + Refresh #8 1.) Use INT_STATUS_ macros for oInteractStatus (#911) 2.) Update bullet_bill.inc.c (#912) diff --git a/Dockerfile b/Dockerfile index ca63fa0f..b3200018 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,14 +5,9 @@ RUN apt-get update && \ binutils-mips-linux-gnu \ bsdmainutils \ build-essential \ - git \ libaudiofile-dev \ - libsdl2-dev \ - pkg-config \ python3 \ - wget \ - zlib1g-dev && \ - rm -rf /var/lib/apt/lists/* + wget RUN wget \ https://github.com/n64decomp/qemu-irix/releases/download/v2.11-deb/qemu-irix-2.11.0-2169-g32ab296eef_amd64.deb \ @@ -21,13 +16,9 @@ RUN wget \ dpkg -i qemu.deb && \ rm qemu.deb -RUN git clone --depth 1 https://github.com/emscripten-core/emsdk.git && \ - ./emsdk/emsdk install latest && \ - ./emsdk/emsdk activate latest - RUN mkdir /sm64 WORKDIR /sm64 -ENV PATH="/sm64/tools:/emsdk:/emsdk/upstream/emscripten:${PATH}" +ENV PATH="/sm64/tools:${PATH}" CMD echo 'usage: docker run --rm --mount type=bind,source="$(pwd)",destination=/sm64 sm64 make VERSION=${VERSION:-us} -j4\n' \ 'see https://github.com/n64decomp/sm64/blob/master/README.md for advanced usage' diff --git a/Makefile b/Makefile index 8360415b..58aa2b53 100644 --- a/Makefile +++ b/Makefile @@ -115,33 +115,21 @@ endif # Release (version) flag defs ifeq ($(VERSION),jp) - VERSION_CFLAGS := -DVERSION_JP - VERSION_ASFLAGS := --defsym VERSION_JP=1 - GRUCODE_CFLAGS := -DF3D_OLD - GRUCODE_ASFLAGS := --defsym F3D_OLD=1 - TARGET := sm64.jp + VERSION_DEF := VERSION_JP + GRUCODE_DEF := F3D_OLD else ifeq ($(VERSION),us) - VERSION_CFLAGS := -DVERSION_US - VERSION_ASFLAGS := --defsym VERSION_US=1 - GRUCODE_CFLAGS := -DF3D_OLD - GRUCODE_ASFLAGS := --defsym F3D_OLD=1 - TARGET := sm64.us + VERSION_DEF := VERSION_US + GRUCODE_DEF := F3D_OLD else ifeq ($(VERSION),eu) - VERSION_CFLAGS := -DVERSION_EU - VERSION_ASFLAGS := --defsym VERSION_EU=1 - GRUCODE_CFLAGS := -DF3D_NEW - GRUCODE_ASFLAGS := --defsym F3D_NEW=1 - TARGET := sm64.eu + VERSION_DEF := VERSION_EU + GRUCODE_DEF := F3D_NEW else ifeq ($(VERSION),sh) $(warning Building SH is experimental and is prone to breaking. Try at your own risk.) - VERSION_CFLAGS := -DVERSION_SH - VERSION_ASFLAGS := --defsym VERSION_SH=1 - GRUCODE_CFLAGS := -DF3D_NEW - GRUCODE_ASFLAGS := --defsym F3D_NEW=1 - TARGET := sm64.sh + VERSION_DEF := VERSION_SH + GRUCODE_DEF := F3D_NEW # TODO: GET RID OF THIS!!! We should mandate assets for Shindou like EU but we dont have the addresses extracted yet so we'll just pretend you have everything extracted for now. NOEXTRACT := 1 else @@ -151,6 +139,10 @@ endif endif endif +TARGET := sm64.$(VERSION) +VERSION_CFLAGS := -D$(VERSION_DEF) -D_LANGUAGE_C +VERSION_ASFLAGS := --defsym $(VERSION_DEF)=1 + # Stuff for showing the git hash in the intro on nightly builds # From https://stackoverflow.com/questions/44038428/include-git-commit-hash-and-or-branch-name-in-c-c-source ifeq ($(shell git rev-parse --abbrev-ref HEAD),nightly) @@ -162,14 +154,14 @@ endif # Microcode ifeq ($(GRUCODE),f3dex) # Fast3DEX - GRUCODE_CFLAGS := -DF3DEX_GBI - GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 --defsym F3DEX_GBI=1 + GRUCODE_DEF := F3DEX_GBI + GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 TARGET := $(TARGET).f3dex COMPARE := 0 else ifeq ($(GRUCODE), f3dex2) # Fast3DEX2 - GRUCODE_CFLAGS := -DF3DEX_GBI_2 - GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 --defsym F3DEX_GBI_2=1 + GRUCODE_DEF := F3DEX_GBI_2 + GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 TARGET := $(TARGET).f3dex2 COMPARE := 0 else @@ -179,15 +171,14 @@ ifeq ($(GRUCODE), f3dex2e) # Fast3DEX2 Extended (PC default) COMPARE := 0 else ifeq ($(GRUCODE),f3d_new) # Fast3D 2.0H (Shindou) - GRUCODE_CFLAGS := -DF3D_NEW - GRUCODE_ASFLAGS := --defsym F3D_NEW=1 + GRUCODE_DEF := F3D_NEW TARGET := $(TARGET).f3d_new COMPARE := 0 else ifeq ($(GRUCODE),f3dzex) # Fast3DZEX (2.0J / Animal Forest - Dōbutsu no Mori) $(warning Fast3DZEX is experimental. Try at your own risk.) - GRUCODE_CFLAGS := -DF3DEX_GBI_2 - GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 --defsym F3DZEX_GBI=1 + GRUCODE_DEF := F3DEX_GBI_2 + GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 TARGET := $(TARGET).f3dzex COMPARE := 0 endif @@ -196,6 +187,9 @@ endif endif endif +GRUCODE_CFLAGS := -D$(GRUCODE_DEF) +GRUCODE_ASFLAGS := $(GRUCODE_ASFLAGS) --defsym $(GRUCODE_DEF)=1 + # Default build is for PC now VERSION_CFLAGS := $(VERSION_CFLAGS) -DNON_MATCHING -DAVOID_UB @@ -454,10 +448,7 @@ SOUND_SAMPLE_DIRS := $(wildcard sound/samples/*) SOUND_SAMPLE_AIFFS := $(foreach dir,$(SOUND_SAMPLE_DIRS),$(wildcard $(dir)/*.aiff)) 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)) -SOUND_OBJ_FILES := $(SOUND_BIN_DIR)/sound_data.ctl.o \ - $(SOUND_BIN_DIR)/sound_data.tbl.o \ - $(SOUND_BIN_DIR)/sequences.bin.o \ - $(SOUND_BIN_DIR)/bank_sets.o +SOUND_OBJ_FILES := $(SOUND_BIN_DIR)/sound_data.o # Object files O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \ @@ -626,8 +617,8 @@ endif # Check for Discord Rich Presence option ifeq ($(DISCORDRPC),1) -CC_CHECK += -DDISCORDRPC -CFLAGS += -DDISCORDRPC + CC_CHECK += -DDISCORDRPC + CFLAGS += -DDISCORDRPC endif # Check for texture fix option @@ -709,7 +700,6 @@ N64CKSUM = $(TOOLS_DIR)/n64cksum N64GRAPHICS = $(TOOLS_DIR)/n64graphics N64GRAPHICS_CI = $(TOOLS_DIR)/n64graphics_ci 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 @@ -787,10 +777,10 @@ $(BUILD_DIR)/$(RPC_LIBS): libultra: $(BUILD_DIR)/libultra.a -asm/boot.s: $(BUILD_DIR)/lib/bin/ipl3_font.bin +$(BUILD_DIR)/asm/boot.o: $(IPL3_RAW_FILES) +$(BUILD_DIR)/src/game/crash_screen.o: $(CRASH_TEXTURE_C_FILES) -$(BUILD_DIR)/lib/bin/ipl3_font.bin: lib/ipl3_font.png - $(IPLFONTUTIL) e $< $@ +$(BUILD_DIR)/lib/rsp.o: $(BUILD_DIR)/rsp/rspboot.bin $(BUILD_DIR)/rsp/fast3d.bin $(BUILD_DIR)/rsp/audio.bin #Required so the compiler doesn't complain about this not existing. $(BUILD_DIR)/src/game/camera.o: $(BUILD_DIR)/include/text_strings.h @@ -837,7 +827,8 @@ $(BUILD_DIR)/text/%/define_text.inc.c: text/define_text.inc.c text/%/courses.h t $(CPP) $(VERSION_CFLAGS) $< -o $@ -I text/$*/ $(TEXTCONV) charmap.txt $@ $@ -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) $(TEXT_DIRS) $(SOUND_SAMPLE_DIRS) $(addprefix levels/,$(LEVEL_DIRS)) include) $(MIO0_DIR) $(addprefix $(MIO0_DIR)/,$(VERSION)) $(SOUND_BIN_DIR) $(SOUND_BIN_DIR)/sequences/$(VERSION) +RSP_DIRS := $(BUILD_DIR)/rsp +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) $(TEXT_DIRS) $(SOUND_SAMPLE_DIRS) $(addprefix levels/,$(LEVEL_DIRS)) include) $(MIO0_DIR) $(addprefix $(MIO0_DIR)/,$(VERSION)) $(SOUND_BIN_DIR) $(SOUND_BIN_DIR)/sequences/$(VERSION) $(RSP_DIRS) # Make sure build directory exists before compiling anything DUMMY != mkdir -p $(ALL_DIRS) @@ -869,12 +860,17 @@ endif ################################################################ # RGBA32, RGBA16, IA16, IA8, IA4, IA1, I8, I4 + ifeq ($(EXTERNAL_DATA),1) + $(BUILD_DIR)/%: %.png $(ZEROTERM) "$(patsubst %.png,%,$^)" > $@ + else + $(BUILD_DIR)/%: %.png $(N64GRAPHICS) -i $@ -g $< -f $(lastword $(subst ., ,$@)) + endif $(BUILD_DIR)/%.inc.c: $(BUILD_DIR)/% %.png @@ -882,6 +878,7 @@ $(BUILD_DIR)/%.inc.c: $(BUILD_DIR)/% %.png echo >> $@ ifeq ($(EXTERNAL_DATA),0) + # Color Index CI8 $(BUILD_DIR)/%.ci8: %.ci8.png $(N64GRAPHICS_CI) -i $@ -g $< -f ci8 @@ -889,6 +886,7 @@ $(BUILD_DIR)/%.ci8: %.ci8.png # Color Index CI4 $(BUILD_DIR)/%.ci4: %.ci4.png $(N64GRAPHICS_CI) -i $@ -g $< -f ci4 + endif ################################################################ @@ -902,6 +900,9 @@ $(BUILD_DIR)/%.table: %.aiff $(BUILD_DIR)/%.aifc: $(BUILD_DIR)/%.table %.aiff $(VADPCM_ENC) -c $^ $@ +$(BUILD_DIR)/rsp/%.bin $(BUILD_DIR)/rsp/%_data.bin: rsp/%.s + $(RSPASM) -sym $@.sym -definelabel $(VERSION_DEF) 1 -definelabel $(GRUCODE_DEF) 1 -strequ CODE_FILE $(BUILD_DIR)/rsp/$*.bin -strequ DATA_FILE $(BUILD_DIR)/rsp/$*_data.bin $< + $(ENDIAN_BITWIDTH): tools/determine-endian-bitwidth.c $(CC) -c $(CFLAGS) -o $@.dummy2 $< 2>$@.dummy1; true grep -o 'msgbegin --endian .* --bitwidth .* msgend' $@.dummy1 > $@.dummy2 @@ -934,39 +935,19 @@ $(SOUND_BIN_DIR)/%.o: $(SOUND_BIN_DIR)/%.s ifeq ($(EXTERNAL_DATA),1) -$(SOUND_BIN_DIR)/sound_data.ctl.c: $(SOUND_BIN_DIR)/sound_data.ctl - echo "unsigned char gSoundDataADSR[] = \"sound/sound_data.ctl\";" > $@ -$(SOUND_BIN_DIR)/sound_data.tbl.c: $(SOUND_BIN_DIR)/sound_data.tbl - echo "unsigned char gSoundDataRaw[] = \"sound/sound_data.tbl\";" > $@ -$(SOUND_BIN_DIR)/sequences.bin.c: $(SOUND_BIN_DIR)/sequences.bin - echo "unsigned char gMusicData[] = \"sound/sequences.bin\";" > $@ -$(SOUND_BIN_DIR)/bank_sets.c: $(SOUND_BIN_DIR)/bank_sets - echo "unsigned char gBankSetsData[] = \"sound/bank_sets\";" > $@ +$(SOUND_BIN_DIR)/%.inc.c: $(SOUND_BIN_DIR)/% + $(ZEROTERM) "$(patsubst %.inc.c,%,$^)" | hexdump -v -e '1/1 "0x%X,"' > $@ else -$(SOUND_BIN_DIR)/sound_data.ctl.c: $(SOUND_BIN_DIR)/sound_data.ctl - echo "unsigned char gSoundDataADSR[] = {" > $@ - hexdump -v -e '1/1 "0x%X,"' $< >> $@ - echo "};" >> $@ - -$(SOUND_BIN_DIR)/sound_data.tbl.c: $(SOUND_BIN_DIR)/sound_data.tbl - echo "unsigned char gSoundDataRaw[] = {" > $@ - hexdump -v -e '1/1 "0x%X,"' $< >> $@ - echo "};" >> $@ - -$(SOUND_BIN_DIR)/sequences.bin.c: $(SOUND_BIN_DIR)/sequences.bin - echo "unsigned char gMusicData[] = {" > $@ - hexdump -v -e '1/1 "0x%X,"' $< >> $@ - echo "};" >> $@ - -$(SOUND_BIN_DIR)/bank_sets.c: $(SOUND_BIN_DIR)/bank_sets - echo "unsigned char gBankSetsData[0x100] = {" > $@ - hexdump -v -e '1/1 "0x%X,"' $< >> $@ - echo "};" >> $@ +$(SOUND_BIN_DIR)/%.inc.c: $(SOUND_BIN_DIR)/% + hexdump -v -e '1/1 "0x%X,"' $< > $@ + echo >> $@ endif +$(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 + $(BUILD_DIR)/levels/scripts.o: $(BUILD_DIR)/include/level_headers.h $(BUILD_DIR)/include/level_headers.h: levels/level_headers.h.in @@ -1012,12 +993,18 @@ else # acpp, which needs -Wp,-+ to handle C++-style comments. $(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/seqplayer.o: OPT_FLAGS := -O2 -sopt,-inline_manual,-scalaroptimize=1 -Wp,-+ #-Wo,-v,-bb,-l,seqplayer_list.txt # Add a target for build/eu/src/audio/*.copt to make it easier to see debug $(BUILD_DIR)/src/audio/%.acpp: src/audio/%.c - $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/lib/acpp $(TARGET_CFLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -D__sgi -+ $< > $@ + $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/lib/acpp $(TARGET_CFLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(MATCH_CFLAGS) $(GRUCODE_CFLAGS) -D__sgi -+ $< > $@ + +$(BUILD_DIR)/src/audio/seqplayer.copt: $(BUILD_DIR)/src/audio/seqplayer.acpp + $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/lib/copt -signed -I=$< -CMP=$@ -cp=i -scalaroptimize=1 -inline_manual + $(BUILD_DIR)/src/audio/%.copt: $(BUILD_DIR)/src/audio/%.acpp $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/lib/copt -signed -I=$< -CMP=$@ -cp=i -scalaroptimize=1 + endif # Rebuild files with 'GLOBAL_ASM' if the NON_MATCHING flag changes. @@ -1031,12 +1018,12 @@ $(BUILD_DIR)/%.o: %.cpp $(CXX) -c $(CFLAGS) -o $@ $< $(BUILD_DIR)/%.o: %.c - @$(CC_CHECK) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $< + @$(CC_CHECK) $(CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $< $(CC) -c $(CFLAGS) -o $@ $< $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c - @$(CC_CHECK) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $< + @$(CC_CHECK) $(CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $< $(CC) -c $(CFLAGS) -o $@ $< $(BUILD_DIR)/%.o: %.s diff --git a/Makefile.split b/Makefile.split index c7bdaa2e..609222f0 100644 --- a/Makefile.split +++ b/Makefile.split @@ -5,7 +5,7 @@ # obtain a list of segments from the *.c files in bin directory SEGMENTS := $(notdir $(basename $(wildcard bin/*.c))) $(addprefix $(VERSION)/,$(notdir $(basename $(wildcard bin/$(VERSION)/*.c)))) $(addsuffix _skybox,$(notdir $(basename $(wildcard textures/skyboxes/*.png)))) ACTORS := $(filter %/,$(wildcard actors/*/)) -TEXTURE_DIRS := $(addprefix textures/,$(SEGMENTS)) $(ACTORS) textures/intro_raw textures/skybox_tiles +TEXTURE_DIRS := $(addprefix textures/,$(SEGMENTS)) $(ACTORS) textures/crash_screen textures/intro_raw textures/ipl3_raw textures/skybox_tiles # NOTE: textures assume naming convention "texture..png" generates "texture." @@ -243,6 +243,12 @@ $(BUILD_DIR)/bin/%_skybox.elf: SEGMENT_ADDRESS := 0x0A000000 # Misc Rules # -------------------------------------- -# intro_raw textures are not compressed +# intro and ipl3 textures are not compressed INTRO_RAW_FILES := $(wildcard $(TEXTURE_DIR)/intro_raw/*.png) $(BUILD_DIR)/src/goddard/renderer.o: $(addprefix $(BUILD_DIR)/,$(patsubst %.png,%.inc.c,$(INTRO_RAW_FILES))) + +IPL3_TEXTURE_FILES := $(wildcard $(TEXTURE_DIR)/ipl3_raw/*.png) +IPL3_RAW_FILES := $(addprefix $(BUILD_DIR)/,$(patsubst %.png,%,$(IPL3_TEXTURE_FILES))) + +CRASH_TEXTURE_FILES := $(wildcard $(TEXTURE_DIR)/crash_screen/*.png) +CRASH_TEXTURE_C_FILES := $(addprefix $(BUILD_DIR)/,$(patsubst %.png,%.inc.c,$(CRASH_TEXTURE_FILES))) diff --git a/actors/blue_coin_switch/collision.inc.c b/actors/blue_coin_switch/collision.inc.c index 5ae6133e..5134eac2 100644 --- a/actors/blue_coin_switch/collision.inc.c +++ b/actors/blue_coin_switch/collision.inc.c @@ -1,7 +1,7 @@ // Blue Coin Switch // 0x08000E98 - 0x08000F10 -const s16 blue_coin_switch_seg8_collision_08000E98[] = { +const Collision blue_coin_switch_seg8_collision_08000E98[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(26, 0, 26), diff --git a/actors/breakable_box/collision.inc.c b/actors/breakable_box/collision.inc.c index 7db0c26f..8434a161 100644 --- a/actors/breakable_box/collision.inc.c +++ b/actors/breakable_box/collision.inc.c @@ -1,7 +1,7 @@ // Breakable Box // 0x08012D70 - 0x08012DF4 -const s16 breakable_box_seg8_collision_08012D70[] = { +const Collision breakable_box_seg8_collision_08012D70[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(-100, 0, -100), diff --git a/actors/cannon_lid/collision.inc.c b/actors/cannon_lid/collision.inc.c index ef9c82ce..57ed1681 100644 --- a/actors/cannon_lid/collision.inc.c +++ b/actors/cannon_lid/collision.inc.c @@ -1,7 +1,7 @@ // Cannon Lid // 0x08004950 - 0x08004980 -const s16 cannon_lid_seg8_collision_08004950[] = { +const Collision cannon_lid_seg8_collision_08004950[] = { COL_INIT(), COL_VERTEX_INIT(0x4), COL_VERTEX(112, 0, -111), diff --git a/actors/capswitch/collision.inc.c b/actors/capswitch/collision.inc.c index 75045323..bb504694 100644 --- a/actors/capswitch/collision.inc.c +++ b/actors/capswitch/collision.inc.c @@ -1,6 +1,6 @@ // Capswitch -const s16 capswitch_collision_050033D0[] = { +const Collision capswitch_collision_050033D0[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(292, 0, 254), @@ -27,7 +27,7 @@ const s16 capswitch_collision_050033D0[] = { COL_END(), }; -const s16 capswitch_collision_05003448[] = { +const Collision capswitch_collision_05003448[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(292, 0, 254), diff --git a/actors/checkerboard_platform/collision.inc.c b/actors/checkerboard_platform/collision.inc.c index 3cf85b32..9c92db41 100644 --- a/actors/checkerboard_platform/collision.inc.c +++ b/actors/checkerboard_platform/collision.inc.c @@ -1,7 +1,7 @@ // Checkerboard Platform // 0x0800D710 - 0x0800D794 -const s16 checkerboard_platform_seg8_collision_0800D710[] = { +const Collision checkerboard_platform_seg8_collision_0800D710[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(256, -25, -153), diff --git a/actors/common0.h b/actors/common0.h index 0c0c7804..f4a791db 100644 --- a/actors/common0.h +++ b/actors/common0.h @@ -28,7 +28,7 @@ extern const GeoLayout blue_coin_switch_geo[]; extern const Gfx blue_coin_switch_seg8_dl_08000D58[]; extern const Gfx blue_coin_switch_seg8_dl_08000DD0[]; extern const Gfx blue_coin_switch_seg8_dl_08000E08[]; -extern const s16 blue_coin_switch_seg8_collision_08000E98[]; +extern const Collision blue_coin_switch_seg8_collision_08000E98[]; // bobomb extern const GeoLayout black_bobomb_geo[]; @@ -57,7 +57,7 @@ extern const Gfx breakable_box_seg8_dl_08012C30[]; extern const Gfx breakable_box_seg8_dl_08012CD8[]; extern const Gfx breakable_box_seg8_dl_08012D20[]; extern const Gfx breakable_box_seg8_dl_08012D48[]; -extern const s16 breakable_box_seg8_collision_08012D70[]; +extern const Collision breakable_box_seg8_collision_08012D70[]; // cannon_barrel extern const GeoLayout cannon_barrel_geo[]; @@ -74,14 +74,14 @@ extern const Gfx cannon_base_seg8_dl_080057F8[]; // cannon_lid extern const Gfx cannon_lid_seg8_dl_08004898[]; extern const Gfx cannon_lid_seg8_dl_080048E0[]; -extern const s16 cannon_lid_seg8_collision_08004950[]; +extern const Collision cannon_lid_seg8_collision_08004950[]; // checkerboard_platform extern const GeoLayout checkerboard_platform_geo[]; extern const Gfx checkerboard_platform_seg8_dl_0800D5C0[]; extern const Gfx checkerboard_platform_seg8_dl_0800D618[]; extern const Gfx checkerboard_platform_seg8_dl_0800D680[]; -extern const s16 checkerboard_platform_seg8_collision_0800D710[]; +extern const Collision checkerboard_platform_seg8_collision_0800D710[]; // chuckya extern const GeoLayout chuckya_geo[]; @@ -136,7 +136,7 @@ extern const Gfx exclamation_box_outline_seg8_dl_08025968[]; extern const Gfx exclamation_box_outline_seg8_dl_080259F8[]; extern const Gfx exclamation_box_outline_seg8_dl_08025EC0[]; extern const Gfx exclamation_box_outline_seg8_dl_08025F08[]; -extern const s16 exclamation_box_outline_seg8_collision_08025F78[]; +extern const Collision exclamation_box_outline_seg8_collision_08025F78[]; // flyguy extern const GeoLayout flyguy_geo[]; @@ -189,18 +189,18 @@ extern const Gfx koopa_shell_seg8_dl_08028B78[]; extern const GeoLayout metal_box_geo[]; extern const Gfx metal_box_seg8_dl_08024B18[]; extern const Gfx metal_box_dl[]; -extern const s16 metal_box_seg8_collision_08024C28[]; +extern const Collision metal_box_seg8_collision_08024C28[]; // purple_switch extern const GeoLayout purple_switch_geo[]; extern const Gfx purple_switch_seg8_dl_0800C668[]; extern const Gfx purple_switch_seg8_dl_0800C6E0[]; extern const Gfx purple_switch_seg8_dl_0800C718[]; -extern const s16 purple_switch_seg8_collision_0800C7A8[]; +extern const Collision purple_switch_seg8_collision_0800C7A8[]; // test_platform extern const GeoLayout test_platform_geo[]; extern const Gfx unknown_seg8_dl_08026260[]; -extern const s16 unknown_seg8_collision_080262F8[]; +extern const Collision unknown_seg8_collision_080262F8[]; #endif diff --git a/actors/common1.h b/actors/common1.h index c5383c40..9a1b650e 100644 --- a/actors/common1.h +++ b/actors/common1.h @@ -225,8 +225,8 @@ extern const Gfx tree_seg3_dl_03032170[]; extern const Gfx tree_seg3_dl_03033258[]; // warp_collision -extern const s16 door_seg3_collision_0301CE78[]; -extern const s16 lll_hexagonal_mesh_seg3_collision_0301CECC[]; +extern const Collision door_seg3_collision_0301CE78[]; +extern const Collision lll_hexagonal_mesh_seg3_collision_0301CECC[]; // warp_pipe extern const GeoLayout warp_pipe_geo[]; @@ -235,7 +235,7 @@ extern const Gfx warp_pipe_seg3_dl_03008F98[]; extern const Gfx warp_pipe_seg3_dl_03009968[]; extern const Gfx warp_pipe_seg3_dl_03009A20[]; extern const Gfx warp_pipe_seg3_dl_03009A50[]; -extern const s16 warp_pipe_seg3_collision_03009AC8[]; +extern const Collision warp_pipe_seg3_collision_03009AC8[]; // white_particle extern const GeoLayout white_particle_geo[]; @@ -248,6 +248,6 @@ extern const Gfx wooden_signpost_seg3_dl_0302DA48[]; extern const Gfx wooden_signpost_seg3_dl_0302DC40[]; extern const Gfx wooden_signpost_seg3_dl_0302DCD0[]; extern const Gfx wooden_signpost_seg3_dl_0302DD08[]; -extern const s16 wooden_signpost_seg3_collision_0302DD80[]; +extern const Collision wooden_signpost_seg3_collision_0302DD80[]; #endif diff --git a/actors/dorrie/collision.inc.c b/actors/dorrie/collision.inc.c index 20ff2ec2..abdf16b3 100644 --- a/actors/dorrie/collision.inc.c +++ b/actors/dorrie/collision.inc.c @@ -1,7 +1,7 @@ // Dorrie // 0x0600F644 - 0x0600FBB8 -const s16 dorrie_seg6_collision_0600F644[] = { +const Collision dorrie_seg6_collision_0600F644[] = { COL_INIT(), COL_VERTEX_INIT(0x4E), COL_VERTEX(-104, 657, 512), @@ -243,7 +243,7 @@ const s16 dorrie_seg6_collision_0600F644[] = { }; // 0x0600FBB8 - 0x060100CE -const s16 dorrie_seg6_collision_0600FBB8[] = { +const Collision dorrie_seg6_collision_0600FBB8[] = { COL_INIT(), COL_VERTEX_INIT(0x49), COL_VERTEX(-301, -141, -152), diff --git a/actors/exclamation_box_outline/collision.inc.c b/actors/exclamation_box_outline/collision.inc.c index b16119bb..b85406c9 100644 --- a/actors/exclamation_box_outline/collision.inc.c +++ b/actors/exclamation_box_outline/collision.inc.c @@ -1,7 +1,7 @@ // Exclamation Box Outline // 0x08025F78 - 0x08025FFC -const s16 exclamation_box_outline_seg8_collision_08025F78[] = { +const Collision exclamation_box_outline_seg8_collision_08025F78[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(-26, 30, -26), diff --git a/actors/group1.h b/actors/group1.h index 8e0bf32c..23990b04 100644 --- a/actors/group1.h +++ b/actors/group1.h @@ -70,8 +70,8 @@ extern const GeoLayout thwomp_geo[]; extern const Gfx thwomp_seg5_dl_0500B570[]; extern const Gfx thwomp_seg5_dl_0500B718[]; extern const Gfx thwomp_seg5_dl_0500B750[]; -extern const s16 thwomp_seg5_collision_0500B7D0[]; -extern const s16 thwomp_seg5_collision_0500B92C[]; +extern const Collision thwomp_seg5_collision_0500B7D0[]; +extern const Collision thwomp_seg5_collision_0500B92C[]; // yellow_sphere_small extern const GeoLayout yellow_sphere_geo[]; diff --git a/actors/group14.h b/actors/group14.h index 474af4e3..f776dcd5 100644 --- a/actors/group14.h +++ b/actors/group14.h @@ -110,7 +110,7 @@ extern const GeoLayout wooden_post_geo[]; extern const Gfx poundable_pole_seg6_dl_060022F0[]; extern const Gfx poundable_pole_seg6_dl_06002358[]; extern const Gfx poundable_pole_seg6_dl_06002410[]; -extern const s16 poundable_pole_collision_06002490[]; +extern const Collision poundable_pole_collision_06002490[]; // whomp extern const GeoLayout whomp_geo[]; @@ -131,6 +131,6 @@ extern const Gfx whomp_seg6_dl_0601FEA8[]; extern const Gfx whomp_seg6_dl_0601FFA0[]; extern const Gfx whomp_seg6_dl_06020038[]; extern const struct Animation *const whomp_seg6_anims_06020A04[]; -extern const s16 whomp_seg6_collision_06020A0C[]; +extern const Collision whomp_seg6_collision_06020A0C[]; #endif diff --git a/actors/group17.h b/actors/group17.h index 8c2c6a5b..e28bc024 100644 --- a/actors/group17.h +++ b/actors/group17.h @@ -32,8 +32,8 @@ extern const Gfx dorrie_seg6_dl_0600DE38[]; extern const Gfx dorrie_seg6_dl_0600DF60[]; extern const Gfx dorrie_seg6_dl_0600DFA8[]; extern const struct Animation *const dorrie_seg6_anims_0600F638[]; -extern const s16 dorrie_seg6_collision_0600F644[]; -extern const s16 dorrie_seg6_collision_0600FBB8[]; +extern const Collision dorrie_seg6_collision_0600F644[]; +extern const Collision dorrie_seg6_collision_0600FBB8[]; // mr_i_eyeball extern const GeoLayout mr_i_geo[]; diff --git a/actors/group7.h b/actors/group7.h index 00e50ad8..f5d9332f 100644 --- a/actors/group7.h +++ b/actors/group7.h @@ -22,7 +22,7 @@ extern const Gfx penguin_seg5_dl_050072C8[]; extern const Gfx penguin_seg5_dl_05007358[]; extern const Gfx penguin_seg5_dl_05007540[]; extern const struct Animation *const penguin_seg5_anims_05008B74[]; -extern const s16 penguin_seg5_collision_05008B88[]; +extern const Collision penguin_seg5_collision_05008B88[]; // snowman extern const GeoLayout mr_blizzard_hidden_geo[]; diff --git a/actors/group8.h b/actors/group8.h index 973becfe..19b3956b 100644 --- a/actors/group8.h +++ b/actors/group8.h @@ -14,8 +14,8 @@ extern const Gfx capswitch_seg5_dl_05003350[]; extern const Gfx capswitch_seg5_dl_05003370[]; extern const Gfx capswitch_seg5_dl_05003390[]; extern const Gfx capswitch_seg5_dl_050033B0[]; -extern const s16 capswitch_collision_050033D0[]; -extern const s16 capswitch_collision_05003448[]; +extern const Collision capswitch_collision_050033D0[]; +extern const Collision capswitch_collision_05003448[]; // springboard extern const GeoLayout springboard_top_geo[]; @@ -24,6 +24,6 @@ extern const GeoLayout springboard_bottom_geo[]; extern const Gfx springboard_checkerboard_seg5_dl_050016B8[]; extern const Gfx springboard_spring_seg5_dl_05001800[]; extern const Gfx springboard_checkerboard_seg5_dl_05001900[]; -extern const s16 springboard_collision_05001A28[]; +extern const Collision springboard_collision_05001A28[]; #endif diff --git a/actors/metal_box/collision.inc.c b/actors/metal_box/collision.inc.c index ac377c19..70a0de29 100644 --- a/actors/metal_box/collision.inc.c +++ b/actors/metal_box/collision.inc.c @@ -1,7 +1,7 @@ // Metal Box // 0x08024C28 - 0x08024CAC -const s16 metal_box_seg8_collision_08024C28[] = { +const Collision metal_box_seg8_collision_08024C28[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(154, 307, -153), diff --git a/actors/penguin/collision.inc.c b/actors/penguin/collision.inc.c index 38bc405f..4bb97628 100644 --- a/actors/penguin/collision.inc.c +++ b/actors/penguin/collision.inc.c @@ -1,7 +1,7 @@ // Penguin // 0x05008B88 - 0x05008C00 -const s16 penguin_seg5_collision_05008B88[] = { +const Collision penguin_seg5_collision_05008B88[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(12, 66, -12), diff --git a/actors/poundable_pole/collision.inc.c b/actors/poundable_pole/collision.inc.c index bc3cd035..568e60e0 100644 --- a/actors/poundable_pole/collision.inc.c +++ b/actors/poundable_pole/collision.inc.c @@ -1,7 +1,7 @@ // Poundable Pole // 0x06002490 - 0x06002580 -const s16 poundable_pole_collision_06002490[] = { +const Collision poundable_pole_collision_06002490[] = { COL_INIT(), COL_VERTEX_INIT(0x10), COL_VERTEX(-39, -19, -96), diff --git a/actors/purple_switch/collision.inc.c b/actors/purple_switch/collision.inc.c index 0722dd60..764638bc 100644 --- a/actors/purple_switch/collision.inc.c +++ b/actors/purple_switch/collision.inc.c @@ -1,7 +1,7 @@ // Purple Switch // 0x0800C7A8 - 0x0800C820 -const s16 purple_switch_seg8_collision_0800C7A8[] = { +const Collision purple_switch_seg8_collision_0800C7A8[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(61, 36, -60), diff --git a/actors/springboard/collision.inc.c b/actors/springboard/collision.inc.c index 700af866..06fa6368 100644 --- a/actors/springboard/collision.inc.c +++ b/actors/springboard/collision.inc.c @@ -1,7 +1,7 @@ // Springboard // 0x05001A28 - 0x05001B48 -const s16 springboard_collision_05001A28[] = { +const Collision springboard_collision_05001A28[] = { COL_INIT(), COL_VERTEX_INIT(0xC), COL_VERTEX(205, 0, 0), diff --git a/actors/test_platform/collision.inc.c b/actors/test_platform/collision.inc.c index 83eb273d..b5ef4ba7 100644 --- a/actors/test_platform/collision.inc.c +++ b/actors/test_platform/collision.inc.c @@ -1,7 +1,7 @@ // Test Platform (small tiny platform 1/4th the size of a box. Probably used in early modeling tests?) // 0x080262F8 - 0x0802637C -const s16 unknown_seg8_collision_080262F8[] = { +const Collision unknown_seg8_collision_080262F8[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(200, 0, -200), diff --git a/actors/thwomp/collision.inc.c b/actors/thwomp/collision.inc.c index e2e8e6b8..bb2f8b48 100644 --- a/actors/thwomp/collision.inc.c +++ b/actors/thwomp/collision.inc.c @@ -1,7 +1,7 @@ // Thwomp // 0x0500B7D0 - 0x0500B92C -const s16 thwomp_seg5_collision_0500B7D0[] = { +const Collision thwomp_seg5_collision_0500B7D0[] = { COL_INIT(), COL_VERTEX_INIT(0x14), COL_VERTEX(-156, 3, 73), @@ -67,7 +67,7 @@ const s16 thwomp_seg5_collision_0500B7D0[] = { }; // 0x0500B92C - 0x0500BA88 -const s16 thwomp_seg5_collision_0500B92C[] = { +const Collision thwomp_seg5_collision_0500B92C[] = { COL_INIT(), COL_VERTEX_INIT(0x14), COL_VERTEX(-156, 3, 73), diff --git a/actors/warp_collision/collision.inc.c b/actors/warp_collision/collision.inc.c index 3fa8cd57..5cc45b24 100644 --- a/actors/warp_collision/collision.inc.c +++ b/actors/warp_collision/collision.inc.c @@ -1,7 +1,7 @@ // Warp Collision (seems strange to put these collision in another file. Only instance of this seperation thus far. Not sure what this is doing as a file.) // 0x0301CE78 - 0x0301CECC -const s16 door_seg3_collision_0301CE78[] = { +const Collision door_seg3_collision_0301CE78[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(-80, 240, 30), @@ -23,7 +23,7 @@ const s16 door_seg3_collision_0301CE78[] = { }; // 0x0301CECC - 0x0301CEFC -const s16 lll_hexagonal_mesh_seg3_collision_0301CECC[] = { +const Collision lll_hexagonal_mesh_seg3_collision_0301CECC[] = { COL_INIT(), COL_VERTEX_INIT(0x4), COL_VERTEX(-200, 0, -200), diff --git a/actors/warp_pipe/collision.inc.c b/actors/warp_pipe/collision.inc.c index 811f3c2b..00d5f194 100644 --- a/actors/warp_pipe/collision.inc.c +++ b/actors/warp_pipe/collision.inc.c @@ -1,7 +1,7 @@ // Warp Pipe // 0x03009AC8 - 0x03009CD8 -const s16 warp_pipe_seg3_collision_03009AC8[] = { +const Collision warp_pipe_seg3_collision_03009AC8[] = { COL_INIT(), COL_VERTEX_INIT(0x24), COL_VERTEX(-101, 0, 102), diff --git a/actors/whomp/collision.inc.c b/actors/whomp/collision.inc.c index 483b3191..342720e1 100644 --- a/actors/whomp/collision.inc.c +++ b/actors/whomp/collision.inc.c @@ -1,7 +1,7 @@ // Whomp // 0x06020A0C - 0x06020A90 -const s16 whomp_seg6_collision_06020A0C[] = { +const Collision whomp_seg6_collision_06020A0C[] = { #ifdef VERSION_JP COL_INIT(), COL_VERTEX_INIT(0x8), diff --git a/actors/wooden_signpost/collision.inc.c b/actors/wooden_signpost/collision.inc.c index 482554b7..2c10e4ca 100644 --- a/actors/wooden_signpost/collision.inc.c +++ b/actors/wooden_signpost/collision.inc.c @@ -1,7 +1,7 @@ // Wooden Signpost // 0x0302DD80 - 0x0302DE04 -const s16 wooden_signpost_seg3_collision_0302DD80[] = { +const Collision wooden_signpost_seg3_collision_0302DD80[] = { COL_INIT(), COL_VERTEX_INIT(0x8), COL_VERTEX(-44, -9, -12), diff --git a/asm/boot.s b/asm/boot.s index bfe6b4e4..be12ff0a 100644 --- a/asm/boot.s +++ b/asm/boot.s @@ -799,4 +799,54 @@ func_A4000AD0: # 0xA4000B70-0xA4000FFF: IPL3 Font glabel ipl3_font -.incbin "lib/bin/ipl3_font.bin" +.incbin "textures/ipl3_raw/ipl3_font_00.ia1" +.incbin "textures/ipl3_raw/ipl3_font_01.ia1" +.incbin "textures/ipl3_raw/ipl3_font_02.ia1" +.incbin "textures/ipl3_raw/ipl3_font_03.ia1" +.incbin "textures/ipl3_raw/ipl3_font_04.ia1" +.incbin "textures/ipl3_raw/ipl3_font_05.ia1" +.incbin "textures/ipl3_raw/ipl3_font_06.ia1" +.incbin "textures/ipl3_raw/ipl3_font_07.ia1" +.incbin "textures/ipl3_raw/ipl3_font_08.ia1" +.incbin "textures/ipl3_raw/ipl3_font_09.ia1" +.incbin "textures/ipl3_raw/ipl3_font_10.ia1" +.incbin "textures/ipl3_raw/ipl3_font_11.ia1" +.incbin "textures/ipl3_raw/ipl3_font_12.ia1" +.incbin "textures/ipl3_raw/ipl3_font_13.ia1" +.incbin "textures/ipl3_raw/ipl3_font_14.ia1" +.incbin "textures/ipl3_raw/ipl3_font_15.ia1" +.incbin "textures/ipl3_raw/ipl3_font_16.ia1" +.incbin "textures/ipl3_raw/ipl3_font_17.ia1" +.incbin "textures/ipl3_raw/ipl3_font_18.ia1" +.incbin "textures/ipl3_raw/ipl3_font_19.ia1" +.incbin "textures/ipl3_raw/ipl3_font_20.ia1" +.incbin "textures/ipl3_raw/ipl3_font_21.ia1" +.incbin "textures/ipl3_raw/ipl3_font_22.ia1" +.incbin "textures/ipl3_raw/ipl3_font_23.ia1" +.incbin "textures/ipl3_raw/ipl3_font_24.ia1" +.incbin "textures/ipl3_raw/ipl3_font_25.ia1" +.incbin "textures/ipl3_raw/ipl3_font_26.ia1" +.incbin "textures/ipl3_raw/ipl3_font_27.ia1" +.incbin "textures/ipl3_raw/ipl3_font_28.ia1" +.incbin "textures/ipl3_raw/ipl3_font_29.ia1" +.incbin "textures/ipl3_raw/ipl3_font_30.ia1" +.incbin "textures/ipl3_raw/ipl3_font_31.ia1" +.incbin "textures/ipl3_raw/ipl3_font_32.ia1" +.incbin "textures/ipl3_raw/ipl3_font_33.ia1" +.incbin "textures/ipl3_raw/ipl3_font_34.ia1" +.incbin "textures/ipl3_raw/ipl3_font_35.ia1" +.incbin "textures/ipl3_raw/ipl3_font_36.ia1" +.incbin "textures/ipl3_raw/ipl3_font_37.ia1" +.incbin "textures/ipl3_raw/ipl3_font_38.ia1" +.incbin "textures/ipl3_raw/ipl3_font_39.ia1" +.incbin "textures/ipl3_raw/ipl3_font_40.ia1" +.incbin "textures/ipl3_raw/ipl3_font_41.ia1" +.incbin "textures/ipl3_raw/ipl3_font_42.ia1" +.incbin "textures/ipl3_raw/ipl3_font_43.ia1" +.incbin "textures/ipl3_raw/ipl3_font_44.ia1" +.incbin "textures/ipl3_raw/ipl3_font_45.ia1" +.incbin "textures/ipl3_raw/ipl3_font_46.ia1" +.incbin "textures/ipl3_raw/ipl3_font_47.ia1" +.incbin "textures/ipl3_raw/ipl3_font_48.ia1" +.incbin "textures/ipl3_raw/ipl3_font_49.ia1" +.fill 0x12 diff --git a/asm/non_matchings/eu/audio/seq_channel_layer_process_script.s b/asm/non_matchings/eu/audio/seq_channel_layer_process_script.s deleted file mode 100644 index 7f85ce25..00000000 --- a/asm/non_matchings/eu/audio/seq_channel_layer_process_script.s +++ /dev/null @@ -1,781 +0,0 @@ -.late_rodata -glabel jtbl_EU_803066A0 - .word L_EU_802E7960, L_EU_802E7B6C - .word L_EU_802E7B6C, L_EU_802E78F8 - .word L_EU_802E78C0, L_EU_802E7B6C - .word L_EU_802E7B6C, L_EU_802E7940 - .word L_EU_802E7880, L_EU_802E7B6C - .word L_EU_802E7B6C, L_EU_802E7848 - -glabel jtbl_EU_803066D0 - .word L_EU_802E7980, L_EU_802E79BC - .word L_EU_802E7A1C, L_EU_802E79E4 - .word L_EU_802E79E4, L_EU_802E7A30 - .word L_EU_802E7AA0, L_EU_802E7B28 - .word L_EU_802E79BC, L_EU_802E7980 - .word L_EU_802E7B30, L_EU_802E7B5C - -glabel jtbl_EU_80306700 - .word L_EU_802E7F48, L_EU_802E7F50 - .word L_EU_802E7F48, L_EU_802E7F50 - .word L_EU_802E7F48 - -.text -glabel seq_channel_layer_process_script -/* 0A6F08 802E7708 27BDFF90 */ addiu $sp, $sp, -0x70 -/* 0A6F0C 802E770C 240E0001 */ li $t6, 1 -/* 0A6F10 802E7710 AFBF002C */ sw $ra, 0x2c($sp) -/* 0A6F14 802E7714 AFB40028 */ sw $s4, 0x28($sp) -/* 0A6F18 802E7718 AFB30024 */ sw $s3, 0x24($sp) -/* 0A6F1C 802E771C AFB20020 */ sw $s2, 0x20($sp) -/* 0A6F20 802E7720 AFB1001C */ sw $s1, 0x1c($sp) -/* 0A6F24 802E7724 AFB00018 */ sw $s0, 0x18($sp) -/* 0A6F28 802E7728 AFAE0044 */ sw $t6, 0x44($sp) -/* 0A6F2C 802E772C 8C820000 */ lw $v0, ($a0) -/* 0A6F30 802E7730 00808825 */ move $s1, $a0 -/* 0A6F34 802E7734 00027FC2 */ srl $t7, $v0, 0x1f -/* 0A6F38 802E7738 51E0028E */ beql $t7, $zero, .L80202184 -/* 0A6F3C 802E773C 8FBF002C */ lw $ra, 0x2c($sp) -/* 0A6F40 802E7740 84830038 */ lh $v1, 0x38($a0) -/* 0A6F44 802E7744 00024080 */ sll $t0, $v0, 2 -/* 0A6F48 802E7748 000278C0 */ sll $t7, $v0, 3 -/* 0A6F4C 802E774C 28610002 */ slti $at, $v1, 2 -/* 0A6F50 802E7750 1420000E */ bnez $at, .L8020179C -/* 0A6F54 802E7754 2478FFFF */ addiu $t8, $v1, -1 -/* 0A6F58 802E7758 05000285 */ bltz $t0, .L80202180 -/* 0A6F5C 802E775C A4980038 */ sh $t8, 0x38($a0) -/* 0A6F60 802E7760 8489003A */ lh $t1, 0x3a($a0) -/* 0A6F64 802E7764 848A0038 */ lh $t2, 0x38($a0) -/* 0A6F68 802E7768 012A082A */ slt $at, $t1, $t2 -/* 0A6F6C 802E776C 54200281 */ bnezl $at, .L80202184 -/* 0A6F70 802E7770 8FBF002C */ lw $ra, 0x2c($sp) -/* 0A6F74 802E7774 0C0B95B3 */ jal seq_channel_layer_note_decay -/* 0A6F78 802E7778 00000000 */ nop -/* 0A6F7C 802E777C 922C0000 */ lbu $t4, ($s1) -/* 0A6F80 802E7780 358D0020 */ ori $t5, $t4, 0x20 -/* 0A6F84 802E7784 1000027A */ b .L80202180 -/* 0A6F88 802E7788 A22D0000 */ sb $t5, ($s1) -.L8020179C: -/* 0A6F8C 802E778C 05E20004 */ bltzl $t7, .L802017B0 -/* 0A6F90 802E7790 92220008 */ lbu $v0, 8($s1) -/* 0A6F94 802E7794 0C0B95B3 */ jal seq_channel_layer_note_decay -/* 0A6F98 802E7798 02202025 */ move $a0, $s1 -/* 0A6F9C 802E779C 92220008 */ lbu $v0, 8($s1) -.L802017B0: -/* 0A6FA0 802E77A0 2401FF7F */ li $at, -129 -/* 0A6FA4 802E77A4 0041C024 */ and $t8, $v0, $at -/* 0A6FA8 802E77A8 24010001 */ li $at, 1 -/* 0A6FAC 802E77AC 13010003 */ beq $t8, $at, .L802017CC -/* 0A6FB0 802E77B0 24010002 */ li $at, 2 -/* 0A6FB4 802E77B4 57010003 */ bnel $t8, $at, .L802017D4 -/* 0A6FB8 802E77B8 8E22004C */ lw $v0, 0x4c($s1) -.L802017CC: -/* 0A6FBC 802E77BC A2200008 */ sb $zero, 8($s1) -/* 0A6FC0 802E77C0 8E22004C */ lw $v0, 0x4c($s1) -.L802017D4: -/* 0A6FC4 802E77C4 92280000 */ lbu $t0, ($s1) -/* 0A6FC8 802E77C8 26300050 */ addiu $s0, $s1, 0x50 -/* 0A6FCC 802E77CC 8C540044 */ lw $s4, 0x44($v0) -/* 0A6FD0 802E77D0 35090004 */ ori $t1, $t0, 4 -/* 0A6FD4 802E77D4 A2290000 */ sb $t1, ($s1) -/* 0A6FD8 802E77D8 97B3004A */ lhu $s3, 0x4a($sp) -/* 0A6FDC 802E77DC AFA20068 */ sw $v0, 0x68($sp) -.L802017F0: -/* 0A6FE0 802E77E0 0C0B9DA0 */ jal m64_read_u8 -/* 0A6FE4 802E77E4 02002025 */ move $a0, $s0 -/* 0A6FE8 802E77E8 284100C1 */ slti $at, $v0, 0xc1 -/* 0A6FEC 802E77EC 305200FF */ andi $s2, $v0, 0xff -/* 0A6FF0 802E77F0 142000F7 */ bnez $at, .L80201BE0 -/* 0A6FF4 802E77F4 00402825 */ move $a1, $v0 -/* 0A6FF8 802E77F8 284100CD */ slti $at, $v0, 0xcd -/* 0A6FFC 802E77FC 1420000A */ bnez $at, .L80201838 -/* 0A7000 802E7800 24ABFF3F */ addiu $t3, $a1, -0xc1 -/* 0A7004 802E7804 244AFF0C */ addiu $t2, $v0, -0xf4 -/* 0A7008 802E7808 2D41000C */ sltiu $at, $t2, 0xc -/* 0A700C 802E780C 102000D7 */ beqz $at, .L_EU_802E7B6C -/* 0A7010 802E7810 000A5080 */ sll $t2, $t2, 2 -/* 0A7014 802E7814 3C018030 */ lui $at, %hi(jtbl_EU_803066A0) -/* 0A7018 802E7818 002A0821 */ addu $at, $at, $t2 -/* 0A701C 802E781C 8C2A66A0 */ lw $t2, %lo(jtbl_EU_803066A0)($at) -/* 0A7020 802E7820 01400008 */ jr $t2 -/* 0A7024 802E7824 00000000 */ nop -.L80201838: -/* 0A7028 802E7828 2D61000C */ sltiu $at, $t3, 0xc -/* 0A702C 802E782C 102000CF */ beqz $at, .L_EU_802E7B6C -/* 0A7030 802E7830 000B5880 */ sll $t3, $t3, 2 -/* 0A7034 802E7834 3C018030 */ lui $at, %hi(jtbl_EU_803066D0) -/* 0A7038 802E7838 002B0821 */ addu $at, $at, $t3 -/* 0A703C 802E783C 8C2B66D0 */ lw $t3, %lo(jtbl_EU_803066D0)($at) -/* 0A7040 802E7840 01600008 */ jr $t3 -/* 0A7044 802E7844 00000000 */ nop -glabel L_EU_802E7848 -/* 0A7048 802E7848 92030018 */ lbu $v1, 0x18($s0) -/* 0A704C 802E784C 14600005 */ bnez $v1, .L80201874 -/* 0A7050 802E7850 2462FFFF */ addiu $v0, $v1, -1 -/* 0A7054 802E7854 0C0B9C1E */ jal seq_channel_layer_disable -/* 0A7058 802E7858 02202025 */ move $a0, $s1 -/* 0A705C 802E785C 10000245 */ b .L80202184 -/* 0A7060 802E7860 8FBF002C */ lw $ra, 0x2c($sp) -.L80201874: -/* 0A7064 802E7864 304C00FF */ andi $t4, $v0, 0xff -/* 0A7068 802E7868 000C6880 */ sll $t5, $t4, 2 -/* 0A706C 802E786C 020D7021 */ addu $t6, $s0, $t5 -/* 0A7070 802E7870 A20C0018 */ sb $t4, 0x18($s0) -/* 0A7074 802E7874 8DCF0004 */ lw $t7, 4($t6) -/* 0A7078 802E7878 1000FFD9 */ b .L802017F0 -/* 0A707C 802E787C AE0F0000 */ sw $t7, ($s0) -glabel L_EU_802E7880 -/* 0A7080 802E7880 0C0B9DA5 */ jal m64_read_s16 -/* 0A7084 802E7884 02002025 */ move $a0, $s0 -/* 0A7088 802E7888 92190018 */ lbu $t9, 0x18($s0) -/* 0A708C 802E788C 8E180000 */ lw $t8, ($s0) -/* 0A7090 802E7890 304DFFFF */ andi $t5, $v0, 0xffff -/* 0A7094 802E7894 00194080 */ sll $t0, $t9, 2 -/* 0A7098 802E7898 02084821 */ addu $t1, $s0, $t0 -/* 0A709C 802E789C AD380004 */ sw $t8, 4($t1) -/* 0A70A0 802E78A0 920A0018 */ lbu $t2, 0x18($s0) -/* 0A70A4 802E78A4 3053FFFF */ andi $s3, $v0, 0xffff -/* 0A70A8 802E78A8 254B0001 */ addiu $t3, $t2, 1 -/* 0A70AC 802E78AC A20B0018 */ sb $t3, 0x18($s0) -/* 0A70B0 802E78B0 8E8C0014 */ lw $t4, 0x14($s4) -/* 0A70B4 802E78B4 018D7021 */ addu $t6, $t4, $t5 -/* 0A70B8 802E78B8 1000FFC9 */ b .L802017F0 -/* 0A70BC 802E78BC AE0E0000 */ sw $t6, ($s0) -glabel L_EU_802E78C0 -/* 0A70C0 802E78C0 0C0B9DA0 */ jal m64_read_u8 -/* 0A70C4 802E78C4 02002025 */ move $a0, $s0 -/* 0A70C8 802E78C8 920F0018 */ lbu $t7, 0x18($s0) -/* 0A70CC 802E78CC 020FC821 */ addu $t9, $s0, $t7 -/* 0A70D0 802E78D0 A3220014 */ sb $v0, 0x14($t9) -/* 0A70D4 802E78D4 92180018 */ lbu $t8, 0x18($s0) -/* 0A70D8 802E78D8 8E080000 */ lw $t0, ($s0) -/* 0A70DC 802E78DC 00184880 */ sll $t1, $t8, 2 -/* 0A70E0 802E78E0 02095021 */ addu $t2, $s0, $t1 -/* 0A70E4 802E78E4 AD480004 */ sw $t0, 4($t2) -/* 0A70E8 802E78E8 920B0018 */ lbu $t3, 0x18($s0) -/* 0A70EC 802E78EC 256C0001 */ addiu $t4, $t3, 1 -/* 0A70F0 802E78F0 1000FFBB */ b .L802017F0 -/* 0A70F4 802E78F4 A20C0018 */ sb $t4, 0x18($s0) -glabel L_EU_802E78F8 -/* 0A70F8 802E78F8 920D0018 */ lbu $t5, 0x18($s0) -/* 0A70FC 802E78FC 020D1021 */ addu $v0, $s0, $t5 -/* 0A7100 802E7900 904E0013 */ lbu $t6, 0x13($v0) -/* 0A7104 802E7904 25CFFFFF */ addiu $t7, $t6, -1 -/* 0A7108 802E7908 A04F0013 */ sb $t7, 0x13($v0) -/* 0A710C 802E790C 92030018 */ lbu $v1, 0x18($s0) -/* 0A7110 802E7910 0203C821 */ addu $t9, $s0, $v1 -/* 0A7114 802E7914 93380013 */ lbu $t8, 0x13($t9) -/* 0A7118 802E7918 00602025 */ move $a0, $v1 -/* 0A711C 802E791C 00044880 */ sll $t1, $a0, 2 -/* 0A7120 802E7920 13000005 */ beqz $t8, .L80201948 -/* 0A7124 802E7924 246BFFFF */ addiu $t3, $v1, -1 -/* 0A7128 802E7928 02094021 */ addu $t0, $s0, $t1 -/* 0A712C 802E792C 8D0A0000 */ lw $t2, ($t0) -/* 0A7130 802E7930 1000FFAB */ b .L802017F0 -/* 0A7134 802E7934 AE0A0000 */ sw $t2, ($s0) -.L80201948: -/* 0A7138 802E7938 1000FFA9 */ b .L802017F0 -/* 0A713C 802E793C A20B0018 */ sb $t3, 0x18($s0) -glabel L_EU_802E7940 -/* 0A7140 802E7940 0C0B9DA5 */ jal m64_read_s16 -/* 0A7144 802E7944 02002025 */ move $a0, $s0 -/* 0A7148 802E7948 8E8C0014 */ lw $t4, 0x14($s4) -/* 0A714C 802E794C 304DFFFF */ andi $t5, $v0, 0xffff -/* 0A7150 802E7950 3053FFFF */ andi $s3, $v0, 0xffff -/* 0A7154 802E7954 018D7021 */ addu $t6, $t4, $t5 -/* 0A7158 802E7958 1000FFA1 */ b .L802017F0 -/* 0A715C 802E795C AE0E0000 */ sw $t6, ($s0) -glabel L_EU_802E7960 -/* 0A7160 802E7960 0C0B9DA0 */ jal m64_read_u8 -/* 0A7164 802E7964 02002025 */ move $a0, $s0 -/* 0A7168 802E7968 8E0F0000 */ lw $t7, ($s0) -/* 0A716C 802E796C 0002CE00 */ sll $t9, $v0, 0x18 -/* 0A7170 802E7970 0019C603 */ sra $t8, $t9, 0x18 -/* 0A7174 802E7974 01F84821 */ addu $t1, $t7, $t8 -/* 0A7178 802E7978 1000FF99 */ b .L802017F0 -/* 0A717C 802E797C AE090000 */ sw $t1, ($s0) -glabel L_EU_802E7980 -/* 0A7180 802E7980 8E030000 */ lw $v1, ($s0) -/* 0A7184 802E7984 240100C1 */ li $at, 193 -/* 0A7188 802E7988 90640000 */ lbu $a0, ($v1) -/* 0A718C 802E798C 24680001 */ addiu $t0, $v1, 1 -/* 0A7190 802E7990 14A10008 */ bne $a1, $at, .L802019C4 -/* 0A7194 802E7994 AE080000 */ sw $t0, ($s0) -/* 0A7198 802E7998 00840019 */ multu $a0, $a0 -/* 0A719C 802E799C 00005012 */ mflo $t2 -/* 0A71A0 802E79A0 448A2000 */ mtc1 $t2, $f4 -/* 0A71A4 802E79A4 00000000 */ nop -/* 0A71A8 802E79A8 468021A0 */ cvt.s.w $f6, $f4 -/* 0A71AC 802E79AC 1000FF8C */ b .L802017F0 -/* 0A71B0 802E79B0 E6260028 */ swc1 $f6, 0x28($s1) -.L802019C4: -/* 0A71B4 802E79B4 1000FF8A */ b .L802017F0 -/* 0A71B8 802E79B8 A2240005 */ sb $a0, 5($s1) -glabel L_EU_802E79BC -/* 0A71BC 802E79BC 8E030000 */ lw $v1, ($s0) -/* 0A71C0 802E79C0 240100C9 */ li $at, 201 -/* 0A71C4 802E79C4 90640000 */ lbu $a0, ($v1) -/* 0A71C8 802E79C8 246B0001 */ addiu $t3, $v1, 1 -/* 0A71CC 802E79CC 14A10003 */ bne $a1, $at, .L802019EC -/* 0A71D0 802E79D0 AE0B0000 */ sw $t3, ($s0) -/* 0A71D4 802E79D4 1000FF82 */ b .L802017F0 -/* 0A71D8 802E79D8 A2240003 */ sb $a0, 3($s1) -.L802019EC: -/* 0A71DC 802E79DC 1000FF80 */ b .L802017F0 -/* 0A71E0 802E79E0 A6240022 */ sh $a0, 0x22($s1) -glabel L_EU_802E79E4 -/* 0A71E4 802E79E4 240100C4 */ li $at, 196 -/* 0A71E8 802E79E8 54A10006 */ bnel $a1, $at, .L80201A14 -/* 0A71EC 802E79EC 92390000 */ lbu $t9, ($s1) -/* 0A71F0 802E79F0 922D0000 */ lbu $t5, ($s1) -/* 0A71F4 802E79F4 35AE0010 */ ori $t6, $t5, 0x10 -/* 0A71F8 802E79F8 10000004 */ b .L80201A1C -/* 0A71FC 802E79FC A22E0000 */ sb $t6, ($s1) -/* 0A7200 802E7A00 92390000 */ lbu $t9, ($s1) -.L80201A14: -/* 0A7204 802E7A04 332FFFEF */ andi $t7, $t9, 0xffef -/* 0A7208 802E7A08 A22F0000 */ sb $t7, ($s1) -.L80201A1C: -/* 0A720C 802E7A0C 0C0B95B3 */ jal seq_channel_layer_note_decay -/* 0A7210 802E7A10 02202025 */ move $a0, $s1 -/* 0A7214 802E7A14 1000FF72 */ b .L802017F0 -/* 0A7218 802E7A18 00000000 */ nop -glabel L_EU_802E7A1C -/* 0A721C 802E7A1C 0C0B9DB1 */ jal m64_read_compressed_u16 -/* 0A7220 802E7A20 02002025 */ move $a0, $s0 -/* 0A7224 802E7A24 3053FFFF */ andi $s3, $v0, 0xffff -/* 0A7228 802E7A28 1000FF6D */ b .L802017F0 -/* 0A722C 802E7A2C A6220034 */ sh $v0, 0x34($s1) -glabel L_EU_802E7A30 -/* 0A7230 802E7A30 0C0B9DA0 */ jal m64_read_u8 -/* 0A7234 802E7A34 02002025 */ move $a0, $s0 -/* 0A7238 802E7A38 2841007F */ slti $at, $v0, 0x7f -/* 0A723C 802E7A3C 305200FF */ andi $s2, $v0, 0xff -/* 0A7240 802E7A40 1420000D */ bnez $at, .L80201A88 -/* 0A7244 802E7A44 00402825 */ move $a1, $v0 -/* 0A7248 802E7A48 2401007F */ li $at, 127 -/* 0A724C 802E7A4C 54410004 */ bnel $v0, $at, .L80201A70 -/* 0A7250 802E7A50 A2220001 */ sb $v0, 1($s1) -/* 0A7254 802E7A54 10000003 */ b .L80201A74 -/* 0A7258 802E7A58 A2200001 */ sb $zero, 1($s1) -/* 0A725C 802E7A5C A2220001 */ sb $v0, 1($s1) -.L80201A70: -/* 0A7260 802E7A60 AE200044 */ sw $zero, 0x44($s1) -.L80201A74: -/* 0A7264 802E7A64 240100FF */ li $at, 255 -/* 0A7268 802E7A68 14A1FF5D */ bne $a1, $at, .L802017F0 -/* 0A726C 802E7A6C 00000000 */ nop -/* 0A7270 802E7A70 1000FF5B */ b .L802017F0 -/* 0A7274 802E7A74 A2200018 */ sb $zero, 0x18($s1) -.L80201A88: -/* 0A7278 802E7A78 8FA40068 */ lw $a0, 0x68($sp) -/* 0A727C 802E7A7C 324500FF */ andi $a1, $s2, 0xff -/* 0A7280 802E7A80 26260044 */ addiu $a2, $s1, 0x44 -/* 0A7284 802E7A84 0C0BA064 */ jal get_instrument -/* 0A7288 802E7A88 26270018 */ addiu $a3, $s1, 0x18 -/* 0A728C 802E7A8C 1440FF54 */ bnez $v0, .L802017F0 -/* 0A7290 802E7A90 A2220001 */ sb $v0, 1($s1) -/* 0A7294 802E7A94 241800FF */ li $t8, 255 -/* 0A7298 802E7A98 1000FF51 */ b .L802017F0 -/* 0A729C 802E7A9C A2380001 */ sb $t8, 1($s1) -glabel L_EU_802E7AA0 -/* 0A72A0 802E7AA0 0C0B9DA0 */ jal m64_read_u8 -/* 0A72A4 802E7AA4 02002025 */ move $a0, $s0 -/* 0A72A8 802E7AA8 A2220008 */ sb $v0, 8($s1) -/* 0A72AC 802E7AAC 0C0B9DA0 */ jal m64_read_u8 -/* 0A72B0 802E7AB0 02002025 */ move $a0, $s0 -/* 0A72B4 802E7AB4 8FA90068 */ lw $t1, 0x68($sp) -/* 0A72B8 802E7AB8 862B0022 */ lh $t3, 0x22($s1) -/* 0A72BC 802E7ABC 868D000C */ lh $t5, 0xc($s4) -/* 0A72C0 802E7AC0 8528001E */ lh $t0, 0x1e($t1) -/* 0A72C4 802E7AC4 00485021 */ addu $t2, $v0, $t0 -/* 0A72C8 802E7AC8 014B6021 */ addu $t4, $t2, $t3 -/* 0A72CC 802E7ACC 018D9021 */ addu $s2, $t4, $t5 -/* 0A72D0 802E7AD0 324E00FF */ andi $t6, $s2, 0xff -/* 0A72D4 802E7AD4 29C10080 */ slti $at, $t6, 0x80 -/* 0A72D8 802E7AD8 14200002 */ bnez $at, .L80201AF4 -/* 0A72DC 802E7ADC 01C09025 */ move $s2, $t6 -/* 0A72E0 802E7AE0 00009025 */ move $s2, $zero -.L80201AF4: -/* 0A72E4 802E7AE4 92390008 */ lbu $t9, 8($s1) -/* 0A72E8 802E7AE8 A2320004 */ sb $s2, 4($s1) -/* 0A72EC 802E7AEC 332F0080 */ andi $t7, $t9, 0x80 -/* 0A72F0 802E7AF0 11E00008 */ beqz $t7, .L80201B24 -/* 0A72F4 802E7AF4 00000000 */ nop -/* 0A72F8 802E7AF8 8E180000 */ lw $t8, ($s0) -/* 0A72FC 802E7AFC 93090000 */ lbu $t1, ($t8) -/* 0A7300 802E7B00 A6290020 */ sh $t1, 0x20($s1) -/* 0A7304 802E7B04 8E080000 */ lw $t0, ($s0) -/* 0A7308 802E7B08 250A0001 */ addiu $t2, $t0, 1 -/* 0A730C 802E7B0C 1000FF34 */ b .L802017F0 -/* 0A7310 802E7B10 AE0A0000 */ sw $t2, ($s0) -.L80201B24: -/* 0A7314 802E7B14 0C0B9DB1 */ jal m64_read_compressed_u16 -/* 0A7318 802E7B18 02002025 */ move $a0, $s0 -/* 0A731C 802E7B1C 3053FFFF */ andi $s3, $v0, 0xffff -/* 0A7320 802E7B20 1000FF2F */ b .L802017F0 -/* 0A7324 802E7B24 A6220020 */ sh $v0, 0x20($s1) -glabel L_EU_802E7B28 -/* 0A7328 802E7B28 1000FF2D */ b .L802017F0 -/* 0A732C 802E7B2C A2200008 */ sb $zero, 8($s1) -glabel L_EU_802E7B30 -/* 0A7330 802E7B30 0C0B9DA5 */ jal m64_read_s16 -/* 0A7334 802E7B34 02002025 */ move $a0, $s0 -/* 0A7338 802E7B38 8E8B0014 */ lw $t3, 0x14($s4) -/* 0A733C 802E7B3C 304CFFFF */ andi $t4, $v0, 0xffff -/* 0A7340 802E7B40 3053FFFF */ andi $s3, $v0, 0xffff -/* 0A7344 802E7B44 016C6821 */ addu $t5, $t3, $t4 -/* 0A7348 802E7B48 AE2D001C */ sw $t5, 0x1c($s1) -/* 0A734C 802E7B4C 0C0B9DA0 */ jal m64_read_u8 -/* 0A7350 802E7B50 02002025 */ move $a0, $s0 -/* 0A7354 802E7B54 1000FF22 */ b .L802017F0 -/* 0A7358 802E7B58 A2220018 */ sb $v0, 0x18($s1) -glabel L_EU_802E7B5C -/* 0A735C 802E7B5C 92390000 */ lbu $t9, ($s1) -/* 0A7360 802E7B60 372F0002 */ ori $t7, $t9, 2 -/* 0A7364 802E7B64 1000FF1E */ b .L802017F0 -/* 0A7368 802E7B68 A22F0000 */ sb $t7, ($s1) -glabel L_EU_802E7B6C -.L_EU_802E7B6C: -/* 0A736C 802E7B6C 30A300F0 */ andi $v1, $a1, 0xf0 -/* 0A7370 802E7B70 240100D0 */ li $at, 208 -/* 0A7374 802E7B74 10610005 */ beq $v1, $at, .L80201B9C -/* 0A7378 802E7B78 240100E0 */ li $at, 224 -/* 0A737C 802E7B7C 5061000F */ beql $v1, $at, .L80201BCC -/* 0A7380 802E7B80 8E8B0090 */ lw $t3, 0x90($s4) -/* 0A7384 802E7B84 1000FF16 */ b .L802017F0 -/* 0A7388 802E7B88 00000000 */ nop -.L80201B9C: -/* 0A738C 802E7B8C 8E98008C */ lw $t8, 0x8c($s4) -/* 0A7390 802E7B90 30A9000F */ andi $t1, $a1, 0xf -/* 0A7394 802E7B94 03094021 */ addu $t0, $t8, $t1 -/* 0A7398 802E7B98 91130000 */ lbu $s3, ($t0) -/* 0A739C 802E7B9C 02730019 */ multu $s3, $s3 -/* 0A73A0 802E7BA0 00005012 */ mflo $t2 -/* 0A73A4 802E7BA4 448A4000 */ mtc1 $t2, $f8 -/* 0A73A8 802E7BA8 00000000 */ nop -/* 0A73AC 802E7BAC 468042A0 */ cvt.s.w $f10, $f8 -/* 0A73B0 802E7BB0 1000FF0B */ b .L802017F0 -/* 0A73B4 802E7BB4 E62A0028 */ swc1 $f10, 0x28($s1) -/* 0A73B8 802E7BB8 8E8B0090 */ lw $t3, 0x90($s4) -.L80201BCC: -/* 0A73BC 802E7BBC 30AC000F */ andi $t4, $a1, 0xf -/* 0A73C0 802E7BC0 016C6821 */ addu $t5, $t3, $t4 -/* 0A73C4 802E7BC4 91AE0000 */ lbu $t6, ($t5) -/* 0A73C8 802E7BC8 1000FF05 */ b .L802017F0 -/* 0A73CC 802E7BCC A22E0003 */ sb $t6, 3($s1) -.L80201BE0: -/* 0A73D0 802E7BD0 240100C0 */ li $at, 192 -/* 0A73D4 802E7BD4 14A10008 */ bne $a1, $at, .L80201C08 -/* 0A73D8 802E7BD8 30A300C0 */ andi $v1, $a1, 0xc0 -/* 0A73DC 802E7BDC 0C0B9DB1 */ jal m64_read_compressed_u16 -/* 0A73E0 802E7BE0 02002025 */ move $a0, $s0 -/* 0A73E4 802E7BE4 922F0000 */ lbu $t7, ($s1) -/* 0A73E8 802E7BE8 A6220038 */ sh $v0, 0x38($s1) -/* 0A73EC 802E7BEC 35F80020 */ ori $t8, $t7, 0x20 -/* 0A73F0 802E7BF0 10000125 */ b .L80202098 -/* 0A73F4 802E7BF4 A2380000 */ sb $t8, ($s1) -.L80201C08: -/* 0A73F8 802E7BF8 92290000 */ lbu $t1, ($s1) -/* 0A73FC 802E7BFC 24010001 */ li $at, 1 -/* 0A7400 802E7C00 3128FFDF */ andi $t0, $t1, 0xffdf -/* 0A7404 802E7C04 A2280000 */ sb $t0, ($s1) -/* 0A7408 802E7C08 8FAA0068 */ lw $t2, 0x68($sp) -/* 0A740C 802E7C0C 8D4B0000 */ lw $t3, ($t2) -/* 0A7410 802E7C10 000B6180 */ sll $t4, $t3, 6 -/* 0A7414 802E7C14 000C6FC2 */ srl $t5, $t4, 0x1f -/* 0A7418 802E7C18 15A10038 */ bne $t5, $at, .L80201D0C -/* 0A741C 802E7C1C 00000000 */ nop -/* 0A7420 802E7C20 30A300C0 */ andi $v1, $a1, 0xc0 -/* 0A7424 802E7C24 10600007 */ beqz $v1, .L80201C54 -/* 0A7428 802E7C28 24010040 */ li $at, 64 -/* 0A742C 802E7C2C 10610014 */ beq $v1, $at, .L80201C90 -/* 0A7430 802E7C30 24010080 */ li $at, 128 -/* 0A7434 802E7C34 1061001D */ beq $v1, $at, .L80201CBC -/* 0A7438 802E7C38 02602025 */ move $a0, $s3 -/* 0A743C 802E7C3C 10000026 */ b .L80201CE8 -/* 0A7440 802E7C40 8FA60034 */ lw $a2, 0x34($sp) -.L80201C54: -/* 0A7444 802E7C44 0C0B9DB1 */ jal m64_read_compressed_u16 -/* 0A7448 802E7C48 02002025 */ move $a0, $s0 -/* 0A744C 802E7C4C 8E030000 */ lw $v1, ($s0) -/* 0A7450 802E7C50 3053FFFF */ andi $s3, $v0, 0xffff -/* 0A7454 802E7C54 02602025 */ move $a0, $s3 -/* 0A7458 802E7C58 90660000 */ lbu $a2, ($v1) -/* 0A745C 802E7C5C 246E0001 */ addiu $t6, $v1, 1 -/* 0A7460 802E7C60 AE0E0000 */ sw $t6, ($s0) -/* 0A7464 802E7C64 91CF0000 */ lbu $t7, ($t6) -/* 0A7468 802E7C68 A22F0003 */ sb $t7, 3($s1) -/* 0A746C 802E7C6C 8E180000 */ lw $t8, ($s0) -/* 0A7470 802E7C70 27090001 */ addiu $t1, $t8, 1 -/* 0A7474 802E7C74 AE090000 */ sw $t1, ($s0) -/* 0A7478 802E7C78 10000017 */ b .L80201CE8 -/* 0A747C 802E7C7C A6220036 */ sh $v0, 0x36($s1) -.L80201C90: -/* 0A7480 802E7C80 0C0B9DB1 */ jal m64_read_compressed_u16 -/* 0A7484 802E7C84 02002025 */ move $a0, $s0 -/* 0A7488 802E7C88 8E030000 */ lw $v1, ($s0) -/* 0A748C 802E7C8C 3053FFFF */ andi $s3, $v0, 0xffff -/* 0A7490 802E7C90 02602025 */ move $a0, $s3 -/* 0A7494 802E7C94 90660000 */ lbu $a2, ($v1) -/* 0A7498 802E7C98 24680001 */ addiu $t0, $v1, 1 -/* 0A749C 802E7C9C AE080000 */ sw $t0, ($s0) -/* 0A74A0 802E7CA0 A2200003 */ sb $zero, 3($s1) -/* 0A74A4 802E7CA4 1000000C */ b .L80201CE8 -/* 0A74A8 802E7CA8 A6220036 */ sh $v0, 0x36($s1) -.L80201CBC: -/* 0A74AC 802E7CAC 8E030000 */ lw $v1, ($s0) -/* 0A74B0 802E7CB0 96330036 */ lhu $s3, 0x36($s1) -/* 0A74B4 802E7CB4 90660000 */ lbu $a2, ($v1) -/* 0A74B8 802E7CB8 246A0001 */ addiu $t2, $v1, 1 -/* 0A74BC 802E7CBC AE0A0000 */ sw $t2, ($s0) -/* 0A74C0 802E7CC0 914C0000 */ lbu $t4, ($t2) -/* 0A74C4 802E7CC4 02602025 */ move $a0, $s3 -/* 0A74C8 802E7CC8 A22C0003 */ sb $t4, 3($s1) -/* 0A74CC 802E7CCC 8E0D0000 */ lw $t5, ($s0) -/* 0A74D0 802E7CD0 25AE0001 */ addiu $t6, $t5, 1 -/* 0A74D4 802E7CD4 AE0E0000 */ sw $t6, ($s0) -.L80201CE8: -/* 0A74D8 802E7CD8 44868000 */ mtc1 $a2, $f16 -/* 0A74DC 802E7CDC 325900C0 */ andi $t9, $s2, 0xc0 -/* 0A74E0 802E7CE0 02599023 */ subu $s2, $s2, $t9 -/* 0A74E4 802E7CE4 46808020 */ cvt.s.w $f0, $f16 -/* 0A74E8 802E7CE8 324F00FF */ andi $t7, $s2, 0xff -/* 0A74EC 802E7CEC 01E09025 */ move $s2, $t7 -/* 0A74F0 802E7CF0 46000482 */ mul.s $f18, $f0, $f0 -/* 0A74F4 802E7CF4 10000018 */ b .L80201D68 -/* 0A74F8 802E7CF8 E6320028 */ swc1 $f18, 0x28($s1) -.L80201D0C: -/* 0A74FC 802E7CFC 10600007 */ beqz $v1, .L80201D2C -/* 0A7500 802E7D00 24010040 */ li $at, 64 -/* 0A7504 802E7D04 1061000B */ beq $v1, $at, .L80201D44 -/* 0A7508 802E7D08 24010080 */ li $at, 128 -/* 0A750C 802E7D0C 5061000D */ beql $v1, $at, .L80201D54 -/* 0A7510 802E7D10 96330036 */ lhu $s3, 0x36($s1) -/* 0A7514 802E7D14 1000000C */ b .L80201D58 -/* 0A7518 802E7D18 02602025 */ move $a0, $s3 -.L80201D2C: -/* 0A751C 802E7D1C 0C0B9DB1 */ jal m64_read_compressed_u16 -/* 0A7520 802E7D20 02002025 */ move $a0, $s0 -/* 0A7524 802E7D24 3053FFFF */ andi $s3, $v0, 0xffff -/* 0A7528 802E7D28 A6220036 */ sh $v0, 0x36($s1) -/* 0A752C 802E7D2C 10000006 */ b .L80201D58 -/* 0A7530 802E7D30 02602025 */ move $a0, $s3 -.L80201D44: -/* 0A7534 802E7D34 96330034 */ lhu $s3, 0x34($s1) -/* 0A7538 802E7D38 10000003 */ b .L80201D58 -/* 0A753C 802E7D3C 02602025 */ move $a0, $s3 -/* 0A7540 802E7D40 96330036 */ lhu $s3, 0x36($s1) -.L80201D54: -/* 0A7544 802E7D44 02602025 */ move $a0, $s3 -.L80201D58: -/* 0A7548 802E7D48 325800C0 */ andi $t8, $s2, 0xc0 -/* 0A754C 802E7D4C 02589023 */ subu $s2, $s2, $t8 -/* 0A7550 802E7D50 324900FF */ andi $t1, $s2, 0xff -/* 0A7554 802E7D54 01209025 */ move $s2, $t1 -.L80201D68: -/* 0A7558 802E7D58 92280003 */ lbu $t0, 3($s1) -/* 0A755C 802E7D5C A6240038 */ sh $a0, 0x38($s1) -/* 0A7560 802E7D60 01040019 */ multu $t0, $a0 -/* 0A7564 802E7D64 00005012 */ mflo $t2 -/* 0A7568 802E7D68 000A5A03 */ sra $t3, $t2, 8 -/* 0A756C 802E7D6C A62B003A */ sh $t3, 0x3a($s1) -/* 0A7570 802E7D70 8E8C0000 */ lw $t4, ($s4) -/* 0A7574 802E7D74 8FB90068 */ lw $t9, 0x68($sp) -/* 0A7578 802E7D78 8FA90068 */ lw $t1, 0x68($sp) -/* 0A757C 802E7D7C 000C7080 */ sll $t6, $t4, 2 -/* 0A7580 802E7D80 05C10005 */ bgez $t6, .L80201DA8 -/* 0A7584 802E7D84 8FAC0068 */ lw $t4, 0x68($sp) -/* 0A7588 802E7D88 932F0003 */ lbu $t7, 3($t9) -/* 0A758C 802E7D8C 31F80040 */ andi $t8, $t7, 0x40 -/* 0A7590 802E7D90 57000007 */ bnezl $t8, .L80201DC0 -/* 0A7594 802E7D94 922D0000 */ lbu $t5, ($s1) -.L80201DA8: -/* 0A7598 802E7D98 8D280000 */ lw $t0, ($t1) -/* 0A759C 802E7D9C 8FB90068 */ lw $t9, 0x68($sp) -/* 0A75A0 802E7DA0 000858C0 */ sll $t3, $t0, 3 -/* 0A75A4 802E7DA4 05630006 */ bgezl $t3, .L80201DD0 -/* 0A75A8 802E7DA8 92230001 */ lbu $v1, 1($s1) -/* 0A75AC 802E7DAC 922D0000 */ lbu $t5, ($s1) -.L80201DC0: -/* 0A75B0 802E7DB0 35AE0020 */ ori $t6, $t5, 0x20 -/* 0A75B4 802E7DB4 100000B4 */ b .L80202098 -/* 0A75B8 802E7DB8 A22E0000 */ sb $t6, ($s1) -/* 0A75BC 802E7DBC 92230001 */ lbu $v1, 1($s1) -.L80201DD0: -/* 0A75C0 802E7DC0 240100FF */ li $at, 255 -/* 0A75C4 802E7DC4 14610002 */ bne $v1, $at, .L80201DE0 -/* 0A75C8 802E7DC8 00601025 */ move $v0, $v1 -/* 0A75CC 802E7DCC 8722001C */ lh $v0, 0x1c($t9) -.L80201DE0: -/* 0A75D0 802E7DD0 5440001D */ bnezl $v0, .L80201E58 -/* 0A75D4 802E7DD4 868F000C */ lh $t7, 0xc($s4) -/* 0A75D8 802E7DD8 8FAF0068 */ lw $t7, 0x68($sp) -/* 0A75DC 802E7DDC 86280022 */ lh $t0, 0x22($s1) -/* 0A75E0 802E7DE0 85F8001E */ lh $t8, 0x1e($t7) -/* 0A75E4 802E7DE4 91E40006 */ lbu $a0, 6($t7) -/* 0A75E8 802E7DE8 02584821 */ addu $t1, $s2, $t8 -/* 0A75EC 802E7DEC 01289021 */ addu $s2, $t1, $t0 -/* 0A75F0 802E7DF0 0C0B93EE */ jal get_drum -/* 0A75F4 802E7DF4 324500FF */ andi $a1, $s2, 0xff -/* 0A75F8 802E7DF8 14400005 */ bnez $v0, .L80201E20 -/* 0A75FC 802E7DFC 24430004 */ addiu $v1, $v0, 4 -/* 0A7600 802E7E00 922C0000 */ lbu $t4, ($s1) -/* 0A7604 802E7E04 358D0020 */ ori $t5, $t4, 0x20 -/* 0A7608 802E7E08 1000009D */ b .L80202090 -/* 0A760C 802E7E0C A22D0000 */ sb $t5, ($s1) -.L80201E20: -/* 0A7610 802E7E10 8C4E000C */ lw $t6, 0xc($v0) -/* 0A7614 802E7E14 8E380000 */ lw $t8, ($s1) -/* 0A7618 802E7E18 AE2E001C */ sw $t6, 0x1c($s1) -/* 0A761C 802E7E1C 90590000 */ lbu $t9, ($v0) -/* 0A7620 802E7E20 00184180 */ sll $t0, $t8, 6 -/* 0A7624 802E7E24 05000003 */ bltz $t0, .L80201E44 -/* 0A7628 802E7E28 A2390018 */ sb $t9, 0x18($s1) -/* 0A762C 802E7E2C 904A0001 */ lbu $t2, 1($v0) -/* 0A7630 802E7E30 A22A0005 */ sb $t2, 5($s1) -.L80201E44: -/* 0A7634 802E7E34 AE230048 */ sw $v1, 0x48($s1) # AudioBankSound -/* 0A7638 802E7E38 C4640004 */ lwc1 $f4, 4($v1) # AudioBankSound.tuning -/* 0A763C 802E7E3C 10000090 */ b .L80202090 -/* 0A7640 802E7E40 E6240024 */ swc1 $f4, 0x24($s1) -/* 0A7644 802E7E44 868F000C */ lh $t7, 0xc($s4) -.L80201E58: -/* 0A7648 802E7E48 858D001E */ lh $t5, 0x1e($t4) -/* 0A764C 802E7E4C 86390022 */ lh $t9, 0x22($s1) -/* 0A7650 802E7E50 024F5821 */ addu $t3, $s2, $t7 -/* 0A7654 802E7E54 016D7021 */ addu $t6, $t3, $t5 -/* 0A7658 802E7E58 01D99021 */ addu $s2, $t6, $t9 -/* 0A765C 802E7E5C 324500FF */ andi $a1, $s2, 0xff # a1 = s2 & 0xff -/* 0A7660 802E7E60 28A10080 */ slti $at, $a1, 0x80 -/* 0A7664 802E7E64 14200005 */ bnez $at, .L80201E8C -/* 0A7668 802E7E68 00A09025 */ move $s2, $a1 -/* 0A766C 802E7E6C 92280000 */ lbu $t0, ($s1) -/* 0A7670 802E7E70 350A0020 */ ori $t2, $t0, 0x20 -/* 0A7674 802E7E74 10000082 */ b .L80202090 -/* 0A7678 802E7E78 A22A0000 */ sb $t2, ($s1) -.L80201E8C: -/* 0A767C 802E7E7C 240100FF */ li $at, 255 -/* 0A7680 802E7E80 14610003 */ bne $v1, $at, .L80201EA0 -/* 0A7684 802E7E84 8FAF0068 */ lw $t7, 0x68($sp) -/* 0A7688 802E7E88 10000002 */ b .L80201EA4 -/* 0A768C 802E7E8C 8DE40040 */ lw $a0, 0x40($t7) # SequenceChannel.Instrument -.L80201EA0: -/* 0A7690 802E7E90 8E240044 */ lw $a0, 0x44($s1) # SequenceChannelLayer.Instrument -.L80201EA4: -/* 0A7694 802E7E94 922C0008 */ lbu $t4, 8($s1) # SequenceChannelLayer.portamento -/* 0A7698 802E7E98 11800061 */ beqz $t4, .L80202030 -/* 0A769C 802E7E9C 00000000 */ nop -/* 0A76A0 802E7EA0 92220004 */ lbu $v0, 4($s1) # SequenceChannelLayer.portamentoTargetNote -/* 0A76A4 802E7EA4 0045082A */ slt $at, $v0, $a1 -/* 0A76A8 802E7EA8 10200003 */ beqz $at, .L80201EC8 -/* 0A76AC 802E7EAC 00403025 */ move $a2, $v0 # arg1 = min(portamentoTargetNote, a1) -/* 0A76B0 802E7EB0 10000001 */ b .L80201EC8 -/* 0A76B4 802E7EB4 00A03025 */ move $a2, $a1 -.L80201EC8: -/* 0A76B8 802E7EB8 1080000A */ beqz $a0, .L80201EF4 -/* 0A76BC 802E7EBC 3C013F80 */ li $at, 0x3F800000 # 1.000000 -/* 0A76C0 802E7EC0 0C0B9397 */ jal instrument_get_audio_bank_sound -/* 0A76C4 802E7EC4 00C02825 */ move $a1, $a2 -/* 0A76C8 802E7EC8 8E2B0048 */ lw $t3, 0x48($s1) -/* 0A76CC 802E7ECC 004B6826 */ xor $t5, $v0, $t3 -/* 0A76D0 802E7ED0 2DAD0001 */ sltiu $t5, $t5, 1 -/* 0A76D4 802E7ED4 AFAD0044 */ sw $t5, 0x44($sp) -/* 0A76D8 802E7ED8 AE220048 */ sw $v0, 0x48($s1) -/* 0A76DC 802E7EDC 10000003 */ b .L80201EFC -/* 0A76E0 802E7EE0 C4400004 */ lwc1 $f0, 4($v0) -.L80201EF4: -/* 0A76E4 802E7EE4 44810000 */ mtc1 $at, $f0 -/* 0A76E8 802E7EE8 AE200048 */ sw $zero, 0x48($s1) -.L80201EFC: -/* 0A76EC 802E7EEC 3C038030 */ lui $v1, %hi(gNoteFrequencies) # $v1, 0x8030 -/* 0A76F0 802E7EF0 92380004 */ lbu $t8, 4($s1) -/* 0A76F4 802E7EF4 24630AE8 */ addiu $v1, %lo(gNoteFrequencies) # addiu $v1, $v1, 0xae8 -/* 0A76F8 802E7EF8 00127080 */ sll $t6, $s2, 2 -/* 0A76FC 802E7EFC 006EC821 */ addu $t9, $v1, $t6 -/* 0A7700 802E7F00 C7260000 */ lwc1 $f6, ($t9) -/* 0A7704 802E7F04 922A0008 */ lbu $t2, 8($s1) -/* 0A7708 802E7F08 00184880 */ sll $t1, $t8, 2 -/* 0A770C 802E7F0C 00694021 */ addu $t0, $v1, $t1 -/* 0A7710 802E7F10 C5080000 */ lwc1 $f8, ($t0) -/* 0A7714 802E7F14 46003082 */ mul.s $f2, $f6, $f0 -/* 0A7718 802E7F18 2401FF7F */ li $at, -129 -/* 0A771C 802E7F1C 01417824 */ and $t7, $t2, $at -/* 0A7720 802E7F20 25ECFFFF */ addiu $t4, $t7, -1 -/* 0A7724 802E7F24 2D810005 */ sltiu $at, $t4, 5 -/* 0A7728 802E7F28 46004302 */ mul.s $f12, $f8, $f0 -/* 0A772C 802E7F2C 10200008 */ beqz $at, .L_EU_802E7F50 -/* 0A7730 802E7F30 000C6080 */ sll $t4, $t4, 2 -/* 0A7734 802E7F34 3C018030 */ lui $at, %hi(jtbl_EU_80306700) -/* 0A7738 802E7F38 002C0821 */ addu $at, $at, $t4 -/* 0A773C 802E7F3C 8C2C6700 */ lw $t4, %lo(jtbl_EU_80306700)($at) -/* 0A7740 802E7F40 01800008 */ jr $t4 -/* 0A7744 802E7F44 00000000 */ nop -glabel L_EU_802E7F48 -/* 0A7748 802E7F48 10000002 */ b .L80201F64 -/* 0A774C 802E7F4C 46006006 */ mov.s $f0, $f12 -glabel L_EU_802E7F50 -.L_EU_802E7F50: -/* 0A7750 802E7F50 46001006 */ mov.s $f0, $f2 -.L80201F64: -/* 0A7754 802E7F54 46001283 */ div.s $f10, $f2, $f0 -/* 0A7758 802E7F58 3C013F80 */ li $at, 0x3F800000 # 1.000000 -/* 0A775C 802E7F5C 44818000 */ mtc1 $at, $f16 -/* 0A7760 802E7F60 26220008 */ addiu $v0, $s1, 8 -/* 0A7764 802E7F64 3C0146FE */ li $at, 0x46FE0000 # 32512.000000 -/* 0A7768 802E7F68 46105481 */ sub.s $f18, $f10, $f16 -/* 0A776C 802E7F6C E452000C */ swc1 $f18, 0xc($v0) -/* 0A7770 802E7F70 922B0008 */ lbu $t3, 8($s1) -/* 0A7774 802E7F74 316D0080 */ andi $t5, $t3, 0x80 -/* 0A7778 802E7F78 51A00017 */ beql $t5, $zero, .L80201FE8 -/* 0A777C 802E7F7C 96280020 */ lhu $t0, 0x20($s1) -/* 0A7780 802E7F80 968E0008 */ lhu $t6, 8($s4) -/* 0A7784 802E7F84 3C188023 */ lui $t8, %hi(gTempoInternalToExternal) # $t8, 0x8023 -/* 0A7788 802E7F88 8718980C */ lh $t8, %lo(gTempoInternalToExternal)($t8) -/* 0A778C 802E7F8C 448E2000 */ mtc1 $t6, $f4 -/* 0A7790 802E7F90 86390038 */ lh $t9, 0x38($s1) -/* 0A7794 802E7F94 44814000 */ mtc1 $at, $f8 -/* 0A7798 802E7F98 468021A0 */ cvt.s.w $f6, $f4 -/* 0A779C 802E7F9C 44982000 */ mtc1 $t8, $f4 -/* 0A77A0 802E7FA0 44998000 */ mtc1 $t9, $f16 -/* 0A77A4 802E7FA4 96290020 */ lhu $t1, 0x20($s1) -/* 0A77A8 802E7FA8 468084A0 */ cvt.s.w $f18, $f16 -/* 0A77AC 802E7FAC 46083282 */ mul.s $f10, $f6, $f8 -/* 0A77B0 802E7FB0 44898000 */ mtc1 $t1, $f16 -/* 0A77B4 802E7FB4 468021A0 */ cvt.s.w $f6, $f4 -/* 0A77B8 802E7FB8 46808120 */ cvt.s.w $f4, $f16 -/* 0A77BC 802E7FBC 46069202 */ mul.s $f8, $f18, $f6 -/* 0A77C0 802E7FC0 00000000 */ nop -/* 0A77C4 802E7FC4 46044482 */ mul.s $f18, $f8, $f4 -/* 0A77C8 802E7FC8 46125183 */ div.s $f6, $f10, $f18 -/* 0A77CC 802E7FCC 10000009 */ b .L80202004 -/* 0A77D0 802E7FD0 E4460008 */ swc1 $f6, 8($v0) -/* 0A77D4 802E7FD4 96280020 */ lhu $t0, 0x20($s1) -.L80201FE8: -/* 0A77D8 802E7FD8 3C0142FE */ li $at, 0x42FE0000 # 127.000000 -/* 0A77DC 802E7FDC 44818000 */ mtc1 $at, $f16 -/* 0A77E0 802E7FE0 44884000 */ mtc1 $t0, $f8 -/* 0A77E4 802E7FE4 00000000 */ nop -/* 0A77E8 802E7FE8 46804120 */ cvt.s.w $f4, $f8 -/* 0A77EC 802E7FEC 46048283 */ div.s $f10, $f16, $f4 -/* 0A77F0 802E7FF0 E44A0008 */ swc1 $f10, 8($v0) -.L80202004: -/* 0A77F4 802E7FF4 44809000 */ mtc1 $zero, $f18 -/* 0A77F8 802E7FF8 2401FF7F */ li $at, -129 -/* 0A77FC 802E7FFC E4520004 */ swc1 $f18, 4($v0) -/* 0A7800 802E8000 922A0008 */ lbu $t2, 8($s1) -/* 0A7804 802E8004 E6200024 */ swc1 $f0, 0x24($s1) -/* 0A7808 802E8008 01417824 */ and $t7, $t2, $at -/* 0A780C 802E800C 24010005 */ li $at, 5 -/* 0A7810 802E8010 55E1001C */ bnel $t7, $at, .L80202094 -/* 0A7814 802E8014 86290038 */ lh $t1, 0x38($s1) -/* 0A7818 802E8018 10000019 */ b .L80202090 -/* 0A781C 802E801C A2320004 */ sb $s2, 4($s1) -.L80202030: -/* 0A7820 802E8020 10800011 */ beqz $a0, .L80202078 -/* 0A7824 802E8024 3C038030 */ lui $v1, %hi(gNoteFrequencies) -/* 0A7828 802E8028 0C0B9397 */ jal instrument_get_audio_bank_sound -/* 0A782C 802E802C 00000000 */ nop -/* 0A7830 802E8030 8E2C0048 */ lw $t4, 0x48($s1) -/* 0A7834 802E8034 3C038030 */ lui $v1, %hi(gNoteFrequencies) # $v1, 0x8030 -/* 0A7838 802E8038 24630AE8 */ addiu $v1, %lo(gNoteFrequencies) # addiu $v1, $v1, 0xae8 -/* 0A783C 802E803C 004C5826 */ xor $t3, $v0, $t4 -/* 0A7840 802E8040 2D6B0001 */ sltiu $t3, $t3, 1 -/* 0A7844 802E8044 AFAB0044 */ sw $t3, 0x44($sp) -/* 0A7848 802E8048 AE220048 */ sw $v0, 0x48($s1) -/* 0A784C 802E804C 00126880 */ sll $t5, $s2, 2 -/* 0A7850 802E8050 006D7021 */ addu $t6, $v1, $t5 -/* 0A7854 802E8054 C5C60000 */ lwc1 $f6, ($t6) -/* 0A7858 802E8058 C4480004 */ lwc1 $f8, 4($v0) -/* 0A785C 802E805C 46083402 */ mul.s $f16, $f6, $f8 -/* 0A7860 802E8060 10000007 */ b .L80202090 -/* 0A7864 802E8064 E6300024 */ swc1 $f16, 0x24($s1) -.L80202078: -/* 0A7868 802E8068 24630AE8 */ addiu $v1, $v1, 0xae8 -/* 0A786C 802E806C 0012C880 */ sll $t9, $s2, 2 -/* 0A7870 802E8070 AE200048 */ sw $zero, 0x48($s1) -/* 0A7874 802E8074 0079C021 */ addu $t8, $v1, $t9 -/* 0A7878 802E8078 C7040000 */ lwc1 $f4, ($t8) -/* 0A787C 802E807C E6240024 */ swc1 $f4, 0x24($s1) -.L80202090: -/* 0A7880 802E8080 86290038 */ lh $t1, 0x38($s1) -.L80202094: -/* 0A7884 802E8084 A629003C */ sh $t1, 0x3c($s1) -.L80202098: -/* 0A7888 802E8088 8E220000 */ lw $v0, ($s1) -/* 0A788C 802E808C 24010001 */ li $at, 1 -/* 0A7890 802E8090 00024080 */ sll $t0, $v0, 2 -/* 0A7894 802E8094 000857C2 */ srl $t2, $t0, 0x1f -/* 0A7898 802E8098 1541000B */ bne $t2, $at, .L802020D8 -/* 0A789C 802E809C 000270C0 */ sll $t6, $v0, 3 -/* 0A78A0 802E80A0 8E2F0040 */ lw $t7, 0x40($s1) -/* 0A78A4 802E80A4 000258C0 */ sll $t3, $v0, 3 -/* 0A78A8 802E80A8 15E00003 */ bnez $t7, .L802020C8 -/* 0A78AC 802E80AC 00000000 */ nop -/* 0A78B0 802E80B0 05630030 */ bgezl $t3, .L80202184 -/* 0A78B4 802E80B4 8FBF002C */ lw $ra, 0x2c($sp) -.L802020C8: -/* 0A78B8 802E80B8 0C0B95B3 */ jal seq_channel_layer_note_decay -/* 0A78BC 802E80BC 02202025 */ move $a0, $s1 -/* 0A78C0 802E80C0 1000002C */ b .L80202184 -/* 0A78C4 802E80C4 8FBF002C */ lw $ra, 0x2c($sp) -.L802020D8: -/* 0A78C8 802E80C8 05C00003 */ bltz $t6, .L802020E8 -/* 0A78CC 802E80CC 00009025 */ move $s2, $zero -/* 0A78D0 802E80D0 1000001A */ b .L8020214C -/* 0A78D4 802E80D4 24120001 */ li $s2, 1 -.L802020E8: -/* 0A78D8 802E80D8 8E240040 */ lw $a0, 0x40($s1) -/* 0A78DC 802E80DC 10800005 */ beqz $a0, .L80202104 -/* 0A78E0 802E80E0 00000000 */ nop -/* 0A78E4 802E80E4 92390002 */ lbu $t9, 2($s1) -/* 0A78E8 802E80E8 8FB80044 */ lw $t8, 0x44($sp) -/* 0A78EC 802E80EC 17200003 */ bnez $t9, .L8020210C -/* 0A78F0 802E80F0 00000000 */ nop -.L80202104: -/* 0A78F4 802E80F4 10000011 */ b .L8020214C -/* 0A78F8 802E80F8 24120001 */ li $s2, 1 -.L8020210C: -/* 0A78FC 802E80FC 57000006 */ bnezl $t8, .L80202128 -/* 0A7900 802E8100 8C890044 */ lw $t1, 0x44($a0) -/* 0A7904 802E8104 0C0B95B3 */ jal seq_channel_layer_note_decay -/* 0A7908 802E8108 02202025 */ move $a0, $s1 -/* 0A790C 802E810C 1000000B */ b .L8020214C -/* 0A7910 802E8110 24120001 */ li $s2, 1 -/* 0A7914 802E8114 8C890044 */ lw $t1, 0x44($a0) -.L80202128: -/* 0A7918 802E8118 52290004 */ beql $s1, $t1, .L8020213C -/* 0A791C 802E811C 8E280048 */ lw $t0, 0x48($s1) -/* 0A7920 802E8120 10000006 */ b .L8020214C -/* 0A7924 802E8124 24120001 */ li $s2, 1 -/* 0A7928 802E8128 8E280048 */ lw $t0, 0x48($s1) -.L8020213C: -/* 0A792C 802E812C 15000003 */ bnez $t0, .L8020214C -/* 0A7930 802E8130 00000000 */ nop -/* 0A7934 802E8134 0C0B9604 */ jal init_synthetic_wave -/* 0A7938 802E8138 02202825 */ move $a1, $s1 -.L8020214C: -/* 0A793C 802E813C 52400005 */ beql $s2, $zero, .L80202164 -/* 0A7940 802E8140 8E240040 */ lw $a0, 0x40($s1) -/* 0A7944 802E8144 0C0B97FC */ jal alloc_note -/* 0A7948 802E8148 02202025 */ move $a0, $s1 -/* 0A794C 802E814C AE220040 */ sw $v0, 0x40($s1) -/* 0A7950 802E8150 8E240040 */ lw $a0, 0x40($s1) -.L80202164: -/* 0A7954 802E8154 50800007 */ beql $a0, $zero, .L80202184 -/* 0A7958 802E8158 8FBF002C */ lw $ra, 0x2c($sp) -/* 0A795C 802E815C 8C8A0044 */ lw $t2, 0x44($a0) -/* 0A7960 802E8160 562A0004 */ bnel $s1, $t2, .L80202184 -/* 0A7964 802E8164 8FBF002C */ lw $ra, 0x2c($sp) -/* 0A7968 802E8168 0C0B9AA0 */ jal note_vibrato_init -/* 0A796C 802E816C 00000000 */ nop -.L80202180: -/* 0A7970 802E8170 8FBF002C */ lw $ra, 0x2c($sp) -.L80202184: -/* 0A7974 802E8174 8FB00018 */ lw $s0, 0x18($sp) -/* 0A7978 802E8178 8FB1001C */ lw $s1, 0x1c($sp) -/* 0A797C 802E817C 8FB20020 */ lw $s2, 0x20($sp) -/* 0A7980 802E8180 8FB30024 */ lw $s3, 0x24($sp) -/* 0A7984 802E8184 8FB40028 */ lw $s4, 0x28($sp) -/* 0A7988 802E8188 03E00008 */ jr $ra -/* 0A798C 802E818C 27BD0070 */ addiu $sp, $sp, 0x70 diff --git a/asm/non_matchings/eu/audio/sequence_channel_process_script.s b/asm/non_matchings/eu/audio/sequence_channel_process_script.s index 802f5b15..30649af9 100644 --- a/asm/non_matchings/eu/audio/sequence_channel_process_script.s +++ b/asm/non_matchings/eu/audio/sequence_channel_process_script.s @@ -1,129 +1,129 @@ .late_rodata .late_rodata_alignment 4 glabel jtbl_EU_80306714 - .word L_EU_802E8650 - .word L_EU_802E85A0, L_EU_802E866C - .word L_EU_802E867C, L_EU_802E85BC - .word L_EU_802E8888, L_EU_802E88E4 - .word L_EU_802E891C, L_EU_802E891C - .word L_EU_802E8968, L_EU_802E8978 - .word L_EU_802E891C, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8998, L_EU_802E89BC - .word L_EU_802E89CC, L_EU_802E8714 - .word L_EU_802E8878, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E87E0 - .word L_EU_802E87C4, L_EU_802E87B4 - .word L_EU_802E8798, L_EU_802E8780 - .word L_EU_802E8764, L_EU_802E8748 - .word L_EU_802E86E0, L_EU_802E868C - .word L_EU_802E86B0, L_EU_802E8830 - .word L_EU_802E87FC, L_EU_802E8864 - .word L_EU_802E89EC, L_EU_802E89DC - .word L_EU_802E8A48, L_EU_802E8A58 - .word L_EU_802E8AC0, L_EU_802E8B60 - .word L_EU_802E83EC, L_EU_802E85F8 - .word L_EU_802E8B38, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8590, L_EU_802E8568 - .word L_EU_802E8520, L_EU_802E8520 - .word L_EU_802E8520, L_EU_802E84C8 - .word L_EU_802E84B8, L_EU_802E8470 - .word L_EU_802E8438, L_EU_802E84C8 - .word L_EU_802E84C8, L_EU_802E84C8 - .word L_EU_802E83FC, L_EU_802E83DC - .word L_EU_802E8D98, L_EU_802E83A4 + .word L802E8650 + .word L802E85A0, L802E866C + .word L802E867C, L802E85BC + .word L802E8888, L802E88E4 + .word L802E891C, L802E891C + .word L802E8968, L802E8978 + .word L802E891C, L802E8368 + .word L802E8368, L802E8368 + .word L802E8998, L802E89BC + .word L802E89CC, L802E8714 + .word L802E8878, L802E8368 + .word L802E8368, L802E87E0 + .word L802E87C4, L802E87B4 + .word L802E8798, L802E8780 + .word L802E8764, L802E8748 + .word L802E86E0, L802E868C + .word L802E86B0, L802E8830 + .word L802E87FC, L802E8864 + .word L802E89EC, L802E89DC + .word L802E8A48, L802E8A58 + .word L802E8AC0, L802E8B60 + .word L802E83EC, L802E85F8 + .word L802E8B38, L802E8368 + .word L802E8368, L802E8368 + .word L802E8590, L802E8568 + .word L802E8520, L802E8520 + .word L802E8520, L802E84C8 + .word L802E84B8, L802E8470 + .word L802E8438, L802E84C8 + .word L802E84C8, L802E84C8 + .word L802E83FC, L802E83DC + .word L802E8D98, L802E83A4 glabel jtbl_EU_80306810 - .word L_EU_802E8B9C, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8CFC, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8D2C, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8D48, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8D70, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8C04, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8C20, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8BD4, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8BE4, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8C2C, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8C78, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8368, L_EU_802E8368 - .word L_EU_802E8C94 + .word L802E8B9C, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8CFC, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8D2C, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8D48, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8D70, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8C04, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8C20, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8BD4, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8BE4, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8C2C, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8C78, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8368, L802E8368 + .word L802E8C94 .text glabel sequence_channel_process_script @@ -137,89 +137,89 @@ glabel sequence_channel_process_script /* 0A7AD4 802E82D4 8C820000 */ lw $v0, ($a0) /* 0A7AD8 802E82D8 00809025 */ move $s2, $a0 /* 0A7ADC 802E82DC 000277C2 */ srl $t6, $v0, 0x1f -/* 0A7AE0 802E82E0 11C002B8 */ beqz $t6, .L080200BC4 +/* 0A7AE0 802E82E0 11C002B8 */ beqz $t6, .L80200BC4 /* 0A7AE4 802E82E4 0002C080 */ sll $t8, $v0, 2 -/* 0A7AE8 802E82E8 0701000D */ bgez $t8, .L080200120 +/* 0A7AE8 802E82E8 0701000D */ bgez $t8, .L80200120 /* 0A7AEC 802E82EC 00008025 */ move $s0, $zero /* 0A7AF0 802E82F0 00808825 */ move $s1, $a0 /* 0A7AF4 802E82F4 24120010 */ li $s2, 16 -.L0802000F8: +.L802000F8: /* 0A7AF8 802E82F8 8E240048 */ lw $a0, 0x48($s1) -/* 0A7AFC 802E82FC 50800004 */ beql $a0, $zero, .L080200110 +/* 0A7AFC 802E82FC 50800004 */ beql $a0, $zero, .L80200110 /* 0A7B00 802E8300 26100004 */ addiu $s0, $s0, 4 /* 0A7B04 802E8304 0C0B9DC2 */ jal seq_channel_layer_process_script /* 0A7B08 802E8308 00000000 */ nop /* 0A7B0C 802E830C 26100004 */ addiu $s0, $s0, 4 -.L080200110: -/* 0A7B10 802E8310 1612FFF9 */ bne $s0, $s2, .L0802000F8 +.L80200110: +/* 0A7B10 802E8310 1612FFF9 */ bne $s0, $s2, .L802000F8 /* 0A7B14 802E8314 26310004 */ addiu $s1, $s1, 4 -/* 0A7B18 802E8318 100002AB */ b .L080200BC8 +/* 0A7B18 802E8318 100002AB */ b .L80200BC8 /* 0A7B1C 802E831C 8FBF002C */ lw $ra, 0x2c($sp) -.L080200120: +.L80200120: /* 0A7B20 802E8320 8E540044 */ lw $s4, 0x44($s2) /* 0A7B24 802E8324 8E990000 */ lw $t9, ($s4) /* 0A7B28 802E8328 00195080 */ sll $t2, $t9, 2 -/* 0A7B2C 802E832C 05430006 */ bgezl $t2, .L080200148 +/* 0A7B2C 802E832C 05430006 */ bgezl $t2, .L80200148 /* 0A7B30 802E8330 9643001A */ lhu $v1, 0x1a($s2) /* 0A7B34 802E8334 924B0003 */ lbu $t3, 3($s2) /* 0A7B38 802E8338 316C0080 */ andi $t4, $t3, 0x80 -/* 0A7B3C 802E833C 558002A2 */ bnezl $t4, .L080200BC8 +/* 0A7B3C 802E833C 558002A2 */ bnezl $t4, .L80200BC8 /* 0A7B40 802E8340 8FBF002C */ lw $ra, 0x2c($sp) /* 0A7B44 802E8344 9643001A */ lhu $v1, 0x1a($s2) -.L080200148: +.L80200148: /* 0A7B48 802E8348 26510060 */ addiu $s1, $s2, 0x60 -/* 0A7B4C 802E834C 10600004 */ beqz $v1, .L080200160 +/* 0A7B4C 802E834C 10600004 */ beqz $v1, .L80200160 /* 0A7B50 802E8350 00601025 */ move $v0, $v1 /* 0A7B54 802E8354 246DFFFF */ addiu $t5, $v1, -1 /* 0A7B58 802E8358 A64D001A */ sh $t5, 0x1a($s2) /* 0A7B5C 802E835C 31A2FFFF */ andi $v0, $t5, 0xffff -.L080200160: -/* 0A7B60 802E8360 1440028D */ bnez $v0, .L_EU_802E8D98 +.L80200160: +/* 0A7B60 802E8360 1440028D */ bnez $v0, .L802E8D98 /* 0A7B64 802E8364 83B3004B */ lb $s3, 0x4b($sp) -glabel L_EU_802E8368 -.L_EU_802E8368: +glabel L802E8368 +.L802E8368: /* 0A7B68 802E8368 0C0B9DA0 */ jal m64_read_u8 /* 0A7B6C 802E836C 02202025 */ move $a0, $s1 /* 0A7B70 802E8370 284100C1 */ slti $at, $v0, 0xc1 /* 0A7B74 802E8374 305000FF */ andi $s0, $v0, 0xff -/* 0A7B78 802E8378 142001FD */ bnez $at, .L080200970 +/* 0A7B78 802E8378 142001FD */ bnez $at, .L80200970 /* 0A7B7C 802E837C 00401825 */ move $v1, $v0 /* 0A7B80 802E8380 244EFF3F */ addiu $t6, $v0, -0xc1 /* 0A7B84 802E8384 2DC1003F */ sltiu $at, $t6, 0x3f -/* 0A7B88 802E8388 1020FFF7 */ beqz $at, .L_EU_802E8368 +/* 0A7B88 802E8388 1020FFF7 */ beqz $at, .L802E8368 /* 0A7B8C 802E838C 000E7080 */ sll $t6, $t6, 2 /* 0A7B90 802E8390 3C018030 */ lui $at, %hi(jtbl_EU_80306714) /* 0A7B94 802E8394 002E0821 */ addu $at, $at, $t6 /* 0A7B98 802E8398 8C2E6714 */ lw $t6, %lo(jtbl_EU_80306714)($at) /* 0A7B9C 802E839C 01C00008 */ jr $t6 /* 0A7BA0 802E83A0 00000000 */ nop -glabel L_EU_802E83A4 +glabel L802E83A4 /* 0A7BA4 802E83A4 92240018 */ lbu $a0, 0x18($s1) -/* 0A7BA8 802E83A8 14800005 */ bnez $a0, .L0802001C0 +/* 0A7BA8 802E83A8 14800005 */ bnez $a0, .L802001C0 /* 0A7BAC 802E83AC 2482FFFF */ addiu $v0, $a0, -1 /* 0A7BB0 802E83B0 0C0B9C41 */ jal sequence_channel_disable /* 0A7BB4 802E83B4 02402025 */ move $a0, $s2 -/* 0A7BB8 802E83B8 10000278 */ b .L080200B9C +/* 0A7BB8 802E83B8 10000278 */ b .L80200B9C /* 0A7BBC 802E83BC 02408825 */ move $s1, $s2 -.L0802001C0: +.L802001C0: /* 0A7BC0 802E83C0 304F00FF */ andi $t7, $v0, 0xff /* 0A7BC4 802E83C4 000FC080 */ sll $t8, $t7, 2 /* 0A7BC8 802E83C8 0238C821 */ addu $t9, $s1, $t8 /* 0A7BCC 802E83CC A22F0018 */ sb $t7, 0x18($s1) /* 0A7BD0 802E83D0 8F290004 */ lw $t1, 4($t9) -/* 0A7BD4 802E83D4 1000FFE4 */ b .L_EU_802E8368 +/* 0A7BD4 802E83D4 1000FFE4 */ b .L802E8368 /* 0A7BD8 802E83D8 AE290000 */ sw $t1, ($s1) -glabel L_EU_802E83DC +glabel L802E83DC /* 0A7BDC 802E83DC 0C0B9DB1 */ jal m64_read_compressed_u16 /* 0A7BE0 802E83E0 02202025 */ move $a0, $s1 -/* 0A7BE4 802E83E4 1000026C */ b .L_EU_802E8D98 +/* 0A7BE4 802E83E4 1000026C */ b .L802E8D98 /* 0A7BE8 802E83E8 A642001A */ sh $v0, 0x1a($s2) -glabel L_EU_802E83EC +glabel L802E83EC /* 0A7BEC 802E83EC 924B0000 */ lbu $t3, ($s2) /* 0A7BF0 802E83F0 356C0020 */ ori $t4, $t3, 0x20 -/* 0A7BF4 802E83F4 10000268 */ b .L_EU_802E8D98 +/* 0A7BF4 802E83F4 10000268 */ b .L802E8D98 /* 0A7BF8 802E83F8 A24C0000 */ sb $t4, ($s2) -glabel L_EU_802E83FC +glabel L802E83FC /* 0A7BFC 802E83FC 0C0B9DA5 */ jal m64_read_s16 /* 0A7C00 802E8400 02202025 */ move $a0, $s1 /* 0A7C04 802E8404 922E0018 */ lbu $t6, 0x18($s1) @@ -233,9 +233,9 @@ glabel L_EU_802E83FC /* 0A7C24 802E8424 A2290018 */ sb $t1, 0x18($s1) /* 0A7C28 802E8428 8E8A0014 */ lw $t2, 0x14($s4) /* 0A7C2C 802E842C 014B6021 */ addu $t4, $t2, $t3 -/* 0A7C30 802E8430 1000FFCD */ b .L_EU_802E8368 +/* 0A7C30 802E8430 1000FFCD */ b .L802E8368 /* 0A7C34 802E8434 AE2C0000 */ sw $t4, ($s1) -glabel L_EU_802E8438 +glabel L802E8438 /* 0A7C38 802E8438 0C0B9DA0 */ jal m64_read_u8 /* 0A7C3C 802E843C 02202025 */ move $a0, $s1 /* 0A7C40 802E8440 922E0018 */ lbu $t6, 0x18($s1) @@ -248,9 +248,9 @@ glabel L_EU_802E8438 /* 0A7C5C 802E845C AD2D0004 */ sw $t5, 4($t1) /* 0A7C60 802E8460 922A0018 */ lbu $t2, 0x18($s1) /* 0A7C64 802E8464 254B0001 */ addiu $t3, $t2, 1 -/* 0A7C68 802E8468 1000FFBF */ b .L_EU_802E8368 +/* 0A7C68 802E8468 1000FFBF */ b .L802E8368 /* 0A7C6C 802E846C A22B0018 */ sb $t3, 0x18($s1) -glabel L_EU_802E8470 +glabel L802E8470 /* 0A7C70 802E8470 922C0018 */ lbu $t4, 0x18($s1) /* 0A7C74 802E8474 022C1021 */ addu $v0, $s1, $t4 /* 0A7C78 802E8478 904E0013 */ lbu $t6, 0x13($v0) @@ -261,68 +261,68 @@ glabel L_EU_802E8470 /* 0A7C8C 802E848C 93190013 */ lbu $t9, 0x13($t8) /* 0A7C90 802E8490 00801825 */ move $v1, $a0 /* 0A7C94 802E8494 00036880 */ sll $t5, $v1, 2 -/* 0A7C98 802E8498 13200005 */ beqz $t9, .L0802002B0 +/* 0A7C98 802E8498 13200005 */ beqz $t9, .L802002B0 /* 0A7C9C 802E849C 248BFFFF */ addiu $t3, $a0, -1 /* 0A7CA0 802E84A0 022D4821 */ addu $t1, $s1, $t5 /* 0A7CA4 802E84A4 8D2A0000 */ lw $t2, ($t1) -/* 0A7CA8 802E84A8 1000FFAF */ b .L_EU_802E8368 +/* 0A7CA8 802E84A8 1000FFAF */ b .L802E8368 /* 0A7CAC 802E84AC AE2A0000 */ sw $t2, ($s1) -.L0802002B0: -/* 0A7CB0 802E84B0 1000FFAD */ b .L_EU_802E8368 +.L802002B0: +/* 0A7CB0 802E84B0 1000FFAD */ b .L802E8368 /* 0A7CB4 802E84B4 A22B0018 */ sb $t3, 0x18($s1) -glabel L_EU_802E84B8 +glabel L802E84B8 /* 0A7CB8 802E84B8 922C0018 */ lbu $t4, 0x18($s1) /* 0A7CBC 802E84BC 258EFFFF */ addiu $t6, $t4, -1 -/* 0A7CC0 802E84C0 1000FFA9 */ b .L_EU_802E8368 +/* 0A7CC0 802E84C0 1000FFA9 */ b .L802E8368 /* 0A7CC4 802E84C4 A22E0018 */ sb $t6, 0x18($s1) -glabel L_EU_802E84C8 +glabel L802E84C8 /* 0A7CC8 802E84C8 0C0B9DA5 */ jal m64_read_s16 /* 0A7CCC 802E84CC 02202025 */ move $a0, $s1 /* 0A7CD0 802E84D0 240100FA */ li $at, 250 -/* 0A7CD4 802E84D4 16010003 */ bne $s0, $at, .L0802002E4 +/* 0A7CD4 802E84D4 16010003 */ bne $s0, $at, .L802002E4 /* 0A7CD8 802E84D8 02001825 */ move $v1, $s0 -/* 0A7CDC 802E84DC 1660FFA2 */ bnez $s3, .L_EU_802E8368 +/* 0A7CDC 802E84DC 1660FFA2 */ bnez $s3, .L802E8368 /* 0A7CE0 802E84E0 00000000 */ nop -.L0802002E4: +.L802002E4: /* 0A7CE4 802E84E4 240100F9 */ li $at, 249 -/* 0A7CE8 802E84E8 54610004 */ bnel $v1, $at, .L0802002FC +/* 0A7CE8 802E84E8 54610004 */ bnel $v1, $at, .L802002FC /* 0A7CEC 802E84EC 240100F5 */ li $at, 245 -/* 0A7CF0 802E84F0 0661FF9D */ bgez $s3, .L_EU_802E8368 +/* 0A7CF0 802E84F0 0661FF9D */ bgez $s3, .L802E8368 /* 0A7CF4 802E84F4 00000000 */ nop /* 0A7CF8 802E84F8 240100F5 */ li $at, 245 -.L0802002FC: -/* 0A7CFC 802E84FC 54610004 */ bnel $v1, $at, .L080200310 +.L802002FC: +/* 0A7CFC 802E84FC 54610004 */ bnel $v1, $at, .L80200310 /* 0A7D00 802E8500 8E8F0014 */ lw $t7, 0x14($s4) -/* 0A7D04 802E8504 0660FF98 */ bltz $s3, .L_EU_802E8368 +/* 0A7D04 802E8504 0660FF98 */ bltz $s3, .L802E8368 /* 0A7D08 802E8508 00000000 */ nop /* 0A7D0C 802E850C 8E8F0014 */ lw $t7, 0x14($s4) -.L080200310: +.L80200310: /* 0A7D10 802E8510 3058FFFF */ andi $t8, $v0, 0xffff /* 0A7D14 802E8514 01F8C821 */ addu $t9, $t7, $t8 -/* 0A7D18 802E8518 1000FF93 */ b .L_EU_802E8368 +/* 0A7D18 802E8518 1000FF93 */ b .L802E8368 /* 0A7D1C 802E851C AE390000 */ sw $t9, ($s1) -glabel L_EU_802E8520 +glabel L802E8520 /* 0A7D20 802E8520 0C0B9DA0 */ jal m64_read_u8 /* 0A7D24 802E8524 02202025 */ move $a0, $s1 /* 0A7D28 802E8528 240100F3 */ li $at, 243 -/* 0A7D2C 802E852C 16010003 */ bne $s0, $at, .L08020033C +/* 0A7D2C 802E852C 16010003 */ bne $s0, $at, .L8020033C /* 0A7D30 802E8530 02001825 */ move $v1, $s0 -/* 0A7D34 802E8534 1660FF8C */ bnez $s3, .L_EU_802E8368 +/* 0A7D34 802E8534 1660FF8C */ bnez $s3, .L802E8368 /* 0A7D38 802E8538 00000000 */ nop -.L08020033C: +.L8020033C: /* 0A7D3C 802E853C 240100F2 */ li $at, 242 -/* 0A7D40 802E8540 54610004 */ bnel $v1, $at, .L080200354 +/* 0A7D40 802E8540 54610004 */ bnel $v1, $at, .L80200354 /* 0A7D44 802E8544 8E2D0000 */ lw $t5, ($s1) -/* 0A7D48 802E8548 0661FF87 */ bgez $s3, .L_EU_802E8368 +/* 0A7D48 802E8548 0661FF87 */ bgez $s3, .L802E8368 /* 0A7D4C 802E854C 00000000 */ nop /* 0A7D50 802E8550 8E2D0000 */ lw $t5, ($s1) -.L080200354: +.L80200354: /* 0A7D54 802E8554 00024E00 */ sll $t1, $v0, 0x18 /* 0A7D58 802E8558 00095603 */ sra $t2, $t1, 0x18 /* 0A7D5C 802E855C 01AA5821 */ addu $t3, $t5, $t2 -/* 0A7D60 802E8560 1000FF81 */ b .L_EU_802E8368 +/* 0A7D60 802E8560 1000FF81 */ b .L802E8368 /* 0A7D64 802E8564 AE2B0000 */ sw $t3, ($s1) -glabel L_EU_802E8568 +glabel L802E8568 /* 0A7D68 802E8568 26500084 */ addiu $s0, $s2, 0x84 /* 0A7D6C 802E856C 0C0B9671 */ jal note_pool_clear /* 0A7D70 802E8570 02002025 */ move $a0, $s0 @@ -331,24 +331,24 @@ glabel L_EU_802E8568 /* 0A7D7C 802E857C 02002025 */ move $a0, $s0 /* 0A7D80 802E8580 0C0B96C9 */ jal note_pool_fill /* 0A7D84 802E8584 00402825 */ move $a1, $v0 -/* 0A7D88 802E8588 1000FF77 */ b .L_EU_802E8368 +/* 0A7D88 802E8588 1000FF77 */ b .L802E8368 /* 0A7D8C 802E858C 00000000 */ nop -glabel L_EU_802E8590 +glabel L802E8590 /* 0A7D90 802E8590 0C0B9671 */ jal note_pool_clear /* 0A7D94 802E8594 26440084 */ addiu $a0, $s2, 0x84 -/* 0A7D98 802E8598 1000FF73 */ b .L_EU_802E8368 +/* 0A7D98 802E8598 1000FF73 */ b .L802E8368 /* 0A7D9C 802E859C 00000000 */ nop -glabel L_EU_802E85A0 +glabel L802E85A0 /* 0A7DA0 802E85A0 0C0B9DA5 */ jal m64_read_s16 /* 0A7DA4 802E85A4 02202025 */ move $a0, $s1 /* 0A7DA8 802E85A8 8E8C0014 */ lw $t4, 0x14($s4) /* 0A7DAC 802E85AC 304EFFFF */ andi $t6, $v0, 0xffff /* 0A7DB0 802E85B0 018E7821 */ addu $t7, $t4, $t6 -/* 0A7DB4 802E85B4 1000FF6C */ b .L_EU_802E8368 +/* 0A7DB4 802E85B4 1000FF6C */ b .L802E8368 /* 0A7DB8 802E85B8 AE4F0034 */ sw $t7, 0x34($s2) -glabel L_EU_802E85BC +glabel L802E85BC /* 0A7DBC 802E85BC 2401FFFF */ li $at, -1 -/* 0A7DC0 802E85C0 1261FF69 */ beq $s3, $at, .L_EU_802E8368 +/* 0A7DC0 802E85C0 1261FF69 */ beq $s3, $at, .L802E8368 /* 0A7DC4 802E85C4 00000000 */ nop /* 0A7DC8 802E85C8 8E580034 */ lw $t8, 0x34($s2) /* 0A7DCC 802E85CC 0013C840 */ sll $t9, $s3, 1 @@ -360,9 +360,9 @@ glabel L_EU_802E85BC /* 0A7DE4 802E85E4 012A3821 */ addu $a3, $t1, $t2 /* 0A7DE8 802E85E8 30EBFFFF */ andi $t3, $a3, 0xffff /* 0A7DEC 802E85EC 018B7021 */ addu $t6, $t4, $t3 -/* 0A7DF0 802E85F0 1000FF5D */ b .L_EU_802E8368 +/* 0A7DF0 802E85F0 1000FF5D */ b .L802E8368 /* 0A7DF4 802E85F4 AE4E0034 */ sw $t6, 0x34($s2) -glabel L_EU_802E85F8 +glabel L802E85F8 /* 0A7DF8 802E85F8 0C0B9DA0 */ jal m64_read_u8 /* 0A7DFC 802E85FC 02202025 */ move $a0, $s1 /* 0A7E00 802E8600 928F0004 */ lbu $t7, 4($s4) @@ -382,29 +382,29 @@ glabel L_EU_802E85F8 /* 0A7E38 802E8638 91700000 */ lbu $s0, ($t3) /* 0A7E3C 802E863C 0C0B89CF */ jal get_bank_or_seq /* 0A7E40 802E8640 02003025 */ move $a2, $s0 -/* 0A7E44 802E8644 10400002 */ beqz $v0, .L_EU_802E8650 +/* 0A7E44 802E8644 10400002 */ beqz $v0, .L802E8650 /* 0A7E48 802E8648 00000000 */ nop /* 0A7E4C 802E864C A2500006 */ sb $s0, 6($s2) -glabel L_EU_802E8650 -.L_EU_802E8650: +glabel L802E8650 +.L802E8650: /* 0A7E50 802E8650 0C0B9DA0 */ jal m64_read_u8 /* 0A7E54 802E8654 02202025 */ move $a0, $s1 /* 0A7E58 802E8658 02402025 */ move $a0, $s2 /* 0A7E5C 802E865C 0C0BA080 */ jal set_instrument /* 0A7E60 802E8660 304500FF */ andi $a1, $v0, 0xff -/* 0A7E64 802E8664 1000FF40 */ b .L_EU_802E8368 +/* 0A7E64 802E8664 1000FF40 */ b .L802E8368 /* 0A7E68 802E8668 00000000 */ nop -glabel L_EU_802E866C +glabel L802E866C /* 0A7E6C 802E866C 924C0000 */ lbu $t4, ($s2) /* 0A7E70 802E8670 318EFFFD */ andi $t6, $t4, 0xfffd -/* 0A7E74 802E8674 1000FF3C */ b .L_EU_802E8368 +/* 0A7E74 802E8674 1000FF3C */ b .L802E8368 /* 0A7E78 802E8678 A24E0000 */ sb $t6, ($s2) -glabel L_EU_802E867C +glabel L802E867C /* 0A7E7C 802E867C 92580000 */ lbu $t8, ($s2) /* 0A7E80 802E8680 37190002 */ ori $t9, $t8, 2 -/* 0A7E84 802E8684 1000FF38 */ b .L_EU_802E8368 +/* 0A7E84 802E8684 1000FF38 */ b .L802E8368 /* 0A7E88 802E8688 A2590000 */ sb $t9, ($s2) -glabel L_EU_802E868C +glabel L802E868C /* 0A7E8C 802E868C 0C0B9DA0 */ jal m64_read_u8 /* 0A7E90 802E8690 02202025 */ move $a0, $s1 /* 0A7E94 802E8694 02402025 */ move $a0, $s2 @@ -412,9 +412,9 @@ glabel L_EU_802E868C /* 0A7E9C 802E869C 304500FF */ andi $a1, $v0, 0xff /* 0A7EA0 802E86A0 92490001 */ lbu $t1, 1($s2) /* 0A7EA4 802E86A4 352A0040 */ ori $t2, $t1, 0x40 -/* 0A7EA8 802E86A8 1000FF2F */ b .L_EU_802E8368 +/* 0A7EA8 802E86A8 1000FF2F */ b .L802E8368 /* 0A7EAC 802E86AC A24A0001 */ sb $t2, 1($s2) -glabel L_EU_802E86B0 +glabel L802E86B0 /* 0A7EB0 802E86B0 0C0B9DA0 */ jal m64_read_u8 /* 0A7EB4 802E86B4 02202025 */ move $a0, $s1 /* 0A7EB8 802E86B8 44822000 */ mtc1 $v0, $f4 @@ -425,9 +425,9 @@ glabel L_EU_802E86B0 /* 0A7ECC 802E86CC 358E0040 */ ori $t6, $t4, 0x40 /* 0A7ED0 802E86D0 A24E0001 */ sb $t6, 1($s2) /* 0A7ED4 802E86D4 46083282 */ mul.s $f10, $f6, $f8 -/* 0A7ED8 802E86D8 1000FF23 */ b .L_EU_802E8368 +/* 0A7ED8 802E86D8 1000FF23 */ b .L802E8368 /* 0A7EDC 802E86DC E64A0020 */ swc1 $f10, 0x20($s2) -glabel L_EU_802E86E0 +glabel L802E86E0 /* 0A7EE0 802E86E0 0C0B9DA5 */ jal m64_read_s16 /* 0A7EE4 802E86E4 02202025 */ move $a0, $s1 /* 0A7EE8 802E86E8 304FFFFF */ andi $t7, $v0, 0xffff @@ -439,9 +439,9 @@ glabel L_EU_802E86E0 /* 0A7F00 802E8700 372D0080 */ ori $t5, $t9, 0x80 /* 0A7F04 802E8704 A24D0001 */ sb $t5, 1($s2) /* 0A7F08 802E8708 46049183 */ div.s $f6, $f18, $f4 -/* 0A7F0C 802E870C 1000FF16 */ b .L_EU_802E8368 +/* 0A7F0C 802E870C 1000FF16 */ b .L802E8368 /* 0A7F10 802E8710 E6460030 */ swc1 $f6, 0x30($s2) -glabel L_EU_802E8714 +glabel L802E8714 /* 0A7F14 802E8714 0C0B9DA0 */ jal m64_read_u8 /* 0A7F18 802E8718 02202025 */ move $a0, $s1 /* 0A7F1C 802E871C 2449007F */ addiu $t1, $v0, 0x7f @@ -453,61 +453,61 @@ glabel L_EU_802E8714 /* 0A7F34 802E8734 C42806E8 */ lwc1 $f8, %lo(gPitchBendFrequencyScale)($at) /* 0A7F38 802E8738 35CF0080 */ ori $t7, $t6, 0x80 /* 0A7F3C 802E873C A24F0001 */ sb $t7, 1($s2) -/* 0A7F40 802E8740 1000FF09 */ b .L_EU_802E8368 +/* 0A7F40 802E8740 1000FF09 */ b .L802E8368 /* 0A7F44 802E8744 E6480030 */ swc1 $f8, 0x30($s2) -glabel L_EU_802E8748 +glabel L802E8748 /* 0A7F48 802E8748 0C0B9DA0 */ jal m64_read_u8 /* 0A7F4C 802E874C 02202025 */ move $a0, $s1 /* 0A7F50 802E8750 92590001 */ lbu $t9, 1($s2) /* 0A7F54 802E8754 A2420009 */ sb $v0, 9($s2) /* 0A7F58 802E8758 372D0020 */ ori $t5, $t9, 0x20 -/* 0A7F5C 802E875C 1000FF02 */ b .L_EU_802E8368 +/* 0A7F5C 802E875C 1000FF02 */ b .L802E8368 /* 0A7F60 802E8760 A24D0001 */ sb $t5, 1($s2) -glabel L_EU_802E8764 +glabel L802E8764 /* 0A7F64 802E8764 0C0B9DA0 */ jal m64_read_u8 /* 0A7F68 802E8768 02202025 */ move $a0, $s1 /* 0A7F6C 802E876C 924A0001 */ lbu $t2, 1($s2) /* 0A7F70 802E8770 A242000A */ sb $v0, 0xa($s2) /* 0A7F74 802E8774 354B0020 */ ori $t3, $t2, 0x20 -/* 0A7F78 802E8778 1000FEFB */ b .L_EU_802E8368 +/* 0A7F78 802E8778 1000FEFB */ b .L802E8368 /* 0A7F7C 802E877C A24B0001 */ sb $t3, 1($s2) -glabel L_EU_802E8780 +glabel L802E8780 /* 0A7F80 802E8780 8E220000 */ lw $v0, ($s1) /* 0A7F84 802E8784 80430000 */ lb $v1, ($v0) /* 0A7F88 802E8788 244C0001 */ addiu $t4, $v0, 1 /* 0A7F8C 802E878C AE2C0000 */ sw $t4, ($s1) -/* 0A7F90 802E8790 1000FEF5 */ b .L_EU_802E8368 +/* 0A7F90 802E8790 1000FEF5 */ b .L802E8368 /* 0A7F94 802E8794 A643001E */ sh $v1, 0x1e($s2) -glabel L_EU_802E8798 +glabel L802E8798 /* 0A7F98 802E8798 0C0B9DA5 */ jal m64_read_s16 /* 0A7F9C 802E879C 02202025 */ move $a0, $s1 /* 0A7FA0 802E87A0 8E8E0014 */ lw $t6, 0x14($s4) /* 0A7FA4 802E87A4 304FFFFF */ andi $t7, $v0, 0xffff /* 0A7FA8 802E87A8 01CFC021 */ addu $t8, $t6, $t7 -/* 0A7FAC 802E87AC 1000FEEE */ b .L_EU_802E8368 +/* 0A7FAC 802E87AC 1000FEEE */ b .L802E8368 /* 0A7FB0 802E87B0 AE580080 */ sw $t8, 0x80($s2) -glabel L_EU_802E87B4 +glabel L802E87B4 /* 0A7FB4 802E87B4 0C0B9DA0 */ jal m64_read_u8 /* 0A7FB8 802E87B8 02202025 */ move $a0, $s1 -/* 0A7FBC 802E87BC 1000FEEA */ b .L_EU_802E8368 +/* 0A7FBC 802E87BC 1000FEEA */ b .L802E8368 /* 0A7FC0 802E87C0 A242007C */ sb $v0, 0x7c($s2) -glabel L_EU_802E87C4 +glabel L802E87C4 /* 0A7FC4 802E87C4 0C0B9DA0 */ jal m64_read_u8 /* 0A7FC8 802E87C8 02202025 */ move $a0, $s1 /* 0A7FCC 802E87CC 0002C8C0 */ sll $t9, $v0, 3 /* 0A7FD0 802E87D0 A6590012 */ sh $t9, 0x12($s2) /* 0A7FD4 802E87D4 A640000E */ sh $zero, 0xe($s2) -/* 0A7FD8 802E87D8 1000FEE3 */ b .L_EU_802E8368 +/* 0A7FD8 802E87D8 1000FEE3 */ b .L802E8368 /* 0A7FDC 802E87DC A6400016 */ sh $zero, 0x16($s2) -glabel L_EU_802E87E0 +glabel L802E87E0 /* 0A7FE0 802E87E0 0C0B9DA0 */ jal m64_read_u8 /* 0A7FE4 802E87E4 02202025 */ move $a0, $s1 /* 0A7FE8 802E87E8 00021940 */ sll $v1, $v0, 5 /* 0A7FEC 802E87EC A6430010 */ sh $v1, 0x10($s2) /* 0A7FF0 802E87F0 A643000C */ sh $v1, 0xc($s2) -/* 0A7FF4 802E87F4 1000FEDC */ b .L_EU_802E8368 +/* 0A7FF4 802E87F4 1000FEDC */ b .L802E8368 /* 0A7FF8 802E87F8 A6400014 */ sh $zero, 0x14($s2) -glabel L_EU_802E87FC +glabel L802E87FC /* 0A7FFC 802E87FC 0C0B9DA0 */ jal m64_read_u8 /* 0A8000 802E8800 02202025 */ move $a0, $s1 /* 0A8004 802E8804 000268C0 */ sll $t5, $v0, 3 @@ -519,9 +519,9 @@ glabel L_EU_802E87FC /* 0A801C 802E881C 0C0B9DA0 */ jal m64_read_u8 /* 0A8020 802E8820 02202025 */ move $a0, $s1 /* 0A8024 802E8824 00025100 */ sll $t2, $v0, 4 -/* 0A8028 802E8828 1000FECF */ b .L_EU_802E8368 +/* 0A8028 802E8828 1000FECF */ b .L802E8368 /* 0A802C 802E882C A64A0016 */ sh $t2, 0x16($s2) -glabel L_EU_802E8830 +glabel L802E8830 /* 0A8030 802E8830 0C0B9DA0 */ jal m64_read_u8 /* 0A8034 802E8834 02202025 */ move $a0, $s1 /* 0A8038 802E8838 00025940 */ sll $t3, $v0, 5 @@ -533,20 +533,20 @@ glabel L_EU_802E8830 /* 0A8050 802E8850 0C0B9DA0 */ jal m64_read_u8 /* 0A8054 802E8854 02202025 */ move $a0, $s1 /* 0A8058 802E8858 00027100 */ sll $t6, $v0, 4 -/* 0A805C 802E885C 1000FEC2 */ b .L_EU_802E8368 +/* 0A805C 802E885C 1000FEC2 */ b .L802E8368 /* 0A8060 802E8860 A64E0014 */ sh $t6, 0x14($s2) -glabel L_EU_802E8864 +glabel L802E8864 /* 0A8064 802E8864 0C0B9DA0 */ jal m64_read_u8 /* 0A8068 802E8868 02202025 */ move $a0, $s1 /* 0A806C 802E886C 00027900 */ sll $t7, $v0, 4 -/* 0A8070 802E8870 1000FEBD */ b .L_EU_802E8368 +/* 0A8070 802E8870 1000FEBD */ b .L802E8368 /* 0A8074 802E8874 A64F0018 */ sh $t7, 0x18($s2) -glabel L_EU_802E8878 +glabel L802E8878 /* 0A8078 802E8878 0C0B9DA0 */ jal m64_read_u8 /* 0A807C 802E887C 02202025 */ move $a0, $s1 -/* 0A8080 802E8880 1000FEB9 */ b .L_EU_802E8368 +/* 0A8080 802E8880 1000FEB9 */ b .L802E8368 /* 0A8084 802E8884 A2420004 */ sb $v0, 4($s2) -glabel L_EU_802E8888 +glabel L802E8888 /* 0A8088 802E8888 0C0B9DA0 */ jal m64_read_u8 /* 0A808C 802E888C 02202025 */ move $a0, $s1 /* 0A8090 802E8890 92980004 */ lbu $t8, 4($s4) @@ -566,11 +566,11 @@ glabel L_EU_802E8888 /* 0A80C8 802E88C8 91900000 */ lbu $s0, ($t4) /* 0A80CC 802E88CC 0C0B89CF */ jal get_bank_or_seq /* 0A80D0 802E88D0 02003025 */ move $a2, $s0 -/* 0A80D4 802E88D4 1040FEA4 */ beqz $v0, .L_EU_802E8368 +/* 0A80D4 802E88D4 1040FEA4 */ beqz $v0, .L802E8368 /* 0A80D8 802E88D8 00000000 */ nop -/* 0A80DC 802E88DC 1000FEA2 */ b .L_EU_802E8368 +/* 0A80DC 802E88DC 1000FEA2 */ b .L802E8368 /* 0A80E0 802E88E0 A2500006 */ sb $s0, 6($s2) -glabel L_EU_802E88E4 +glabel L802E88E4 /* 0A80E4 802E88E4 326E00FF */ andi $t6, $s3, 0xff /* 0A80E8 802E88E8 AFAE0034 */ sw $t6, 0x34($sp) /* 0A80EC 802E88EC 0C0B9DA0 */ jal m64_read_u8 @@ -583,45 +583,45 @@ glabel L_EU_802E88E4 /* 0A8108 802E8908 3058FFFF */ andi $t8, $v0, 0xffff /* 0A810C 802E890C 01F81821 */ addu $v1, $t7, $t8 /* 0A8110 802E8910 03306821 */ addu $t5, $t9, $s0 -/* 0A8114 802E8914 1000FE94 */ b .L_EU_802E8368 +/* 0A8114 802E8914 1000FE94 */ b .L802E8368 /* 0A8118 802E8918 A06D0000 */ sb $t5, ($v1) -glabel L_EU_802E891C +glabel L802E891C /* 0A811C 802E891C 0C0B9DA0 */ jal m64_read_u8 /* 0A8120 802E8920 02202025 */ move $a0, $s1 /* 0A8124 802E8924 240100C8 */ li $at, 200 -/* 0A8128 802E8928 16010005 */ bne $s0, $at, .L080200740 +/* 0A8128 802E8928 16010005 */ bne $s0, $at, .L80200740 /* 0A812C 802E892C 02001825 */ move $v1, $s0 /* 0A8130 802E8930 02629823 */ subu $s3, $s3, $v0 /* 0A8134 802E8934 00135E00 */ sll $t3, $s3, 0x18 -/* 0A8138 802E8938 1000FE8B */ b .L_EU_802E8368 +/* 0A8138 802E8938 1000FE8B */ b .L802E8368 /* 0A813C 802E893C 000B9E03 */ sra $s3, $t3, 0x18 -.L080200740: +.L80200740: /* 0A8140 802E8940 240100CC */ li $at, 204 -/* 0A8144 802E8944 14610005 */ bne $v1, $at, .L08020075C +/* 0A8144 802E8944 14610005 */ bne $v1, $at, .L8020075C /* 0A8148 802E8948 02629824 */ and $s3, $s3, $v0 /* 0A814C 802E894C 00029E00 */ sll $s3, $v0, 0x18 /* 0A8150 802E8950 00137603 */ sra $t6, $s3, 0x18 -/* 0A8154 802E8954 1000FE84 */ b .L_EU_802E8368 +/* 0A8154 802E8954 1000FE84 */ b .L802E8368 /* 0A8158 802E8958 01C09825 */ move $s3, $t6 -.L08020075C: +.L8020075C: /* 0A815C 802E895C 0013CE00 */ sll $t9, $s3, 0x18 -/* 0A8160 802E8960 1000FE81 */ b .L_EU_802E8368 +/* 0A8160 802E8960 1000FE81 */ b .L802E8368 /* 0A8164 802E8964 00199E03 */ sra $s3, $t9, 0x18 -glabel L_EU_802E8968 +glabel L802E8968 /* 0A8168 802E8968 0C0B9DA0 */ jal m64_read_u8 /* 0A816C 802E896C 02202025 */ move $a0, $s1 -/* 0A8170 802E8970 1000FE7D */ b .L_EU_802E8368 +/* 0A8170 802E8970 1000FE7D */ b .L802E8368 /* 0A8174 802E8974 A2420003 */ sb $v0, 3($s2) -glabel L_EU_802E8978 +glabel L802E8978 /* 0A8178 802E8978 0C0B9DA5 */ jal m64_read_s16 /* 0A817C 802E897C 02202025 */ move $a0, $s1 /* 0A8180 802E8980 8E890014 */ lw $t1, 0x14($s4) /* 0A8184 802E8984 304AFFFF */ andi $t2, $v0, 0xffff /* 0A8188 802E8988 01535821 */ addu $t3, $t2, $s3 /* 0A818C 802E898C 012B6021 */ addu $t4, $t1, $t3 -/* 0A8190 802E8990 1000FE75 */ b .L_EU_802E8368 +/* 0A8190 802E8990 1000FE75 */ b .L802E8368 /* 0A8194 802E8994 81930000 */ lb $s3, ($t4) -glabel L_EU_802E8998 +glabel L802E8998 /* 0A8198 802E8998 0C0B9DA0 */ jal m64_read_u8 /* 0A819C 802E899C 02202025 */ move $a0, $s1 /* 0A81A0 802E89A0 92590000 */ lbu $t9, ($s2) @@ -629,26 +629,26 @@ glabel L_EU_802E8998 /* 0A81A8 802E89A8 31F80004 */ andi $t8, $t7, 4 /* 0A81AC 802E89AC 332DFFFB */ andi $t5, $t9, 0xfffb /* 0A81B0 802E89B0 030D5025 */ or $t2, $t8, $t5 -/* 0A81B4 802E89B4 1000FE6C */ b .L_EU_802E8368 +/* 0A81B4 802E89B4 1000FE6C */ b .L802E8368 /* 0A81B8 802E89B8 A24A0000 */ sb $t2, ($s2) -glabel L_EU_802E89BC +glabel L802E89BC /* 0A81BC 802E89BC 0C0B9DA0 */ jal m64_read_u8 /* 0A81C0 802E89C0 02202025 */ move $a0, $s1 -/* 0A81C4 802E89C4 1000FE68 */ b .L_EU_802E8368 +/* 0A81C4 802E89C4 1000FE68 */ b .L802E8368 /* 0A81C8 802E89C8 A2420002 */ sb $v0, 2($s2) -glabel L_EU_802E89CC +glabel L802E89CC /* 0A81CC 802E89CC 0C0B9DA0 */ jal m64_read_u8 /* 0A81D0 802E89D0 02202025 */ move $a0, $s1 -/* 0A81D4 802E89D4 1000FE64 */ b .L_EU_802E8368 +/* 0A81D4 802E89D4 1000FE64 */ b .L802E8368 /* 0A81D8 802E89D8 A242007D */ sb $v0, 0x7d($s2) -glabel L_EU_802E89DC +glabel L802E89DC /* 0A81DC 802E89DC 0C0B9DA0 */ jal m64_read_u8 /* 0A81E0 802E89E0 02202025 */ move $a0, $s1 -/* 0A81E4 802E89E4 1000FE60 */ b .L_EU_802E8368 +/* 0A81E4 802E89E4 1000FE60 */ b .L802E8368 /* 0A81E8 802E89E8 A2420007 */ sb $v0, 7($s2) -glabel L_EU_802E89EC +glabel L802E89EC /* 0A81EC 802E89EC 2401FFFF */ li $at, -1 -/* 0A81F0 802E89F0 1261FE5D */ beq $s3, $at, .L_EU_802E8368 +/* 0A81F0 802E89F0 1261FE5D */ beq $s3, $at, .L802E8368 /* 0A81F4 802E89F4 00000000 */ nop /* 0A81F8 802E89F8 92240018 */ lbu $a0, 0x18($s1) /* 0A81FC 802E89FC 8E2B0000 */ lw $t3, ($s1) @@ -668,14 +668,14 @@ glabel L_EU_802E89EC /* 0A8234 802E8A34 030A3821 */ addu $a3, $t8, $t2 /* 0A8238 802E8A38 30E9FFFF */ andi $t1, $a3, 0xffff /* 0A823C 802E8A3C 01895821 */ addu $t3, $t4, $t1 -/* 0A8240 802E8A40 1000FE49 */ b .L_EU_802E8368 +/* 0A8240 802E8A40 1000FE49 */ b .L802E8368 /* 0A8244 802E8A44 AE2B0000 */ sw $t3, ($s1) -glabel L_EU_802E8A48 +glabel L802E8A48 /* 0A8248 802E8A48 0C0B9DA0 */ jal m64_read_u8 /* 0A824C 802E8A4C 02202025 */ move $a0, $s1 -/* 0A8250 802E8A50 1000FE45 */ b .L_EU_802E8368 +/* 0A8250 802E8A50 1000FE45 */ b .L802E8368 /* 0A8254 802E8A54 A2420008 */ sb $v0, 8($s2) -glabel L_EU_802E8A58 +glabel L802E8A58 /* 0A8258 802E8A58 0C0B9DA5 */ jal m64_read_s16 /* 0A825C 802E8A5C 02202025 */ move $a0, $s1 /* 0A8260 802E8A60 8E8E0014 */ lw $t6, 0x14($s4) @@ -700,9 +700,9 @@ glabel L_EU_802E8A58 /* 0A82AC 802E8AAC A24B0004 */ sb $t3, 4($s2) /* 0A82B0 802E8AB0 906E0000 */ lbu $t6, ($v1) /* 0A82B4 802E8AB4 A24D0001 */ sb $t5, 1($s2) -/* 0A82B8 802E8AB8 1000FE2B */ b .L_EU_802E8368 +/* 0A82B8 802E8AB8 1000FE2B */ b .L802E8368 /* 0A82BC 802E8ABC A24E0007 */ sb $t6, 7($s2) -glabel L_EU_802E8AC0 +glabel L802E8AC0 /* 0A82C0 802E8AC0 0C0B9DA0 */ jal m64_read_u8 /* 0A82C4 802E8AC4 02202025 */ move $a0, $s1 /* 0A82C8 802E8AC8 A2420003 */ sb $v0, 3($s2) @@ -731,9 +731,9 @@ glabel L_EU_802E8AC0 /* 0A8324 802E8B24 924C0001 */ lbu $t4, 1($s2) /* 0A8328 802E8B28 A2420007 */ sb $v0, 7($s2) /* 0A832C 802E8B2C 358B0020 */ ori $t3, $t4, 0x20 -/* 0A8330 802E8B30 1000FE0D */ b .L_EU_802E8368 +/* 0A8330 802E8B30 1000FE0D */ b .L802E8368 /* 0A8334 802E8B34 A24B0001 */ sb $t3, 1($s2) -glabel L_EU_802E8B38 +glabel L802E8B38 /* 0A8338 802E8B38 3C013F80 */ li $at, 0x3F800000 # 1.000000 /* 0A833C 802E8B3C 44815000 */ mtc1 $at, $f10 /* 0A8340 802E8B40 A6400012 */ sh $zero, 0x12($s2) @@ -742,18 +742,18 @@ glabel L_EU_802E8B38 /* 0A834C 802E8B4C A6400010 */ sh $zero, 0x10($s2) /* 0A8350 802E8B50 A640000C */ sh $zero, 0xc($s2) /* 0A8354 802E8B54 A6400014 */ sh $zero, 0x14($s2) -/* 0A8358 802E8B58 1000FE03 */ b .L_EU_802E8368 +/* 0A8358 802E8B58 1000FE03 */ b .L802E8368 /* 0A835C 802E8B5C E64A0030 */ swc1 $f10, 0x30($s2) -glabel L_EU_802E8B60 +glabel L802E8B60 /* 0A8360 802E8B60 0C0B9DA0 */ jal m64_read_u8 /* 0A8364 802E8B64 02202025 */ move $a0, $s1 -/* 0A8368 802E8B68 1000FDFF */ b .L_EU_802E8368 +/* 0A8368 802E8B68 1000FDFF */ b .L802E8368 /* 0A836C 802E8B6C A2420005 */ sb $v0, 5($s2) -.L080200970: +.L80200970: /* 0A8370 802E8B70 306E00F0 */ andi $t6, $v1, 0xf0 /* 0A8374 802E8B74 3064000F */ andi $a0, $v1, 0xf /* 0A8378 802E8B78 2DC100B1 */ sltiu $at, $t6, 0xb1 -/* 0A837C 802E8B7C 1020FDFA */ beqz $at, .L_EU_802E8368 +/* 0A837C 802E8B7C 1020FDFA */ beqz $at, .L802E8368 /* 0A8380 802E8B80 308800FF */ andi $t0, $a0, 0xff /* 0A8384 802E8B84 000E7080 */ sll $t6, $t6, 2 /* 0A8388 802E8B88 3C018030 */ lui $at, %hi(jtbl_EU_80306810) @@ -761,49 +761,49 @@ glabel L_EU_802E8B60 /* 0A8390 802E8B90 8C2E6810 */ lw $t6, %lo(jtbl_EU_80306810)($at) /* 0A8394 802E8B94 01C00008 */ jr $t6 /* 0A8398 802E8B98 00000000 */ nop -glabel L_EU_802E8B9C +glabel L802E8B9C /* 0A839C 802E8B9C 308F00FF */ andi $t7, $a0, 0xff /* 0A83A0 802E8BA0 000FC880 */ sll $t9, $t7, 2 /* 0A83A4 802E8BA4 02596821 */ addu $t5, $s2, $t9 /* 0A83A8 802E8BA8 8DA30048 */ lw $v1, 0x48($t5) -/* 0A83AC 802E8BAC 10600007 */ beqz $v1, .L0802009CC +/* 0A83AC 802E8BAC 10600007 */ beqz $v1, .L802009CC /* 0A83B0 802E8BB0 00000000 */ nop /* 0A83B4 802E8BB4 8C730000 */ lw $s3, ($v1) /* 0A83B8 802E8BB8 0013C040 */ sll $t8, $s3, 1 /* 0A83BC 802E8BBC 001857C2 */ srl $t2, $t8, 0x1f /* 0A83C0 802E8BC0 000A4E00 */ sll $t1, $t2, 0x18 -/* 0A83C4 802E8BC4 1000FDE8 */ b .L_EU_802E8368 +/* 0A83C4 802E8BC4 1000FDE8 */ b .L802E8368 /* 0A83C8 802E8BC8 00099E03 */ sra $s3, $t1, 0x18 -.L0802009CC: -/* 0A83CC 802E8BCC 1000FDE6 */ b .L_EU_802E8368 +.L802009CC: +/* 0A83CC 802E8BCC 1000FDE6 */ b .L802E8368 /* 0A83D0 802E8BD0 2413FFFF */ li $s3, -1 -glabel L_EU_802E8BD4 +glabel L802E8BD4 /* 0A83D4 802E8BD4 308B00FF */ andi $t3, $a0, 0xff /* 0A83D8 802E8BD8 024B7021 */ addu $t6, $s2, $t3 -/* 0A83DC 802E8BDC 1000FDE2 */ b .L_EU_802E8368 +/* 0A83DC 802E8BDC 1000FDE2 */ b .L802E8368 /* 0A83E0 802E8BE0 A1D30058 */ sb $s3, 0x58($t6) -glabel L_EU_802E8BE4 +glabel L802E8BE4 /* 0A83E4 802E8BE4 308300FF */ andi $v1, $a0, 0xff /* 0A83E8 802E8BE8 02432821 */ addu $a1, $s2, $v1 /* 0A83EC 802E8BEC 28610004 */ slti $at, $v1, 4 -/* 0A83F0 802E8BF0 1020FDDD */ beqz $at, .L_EU_802E8368 +/* 0A83F0 802E8BF0 1020FDDD */ beqz $at, .L802E8368 /* 0A83F4 802E8BF4 80B30058 */ lb $s3, 0x58($a1) /* 0A83F8 802E8BF8 240FFFFF */ li $t7, -1 -/* 0A83FC 802E8BFC 1000FDDA */ b .L_EU_802E8368 +/* 0A83FC 802E8BFC 1000FDDA */ b .L802E8368 /* 0A8400 802E8C00 A0AF0058 */ sb $t7, 0x58($a1) -glabel L_EU_802E8C04 +glabel L802E8C04 /* 0A8404 802E8C04 309900FF */ andi $t9, $a0, 0xff /* 0A8408 802E8C08 02596821 */ addu $t5, $s2, $t9 /* 0A840C 802E8C0C 81B80058 */ lb $t8, 0x58($t5) /* 0A8410 802E8C10 02789823 */ subu $s3, $s3, $t8 /* 0A8414 802E8C14 00135600 */ sll $t2, $s3, 0x18 -/* 0A8418 802E8C18 1000FDD3 */ b .L_EU_802E8368 +/* 0A8418 802E8C18 1000FDD3 */ b .L802E8368 /* 0A841C 802E8C1C 000A9E03 */ sra $s3, $t2, 0x18 -glabel L_EU_802E8C20 +glabel L802E8C20 /* 0A8420 802E8C20 308C00FF */ andi $t4, $a0, 0xff -/* 0A8424 802E8C24 1000005C */ b .L_EU_802E8D98 +/* 0A8424 802E8C24 1000005C */ b .L802E8D98 /* 0A8428 802E8C28 A64C001A */ sh $t4, 0x1a($s2) -glabel L_EU_802E8C2C +glabel L802E8C2C /* 0A842C 802E8C2C 0C0B9DA5 */ jal m64_read_s16 /* 0A8430 802E8C30 02202025 */ move $a0, $s1 /* 0A8434 802E8C34 02003025 */ move $a2, $s0 @@ -814,26 +814,26 @@ glabel L_EU_802E8C2C /* 0A8448 802E8C48 0C0B9BDC */ jal seq_channel_set_layer /* 0A844C 802E8C4C A7A20052 */ sh $v0, 0x52($sp) /* 0A8450 802E8C50 8FA60034 */ lw $a2, 0x34($sp) -/* 0A8454 802E8C54 1440FDC4 */ bnez $v0, .L_EU_802E8368 +/* 0A8454 802E8C54 1440FDC4 */ bnez $v0, .L802E8368 /* 0A8458 802E8C58 97A70052 */ lhu $a3, 0x52($sp) /* 0A845C 802E8C5C 8E8E0014 */ lw $t6, 0x14($s4) /* 0A8460 802E8C60 0006C880 */ sll $t9, $a2, 2 /* 0A8464 802E8C64 02596821 */ addu $t5, $s2, $t9 /* 0A8468 802E8C68 8DB80048 */ lw $t8, 0x48($t5) /* 0A846C 802E8C6C 01C77821 */ addu $t7, $t6, $a3 -/* 0A8470 802E8C70 1000FDBD */ b .L_EU_802E8368 +/* 0A8470 802E8C70 1000FDBD */ b .L802E8368 /* 0A8474 802E8C74 AF0F0050 */ sw $t7, 0x50($t8) -glabel L_EU_802E8C78 +glabel L802E8C78 /* 0A8478 802E8C78 02002825 */ move $a1, $s0 /* 0A847C 802E8C7C 30AA000F */ andi $t2, $a1, 0xf /* 0A8480 802E8C80 01402825 */ move $a1, $t2 /* 0A8484 802E8C84 0C0B9C2D */ jal seq_channel_layer_free /* 0A8488 802E8C88 02402025 */ move $a0, $s2 -/* 0A848C 802E8C8C 1000FDB6 */ b .L_EU_802E8368 +/* 0A848C 802E8C8C 1000FDB6 */ b .L802E8368 /* 0A8490 802E8C90 00000000 */ nop -glabel L_EU_802E8C94 +glabel L802E8C94 /* 0A8494 802E8C94 2401FFFF */ li $at, -1 -/* 0A8498 802E8C98 1261FDB3 */ beq $s3, $at, .L_EU_802E8368 +/* 0A8498 802E8C98 1261FDB3 */ beq $s3, $at, .L802E8368 /* 0A849C 802E8C9C 02402025 */ move $a0, $s2 /* 0A84A0 802E8CA0 02003025 */ move $a2, $s0 /* 0A84A4 802E8CA4 30C5000F */ andi $a1, $a2, 0xf @@ -841,7 +841,7 @@ glabel L_EU_802E8C94 /* 0A84AC 802E8CAC 0C0B9BDC */ jal seq_channel_set_layer /* 0A84B0 802E8CB0 AFA50034 */ sw $a1, 0x34($sp) /* 0A84B4 802E8CB4 2401FFFF */ li $at, -1 -/* 0A84B8 802E8CB8 1041FDAB */ beq $v0, $at, .L_EU_802E8368 +/* 0A84B8 802E8CB8 1041FDAB */ beq $v0, $at, .L802E8368 /* 0A84BC 802E8CBC 8FA60034 */ lw $a2, 0x34($sp) /* 0A84C0 802E8CC0 8E4C0034 */ lw $t4, 0x34($s2) /* 0A84C4 802E8CC4 00135840 */ sll $t3, $s3, 1 @@ -856,9 +856,9 @@ glabel L_EU_802E8C94 /* 0A84E8 802E8CE8 8D8B0048 */ lw $t3, 0x48($t4) /* 0A84EC 802E8CEC 30EFFFFF */ andi $t7, $a3, 0xffff /* 0A84F0 802E8CF0 030F5021 */ addu $t2, $t8, $t7 -/* 0A84F4 802E8CF4 1000FD9C */ b .L_EU_802E8368 +/* 0A84F4 802E8CF4 1000FD9C */ b .L802E8368 /* 0A84F8 802E8CF8 AD6A0050 */ sw $t2, 0x50($t3) -glabel L_EU_802E8CFC +glabel L802E8CFC /* 0A84FC 802E8CFC 0C0B9DA5 */ jal m64_read_s16 /* 0A8500 802E8D00 02202025 */ move $a0, $s1 /* 0A8504 802E8D04 8E8E0014 */ lw $t6, 0x14($s4) @@ -869,17 +869,17 @@ glabel L_EU_802E8CFC /* 0A8518 802E8D18 02802025 */ move $a0, $s4 /* 0A851C 802E8D1C 0C0B9CFA */ jal sequence_channel_enable /* 0A8520 802E8D20 01CD3021 */ addu $a2, $t6, $t5 -/* 0A8524 802E8D24 1000FD90 */ b .L_EU_802E8368 +/* 0A8524 802E8D24 1000FD90 */ b .L802E8368 /* 0A8528 802E8D28 00000000 */ nop -glabel L_EU_802E8D2C +glabel L802E8D2C /* 0A852C 802E8D2C 3218000F */ andi $t8, $s0, 0xf /* 0A8530 802E8D30 00184880 */ sll $t1, $t8, 2 /* 0A8534 802E8D34 02896021 */ addu $t4, $s4, $t1 /* 0A8538 802E8D38 0C0B9C41 */ jal sequence_channel_disable /* 0A853C 802E8D3C 8D840030 */ lw $a0, 0x30($t4) -/* 0A8540 802E8D40 1000FD89 */ b .L_EU_802E8368 +/* 0A8540 802E8D40 1000FD89 */ b .L802E8368 /* 0A8544 802E8D44 00000000 */ nop -glabel L_EU_802E8D48 +glabel L802E8D48 /* 0A8548 802E8D48 02202025 */ move $a0, $s1 /* 0A854C 802E8D4C 0C0B9DA0 */ jal m64_read_u8 /* 0A8550 802E8D50 A3A80055 */ sb $t0, 0x55($sp) @@ -888,9 +888,9 @@ glabel L_EU_802E8D48 /* 0A855C 802E8D5C 028A5821 */ addu $t3, $s4, $t2 /* 0A8560 802E8D60 8D790030 */ lw $t9, 0x30($t3) /* 0A8564 802E8D64 03227021 */ addu $t6, $t9, $v0 -/* 0A8568 802E8D68 1000FD7F */ b .L_EU_802E8368 +/* 0A8568 802E8D68 1000FD7F */ b .L802E8368 /* 0A856C 802E8D6C A1D30058 */ sb $s3, 0x58($t6) -glabel L_EU_802E8D70 +glabel L802E8D70 /* 0A8570 802E8D70 02202025 */ move $a0, $s1 /* 0A8574 802E8D74 0C0B9DA0 */ jal m64_read_u8 /* 0A8578 802E8D78 A3A80055 */ sb $t0, 0x55($sp) @@ -899,27 +899,27 @@ glabel L_EU_802E8D70 /* 0A8584 802E8D84 028D7821 */ addu $t7, $s4, $t5 /* 0A8588 802E8D88 8DF80030 */ lw $t8, 0x30($t7) /* 0A858C 802E8D8C 03024821 */ addu $t1, $t8, $v0 -/* 0A8590 802E8D90 1000FD75 */ b .L_EU_802E8368 +/* 0A8590 802E8D90 1000FD75 */ b .L802E8368 /* 0A8594 802E8D94 81330058 */ lb $s3, 0x58($t1) -glabel L_EU_802E8D98 -.L_EU_802E8D98: +glabel L802E8D98 +.L802E8D98: /* 0A8598 802E8D98 02408825 */ move $s1, $s2 -.L080200B9C: +.L80200B9C: /* 0A859C 802E8D9C 24120010 */ li $s2, 16 /* 0A85A0 802E8DA0 00008025 */ move $s0, $zero -.L080200BA4: +.L80200BA4: /* 0A85A4 802E8DA4 8E240048 */ lw $a0, 0x48($s1) -/* 0A85A8 802E8DA8 50800004 */ beql $a0, $zero, .L080200BBC +/* 0A85A8 802E8DA8 50800004 */ beql $a0, $zero, .L80200BBC /* 0A85AC 802E8DAC 26100004 */ addiu $s0, $s0, 4 /* 0A85B0 802E8DB0 0C0B9DC2 */ jal seq_channel_layer_process_script /* 0A85B4 802E8DB4 00000000 */ nop /* 0A85B8 802E8DB8 26100004 */ addiu $s0, $s0, 4 -.L080200BBC: -/* 0A85BC 802E8DBC 1612FFF9 */ bne $s0, $s2, .L080200BA4 +.L80200BBC: +/* 0A85BC 802E8DBC 1612FFF9 */ bne $s0, $s2, .L80200BA4 /* 0A85C0 802E8DC0 26310004 */ addiu $s1, $s1, 4 -.L080200BC4: +.L80200BC4: /* 0A85C4 802E8DC4 8FBF002C */ lw $ra, 0x2c($sp) -.L080200BC8: +.L80200BC8: /* 0A85C8 802E8DC8 8FB00018 */ lw $s0, 0x18($sp) /* 0A85CC 802E8DCC 8FB1001C */ lw $s1, 0x1c($sp) /* 0A85D0 802E8DD0 8FB20020 */ lw $s2, 0x20($sp) diff --git a/asm/non_matchings/seq_channel_layer_process_script_us.s b/asm/non_matchings/seq_channel_layer_process_script_us.s index 32e57b67..fd64cbd0 100644 --- a/asm/non_matchings/seq_channel_layer_process_script_us.s +++ b/asm/non_matchings/seq_channel_layer_process_script_us.s @@ -1,33 +1,33 @@ .late_rodata glabel jtbl_80337C90 - .word L_U_8031C2DC - .word L_U_8031C298 - .word L_U_8031C6A0 - .word L_U_8031C6A0 - .word L_U_8031C328 - .word L_U_8031C23C - .word L_U_8031C6A0 - .word L_U_8031C6A0 - .word L_U_8031C200 + .word L8031C2DC + .word L8031C298 + .word L8031C6A0 + .word L8031C6A0 + .word L8031C328 + .word L8031C23C + .word L8031C6A0 + .word L8031C6A0 + .word L8031C200 glabel jtbl_80337CB4 - .word L_U_8031C36C - .word L_U_8031C3BC - .word L_U_8031C454 - .word L_U_8031C3E8 - .word L_U_8031C3E8 - .word L_U_8031C4A4 - .word L_U_8031C5C8 - .word L_U_8031C698 - .word L_U_8031C3BC - .word L_U_8031C36C + .word L8031C36C + .word L8031C3BC + .word L8031C454 + .word L8031C3E8 + .word L8031C3E8 + .word L8031C4A4 + .word L8031C5C8 + .word L8031C698 + .word L8031C3BC + .word L8031C36C glabel jtbl_80337CDC - .word L_U_8031CBE0 - .word L_U_8031CBEC - .word L_U_8031CBE0 - .word L_U_8031CBEC - .word L_U_8031CBE0 + .word L8031CBE0 + .word L8031CBEC + .word L8031CBE0 + .word L8031CBEC + .word L8031CBE0 .text glabel seq_channel_layer_process_script @@ -117,7 +117,7 @@ glabel seq_channel_layer_process_script /* 0D71F4 8031C1F4 8C398E84 */ lw $t9, %lo(jtbl_80337CB4)($at) /* 0D71F8 8031C1F8 03200008 */ jr $t9 /* 0D71FC 8031C1FC 00000000 */ nop -glabel L_U_8031C200 +glabel L8031C200 /* 0D7200 8031C200 26020054 */ addiu $v0, $s0, 0x54 /* 0D7204 8031C204 90430018 */ lbu $v1, 0x18($v0) /* 0D7208 8031C208 14600005 */ bnez $v1, .L8031C220 @@ -134,7 +134,7 @@ glabel L_U_8031C200 /* 0D7230 8031C230 8F2E0004 */ lw $t6, 4($t9) /* 0D7234 8031C234 1000FFD7 */ b .L8031C194 /* 0D7238 8031C238 AC4E0000 */ sw $t6, ($v0) -glabel L_U_8031C23C +glabel L8031C23C /* 0D723C 8031C23C 26020054 */ addiu $v0, $s0, 0x54 /* 0D7240 8031C240 8C430000 */ lw $v1, ($v0) /* 0D7244 8031C244 90640000 */ lbu $a0, ($v1) @@ -158,7 +158,7 @@ glabel L_U_8031C23C /* 0D728C 8031C28C 01CFC821 */ addu $t9, $t6, $t7 /* 0D7290 8031C290 1000FFC0 */ b .L8031C194 /* 0D7294 8031C294 AC590000 */ sw $t9, ($v0) -glabel L_U_8031C298 +glabel L8031C298 /* 0D7298 8031C298 26020054 */ addiu $v0, $s0, 0x54 /* 0D729C 8031C29C 8C430000 */ lw $v1, ($v0) /* 0D72A0 8031C2A0 904E0018 */ lbu $t6, 0x18($v0) @@ -176,7 +176,7 @@ glabel L_U_8031C298 /* 0D72D0 8031C2D0 0059C021 */ addu $t8, $v0, $t9 /* 0D72D4 8031C2D4 1000FFAF */ b .L8031C194 /* 0D72D8 8031C2D8 AF0E0000 */ sw $t6, ($t8) -glabel L_U_8031C2DC +glabel L8031C2DC /* 0D72DC 8031C2DC 26020054 */ addiu $v0, $s0, 0x54 /* 0D72E0 8031C2E0 904F0018 */ lbu $t7, 0x18($v0) /* 0D72E4 8031C2E4 004F2021 */ addu $a0, $v0, $t7 @@ -197,7 +197,7 @@ glabel L_U_8031C2DC /* 0D731C 8031C31C 246FFFFF */ addiu $t7, $v1, -1 /* 0D7320 8031C320 1000FF9C */ b .L8031C194 /* 0D7324 8031C324 A04F0018 */ sb $t7, 0x18($v0) -glabel L_U_8031C328 +glabel L8031C328 /* 0D7328 8031C328 26020054 */ addiu $v0, $s0, 0x54 /* 0D732C 8031C32C 8C430000 */ lw $v1, ($v0) /* 0D7330 8031C330 90640000 */ lbu $a0, ($v1) @@ -215,7 +215,7 @@ glabel L_U_8031C328 /* 0D7360 8031C360 032EC021 */ addu $t8, $t9, $t6 /* 0D7364 8031C364 1000FF8B */ b .L8031C194 /* 0D7368 8031C368 AC580000 */ sw $t8, ($v0) -glabel L_U_8031C36C +glabel L8031C36C /* 0D736C 8031C36C 26020054 */ addiu $v0, $s0, 0x54 /* 0D7370 8031C370 8C430000 */ lw $v1, ($v0) /* 0D7374 8031C374 240100C1 */ li $at, 193 @@ -237,7 +237,7 @@ glabel L_U_8031C36C /* 0D73B0 8031C3B0 46005402 */ mul.s $f16, $f10, $f0 /* 0D73B4 8031C3B4 1000FF77 */ b .L8031C194 /* 0D73B8 8031C3B8 E6100028 */ swc1 $f16, 0x28($s0) -glabel L_U_8031C3BC +glabel L8031C3BC /* 0D73BC 8031C3BC 26020054 */ addiu $v0, $s0, 0x54 /* 0D73C0 8031C3C0 8C430000 */ lw $v1, ($v0) /* 0D73C4 8031C3C4 240100C9 */ li $at, 201 @@ -250,7 +250,7 @@ glabel L_U_8031C3BC .L8031C3E0: /* 0D73E0 8031C3E0 1000FF6C */ b .L8031C194 /* 0D73E4 8031C3E4 A604001E */ sh $a0, 0x1e($s0) -glabel L_U_8031C3E8 +glabel L8031C3E8 /* 0D73E8 8031C3E8 240100C4 */ li $at, 196 /* 0D73EC 8031C3EC 14A10003 */ bne $a1, $at, .L8031C3FC /* 0D73F0 8031C3F0 02002025 */ move $a0, $s0 @@ -280,7 +280,7 @@ glabel L_U_8031C3E8 /* 0D7448 8031C448 8FAC005C */ lw $t4, 0x5c($sp) /* 0D744C 8031C44C 1000FF51 */ b .L8031C194 /* 0D7450 8031C450 8FAD0058 */ lw $t5, 0x58($sp) -glabel L_U_8031C454 +glabel L8031C454 /* 0D7454 8031C454 26020054 */ addiu $v0, $s0, 0x54 /* 0D7458 8031C458 8C430000 */ lw $v1, ($v0) /* 0D745C 8031C45C 90640000 */ lbu $a0, ($v1) @@ -302,7 +302,7 @@ glabel L_U_8031C454 /* 0D7498 8031C498 308AFFFF */ andi $t2, $a0, 0xffff /* 0D749C 8031C49C 1000FF3D */ b .L8031C194 /* 0D74A0 8031C4A0 A6050038 */ sh $a1, 0x38($s0) -glabel L_U_8031C4A4 +glabel L8031C4A4 /* 0D74A4 8031C4A4 26020054 */ addiu $v0, $s0, 0x54 /* 0D74A8 8031C4A8 8C430000 */ lw $v1, ($v0) /* 0D74AC 8031C4AC 246F0001 */ addiu $t7, $v1, 1 @@ -383,7 +383,7 @@ glabel L_U_8031C4A4 /* 0D75BC 8031C5BC AC2F2E50 */ sw $t7, %lo(gAudioErrorFlags)($at) /* 0D75C0 8031C5C0 1000FEF4 */ b .L8031C194 /* 0D75C4 8031C5C4 ACA00000 */ sw $zero, ($a1) -glabel L_U_8031C5C8 +glabel L8031C5C8 /* 0D75C8 8031C5C8 26020054 */ addiu $v0, $s0, 0x54 /* 0D75CC 8031C5CC 8C430000 */ lw $v1, ($v0) /* 0D75D0 8031C5D0 24790001 */ addiu $t9, $v1, 1 @@ -439,10 +439,10 @@ glabel L_U_8031C5C8 /* 0D768C 8031C68C 308AFFFF */ andi $t2, $a0, 0xffff /* 0D7690 8031C690 1000FEC0 */ b .L8031C194 /* 0D7694 8031C694 A604001C */ sh $a0, 0x1c($s0) -glabel L_U_8031C698 +glabel L8031C698 /* 0D7698 8031C698 1000FEBE */ b .L8031C194 /* 0D769C 8031C69C A2000004 */ sb $zero, 4($s0) -glabel L_U_8031C6A0 +glabel L8031C6A0 .L8031C6A0: /* 0D76A0 8031C6A0 30A200F0 */ andi $v0, $a1, 0xf0 /* 0D76A4 8031C6A4 240100D0 */ li $at, 208 @@ -816,11 +816,11 @@ glabel L_U_8031C6A0 /* 0D7BD4 8031CBD4 8C398EAC */ lw $t9, %lo(jtbl_80337CDC)($at) /* 0D7BD8 8031CBD8 03200008 */ jr $t9 /* 0D7BDC 8031CBDC 00000000 */ nop -glabel L_U_8031CBE0 +glabel L8031CBE0 /* 0D7BE0 8031CBE0 E7A20024 */ swc1 $f2, 0x24($sp) /* 0D7BE4 8031CBE4 10000005 */ b .L8031CBFC /* 0D7BE8 8031CBE8 46006006 */ mov.s $f0, $f12 -glabel L_U_8031CBEC +glabel L8031CBEC /* 0D7BEC 8031CBEC 46001006 */ mov.s $f0, $f2 /* 0D7BF0 8031CBF0 10000002 */ b .L8031CBFC /* 0D7BF4 8031CBF4 E7AC0024 */ swc1 $f12, 0x24($sp) diff --git a/asmdiff.us.sh b/asmdiff.us.sh deleted file mode 100755 index 9ad32c1a..00000000 --- a/asmdiff.us.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -OBJDUMP="mips-linux-gnu-objdump -D -z -bbinary -mmips -EB" -OPTIONS="--start-address=$(($1)) --stop-address=$(($2))" -$OBJDUMP $OPTIONS baserom.us.z64 > baserom.us.dump -$OBJDUMP $OPTIONS build/us/sm64.us.z64 > sm64.us.dump -diff baserom.us.dump sm64.us.dump | colordiff - diff --git a/assets.json b/assets.json index b2ebf99e..422858ee 100644 --- a/assets.json +++ b/assets.json @@ -7,6 +7,65 @@ "@sound tbl eu": [2216704,{"us":[5846368],"eu":[5723888]}], "@sound tbl jp": [1793408,{"jp":[5833216]}], "@sound tbl us": [2216704,{"us":[5846368],"eu":[5723888]}], +"textures/ipl3_raw/ipl3_font_00.ia1.png": [13,14,23,{"jp":[2928],"us":[2928],"eu":[2928],"sh":[2928]}], +"textures/ipl3_raw/ipl3_font_01.ia1.png": [13,14,23,{"jp":[2951],"us":[2951],"eu":[2951],"sh":[2951]}], +"textures/ipl3_raw/ipl3_font_02.ia1.png": [13,14,23,{"jp":[2974],"us":[2974],"eu":[2974],"sh":[2974]}], +"textures/ipl3_raw/ipl3_font_03.ia1.png": [13,14,23,{"jp":[2997],"us":[2997],"eu":[2997],"sh":[2997]}], +"textures/ipl3_raw/ipl3_font_04.ia1.png": [13,14,23,{"jp":[3020],"us":[3020],"eu":[3020],"sh":[3020]}], +"textures/ipl3_raw/ipl3_font_05.ia1.png": [13,14,23,{"jp":[3043],"us":[3043],"eu":[3043],"sh":[3043]}], +"textures/ipl3_raw/ipl3_font_06.ia1.png": [13,14,23,{"jp":[3066],"us":[3066],"eu":[3066],"sh":[3066]}], +"textures/ipl3_raw/ipl3_font_07.ia1.png": [13,14,23,{"jp":[3089],"us":[3089],"eu":[3089],"sh":[3089]}], +"textures/ipl3_raw/ipl3_font_08.ia1.png": [13,14,23,{"jp":[3112],"us":[3112],"eu":[3112],"sh":[3112]}], +"textures/ipl3_raw/ipl3_font_09.ia1.png": [13,14,23,{"jp":[3135],"us":[3135],"eu":[3135],"sh":[3135]}], +"textures/ipl3_raw/ipl3_font_10.ia1.png": [13,14,23,{"jp":[3158],"us":[3158],"eu":[3158],"sh":[3158]}], +"textures/ipl3_raw/ipl3_font_11.ia1.png": [13,14,23,{"jp":[3181],"us":[3181],"eu":[3181],"sh":[3181]}], +"textures/ipl3_raw/ipl3_font_12.ia1.png": [13,14,23,{"jp":[3204],"us":[3204],"eu":[3204],"sh":[3204]}], +"textures/ipl3_raw/ipl3_font_13.ia1.png": [13,14,23,{"jp":[3227],"us":[3227],"eu":[3227],"sh":[3227]}], +"textures/ipl3_raw/ipl3_font_14.ia1.png": [13,14,23,{"jp":[3250],"us":[3250],"eu":[3250],"sh":[3250]}], +"textures/ipl3_raw/ipl3_font_15.ia1.png": [13,14,23,{"jp":[3273],"us":[3273],"eu":[3273],"sh":[3273]}], +"textures/ipl3_raw/ipl3_font_16.ia1.png": [13,14,23,{"jp":[3296],"us":[3296],"eu":[3296],"sh":[3296]}], +"textures/ipl3_raw/ipl3_font_17.ia1.png": [13,14,23,{"jp":[3319],"us":[3319],"eu":[3319],"sh":[3319]}], +"textures/ipl3_raw/ipl3_font_18.ia1.png": [13,14,23,{"jp":[3342],"us":[3342],"eu":[3342],"sh":[3342]}], +"textures/ipl3_raw/ipl3_font_19.ia1.png": [13,14,23,{"jp":[3365],"us":[3365],"eu":[3365],"sh":[3365]}], +"textures/ipl3_raw/ipl3_font_20.ia1.png": [13,14,23,{"jp":[3388],"us":[3388],"eu":[3388],"sh":[3388]}], +"textures/ipl3_raw/ipl3_font_21.ia1.png": [13,14,23,{"jp":[3411],"us":[3411],"eu":[3411],"sh":[3411]}], +"textures/ipl3_raw/ipl3_font_22.ia1.png": [13,14,23,{"jp":[3434],"us":[3434],"eu":[3434],"sh":[3434]}], +"textures/ipl3_raw/ipl3_font_23.ia1.png": [13,14,23,{"jp":[3457],"us":[3457],"eu":[3457],"sh":[3457]}], +"textures/ipl3_raw/ipl3_font_24.ia1.png": [13,14,23,{"jp":[3480],"us":[3480],"eu":[3480],"sh":[3480]}], +"textures/ipl3_raw/ipl3_font_25.ia1.png": [13,14,23,{"jp":[3503],"us":[3503],"eu":[3503],"sh":[3503]}], +"textures/ipl3_raw/ipl3_font_26.ia1.png": [13,14,23,{"jp":[3526],"us":[3526],"eu":[3526],"sh":[3526]}], +"textures/ipl3_raw/ipl3_font_27.ia1.png": [13,14,23,{"jp":[3549],"us":[3549],"eu":[3549],"sh":[3549]}], +"textures/ipl3_raw/ipl3_font_28.ia1.png": [13,14,23,{"jp":[3572],"us":[3572],"eu":[3572],"sh":[3572]}], +"textures/ipl3_raw/ipl3_font_29.ia1.png": [13,14,23,{"jp":[3595],"us":[3595],"eu":[3595],"sh":[3595]}], +"textures/ipl3_raw/ipl3_font_30.ia1.png": [13,14,23,{"jp":[3618],"us":[3618],"eu":[3618],"sh":[3618]}], +"textures/ipl3_raw/ipl3_font_31.ia1.png": [13,14,23,{"jp":[3641],"us":[3641],"eu":[3641],"sh":[3641]}], +"textures/ipl3_raw/ipl3_font_32.ia1.png": [13,14,23,{"jp":[3664],"us":[3664],"eu":[3664],"sh":[3664]}], +"textures/ipl3_raw/ipl3_font_33.ia1.png": [13,14,23,{"jp":[3687],"us":[3687],"eu":[3687],"sh":[3687]}], +"textures/ipl3_raw/ipl3_font_34.ia1.png": [13,14,23,{"jp":[3710],"us":[3710],"eu":[3710],"sh":[3710]}], +"textures/ipl3_raw/ipl3_font_35.ia1.png": [13,14,23,{"jp":[3733],"us":[3733],"eu":[3733],"sh":[3733]}], +"textures/ipl3_raw/ipl3_font_36.ia1.png": [13,14,23,{"jp":[3756],"us":[3756],"eu":[3756],"sh":[3756]}], +"textures/ipl3_raw/ipl3_font_37.ia1.png": [13,14,23,{"jp":[3779],"us":[3779],"eu":[3779],"sh":[3779]}], +"textures/ipl3_raw/ipl3_font_38.ia1.png": [13,14,23,{"jp":[3802],"us":[3802],"eu":[3802],"sh":[3802]}], +"textures/ipl3_raw/ipl3_font_39.ia1.png": [13,14,23,{"jp":[3825],"us":[3825],"eu":[3825],"sh":[3825]}], +"textures/ipl3_raw/ipl3_font_40.ia1.png": [13,14,23,{"jp":[3848],"us":[3848],"eu":[3848],"sh":[3848]}], +"textures/ipl3_raw/ipl3_font_41.ia1.png": [13,14,23,{"jp":[3871],"us":[3871],"eu":[3871],"sh":[3871]}], +"textures/ipl3_raw/ipl3_font_42.ia1.png": [13,14,23,{"jp":[3894],"us":[3894],"eu":[3894],"sh":[3894]}], +"textures/ipl3_raw/ipl3_font_43.ia1.png": [13,14,23,{"jp":[3917],"us":[3917],"eu":[3917],"sh":[3917]}], +"textures/ipl3_raw/ipl3_font_44.ia1.png": [13,14,23,{"jp":[3940],"us":[3940],"eu":[3940],"sh":[3940]}], +"textures/ipl3_raw/ipl3_font_45.ia1.png": [13,14,23,{"jp":[3963],"us":[3963],"eu":[3963],"sh":[3963]}], +"textures/ipl3_raw/ipl3_font_46.ia1.png": [13,14,23,{"jp":[3986],"us":[3986],"eu":[3986],"sh":[3986]}], +"textures/ipl3_raw/ipl3_font_47.ia1.png": [13,14,23,{"jp":[4009],"us":[4009],"eu":[4009],"sh":[4009]}], +"textures/ipl3_raw/ipl3_font_48.ia1.png": [13,14,23,{"jp":[4032],"us":[4032],"eu":[4032],"sh":[4032]}], +"textures/ipl3_raw/ipl3_font_49.ia1.png": [13,14,23,{"jp":[4055],"us":[4055],"eu":[4055],"sh":[4055]}], +"textures/crash_screen/crash_font_01234.ia1.png": [32,7,28,{"eu":[757168],"sh":[805680]}], +"textures/crash_screen/crash_font_56789.ia1.png": [32,7,28,{"eu":[757196],"sh":[805708]}], +"textures/crash_screen/crash_font_ABCDE.ia1.png": [32,7,28,{"eu":[757224],"sh":[805736]}], +"textures/crash_screen/crash_font_FGHIJ.ia1.png": [32,7,28,{"eu":[757252],"sh":[805764]}], +"textures/crash_screen/crash_font_KLMNO.ia1.png": [32,7,28,{"eu":[757280],"sh":[805792]}], +"textures/crash_screen/crash_font_PQRST.ia1.png": [32,7,28,{"eu":[757308],"sh":[805820]}], +"textures/crash_screen/crash_font_UVWXY.ia1.png": [32,7,28,{"eu":[757336],"sh":[805848]}], +"textures/crash_screen/crash_font_Zsym1.ia1.png": [32,7,28,{"eu":[757364],"sh":[805876]}], +"textures/crash_screen/crash_font_sym2.ia1.png": [32,7,28,{"eu":[757392],"sh":[805904]}], "actors/amp/amp_body.rgba16.png": [32,32,2048,{"jp":[2032944,6936],"us":[2040320,6936],"eu":[1912288,6936],"sh":[1888800,6936]}], "actors/amp/amp_electricity.rgba16.png": [16,32,1024,{"jp":[2032944,3864],"us":[2040320,3864],"eu":[1912288,3864],"sh":[1888800,3864]}], "actors/amp/amp_eyes.rgba16.png": [32,32,2048,{"jp":[2032944,4888],"us":[2040320,4888],"eu":[1912288,4888],"sh":[1888800,4888]}], diff --git a/bin/eu/translation_de.c b/bin/eu/translation_de.c index 6be959e0..d7c1f597 100644 --- a/bin/eu/translation_de.c +++ b/bin/eu/translation_de.c @@ -1,5 +1,7 @@ // SM64 (EU) Segment 19 - Deutsch +#include "macros.h" + #include "game/ingame_menu.h" #include "make_const_nonconst.h" diff --git a/bin/eu/translation_en.c b/bin/eu/translation_en.c index e6f2cacd..9817bc5a 100644 --- a/bin/eu/translation_en.c +++ b/bin/eu/translation_en.c @@ -1,5 +1,7 @@ // SM64 (EU) Segment 19 - English +#include "macros.h" + #include "game/ingame_menu.h" #include "make_const_nonconst.h" diff --git a/bin/eu/translation_fr.c b/bin/eu/translation_fr.c index ed0d0572..119839c9 100644 --- a/bin/eu/translation_fr.c +++ b/bin/eu/translation_fr.c @@ -1,5 +1,7 @@ // SM64 (EU) Segment 19 - Français +#include "macros.h" + #include "game/ingame_menu.h" #include "make_const_nonconst.h" diff --git a/bin/segment2.c b/bin/segment2.c index 5d5398aa..a6756e95 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2499,23 +2499,19 @@ static const Lights1 segment2_lights_unused = gdSPDefLights1( // 0x02014470 - 0x020144B0 static const Mtx matrix_identity = { - {{1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}} - }; // 0x020144B0 - 0x020144F0 static const Mtx matrix_fullscreen = { - {{2.0f / SCREEN_WIDTH, 0.0f, 0.0f, 0.0f}, {0.0f, 2.0f / SCREEN_HEIGHT, 0.0f, 0.0f}, {0.0f, 0.0f, -1.0f, 0.0f}, {-1.0f, -1.0f, -1.0f, 1.0f}} - }; diff --git a/data/behavior_data.c b/data/behavior_data.c index 3b4af5a0..e036469d 100644 --- a/data/behavior_data.c +++ b/data/behavior_data.c @@ -3399,7 +3399,7 @@ const BehaviorScript bhvShallowWaterWave[] = { OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE), DISABLE_RENDERING(), BEGIN_REPEAT(5), - SPAWN_WATER_DROPLET(&sShallowWaterWaveDropletParams), + SPAWN_WATER_DROPLET(&gShallowWaterWaveDropletParams), END_REPEAT_CONTINUE(), DELAY(1), PARENT_BIT_CLEAR(oActiveParticleFlags, ACTIVE_PARTICLE_SHALLOW_WATER_WAVE), @@ -3414,7 +3414,7 @@ const BehaviorScript bhvShallowWaterSplash[] = { OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE), DISABLE_RENDERING(), BEGIN_REPEAT(18), - SPAWN_WATER_DROPLET(&sShallowWaterSplashDropletParams), + SPAWN_WATER_DROPLET(&gShallowWaterSplashDropletParams), END_REPEAT_CONTINUE(), CALL_NATIVE(bhv_shallow_water_splash_init), DELAY(1), @@ -3542,19 +3542,19 @@ const BehaviorScript bhvUnlockDoorStar[] = { END_LOOP(), }; -const BehaviorScript bhvWarps60[] = { +const BehaviorScript bhvInstantActiveWarp[] = { BREAK(), }; -const BehaviorScript bhvWarps64[] = { +const BehaviorScript bhvAirborneWarp[] = { BREAK(), }; -const BehaviorScript bhvWarps68[] = { +const BehaviorScript bhvHardAirKnockBackWarp[] = { BREAK(), }; -const BehaviorScript bhvWarps6C[] = { +const BehaviorScript bhvSpinAirborneCircleWarp[] = { BREAK(), }; @@ -3562,15 +3562,15 @@ const BehaviorScript bhvDeathWarp[] = { BREAK(), }; -const BehaviorScript bhvWarps74[] = { +const BehaviorScript bhvSpinAirborneWarp[] = { BREAK(), }; -const BehaviorScript bhvWarps78[] = { +const BehaviorScript bhvFlyingWarp[] = { BREAK(), }; -const BehaviorScript bhvWarps7C[] = { +const BehaviorScript bhvPaintingStarCollectWarp[] = { BREAK(), }; @@ -3578,23 +3578,23 @@ const BehaviorScript bhvPaintingDeathWarp[] = { BREAK(), }; -const BehaviorScript bhvWarps84[] = { +const BehaviorScript bhvAirborneDeathWarp[] = { BREAK(), }; -const BehaviorScript bhvWarps88[] = { +const BehaviorScript bhvAirborneStarCollectWarp[] = { BREAK(), }; -const BehaviorScript bhvWarps8C[] = { +const BehaviorScript bhvLaunchStarCollectWarp[] = { BREAK(), }; -const BehaviorScript bhvWarps90[] = { +const BehaviorScript bhvLaunchDeathWarp[] = { BREAK(), }; -const BehaviorScript bhvWarps94[] = { +const BehaviorScript bhvSwimmingWarp[] = { BREAK(), }; @@ -5566,7 +5566,7 @@ const BehaviorScript bhvMrBlizzard[] = { SET_HOME(), SET_OBJ_PHYSICS(/*Wall hitbox radius*/ 30, /*Gravity*/ -400, /*Bounciness*/ 0, /*Drag strength*/ 1000, /*Friction*/ 1000, /*Buoyancy*/ 200, /*Unused*/ 0, 0), CALL_NATIVE(bhv_mr_blizzard_init), - SET_FLOAT(oMrBlizzardUnkF4, 1), + SET_FLOAT(oMrBlizzardScale, 1), BEGIN_LOOP(), CALL_NATIVE(bhv_mr_blizzard_update), END_LOOP(), diff --git a/diff.py b/diff.py index 6bafc0f6..e379eb0e 100755 --- a/diff.py +++ b/diff.py @@ -12,21 +12,25 @@ import threading import queue import time + def fail(msg): print(msg, file=sys.stderr) sys.exit(1) + try: import attr from colorama import Fore, Style, Back import ansiwrap import watchdog except ModuleNotFoundError as e: - fail(f"Missing prerequisite python module {e.name}. " - "Run `python3 -m pip install --user colorama ansiwrap attrs watchdog` to install prerequisites.") + fail( + f"Missing prerequisite python module {e.name}. " + "Run `python3 -m pip install --user colorama ansiwrap attrs watchdog` to install prerequisites." + ) # Prefer to use diff_settings.py from the current working directory -sys.path.insert(0, '.') +sys.path.insert(0, ".") try: import diff_settings except ModuleNotFoundError: @@ -34,38 +38,89 @@ except ModuleNotFoundError: # ==== CONFIG ==== -parser = argparse.ArgumentParser( - description="Diff MIPS assembly.") -parser.add_argument('start', - help="Function name or address to start diffing from.") -parser.add_argument('end', nargs='?', - help="Address to end diff at.") -parser.add_argument('-o', dest='diff_obj', action='store_true', - help="Diff .o files rather than a whole binary. This makes it possible to see symbol names. (Recommended)") -parser.add_argument('--base-asm', dest='base_asm', metavar='FILE', - help="Read assembly from given file instead of configured base img.") -parser.add_argument('--write-asm', dest='write_asm', metavar='FILE', - help="Write the current assembly output to file, e.g. for use with --base-asm.") -parser.add_argument('-m', '--make', dest='make', action='store_true', - help="Automatically run 'make' on the .o file or binary before diffing.") -parser.add_argument('-l', '--skip-lines', dest='skip_lines', type=int, default=0, - help="Skip the first N lines of output.") -parser.add_argument('-f', '--stop-jr-ra', dest='stop_jrra', action='store_true', - help="Stop disassembling at the first 'jr ra'. Some functions have multiple return points, so use with care!") -parser.add_argument('-i', '--ignore-large-imms', dest='ignore_large_imms', action='store_true', - help="Pretend all large enough immediates are the same.") -parser.add_argument('-B', '--no-show-branches', dest='show_branches', action='store_false', - help="Don't visualize branches/branch targets.") -parser.add_argument('-S', '--base-shift', dest='base_shift', type=str, default='0', - help="Diff position X in our img against position X + shift in the base img. " - "Arithmetic is allowed, so e.g. |-S \"0x1234 - 0x4321\"| is a reasonable " - "flag to pass if it is known that position 0x1234 in the base img syncs " - "up with position 0x4321 in our img. Not supported together with -o.") -parser.add_argument('-w', '--watch', dest='watch', action='store_true', - help="Automatically update when source/object files change. " - "Recommended in combination with -m.") -parser.add_argument('--width', dest='column_width', type=int, default=50, - help="Sets the width of the left and right view column.") +parser = argparse.ArgumentParser(description="Diff MIPS assembly.") +parser.add_argument("start", help="Function name or address to start diffing from.") +parser.add_argument("end", nargs="?", help="Address to end diff at.") +parser.add_argument( + "-o", + dest="diff_obj", + action="store_true", + help="Diff .o files rather than a whole binary. This makes it possible to see symbol names. (Recommended)", +) +parser.add_argument( + "--base-asm", + dest="base_asm", + metavar="FILE", + help="Read assembly from given file instead of configured base img.", +) +parser.add_argument( + "--write-asm", + dest="write_asm", + metavar="FILE", + help="Write the current assembly output to file, e.g. for use with --base-asm.", +) +parser.add_argument( + "-m", + "--make", + dest="make", + action="store_true", + help="Automatically run 'make' on the .o file or binary before diffing.", +) +parser.add_argument( + "-l", + "--skip-lines", + dest="skip_lines", + type=int, + default=0, + help="Skip the first N lines of output.", +) +parser.add_argument( + "-f", + "--stop-jr-ra", + dest="stop_jrra", + action="store_true", + help="Stop disassembling at the first 'jr ra'. Some functions have multiple return points, so use with care!", +) +parser.add_argument( + "-i", + "--ignore-large-imms", + dest="ignore_large_imms", + action="store_true", + help="Pretend all large enough immediates are the same.", +) +parser.add_argument( + "-B", + "--no-show-branches", + dest="show_branches", + action="store_false", + help="Don't visualize branches/branch targets.", +) +parser.add_argument( + "-S", + "--base-shift", + dest="base_shift", + type=str, + default="0", + help="Diff position X in our img against position X + shift in the base img. " + 'Arithmetic is allowed, so e.g. |-S "0x1234 - 0x4321"| is a reasonable ' + "flag to pass if it is known that position 0x1234 in the base img syncs " + "up with position 0x4321 in our img. Not supported together with -o.", +) +parser.add_argument( + "-w", + "--watch", + dest="watch", + action="store_true", + help="Automatically update when source/object files change. " + "Recommended in combination with -m.", +) +parser.add_argument( + "--width", + dest="column_width", + type=int, + default=50, + help="Sets the width of the left and right view column.", +) # Project-specific flags, e.g. different versions/make arguments. if hasattr(diff_settings, "add_custom_arguments"): @@ -77,11 +132,11 @@ args = parser.parse_args() config = {} diff_settings.apply(config, args) -baseimg = config.get('baseimg', None) -myimg = config.get('myimg', None) -mapfile = config.get('mapfile', None) -makeflags = config.get('makeflags', []) -source_directories = config.get('source_directories', None) +baseimg = config.get("baseimg", None) +myimg = config.get("myimg", None) +mapfile = config.get("mapfile", None) +makeflags = config.get("makeflags", []) +source_directories = config.get("source_directories", None) MAX_FUNCTION_SIZE_LINES = 1024 MAX_FUNCTION_SIZE_BYTES = 1024 * 4 @@ -98,19 +153,23 @@ COLOR_ROTATION = [ Fore.LIGHTBLACK_EX, ] -BUFFER_CMD = ["tail", "-c", str(10**9)] +BUFFER_CMD = ["tail", "-c", str(10 ** 9)] LESS_CMD = ["less", "-Ric"] DEBOUNCE_DELAY = 0.1 -FS_WATCH_EXTENSIONS = ['.c', '.h'] +FS_WATCH_EXTENSIONS = [".c", ".h"] # ==== LOGIC ==== binutils_prefix = None -for binutils_cand in ['mips-linux-gnu-', 'mips64-elf-']: +for binutils_cand in ["mips-linux-gnu-", "mips64-elf-"]: try: - subprocess.check_call([binutils_cand + "objdump", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.check_call( + [binutils_cand + "objdump", "--version"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) binutils_prefix = binutils_cand break except subprocess.CalledProcessError: @@ -119,7 +178,10 @@ for binutils_cand in ['mips-linux-gnu-', 'mips64-elf-']: pass if not binutils_prefix: - fail("Missing binutils; please ensure mips-linux-gnu-objdump or mips64-elf-objdump exist.") + fail( + "Missing binutils; please ensure mips-linux-gnu-objdump or mips64-elf-objdump exist." + ) + def eval_int(expr, emsg=None): try: @@ -132,33 +194,46 @@ def eval_int(expr, emsg=None): fail(emsg) return None + def run_make(target, capture_output=False): if capture_output: - return subprocess.run(["make"] + makeflags + [target], stderr=subprocess.PIPE, stdout=subprocess.PIPE) + return subprocess.run( + ["make"] + makeflags + [target], + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + ) else: subprocess.check_call(["make"] + makeflags + [target]) + def restrict_to_function(dump, fn_name): out = [] - search = f'<{fn_name}>:' + search = f"<{fn_name}>:" found = False - for line in dump.split('\n'): + for line in dump.split("\n"): if found: if len(out) >= MAX_FUNCTION_SIZE_LINES: break out.append(line) elif search in line: found = True - return '\n'.join(out) + return "\n".join(out) + def run_objdump(cmd): flags, target, restrict = cmd - out = subprocess.check_output([binutils_prefix + "objdump"] + flags + [target], universal_newlines=True) + out = subprocess.check_output( + [binutils_prefix + "objdump"] + flags + [target], universal_newlines=True + ) if restrict is not None: return restrict_to_function(out, restrict) return out -base_shift = eval_int(args.base_shift, "Failed to parse --base-shift (-S) argument as an integer.") + +base_shift = eval_int( + args.base_shift, "Failed to parse --base-shift (-S) argument as an integer." +) + def search_map_file(fn_name): if not mapfile: @@ -166,7 +241,7 @@ def search_map_file(fn_name): try: with open(mapfile) as f: - lines = f.read().split('\n') + lines = f.read().split("\n") except Exception: fail(f"Failed to open map file {mapfile} for reading.") @@ -174,22 +249,23 @@ def search_map_file(fn_name): cur_objfile = None ram_to_rom = None cands = [] - last_line = '' + last_line = "" for line in lines: - if line.startswith(' .text'): + if line.startswith(" .text"): cur_objfile = line.split()[3] - if 'load address' in line: + if "load address" in line: tokens = last_line.split() + line.split() ram = int(tokens[1], 0) rom = int(tokens[5], 0) ram_to_rom = rom - ram - if line.endswith(' ' + fn_name): + if line.endswith(" " + fn_name): ram = int(line.split()[0], 0) if cur_objfile is not None and ram_to_rom is not None: cands.append((cur_objfile, ram + ram_to_rom)) last_line = line except Exception as e: import traceback + traceback.print_exc() fail(f"Internal error while parsing map file") @@ -199,12 +275,13 @@ def search_map_file(fn_name): return cands[0] return None, None + def dump_objfile(): if base_shift: fail("--base-shift not compatible with -o") if args.end is not None: fail("end address not supported together with -o") - if args.start.startswith('0'): + if args.start.startswith("0"): fail("numerical start address not supported with -o; pass a function name") objfile, _ = search_map_file(args.start) @@ -225,9 +302,10 @@ def dump_objfile(): return ( objfile, (objdump_flags, refobjfile, args.start), - (objdump_flags, objfile, args.start) + (objdump_flags, objfile, args.start), ) + def dump_binary(): if not baseimg or not myimg: fail("Missing myimg/baseimg in config.") @@ -242,37 +320,53 @@ def dump_binary(): end_addr = eval_int(args.end, "End address must be an integer expression.") else: end_addr = start_addr + MAX_FUNCTION_SIZE_BYTES - objdump_flags = ['-Dz', '-bbinary', '-mmips', '-EB'] - flags1 = [f"--start-address={start_addr + base_shift}", f"--stop-address={end_addr + base_shift}"] + objdump_flags = ["-Dz", "-bbinary", "-mmips", "-EB"] + flags1 = [ + f"--start-address={start_addr + base_shift}", + f"--stop-address={end_addr + base_shift}", + ] flags2 = [f"--start-address={start_addr}", f"--stop-address={end_addr}"] return ( myimg, (objdump_flags + flags1, baseimg, None), - (objdump_flags + flags2, myimg, None) + (objdump_flags + flags2, myimg, None), ) + # Alignment with ANSI colors is broken, let's fix it. def ansi_ljust(s, width): needed = width - ansiwrap.ansilen(s) if needed > 0: - return s + ' ' * needed + return s + " " * needed else: return s -re_int = re.compile(r'[0-9]+') -re_comments = re.compile(r'<.*?>') -re_regs = re.compile(r'\b(a[0-3]|t[0-9]|s[0-7]|at|v[01]|f[12]?[0-9]|f3[01]|fp)\b') -re_sprel = re.compile(r',([1-9][0-9]*|0x[1-9a-f][0-9a-f]*)\(sp\)') -re_large_imm = re.compile(r'-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}') -forbidden = set(string.ascii_letters + '_') -branch_likely_instructions = set([ - 'beql', 'bnel', 'beqzl', 'bnezl', 'bgezl', 'bgtzl', 'blezl', 'bltzl', - 'bc1tl', 'bc1fl' -]) -branch_instructions = set([ - 'b', 'beq', 'bne', 'beqz', 'bnez', 'bgez', 'bgtz', 'blez', 'bltz', - 'bc1t', 'bc1f' -] + list(branch_likely_instructions)) + +re_int = re.compile(r"[0-9]+") +re_comments = re.compile(r"<.*?>") +re_regs = re.compile(r"\b(a[0-3]|t[0-9]|s[0-7]|at|v[01]|f[12]?[0-9]|f3[01]|fp)\b") +re_sprel = re.compile(r",([1-9][0-9]*|0x[1-9a-f][0-9a-f]*)\(sp\)") +re_large_imm = re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}") +forbidden = set(string.ascii_letters + "_") +branch_likely_instructions = set( + [ + "beql", + "bnel", + "beqzl", + "bnezl", + "bgezl", + "bgtzl", + "blezl", + "bltzl", + "bc1tl", + "bc1fl", + ] +) +branch_instructions = set( + ["b", "beq", "bne", "beqz", "bnez", "bgez", "bgtz", "blez", "bltz", "bc1t", "bc1f"] + + list(branch_likely_instructions) +) + def hexify_int(row, pat): full = pat.group(0) @@ -286,40 +380,43 @@ def hexify_int(row, pat): return full return hex(int(full)) + def parse_relocated_line(line): try: - ind2 = line.rindex(',') + ind2 = line.rindex(",") except ValueError: - ind2 = line.rindex('\t') - before = line[:ind2+1] - after = line[ind2+1:] - ind2 = after.find('(') + ind2 = line.rindex("\t") + before = line[: ind2 + 1] + after = line[ind2 + 1 :] + ind2 = after.find("(") if ind2 == -1: - imm, after = after, '' + imm, after = after, "" else: imm, after = after[:ind2], after[ind2:] - if imm == '0x0': - imm = '0' + if imm == "0x0": + imm = "0" return before, imm, after + def process_reloc(row, prev): before, imm, after = parse_relocated_line(prev) repl = row.split()[-1] - if imm != '0': - if before.strip() == 'jal' and not imm.startswith('0x'): - imm = '0x' + imm - repl += '+' + imm if int(imm,0) > 0 else imm - if 'R_MIPS_LO16' in row: - repl = f'%lo({repl})' - elif 'R_MIPS_HI16' in row: + if imm != "0": + if before.strip() == "jal" and not imm.startswith("0x"): + imm = "0x" + imm + repl += "+" + imm if int(imm, 0) > 0 else imm + if "R_MIPS_LO16" in row: + repl = f"%lo({repl})" + elif "R_MIPS_HI16" in row: # Ideally we'd pair up R_MIPS_LO16 and R_MIPS_HI16 to generate a # correct addend for each, but objdump doesn't give us the order of # the relocations, so we can't find the right LO16. :( - repl = f'%hi({repl})' + repl = f"%hi({repl})" else: - assert 'R_MIPS_26' in row, f"unknown relocation type '{row}'" + assert "R_MIPS_26" in row, f"unknown relocation type '{row}'" return before + repl + after + def process(lines): mnemonics = [] diff_rows = [] @@ -333,35 +430,35 @@ def process(lines): lines.pop() for row in lines: - if args.diff_obj and ('>:' in row or not row): + if args.diff_obj and (">:" in row or not row): continue - if 'R_MIPS_' in row: - if diff_rows[-1] != '': + if "R_MIPS_" in row: + if diff_rows[-1] != "": diff_rows[-1] = process_reloc(row, diff_rows[-1]) originals[-1] = process_reloc(row, originals[-1]) continue - row = re.sub(re_comments, '', row) + row = re.sub(re_comments, "", row) row = row.rstrip() - tabs = row.split('\t') - row = '\t'.join(tabs[2:]) + tabs = row.split("\t") + row = "\t".join(tabs[2:]) line_num = tabs[0].strip() - row_parts = row.split('\t', 1) + row_parts = row.split("\t", 1) mnemonic = row_parts[0].strip() if mnemonic not in branch_instructions: row = re.sub(re_int, lambda s: hexify_int(row, s), row) original = row if skip_next: skip_next = False - row = '' - mnemonic = '' + row = "" + mnemonic = "" if mnemonic in branch_likely_instructions: skip_next = True - row = re.sub(re_regs, '', row) - row = re.sub(re_sprel, ',addr(sp)', row) + row = re.sub(re_regs, "", row) + row = re.sub(re_sprel, ",addr(sp)", row) if args.ignore_large_imms: - row = re.sub(re_large_imm, '', row) + row = re.sub(re_large_imm, "", row) # Replace tabs with spaces mnemonics.append(mnemonic) @@ -369,24 +466,28 @@ def process(lines): originals.append(original) line_nums.append(line_num) if mnemonic in branch_instructions: - target = row_parts[1].strip().split(',')[-1] + target = row_parts[1].strip().split(",")[-1] if mnemonic in branch_likely_instructions: target = hex(int(target, 16) - 4)[2:] branch_targets.append(target) else: branch_targets.append(None) - if args.stop_jrra and mnemonic == 'jr' and row_parts[1].strip() == 'ra': + if args.stop_jrra and mnemonic == "jr" and row_parts[1].strip() == "ra": break # Cleanup whitespace originals = [original.strip() for original in originals] - originals = [''.join(f'{o:<8s}' for o in original.split('\t')) for original in originals] + originals = [ + "".join(f"{o:<8s}" for o in original.split("\t")) for original in originals + ] # return diff_rows, diff_rows, line_nums return mnemonics, diff_rows, originals, line_nums, branch_targets + def format_single_line_diff(line1, line2, column_width): return f"{ansi_ljust(line1,column_width)}{ansi_ljust(line2,column_width)}" + class SymbolColorer: def __init__(self, base_index): self.color_index = base_index @@ -400,24 +501,30 @@ class SymbolColorer: self.color_index += 1 self.symbol_colors[s] = color t = t or s - return f'{color}{t}{Fore.RESET}' + return f"{color}{t}{Fore.RESET}" + def normalize_large_imms(row): if args.ignore_large_imms: - row = re.sub(re_large_imm, '', row) + row = re.sub(re_large_imm, "", row) return row + def do_diff(basedump, mydump): - asm_lines1 = basedump.split('\n') - asm_lines2 = mydump.split('\n') + asm_lines1 = basedump.split("\n") + asm_lines2 = mydump.split("\n") output = [] # TODO: status line? # output.append(sha1sum(mydump)) - mnemonics1, asm_lines1, originals1, line_nums1, branch_targets1 = process(asm_lines1) - mnemonics2, asm_lines2, originals2, line_nums2, branch_targets2 = process(asm_lines2) + mnemonics1, asm_lines1, originals1, line_nums1, branch_targets1 = process( + asm_lines1 + ) + mnemonics2, asm_lines2, originals2, line_nums2, branch_targets2 = process( + asm_lines2 + ) sc1 = SymbolColorer(0) sc2 = SymbolColorer(0) @@ -429,94 +536,103 @@ def do_diff(basedump, mydump): bts2 = set() if args.show_branches: - for (bts, btset, sc) in [(branch_targets1, bts1, sc5), (branch_targets2, bts2, sc6)]: + for (bts, btset, sc) in [ + (branch_targets1, bts1, sc5), + (branch_targets2, bts2, sc6), + ]: for bt in bts: if bt is not None: btset.add(bt + ":") sc.color_symbol(bt + ":") - differ: difflib.SequenceMatcher = difflib.SequenceMatcher(a=mnemonics1, b=mnemonics2, autojunk=False) + differ: difflib.SequenceMatcher = difflib.SequenceMatcher( + a=mnemonics1, b=mnemonics2, autojunk=False + ) for (tag, i1, i2, j1, j2) in differ.get_opcodes(): lines1 = asm_lines1[i1:i2] lines2 = asm_lines2[j1:j2] for k, (line1, line2) in enumerate(itertools.zip_longest(lines1, lines2)): - if tag == 'replace': + if tag == "replace": if line1 is None: - tag = 'insert' + tag = "insert" elif line2 is None: - tag = 'delete' + tag = "delete" try: - original1 = originals1[i1+k] - line_num1 = line_nums1[i1+k] + original1 = originals1[i1 + k] + line_num1 = line_nums1[i1 + k] except: - original1 = '' - line_num1 = '' + original1 = "" + line_num1 = "" try: - original2 = originals2[j1+k] - line_num2 = line_nums2[j1+k] + original2 = originals2[j1 + k] + line_num2 = line_nums2[j1 + k] except: - original2 = '' - line_num2 = '' + original2 = "" + line_num2 = "" line_color = Fore.RESET - line_prefix = ' ' + line_prefix = " " if line1 == line2: if normalize_large_imms(original1) == normalize_large_imms(original2): - out1 = f'{original1}' - out2 = f'{original2}' - elif line1 == '': - out1 = f'{Style.DIM}{original1}' - out2 = f'{Style.DIM}{original2}' + out1 = f"{original1}" + out2 = f"{original2}" + elif line1 == "": + out1 = f"{Style.DIM}{original1}" + out2 = f"{Style.DIM}{original2}" else: line_color = Fore.YELLOW - line_prefix = 'r' - out1 = f'{Fore.YELLOW}{original1}{Style.RESET_ALL}' - out2 = f'{Fore.YELLOW}{original2}{Style.RESET_ALL}' + line_prefix = "r" + out1 = f"{Fore.YELLOW}{original1}{Style.RESET_ALL}" + out2 = f"{Fore.YELLOW}{original2}{Style.RESET_ALL}" out1 = re.sub(re_regs, lambda s: sc1.color_symbol(s.group()), out1) out2 = re.sub(re_regs, lambda s: sc2.color_symbol(s.group()), out2) out1 = re.sub(re_sprel, lambda s: sc3.color_symbol(s.group()), out1) out2 = re.sub(re_sprel, lambda s: sc4.color_symbol(s.group()), out2) - elif tag in ['replace', 'equal']: - line_prefix = '|' + elif tag in ["replace", "equal"]: + line_prefix = "|" line_color = Fore.BLUE out1 = f"{Fore.BLUE}{original1}{Style.RESET_ALL}" out2 = f"{Fore.BLUE}{original2}{Style.RESET_ALL}" - elif tag == 'delete': - line_prefix = '<' + elif tag == "delete": + line_prefix = "<" line_color = Fore.RED out1 = f"{Fore.RED}{original1}{Style.RESET_ALL}" - out2 = '' - elif tag == 'insert': - line_prefix = '>' + out2 = "" + elif tag == "insert": + line_prefix = ">" line_color = Fore.GREEN - out1 = '' + out1 = "" out2 = f"{Fore.GREEN}{original2}{Style.RESET_ALL}" - in_arrow1 = ' ' - in_arrow2 = ' ' - out_arrow1 = '' - out_arrow2 = '' - line_num1 = line_num1 if out1 else '' - line_num2 = line_num2 if out2 else '' + in_arrow1 = " " + in_arrow2 = " " + out_arrow1 = "" + out_arrow2 = "" + line_num1 = line_num1 if out1 else "" + line_num2 = line_num2 if out2 else "" if args.show_branches and out1: if line_num1 in bts1: - in_arrow1 = sc5.color_symbol(line_num1, '~>') - if branch_targets1[i1+k] is not None: - out_arrow1 = ' ' + sc5.color_symbol(branch_targets1[i1+k] + ":", '~>') + in_arrow1 = sc5.color_symbol(line_num1, "~>") + if branch_targets1[i1 + k] is not None: + out_arrow1 = " " + sc5.color_symbol( + branch_targets1[i1 + k] + ":", "~>" + ) if args.show_branches and out2: if line_num2 in bts2: - in_arrow2 = sc6.color_symbol(line_num2, '~>') - if branch_targets2[j1+k] is not None: - out_arrow2 = ' ' + sc6.color_symbol(branch_targets2[j1+k] + ":", '~>') + in_arrow2 = sc6.color_symbol(line_num2, "~>") + if branch_targets2[j1 + k] is not None: + out_arrow2 = " " + sc6.color_symbol( + branch_targets2[j1 + k] + ":", "~>" + ) - out1 = f"{line_color}{line_num1} {in_arrow1} {out1}{Style.RESET_ALL}{out_arrow1}" + out1 = f"{line_color}{line_num1} {in_arrow1} {out1}{Style.RESET_ALL}{out_arrow1}" out2 = f"{line_color}{line_prefix} {line_num2} {in_arrow2} {out2}{Style.RESET_ALL}{out_arrow2}" output.append(format_single_line_diff(out1, out2, args.column_width)) - return output[args.skip_lines:] + return output[args.skip_lines :] def debounced_fs_watch(targets, outq, debounce_delay): @@ -540,7 +656,9 @@ def debounced_fs_watch(targets, outq, debounce_delay): for target in self.file_targets: if path == target: return True - if args.make and any(path.endswith(suffix) for suffix in FS_WATCH_EXTENSIONS): + if args.make and any( + path.endswith(suffix) for suffix in FS_WATCH_EXTENSIONS + ): return True return False @@ -580,11 +698,12 @@ def debounced_fs_watch(targets, outq, debounce_delay): except queue.Empty: pass outq.put(t) + th = threading.Thread(target=debounce_thread, daemon=True) th.start() -class Display(): +class Display: def __init__(self, basedump, mydump): self.basedump = basedump self.mydump = mydump @@ -594,14 +713,15 @@ class Display(): if self.emsg is not None: output = self.emsg else: - output = '\n'.join(do_diff(self.basedump, self.mydump)) + output = "\n".join(do_diff(self.basedump, self.mydump)) # Pipe the output through 'tail' and only then to less, to ensure the # write call doesn't block. ('tail' has to buffer all its input before # it starts writing.) This also means we don't have to deal with pipe # closure errors. - buffer_proc = subprocess.Popen(BUFFER_CMD, stdin=subprocess.PIPE, - stdout=subprocess.PIPE) + buffer_proc = subprocess.Popen( + BUFFER_CMD, stdin=subprocess.PIPE, stdout=subprocess.PIPE + ) less_proc = subprocess.Popen(LESS_CMD, stdin=buffer_proc.stdout) buffer_proc.stdin.write(output.encode()) buffer_proc.stdin.close() @@ -699,8 +819,10 @@ def main(): display.run_sync() else: if not args.make: - yn = input("Warning: watch-mode (-w) enabled without auto-make (-m). You will have to run make manually. Ok? (Y/n) ") - if yn.lower() == 'n': + yn = input( + "Warning: watch-mode (-w) enabled without auto-make (-m). You will have to run make manually. Ok? (Y/n) " + ) + if yn.lower() == "n": return if args.make: watch_sources = None @@ -727,11 +849,14 @@ def main(): display.progress("Building...") ret = run_make(make_target, capture_output=True) if ret.returncode != 0: - display.update(ret.stderr.decode() or ret.stdout.decode(), error=True) + display.update( + ret.stderr.decode() or ret.stdout.decode(), error=True + ) continue mydump = run_objdump(mycmd) display.update(mydump, error=False) except KeyboardInterrupt: display.terminate() + main() diff --git a/enhancements/crash.patch b/enhancements/crash.patch index 1ff6fd47..f0eb61a9 100644 --- a/enhancements/crash.patch +++ b/enhancements/crash.patch @@ -1,42 +1,36 @@ diff --git a/asm/crash.s b/asm/crash.s new file mode 100644 -index 00000000..870b7e2c +index 00000000..7c272050 --- /dev/null +++ b/asm/crash.s -@@ -0,0 +1,160 @@ +@@ -0,0 +1,153 @@ +# SM64 Crash Handler +# See Readme below. + +.include "macros.inc" + -+.set COP0_CAUSE, 13 -+.set COP0_EPC, 14 -+.set COP0_BADVADDR, 8 -+ +/* --------------------------------------------------------------- + * IMPORTANT README: + * --------------------------------------------------------------- -+ * To use this crash screen, in lib/__osExceptionPreamble.s, change -+ * the function to use the following assembly: ++ * Frame buffer emulation is required. To enable it in GlideN64, ++ * check "Emulate frame buffer" and "Render frame buffer to output" ++ * in the "Frame buffer" tab. + * -+ * lui $k0, %hi(__crash_handler_entry) -+ * addiu $k0, $k0, %lo(__crash_handler_entry) -+ * jr $k0 -+ * nop -+ * -+ * Doing just a jal __crash_handler_entry will cause mupen recompiler -+ * errors, so be sure to use the original exception style assembly -+ * above! -+ * -+ * Be sure to add #include "../../enhancements/crash.inc.c" to -+ * the top of game.c. Add .include "../enhancements/crash.inc.s" to -+ * the bottom of asm/decompress.s. Add "../enhancements/crash.h" to -+ * the top of sm64.h, above the CRASH_SCREEN_INCLUDED condition. ++ * Your emulator's CPU core style should be set to interpreter for best results. + * + * See the DEBUG_ASSERT macro on how to call the crash screen for + * detected exceptions. ++ * + */ + ++.set noat ++.set noreorder ++.set gp=64 ++ ++.set COP0_CAUSE, $13 ++.set COP0_EPC, $14 ++.set COP0_BADVADDR, $8 ++ +glabel crashFont + .incbin "enhancements/crash_font.bin" + .align 4 @@ -63,23 +57,23 @@ index 00000000..870b7e2c + lui $at, %hi(nAssertStopProgram) + sw $a3, %lo(nAssertStopProgram)($at) + beqz $a3, .end_2 -+ nop ++ nop + syscall # trigger crash screen +.end_2: + jr $ra -+ nop ++ nop + +glabel cop0_get_cause + jr $ra -+ mfc0 $v0, $13 # COP0_CAUSE ++ mfc0 $v0, COP0_CAUSE + +glabel cop0_get_epc + jr $ra -+ mfc0 $v0, $14 # COP0_EPC ++ mfc0 $v0, COP0_EPC + +glabel cop0_get_badvaddr + jr $ra -+ mfc0 $v0, $8 # COP0_BADVADDR ++ mfc0 $v0, COP0_BADVADDR + +# If the error code field of cop0's cause register is non-zero, +# draw crash details to the screen and hang @@ -87,6 +81,10 @@ index 00000000..870b7e2c +# If there wasn't an error, continue to the original handler + +glabel __crash_handler_entry ++ mfc0 $k1, COP0_CAUSE ++ andi $k1, $k1, (0x1F << 2) ++ beqzl $k1, .end2 # exit if ExCode is 0 ++ lui $k0, %hi(__osException) + la $k0, exceptionRegContext + sd $zero, 0x018 ($k0) + sd $at, 0x020 ($k0) @@ -116,21 +114,15 @@ index 00000000..870b7e2c + sd $t9, 0x0E0 ($k0) + sd $gp, 0x0E8 ($k0) + sd $sp, 0x0F0 ($k0) -+ sd $s8, 0x0F8 ($k0) ++ sd $fp, 0x0F8 ($k0) + sd $ra, 0x100 ($k0) -+ mfc0 $t0, $13 # COP0_CAUSE -+ srl $t0, $t0, 2 -+ andi $t0, $t0, 0x1F -+ beqz $t0, .end -+ nop + # cop unusable exception fired twice on startup so we'll ignore it for now -+ li $at, 0x0B -+ beq $t0, $at, .end -+ nop ++ li $t0, (0x0B << 2) ++ beq $k1, $t0, .end ++ nop + jal show_crash_screen_and_hang -+ nop ++ nop + .end: -+ ld $zero, 0x018 ($k0) + ld $at, 0x020 ($k0) + ld $v0, 0x028 ($k0) + ld $v1, 0x030 ($k0) @@ -158,36 +150,33 @@ index 00000000..870b7e2c + ld $t9, 0x0E0 ($k0) + ld $gp, 0x0E8 ($k0) + ld $sp, 0x0F0 ($k0) -+ ld $s8, 0x0F8 ($k0) ++ ld $fp, 0x0F8 ($k0) + ld $ra, 0x100 ($k0) + lui $k0, %hi(__osException) ++ .end2: + addiu $k0, $k0, %lo(__osException) + jr $k0 # run the original handler -+ nop ++ nop diff --git a/lib/asm/__osExceptionPreamble.s b/lib/asm/__osExceptionPreamble.s -index fdc36c8b..ccbf4ecc 100644 +index 865273d9..f9ce7596 100644 --- a/lib/asm/__osExceptionPreamble.s +++ b/lib/asm/__osExceptionPreamble.s -@@ -8,12 +8,11 @@ - .section .text, "ax" +@@ -15,8 +15,8 @@ + .endif glabel __osExceptionPreamble -- lui $k0, %hi(__osException) # $k0, 0x8032 -- addiu $k0, %lo(__osException) # addiu $k0, $k0, 0x66d0 -+ lui $k0, %hi(__crash_handler_entry) # $k0, 0x8032 -+ addiu $k0, %lo(__crash_handler_entry) # addiu $k0, $k0, 0x66d0 +- lui $k0, %hi(__osException) +- addiu $k0, %lo(__osException) ++ lui $k0, %hi(__crash_handler_entry) ++ addiu $k0, %lo(__crash_handler_entry) jr $k0 nop -- - glabel __osException - lui $k0, %hi(gInterruptedThread) # $k0, 0x8036 - addiu $k0, %lo(gInterruptedThread) # addiu $k0, $k0, 0x5f40 diff --git a/sm64.ld b/sm64.ld -index dea5c8bd..22fff2d8 100755 +index e6f5c942..c0feb343 --- a/sm64.ld +++ b/sm64.ld -@@ -112,6 +112,7 @@ SECTIONS +@@ -116,6 +116,7 @@ SECTIONS BUILD_DIR/src/game/rendering_graph_node.o(.text); BUILD_DIR/src/game/profiler.o(.text); BUILD_DIR/asm/decompress.o(.text); @@ -197,10 +186,10 @@ index dea5c8bd..22fff2d8 100755 BUILD_DIR/src/game/object_list_processor.o(.text); diff --git a/src/game/crash.c b/src/game/crash.c new file mode 100644 -index 00000000..587ac86d +index 00000000..716adfbd --- /dev/null +++ b/src/game/crash.c -@@ -0,0 +1,291 @@ +@@ -0,0 +1,260 @@ +/* SM64 Crash Handler */ + +#include @@ -246,37 +235,6 @@ index 00000000..587ac86d + "S5", "S6", "S7", "T8", "T9", /*"K0", "K1",*/ + "GP", "SP", "FP", "RA", NULL }; + -+/* -+ Generates new preamble code at the exception vectors (0x000, 0x180) -+ -+ eg: generate_exception_preambles(crash_handler_entry); -+ -+ 000: lui k0, hi(crash_handler_entry) -+ 004: addiu k0, k0, lo(crash_handler_entry) -+ 008: jr k0 -+ 00C: nop -+*/ -+void generate_exception_preambles(void *entryPoint) { -+ u8 *mem = (u8 *) 0xA0000000; -+ int offs = 0; -+ int i; -+ -+ u16 hi = (u32) entryPoint >> 16; -+ u16 lo = (u32) entryPoint & 0xFFFF; -+ -+ if (lo & 0x8000) { -+ hi++; -+ } -+ -+ for (i = 0; i < 2; i++) { -+ *(u32 *) &mem[offs + 0x00] = 0x3C1A0000 | hi; -+ *(u32 *) &mem[offs + 0x04] = 0x275A0000 | lo; -+ *(u32 *) &mem[offs + 0x08] = 0x03400008; -+ *(u32 *) &mem[offs + 0x0C] = 0x00000000; -+ offs += 0x180; -+ } -+} -+ +int crash_strlen(char *str) { + int len = 0; + while (*str++) { @@ -303,7 +261,7 @@ index 00000000..587ac86d + + fb_print_str(80, 20, "AN ERROR HAS OCCURRED!"); + fb_print_int_hex(80, 30, errno, 8); -+ fb_print_str(107, 30, szErrCodes[errno]); ++ fb_print_str(95, 30, szErrCodes[errno]); + + if (errno >= 2 && errno <= 5) { + /* @@ -314,8 +272,8 @@ index 00000000..587ac86d + */ + u32 badvaddr = cop0_get_badvaddr(); + -+ fb_print_str(188, 50, "VA"); -+ fb_print_int_hex(215, 50, badvaddr, 32); ++ fb_print_str(145, 50, "VA"); ++ fb_print_int_hex(160, 50, badvaddr, 32); + } + } else { + int afterFileX; @@ -385,7 +343,7 @@ index 00000000..587ac86d + u8 curbyte = in[nbyte]; + for (nrow = 0; nrow < 2; nrow++) { + for (ncol = 0; ncol < 4; ncol++) { -+ u8 px = curbyte & (1 << 7 - (nrow * 4 + ncol)); ++ u8 px = curbyte & (1 << (7 - (nrow * 4 + ncol))); + if (px != 0) { + out[ncol] = fbFillColor; + } @@ -494,10 +452,10 @@ index 00000000..587ac86d +} diff --git a/src/game/crash.h b/src/game/crash.h new file mode 100644 -index 00000000..da4e011e +index 00000000..1386930d --- /dev/null +++ b/src/game/crash.h -@@ -0,0 +1,29 @@ +@@ -0,0 +1,28 @@ +#ifndef _CRASH_H_ +#define _CRASH_H_ + @@ -513,7 +471,6 @@ index 00000000..da4e011e + +extern u8 __crash_handler_entry[]; + -+void generate_exception_preambles(void *entryPoint); +void show_crash_screen_and_hang(void); +u8 ascii_to_idx(char c); +void fb_set_address(void *address); diff --git a/enhancements/ique_support.patch b/enhancements/ique_support.patch index 05b474b9..f52b9b16 100644 --- a/enhancements/ique_support.patch +++ b/enhancements/ique_support.patch @@ -108,16 +108,16 @@ index d550b846..bbaf2bcc 100644 __osSiRelAccess(); return status; diff --git a/lib/src/osEepromRead.c b/lib/src/osEepromRead.c -index 905eff74..23f34dd5 100644 +index ea784b2c..116dae2d 100644 --- a/lib/src/osEepromRead.c +++ b/lib/src/osEepromRead.c @@ -1,4 +1,5 @@ #include "libultra_internal.h" +#include - extern u32 D_80365E00[15]; - extern u32 D_80365E3C; -@@ -44,33 +45,44 @@ s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) { + extern u8 _osLastSentSiCmd; + +@@ -42,33 +43,44 @@ s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) { return -1; } __osSiGetAccess(); @@ -140,7 +140,7 @@ index 905eff74..23f34dd5 100644 - } - D_80365E3C = 0; - sp34 = __osSiRawStartDma(OS_READ, D_80365E00); -- D_80365D20 = 4; +- _osLastSentSiCmd = 4; - osRecvMesg(mq, NULL, OS_MESG_BLOCK); - for (sp30 = 0; sp30 < 4; sp30++) { - sp2c++; @@ -163,7 +163,7 @@ index 905eff74..23f34dd5 100644 } + D_80365E3C = 0; + sp34 = __osSiRawStartDma(OS_READ, D_80365E00); -+ D_80365D20 = 4; ++ _osLastSentSiCmd = 4; + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + for (sp30 = 0; sp30 < 4; sp30++) { + sp2c++; @@ -188,7 +188,7 @@ index 905eff74..23f34dd5 100644 __osSiRelAccess(); return sp34; diff --git a/lib/src/osEepromWrite.c b/lib/src/osEepromWrite.c -index 71d0b7d6..c855cc20 100644 +index 1a86477b..52a23e5e 100644 --- a/lib/src/osEepromWrite.c +++ b/lib/src/osEepromWrite.c @@ -1,5 +1,6 @@ @@ -196,9 +196,9 @@ index 71d0b7d6..c855cc20 100644 #include "osContInternal.h" +#include - u32 D_80365E00[0x3c >> 2]; - u32 D_80365E3C; -@@ -46,36 +47,47 @@ s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) { + #ifndef AVOID_UB + ALIGNED8 u32 D_80365E00[15]; +@@ -52,36 +53,47 @@ s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) { } __osSiGetAccess(); @@ -237,11 +237,11 @@ index 71d0b7d6..c855cc20 100644 - D_80365E3C = 0; - sp34 = __osSiRawStartDma(OS_READ, D_80365E00); -- D_80365D20 = 5; +- _osLastSentSiCmd = 5; - osRecvMesg(mq, NULL, OS_MESG_BLOCK); + D_80365E3C = 0; + sp34 = __osSiRawStartDma(OS_READ, D_80365E00); -+ D_80365D20 = 5; ++ _osLastSentSiCmd = 5; + osRecvMesg(mq, NULL, OS_MESG_BLOCK); - for (sp30 = 0; sp30 < 4; sp30++) { @@ -269,7 +269,7 @@ index 71d0b7d6..c855cc20 100644 return sp34; } diff --git a/lib/src/osInitialize.c b/lib/src/osInitialize.c -index 0b9f7128..660d1991 100644 +index 3cbca8ea..20723b2f 100644 --- a/lib/src/osInitialize.c +++ b/lib/src/osInitialize.c @@ -1,6 +1,7 @@ @@ -289,19 +289,19 @@ index 0b9f7128..660d1991 100644 __osSetSR(__osGetSR() | 0x20000000); __osSetFpcCsr(0x01000800); diff --git a/sm64.ld b/sm64.ld -index 59a5a2a6..c8976649 100755 +index 3275819f..6f97698f 100755 --- a/sm64.ld +++ b/sm64.ld -@@ -256,6 +256,8 @@ SECTIONS +@@ -261,6 +261,8 @@ SECTIONS BUILD_DIR/libultra.a:func_802F7140.o(.text) BUILD_DIR/libultra.a:func_802F71A0.o(.text) BUILD_DIR/libultra.a:func_802F71F0.o(.text) + BUILD_DIR/libultra.a:consoleType.o(.text) + BUILD_DIR/libultra.a:skGetId.o(.text) - BUILD_DIR/lib/rsp.o(.text); - -@@ -369,6 +371,8 @@ SECTIONS + #else + BUILD_DIR/src/game*.o(.text); +@@ -371,6 +373,8 @@ SECTIONS BUILD_DIR/libultra.a:__osGetCause.o(.text); BUILD_DIR/libultra.a:__osAtomicDec.o(.text); BUILD_DIR/libultra.a:guLookAtRef.o(.text); /* Fast3DEX2 only */ diff --git a/enhancements/record_demo.patch b/enhancements/record_demo.patch index b1c970b1..5d2c25de 100644 --- a/enhancements/record_demo.patch +++ b/enhancements/record_demo.patch @@ -1,8 +1,16 @@ diff --git a/src/game/game_init.c b/src/game/game_init.c -index 0852a141..004941d8 100644 +index a4302124..5ffbf3ed 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c -@@ -332,6 +332,45 @@ void display_and_vsync(void) { +@@ -11,6 +11,7 @@ + #include "game_init.h" + #include "main.h" + #include "memory.h" ++#include "object_list_processor.h" + #include "profiler.h" + #include "save_file.h" + #include "seq_ids.h" +@@ -335,6 +336,45 @@ void display_and_vsync(void) { gGlobalTimer++; } @@ -48,7 +56,7 @@ index 0852a141..004941d8 100644 // this function records distinct inputs over a 255-frame interval to RAM locations and was likely // used to record the demo sequences seen in the final game. This function is unused. static void record_demo(void) { -@@ -365,6 +404,118 @@ static void record_demo(void) { +@@ -368,6 +408,118 @@ static void record_demo(void) { gRecordedDemoInput.timer++; } @@ -167,7 +175,7 @@ index 0852a141..004941d8 100644 // take the updated controller struct and calculate // the new x, y, and distance floats. void adjust_analog_stick(struct Controller *controller) { -@@ -605,6 +756,7 @@ void thread5_game_loop(UNUSED void *arg) { +@@ -623,6 +775,7 @@ void thread5_game_loop(UNUSED void *arg) { audio_game_loop_tick(); config_gfx_pool(); read_controller_inputs(); diff --git a/extract_assets.py b/extract_assets.py index 7c29358b..d1760a5c 100755 --- a/extract_assets.py +++ b/extract_assets.py @@ -47,7 +47,6 @@ def remove_file(fname): def clean_assets(local_asset_file): assets = set(read_asset_map().keys()) assets.update(read_local_asset_list(local_asset_file)) - local_asset_file.close() for fname in list(assets) + [".assets-local.txt"]: if fname.startswith("@"): continue @@ -137,8 +136,8 @@ def main(): try: with open(fname, "rb") as f: roms[lang] = f.read() - except: - print("Failed to open " + fname + ". Please ensure it exists!") + except Exception as e: + print("Failed to open " + fname + "! " + str(e)) sys.exit(1) sha1 = hashlib.sha1(roms[lang]).hexdigest() with open("sm64." + lang + ".sha1", "r") as f: @@ -216,9 +215,11 @@ def main(): input = image[pos : pos + size] os.makedirs(os.path.dirname(asset), exist_ok=True) if asset.endswith(".png"): - with tempfile.NamedTemporaryFile(prefix="asset", delete=False) as png_file: + png_file = tempfile.NamedTemporaryFile(prefix="asset", delete=False) + try: png_file.write(input) png_file.flush() + png_file.close() if asset.startswith("textures/skyboxes/") or asset.startswith("levels/ending/cake"): if asset.startswith("textures/skyboxes/"): imagetype = "sky" @@ -254,6 +255,9 @@ def main(): ], check=True, ) + finally: + png_file.close() + remove_file(png_file.name) else: with open(asset, "wb") as f: f.write(input) @@ -279,4 +283,4 @@ def main(): f.write(output) -main() \ No newline at end of file +main() diff --git a/first-diff.py b/first-diff.py index f47d2ff5..202a7daf 100755 --- a/first-diff.py +++ b/first-diff.py @@ -1,52 +1,107 @@ #!/usr/bin/env python3 -import sys import os.path - -lang = None +import argparse +from subprocess import check_call # TODO: -S argument for shifted ROMs -args = [] -for arg in sys.argv[1:]: - if arg == '-j': - lang = 'jp' - elif arg == '-u': - lang = 'us' - elif arg == '-e': - lang = 'eu' - elif arg == '-s': - lang = 'sh' - else: - args.append(arg) -if lang is None: - lang = 'us' +parser = argparse.ArgumentParser( + description="find the first difference(s) between the compiled ROM and the baserom" +) +versionGroup = parser.add_mutually_exclusive_group() +versionGroup.add_argument( + "-j", + "--jp", + help="use original Japanese version", + action="store_const", + const="jp", + dest="version", +) +versionGroup.add_argument( + "-u", + "--us", + help="use United States version", + action="store_const", + const="us", + dest="version", +) +versionGroup.add_argument( + "-e", + "--eu", + help="use European (PAL) version", + action="store_const", + const="eu", + dest="version", +) +versionGroup.add_argument( + "-s", + "--sh", + help="use Shindou (Rumble) version", + action="store_const", + const="sh", + dest="version", +) +parser.add_argument( + "-m", "--make", help="run make before finding difference(s)", action="store_true" +) +parser.add_argument( + "-c", + "--count", + type=int, + default=1, + help="find up to this many instruction difference(s)", +) +parser.add_argument( + "-n", "--by-name", type=str, default="", help="perform a symbol or address lookup" +) +parser.add_argument( + "-d", "--diff", action="store_true", help="run ./diff.py on the result" +) +args = parser.parse_args() +diff_count = args.count + +version = args.version + +if version is None: + version = "us" best = 0 - for path in ['build/us/sm64.us.z64', 'build/jp/sm64.jp.z64', 'build/eu/sm64.eu.z64', 'build/sh/sm64.sh.z64']: + for ver in ["us", "jp", "eu", "sh"]: try: - mtime = os.path.getmtime(path) + mtime = os.path.getmtime(f"build/{ver}/sm64.{ver}.z64") if mtime > best: best = mtime - lang = path.split('/')[1] + version = ver except Exception: pass - print("Assuming language " + lang) + print("Assuming version " + version) -baseimg = 'baserom.' + lang + '.z64' -basemap = 'sm64.' + lang + '.map' +if args.make: + check_call(["make", "-j4", "VERSION=" + version, "COMPARE=0"]) -myimg = 'build/' + lang + '/sm64.' + lang + '.z64' -mymap = 'build/' + lang + '/sm64.' + lang + '.map' +baseimg = f"baserom.{version}.z64" +basemap = f"sm64.{version}.map" -if os.path.isfile('expected/' + mymap): - basemap = 'expected/' + mymap +myimg = f"build/{version}/sm64.{version}.z64" +mymap = f"build/{version}/{basemap}" + +if os.path.isfile("expected/" + mymap): + basemap = "expected/" + mymap required_files = [baseimg, myimg, mymap] -if any(not os.path.isfile(path) for path in required_files): - print(', '.join(required_files[:-1]) + " and " + required_files[-1] + " must exist.") +if not os.path.isfile(baseimg): + print(baseimg + " must exist.") + exit(1) +if not os.path.isfile(myimg) or not os.path.isfile(mymap): + print( + myimg + + " and " + + mymap + + " must exist. Try rerunning with --make to build them." + ) exit(1) -mybin = open(myimg, 'rb').read() -basebin = open(baseimg, 'rb').read() +mybin = open(myimg, "rb").read() +basebin = open(baseimg, "rb").read() if len(mybin) != len(basebin): print("Modified ROM has different size...") @@ -56,75 +111,88 @@ if mybin == basebin: print("No differences!") exit(0) + def search_map(rom_addr): ram_offset = None last_ram = 0 last_rom = 0 - last_fn = '' - last_file = '' - prev_line = '' + last_fn = "" + last_file = "" + prev_line = "" with open(mymap) as f: for line in f: - if 'load address' in line: + if "load address" in line: # Example: ".boot 0x0000000004000000 0x1000 load address 0x0000000000000000" - if 'noload' in line or 'noload' in prev_line: + if "noload" in line or "noload" in prev_line: ram_offset = None continue - ram = int(line[16:16+18], 0) - rom = int(line[59:59+18], 0) + ram = int(line[16 : 16 + 18], 0) + rom = int(line[59 : 59 + 18], 0) ram_offset = ram - rom continue prev_line = line - if ram_offset is None or '=' in line or '*fill*' in line or ' 0x' not in line: + if ( + ram_offset is None + or "=" in line + or "*fill*" in line + or " 0x" not in line + ): continue - ram = int(line[16:16+18], 0) + ram = int(line[16 : 16 + 18], 0) rom = ram - ram_offset fn = line.split()[-1] - if '0x' in fn: + if "0x" in fn: ram_offset = None continue if rom > rom_addr or (rom_addr & 0x80000000 and ram > rom_addr): - return 'in {} (ram 0x{:08x}, rom 0x{:x}, {})'.format(last_fn, last_ram, last_rom, last_file) + return f"in {last_fn} (ram 0x{last_ram:08x}, rom 0x{last_rom:06x}, {last_file})" last_ram = ram last_rom = rom last_fn = fn - if '/' in fn: + if "/" in fn: last_file = fn - return 'at end of rom?' + return "at end of rom?" + def parse_map(fname): ram_offset = None - cur_file = '' + cur_file = "" syms = {} prev_sym = None - prev_line = '' + prev_line = "" with open(fname) as f: for line in f: - if 'load address' in line: - if 'noload' in line or 'noload' in prev_line: + if "load address" in line: + if "noload" in line or "noload" in prev_line: ram_offset = None continue - ram = int(line[16:16+18], 0) - rom = int(line[59:59+18], 0) + ram = int(line[16 : 16 + 18], 0) + rom = int(line[59 : 59 + 18], 0) ram_offset = ram - rom continue prev_line = line - if ram_offset is None or '=' in line or '*fill*' in line or ' 0x' not in line: + if ( + ram_offset is None + or "=" in line + or "*fill*" in line + or " 0x" not in line + ): continue - ram = int(line[16:16+18], 0) + ram = int(line[16 : 16 + 18], 0) rom = ram - ram_offset fn = line.split()[-1] - if '0x' in fn: + if "0x" in fn: ram_offset = None - elif '/' in fn: + elif "/" in fn: cur_file = fn else: syms[fn] = (rom, cur_file, prev_sym, ram) prev_sym = fn return syms + def map_diff(): map1 = parse_map(mymap) map2 = parse_map(basemap) @@ -141,62 +209,110 @@ def map_diff(): return False else: print() - print("Map appears to have shifted just before {} ({}) -- in {}?".format(found[0], found[1], found[2])) + print( + f"Map appears to have shifted just before {found[0]} ({found[1]}) -- in {found[2]}?" + ) if found[2] is not None and found[2] not in map2: print() - print("(Base map file {} out of date due to renamed symbols, so result may be imprecise.)".format(basemap)) + print( + f"(Base map file {basemap} out of date due to renamed symbols, so result may be imprecise.)" + ) return True + def hexbytes(bs): return ":".join("{:02x}".format(c) for c in bs) + # For convenience, allow `./first-diff.py ` # to do a symbol <-> address lookup. This should really be split out into a # separate script... -if args: +if args.by_name: try: - addr = int(args[0], 0) - print(args[0], "is", search_map(addr)) + addr = int(args.by_name, 0) + print(args.by_name, "is", search_map(addr)) except ValueError: m = parse_map(mymap) try: - print(args[0], "is at position", hex(m[args[0]][0]), "in ROM,", hex(m[args[0]][3]), "in RAM") + print( + args.by_name, + "is at position", + hex(m[args.by_name][0]), + "in ROM,", + hex(m[args.by_name][3]), + "in RAM", + ) except KeyError: - print("function", args[0], "not found") + print("function", args.by_name, "not found") exit() -found_instr_diff = None +found_instr_diff = [] +map_search_diff = [] diffs = 0 shift_cap = 1000 for i in range(24, len(mybin), 4): # (mybin[i:i+4] != basebin[i:i+4], but that's slightly slower in CPython...) - if diffs <= shift_cap and (mybin[i] != basebin[i] or mybin[i+1] != basebin[i+1] or mybin[i+2] != basebin[i+2] or mybin[i+3] != basebin[i+3]): + if diffs <= shift_cap and ( + mybin[i] != basebin[i] + or mybin[i + 1] != basebin[i + 1] + or mybin[i + 2] != basebin[i + 2] + or mybin[i + 3] != basebin[i + 3] + ): if diffs == 0: - print("First difference at ROM addr " + hex(i) + ", " + search_map(i)) - print("Bytes:", hexbytes(mybin[i:i+4]), 'vs', hexbytes(basebin[i:i+4])) + print(f"First difference at ROM addr {hex(i)}, {search_map(i)}") + print( + f"Bytes: {hexbytes(mybin[i : i + 4])} vs {hexbytes(basebin[i : i + 4])}" + ) diffs += 1 - if found_instr_diff is None and mybin[i] >> 2 != basebin[i] >> 2: - found_instr_diff = i + if ( + len(found_instr_diff) < diff_count + and mybin[i] >> 2 != basebin[i] >> 2 + and not search_map(i) in map_search_diff + ): + found_instr_diff.append(i) + map_search_diff.append(search_map(i)) if diffs == 0: print("No differences!") exit() -definite_shift = (diffs > shift_cap) +definite_shift = diffs > shift_cap if not definite_shift: print(str(diffs) + " differing word(s).") if diffs > 100: - if found_instr_diff is not None: - i = found_instr_diff - print("First instruction difference at ROM addr " + hex(i) + ", " + search_map(i)) - print("Bytes:", hexbytes(mybin[i:i+4]), 'vs', hexbytes(basebin[i:i+4])) - if lang == 'sh': + if len(found_instr_diff) > 0: + for i in found_instr_diff: + print(f"Instruction difference at ROM addr {hex(i)}, {search_map(i)}") + print( + f"Bytes: {hexbytes(mybin[i : i + 4])} vs {hexbytes(basebin[i : i + 4])}" + ) + if version == "sh": print("Shifted ROM, as expected.") else: if not os.path.isfile(basemap): if definite_shift: print("Tons of differences, must be a shifted ROM.") - print("To find ROM shifts, copy a clean .map file to " + basemap + " and rerun this script.") + print( + "To find ROM shifts, copy a clean .map file to " + + basemap + + " and rerun this script." + ) exit() if not map_diff(): - print("No ROM shift{}.".format(" (!?)" if definite_shift else "")) + print(f"No ROM shift{' (!?)' if definite_shift else ''}") +if args.diff: + diff_args = input("Call ./diff.py with which arguments? ") or "--" + if diff_args[0] != "-": + diff_args = "-" + diff_args + if "w" in diff_args and args.make: + diff_args += "m" # To avoid warnings when passing -w, also pass -m as long as -m was passed to first-diff itself + + check_call( + [ + "python3", + "diff.py", + f"-{version[0]}", + diff_args, + search_map(found_instr_diff[0]).split()[1], + ] + ) diff --git a/include/PR/abi.h b/include/PR/abi.h index 8545be3b..0cec6a9c 100644 --- a/include/PR/abi.h +++ b/include/PR/abi.h @@ -391,7 +391,7 @@ typedef short ENVMIX_STATE[40]; * First call: * aSetBuffer(cmd++, 0, 0, output, count) * - * The count refers to the size of the output. + * The count refers to the size of each input. Hence 2 * count bytes will be written out. * A left sample will be placed before the right sample. * * Note: count will be rounded up to the nearest multiple of 16 bytes. @@ -472,7 +472,7 @@ typedef short ENVMIX_STATE[40]; * For 1 octave up or downsampling to (roughly) half number of samples, use pitch 0xffff. * For 1 octave down or upsampling to double as many samples, use pitch 0x4000. * - * Note: count represents the number of output samples and is rounded up to + * Note: count represents the number of output sample bytes and is rounded up to * the nearest multiple of 16 bytes. * * The state consists of the four following source samples when the algorithm stopped as @@ -484,7 +484,7 @@ typedef short ENVMIX_STATE[40]; * the four next source samples and then moving the source position zero or more * samples forward. The first output sample (when A_INIT is given) is always 0. * - * When "count" samples have been written, the following four source samples + * When "count" bytes have been written, the following four source samples * are written to the state in DRAM as well as a fractional position. */ #define aResample(pkt, f, p, s) \ diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 0f63e04f..bd981be8 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -91,6 +91,7 @@ # ifndef F3DEX_GBI_2 # define F3DEX_GBI_2 # endif +# define GBI_FLOATS #endif #ifdef F3DEX_GBI_2 diff --git a/include/audio_defines.h b/include/audio_defines.h index 15ac3185..021d2d8f 100644 --- a/include/audio_defines.h +++ b/include/audio_defines.h @@ -31,11 +31,11 @@ #define SOUND_NO_ECHO 0x20 // not in JP #define SOUND_LO_BITFLAG_UNK8 0x80 // restart playing on each play_sound call? -/* Audio playback bitflags. TODO: Figure out what these mean and use them below. */ -#define SOUND_PL_BITFLAG_UNK1 0x1000000 -#define SOUND_PL_BITFLAG_UNK2 0x2000000 -#define SOUND_PL_BITFLAG_UNK4 0x4000000 -#define SOUND_PL_BITFLAG_UNK8 0x8000000 +/* Audio playback bitflags. */ +#define SOUND_NO_VOLUME_LOSS 0x1000000 // No volume loss with distance +#define SOUND_VIBRATO 0x2000000 // Randomly alter frequency each audio frame +#define SOUND_NO_PRIORITY_LOSS 0x4000000 // Do not prioritize closer sounds +#define SOUND_NO_FREQUENCY_LOSS 0x8000000 // Frequency scale does not change with distance // silence #define NO_SOUND 0 @@ -558,4 +558,4 @@ #define SOUND_OBJ2_BOSS_DIALOG_GRUNT SOUND_ARG_LOAD(9, 0, 0x69, 0x40, 8) #define SOUND_OBJ2_MRI_SPINNING SOUND_ARG_LOAD(9, 0, 0x6B, 0x00, 8) -#endif /* AUDIO_DEFINES_H */ +#endif // AUDIO_DEFINES_H diff --git a/include/behavior_data.h b/include/behavior_data.h index 19802282..6a92882e 100644 --- a/include/behavior_data.h +++ b/include/behavior_data.h @@ -1,5 +1,5 @@ -#ifndef _BEHAVIOR_DATA_H -#define _BEHAVIOR_DATA_H +#ifndef BEHAVIOR_DATA_H +#define BEHAVIOR_DATA_H #include "types.h" @@ -302,20 +302,20 @@ extern const BehaviorScript bhvYellowBall[]; extern const BehaviorScript bhvMario[]; extern const BehaviorScript bhvToadMessage[]; extern const BehaviorScript bhvUnlockDoorStar[]; -extern const BehaviorScript bhvWarps60[]; -extern const BehaviorScript bhvWarps64[]; -extern const BehaviorScript bhvWarps68[]; -extern const BehaviorScript bhvWarps6C[]; +extern const BehaviorScript bhvInstantActiveWarp[]; +extern const BehaviorScript bhvAirborneWarp[]; +extern const BehaviorScript bhvHardAirKnockBackWarp[]; +extern const BehaviorScript bhvSpinAirborneCircleWarp[]; extern const BehaviorScript bhvDeathWarp[]; -extern const BehaviorScript bhvWarps74[]; -extern const BehaviorScript bhvWarps78[]; -extern const BehaviorScript bhvWarps7C[]; +extern const BehaviorScript bhvSpinAirborneWarp[]; +extern const BehaviorScript bhvFlyingWarp[]; +extern const BehaviorScript bhvPaintingStarCollectWarp[]; extern const BehaviorScript bhvPaintingDeathWarp[]; -extern const BehaviorScript bhvWarps84[]; -extern const BehaviorScript bhvWarps88[]; -extern const BehaviorScript bhvWarps8C[]; -extern const BehaviorScript bhvWarps90[]; -extern const BehaviorScript bhvWarps94[]; +extern const BehaviorScript bhvAirborneDeathWarp[]; +extern const BehaviorScript bhvAirborneStarCollectWarp[]; +extern const BehaviorScript bhvLaunchStarCollectWarp[]; +extern const BehaviorScript bhvLaunchDeathWarp[]; +extern const BehaviorScript bhvSwimmingWarp[]; extern const BehaviorScript bhvRandomAnimatedTexture[]; extern const BehaviorScript bhvYellowBackgroundInMenu[]; extern const BehaviorScript bhvMenuButton[]; @@ -543,4 +543,4 @@ extern const BehaviorScript bhvEndBirds2[]; extern const BehaviorScript bhvIntroScene[]; extern const BehaviorScript bhvUnusedFakeStar[]; -#endif /* _BEHAVIOR_DATA_H */ +#endif // BEHAVIOR_DATA_H diff --git a/include/command_macros_base.h b/include/command_macros_base.h index e2fc760e..5a0aea51 100644 --- a/include/command_macros_base.h +++ b/include/command_macros_base.h @@ -25,4 +25,4 @@ #define CMD_HHHHHH(a, b, c, d, e, f) CMD_HH(a, b), CMD_HH(c, d), CMD_HH(e, f) -#endif +#endif // COMMAND_MACROS_BASE_H diff --git a/include/config.h b/include/config.h index 23a317e8..4512546e 100644 --- a/include/config.h +++ b/include/config.h @@ -31,4 +31,4 @@ // What's the point of having a border if we're not an N64? #define BORDER_HEIGHT 0 // Never use a border as not-N64 -#endif +#endif // CONFIG_H diff --git a/include/course_table.h b/include/course_table.h index 58b30902..ec2d4296 100644 --- a/include/course_table.h +++ b/include/course_table.h @@ -1,5 +1,5 @@ -#ifndef _COURSE_TABLE_H -#define _COURSE_TABLE_H +#ifndef COURSE_TABLE_H +#define COURSE_TABLE_H // Start of the 3 cap courses in a row. #define COURSE_CAP_COURSES COURSE_COTMC @@ -15,8 +15,8 @@ enum CourseNum { #include "levels/course_defines.h" - COURSE_END, // To mark end + 1 for marking max and count. - // Todo: clean this up. This is still bad. Which + COURSE_END, // To mark end + 1 for marking max and count. + // TODO: clean this up. This is still bad. Which // one is clearer? Need to get rid of one of these. COURSE_MAX = COURSE_END - 1, COURSE_COUNT = COURSE_MAX, @@ -29,4 +29,4 @@ enum CourseNum #define COURSE_IS_MAIN_COURSE(cmd) (cmd >= COURSE_MIN && cmd <= COURSE_STAGES_MAX) -#endif // _COURSE_TABLE_H +#endif // COURSE_TABLE_H diff --git a/include/dialog_ids.h b/include/dialog_ids.h index bc92c20d..6feadafb 100644 --- a/include/dialog_ids.h +++ b/include/dialog_ids.h @@ -1,5 +1,5 @@ -#ifndef DIALOG_IDS -#define DIALOG_IDS +#ifndef DIALOG_IDS_H +#define DIALOG_IDS_H enum DialogId { DIALOG_000, @@ -175,4 +175,4 @@ enum DialogId { DIALOG_COUNT }; -#endif +#endif // DIALOG_IDS_H diff --git a/include/eu_translation.h b/include/eu_translation.h index fc476ede..beb6fa7b 100644 --- a/include/eu_translation.h +++ b/include/eu_translation.h @@ -1,8 +1,6 @@ #ifndef EU_TRANSLATION_H #define EU_TRANSLATION_H -#include "types.h" - // PAL changes most text to arrays for each language. This define allows these // differences to be combined. #ifdef VERSION_EU @@ -11,14 +9,6 @@ #define LANGUAGE_ARRAY(cmd) cmd #endif -// EU translations are contained in three segment 0x19 compressed data blocks -extern u8 _translation_en_mio0SegmentRomStart[]; -extern u8 _translation_en_mio0SegmentRomEnd[]; -extern u8 _translation_fr_mio0SegmentRomStart[]; -extern u8 _translation_fr_mio0SegmentRomEnd[]; -extern u8 _translation_de_mio0SegmentRomStart[]; -extern u8 _translation_de_mio0SegmentRomEnd[]; - extern void *dialog_table_eu_en[]; extern void *course_name_table_eu_en[]; extern void *act_name_table_eu_en[]; @@ -31,4 +21,4 @@ extern void *dialog_table_eu_de[]; extern void *course_name_table_eu_de[]; extern void *act_name_table_eu_de[]; -#endif /* EU_TRANSLATION_H */ +#endif // EU_TRANSLATION_H diff --git a/include/geo_commands.h b/include/geo_commands.h index 33f2b7eb..432ec1fd 100644 --- a/include/geo_commands.h +++ b/include/geo_commands.h @@ -429,4 +429,4 @@ #define GEO_CULLING_RADIUS(cullingRadius) \ CMD_BBH(0x20, 0x00, cullingRadius) -#endif +#endif // GEO_COMMANDS_H diff --git a/include/gfx_dimensions.h b/include/gfx_dimensions.h index f3a5ee23..a0c90a43 100644 --- a/include/gfx_dimensions.h +++ b/include/gfx_dimensions.h @@ -3,10 +3,14 @@ #include #include "pc/gfx/gfx_pc.h" + #define GFX_DIMENSIONS_FROM_LEFT_EDGE(v) (SCREEN_WIDTH / 2 - SCREEN_HEIGHT / 2 * gfx_current_dimensions.aspect_ratio + (v)) #define GFX_DIMENSIONS_FROM_RIGHT_EDGE(v) (SCREEN_WIDTH / 2 + SCREEN_HEIGHT / 2 * gfx_current_dimensions.aspect_ratio - (v)) #define GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(v) ((int)floorf(GFX_DIMENSIONS_FROM_LEFT_EDGE(v))) #define GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(v) ((int)ceilf(GFX_DIMENSIONS_FROM_RIGHT_EDGE(v))) #define GFX_DIMENSIONS_ASPECT_RATIO (gfx_current_dimensions.aspect_ratio) +// If screen is taller than it is wide, radius should be equal to SCREEN_HEIGHT since we scale horizontally +#define GFX_DIMENSIONS_FULL_RADIUS (SCREEN_HEIGHT * (GFX_DIMENSIONS_ASPECT_RATIO > 1 ? GFX_DIMENSIONS_ASPECT_RATIO : 1)) + #endif diff --git a/include/helper_macros.h b/include/helper_macros.h index 5e381e9d..a994af6f 100644 --- a/include/helper_macros.h +++ b/include/helper_macros.h @@ -1,6 +1,6 @@ -#ifndef _HELPER_MACROS_H -#define _HELPER_MACROS_H +#ifndef HELPER_MACROS_H +#define HELPER_MACROS_H #define LIST_NEXT_ITEM(curItem, type) ((type *)((s32)curItem + sizeof(type))) -#endif +#endif // HELPER_MACROS_H diff --git a/include/level_commands.h b/include/level_commands.h index 214709e0..513ff6f0 100644 --- a/include/level_commands.h +++ b/include/level_commands.h @@ -35,15 +35,15 @@ #define DIZZY_FACE 0x0003 #define EXECUTE(seg, script, scriptEnd, entry) \ - CMD_BBH(0x00, 0x10, seg), \ - CMD_PTR(script), \ - CMD_PTR(scriptEnd), \ + CMD_BBH(0x00, 0x10, 0x0000), \ + CMD_PTR(NULL), \ + CMD_PTR(NULL), \ CMD_PTR(entry) #define EXIT_AND_EXECUTE(seg, script, scriptEnd, entry) \ - CMD_BBH(0x01, 0x10, seg), \ - CMD_PTR(script), \ - CMD_PTR(scriptEnd), \ + CMD_BBH(0x01, 0x10, 0x0000), \ + CMD_PTR(NULL), \ + CMD_PTR(NULL), \ CMD_PTR(entry) #define EXIT() \ @@ -119,27 +119,27 @@ #define FIXED_LOAD(loadAddr, romStart, romEnd) \ CMD_BBH(0x16, 0x10, 0x0000), \ - CMD_PTR(loadAddr), \ - CMD_PTR(romStart), \ - CMD_PTR(romEnd) + CMD_PTR(NULL), \ + CMD_PTR(NULL), \ + CMD_PTR(NULL) #define LOAD_RAW(seg, romStart, romEnd) \ - CMD_BBH(0x17, 0x0C, seg), \ - CMD_PTR(romStart), \ - CMD_PTR(romEnd) + CMD_BBH(0x17, 0x0C, 0x0000), \ + CMD_PTR(NULL), \ + CMD_PTR(NULL) #define LOAD_MIO0(seg, romStart, romEnd) \ - CMD_BBH(0x18, 0x0C, seg), \ - CMD_PTR(romStart), \ - CMD_PTR(romEnd) + CMD_BBH(0x18, 0x0C, 0x0000), \ + CMD_PTR(NULL), \ + CMD_PTR(NULL) #define LOAD_MARIO_HEAD(sethead) \ CMD_BBH(0x19, 0x04, sethead) #define LOAD_MIO0_TEXTURE(seg, romStart, romEnd) \ - CMD_BBH(0x1A, 0x0C, seg), \ - CMD_PTR(romStart), \ - CMD_PTR(romEnd) + CMD_BBH(0x1A, 0x0C, 0x0000), \ + CMD_PTR(NULL), \ + CMD_PTR(NULL) #define INIT_LEVEL() \ CMD_BBH(0x1B, 0x04, 0x0000) @@ -281,4 +281,4 @@ #define CLEAR_DEMO_PTR() \ CMD_BBH(0x3E, 0x04, 0x0000) -#endif +#endif // LEVEL_COMMANDS_H diff --git a/include/level_misc_macros.h b/include/level_misc_macros.h index 4810507b..91ccd784 100644 --- a/include/level_misc_macros.h +++ b/include/level_misc_macros.h @@ -25,4 +25,4 @@ #define TRAJECTORY_END() \ -1 -#endif +#endif // LEVEL_MISC_MACROS_H diff --git a/include/level_table.h b/include/level_table.h index 9b7401b1..e3062c49 100644 --- a/include/level_table.h +++ b/include/level_table.h @@ -1,5 +1,5 @@ -#ifndef _LEVEL_TABLE_H -#define _LEVEL_TABLE_H +#ifndef LEVEL_TABLE_H +#define LEVEL_TABLE_H // For LEVEL_NAME defines, see level_defines.h. // Please include this file if you want to use them. @@ -19,4 +19,4 @@ enum LevelNum #undef STUB_LEVEL #undef DEFINE_LEVEL -#endif // _LEVEL_TABLE_H +#endif // LEVEL_TABLE_H diff --git a/include/macro_preset_names.h b/include/macro_preset_names.h index 52393d8c..2700a8e8 100644 --- a/include/macro_preset_names.h +++ b/include/macro_preset_names.h @@ -1,5 +1,5 @@ -#ifndef _MACRO_PRESET_NAMES_H -#define _MACRO_PRESET_NAMES_H +#ifndef MACRO_PRESET_NAMES_H +#define MACRO_PRESET_NAMES_H enum MacroPresets { macro_yellow_coin, @@ -370,4 +370,4 @@ enum MacroPresets { macro_empty_365 }; -#endif // _MACRO_PRESET_NAMES_H +#endif // MACRO_PRESET_NAMES_H diff --git a/include/macro_presets.h b/include/macro_presets.h index bb123e59..a7ad50f6 100644 --- a/include/macro_presets.h +++ b/include/macro_presets.h @@ -1,5 +1,5 @@ -#ifndef _MACRO_PRESETS_H -#define _MACRO_PRESETS_H +#ifndef MACRO_PRESETS_H +#define MACRO_PRESETS_H #include "macro_preset_names.h" #include "behavior_data.h" @@ -381,4 +381,4 @@ struct MacroPreset MacroObjectPresets[] = { {bhvYellowCoin, MODEL_YELLOW_COIN, 0} }; -#endif // _MACRO_PRESETS_H +#endif // MACRO_PRESETS_H diff --git a/include/macros.h b/include/macros.h index 85512d23..1d070362 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,5 +1,5 @@ -#ifndef _MACROS_H_ -#define _MACROS_H_ +#ifndef MACROS_H +#define MACROS_H #include "platform_info.h" @@ -25,6 +25,13 @@ #define UNUSED #endif +// Avoid undefined behaviour for non-returning functions +#ifdef __GNUC__ +#define NORETURN __attribute__((noreturn)) +#else +#define NORETURN +#endif + // Static assertions #ifdef __GNUC__ #define STATIC_ASSERT(cond, msg) _Static_assert(cond, msg) @@ -70,4 +77,4 @@ # define LE_TO_HOST32(x) (x) #endif -#endif +#endif // MACROS_H diff --git a/include/mario_animation_ids.h b/include/mario_animation_ids.h index 2c32b880..1d22d3d1 100644 --- a/include/mario_animation_ids.h +++ b/include/mario_animation_ids.h @@ -1,5 +1,5 @@ -#ifndef _MARIO_ANIMATION_IDS_H -#define _MARIO_ANIMATION_IDS_H +#ifndef MARIO_ANIMATION_IDS_H +#define MARIO_ANIMATION_IDS_H /* Mario Animation IDs */ @@ -208,7 +208,7 @@ enum MarioAnimID /* 0xC8 */ MARIO_ANIM_WAKE_FROM_SLEEP, /* 0xC9 */ MARIO_ANIM_WAKE_FROM_LYING, /* 0xCA */ MARIO_ANIM_START_TIPTOE, - /* 0xCB */ MARIO_ANIM_SLIDEJUMP, // pole jump and wall kick + /* 0xCB */ MARIO_ANIM_SLIDEJUMP, // pole jump and wall kick /* 0xCC */ MARIO_ANIM_START_WALLKICK, /* 0xCD */ MARIO_ANIM_STAR_DANCE, /* 0xCE */ MARIO_ANIM_RETURN_FROM_STAR_DANCE, @@ -216,4 +216,4 @@ enum MarioAnimID /* 0xD0 */ MARIO_ANIM_TRIPLE_JUMP_FLY }; -#endif /* _MARIO_ANIMATION_IDS_H */ +#endif // MARIO_ANIMATION_IDS_H diff --git a/include/mario_geo_switch_case_ids.h b/include/mario_geo_switch_case_ids.h index 3b604b07..007d23b0 100644 --- a/include/mario_geo_switch_case_ids.h +++ b/include/mario_geo_switch_case_ids.h @@ -1,5 +1,5 @@ -#ifndef _MARIO_GEO_SWITCH_CASE_IDS_H -#define _MARIO_GEO_SWITCH_CASE_IDS_H +#ifndef MARIO_GEO_SWITCH_CASE_IDS_H +#define MARIO_GEO_SWITCH_CASE_IDS_H /* Mario Geo-Switch-Case IDs */ @@ -42,5 +42,4 @@ enum MarioGrabPosGSCId /*0x03*/ GRAB_POS_BOWSER }; - -#endif /* _MARIO_GEO_SWITCH_CASE_IDS_H */ +#endif // MARIO_GEO_SWITCH_CASE_IDS_H diff --git a/include/model_ids.h b/include/model_ids.h index 8b6e2991..1cd0a253 100644 --- a/include/model_ids.h +++ b/include/model_ids.h @@ -1,5 +1,6 @@ -#ifndef _MODEL_IDS_H -#define _MODEL_IDS_H +#ifndef MODEL_IDS_H +#define MODEL_IDS_H + #define ACT_1 (1 << 0) #define ACT_2 (1 << 1) #define ACT_3 (1 << 2) @@ -585,4 +586,4 @@ #define MODEL_VCUTM_WARP_PIPE MODEL_LEVEL_GEOMETRY_16 // warp_pipe_geo #define MODEL_CASTLE_GROUNDS_WARP_PIPE MODEL_LEVEL_GEOMETRY_16 // warp_pipe_geo -#endif +#endif // MODEL_IDS_H diff --git a/include/moving_texture_macros.h b/include/moving_texture_macros.h index f7d033ff..a7067d6d 100644 --- a/include/moving_texture_macros.h +++ b/include/moving_texture_macros.h @@ -69,4 +69,4 @@ #define MOV_TEX_ROT_END() \ 0, 0 -#endif +#endif // MOVING_TEXTURE_MACROS_H diff --git a/include/object_constants.h b/include/object_constants.h index 9e7623a9..4dcbb4c2 100644 --- a/include/object_constants.h +++ b/include/object_constants.h @@ -1,10 +1,11 @@ -#ifndef _OBJECT_CONSTANTS_H -#define _OBJECT_CONSTANTS_H +#ifndef OBJECT_CONSTANTS_H +#define OBJECT_CONSTANTS_H // This file contains macros that provide descriptive names for // field-specific and object-specific constants, e.g. actions. /* activeFlags */ +#define ACTIVE_FLAG_DEACTIVATED 0 // 0x0000 #define ACTIVE_FLAG_ACTIVE (1 << 0) // 0x0001 #define ACTIVE_FLAG_FAR_AWAY (1 << 1) // 0x0002 #define ACTIVE_FLAG_UNK2 (1 << 2) // 0x0004 @@ -12,12 +13,11 @@ #define ACTIVE_FLAG_UNIMPORTANT (1 << 4) // 0x0010 #define ACTIVE_FLAG_INITIATED_TIME_STOP (1 << 5) // 0x0020 #define ACTIVE_FLAG_MOVE_THROUGH_GRATE (1 << 6) // 0x0040 -#define ACTIVE_FLAG_UNK7 (1 << 7) // 0x0080 +#define ACTIVE_FLAG_DITHERED_ALPHA (1 << 7) // 0x0080 #define ACTIVE_FLAG_UNK8 (1 << 8) // 0x0100 #define ACTIVE_FLAG_UNK9 (1 << 9) // 0x0200 #define ACTIVE_FLAG_UNK10 (1 << 10) // 0x0400 -#define ACTIVE_FLAGS_DEACTIVATED 0 /* respawnInfoType */ #define RESPAWN_INFO_TYPE_NULL 0 @@ -211,7 +211,7 @@ #define BLUE_FISH_ACT_TURN 1 #define BLUE_FISH_ACT_ASCEND 2 #define BLUE_FISH_ACT_TURN_BACK 3 - + /* oAction: bhv_blue_fish_spawn_loop */ #define BLUE_FISH_ACT_SPAWN 0 #define BLUE_FISH_ACT_ROOM 1 @@ -757,11 +757,11 @@ /* Walking sounds */ #define PENGUIN_WALK_BABY 0 #define PENGUIN_WALK_BIG 1 - + /* Animations */ #define PENGUIN_ANIM_WALK 0 #define PENGUIN_ANIM_IDLE 3 - + /* Racing penguin */ /* oAction */ #define RACING_PENGUIN_ACT_WAIT_FOR_MARIO 0 @@ -770,14 +770,14 @@ #define RACING_PENGUIN_ACT_RACE 3 #define RACING_PENGUIN_ACT_FINISH_RACE 4 #define RACING_PENGUIN_ACT_SHOW_FINAL_TEXT 5 - + /* SL walking penguin */ /* oAction */ #define SL_WALKING_PENGUIN_ACT_MOVING_FORWARDS 0 #define SL_WALKING_PENGUIN_ACT_TURNING_BACK 1 #define SL_WALKING_PENGUIN_ACT_RETURNING 2 #define SL_WALKING_PENGUIN_ACT_TURNING_FORWARDS 3 - + /* Snowman wind */ /* oSubAction */ #define SL_SNOWMAN_WIND_ACT_IDLE 0 @@ -971,4 +971,4 @@ #define BOWSER_PUZZLE_ACT_WAIT_FOR_COMPLETE 1 #define BOWSER_PUZZLE_ACT_DONE 2 -#endif +#endif // OBJECT_CONSTANTS_H diff --git a/include/object_fields.h b/include/object_fields.h index 5ba0e1cb..39a41524 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -1,6 +1,5 @@ -#ifndef _OBJECT_FIELDS_H -#define _OBJECT_FIELDS_H - +#ifndef OBJECT_FIELDS_H +#define OBJECT_FIELDS_H /** * The array [0x88, 0x1C8) in struct Object consists of fields that can vary by @@ -327,7 +326,7 @@ #define /*0x1B2*/ oBubbaUnk1B2 OBJECT_FIELD_S16(0x4A, + 1) /* Bullet Bill */ -#define /*0x0F8*/ oBulletBillUnkF8 OBJECT_FIELD_S32(0x1C) +#define /*0x0F8*/ oBulletBillInitialMoveYaw OBJECT_FIELD_S32(0x1C) /* Bully (all variants) */ #define /*0x0F4*/ oBullySubtype OBJECT_FIELD_S32(0x1B) @@ -703,15 +702,15 @@ #define /*0x0F4*/ oMontyMoleHoleCooldown OBJECT_FIELD_S32(0x1B) /* Mr. Blizzard */ -#define /*0x0F4*/ oMrBlizzardUnkF4 OBJECT_FIELD_F32(0x1B) -#define /*0x0F8*/ oMrBlizzardUnkF8 OBJECT_FIELD_OBJ(0x1C) -#define /*0x0FC*/ oMrBlizzardUnkFC OBJECT_FIELD_F32(0x1D) -#define /*0x100*/ oMrBlizzardUnk100 OBJECT_FIELD_S32(0x1E) -#define /*0x104*/ oMrBlizzardUnk104 OBJECT_FIELD_F32(0x1F) -#define /*0x108*/ oMrBlizzardUnk108 OBJECT_FIELD_F32(0x20) -#define /*0x10C*/ oMrBlizzardUnk10C OBJECT_FIELD_F32(0x21) -#define /*0x110*/ oMrBlizzardUnk110 OBJECT_FIELD_S32(0x22) -#define /*0x1AC*/ oMrBlizzardUnk1AC OBJECT_FIELD_S32(0x49) +#define /*0x0F4*/ oMrBlizzardScale OBJECT_FIELD_F32(0x1B) +#define /*0x0F8*/ oMrBlizzardHeldObj OBJECT_FIELD_OBJ(0x1C) +#define /*0x0FC*/ oMrBlizzardGraphYVel OBJECT_FIELD_F32(0x1D) +#define /*0x100*/ oMrBlizzardTimer OBJECT_FIELD_S32(0x1E) +#define /*0x104*/ oMrBlizzardDizziness OBJECT_FIELD_F32(0x1F) +#define /*0x108*/ oMrBlizzardChangeInDizziness OBJECT_FIELD_F32(0x20) +#define /*0x10C*/ oMrBlizzardGraphYOffset OBJECT_FIELD_F32(0x21) +#define /*0x110*/ oMrBlizzardDistFromHome OBJECT_FIELD_S32(0x22) +#define /*0x1AC*/ oMrBlizzardTargetMoveYaw OBJECT_FIELD_S32(0x49) /* Mr. I */ #define /*0x0F4*/ oMrIUnkF4 OBJECT_FIELD_S32(0x1B) @@ -953,7 +952,7 @@ #define /*0x0FC*/ oSwoopTargetYaw OBJECT_FIELD_S32(0x1D) /* Thwomp */ -#define /*0x0F4*/ oThwompUnkF4 OBJECT_FIELD_S32(0x1B) +#define /*0x0F4*/ oThwompRandomTimer OBJECT_FIELD_S32(0x1B) /* Tilting Platform */ #define /*0x0F4*/ oTiltingPyramidNormalX OBJECT_FIELD_F32(0x1B) @@ -1133,7 +1132,7 @@ #define /*0x0F4*/ oStrongWindParticlePenguinObj OBJECT_FIELD_OBJ(0x1B) /* Whomp */ -#define /*0x0F8*/ oWhompUnkF8 OBJECT_FIELD_S32(0x1C) +#define /*0x0F8*/ oWhompShakeVal OBJECT_FIELD_S32(0x1C) /* Wiggler */ #define /*0x0F4*/ oWigglerFallThroughFloorsHeight OBJECT_FIELD_F32(0x1B) @@ -1143,11 +1142,11 @@ #define /*0x108*/ oWigglerTimeUntilRandomTurn OBJECT_FIELD_S32(0x20) #define /*0x10C*/ oWigglerTargetYaw OBJECT_FIELD_S32(0x21) #define /*0x110*/ oWigglerWalkAwayFromWallTimer OBJECT_FIELD_S32(0x22) -#define /*0x1AC*/ oWigglerUnk1AC OBJECT_FIELD_S16(0x49, 0) +#define /*0x1AC*/ oWigglerUnused OBJECT_FIELD_S16(0x49, 0) #define /*0x1AE*/ oWigglerTextStatus OBJECT_FIELD_S16(0x49, + 1) /* Lll Wood Piece */ -#define /*0x0F4*/ oLllWoodPieceUnkF4 OBJECT_FIELD_S32(0x1B) +#define /*0x0F4*/ oLllWoodPieceOscillationTimer OBJECT_FIELD_S32(0x1B) /* Wooden Post */ #define /*0x0F4*/ oWoodenPostTotalMarioAngle OBJECT_FIELD_S32(0x1B) @@ -1157,8 +1156,8 @@ #define /*0x104*/ oWoodenPostOffsetY OBJECT_FIELD_F32(0x1F) /* Yoshi */ -#define /*0x0F4*/ oYoshiUnkF4 OBJECT_FIELD_S32(0x1B) +#define /*0x0F4*/ oYoshiBlinkTimer OBJECT_FIELD_S32(0x1B) #define /*0x0FC*/ oYoshiChosenHome OBJECT_FIELD_S32(0x1D) #define /*0x100*/ oYoshiTargetYaw OBJECT_FIELD_S32(0x1E) -#endif +#endif // OBJECT_FIELDS_H diff --git a/include/platform_info.h b/include/platform_info.h index 2197833a..3222bc7a 100644 --- a/include/platform_info.h +++ b/include/platform_info.h @@ -7,4 +7,4 @@ #define DOUBLE_SIZE_ON_64_BIT(size) ((size) * (sizeof(void *) / 4)) -#endif +#endif // PLATFORM_INFO_H diff --git a/include/prevent_bss_reordering.h b/include/prevent_bss_reordering.h index 8bc78e06..51a85ade 100644 --- a/include/prevent_bss_reordering.h +++ b/include/prevent_bss_reordering.h @@ -1,5 +1,5 @@ -#ifndef _PREVENT_BSS_REORDERING_H -#define _PREVENT_BSS_REORDERING_H +#ifndef PREVENT_BSS_REORDERING_H +#define PREVENT_BSS_REORDERING_H /** * To determine variable order for .bss, the compiler sorts variables by their @@ -80,4 +80,4 @@ struct Dummy61 { int x; }; struct Dummy62 { int x; }; typedef int Dummy63; -#endif +#endif // PREVENT_BSS_REORDERING_H diff --git a/include/segment_symbols.h b/include/segment_symbols.h index 26d65cde..09c950d0 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -1,82 +1,4 @@ #ifndef SEGMENT_SYMBOLS_H #define SEGMENT_SYMBOLS_H -#define DECLARE_SEGMENT(name) \ - static u8 _##name##SegmentRomStart[1]; \ - static u8 _##name##SegmentRomEnd[1]; - -#define DECLARE_ACTOR_SEGMENT(name) \ - DECLARE_SEGMENT(name##_mio0) \ - DECLARE_SEGMENT(name##_geo) - -#define DECLARE_LEVEL_SEGMENT(name) \ - DECLARE_SEGMENT(name) \ - DECLARE_SEGMENT(name##_segment_7) - -DECLARE_ACTOR_SEGMENT(common0) -DECLARE_ACTOR_SEGMENT(common1) -DECLARE_ACTOR_SEGMENT(group0) -DECLARE_ACTOR_SEGMENT(group1) -DECLARE_ACTOR_SEGMENT(group2) -DECLARE_ACTOR_SEGMENT(group3) -DECLARE_ACTOR_SEGMENT(group4) -DECLARE_ACTOR_SEGMENT(group5) -DECLARE_ACTOR_SEGMENT(group6) -DECLARE_ACTOR_SEGMENT(group7) -DECLARE_ACTOR_SEGMENT(group8) -DECLARE_ACTOR_SEGMENT(group9) -DECLARE_ACTOR_SEGMENT(group10) -DECLARE_ACTOR_SEGMENT(group11) -DECLARE_ACTOR_SEGMENT(group12) -DECLARE_ACTOR_SEGMENT(group13) -DECLARE_ACTOR_SEGMENT(group14) -DECLARE_ACTOR_SEGMENT(group15) -DECLARE_ACTOR_SEGMENT(group16) -DECLARE_ACTOR_SEGMENT(group17) - -DECLARE_SEGMENT(behavior) -DECLARE_SEGMENT(scripts) -DECLARE_SEGMENT(goddard) -static u8 _goddardSegmentStart[1]; - -DECLARE_LEVEL_SEGMENT(menu) -DECLARE_LEVEL_SEGMENT(intro) -DECLARE_LEVEL_SEGMENT(ending) - -#define STUB_LEVEL(_0, _1, _2, _3, _4, _5, _6, _7, _8) -#define DEFINE_LEVEL(_0, _1, _2, folder, _4, _5, _6, _7, _8, _9, _10) DECLARE_LEVEL_SEGMENT(folder) - -#include "levels/level_defines.h" - -#undef STUB_LEVEL -#undef DEFINE_LEVEL - -DECLARE_SEGMENT(water_skybox_mio0) -DECLARE_SEGMENT(ccm_skybox_mio0) -DECLARE_SEGMENT(clouds_skybox_mio0) -DECLARE_SEGMENT(bitfs_skybox_mio0) -DECLARE_SEGMENT(wdw_skybox_mio0) -DECLARE_SEGMENT(cloud_floor_skybox_mio0) -DECLARE_SEGMENT(ssl_skybox_mio0) -DECLARE_SEGMENT(bbh_skybox_mio0) -DECLARE_SEGMENT(bidw_skybox_mio0) -DECLARE_SEGMENT(bits_skybox_mio0) - -DECLARE_SEGMENT(fire_mio0) -DECLARE_SEGMENT(spooky_mio0) -DECLARE_SEGMENT(generic_mio0) -DECLARE_SEGMENT(water_mio0) -DECLARE_SEGMENT(sky_mio0) -DECLARE_SEGMENT(snow_mio0) -DECLARE_SEGMENT(cave_mio0) -DECLARE_SEGMENT(machine_mio0) -DECLARE_SEGMENT(mountain_mio0) -DECLARE_SEGMENT(grass_mio0) -DECLARE_SEGMENT(outside_mio0) -DECLARE_SEGMENT(inside_mio0) -DECLARE_SEGMENT(effect_mio0) -DECLARE_SEGMENT(title_screen_bg_mio0) - -DECLARE_SEGMENT(debug_level_select_mio0) - -#endif +#endif // SEGMENT_SYMBOLS_H diff --git a/include/segments.h b/include/segments.h index b03463ae..ab4c68d7 100644 --- a/include/segments.h +++ b/include/segments.h @@ -1,5 +1,5 @@ -#ifndef _SEGMENTS_H -#define _SEGMENTS_H +#ifndef SEGMENTS_H +#define SEGMENTS_H #ifdef BETTERCAMERA #define USE_EXT_RAM @@ -64,4 +64,4 @@ #define SEG_GODDARD SEG_POOL_START + 0x113000 #endif -#endif // _SEGMENTS_H +#endif // SEGMENTS_H diff --git a/include/seq_ids.h b/include/seq_ids.h index 3ed81ff9..4e529791 100644 --- a/include/seq_ids.h +++ b/include/seq_ids.h @@ -42,4 +42,4 @@ enum SeqId { SEQ_COUNT }; -#endif +#endif // SEQ_IDS_H diff --git a/include/sm64.h b/include/sm64.h index 8dede4e8..632224e0 100644 --- a/include/sm64.h +++ b/include/sm64.h @@ -1,5 +1,5 @@ -#ifndef _SM64_H_ -#define _SM64_H_ +#ifndef SM64_H +#define SM64_H // Global header for Super Mario 64 @@ -430,4 +430,4 @@ #define C_BUTTONS (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS ) -#endif +#endif // SM64_H diff --git a/include/special_preset_names.h b/include/special_preset_names.h index 92055a88..229d2878 100644 --- a/include/special_preset_names.h +++ b/include/special_preset_names.h @@ -1,5 +1,5 @@ -#ifndef _SPECIAL_PRESET_NAMES_H -#define _SPECIAL_PRESET_NAMES_H +#ifndef SPECIAL_PRESET_NAMES_H +#define SPECIAL_PRESET_NAMES_H enum SpecialPresets { special_null_start, @@ -43,7 +43,7 @@ enum SpecialPresets { special_rotating_counter_clockwise, special_wf_tumbling_bridge, special_large_bomp, - + special_level_geo_03 = 0x65, special_level_geo_04, special_level_geo_05, @@ -86,9 +86,8 @@ enum SpecialPresets { special_1star_door, special_3star_door, special_key_door, - + special_null_end = 0xFF }; -#endif // _SPECIAL_PRESET_NAMES_H - +#endif // SPECIAL_PRESET_NAMES_H diff --git a/include/special_presets.h b/include/special_presets.h index 3256430b..e16ac6a8 100644 --- a/include/special_presets.h +++ b/include/special_presets.h @@ -1,5 +1,5 @@ -#ifndef _SPECIAL_PRESETS_H -#define _SPECIAL_PRESETS_H +#ifndef SPECIAL_PRESETS_H +#define SPECIAL_PRESETS_H #include "special_preset_names.h" #include "behavior_data.h" @@ -17,13 +17,13 @@ struct SpecialPreset /*00*/ u8 preset_id; /*01*/ u8 type; // Determines whether object is 8, 10, 12 or 14 bytes long. /*02*/ u8 defParam; // Default parameter, only used when type is SPTYPE_DEF_PARAM_AND_YROT - /*03*/ u8 model; + /*03*/ u8 model; /*04*/ const BehaviorScript *behavior; }; // Some Models ID's are missing their names because they are probably unused -static struct SpecialPreset SpecialObjectPresets[] = +static struct SpecialPreset SpecialObjectPresets[] = { {0x00, SPTYPE_YROT_NO_PARAMS , 0x00, MODEL_NONE, NULL}, {0x01, SPTYPE_NO_YROT_OR_PARAMS , 0x00, MODEL_YELLOW_COIN, bhvYellowCoin}, @@ -110,4 +110,4 @@ static struct SpecialPreset SpecialObjectPresets[] = {0xFF, SPTYPE_NO_YROT_OR_PARAMS , 0x00, MODEL_NONE, NULL} }; -#endif // _SPECIAL_PRESETS_H +#endif // SPECIAL_PRESETS_H diff --git a/include/surface_terrains.h b/include/surface_terrains.h index bae4df2a..669a0ac2 100644 --- a/include/surface_terrains.h +++ b/include/surface_terrains.h @@ -220,4 +220,4 @@ // Water Box #define COL_WATER_BOX(id, x1, z1, x2, z2, y) id, x1, z1, x2, z2, y -#endif +#endif // SURFACE_TERRAINS_H diff --git a/include/text_menu_strings.h.in b/include/text_menu_strings.h.in index 04cb3295..c9f93af3 100644 --- a/include/text_menu_strings.h.in +++ b/include/text_menu_strings.h.in @@ -15,4 +15,4 @@ #define TEXT_JPHUD_ERASE_FILE _("ファむルけす") #define TEXT_JPHUD_SOUND_SELECT _("サりンドセレクト") -#endif +#endif // TEXT_MENU_STRINGS_H diff --git a/include/text_strings.h.in b/include/text_strings.h.in index 786e3a36..e5065c57 100644 --- a/include/text_strings.h.in +++ b/include/text_strings.h.in @@ -482,6 +482,6 @@ #define TEXT_MENU_SA_DE _(" VERSTECKTES AQUARIUM") #define TEXT_MENU_NONE_DE _("") #define TEXT_MENU_STARS_DE _(" GEHEIME STERNE") -#endif +#endif // VERSION_EU -#endif +#endif // TEXT_STRINGS_H diff --git a/include/textures.h b/include/textures.h index a558d19e..a3205ae5 100644 --- a/include/textures.h +++ b/include/textures.h @@ -1,7 +1,8 @@ #ifndef TEXTURES_H #define TEXTURES_H -#include +#include +#include // cave extern const u8 cave_09000000[]; @@ -277,4 +278,4 @@ extern const Gfx title_screen_bg_dl_0A000190[]; extern const u8 *const mario_title_texture_table[]; extern const u8 *const game_over_texture_table[]; -#endif +#endif // TEXTURES_H diff --git a/include/types.h b/include/types.h index 48b4fcd0..d11e2380 100644 --- a/include/types.h +++ b/include/types.h @@ -338,10 +338,10 @@ struct MarioState /*0xB4*/ u8 squishTimer; /*0xB5*/ u8 fadeWarpOpacity; /*0xB6*/ u16 capTimer; - /*0xB8*/ s16 unkB8; + /*0xB8*/ s16 prevNumStarsForDialog; /*0xBC*/ f32 peakHeight; /*0xC0*/ f32 quicksandDepth; /*0xC4*/ f32 unkC4; }; -#endif +#endif // _SM64_TYPES_H_ diff --git a/levels/bbh/script.c b/levels/bbh/script.c index 9c400b68..bfa04334 100644 --- a/levels/bbh/script.c +++ b/levels/bbh/script.c @@ -107,7 +107,7 @@ const LevelScript level_bbh_entry[] = { JUMP_LINK(script_func_local_2), JUMP_LINK(script_func_local_3), JUMP_LINK(script_func_local_4), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 666, 796, 5350, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 666, 796, 5350, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_BBH, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE_COURTYARD, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE_COURTYARD, /*destArea*/ 0x01, /*destNode*/ 0x0B, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/bitdw/script.c b/levels/bitdw/script.c index d97fec47..5e14a7ee 100644 --- a/levels/bitdw/script.c +++ b/levels/bitdw/script.c @@ -87,7 +87,7 @@ const LevelScript level_bitdw_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_BITDW_STAIRCASE, geo_bitdw_000600), AREA(/*index*/ 1, geo_bitdw_000618), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7443, -2153, 3886, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7443, -2153, 3886, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), OBJECT(/*model*/ MODEL_BITDW_WARP_PIPE, /*pos*/ 6816, 2860, -7, /*angle*/ 0, 0, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvWarpPipe), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 5910, 3500, -7, /*angle*/ 0, 90, 0, /*behParam*/ 0x000C0000, /*beh*/ bhvDeathWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_BITDW, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/bitfs/script.c b/levels/bitfs/script.c index f9f1f645..56b108dc 100644 --- a/levels/bitfs/script.c +++ b/levels/bitfs/script.c @@ -100,7 +100,7 @@ const LevelScript level_bitfs_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_BITFS_TUMBLING_PLATFORM, bitfs_geo_0006F0), AREA(/*index*/ 1, bitfs_geo_0007A0), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7577, -1764, 0, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7577, -1764, 0, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 6735, 3681, 99, /*angle*/ 0, 0, 0, /*behParam*/ 0x140B0000, /*beh*/ bhvWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 5886, 5000, 99, /*angle*/ 0, 90, 0, /*behParam*/ 0x000C0000, /*beh*/ bhvDeathWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_BITFS, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/bits/script.c b/levels/bits/script.c index 59dc60d6..2d1bd872 100644 --- a/levels/bits/script.c +++ b/levels/bits/script.c @@ -90,7 +90,7 @@ const LevelScript level_bits_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_BITS_WARP_PIPE, warp_pipe_geo), AREA(/*index*/ 1, bits_geo_000718), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7039, -3812, 4, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7039, -3812, 4, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), OBJECT(/*model*/ MODEL_BITS_WARP_PIPE, /*pos*/ 351, 6652, -6030, /*angle*/ 0, 0, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvWarpPipe), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 351, 6800, -3900, /*angle*/ 0, 180, 0, /*behParam*/ 0x000C0000, /*beh*/ bhvDeathWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_BITS, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/bob/script.c b/levels/bob/script.c index fac6daf7..ce7bf54c 100644 --- a/levels/bob/script.c +++ b/levels/bob/script.c @@ -78,7 +78,7 @@ const LevelScript level_bob_entry[] = { JUMP_LINK(script_func_local_1), JUMP_LINK(script_func_local_2), JUMP_LINK(script_func_local_3), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -6558, 1000, 6464, /*angle*/ 0, 135, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -6558, 1000, 6464, /*angle*/ 0, 135, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 583, 2683, -5387, /*angle*/ 0, -154, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvFadingWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 1680, 3835, -5523, /*angle*/ 0, -153, 0, /*behParam*/ 0x000C0000, /*beh*/ bhvFadingWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -6612, 1024, -3351, /*angle*/ 0, 107, 0, /*behParam*/ 0x000D0000, /*beh*/ bhvFadingWarp), diff --git a/levels/bowser_1/script.c b/levels/bowser_1/script.c index bb201194..e70de999 100644 --- a/levels/bowser_1/script.c +++ b/levels/bowser_1/script.c @@ -28,7 +28,7 @@ const LevelScript level_bowser_1_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_LEVEL_GEOMETRY_03, bowser_1_yellow_sphere_geo), AREA(/*index*/ 1, bowser_1_geo_0000D0), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 1307, 0, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps6C), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 1307, 0, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneCircleWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_BOWSER_1, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x24, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_BITDW, /*destArea*/ 0x01, /*destNode*/ 0x0C, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/bowser_2/script.c b/levels/bowser_2/script.c index f72b70d5..b848c00c 100644 --- a/levels/bowser_2/script.c +++ b/levels/bowser_2/script.c @@ -38,7 +38,7 @@ const LevelScript level_bowser_2_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_BOWSER_2_TILTING_ARENA, bowser_2_geo_000170), AREA(/*index*/ 1, bowser_2_geo_000188), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 2229, 0, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps6C), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 2229, 0, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneCircleWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_BOWSER_2, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x36, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_BITFS, /*destArea*/ 0x01, /*destNode*/ 0x0C, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/bowser_3/script.c b/levels/bowser_3/script.c index 18bb87d0..756ef81b 100644 --- a/levels/bowser_3/script.c +++ b/levels/bowser_3/script.c @@ -56,7 +56,7 @@ const LevelScript level_bowser_3_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_LEVEL_GEOMETRY_03, bowser_3_geo_000380), AREA(/*index*/ 1, bowser_3_geo_000398), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 1307, 0, /*angle*/ 0, 183, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps6C), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 1307, 0, /*angle*/ 0, 183, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneCircleWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_BOWSER_3, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), JUMP_LINK(script_func_local_1), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_BITS, /*destArea*/ 0x01, /*destNode*/ 0x0C, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/castle_courtyard/script.c b/levels/castle_courtyard/script.c index 05e7f995..c17cc21a 100644 --- a/levels/castle_courtyard/script.c +++ b/levels/castle_courtyard/script.c @@ -48,8 +48,8 @@ const LevelScript level_castle_courtyard_entry[] = { AREA(/*index*/ 1, castle_courtyard_geo_000218), OBJECT(/*model*/ MODEL_BOO, /*pos*/ -2360, -100, -2712, /*angle*/ 0, 0, 0, /*behParam*/ 0x01050000, /*beh*/ bhvBooWithCage), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 51, -1000, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps8C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 51, -1000, /*angle*/ 0, 180, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvWarps90), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 51, -1000, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvLaunchStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 51, -1000, /*angle*/ 0, 180, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvLaunchDeathWarp), WARP_NODE(/*id*/ 0x05, /*destLevel*/ LEVEL_BBH, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_CASTLE_COURTYARD, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_CASTLE_COURTYARD, /*destArea*/ 0x01, /*destNode*/ 0x0B, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/castle_grounds/script.c b/levels/castle_grounds/script.c index ccba9859..8d197f93 100644 --- a/levels/castle_grounds/script.c +++ b/levels/castle_grounds/script.c @@ -21,21 +21,21 @@ static const LevelScript script_func_local_1[] = { WARP_NODE(/*id*/ 0x02, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x02, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 900, -1710, /*angle*/ 0, 180, 0, /*behParam*/ 0x00030000, /*beh*/ bhvDeathWarp), WARP_NODE(/*id*/ 0x03, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x03, /*flags*/ WARP_NO_CHECKPOINT), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1328, 260, 4664, /*angle*/ 0, 180, 0, /*behParam*/ 0x00040000, /*beh*/ bhvWarps6C), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1328, 260, 4664, /*angle*/ 0, 180, 0, /*behParam*/ 0x00040000, /*beh*/ bhvSpinAirborneCircleWarp), WARP_NODE(/*id*/ 0x04, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x04, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3379, -815, -2025, /*angle*/ 0, 0, 0, /*behParam*/ 0x3C050000, /*beh*/ bhvWarp), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3379, -500, -2025, /*angle*/ 0, 180, 0, /*behParam*/ 0x00060000, /*beh*/ bhvWarps90), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3799, -1199, -5816, /*angle*/ 0, 0, 0, /*behParam*/ 0x00070000, /*beh*/ bhvWarps94), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3379, -500, -2025, /*angle*/ 0, 180, 0, /*behParam*/ 0x00080000, /*beh*/ bhvWarps8C), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3379, -500, -2025, /*angle*/ 0, 180, 0, /*behParam*/ 0x00060000, /*beh*/ bhvLaunchDeathWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3799, -1199, -5816, /*angle*/ 0, 0, 0, /*behParam*/ 0x00070000, /*beh*/ bhvSwimmingWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3379, -500, -2025, /*angle*/ 0, 180, 0, /*behParam*/ 0x00080000, /*beh*/ bhvLaunchStarCollectWarp), WARP_NODE(/*id*/ 0x05, /*destLevel*/ LEVEL_VCUTM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x06, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x06, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x07, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x07, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x08, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x08, /*flags*/ WARP_NO_CHECKPOINT), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 5408, 4500, 3637, /*angle*/ 0, 225, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 5408, 4500, 3637, /*angle*/ 0, 225, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -6901, 2376, -6509, /*angle*/ 0, 230, 0, /*behParam*/ 0x00140000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -6901, 2376, -6509, /*angle*/ 0, 230, 0, /*behParam*/ 0x00140000, /*beh*/ bhvAirborneWarp), WARP_NODE(/*id*/ 0x14, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x14, /*flags*/ WARP_NO_CHECKPOINT), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 4997, -1250, 2258, /*angle*/ 0, 210, 0, /*behParam*/ 0x001E0000, /*beh*/ bhvWarps94), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 4997, -1250, 2258, /*angle*/ 0, 210, 0, /*behParam*/ 0x001E0000, /*beh*/ bhvSwimmingWarp), WARP_NODE(/*id*/ 0x1E, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x1E, /*flags*/ WARP_NO_CHECKPOINT), RETURN(), }; diff --git a/levels/castle_inside/header.h b/levels/castle_inside/header.h index 7ad2a7bf..dfd63923 100644 --- a/levels/castle_inside/header.h +++ b/levels/castle_inside/header.h @@ -2,6 +2,7 @@ #define CASTLE_INSIDE_HEADER_H #include "types.h" +#include "game/paintings.h" #include "game/moving_texture.h" // geo diff --git a/levels/castle_inside/script.c b/levels/castle_inside/script.c index 28d9c731..5d9ae4fb 100644 --- a/levels/castle_inside/script.c +++ b/levels/castle_inside/script.c @@ -49,16 +49,16 @@ static const LevelScript script_func_local_1[] = { OBJECT(/*model*/ MODEL_NONE, /*pos*/ 1963, 819, 1280, /*angle*/ 0, 0, 0, /*behParam*/ 0x050C0000, /*beh*/ bhvWarp), WARP_NODE(/*id*/ 0x0C, /*destLevel*/ LEVEL_SA, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF2, /*destLevel*/ LEVEL_TOTWC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 512, -650, /*angle*/ 0, 0, 0, /*behParam*/ 0x001E0000, /*beh*/ bhvWarps60), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, -50, 717, /*angle*/ 0, 180, 0, /*behParam*/ 0x001F0000, /*beh*/ bhvWarps60), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 900, 717, /*angle*/ 0, 180, 0, /*behParam*/ 0x00200000, /*beh*/ bhvWarps64), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 900, 717, /*angle*/ 0, 180, 0, /*behParam*/ 0x00210000, /*beh*/ bhvWarps84), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 900, 717, /*angle*/ 0, 180, 0, /*behParam*/ 0x00220000, /*beh*/ bhvWarps68), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 512, -650, /*angle*/ 0, 0, 0, /*behParam*/ 0x001E0000, /*beh*/ bhvInstantActiveWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, -50, 717, /*angle*/ 0, 180, 0, /*behParam*/ 0x001F0000, /*beh*/ bhvInstantActiveWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 900, 717, /*angle*/ 0, 180, 0, /*behParam*/ 0x00200000, /*beh*/ bhvAirborneWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 900, 717, /*angle*/ 0, 180, 0, /*behParam*/ 0x00210000, /*beh*/ bhvAirborneDeathWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 900, 717, /*angle*/ 0, 180, 0, /*behParam*/ 0x00220000, /*beh*/ bhvHardAirKnockBackWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 900, 717, /*angle*/ 0, 180, 0, /*behParam*/ 0x00230000, /*beh*/ bhvDeathWarp), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -5513, 512, -4324, /*angle*/ 0, -135, 0, /*behParam*/ 0x00240000, /*beh*/ bhvWarps8C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -5513, 512, -4324, /*angle*/ 0, -135, 0, /*behParam*/ 0x00250000, /*beh*/ bhvWarps90), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 900, 717, /*angle*/ 0, 0, 0, /*behParam*/ 0x00260000, /*beh*/ bhvWarps88), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2816, 1200, -256, /*angle*/ 0, 90, 0, /*behParam*/ 0x00270000, /*beh*/ bhvWarps88), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -5513, 512, -4324, /*angle*/ 0, -135, 0, /*behParam*/ 0x00240000, /*beh*/ bhvLaunchStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -5513, 512, -4324, /*angle*/ 0, -135, 0, /*behParam*/ 0x00250000, /*beh*/ bhvLaunchDeathWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1024, 900, 717, /*angle*/ 0, 0, 0, /*behParam*/ 0x00260000, /*beh*/ bhvAirborneStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2816, 1200, -256, /*angle*/ 0, 90, 0, /*behParam*/ 0x00270000, /*beh*/ bhvAirborneStarCollectWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2816, 1200, -256, /*angle*/ 0, 270, 0, /*behParam*/ 0x00280000, /*beh*/ bhvDeathWarp), WARP_NODE(/*id*/ 0x1E, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x1E, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x1F, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x1F, /*flags*/ WARP_NO_CHECKPOINT), @@ -71,10 +71,10 @@ static const LevelScript script_func_local_1[] = { WARP_NODE(/*id*/ 0x26, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x26, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x27, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x27, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x28, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x28, /*flags*/ WARP_NO_CHECKPOINT), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -5422, 717, -461, /*angle*/ 0, 270, 0, /*behParam*/ 0x00320000, /*beh*/ bhvWarps7C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2304, 0, -4552, /*angle*/ 0, 180, 0, /*behParam*/ 0x00330000, /*beh*/ bhvWarps7C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 256, 102, -4706, /*angle*/ 0, 180, 0, /*behParam*/ 0x00340000, /*beh*/ bhvWarps7C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 4501, 717, -230, /*angle*/ 0, 90, 0, /*behParam*/ 0x00350000, /*beh*/ bhvWarps7C), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -5422, 717, -461, /*angle*/ 0, 270, 0, /*behParam*/ 0x00320000, /*beh*/ bhvPaintingStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2304, 0, -4552, /*angle*/ 0, 180, 0, /*behParam*/ 0x00330000, /*beh*/ bhvPaintingStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 256, 102, -4706, /*angle*/ 0, 180, 0, /*behParam*/ 0x00340000, /*beh*/ bhvPaintingStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 4501, 717, -230, /*angle*/ 0, 90, 0, /*behParam*/ 0x00350000, /*beh*/ bhvPaintingStarCollectWarp), WARP_NODE(/*id*/ 0x32, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x32, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x33, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x33, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x34, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x34, /*flags*/ WARP_NO_CHECKPOINT), @@ -122,14 +122,14 @@ static const LevelScript script_func_local_2[] = { WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_WMOTR, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -230, 4813, -3352, /*angle*/ 0, 0, 0, /*behParam*/ 0x0F0B0000, /*beh*/ bhvWarp), WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_BITS, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -659, 1613, -350, /*angle*/ 0, 180, 0, /*behParam*/ 0x00320000, /*beh*/ bhvWarps7C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -4693, 2157, 1828, /*angle*/ 0, 270, 0, /*behParam*/ 0x00330000, /*beh*/ bhvWarps88), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -675, 1400, 3870, /*angle*/ 0, 0, 0, /*behParam*/ 0x00340000, /*beh*/ bhvWarps7C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -205, 2918, 7300, /*angle*/ 0, 0, 0, /*behParam*/ 0x00350000, /*beh*/ bhvWarps7C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3538, 1766, -400, /*angle*/ 0, 180, 0, /*behParam*/ 0x00360000, /*beh*/ bhvWarps7C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -4693, 2157, 1828, /*angle*/ 0, 270, 0, /*behParam*/ 0x00370000, /*beh*/ bhvWarps88), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3002, 2816, 5886, /*angle*/ 0, 90, 0, /*behParam*/ 0x00380000, /*beh*/ bhvWarps8C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3412, 2816, 5886, /*angle*/ 0, 270, 0, /*behParam*/ 0x003A0000, /*beh*/ bhvWarps8C), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -659, 1613, -350, /*angle*/ 0, 180, 0, /*behParam*/ 0x00320000, /*beh*/ bhvPaintingStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -4693, 2157, 1828, /*angle*/ 0, 270, 0, /*behParam*/ 0x00330000, /*beh*/ bhvAirborneStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -675, 1400, 3870, /*angle*/ 0, 0, 0, /*behParam*/ 0x00340000, /*beh*/ bhvPaintingStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -205, 2918, 7300, /*angle*/ 0, 0, 0, /*behParam*/ 0x00350000, /*beh*/ bhvPaintingStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3538, 1766, -400, /*angle*/ 0, 180, 0, /*behParam*/ 0x00360000, /*beh*/ bhvPaintingStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -4693, 2157, 1828, /*angle*/ 0, 270, 0, /*behParam*/ 0x00370000, /*beh*/ bhvAirborneStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3002, 2816, 5886, /*angle*/ 0, 90, 0, /*behParam*/ 0x00380000, /*beh*/ bhvLaunchStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3412, 2816, 5886, /*angle*/ 0, 270, 0, /*behParam*/ 0x003A0000, /*beh*/ bhvLaunchStarCollectWarp), WARP_NODE(/*id*/ 0x32, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x32, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x33, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x33, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x34, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x34, /*flags*/ WARP_NO_CHECKPOINT), @@ -144,9 +144,9 @@ static const LevelScript script_func_local_2[] = { OBJECT(/*model*/ MODEL_NONE, /*pos*/ -205, 2918, 7300, /*angle*/ 0, 0, 0, /*behParam*/ 0x00670000, /*beh*/ bhvPaintingDeathWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3538, 1766, -400, /*angle*/ 0, 180, 0, /*behParam*/ 0x00680000, /*beh*/ bhvPaintingDeathWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -4693, 2157, 1828, /*angle*/ 0, 270, 0, /*behParam*/ 0x00690000, /*beh*/ bhvDeathWarp), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -230, 4813, -3352, /*angle*/ 0, 180, 0, /*behParam*/ 0x006B0000, /*beh*/ bhvWarps90), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3412, 2816, 5886, /*angle*/ 0, 270, 0, /*behParam*/ 0x006C0000, /*beh*/ bhvWarps90), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3002, 2816, 5886, /*angle*/ 0, 90, 0, /*behParam*/ 0x006D0000, /*beh*/ bhvWarps90), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -230, 4813, -3352, /*angle*/ 0, 180, 0, /*behParam*/ 0x006B0000, /*beh*/ bhvLaunchDeathWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3412, 2816, 5886, /*angle*/ 0, 270, 0, /*behParam*/ 0x006C0000, /*beh*/ bhvLaunchDeathWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3002, 2816, 5886, /*angle*/ 0, 90, 0, /*behParam*/ 0x006D0000, /*beh*/ bhvLaunchDeathWarp), WARP_NODE(/*id*/ 0x64, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x64, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x65, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x65, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x66, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x66, /*flags*/ WARP_NO_CHECKPOINT), @@ -179,11 +179,11 @@ static const LevelScript script_func_local_3[] = { PAINTING_WARP_NODE(/*id*/ 0x17, /*destLevel*/ LEVEL_DDD, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 4147, -1280, 1997, /*angle*/ 0, 0, 0, /*behParam*/ 0x0F180000, /*beh*/ bhvWarp), WARP_NODE(/*id*/ 0x18, /*destLevel*/ LEVEL_BITFS, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1382, -819, -4150, /*angle*/ 0, 180, 0, /*behParam*/ 0x00320000, /*beh*/ bhvWarps7C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2918, -870, -875, /*angle*/ 0, 0, 0, /*behParam*/ 0x00330000, /*beh*/ bhvWarps7C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2483, -1688, -2662, /*angle*/ 0, 270, 0, /*behParam*/ 0x00340000, /*beh*/ bhvWarps8C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2381, -500, 2011, /*angle*/ 0, 90, 0, /*behParam*/ 0x00350000, /*beh*/ bhvWarps88), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 4147, -1100, 1997, /*angle*/ 0, 90, 0, /*behParam*/ 0x00360000, /*beh*/ bhvWarps8C), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1382, -819, -4150, /*angle*/ 0, 180, 0, /*behParam*/ 0x00320000, /*beh*/ bhvPaintingStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2918, -870, -875, /*angle*/ 0, 0, 0, /*behParam*/ 0x00330000, /*beh*/ bhvPaintingStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2483, -1688, -2662, /*angle*/ 0, 270, 0, /*behParam*/ 0x00340000, /*beh*/ bhvLaunchStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2381, -500, 2011, /*angle*/ 0, 90, 0, /*behParam*/ 0x00350000, /*beh*/ bhvAirborneStarCollectWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 4147, -1100, 1997, /*angle*/ 0, 90, 0, /*behParam*/ 0x00360000, /*beh*/ bhvLaunchStarCollectWarp), WARP_NODE(/*id*/ 0x32, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x32, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x33, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x33, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x34, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x34, /*flags*/ WARP_NO_CHECKPOINT), @@ -191,9 +191,9 @@ static const LevelScript script_func_local_3[] = { WARP_NODE(/*id*/ 0x36, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x36, /*flags*/ WARP_NO_CHECKPOINT), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1382, -819, -4150, /*angle*/ 0, 180, 0, /*behParam*/ 0x00640000, /*beh*/ bhvPaintingDeathWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2918, -870, -875, /*angle*/ 0, 0, 0, /*behParam*/ 0x00650000, /*beh*/ bhvPaintingDeathWarp), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2483, -1688, -2662, /*angle*/ 0, 270, 0, /*behParam*/ 0x00660000, /*beh*/ bhvWarps90), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2483, -1688, -2662, /*angle*/ 0, 270, 0, /*behParam*/ 0x00660000, /*beh*/ bhvLaunchDeathWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2381, -500, 2011, /*angle*/ 0, 90, 0, /*behParam*/ 0x00670000, /*beh*/ bhvDeathWarp), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 4147, -1100, 1997, /*angle*/ 0, 90, 0, /*behParam*/ 0x00680000, /*beh*/ bhvWarps90), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 4147, -1100, 1997, /*angle*/ 0, 90, 0, /*behParam*/ 0x00680000, /*beh*/ bhvLaunchDeathWarp), WARP_NODE(/*id*/ 0x64, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x64, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x65, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x65, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x66, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x66, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/ccm/script.c b/levels/ccm/script.c index 5345a000..c43f7891 100644 --- a/levels/ccm/script.c +++ b/levels/ccm/script.c @@ -78,7 +78,7 @@ const LevelScript level_ccm_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_CCM_SNOWMAN_HEAD, ccm_geo_00040C), AREA(/*index*/ 1, ccm_geo_00051C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1512, 3560, -2305, /*angle*/ 0, 140, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1512, 3560, -2305, /*angle*/ 0, 140, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -181, 2918, -1486, /*angle*/ 0, 0, 0, /*behParam*/ 0x0F1E0000, /*beh*/ bhvWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1847, 2815, -321, /*angle*/ 0, -158, 0, /*behParam*/ 0x001F0000, /*beh*/ bhvFadingWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3349, -4694, -183, /*angle*/ 0, -34, 0, /*behParam*/ 0x00200000, /*beh*/ bhvFadingWarp), @@ -100,7 +100,7 @@ const LevelScript level_ccm_entry[] = { END_AREA(), AREA(/*index*/ 2, ccm_geo_0005E8), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -5836, 7465, -6143, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -5836, 7465, -6143, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), WARP_NODE(/*id*/ 0x14, /*destLevel*/ LEVEL_CCM, /*destArea*/ 0x01, /*destNode*/ 0x14, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_CCM, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x33, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/cotmc/script.c b/levels/cotmc/script.c index 2cef52fb..118136ce 100644 --- a/levels/cotmc/script.c +++ b/levels/cotmc/script.c @@ -45,7 +45,7 @@ const LevelScript level_cotmc_entry[] = { JUMP_LINK(script_func_global_1), AREA(/*index*/ 1, cotmc_geo_0001A0), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -4185, 1020, -47, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -4185, 1020, -47, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_COTMC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x34, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x66, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/ddd/script.c b/levels/ddd/script.c index 90a37c34..73d9a8ec 100644 --- a/levels/ddd/script.c +++ b/levels/ddd/script.c @@ -82,7 +82,7 @@ const LevelScript level_ddd_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_DDD_POLE, ddd_geo_000450), AREA(/*index*/ 1, ddd_geo_0004C0), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3071, 3000, 0, /*angle*/ 0, 7, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3071, 3000, 0, /*angle*/ 0, 7, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_DDD, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x35, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x67, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/hmc/script.c b/levels/hmc/script.c index 901ce570..06198229 100644 --- a/levels/hmc/script.c +++ b/levels/hmc/script.c @@ -95,7 +95,7 @@ const LevelScript level_hmc_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_HMC_RED_GRILLS, hmc_geo_000530), AREA(/*index*/ 1, hmc_geo_000B90), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7152, 3161, 7181, /*angle*/ 0, 135, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7152, 3161, 7181, /*angle*/ 0, 135, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3351, -4690, 4773, /*angle*/ 0, 0, 0, /*behParam*/ 0x340B0000, /*beh*/ bhvWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_HMC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_COTMC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/jrb/script.c b/levels/jrb/script.c index c09e177a..af2dd410 100644 --- a/levels/jrb/script.c +++ b/levels/jrb/script.c @@ -142,7 +142,7 @@ const LevelScript level_jrb_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_JRB_FLOATING_PLATFORM, jrb_geo_000948), AREA(/*index*/ 1, jrb_geo_000A18), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -6750, 2126, 1482, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -6750, 2126, 1482, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_JRB, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF3, /*destLevel*/ LEVEL_JRB, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x35, /*flags*/ WARP_NO_CHECKPOINT), @@ -158,7 +158,7 @@ const LevelScript level_jrb_entry[] = { END_AREA(), AREA(/*index*/ 2, jrb_geo_000AFC), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 928, 1050, -1248, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps94), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 928, 1050, -1248, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSwimmingWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_JRB, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x35, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x67, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/lll/script.c b/levels/lll/script.c index 468db3e9..1322d6c2 100644 --- a/levels/lll/script.c +++ b/levels/lll/script.c @@ -175,7 +175,7 @@ const LevelScript level_lll_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_LLL_VOLCANO_FALLING_TRAP, lll_geo_000EA8), AREA(/*index*/ 1, lll_geo_000E00), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3839, 1154, 6272, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3839, 1154, 6272, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 105, 0, /*angle*/ 0, 0, 0, /*behParam*/ 0x190B0000, /*beh*/ bhvWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3200, 11, 3456, /*angle*/ 0, -100, 0, /*behParam*/ 0x000C0000, /*beh*/ bhvFadingWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -5888, 154, 6656, /*angle*/ 0, 100, 0, /*behParam*/ 0x000D0000, /*beh*/ bhvFadingWarp), @@ -198,7 +198,7 @@ const LevelScript level_lll_entry[] = { END_AREA(), AREA(/*index*/ 2, lll_geo_000EC0), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -955, 1103, -1029, /*angle*/ 0, 118, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -955, 1103, -1029, /*angle*/ 0, 118, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_LLL, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x32, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x03, /*destNode*/ 0x64, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/pss/script.c b/levels/pss/script.c index c07d36d4..3547bf6b 100644 --- a/levels/pss/script.c +++ b/levels/pss/script.c @@ -29,7 +29,7 @@ const LevelScript level_pss_entry[] = { JUMP_LINK(script_func_global_9), AREA(/*index*/ 1, pss_geo_000100), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 5632, 6751, -5631, /*angle*/ 0, 270, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 5632, 6751, -5631, /*angle*/ 0, 270, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_PSS, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF3, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x20, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x26, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/rr/script.c b/levels/rr/script.c index fea2baa2..85f925e1 100644 --- a/levels/rr/script.c +++ b/levels/rr/script.c @@ -119,7 +119,7 @@ const LevelScript level_rr_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_RR_TRICKY_TRIANGLES_FRAME4, rr_geo_0009B8), AREA(/*index*/ 1, rr_geo_0009D0), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2599, -833, 2071, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2599, -833, 2071, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7092, 2364, -63, /*angle*/ 0, 90, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvFadingWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -4213, 3379, -2815, /*angle*/ 0, 180, 0, /*behParam*/ 0x000C0000, /*beh*/ bhvFadingWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_RR, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/sa/script.c b/levels/sa/script.c index 720f5ee0..57dd3014 100644 --- a/levels/sa/script.c +++ b/levels/sa/script.c @@ -42,7 +42,7 @@ const LevelScript level_sa_entry[] = { JUMP_LINK(script_func_global_14), AREA(/*index*/ 1, sa_geo_000170), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, -1535, 0, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps94), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, -1535, 0, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSwimmingWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_SA, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x27, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x28, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/sl/script.c b/levels/sl/script.c index 59ff7a3e..47e1338c 100644 --- a/levels/sl/script.c +++ b/levels/sl/script.c @@ -65,8 +65,8 @@ const LevelScript level_sl_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_SL_SNOW_TREE, snow_tree_geo), AREA(/*index*/ 1, sl_geo_0003A8), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 5541, 2024, 443, /*angle*/ 0, 270, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 257, 2150, 1399, /*angle*/ 0, 290, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvWarps60), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 5541, 2024, 443, /*angle*/ 0, 270, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 257, 2150, 1399, /*angle*/ 0, 290, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvInstantActiveWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 569, 2150, 1336, /*angle*/ 0, 0, 0, /*behParam*/ 0x060C0000, /*beh*/ bhvWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 5468, 1056, -5400, /*angle*/ 0, -20, 0, /*behParam*/ 0x000D0000, /*beh*/ bhvFadingWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -3698, 1024, -1237, /*angle*/ 0, 6, 0, /*behParam*/ 0x000E0000, /*beh*/ bhvFadingWarp), @@ -87,7 +87,7 @@ const LevelScript level_sl_entry[] = { END_AREA(), AREA(/*index*/ 2, sl_geo_000484), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 0, 2867, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps60), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 0, 2867, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvInstantActiveWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 0, 3277, /*angle*/ 0, 0, 0, /*behParam*/ 0x140B0000, /*beh*/ bhvWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_SL, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_SL, /*destArea*/ 0x01, /*destNode*/ 0x0B, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/ssl/script.c b/levels/ssl/script.c index 684dc9b1..65aec751 100644 --- a/levels/ssl/script.c +++ b/levels/ssl/script.c @@ -91,7 +91,7 @@ const LevelScript level_ssl_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_SSL_TOX_BOX, ssl_geo_000630), AREA(/*index*/ 1, ssl_geo_000648), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 653, 1038, 6566, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 653, 1038, 6566, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2048, 0, 56, /*angle*/ 0, 0, 0, /*behParam*/ 0x00140000, /*beh*/ bhvWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2048, 768, -1024, /*angle*/ 0, 0, 0, /*behParam*/ 0x0F1E0000, /*beh*/ bhvWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 6930, 0, -4871, /*angle*/ 0, 159, 0, /*behParam*/ 0x001F0000, /*beh*/ bhvFadingWarp), @@ -113,8 +113,8 @@ const LevelScript level_ssl_entry[] = { END_AREA(), AREA(/*index*/ 2, ssl_geo_0007CC), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 300, 6451, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 5500, 256, /*angle*/ 0, 180, 0, /*behParam*/ 0x00140000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 300, 6451, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 5500, 256, /*angle*/ 0, 180, 0, /*behParam*/ 0x00140000, /*beh*/ bhvAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3070, 1280, 2900, /*angle*/ 0, 180, 0, /*behParam*/ 0x00150000, /*beh*/ bhvFadingWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2546, 1150, -2647, /*angle*/ 0, 78, 0, /*behParam*/ 0x00160000, /*beh*/ bhvFadingWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_SSL, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/thi/script.c b/levels/thi/script.c index 3d5bfac5..dcddbc4e 100644 --- a/levels/thi/script.c +++ b/levels/thi/script.c @@ -100,8 +100,8 @@ const LevelScript level_thi_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_THI_TINY_ISLAND_TOP, thi_geo_0005C8), AREA(/*index*/ 1, thi_geo_000608), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7372, -1969, 7373, /*angle*/ 0, 149, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 410, -512, 922, /*angle*/ 0, 0, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvWarps60), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -7372, -1969, 7373, /*angle*/ 0, 149, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 410, -512, 922, /*angle*/ 0, 0, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvInstantActiveWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 410, -512, 717, /*angle*/ 0, 0, 0, /*behParam*/ 0x050C0000, /*beh*/ bhvWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 3170, -1570, /*angle*/ 0, 0, 0, /*behParam*/ 0x0A0D0000, /*beh*/ bhvWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), @@ -121,7 +121,7 @@ const LevelScript level_thi_entry[] = { END_AREA(), AREA(/*index*/ 2, thi_geo_0006D4), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2211, 110, 2212, /*angle*/ 0, 149, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2211, 110, 2212, /*angle*/ 0, 149, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 280, -767, -4180, /*angle*/ 0, 0, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvFadingWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -1638, 0, -1988, /*angle*/ 0, -126, 0, /*behParam*/ 0x000C0000, /*beh*/ bhvFadingWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), @@ -139,8 +139,8 @@ const LevelScript level_thi_entry[] = { END_AREA(), AREA(/*index*/ 3, thi_geo_00079C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 512, 1024, 2150, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps60), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 3277, 0, /*angle*/ 0, 0, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 512, 1024, 2150, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvInstantActiveWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 0, 3277, 0, /*angle*/ 0, 0, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 512, 1024, 2355, /*angle*/ 0, 0, 0, /*behParam*/ 0x050C0000, /*beh*/ bhvWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x03, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0x0B, /*destLevel*/ LEVEL_THI, /*destArea*/ 0x03, /*destNode*/ 0x0B, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/totwc/script.c b/levels/totwc/script.c index b747edaf..d0172c76 100644 --- a/levels/totwc/script.c +++ b/levels/totwc/script.c @@ -42,7 +42,7 @@ const LevelScript level_totwc_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_LEVEL_GEOMETRY_03, totwc_geo_000160), AREA(/*index*/ 1, totwc_geo_000188), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -4095, 2935, 0, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps78), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -4095, 2935, 0, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvFlyingWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_TOTWC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF3, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x20, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x26, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/ttc/script.c b/levels/ttc/script.c index 18bb3b36..4b93de86 100644 --- a/levels/ttc/script.c +++ b/levels/ttc/script.c @@ -60,7 +60,7 @@ const LevelScript level_ttc_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_TTC_LARGE_GEAR, ttc_geo_0003A0), AREA(/*index*/ 1, ttc_geo_0003B8), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 1417, -3822, -548, /*angle*/ 0, 316, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 1417, -3822, -548, /*angle*/ 0, 316, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_TTC, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x35, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x67, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/ttm/script.c b/levels/ttm/script.c index ae68d8ea..bc593aac 100644 --- a/levels/ttm/script.c +++ b/levels/ttm/script.c @@ -121,8 +121,8 @@ const LevelScript level_ttm_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_LEVEL_GEOMETRY_16, ttm_geo_000A40), AREA(/*index*/ 1, ttm_geo_000A70), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 102, -3332, 5734, /*angle*/ 0, 45, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2447, -2457, 3952, /*angle*/ 0, -105, 0, /*behParam*/ 0x00140000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 102, -3332, 5734, /*angle*/ 0, 45, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2447, -2457, 3952, /*angle*/ 0, -105, 0, /*behParam*/ 0x00140000, /*beh*/ bhvAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2267, -3006, -3788, /*angle*/ 0, 148, 0, /*behParam*/ 0x00150000, /*beh*/ bhvFadingWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -557, -3448, -4146, /*angle*/ 0, -168, 0, /*behParam*/ 0x00160000, /*beh*/ bhvFadingWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), @@ -144,7 +144,7 @@ const LevelScript level_ttm_entry[] = { END_AREA(), AREA(/*index*/ 2, ttm_geo_000B5C), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 7000, 5381, 6750, /*angle*/ 0, 225, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 7000, 5381, 6750, /*angle*/ 0, 225, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_TTM, /*destArea*/ 0x02, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x34, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x66, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/vcutm/script.c b/levels/vcutm/script.c index 1effd476..fb52c956 100644 --- a/levels/vcutm/script.c +++ b/levels/vcutm/script.c @@ -53,7 +53,7 @@ const LevelScript level_vcutm_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_VCUTM_WARP_PIPE, warp_pipe_geo), AREA(/*index*/ 1, vcutm_geo_000208), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -6143, 6734, -6143, /*angle*/ 0, 0, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -6143, 6734, -6143, /*angle*/ 0, 0, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_VCUTM, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF3, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x07, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE_GROUNDS, /*destArea*/ 0x01, /*destNode*/ 0x08, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/wdw/script.c b/levels/wdw/script.c index 773109c4..0c4b5980 100644 --- a/levels/wdw/script.c +++ b/levels/wdw/script.c @@ -93,7 +93,7 @@ const LevelScript level_wdw_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_WDW_ROTATING_PLATFORM, wdw_geo_000640), AREA(/*index*/ 1, wdw_geo_000658), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3395, 3580, 384, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 3395, 3580, 384, /*angle*/ 0, 180, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 818, 0, 3634, /*angle*/ 0, 45, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvFadingWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2865, 3328, 3065, /*angle*/ 0, 0, 0, /*behParam*/ 0x000C0000, /*beh*/ bhvFadingWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_WDW, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/wf/script.c b/levels/wf/script.c index 6924d8fc..6697b497 100644 --- a/levels/wf/script.c +++ b/levels/wf/script.c @@ -140,7 +140,7 @@ const LevelScript level_wf_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_WF_KICKABLE_BOARD_FELLED, wf_geo_000BC8), AREA(/*index*/ 1, wf_geo_000BF8), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2600, 1256, 5120, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps74), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2600, 1256, 5120, /*angle*/ 0, 90, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvSpinAirborneWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ -2925, 2560, -947, /*angle*/ 0, 19, 0, /*behParam*/ 0x000B0000, /*beh*/ bhvFadingWarp), OBJECT(/*model*/ MODEL_NONE, /*pos*/ 2548, 1075, -3962, /*angle*/ 0, 51, 0, /*behParam*/ 0x000C0000, /*beh*/ bhvFadingWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_WF, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/levels/wmotr/script.c b/levels/wmotr/script.c index 5daf0dec..dfbaae27 100644 --- a/levels/wmotr/script.c +++ b/levels/wmotr/script.c @@ -48,7 +48,7 @@ const LevelScript level_wmotr_entry[] = { JUMP_LINK(script_func_global_18), AREA(/*index*/ 1, wmotr_geo_0001F0), - OBJECT(/*model*/ MODEL_NONE, /*pos*/ -67, 2669, -16, /*angle*/ 0, 270, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvWarps64), + OBJECT(/*model*/ MODEL_NONE, /*pos*/ -67, 2669, -16, /*angle*/ 0, 270, 0, /*behParam*/ 0x000A0000, /*beh*/ bhvAirborneWarp), WARP_NODE(/*id*/ 0x0A, /*destLevel*/ LEVEL_WMOTR, /*destArea*/ 0x01, /*destNode*/ 0x0A, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF0, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x38, /*flags*/ WARP_NO_CHECKPOINT), WARP_NODE(/*id*/ 0xF1, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x02, /*destNode*/ 0x6D, /*flags*/ WARP_NO_CHECKPOINT), diff --git a/lib/ipl3_font.png b/lib/ipl3_font.png deleted file mode 100644 index 32881ff6..00000000 Binary files a/lib/ipl3_font.png and /dev/null differ diff --git a/lib/src/EU_D_802f4330.c b/lib/src/EU_D_802f4330.c index a67673d2..ad9b3bac 100644 --- a/lib/src/EU_D_802f4330.c +++ b/lib/src/EU_D_802f4330.c @@ -3,7 +3,7 @@ // an array of pointers to functions taking no arguments and returning u32... // this is only referenced in the exception handler and here. this function is called with a0=1 and // then the same memory address is loaded. it's definitely an array access though.. -extern u32 (*D_80334920[8])() ; +extern u32 (*D_80334920[8])(void) ; void EU_D_802f4330(u32 a0, u32 a1(void)) { register u32 int_disabled = __osDisableInt(); diff --git a/lib/src/__osPiCreateAccessQueue.c b/lib/src/__osPiCreateAccessQueue.c index 2a2f2c04..90d4c86a 100644 --- a/lib/src/__osPiCreateAccessQueue.c +++ b/lib/src/__osPiCreateAccessQueue.c @@ -6,13 +6,13 @@ OSMesg osPiMesgBuff[PIAccessQueueSize]; OSMesgQueue gOsPiMessageQueue; u32 gOsPiAccessQueueCreated = 0; -void __osPiCreateAccessQueue() { +void __osPiCreateAccessQueue(void) { gOsPiAccessQueueCreated = 1; osCreateMesgQueue(&gOsPiMessageQueue, &osPiMesgBuff[0], PIAccessQueueSize - 1); osSendMesg(&gOsPiMessageQueue, NULL, OS_MESG_NOBLOCK); } -void __osPiGetAccess() { +void __osPiGetAccess(void) { OSMesg sp1c; if (!gOsPiAccessQueueCreated) { __osPiCreateAccessQueue(); @@ -20,6 +20,6 @@ void __osPiGetAccess() { osRecvMesg(&gOsPiMessageQueue, &sp1c, OS_MESG_BLOCK); } -void __osPiRelAccess() { +void __osPiRelAccess(void) { osSendMesg(&gOsPiMessageQueue, NULL, OS_MESG_NOBLOCK); } diff --git a/lib/src/alBnkfNew.c b/lib/src/alBnkfNew.c index d5870faa..11db85bd 100644 --- a/lib/src/alBnkfNew.c +++ b/lib/src/alBnkfNew.c @@ -57,7 +57,7 @@ static void _bnkfPatchBank(ALInstrument *inst, ALBankFile *f, u8 *table) { // Force adding another jr $ra. Has to be called or it doesn't get put in the // right place. -static void unused() { +static void unused(void) { } void alBnkfNew(ALBankFile *f, u8 *table) { diff --git a/lib/src/func_802F4A20.c b/lib/src/func_802F4A20.c index f1e85625..3e253ec7 100644 --- a/lib/src/func_802F4A20.c +++ b/lib/src/func_802F4A20.c @@ -1,82 +1,16 @@ #include "new_func.h" -void func_802F4A20() { +void func_802F4A20(void) { __OSTranxInfo *sp1c; volatile u32 sp18; - // lui $t6, %hi(__osDiskHandle) # $t6, 0x8033 - // lw $t6, %lo(__osDiskHandle)($t6) - // addiu $sp, $sp, -0x20 - // sw $ra, 0x14($sp) - // addiu $t7, $t6, 0x14 - // sw $t7, 0x1c($sp) sp1c = &__osDiskHandle->transferInfo; - // lui $t8, %hi(PI_STATUS_REG) # $t8, 0xa460 - // lw $t9, %lo(PI_STATUS_REG)($t8) - // sw $t9, 0x18($sp) - // sp18 = HW_REG(PI_STATUS_REG, u32); - // while(sp18 & 0x2) sp18 = HW_REG(PI_STATUS_REG, u32); WAIT_ON_IOBUSY(sp18); - // lw $t0, 0x18($sp) - // andi $t1, $t0, 2 - // beqz $t1, .L802F4A70 - // nop - // L802F4A54: - // lui $t2, %hi(PI_STATUS_REG) # $t2, 0xa460 - // lw $t3, %lo(PI_STATUS_REG)($t2) - // sw $t3, 0x18($sp) - // lw $t4, 0x18($sp) - // andi $t5, $t4, 2 - // bnez $t5, .L802F4A54 - // nop - - // L802F4A70: - // lw $t6, 0x1c($sp) - // lui $at, 0x1000 - // lui $t9, %hi(D_A5000510) # $t9, 0xa500 - // lw $t7, 0x14($t6) - // lui $t0, %hi(PI_STATUS_REG) # $t0, 0xa460 - // or $t8, $t7, $at - // sw $t8, %lo(D_A5000510)($t9) HW_REG(ASIC_BM_CTL, u32) = BUFFER_MANAGER_RESET | sp1c->bmCtlShadow; //should be unk10?? - // lw $t1, %lo(PI_STATUS_REG)($t0) - // sw $t1, 0x18($sp) - // lw $t2, 0x18($sp) - // andi $t3, $t2, 2 - // beqz $t3, .L802F4AC0 - // nop WAIT_ON_IOBUSY(sp18); - // L802F4AA4: - // lui $t4, %hi(PI_STATUS_REG) # $t4, 0xa460 - // lw $t5, %lo(PI_STATUS_REG)($t4) - // sw $t5, 0x18($sp) - // lw $t6, 0x18($sp) - // andi $t7, $t6, 2 - // bnez $t7, .L802F4AA4 - // nop - // L802F4AC0: - - // lw $t8, 0x1c($sp) - // lui $t0, %hi(D_A5000510) # $t0, 0xa500 - // lw $t9, 0x14($t8) - // jal func_802F4B08 - // sw $t9, %lo(D_A5000510)($t0) HW_REG(ASIC_BM_CTL, u32) = sp1c->bmCtlShadow; func_802F4B08(); - // li $t1, 2 - // lui $t2, %hi(PI_STATUS_REG) # $t2, 0xa460 - // sw $t1, %lo(PI_STATUS_REG)($t2) HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR; - // lui $t3, %hi(D_8030208C) # $t3, 0x8030 - // lw $t3, %lo(D_8030208C)($t3) - // lui $at, (0x00100401 >> 16) # lui $at, 0x10 - // lw $ra, 0x14($sp) - // ori $at, (0x00100401 & 0xFFFF) # ori $at, $at, 0x401 - // or $t4, $t3, $at - // lui $at, %hi(D_8030208C) # $at, 0x8030 - // sw $t4, %lo(D_8030208C)($at) D_8030208C |= 0x00100401; //TODO: fix magic numbers - // jr $ra - // addiu $sp, $sp, 0x20 } typedef struct OSEventMessageStruct_0_s { @@ -85,86 +19,21 @@ typedef struct OSEventMessageStruct_0_s { } OSEventMessageStruct_0; extern OSEventMessageStruct_0 D_80363830[16]; // should be OS_NUM_EVENTS + 1 I think -void func_802F4B08() { + +void func_802F4B08(void) { OSEventMessageStruct_0 *sp2c; OSMesgQueue *sp28; u32 sp24; register OSThread *s0; - // addiu $sp, $sp, -0x30 - // lui $t6, %hi(D_80363830) # $t6, 0x8033 - // addiu $t6, %lo(D_80363830) # addiu $t6, $t6, 0x36d0 - // addiu $t7, $t6, 0x40 - // sw $ra, 0x1c($sp) - // sw $s0, 0x18($sp) - // sw $t7, 0x2c($sp) sp2c = &D_80363830[OS_EVENT_PI]; - // lw $t8, 0x40($t6) - // beqz $t8, .L802F4BE0 - // sw $t8, 0x28($sp) sp28 = sp2c->queue; - // lw $t9, 8($t8) - // lw $t0, 0x10($t8) - // slt $at, $t9, $t0 - // beqz $at, .L802F4BE0 - // nop if (!sp28 || sp28->validCount >= sp28->msgCount) return; - // lw $t1, 0x28($sp) - // lw $t6, 0x2c($sp) - // lw $t2, 0xc($t1) - // lw $t3, 8($t1) - // lw $t5, 0x10($t1) - // addu $t4, $t2, $t3 - // div $zero, $t4, $t5 - // mfhi $t7 - // sw $t7, 0x24($sp) sp24 = (sp28->first + sp28->validCount) % sp28->msgCount; - // lw $t0, 0x14($t1) - // lw $t8, 4($t6) - // sll $t9, $t7, 2 - // addu $t2, $t0, $t9 - // sw $t8, ($t2) sp28->msg[sp24] = sp2c->msg; - // lw $t3, 0x28($sp) - // bnez $t5, .L802F4B8C - // nop - // break 7 - // L802F4B8C: - // li $at, -1 - // bne $t5, $at, .L802F4BA4 - // lui $at, 0x8000 - // bne $t4, $at, .L802F4BA4 - // nop - // break 6 - // L802F4BA4: - // lw $t4, 8($t3) - // addiu $t5, $t4, 1 - // sw $t5, 8($t3) sp28->validCount += 1; - // lw $t6, 0x28($sp) - // lw $t7, ($t6) - // lw $t1, ($t7) - // beqz $t1, .L802F4BE0 - // nop - // jal __osPopThread - // move $a0, $t6 if (sp28->mtqueue->next != NULL) { s0 = __osPopThread(&sp28->mtqueue); - // move $s0, $v0 - // lui $a0, %hi(D_80334898) # $a0, 0x8030 - // addiu $a0, %lo(D_80334898) # addiu $a0, $a0, 0x2ef8 - // jal __osEnqueueThread - // move $a1, $s0 __osEnqueueThread(&D_80334898, s0); } - // L802F4BE0: - // lw $ra, 0x1c($sp) - // lw $s0, 0x18($sp) - // addiu $sp, $sp, 0x30 - // jr $ra - // nop - - // nop - // nop - // nop } diff --git a/lib/src/func_802F7140.c b/lib/src/func_802F7140.c index 3c328c69..95475578 100644 --- a/lib/src/func_802F7140.c +++ b/lib/src/func_802F7140.c @@ -1,31 +1,9 @@ #include "libultra_internal.h" -extern u32 D_8030208C; +#include "new_func.h" + void func_802F7140(u32 a0) { register u32 s0; s0 = __osDisableInt(); D_8030208C &= ~(-0x402 & a0); __osRestoreInt(s0); } -/* -/ 0B6940 802F7140 27BDFFD8 / addiu $sp, $sp, -0x28 -/ 0B6944 802F7144 AFBF001C / sw $ra, 0x1c($sp) -/ 0B6948 802F7148 AFA40028 / sw $a0, 0x28($sp) -/ 0B694C 802F714C 0C0BD400 / jal __osDisableInt -/ 0B6950 802F7150 AFB00018 / sw $s0, 0x18($sp) -/ 0B6954 802F7154 8FAF0028 / lw $t7, 0x28($sp) -/ 0B6958 802F7158 3C0E8030 / lui $t6, %hi(D_8030208C) # $t6, 0x8030 -/ 0B695C 802F715C 8DCE208C / lw $t6, %lo(D_8030208C)($t6) -/ 0B6960 802F7160 2401FBFE / li $at, -1026 -/ 0B6964 802F7164 01E1C024 / and $t8, $t7, $at -/ 0B6968 802F7168 0300C827 / not $t9, $t8 -/ 0B696C 802F716C 00408025 / move $s0, $v0 -/ 0B6970 802F7170 3C018030 / lui $at, %hi(D_8030208C) # $at, 0x8030 -/ 0B6974 802F7174 01D94024 / and $t0, $t6, $t9 -/ 0B6978 802F7178 AC28208C / sw $t0, %lo(D_8030208C)($at) -/ 0B697C 802F717C 0C0BD408 / jal __osRestoreInt -/ 0B6980 802F7180 02002025 / move $a0, $s0 -/ 0B6984 802F7184 8FBF001C / lw $ra, 0x1c($sp) -/ 0B6988 802F7188 8FB00018 / lw $s0, 0x18($sp) -/ 0B698C 802F718C 27BD0028 / addiu $sp, $sp, 0x28 -/ 0B6990 802F7190 03E00008 / jr $ra -/ 0B6994 802F7194 00000000 / nop */ diff --git a/lib/src/func_802F71F0.c b/lib/src/func_802F71F0.c index 6785cc42..e829ae47 100644 --- a/lib/src/func_802F71F0.c +++ b/lib/src/func_802F71F0.c @@ -1,31 +1,8 @@ #include "libultra_internal.h" -void func_802F71F0() { +void func_802F71F0(void) { register u32 s0 = __osDisableInt(); D_803348A0->state = OS_STATE_RUNNABLE; __osEnqueueAndYield(&D_80334898); __osRestoreInt(s0); } -/* -/ 0B69F0 802F71F0 27BDFFD8 / addiu $sp, $sp, -0x28 -/ 0B69F4 802F71F4 AFBF001C / sw $ra, 0x1c($sp) -/ 0B69F8 802F71F8 0C0BD400 / jal __osDisableInt -/ 0B69FC 802F71FC AFB00018 / sw $s0, 0x18($sp) -/ 0B6A00 802F7200 3C0F8030 / lui $t7, %hi(D_803348A0) # $t7, 0x8030 -/ 0B6A04 802F7204 8DEF2F00 / lw $t7, %lo(D_803348A0)($t7) -/ 0B6A08 802F7208 240E0002 / li $t6, 2 -/ 0B6A0C 802F720C 3C048030 / lui $a0, %hi(D_80334898) # $a0, 0x8030 -/ 0B6A10 802F7210 00408025 / move $s0, $v0 -/ 0B6A14 802F7214 24842EF8 / addiu $a0, %lo(D_80334898) # addiu $a0, $a0, 0x2ef8 -/ 0B6A18 802F7218 0C0BCFC3 / jal __osEnqueueAndYield -/ 0B6A1C 802F721C A5EE0010 / sh $t6, 0x10($t7) - -/ 0B6A20 802F7220 0C0BD408 / jal __osRestoreInt -/ 0B6A24 802F7224 02002025 / move $a0, $s0 -/ 0B6A28 802F7228 8FBF001C / lw $ra, 0x1c($sp) -/ 0B6A2C 802F722C 8FB00018 / lw $s0, 0x18($sp) -/ 0B6A30 802F7230 27BD0028 / addiu $sp, $sp, 0x28 -/ 0B6A34 802F7234 03E00008 / jr $ra -/ 0B6A38 802F7238 00000000 / nop - -/ 0B6A3C 802F723C 00000000 / nop */ diff --git a/lib/src/guMtxF2L.c b/lib/src/guMtxF2L.c index 9cd7359c..e76ab6e7 100644 --- a/lib/src/guMtxF2L.c +++ b/lib/src/guMtxF2L.c @@ -2,7 +2,7 @@ #include void guMtxF2L(float mf[4][4], Mtx *m) { - memcpy(m, mf, sizeof(Mtx)); + memcpy(m->m, mf, sizeof(Mtx)); } void guMtxIdentF(float mf[4][4]) { @@ -18,8 +18,6 @@ void guMtxIdentF(float mf[4][4]) { } } void guMtxIdent(Mtx *m) { - guMtxIdentF(m->m); - } diff --git a/lib/src/kdebugserver.c b/lib/src/kdebugserver.c index 96743337..c4aba2b5 100644 --- a/lib/src/kdebugserver.c +++ b/lib/src/kdebugserver.c @@ -68,14 +68,16 @@ void send(u8 *buff, s32 len) { send_packet(&buff[end], rem); } } -void process_command_memory() { + +void process_command_memory(void) { u32 sp1c; u32 sp18; sp1c = string_to_u32(&D_80365E40[1]); sp18 = string_to_u32(&D_80365E40[5]); send((u8 *) (uintptr_t) sp1c, sp18); } -void process_command_register() { + +void process_command_register(void) { send((u8 *) &gInterruptedThread.context, sizeof(__OSThreadContext)); } diff --git a/lib/src/libultra_internal.h b/lib/src/libultra_internal.h index 4b2473b3..440daa73 100644 --- a/lib/src/libultra_internal.h +++ b/lib/src/libultra_internal.h @@ -60,40 +60,40 @@ typedef struct { #endif } OSMgrArgs; -s32 __osDisableInt(); +s32 __osDisableInt(void); void __osRestoreInt(s32); void __osEnqueueAndYield(OSThread **); void __osDequeueThread(OSThread **, OSThread *); void __osEnqueueThread(OSThread **, OSThread *); OSThread *__osPopThread(OSThread **); s32 __osSiRawStartDma(s32, void *); -void __osSiCreateAccessQueue(); -void __osSiGetAccess(); -void __osSiRelAccess(); +void __osSiCreateAccessQueue(void); +void __osSiGetAccess(void); +void __osSiRelAccess(void); u32 __osProbeTLB(void *); -void __osPiCreateAccessQueue(); -void __osPiGetAccess(); +void __osPiCreateAccessQueue(void); +void __osPiGetAccess(void); void __osSetSR(u32); -u32 __osGetSR(); +u32 __osGetSR(void); void __osSetFpcCsr(u32); s32 __osSiRawReadIo(void *, u32 *); s32 __osSiRawWriteIo(void *, u32); s32 osPiRawReadIo(u32 a0, u32 *a1); void __osSpSetStatus(u32); -u32 __osSpGetStatus(); +u32 __osSpGetStatus(void); s32 __osSpSetPc(void *); -s32 __osSpDeviceBusy(); -s32 __osSiDeviceBusy(); +s32 __osSpDeviceBusy(void); +s32 __osSiDeviceBusy(void); s32 __osSpRawStartDma(u32 dir, void *sp_ptr, void *dram_ptr, size_t size); -void __osViInit(); -OSViContext *__osViGetCurrentContext(); -OSViContext *__osViGetCurrentContext2(); -void __osViSwapContext(); +void __osViInit(void); +OSViContext *__osViGetCurrentContext(void); +OSViContext *__osViGetCurrentContext2(void); +void __osViSwapContext(void); void __osSetTimerIntr(u64); u64 __osInsertTimer(OSTimer *); void __osSetCompare(u32); -s32 __osAiDeviceBusy(); -void __osDispatchThread(); -u32 __osGetCause(); +s32 __osAiDeviceBusy(void); +void __osDispatchThread(void); +u32 __osGetCause(void); s32 __osAtomicDec(u32 *); #endif diff --git a/lib/src/new_func.h b/lib/src/new_func.h index 3453925a..c72a6b23 100644 --- a/lib/src/new_func.h +++ b/lib/src/new_func.h @@ -1,5 +1,6 @@ #ifndef NEW_FUNC_H #define NEW_FUNC_H + #include "libultra_internal.h" #include "hardware.h" @@ -14,9 +15,10 @@ extern OSPiHandle *__osDiskHandle; //possibly __osPiTable extern volatile u32 D_8030208C; s32 osEPiRawStartDma(OSPiHandle *arg0, s32 dir, u32 cart_addr, void *dram_addr, u32 size); -void func_802F4B08(); -void func_802F4A20(); +void func_802F4B08(void); +void func_802F4A20(void); void func_802F7140(u32); void func_802F71A0(OSPiHandle*, u32, u32); //osEPi something -void func_802F71F0(); +void func_802F71F0(void); + #endif diff --git a/lib/src/osContInit.c b/lib/src/osContInit.c index d40bf7e0..d0c707f6 100644 --- a/lib/src/osContInit.c +++ b/lib/src/osContInit.c @@ -4,96 +4,96 @@ void __osPackRequestData(u8); void __osContGetInitData(u8 *, OSContStatus *); -u32 D_80334810 = 0; // probably initialized +u32 _osContInitialized = 0; // probably initialized extern u64 osClockRate; // these probably belong in EEPROMlongread or something -u8 D_80365D20; -u8 _osCont_numControllers; -OSTimer D_80365D28; // some kind of buffer, or maybe an as yet unknown struct +u8 _osLastSentSiCmd; +u8 _osContNumControllers; +OSTimer D_80365D28; OSMesgQueue _osContMesgQueue; OSMesg _osContMesgBuff[4]; -s32 osContInit(OSMesgQueue *mq, u8 *a1, OSContStatus *status) { +s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *status) { OSMesg mesg; - u32 sp78 = 0; + u32 ret = 0; OSTime currentTime; - OSTimer sp50; - OSMesgQueue sp38; + OSTimer timer; + OSMesgQueue timerMesgQueue; - if (D_80334810) { + if (_osContInitialized) { return 0; } - D_80334810 = 1; + _osContInitialized = 1; currentTime = osGetTime(); if (500000 * osClockRate / 1000000 > currentTime) { - osCreateMesgQueue(&sp38, &mesg, 1); - osSetTimer(&sp50, 500000 * osClockRate / 1000000 - currentTime, 0, &sp38, &mesg); - osRecvMesg(&sp38, &mesg, OS_MESG_BLOCK); + osCreateMesgQueue(&timerMesgQueue, &mesg, 1); + osSetTimer(&timer, 500000 * osClockRate / 1000000 - currentTime, 0, &timerMesgQueue, &mesg); + osRecvMesg(&timerMesgQueue, &mesg, OS_MESG_BLOCK); } - _osCont_numControllers = 4; // TODO: figure out what it means + _osContNumControllers = 4; // TODO: figure out what it means #ifdef VERSION_EU __osPackRequestData(0); #else __osPackRequestData(255); #endif - sp78 = __osSiRawStartDma(1, D_80365CE0); + ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf); osRecvMesg(mq, &mesg, OS_MESG_BLOCK); - sp78 = __osSiRawStartDma(0, D_80365CE0); + ret = __osSiRawStartDma(OS_READ, _osContCmdBuf); osRecvMesg(mq, &mesg, OS_MESG_BLOCK); - __osContGetInitData(a1, status); + __osContGetInitData(bitpattern, status); #ifdef VERSION_EU - D_80365D20 = 0; + _osLastSentSiCmd = 0; #else - D_80365D20 = 255; + _osLastSentSiCmd = 255; #endif __osSiCreateAccessQueue(); osCreateMesgQueue(&_osContMesgQueue, _osContMesgBuff, 1); - return sp78; + return ret; } -void __osContGetInitData(u8 *a0, OSContStatus *status) { - OSContPackedRequest *sp14; - OSContPackedRequest spc; +void __osContGetInitData(u8 *bitpattern, OSContStatus *status) { + OSContPackedRequest *cmdBufPtr; + OSContPackedRequest response; s32 i; u8 sp7; sp7 = 0; - sp14 = &(D_80365CE0[0].request); - for (i = 0; i < _osCont_numControllers; i++, sp14++, status++) { - spc = *(OSContPackedRequest *) sp14; - status->errnum = (spc.unk02 & 0xc0) >> 4; + cmdBufPtr = &(_osContCmdBuf[0].request); + for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, status++) { + response = *(OSContPackedRequest *) cmdBufPtr; + status->errnum = (response.rxLen & 0xc0) >> 4; if (status->errnum == 0) { - status->type = spc.unk05 << 8 | spc.unk04; - status->status = spc.unk06; + status->type = response.data2 << 8 | response.data1; + status->status = response.data3; sp7 |= 1 << i; } } - *a0 = sp7; + *bitpattern = sp7; } -void __osPackRequestData(u8 a0) { - OSContPackedRequest *spc; - OSContPackedRequest sp4; +void __osPackRequestData(u8 command) { + OSContPackedRequest *cmdBufPtr; + OSContPackedRequest request; s32 i; // some kind of weird zeroing code for (i = 0; i < 0x10; i++) { - *((u32 *) &D_80365CE0 + i) = 0; + *((u32 *) &_osContCmdBuf + i) = 0; } - D_80365D1C = 1; - spc = &D_80365CE0[0].request; - sp4.unk00 = 255; - sp4.unk01 = 1; - sp4.unk02 = 3; - sp4.unk03 = a0; - sp4.unk04 = 255; - sp4.unk05 = 255; - sp4.unk06 = 255; - sp4.unk07 = 255; + _osContPifCtrl = 1; + cmdBufPtr = &_osContCmdBuf[0].request; + request.padOrEnd = 255; + request.txLen = 1; + request.rxLen = 3; + request.command = command; + request.data1 = 255; + request.data2 = 255; + request.data3 = 255; + request.data4 = 255; - for (i = 0; i < _osCont_numControllers; i++) { - *spc++ = sp4; + for (i = 0; i < _osContNumControllers; i++) { + *cmdBufPtr++ = request; } - spc->unk00 = 254; + cmdBufPtr->padOrEnd = 254; } diff --git a/lib/src/osContInternal.h b/lib/src/osContInternal.h index 2b577e07..3131f0e3 100644 --- a/lib/src/osContInternal.h +++ b/lib/src/osContInternal.h @@ -3,10 +3,10 @@ #include typedef struct { - u8 unk00; //unknown, set to 255 a lot - u8 unk01; - u8 unk02; //probably status - u8 unk03; //maybe errno + u8 padOrEnd; + u8 txLen; + u8 rxLen; //includes errno + u8 command; u16 button; s8 rawStickX; s8 rawStickY; @@ -14,14 +14,14 @@ typedef struct typedef struct { - u8 unk00; //unknown, set to 255 a lot - u8 unk01; - u8 unk02; //probably status - u8 unk03; //maybe errno - u8 unk04; - u8 unk05; - u8 unk06; - u8 unk07; + u8 padOrEnd; + u8 txLen; + u8 rxLen; + u8 command; + u8 data1; + u8 data2; + u8 data3; + u8 data4; } OSContPackedRequest; typedef union { @@ -32,14 +32,14 @@ typedef union { #ifdef AVOID_UB // Fix the OSContPackedStruct array -extern OSContPackedStruct D_80365CE0[8]; +extern OSContPackedStruct _osContCmdBuf[8]; // And fix the last element -#define D_80365D1C D_80365CE0[7].as_raw[1] +#define _osContPifCtrl _osContCmdBuf[7].as_raw[1] #else // Original OSContPackedStruct definitions -extern OSContPackedStruct D_80365CE0[7]; -extern u32 D_80365D1C; +extern OSContPackedStruct _osContCmdBuf[7]; +extern u32 _osContPifCtrl; #endif #endif diff --git a/lib/src/osContStartReadData.c b/lib/src/osContStartReadData.c index 3f3c43e9..4362223a 100644 --- a/lib/src/osContStartReadData.c +++ b/lib/src/osContStartReadData.c @@ -3,71 +3,71 @@ #include #ifndef AVOID_UB -OSContPackedStruct D_80365CE0[7]; +ALIGNED8 OSContPackedStruct _osContCmdBuf[7]; UNUSED static u32 unused; // padding between these two variables -u32 D_80365D1C; +u32 _osContPifCtrl; #else // Reordered gcc vars above will disturb the aliasing done to access all 8 members of this array, hence AVOID_UB. -OSContPackedStruct D_80365CE0[8]; +ALIGNED8 OSContPackedStruct _osContCmdBuf[8]; #endif -extern u8 D_80365D20; -extern u8 _osCont_numControllers; +extern u8 _osLastSentSiCmd; +extern u8 _osContNumControllers; void __osPackReadData(void); s32 osContStartReadData(OSMesgQueue *mesg) { s32 ret = 0; s32 i; __osSiGetAccess(); - if (D_80365D20 != 1) { + if (_osLastSentSiCmd != 1) { __osPackReadData(); - ret = __osSiRawStartDma(1, D_80365CE0); + ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf); osRecvMesg(mesg, NULL, OS_MESG_BLOCK); } for (i = 0; i < 0x10; i++) { - *((u32 *) &D_80365CE0 + i) = 255; + *((u32 *) &_osContCmdBuf + i) = 255; } - D_80365D1C = 0; - ret = __osSiRawStartDma(0, &D_80365CE0); - D_80365D20 = 1; + _osContPifCtrl = 0; + ret = __osSiRawStartDma(OS_READ, _osContCmdBuf); + _osLastSentSiCmd = 1; __osSiRelAccess(); return ret; } void osContGetReadData(OSContPad *pad) { - OSContPackedRead *spc; - OSContPackedRead sp4; + OSContPackedRead *cmdBufPtr; + OSContPackedRead response; s32 i; - spc = &D_80365CE0[0].read; - for (i = 0; i < _osCont_numControllers; i++, spc++, pad++) { - sp4 = *spc; - pad->errnum = (sp4.unk02 & 0xc0) >> 4; + cmdBufPtr = &_osContCmdBuf[0].read; + for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, pad++) { + response = *cmdBufPtr; + pad->errnum = (response.rxLen & 0xc0) >> 4; if (pad->errnum == 0) { - pad->button = sp4.button; - pad->stick_x = sp4.rawStickX; - pad->stick_y = sp4.rawStickY; + pad->button = response.button; + pad->stick_x = response.rawStickX; + pad->stick_y = response.rawStickY; } }; } void __osPackReadData() { - OSContPackedRead *spc; - OSContPackedRead sp4; + OSContPackedRead *cmdBufPtr; + OSContPackedRead request; s32 i; - spc = &D_80365CE0[0].read; + cmdBufPtr = &_osContCmdBuf[0].read; for (i = 0; i < 0x10; i++) { - *((u32 *) &D_80365CE0 + i) = 0; + *((u32 *) &_osContCmdBuf + i) = 0; } - D_80365D1C = 1; - sp4.unk00 = 255; - sp4.unk01 = 1; - sp4.unk02 = 4; - sp4.unk03 = 1; - sp4.button = 65535; - sp4.rawStickX = -1; - sp4.rawStickY = -1; - for (i = 0; i < _osCont_numControllers; i++) { - *spc++ = sp4; + _osContPifCtrl = 1; + request.padOrEnd = 255; + request.txLen = 1; + request.rxLen = 4; + request.command = 1; + request.button = 65535; + request.rawStickX = -1; + request.rawStickY = -1; + for (i = 0; i < _osContNumControllers; i++) { + *cmdBufPtr++ = request; } - spc->unk00 = 254; + cmdBufPtr->padOrEnd = 254; } diff --git a/lib/src/osEepromLongRead.c b/lib/src/osEepromLongRead.c index 2a0b956b..d6c7ed37 100644 --- a/lib/src/osEepromLongRead.c +++ b/lib/src/osEepromLongRead.c @@ -2,7 +2,7 @@ extern u64 osClockRate; extern u8 D_80365D20; -extern u8 _osCont_numControllers; +extern u8 _osContNumControllers; extern OSTimer D_80365D28; // not sure what this is yet extern OSMesgQueue _osContMesgQueue; extern OSMesg _osContMesgBuff[4]; diff --git a/lib/src/osEepromLongWrite.c b/lib/src/osEepromLongWrite.c index 78c094f0..92d52442 100644 --- a/lib/src/osEepromLongWrite.c +++ b/lib/src/osEepromLongWrite.c @@ -2,7 +2,7 @@ extern u64 osClockRate; extern u8 D_80365D20; -extern u8 _osCont_numControllers; +extern u8 _osContNumControllers; extern OSTimer D_80365D28; extern OSMesgQueue _osContMesgQueue; extern OSMesg _osContMesgBuff[4]; diff --git a/lib/src/osEepromRead.c b/lib/src/osEepromRead.c index 9c4aa641..ea784b2c 100644 --- a/lib/src/osEepromRead.c +++ b/lib/src/osEepromRead.c @@ -1,6 +1,6 @@ #include "libultra_internal.h" -extern u8 D_80365D20; +extern u8 _osLastSentSiCmd; typedef struct { u16 unk00; @@ -58,7 +58,7 @@ s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) { } D_80365E3C = 0; sp34 = __osSiRawStartDma(OS_READ, D_80365E00); - D_80365D20 = 4; + _osLastSentSiCmd = 4; osRecvMesg(mq, NULL, OS_MESG_BLOCK); for (sp30 = 0; sp30 < 4; sp30++) { sp2c++; diff --git a/lib/src/osEepromWrite.c b/lib/src/osEepromWrite.c index ab7d544a..1a86477b 100644 --- a/lib/src/osEepromWrite.c +++ b/lib/src/osEepromWrite.c @@ -2,14 +2,14 @@ #include "osContInternal.h" #ifndef AVOID_UB -u32 D_80365E00[15]; +ALIGNED8 u32 D_80365E00[15]; u32 D_80365E3C; #else // Certain code accesses the 16th element (D_80365E3C) in this array, making a seperate // definition UB when gcc rearranges those. -u32 D_80365E00[16]; +ALIGNED8 u32 D_80365E00[16]; #endif -extern u8 D_80365D20; +extern u8 _osLastSentSiCmd; typedef struct { u16 unk00; @@ -73,7 +73,7 @@ s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) { D_80365E3C = 0; sp34 = __osSiRawStartDma(OS_READ, D_80365E00); - D_80365D20 = 5; + _osLastSentSiCmd = 5; osRecvMesg(mq, NULL, OS_MESG_BLOCK); for (sp30 = 0; sp30 < 4; sp30++) { @@ -142,7 +142,7 @@ s32 __osEepStatus(OSMesgQueue *a0, unkStruct *a1) { sp2c = __osSiRawStartDma(OS_WRITE, D_80365E00); osRecvMesg(a0, NULL, OS_MESG_BLOCK); - D_80365D20 = 5; + _osLastSentSiCmd = 5; sp2c = __osSiRawStartDma(OS_READ, D_80365E00); osRecvMesg(a0, NULL, OS_MESG_BLOCK); diff --git a/lib/src/osLeoDiskInit.c b/lib/src/osLeoDiskInit.c index ee8e8688..8e21d6fd 100644 --- a/lib/src/osLeoDiskInit.c +++ b/lib/src/osLeoDiskInit.c @@ -1,5 +1,6 @@ #include "libultra_internal.h" #include "hardware.h" + // this file must include some globally referenced data because it is not called anywhere // data, comes shortly before _Ldtob I think, before crash_screen @@ -7,8 +8,9 @@ extern OSPiHandle *D_80302DFC; // bss OSPiHandle LeoDiskHandle; OSPiHandle *__osDiskHandle; + // some kind of piHandle init function, maybe osDriveRomInit or osCartRomInit -OSPiHandle *osLeoDiskInit() { +OSPiHandle *osLeoDiskInit(void) { s32 sp1c; LeoDiskHandle.type = 2; LeoDiskHandle.baseAddress = (0xa0000000 | 0x05000000); diff --git a/lib/src/osTimer.c b/lib/src/osTimer.c index cd770c63..e6410310 100644 --- a/lib/src/osTimer.c +++ b/lib/src/osTimer.c @@ -8,7 +8,8 @@ OSTime _osCurrentTime; u32 D_80365DA8; u32 __osViIntrCount; u32 D_80365DB0; -void __osTimerServicesInit() { + +void __osTimerServicesInit(void) { _osCurrentTime = 0; D_80365DA8 = 0; __osViIntrCount = 0; @@ -20,7 +21,7 @@ void __osTimerServicesInit() { D_80334830->msg = NULL; } -void __osTimerInterrupt() { +void __osTimerInterrupt(void) { OSTimer *sp24; u32 sp20; u32 sp1c; diff --git a/lib/src/sqrtf.c b/lib/src/sqrtf.c deleted file mode 100644 index 05767880..00000000 --- a/lib/src/sqrtf.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -#ifndef __GNUC__ -#pragma intrinsic(sqrtf) -#define __builtin_sqrtf sqrtf -#endif - -float sqrtf(float f) { - return __builtin_sqrtf(f); -} diff --git a/sm64.ld b/sm64.ld index 85069852..e6f5c942 100755 --- a/sm64.ld +++ b/sm64.ld @@ -82,9 +82,11 @@ SECTIONS /* lib/src/__osDevMgrMain.c and lib/src/osCreateViManager.c contain infinite * loops compiled without -g, which cause the return statements and the .o - * files themselves to be aligned to 32-byte boundaries. But in the binary, - * they are actually aligned only to 16 bytes! We force this to happen using - * a SUBALIGN directive. */ + * files themselves to be aligned to 32-byte boundaries. But the linker + * Nintendo used did not respect .o file alignment, and aligned the files + * only to 16 bytes, in some cases misaligning them. We force the same to + * happen using the SUBALIGN directive. This is harmless; the alignment is + * just an optimization. */ BEGIN_SEG(main, SEG_MAIN) SUBALIGN(16) { BUILD_DIR/asm/entry.o(.text); @@ -150,6 +152,7 @@ SECTIONS BUILD_DIR/src/audio/seqplayer.o(.text); BUILD_DIR/src/audio/external.o(.text); BUILD_DIR/src/audio/port_eu.o(.text); + #if defined(VERSION_EU) || defined(VERSION_SH) BUILD_DIR/libultra.a:string.o(.text); BUILD_DIR/libultra.a:_Printf.o(.text); @@ -258,9 +261,7 @@ SECTIONS BUILD_DIR/libultra.a:func_802F7140.o(.text) BUILD_DIR/libultra.a:func_802F71A0.o(.text) BUILD_DIR/libultra.a:func_802F71F0.o(.text) - BUILD_DIR/lib/rsp.o(.text); - #else BUILD_DIR/src/game*.o(.text); BUILD_DIR/src/audio*.o(.text); @@ -310,9 +311,7 @@ SECTIONS BUILD_DIR/libultra.a:guTranslateF.o(.text); BUILD_DIR/libultra.a:guRotateF.o(.text); BUILD_DIR/libultra.a:guScaleF.o(.text); -#ifndef VERSION_EU BUILD_DIR/libultra.a:osAiSetFrequency.o(.text); -#endif BUILD_DIR/libultra.a:alBnkfNew.o(.text); BUILD_DIR/libultra.a:osWritebackDCache.o(.text); BUILD_DIR/libultra.a:osAiGetLength.o(.text); @@ -418,7 +417,7 @@ SECTIONS BUILD_DIR/src/game/obj_behaviors.o(.data*); BUILD_DIR/src/game/obj_behaviors_2.o(.data*); #ifndef VERSION_EU - /* wildcard doesn't work on EU due to files being moved to engine/ */ + /* wildcard doesn't match on EU due to files being moved to engine/ */ BUILD_DIR/src/game*.o(.data*); #endif BUILD_DIR/src/audio/external.o(.data*); @@ -427,7 +426,6 @@ SECTIONS BUILD_DIR/src/audio*.o(.data*); #ifdef VERSION_EU - BUILD_DIR/libultra.a:_Printf.o(.data*); BUILD_DIR/libultra.a:osInitialize.o(.data*); BUILD_DIR/libultra.a:osCreateViManager.o(.data*); @@ -435,21 +433,15 @@ SECTIONS BUILD_DIR/libultra.a:osCreatePiManager.o(.data*); BUILD_DIR/libultra.a:osContInit.o(.data*); BUILD_DIR/libultra.a:osAiSetNextBuffer.o(.data*); - BUILD_DIR/libultra.a:_Litob.o(.data*); - BUILD_DIR/libultra.a:__osExceptionPreamble.o(.data*); - BUILD_DIR/libultra.a:osTimer.o(.data*); BUILD_DIR/libultra.a:__osViInit.o(.data*); - BUILD_DIR/libultra.a:__osDequeueThread.o(.data*); // ffff... - + BUILD_DIR/libultra.a:__osDequeueThread.o(.data*); BUILD_DIR/libultra.a:__osPiCreateAccessQueue.o(.data*); BUILD_DIR/libultra.a:__osSiCreateAccessQueue.o(.data*); BUILD_DIR/libultra.a:osViData.o(.data*); - #else - BUILD_DIR/libultra.a:osViTable.o(.data*); BUILD_DIR/libultra.a:osCreateViManager.o(.data*); BUILD_DIR/libultra.a:osCreatePiManager.o(.data*); @@ -470,10 +462,8 @@ SECTIONS BUILD_DIR/libultra.a:__osSyncPutChars.o(.data*); BUILD_DIR/libultra.a:guRotateF.o(.data*); BUILD_DIR/libultra.a:*.o(.data*); - #endif - /* rodata */ BUILD_DIR/src/game/crash_screen.o(.rodata*); BUILD_DIR/src/game/main.o(.rodata*); @@ -534,6 +524,7 @@ SECTIONS #ifdef VERSION_EU BUILD_DIR/libultra.a:_Printf.o(.rodata*); +#endif BUILD_DIR/libultra.a:guPerspectiveF.o(.rodata*); BUILD_DIR/libultra.a:llconv.o(.rodata*); @@ -541,25 +532,20 @@ SECTIONS BUILD_DIR/libultra.a:sinf.o(.rodata*); BUILD_DIR/libultra.a:guRotateF.o(.rodata*); +#ifdef VERSION_EU BUILD_DIR/libultra.a:_Litob.o(.rodata*); BUILD_DIR/libultra.a:_Ldtob.o(.rodata*); - BUILD_DIR/libultra.a:__osExceptionPreamble.o(.rodata*); BUILD_DIR/libultra.a:__osDevMgrMain.o(.rodata*); - BUILD_DIR/libultra.a:NaN.o(.rodata*); #else - BUILD_DIR/libultra.a:guPerspectiveF.o(.rodata*); - BUILD_DIR/libultra.a:llconv.o(.rodata*); - BUILD_DIR/libultra.a:cosf.o(.rodata*); - BUILD_DIR/libultra.a:sinf.o(.rodata*); - BUILD_DIR/libultra.a:guRotateF.o(.rodata*); BUILD_DIR/libultra.a:_Printf.o(.rodata*); BUILD_DIR/libultra.a:__osExceptionPreamble.o(.rodata*); BUILD_DIR/libultra.a:NaN.o(.rodata*); BUILD_DIR/libultra.a:_Litob.o(.rodata*); BUILD_DIR/libultra.a:_Ldtob.o(.rodata*); #endif + BUILD_DIR/libultra.a:osSetIntMask.o(.rodata*); BUILD_DIR/libultra.a:guLookAtRef.o(.rodata*); /* Fast3DEX2 only */ #ifndef VERSION_EU @@ -611,33 +597,26 @@ SECTIONS #endif BUILD_DIR/src/audio/external.o(.bss*); BUILD_DIR/src/audio/port_eu.o(.bss*); - + #ifdef VERSION_EU BUILD_DIR/libultra.a:osInitialize.o(.bss*); - BUILD_DIR/libultra.a:osSetEventMesg.o(.bss*); BUILD_DIR/libultra.a:osSpTaskLoadGo.o(.bss*); BUILD_DIR/libultra.a:osCreateViManager.o(.bss*); - BUILD_DIR/libultra.a:osCreatePiManager.o(.bss*); BUILD_DIR/libultra.a:osContStartReadData.o(.bss*); BUILD_DIR/libultra.a:osContInit.o(.bss*); - BUILD_DIR/libultra.a:guRotateF.o(.bss*); - BUILD_DIR/libultra.a:unk_stack_data.o(.bss*); BUILD_DIR/libultra.a:osTimer.o(.bss*); BUILD_DIR/libultra.a:__osPiCreateAccessQueue.o(.bss*); BUILD_DIR/libultra.a:__osSiCreateAccessQueue.o(.bss*); BUILD_DIR/libultra.a:osEepromWrite.o(.bss*); - BUILD_DIR/libultra.a:kdebugserver.o(.bss*); BUILD_DIR/libultra.a:osLeoDiskInit.o(.bss*) - BUILD_DIR/libultra.a:_Printf.o(.bss*); BUILD_DIR/libultra.a:osAiSetNextBuffer.o(.bss*); BUILD_DIR/libultra.a:EU_D_802f4330.o(.bss*); - #else BUILD_DIR/libultra.a:osSetEventMesg.o(.bss*); BUILD_DIR/libultra.a:osSpTaskLoadGo.o(.bss*); @@ -724,7 +703,7 @@ SECTIONS } END_NOLOAD(engine) - // ASSERT((. <= SEG_FRAMEBUFFERS), "Error: engine segment extended into framebuffers.") + ASSERT((. <= SEG_FRAMEBUFFERS), "Error: engine segment extended into framebuffers.") . = SEG_FRAMEBUFFERS; BEGIN_NOLOAD(framebuffers) @@ -876,30 +855,22 @@ SECTIONS { BUILD_DIR/src/buffers/buffers.o(.bss*); BUILD_DIR/src/audio/globals_start.o(.bss*); - BUILD_DIR/src/audio/synthesis.o(.bss*); BUILD_DIR/src/audio/heap.o(.bss*); BUILD_DIR/src/audio/load.o(.bss*); BUILD_DIR/src/audio/data.o(.bss*); - BUILD_DIR/src/audio/globals_end.o(.bss*); + BUILD_DIR/src/audio*.o(.bss*); + #ifdef VERSION_EU - . += 0x4f0; -#endif - -#ifndef VERSION_EU + . = ALIGN(0x200); +#else . = ALIGN(0x1000); #endif BUILD_DIR/src/buffers/gfx_output_buffer.o(.bss*); - - BUILD_DIR/src/audio*.o(.bss*); } END_NOLOAD(buffers) - /* While EU is being worked on, don't warn for a too large buffers segment. - * This is a broken thing to do, so please enforce this again when it's fixed! */ -#ifndef VERSION_EU - ASSERT((. <= SEG_MAIN), "Error: buffers segment extended into main.") -#endif + ASSERT((. <= SEG_MAIN), "Error: buffers segment extended into main") /* 0x268020 0x268020-0 [0] */ BEGIN_SEG(intro, 0x14000000) @@ -1002,14 +973,7 @@ SECTIONS BUILD_DIR/assets/mario_anim_data.o(.data); BUILD_DIR/assets/mario_anim_data.o(.rodata); BUILD_DIR/assets/demo_data.o(.data); - gSoundDataADSR = .; - BUILD_DIR/sound/sound_data.ctl.o(.data); - gSoundDataRaw = .; - BUILD_DIR/sound/sound_data.tbl.o(.data); - gMusicData = .; - BUILD_DIR/sound/sequences.bin.o(.data); - gBankSetsData = .; - BUILD_DIR/sound/bank_sets.o(.data); + BUILD_DIR/sound/sound_data.o(.data); } END_SEG(assets) diff --git a/sound/sound_data.c b/sound/sound_data.c new file mode 100644 index 00000000..598cc1e3 --- /dev/null +++ b/sound/sound_data.c @@ -0,0 +1,15 @@ +unsigned char gSoundDataADSR[] = { +#include "sound/sound_data.ctl.inc.c" +}; + +unsigned char gSoundDataRaw[] = { +#include "sound/sound_data.tbl.inc.c" +}; + +unsigned char gMusicData[] = { +#include "sound/sequences.bin.inc.c" +}; + +unsigned char gBankSetsData[] = { +#include "sound/bank_sets.inc.c" +}; diff --git a/src/audio/data.c b/src/audio/data.c index 711ee847..47b02c4d 100644 --- a/src/audio/data.c +++ b/src/audio/data.c @@ -1,5 +1,4 @@ #include -#include #include "data.h" #include "effects.h" @@ -587,11 +586,12 @@ s8 gUnusedCount80333EE8 = UNUSED_COUNT_80333EE8; s32 gAudioHeapSize = DOUBLE_SIZE_ON_64_BIT(AUDIO_HEAP_SIZE); s32 D_80333EF0 = DOUBLE_SIZE_ON_64_BIT(D_80333EF0_VAL); volatile s32 gAudioLoadLock = AUDIO_LOCK_UNINITIALIZED; + #ifdef VERSION_EU u8 bufferDelete2[12] = { 0 }; u8 D_EU_80302010 = 0; u8 D_EU_80302014 = 0; -struct OSMesgQueue *OSMesgQueues[4] = { &OSMesgQueue0, &OSMesgQueue1, &OSMesgQueue2, &OSMesgQueue3 }; // { 0x80332e40, 0x80332e58, 0x80332e70, 0x80332e88 }; +struct OSMesgQueue *OSMesgQueues[4] = { &OSMesgQueue0, &OSMesgQueue1, &OSMesgQueue2, &OSMesgQueue3 }; #else s8 sUnused8033EF8 = 24; #endif @@ -620,18 +620,18 @@ f32 D_EU_802298D0; s32 gRefreshRate; #endif -u16 *gAiBuffers[NUMAIBUFFERS]; +s16 *gAiBuffers[NUMAIBUFFERS]; s16 gAiBufferLengths[NUMAIBUFFERS]; -#ifdef VERSION_EU -u32 gAudioRandom; -s32 gAudioErrorFlags; -u64 gAudioGlobalsEndMarker; -#endif - #ifndef VERSION_EU u32 gUnused80226E58[0x10]; u16 gUnused80226E98[0x10]; +#endif u32 gAudioRandom; + +#ifdef VERSION_EU +s32 gAudioErrorFlags; #endif + +u64 gAudioGlobalsEndMarker; diff --git a/src/audio/data.h b/src/audio/data.h index 62a3392d..d2a8b4db 100644 --- a/src/audio/data.h +++ b/src/audio/data.h @@ -1,7 +1,10 @@ #ifndef AUDIO_DATA_H #define AUDIO_DATA_H +#include + #include "internal.h" +#include "types.h" #define AUDIO_LOCK_UNINITIALIZED 0 #define AUDIO_LOCK_NOT_LOADING 0x76557364 @@ -87,7 +90,7 @@ extern f32 D_EU_802298D0; extern s32 gRefreshRate; #endif -extern u16 *gAiBuffers[NUMAIBUFFERS]; +extern s16 *gAiBuffers[NUMAIBUFFERS]; extern s16 gAiBufferLengths[NUMAIBUFFERS]; #ifdef VERSION_EU #define AIBUFFER_LEN (0xa0 * 17) @@ -112,4 +115,4 @@ extern u32 gAudioRandom; #endif -#endif /* AUDIO_DATA_H */ +#endif // AUDIO_DATA_H diff --git a/src/audio/effects.c b/src/audio/effects.c index fd78f7af..bf8c343a 100644 --- a/src/audio/effects.c +++ b/src/audio/effects.c @@ -1,5 +1,4 @@ #include -#include #include "effects.h" #include "load.h" diff --git a/src/audio/effects.h b/src/audio/effects.h index 425eff57..b858dbbd 100644 --- a/src/audio/effects.h +++ b/src/audio/effects.h @@ -1,6 +1,8 @@ #ifndef AUDIO_EFFECTS_H #define AUDIO_EFFECTS_H +#include + #include "internal.h" #include "platform_info.h" #include "macros.h" @@ -39,4 +41,4 @@ f32 adsr_update(struct AdsrState *adsr); s32 adsr_update(struct AdsrState *adsr); #endif -#endif /* AUDIO_EFFECTS_H */ +#endif // AUDIO_EFFECTS_H diff --git a/src/audio/external.c b/src/audio/external.c index ff8614e7..9c46f2e3 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -7,15 +7,12 @@ #include "external.h" #include "playback.h" #include "synthesis.h" -#include "game/mario.h" #include "game/level_update.h" -#include "game/area.h" #include "game/object_list_processor.h" #include "game/camera.h" #include "seq_ids.h" #include "dialog_ids.h" #include "level_table.h" -#include "pc/configfile.h" #ifdef VERSION_EU #define EU_FLOAT(x) x ## f @@ -491,7 +488,7 @@ u8 sUnused8033323C = 0; // never read, set to 0 // bss #ifndef VERSION_EU -u16 *gCurrAiBuffer; +s16 *gCurrAiBuffer; #endif struct Sound sSoundRequests[0x100]; // Curiously, this has size 3, despite SEQUENCE_PLAYERS == 4 on EU @@ -937,7 +934,7 @@ void func_8031E16C(u8 bankIndex) { val = (gSoundBanks[bankIndex][soundIndex].soundBits & SOUNDARGS_MASK_PRIORITY) >> SOUNDARGS_SHIFT_PRIORITY; - if (gSoundBanks[bankIndex][soundIndex].soundBits & SOUND_PL_BITFLAG_UNK4) { + if (gSoundBanks[bankIndex][soundIndex].soundBits & SOUND_NO_PRIORITY_LOSS) { gSoundBanks[bankIndex][soundIndex].priority = 0x4c * (0xff - val); } else if (*gSoundBanks[bankIndex][soundIndex].z > 0.0f) { gSoundBanks[bankIndex][soundIndex].priority = @@ -1081,7 +1078,7 @@ f32 get_sound_dynamics(u8 bankIndex, u8 item, f32 arg2) { s32 div = bankIndex < 3 ? 2 : 3; #endif - if (!(gSoundBanks[bankIndex][item].soundBits & SOUND_PL_BITFLAG_UNK1)) { + if (!(gSoundBanks[bankIndex][item].soundBits & SOUND_NO_VOLUME_LOSS)) { #ifdef VERSION_JP f0 = D_80332028[gCurrLevelNum]; if (f0 < gSoundBanks[bankIndex][item].distance) { @@ -1104,7 +1101,7 @@ f32 get_sound_dynamics(u8 bankIndex, u8 item, f32 arg2) { } #endif - if (gSoundBanks[bankIndex][item].soundBits & SOUND_PL_BITFLAG_UNK2) { + if (gSoundBanks[bankIndex][item].soundBits & SOUND_VIBRATO) { #ifdef VERSION_JP if (intensity != 0.0) #else @@ -1124,9 +1121,9 @@ f32 get_sound_dynamics(u8 bankIndex, u8 item, f32 arg2) { f32 get_sound_freq_scale(u8 bankIndex, u8 item) { f32 f2; - if (!(gSoundBanks[bankIndex][item].soundBits & SOUND_PL_BITFLAG_UNK8)) { + if (!(gSoundBanks[bankIndex][item].soundBits & SOUND_NO_FREQUENCY_LOSS)) { f2 = gSoundBanks[bankIndex][item].distance / AUDIO_MAX_DISTANCE; - if (gSoundBanks[bankIndex][item].soundBits & SOUND_PL_BITFLAG_UNK2) { + if (gSoundBanks[bankIndex][item].soundBits & SOUND_VIBRATO) { f2 += (f32)(gAudioRandom & 0xff) / US_FLOAT(64.0); } } else { @@ -1226,7 +1223,7 @@ void update_game_sound(void) { switch (bankIndex) { case 1: - if (!(gSoundBanks[bankIndex][index].soundBits & SOUND_PL_BITFLAG_UNK8)) { + if (!(gSoundBanks[bankIndex][index].soundBits & SOUND_NO_FREQUENCY_LOSS)) { if (D_80363808[bankIndex] > 8) { #ifdef VERSION_EU func_802ad728(0x02020000 | ((channelIndex & 0xff) << 8), @@ -1383,7 +1380,7 @@ void update_game_sound(void) { // computes function arguments in the wrong order). switch (bankIndex) { case 1: - if (!(gSoundBanks[bankIndex][index].soundBits & SOUND_PL_BITFLAG_UNK8)) { + if (!(gSoundBanks[bankIndex][index].soundBits & SOUND_NO_FREQUENCY_LOSS)) { if (D_80363808[bankIndex] > 8) { #ifdef VERSION_EU func_802ad728(0x02020000 | ((channelIndex & 0xff) << 8), diff --git a/src/audio/external.h b/src/audio/external.h index f2ab3ad0..cdbd28b6 100644 --- a/src/audio/external.h +++ b/src/audio/external.h @@ -1,6 +1,8 @@ #ifndef AUDIO_EXTERNAL_H #define AUDIO_EXTERNAL_H +#include + #include "types.h" // Sequence arguments, passed to play_sequence. seqId may be bit-OR'ed with @@ -53,13 +55,13 @@ void play_star_fanfare(void); void play_power_star_jingle(u8 arg0); void play_race_fanfare(void); void play_toads_jingle(void); -void sound_reset(u8 arg0); +void sound_reset(u8 presetId); void audio_set_sound_mode(u8 arg0); void audio_init(void); // in load.c #ifdef VERSION_EU -struct SPTask *unused_80321460(); +struct SPTask *unused_80321460(void); #endif -#endif /* AUDIO_EXTERNAL_H */ +#endif // AUDIO_EXTERNAL_H diff --git a/src/audio/globals_end.c b/src/audio/globals_end.c deleted file mode 100644 index 7f5b0899..00000000 --- a/src/audio/globals_end.c +++ /dev/null @@ -1,5 +0,0 @@ -#include - -#ifndef VERSION_EU -u64 gAudioGlobalsEndMarker; -#endif diff --git a/src/audio/heap.c b/src/audio/heap.c index d1d69417..8c321054 100644 --- a/src/audio/heap.c +++ b/src/audio/heap.c @@ -1,5 +1,4 @@ #include -#include #include "heap.h" #include "data.h" @@ -303,7 +302,7 @@ void temporary_pools_init(struct PoolSplit *a) { } #ifndef VERSION_EU -static void unused_803163D4() { +static void unused_803163D4(void) { } #endif diff --git a/src/audio/heap.h b/src/audio/heap.h index 5226baa8..7f99b9a7 100644 --- a/src/audio/heap.h +++ b/src/audio/heap.h @@ -1,6 +1,8 @@ #ifndef AUDIO_HEAP_H #define AUDIO_HEAP_H +#include + #include "internal.h" #define SOUND_LOAD_STATUS_NOT_LOADED 0 @@ -69,4 +71,4 @@ void audio_reset_session(void); void audio_reset_session(struct AudioSessionSettings *preset); #endif -#endif /* AUDIO_HEAP_H */ +#endif // AUDIO_HEAP_H diff --git a/src/audio/internal.h b/src/audio/internal.h index bd9f1a2d..89dcc791 100644 --- a/src/audio/internal.h +++ b/src/audio/internal.h @@ -113,7 +113,7 @@ struct VibratoState { // Pitch sliding by up to one octave in the positive direction. Negative // direction is "supported" by setting extent to be negative. The code -// exterpolates exponentially in the wrong direction in that case, but that +// extrapolates exponentially in the wrong direction in that case, but that // doesn't prevent seqplayer from doing it, AFAICT. struct Portamento { u8 mode; // bit 0x80 denotes something; the rest are an index 0-5 @@ -687,4 +687,4 @@ struct EuAudioCmd { } u2; }; -#endif /* AUDIO_INTERNAL_H */ +#endif // AUDIO_INTERNAL_H diff --git a/src/audio/load.c b/src/audio/load.c index e85fcdf5..775ed14d 100644 --- a/src/audio/load.c +++ b/src/audio/load.c @@ -1,13 +1,13 @@ #include -#include -#include "load.h" -#include "heap.h" #include "data.h" +#include "external.h" +#include "heap.h" +#include "load.h" #include "seqplayer.h" -#include "../pc/platform.h" -#include "../pc/fs/fs.h" +#include "pc/platform.h" +#include "pc/fs/fs.h" #define ALIGN16(val) (((val) + 0xF) & ~0xF) @@ -886,6 +886,7 @@ static inline void *load_sound_res(const char *path) { # define LOAD_DATA(x) x #endif +// (void) must be omitted from parameters void audio_init() { #ifdef VERSION_EU UNUSED s8 pad[16]; @@ -920,26 +921,11 @@ void audio_init() { ((u64 *) gAudioHeap)[i] = 0; } -#ifndef AVOID_UB - i = 0; - lim3 = ((uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker) / 8; - ptr64 = &gAudioGlobalsStartMarker - 1; - for (k = lim3; k >= 0; k--) { - i++; - ptr64[i] = 0; - } -#endif #else for (i = 0; i < gAudioHeapSize / 8; i++) { ((u64 *) gAudioHeap)[i] = 0; } - lim3 = ((uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker) / 8; - ptr64 = &gAudioGlobalsStartMarker; - for (k = lim3; k >= 0; k--) { - *ptr64++ = 0; - } - D_EU_802298D0 = 20.03042f; gRefreshRate = 50; port_eu_init(); @@ -1027,3 +1013,4 @@ void audio_init() { init_sequence_players(); gAudioLoadLock = AUDIO_LOCK_NOT_LOADING; } + diff --git a/src/audio/load.h b/src/audio/load.h index 5632f52b..d1162077 100644 --- a/src/audio/load.h +++ b/src/audio/load.h @@ -1,6 +1,8 @@ #ifndef AUDIO_LOAD_H #define AUDIO_LOAD_H +#include + #include "internal.h" #define AUDIO_FRAME_DMA_QUEUE_SIZE 0x40 @@ -54,4 +56,4 @@ void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32 void preload_sequence(u32 seqId, u8 preloadMask); void load_sequence(u32 player, u32 seqId, s32 loadAsync); -#endif /* AUDIO_LOAD_H */ +#endif // AUDIO_LOAD_H diff --git a/src/audio/playback.c b/src/audio/playback.c index 376f1817..b34089db 100644 --- a/src/audio/playback.c +++ b/src/audio/playback.c @@ -1,5 +1,4 @@ #include -#include #include "heap.h" #include "data.h" @@ -152,9 +151,6 @@ struct Drum *get_drum(s32 bankId, s32 drumId) { gAudioErrorFlags = ((bankId << 8) + drumId) + 0x4000000; return 0; } - if ((uintptr_t) gCtlEntries[bankId].drums < 0x80000000U) { - return 0; - } drum = gCtlEntries[bankId].drums[drumId]; if (drum == NULL) { gAudioErrorFlags = ((bankId << 8) + drumId) + 0x5000000; @@ -248,9 +244,6 @@ void process_notes(void) { #ifdef VERSION_EU playbackState = (struct NotePlaybackState *) ¬e->priority; if (note->parentLayer != NO_LAYER) { - if ((uintptr_t) playbackState->parentLayer < 0x7fffffffU) { - continue; - } if (!playbackState->parentLayer->enabled && playbackState->priority >= NOTE_PRIORITY_MIN) { goto c; } else if (playbackState->parentLayer->seqChannel->seqPlayer == NULL) { @@ -765,8 +758,7 @@ struct Note *pop_node_with_value_less_equal(struct AudioListItem *list, s32 limi return NULL; } - best = cur; - for (; cur != list; cur = cur->next) { + for (best = cur; cur != list; cur = cur->next) { if (((struct Note *) best->u.value)->priority >= ((struct Note *) cur->u.value)->priority) { best = cur; } diff --git a/src/audio/playback.h b/src/audio/playback.h index b267fd09..9c73e6e3 100644 --- a/src/audio/playback.h +++ b/src/audio/playback.h @@ -1,5 +1,7 @@ -#ifndef _AUDIO_PLAYBACK_H -#define _AUDIO_PLAYBACK_H +#ifndef AUDIO_PLAYBACK_H +#define AUDIO_PLAYBACK_H + +#include #include "internal.h" @@ -40,4 +42,4 @@ void note_disable(struct Note *note); #endif -#endif /* _AUDIO_PLAYBACK_H */ +#endif // AUDIO_PLAYBACK_H diff --git a/src/audio/port_eu.c b/src/audio/port_eu.c index b0d0650e..85476cf7 100644 --- a/src/audio/port_eu.c +++ b/src/audio/port_eu.c @@ -34,6 +34,103 @@ void decrease_sample_dma_ttls(void); s32 audio_shut_down_and_reset_step(void); void func_802ad7ec(u32); +struct SPTask *create_next_audio_frame_task(void) { + u32 samplesRemainingInAI; + s32 writtenCmds; + s32 index; + OSTask_t *task; + s32 flags; + s16 *currAiBuffer; + s32 oldDmaCount; + OSMesg sp30; + OSMesg sp2C; + + gAudioFrameCount++; + if (gAudioFrameCount % gAudioBufferParameters.presetUnk4 != 0) { + stubbed_printf("DAC:Lost 1 Frame.\n"); + return NULL; + } + + osSendMesg(OSMesgQueues[0], (OSMesg) gAudioFrameCount, 0); + + gAudioTaskIndex ^= 1; + gCurrAiBufferIndex++; + gCurrAiBufferIndex %= NUMAIBUFFERS; + index = (gCurrAiBufferIndex - 2 + NUMAIBUFFERS) % NUMAIBUFFERS; + samplesRemainingInAI = osAiGetLength() / 4; + + if (gAiBufferLengths[index] != 0) { + osAiSetNextBuffer(gAiBuffers[index], gAiBufferLengths[index] * 4); + } + + oldDmaCount = gCurrAudioFrameDmaCount; + if (oldDmaCount > AUDIO_FRAME_DMA_QUEUE_SIZE) { + stubbed_printf("DMA: Request queue over.( %d )\n", oldDmaCount); + } + gCurrAudioFrameDmaCount = 0; + + decrease_sample_dma_ttls(); + if (osRecvMesg(OSMesgQueues[2], &sp30, 0) != -1) { + gAudioResetPresetIdToLoad = (u8) (s32) sp30; + gAudioResetStatus = 5; + } + + if (gAudioResetStatus != 0) { + if (audio_shut_down_and_reset_step() == 0) { + if (gAudioResetStatus == 0) { + osSendMesg(OSMesgQueues[3], (OSMesg) (s32) gAudioResetPresetIdToLoad, OS_MESG_NOBLOCK); + } + return NULL; + } + } + + gAudioTask = &gAudioTasks[gAudioTaskIndex]; + gAudioCmd = gAudioCmdBuffers[gAudioTaskIndex]; + index = gCurrAiBufferIndex; + currAiBuffer = gAiBuffers[index]; + + gAiBufferLengths[index] = ((gAudioBufferParameters.samplesPerFrameTarget - samplesRemainingInAI + + EXTRA_BUFFERED_AI_SAMPLES_TARGET) & ~0xf) + SAMPLES_TO_OVERPRODUCE; + if (gAiBufferLengths[index] < gAudioBufferParameters.minAiBufferLength) { + gAiBufferLengths[index] = gAudioBufferParameters.minAiBufferLength; + } + if (gAiBufferLengths[index] > gAudioBufferParameters.maxAiBufferLength) { + gAiBufferLengths[index] = gAudioBufferParameters.maxAiBufferLength; + } + + if (osRecvMesg(OSMesgQueues[1], &sp2C, OS_MESG_NOBLOCK) != -1) { + func_802ad7ec((u32) sp2C); + } + + flags = 0; + gAudioCmd = synthesis_execute(gAudioCmd, &writtenCmds, currAiBuffer, gAiBufferLengths[index]); + gAudioRandom = ((gAudioRandom + gAudioFrameCount) * gAudioFrameCount); + gAudioRandom = gAudioRandom + writtenCmds / 8; + + index = gAudioTaskIndex; + gAudioTask->msgqueue = NULL; + gAudioTask->msg = NULL; + + task = &gAudioTask->task.t; + task->type = M_AUDTASK; + task->flags = flags; + task->ucode_boot = rspF3DBootStart; + task->ucode_boot_size = (u8 *) rspF3DBootEnd - (u8 *) rspF3DBootStart; + task->ucode = rspAspMainStart; + task->ucode_data = rspAspMainDataStart; + task->ucode_size = 0x800; // (this size is ignored) + task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64); + task->dram_stack = NULL; + task->dram_stack_size = 0; + task->output_buff = NULL; + task->output_buff_size = NULL; + task->data_ptr = gAudioCmdBuffers[index]; + task->data_size = writtenCmds * sizeof(u64); + task->yield_data_ptr = NULL; + task->yield_data_size = 0; + return gAudioTask; +} + void eu_process_audio_cmd(struct EuAudioCmd *cmd) { s32 i; diff --git a/src/audio/seq_channel_layer_process_script.h b/src/audio/seq_channel_layer_process_script.h new file mode 100644 index 00000000..17f67335 --- /dev/null +++ b/src/audio/seq_channel_layer_process_script.h @@ -0,0 +1,527 @@ +//! Copt inlining for US/JP. Here be dragons + +#include +#include + +#include "heap.h" +#include "data.h" +#include "load.h" +#include "seqplayer.h" +#include "external.h" +#include "effects.h" + +#define PORTAMENTO_IS_SPECIAL(x) ((x).mode & 0x80) +#define PORTAMENTO_MODE(x) ((x).mode & ~0x80) +#define PORTAMENTO_MODE_1 1 +#define PORTAMENTO_MODE_2 2 +#define PORTAMENTO_MODE_3 3 +#define PORTAMENTO_MODE_4 4 +#define PORTAMENTO_MODE_5 5 + +#define COPT 0 +#if COPT +#define M64_READ_U8(state, dst) \ + dst = m64_read_u8(state); +#else +#define M64_READ_U8(state, dst) \ +{ \ + u8 * _ptr_pc; \ + u8 _pc; \ + _ptr_pc = (*state).pc; \ + ((*state).pc)++; \ + _pc = *_ptr_pc; \ + dst = _pc; \ +} +#endif + + +#if COPT +#define M64_READ_S16(state, dst) \ + dst = m64_read_s16(state); +#else +#define M64_READ_S16(state, dst) \ +{ \ + s16 _ret; \ + _ret = *(*state).pc << 8; \ + ((*state).pc)++; \ + _ret = *(*state).pc | _ret; \ + ((*state).pc)++; \ + dst = _ret; \ +} +#endif +#if COPT +#define M64_READ_COMPRESSED_U16(state, dst) \ + dst = m64_read_compressed_u16(state); +#else +#define M64_READ_COMPRESSED_U16(state, dst) \ +{ \ + u16 ret = *(state->pc++); \ + if (ret & 0x80) { \ + ret = (ret << 8) & 0x7f00; \ + ret = *(state->pc++) | ret; \ + } \ + dst = ret; \ +} +#endif + +#if COPT +#define GET_INSTRUMENT(seqChannel, instId, _instOut, _adsr, dst, l) \ + dst = get_instrument(seqChannel, instId, _instOut, _adsr); +#else +#define GET_INSTRUMENT(seqChannel, instId, _instOut, _adsr, dst, l) \ +{ \ +struct AdsrSettings *adsr = _adsr; \ +struct Instrument **instOut = _instOut;\ + u8 _instId = instId; \ + struct Instrument *inst; \ + UNUSED u32 pad; \ + /* copt inlines instId here */ \ + if (instId >= gCtlEntries[(*seqChannel).bankId].numInstruments) { \ + _instId = gCtlEntries[(*seqChannel).bankId].numInstruments; \ + if (_instId == 0) { \ + dst = 0; \ + goto ret ## l; \ + } \ + _instId--; \ + } \ + inst = gCtlEntries[(*seqChannel).bankId].instruments[_instId]; \ + if (inst == NULL) { \ + while (_instId != 0xff) { \ + inst = gCtlEntries[(*seqChannel).bankId].instruments[_instId]; \ + if (inst != NULL) { \ + goto gi ## l; \ + } \ + _instId--; \ + } \ + gi ## l:; \ + } \ + if (((uintptr_t) gBankLoadedPool.persistent.pool.start <= (uintptr_t) inst \ + && (uintptr_t) inst <= (uintptr_t)(gBankLoadedPool.persistent.pool.start \ + + gBankLoadedPool.persistent.pool.size)) \ + || ((uintptr_t) gBankLoadedPool.temporary.pool.start <= (uintptr_t) inst \ + && (uintptr_t) inst <= (uintptr_t)(gBankLoadedPool.temporary.pool.start \ + + gBankLoadedPool.temporary.pool.size))) { \ + (*adsr).envelope = (*inst).envelope; \ + (*adsr).releaseRate = (*inst).releaseRate; \ + *instOut = inst; \ + _instId++; \ + goto ret ## l; \ + } \ + gAudioErrorFlags = _instId + 0x20000; \ + *instOut = NULL; \ + ret ## l: ; \ +} +#endif + +#ifdef VERSION_EU + #define PORTAMENTO_TGT_NOTE cmd + #define DRUM_INDEX cmd + #define SEMITONE cmd + #define USED_SEMITONE vel +#else + #define PORTAMENTO_TGT_NOTE portamentoTargetNote + #define DRUM_INDEX cmdSemitone + #define SEMITONE cmdSemitone + #define USED_SEMITONE usedSemitone +#endif + +void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { + struct SequencePlayer *seqPlayer; // sp5C, t4 + struct SequenceChannel *seqChannel; // sp58, t5 + struct M64ScriptState *state; // v0 + struct Portamento *portamento; // v0 + struct AudioBankSound *sound; // v0 + struct Instrument *instrument; // v1 + struct Drum *drum; + UNUSED s32 pad[1]; + u8 sameSound; // sp3F + UNUSED u8 allocNewNote; // sp3D, t0 + u8 cmd; // a0 sp3E, EU s2 + UNUSED u8 loBits; + u16 sp3A; // t2, a0, a1 + UNUSED s32 pad2[1]; + s32 vel; // sp30, t3 + UNUSED s32 pad3[1]; + f32 freqScale; // sp28, f0 + f32 sp24; + u8 temp8; + UNUSED u8 semitone; // v0 + s32 usedSemitone; // a1 + f32 temp_f12; + f32 temp_f2; + s32 temp_a0_5; + UNUSED u8 drumIndex; // t0 + UNUSED s32 cmdBase; // t1 + u8 temp_a0_6; + u8 portamentoTargetNote; // t7 + UNUSED s32 bankId; // a3 + u8 instId; // v0 + u8 cmdSemitone; // v1 + f32 tuning; // f0 + + // inlined copt var that gets pulled out to the rest of the function + unsigned char _Kqi6; + +//! Copt: manually inline these functions in the scope of this routine +#ifdef __sgi +#pragma inline routine(m64_read_u8) +#pragma inline routine(m64_read_compressed_u16) +#pragma inline routine(m64_read_s16) +#pragma inline routine(get_instrument) +#endif + + sameSound = TRUE; + if (layer->enabled == FALSE) { + return; + } + + if (layer->delay > 1) { + layer->delay--; + if (!layer->stopSomething && layer->delay <= layer->duration) { + seq_channel_layer_note_decay(layer); + layer->stopSomething = TRUE; + } + return; + } + + if (!layer->continuousNotes) { + seq_channel_layer_note_decay(layer); + } + + if (PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_1 || + PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_2) { + layer->portamento.mode = 0; + } + + seqChannel = (*(layer)).seqChannel; + seqPlayer = (*(seqChannel)).seqPlayer; + for (;;) { + state = &layer->scriptState; + //M64_READ_U8(state, cmd); + // manually inlined because we need _Kqi6 :( + { + u8 *_ptr_pc; + _ptr_pc = (*state).pc; + ((*state).pc)++; + //cmd = *_ptr_pc; + + _Kqi6 = *_ptr_pc; + cmd = _Kqi6; + } + + if (cmd <= 0xc0) { + break; + } + + switch (_Kqi6) + { + case 0xff: // layer_end; function return or end of script + if (state->depth == 0) { + // N.B. this function call is *not* inlined even though it's + // within the same file, unlike in the rest of this function. + seq_channel_layer_disable(layer); + return; + } + state->depth--, state->pc = state->stack[state->depth]; + break; + + case 0xfc: // layer_call + M64_READ_S16(state, sp3A); + state->depth++, state->stack[state->depth - 1] = state->pc; + state->pc = seqPlayer->seqData + sp3A; + break; + + case 0xf8: // layer_loop; loop start, N iterations (or 256 if N = 0) + M64_READ_U8(state, state->remLoopIters[state->depth]) + state->depth++, state->stack[state->depth - 1] = state->pc; + break; + + case 0xf7: // layer_loopend + if (--state->remLoopIters[state->depth - 1] != 0) { + state->pc = state->stack[state->depth - 1]; + } else { + state->depth--; + } + break; + + case 0xfb: // layer_jump + M64_READ_S16(state, sp3A); + state->pc = seqPlayer->seqData + sp3A; + break; + + case 0xc1: // layer_setshortnotevelocity + case 0xca: // layer_setpan + temp_a0_5 = *(state->pc++); + if (cmd == 0xc1) { + layer->velocitySquare = (f32)(temp_a0_5 * temp_a0_5); + } else { + layer->pan = (f32) temp_a0_5 / US_FLOAT(128.0); + } + break; + + case 0xc2: // layer_transpose; set transposition in semitones + case 0xc9: // layer_setshortnoteduration + temp_a0_6 = *(state->pc++); + if (cmd == 0xc9) { + layer->noteDuration = temp_a0_6; + } else { + layer->transposition = temp_a0_6; + } + break; + + case 0xc4: // layer_somethingon + case 0xc5: // layer_somethingoff + //! copt needs a ternary: + //layer->continuousNotes = (cmd == 0xc4) ? TRUE : FALSE; + if (cmd == 0xc4) { + temp8 = TRUE; + } else { + temp8 = FALSE; + } + layer->continuousNotes = temp8; + seq_channel_layer_note_decay(layer); + break; + + case 0xc3: // layer_setshortnotedefaultplaypercentage + M64_READ_COMPRESSED_U16(state, sp3A) + layer->shortNoteDefaultPlayPercentage = sp3A; + break; + + case 0xc6: // layer_setinstr + M64_READ_U8(state, instId); + if (instId < 127) { + GET_INSTRUMENT(seqChannel, instId, &(*layer).instrument, &(*layer).adsr, instId, 1); + } + break; + + case 0xc7: // layer_portamento + M64_READ_U8(state, (*layer).portamento.mode); + M64_READ_U8(state, PORTAMENTO_TGT_NOTE); + PORTAMENTO_TGT_NOTE = PORTAMENTO_TGT_NOTE + (*layer).transposition + (*seqPlayer).transposition + (*seqChannel).transposition; + if (PORTAMENTO_TGT_NOTE >= 0x80) { + PORTAMENTO_TGT_NOTE = 0; + } + layer->portamentoTargetNote = PORTAMENTO_TGT_NOTE; + + // If special, the next param is u8 instead of var + if (PORTAMENTO_IS_SPECIAL((*(layer)).portamento)) { + layer->portamentoTime = *((state)->pc++); + break; + } + + M64_READ_COMPRESSED_U16(state, sp3A) + layer->portamentoTime = sp3A; + break; + + case 0xc8: // layer_disableportamento + layer->portamento.mode = 0; + break; + + default: + switch (cmd & 0xf0) { + case 0xd0: // layer_setshortnotevelocityfromtable + sp3A = seqPlayer->shortNoteVelocityTable[cmd & 0xf]; + (*(layer)).velocitySquare = (f32)(sp3A * sp3A); + break; + case 0xe0: // layer_setshortnotedurationfromtable + (*(layer)).noteDuration = seqPlayer->shortNoteDurationTable[cmd & 0xf]; + break; + } + } + } + if (cmd == 0xc0) // layer_delay + { + M64_READ_COMPRESSED_U16(state, layer->delay); + layer->stopSomething = TRUE; + } else { + layer->stopSomething = FALSE; + + if (seqChannel->largeNotes == TRUE) { + switch (cmd & 0xc0) { + case 0x00: // layer_note0 (play percentage, velocity, duration) + M64_READ_COMPRESSED_U16(state, sp3A) + vel = *((*state).pc++); + layer->noteDuration = *(state->pc++); + layer->playPercentage = sp3A; + goto l1090; + + case 0x40: // layer_note1 (play percentage, velocity) + M64_READ_COMPRESSED_U16(state, sp3A) + vel = *(state->pc++); + layer->noteDuration = 0; + layer->playPercentage = sp3A; + goto l1090; + + + case 0x80: // layer_note2 (velocity, duration; uses last play percentage) + sp3A = layer->playPercentage; + vel = *(state->pc++); + layer->noteDuration = *(state->pc++); + goto l1090; + } +l1090: + cmdSemitone = (cmd - (cmd & 0xc0)); + layer->velocitySquare = vel * vel; + } else { + switch (cmd & 0xc0) { + case 0x00: // play note, type 0 (play percentage) + M64_READ_COMPRESSED_U16(state, sp3A) + layer->playPercentage = sp3A; + break; + + case 0x40: // play note, type 1 (uses default play percentage) + sp3A = layer->shortNoteDefaultPlayPercentage; + break; + + case 0x80: // play note, type 2 (uses last play percentage) + sp3A = layer->playPercentage; + break; + } + + cmdSemitone = cmd - (cmd & 0xc0); + } + + layer->delay = sp3A; + layer->duration = layer->noteDuration * sp3A / 256; + if ((seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_STOP_NOTES) != 0) + || seqChannel->stopSomething2 + || !seqChannel->hasInstrument + ) { + layer->stopSomething = TRUE; + } else { + if (seqChannel->instOrWave == 0) { // drum + //DRUM_INDEX = cmdSemitone; + DRUM_INDEX += (*seqChannel).transposition + (*layer).transposition; + if (DRUM_INDEX >= gCtlEntries[seqChannel->bankId].numDrums) { + DRUM_INDEX = gCtlEntries[seqChannel->bankId].numDrums; + if (DRUM_INDEX == 0) { + // this goto looks a bit like a function return... + layer->stopSomething = TRUE; + goto skip; + } + + DRUM_INDEX--; + } + + drum = gCtlEntries[seqChannel->bankId].drums[DRUM_INDEX]; + if (drum == NULL) { + layer->stopSomething = TRUE; + } else { + layer->adsr.envelope = drum->envelope; + layer->adsr.releaseRate = drum->releaseRate; + layer->pan = FLOAT_CAST(drum->pan) / US_FLOAT(128.0); + layer->sound = &drum->sound; + layer->freqScale = layer->sound->tuning; + } + + skip:; + } else { // instrument + //SEMITONE = cmdSemitone; + SEMITONE += (*(seqPlayer)).transposition + (*(seqChannel)).transposition + (*(layer)).transposition; + if (SEMITONE >= 0x80) { + layer->stopSomething = TRUE; + } else { + instrument = layer->instrument; + if (instrument == NULL) { + instrument = seqChannel->instrument; + } + + if (layer->portamento.mode != 0) { + //! copt needs a ternary: + //usedSemitone = (layer->portamentoTargetNote < SEMITONE) ? SEMITONE : layer->portamentoTargetNote; + if (layer->portamentoTargetNote < SEMITONE) { + USED_SEMITONE = SEMITONE; + } else { + USED_SEMITONE = layer->portamentoTargetNote; + } + + if (instrument != NULL) { + sound = (u8) USED_SEMITONE < instrument->normalRangeLo ? &instrument->lowNotesSound + : (u8) USED_SEMITONE <= instrument->normalRangeHi ? + &instrument->normalNotesSound : &instrument->highNotesSound; + + sameSound = (sound == (*layer).sound); + layer->sound = sound; + tuning = (*sound).tuning; + } else { + layer->sound = NULL; + tuning = 1.0f; + } + + temp_f2 = gNoteFrequencies[SEMITONE] * tuning; + temp_f12 = gNoteFrequencies[layer->portamentoTargetNote] * tuning; + + portamento = &layer->portamento; + switch (PORTAMENTO_MODE(layer->portamento)) { + case PORTAMENTO_MODE_1: + case PORTAMENTO_MODE_3: + case PORTAMENTO_MODE_5: + sp24 = temp_f2; + freqScale = temp_f12; + goto l13cc; + + case PORTAMENTO_MODE_2: + case PORTAMENTO_MODE_4: + freqScale = temp_f2; + sp24 = temp_f12; + goto l13cc; + } +l13cc: + portamento->extent = sp24 / freqScale - US_FLOAT(1.0); + if (PORTAMENTO_IS_SPECIAL((*(layer)).portamento)) { + portamento->speed = US_FLOAT(32512.0) * FLOAT_CAST((*(seqPlayer)).tempo) + / ((f32)(*(layer)).delay * (f32) gTempoInternalToExternal + * FLOAT_CAST((*(layer)).portamentoTime)); + } else { + portamento->speed = US_FLOAT(127.0) / FLOAT_CAST((*(layer)).portamentoTime); + } + portamento->cur = 0.0f; + layer->freqScale = freqScale; + if (PORTAMENTO_MODE((*(layer)).portamento) == PORTAMENTO_MODE_5) { + layer->portamentoTargetNote = SEMITONE; + } + } else if (instrument != NULL) { + sound = SEMITONE < instrument->normalRangeLo ? + &instrument->lowNotesSound : SEMITONE <= instrument->normalRangeHi ? + &instrument->normalNotesSound : &instrument->highNotesSound; + + sameSound = (sound == (*(layer)).sound); + layer->sound = sound; + layer->freqScale = gNoteFrequencies[SEMITONE] * (*(sound)).tuning; + } else { + layer->sound = NULL; + layer->freqScale = gNoteFrequencies[SEMITONE]; + } + } + } + layer->delayUnused = layer->delay; + } + } + + if (layer->stopSomething == TRUE) { + if (layer->note != NULL || layer->continuousNotes) { + seq_channel_layer_note_decay(layer); + } + return; + } + + cmd = FALSE; + if (!layer->continuousNotes) { + cmd = TRUE; + } else if (layer->note == NULL || layer->status == SOUND_LOAD_STATUS_NOT_LOADED) { + cmd = TRUE; + } else if (sameSound == FALSE) { + seq_channel_layer_note_decay(layer); + cmd = TRUE; + } else if (layer->sound == NULL) { + init_synthetic_wave(layer->note, layer); + } + + if (cmd != FALSE) { + (*(layer)).note = alloc_note(layer); + } + + if (layer->note != NULL && layer->note->parentLayer == layer) { + note_vibrato_init(layer->note); + } +} diff --git a/src/audio/seqplayer.c b/src/audio/seqplayer.c index 810dc9ec..91146bbb 100644 --- a/src/audio/seqplayer.c +++ b/src/audio/seqplayer.c @@ -1,12 +1,11 @@ -#include -#include +#include -#include "heap.h" #include "data.h" +#include "effects.h" +#include "external.h" +#include "heap.h" #include "load.h" #include "seqplayer.h" -#include "external.h" -#include "effects.h" #define PORTAMENTO_IS_SPECIAL(x) ((x).mode & 0x80) #define PORTAMENTO_MODE(x) ((x).mode & ~0x80) @@ -378,62 +377,57 @@ u16 m64_read_compressed_u16(struct M64ScriptState *state) { return ret; } -#ifdef NON_MATCHING +#if defined(VERSION_EU) void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { struct SequencePlayer *seqPlayer; // sp5C, t4 struct SequenceChannel *seqChannel; // sp58, t5 +#ifdef VERSION_EU + UNUSED u64 pad0; +#endif struct M64ScriptState *state; // v0 -#ifndef VERSION_EU - struct AdsrSettings *adsr; // v0 -#endif struct Portamento *portamento; // v0 -#ifndef VERSION_EU - struct Instrument **instOut; // a1 - struct Instrument *inst; // a0 -#endif struct AudioBankSound *sound; // v0 struct Instrument *instrument; // v1 struct Drum *drum; #ifdef VERSION_EU + u16 sp3A; // t2, a0, a1 s32 sameSound; + UNUSED s32 pad[1]; #else + UNUSED s32 pad[1]; u8 sameSound; // sp3F #endif - u8 cmd; // a0 - u8 allocNewNote; // sp3D, t0 - u8 loBits; + UNUSED u8 allocNewNote; // sp3D, t0 + u8 cmd; // a0 sp3E, EU s2 + UNUSED u8 loBits; +#ifndef VERSION_EU u16 sp3A; // t2, a0, a1 +#endif + UNUSED s32 pad2[1]; s32 vel; // sp30, t3 + UNUSED s32 pad3[1]; #ifdef VERSION_EU - f32 velFloat; + UNUSED f32 velFloat; #endif f32 freqScale; // sp28, f0 #ifndef VERSION_EU f32 sp24; #endif -#ifdef VERSION_EU - s8 temp8; -#else - u8 temp8; -#endif -#ifndef VERSION_EU - u8 *old; - u8 *old2; -#endif - u8 semitone; // v0 - u8 usedSemitone; // a1 + UNUSED u8 temp8; + UNUSED u8 semitone; // v0 + UNUSED s32 usedSemitone; // a1 f32 temp_f12; f32 temp_f2; s32 temp_a0_5; - u8 drumIndex; // t0 - s32 cmdBase; // t1 + UNUSED u8 drumIndex; // t0 + UNUSED s32 cmdBase; // t1 u8 temp_a0_6; - u8 portamentoTargetNote; // t7 + UNUSED u8 portamentoTargetNote; // t7 #ifndef VERSION_EU - s32 bankId; // a3 + UNUSED s32 bankId; // a3 #endif - u8 instId; // v0 - s32 cmdSemitone; // v1 + UNUSED u8 instId; // v0 + UNUSED u8 cmdSemitone; // v1 f32 tuning; // f0 sameSound = TRUE; @@ -461,20 +455,14 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { seqChannel = layer->seqChannel; seqPlayer = seqChannel->seqPlayer; - #ifdef VERSION_EU layer->notePropertiesNeedInit = TRUE; #endif for (;;) { - // (Moving state outside the loop improves initial regalloc, but is wrong) state = &layer->scriptState; -#ifdef VERSION_EU cmd = m64_read_u8(state); -#else - old2 = state->pc++; - cmd = *old2; -#endif + if (cmd <= 0xc0) { break; } @@ -487,41 +475,22 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { seq_channel_layer_disable(layer); return; } - state->depth--, state->pc = state->stack[state->depth]; + state->pc = state->stack[--state->depth]; break; case 0xfc: // layer_call - // Something is wrong with the codegen here... It almost looks like - // it's inlining m64_read_s16, but it lacks a s16 cast. - // Maybe they did macro-based inlining since there are more layers - // than channels or sequences, making the code hotter. -#ifdef VERSION_EU sp3A = m64_read_s16(state); state->stack[state->depth++] = state->pc; -#else - sp3A = *(state->pc++) << 8; - sp3A = *(state->pc++) | sp3A; - state->depth++; - state->stack[state->depth - 1] = state->pc; -#endif state->pc = seqPlayer->seqData + sp3A; break; case 0xf8: // layer_loop; loop start, N iterations (or 256 if N = 0) -#ifdef VERSION_EU state->remLoopIters[state->depth] = m64_read_u8(state); state->stack[state->depth++] = state->pc; -#else - old = state->pc++; - state->remLoopIters[state->depth] = *old; - state->depth++; - state->stack[state->depth - 1] = state->pc; -#endif break; case 0xf7: // layer_loopend - state->remLoopIters[state->depth - 1]--; - if (state->remLoopIters[state->depth - 1] != 0) { + if (--state->remLoopIters[state->depth - 1] != 0) { state->pc = state->stack[state->depth - 1]; } else { state->depth--; @@ -529,19 +498,13 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { break; case 0xfb: // layer_jump -#ifdef VERSION_EU sp3A = m64_read_s16(state); -#else - sp3A = *(state->pc++) << 8; - sp3A = *(state->pc++) | sp3A; -#endif state->pc = seqPlayer->seqData + sp3A; break; #ifdef VERSION_EU case 0xf4: - temp8 = m64_read_u8(state); - state->pc += temp8; + state->pc += (s8)m64_read_u8(state); break; #endif @@ -571,151 +534,71 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { case 0xc4: // layer_somethingon case 0xc5: // layer_somethingoff -#ifdef VERSION_EU if (cmd == 0xc4) { layer->continuousNotes = TRUE; } else { layer->continuousNotes = FALSE; } -#else - if (cmd == 0xc4) { - temp8 = TRUE; - } else { - temp8 = FALSE; - } - layer->continuousNotes = temp8; -#endif seq_channel_layer_note_decay(layer); break; case 0xc3: // layer_setshortnotedefaultplaypercentage - // This doesn't match very well... sp3A is definitely set here - // (it's falsely preserved until after the loop), but maybe there's - // also inlining going on, with sp3A as a temp variable being used - // for no good reason? Or it could just be a macro. -#ifdef VERSION_EU sp3A = m64_read_compressed_u16(state); -#else - sp3A = *(state->pc++); - if (sp3A & 0x80) { - sp3A = (sp3A << 8) & 0x7f00; - sp3A = *(state->pc++) | sp3A; - } -#endif layer->shortNoteDefaultPlayPercentage = sp3A; break; case 0xc6: // layer_setinstr -#ifdef VERSION_EU - instId = m64_read_u8(state); + cmd = m64_read_u8(state); +#ifndef VERSION_EU + if (cmd < 127) { + cmd = get_instrument(seqChannel, cmd, &layer->instrument, &layer->adsr); + } #else - old = state->pc++; - instId = *old; -#endif - // The rest of this case is identical to - // if (instId < 0x7f) { - // get_instrument(seqChannel, instId, &layer->instrument, &layer->adsr); - // } - // except without seqChannelCpy... - // interestingly, get_instrument comes just *after* this function, - // which I think wouldn't be the case with __inline (maybe if they - // both inline a common helper?) - if (instId >= 0x7f) { -#ifdef VERSION_EU - if (instId == 0x7f) { + if (cmd >= 0x7f) { + if (cmd == 0x7f) { layer->instOrWave = 0; } else { - layer->instOrWave = instId; + layer->instOrWave = cmd; layer->instrument = NULL; } - if (instId != 0xff) { - break; + + if (1) { + } + + if (cmd == 0xff) { + layer->adsr.releaseRate = 0; } - layer->adsr.releaseRate = 0; -#endif break; } -#ifdef VERSION_EU - instId = get_instrument(seqChannel, instId, &layer->instrument, &layer->adsr); - layer->instOrWave = instId; - if (instId == 0) { + cmd = get_instrument(seqChannel, cmd, &layer->instrument, &layer->adsr); + layer->instOrWave = cmd; + if (cmd == 0) { layer->instOrWave = 0xff; } - //layer->instOrWave = instId == 0 ? 0xff : instId; - break; -#else - bankId = seqChannel->bankId; // maybe a temp, to match get_instrument - if (instId >= gCtlEntries[bankId].numInstruments) { - instId = gCtlEntries[bankId].numInstruments; - if (instId == 0) { - break; - } - instId--; - } - - instOut = &layer->instrument; - inst = gCtlEntries[bankId].instruments[instId]; - if (inst == NULL) { - while (instId != 0xff) { - inst = gCtlEntries[bankId].instruments[instId]; - if (inst != NULL) { - break; - } - instId--; - } - } - - adsr = &layer->adsr; - if (((uintptr_t) gBankLoadedPool.persistent.pool.start <= (uintptr_t) inst - && (uintptr_t) inst <= (uintptr_t)(gBankLoadedPool.persistent.pool.start - + gBankLoadedPool.persistent.pool.size)) - || ((uintptr_t) gBankLoadedPool.temporary.pool.start <= (uintptr_t) inst - && (uintptr_t) inst <= (uintptr_t)(gBankLoadedPool.temporary.pool.start - + gBankLoadedPool.temporary.pool.size))) { - adsr->envelope = inst->envelope; - adsr->releaseRate = inst->releaseRate; - *instOut = inst; - // instId++; - } else { - gAudioErrorFlags = instId + 0x20000; - *instOut = NULL; - } #endif break; case 0xc7: // layer_portamento -#ifdef VERSION_EU layer->portamento.mode = m64_read_u8(state); - portamentoTargetNote = m64_read_u8(state) + seqChannel->transposition + + + // cmd is reused for the portamento's semitone + cmd = m64_read_u8(state) + seqChannel->transposition + layer->transposition + seqPlayer->transposition; -#else - old = state->pc++; - layer->portamento.mode = *old; - old = state->pc++; - portamentoTargetNote = *old + seqChannel->transposition + - layer->transposition + seqPlayer->transposition; -#endif - if (portamentoTargetNote >= 0x80) { - portamentoTargetNote = 0; + + if (cmd >= 0x80) { + cmd = 0; } - layer->portamentoTargetNote = portamentoTargetNote; + + layer->portamentoTargetNote = cmd; // If special, the next param is u8 instead of var if (PORTAMENTO_IS_SPECIAL(layer->portamento)) { - layer->portamentoTime = *(state->pc++); + layer->portamentoTime = *((state)->pc++); break; } -#ifdef VERSION_EU sp3A = m64_read_compressed_u16(state); -#else - sp3A = *(state->pc++); - if (sp3A & 0x80) { - sp3A = (sp3A << 8) & 0x7f00; - sp3A = *(state->pc++) | sp3A; - } -#endif layer->portamentoTime = sp3A; break; @@ -736,104 +619,58 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { #endif default: - loBits = cmd & 0xf; switch (cmd & 0xf0) { case 0xd0: // layer_setshortnotevelocityfromtable - sp3A = seqPlayer->shortNoteVelocityTable[loBits]; + sp3A = seqPlayer->shortNoteVelocityTable[cmd & 0xf]; layer->velocitySquare = (f32)(sp3A * sp3A); break; case 0xe0: // layer_setshortnotedurationfromtable - layer->noteDuration = seqPlayer->shortNoteDurationTable[loBits]; + layer->noteDuration = seqPlayer->shortNoteDurationTable[cmd & 0xf]; break; } } } - state = &layer->scriptState; - if (cmd == 0xc0) // layer_delay - { -#ifdef VERSION_EU - sp3A = m64_read_compressed_u16(state); -#else - sp3A = *(state->pc++); - if (sp3A & 0x80) { - sp3A = (sp3A << 8) & 0x7f00; - sp3A = *(state->pc++) | sp3A; - } -#endif - layer->delay = sp3A; + if (cmd == 0xc0) { // layer_delay + layer->delay = m64_read_compressed_u16(state); layer->stopSomething = TRUE; } else { layer->stopSomething = FALSE; if (seqChannel->largeNotes == TRUE) { - cmdBase = cmd & 0xc0; - - // phi_a0_3 = sp3A; // real assignment, or same vars? - state = &layer->scriptState; - switch (cmdBase) { + switch (cmd & 0xc0) { case 0x00: // layer_note0 (play percentage, velocity, duration) -#ifdef VERSION_EU sp3A = m64_read_compressed_u16(state); -#else - sp3A = *(state->pc++); - if (sp3A & 0x80) { - sp3A = (sp3A << 8) & 0x7f00; - sp3A = *(state->pc++) | sp3A; - } -#endif vel = *(state->pc++); layer->noteDuration = *(state->pc++); layer->playPercentage = sp3A; break; case 0x40: // layer_note1 (play percentage, velocity) -#ifdef VERSION_EU sp3A = m64_read_compressed_u16(state); -#else - sp3A = *(state->pc++); - if (sp3A & 0x80) { - sp3A = (sp3A << 8) & 0x7f00; - sp3A = *(state->pc++) | sp3A; - } -#endif vel = *(state->pc++); layer->noteDuration = 0; layer->playPercentage = sp3A; break; case 0x80: // layer_note2 (velocity, duration; uses last play percentage) + sp3A = layer->playPercentage; vel = *(state->pc++); layer->noteDuration = *(state->pc++); - sp3A = layer->playPercentage; break; } + // the remaining bits are used for the semitone + cmd -= (cmd & 0xc0); #ifdef VERSION_EU - velFloat = (f32) vel; - layer->velocitySquare = velFloat * velFloat; - cmdSemitone = (cmd - (cmd & 0xc0)) & 0xff; + layer->velocitySquare = (f32)(vel) * (f32)vel; #else layer->velocitySquare = vel * vel; - cmdSemitone = cmd - cmdBase; #endif } else { - cmdBase = cmd & 0xc0; - - state = &layer->scriptState; - - // phi_a0_3 = sp3A; - switch (cmdBase) { + switch (cmd & 0xc0) { case 0x00: // play note, type 0 (play percentage) -#ifdef VERSION_EU sp3A = m64_read_compressed_u16(state); -#else - sp3A = *(state->pc++); - if (sp3A & 0x80) { - sp3A = (sp3A << 8) & 0x7f00; - sp3A = *(state->pc++) | sp3A; - } -#endif layer->playPercentage = sp3A; break; @@ -846,11 +683,8 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { break; } -#ifdef VERSION_EU - cmdSemitone = (cmd - (cmd & 0xc0)) & 0xff; -#else - cmdSemitone = cmd - cmdBase; -#endif + // the remaining bits are used for the semitone + cmd -= cmd & 0xc0; } layer->delay = sp3A; @@ -868,23 +702,31 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { layer->stopSomething = TRUE; } else { #ifdef VERSION_EU - if ((layer->instOrWave == 0xff ? seqChannel->instOrWave : layer->instOrWave) == 0) { - drumIndex = cmdSemitone + seqChannel->transposition + layer->transposition; - drum = get_drum(seqChannel->bankId, drumIndex); + s32 temp = layer->instOrWave; + if (temp == 0xff) temp = seqChannel->instOrWave; + if (temp == 0) #else - if (seqChannel->instOrWave == 0) { // drum - drumIndex = cmdSemitone + seqChannel->transposition + layer->transposition; - if (drumIndex >= gCtlEntries[seqChannel->bankId].numDrums) { - drumIndex = gCtlEntries[seqChannel->bankId].numDrums; - if (drumIndex == 0) { + if (seqChannel->instOrWave == 0) +#endif + { // drum + // cmd is reused for the drum semitone + cmd += seqChannel->transposition + layer->transposition; + +#ifdef VERSION_EU + drum = get_drum(seqChannel->bankId, cmd); +#else + if (cmd >= gCtlEntries[seqChannel->bankId].numDrums) { + cmd = gCtlEntries[seqChannel->bankId].numDrums; + if (cmd == 0) { // this goto looks a bit like a function return... layer->stopSomething = TRUE; goto skip; } - drumIndex--; + + cmd--; } - drum = gCtlEntries[seqChannel->bankId].drums[drumIndex]; + drum = gCtlEntries[seqChannel->bankId].drums[cmd]; #endif if (drum == NULL) { layer->stopSomething = TRUE; @@ -905,40 +747,39 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { skip:; #endif } else { // instrument - semitone = cmdSemitone + seqPlayer->transposition + seqChannel->transposition - + layer->transposition; - if (semitone >= 0x80) { + // cmd is reused for the instrument semitone + cmd += seqPlayer->transposition + seqChannel->transposition + layer->transposition; + + if (cmd >= 0x80) { layer->stopSomething = TRUE; } else { #ifdef VERSION_EU - if (layer->instOrWave == 0xff) { + if (layer->instOrWave == 0xffu) { instrument = seqChannel->instrument; } else { instrument = layer->instrument; } #else instrument = layer->instrument; - if (layer->instrument == NULL) { + if (instrument == NULL) { instrument = seqChannel->instrument; } #endif if (layer->portamento.mode != 0) { - usedSemitone = layer->portamentoTargetNote; - if (usedSemitone < semitone) { - usedSemitone = semitone; + if (layer->portamentoTargetNote < cmd) { + vel = cmd; + } else { + vel = layer->portamentoTargetNote; } + if (instrument != NULL) { #ifdef VERSION_EU - sound = instrument_get_audio_bank_sound(instrument, usedSemitone); + sound = instrument_get_audio_bank_sound(instrument, vel); #else - if (usedSemitone < instrument->normalRangeLo) { - sound = &instrument->lowNotesSound; - } else if (usedSemitone <= instrument->normalRangeHi) { - sound = &instrument->normalNotesSound; - } else { - sound = &instrument->highNotesSound; - } + sound = (u8) vel < instrument->normalRangeLo ? &instrument->lowNotesSound + : (u8) vel <= instrument->normalRangeHi ? + &instrument->normalNotesSound : &instrument->highNotesSound; #endif sameSound = (sound == layer->sound); layer->sound = sound; @@ -948,7 +789,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { tuning = 1.0f; } - temp_f2 = gNoteFrequencies[semitone] * tuning; + temp_f2 = gNoteFrequencies[cmd] * tuning; temp_f12 = gNoteFrequencies[layer->portamentoTargetNote] * tuning; portamento = &layer->portamento; @@ -961,12 +802,16 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { #endif freqScale = temp_f12; break; + case PORTAMENTO_MODE_2: case PORTAMENTO_MODE_4: +#ifdef VERSION_EU + default: +#endif + freqScale = temp_f2; #ifndef VERSION_EU sp24 = temp_f12; #endif - freqScale = temp_f2; break; } @@ -975,6 +820,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { #else portamento->extent = sp24 / freqScale - US_FLOAT(1.0); #endif + if (PORTAMENTO_IS_SPECIAL(layer->portamento)) { portamento->speed = US_FLOAT(32512.0) * FLOAT_CAST(seqPlayer->tempo) / ((f32) layer->delay * (f32) gTempoInternalToExternal @@ -985,26 +831,22 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { portamento->cur = 0.0f; layer->freqScale = freqScale; if (PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_5) { - layer->portamentoTargetNote = semitone; + layer->portamentoTargetNote = cmd; } } else if (instrument != NULL) { #ifdef VERSION_EU - sound = instrument_get_audio_bank_sound(instrument, semitone); + sound = instrument_get_audio_bank_sound(instrument, cmd); #else - if (semitone < instrument->normalRangeLo) { - sound = &instrument->lowNotesSound; - } else if (semitone <= instrument->normalRangeHi) { - sound = &instrument->normalNotesSound; - } else { - sound = &instrument->highNotesSound; - } + sound = cmd < instrument->normalRangeLo ? + &instrument->lowNotesSound : cmd <= instrument->normalRangeHi ? + &instrument->normalNotesSound : &instrument->highNotesSound; #endif sameSound = (sound == layer->sound); layer->sound = sound; - layer->freqScale = sound->tuning * gNoteFrequencies[semitone]; + layer->freqScale = gNoteFrequencies[cmd] * sound->tuning; } else { layer->sound = NULL; - layer->freqScale = gNoteFrequencies[semitone]; + layer->freqScale = gNoteFrequencies[cmd]; } } } @@ -1019,44 +861,46 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { return; } + cmd = FALSE; if (!layer->continuousNotes) { - allocNewNote = TRUE; + cmd = TRUE; } else if (layer->note == NULL || layer->status == SOUND_LOAD_STATUS_NOT_LOADED) { - allocNewNote = TRUE; + cmd = TRUE; } else if (sameSound == FALSE) { seq_channel_layer_note_decay(layer); - allocNewNote = TRUE; + cmd = TRUE; + } #ifdef VERSION_EU - } else if (layer != layer->note->parentLayer) { - allocNewNote = TRUE; + else if (layer != layer->note->parentLayer) { + cmd = TRUE; + } #endif - } else { - allocNewNote = FALSE; - if (layer->sound == NULL) { - init_synthetic_wave(layer->note, layer); - } + else if (layer->sound == NULL) { + init_synthetic_wave(layer->note, layer); } - if (allocNewNote != FALSE) { + if (cmd != FALSE) { layer->note = alloc_note(layer); } if (layer->note != NULL && layer->note->parentLayer == layer) { note_vibrato_init(layer->note); } +#ifdef VERSION_EU + if (seqChannel) { + } +#endif } - -#elif defined(VERSION_EU) -GLOBAL_ASM("asm/non_matchings/eu/audio/seq_channel_layer_process_script.s") +#elif defined(NON_MATCHING) +// US/JP version with macros to simulate inlining by copt. Edit if you dare. +#include "seq_channel_layer_process_script.h" #elif defined(VERSION_JP) GLOBAL_ASM("asm/non_matchings/seq_channel_layer_process_script_jp.s") #else GLOBAL_ASM("asm/non_matchings/seq_channel_layer_process_script_us.s") #endif -u8 get_instrument(struct SequenceChannel *seqChannel, u8 instId, struct Instrument **instOut, - struct AdsrSettings *adsr) -{ +u8 get_instrument(struct SequenceChannel *seqChannel, u8 instId, struct Instrument **instOut, struct AdsrSettings *adsr) { struct Instrument *inst; #ifdef VERSION_EU inst = get_instrument_inner(seqChannel->bankId, instId); @@ -1142,19 +986,21 @@ void sequence_channel_set_volume(struct SequenceChannel *seqChannel, u8 volume) } #ifdef NON_MATCHING +//rodata: 0xf3e30 void sequence_channel_process_script(struct SequenceChannel *seqChannel) { - u16 sp5A; - s8 value; // sp53 - u8 sp38; - u8 cmd; // v1, s1 - u8 loBits; // t0, a0 struct M64ScriptState *state; struct SequencePlayer *seqPlayer; + u16 sp5A; + UNUSED u8 t0; + UNUSED u8 sp38; + u8 cmd; // v1, s1 + u8 loBits; // t0, a0 + s32 offset; + s8 value; // sp53, 4b u8 temp; s8 tempSigned; - s32 offset; + UNUSED u8 temp2; s32 i; - u8 temp2; #ifdef VERSION_EU u8 *arr; #endif @@ -1216,16 +1062,18 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) { // towards the bottom of the function) if (cmd > 0xc0) { switch (cmd) { -#ifdef VERSION_EU case 0xff: // chan_end +#ifdef VERSION_EU if (state->depth == 0) { sequence_channel_disable(seqChannel); goto out; } else { - state->depth--, state->pc = state->stack[state->depth]; + state->pc = state->stack[--state->depth]; } +#endif break; +#ifdef VERSION_EU case 0xfe: // chan_delay1 goto out; @@ -1463,7 +1311,8 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) { break; case 0xc6: // chan_setbank; switch bank within set - temp = m64_read_u8(state); + { + u8 temp = m64_read_u8(state); // Switch to the temp's (0-indexed) bank in this sequence's // bank set. Note that in the binary format (not in the JSON!) // the banks are listed backwards, so we counts from the back. @@ -1474,14 +1323,18 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) { if (get_bank_or_seq(&gBankLoadedPool, 2, temp) != NULL) { seqChannel->bankId = temp; } + } break; case 0xc7: // chan_writeseq; write to sequence data (!) // sp38 doesn't go on the stack + { + u8 sp38; + u8 temp; sp38 = value; - temp2 = m64_read_u8(state); - sp5A = m64_read_s16(state); - seqPlayer->seqData[sp5A] = sp38 + temp2; + temp = m64_read_u8(state); + seqPlayer->seqData[(u16)m64_read_s16(state)] = sp38 + temp; + } break; case 0xc8: // chan_subtract @@ -1676,6 +1529,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) { seq_channel_layer_process_script(seqChannel->layers[i]); } } +#undef loBits } #elif defined(VERSION_EU) diff --git a/src/audio/seqplayer.h b/src/audio/seqplayer.h index 005b5193..99ea13ac 100644 --- a/src/audio/seqplayer.h +++ b/src/audio/seqplayer.h @@ -1,7 +1,9 @@ -#ifndef _AUDIO_SEQPLAYER_H -#define _AUDIO_SEQPLAYER_H +#ifndef AUDIO_SEQPLAYER_H +#define AUDIO_SEQPLAYER_H -#include "types.h" +#include + +#include "internal.h" #include "playback.h" void seq_channel_layer_disable(struct SequenceChannelLayer *seqPlayer); @@ -14,4 +16,4 @@ void process_sequences(s32 iterationsRemaining); void init_sequence_player(u32 player); void init_sequence_players(void); -#endif /* _AUDIO_SEQPLAYER_H */ +#endif // AUDIO_SEQPLAYER_H diff --git a/src/audio/synthesis.c b/src/audio/synthesis.c index b332c9f0..8a907c81 100644 --- a/src/audio/synthesis.c +++ b/src/audio/synthesis.c @@ -1,5 +1,4 @@ #include -#include #include "synthesis.h" #include "heap.h" @@ -44,15 +43,15 @@ struct VolumeChange { u16 targetRight; }; -u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex); +u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex); #ifdef VERSION_EU -u64 *synthesis_process_note(struct Note *note, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, u16 *aiBuf, s32 bufLen, u64 *cmd); +u64 *synthesis_process_note(struct Note *note, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 bufLen, u64 *cmd); u64 *load_wave_samples(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad); u64 *final_resample(u64 *cmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags); u64 *process_envelope(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, u32 flags); u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight); #else -u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd); +u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd); u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad); u64 *final_resample(u64 *cmd, struct Note *note, s32 count, u16 pitch, u16 dmemIn, u32 flags); u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings, @@ -256,7 +255,7 @@ s32 get_volume_ramping(u16 sourceVol, u16 targetVol, s32 arg2) { #ifdef VERSION_EU //TODO: (Scrub C) pointless mask and whitespace -u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) { +u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) { s32 i, j; f32 *leftVolRamp; f32 *rightVolRamp; @@ -291,7 +290,7 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) { prepare_reverb_ring_buffer(chunkLen, gAudioBufferParameters.updatesPerFrame - i, j); } } - cmd = synthesis_do_one_audio_update((u16 *) aiBufPtr, chunkLen, cmd, gAudioBufferParameters.updatesPerFrame - i); + cmd = synthesis_do_one_audio_update((s16 *) aiBufPtr, chunkLen, cmd, gAudioBufferParameters.updatesPerFrame - i); bufLen -= chunkLen; aiBufPtr += chunkLen; } @@ -307,7 +306,7 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) { } #else // bufLen will be divisible by 16 -u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) { +u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) { s32 chunkLen; s32 i; u32 *aiBufPtr = (u32 *) aiBuf; @@ -333,7 +332,7 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) { if (gSynthesisReverb.useReverb != 0) { prepare_reverb_ring_buffer(chunkLen, gAudioUpdatesPerFrame - i); } - cmd = synthesis_do_one_audio_update((u16 *) aiBufPtr, chunkLen, cmd, gAudioUpdatesPerFrame - i); + cmd = synthesis_do_one_audio_update((s16 *) aiBufPtr, chunkLen, cmd, gAudioUpdatesPerFrame - i); bufLen -= chunkLen; aiBufPtr += chunkLen; } @@ -417,7 +416,7 @@ u64 *synthesis_save_reverb_samples(u64 *cmdBuf, s16 reverbIndex, s16 updateIndex #endif #ifdef VERSION_EU -u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) { +u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) { struct NoteSubEu *noteSubEu; u8 noteIndices[56]; s32 temp; @@ -496,7 +495,7 @@ u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateI return cmd; } #else -u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) { +u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) { UNUSED s32 pad1[1]; s16 ra; s16 t4; @@ -573,10 +572,10 @@ u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateI #ifdef VERSION_EU // Processes just one note, not all -u64 *synthesis_process_note(struct Note *note, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, UNUSED u16 *aiBuf, s32 bufLen, u64 *cmd) { +u64 *synthesis_process_note(struct Note *note, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, UNUSED s16 *aiBuf, s32 bufLen, u64 *cmd) { UNUSED s32 pad0[3]; #else -u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) { +u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) { s32 noteIndex; // sp174 struct Note *note; // s7 UNUSED u8 pad0[0x08]; diff --git a/src/audio/synthesis.h b/src/audio/synthesis.h index c6c751b4..698358c8 100644 --- a/src/audio/synthesis.h +++ b/src/audio/synthesis.h @@ -63,7 +63,7 @@ extern f32 *gCurrentRightVolRamping; // Points to any of the three right buffers extern struct SynthesisReverb gSynthesisReverb; #endif -u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen); +u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen); #ifndef VERSION_EU void note_init_volume(struct Note *note); void note_set_vel_pan_reverb(struct Note *note, f32 velocity, f32 pan, u8 reverb); @@ -72,4 +72,4 @@ void note_enable(struct Note *note); void note_disable(struct Note *note); #endif -#endif /* AUDIO_SYNTHESIS_H */ +#endif // AUDIO_SYNTHESIS_H diff --git a/src/buffers/buffers.h b/src/buffers/buffers.h index 3d8b6c64..9d1d692b 100644 --- a/src/buffers/buffers.h +++ b/src/buffers/buffers.h @@ -1,7 +1,8 @@ #ifndef BUFFERS_H #define BUFFERS_H -#include "types.h" +#include + #include "game/save_file.h" #include "game/game_init.h" @@ -31,4 +32,4 @@ extern u8 gGfxSPTaskStack[]; extern struct GfxPool gGfxPools[GFX_NUM_POOLS]; -#endif +#endif // BUFFERS_H diff --git a/src/buffers/framebuffers.c b/src/buffers/framebuffers.c index 6a16e21c..bb3589d2 100644 --- a/src/buffers/framebuffers.c +++ b/src/buffers/framebuffers.c @@ -1,6 +1,6 @@ #include -#include "sm64.h" +#include "config.h" // 0x70800 bytes #ifdef AVOID_UB diff --git a/src/buffers/framebuffers.h b/src/buffers/framebuffers.h index 35fb3467..d17f1fb7 100644 --- a/src/buffers/framebuffers.h +++ b/src/buffers/framebuffers.h @@ -1,6 +1,10 @@ #ifndef FRAMEBUFFERS_H #define FRAMEBUFFERS_H +#include + +#include "config.h" + // level_script.c assumes that the frame buffers are adjacent, while game.c's // -g codegen implies that they are separate variables. This is impossible to // reconcile without undefined behavior. Avoid that when possible. @@ -15,4 +19,4 @@ extern u16 gFrameBuffer1[SCREEN_WIDTH * SCREEN_HEIGHT]; extern u16 gFrameBuffer2[SCREEN_WIDTH * SCREEN_HEIGHT]; #endif -#endif +#endif // FRAMEBUFFERS_H diff --git a/src/buffers/gfx_output_buffer.c b/src/buffers/gfx_output_buffer.c index 60f3894b..d948d420 100644 --- a/src/buffers/gfx_output_buffer.c +++ b/src/buffers/gfx_output_buffer.c @@ -1,5 +1,12 @@ #include +#include "gfx_output_buffer.h" +#ifdef VERSION_EU +// 0x17e00 bytes, aligned to a 0x200-byte boundary through sm64.ld. The alignment +// wastes 0x100 bytes of space. +u64 gGfxSPTaskOutputBuffer[0x2fc0]; +#else // 0x1f000 bytes, aligned to a 0x1000-byte boundary through sm64.ld. (This results // in a bunch of unused space: ~0x100 in JP, ~0x300 in US.) u64 gGfxSPTaskOutputBuffer[0x3e00]; +#endif diff --git a/src/buffers/gfx_output_buffer.h b/src/buffers/gfx_output_buffer.h index cc5a423b..db693b23 100644 --- a/src/buffers/gfx_output_buffer.h +++ b/src/buffers/gfx_output_buffer.h @@ -1,6 +1,12 @@ #ifndef GFX_OUTPUT_BUFFER_H #define GFX_OUTPUT_BUFFER_H -extern u64 gGfxSPTaskOutputBuffer[0x3e00]; +#include +#ifdef VERSION_EU +extern u64 gGfxSPTaskOutputBuffer[0x2fc0]; +#else +extern u64 gGfxSPTaskOutputBuffer[0x3e00]; #endif + +#endif // GFX_OUTPUT_BUFFER_H diff --git a/src/buffers/zbuffer.c b/src/buffers/zbuffer.c index 148ab574..7c0ab6ec 100644 --- a/src/buffers/zbuffer.c +++ b/src/buffers/zbuffer.c @@ -1,5 +1,6 @@ #include +#include "config.h" #include "zbuffer.h" ALIGNED8 u16 gZBuffer[SCREEN_WIDTH * SCREEN_HEIGHT]; diff --git a/src/buffers/zbuffer.h b/src/buffers/zbuffer.h index dc3debaa..bb02f597 100644 --- a/src/buffers/zbuffer.h +++ b/src/buffers/zbuffer.h @@ -1,9 +1,11 @@ #ifndef ZBUFFER_H #define ZBUFFER_H -#include "types.h" +#include + #include "config.h" +#include "macros.h" extern u16 gZBuffer[SCREEN_WIDTH * SCREEN_HEIGHT]; -#endif +#endif // ZBUFFER_H diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index 539f3a32..f61f2bf4 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -1,16 +1,18 @@ #include #include "sm64.h" +#include "behavior_data.h" #include "behavior_script.h" +#include "game/area.h" +#include "game/behavior_actions.h" +#include "game/game_init.h" +#include "game/mario.h" #include "game/memory.h" +#include "game/obj_behaviors_2.h" +#include "game/object_helpers.h" +#include "game/object_list_processor.h" #include "graph_node.h" #include "surface_collision.h" -#include "game/object_helpers.h" -#include "game/mario.h" -#include "game/game_init.h" -#include "game/obj_behaviors_2.h" -#include "behavior_data.h" -#include "game/object_list_processor.h" // Macros for retrieving arguments from behavior scripts. #define BHV_CMD_GET_1ST_U8(index) (u8)((gCurBhvCommand[index] >> 24) & 0xFF) // unused @@ -63,7 +65,7 @@ u16 random_u16(void) { return gRandomSeed16; } -// Generate a pseudorandom float from 0 to 1. +// Generate a pseudorandom float in the range [0, 1). f32 random_float(void) { f32 rnd = random_u16(); return rnd / (double) 0x10000; @@ -203,7 +205,7 @@ static s32 bhv_cmd_spawn_child_with_param(void) { // Command 0x1D: Exits the behavior script and despawns the object. // Usage: DEACTIVATE() static s32 bhv_cmd_deactivate(void) { - gCurrentObject->activeFlags = 0; + gCurrentObject->activeFlags = ACTIVE_FLAG_DEACTIVATED; return BHV_PROC_BREAK; } diff --git a/src/engine/behavior_script.h b/src/engine/behavior_script.h index 23d98716..92ba1099 100644 --- a/src/engine/behavior_script.h +++ b/src/engine/behavior_script.h @@ -1,5 +1,7 @@ -#ifndef _BEHAVIOR_SCRIPT_H_ -#define _BEHAVIOR_SCRIPT_H_ +#ifndef BEHAVIOR_SCRIPT_H +#define BEHAVIOR_SCRIPT_H + +#include #define BHV_PROC_CONTINUE 0 #define BHV_PROC_BREAK 1 @@ -21,9 +23,8 @@ u16 random_u16(void); float random_float(void); s32 random_sign(void); -void obj_update_gfx_pos_and_angle(struct Object *); void stub_behavior_script_2(void); void cur_obj_update(void); -#endif /* _BEHAVIOR_SCRIPT_H_ */ +#endif // BEHAVIOR_SCRIPT_H diff --git a/src/engine/geo_layout.c b/src/engine/geo_layout.c index ce366177..d071d1a6 100644 --- a/src/engine/geo_layout.c +++ b/src/engine/geo_layout.c @@ -210,7 +210,7 @@ void geo_layout_cmd_node_root(void) { // number of entries to allocate for gGeoViews array // at least 2 are allocated by default - // cmd+0x02 = 0x00: mario face, 0x0A: all other levels + // cmd+0x02 = 0x00: Mario face, 0x0A: all other levels gGeoNumViews = cur_geo_cmd_s16(0x02) + 2; graphNode = init_graph_node_root(gGraphNodePool, NULL, 0, x, y, width, height); diff --git a/src/engine/geo_layout.h b/src/engine/geo_layout.h index cd9e7f41..6211e141 100644 --- a/src/engine/geo_layout.h +++ b/src/engine/geo_layout.h @@ -1,14 +1,18 @@ -#ifndef _GEO_LAYOUT_H_ -#define _GEO_LAYOUT_H_ +#ifndef GEO_LAYOUT_H +#define GEO_LAYOUT_H + +#include #include "game/memory.h" +#include "macros.h" +#include "types.h" #define GEO_CMD_FLAGS_RESET 0 #define GEO_CMD_FLAGS_SET 1 #define GEO_CMD_FLAGS_CLEAR 2 #define CMD_SIZE_SHIFT (sizeof(void *) >> 3) -#define CMD_PROCESS_OFFSET(offset) ((offset & 3) | ((offset & ~3) << CMD_SIZE_SHIFT)) +#define CMD_PROCESS_OFFSET(offset) (((offset) & 3) | (((offset) & ~3) << CMD_SIZE_SHIFT)) #define cur_geo_cmd_u8(offset) \ (gGeoLayoutCommand[CMD_PROCESS_OFFSET(offset)]) @@ -80,4 +84,4 @@ void geo_layout_cmd_node_culling_radius(void); struct GraphNode *process_geo_layout(struct AllocOnlyPool *a0, void *segptr); -#endif /* _GEO_LAYOUT_H_ */ +#endif // GEO_LAYOUT_H diff --git a/src/engine/graph_node.h b/src/engine/graph_node.h index c99e5f32..332522d5 100644 --- a/src/engine/graph_node.h +++ b/src/engine/graph_node.h @@ -1,29 +1,12 @@ -#ifndef _GRAPH_NODE_H_ -#define _GRAPH_NODE_H_ +#ifndef GRAPH_NODE_H +#define GRAPH_NODE_H + +#include +#include #include "types.h" #include "game/memory.h" -struct AllocOnlyPool; - -extern struct GraphNodeMasterList *gCurGraphNodeMasterList; -extern struct GraphNodePerspective *gCurGraphNodeCamFrustum; -extern struct GraphNodeCamera *gCurGraphNodeCamera; -extern struct GraphNodeHeldObject *gCurGraphNodeHeldObject; -extern u16 gAreaUpdateCounter; - -extern struct GraphNode *gCurRootGraphNode; -extern struct GraphNode *gCurGraphNodeList[]; - -extern s16 gCurGraphNodeIndex; - -extern struct GraphNode gObjParentGraphNode; - -extern Vec3f gVec3fZero; -extern Vec3s gVec3sZero; -extern Vec3f gVec3fOne; -extern Vec3s gVec3sOne; - #define GRAPH_RENDER_ACTIVE (1 << 0) #define GRAPH_RENDER_CHILDREN_FIRST (1 << 1) #define GRAPH_RENDER_BILLBOARD (1 << 2) @@ -250,7 +233,7 @@ struct GraphNodeRotation * data. This animation data is not stored in the node itself but in global * variables that are set when object nodes are processed if the object has * animation. - * Usef for Mario, enemies and anything else with animation data. + * Used for Mario, enemies and anything else with animation data. * The display list can be null, in which case it won't draw anything itself. */ struct GraphNodeAnimatedPart @@ -333,7 +316,7 @@ struct GraphNodeGenerated }; /** GraphNode that draws a background image or a rectangle of a color. - * Drawn in an orthgraphic projection, used for skyboxes. + * Drawn in an orthographic projection, used for skyboxes. */ struct GraphNodeBackground { @@ -354,84 +337,99 @@ struct GraphNodeHeldObject /** A node that allows an object to specify a different culling radius than the * default one of 300. For this to work, it needs to be a direct child of the - * object node. Used for very large objects, such as shockwave rings that Bowser - * creates, tornados, the big eel. + * object node. Used for very large objects, such as shock wave rings that Bowser + * creates, tornadoes, the big eel. */ struct GraphNodeCullingRadius { /*0x00*/ struct GraphNode node; - /*0x14*/ s16 cullingRadius; // specifies the 'sphere radius' for purposes of frustrum culling + /*0x14*/ s16 cullingRadius; // specifies the 'sphere radius' for purposes of frustum culling u8 pad1E[2]; }; -void init_scene_graph_node_links(struct GraphNode *, s32); +extern struct GraphNodeMasterList *gCurGraphNodeMasterList; +extern struct GraphNodePerspective *gCurGraphNodeCamFrustum; +extern struct GraphNodeCamera *gCurGraphNodeCamera; +extern struct GraphNodeHeldObject *gCurGraphNodeHeldObject; +extern u16 gAreaUpdateCounter; -struct GraphNodeRoot *init_graph_node_root(struct AllocOnlyPool *, struct GraphNodeRoot *, - s16, s16 x, s16 y, s16 width, s16 height); -struct GraphNodeOrthoProjection *init_graph_node_ortho_projection(struct AllocOnlyPool *, struct GraphNodeOrthoProjection *, f32); -struct GraphNodePerspective *init_graph_node_perspective(struct AllocOnlyPool *pool, struct GraphNodePerspective *sp1c, - f32 sp20, s16 sp26, s16 sp2a, GraphNodeFunc sp2c, s32 sp30); -struct GraphNodeStart *init_graph_node_start(struct AllocOnlyPool *pool, struct GraphNodeStart *sp1c); -struct GraphNodeMasterList *init_graph_node_master_list(struct AllocOnlyPool *pool, struct GraphNodeMasterList *, s16 sp22); +extern struct GraphNode *gCurRootGraphNode; +extern struct GraphNode *gCurGraphNodeList[]; + +extern s16 gCurGraphNodeIndex; + +extern Vec3f gVec3fZero; +extern Vec3s gVec3sZero; +extern Vec3f gVec3fOne; +extern Vec3s gVec3sOne; + +void init_scene_graph_node_links(struct GraphNode *graphNode, s32 type); + +struct GraphNodeRoot *init_graph_node_root(struct AllocOnlyPool *pool, struct GraphNodeRoot *graphNode, + s16 areaIndex, s16 x, s16 y, s16 width, s16 height); +struct GraphNodeOrthoProjection *init_graph_node_ortho_projection(struct AllocOnlyPool *pool, struct GraphNodeOrthoProjection *graphNode, f32 scale); +struct GraphNodePerspective *init_graph_node_perspective(struct AllocOnlyPool *pool, struct GraphNodePerspective *graphNode, + f32 fov, s16 near, s16 far, GraphNodeFunc nodeFunc, s32 unused); +struct GraphNodeStart *init_graph_node_start(struct AllocOnlyPool *pool, struct GraphNodeStart *graphNode); +struct GraphNodeMasterList *init_graph_node_master_list(struct AllocOnlyPool *pool, struct GraphNodeMasterList *graphNode, s16 on); struct GraphNodeLevelOfDetail *init_graph_node_render_range(struct AllocOnlyPool *pool, struct GraphNodeLevelOfDetail *graphNode, - s16 minDistance, s16 maxDistance); + s16 minDistance, s16 maxDistance); struct GraphNodeSwitchCase *init_graph_node_switch_case(struct AllocOnlyPool *pool, struct GraphNodeSwitchCase *graphNode, - s16 numCases, s16 sp26, GraphNodeFunc nodeFunc, s32 sp2c); -struct GraphNodeCamera *init_graph_node_camera(struct AllocOnlyPool *pool, struct GraphNodeCamera * sp1c, - f32 *sp20, f32 *sp24, GraphNodeFunc sp28, s32 sp2c); -struct GraphNodeTranslationRotation *init_graph_node_translation_rotation(struct AllocOnlyPool *pool, - struct GraphNodeTranslationRotation *graphNode, s32 drawingLayer, void *displayList, Vec3s sp28, Vec3s sp2c); + s16 numCases, s16 selectedCase, GraphNodeFunc nodeFunc, s32 unused); +struct GraphNodeCamera *init_graph_node_camera(struct AllocOnlyPool *pool, struct GraphNodeCamera *graphNode, + f32 *pos, f32 *focus, GraphNodeFunc func, s32 mode); +struct GraphNodeTranslationRotation *init_graph_node_translation_rotation(struct AllocOnlyPool *pool, struct GraphNodeTranslationRotation *graphNode, + s32 drawingLayer, void *displayList, Vec3s translation, Vec3s rotation); struct GraphNodeTranslation *init_graph_node_translation(struct AllocOnlyPool *pool, struct GraphNodeTranslation *graphNode, - s32 drawingLayer, void *displayList, Vec3s sp28); + s32 drawingLayer, void *displayList, Vec3s translation); struct GraphNodeRotation *init_graph_node_rotation(struct AllocOnlyPool *pool, struct GraphNodeRotation *graphNode, - s32 drawingLayer, void *displayList, Vec3s sp28); -struct GraphNodeScale *init_graph_node_scale(struct AllocOnlyPool *pool, - struct GraphNodeScale *graphNode, s32 drawingLayer, void *displayList, f32 sp28); + s32 drawingLayer, void *displayList, Vec3s rotation); +struct GraphNodeScale *init_graph_node_scale(struct AllocOnlyPool *pool, struct GraphNodeScale *graphNode, + s32 drawingLayer, void *displayList, f32 scale); struct GraphNodeObject *init_graph_node_object(struct AllocOnlyPool *pool, struct GraphNodeObject *graphNode, - struct GraphNode *sp20, Vec3f pos, Vec3s angle, Vec3f scale); -struct GraphNodeCullingRadius *init_graph_node_culling_radius(struct AllocOnlyPool *pool, struct GraphNodeCullingRadius *sp1c, - s16 sp22); + struct GraphNode *sharedChild, Vec3f pos, Vec3s angle, Vec3f scale); +struct GraphNodeCullingRadius *init_graph_node_culling_radius(struct AllocOnlyPool *pool, struct GraphNodeCullingRadius *graphNode, s16 radius); struct GraphNodeAnimatedPart *init_graph_node_animated_part(struct AllocOnlyPool *pool, struct GraphNodeAnimatedPart *graphNode, - s32 drawingLayer, void *displayList, Vec3s relativePos); -struct GraphNodeBillboard *init_graph_node_billboard(struct AllocOnlyPool *pool, - struct GraphNodeBillboard *graphNode, s32 drawingLayer, void *displayList, Vec3s sp28); + s32 drawingLayer, void *displayList, Vec3s translation); +struct GraphNodeBillboard *init_graph_node_billboard(struct AllocOnlyPool *pool, struct GraphNodeBillboard *graphNode, + s32 drawingLayer, void *displayList, Vec3s translation); struct GraphNodeDisplayList *init_graph_node_display_list(struct AllocOnlyPool *pool, struct GraphNodeDisplayList *graphNode, - s32 drawingLayer, void *displayList); -struct GraphNodeShadow *init_graph_node_shadow(struct AllocOnlyPool *pool, struct GraphNodeShadow *sp1c, - s16 sp22, u8 sp27, u8 sp2b); + s32 drawingLayer, void *displayList); +struct GraphNodeShadow *init_graph_node_shadow(struct AllocOnlyPool *pool, struct GraphNodeShadow *graphNode, + s16 shadowScale, u8 shadowSolidity, u8 shadowType); struct GraphNodeObjectParent *init_graph_node_object_parent(struct AllocOnlyPool *pool, struct GraphNodeObjectParent *sp1c, - struct GraphNode *sp20); + struct GraphNode *sharedChild); struct GraphNodeGenerated *init_graph_node_generated(struct AllocOnlyPool *pool, struct GraphNodeGenerated *sp1c, - GraphNodeFunc sp20, s32 sp24); + GraphNodeFunc gfxFunc, s32 parameter); struct GraphNodeBackground *init_graph_node_background(struct AllocOnlyPool *pool, struct GraphNodeBackground *sp1c, - u16 sp22, GraphNodeFunc sp24, s32 sp28); + u16 background, GraphNodeFunc backgroundFunc, s32 zero); struct GraphNodeHeldObject *init_graph_node_held_object(struct AllocOnlyPool *pool, struct GraphNodeHeldObject *sp1c, - struct Object *objNode, Vec3s translation, GraphNodeFunc nodeFunc, s32 playerIndex); + struct Object *objNode, Vec3s translation, + GraphNodeFunc nodeFunc, s32 playerIndex); +struct GraphNode *geo_add_child(struct GraphNode *parent, struct GraphNode *childNode); +struct GraphNode *geo_remove_child(struct GraphNode *graphNode); +struct GraphNode *geo_make_first_child(struct GraphNode *newFirstChild); -struct GraphNode *geo_add_child(struct GraphNode *, struct GraphNode *); -struct GraphNode *geo_remove_child(struct GraphNode *); -struct GraphNode *geo_make_first_child(struct GraphNode *a0); +void geo_call_global_function_nodes_helper(struct GraphNode *graphNode, s32 callContext); +void geo_call_global_function_nodes(struct GraphNode *graphNode, s32 callContext); -void geo_call_global_function_nodes_helper(struct GraphNode *, s32); -void geo_call_global_function_nodes(struct GraphNode *graphNode, s32 sp1c); - -void geo_reset_object_node(struct GraphNodeObject *sp20); -void geo_obj_init(struct GraphNodeObject *sp18, void *sp1c, Vec3f sp20, Vec3s sp24); -void geo_obj_init_spawninfo(struct GraphNodeObject *sp18, struct SpawnInfo *sp1c); +void geo_reset_object_node(struct GraphNodeObject *graphNode); +void geo_obj_init(struct GraphNodeObject *graphNode, void *sharedChild, Vec3f pos, Vec3s angle); +void geo_obj_init_spawninfo(struct GraphNodeObject *graphNode, struct SpawnInfo *spawn); void geo_obj_init_animation(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr); void geo_obj_init_animation_accel(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr, u32 animAccel); -s32 retrieve_animation_index(s32 a0, u16 **a1); +s32 retrieve_animation_index(s32 frame, u16 **attributes); -s16 geo_update_animation_frame(struct GraphNodeObject_sub *a0, s32* a1); -void geo_retreive_animation_translation(struct GraphNodeObject *sp28, Vec3f sp2c); +s16 geo_update_animation_frame(struct GraphNodeObject_sub *obj, s32 *accelAssist); +void geo_retreive_animation_translation(struct GraphNodeObject *obj, Vec3f position); struct GraphNodeRoot *geo_find_root(struct GraphNode *graphNode); +// graph_node_manager s16 *read_vec3s_to_vec3f(Vec3f, s16 *src); s16 *read_vec3s(Vec3s dst, s16 *src); s16 *read_vec3s_angle(Vec3s dst, s16 *src); +void register_scene_graph_node(struct GraphNode *graphNode); -void register_scene_graph_node(struct GraphNode *); - -#endif /* _GRAPH_NODE_H_ */ +#endif // GRAPH_NODE_H diff --git a/src/engine/graph_node_manager.c b/src/engine/graph_node_manager.c index 6cc8939c..20af9835 100644 --- a/src/engine/graph_node_manager.c +++ b/src/engine/graph_node_manager.c @@ -1,13 +1,8 @@ -#include -#include "sm64.h" +#include + +#include "types.h" -#include "game/level_update.h" -#include "math_util.h" -#include "game/memory.h" #include "graph_node.h" -#include "game/rendering_graph_node.h" -#include "game/area.h" -#include "geo_layout.h" #if IS_64_BIT static s16 next_s16_in_geo_script(s16 **src) { diff --git a/src/engine/level_script.c b/src/engine/level_script.c index 64e4d46e..b623c7f1 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -1,7 +1,6 @@ #include #include - #include "sm64.h" #include "audio/external.h" #include "buffers/framebuffers.h" @@ -19,14 +18,12 @@ #include "geo_layout.h" #include "graph_node.h" #include "level_script.h" +#include "level_misc_macros.h" #include "math_util.h" #include "surface_collision.h" #include "surface_load.h" #include "level_table.h" -#define CMD_SIZE_SHIFT (sizeof(void *) >> 3) -#define CMD_PROCESS_OFFSET(offset) ((offset & 3) | ((offset & ~3) << CMD_SIZE_SHIFT)) - #define CMD_GET(type, offset) (*(type *) (CMD_PROCESS_OFFSET(offset) + (u8 *) sCurrentCmd)) // These are equal @@ -356,7 +353,7 @@ static void level_cmd_begin_area(void) { sCurrAreaIndex = areaIndex; screenArea->areaIndex = areaIndex; - gAreas[areaIndex].unk04 = (struct GraphNode *) screenArea; + gAreas[areaIndex].unk04 = screenArea; if (node != NULL) { gAreas[areaIndex].camera = (struct Camera *) node->config.camera; @@ -604,15 +601,14 @@ static void level_cmd_set_gamma(void) { static void level_cmd_set_terrain_data(void) { if (sCurrAreaIndex != -1) { - Collision *data; u32 size; + // The game modifies the terrain data and must be reset upon level reload. data = segmented_to_virtual(CMD_GET(void *, 4)); size = get_area_terrain_size(data) * sizeof(Collision); gAreas[sCurrAreaIndex].terrainData = alloc_only_pool_alloc(sLevelPool, size); memcpy(gAreas[sCurrAreaIndex].terrainData, data, size); - } sCurrentCmd = CMD_NEXT; } @@ -626,15 +622,15 @@ static void level_cmd_set_rooms(void) { static void level_cmd_set_macro_objects(void) { if (sCurrAreaIndex != -1) { - + // The game modifies the macro object data (for example marking coins as taken), + // so it must be reset when the level reloads. MacroObject *data = segmented_to_virtual(CMD_GET(void *, 4)); s32 len = 0; - while (data[len++] != 0x001E) { + while (data[len++] != MACRO_OBJECT_END()) { len += 4; } gAreas[sCurrAreaIndex].macroObjects = alloc_only_pool_alloc(sLevelPool, len * sizeof(MacroObject)); memcpy(gAreas[sCurrAreaIndex].macroObjects, data, len * sizeof(MacroObject)); - } sCurrentCmd = CMD_NEXT; } diff --git a/src/engine/level_script.h b/src/engine/level_script.h index 89bfb4ed..d41a91c8 100644 --- a/src/engine/level_script.h +++ b/src/engine/level_script.h @@ -1,8 +1,12 @@ -#ifndef _LEVEL_SCRIPT_H -#define _LEVEL_SCRIPT_H +#ifndef LEVEL_SCRIPT_H +#define LEVEL_SCRIPT_H -struct LevelCommand *level_script_execute(struct LevelCommand *cmd); +#include + +struct LevelCommand; extern u8 level_script_entry[]; -#endif /* _LEVEL_SCRIPT_H */ +struct LevelCommand *level_script_execute(struct LevelCommand *cmd); + +#endif // LEVEL_SCRIPT_H diff --git a/src/engine/math_util.c b/src/engine/math_util.c index 3f027ed5..ca2a7457 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -377,7 +377,8 @@ void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) { dest[3][3] = 1; } -void mtxf_cylboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) { //straight up mtxf_billboard but minus the dest[1][n] lines. transform for cylindrical billboards +// straight up mtxf_billboard but minus the dest[1][n] lines. transform for cylindrical billboards +void mtxf_cylboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) { dest[0][0] = coss(angle); dest[0][1] = sins(angle); dest[0][2] = 0; @@ -603,7 +604,7 @@ void mtxf_mul_vec3s(Mat4 mtx, Vec3s b) { * Convert float matrix 'src' to fixed point matrix 'dest'. * The float matrix may not contain entries larger than 65536 or the console * crashes. The fixed point matrix has entries with a 16-bit integer part, so - * the floating point numbers are multipled by 2^16 before being cast to a s32 + * the floating point numbers are multiplied by 2^16 before being cast to a s32 * integer. If this doesn't fit, the N64 and iQue consoles will throw an * exception. On Wii and Wii U Virtual Console the value will simply be clamped * and no crashes occur. @@ -804,7 +805,7 @@ f32 atan2f(f32 y, f32 x) { * value t in [0, 1] and gSplineState. Given the current control point P, these * weights are for P[0], P[1], P[2] and P[3] to obtain an interpolated point. * The weights naturally sum to 1, and they are also always in range [0, 1] so - * the inteprolated point will never overshoot. The curve is guaranteed to go + * the interpolated point will never overshoot. The curve is guaranteed to go * through the first and last point, but not through intermediate points. * * gSplineState ensures that the curve is clamped: the first two points @@ -866,7 +867,7 @@ void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c) { /** * Initialize a spline animation. - * 'keyframes' should be an array of (s, x, y, z) vectors + * 'keyFrames' should be an array of (s, x, y, z) vectors * s: the speed of the keyframe in 1000/frames, e.g. s=100 means the keyframe lasts 10 frames * (x, y, z): point in 3D space on the curve * The array should end with three entries with s=0 (infinite keyframe duration). diff --git a/src/engine/math_util.h b/src/engine/math_util.h index f28799d2..00245064 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -1,5 +1,8 @@ -#ifndef _MATH_UTIL_H_ -#define _MATH_UTIL_H_ +#ifndef MATH_UTIL_H +#define MATH_UTIL_H + +#include + #include "types.h" /* @@ -51,30 +54,30 @@ void *vec3f_cross(Vec3f dest, Vec3f a, Vec3f b); void *vec3f_normalize(Vec3f dest); f32 vec3f_length(Vec3f a); f32 vec3f_dot(Vec3f a, Vec3f b); -void mtxf_copy(f32 dest[4][4], f32 src[4][4]); -void mtxf_identity(f32 mtx[4][4]); -void mtxf_translate(f32 a[4][4], Vec3f b); -void mtxf_lookat(f32 mtx[4][4], Vec3f b, Vec3f c, s16 d); -void mtxf_rotate_zxy_and_translate(f32 mtx[4][4], Vec3f b, Vec3s c); -void mtxf_rotate_xyz_and_translate(f32 mtx[4][4], Vec3f b, Vec3s c); -void mtxf_billboard(f32 mtx1[4][4], f32 mtx2[4][4], Vec3f c, s16 d); -void mtxf_cylboard(f32 mtx1[4][4], f32 mtx2[4][4], Vec3f c, s16 d); -void mtxf_align_terrain_normal(f32 mtx[4][4], Vec3f b, Vec3f c, s16 d); -void mtxf_align_terrain_triangle(f32 mtx[4][4], Vec3f b, s16 c, f32 d); -void mtxf_mul(f32 dest[4][4], f32 a[4][4], f32 b[4][4]); -void mtxf_scale_vec3f(f32 a[4][4], f32 b[4][4], Vec3f c); -void mtxf_mul_vec3s(f32 a[4][4], Vec3s b); -void mtxf_to_mtx(Mtx *a, f32 b[4][4]); -void mtxf_rotate_xy(Mtx *a, s16 b); -void get_pos_from_transform_mtx(Vec3f a, f32 b[4][4], f32 c[4][4]); +void mtxf_copy(Mat4 dest, Mat4 src); +void mtxf_identity(Mat4 mtx); +void mtxf_translate(Mat4 dest, Vec3f b); +void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll); +void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f translate, Vec3s rotate); +void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f b, Vec3s c); +void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle); +void mtxf_cylboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle); +void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw); +void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius); +void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b); +void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s); +void mtxf_mul_vec3s(Mat4 mtx, Vec3s b); +void mtxf_to_mtx(Mtx *dest, Mat4 src); +void mtxf_rotate_xy(Mtx *mtx, s16 angle); +void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx); void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw); void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw); s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec); f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec); -s16 atan2s(f32 a, f32 b); +s16 atan2s(f32 y, f32 x); f32 atan2f(f32 a, f32 b); -void spline_get_weights(Vec4f a, f32 b, UNUSED s32 c); -void anim_spline_init(Vec4s *a); -s32 anim_spline_poll(Vec3f a); +void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c); +void anim_spline_init(Vec4s *keyFrames); +s32 anim_spline_poll(Vec3f result); -#endif +#endif // MATH_UTIL_H diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index c0e97dda..5b6775fe 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -1,18 +1,16 @@ -#include +#include #include "sm64.h" -#include "game/level_update.h" #include "game/debug.h" -#include "game/camera.h" +#include "game/level_update.h" #include "game/mario.h" -#include "behavior_script.h" +#include "game/object_list_processor.h" #include "surface_collision.h" #include "surface_load.h" -#include "game/object_list_processor.h" #include "math_util.h" /************************************************** - * WALLS * + * WALLS * **************************************************/ /** @@ -220,14 +218,13 @@ s32 find_wall_collisions(struct WallCollisionData *colData) { } /************************************************** - * CEILINGS * + * CEILINGS * **************************************************/ /** * Iterate through the list of ceilings and find the first ceiling over a given point. */ -static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32 x, s32 y, s32 z, - f32 *pheight) { +static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32 x, s32 y, s32 z, f32 *pheight) { register struct Surface *surf; register s32 x1, z1, x2, z2, x3, z3; struct Surface *ceil = NULL; @@ -356,7 +353,7 @@ f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil) { } /************************************************** - * FLOORS * + * FLOORS * **************************************************/ /** @@ -400,8 +397,7 @@ f32 find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct FloorGeometr /** * Iterate through the list of floors and find the first floor under a given point. */ -static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32 x, s32 y, s32 z, - f32 *pheight) { +static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32 x, s32 y, s32 z, f32 *pheight) { register struct Surface *surf; register s32 x1, z1, x2, z2, x3, z3; f32 nx, ny, nz; @@ -485,7 +481,7 @@ f32 find_floor_height(f32 x, f32 y, f32 z) { } /** - * Find the highest dynamic floor under a given position. Perhaps originally static and + * Find the highest dynamic floor under a given position. Perhaps originally static * and dynamic floors were checked separately. */ f32 unused_find_dynamic_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) { @@ -585,7 +581,7 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) { } /************************************************** - * ENVIRONMENTAL BOXES * + * ENVIRONMENTAL BOXES * **************************************************/ /** @@ -664,7 +660,7 @@ f32 find_poison_gas_level(f32 x, f32 z) { } /************************************************** - * DEBUG * + * DEBUG * **************************************************/ /** @@ -742,7 +738,7 @@ void debug_surface_list_info(f32 xPos, f32 zPos) { * Perhaps an original implementation of surfaces before they were more specialized. */ s32 unused_resolve_floor_or_ceil_collisions(s32 checkCeil, f32 *px, f32 *py, f32 *pz, f32 radius, - struct Surface **psurface, f32 *surfaceHeight) { + struct Surface **psurface, f32 *surfaceHeight) { f32 nx, ny, nz, oo; f32 x = *px; f32 y = *py; diff --git a/src/engine/surface_collision.h b/src/engine/surface_collision.h index 6e79dca5..6332c481 100644 --- a/src/engine/surface_collision.h +++ b/src/engine/surface_collision.h @@ -1,5 +1,9 @@ -#ifndef _SURFACE_COLLISION_H -#define _SURFACE_COLLISION_H +#ifndef SURFACE_COLLISION_H +#define SURFACE_COLLISION_H + +#include + +#include "types.h" #define LEVEL_BOUNDARY_MAX 0x2000 #define CELL_SIZE 0x400 @@ -34,4 +38,4 @@ f32 find_poison_gas_level(f32 x, f32 z); void debug_surface_list_info(f32 xPos, f32 zPos); void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos); -#endif /* _SURFACE_COLLISION_H */ +#endif // SURFACE_COLLISION_H diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index 7a7da511..ac2ee50c 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -1,4 +1,4 @@ -#include +#include #include "prevent_bss_reordering.h" @@ -491,8 +491,7 @@ static s16 *read_vertex_data(s16 **data) { } /** - * Loads in special environmental regions, such as water, - * poison gas, and JRB fog. + * Loads in special environmental regions, such as water, poison gas, and JRB fog. */ static void load_environmental_regions(s16 **data) { s32 numRegions; @@ -581,6 +580,7 @@ u32 get_area_terrain_size(s16 *data) { return data - startPos; } + /** * Process the level file, loading in vertices, surfaces, some objects, and environmental * boxes (water, gas, JRB fog). @@ -598,7 +598,7 @@ void load_area_terrain(s16 index, s16 *data, s8 *surfaceRooms, s16 *macroObjects clear_static_surfaces(); - // A while loop interating through each section of the level data. Sections of data + // A while loop iterating through each section of the level data. Sections of data // are prefixed by a terrain "type." This type is reused for surfaces as the surface // type. while (TRUE) { @@ -655,7 +655,7 @@ static void unused_80383604(void) { } /** - * Applies an object's tranformation to the object's vertices. + * Applies an object's transformation to the object's vertices. */ void transform_object_vertices(s16 **data, s16 *vertexData) { register s16 *vertices; @@ -695,8 +695,7 @@ void transform_object_vertices(s16 **data, s16 *vertexData) { } /** - * Load in the surfaces for the gCurrentObject. This includes setting the flags, - * exertion, and room. + * Load in the surfaces for the gCurrentObject. This includes setting the flags, exertion, and room. */ void load_object_surfaces(s16 **data, s16 *vertexData) { s32 surfaceType; diff --git a/src/engine/surface_load.h b/src/engine/surface_load.h index b8637be4..7d541361 100644 --- a/src/engine/surface_load.h +++ b/src/engine/surface_load.h @@ -1,5 +1,7 @@ -#ifndef _SURFACE_LOAD_H -#define _SURFACE_LOAD_H +#ifndef SURFACE_LOAD_H +#define SURFACE_LOAD_H + +#include #include "types.h" @@ -35,4 +37,4 @@ void load_area_terrain(s16 index, s16 *data, s8 *surfaceRooms, s16 *macroObjects void clear_dynamic_surfaces(void); void load_object_collision_model(void); -#endif +#endif // SURFACE_LOAD_H diff --git a/src/game/area.c b/src/game/area.c index d408190c..ba7768a4 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -1,5 +1,6 @@ -#include +#include +#include "prevent_bss_reordering.h" #include "area.h" #include "sm64.h" #include "gfx_dimensions.h" @@ -52,7 +53,7 @@ u8 gWarpTransBlue = 0; s16 gCurrSaveFileNum = 1; s16 gCurrLevelNum = LEVEL_MIN; -/* +/* * The following two tables are used in get_mario_spawn_type() to determine spawn type * from warp behavior. * When looping through sWarpBhvSpawnTable, if the behavior function in the table matches @@ -61,20 +62,20 @@ s16 gCurrLevelNum = LEVEL_MIN; // D_8032CE9C const BehaviorScript *sWarpBhvSpawnTable[] = { - bhvDoorWarp, bhvStar, bhvExitPodiumWarp, bhvWarp, - bhvWarpPipe, bhvFadingWarp, bhvWarps60, bhvWarps64, - bhvWarps68, bhvWarps6C, bhvDeathWarp, bhvWarps74, - bhvWarps78, bhvWarps94, bhvWarps7C, bhvPaintingDeathWarp, - bhvWarps88, bhvWarps84, bhvWarps8C, bhvWarps90, + bhvDoorWarp, bhvStar, bhvExitPodiumWarp, bhvWarp, + bhvWarpPipe, bhvFadingWarp, bhvInstantActiveWarp, bhvAirborneWarp, + bhvHardAirKnockBackWarp, bhvSpinAirborneCircleWarp, bhvDeathWarp, bhvSpinAirborneWarp, + bhvFlyingWarp, bhvSwimmingWarp, bhvPaintingStarCollectWarp, bhvPaintingDeathWarp, + bhvAirborneStarCollectWarp, bhvAirborneDeathWarp, bhvLaunchStarCollectWarp, bhvLaunchDeathWarp, }; // D_8032CEEC u8 sSpawnTypeFromWarpBhv[] = { - MARIO_SPAWN_UNKNOWN_01, MARIO_SPAWN_UNKNOWN_02, MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_UNKNOWN_03, - MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_UNKNOWN_04, MARIO_SPAWN_UNKNOWN_10, MARIO_SPAWN_UNKNOWN_12, - MARIO_SPAWN_UNKNOWN_13, MARIO_SPAWN_UNKNOWN_14, MARIO_SPAWN_DEATH, MARIO_SPAWN_UNKNOWN_16, - MARIO_SPAWN_UNKNOWN_17, MARIO_SPAWN_UNKNOWN_11, MARIO_SPAWN_UNKNOWN_20, MARIO_SPAWN_PAINTING_DEATH, - MARIO_SPAWN_UNKNOWN_22, MARIO_SPAWN_UNKNOWN_23, MARIO_SPAWN_UNKNOWN_24, MARIO_SPAWN_UNKNOWN_25, + MARIO_SPAWN_DOOR_WARP, MARIO_SPAWN_UNKNOWN_02, MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_UNKNOWN_03, + MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_TELEPORT, MARIO_SPAWN_INSTANT_ACTIVE, MARIO_SPAWN_AIRBORNE, + MARIO_SPAWN_HARD_AIR_KNOCKBACK, MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE, MARIO_SPAWN_DEATH, MARIO_SPAWN_SPIN_AIRBORNE, + MARIO_SPAWN_FLYING, MARIO_SPAWN_SWIMMING, MARIO_SPAWN_PAINTING_STAR_COLLECT, MARIO_SPAWN_PAINTING_DEATH, + MARIO_SPAWN_AIRBORNE_STAR_COLLECT, MARIO_SPAWN_AIRBORNE_DEATH, MARIO_SPAWN_LAUNCH_STAR_COLLECT, MARIO_SPAWN_LAUNCH_DEATH, }; Vp D_8032CF00 = { { @@ -170,7 +171,7 @@ void load_obj_warp_nodes(void) { do { struct Object *sp1C = sp20; - if (sp1C->activeFlags && get_mario_spawn_type(sp1C) != 0) { + if (sp1C->activeFlags != ACTIVE_FLAG_DEACTIVATED && get_mario_spawn_type(sp1C) != 0) { sp24 = area_get_warp_node_from_params(sp1C); if (sp24 != NULL) { sp24->object = sp1C; @@ -215,14 +216,14 @@ void clear_area_graph_nodes(void) { s32 i; if (gCurrentArea != NULL) { - geo_call_global_function_nodes(gCurrentArea->unk04, GEO_CONTEXT_AREA_UNLOAD); + geo_call_global_function_nodes(&gCurrentArea->unk04->node, GEO_CONTEXT_AREA_UNLOAD); gCurrentArea = NULL; gWarpTransition.isActive = FALSE; } for (i = 0; i < 8; i++) { if (gAreaData[i].unk04 != NULL) { - geo_call_global_function_nodes(gAreaData[i].unk04, GEO_CONTEXT_AREA_INIT); + geo_call_global_function_nodes(&gAreaData[i].unk04->node, GEO_CONTEXT_AREA_INIT); gAreaData[i].unk04 = NULL; } } @@ -243,14 +244,14 @@ void load_area(s32 index) { } load_obj_warp_nodes(); - geo_call_global_function_nodes(gCurrentArea->unk04, GEO_CONTEXT_AREA_LOAD); + geo_call_global_function_nodes(&gCurrentArea->unk04->node, GEO_CONTEXT_AREA_LOAD); } } void unload_area(void) { if (gCurrentArea != NULL) { unload_objects_from_area(0, gCurrentArea->index); - geo_call_global_function_nodes(gCurrentArea->unk04, GEO_CONTEXT_AREA_UNLOAD); + geo_call_global_function_nodes(&gCurrentArea->unk04->node, GEO_CONTEXT_AREA_UNLOAD); gCurrentArea->flags = 0; gCurrentArea = NULL; @@ -339,7 +340,7 @@ void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue) { if (transType & 1) // Is the image fading in? { - gWarpTransition.data.startTexRadius = SCREEN_WIDTH; + gWarpTransition.data.startTexRadius = GFX_DIMENSIONS_FULL_RADIUS; if (transType >= 0x0F) { gWarpTransition.data.endTexRadius = 16; } else { @@ -352,7 +353,7 @@ void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue) { } else { gWarpTransition.data.startTexRadius = 0; } - gWarpTransition.data.endTexRadius = SCREEN_WIDTH; + gWarpTransition.data.endTexRadius = GFX_DIMENSIONS_FULL_RADIUS; } } } @@ -388,7 +389,7 @@ void render_game(void) { if (gPauseScreenMode != 0) { gSaveOptSelectIndex = gPauseScreenMode; } - + if (D_8032CE78 != NULL) { make_viewport_clip_rect(D_8032CE78); } else diff --git a/src/game/area.h b/src/game/area.h index 2452d86f..d746caa7 100644 --- a/src/game/area.h +++ b/src/game/area.h @@ -1,7 +1,11 @@ -#ifndef _AREA_H -#define _AREA_H +#ifndef AREA_H +#define AREA_H + +#include #include "types.h" +#include "camera.h" +#include "engine/graph_node.h" struct WarpNode { @@ -61,7 +65,7 @@ struct Area /*0x00*/ s8 index; /*0x01*/ s8 flags; // Only has 1 flag: 0x01 = Is this the active area? /*0x02*/ u16 terrainType; // default terrain of the level (set from level script cmd 0x31) - /*0x04*/ struct GraphNode *unk04; // geometry layout data + /*0x04*/ struct GraphNodeRoot *unk04; // geometry layout data /*0x08*/ s16 *terrainData; // collision data (set from level script cmd 0x2E) /*0x0C*/ s8 *surfaceRooms; // (set from level script cmd 0x2F) /*0x10*/ s16 *macroObjects; // Macro Objects Ptr (set from level script cmd 0x39) @@ -114,6 +118,7 @@ struct WarpTransition /*0x04*/ struct WarpTransitionData data; }; +extern struct GraphNode **gLoadedGraphNodes; extern struct SpawnInfo gPlayerSpawnInfos[]; extern struct GraphNode *D_8033A160[]; extern struct Area gAreaData[]; @@ -150,5 +155,4 @@ void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue); void play_transition_after_delay(s16 transType, s16 time, u8 red, u8 green, u8 blue, s16 delay); void render_game(void); - -#endif +#endif // AREA_H diff --git a/src/game/behavior_actions.c b/src/game/behavior_actions.c index 35fa3ed1..246d2334 100644 --- a/src/game/behavior_actions.c +++ b/src/game/behavior_actions.c @@ -1,40 +1,46 @@ -#include +#include -#include "sm64.h" #include "types.h" +#include "actors/common1.h" +#include "actors/group12.h" +#include "actors/group13.h" +#include "area.h" +#include "audio/external.h" #include "behavior_actions.h" -#include "game_init.h" -#include "main.h" -#include "mario.h" -#include "engine/behavior_script.h" -#include "engine/math_util.h" -#include "object_helpers.h" #include "behavior_data.h" -#include "obj_behaviors.h" +#include "camera.h" +#include "debug.h" +#include "dialog_ids.h" +#include "engine/behavior_script.h" +#include "engine/graph_node.h" +#include "engine/math_util.h" #include "engine/surface_collision.h" #include "engine/surface_load.h" +#include "game_init.h" +#include "ingame_menu.h" +#include "interaction.h" +#include "level_table.h" #include "level_update.h" -#include "audio/external.h" -#include "seq_ids.h" -#include "dialog_ids.h" -#include "save_file.h" -#include "area.h" -#include "engine/graph_node.h" -#include "camera.h" -#include "spawn_object.h" +#include "levels/bob/header.h" +#include "levels/castle_inside/header.h" +#include "levels/hmc/header.h" +#include "main.h" +#include "mario.h" #include "mario_actions_cutscene.h" -#include "object_list_processor.h" -#include "spawn_sound.h" -#include "debug.h" -#include "object_constants.h" #include "mario_step.h" +#include "obj_behaviors.h" #include "obj_behaviors_2.h" +#include "object_constants.h" +#include "object_helpers.h" +#include "object_list_processor.h" #include "paintings.h" #include "platform_displacement.h" -#include "interaction.h" -#include "ingame_menu.h" #include "rendering_graph_node.h" -#include "level_table.h" +#include "save_file.h" +#include "seq_ids.h" +#include "sm64.h" +#include "spawn_object.h" +#include "spawn_sound.h" #include "thread6.h" #define o gCurrentObject @@ -79,31 +85,12 @@ struct Struct8032F754 { f32 unk2; }; -struct Struct8032FCE8 { - s16 unk0; - s16 unk1; - void *unk2; +struct OpenableGrill { + s16 halfWidth; + s16 modelID; + const Collision *collision; }; -extern void bhv_pole_base_loop(); -extern s16 gDebugInfo[][8]; -extern s8 gDoorAdjacentRooms[][2]; -extern u8 inside_castle_seg7_collision_ddd_warp_2[]; -extern u8 inside_castle_seg7_collision_ddd_warp[]; -extern s32 gDialogResponse; -extern s32 gObjCutsceneDone; -extern u8 gRecentCutscene; -extern s8 *D_8032F96C[]; -extern s16 bowser_seg6_unkmoveshorts_060576FC[]; -extern struct Animation *blue_fish_seg3_anims_0301C2B0[]; -extern struct Animation *cyan_fish_seg6_anims_0600E264[]; -extern struct Animation *blue_fish_seg3_anims_0301C2B0[]; - -void common_anchor_mario_behavior(f32, f32, s32); - -s32 mario_moving_fast_enough_to_make_piranha_plant_bite(void); -void obj_set_secondary_camera_focus(void); - s32 D_8032F0C0[] = { SAVE_FLAG_HAVE_WING_CAP, SAVE_FLAG_HAVE_METAL_CAP, SAVE_FLAG_HAVE_VANISH_CAP }; // Boo Roll @@ -133,14 +120,14 @@ s16 D_8032F0CC[] = { 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624, 3329, 3046, struct SpawnParticlesInfo D_8032F270 = { 2, 20, MODEL_MIST, 0, 40, 5, 30, 20, 252, 30, 330.0f, 10.0f }; // generate_wind_puffs/dust (something like that) -void spawn_mist_particles_variable(s32 sp18, s32 sp1C, f32 sp20) { - D_8032F270.sizeBase = sp20; - D_8032F270.sizeRange = sp20 / 20.0; - D_8032F270.offsetY = sp1C; - if (sp18 == 0) { +void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size) { + D_8032F270.sizeBase = size; + D_8032F270.sizeRange = size / 20.0; + D_8032F270.offsetY = offsetY; + if (count == 0) { D_8032F270.count = 20; - } else if (sp18 > 20) { - D_8032F270.count = sp18; + } else if (count > 20) { + D_8032F270.count = count; } else { D_8032F270.count = 4; } diff --git a/src/game/behavior_actions.h b/src/game/behavior_actions.h index 7607d787..ba6e99b1 100644 --- a/src/game/behavior_actions.h +++ b/src/game/behavior_actions.h @@ -1,21 +1,21 @@ -#ifndef _BEHAVIOR_ACTIONS_H -#define _BEHAVIOR_ACTIONS_H +#ifndef BEHAVIOR_ACTIONS_H +#define BEHAVIOR_ACTIONS_H -extern void spawn_mist_particles_variable(s32,s32,f32); -extern void bhv_spawn_star_no_level_exit(u32); -extern void bhv_star_door_loop_2(); -extern void spawn_triangle_break_particles(s16,s16,f32,s16); +void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size); +void bhv_spawn_star_no_level_exit(u32); +void bhv_star_door_loop_2(void); +void spawn_triangle_break_particles(s16 numTris, s16 triModel, f32 triSize, s16 triAnimState); -extern void spawn_mist_from_global(void); -extern void clear_particle_flags(u32); -extern void spawn_wind_particles(s16,s16); -extern s32 check_if_moving_over_floor(f32,f32); -extern s32 arc_to_goal_pos(f32*,f32*,f32,f32); -void vec3f_copy_2(Vec3f dest,Vec3f src); -extern void tox_box_move(f32,f32,s16,s16); -extern void play_penguin_walking_sound(s32); -extern s32 update_angle_from_move_flags(s32*); -extern void cur_obj_spawn_strong_wind_particles(s32, f32, f32, f32, f32); +void spawn_mist_from_global(void); +void clear_particle_flags(u32 flags); +void spawn_wind_particles(s16 pitch, s16 yaw); +s32 check_if_moving_over_floor(f32 a0, f32 a1); +s32 arc_to_goal_pos(Vec3f a0, Vec3f a1, f32 yVel, f32 gravity); +void vec3f_copy_2(Vec3f dest, Vec3f src); +void tox_box_move(f32 forwardVel, f32 a1, s16 deltaPitch, s16 deltaRoll); +void play_penguin_walking_sound(s32 walk); +s32 update_angle_from_move_flags(s32 *angle); +void cur_obj_spawn_strong_wind_particles(s32 windSpread, f32 scale, f32 relPosX, f32 relPosY, f32 relPosZ); void bhv_cap_switch_loop(void); void bhv_tiny_star_particles_init(void); @@ -51,6 +51,7 @@ void bhv_fish_group_loop(void); void bhv_cannon_base_loop(void); void bhv_cannon_barrel_loop(void); void bhv_cannon_base_unused_loop(void); +void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30); void bhv_chuckya_loop(void); void bhv_chuckya_anchor_mario_loop(void); void bhv_rotating_platform_loop(void); @@ -190,6 +191,7 @@ void bhv_lll_sinking_square_platforms_loop(void); void bhv_koopa_shell_loop(void); void bhv_koopa_shell_flame_loop(void); void bhv_tox_box_loop(void); +s32 mario_moving_fast_enough_to_make_piranha_plant_bite(void); void bhv_piranha_plant_loop(void); void bhv_lll_bowser_puzzle_piece_loop(void); void bhv_lll_bowser_puzzle_loop(void); @@ -227,6 +229,7 @@ void bhv_boo_with_cage_loop(void); void bhv_boo_init(void); void bhv_big_boo_loop(void); void bhv_courtyard_boo_triplet_init(void); +void obj_set_secondary_camera_focus(void); void bhv_boo_loop(void); void bhv_boo_boss_spawned_bridge_loop(void); void bhv_bbh_tilting_trap_platform_loop(void); @@ -549,28 +552,28 @@ void bhv_dust_smoke_loop(void); void bhv_yoshi_loop(void); void bhv_volcano_trap_loop(void); -extern Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx); +Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx); // Bowser -extern Gfx *geo_bits_bowser_coloring(s32 a0, struct GraphNode *node, UNUSED s32 a2); -extern Gfx *geo_update_body_rot_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx); -extern Gfx *geo_switch_bowser_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx); +Gfx *geo_bits_bowser_coloring(s32 run, struct GraphNode *node, UNUSED s32 a2); +Gfx *geo_update_body_rot_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx); +Gfx *geo_switch_bowser_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx); // Tuxie -extern Gfx *geo_switch_tuxie_mother_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx); +Gfx *geo_switch_tuxie_mother_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx); // Cap switch -extern Gfx *geo_update_held_mario_pos(s32 run, UNUSED struct GraphNode *node, Mat4 mtx); +Gfx *geo_update_held_mario_pos(s32 run, UNUSED struct GraphNode *node, Mat4 mtx); // Snufit -extern Gfx *geo_snufit_move_mask(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); -extern Gfx *geo_snufit_scale_body(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_snufit_move_mask(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_snufit_scale_body(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); // Bowser key cutscene -extern Gfx *geo_scale_bowser_key(s32 run, struct GraphNode *node, UNUSED f32 mtx[4][4]); +Gfx *geo_scale_bowser_key(s32 run, struct GraphNode *node, UNUSED f32 mtx[4][4]); // Water splash -extern struct WaterDropletParams sShallowWaterSplashDropletParams; -extern struct WaterDropletParams sShallowWaterWaveDropletParams; +extern struct WaterDropletParams gShallowWaterSplashDropletParams; +extern struct WaterDropletParams gShallowWaterWaveDropletParams; -#endif // _BEHAVIOR_ACTIONS_H +#endif // BEHAVIOR_ACTIONS_H diff --git a/src/game/behaviors/activated_bf_plat.inc.c b/src/game/behaviors/activated_bf_plat.inc.c index 9a8fd49f..49fa5657 100644 --- a/src/game/behaviors/activated_bf_plat.inc.c +++ b/src/game/behaviors/activated_bf_plat.inc.c @@ -16,7 +16,7 @@ * move off of it. To do this, they changed it to a bhvPlatformOnTrack, but * forgot to remove its entry in this table. */ -static void *sActivatedBackAndForthPlatformCollisionModels[] = { +static void const *sActivatedBackAndForthPlatformCollisionModels[] = { /* ACTIVATED_BF_PLAT_TYPE_BITS_ARROW_PLAT */ bits_seg7_collision_0701AD54, /* ACTIVATED_BF_PLAT_TYPE_BITFS_MESH_PLAT */ bitfs_seg7_collision_070157E0, /* ACTIVATED_BF_PLAT_TYPE_BITFS_ELEVATOR */ bitfs_seg7_collision_07015124 diff --git a/src/game/behaviors/animated_floor_switch.inc.c b/src/game/behaviors/animated_floor_switch.inc.c index 1f3bc978..8f502310 100644 --- a/src/game/behaviors/animated_floor_switch.inc.c +++ b/src/game/behaviors/animated_floor_switch.inc.c @@ -1,7 +1,7 @@ // animated_floor_switch.inc.c struct Struct80331A54 { - void *unk00; + const void *unk00; s16 unk04; }; diff --git a/src/game/behaviors/bobomb.inc.c b/src/game/behaviors/bobomb.inc.c index 146ecbcf..4d10d978 100644 --- a/src/game/behaviors/bobomb.inc.c +++ b/src/game/behaviors/bobomb.inc.c @@ -37,7 +37,7 @@ void bobomb_act_explode(void) { bobomb_spawn_coin(); create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -128,7 +128,7 @@ void generic_bobomb_free_loop(void) { break; case BOBOMB_ACT_DEATH_PLANE_DEATH: - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000); break; } @@ -155,7 +155,7 @@ void stationary_bobomb_free_loop(void) { break; case BOBOMB_ACT_DEATH_PLANE_DEATH: - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000); break; } @@ -346,7 +346,7 @@ void bobomb_buddy_cannon_dialog(s16 dialogFirstText, s16 dialogSecondText) { case BOBOMB_BUDDY_CANNON_STOP_TALKING: set_mario_npc_dialog(0); - o->activeFlags &= ~0x20; /* bit 5 */ + o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP; o->oBobombBuddyHasTalkedToMario = BOBOMB_BUDDY_HAS_TALKED; o->oInteractStatus = 0; o->oAction = BOBOMB_BUDDY_ACT_IDLE; @@ -357,7 +357,7 @@ void bobomb_buddy_cannon_dialog(s16 dialogFirstText, s16 dialogSecondText) { void bobomb_buddy_act_talk(void) { if (set_mario_npc_dialog(1) == 2) { - o->activeFlags |= 0x20; /* bit 5 */ + o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; switch (o->oBobombBuddyRole) { case BOBOMB_BUDDY_ROLE_ADVICE: @@ -365,7 +365,7 @@ void bobomb_buddy_act_talk(void) { != BOBOMB_BUDDY_BP_STYPE_GENERIC) { set_mario_npc_dialog(0); - o->activeFlags &= ~0x20; /* bit 5 */ + o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP; o->oBobombBuddyHasTalkedToMario = BOBOMB_BUDDY_HAS_TALKED; o->oInteractStatus = 0; o->oAction = BOBOMB_BUDDY_ACT_IDLE; diff --git a/src/game/behaviors/boo.inc.c b/src/game/behaviors/boo.inc.c index 14f322bb..8525e28f 100644 --- a/src/game/behaviors/boo.inc.c +++ b/src/game/behaviors/boo.inc.c @@ -191,7 +191,7 @@ static void boo_move_during_hit(s32 roll, f32 fVel) { // This is such a small change that the Y position only changes by 5 units. // It's completely unnoticable in-game. s32 oscillationVel = o->oTimer * 0x800 + 0x800; - + o->oForwardVel = fVel; o->oVelY = coss(oscillationVel); o->oMoveAngleYaw = o->oBooMoveYawDuringHit; @@ -237,11 +237,11 @@ static s32 boo_update_after_bounced_on(f32 a0) { // called iff big boo nonlethally hit static s32 big_boo_update_during_nonlethal_hit(f32 a0) { boo_stop(); - + if (o->oTimer == 0) { boo_set_move_yaw_for_during_hit(TRUE); } - + if (o->oTimer < 32) { boo_move_during_hit(TRUE, D_8032F0CC[o->oTimer]/5000.0f * a0); } else if (o->oTimer < 48) { @@ -249,12 +249,12 @@ static s32 big_boo_update_during_nonlethal_hit(f32 a0) { } else { cur_obj_become_tangible(); boo_reset_after_hit(); - + o->oAction = 1; - + return TRUE; } - + return FALSE; } @@ -279,7 +279,7 @@ static s32 boo_update_during_death(void) { if (o->oBooParentBigBoo != NULL) { parentBigBoo = o->oBooParentBigBoo; - + #ifndef VERSION_JP if (!cur_obj_has_behavior(bhvBoo)) { parentBigBoo->oBigBooNumMinionBoosKilled++; @@ -288,7 +288,7 @@ static s32 boo_update_during_death(void) { parentBigBoo->oBigBooNumMinionBoosKilled++; #endif } - + return TRUE; } } @@ -310,25 +310,25 @@ static s32 obj_has_attack_type(u32 attackType) { static s32 boo_get_attack_status(void) { s32 attackStatus = BOO_NOT_ATTACKED; - + if (o->oInteractStatus & INT_STATUS_INTERACTED) { if ((o->oInteractStatus & INT_STATUS_WAS_ATTACKED) && obj_has_attack_type(ATTACK_FROM_ABOVE) == FALSE) { cur_obj_become_intangible(); - + o->oInteractStatus = 0; - + cur_obj_play_sound_2(SOUND_OBJ_BOO_LAUGH_SHORT); - + attackStatus = BOO_ATTACKED; } else { cur_obj_play_sound_2(SOUND_OBJ_BOO_BOUNCE_TOP); - + o->oInteractStatus = 0; - + attackStatus = BOO_BOUNCED_ON; } } - + return attackStatus; } @@ -336,28 +336,28 @@ static s32 boo_get_attack_status(void) { static void boo_chase_mario(f32 a0, s16 a1, f32 a2) { f32 sp1C; s16 sp1A; - + if (boo_vanish_or_appear()) { o->oInteractType = 0x8000; - + if (cur_obj_lateral_dist_from_mario_to_home() > 1500.0f) { sp1A = cur_obj_angle_to_home(); } else { sp1A = o->oAngleToMario; } - + cur_obj_rotate_yaw_toward(sp1A, a1); o->oVelY = 0.0f; - + if (mario_is_in_air_action() == 0) { sp1C = o->oPosY - gMarioObject->oPosY; if (a0 < sp1C && sp1C < 500.0f) { o->oVelY = increment_velocity_toward_range(o->oPosY, gMarioObject->oPosY + 50.0f, 10.f, 2.0f); } } - + cur_obj_set_vel_from_mario_vel(10.0f - o->oBooNegatedAggressiveness, a2); - + if (o->oForwardVel != 0.0f) { boo_oscillate(FALSE); } @@ -372,19 +372,19 @@ static void boo_chase_mario(f32 a0, s16 a1, f32 a2) { static void boo_act_0(void) { o->activeFlags |= ACTIVE_FLAG_MOVE_THROUGH_GRATE; - + if (o->oBehParams2ndByte == 2) { o->oRoom = 10; } - + cur_obj_set_pos_to_home(); o->oMoveAngleYaw = o->oBooInitialMoveYaw; boo_stop(); - + o->oBooParentBigBoo = cur_obj_nearest_object_with_behavior(bhvGhostHuntBigBoo); o->oBooBaseScale = 1.0f; o->oBooTargetOpacity = 0xFF; - + if (boo_should_be_active()) { // Condition is met if the object is bhvBalconyBigBoo or bhvMerryGoRoundBoo if (o->oBehParams2ndByte == 2) { @@ -410,27 +410,27 @@ static void boo_act_5(void) { static void boo_act_1(void) { s32 attackStatus; - + if (o->oTimer == 0) { o->oBooNegatedAggressiveness = -random_float() * 5.0f; o->oBooTurningSpeed = (s32)(random_float() * 128.0f); } - + boo_chase_mario(-100.0f, o->oBooTurningSpeed + 0x180, 0.5f); attackStatus = boo_get_attack_status(); - + if (boo_should_be_stopped()) { o->oAction = 0; } - + if (attackStatus == BOO_BOUNCED_ON) { o->oAction = 2; } - + if (attackStatus == BOO_ATTACKED) { o->oAction = 3; } - + if (attackStatus == BOO_ATTACKED) { create_sound_spawner(SOUND_OBJ_DYING_ENEMY1); } @@ -467,7 +467,7 @@ static void boo_act_4(void) { if (cur_obj_update_dialog(2, 2, dialogID, 0)) { create_sound_spawner(SOUND_OBJ_DYING_ENEMY1); obj_mark_for_deletion(o); - + if (dialogID == DIALOG_108) { // If the Big Boo should spawn, play the jingle play_puzzle_jingle(); } @@ -485,18 +485,18 @@ static void (*sBooActions[])(void) = { void bhv_boo_loop(void) { //PARTIAL_UPDATE - + cur_obj_update_floor_and_walls(); cur_obj_call_action_function(sBooActions); cur_obj_move_standard(78); boo_approach_target_opacity_and_update_scale(); - + if (obj_has_behavior(o->parentObj, bhvMerryGoRoundBooManager)) { - if (o->activeFlags == 0) { + if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED) { o->parentObj->oMerryGoRoundBooManagerNumBoosKilled++; } } - + o->oInteractStatus = 0; } @@ -507,25 +507,25 @@ static void big_boo_act_0(void) { // redundant? this is also done in behavior_data.s o->oBigBooNumMinionBoosKilled = 10; } - + o->oBooParentBigBoo = NULL; - + #ifndef VERSION_JP if (boo_should_be_active() && gDebugInfo[5][0] + 5 <= o->oBigBooNumMinionBoosKilled) { #else if (boo_should_be_active() && o->oBigBooNumMinionBoosKilled >= 5) { #endif o->oAction = 1; - + cur_obj_set_pos_to_home(); o->oMoveAngleYaw = o->oBooInitialMoveYaw; - + cur_obj_unhide(); - + o->oBooTargetOpacity = 0xFF; o->oBooBaseScale = 3.0f; o->oHealth = 3; - + cur_obj_scale(3.0f); cur_obj_become_tangible(); } else { @@ -539,7 +539,7 @@ static void big_boo_act_1(void) { s32 attackStatus; s16 sp22; f32 sp1C; - + if (o->oHealth == 3) { sp22 = 0x180; sp1C = 0.5f; } else if (o->oHealth == 2) { @@ -547,11 +547,11 @@ static void big_boo_act_1(void) { } else { sp22 = 0x300; sp1C = 0.8f; } - + boo_chase_mario(-100.0f, sp22, sp1C); - + attackStatus = boo_get_attack_status(); - + // redundant; this check is in boo_should_be_stopped if (cur_obj_has_behavior(bhvMerryGoRoundBigBoo)) { if (gMarioOnMerryGoRound == FALSE) { @@ -560,15 +560,15 @@ static void big_boo_act_1(void) { } else if (boo_should_be_stopped()) { o->oAction = 0; } - + if (attackStatus == BOO_BOUNCED_ON) { o->oAction = 2; } - + if (attackStatus == BOO_ATTACKED) { o->oAction = 3; } - + if (attackStatus == 1) { create_sound_spawner(SOUND_OBJ_THWOMP); } @@ -604,15 +604,15 @@ static void big_boo_act_3(void) { if (o->oTimer == 0) { o->oHealth--; } - + if (o->oHealth == 0) { if (boo_update_during_death()) { cur_obj_disable(); - + o->oAction = 4; - + obj_set_angle(o, 0, 0, 0); - + if (o->oBehParams2ndByte == 0) { big_boo_spawn_ghost_hunt_star(); } else if (o->oBehParams2ndByte == 1) { @@ -626,7 +626,7 @@ static void big_boo_act_3(void) { spawn_mist_particles(); o->oBooBaseScale -= 0.5; } - + if (big_boo_update_during_nonlethal_hit(40.0f)) { o->oAction = 1; } @@ -637,17 +637,17 @@ static void big_boo_act_4(void) { #ifndef VERSION_JP boo_stop(); #endif - + if (o->oBehParams2ndByte == 0) { obj_set_pos(o, 973, 0, 626); - + if (o->oTimer > 60 && o->oDistanceToMario < 600.0f) { obj_set_pos(o, 973, 0, 717); - + spawn_object_relative(0, 0, 0, 0, o, MODEL_BBH_STAIRCASE_STEP, bhvBooBossSpawnedBridge); spawn_object_relative(1, 0, 0, -200, o, MODEL_BBH_STAIRCASE_STEP, bhvBooBossSpawnedBridge); spawn_object_relative(2, 0, 0, 200, o, MODEL_BBH_STAIRCASE_STEP, bhvBooBossSpawnedBridge); - + obj_mark_for_deletion(o); } } else { @@ -665,15 +665,15 @@ static void (*sBooGivingStarActions[])(void) = { void bhv_big_boo_loop(void) { //PARTIAL_UPDATE - + obj_set_hitbox(o, &sBooGivingStarHitbox); - + o->oGraphYOffset = o->oBooBaseScale * 60.0f; - + cur_obj_update_floor_and_walls(); cur_obj_call_action_function(sBooGivingStarActions); cur_obj_move_standard(78); - + boo_approach_target_opacity_and_update_scale(); o->oInteractStatus = 0; } @@ -682,10 +682,10 @@ static void boo_with_cage_act_0(void) { o->oBooParentBigBoo = NULL; o->oBooTargetOpacity = 0xFF; o->oBooBaseScale = 2.0f; - + cur_obj_scale(2.0f); cur_obj_become_tangible(); - + if (boo_should_be_active()) { o->oAction = 1; } @@ -695,17 +695,17 @@ static void boo_with_cage_act_1(void) { s32 attackStatus; boo_chase_mario(100.0f, 512, 0.5f); - + attackStatus = boo_get_attack_status(); - + if (boo_should_be_stopped()) { o->oAction = 0; } - + if (attackStatus == BOO_BOUNCED_ON) { o->oAction = 2; } - + if (attackStatus == BOO_ATTACKED) { o->oAction = 3; } @@ -725,7 +725,7 @@ static void boo_with_cage_act_3(void) { void bhv_boo_with_cage_init(void) { struct Object* cage; - + if (gHudDisplay.stars < 12) { obj_mark_for_deletion(o); } else { @@ -744,7 +744,7 @@ static void (*sBooWithCageActions[])(void) = { void bhv_boo_with_cage_loop(void) { //PARTIAL_UPDATE - + cur_obj_update_floor_and_walls(); cur_obj_call_action_function(sBooWithCageActions); cur_obj_move_standard(78); @@ -764,16 +764,16 @@ void bhv_merry_go_round_boo_manager_loop(void) { o->oMerryGoRoundBooManagerNumBoosSpawned++; } } - + o->oAction++; } - + if (o->oMerryGoRoundBooManagerNumBoosKilled > 4) { struct Object *boo = spawn_object(o, MODEL_BOO, bhvMerryGoRoundBigBoo); obj_copy_behavior_params(boo, o); - + o->oAction = 2; - + #ifndef VERSION_JP play_puzzle_jingle(); #else @@ -781,13 +781,13 @@ void bhv_merry_go_round_boo_manager_loop(void) { #endif } } - + break; case 1: if (o->oTimer > 60) { o->oAction = 0; } - + break; case 2: break; @@ -804,43 +804,43 @@ void bhv_animated_texture_loop(void) { void bhv_boo_in_castle_loop(void) { s16 targetAngle; - + o->oBooBaseScale = 2.0f; - + if (o->oAction == 0) { cur_obj_hide(); - + if (gHudDisplay.stars < 12) { obj_mark_for_deletion(o); } - + if (gMarioCurrentRoom == 1) { o->oAction++; } } else if (o->oAction == 1) { cur_obj_unhide(); - + o->oOpacity = 180; - + if (o->oTimer == 0) { cur_obj_scale(o->oBooBaseScale); } - + if (o->oDistanceToMario < 1000.0f) { o->oAction++; cur_obj_play_sound_2(SOUND_OBJ_BOO_LAUGH_LONG); } - + o->oForwardVel = 0.0f; targetAngle = o->oAngleToMario; } else { cur_obj_forward_vel_approach_upward(32.0f, 1.0f); - + o->oHomeX = -1000.0f; o->oHomeZ = -9000.0f; - + targetAngle = cur_obj_angle_to_home(); - + if (o->oPosZ < -5000.0f) { if (o->oOpacity > 0) { o->oOpacity -= 20; @@ -848,16 +848,16 @@ void bhv_boo_in_castle_loop(void) { o->oOpacity = 0; } } - + if (o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) { o->oAction = 1; } } - + o->oVelY = 0.0f; - + targetAngle = cur_obj_angle_to_home(); - + cur_obj_rotate_yaw_toward(targetAngle, 0x5A8); boo_oscillate(TRUE); cur_obj_move_using_fvel_and_gravity(); @@ -865,7 +865,7 @@ void bhv_boo_in_castle_loop(void) { void bhv_boo_boss_spawned_bridge_loop(void) { f32 targetY; - + switch (o->oBehParams2ndByte) { case 1: targetY = 0.0f; @@ -877,7 +877,7 @@ void bhv_boo_boss_spawned_bridge_loop(void) { targetY = -413.0f; break; } - + switch(o->oAction) { case 0: o->oPosY = o->oHomeY - 620.0f; @@ -886,28 +886,28 @@ void bhv_boo_boss_spawned_bridge_loop(void) { case 1: o->oPosY += 8.0f; cur_obj_play_sound_1(SOUND_ENV_ELEVATOR2); - + if (o->oPosY > targetY) { o->oPosY = targetY; o->oAction++; } - + break; case 2: if (o->oTimer == 0) { cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN4_LOWPRIO); } - + if (cur_obj_move_up_and_down(o->oTimer)) { o->oAction++; } - + break; case 3: if (o->oTimer == 0 && o->oBehParams2ndByte == 1) { play_puzzle_jingle(); } - + break; } } diff --git a/src/game/behaviors/boulder.inc.c b/src/game/behaviors/boulder.inc.c index ccc36c3c..18bd53fb 100644 --- a/src/game/behaviors/boulder.inc.c +++ b/src/game/behaviors/boulder.inc.c @@ -23,7 +23,7 @@ void boulder_act_1(void) { o->oForwardVel = 70.0f; if (o->oPosY < -1000.0f) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } void bhv_big_boulder_loop(void) { diff --git a/src/game/behaviors/bouncing_fireball.inc.c b/src/game/behaviors/bouncing_fireball.inc.c index 2ebda22a..8cf6b99c 100644 --- a/src/game/behaviors/bouncing_fireball.inc.c +++ b/src/game/behaviors/bouncing_fireball.inc.c @@ -1,7 +1,7 @@ // bouncing_fireball.c.inc void bhv_bouncing_fireball_flame_loop(void) { - o->activeFlags |= 0x400; + o->activeFlags |= ACTIVE_FLAG_UNK10; cur_obj_update_floor_and_walls(); switch (o->oAction) { case 0: diff --git a/src/game/behaviors/bowling_ball.inc.c b/src/game/behaviors/bowling_ball.inc.c index 292b7c4d..d9d58ced 100644 --- a/src/game/behaviors/bowling_ball.inc.c +++ b/src/game/behaviors/bowling_ball.inc.c @@ -87,7 +87,7 @@ void bhv_bowling_ball_roll_loop(void) { spawn_mist_particles_variable(0, 0, 92.0f); } - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) && (o->oVelY > 5.0f)) diff --git a/src/game/behaviors/bowser.inc.c b/src/game/behaviors/bowser.inc.c index 38908d01..357505a1 100644 --- a/src/game/behaviors/bowser.inc.c +++ b/src/game/behaviors/bowser.inc.c @@ -160,7 +160,7 @@ void bowser_initialize_action(void) { o->oAction = 0; } -void bowser_act_text_wait() // not much +void bowser_act_text_wait(void) // not much { o->oForwardVel = 0.0f; cur_obj_init_animation_with_sound(12); @@ -295,13 +295,13 @@ void bowser_reset_fallen_off_stage(void) { } #endif -void bowser_act_unused_slow_walk() // unused? +void bowser_act_unused_slow_walk(void) // unused? { if (cur_obj_init_animation_and_check_if_near_end(12)) o->oAction = 0; } -void bowser_act_default() // only lasts one frame +void bowser_act_default(void) // only lasts one frame { o->oBowserEyesShut = 0; cur_obj_init_animation_with_sound(12); @@ -326,7 +326,7 @@ void bowser_act_breath_fire(void) { o->oAction = 0; } -void bowser_act_walk_to_mario() // turn towards Mario +void bowser_act_walk_to_mario(void) // turn towards Mario { UNUSED s32 facing; // is Bowser facing Mario? s16 turnSpeed; @@ -892,7 +892,7 @@ void bowser_act_dead(void) { if (BITS) o->oSubAction = 10; else { - o->activeFlags |= 0x80; + o->activeFlags |= ACTIVE_FLAG_DITHERED_ALPHA; o->oSubAction++; } } @@ -1258,13 +1258,13 @@ Gfx *geo_switch_bowser_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx) { return NULL; } -Gfx *geo_bits_bowser_coloring(s32 a0, struct GraphNode *node, UNUSED s32 a2) { +Gfx *geo_bits_bowser_coloring(s32 run, struct GraphNode *node, UNUSED s32 a2) { Gfx *sp2C = NULL; Gfx *sp28; struct Object *sp24; struct GraphNodeGenerated *sp20; - if (a0 == 1) { + if (run == 1) { sp24 = (struct Object *) gCurGraphNodeObject; sp20 = (struct GraphNodeGenerated *) node; if (gCurGraphNodeHeldObject != 0) @@ -1379,8 +1379,8 @@ void bowser_flame_despawn(void) { spawn_object(o, MODEL_YELLOW_COIN, bhvTemporaryYellowCoin); } -s32 bowser_flame_should_despawn(s32 a0) { - if (a0 < o->oTimer) +s32 bowser_flame_should_despawn(s32 maxTime) { + if (maxTime < o->oTimer) return 1; if (o->oFloorType == 1) return 1; diff --git a/src/game/behaviors/bowser_bomb.inc.c b/src/game/behaviors/bowser_bomb.inc.c index 0a0eab25..e1e560ae 100644 --- a/src/game/behaviors/bowser_bomb.inc.c +++ b/src/game/behaviors/bowser_bomb.inc.c @@ -4,7 +4,7 @@ void bhv_bowser_bomb_loop(void) { if (obj_check_if_collided_with_object(o, gMarioObject) == 1) { o->oInteractStatus &= ~INT_STATUS_INTERACTED; spawn_object(o, MODEL_EXPLOSION, bhvExplosion); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } if (o->oInteractStatus & INT_STATUS_HIT_MINE) @@ -12,7 +12,7 @@ void bhv_bowser_bomb_loop(void) { spawn_object(o, MODEL_BOWSER_FLAMES, bhvBowserBombExplosion); create_sound_spawner(SOUND_GENERAL_BOWSER_BOMB_EXPLOSION); set_camera_shake_from_point(SHAKE_POS_LARGE, o->oPosX, o->oPosY, o->oPosZ); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } set_object_visibility(o, 7000); @@ -32,7 +32,7 @@ void bhv_bowser_bomb_explosion_loop(void) { if (o->oTimer % 2 == 0) o->oAnimState++; if (o->oTimer == 28) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } void bhv_bowser_bomb_smoke_loop(void) { @@ -47,5 +47,5 @@ void bhv_bowser_bomb_smoke_loop(void) { o->oPosY += o->oVelY; if (o->oTimer == 28) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } diff --git a/src/game/behaviors/breakable_box_small.inc.c b/src/game/behaviors/breakable_box_small.inc.c index 5b8745f5..bb9a4edd 100644 --- a/src/game/behaviors/breakable_box_small.inc.c +++ b/src/game/behaviors/breakable_box_small.inc.c @@ -19,7 +19,7 @@ void bhv_breakable_box_small_init(void) { cur_obj_scale(0.4f); obj_set_hitbox(o, &sBreakableBoxSmallHitbox); o->oAnimState = 1; - o->activeFlags |= 0x200; + o->activeFlags |= ACTIVE_FLAG_UNK9; } void small_breakable_box_spawn_dust(void) { @@ -46,7 +46,7 @@ void small_breakable_box_act_move(void) { spawn_triangle_break_particles(20, 138, 0.7f, 3); obj_spawn_yellow_coins(o, 3); create_sound_spawner(SOUND_GENERAL_BREAK_BOX); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } obj_check_floor_death(sp1E, sObjFloor); @@ -66,7 +66,7 @@ void breakable_box_small_released_loop(void) { // Despawn, and create a corkbox respawner if (o->oBreakableBoxSmallFramesSinceReleased > 900) { create_respawner(MODEL_BREAKABLE_BOX_SMALL, bhvBreakableBoxSmall, 3000); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -81,7 +81,7 @@ void breakable_box_small_idle_loop(void) { break; case 101: - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; create_respawner(MODEL_BREAKABLE_BOX_SMALL, bhvBreakableBoxSmall, 3000); break; } @@ -111,7 +111,7 @@ void breakable_box_small_get_thrown(void) { o->oVelY = 20.0f; o->oBreakableBoxSmallReleased = 1; o->oBreakableBoxSmallFramesSinceReleased = 0; - o->activeFlags &= ~0x200; + o->activeFlags &= ~ACTIVE_FLAG_UNK9; } void bhv_breakable_box_small_loop(void) { diff --git a/src/game/behaviors/bubble.inc.c b/src/game/behaviors/bubble.inc.c index 9afa4e52..49b06275 100644 --- a/src/game/behaviors/bubble.inc.c +++ b/src/game/behaviors/bubble.inc.c @@ -19,6 +19,6 @@ void bhv_object_bubble_loop(void) { bubbleSplash->oPosZ = o->oPosZ; } - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } diff --git a/src/game/behaviors/bullet_bill.inc.c b/src/game/behaviors/bullet_bill.inc.c index 4a5650ed..643df723 100644 --- a/src/game/behaviors/bullet_bill.inc.c +++ b/src/game/behaviors/bullet_bill.inc.c @@ -6,13 +6,13 @@ void bhv_white_puff_smoke_init(void) { } void bhv_bullet_bill_init(void) { - o->oBulletBillUnkF8 = o->oMoveAngleYaw; + o->oBulletBillInitialMoveYaw = o->oMoveAngleYaw; } void bullet_bill_act_0(void) { cur_obj_become_tangible(); o->oForwardVel = 0.0f; - o->oMoveAngleYaw = o->oBulletBillUnkF8; + o->oMoveAngleYaw = o->oBulletBillInitialMoveYaw; o->oFaceAnglePitch = 0; o->oFaceAngleRoll = 0; o->oMoveFlags = 0; diff --git a/src/game/behaviors/bully.inc.c b/src/game/behaviors/bully.inc.c index 725fb6c3..efe0ee18 100644 --- a/src/game/behaviors/bully.inc.c +++ b/src/game/behaviors/bully.inc.c @@ -253,7 +253,7 @@ void bhv_bully_loop(void) { break; case BULLY_ACT_DEATH_PLANE_DEATH: - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; } @@ -364,7 +364,7 @@ void bhv_big_bully_with_minions_loop(void) { break; case BULLY_ACT_DEATH_PLANE_DEATH: - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; } } diff --git a/src/game/behaviors/cannon_door.inc.c b/src/game/behaviors/cannon_door.inc.c index 1bc440d9..cb710322 100644 --- a/src/game/behaviors/cannon_door.inc.c +++ b/src/game/behaviors/cannon_door.inc.c @@ -12,7 +12,7 @@ void bhv_cannon_closed_init(void) { cannon->oPosZ = o->oHomeZ; o->oAction = CANNON_TRAP_DOOR_ACT_OPEN; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } diff --git a/src/game/behaviors/cap.inc.c b/src/game/behaviors/cap.inc.c index 8a2d08c4..066ff1fb 100644 --- a/src/game/behaviors/cap.inc.c +++ b/src/game/behaviors/cap.inc.c @@ -15,7 +15,7 @@ static struct ObjectHitbox sCapHitbox = { s32 cap_set_hitbox(void) { obj_set_hitbox(o, &sCapHitbox); if (o->oInteractStatus & INT_STATUS_INTERACTED) { - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; o->oInteractStatus = 0; return 1; } @@ -35,7 +35,7 @@ void cap_check_quicksand(void) { switch (sObjFloor->type) { case SURFACE_DEATH_PLANE: - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; case SURFACE_SHALLOW_QUICKSAND: @@ -85,14 +85,14 @@ void cap_sink_quicksand(void) { case 12: o->oGraphYOffset += -1.0f; if (o->oTimer >= 21) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; case 13: o->oGraphYOffset += -6.0f; if (o->oTimer >= 21) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; o->oFaceAnglePitch = 0x2000; break; @@ -254,7 +254,7 @@ void bhv_normal_cap_loop(void) { if ((s32) o->oForwardVel != 0) save_file_set_cap_pos(o->oPosX, o->oPosY, o->oPosZ); - if (o->activeFlags == 0) + if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED) normal_cap_set_save_flags(); if (cap_set_hitbox() == 1) diff --git a/src/game/behaviors/capswitch.inc.c b/src/game/behaviors/capswitch.inc.c index ab745560..12fa5b82 100644 --- a/src/game/behaviors/capswitch.inc.c +++ b/src/game/behaviors/capswitch.inc.c @@ -40,7 +40,7 @@ void cap_switch_act_2(void) { } } -void cap_switch_act_3() { +void cap_switch_act_3(void) { } // dead function void (*sCapSwitchActions[])(void) = { cap_switch_act_0, cap_switch_act_1, diff --git a/src/game/behaviors/castle_cannon_grate.inc.c b/src/game/behaviors/castle_cannon_grate.inc.c index 16a6b0d4..cc0c8b31 100644 --- a/src/game/behaviors/castle_cannon_grate.inc.c +++ b/src/game/behaviors/castle_cannon_grate.inc.c @@ -2,5 +2,5 @@ void bhv_castle_cannon_grate_init(void) { if (save_file_get_total_star_count(gCurrSaveFileNum - 1, 0, 24) >= 120) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } diff --git a/src/game/behaviors/celebration_star.inc.c b/src/game/behaviors/celebration_star.inc.c index 8782d885..85f8964b 100644 --- a/src/game/behaviors/celebration_star.inc.c +++ b/src/game/behaviors/celebration_star.inc.c @@ -62,7 +62,7 @@ void celeb_star_act_face_camera(void) { } if (o->oTimer == 59) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } void bhv_celebration_star_loop(void) { @@ -81,10 +81,10 @@ void bhv_celebration_star_sparkle_loop(void) { o->oPosY -= 15.0f; if (o->oTimer == 12) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } void bhv_star_key_collection_puff_spawner_loop(void) { spawn_mist_particles_variable(0, 10, 30.0f); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } diff --git a/src/game/behaviors/chuckya.inc.c b/src/game/behaviors/chuckya.inc.c index 4eab68c9..2e007093 100644 --- a/src/game/behaviors/chuckya.inc.c +++ b/src/game/behaviors/chuckya.inc.c @@ -22,7 +22,7 @@ void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30) { break; } o->oMoveAngleYaw = o->parentObj->oMoveAngleYaw; - if (!o->parentObj->activeFlags) + if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) obj_mark_for_deletion(o); } diff --git a/src/game/behaviors/cloud.inc.c b/src/game/behaviors/cloud.inc.c index fa82e3f4..c1d708bf 100644 --- a/src/game/behaviors/cloud.inc.c +++ b/src/game/behaviors/cloud.inc.c @@ -118,7 +118,7 @@ static void cloud_act_main(void) { if (o->parentObj != o) { // Despawn if the parent lakitu does - if (o->parentObj->activeFlags == ACTIVE_FLAGS_DEACTIVATED) { + if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) { o->oAction = CLOUD_ACT_UNLOAD; } else { o->oCloudCenterX = o->parentObj->oPosX; diff --git a/src/game/behaviors/controllable_platform.inc.c b/src/game/behaviors/controllable_platform.inc.c index 73564a0f..7634c3ad 100644 --- a/src/game/behaviors/controllable_platform.inc.c +++ b/src/game/behaviors/controllable_platform.inc.c @@ -46,8 +46,8 @@ void bhv_controllable_platform_sub_loop(void) { o->oVelX = o->parentObj->oVelX; o->oVelZ = o->parentObj->oVelZ; - if (o->parentObj->activeFlags == 0) - o->activeFlags = 0; + if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } void bhv_controllable_platform_init(void) { diff --git a/src/game/behaviors/corkbox.inc.c b/src/game/behaviors/corkbox.inc.c index f9ea7fce..e9316513 100644 --- a/src/game/behaviors/corkbox.inc.c +++ b/src/game/behaviors/corkbox.inc.c @@ -26,13 +26,13 @@ void bhv_bobomb_explosion_bubble_loop(void) { o->oBobombExpBubGfxScaleFacY += o->oBobombExpBubGfxExpRateY; if (o->oPosY > waterY) { - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; o->oPosY += 5.0f; spawn_object(o, MODEL_SMALL_WATER_SPLASH, bhvObjectWaterSplash); } if (o->oTimer >= 61) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; o->oPosY += o->oVelY; o->oTimer++; @@ -44,7 +44,7 @@ void bhv_respawner_loop(void) { if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, o->oRespawnerMinSpawnDist)) { spawnedObject = spawn_object(o, o->oRespawnerModelToRespawn, o->oRespawnerBehaviorToRespawn); spawnedObject->oBehParams = o->oBehParams; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } diff --git a/src/game/behaviors/dorrie.inc.c b/src/game/behaviors/dorrie.inc.c index 7cf5c8b9..abe7ad31 100644 --- a/src/game/behaviors/dorrie.inc.c +++ b/src/game/behaviors/dorrie.inc.c @@ -115,7 +115,7 @@ void bhv_dorrie_update(void) { UNUSED s32 unused2; f32 maxOffsetY; - if (!(o->activeFlags & 0x0008)) { + if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { o->oDorrieForwardDistToMario = o->oDistanceToMario * coss(o->oAngleToMario - o->oMoveAngleYaw); obj_perform_position_op(0); diff --git a/src/game/behaviors/drawbridge.inc.c b/src/game/behaviors/drawbridge.inc.c index e23c163d..0fd04905 100644 --- a/src/game/behaviors/drawbridge.inc.c +++ b/src/game/behaviors/drawbridge.inc.c @@ -13,7 +13,7 @@ void bhv_lll_drawbridge_spawner_loop(void) { drawbridge2->oPosX += coss(o->oMoveAngleYaw) * -640.0f; drawbridge2->oPosZ += sins(o->oMoveAngleYaw) * -640.0f; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } void bhv_lll_drawbridge_loop(void) { diff --git a/src/game/behaviors/elevator.inc.c b/src/game/behaviors/elevator.inc.c index d2445ae4..f9df6856 100644 --- a/src/game/behaviors/elevator.inc.c +++ b/src/game/behaviors/elevator.inc.c @@ -42,7 +42,7 @@ void elevator_act_1(void) { } } -void elevator_act_2() // Pretty similar code to action 1 +void elevator_act_2(void) // Pretty similar code to action 1 { cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1); if (o->oTimer == 0 && cur_obj_is_mario_on_platform()) @@ -62,7 +62,7 @@ void elevator_act_2() // Pretty similar code to action 1 } } -void elevator_act_4() { +void elevator_act_4(void) { o->oVelY = 0; if (o->oTimer == 0) { cur_obj_shake_screen(SHAKE_POS_SMALL); @@ -72,7 +72,7 @@ void elevator_act_4() { o->oAction = 1; } -void elevator_act_3() // nearly identical to action 2 +void elevator_act_3(void) // nearly identical to action 2 { o->oVelY = 0; if (o->oTimer == 0) { diff --git a/src/game/behaviors/explosion.inc.c b/src/game/behaviors/explosion.inc.c index 2c79f88a..75428d56 100644 --- a/src/game/behaviors/explosion.inc.c +++ b/src/game/behaviors/explosion.inc.c @@ -17,7 +17,7 @@ void bhv_explosion_loop(void) { } else spawn_object(o, MODEL_SMOKE, bhvBobombBullyDeathSmoke); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } o->oOpacity -= 14; diff --git a/src/game/behaviors/falling_pillar.inc.c b/src/game/behaviors/falling_pillar.inc.c index 3ed7b419..5c53b283 100644 --- a/src/game/behaviors/falling_pillar.inc.c +++ b/src/game/behaviors/falling_pillar.inc.c @@ -109,7 +109,7 @@ void bhv_falling_pillar_loop(void) { spawn_mist_particles_variable(0, 0, 92.0f); // Go invisible. - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; // Play the hitting the ground sound. create_sound_spawner(SOUND_GENERAL_BIG_POUND); @@ -139,6 +139,6 @@ void bhv_falling_pillar_hitbox_loop(void) { obj_set_hitbox(o, &sFallingPillarHitbox); // When the pillar goes inactive, the hitboxes also go inactive. - if (o->parentObj->activeFlags == 0) - o->activeFlags = 0; + if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } diff --git a/src/game/behaviors/ferris_wheel.inc.c b/src/game/behaviors/ferris_wheel.inc.c index d79a33b0..5eb12617 100644 --- a/src/game/behaviors/ferris_wheel.inc.c +++ b/src/game/behaviors/ferris_wheel.inc.c @@ -9,8 +9,8 @@ * Properties for the ferris wheel axle and platforms. */ struct FerrisWheelProperties { - void *axleCollision; - void *platformCollision; + void const *axleCollision; + void const *platformCollision; s16 platformModel; }; diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c index ed1d767e..d169ecf7 100644 --- a/src/game/behaviors/fish.inc.c +++ b/src/game/behaviors/fish.inc.c @@ -13,7 +13,7 @@ void fish_act_spawn(void) { s32 schoolQuantity; s16 model; f32 minDistToMario; - struct Animation **fishAnimation; + const struct Animation * const*fishAnimation; struct Object *fishObject; switch (o->oBehParams2ndByte) { diff --git a/src/game/behaviors/fly_guy.inc.c b/src/game/behaviors/fly_guy.inc.c index 6dcd78b1..4ae1f844 100644 --- a/src/game/behaviors/fly_guy.inc.c +++ b/src/game/behaviors/fly_guy.inc.c @@ -100,7 +100,7 @@ static void fly_guy_act_lunge(void) { cur_obj_rotate_yaw_toward(o->oFaceAngleYaw, 0x800); obj_face_pitch_approach(o->oFlyGuyLungeTargetPitch, 0x400); - // Range [-0x1000, 0x2000] + // Possible values: {-0x1000, 0x0000, 0x1000} o->oFlyGuyTargetRoll = 0x1000 * (s16)(random_float() * 3.0f) - 0x1000; o->oTimer = 0; } else { diff --git a/src/game/behaviors/flying_bookend_switch.inc.c b/src/game/behaviors/flying_bookend_switch.inc.c index 6b2f25c2..1d89c224 100644 --- a/src/game/behaviors/flying_bookend_switch.inc.c +++ b/src/game/behaviors/flying_bookend_switch.inc.c @@ -98,7 +98,7 @@ void flying_bookend_act_3(void) { } void bhv_flying_bookend_loop(void) { - if (!(o->activeFlags & 0x0008)) { + if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { o->oDeathSound = SOUND_OBJ_POUNDING1; cur_obj_scale(o->header.gfx.scale[0]); @@ -130,7 +130,7 @@ void bhv_flying_bookend_loop(void) { void bhv_bookend_spawn_loop(void) { struct Object *sp1C; - if (!(o->activeFlags & 0x0008)) { + if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { if (o->oTimer > 40 && obj_is_near_to_and_facing_mario(600.0f, 0x2000)) { sp1C = spawn_object(o, MODEL_BOOKEND, bhvFlyingBookend); if (sp1C != NULL) { @@ -145,7 +145,7 @@ void bhv_bookend_spawn_loop(void) { void bookshelf_manager_act_0(void) { s32 val04; - if (!(o->activeFlags & 0x0008)) { + if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { for (val04 = 0; val04 < 3; val04++) { spawn_object_relative(val04, D_80331B30[val04].unk00, D_80331B30[val04].unk02, 0, o, MODEL_BOOKEND, bhvBookSwitch); @@ -167,7 +167,7 @@ void bookshelf_manager_act_1(void) { } void bookshelf_manager_act_2(void) { - if (!(o->activeFlags & 0x0008)) { + if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { if (o->oBookSwitchManagerUnkF4 < 0) { if (o->oTimer > 30) { o->oBookSwitchManagerUnkF4 = o->oBookSwitchManagerUnkF8 = 0; diff --git a/src/game/behaviors/grill_door.inc.c b/src/game/behaviors/grill_door.inc.c index 0062bf9e..3cff966b 100644 --- a/src/game/behaviors/grill_door.inc.c +++ b/src/game/behaviors/grill_door.inc.c @@ -1,9 +1,7 @@ // grill_door.c.inc -extern u8 bob_seg7_collision_gate[]; -extern u8 hmc_seg7_collision_0702B65C[]; -struct Struct8032FCE8 D_8032FCE8[] = { { 320, MODEL_BOB_BARS_GRILLS, bob_seg7_collision_gate }, - { 410, MODEL_HMC_RED_GRILLS, hmc_seg7_collision_0702B65C } }; +struct OpenableGrill gOpenableGrills[] = { { 320, MODEL_BOB_BARS_GRILLS, bob_seg7_collision_gate }, + { 410, MODEL_HMC_RED_GRILLS, hmc_seg7_collision_0702B65C } }; void bhv_openable_cage_door_loop(void) { if (gCurrentObject->oAction == 0) { @@ -18,18 +16,18 @@ void bhv_openable_cage_door_loop(void) { } void bhv_openable_grill_loop(void) { - struct Object *sp3C; - s32 sp38; + struct Object *grillObj; + s32 grillIdx; switch (o->oAction) { case 0: - sp38 = o->oBehParams2ndByte; - sp3C = spawn_object_relative(-1, D_8032FCE8[sp38].unk0, 0, 0, o, D_8032FCE8[sp38].unk1, - bhvOpenableCageDoor); - sp3C->oMoveAngleYaw += 0x8000; - obj_set_collision_data(sp3C, D_8032FCE8[sp38].unk2); - sp3C = spawn_object_relative(1, -D_8032FCE8[sp38].unk0, 0, 0, o, D_8032FCE8[sp38].unk1, - bhvOpenableCageDoor); - obj_set_collision_data(sp3C, D_8032FCE8[sp38].unk2); + grillIdx = o->oBehParams2ndByte; + grillObj = spawn_object_relative(-1, gOpenableGrills[grillIdx].halfWidth, 0, 0, o, gOpenableGrills[grillIdx].modelID, + bhvOpenableCageDoor); + grillObj->oMoveAngleYaw += 0x8000; + obj_set_collision_data(grillObj, gOpenableGrills[grillIdx].collision); + grillObj = spawn_object_relative(1, -gOpenableGrills[grillIdx].halfWidth, 0, 0, o, gOpenableGrills[grillIdx].modelID, + bhvOpenableCageDoor); + obj_set_collision_data(grillObj, gOpenableGrills[grillIdx].collision); o->oAction++; break; case 1: @@ -38,8 +36,8 @@ void bhv_openable_grill_loop(void) { o->oAction++; break; case 2: - sp3C = o->oOpenableGrillUnkF4; - if (sp3C->oAction == 2) { + grillObj = o->oOpenableGrillUnkF4; + if (grillObj->oAction == 2) { o->oOpenableGrillUnk88 = 2; cur_obj_play_sound_2(SOUND_GENERAL_CAGE_OPEN); o->oAction++; diff --git a/src/game/behaviors/haunted_chair.inc.c b/src/game/behaviors/haunted_chair.inc.c index 4627a0b7..89e7e83b 100644 --- a/src/game/behaviors/haunted_chair.inc.c +++ b/src/game/behaviors/haunted_chair.inc.c @@ -128,7 +128,7 @@ void haunted_chair_act_1(void) { } void bhv_haunted_chair_loop(void) { - if (!(o->activeFlags & 0x0008)) { + if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { switch (o->oAction) { case 0: haunted_chair_act_0(); diff --git a/src/game/behaviors/hidden_star.inc.c b/src/game/behaviors/hidden_star.inc.c index 693c7991..03b71500 100644 --- a/src/game/behaviors/hidden_star.inc.c +++ b/src/game/behaviors/hidden_star.inc.c @@ -9,7 +9,7 @@ void bhv_hidden_star_init(void) { sp30 = spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0); sp30->oBehParams = o->oBehParams; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } o->oHiddenStarTriggerCounter = 5 - sp36; @@ -26,7 +26,7 @@ void bhv_hidden_star_loop(void) { if (o->oTimer > 2) { spawn_red_coin_cutscene_star(o->oPosX, o->oPosY, o->oPosZ); spawn_mist_particles(); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } break; } @@ -52,7 +52,7 @@ void bhv_hidden_star_trigger_loop(void) { #endif } - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -68,7 +68,7 @@ void bhv_bowser_course_red_coin_star_loop(void) { if (o->oTimer > 2) { spawn_no_exit_star(o->oPosX, o->oPosY, o->oPosZ); spawn_mist_particles(); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } break; } diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c index af1cb0a6..ced26d7b 100644 --- a/src/game/behaviors/king_bobomb.inc.c +++ b/src/game/behaviors/king_bobomb.inc.c @@ -192,7 +192,7 @@ void king_bobomb_act_8(void) { stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS)); } -void king_bobomb_act_4() { // bobomb been thrown +void king_bobomb_act_4(void) { // bobomb been thrown if (o->oPosY - o->oHomeY > -100.0f) { // not thrown off hill if (o->oMoveFlags & 1) { o->oHealth--; @@ -220,7 +220,7 @@ void king_bobomb_act_4() { // bobomb been thrown } } -void king_bobomb_act_5() { // bobomb returns home +void king_bobomb_act_5(void) { // bobomb returns home switch (o->oSubAction) { case 0: if (o->oTimer == 0) diff --git a/src/game/behaviors/koopa.inc.c b/src/game/behaviors/koopa.inc.c index 87824452..2303906e 100644 --- a/src/game/behaviors/koopa.inc.c +++ b/src/game/behaviors/koopa.inc.c @@ -53,7 +53,7 @@ static u8 sKoopaShelledAttackHandlers[] = { struct KoopaTheQuickProperties { s16 initText; s16 winText; - void *path; + void const *path; Vec3s starPos; }; diff --git a/src/game/behaviors/lll_floating_wood_piece.inc.c b/src/game/behaviors/lll_floating_wood_piece.inc.c index fad31f3f..7994e2d9 100644 --- a/src/game/behaviors/lll_floating_wood_piece.inc.c +++ b/src/game/behaviors/lll_floating_wood_piece.inc.c @@ -3,8 +3,8 @@ void bhv_lll_wood_piece_loop(void) { if (o->oTimer == 0) o->oPosY -= 100.0f; - o->oPosY += sins(o->oLllWoodPieceUnkF4) * 3.0f; - o->oLllWoodPieceUnkF4 += 0x400; + o->oPosY += sins(o->oLllWoodPieceOscillationTimer) * 3.0f; + o->oLllWoodPieceOscillationTimer += 0x400; if (o->parentObj->oAction == 2) obj_mark_for_deletion(o); } @@ -20,7 +20,7 @@ void bhv_lll_floating_wood_bridge_loop(void) { for (i = 1; i < 4; i++) { sp3C = spawn_object_relative(0, (i - 2) * 300, 0, 0, o, MODEL_LLL_WOOD_BRIDGE, bhvLllWoodPiece); - sp3C->oLllWoodPieceUnkF4 = i * 4096; + sp3C->oLllWoodPieceOscillationTimer = i * 4096; } o->oAction = 1; #ifndef NODRAWINGDISTANCE diff --git a/src/game/behaviors/lll_sinking_rectangle.inc.c b/src/game/behaviors/lll_sinking_rectangle.inc.c index 63910414..bda4a844 100644 --- a/src/game/behaviors/lll_sinking_rectangle.inc.c +++ b/src/game/behaviors/lll_sinking_rectangle.inc.c @@ -6,8 +6,8 @@ void sinking_rectangular_plat_actions(f32 a0, s32 a1) { o->oAction++; break; case 1: - o->oPosY -= sins(o->oLllWoodPieceUnkF4) * a0; - o->oLllWoodPieceUnkF4 += a1; + o->oPosY -= sins(o->oLllWoodPieceOscillationTimer) * a0; + o->oLllWoodPieceOscillationTimer += a1; break; case 2: break; @@ -21,8 +21,8 @@ void bhv_lll_sinking_rectangular_platform_loop(void) { if (o->oMoveAngleYaw != 0) sinking_rectangular_plat_actions(sp1C, sp18); else { - o->oFaceAnglePitch = sins(o->oLllWoodPieceUnkF4) * 512.0f; - o->oLllWoodPieceUnkF4 += 0x100; + o->oFaceAnglePitch = sins(o->oLllWoodPieceOscillationTimer) * 512.0f; + o->oLllWoodPieceOscillationTimer += 0x100; } } diff --git a/src/game/behaviors/mad_piano.inc.c b/src/game/behaviors/mad_piano.inc.c index 903403f7..efefaba4 100644 --- a/src/game/behaviors/mad_piano.inc.c +++ b/src/game/behaviors/mad_piano.inc.c @@ -61,7 +61,7 @@ static void mad_piano_act_attack(void) { } void bhv_mad_piano_update(void) { - if (!(o->activeFlags & 0x0008)) { + if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { o->oFaceAngleYaw = o->oMoveAngleYaw - 0x4000; switch (o->oAction) { diff --git a/src/game/behaviors/mips.inc.c b/src/game/behaviors/mips.inc.c index 35816129..a24cecd1 100644 --- a/src/game/behaviors/mips.inc.c +++ b/src/game/behaviors/mips.inc.c @@ -27,7 +27,7 @@ void bhv_mips_init(void) { #endif } else { // No MIPS stars are available, hide MIPS. - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } o->oInteractionSubtype = INT_SUBTYPE_HOLDABLE_NPC; diff --git a/src/game/behaviors/moneybag.inc.c b/src/game/behaviors/moneybag.inc.c index d92600b5..209aa5ea 100644 --- a/src/game/behaviors/moneybag.inc.c +++ b/src/game/behaviors/moneybag.inc.c @@ -166,7 +166,7 @@ void moneybag_act_disappear(void) { o->oOpacity -= 6; if (o->oOpacity < 0) { o->oOpacity = 0; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -175,7 +175,7 @@ void moneybag_act_death(void) { obj_spawn_yellow_coins(o, 5); create_sound_spawner(SOUND_GENERAL_SPLATTERING); spawn_mist_particles(); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -186,7 +186,7 @@ void bhv_moneybag_loop(void) { o->oOpacity += 12; if (o->oOpacity >= 256) { o->oOpacity = 255; - o->parentObj->activeFlags = 0; + o->parentObj->activeFlags = ACTIVE_FLAG_DEACTIVATED; o->oAction = MONEYBAG_ACT_MOVE_AROUND; } break; diff --git a/src/game/behaviors/monty_mole.inc.c b/src/game/behaviors/monty_mole.inc.c index 377226c6..685f5aae 100644 --- a/src/game/behaviors/monty_mole.inc.c +++ b/src/game/behaviors/monty_mole.inc.c @@ -42,7 +42,7 @@ static struct Object *link_objects_with_behavior(const BehaviorScript *behavior) obj = (struct Object *) listHead->next; while (obj != (struct Object *) listHead) { - if (obj->behavior == behaviorAddr && obj->activeFlags != ACTIVE_FLAGS_DEACTIVATED) { + if (obj->behavior == behaviorAddr && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED) { obj->parentObj = lastObject; lastObject = obj; } @@ -126,7 +126,7 @@ void monty_mole_spawn_dirt_particles(s8 offsetY, s8 velYBase) { /* sizeBase: */ 10.0f, /* sizeRange: */ 7.0f, }; - + sMontyMoleRiseFromGroundParticles.offsetY = offsetY; sMontyMoleRiseFromGroundParticles.velYBase = velYBase; cur_obj_spawn_particles(&sMontyMoleRiseFromGroundParticles); diff --git a/src/game/behaviors/moving_coin.inc.c b/src/game/behaviors/moving_coin.inc.c index fa105ca1..5073ea48 100644 --- a/src/game/behaviors/moving_coin.inc.c +++ b/src/game/behaviors/moving_coin.inc.c @@ -49,7 +49,7 @@ void moving_coin_flicker(void) { void coin_collected(void) { spawn_object(o, MODEL_SPARKLES, bhvGoldenCoinSparkles); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } void bhv_moving_yellow_coin_init(void) { @@ -80,11 +80,11 @@ void bhv_moving_yellow_coin_loop(void) { break; case MOV_YCOIN_ACT_LAVA_DEATH: - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; case MOV_YCOIN_ACT_DEATH_PLANE_DEATH: - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; } @@ -206,11 +206,11 @@ void bhv_blue_coin_sliding_loop(void) { break; case 100: - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; case 101: - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; } diff --git a/src/game/behaviors/mr_blizzard.inc.c b/src/game/behaviors/mr_blizzard.inc.c index e1d35583..52a93d72 100644 --- a/src/game/behaviors/mr_blizzard.inc.c +++ b/src/game/behaviors/mr_blizzard.inc.c @@ -37,8 +37,8 @@ void mr_blizzard_spawn_white_particles(s8 count, s8 offsetY, s8 forwardVelBase, void bhv_mr_blizzard_init(void) { if (o->oBehParams2ndByte == 1) { o->oAction = 7; - o->oMrBlizzardUnk10C = 24.0f; - o->oMrBlizzardUnk1AC = o->oMoveAngleYaw; + o->oMrBlizzardGraphYOffset = 24.0f; + o->oMrBlizzardTargetMoveYaw = o->oMoveAngleYaw; } else { if (o->oBehParams2ndByte != 0) { if (save_file_get_flags() & SAVE_FLAG_CAP_ON_MR_BLIZZARD) { @@ -46,19 +46,19 @@ void bhv_mr_blizzard_init(void) { } } - o->oMrBlizzardUnk10C = -200.0f; - o->oMrBlizzardUnkF8 = NULL; + o->oMrBlizzardGraphYOffset = -200.0f; + o->oMrBlizzardHeldObj = NULL; } } static void mr_blizzard_act_0(void) { - if (o->oMrBlizzardUnkF8 == NULL && cur_obj_init_anim_check_frame(0, 5)) { - o->oMrBlizzardUnkF8 = spawn_object_relative(0, -70, (s32)(o->oMrBlizzardUnk10C + 153.0f), 0, o, + if (o->oMrBlizzardHeldObj == NULL && cur_obj_init_anim_check_frame(0, 5)) { + o->oMrBlizzardHeldObj = spawn_object_relative(0, -70, (s32)(o->oMrBlizzardGraphYOffset + 153.0f), 0, o, MODEL_WHITE_PARTICLE, bhvMrBlizzardSnowball); } else if (cur_obj_check_anim_frame(10)) { - o->prevObj = o->oMrBlizzardUnkF8; + o->prevObj = o->oMrBlizzardHeldObj; } else if (cur_obj_check_if_near_animation_end()) { - if (o->oMrBlizzardUnk10C < 0.0f) { + if (o->oMrBlizzardGraphYOffset < 0.0f) { o->oAction = 1; } else { o->oAction = 3; @@ -71,7 +71,7 @@ static void mr_blizzard_act_1(void) { cur_obj_play_sound_2(SOUND_OBJ_SNOW_SAND2); o->oAction = 2; o->oMoveAngleYaw = o->oAngleToMario; - o->oMrBlizzardUnkFC = 42.0f; + o->oMrBlizzardGraphYVel = 42.0f; mr_blizzard_spawn_white_particles(8, -10, 15, 20, 10); cur_obj_unhide(); @@ -82,19 +82,19 @@ static void mr_blizzard_act_1(void) { } static void mr_blizzard_act_2(void) { - if (o->oMrBlizzardUnk100 != 0) { - o->oMrBlizzardUnk100 -= 1; - } else if ((o->oMrBlizzardUnk10C += o->oMrBlizzardUnkFC) > 24.0f) { - o->oPosY += o->oMrBlizzardUnk10C - 24.0f; - o->oMrBlizzardUnk10C = 24.0f; + if (o->oMrBlizzardTimer != 0) { + o->oMrBlizzardTimer -= 1; + } else if ((o->oMrBlizzardGraphYOffset += o->oMrBlizzardGraphYVel) > 24.0f) { + o->oPosY += o->oMrBlizzardGraphYOffset - 24.0f; + o->oMrBlizzardGraphYOffset = 24.0f; mr_blizzard_spawn_white_particles(8, -20, 20, 15, 10); o->oAction = 3; - o->oVelY = o->oMrBlizzardUnkFC; - } else if ((o->oMrBlizzardUnkFC -= 10.0f) < 0.0f) { - o->oMrBlizzardUnkFC = 47.0f; - o->oMrBlizzardUnk100 = 5; + o->oVelY = o->oMrBlizzardGraphYVel; + } else if ((o->oMrBlizzardGraphYVel -= 10.0f) < 0.0f) { + o->oMrBlizzardGraphYVel = 47.0f; + o->oMrBlizzardTimer = 5; } } @@ -108,36 +108,36 @@ static void mr_blizzard_act_3(void) { val06 = o->oAngleToMario - o->oMoveAngleYaw; if (val06 != 0) { if (val06 < 0) { - o->oMrBlizzardUnk108 -= 8.0f; + o->oMrBlizzardChangeInDizziness -= 8.0f; } else { - o->oMrBlizzardUnk108 += 8.0f; + o->oMrBlizzardChangeInDizziness += 8.0f; } - o->oMrBlizzardUnk104 += o->oMrBlizzardUnk108; - } else if (o->oMrBlizzardUnk104 != 0.0f) { - val00 = o->oMrBlizzardUnk104; - if (o->oMrBlizzardUnk104 < 0.0f) { - approach_f32_ptr(&o->oMrBlizzardUnk108, 1000.0f, 80.0f); + o->oMrBlizzardDizziness += o->oMrBlizzardChangeInDizziness; + } else if (o->oMrBlizzardDizziness != 0.0f) { + val00 = o->oMrBlizzardDizziness; + if (o->oMrBlizzardDizziness < 0.0f) { + approach_f32_ptr(&o->oMrBlizzardChangeInDizziness, 1000.0f, 80.0f); } else { - approach_f32_ptr(&o->oMrBlizzardUnk108, -1000.0f, 80.0f); + approach_f32_ptr(&o->oMrBlizzardChangeInDizziness, -1000.0f, 80.0f); } - o->oMrBlizzardUnk104 += o->oMrBlizzardUnk108; - if (val00 * o->oMrBlizzardUnk104 < 0.0f) { - o->oMrBlizzardUnk104 = o->oMrBlizzardUnk108 = 0.0f; + o->oMrBlizzardDizziness += o->oMrBlizzardChangeInDizziness; + if (val00 * o->oMrBlizzardDizziness < 0.0f) { + o->oMrBlizzardDizziness = o->oMrBlizzardChangeInDizziness = 0.0f; } } - if (o->oMrBlizzardUnk104 != 0.0f) { + if (o->oMrBlizzardDizziness != 0.0f) { if (absi(o->oFaceAngleRoll) > 0x3000) { o->oAction = 6; - o->prevObj = o->oMrBlizzardUnkF8 = NULL; + o->prevObj = o->oMrBlizzardHeldObj = NULL; cur_obj_become_intangible(); } } else if (o->oDistanceToMario > 1500.0f) { o->oAction = 5; - o->oMrBlizzardUnk108 = 300.0f; - o->prevObj = o->oMrBlizzardUnkF8 = NULL; + o->oMrBlizzardChangeInDizziness = 300.0f; + o->prevObj = o->oMrBlizzardHeldObj = NULL; } else if (o->oTimer > 60 && abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw) < 0x800) { o->oAction = 4; } @@ -147,8 +147,8 @@ static void mr_blizzard_act_3(void) { static void mr_blizzard_act_6(void) { struct Object *val04; - if (clamp_f32(&o->oMrBlizzardUnk104, -0x4000, 0x4000)) { - if (o->oMrBlizzardUnk108 != 0.0f) { + if (clamp_f32(&o->oMrBlizzardDizziness, -0x4000, 0x4000)) { + if (o->oMrBlizzardChangeInDizziness != 0.0f) { cur_obj_play_sound_2(SOUND_OBJ_SNOW_SAND1); if (o->oAnimState) { save_file_clear_flags(SAVE_FLAG_CAP_ON_MR_BLIZZARD); @@ -163,16 +163,16 @@ static void mr_blizzard_act_6(void) { o->oAnimState = 0; } - o->oMrBlizzardUnk108 = 0.0f; + o->oMrBlizzardChangeInDizziness = 0.0f; } } else { - if (o->oMrBlizzardUnk104 < 0) { - o->oMrBlizzardUnk108 -= 40.0f; + if (o->oMrBlizzardDizziness < 0) { + o->oMrBlizzardChangeInDizziness -= 40.0f; } else { - o->oMrBlizzardUnk108 += 40.0f; + o->oMrBlizzardChangeInDizziness += 40.0f; } - o->oMrBlizzardUnk104 += o->oMrBlizzardUnk108; + o->oMrBlizzardDizziness += o->oMrBlizzardChangeInDizziness; } if (o->oTimer >= 30) { @@ -180,9 +180,9 @@ static void mr_blizzard_act_6(void) { cur_obj_play_sound_2(SOUND_OBJ_ENEMY_DEFEAT_SHRINK); } - if (o->oMrBlizzardUnkF4 != 0.0f) { - if ((o->oMrBlizzardUnkF4 -= 0.03f) <= 0.0f) { - o->oMrBlizzardUnkF4 = 0.0f; + if (o->oMrBlizzardScale != 0.0f) { + if ((o->oMrBlizzardScale -= 0.03f) <= 0.0f) { + o->oMrBlizzardScale = 0.0f; if (!(o->oBehParams & 0x0000FF00)) { obj_spawn_loot_yellow_coins(o, o->oNumLootCoins, 20.0f); set_object_respawn_info_bits(o, 1); @@ -192,10 +192,10 @@ static void mr_blizzard_act_6(void) { cur_obj_init_animation_with_sound(1); o->oAction = 0; - o->oMrBlizzardUnkF4 = 1.0f; - o->oMrBlizzardUnk10C = -200.0f; + o->oMrBlizzardScale = 1.0f; + o->oMrBlizzardGraphYOffset = -200.0f; o->oFaceAngleRoll = 0; - o->oMrBlizzardUnk104 = o->oMrBlizzardUnk108 = 0.0f; + o->oMrBlizzardDizziness = o->oMrBlizzardChangeInDizziness = 0.0f; } } } @@ -203,39 +203,39 @@ static void mr_blizzard_act_6(void) { static void mr_blizzard_act_4(void) { if (cur_obj_init_anim_check_frame(1, 7)) { cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT); - o->prevObj = o->oMrBlizzardUnkF8 = NULL; + o->prevObj = o->oMrBlizzardHeldObj = NULL; } else if (cur_obj_check_if_near_animation_end()) { o->oAction = 0; } } static void mr_blizzard_act_5(void) { - o->oMrBlizzardUnk104 += o->oMrBlizzardUnk108; + o->oMrBlizzardDizziness += o->oMrBlizzardChangeInDizziness; - if (o->oMrBlizzardUnk104 < 0.0f) { - o->oMrBlizzardUnk108 += 150.0f; + if (o->oMrBlizzardDizziness < 0.0f) { + o->oMrBlizzardChangeInDizziness += 150.0f; } else { - o->oMrBlizzardUnk108 -= 150.0f; + o->oMrBlizzardChangeInDizziness -= 150.0f; } - if (approach_f32_ptr(&o->oMrBlizzardUnk10C, -200.0f, 4.0f)) { + if (approach_f32_ptr(&o->oMrBlizzardGraphYOffset, -200.0f, 4.0f)) { o->oAction = 0; cur_obj_init_animation_with_sound(1); } } static void mr_blizzard_act_7(void) { - if (o->oMrBlizzardUnk100 != 0) { - cur_obj_rotate_yaw_toward(o->oMrBlizzardUnk1AC, 3400); + if (o->oMrBlizzardTimer != 0) { + cur_obj_rotate_yaw_toward(o->oMrBlizzardTargetMoveYaw, 3400); - if (--o->oMrBlizzardUnk100 == 0) { + if (--o->oMrBlizzardTimer == 0) { cur_obj_play_sound_2(SOUND_OBJ_MR_BLIZZARD_ALERT); - if (o->oMrBlizzardUnk110 > 700) { - o->oMrBlizzardUnk1AC += 0x8000; + if (o->oMrBlizzardDistFromHome > 700) { + o->oMrBlizzardTargetMoveYaw += 0x8000; o->oVelY = 25.0f; - o->oMrBlizzardUnk100 = 30; - o->oMrBlizzardUnk110 = 0; + o->oMrBlizzardTimer = 30; + o->oMrBlizzardDistFromHome = 0; } else { o->oForwardVel = 10.0f; o->oVelY = 50.0f; @@ -244,14 +244,14 @@ static void mr_blizzard_act_7(void) { } } else if (o->oMoveFlags & 0x00000003) { cur_obj_play_sound_2(SOUND_OBJ_SNOW_SAND1); - if (o->oMrBlizzardUnk110 != 0) { - o->oMrBlizzardUnk110 = (s32) cur_obj_lateral_dist_to_home(); + if (o->oMrBlizzardDistFromHome != 0) { + o->oMrBlizzardDistFromHome = (s32) cur_obj_lateral_dist_to_home(); } else { - o->oMrBlizzardUnk110 = 700; + o->oMrBlizzardDistFromHome = 700; } o->oForwardVel = 0.0f; - o->oMrBlizzardUnk100 = 15; + o->oMrBlizzardTimer = 15; } } @@ -285,11 +285,11 @@ void bhv_mr_blizzard_update(void) { break; } - o->oFaceAngleRoll = o->oMrBlizzardUnk104; - o->oGraphYOffset = o->oMrBlizzardUnk10C + absf(20.0f * sins(o->oFaceAngleRoll)) - - 40.0f * (1.0f - o->oMrBlizzardUnkF4); + o->oFaceAngleRoll = o->oMrBlizzardDizziness; + o->oGraphYOffset = o->oMrBlizzardGraphYOffset + absf(20.0f * sins(o->oFaceAngleRoll)) + - 40.0f * (1.0f - o->oMrBlizzardScale); - cur_obj_scale(o->oMrBlizzardUnkF4); + cur_obj_scale(o->oMrBlizzardScale); cur_obj_move_standard(78); obj_check_attacks(&sMrBlizzardHitbox, o->oAction); } diff --git a/src/game/behaviors/mr_i.inc.c b/src/game/behaviors/mr_i.inc.c index 4e03f8f1..57a4a2f1 100644 --- a/src/game/behaviors/mr_i.inc.c +++ b/src/game/behaviors/mr_i.inc.c @@ -17,7 +17,7 @@ void mr_i_piranha_particle_act_0(void) { cur_obj_update_floor_and_walls(); if (0x8000 & o->oInteractStatus) o->oAction = 1; - else if ((o->oTimer >= 101) || (0x200 & o->oMoveFlags) || (8 & (s16) o->activeFlags)) { + else if ((o->oTimer >= 101) || (0x200 & o->oMoveFlags) || o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) { obj_mark_for_deletion(o); spawn_mist_particles(); } @@ -48,7 +48,7 @@ void spawn_mr_i_particle(void) { void bhv_mr_i_body_loop(void) { obj_copy_pos_and_angle(o, o->parentObj); - if (!(8 & o->activeFlags)) { + if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { obj_copy_scale(o, o->parentObj); obj_set_parent_relative_pos(o, 0, 0, o->header.gfx.scale[1] * 100.0f); obj_build_transform_from_pos_and_angle(o, 44, 15); @@ -63,7 +63,7 @@ void bhv_mr_i_body_loop(void) { if (o->oAnimState == 15) o->parentObj->oMrIUnk110 = 0; } - if (!o->parentObj->activeFlags) + if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) obj_mark_for_deletion(o); } @@ -122,7 +122,7 @@ void mr_i_act_3(void) { obj_mark_for_deletion(o); } -void mr_i_act_2() { +void mr_i_act_2(void) { s16 sp1E; s16 sp1C; sp1E = o->oMoveAngleYaw; @@ -248,7 +248,7 @@ void bhv_mr_i_loop(void) { obj_set_hitbox(o, &sMrIHitbox); cur_obj_call_action_function(sMrIActions); if (o->oAction != 3) - if (o->oDistanceToMario > 3000.0f || o->activeFlags & 8) + if (o->oDistanceToMario > 3000.0f || o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) o->oAction = 0; o->oInteractStatus = 0; } diff --git a/src/game/behaviors/mushroom_1up.inc.c b/src/game/behaviors/mushroom_1up.inc.c index ad4d995f..103534df 100644 --- a/src/game/behaviors/mushroom_1up.inc.c +++ b/src/game/behaviors/mushroom_1up.inc.c @@ -6,7 +6,7 @@ void bhv_1up_interact(void) { if (obj_check_if_collided_with_object(o, gMarioObject) == 1) { play_sound(SOUND_GENERAL_COLLECT_1UP, gDefaultSoundArgs); gMarioState->numLives++; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -21,10 +21,10 @@ void bhv_1up_init(void) { bhv_1up_common_init(); if (o->oBehParams2ndByte == 1) { if ((save_file_get_flags() & 0x50) == 0) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } else if (o->oBehParams2ndByte == 2) { if ((save_file_get_flags() & 0xa0) == 0) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -254,7 +254,7 @@ void bhv_1up_hidden_trigger_loop(void) { if (sp1C != NULL) sp1C->o1UpHiddenUnkF4++; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -302,7 +302,7 @@ void bhv_1up_hidden_in_pole_trigger_loop(void) { ; } - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -315,6 +315,6 @@ void bhv_1up_hidden_in_pole_spawner_loop(void) { spawn_object_relative(0, 0, sp2F * -200, 0, o, MODEL_NONE, bhvHidden1upInPoleTrigger); } - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } diff --git a/src/game/behaviors/orange_number.inc.c b/src/game/behaviors/orange_number.inc.c index f2d9e917..84bf01e9 100644 --- a/src/game/behaviors/orange_number.inc.c +++ b/src/game/behaviors/orange_number.inc.c @@ -15,6 +15,6 @@ void bhv_orange_number_loop(void) { if (o->oTimer == 35) { sp1C = spawn_object(o, MODEL_SPARKLES, bhvGoldenCoinSparkles); sp1C->oPosY -= 30.f; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } diff --git a/src/game/behaviors/platform_on_track.inc.c b/src/game/behaviors/platform_on_track.inc.c index 2d549bd4..f33a1656 100644 --- a/src/game/behaviors/platform_on_track.inc.c +++ b/src/game/behaviors/platform_on_track.inc.c @@ -8,7 +8,7 @@ /** * Collision models for the different types of platforms. */ -static void *sPlatformOnTrackCollisionModels[] = { +static void const *sPlatformOnTrackCollisionModels[] = { /* PLATFORM_ON_TRACK_TYPE_CARPET */ rr_seg7_collision_07029038, /* PLATFORM_ON_TRACK_TYPE_SKI_LIFT */ ccm_seg7_collision_070163F8, /* PLATFORM_ON_TRACK_TYPE_CHECKERED */ checkerboard_platform_seg8_collision_0800D710, @@ -18,7 +18,7 @@ static void *sPlatformOnTrackCollisionModels[] = { /** * Paths for the different instances of these platforms. */ -static void *sPlatformOnTrackPaths[] = { +static void const *sPlatformOnTrackPaths[] = { rr_seg7_trajectory_0702EC3C, rr_seg7_trajectory_0702ECC0, ccm_seg7_trajectory_0701669C, bitfs_seg7_trajectory_070159AC, hmc_seg7_trajectory_0702B86C, lll_seg7_trajectory_0702856C, lll_seg7_trajectory_07028660, rr_seg7_trajectory_0702ED9C, rr_seg7_trajectory_0702EEE0, diff --git a/src/game/behaviors/pyramid_elevator.inc.c b/src/game/behaviors/pyramid_elevator.inc.c index 4754fc5d..4379e70d 100644 --- a/src/game/behaviors/pyramid_elevator.inc.c +++ b/src/game/behaviors/pyramid_elevator.inc.c @@ -79,7 +79,7 @@ void bhv_pyramid_elevator_trajectory_marker_ball_loop(void) { if (elevator != NULL) { if (elevator->oAction != PYRAMID_ELEVATOR_IDLE) { - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } } diff --git a/src/game/behaviors/pyramid_top.inc.c b/src/game/behaviors/pyramid_top.inc.c index 536ce96f..824d24f2 100644 --- a/src/game/behaviors/pyramid_top.inc.c +++ b/src/game/behaviors/pyramid_top.inc.c @@ -87,7 +87,7 @@ void bhv_pyramid_top_explode(void) { } // Deactivate the pyramid top. - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } void bhv_pyramid_top_loop(void) { @@ -137,7 +137,7 @@ void bhv_pyramid_top_fragment_loop(void) { o->oFaceAnglePitch += 0x1000; if (o->oTimer == 60) { - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -150,6 +150,6 @@ void bhv_pyramid_pillar_touch_detector_loop(void) { if (obj_check_if_collided_with_object(o, gMarioObject) == 1) { // Increase the pyramid top's count of pillars touched. o->parentObj->oPyramidTopPillarsTouched++; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } diff --git a/src/game/behaviors/rotating_octagonal_plat.inc.c b/src/game/behaviors/rotating_octagonal_plat.inc.c index 3a8b0e8e..86d758c8 100644 --- a/src/game/behaviors/rotating_octagonal_plat.inc.c +++ b/src/game/behaviors/rotating_octagonal_plat.inc.c @@ -1,6 +1,6 @@ // rotating_octagonal_plat.inc.c -void *D_80331A44[] = { +void const *D_80331A44[] = { bits_seg7_collision_0701AA84, rr_seg7_collision_07029508, }; diff --git a/src/game/behaviors/scuttlebug.inc.c b/src/game/behaviors/scuttlebug.inc.c index 31de84a5..40d45461 100644 --- a/src/game/behaviors/scuttlebug.inc.c +++ b/src/game/behaviors/scuttlebug.inc.c @@ -12,12 +12,12 @@ struct ObjectHitbox sScuttlebugHitbox = { /* hurtboxHeight: */ 60, }; -s32 update_angle_from_move_flags(s32 *a0) { - if (o->oMoveFlags & 0x200) { - *a0 = o->oWallAngle; +s32 update_angle_from_move_flags(s32 *angle) { + if (o->oMoveFlags & OBJ_MOVE_HIT_WALL) { + *angle = o->oWallAngle; return 1; - } else if (o->oMoveFlags & 0x400) { - *a0 = o->oMoveAngleYaw + 0x8000; + } else if (o->oMoveFlags & OBJ_MOVE_HIT_EDGE) { + *angle = o->oMoveAngleYaw + 0x8000; return -1; } return 0; @@ -110,7 +110,7 @@ void bhv_scuttlebug_loop(void) { if (o->parentObj != o) { if (obj_is_hidden(o)) obj_mark_for_deletion(o); - if (o->activeFlags == 0) + if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED) o->parentObj->oScuttlebugSpawnerUnk88 = 1; } cur_obj_move_standard(-50); diff --git a/src/game/behaviors/seesaw_platform.inc.c b/src/game/behaviors/seesaw_platform.inc.c index 71cbba06..81a47e76 100644 --- a/src/game/behaviors/seesaw_platform.inc.c +++ b/src/game/behaviors/seesaw_platform.inc.c @@ -6,7 +6,7 @@ /** * Collision models for the different seesaw platforms. */ -static void *sSeesawPlatformCollisionModels[] = { +static void const *sSeesawPlatformCollisionModels[] = { bitdw_seg7_collision_0700F70C, bits_seg7_collision_0701ADD8, bits_seg7_collision_0701AE5C, bob_seg7_collision_bridge, bitfs_seg7_collision_07015928, rr_seg7_collision_07029750, rr_seg7_collision_07029858, vcutm_seg7_collision_0700AC44, diff --git a/src/game/behaviors/sliding_platform_2.inc.c b/src/game/behaviors/sliding_platform_2.inc.c index bb9b7ced..fc0351ac 100644 --- a/src/game/behaviors/sliding_platform_2.inc.c +++ b/src/game/behaviors/sliding_platform_2.inc.c @@ -1,6 +1,6 @@ // sliding_platform_2.inc.c -void *D_80331A24[] = { +void const *D_80331A24[] = { bits_seg7_collision_0701A9A0, bits_seg7_collision_0701AA0C, bitfs_seg7_collision_07015714, diff --git a/src/game/behaviors/snow_mound.inc.c b/src/game/behaviors/snow_mound.inc.c index 1e9218d7..f8fcc539 100644 --- a/src/game/behaviors/snow_mound.inc.c +++ b/src/game/behaviors/snow_mound.inc.c @@ -18,7 +18,7 @@ void bhv_sliding_snow_mound_loop(void) { o->oPosY += o->oVelY; o->oPosZ = o->oHomeZ - 2.0f; if (o->oTimer > 50) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; break; } } diff --git a/src/game/behaviors/snowman.inc.c b/src/game/behaviors/snowman.inc.c index 33857d0c..174123d1 100644 --- a/src/game/behaviors/snowman.inc.c +++ b/src/game/behaviors/snowman.inc.c @@ -97,7 +97,7 @@ void snowmans_bottom_act_2(void) { if (o->oTimer == 200) { create_respawner(MODEL_CCM_SNOWMAN_BASE, bhvSnowmansBottom, 3000); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -228,9 +228,9 @@ void bhv_snowmans_head_loop(void) { void bhv_snowmans_body_checkpoint_loop(void) { if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 800)) { o->parentObj->oSnowmansBottomUnk1AC++; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } - if (o->parentObj->activeFlags == 0) - o->activeFlags = 0; + if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } diff --git a/src/game/behaviors/sparkle_spawn_star.inc.c b/src/game/behaviors/sparkle_spawn_star.inc.c index c444cbba..b6608708 100644 --- a/src/game/behaviors/sparkle_spawn_star.inc.c +++ b/src/game/behaviors/sparkle_spawn_star.inc.c @@ -58,7 +58,7 @@ void bhv_spawned_star_loop(void) { if (o->oTimer == 0) { cutscene_object(CUTSCENE_STAR_SPAWN, o); set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); - o->activeFlags |= 0x20; + o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; o->oAngleVelYaw = 0x800; if (o->oBehParams2ndByte == 0) set_home_to_mario(); @@ -98,7 +98,7 @@ void bhv_spawned_star_loop(void) { } else if (o->oAction == 2) { if (gCamera->cutscene == 0 && gRecentCutscene == 0) { clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); - o->activeFlags &= ~0x20; + o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP; o->oAction++; } } else { diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c index 2571f3d6..9a194a5c 100644 --- a/src/game/behaviors/spawn_star.inc.c +++ b/src/game/behaviors/spawn_star.inc.c @@ -13,12 +13,12 @@ static struct ObjectHitbox sCollectStarHitbox = { }; void bhv_collect_star_init(void) { - s8 sp1F; - u8 sp1E; + s8 starId; + u8 currentLevelStarFlags; - sp1F = (o->oBehParams >> 24) & 0xFF; - sp1E = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1); - if (sp1E & (1 << sp1F)) { + starId = (o->oBehParams >> 24) & 0xFF; + currentLevelStarFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1); + if (currentLevelStarFlags & (1 << starId)) { o->header.gfx.sharedChild = gLoadedGraphNodes[MODEL_TRANSPARENT_STAR]; } else { o->header.gfx.sharedChild = gLoadedGraphNodes[MODEL_STAR]; @@ -48,7 +48,7 @@ void bhv_star_spawn_init(void) { cutscene_object(CUTSCENE_RED_COIN_STAR_SPAWN, o); set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); - o->activeFlags |= 0x20; + o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; cur_obj_become_intangible(); } @@ -98,7 +98,7 @@ void bhv_star_spawn_loop(void) { if (o->oTimer == 20) { gObjCutsceneDone = TRUE; clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); - o->activeFlags &= ~0x20; + o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP; } if (o->oInteractStatus & INT_STATUS_INTERACTED) { @@ -152,7 +152,7 @@ void bhv_hidden_red_coin_star_init(void) { sp30 = spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0); sp30->oBehParams = o->oBehParams; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } o->oHiddenStarTriggerCounter = 8 - sp36; @@ -170,7 +170,7 @@ void bhv_hidden_red_coin_star_loop(void) { if (o->oTimer > 2) { spawn_red_coin_cutscene_star(o->oPosX, o->oPosY, o->oPosZ); spawn_mist_particles(); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } break; } diff --git a/src/game/behaviors/spindrift.inc.c b/src/game/behaviors/spindrift.inc.c index ad6a798f..bc04018e 100644 --- a/src/game/behaviors/spindrift.inc.c +++ b/src/game/behaviors/spindrift.inc.c @@ -13,7 +13,7 @@ struct ObjectHitbox sSpindriftHitbox = { }; void bhv_spindrift_loop(void) { - o->activeFlags |= 0x400; + o->activeFlags |= ACTIVE_FLAG_UNK10; if (cur_obj_set_hitbox_and_die_if_attacked(&sSpindriftHitbox, SOUND_OBJ_DYING_ENEMY1, 0)) cur_obj_change_action(1); cur_obj_update_floor_and_walls(); diff --git a/src/game/behaviors/thwomp.inc.c b/src/game/behaviors/thwomp.inc.c index 5f46b9ef..fdb3345b 100644 --- a/src/game/behaviors/thwomp.inc.c +++ b/src/game/behaviors/thwomp.inc.c @@ -2,8 +2,8 @@ void grindel_thwomp_act_4(void) { if (o->oTimer == 0) - o->oThwompUnkF4 = random_float() * 10.0f + 20.0f; - if (o->oTimer > o->oThwompUnkF4) + o->oThwompRandomTimer = random_float() * 10.0f + 20.0f; + if (o->oTimer > o->oThwompRandomTimer) o->oAction = 0; } @@ -29,8 +29,8 @@ void grindel_thwomp_act_3(void) { void grindel_thwomp_act_1(void) { if (o->oTimer == 0) - o->oThwompUnkF4 = random_float() * 30.0f + 10.0f; - if (o->oTimer > o->oThwompUnkF4) + o->oThwompRandomTimer = random_float() * 30.0f + 10.0f; + if (o->oTimer > o->oThwompRandomTimer) o->oAction = 2; } diff --git a/src/game/behaviors/tox_box.inc.c b/src/game/behaviors/tox_box.inc.c index c083944d..2bbb40bf 100644 --- a/src/game/behaviors/tox_box.inc.c +++ b/src/game/behaviors/tox_box.inc.c @@ -13,15 +13,15 @@ void tox_box_shake_screen(void) { cur_obj_shake_screen(SHAKE_POS_SMALL); } -void tox_box_move(f32 a0, f32 a1, s16 a2, s16 a3) // 0x18 0x1c 0x22 0x26 +void tox_box_move(f32 forwardVel, f32 a1, s16 deltaPitch, s16 deltaRoll) { o->oPosY = 99.41124 * sins((f32)(o->oTimer + 1) / 8 * 0x8000) + o->oHomeY + 3.0f; - o->oForwardVel = a0; + o->oForwardVel = forwardVel; o->oUnkC0 = a1; - o->oFaceAnglePitch += a2; + o->oFaceAnglePitch += deltaPitch; if ((s16) o->oFaceAnglePitch < 0) - a3 = -a3; - o->oFaceAngleRoll += a3; + deltaRoll = -deltaRoll; + o->oFaceAngleRoll += deltaRoll; cur_obj_set_pos_via_transform(); if (o->oTimer == 7) { o->oAction = cur_obj_progress_direction_table(); diff --git a/src/game/behaviors/treasure_chest.inc.c b/src/game/behaviors/treasure_chest.inc.c index 94f30629..ca00ec2d 100644 --- a/src/game/behaviors/treasure_chest.inc.c +++ b/src/game/behaviors/treasure_chest.inc.c @@ -134,7 +134,7 @@ void bhv_treasure_chest_ship_loop(void) { set_environmental_camera_shake(SHAKE_ENV_JRB_SHIP_DRAIN); if (gEnvironmentRegions[6] < -335) { gEnvironmentRegions[6] = -335; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } break; diff --git a/src/game/behaviors/ttc_cog.inc.c b/src/game/behaviors/ttc_cog.inc.c index fe7a502a..7d15c911 100644 --- a/src/game/behaviors/ttc_cog.inc.c +++ b/src/game/behaviors/ttc_cog.inc.c @@ -7,7 +7,7 @@ /** * Collision model for hexagon and triangle, respectively. */ -static void *sTTCCogCollisionModels[] = { +static Collision const *sTTCCogCollisionModels[] = { ttc_seg7_collision_07015584, ttc_seg7_collision_07015650, }; diff --git a/src/game/behaviors/ttc_pit_block.inc.c b/src/game/behaviors/ttc_pit_block.inc.c index d81dc227..1f3c221f 100644 --- a/src/game/behaviors/ttc_pit_block.inc.c +++ b/src/game/behaviors/ttc_pit_block.inc.c @@ -7,7 +7,7 @@ /** * Collision models. The second one is unused. */ -static void *sTTCPitBlockCollisionModels[] = { +static Collision const *sTTCPitBlockCollisionModels[] = { ttc_seg7_collision_07015754, ttc_seg7_collision_070157D8, }; diff --git a/src/game/behaviors/ttc_rotating_solid.inc.c b/src/game/behaviors/ttc_rotating_solid.inc.c index 1f9e8ada..238a8835 100644 --- a/src/game/behaviors/ttc_rotating_solid.inc.c +++ b/src/game/behaviors/ttc_rotating_solid.inc.c @@ -7,7 +7,7 @@ /** * The collision models for cube and triangular prism, respectively. */ -static void *sTTCRotatingSolidCollisionModels[] = { +static void const *sTTCRotatingSolidCollisionModels[] = { ttc_seg7_collision_07014F70, ttc_seg7_collision_07015008, }; diff --git a/src/game/behaviors/ttc_treadmill.inc.c b/src/game/behaviors/ttc_treadmill.inc.c index b4d49f61..537540b1 100644 --- a/src/game/behaviors/ttc_treadmill.inc.c +++ b/src/game/behaviors/ttc_treadmill.inc.c @@ -9,7 +9,7 @@ /** * Collision models for the different sized treadmills. */ -static void *sTTCTreadmillCollisionModels[] = { +static Collision const *sTTCTreadmillCollisionModels[] = { ttc_seg7_collision_070152B4, ttc_seg7_collision_070153E0, }; diff --git a/src/game/behaviors/tuxie.inc.c b/src/game/behaviors/tuxie.inc.c index 1a1c204b..1dae5850 100644 --- a/src/game/behaviors/tuxie.inc.c +++ b/src/game/behaviors/tuxie.inc.c @@ -134,7 +134,7 @@ void (*sTuxiesMotherActions[])(void) = { tuxies_mother_act_0, tuxies_mother_act_ tuxies_mother_act_2 }; void bhv_tuxies_mother_loop(void) { - o->activeFlags |= 0x400; + o->activeFlags |= ACTIVE_FLAG_UNK10; cur_obj_update_floor_and_walls(); cur_obj_call_action_function(sTuxiesMotherActions); cur_obj_move_standard(-78); diff --git a/src/game/behaviors/water_objs.inc.c b/src/game/behaviors/water_objs.inc.c index 0926a0c4..e907e93e 100644 --- a/src/game/behaviors/water_objs.inc.c +++ b/src/game/behaviors/water_objs.inc.c @@ -61,7 +61,7 @@ void bhv_small_water_wave_loop(void) { o->header.gfx.scale[1] = sins(o->oWaterObjUnkF8) * 0.2 + 1.0; o->oWaterObjUnkF8 += o->oWaterObjUnk100; if (o->oPosY > sp1C) { - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; o->oPosY += 5.0f; if (gFreeObjectList.next != NULL) spawn_object(o, MODEL_SMALL_WATER_SPLASH, bhvObjectWaterSplash); diff --git a/src/game/behaviors/water_ring.inc.c b/src/game/behaviors/water_ring.inc.c index dfb4482b..5fa6efb8 100644 --- a/src/game/behaviors/water_ring.inc.c +++ b/src/game/behaviors/water_ring.inc.c @@ -96,7 +96,7 @@ void water_ring_act_collected(void) { f32 avgScale = (f32) o->oTimer * 0.2 + o->oWaterRingAvgScale; if (o->oTimer >= 21) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; o->oOpacity -= 10; if (o->oOpacity < 0) @@ -116,7 +116,7 @@ void water_ring_act_not_collected(void) { if (o->oTimer >= 226) { o->oOpacity -= 2; if (o->oOpacity < 3) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } water_ring_check_collection(avgScale, ringManager); @@ -207,7 +207,7 @@ void manta_water_ring_act_not_collected(void) { if (o->oTimer >= 151) { o->oOpacity -= 2; if (o->oOpacity < 3) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } water_ring_check_collection(avgScale, ringManager); diff --git a/src/game/behaviors/water_splashes_and_waves.inc.c b/src/game/behaviors/water_splashes_and_waves.inc.c index 07722c04..c70a95ae 100644 --- a/src/game/behaviors/water_splashes_and_waves.inc.c +++ b/src/game/behaviors/water_splashes_and_waves.inc.c @@ -12,7 +12,7 @@ struct WaterDropletParams sWaterSplashDropletParams = { }; // Water droplets from Mario jumping in shallow water. -struct WaterDropletParams sShallowWaterSplashDropletParams = { +struct WaterDropletParams gShallowWaterSplashDropletParams = { /* Flags */ WATER_DROPLET_FLAG_RAND_ANGLE | WATER_DROPLET_FLAG_SET_Y_TO_WATER_LEVEL, /* Model */ MODEL_WHITE_PARTICLE_SMALL, /* Behavior */ bhvWaterDroplet, @@ -34,10 +34,10 @@ struct WaterDropletParams sWaterDropletFishParams = { }; // Water droplets from Mario running in shallow water. -struct WaterDropletParams sShallowWaterWaveDropletParams = { +struct WaterDropletParams gShallowWaterWaveDropletParams = { /* Flags */ WATER_DROPLET_FLAG_RAND_ANGLE_INCR_PLUS_8000 | WATER_DROPLET_FLAG_RAND_ANGLE | WATER_DROPLET_FLAG_SET_Y_TO_WATER_LEVEL, - /* Model */ MODEL_WHITE_PARTICLE_SMALL, - /* Behavior */ bhvWaterDroplet, + /* Model */ MODEL_WHITE_PARTICLE_SMALL, + /* Behavior */ bhvWaterDroplet, /* Move angle range */ 0x6000, /* Unused (flag-specific) */ 0, /* Random fvel offset, scale */ 2.0f, 8.0f, @@ -50,7 +50,7 @@ void bhv_water_splash_spawn_droplets(void) { s32 i; if (o->oTimer == 0) o->oPosY = find_water_level(o->oPosX, o->oPosZ); - + if (o->oPosY > -10000.0f) // Make sure it is not at the default water level for (i = 0; i < 3; i++) spawn_water_droplet(o, &sWaterSplashDropletParams); @@ -59,7 +59,7 @@ void bhv_water_splash_spawn_droplets(void) { void bhv_water_droplet_loop(void) { UNUSED u32 unusedVar; f32 waterLevel = find_water_level(o->oPosX, o->oPosZ); - + if (o->oTimer == 0) { if (cur_obj_has_model(MODEL_FISH)) o->header.gfx.node.flags &= ~GRAPH_RENDER_BILLBOARD; @@ -88,7 +88,7 @@ void bhv_idle_water_wave_loop(void) { o->oPosY = gMarioStates->waterLevel + 5; if (!(gMarioObject->oMarioParticleFlags & ACTIVE_PARTICLE_IDLE_WATER_WAVE)) { gMarioObject->oActiveParticleFlags &= (u16)~ACTIVE_PARTICLE_IDLE_WATER_WAVE; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -119,10 +119,10 @@ void bhv_wave_trail_shrink(void) { if (gGlobalTimer & 1) obj_mark_for_deletion(o); o->oPosY = waterLevel + 5.0f; - + if (o->oTimer == 0) o->oWaveTrailSize = o->header.gfx.scale[0]; - + if (o->oAnimState > 3) { o->oWaveTrailSize = o->oWaveTrailSize - 0.1; // Shrink the wave if (o->oWaveTrailSize < 0.0f) diff --git a/src/game/behaviors/water_wave.inc.c b/src/game/behaviors/water_wave.inc.c index 39e316a3..4fae68d9 100644 --- a/src/game/behaviors/water_wave.inc.c +++ b/src/game/behaviors/water_wave.inc.c @@ -8,5 +8,5 @@ void bhv_object_water_wave_init(void) { void bhv_object_water_wave_loop(void) { s32 globalTimer = gGlobalTimer; if ((globalTimer % 16) == 0) - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } diff --git a/src/game/behaviors/whomp.inc.c b/src/game/behaviors/whomp.inc.c index c7c39241..a10ac656 100644 --- a/src/game/behaviors/whomp.inc.c +++ b/src/game/behaviors/whomp.inc.c @@ -151,16 +151,16 @@ void king_whomp_on_ground(void) { } o->oSubAction++; } - o->oWhompUnkF8 = 0; + o->oWhompShakeVal = 0; } else { - if (o->oWhompUnkF8 < 10) { - if (o->oWhompUnkF8 % 2) + if (o->oWhompShakeVal < 10) { + if (o->oWhompShakeVal % 2) o->oPosY += 8.0f; else o->oPosY -= 8.0f; } else o->oSubAction = 10; - o->oWhompUnkF8++; + o->oWhompShakeVal++; } } diff --git a/src/game/behaviors/yoshi.inc.c b/src/game/behaviors/yoshi.inc.c index ed61f400..136a2bda 100644 --- a/src/game/behaviors/yoshi.inc.c +++ b/src/game/behaviors/yoshi.inc.c @@ -12,7 +12,7 @@ void bhv_yoshi_init(void) { o->oInteractionSubtype = INT_SUBTYPE_NPC; if (save_file_get_total_star_count(gCurrSaveFileNum - 1, 0, 24) < 120 || sYoshiDead == TRUE) { - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -35,7 +35,7 @@ void yoshi_walk_loop(void) { if (o->oPosY < 2100.0f) { create_respawner(MODEL_YOSHI, bhvYoshi, 3000); - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -76,9 +76,9 @@ void yoshi_talk_loop(void) { if ((s16) o->oMoveAngleYaw == (s16) o->oAngleToMario) { cur_obj_init_animation(0); if (set_mario_npc_dialog(1) == 2) { - o->activeFlags |= 0x20; + o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_161)) { - o->activeFlags &= ~0x20; + o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP; o->oInteractStatus = 0; o->oHomeX = sYoshiHomeLocations[2]; o->oHomeZ = sYoshiHomeLocations[3]; @@ -125,7 +125,7 @@ void yoshi_finish_jumping_and_despawn_loop(void) { set_mario_npc_dialog(0); gObjCutsceneDone = TRUE; sYoshiDead = 1; - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; } } @@ -176,5 +176,5 @@ void bhv_yoshi_loop(void) { break; } - curr_obj_random_blink(&o->oYoshiUnkF4); + curr_obj_random_blink(&o->oYoshiBlinkTimer); } diff --git a/src/game/camera.c b/src/game/camera.c index 5ae68805..c1f75d2f 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -2,6 +2,7 @@ #define INCLUDED_FROM_CAMERA_C +#include "prevent_bss_reordering.h" #include "sm64.h" #include "camera.h" #include "seq_ids.h" @@ -76,11 +77,11 @@ // BSS /** - * Stores lakitu's position from the last frame, used for transitioning in next_lakitu_state() + * Stores Lakitu's position from the last frame, used for transitioning in next_lakitu_state() */ Vec3f sOldPosition; /** - * Stores lakitu's focus from the last frame, used for transitioning in next_lakitu_state() + * Stores Lakitu's focus from the last frame, used for transitioning in next_lakitu_state() */ Vec3f sOldFocus; /** @@ -105,7 +106,6 @@ s16 sCreditsPlayer2Yaw; */ u8 sFramesPaused; -#ifndef VERSION_EU extern struct CameraFOVStatus sFOVState; extern struct TransitionInfo sModeTransition; extern struct PlayerGeometry sMarioGeometry; @@ -167,7 +167,6 @@ extern struct CutsceneVariable sCutsceneVars[10]; extern s32 gObjCutsceneDone; extern u32 gCutsceneObjSpawn; extern struct Camera *gCamera; -#endif /** * Lakitu's position and focus. @@ -221,7 +220,7 @@ s16 sHandheldShakeRoll; u32 gCutsceneObjSpawn; /** * Controls when an object-based cutscene should end. It's only used in the star spawn cutscenes, but - * yoshi also toggles this. + * Yoshi also toggles this. */ s32 gObjCutsceneDone; @@ -240,8 +239,8 @@ s16 gCameraMovementFlags; s16 unused8033B316; /** - * Flags that change how modes operate and how lakitu moves. - * The most commonly used flag is CAM_FLAG_SMOOTH_MOVEMENT, which makes lakitu fly to the next position, + * Flags that change how modes operate and how Lakitu moves. + * The most commonly used flag is CAM_FLAG_SMOOTH_MOVEMENT, which makes Lakitu fly to the next position, * instead of warping. */ s16 sStatusFlags; @@ -276,22 +275,22 @@ s16 unused8033B3E8; s16 unused8033B3E82; #endif /** - * The angle of the direction vector from the area's center to mario's position. + * The angle of the direction vector from the area's center to Mario's position. */ s16 sAreaYaw; /** - * How much sAreaYaw changed when mario moved. + * How much sAreaYaw changed when Mario moved. */ s16 sAreaYawChange; /** - * Lakitu's distance from mario in C-Down mode + * Lakitu's distance from Mario in C-Down mode */ s16 sLakituDist; /** - * How much lakitu looks down in C-Down mode + * How much Lakitu looks down in C-Down mode */ s16 sLakituPitch; @@ -303,7 +302,7 @@ f32 sZoomAmount; s16 sCSideButtonYaw; /** - * Sound timer used to space out sounds in behind mario mode + * Sound timer used to space out sounds in behind Mario mode */ s16 sBehindMarioSoundTimer; @@ -313,7 +312,7 @@ s16 sBehindMarioSoundTimer; f32 sZeroZoomDist; /** - * The camera's pitch in C-Up mode. Mainly controls mario's head rotation. + * The camera's pitch in C-Up mode. Mainly controls Mario's head rotation. */ s16 sCUpCameraPitch; /** @@ -322,7 +321,7 @@ s16 sCUpCameraPitch; s16 sModeOffsetYaw; /** - * Stores mario's yaw around the stairs, relative to the camera's position. + * Stores Mario's yaw around the stairs, relative to the camera's position. * * Used in update_spiral_stairs_camera() */ @@ -338,12 +337,12 @@ s16 s8DirModeBaseYaw; s16 s8DirModeYawOffset; /** - * The distance that the camera will look ahead of mario in the direction mario is facing. + * The distance that the camera will look ahead of Mario in the direction Mario is facing. */ f32 sPanDistance; /** - * When mario gets in the cannon, it is pointing straight up and rotates down. + * When Mario gets in the cannon, it is pointing straight up and rotates down. * This is used to make the camera start up and rotate down, like the cannon. */ f32 sCannonYOffset; @@ -355,7 +354,7 @@ f32 sCannonYOffset; struct CutsceneVariable sCutsceneVars[10]; struct ModeTransitionInfo sModeInfo; /** - * Offset added to sFixedModeBasePosition when mario is inside, near the castle lobby entrance + * Offset added to sFixedModeBasePosition when Mario is inside, near the castle lobby entrance */ Vec3f sCastleEntranceOffset; @@ -379,7 +378,7 @@ struct ParallelTrackingPoint *sParTrackPath; struct CameraStoredInfo sParTrackTransOff; /** - * The information stored when C-Up is active, used to update lakitu's rotation when exiting C-Up + * The information stored when C-Up is active, used to update Lakitu's rotation when exiting C-Up */ struct CameraStoredInfo sCameraStoreCUp; @@ -651,7 +650,7 @@ void unused_set_camera_pitch_shake_env(s16 shake) { } /** - * Calculates mario's distance to the floor, or the water level if it is above the floor. Then: + * Calculates Mario's distance to the floor, or the water level if it is above the floor. Then: * `posOff` is set to the distance multiplied by posMul and bounded to [-posBound, posBound] * `focOff` is set to the distance multiplied by focMul and bounded to [-focBound, focBound] * @@ -782,7 +781,7 @@ void set_camera_height(struct Camera *c, f32 goalHeight) { goalHeight = camFloorHeight; c->pos[1] = goalHeight; } - // Warp camera to goalHeight if further than 1000 and mario is stuck in the ground + // Warp camera to goalHeight if further than 1000 and Mario is stuck in the ground if (sMarioCamState->action == ACT_BUTT_STUCK_IN_GROUND || sMarioCamState->action == ACT_HEAD_STUCK_IN_GROUND || sMarioCamState->action == ACT_FEET_STUCK_IN_GROUND) { @@ -837,7 +836,7 @@ s16 look_down_slopes(s16 camYaw) { * pan[0] = sins(sMarioCamState->faceAngle[1] + yaw) * sins(0xC00) * dist; * Perhaps, early in development, the pan used to be calculated for both the x and z directions * - * Since this function only affects the camera's focus, mario's movement direction isn't affected. + * Since this function only affects the camera's focus, Mario's movement direction isn't affected. */ void pan_ahead_of_player(struct Camera *c) { f32 dist; @@ -845,10 +844,10 @@ void pan_ahead_of_player(struct Camera *c) { s16 yaw; Vec3f pan = { 0, 0, 0 }; - // Get distance and angle from camera to mario. + // Get distance and angle from camera to Mario. vec3f_get_dist_and_angle(c->pos, sMarioCamState->pos, &dist, &pitch, &yaw); - // The camera will pan ahead up to about 30% of the camera's distance to mario. + // The camera will pan ahead up to about 30% of the camera's distance to Mario. pan[2] = sins(0xC00) * dist; rotate_in_xz(pan, pan, sMarioCamState->faceAngle[1]); @@ -858,21 +857,21 @@ void pan_ahead_of_player(struct Camera *c) { // Only pan left or right pan[2] = 0.f; - // If mario is long jumping, or on a flag pole (but not at the top), then pan in the opposite direction + // If Mario is long jumping, or on a flag pole (but not at the top), then pan in the opposite direction if (sMarioCamState->action == ACT_LONG_JUMP || (sMarioCamState->action != ACT_TOP_OF_POLE && (sMarioCamState->action & ACT_FLAG_ON_POLE))) { pan[0] = -pan[0]; } // Slowly make the actual pan, sPanDistance, approach the calculated pan - // If mario is sleeping, then don't pan + // If Mario is sleeping, then don't pan if (sStatusFlags & CAM_FLAG_SLEEPING) { approach_f32_asymptotic_bool(&sPanDistance, 0.f, 0.025f); } else { approach_f32_asymptotic_bool(&sPanDistance, pan[0], 0.025f); } - // Now apply the pan. It's a dir vector to the left or right, rotated by the camera's yaw to mario + // Now apply the pan. It's a dir vector to the left or right, rotated by the camera's yaw to Mario pan[0] = sPanDistance; yaw = -yaw; rotate_in_xz(pan, pan, yaw); @@ -975,7 +974,7 @@ void radial_camera_move(struct Camera *c) { yawOffset = minAreaYaw; } - // Check if mario stepped on a surface that rotates the camera. For example, when mario enters the + // Check if Mario stepped on a surface that rotates the camera. For example, when Mario enters the // gate in BoB, the camera turns right to face up the hill path if (!(gCameraMovementFlags & CAM_MOVE_ROTATE)) { if (sMarioGeometry.currFloorType == SURFACE_CAMERA_MIDDLE @@ -1061,12 +1060,12 @@ void radial_camera_move(struct Camera *c) { } } if (!(gCameraMovementFlags & CAM_MOVE_ROTATE)) { - // If not rotating, rotate away from walls obscuring mario from view + // If not rotating, rotate away from walls obscuring Mario from view if (avoidStatus == 3) { approach_s16_asymptotic_bool(&sModeOffsetYaw, avoidYaw, 10); } else { if (c->mode == CAMERA_MODE_RADIAL) { - // sModeOffsetYaw only updates when mario is moving + // sModeOffsetYaw only updates when Mario is moving rotateSpeed = gMarioStates[0].forwardVel / 32.f * 128.f; camera_approach_s16_symmetric_bool(&sModeOffsetYaw, yawOffset, rotateSpeed); } @@ -1086,7 +1085,7 @@ void radial_camera_move(struct Camera *c) { } /** - * Moves lakitu from zoomed in to zoomed out and vice versa. + * Moves Lakitu from zoomed in to zoomed out and vice versa. * When C-Down mode is not active, sLakituDist and sLakituPitch decrease to 0. */ void lakitu_zoom(f32 rangeDist, s16 rangePitch) { @@ -1128,7 +1127,7 @@ void radial_camera_input_default(struct Camera *c) { } /** - * Makes lakitu cam's yaw match the angle turned towards in C-Up mode, and makes lakitu slowly fly back + * Makes Lakitu cam's yaw match the angle turned towards in C-Up mode, and makes Lakitu slowly fly back * to the distance he was at before C-Up */ void update_yaw_and_dist_from_c_up(UNUSED struct Camera *c) { @@ -1207,7 +1206,7 @@ s32 update_outward_radial_camera(struct Camera *c, Vec3f focus, Vec3f pos) { s16 camYaw = atan2s(zDistFocToMario, xDistFocToMario) + sModeOffsetYaw + DEGREES(180); s16 pitch = look_down_slopes(camYaw); f32 baseDist = 1000.f; - // A base offset of 125.f is ~= mario's eye height + // A base offset of 125.f is ~= Mario's eye height f32 yOff = 125.f; f32 posY; f32 focusY; @@ -1249,15 +1248,15 @@ void mode_outward_radial_camera(struct Camera *c) { * Uses the line between the next two points in sParTrackPath * The camera can move forward/back and side to side, but it will face perpendicular to that line * - * Although, annoyingly, it's not truly parallel, the function returns the yaw from the camera to mario, - * so mario will run slightly towards the camera. + * Although, annoyingly, it's not truly parallel, the function returns the yaw from the camera to Mario, + * so Mario will run slightly towards the camera. */ s32 update_parallel_tracking_camera(struct Camera *c, Vec3f focus, Vec3f pos) { Vec3f path[2]; Vec3f parMidPoint; Vec3f marioOffset; Vec3f camOffset; - /// Adjusts the focus to look where mario is facing. Unused since marioOffset is copied to focus + /// Adjusts the focus to look where Mario is facing. Unused since marioOffset is copied to focus Vec3f focOffset; s16 pathPitch; s16 pathYaw; @@ -1301,7 +1300,7 @@ s32 update_parallel_tracking_camera(struct Camera *c, Vec3f focus, Vec3f pos) { calc_y_to_curr_floor(&marioFloorDist, 1.f, 200.f, &marioFloorDist, 0.9f, 200.f); marioPos[0] = sMarioCamState->pos[0]; - // Mario's y pos + ~mario's height + mario's height above the floor + // Mario's y pos + ~Mario's height + Mario's height above the floor marioPos[1] = sMarioCamState->pos[1] + 150.f + marioFloorDist; marioPos[2] = sMarioCamState->pos[2]; @@ -1345,8 +1344,8 @@ s32 update_parallel_tracking_camera(struct Camera *c, Vec3f focus, Vec3f pos) { rotate_in_yz(camOffset, camOffset, pathPitch); pathPitch = -pathPitch; - // If mario is distThresh units away from the camera along the path, move the camera - //! When distThresh != 0, it causes mario to move slightly towards the camera when running sideways + // If Mario is distThresh units away from the camera along the path, move the camera + //! When distThresh != 0, it causes Mario to move slightly towards the camera when running sideways //! Set each ParallelTrackingPoint's distThresh to 0 to make Mario truly run parallel to the path if (marioOffset[2] > camOffset[2]) { if (marioOffset[2] - camOffset[2] > distThresh) { @@ -1358,7 +1357,7 @@ s32 update_parallel_tracking_camera(struct Camera *c, Vec3f focus, Vec3f pos) { } } - // If zoom != 0.0, the camera will move zoom% closer to mario + // If zoom != 0.0, the camera will move zoom% closer to Mario marioOffset[0] = -marioOffset[0] * zoom; marioOffset[1] = marioOffset[1] * zoom; marioOffset[2] = camOffset[2]; @@ -1381,7 +1380,7 @@ s32 update_parallel_tracking_camera(struct Camera *c, Vec3f focus, Vec3f pos) { offset_rotated(pos, path[0], marioOffset, pathAngle); vec3f_get_dist_and_angle(path[0], c->pos, &camParDist, &pathPitch, &pathYaw); - // Adjust the focus. Does nothing, focus is set to mario at the end + // Adjust the focus. Does nothing, focus is set to Mario at the end focOffset[2] = pathLength / 2 - focOffset[2]; offset_rotated(c->focus, path[0], focOffset, pathAngle); @@ -1458,7 +1457,7 @@ s32 update_fixed_camera(struct Camera *c, Vec3f focus, UNUSED Vec3f pos) { play_camera_buzz_if_c_sideways(); - // Don't move closer to mario in these areas + // Don't move closer to Mario in these areas switch (gCurrLevelArea) { case AREA_RR: scaleToMario = 0.f; @@ -1565,7 +1564,7 @@ s32 update_boss_fight_camera(struct Camera *c, Vec3f focus, Vec3f pos) { } yaw = sModeOffsetYaw + DEGREES(45); - // Get boss's position and whether mario is holding it. + // Get boss's position and whether Mario is holding it. if ((o = gSecondCameraFocus) != NULL) { object_pos_to_vec3f(secondFocus, o); heldState = o->oHeldState; @@ -1590,7 +1589,7 @@ s32 update_boss_fight_camera(struct Camera *c, Vec3f focus, Vec3f pos) { offset_rotated(secondFocus, sMarioCamState->pos, holdFocOffset, sMarioCamState->faceAngle); } - // Set the camera focus to the average of mario and secondFocus + // Set the camera focus to the average of Mario and secondFocus focus[0] = (sMarioCamState->pos[0] + secondFocus[0]) / 2.f; focus[1] = (sMarioCamState->pos[1] + secondFocus[1]) / 2.f + 125.f; focus[2] = (sMarioCamState->pos[2] + secondFocus[2]) / 2.f; @@ -1652,7 +1651,7 @@ s32 update_boss_fight_camera(struct Camera *c, Vec3f focus, Vec3f pos) { // Move the camera position back as sLakituDist and sLakituPitch increase. // This doesn't zoom out of bounds because pos is set above each frame. // The constant 0x1000 doubles the pitch from the center when sLakituPitch is 0 - // When lakitu is fully zoomed out, the pitch comes to 0x3800, or 78.75 degrees, up from the focus. + // When Lakitu is fully zoomed out, the pitch comes to 0x3800, or 78.75 degrees, up from the focus. vec3f_set_dist_and_angle(pos, pos, sLakituDist, sLakituPitch + 0x1000, yaw); return yaw; @@ -1732,7 +1731,7 @@ void mode_parallel_tracking_camera(struct Camera *c) { } /** - * Fixed camera mode, the camera rotates around a point and looks and zooms toward mario. + * Fixed camera mode, the camera rotates around a point and looks and zooms toward Mario. */ void mode_fixed_camera(struct Camera *c) { UNUSED u8 unused[8]; @@ -1769,7 +1768,7 @@ s32 update_behind_mario_camera(struct Camera *c, Vec3f focus, Vec3f pos) { f32 maxDist = 800.f; f32 focYOff = 125.f; - // Zoom in when mario R_TRIG mode is active + // Zoom in when Mario R_TRIG mode is active if (sSelectionFlags & CAM_MODE_MARIO_ACTIVE) { maxDist = 350.f; focYOff = 120.f; @@ -1778,7 +1777,7 @@ s32 update_behind_mario_camera(struct Camera *c, Vec3f focus, Vec3f pos) { pitchInc = 128; } - // Focus on mario + // Focus on Mario vec3f_copy(focus, sMarioCamState->pos); c->focus[1] += focYOff; //! @bug unnecessary @@ -1897,7 +1896,7 @@ s32 update_behind_mario_camera(struct Camera *c, Vec3f focus, Vec3f pos) { } /** - * "Behind Mario" mode: used when mario is flying, on the water's surface, or shot from a cannon + * "Behind Mario" mode: used when Mario is flying, on the water's surface, or shot from a cannon */ s32 mode_behind_mario(struct Camera *c) { struct MarioState *marioState = &gMarioStates[0]; @@ -1950,7 +1949,7 @@ s32 mode_behind_mario(struct Camera *c) { /** * Update the camera in slide and hoot mode. * - * In slide mode, keep the camera 800 units from mario + * In slide mode, keep the camera 800 units from Mario */ s16 update_slide_camera(struct Camera *c) { struct Surface *floor; @@ -1975,7 +1974,7 @@ s16 update_slide_camera(struct Camera *c) { // No C-Button input in this mode, notify the player with a buzzer play_camera_buzz_if_cbutton(); - // Focus on mario + // Focus on Mario vec3f_copy(c->focus, sMarioCamState->pos); c->focus[1] += 50.f; @@ -2055,7 +2054,7 @@ s32 update_mario_camera(UNUSED struct Camera *c, Vec3f focus, Vec3f pos) { /** * Update the camera in default, close, and free roam mode * - * The camera moves behind mario, and can rotate all the way around + * The camera moves behind Mario, and can rotate all the way around */ s16 update_default_camera(struct Camera *c) { Vec3f tempPos; @@ -2097,9 +2096,9 @@ s16 update_default_camera(struct Camera *c) { handle_c_button_movement(c); vec3f_get_dist_and_angle(sMarioCamState->pos, c->pos, &dist, &pitch, &yaw); - // If C-Down is active, determine what distance the camera should be from mario + // If C-Down is active, determine what distance the camera should be from Mario if (gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT) { - //! In Mario mode, the camera is zoomed out further than in lakitu mode (1400 vs 1200) + //! In Mario mode, the camera is zoomed out further than in Lakitu mode (1400 vs 1200) if (set_cam_angle(0) == CAM_ANGLE_MARIO) { zoomDist = gCameraZoomDist + 1050; } else { @@ -2172,7 +2171,7 @@ s16 update_default_camera(struct Camera *c) { sStatusFlags |= CAM_FLAG_BLOCK_SMOOTH_MOVEMENT; } } else if (xzDist < 250) { - // Turn rapidly if very close to mario + // Turn rapidly if very close to Mario c->pos[0] += (250 - xzDist) * sins(yaw); c->pos[2] += (250 - xzDist) * coss(yaw); if (sCSideButtonYaw == 0) { @@ -2190,7 +2189,7 @@ s16 update_default_camera(struct Camera *c) { calc_y_to_curr_floor(&posHeight, 1, 200, &focHeight, 0.9f, 200); vec3f_copy(cPos, c->pos); avoidStatus = rotate_camera_around_walls(c, cPos, &avoidYaw, 0x600); - // If a wall is blocking the view of mario, then rotate in the calculated direction + // If a wall is blocking the view of Mario, then rotate in the calculated direction if (avoidStatus == 3) { unusedFreeRoamWallYaw = avoidYaw; sAvoidYawVel = yaw; @@ -2227,7 +2226,7 @@ s16 update_default_camera(struct Camera *c) { if (avoidStatus != 0) { yawVel += yawVel; } - // ...Unless the camera already rotated from being close to mario + // ...Unless the camera already rotated from being close to Mario if ((closeToMario & 1) && avoidStatus != 0) { yawVel = 0; } @@ -2236,7 +2235,7 @@ s16 update_default_camera(struct Camera *c) { } } - // Only zoom out if not obstructed by walls and lakitu hasn't collided with any + // Only zoom out if not obstructed by walls and Lakitu hasn't collided with any if (avoidStatus == 0 && !(sStatusFlags & CAM_FLAG_COLLIDED_WITH_WALL)) { approach_f32_asymptotic_bool(&dist, zoomDist - 100.f, 0.05f); } @@ -2264,7 +2263,7 @@ s16 update_default_camera(struct Camera *c) { } } - // Lower the camera in mario mode + // Lower the camera in Mario mode if (sSelectionFlags & CAM_MODE_MARIO_ACTIVE) { marioFloorHeight -= 35.f; camFloorHeight -= 35.f; @@ -2321,7 +2320,7 @@ s16 update_default_camera(struct Camera *c) { } } - // Make lakitu fly above the gas + // Make Lakitu fly above the gas gasHeight = find_poison_gas_level(cPos[0], cPos[2]); if (gasHeight != -11000.f) { if ((gasHeight += 130.f) > c->pos[1]) { @@ -2399,7 +2398,7 @@ void mode_lakitu_camera(struct Camera *c) { } /** - * When no other mode is active and the current R button mode is mario + * When no other mode is active and the current R button mode is Mario */ void mode_mario_camera(struct Camera *c) { gCameraZoomDist = 350.f; @@ -2415,7 +2414,7 @@ s32 update_spiral_stairs_camera(struct Camera *c, Vec3f focus, Vec3f pos) { s16 camYaw; // unused s16 focPitch; - /// The focus (mario)'s yaw around the stairs + /// The focus (Mario)'s yaw around the stairs s16 focYaw; // unused s16 posPitch; @@ -2435,7 +2434,7 @@ s32 update_spiral_stairs_camera(struct Camera *c, Vec3f focus, Vec3f pos) { // Set base pos to the center of the staircase vec3f_set(sFixedModeBasePosition, -1280.f, 614.f, 1740.f); - // Focus on mario, and move the focus up the staircase with him + // Focus on Mario, and move the focus up the staircase with him calc_y_to_curr_floor(&focusHeight, 1.f, 200.f, &focusHeight, 0.9f, 200.f); focus[0] = sMarioCamState->pos[0]; focY = sMarioCamState->pos[1] + 125.f + focusHeight; @@ -2446,7 +2445,7 @@ s32 update_spiral_stairs_camera(struct Camera *c, Vec3f focus, Vec3f pos) { vec3f_get_dist_and_angle(sFixedModeBasePosition, cPos, &dist, &posPitch, &posYaw); sSpiralStairsYawOffset = posYaw - focYaw; - // posYaw will change if mario is more than 90 degrees around the stairs, relative to the camera + // posYaw will change if Mario is more than 90 degrees around the stairs, relative to the camera if (sSpiralStairsYawOffset < DEGREES(-90)) { sSpiralStairsYawOffset = DEGREES(-90); } @@ -2504,7 +2503,7 @@ static UNUSED void unused_mode_0f_camera(struct Camera *c) { /** * Slide/hoot mode. - * In this mode, the camera is always at the back of mario, because mario generally only moves forward. + * In this mode, the camera is always at the back of Mario, because Mario generally only moves forward. */ void mode_slide_camera(struct Camera *c) { if (sMarioGeometry.currFloorType == SURFACE_CLOSE_CAMERA || @@ -2521,7 +2520,7 @@ void mode_slide_camera(struct Camera *c) { void store_lakitu_cam_info_for_c_up(struct Camera *c) { vec3f_copy(sCameraStoreCUp.pos, c->pos); vec3f_sub(sCameraStoreCUp.pos, sMarioCamState->pos); - // Only store the y value, and as an offset from mario, for some reason + // Only store the y value, and as an offset from Mario, for some reason vec3f_set(sCameraStoreCUp.focus, 0.f, c->focus[1] - sMarioCamState->pos[1], 0.f); } @@ -2581,14 +2580,14 @@ s32 exit_c_up(struct Camera *c) { if (sModeInfo.lastMode == CAMERA_MODE_SPIRAL_STAIRS || sModeInfo.lastMode == CAMERA_MODE_CLOSE || sModeInfo.lastMode == CAMERA_MODE_FREE_ROAM) { searching = 1; - // Check the whole circle around mario for an open direction to zoom out to + // Check the whole circle around Mario for an open direction to zoom out to for (sector = 0; sector < 16 && searching == 1; sector++) { vec3f_set_dist_and_angle(checkFoc, curPos, curDist, 0, curYaw + checkYaw); // If there are no walls this way, if (f32_find_wall_collision(&curPos[0], &curPos[1], &curPos[2], 20.f, 50.f) == 0) { - // Start close to mario, check for walls, floors, and ceilings all the way to the + // Start close to Mario, check for walls, floors, and ceilings all the way to the // zoomed out distance for (d = curDist; d < gCameraZoomDist; d += 20.f) { vec3f_set_dist_and_angle(checkFoc, curPos, d, 0, curYaw + checkYaw); @@ -2658,7 +2657,7 @@ s32 update_c_up(UNUSED struct Camera *c, Vec3f focus, Vec3f pos) { } /** - * Make mario's head move in C-Up mode. + * Make Mario's head move in C-Up mode. */ void move_mario_head_c_up(UNUSED struct Camera *c) { UNUSED s16 pitch = sCUpCameraPitch; @@ -2684,7 +2683,7 @@ void move_mario_head_c_up(UNUSED struct Camera *c) { sModeOffsetYaw = -0x5555; } - // Give mario's neck natural-looking constraints + // Give Mario's neck natural-looking constraints sMarioCamState->headRotation[0] = sCUpCameraPitch * 3 / 4; sMarioCamState->headRotation[1] = sModeOffsetYaw * 3 / 4; } @@ -2753,7 +2752,7 @@ s32 mode_c_up_camera(struct Camera *c) { vec3f_add(c->pos, sMarioCamState->pos); vec3f_copy(c->focus, sCameraStoreCUp.focus); vec3f_add(c->focus, sMarioCamState->pos); - // Make mario look forward + // Make Mario look forward camera_approach_s16_symmetric_bool(&sMarioCamState->headRotation[0], 0, 1024); camera_approach_s16_symmetric_bool(&sMarioCamState->headRotation[1], 0, 1024); } else { @@ -2771,7 +2770,7 @@ s32 mode_c_up_camera(struct Camera *c) { } /** - * Used when mario is in a cannon. + * Used when Mario is in a cannon. */ s32 update_in_cannon(UNUSED struct Camera *c, Vec3f focus, Vec3f pos) { focus_on_mario(pos, focus, 125.f + sCannonYOffset, 125.f, 800.f, @@ -2780,8 +2779,8 @@ s32 update_in_cannon(UNUSED struct Camera *c, Vec3f focus, Vec3f pos) { } /** - * Updates the camera when mario is in a cannon. - * sCannonYOffset is used to make the camera rotate down when mario has just entered the cannon + * Updates the camera when Mario is in a cannon. + * sCannonYOffset is used to make the camera rotate down when Mario has just entered the cannon */ void mode_cannon_camera(struct Camera *c) { UNUSED u8 unused[24]; @@ -2800,9 +2799,9 @@ void mode_cannon_camera(struct Camera *c) { } /** - * Cause lakitu to fly to the next Camera position and focus over a number of frames. + * Cause Lakitu to fly to the next Camera position and focus over a number of frames. * - * At the end of each frame, lakitu's position and focus ("state") are stored. + * At the end of each frame, Lakitu's position and focus ("state") are stored. * Calling this function makes next_lakitu_state() fly from the last frame's state to the * current frame's calculated state. * @@ -2843,7 +2842,7 @@ void transition_to_camera_mode(struct Camera *c, s16 newMode, s16 numFrames) { } /** - * Used to change the camera mode between its default/previous and certain mario-oriented modes, + * Used to change the camera mode between its default/previous and certain Mario-oriented modes, * namely: C_UP, WATER_SURFACE, CLOSE, and BEHIND_MARIO * * Stores the current pos and focus in sModeInfo->transitionStart, and @@ -2910,7 +2909,7 @@ void set_camera_mode(struct Camera *c, s16 mode, s16 frames) { } /** - * Updates lakitu's position/focus and applies camera shakes. + * Updates Lakitu's position/focus and applies camera shakes. */ void update_lakitu(struct Camera *c) { struct Surface *floor = NULL; @@ -2945,14 +2944,14 @@ void update_lakitu(struct Camera *c) { vec3f_copy(gLakituState.goalPos, c->pos); vec3f_copy(gLakituState.goalFocus, c->focus); - // Simulate lakitu flying to the new position and turning towards the new focus + // Simulate Lakitu flying to the new position and turning towards the new focus set_or_approach_vec3f_asymptotic(gLakituState.curPos, newPos, gLakituState.posHSpeed, gLakituState.posVSpeed, gLakituState.posHSpeed); set_or_approach_vec3f_asymptotic(gLakituState.curFocus, newFoc, gLakituState.focHSpeed, gLakituState.focVSpeed, gLakituState.focHSpeed); - // Adjust lakitu's speed back to normal + // Adjust Lakitu's speed back to normal set_or_approach_f32_asymptotic(&gLakituState.focHSpeed, 0.8f, 0.05f); set_or_approach_f32_asymptotic(&gLakituState.focVSpeed, 0.3f, 0.05f); set_or_approach_f32_asymptotic(&gLakituState.posHSpeed, 0.3f, 0.05f); @@ -3198,7 +3197,7 @@ void update_camera(struct Camera *c) { } } } - // Start any mario-related cutscenes + // Start any Mario-related cutscenes start_cutscene(c, get_cutscene_from_mario_status(c)); stub_camera_2(c); gCheckingSurfaceCollisionsForCamera = FALSE; @@ -3217,8 +3216,8 @@ void update_camera(struct Camera *c) { play_sound_rbutton_changed(); } - // Fixed mode only prevents lakitu from moving. The camera pos still updates, so - // lakitu will fly to his next position as normal whenever R_TRIG is released. + // Fixed mode only prevents Lakitu from moving. The camera pos still updates, so + // Lakitu will fly to his next position as normal whenever R_TRIG is released. gLakituState.posHSpeed = 0.f; gLakituState.posVSpeed = 0.f; @@ -3390,7 +3389,7 @@ void init_camera(struct Camera *c) { start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA); break; - //! Hardcoded position checks determine which cutscene to play when mario enters castle grounds. + //! Hardcoded position checks determine which cutscene to play when Mario enters castle grounds. case LEVEL_CASTLE_GROUNDS: if (is_within_100_units_of_mario(-1328.f, 260.f, 4664.f) != 1) { marioOffset[0] = -400.f; @@ -3449,7 +3448,7 @@ void init_camera(struct Camera *c) { break; } - // Set the camera pos to marioOffset (relative to mario), added to mario's position + // Set the camera pos to marioOffset (relative to Mario), added to Mario's position offset_rotated(c->pos, sMarioCamState->pos, marioOffset, sMarioCamState->faceAngle); if (c->mode != CAMERA_MODE_BEHIND_MARIO) { c->pos[1] = find_floor(sMarioCamState->pos[0], sMarioCamState->pos[1] + 100.f, @@ -3554,7 +3553,7 @@ void create_camera(struct GraphNodeCamera *gc, struct AllocOnlyPool *pool) { } /** - * Copy lakitu's pos and foc into `gc` + * Copy Lakitu's pos and foc into `gc` */ void update_graph_node_camera(struct GraphNodeCamera *gc) { UNUSED u8 unused[8]; @@ -3731,7 +3730,7 @@ s32 move_point_along_spline(Vec3f p, struct CutsceneSplinePoint spline[], s16 *s /** * If `selection` is 0, just get the current selection - * If `selection` is 1, select 'mario' as the alt mode. + * If `selection` is 1, select 'Mario' as the alt mode. * If `selection` is 2, select 'fixed' as the alt mode. * * @return the current selection @@ -3761,16 +3760,16 @@ s32 cam_select_alt_mode(s32 selection) { } /** - * Sets the camera angle to either lakitu or mario mode. Returns the current mode. + * Sets the camera angle to either Lakitu or Mario mode. Returns the current mode. * * If `mode` is 0, just returns the current mode. - * If `mode` is 1, start mario mode - * If `mode` is 2, start lakitu mode + * If `mode` is 1, start Mario mode + * If `mode` is 2, start Lakitu mode */ s32 set_cam_angle(s32 mode) { s32 curMode = CAM_ANGLE_LAKITU; - // Switch to mario mode + // Switch to Mario mode if (mode == CAM_ANGLE_MARIO && !(sSelectionFlags & CAM_MODE_MARIO_ACTIVE)) { sSelectionFlags |= CAM_MODE_MARIO_ACTIVE; if (gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT) { @@ -4318,7 +4317,7 @@ s16 reduce_by_dist_from_camera(s16 value, f32 maxDist, f32 posX, f32 posY, f32 p s16 goalPitch; s16 goalYaw; s16 result = 0; - // Direction from pos to (lakitu's) goalPos + // Direction from pos to (Lakitu's) goalPos f32 goalDX = gLakituState.goalPos[0] - posX; f32 goalDY = gLakituState.goalPos[1] - posY; f32 goalDZ = gLakituState.goalPos[2] - posZ; @@ -4371,11 +4370,11 @@ s32 clamp_positions_and_find_yaw(Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f3 } /** - * The yaw passed here is the yaw of the direction FROM mario TO lakitu. + * The yaw passed here is the yaw of the direction FROM Mario TO Lakitu. * * wallYaw always has 90 degrees added to it before this is called -- it's parallel to the wall. * - * @return the new yaw from mario to rotate towards. + * @return the new yaw from Mario to rotate towards. * * @warning this is jank. It actually returns the yaw that will rotate further INTO the wall. So, the * developers just add 180 degrees to the result. @@ -4802,7 +4801,7 @@ s32 offset_yaw_outward_radial(struct Camera *c, s16 areaYaw) { case AREA_SSL_PYRAMID: // This mask splits the 360 degrees of yaw into 4 corners. It adds 45 degrees so that the yaw // offset at the corner will be 0, but the yaw offset near the center will face more towards - // the direction mario is running in. + // the direction Mario is running in. yawGoal = (areaYaw & 0xC000) - areaYaw + DEGREES(45); if (yawGoal < 0) { yawGoal = -yawGoal; @@ -4822,7 +4821,7 @@ s32 offset_yaw_outward_radial(struct Camera *c, s16 areaYaw) { camera_approach_s16_symmetric_bool(&yaw, yawGoal, dYaw); } // When the final yaw is out of [-60,60] degrees, approach yawGoal faster than dYaw will ever be, - // making the camera lock in one direction until yawGoal drops below 60 (or mario presses a C button) + // making the camera lock in one direction until yawGoal drops below 60 (or Mario presses a C button) if (yaw < -DEGREES(60)) { //! Maybe they meant to reverse yawGoal's sign? camera_approach_s16_symmetric_bool(&yaw, -yawGoal, 0x200); @@ -4842,7 +4841,7 @@ void cutscene_intro_peach_play_message_music(void) { } /** - * Plays the music that starts after peach fades and lakitu appears. + * Plays the music that starts after peach fades and Lakitu appears. */ void cutscene_intro_peach_play_lakitu_flying_music(void) { play_music(SEQ_PLAYER_LEVEL, SEQUENCE_ARGS(15, SEQ_EVENT_CUTSCENE_INTRO), 0); @@ -5141,7 +5140,7 @@ s32 determine_dance_cutscene(UNUSED struct Camera *c) { } /** - * @return `pullResult` or `pushResult` depending on mario's door action + * @return `pullResult` or `pushResult` depending on Mario's door action */ u8 open_door_cutscene(u8 pullResult, u8 pushResult) { s16 result; @@ -5156,7 +5155,7 @@ u8 open_door_cutscene(u8 pullResult, u8 pushResult) { } /** - * If no cutscenes are playing, determines if a cutscene should play based on mario's action and + * If no cutscenes are playing, determines if a cutscene should play based on Mario's action and * cameraEvent * * @return the cutscene that should start, 0 if none @@ -5294,7 +5293,7 @@ u8 get_cutscene_from_mario_status(struct Camera *c) { } /** - * Moves the camera when mario has triggered a warp + * Moves the camera when Mario has triggered a warp */ void warp_camera(f32 displacementX, f32 displacementY, f32 displacementZ) { Vec3f displacement; @@ -5342,12 +5341,12 @@ void stub_camera_4(UNUSED s32 a, UNUSED s32 b, UNUSED s32 c, UNUSED s32 d) { } /** - * Set the camera's focus to mario's position, and add several relative offsets. + * Set the camera's focus to Mario's position, and add several relative offsets. * - * @param leftRight offset to mario's left/right, relative to his faceAngle + * @param leftRight offset to Mario's left/right, relative to his faceAngle * @param yOff y offset - * @param forwBack offset to mario's front/back, relative to his faceAngle - * @param yawOff offset to mario's faceAngle, changes the direction of `leftRight` and `forwBack` + * @param forwBack offset to Mario's front/back, relative to his faceAngle + * @param yawOff offset to Mario's faceAngle, changes the direction of `leftRight` and `forwBack` */ void set_focus_rel_mario(struct Camera *c, f32 leftRight, f32 yOff, f32 forwBack, s16 yawOff) { s16 yaw; @@ -5362,12 +5361,12 @@ void set_focus_rel_mario(struct Camera *c, f32 leftRight, f32 yOff, f32 forwBack } /** - * Set the camera's position to mario's position, and add several relative offsets. Unused. + * Set the camera's position to Mario's position, and add several relative offsets. Unused. * - * @param leftRight offset to mario's left/right, relative to his faceAngle + * @param leftRight offset to Mario's left/right, relative to his faceAngle * @param yOff y offset - * @param forwBack offset to mario's front/back, relative to his faceAngle - * @param yawOff offset to mario's faceAngle, changes the direction of `leftRight` and `forwBack` + * @param forwBack offset to Mario's front/back, relative to his faceAngle + * @param yawOff offset to Mario's faceAngle, changes the direction of `leftRight` and `forwBack` */ static void unused_set_pos_rel_mario(struct Camera *c, f32 leftRight, f32 yOff, f32 forwBack, s16 yawOff) { u16 yaw = sMarioCamState->faceAngle[1] + yawOff; @@ -5423,11 +5422,11 @@ void determine_pushing_or_pulling_door(s16 *rotation) { } /** - * Calculate lakitu's next position and focus, according to gCamera's state, + * Calculate Lakitu's next position and focus, according to gCamera's state, * and store them in `newPos` and `newFoc`. * - * @param newPos where lakitu should fly towards this frame - * @param newFoc where lakitu should look towards this frame + * @param newPos where Lakitu should fly towards this frame + * @param newFoc where Lakitu should look towards this frame * * @param curPos gCamera's pos this frame * @param curFoc gCamera's foc this frame @@ -5435,7 +5434,7 @@ void determine_pushing_or_pulling_door(s16 *rotation) { * @param oldPos gCamera's pos last frame * @param oldFoc gCamera's foc last frame * - * @return lakitu's next yaw, which is the same as the yaw passed in if no transition happened + * @return Lakitu's next yaw, which is the same as the yaw passed in if no transition happened */ s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, Vec3f oldPos, Vec3f oldFoc, s16 yaw) { @@ -5465,7 +5464,7 @@ s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, if (sStatusFlags & CAM_FLAG_START_TRANSITION) { for (i = 0; i < 3; i++) { - // Add mario's displacement from this frame to the last frame's pos and focus + // Add Mario's displacement from this frame to the last frame's pos and focus // Makes the transition start from where the camera would have moved startPos[i] = oldPos[i] + sMarioCamState->pos[i] - sModeTransition.marioPos[i]; startFoc[i] = oldFoc[i] + sMarioCamState->pos[i] - sModeTransition.marioPos[i]; @@ -5597,7 +5596,7 @@ void set_camera_mode_close_cam(u8 *mode) { /** * Change to radial mode. - * If the difference in yaw between pos -> mario and pos > focus is < 90 degrees, transition. + * If the difference in yaw between pos -> Mario and pos > focus is < 90 degrees, transition. * Otherwise jump to radial mode. */ void set_camera_mode_radial(struct Camera *c, s16 transitionTime) { @@ -5660,11 +5659,11 @@ void set_fixed_cam_axis_sa_lobby(UNUSED s16 preset) { /** * Block area-specific CameraTrigger and special surface modes. * Generally, block area mode changes if: - * Mario is wearing the metal cap, or at the water's surface, or the camera is in mario mode + * Mario is wearing the metal cap, or at the water's surface, or the camera is in Mario mode * * However, if the level is WDW, DDD, or COTMC (levels that have metal cap and water): - * Only block area mode changes if mario is in a cannon, - * or if the camera is in mario mode and mario is not swimming or in water with the metal cap + * Only block area mode changes if Mario is in a cannon, + * or if the camera is in Mario mode and Mario is not swimming or in water with the metal cap */ void check_blocking_area_processing(const u8 *mode) { if (sMarioCamState->action & ACT_FLAG_METAL_WATER || @@ -5722,7 +5721,7 @@ BAD_RETURN(s32) cam_rr_enter_building_side(struct Camera *c) { } /** - * Fix the camera in place as mario gets exits out the MC cave into the waterfall. + * Fix the camera in place as Mario gets exits out the MC cave into the waterfall. */ BAD_RETURN(s32) cam_cotmc_exit_waterfall(UNUSED struct Camera *c) { gCameraMovementFlags |= CAM_MOVE_FIX_IN_PLACE; @@ -5730,7 +5729,7 @@ BAD_RETURN(s32) cam_cotmc_exit_waterfall(UNUSED struct Camera *c) { /** * Sets 8 directional mode and blocks the next trigger from processing. - * Activated when mario is walking in front of the snowman's head. + * Activated when Mario is walking in front of the snowman's head. */ BAD_RETURN(s32) cam_sl_snowman_head_8dir(struct Camera *c) { sStatusFlags |= CAM_FLAG_BLOCK_AREA_PROCESSING; @@ -5836,7 +5835,7 @@ BAD_RETURN(s32) cam_thi_look_through_tunnel(UNUSED struct Camera *c) { } /** - * Unused. Changes the camera to radial mode when mario is on the tower. + * Unused. Changes the camera to radial mode when Mario is on the tower. * * @see sCamBOB for bounds. */ @@ -5846,7 +5845,7 @@ BAD_RETURN(s32) cam_bob_tower(struct Camera *c) { } /** - * Unused. Changes the camera to free roam mode when mario is not climbing the tower. + * Unused. Changes the camera to free roam mode when Mario is not climbing the tower. * * This is the only CameraTrigger event that uses the area == -1 feature: * If this was used, it would be called by default in BoB. @@ -5858,7 +5857,7 @@ BAD_RETURN(s32) cam_bob_default_free_roam(struct Camera *c) { } /** - * Starts the pool entrance cutscene if mario is not exiting the pool. + * Starts the pool entrance cutscene if Mario is not exiting the pool. * Used in both the castle and HMC. */ BAD_RETURN(s32) cam_castle_hmc_start_pool_cutscene(struct Camera *c) { @@ -5869,7 +5868,7 @@ BAD_RETURN(s32) cam_castle_hmc_start_pool_cutscene(struct Camera *c) { } /** - * Sets the fixed mode pos offset so that the camera faces the doorway when mario is near the entrance + * Sets the fixed mode pos offset so that the camera faces the doorway when Mario is near the entrance * to the castle lobby */ BAD_RETURN(s32) cam_castle_lobby_entrance(UNUSED struct Camera *c) { @@ -5884,7 +5883,7 @@ BAD_RETURN(s32) cam_castle_look_upstairs(struct Camera *c) { struct Surface *floor; f32 floorHeight = find_floor(c->pos[0], c->pos[1], c->pos[2], &floor); - // If mario is on the first few steps, fix the camera pos, making it look up + // If Mario is on the first few steps, fix the camera pos, making it look up if ((sMarioGeometry.currFloorHeight > 1229.f) && (floorHeight < 1229.f) && (sCSideButtonYaw == 0)) { vec3f_set(c->pos, -227.f, 1425.f, 1533.f); @@ -5945,7 +5944,7 @@ BAD_RETURN(s32) cam_castle_close_mode(struct Camera *c) { /** * Functions the same as cam_castle_close_mode, but sets doorStatus so that the camera will enter - * fixed-mode when mario leaves the room. + * fixed-mode when Mario leaves the room. */ BAD_RETURN(s32) cam_castle_leave_lobby_sliding_door(struct Camera *c) { cam_castle_close_mode(c); @@ -6153,7 +6152,7 @@ u32 surface_type_modes(struct Camera *c) { } /** - * Set the camera mode to `mode` if mario is not standing on a special surface + * Set the camera mode to `mode` if Mario is not standing on a special surface */ u32 set_mode_if_not_set_by_surface(struct Camera *c, u8 mode) { u32 modeChanged = 0; @@ -6167,7 +6166,7 @@ u32 set_mode_if_not_set_by_surface(struct Camera *c, u8 mode) { } /** - * Used in THI, check if mario is standing on any of the special surfaces in that area + * Used in THI, check if Mario is standing on any of the special surfaces in that area */ void surface_type_modes_thi(struct Camera *c) { switch (sMarioGeometry.currFloorType) { @@ -6276,7 +6275,7 @@ struct CameraTrigger sCamRR[] = { * mode (which is called "tower mode" in the patent), it's speculated they belonged to BoB. * * This table contains the only instance of a CameraTrigger with an area set to -1, and it sets the mode - * to free_roam when mario is not walking up the tower. + * to free_roam when Mario is not walking up the tower. */ struct CameraTrigger sCamBOB[] = { { 1, cam_bob_tower, 2468, 2720, -4608, 3263, 1696, 3072, 0 }, @@ -6285,7 +6284,7 @@ struct CameraTrigger sCamBOB[] = { }; /** - * The CotMC trigger is only used to prevent fix lakitu in place when mario exits through the waterfall. + * The CotMC trigger is only used to prevent fix Lakitu in place when Mario exits through the waterfall. */ struct CameraTrigger sCamCotMC[] = { { 1, cam_cotmc_exit_waterfall, 0, 1500, 3500, 550, 10000, 1500, 0 }, @@ -6305,8 +6304,8 @@ struct CameraTrigger sCamCCM[] = { * The Castle triggers are used to set the camera to fixed mode when entering the lobby, and to set it * to close mode when leaving it. They also set the mode to spiral staircase. * - * There are two triggers for looking up and down straight staircases when mario is at the start, - * and one trigger that starts the enter pool cutscene when mario enters HMC. + * There are two triggers for looking up and down straight staircases when Mario is at the start, + * and one trigger that starts the enter pool cutscene when Mario enters HMC. */ struct CameraTrigger sCamCastle[] = { { 1, cam_castle_close_mode, -1100, 657, -1346, 300, 150, 300, 0 }, @@ -6466,7 +6465,7 @@ struct CutsceneSplinePoint sIntroStartToPipeFocus[] = { /** * Describes the spline the camera follows, starting when the camera jumps to Lakitu and ending after - * mario jumps out of the pipe when the first dialog opens. This table specifically updates the + * Mario jumps out of the pipe when the first dialog opens. This table specifically updates the * camera's position. */ struct CutsceneSplinePoint sIntroPipeToDialogPosition[] = { @@ -6551,9 +6550,9 @@ struct CutsceneSplinePoint sEndingLookAtSkyFocus[] = { }; /** - * Activates any CameraTriggers that mario is inside. + * Activates any CameraTriggers that Mario is inside. * Then, applies area-specific processing to the camera, such as setting the default mode, or changing - * the mode based on the terrain type mario is standing on. + * the mode based on the terrain type Mario is standing on. * * @return the camera's mode after processing, although this is unused in the code */ @@ -6594,7 +6593,7 @@ s16 camera_course_processing(struct Camera *c) { sCameraTriggers[level][b].boundsY, sCameraTriggers[level][b].boundsZ); - // Check if mario is inside the bounds + // Check if Mario is inside the bounds if (is_pos_in_bounds(sMarioCamState->pos, center, bounds, sCameraTriggers[level][b].boundsYaw) == TRUE) { //! This should be checked before calling is_pos_in_bounds. (It doesn't belong @@ -6607,7 +6606,7 @@ s16 camera_course_processing(struct Camera *c) { } if ((sCameraTriggers[level])[b].area == -1) { - // Default triggers are only active if mario is not already inside another trigger + // Default triggers are only active if Mario is not already inside another trigger if (!insideBounds) { if (!(sStatusFlags & CAM_FLAG_BLOCK_AREA_PROCESSING)) { sCameraTriggers[level][b].event(c); @@ -6782,15 +6781,15 @@ void resolve_geometry_collisions(Vec3f pos, UNUSED Vec3f lastGood) { } /** - * Checks for any walls obstructing mario from view, and calculates a new yaw that the camera should + * Checks for any walls obstructing Mario from view, and calculates a new yaw that the camera should * rotate towards. * - * @param[out] avoidYaw the angle (from mario) that the camera should rotate towards to avoid the wall. - * The camera then approaches avoidYaw until mario is no longer obstructed. + * @param[out] avoidYaw the angle (from Mario) that the camera should rotate towards to avoid the wall. + * The camera then approaches avoidYaw until Mario is no longer obstructed. * avoidYaw is always parallel to the wall. - * @param yawRange how wide of an arc to check for walls obscuring mario. + * @param yawRange how wide of an arc to check for walls obscuring Mario. * - * @return 3 if a wall is covering mario, 1 if a wall is only near the camera. + * @return 3 if a wall is covering Mario, 1 if a wall is only near the camera. */ s32 rotate_camera_around_walls(struct Camera *c, Vec3f cPos, s16 *avoidYaw, s16 yawRange) { UNUSED f32 unused1; @@ -6804,18 +6803,18 @@ s32 rotate_camera_around_walls(struct Camera *c, Vec3f cPos, s16 *avoidYaw, s16 s16 wallYaw, horWallNorm; UNUSED s16 unused4; s16 dummyPitch; - // The yaw of the vector from mario to the camera. + // The yaw of the vector from Mario to the camera. s16 yawFromMario; UNUSED s16 unused5; s32 status = 0; - /// The current iteration. The algorithm takes 8 equal steps from mario back to the camera. + /// The current iteration. The algorithm takes 8 equal steps from Mario back to the camera. s32 step = 0; UNUSED s32 unused6; vec3f_get_dist_and_angle(sMarioCamState->pos, cPos, &dummyDist, &dummyPitch, &yawFromMario); sStatusFlags &= ~CAM_FLAG_CAM_NEAR_WALL; colData.offsetY = 100.0f; - // The distance from mario to lakitu + // The distance from Mario to Lakitu checkDist = 0.0f; /// The radius used to find potential walls to avoid. /// @bug Increases to 250.f, but the max collision radius is 200.f @@ -6824,7 +6823,7 @@ s32 rotate_camera_around_walls(struct Camera *c, Vec3f cPos, s16 *avoidYaw, s16 fineRadius = 100.0f; for (step = 0; step < 8; step++) { - // Start at mario, move backwards to lakitu's position + // Start at Mario, move backwards to Lakitu's position colData.x = sMarioCamState->pos[0] + ((cPos[0] - sMarioCamState->pos[0]) * checkDist); colData.y = sMarioCamState->pos[1] + ((cPos[1] - sMarioCamState->pos[1]) * checkDist); colData.z = sMarioCamState->pos[2] + ((cPos[2] - sMarioCamState->pos[2]) * checkDist); @@ -6835,8 +6834,8 @@ s32 rotate_camera_around_walls(struct Camera *c, Vec3f cPos, s16 *avoidYaw, s16 if (find_wall_collisions(&colData) != 0) { wall = colData.walls[colData.numWalls - 1]; - // If we're over halfway from mario to lakitu, then there's a wall near the camera, but - // not necessarily obstructing mario + // If we're over halfway from Mario to Lakitu, then there's a wall near the camera, but + // not necessarily obstructing Mario if (step >= 5) { sStatusFlags |= CAM_FLAG_CAM_NEAR_WALL; if (status <= 0) { @@ -6861,10 +6860,10 @@ s32 rotate_camera_around_walls(struct Camera *c, Vec3f cPos, s16 *avoidYaw, s16 wall = colData.walls[colData.numWalls - 1]; horWallNorm = atan2s(wall->normal.z, wall->normal.x); wallYaw = horWallNorm + DEGREES(90); - // If mario would be blocked by the surface, then avoid it + // If Mario would be blocked by the surface, then avoid it if ((is_range_behind_surface(sMarioCamState->pos, cPos, wall, yawRange, SURFACE_WALL_MISC) == 0) && (is_mario_behind_surface(c, wall) == TRUE) - // Also check if the wall is tall enough to cover mario + // Also check if the wall is tall enough to cover Mario && (is_surf_within_bounding_box(wall, -1.f, 150.f, -1.f) == FALSE)) { // Calculate the avoid direction. The function returns the opposite direction so add 180 // degrees. @@ -6882,7 +6881,7 @@ s32 rotate_camera_around_walls(struct Camera *c, Vec3f cPos, s16 *avoidYaw, s16 } /** - * Stores type and height of the nearest floor and ceiling to mario in `pg` + * Stores type and height of the nearest floor and ceiling to Mario in `pg` * * Note: Also finds the water level, but waterHeight is unused */ @@ -6943,7 +6942,7 @@ s32 unused_dialog_cutscene_response(u8 cutscene) { sObjectCutscene = cutscene; } - // if playing this cutscene and mario responded, return the response + // if playing this cutscene and Mario responded, return the response if ((gCamera->cutscene == cutscene) && (sCutsceneDialogResponse != 0)) { return (s16) sCutsceneDialogResponse; } else { @@ -7050,11 +7049,11 @@ void copy_spline_segment(struct CutsceneSplinePoint dst[], struct CutsceneSpline } /** - * Triggers mario to enter a dialog state. This is used to make mario look at the focus of a cutscene, + * Triggers Mario to enter a dialog state. This is used to make Mario look at the focus of a cutscene, * for example, bowser. * @param state 0 = stop, 1 = start, 2 = start and look up, and 3 = start and look down * - * @return if mario left the dialog state, return CUTSCENE_LOOP, else return gCutsceneTimer + * @return if Mario left the dialog state, return CUTSCENE_LOOP, else return gCutsceneTimer */ s16 cutscene_common_set_dialog_state(s32 state) { s16 timer = gCutsceneTimer; @@ -7071,7 +7070,7 @@ static UNUSED void unused_cutscene_mario_dialog_looking_down(UNUSED struct Camer } /** - * Cause mario to enter the normal dialog state. + * Cause Mario to enter the normal dialog state. */ static BAD_RETURN(s32) cutscene_mario_dialog(UNUSED struct Camera *c) { gCutsceneTimer = cutscene_common_set_dialog_state(1); @@ -7278,7 +7277,7 @@ BAD_RETURN(s32) cutscene_unused_loop(UNUSED struct Camera *c) { } /** - * Set the camera position and focus for when mario falls from the sky. + * Set the camera position and focus for when Mario falls from the sky. */ BAD_RETURN(s32) cutscene_ending_mario_fall_start(struct Camera *c) { vec3f_set(c->focus, -26.f, 0.f, -137.f); @@ -7286,7 +7285,7 @@ BAD_RETURN(s32) cutscene_ending_mario_fall_start(struct Camera *c) { } /** - * Focus on mario when he's falling from the sky. + * Focus on Mario when he's falling from the sky. */ BAD_RETURN(s32) cutscene_ending_mario_fall_focus_mario(struct Camera *c) { Vec3f offset; @@ -7310,7 +7309,7 @@ BAD_RETURN(s32) cutscene_ending_mario_fall(struct Camera *c) { } /** - * Closeup of mario as the wing cap fades and mario looks up. + * Closeup of Mario as the wing cap fades and Mario looks up. */ BAD_RETURN(s32) cutscene_ending_mario_land_closeup(struct Camera *c) { vec3f_set(c->focus, 85.f, 826.f, 250.f); @@ -7344,7 +7343,7 @@ BAD_RETURN(s32) cutscene_ending_stars_free_peach(struct Camera *c) { } /** - * Move the camera to the ground as mario lands. + * Move the camera to the ground as Mario lands. */ BAD_RETURN(s32) cutscene_ending_mario_land(struct Camera *c) { vec3f_set(c->focus, sEndingFlyToWindowFocus[0].point[0], sEndingFlyToWindowFocus[0].point[1] + 80.f, sEndingFlyToWindowFocus[0].point[2]); @@ -7388,14 +7387,14 @@ BAD_RETURN(s32) cutscene_ending_follow_peach_descent(struct Camera *c) { } /** - * Decrease cvar2's y offset while the camera flies backwards to mario. + * Decrease cvar2's y offset while the camera flies backwards to Mario. */ BAD_RETURN(s32) cutscene_ending_peach_descent_lower_focus(UNUSED struct Camera *c) { camera_approach_f32_symmetric_bool(&(sCutsceneVars[2].point[1]), 90.f, 0.5f); } /** - * Keep following the sEndingPeachDescentCamPos spline, which leads back to mario. + * Keep following the sEndingPeachDescentCamPos spline, which leads back to Mario. */ BAD_RETURN(s32) cutscene_ending_peach_descent_back_to_mario(struct Camera *c) { Vec3f pos; @@ -7407,7 +7406,7 @@ BAD_RETURN(s32) cutscene_ending_peach_descent_back_to_mario(struct Camera *c) { } /** - * Peach starts floating to the ground. Rotate the camera around her, then fly backwards to mario when + * Peach starts floating to the ground. Rotate the camera around her, then fly backwards to Mario when * she lands. */ BAD_RETURN(s32) cutscene_ending_peach_descends(struct Camera *c) { @@ -7422,7 +7421,7 @@ BAD_RETURN(s32) cutscene_ending_peach_descends(struct Camera *c) { /** * Mario runs across the bridge to peach, and takes off his hat. - * Follow the sEndingMarioToPeach* splines while mario runs across. + * Follow the sEndingMarioToPeach* splines while Mario runs across. */ BAD_RETURN(s32) cutscene_ending_mario_to_peach(struct Camera *c) { cutscene_event(cutscene_ending_reset_spline, c, 0, 0); @@ -7458,7 +7457,7 @@ BAD_RETURN(s32) cutscene_ending_peach_wakeup(struct Camera *c) { } /** - * Side view of peach and mario. Peach thanks mario for saving her. + * Side view of peach and Mario. Peach thanks Mario for saving her. */ BAD_RETURN(s32) cutscene_ending_dialog(struct Camera *c) { vec3f_set(c->focus, 11.f, 983.f, -1273.f); @@ -7467,7 +7466,7 @@ BAD_RETURN(s32) cutscene_ending_dialog(struct Camera *c) { } /** - * Zoom in and move the camera close to mario and peach. + * Zoom in and move the camera close to Mario and peach. */ BAD_RETURN(s32) cutscene_ending_kiss_closeup(struct Camera *c) { set_fov_function(CAM_FOV_SET_29); @@ -7476,7 +7475,7 @@ BAD_RETURN(s32) cutscene_ending_kiss_closeup(struct Camera *c) { } /** - * Fly back and zoom out for mario's spin after the kiss. + * Fly back and zoom out for Mario's spin after the kiss. */ BAD_RETURN(s32) cutscene_ending_kiss_here_we_go(struct Camera *c) { Vec3f pos, foc; @@ -7490,7 +7489,7 @@ BAD_RETURN(s32) cutscene_ending_kiss_here_we_go(struct Camera *c) { } /** - * Peach kisses mario on the nose. + * Peach kisses Mario on the nose. */ BAD_RETURN(s32) cutscene_ending_kiss(struct Camera *c) { cutscene_event(cutscene_ending_kiss_closeup, c, 0, 0); @@ -7519,7 +7518,7 @@ BAD_RETURN(s32) cutscene_ending_zoom_fov(UNUSED struct Camera *c) { } /** - * Peach suggests baking a cake for mario. Mario looks back at the camera before going inside the castle. + * Peach suggests baking a cake for Mario. Mario looks back at the camera before going inside the castle. */ BAD_RETURN(s32) cutscene_ending_cake_for_mario(struct Camera *c) { cutscene_event(cutscene_ending_reset_spline, c, 0, 0); @@ -7543,7 +7542,7 @@ BAD_RETURN(s32) cutscene_ending_stop(struct Camera *c) { /** * Start the grand star cutscene. - * cvar0 is a relative offset from mario. + * cvar0 is a relative offset from Mario. * cvar1 is the is the camera's goal position. */ BAD_RETURN(s32) cutscene_grand_star_start(UNUSED struct Camera *c) { @@ -7553,7 +7552,7 @@ BAD_RETURN(s32) cutscene_grand_star_start(UNUSED struct Camera *c) { } /** - * Make the camera fly to the front of mario. + * Make the camera fly to the front of Mario. */ BAD_RETURN(s32) cutscene_grand_star_front_of_mario(struct Camera *c) { f32 goalDist; @@ -7570,7 +7569,7 @@ BAD_RETURN(s32) cutscene_grand_star_front_of_mario(struct Camera *c) { } /** - * Started shortly after mario starts the triple jump. Stores mario's face angle and zeros cvar2. + * Started shortly after Mario starts the triple jump. Stores Mario's face angle and zeros cvar2. */ BAD_RETURN(s32) cutscene_grand_star_mario_jump(UNUSED struct Camera *c) { vec3s_set(sCutsceneVars[0].angle, 0, sMarioCamState->faceAngle[1], 0); @@ -7586,7 +7585,7 @@ BAD_RETURN(s32) cutscene_grand_star_accel_cvar2(UNUSED struct Camera *c) { } /** - * Decrease cvar2 offset, follow mario by directly updating the camera's pos. + * Decrease cvar2 offset, follow Mario by directly updating the camera's pos. */ BAD_RETURN(s32) cutscene_grand_star_approach_mario(struct Camera *c) { camera_approach_f32_symmetric_bool(&sCutsceneVars[2].point[2], 0.f, 2.f); @@ -7596,7 +7595,7 @@ BAD_RETURN(s32) cutscene_grand_star_approach_mario(struct Camera *c) { } /** - * Offset the camera's position by cvar2. Before mario triple jumps, this moves back and to the left. + * Offset the camera's position by cvar2. Before Mario triple jumps, this moves back and to the left. * After the triple jump, cvar2 decelerates to 0. */ BAD_RETURN(s32) cutscene_grand_star_move_cvar2(struct Camera *c) { @@ -7611,7 +7610,7 @@ BAD_RETURN(s32) cutscene_grand_star_focus_mario(struct Camera *c) { } /** - * The first part of the grand star cutscene, after mario has collected the grand star. + * The first part of the grand star cutscene, after Mario has collected the grand star. */ BAD_RETURN(s32) cutscene_grand_star(struct Camera *c) { sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; @@ -7625,7 +7624,7 @@ BAD_RETURN(s32) cutscene_grand_star(struct Camera *c) { } /** - * Zero the cvars that are used when mario is flying. + * Zero the cvars that are used when Mario is flying. */ BAD_RETURN(s32) cutscene_grand_star_fly_start(struct Camera *c) { //! cvar7 is unused in grand star @@ -7639,7 +7638,7 @@ BAD_RETURN(s32) cutscene_grand_star_fly_start(struct Camera *c) { } /** - * Decrease the cvar offsets so that lakitu flies closer to mario. + * Decrease the cvar offsets so that Lakitu flies closer to Mario. */ BAD_RETURN(s32) cutscene_grand_star_fly_move_to_mario(UNUSED struct Camera *c) { Vec3f posOff; @@ -7651,10 +7650,10 @@ BAD_RETURN(s32) cutscene_grand_star_fly_move_to_mario(UNUSED struct Camera *c) { } /** - * Gradually increase the cvar offsets so lakitu flies away. Mario flies offscreen to the right. + * Gradually increase the cvar offsets so Lakitu flies away. Mario flies offscreen to the right. * - * cvar4 is the position offset from mario. - * cvar5 is the focus offset from mario. + * cvar4 is the position offset from Mario. + * cvar5 is the focus offset from Mario. * cvar8.point[0] is the approach velocity. */ BAD_RETURN(s32) cutscene_grand_star_fly_mario_offscreen(UNUSED struct Camera *c) { @@ -7670,7 +7669,7 @@ BAD_RETURN(s32) cutscene_grand_star_fly_mario_offscreen(UNUSED struct Camera *c) } /** - * Make lakitu approach the cvars. + * Make Lakitu approach the cvars. * cvar4 is the position offset. * cvar5 is the focus offset. */ @@ -7693,13 +7692,13 @@ BAD_RETURN(s32) cutscene_grand_star_fly_app_cvars(struct Camera *c) { } /** - * Part of the grand star cutscene, starts after mario is flying. + * Part of the grand star cutscene, starts after Mario is flying. * - * cvar4 and cvar5 are directions, relative to mario: - * cvar4 is used as the camera position's offset from mario. - * cvar5 is used as the camera focus's offset from mario. + * cvar4 and cvar5 are directions, relative to Mario: + * cvar4 is used as the camera position's offset from Mario. + * cvar5 is used as the camera focus's offset from Mario. * - * cvar8.point[2] is lakitu's speed. + * cvar8.point[2] is Lakitu's speed. */ BAD_RETURN(s32) cutscene_grand_star_fly(struct Camera *c) { sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; @@ -7710,9 +7709,9 @@ BAD_RETURN(s32) cutscene_grand_star_fly(struct Camera *c) { } /** - * Adjust the camera focus towards a point `dist` units in front of mario. - * @param dist distance in mario's forward direction. Note that this is relative to mario, so a negative - * distance will focus in front of mario, and a positive distance will focus behind him. + * Adjust the camera focus towards a point `dist` units in front of Mario. + * @param dist distance in Mario's forward direction. Note that this is relative to Mario, so a negative + * distance will focus in front of Mario, and a positive distance will focus behind him. */ void focus_in_front_of_mario(struct Camera *c, f32 dist, f32 speed) { Vec3f goalFocus, offset; @@ -7726,7 +7725,7 @@ void focus_in_front_of_mario(struct Camera *c, f32 dist, f32 speed) { } /** - * Approach mario and look up. Since mario faces the camera when he collects the star, there's no need + * Approach Mario and look up. Since Mario faces the camera when he collects the star, there's no need * to worry about the camera's yaw. */ BAD_RETURN(s32) cutscene_dance_move_to_mario(struct Camera *c) { @@ -7758,7 +7757,7 @@ static BAD_RETURN(s32) cutscene_dance_unused(UNUSED struct Camera *c) { } /** - * Slowly turn to the point 100 units in front of mario + * Slowly turn to the point 100 units in front of Mario */ BAD_RETURN(s32) cutscene_dance_default_focus_mario(struct Camera *c) { focus_in_front_of_mario(c, -100.f, 0.2f); @@ -7777,8 +7776,8 @@ BAD_RETURN(s32) cutscene_dance_shake_fov(UNUSED struct Camera *c) { /** * Handles both the default and rotate dance cutscenes. - * In the default dance: the camera moves closer to mario, then stays in place. - * In the rotate dance: the camera moves closer and rotates clockwise around mario. + * In the default dance: the camera moves closer to Mario, then stays in place. + * In the rotate dance: the camera moves closer and rotates clockwise around Mario. */ BAD_RETURN(s32) cutscene_dance_default_rotate(struct Camera *c) { sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; @@ -7786,13 +7785,13 @@ BAD_RETURN(s32) cutscene_dance_default_rotate(struct Camera *c) { set_fov_function(CAM_FOV_DEFAULT); cutscene_event(cutscene_dance_default_focus_mario, c, 0, 20); cutscene_event(cutscene_dance_move_to_mario, c, 0, 39); - // Shake the camera on the 4th beat of the music, when mario gives the peace sign. + // Shake the camera on the 4th beat of the music, when Mario gives the peace sign. cutscene_event(cutscene_dance_shake_fov, c, 40, 40); if (c->cutscene != CUTSCENE_DANCE_DEFAULT) { // CUTSCENE_DANCE_ROTATE cutscene_event(cutscene_dance_rotate_focus_mario, c, 75, 102); cutscene_event(cutscene_dance_rotate, c, 50, -1); - // These two functions move the camera away and then towards mario. + // These two functions move the camera away and then towards Mario. cutscene_event(cutscene_dance_rotate_move_back, c, 50, 80); cutscene_event(cutscene_dance_rotate_move_towards_mario, c, 70, 90); } else { @@ -7853,7 +7852,7 @@ BAD_RETURN(s32) cutscene_dance_closeup_start(struct Camera *c) { } /** - * Focus the camera on mario eye height. + * Focus the camera on Mario eye height. */ BAD_RETURN(s32) cutscene_dance_closeup_focus_mario(struct Camera *c) { Vec3f marioPos; @@ -7864,7 +7863,7 @@ BAD_RETURN(s32) cutscene_dance_closeup_focus_mario(struct Camera *c) { } /** - * Fly above mario, looking down. + * Fly above Mario, looking down. */ BAD_RETURN(s32) cutscene_dance_closeup_fly_above(struct Camera *c) { s16 pitch, yaw; @@ -7884,7 +7883,7 @@ BAD_RETURN(s32) cutscene_dance_closeup_fly_above(struct Camera *c) { } /** - * Fly closer right when mario gives the peace sign. + * Fly closer right when Mario gives the peace sign. */ BAD_RETURN(s32) cutscene_dance_closeup_fly_closer(struct Camera *c) { s16 pitch, yaw; @@ -7905,14 +7904,14 @@ BAD_RETURN(s32) cutscene_dance_closeup_zoom(UNUSED struct Camera *c) { } /** - * Shake fov, starts on the first frame mario has the peace sign up. + * Shake fov, starts on the first frame Mario has the peace sign up. */ BAD_RETURN(s32) cutscene_dance_closeup_shake_fov(UNUSED struct Camera *c) { set_fov_shake(0x300, 0x30, 0x8000); } /** - * The camera moves in for a closeup on mario. Used for stars that are underwater or in tight places. + * The camera moves in for a closeup on Mario. Used for stars that are underwater or in tight places. */ BAD_RETURN(s32) cutscene_dance_closeup(struct Camera *c) { sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; @@ -7937,7 +7936,7 @@ BAD_RETURN(s32) cutscene_dance_closeup(struct Camera *c) { } /** - * cvar8.point[2] is the amount to increase distance from mario + * cvar8.point[2] is the amount to increase distance from Mario */ BAD_RETURN(s32) cutscene_dance_fly_away_start(struct Camera *c) { Vec3f areaCenter; @@ -7996,7 +7995,7 @@ void cutscene_pan_cvar9(struct Camera *c) { } /** - * Move backwards and rotate slowly around mario. + * Move backwards and rotate slowly around Mario. */ BAD_RETURN(s32) cutscene_dance_fly_rotate_around_mario(struct Camera *c) { cutscene_pan_cvar9(c); @@ -8004,7 +8003,7 @@ BAD_RETURN(s32) cutscene_dance_fly_rotate_around_mario(struct Camera *c) { } /** - * Rotate quickly while lakitu flies up. + * Rotate quickly while Lakitu flies up. */ BAD_RETURN(s32) cutscene_dance_fly_away_rotate_while_flying(struct Camera *c) { rotate_and_move_vec3f(c->pos, sMarioCamState->pos, 0, 0, 0x80); @@ -8015,7 +8014,7 @@ BAD_RETURN(s32) cutscene_dance_fly_away_shake_fov(UNUSED struct Camera *c) { } /** - * After collecting the star, lakitu flies upwards out of the course. + * After collecting the star, Lakitu flies upwards out of the course. */ BAD_RETURN(s32) cutscene_dance_fly_away(struct Camera *c) { sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; @@ -8039,7 +8038,7 @@ BAD_RETURN(s32) cutscene_key_dance_jump_cvar(struct Camera *c) { } /** - * Jump to a closeup view of mario and the key. + * Jump to a closeup view of Mario and the key. */ BAD_RETURN(s32) cutscene_key_dance_jump_closeup(UNUSED struct Camera *c) { vec3f_set(sCutsceneVars[8].point, 38.f, 171.f, -248.f); @@ -8047,7 +8046,7 @@ BAD_RETURN(s32) cutscene_key_dance_jump_closeup(UNUSED struct Camera *c) { } /** - * Jump to a view from the lower left (mario's right). + * Jump to a view from the lower left (Mario's right). */ BAD_RETURN(s32) cutscene_key_dance_jump_lower_left(UNUSED struct Camera *c) { vec3f_set(sCutsceneVars[8].point, -178.f, 62.f, -132.f); @@ -8064,7 +8063,7 @@ BAD_RETURN(s32) cutscene_key_dance_jump_above(UNUSED struct Camera *c) { } /** - * Finally, jump to a further view, slightly to mario's left. + * Finally, jump to a further view, slightly to Mario's left. */ BAD_RETURN(s32) cutscene_key_dance_jump_last(UNUSED struct Camera *c) { gLakituState.keyDanceRoll = 0; @@ -8085,7 +8084,7 @@ BAD_RETURN(s32) cutscene_key_dance_focus_mario(struct Camera *c) { } /** - * Cutscene that plays when mario collects a key from bowser. It's basically a sequence of four jump + * Cutscene that plays when Mario collects a key from bowser. It's basically a sequence of four jump * cuts. */ BAD_RETURN(s32) cutscene_key_dance(struct Camera *c) { @@ -8198,7 +8197,7 @@ BAD_RETURN(s32) cutscene_bowser_arena_start(struct Camera *c) { } /** - * Create the dialog box depending on which bowser fight mario is in. + * Create the dialog box depending on which bowser fight Mario is in. */ BAD_RETURN(s32) bowser_fight_intro_dialog(UNUSED struct Camera *c) { s16 dialog; @@ -8241,7 +8240,7 @@ BAD_RETURN(s32) cutscene_bowser_arena_end(struct Camera *c) { } /** - * Cutscene that plays when mario enters a bowser fight. + * Cutscene that plays when Mario enters a bowser fight. */ BAD_RETURN(s32) cutscene_bowser_arena(struct Camera *c) { //! This does nothing, but may have been used in development @@ -8317,7 +8316,7 @@ BAD_RETURN(s32) cutscene_star_spawn(struct Camera *c) { } /** - * Move the camera back to mario. + * Move the camera back to Mario. */ BAD_RETURN(s32) cutscene_star_spawn_back(struct Camera *c) { if ((c->mode == CAMERA_MODE_BOSS_FIGHT) && (set_cam_angle(0) == CAM_ANGLE_LAKITU)) { @@ -8342,7 +8341,7 @@ BAD_RETURN(s32) cutscene_exit_waterfall_warp(struct Camera *c) { } /** - * Look at mario, used by cutscenes that play when mario exits a course to castle grounds. + * Look at Mario, used by cutscenes that play when Mario exits a course to castle grounds. */ BAD_RETURN(s32) cutscene_exit_to_castle_grounds_focus_mario(struct Camera *c) { vec3f_copy(c->focus, sMarioCamState->pos); @@ -8351,7 +8350,7 @@ BAD_RETURN(s32) cutscene_exit_to_castle_grounds_focus_mario(struct Camera *c) { } /** - * Cutscene that plays when mario leaves CotMC through the waterfall. + * Cutscene that plays when Mario leaves CotMC through the waterfall. */ BAD_RETURN(s32) cutscene_exit_waterfall(struct Camera *c) { cutscene_event(cutscene_exit_waterfall_warp, c, 0, 0); @@ -8360,7 +8359,7 @@ BAD_RETURN(s32) cutscene_exit_waterfall(struct Camera *c) { } /** - * End the cutscene, used by cutscenes that play when mario exits a course to castle grounds. + * End the cutscene, used by cutscenes that play when Mario exits a course to castle grounds. */ BAD_RETURN(s32) cutscene_exit_to_castle_grounds_end(struct Camera *c) { sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; @@ -8375,7 +8374,7 @@ BAD_RETURN(s32) cutscene_exit_fall_to_castle_grounds_warp(struct Camera *c) { } /** - * Cutscene that plays when mario falls from WMOTR. + * Cutscene that plays when Mario falls from WMOTR. */ BAD_RETURN(s32) cutscene_exit_fall_to_castle_grounds(struct Camera *c) { cutscene_event(cutscene_exit_fall_to_castle_grounds_warp, c, 0, 0); @@ -8610,9 +8609,9 @@ BAD_RETURN(s32) cutscene_prepare_cannon_end(struct Camera *c) { } /** - * Moves the camera to mario's side when mario starts ACT_WATER_DEATH - * Note that ACT_WATER_DEATH only starts when mario gets hit by an enemy under water. It does not start - * when mario drowns. + * Moves the camera to Mario's side when Mario starts ACT_WATER_DEATH + * Note that ACT_WATER_DEATH only starts when Mario gets hit by an enemy under water. It does not start + * when Mario drowns. */ void water_death_move_to_mario_side(struct Camera *c) { f32 dist; @@ -8637,7 +8636,7 @@ BAD_RETURN(s32) cutscene_death_standing_start(struct Camera *c) { } /** - * Fly to mario and turn on handheld shake. + * Fly to Mario and turn on handheld shake. */ BAD_RETURN(s32) cutscene_death_standing_goto_mario(struct Camera *c) { death_goto_mario(c); @@ -8645,7 +8644,7 @@ BAD_RETURN(s32) cutscene_death_standing_goto_mario(struct Camera *c) { } /** - * Cutscene that plays when mario dies while standing. + * Cutscene that plays when Mario dies while standing. */ BAD_RETURN(s32) cutscene_death_standing(struct Camera *c) { cutscene_event(cutscene_death_standing_start, c, 0, 0); @@ -8672,7 +8671,7 @@ static void unused_water_death_move_to_side_of_mario(struct Camera *c) { } /** - * Cutscene that plays when mario dies on his stomach. + * Cutscene that plays when Mario dies on his stomach. */ BAD_RETURN(s32) cutscene_death_stomach(struct Camera *c) { cutscene_event(cutscene_death_stomach_start, c, 0, 0); @@ -8693,7 +8692,7 @@ BAD_RETURN(s32) cutscene_bbh_death_goto_mario(struct Camera *c) { } /** - * Cutscene that plays when mario dies in BBH. + * Cutscene that plays when Mario dies in BBH. */ BAD_RETURN(s32) cutscene_bbh_death(struct Camera *c) { cutscene_event(cutscene_bbh_death_start, c, 0, 0); @@ -8710,7 +8709,7 @@ BAD_RETURN(s32) cutscene_quicksand_death_start(struct Camera *c) { } /** - * Fly closer to mario. In WATER_DEATH, move to mario's side. + * Fly closer to Mario. In WATER_DEATH, move to Mario's side. */ BAD_RETURN(s32) cutscene_quicksand_death_goto_mario(struct Camera *c) { cutscene_goto_cvar_pos(c, 400.f, 0x2800, 0x200, 0); @@ -8721,7 +8720,7 @@ BAD_RETURN(s32) cutscene_quicksand_death_goto_mario(struct Camera *c) { } /** - * Cutscene that plays when mario dies in quicksand. + * Cutscene that plays when Mario dies in quicksand. */ BAD_RETURN(s32) cutscene_quicksand_death(struct Camera *c) { sCutsceneVars[3].point[0] = sMarioCamState->pos[0]; @@ -8735,7 +8734,7 @@ BAD_RETURN(s32) cutscene_quicksand_death(struct Camera *c) { } /** - * Fly away from mario near the end of the cutscene. + * Fly away from Mario near the end of the cutscene. */ BAD_RETURN(s32) cutscene_suffocation_fly_away(UNUSED struct Camera *c) { Vec3f target; @@ -8746,7 +8745,7 @@ BAD_RETURN(s32) cutscene_suffocation_fly_away(UNUSED struct Camera *c) { } /** - * Keep lakitu above the gas level. + * Keep Lakitu above the gas level. */ BAD_RETURN(s32) cutscene_suffocation_stay_above_gas(struct Camera *c) { UNUSED f32 unused1; @@ -8764,7 +8763,7 @@ BAD_RETURN(s32) cutscene_suffocation_stay_above_gas(struct Camera *c) { } /** - * Quickly rotate around mario. + * Quickly rotate around Mario. */ BAD_RETURN(s32) cutscene_suffocation_rotate(struct Camera *c) { f32 dist; @@ -8776,7 +8775,7 @@ BAD_RETURN(s32) cutscene_suffocation_rotate(struct Camera *c) { } /** - * Cutscene that plays when mario dies from suffocation (ie due to HMC gas). + * Cutscene that plays when Mario dies from suffocation (ie due to HMC gas). */ BAD_RETURN(s32) cutscene_suffocation(struct Camera *c) { cutscene_event(cutscene_death_stomach_start, c, 0, 0); @@ -8912,7 +8911,7 @@ BAD_RETURN(s32) cutscene_pyramid_top_explode(struct Camera *c) { BAD_RETURN(s32) cutscene_pyramid_top_explode_end(struct Camera *c) { cutscene_stop_dialog(c); stop_cutscene_and_retrieve_stored_info(c); - // Move the camera back to mario + // Move the camera back to Mario transition_next_state(c, 30); } @@ -8925,7 +8924,7 @@ BAD_RETURN(s32) cutscene_enter_pyramid_top_start(struct Camera *c) { } /** - * Cutscene that plays when mario enters the top of the pyramid. + * Cutscene that plays when Mario enters the top of the pyramid. */ BAD_RETURN(s32) cutscene_enter_pyramid_top(struct Camera *c) { cutscene_event(cutscene_enter_pyramid_top_start, c, 0, 0); @@ -8935,7 +8934,7 @@ BAD_RETURN(s32) cutscene_enter_pyramid_top(struct Camera *c) { set_handheld_shake(HAND_CAM_SHAKE_CUTSCENE); if (sMarioCamState->pos[1] > 1250.f) { - // End the cutscene early if mario ledge-grabbed. + // End the cutscene early if Mario ledge-grabbed. // This only works because of the janky way that ledge-grabbing is implemented. cutscene_exit_to_castle_grounds_end(c); } @@ -8950,10 +8949,10 @@ static void unused_cutscene_goto_cvar(struct Camera *c) { } /** - * cvar8 is mario's position and faceAngle + * cvar8 is Mario's position and faceAngle * * cvar9.point is gCutsceneFocus's position - * cvar9.angle[1] is the yaw between mario and the gCutsceneFocus + * cvar9.angle[1] is the yaw between Mario and the gCutsceneFocus */ BAD_RETURN(s32) cutscene_dialog_start(struct Camera *c) { UNUSED f32 unused1; @@ -8975,7 +8974,7 @@ BAD_RETURN(s32) cutscene_dialog_start(struct Camera *c) { } #endif - // Store mario's position and faceAngle + // Store Mario's position and faceAngle sCutsceneVars[8].angle[0] = 0; vec3f_copy(sCutsceneVars[8].point, sMarioCamState->pos); sCutsceneVars[8].point[1] += 125.f; @@ -8994,8 +8993,8 @@ BAD_RETURN(s32) cutscene_dialog_start(struct Camera *c) { } /** - * Move closer to mario and the object, adjusting to their difference in height. - * The camera's generally ends up looking over mario's shoulder. + * Move closer to Mario and the object, adjusting to their difference in height. + * The camera's generally ends up looking over Mario's shoulder. */ BAD_RETURN(s32) cutscene_dialog_move_mario_shoulder(struct Camera *c) { f32 dist; @@ -9019,7 +9018,7 @@ BAD_RETURN(s32) cutscene_dialog_move_mario_shoulder(struct Camera *c) { approach_f32_asymptotic_bool(&dist, 180.f, 0.05f); vec3f_set_dist_and_angle(sCutsceneVars[8].point, pos, dist, pitch, yaw); - // Move up if mario is below the focus object, down is mario is above + // Move up if Mario is below the focus object, down is Mario is above pos[1] = sCutsceneVars[8].point[1] + sins(calculate_pitch(sCutsceneVars[9].point, sCutsceneVars[8].point)) * 100.f; @@ -9043,7 +9042,7 @@ BAD_RETURN(s32) cutscene_dialog_create_dialog_box(struct Camera *c) { } /** - * Cutscene that plays when mario talks to an object. + * Cutscene that plays when Mario talks to an object. */ BAD_RETURN(s32) cutscene_dialog(struct Camera *c) { cutscene_event(cutscene_dialog_start, c, 0, 0); @@ -9111,7 +9110,7 @@ static void unused_cam_to_mario(struct Camera *c) { } /** - * Cutscene that plays when mario is reading a message (a sign or message on the wall) + * Cutscene that plays when Mario is reading a message (a sign or message on the wall) */ BAD_RETURN(s32) cutscene_read_message(struct Camera *c) { UNUSED u32 pad[2]; @@ -9166,7 +9165,7 @@ BAD_RETURN(s32) cutscene_read_message_end(struct Camera *c) { /** * Set cvars: - * cvar7 is mario's pos and angle + * cvar7 is Mario's pos and angle * cvar6 is the focus offset * cvar5 is the position offset */ @@ -9178,7 +9177,7 @@ BAD_RETURN(s32) cutscene_exit_succ_start(UNUSED struct Camera *c) { } /** - * Set the camera pos depending on which level mario exited. + * Set the camera pos depending on which level Mario exited. */ BAD_RETURN(s32) cutscene_non_painting_set_cam_pos(struct Camera *c) { UNUSED u32 unused1; @@ -9210,7 +9209,7 @@ BAD_RETURN(s32) cutscene_non_painting_set_cam_pos(struct Camera *c) { } /** - * Update the camera focus depending on which level mario exited. + * Update the camera focus depending on which level Mario exited. */ BAD_RETURN(s32) cutscene_non_painting_set_cam_focus(struct Camera *c) { offset_rotated(c->focus, sCutsceneVars[7].point, sCutsceneVars[6].point, sCutsceneVars[7].angle); @@ -9226,7 +9225,7 @@ BAD_RETURN(s32) cutscene_non_painting_set_cam_focus(struct Camera *c) { } /** - * Focus slightly left of mario. Perhaps to keep the bowser painting in view? + * Focus slightly left of Mario. Perhaps to keep the bowser painting in view? */ BAD_RETURN(s32) cutscene_exit_bowser_succ_focus_left(UNUSED struct Camera *c) { approach_f32_asymptotic_bool(&sCutsceneVars[6].point[0], -24.f, 0.05f); @@ -9244,14 +9243,14 @@ BAD_RETURN(s32) cutscene_exit_bowser_key_toss_shake(struct Camera *c) { } /** - * Start a camera shake when mario lands on the ground. + * Start a camera shake when Mario lands on the ground. */ BAD_RETURN(s32) cutscene_exit_succ_shake_landing(UNUSED struct Camera *c) { set_environmental_camera_shake(SHAKE_ENV_EXPLOSION); } /** - * Cutscene that plays when mario beats bowser and exits the level. + * Cutscene that plays when Mario beats bowser and exits the level. */ BAD_RETURN(s32) cutscene_exit_bowser_succ(struct Camera *c) { cutscene_event(cutscene_exit_succ_start, c, 0, 0); @@ -9295,7 +9294,7 @@ BAD_RETURN(s32) cutscene_exit_non_painting_succ_override_cvar(UNUSED struct Came } /** - * Cutscene that plays when mario collects a star and leaves a non-painting course, like HMC or BBH. + * Cutscene that plays when Mario collects a star and leaves a non-painting course, like HMC or BBH. */ BAD_RETURN(s32) cutscene_exit_non_painting_succ(struct Camera *c) { cutscene_event(cutscene_exit_succ_start, c, 0, 0); @@ -9308,9 +9307,9 @@ BAD_RETURN(s32) cutscene_exit_non_painting_succ(struct Camera *c) { } /** - * Set cvar7 to mario's pos and faceAngle - * Set cvar6 to the focus offset from mario. - * set cvar5 to the pos offset from mario. (This is always overwritten) + * Set cvar7 to Mario's pos and faceAngle + * Set cvar6 to the focus offset from Mario. + * set cvar5 to the pos offset from Mario. (This is always overwritten) */ BAD_RETURN(s32) cutscene_non_painting_death_start(UNUSED struct Camera *c) { vec3f_copy(sCutsceneVars[7].point, sMarioCamState->pos); @@ -9321,11 +9320,11 @@ BAD_RETURN(s32) cutscene_non_painting_death_start(UNUSED struct Camera *c) { } /** - * This cutscene is the same as non_painting_death, but the camera is closer to mario and lower. + * This cutscene is the same as non_painting_death, but the camera is closer to Mario and lower. * Because it it doesn't call cutscene_non_painting_death_override_offset, the value from * cutscene_non_painting_death_start is used. * - * This cutscene is unused, dying in bowser's arena spawns mario near the warp pipe, not back in the + * This cutscene is unused, dying in bowser's arena spawns Mario near the warp pipe, not back in the * hub. */ BAD_RETURN(s32) cutscene_exit_bowser_death(struct Camera *c) { @@ -9335,7 +9334,7 @@ BAD_RETURN(s32) cutscene_exit_bowser_death(struct Camera *c) { } /** - * Set the offset from mario depending on the course mario exited. + * Set the offset from Mario depending on the course Mario exited. * This overrides cutscene_non_painting_death_start() */ BAD_RETURN(s32) cutscene_non_painting_death_override_offset(UNUSED struct Camera *c) { @@ -9353,7 +9352,7 @@ BAD_RETURN(s32) cutscene_non_painting_death_override_offset(UNUSED struct Camera } /** - * Cutscene played when mario dies in a non-painting course, like HMC or BBH. + * Cutscene played when Mario dies in a non-painting course, like HMC or BBH. */ BAD_RETURN(s32) cutscene_non_painting_death(struct Camera *c) { cutscene_event(cutscene_non_painting_death_start, c, 0, 0); @@ -9365,10 +9364,10 @@ BAD_RETURN(s32) cutscene_non_painting_death(struct Camera *c) { /** * Set cvars: - * cvar3 is an offset applied to the camera's rotation around mario. It starts at 0x1200 + * cvar3 is an offset applied to the camera's rotation around Mario. It starts at 0x1200 * cvar 1 is more complicated: - * First the yaw from mario to the camera is calculated. cvar1 is the high byte of the difference - * between that yaw and mario's faceAngle plus 0x1200. The reason for taking the high byte is + * First the yaw from Mario to the camera is calculated. cvar1 is the high byte of the difference + * between that yaw and Mario's faceAngle plus 0x1200. The reason for taking the high byte is * because cvar1 rotates until is reaches 0, so it's important that it's a multiple of 0x100. */ BAD_RETURN(s32) cutscene_cap_switch_press_start(struct Camera *c) { @@ -9379,13 +9378,13 @@ BAD_RETURN(s32) cutscene_cap_switch_press_start(struct Camera *c) { store_info_star(c); yaw = calculate_yaw(sMarioCamState->pos, c->pos); sCutsceneVars[3].angle[1] = 0x1200; - // Basically the amount of rotation to get from behind mario to in front of mario + // Basically the amount of rotation to get from behind Mario to in front of Mario sCutsceneVars[1].angle[1] = (yaw - (sMarioCamState->faceAngle[1] + sCutsceneVars[3].angle[1])) & 0xFF00; } /** - * Rotate around mario. As each cvar stops updating, the rotation slows until the camera ends up in - * front of mario. + * Rotate around Mario. As each cvar stops updating, the rotation slows until the camera ends up in + * front of Mario. */ BAD_RETURN(s32) cutscene_cap_switch_press_rotate_around_mario(struct Camera *c) { f32 dist; @@ -9418,7 +9417,7 @@ BAD_RETURN(s32) cutscene_cap_switch_press_lower_cam(struct Camera *c) { } /** - * Move the camera closer to mario. + * Move the camera closer to Mario. */ BAD_RETURN(s32) cutscene_cap_switch_press_approach_mario(struct Camera *c) { s16 pitch, yaw; @@ -9435,7 +9434,7 @@ BAD_RETURN(s32) cutscene_cap_switch_press_approach_mario(struct Camera *c) { } /** - * Pan the camera left so that mario is on the right side of the screen when the camera stops spinning. + * Pan the camera left so that Mario is on the right side of the screen when the camera stops spinning. */ BAD_RETURN(s32) cutscene_cap_switch_press_pan_left(struct Camera *c) { vec3f_copy(c->focus, sMarioCamState->pos); @@ -9457,7 +9456,7 @@ static UNUSED BAD_RETURN(s32) unused_cap_switch_retrieve_info(struct Camera *c) } /** - * Cutscene that plays when mario presses a cap switch. + * Cutscene that plays when Mario presses a cap switch. */ BAD_RETURN(s32) cutscene_cap_switch_press(struct Camera *c) { f32 dist; @@ -9507,7 +9506,7 @@ BAD_RETURN(s32) cutscene_unlock_key_door_start(struct Camera *c) { } /** - * Move the camera to the cvars position and focus, closer to mario. + * Move the camera to the cvars position and focus, closer to Mario. * Gives a better view of the key. */ BAD_RETURN(s32) cutscene_unlock_key_door_approach_mario(struct Camera *c) { @@ -9541,7 +9540,7 @@ BAD_RETURN(s32) cutscene_unlock_key_door_fov_shake(UNUSED struct Camera *c) { } /** - * Cutscene that plays when mario unlocks a key door. + * Cutscene that plays when Mario unlocks a key door. */ BAD_RETURN(s32) cutscene_unlock_key_door(UNUSED struct Camera *c) { cutscene_event(cutscene_unlock_key_door_start, c, 0, 0); @@ -9597,7 +9596,7 @@ BAD_RETURN(s32) play_sound_peach_reading_letter(UNUSED struct Camera *c) { #endif /** - * Move the camera from peach reading the letter all the way to mario's warp pipe. Follow the + * Move the camera from peach reading the letter all the way to Mario's warp pipe. Follow the * sIntroStartToPipe splines. */ BAD_RETURN(s32) cutscene_intro_peach_start_to_pipe_spline(struct Camera *c) { @@ -9608,7 +9607,7 @@ BAD_RETURN(s32) cutscene_intro_peach_start_to_pipe_spline(struct Camera *c) { } /** - * Loop the cutscene until mario exits the dialog. + * Loop the cutscene until Mario exits the dialog. */ BAD_RETURN(s32) cutscene_intro_peach_dialog(struct Camera *c) { if (get_dialog_id() == -1) { @@ -9667,7 +9666,7 @@ BAD_RETURN(s32) play_sound_intro_turn_on_hud(UNUSED struct Camera *c) { #endif /** - * Fly to the pipe. Near the end, the camera jumps to lakitu's position and the hud turns on. + * Fly to the pipe. Near the end, the camera jumps to Lakitu's position and the hud turns on. */ BAD_RETURN(s32) cutscene_intro_peach_fly_to_pipe(struct Camera *c) { #if defined(VERSION_US) || defined(VERSION_SH) @@ -9688,7 +9687,7 @@ BAD_RETURN(s32) cutscene_intro_peach_fly_to_pipe(struct Camera *c) { } /** - * Lakitu flies around the warp pipe, then mario jumps out. + * Lakitu flies around the warp pipe, then Mario jumps out. */ BAD_RETURN(s32) cutscene_intro_peach_mario_appears(struct Camera *c) { UNUSED u32 pad[2]; @@ -9702,7 +9701,7 @@ BAD_RETURN(s32) cutscene_intro_peach_mario_appears(struct Camera *c) { approach_f32_asymptotic_bool(&sCutsceneVars[1].point[1], 80.f + sMarioGeometry.currFloorHeight + (sMarioCamState->pos[1] - sMarioGeometry.currFloorHeight) * 1.1f, 0.4f); - // Make the camera look up as mario jumps out of the pipe + // Make the camera look up as Mario jumps out of the pipe if (c->focus[1] < sCutsceneVars[1].point[1]) { c->focus[1] = sCutsceneVars[1].point[1]; } @@ -9718,7 +9717,7 @@ BAD_RETURN(s32) cutscene_intro_peach_reset_fov(UNUSED struct Camera *c) { } /** - * Peach reads the letter to mario. + * Peach reads the letter to Mario. */ BAD_RETURN(s32) cutscene_intro_peach_letter(struct Camera *c) { cutscene_spawn_obj(5, 0); @@ -9956,7 +9955,7 @@ BAD_RETURN(s32) cutscene_credits(struct Camera *c) { } /** - * Set the camera pos relative to mario. + * Set the camera pos relative to Mario. */ BAD_RETURN(s32) cutscene_sliding_doors_open_start(struct Camera *c) { f32 dist; @@ -9975,9 +9974,9 @@ BAD_RETURN(s32) cutscene_sliding_doors_open_start(struct Camera *c) { } /** - * cvar1: mario's position - * cvar0.angle: mario's angle - * cvar0.point: offset from mario + * cvar1: Mario's position + * cvar0.angle: Mario's angle + * cvar0.point: offset from Mario */ BAD_RETURN(s32) cutscene_sliding_doors_open_set_cvars(UNUSED struct Camera *c) { vec3f_copy(sCutsceneVars[1].point, sMarioCamState->pos); @@ -9986,8 +9985,8 @@ BAD_RETURN(s32) cutscene_sliding_doors_open_set_cvars(UNUSED struct Camera *c) { } /** - * Decrease the cvar0 y offset to 75, which would simulate lakitu flying under the doorway. - * However, the initial y offset is too high for lakitu to reach 75 in time. + * Decrease the cvar0 y offset to 75, which would simulate Lakitu flying under the doorway. + * However, the initial y offset is too high for Lakitu to reach 75 in time. */ BAD_RETURN(s32) cutscene_sliding_doors_go_under_doorway(UNUSED struct Camera *c) { camera_approach_f32_symmetric_bool(&sCutsceneVars[0].point[1], 75.f, 10.f); @@ -10001,18 +10000,18 @@ BAD_RETURN(s32) cutscene_sliding_doors_fly_back_up(UNUSED struct Camera *c) { } /** - * Follow mario through the door, by approaching cvar1.point. + * Follow Mario through the door, by approaching cvar1.point. */ BAD_RETURN(s32) cutscene_sliding_doors_follow_mario(struct Camera *c) { Vec3f pos; UNUSED u32 pad[5]; vec3f_copy(pos, c->pos); - // Update cvar1 with mario's position (the y value doesn't change) + // Update cvar1 with Mario's position (the y value doesn't change) sCutsceneVars[1].point[0] = sMarioCamState->pos[0]; sCutsceneVars[1].point[2] = sMarioCamState->pos[2]; - // Decrease cvar0's offsets, moving the camera behind mario at his eye height. + // Decrease cvar0's offsets, moving the camera behind Mario at his eye height. approach_f32_asymptotic_bool(&sCutsceneVars[0].point[0], 0, 0.1f); camera_approach_f32_symmetric_bool(&sCutsceneVars[0].point[2], 125.f, 50.f); // Update cvar0's angle @@ -10022,13 +10021,13 @@ BAD_RETURN(s32) cutscene_sliding_doors_follow_mario(struct Camera *c) { offset_rotated(pos, sCutsceneVars[1].point, sCutsceneVars[0].point, sCutsceneVars[0].angle); approach_vec3f_asymptotic(c->pos, pos, 0.15f, 0.05f, 0.15f); - // Focus on mario's eye height + // Focus on Mario's eye height set_focus_rel_mario(c, 0, 125.f, 0, 0); } /** - * Plays when mario opens the sliding doors. - * Note: the star door unlocking event is not a cutscene, it's handled by mario separately. + * Plays when Mario opens the sliding doors. + * Note: the star door unlocking event is not a cutscene, it's handled by Mario separately. */ BAD_RETURN(s32) cutscene_sliding_doors_open(struct Camera *c) { UNUSED u32 pad[2]; @@ -10057,7 +10056,7 @@ BAD_RETURN(s32) cutscene_enter_painting_stub(UNUSED struct Camera *c) { } /** - * Plays when mario enters a painting. The camera flies up to the painting's center, then it slowly + * Plays when Mario enters a painting. The camera flies up to the painting's center, then it slowly * zooms in until the star select screen appears. */ BAD_RETURN(s32) cutscene_enter_painting(struct Camera *c) { @@ -10112,13 +10111,13 @@ BAD_RETURN(s32) cutscene_enter_painting(struct Camera *c) { } /** - * Warp the camera to mario, then use his faceAngle to calculate the right relative position. + * Warp the camera to Mario, then use his faceAngle to calculate the right relative position. * - * cvar0.point is mario's position - * cvar0.angle is mario's faceAngle + * cvar0.point is Mario's position + * cvar0.angle is Mario's faceAngle * - * cvar1 is the camera's position relative to mario - * cvar2 is the camera's focus relative to mario + * cvar1 is the camera's position relative to Mario + * cvar2 is the camera's focus relative to Mario */ BAD_RETURN(s32) cutscene_exit_painting_start(struct Camera *c) { struct Surface *floor; @@ -10147,16 +10146,16 @@ BAD_RETURN(s32) cutscene_exit_painting_start(struct Camera *c) { } /** - * Decrease cvar2's x and z offset, moving closer to mario. + * Decrease cvar2's x and z offset, moving closer to Mario. */ BAD_RETURN(s32) cutscene_exit_painting_move_to_mario(struct Camera *c) { Vec3f pos; //! Tricky math: Since offset_rotated() flips Z offsets, you'd expect a positive Z offset to move - //! the camera into the wall. However, mario's faceAngle always points into the painting, so a - //! positive Z offset moves the camera "behind" mario, away from the painting. + //! the camera into the wall. However, Mario's faceAngle always points into the painting, so a + //! positive Z offset moves the camera "behind" Mario, away from the painting. //! - //! In the success cutscene, when mario jumps out face-first, only his gfx angle is updated. His + //! In the success cutscene, when Mario jumps out face-first, only his gfx angle is updated. His //! actual face angle isn't updated until after the cutscene. approach_f32_asymptotic_bool(&sCutsceneVars[2].point[0], 178.f, 0.05f); approach_f32_asymptotic_bool(&sCutsceneVars[2].point[2], 889.f, 0.05f); @@ -10166,7 +10165,7 @@ BAD_RETURN(s32) cutscene_exit_painting_move_to_mario(struct Camera *c) { } /** - * Move the camera down to the floor mario lands on. + * Move the camera down to the floor Mario lands on. */ BAD_RETURN(s32) cutscene_exit_painting_move_to_floor(struct Camera *c) { struct Surface *floor; @@ -10186,7 +10185,7 @@ BAD_RETURN(s32) cutscene_exit_painting_move_to_floor(struct Camera *c) { } /** - * Cutscene played when mario leaves a painting, either due to death or collecting a star. + * Cutscene played when Mario leaves a painting, either due to death or collecting a star. */ BAD_RETURN(s32) cutscene_exit_painting(struct Camera *c) { cutscene_event(cutscene_exit_painting_start, c, 0, 0); @@ -10202,7 +10201,7 @@ BAD_RETURN(s32) cutscene_exit_painting(struct Camera *c) { } /** - * Unused. Warp the camera to mario. + * Unused. Warp the camera to Mario. */ BAD_RETURN(s32) cutscene_unused_exit_start(struct Camera *c) { UNUSED Vec3f unused1; @@ -10217,7 +10216,7 @@ BAD_RETURN(s32) cutscene_unused_exit_start(struct Camera *c) { } /** - * Unused. Focus on mario as he exits. + * Unused. Focus on Mario as he exits. */ BAD_RETURN(s32) cutscene_unused_exit_focus_mario(struct Camera *c) { Vec3f focus; @@ -10347,7 +10346,7 @@ BAD_RETURN(s32) cutscene_door_fix_cam(struct Camera *c) { } /** - * Loop until mario is no longer using the door. + * Loop until Mario is no longer using the door. */ BAD_RETURN(s32) cutscene_door_loop(struct Camera *c) { //! bitwise AND instead of boolean @@ -10358,7 +10357,7 @@ BAD_RETURN(s32) cutscene_door_loop(struct Camera *c) { } /** - * Warp the camera behind mario. + * Warp the camera behind Mario. */ BAD_RETURN(s32) cutscene_door_move_behind_mario(struct Camera *c) { Vec3f camOffset; @@ -10380,7 +10379,7 @@ BAD_RETURN(s32) cutscene_door_move_behind_mario(struct Camera *c) { } /** - * Follow mario through the door. + * Follow Mario through the door. */ BAD_RETURN(s32) cutscene_door_follow_mario(struct Camera *c) { s16 pitch, yaw; @@ -10442,7 +10441,7 @@ BAD_RETURN(s32) cutscene_door_mode(struct Camera *c) { c->yaw = c->nextYaw; - // Loop until mario is no longer using the door + // Loop until Mario is no longer using the door if (sMarioCamState->action != ACT_ENTERING_STAR_DOOR && sMarioCamState->action != ACT_PULLING_DOOR && sMarioCamState->action != ACT_PUSHING_DOOR) { @@ -10456,7 +10455,7 @@ BAD_RETURN(s32) cutscene_door_mode(struct Camera *c) { ******************************************************************************************************/ /** - * Cutscene that plays when mario beats the game. + * Cutscene that plays when Mario beats the game. */ struct Cutscene sCutsceneEnding[] = { { cutscene_ending_mario_fall, 170 }, @@ -10485,7 +10484,7 @@ struct Cutscene sCutsceneEnding[] = { }; /** - * Cutscene that plays when mario collects the grand star from bowser. + * Cutscene that plays when Mario collects the grand star from bowser. */ struct Cutscene sCutsceneGrandStar[] = { { cutscene_grand_star, 360 }, @@ -10498,7 +10497,7 @@ struct Cutscene sCutsceneUnused[] = { }; /** - * Cutscene that plays when mario enters a door that warps to another area. + * Cutscene that plays when Mario enters a door that warps to another area. */ struct Cutscene sCutsceneDoorWarp[] = { { cutscene_door_start, 1 }, @@ -10506,7 +10505,7 @@ struct Cutscene sCutsceneDoorWarp[] = { }; /** - * Cutscene that plays after the credits, when lakitu is flying away from the castle. + * Cutscene that plays after the credits, when Lakitu is flying away from the castle. */ struct Cutscene sCutsceneEndWaving[] = { { cutscene_end_waving, CUTSCENE_LOOP } @@ -10520,7 +10519,7 @@ struct Cutscene sCutsceneCredits[] = { }; /** - * Cutscene that plays when mario pulls open a door. + * Cutscene that plays when Mario pulls open a door. */ struct Cutscene sCutsceneDoorPull[] = { { cutscene_door_start, 1 }, @@ -10531,7 +10530,7 @@ struct Cutscene sCutsceneDoorPull[] = { }; /** - * Cutscene that plays when mario pushes open a door. + * Cutscene that plays when Mario pushes open a door. */ struct Cutscene sCutsceneDoorPush[] = { { cutscene_door_start, 1 }, @@ -10542,7 +10541,7 @@ struct Cutscene sCutsceneDoorPush[] = { }; /** - * Cutscene that plays when mario pulls open a door that has some special mode requirement on the other + * Cutscene that plays when Mario pulls open a door that has some special mode requirement on the other * side. */ struct Cutscene sCutsceneDoorPullMode[] = { @@ -10552,7 +10551,7 @@ struct Cutscene sCutsceneDoorPullMode[] = { }; /** - * Cutscene that plays when mario pushes open a door that has some special mode requirement on the other + * Cutscene that plays when Mario pushes open a door that has some special mode requirement on the other * side. */ struct Cutscene sCutsceneDoorPushMode[] = { @@ -10562,7 +10561,7 @@ struct Cutscene sCutsceneDoorPushMode[] = { }; /** - * Cutscene that plays when mario enters the cannon and it rises out of the hole. + * Cutscene that plays when Mario enters the cannon and it rises out of the hole. */ struct Cutscene sCutsceneEnterCannon[] = { { cutscene_enter_cannon_start, 1 }, @@ -10589,14 +10588,14 @@ struct Cutscene sCutsceneRedCoinStarSpawn[] = { }; /** - * Cutscene that plays when mario enters a course painting. + * Cutscene that plays when Mario enters a course painting. */ struct Cutscene sCutsceneEnterPainting[] = { { cutscene_enter_painting, CUTSCENE_LOOP } }; /** - * Cutscene that plays when mario dies and warps back to the castle. + * Cutscene that plays when Mario dies and warps back to the castle. */ struct Cutscene sCutsceneDeathExit[] = { { cutscene_exit_painting, 118 }, @@ -10604,7 +10603,7 @@ struct Cutscene sCutsceneDeathExit[] = { }; /** - * Cutscene that plays when mario warps to the castle after collecting a star. + * Cutscene that plays when Mario warps to the castle after collecting a star. */ struct Cutscene sCutsceneExitPaintingSuccess[] = { { cutscene_exit_painting, 180 }, @@ -10618,7 +10617,7 @@ struct Cutscene sCutsceneUnusedExit[] = { }; /** - * The intro of the game. Peach reads her letter and lakitu flies down to mario's warp pipe. + * The intro of the game. Peach reads her letter and Lakitu flies down to Mario's warp pipe. */ struct Cutscene sCutsceneIntroPeach[] = { { cutscene_intro_peach_letter, CUTSCENE_LOOP }, @@ -10641,7 +10640,7 @@ struct Cutscene sCutscenePrepareCannon[] = { }; /** - * Cutscene that plays when mario enters the castle grounds after leaving CotMC through the waterfall. + * Cutscene that plays when Mario enters the castle grounds after leaving CotMC through the waterfall. */ struct Cutscene sCutsceneExitWaterfall[] = { { cutscene_exit_waterfall, 52 }, @@ -10649,7 +10648,7 @@ struct Cutscene sCutsceneExitWaterfall[] = { }; /** - * Cutscene that plays when mario falls from WMOTR. + * Cutscene that plays when Mario falls from WMOTR. */ struct Cutscene sCutsceneFallToCastleGrounds[] = { { cutscene_exit_fall_to_castle_grounds, 73 }, @@ -10657,7 +10656,7 @@ struct Cutscene sCutsceneFallToCastleGrounds[] = { }; /** - * Cutscene that plays when mario enters the pyramid through the hole at the top. + * Cutscene that plays when Mario enters the pyramid through the hole at the top. */ struct Cutscene sCutsceneEnterPyramidTop[] = { { cutscene_enter_pyramid_top, 90 }, @@ -10674,14 +10673,14 @@ struct Cutscene sCutscenePyramidTopExplode[] = { }; /** - * Cutscene that plays when mario dies while standing, or from electrocution. + * Cutscene that plays when Mario dies while standing, or from electrocution. */ struct Cutscene sCutsceneStandingDeath[] = { { cutscene_death_standing, CUTSCENE_LOOP } }; /** - * Cutscene that plays when mario enters HMC or CotMC. + * Cutscene that plays when Mario enters HMC or CotMC. */ struct Cutscene sCutsceneEnterPool[] = { { cutscene_enter_pool, 100 }, @@ -10689,35 +10688,35 @@ struct Cutscene sCutsceneEnterPool[] = { }; /** - * Cutscene that plays when mario dies on his stomach. + * Cutscene that plays when Mario dies on his stomach. */ struct Cutscene sCutsceneDeathStomach[] = { { cutscene_death_stomach, CUTSCENE_LOOP } }; /** - * Cutscene that plays when mario dies on his back. + * Cutscene that plays when Mario dies on his back. */ struct Cutscene sCutsceneDeathOnBack[] = { { cutscene_bbh_death, CUTSCENE_LOOP } }; /** - * Cutscene that plays when mario dies in quicksand. + * Cutscene that plays when Mario dies in quicksand. */ struct Cutscene sCutsceneQuicksandDeath[] = { { cutscene_quicksand_death, CUTSCENE_LOOP }, }; /** - * Unused cutscene for ACT_WATER_DEATH, which happens when mario gets hit by an enemy under water. + * Unused cutscene for ACT_WATER_DEATH, which happens when Mario gets hit by an enemy under water. */ struct Cutscene sCutsceneWaterDeath[] = { { cutscene_quicksand_death, CUTSCENE_LOOP } }; /** - * Cutscene that plays when mario suffocates. + * Cutscene that plays when Mario suffocates. */ struct Cutscene sCutsceneSuffocation[] = { { cutscene_suffocation, CUTSCENE_LOOP } @@ -10732,12 +10731,12 @@ struct Cutscene sCutsceneEnterBowserArena[] = { { cutscene_bowser_arena_end, 0 } }; -// The dance cutscenes are automatically stopped since reset_camera() is called after mario warps. +// The dance cutscenes are automatically stopped since reset_camera() is called after Mario warps. /** * Star dance cutscene. - * For the default dance, the camera moves closer to mario, then stays in place. - * For the rotate dance, the camera moves closer and rotates clockwise around mario. + * For the default dance, the camera moves closer to Mario, then stays in place. + * For the rotate dance, the camera moves closer and rotates clockwise around Mario. */ struct Cutscene sCutsceneDanceDefaultRotate[] = { { cutscene_dance_default_rotate, CUTSCENE_LOOP } @@ -10745,7 +10744,7 @@ struct Cutscene sCutsceneDanceDefaultRotate[] = { /** * Star dance cutscene. - * The camera moves closer and rotates clockwise around mario. + * The camera moves closer and rotates clockwise around Mario. */ struct Cutscene sCutsceneDanceFlyAway[] = { { cutscene_dance_fly_away, CUTSCENE_LOOP } @@ -10753,7 +10752,7 @@ struct Cutscene sCutsceneDanceFlyAway[] = { /** * Star dance cutscene. - * The camera moves in for a closeup on mario. Used in tight spaces and underwater. + * The camera moves in for a closeup on Mario. Used in tight spaces and underwater. */ struct Cutscene sCutsceneDanceCloseup[] = { { cutscene_dance_closeup, CUTSCENE_LOOP } @@ -10761,21 +10760,21 @@ struct Cutscene sCutsceneDanceCloseup[] = { /** * Star dance cutscene. - * The camera moves closer and rotates clockwise around mario. + * The camera moves closer and rotates clockwise around Mario. */ struct Cutscene sCutsceneKeyDance[] = { { cutscene_key_dance, CUTSCENE_LOOP } }; /** - * Cutscene that plays when mario presses a cap switch. + * Cutscene that plays when Mario presses a cap switch. */ struct Cutscene sCutsceneCapSwitchPress[] = { { cutscene_cap_switch_press, CUTSCENE_LOOP } }; /** - * Cutscene that plays when mario opens a sliding star door. + * Cutscene that plays when Mario opens a sliding star door. */ struct Cutscene sCutsceneSlidingDoorsOpen[] = { { cutscene_sliding_doors_open, 50 }, @@ -10783,7 +10782,7 @@ struct Cutscene sCutsceneSlidingDoorsOpen[] = { }; /** - * Cutscene that plays when mario unlocks the basement or upstairs key door. + * Cutscene that plays when Mario unlocks the basement or upstairs key door. */ struct Cutscene sCutsceneUnlockKeyDoor[] = { { cutscene_unlock_key_door, 200 }, @@ -10791,7 +10790,7 @@ struct Cutscene sCutsceneUnlockKeyDoor[] = { }; /** - * Cutscene that plays when mario exits bowser's arena after getting the key. + * Cutscene that plays when Mario exits bowser's arena after getting the key. */ struct Cutscene sCutsceneExitBowserSuccess[] = { { cutscene_exit_bowser_succ, 190 }, @@ -10799,7 +10798,7 @@ struct Cutscene sCutsceneExitBowserSuccess[] = { }; /** - * Unused cutscene for when mario dies in bowser's arena. Instead, mario just respawns at the warp pipe. + * Unused cutscene for when Mario dies in bowser's arena. Instead, Mario just respawns at the warp pipe. */ struct Cutscene sCutsceneExitBowserDeath[] = { { cutscene_exit_bowser_death, 120 }, @@ -10807,7 +10806,7 @@ struct Cutscene sCutsceneExitBowserDeath[] = { }; /** - * Cutscene that plays when mario exits a non-painting course, like HMC. + * Cutscene that plays when Mario exits a non-painting course, like HMC. */ struct Cutscene sCutsceneExitSpecialSuccess[] = { { cutscene_exit_non_painting_succ, 163 }, @@ -10815,7 +10814,7 @@ struct Cutscene sCutsceneExitSpecialSuccess[] = { }; /** - * Cutscene that plays when mario exits from dying in a non-painting course, like HMC. + * Cutscene that plays when Mario exits from dying in a non-painting course, like HMC. */ struct Cutscene sCutsceneNonPaintingDeath[] = { { cutscene_non_painting_death, 120 }, @@ -10823,7 +10822,7 @@ struct Cutscene sCutsceneNonPaintingDeath[] = { }; /** - * Cutscene that plays when mario talks to a creature. + * Cutscene that plays when Mario talks to a creature. */ struct Cutscene sCutsceneDialog[] = { { cutscene_dialog, CUTSCENE_LOOP }, @@ -10832,7 +10831,7 @@ struct Cutscene sCutsceneDialog[] = { }; /** - * Cutscene that plays when mario reads a sign or message. + * Cutscene that plays when Mario reads a sign or message. */ struct Cutscene sCutsceneReadMessage[] = { { cutscene_read_message, CUTSCENE_LOOP }, @@ -10863,7 +10862,7 @@ struct Cutscene sCutsceneReadMessage[] = { * * 0: Lakitu flies away after the dance * 1: Only rotates the camera, doesn't zoom out - * 2: The camera goes to a close up of mario + * 2: The camera goes to a close up of Mario * 3: Bowser keys and the grand star * 4: Default, used for 100 coin stars, 8 red coin stars in bowser levels, and secret stars */ @@ -11353,7 +11352,7 @@ s32 cutscene_event(CameraEvent event, struct Camera *c, s16 start, s16 end) { * * @see intro_scene.inc.c for details on which objects are spawned. */ -s32 cutscene_spawn_obj(s32 obj, s16 frame) { +s32 cutscene_spawn_obj(u32 obj, s16 frame) { if (frame == gCutsceneTimer) { gCutsceneObjSpawn = obj; } @@ -11431,7 +11430,7 @@ void zoom_fov_30(UNUSED struct MarioState *m) { /** * This is the default fov function. It makes fov approach 45 degrees, and it handles zooming in when - * mario falls a sleep. + * Mario falls a sleep. */ void fov_default(struct MarioState *m) { sStatusFlags &= ~CAM_FLAG_SLEEPING; diff --git a/src/game/camera.h b/src/game/camera.h index 42d78515..173ab8a7 100644 --- a/src/game/camera.h +++ b/src/game/camera.h @@ -1,5 +1,7 @@ -#ifndef _CAMERA_H -#define _CAMERA_H +#ifndef CAMERA_H +#define CAMERA_H + +#include #include "types.h" #include "area.h" @@ -11,7 +13,7 @@ /** * @file camera.h * Constants, defines, and structs used by the camera system. - * @see camera.inc.c + * @see camera.c */ #define ABS(x) ((x) > 0.f ? (x) : -(x)) @@ -21,9 +23,9 @@ * Converts an angle in degrees to sm64's s16 angle units. For example, DEGREES(90) == 0x4000 * This should be used mainly to make camera code clearer at first glance. */ -#define DEGREES(x) (x * 0x10000 / 360) +#define DEGREES(x) ((x) * 0x10000 / 360) -#define LEVEL_AREA_INDEX(levelNum, areaNum) ((levelNum << 4) + areaNum) +#define LEVEL_AREA_INDEX(levelNum, areaNum) (((levelNum) << 4) + (areaNum)) /** * Helper macro for defining which areas of a level should zoom out the camera when the game is paused. @@ -107,7 +109,7 @@ #define CAMERA_MODE_BOSS_FIGHT 0x0B #define CAMERA_MODE_PARALLEL_TRACKING 0x0C #define CAMERA_MODE_FIXED 0x0D -#define CAMERA_MODE_8_DIRECTIONS 0x0E // AKA Parallel Camera, Bowser Courses & Rainbow Road +#define CAMERA_MODE_8_DIRECTIONS 0x0E // AKA Parallel Camera, Bowser Courses & Rainbow Ride #define CAMERA_MODE_FREE_ROAM 0x10 #define CAMERA_MODE_SPIRAL_STAIRS 0x11 #ifdef BETTERCAMERA @@ -358,15 +360,15 @@ typedef BAD_RETURN(s32) (*CameraEvent)(struct Camera *c); typedef CameraEvent CutsceneShot; /** - * Defines a bounding box which activates an event while mario is inside + * Defines a bounding box which activates an event while Mario is inside */ struct CameraTrigger { /** * The area this should be checked in, or -1 if it should run in every area of the level. * - * Triggers with area set to -1 are run by default, they don't care if mario is inside their bounds. - * However, they are only active if mario is not already inside an area-specific trigger's + * Triggers with area set to -1 are run by default, they don't care if Mario is inside their bounds. + * However, they are only active if Mario is not already inside an area-specific trigger's * boundaries. */ s8 area; @@ -381,7 +383,7 @@ struct CameraTrigger s16 boundsX; s16 boundsY; s16 boundsZ; - /// This angle rotates mario's offset from the box's origin, before it is checked for being inside. + /// This angle rotates Mario's offset from the box's origin, before it is checked for being inside. s16 boundsYaw; }; @@ -439,7 +441,7 @@ struct CutsceneSplinePoint /** * Struct containing the nearest floor and ceiling to the player, as well as the previous floor and - * ceilng. It also stores their distances from the player's position. + * ceiling. It also stores their distances from the player's position. */ struct PlayerGeometry { @@ -493,9 +495,9 @@ struct ParallelTrackingPoint s16 startOfPath; /// Point used to define a line segment to follow Vec3f pos; - /// The distance mario can move along the line before the camera should move + /// The distance Mario can move along the line before the camera should move f32 distThresh; - /// The percentage that the camera should move from the line to mario + /// The percentage that the camera should move from the line to Mario f32 zoom; }; @@ -536,7 +538,7 @@ struct Camera /*0x00*/ u8 mode; // What type of mode the camera uses (see defines above) /*0x01*/ u8 defMode; /** - * Determines what direction mario moves in when the analog stick is moved. + * Determines what direction Mario moves in when the analog stick is moved. * * @warning This is NOT the camera's xz-rotation in world space. This is the angle calculated from the * camera's focus TO the camera's position, instead of the other way around like it should @@ -567,7 +569,7 @@ struct Camera * A struct containing info pertaining to lakitu, such as his position and focus, and what * camera-related effects are happening to him, like camera shakes. * - * This struct's pos and foc are what is actually used to render the game. + * This struct's pos and focus are what is actually used to render the game. * * @see update_lakitu() */ @@ -610,7 +612,7 @@ struct LakituState /*0x52*/ Vec3s shakeMagnitude; // shake pitch, yaw, and roll phase: The progression through the camera shake (a cosine wave). - // shake pitch, yaw, and roll vel: The speed of the camera shake + // shake pitch, yaw, and roll vel: The speed of the camera shake. // shake pitch, yaw, and roll decay: The shake's deceleration. /*0x58*/ s16 shakePitchPhase; /*0x5A*/ s16 shakePitchVel; @@ -622,9 +624,9 @@ struct LakituState /// Used to rotate the screen when rendering. /*0x7A*/ s16 roll; - /// Copy of the camera's yaw + /// Copy of the camera's yaw. /*0x7C*/ s16 yaw; - /// Copy of the camera's next yaw + /// Copy of the camera's next yaw. /*0x7E*/ s16 nextYaw; /// The actual focus point the game uses to render. /*0x80*/ Vec3f focus; @@ -652,7 +654,7 @@ struct LakituState /// The roll offset applied during part of the key dance cutscene /*0xB4*/ s16 keyDanceRoll; - /// Mario's action from the previous frame. Only used to determine if mario just finished a dive. + /// Mario's action from the previous frame. Only used to determine if Mario just finished a dive. /*0xB8*/ u32 lastFrameAction; /*0xBC*/ s16 unused; }; @@ -661,7 +663,6 @@ struct LakituState #ifndef INCLUDED_FROM_CAMERA_C // BSS extern s16 sSelectionFlags; -extern s16 sCameraSideCFlags; extern s16 sCameraSoundFlags; extern u16 sCButtonsPressed; extern struct PlayerCameraState gPlayerCameraState[2]; @@ -673,103 +674,103 @@ extern struct Camera *gCamera; extern struct Object *gCutsceneFocus; extern struct Object *gSecondCameraFocus; +extern u8 gRecentCutscene; // TODO: sort all of this extremely messy shit out after the split -extern void set_camera_shake_from_hit(s16); -extern void set_environmental_camera_shake(s16); -extern void set_camera_shake_from_point(s16, f32, f32, f32); -extern void move_mario_head_c_up(struct Camera *); // static (ASM) -extern void transition_next_state(UNUSED struct Camera *c, s16 frames); -extern void set_camera_mode(struct Camera *, s16, s16); -extern void update_camera(struct Camera *); -extern void reset_camera(struct Camera *); -extern void init_camera(struct Camera *); -extern void select_mario_cam_mode(void); -extern Gfx *geo_camera_main(s32 callContext, struct GraphNode *g, void *context); -extern void stub_camera_2(struct Camera *); -extern void stub_camera_3(struct Camera *); -extern void vec3f_sub(Vec3f dst, Vec3f src); -extern void object_pos_to_vec3f(Vec3f, struct Object *); -extern void vec3f_to_object_pos(struct Object *, Vec3f); // static (ASM) -extern s32 move_point_along_spline(Vec3f, struct CutsceneSplinePoint[], s16 *, f32 *); -extern s32 cam_select_alt_mode(s32 angle); -extern s32 set_cam_angle(s32); -extern void set_handheld_shake(u8); -extern void shake_camera_handheld(Vec3f, Vec3f); -extern s32 find_c_buttons_pressed(u16, u16, u16); -extern s32 update_camera_hud_status(struct Camera *); -extern s32 collide_with_walls(Vec3f, f32, f32); -extern s32 clamp_pitch(Vec3f a, Vec3f b, s16 c, s16 d); -extern s32 is_within_100_units_of_mario(f32, f32, f32); -extern s32 set_or_approach_f32_asymptotic(f32 *, f32, f32); -extern s32 approach_f32_asymptotic_bool(f32 *current, f32 target, f32 multiplier); -extern f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier); // static (ASM) -extern s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 multiplier); -extern s32 approach_s16_asymptotic(s16 current, s16 target, s16 multiplier); // static (ASM) -extern void approach_vec3f_asymptotic(Vec3f current, Vec3f target, f32 xMul, f32 yMul, f32 zMul); // static (ASM) +void set_camera_shake_from_hit(s16 shake); +void set_environmental_camera_shake(s16 shake); +void set_camera_shake_from_point(s16 shake, f32 posX, f32 posY, f32 posZ); +void move_mario_head_c_up(UNUSED struct Camera *c); +void transition_next_state(UNUSED struct Camera *c, s16 frames); +void set_camera_mode(struct Camera *c, s16 mode, s16 frames); +void update_camera(struct Camera *c); +void reset_camera(struct Camera *c); +void init_camera(struct Camera *c); +void select_mario_cam_mode(void); +Gfx *geo_camera_main(s32 callContext, struct GraphNode *g, void *context); +void stub_camera_2(UNUSED struct Camera *c); +void stub_camera_3(UNUSED struct Camera *c); +void vec3f_sub(Vec3f dst, Vec3f src); +void object_pos_to_vec3f(Vec3f dst, struct Object *o); +void vec3f_to_object_pos(struct Object *o, Vec3f src); +s32 move_point_along_spline(Vec3f p, struct CutsceneSplinePoint spline[], s16 *splineSegment, f32 *progress); +s32 cam_select_alt_mode(s32 angle); +s32 set_cam_angle(s32 mode); +void set_handheld_shake(u8 mode); +void shake_camera_handheld(Vec3f pos, Vec3f focus); +s32 find_c_buttons_pressed(u16 currentState, u16 buttonsPressed, u16 buttonsDown); +s32 update_camera_hud_status(struct Camera *c); +s32 collide_with_walls(Vec3f pos, f32 offsetY, f32 radius); +s32 clamp_pitch(Vec3f from, Vec3f to, s16 maxPitch, s16 minPitch); +s32 is_within_100_units_of_mario(f32 posX, f32 posY, f32 posZ); +s32 set_or_approach_f32_asymptotic(f32 *dst, f32 goal, f32 scale); +s32 approach_f32_asymptotic_bool(f32 *current, f32 target, f32 multiplier); +f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier); +s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor); +s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor); +void approach_vec3f_asymptotic(Vec3f current, Vec3f target, f32 xMul, f32 yMul, f32 zMul); +void set_or_approach_vec3f_asymptotic(Vec3f dst, Vec3f goal, f32 xMul, f32 yMul, f32 zMul); +s32 camera_approach_s16_symmetric_bool(s16 *current, s16 target, s16 increment); +s32 set_or_approach_s16_symmetric(s16 *current, s16 target, s16 increment); +s32 camera_approach_f32_symmetric_bool(f32 *current, f32 target, f32 increment); +f32 camera_approach_f32_symmetric(f32 value, f32 target, f32 increment); +void random_vec3s(Vec3s dst, s16 xRange, s16 yRange, s16 zRange); +s32 clamp_positions_and_find_yaw(Vec3f pos, Vec3f origin, f32 xMax, f32 xMin, f32 zMax, f32 zMin); +s32 is_range_behind_surface(Vec3f from, Vec3f to, struct Surface *surf, s16 range, s16 surfType); +void scale_along_line(Vec3f dest, Vec3f from, Vec3f to, f32 scale); +s16 calculate_pitch(Vec3f from, Vec3f to); +s16 calculate_yaw(Vec3f from, Vec3f to); +void calculate_angles(Vec3f from, Vec3f to, s16 *pitch, s16 *yaw); +f32 calc_abs_dist(Vec3f a, Vec3f b); +f32 calc_hor_dist(Vec3f a, Vec3f b); +void rotate_in_xz(Vec3f dst, Vec3f src, s16 yaw); +void rotate_in_yz(Vec3f dst, Vec3f src, s16 pitch); +void set_camera_pitch_shake(s16 mag, s16 decay, s16 inc); +void set_camera_yaw_shake(s16 mag, s16 decay, s16 inc); +void set_camera_roll_shake(s16 mag, s16 decay, s16 inc); +void set_pitch_shake_from_point(s16 mag, s16 decay, s16 inc, f32 maxDist, f32 posX, f32 posY, f32 posZ); +void shake_camera_pitch(Vec3f pos, Vec3f focus); +void shake_camera_yaw(Vec3f pos, Vec3f focus); +void shake_camera_roll(s16 *roll); +s32 offset_yaw_outward_radial(struct Camera *c, s16 areaYaw); +void play_camera_buzz_if_cdown(void); +void play_camera_buzz_if_cbutton(void); +void play_camera_buzz_if_c_sideways(void); +void play_sound_cbutton_up(void); +void play_sound_cbutton_down(void); +void play_sound_cbutton_side(void); +void play_sound_button_change_blocked(void); +void play_sound_rbutton_changed(void); +void play_sound_if_cam_switched_to_lakitu_or_mario(void); +s32 radial_camera_input(struct Camera *c, UNUSED f32 unused); +s32 trigger_cutscene_dialog(s32 trigger); +void handle_c_button_movement(struct Camera *c); +void start_cutscene(struct Camera *c, u8 cutscene); +u8 get_cutscene_from_mario_status(struct Camera *c); +void warp_camera(f32 displacementX, f32 displacementY, f32 displacementZ); +void approach_camera_height(struct Camera *c, f32 goal, f32 inc); +void offset_rotated(Vec3f dst, Vec3f from, Vec3f to, Vec3s rotation); +s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, Vec3f oldPos, Vec3f oldFoc, s16 yaw); +void set_fixed_cam_axis_sa_lobby(UNUSED s16 preset); +s16 camera_course_processing(struct Camera *c); +void resolve_geometry_collisions(Vec3f pos, UNUSED Vec3f lastGood); +s32 rotate_camera_around_walls(struct Camera *c, Vec3f cPos, s16 *avoidYaw, s16 yawRange); +void find_mario_floor_and_ceil(struct PlayerGeometry *pg); +u8 start_object_cutscene_without_focus(u8 cutscene); +s16 cutscene_object_with_dialog(u8 cutscene, struct Object *o, s16 dialogID); +s16 cutscene_object_without_dialog(u8 cutscene, struct Object *o); +s16 cutscene_object(u8 cutscene, struct Object *o); +void play_cutscene(struct Camera *c); +s32 cutscene_event(CameraEvent event, struct Camera * c, s16 start, s16 end); +s32 cutscene_spawn_obj(u32 obj, s16 frame); +void set_fov_shake(s16 amplitude, s16 decay, s16 shakeSpeed); -extern void set_or_approach_vec3f_asymptotic(Vec3f dst, Vec3f goal, f32 xMul, f32 yMul, f32 zMul); // postdefined -extern s32 camera_approach_s16_symmetric_bool(s16 *current, s16 target, s16 increment); -extern s32 set_or_approach_s16_symmetric(s16 *current, s16 target, s16 increment); // postdefined -extern s32 camera_approach_f32_symmetric_bool(f32 *current, f32 target, f32 increment); -extern f32 camera_approach_f32_symmetric(f32 value, f32 target, f32 increment); -extern void random_vec3s(Vec3s dst, s16 xRange, s16 yRange, s16 zRange); // postdefined -extern s32 clamp_positions_and_find_yaw(Vec3f, Vec3f, f32, f32, f32, f32); -extern s32 is_range_behind_surface(Vec3f from, Vec3f to, struct Surface *surf, s16 range, s16 surfType); -extern void scale_along_line(Vec3f dest, Vec3f from, Vec3f to, f32 scale); -extern s16 calculate_pitch(Vec3f from, Vec3f to); -extern s16 calculate_yaw(Vec3f from, Vec3f to); -extern void calculate_angles(Vec3f from, Vec3f to, s16 *pitch, s16 *yaw); -extern f32 calc_abs_dist(Vec3f a, Vec3f b); -extern f32 calc_hor_dist(Vec3f a, Vec3f b); -extern void rotate_in_xz(Vec3f dst, Vec3f src, s16 yaw); -extern void rotate_in_yz(Vec3f dst, Vec3f src, s16 pitch); -extern void set_camera_pitch_shake(s16 mag, s16 pitchMagInc, s16 pitchInc); -extern void set_camera_yaw_shake(s16 mag, s16 yawMagInc, s16 yawInc); -extern void set_camera_roll_shake(s16 mag, s16 rollMagInc, s16 rollInc); -extern void set_pitch_shake_from_point(s16 mag, s16 pitchMagInc, s16 pitchInc, f32 maxDist, f32 posX, f32 posY, f32 posZ); -extern void shake_camera_pitch(); // postdefined -extern void shake_camera_yaw(); // postdefined -extern void shake_camera_roll(s16 *); // postdefined -extern s32 offset_yaw_outward_radial(struct Camera *a, s16 b); -extern void play_camera_buzz_if_cdown(void); -extern void play_camera_buzz_if_cbutton(void); -extern void play_camera_buzz_if_c_sideways(void); -extern void play_sound_cbutton_up(void); -extern void play_sound_cbutton_down(void); -extern void play_sound_cbutton_side(void); -extern void play_sound_button_change_blocked(void); // postdefined -extern void play_sound_rbutton_changed(void); // postdefined -extern void play_sound_if_cam_switched_to_lakitu_or_mario(void); // postdefined -extern s32 radial_camera_input(struct Camera *a, f32 b); -extern s32 trigger_cutscene_dialog(s32); -extern void handle_c_button_movement(struct Camera *); -extern void start_cutscene(struct Camera *a, u8 cutscene); // postdefined -extern u8 get_cutscene_from_mario_status(); // postdefined -extern void warp_camera(f32 displacementX, f32 displacementY, f32 displacementZ); -extern void approach_camera_height(struct Camera *c, f32 goal, f32 inc); -extern void offset_rotated(Vec3f dst, Vec3f from, Vec3f to, Vec3s rotation); -s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, Vec3f oldPos, Vec3f oldFoc, s16 yaw); // postdefined -extern void set_fixed_cam_axis_sa_lobby(s16 preset); // postdefined -extern s16 camera_course_processing(struct Camera *); // postdefined -extern void resolve_geometry_collisions(Vec3f, Vec3f); -extern s32 rotate_camera_around_walls(struct Camera *, Vec3f, s16 *, s16); -extern void find_mario_floor_and_ceil(struct PlayerGeometry *); // postdefined -extern u8 start_object_cutscene_without_focus(u8); -extern s16 cutscene_object_with_dialog(u8 cutsceneTable, struct Object *, s16); -extern s16 cutscene_object_without_dialog(u8, struct Object *); -extern s16 cutscene_object(u8 cutscene, struct Object *o); -extern void play_cutscene(struct Camera *c); -extern s32 cutscene_event(CameraEvent event, struct Camera * c, s16 start, s16 end); -extern s32 cutscene_spawn_obj(s32 phase, s16 frame); -extern void set_fov_shake(s16 amplitude, s16 decay, s16 shakeSpeed); +void set_fov_function(u8 func); +void cutscene_set_fov_shake_preset(u8 preset); +void set_fov_shake_from_point_preset(u8 preset, f32 posX, f32 posY, f32 posZ); +void obj_rotate_towards_point(struct Object *o, Vec3f point, s16 pitchOff, s16 yawOff, s16 pitchDiv, s16 yawDiv); -extern void set_fov_function(u8 func); -extern void cutscene_set_fov_shake_preset(u8 preset); -extern void set_fov_shake_from_point_preset(u8 preset, f32 posX, f32 posY, f32 posZ); -extern void obj_rotate_towards_point(struct Object *, Vec3f, s16, s16, s16, s16); +Gfx *geo_camera_fov(s32 callContext, struct GraphNode *g, UNUSED void *context); -extern Gfx *geo_camera_fov(s32 callContext, struct GraphNode *g, UNUSED void *context); - -#endif /* _CAMERA_H */ +#endif // CAMERA_H diff --git a/src/game/debug.c b/src/game/debug.c index 1f6fc799..e5f8c6ac 100644 --- a/src/game/debug.c +++ b/src/game/debug.c @@ -1,17 +1,18 @@ -#include +#include -#include "sm64.h" +#include "behavior_data.h" +#include "debug.h" #include "engine/behavior_script.h" -#include "object_helpers.h" -#include "audio/external.h" -#include "print.h" #include "engine/surface_collision.h" -#include "mario.h" #include "game_init.h" #include "main.h" -#include "debug.h" +#include "object_constants.h" +#include "object_fields.h" +#include "object_helpers.h" #include "object_list_processor.h" -#include "behavior_data.h" +#include "print.h" +#include "sm64.h" +#include "types.h" #define DEBUG_INFO_NOFLAGS (0 << 0) #define DEBUG_INFO_FLAG_DPRINT (1 << 0) diff --git a/src/game/debug.h b/src/game/debug.h index a4a47eda..7e89296c 100644 --- a/src/game/debug.h +++ b/src/game/debug.h @@ -1,7 +1,7 @@ -#ifndef _DEBUG_H -#define _DEBUG_H +#ifndef DEBUG_H +#define DEBUG_H -#include "types.h" +#include enum DebugPage { DEBUG_PAGE_OBJECTINFO, // 0: objectinfo @@ -12,17 +12,17 @@ enum DebugPage { DEBUG_PAGE_ENEMYINFO // 5: enemyinfo }; -extern s64 get_current_clock(void); -extern s64 get_clock_difference(s64 cycles); -extern void set_text_array_x_y(s32 xOffset, s32 yOffset); -extern void print_debug_top_down_objectinfo(const char *str, s32 number); -extern void print_debug_top_down_mapinfo(const char * str, s32 number); -extern void print_debug_bottom_up(const char*,s32); -extern void debug_unknown_level_select_check(void); -extern void reset_debug_objectinfo(void); -extern void stub_debug_5(void); -extern void try_print_debug_mario_object_info(void); -extern void try_do_mario_debug_object_spawn(void); -extern void try_print_debug_mario_level_info(void); +s64 get_current_clock(void); +s64 get_clock_difference(UNUSED s64 cycles); +void set_text_array_x_y(s32 xOffset, s32 yOffset); +void print_debug_top_down_objectinfo(const char *str, s32 number); +void print_debug_top_down_mapinfo(const char * str, s32 number); +void print_debug_bottom_up(const char *str, s32 number); +void debug_unknown_level_select_check(void); +void reset_debug_objectinfo(void); +void stub_debug_5(void); +void try_print_debug_mario_object_info(void); +void try_do_mario_debug_object_spawn(void); +void try_print_debug_mario_level_info(void); -#endif /* _DEBUG_H */ +#endif // DEBUG_H diff --git a/src/game/debug_course.c b/src/game/debug_course.c index 57e2e195..f3fcc46c 100644 --- a/src/game/debug_course.c +++ b/src/game/debug_course.c @@ -1,6 +1,4 @@ -#include - -#include "sm64.h" +#include "debug_course.h" // This is a seperate file according to Europe/Shindou // versions. It is unknown what this file was for. diff --git a/src/game/debug_course.h b/src/game/debug_course.h index 266aef30..8d094e09 100644 --- a/src/game/debug_course.h +++ b/src/game/debug_course.h @@ -1,6 +1,6 @@ -#ifndef _DEBUG_COURSE_H -#define _DEBUG_COURSE_H +#ifndef DEBUG_COURSE_H +#define DEBUG_COURSE_H void nop_change_course(void); -#endif +#endif // DEBUG_COURSE_H diff --git a/src/game/decompress.h b/src/game/decompress.h index 6afdd34d..653b1cd1 100644 --- a/src/game/decompress.h +++ b/src/game/decompress.h @@ -1,8 +1,6 @@ -#ifndef _DECOMPRESS_H -#define _DECOMPRESS_H +#ifndef DECOMPRESS_H +#define DECOMPRESS_H -#include "types.h" +void decompress(void *mio0, void *dest); -extern void decompress(void *, void *); - -#endif /* _DECOMPRESS_H */ +#endif // DECOMPRESS_H diff --git a/src/game/envfx_bubbles.c b/src/game/envfx_bubbles.c index 477c0063..16a92720 100644 --- a/src/game/envfx_bubbles.c +++ b/src/game/envfx_bubbles.c @@ -3,18 +3,17 @@ #include "sm64.h" #include "game_init.h" #include "memory.h" -#include "ingame_menu.h" #include "envfx_snow.h" #include "envfx_bubbles.h" #include "engine/surface_collision.h" #include "engine/math_util.h" #include "engine/behavior_script.h" #include "audio/external.h" -#include "obj_behaviors.h" +#include "textures.h" /** * This file implements environment effects that are not snow: - * Flowers (unused), lava bubbles and jetsream/whirlpool bubbles. + * Flowers (unused), lava bubbles and jet stream/whirlpool bubbles. * Refer to 'envfx_snow.c' for more info about environment effects. * Note that the term 'bubbles' is used as a collective name for * effects in this file even though flowers aren't bubbles. For the @@ -36,13 +35,6 @@ Vtx_t gBubbleTempVtx[3] = { { { 0, 0, 0 }, 0, { -498, 964 }, { 0xFF, 0xFF, 0xFF, 0xFF } }, }; -extern void *flower_bubbles_textures_ptr_0B002008; -extern void *lava_bubble_ptr_0B006020; -extern void *bubble_ptr_0B006848; -extern void *tiny_bubble_dl_0B006AB0; -extern void *tiny_bubble_dl_0B006D38; -extern void *tiny_bubble_dl_0B006D68; - /** * Check whether the particle with the given index is * laterally within distance of point (x, z). Used to @@ -63,7 +55,7 @@ s32 particle_is_laterally_close(s32 index, s32 x, s32 z, s32 distance) { * Generate a uniform random number in range [-2000, -1000[ or [1000, 2000[ * Used to position flower particles */ -s32 random_flower_offset() { +s32 random_flower_offset(void) { s32 result = random_float() * 2000.0f - 1000.0f; if (result < 0) { result -= 1000; @@ -272,7 +264,7 @@ void envfx_update_whirlpool(void) { } /** - * Check whether a jetstream bubble should respawn. Happens if it is laterally + * Check whether a jet stream bubble should respawn. Happens if it is laterally * 1000 units away from the source or 1500 units above it. */ s32 envfx_is_jestream_bubble_alive(s32 index) { @@ -288,7 +280,7 @@ s32 envfx_is_jestream_bubble_alive(s32 index) { } /** - * Update the positions of jestream bubble particles. + * Update the positions of jet stream bubble particles. * They move up and outwards. */ void envfx_update_jetstream(void) { @@ -411,7 +403,7 @@ void envfx_bubbles_update_switch(s32 mode, Vec3s camTo, Vec3s vertex1, Vec3s ver /** * Append 15 vertices to 'gfx', which is enough for 5 bubbles starting at - * 'index'. The 3 input vertices represent the roated triangle around (0,0,0) + * 'index'. The 3 input vertices represent the rotated triangle around (0,0,0) * that will be translated to bubble positions to draw the bubble image * * TODO: (Scrub C) @@ -550,7 +542,7 @@ Gfx *envfx_update_bubble_particles(s32 mode, UNUSED Vec3s marioPos, Vec3s camFro /** * Set the maximum particle count from the gEnvFxBubbleConfig variable, - * which is set by the whirlpool or jetstream behavior. + * which is set by the whirlpool or jet stream behavior. */ void envfx_set_max_bubble_particles(s32 mode) { switch (mode) { diff --git a/src/game/envfx_bubbles.h b/src/game/envfx_bubbles.h index d26b2e06..024c3fe0 100644 --- a/src/game/envfx_bubbles.h +++ b/src/game/envfx_bubbles.h @@ -1,7 +1,8 @@ -#ifndef INGAME_MENU_3_H -#define INGAME_MENU_3_H +#ifndef ENVFX_BUBBLES_H +#define ENVFX_BUBBLES_H -#include "types.h" +#include +#include #define ENVFX_STATE_UNUSED 0 #define ENVFX_STATE_SRC_X 1 // whirlpool / jetsream bubble source position @@ -16,6 +17,6 @@ // Used to communicate from whirlpool behavior to envfx extern s16 gEnvFxBubbleConfig[10]; -extern Gfx *envfx_update_bubbles(s32 sp28, Vec3s sp2C, Vec3s sp30, Vec3s sp34); +Gfx *envfx_update_bubbles(s32 mode, Vec3s marioPos, Vec3s camTo, Vec3s camFrom); -#endif // INGAME_MENU_3_H +#endif // ENVFX_BUBBLES_H diff --git a/src/game/envfx_snow.c b/src/game/envfx_snow.c index ea2dfc4c..c3c14a5c 100644 --- a/src/game/envfx_snow.c +++ b/src/game/envfx_snow.c @@ -18,7 +18,7 @@ * object-based particle effects, are rendered more efficiently by manually * generating display lists instead of drawing each particle separately. * This file implements snow effects, while in 'envfx_bubbles.c' the - * implementation for flowers (unused), lava bubbles and jetstream bubbles + * implementation for flowers (unused), lava bubbles and jet stream bubbles * can be found. * The main entry point for envfx is at the bottom of this file, which is * called from geo_envfx_main in level_geo.c @@ -144,7 +144,7 @@ void envfx_cleanup_snow(void *snowParticleArray) { /** * Given two points, return the vector from one to the other represented - * as euler angles and a length + * as Euler angles and a length */ void orbit_from_positions(Vec3s from, Vec3s to, s16 *radius, s16 *pitch, s16 *yaw) { f32 dx = to[0] - from[0]; @@ -267,7 +267,7 @@ void envfx_update_snow_blizzard(s32 snowCylinderX, s32 snowCylinderY, s32 snowCy * to the point (x: 3380, z: -520). Considering there is an unused blizzard * snow mode, this could have been used to check whether Mario is in a * 'blizzard area'. In Cool Cool Mountain and Snowman's Land the area lies - * near the starting point and doesn't seem meaningfull. Notably, the point is + * near the starting point and doesn't seem meaningful. Notably, the point is * close to the entrance of SL, so maybe there were plans for an extra hint to * find it. The radius of 3000 units is quite large for that though, covering * more than half of the mirror room. @@ -337,7 +337,7 @@ void rotate_triangle_vertices(Vec3s vertex1, Vec3s vertex2, Vec3s vertex3, s16 p /** * Append 15 vertices to 'gfx', which is enough for 5 snowflakes starting at - * 'index' in the buffer. The 3 input vertices represent the roated triangle + * 'index' in the buffer. The 3 input vertices represent the rotated triangle * around (0,0,0) that will be translated to snowflake positions to draw the * snowflake image. * diff --git a/src/game/envfx_snow.h b/src/game/envfx_snow.h index b104ff4e..7a83b536 100644 --- a/src/game/envfx_snow.h +++ b/src/game/envfx_snow.h @@ -1,7 +1,7 @@ #ifndef ENVFX_SNOW_H #define ENVFX_SNOW_H -#include +#include #include "types.h" #define ENVFX_MODE_NONE 0 // no effects @@ -18,7 +18,6 @@ struct EnvFxParticle { s8 isAlive; - //s8 filler01; s16 animFrame; // lava bubbles and flowers have frame animations s32 xPos; s32 yPos; @@ -31,14 +30,10 @@ struct EnvFxParticle { extern s8 gEnvFxMode; extern UNUSED s32 D_80330644; -extern struct SnowFlakeVertex gSnowFlakeVertex1; -extern struct SnowFlakeVertex gSnowFlakeVertex2; -extern struct SnowFlakeVertex gSnowFlakeVertex3; extern struct EnvFxParticle *gEnvFxBuffer; extern Vec3i gSnowCylinderLastPos; extern s16 gSnowParticleCount; -extern s16 gSnowParticleMaxCount; Gfx *envfx_update_particles(s32 snowMode, Vec3s marioPos, Vec3s camTo, Vec3s camFrom); void orbit_from_positions(Vec3s from, Vec3s to, s16 *radius, s16 *pitch, s16 *yaw); diff --git a/src/game/game_init.c b/src/game/game_init.c index 9afd28a6..87012408 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -1,6 +1,7 @@ #include #include "sm64.h" +#include "gfx_dimensions.h" #include "audio/external.h" #include "buffers/buffers.h" #include "gfx_dimensions.h" @@ -17,7 +18,7 @@ #include "sound_init.h" #include "print.h" #include "segment2.h" -#include "main_entry.h" +#include "segment_symbols.h" #include "thread6.h" #include #ifdef BETTERCAMERA @@ -146,16 +147,16 @@ void display_frame_buffer(void) { } /** Clears the framebuffer, allowing it to be overwritten. */ -void clear_frame_buffer(s32 a) { +void clear_frame_buffer(s32 color) { gDPPipeSync(gDisplayListHead++); gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); gDPSetCycleType(gDisplayListHead++, G_CYC_FILL); - gDPSetFillColor(gDisplayListHead++, a); - - // Ratio-correct borderfill - gDPFillRectangle(gDisplayListHead++, GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(0), BORDER_HEIGHT, GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(0) - 1, SCREEN_HEIGHT - BORDER_HEIGHT - 1); + gDPSetFillColor(gDisplayListHead++, color); + gDPFillRectangle(gDisplayListHead++, + GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(0), BORDER_HEIGHT, + GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(0) - 1, SCREEN_HEIGHT - BORDER_HEIGHT - 1); gDPPipeSync(gDisplayListHead++); @@ -163,19 +164,22 @@ void clear_frame_buffer(s32 a) { } /** Clears and initializes the viewport. */ -void clear_viewport(Vp *viewport, s32 b) { +void clear_viewport(Vp *viewport, s32 color) { s16 vpUlx = (viewport->vp.vtrans[0] - viewport->vp.vscale[0]) / 4 + 1; s16 vpUly = (viewport->vp.vtrans[1] - viewport->vp.vscale[1]) / 4 + 1; - s16 VpLrx = (viewport->vp.vtrans[0] + viewport->vp.vscale[0]) / 4 - 2; + s16 vpLrx = (viewport->vp.vtrans[0] + viewport->vp.vscale[0]) / 4 - 2; s16 vpLry = (viewport->vp.vtrans[1] + viewport->vp.vscale[1]) / 4 - 2; + vpUlx = GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(vpUlx); + vpLrx = GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(SCREEN_WIDTH - vpLrx); + gDPPipeSync(gDisplayListHead++); gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); gDPSetCycleType(gDisplayListHead++, G_CYC_FILL); - gDPSetFillColor(gDisplayListHead++, b); - gDPFillRectangle(gDisplayListHead++, vpUlx, vpUly, VpLrx, vpLry); + gDPSetFillColor(gDisplayListHead++, color); + gDPFillRectangle(gDisplayListHead++, vpUlx, vpUly, vpLrx, vpLry); gDPPipeSync(gDisplayListHead++); @@ -193,9 +197,11 @@ void draw_screen_borders(void) { gDPSetFillColor(gDisplayListHead++, GPACK_RGBA5551(0, 0, 0, 0) << 16 | GPACK_RGBA5551(0, 0, 0, 0)); #if BORDER_HEIGHT != 0 - gDPFillRectangle(gDisplayListHead++, 0, 0, SCREEN_WIDTH - 1, BORDER_HEIGHT - 1); - gDPFillRectangle(gDisplayListHead++, 0, SCREEN_HEIGHT - BORDER_HEIGHT, SCREEN_WIDTH - 1, - SCREEN_HEIGHT - 1); + gDPFillRectangle(gDisplayListHead++, GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(0), 0, + GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(0) - 1, BORDER_HEIGHT - 1); + gDPFillRectangle(gDisplayListHead++, + GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(0), SCREEN_HEIGHT - BORDER_HEIGHT, + GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(0) - 1, SCREEN_HEIGHT - 1); #endif } @@ -224,17 +230,9 @@ void create_task_structure(void) { gGfxSPTask->task.t.ucode_data_size = SP_UCODE_DATA_SIZE; gGfxSPTask->task.t.dram_stack = (u64 *) gGfxSPTaskStack; gGfxSPTask->task.t.dram_stack_size = SP_DRAM_STACK_SIZE8; - #ifdef VERSION_EU - // terrible hack - gGfxSPTask->task.t.output_buff = - (u64 *)((u8 *) gGfxSPTaskOutputBuffer - 0x670 + 0x280); - gGfxSPTask->task.t.output_buff_size = - (u64 *)((u8 *) gGfxSPTaskOutputBuffer+ 0x280 + 0x17790); - #else gGfxSPTask->task.t.output_buff = gGfxSPTaskOutputBuffer; gGfxSPTask->task.t.output_buff_size = (u64 *)((u8 *) gGfxSPTaskOutputBuffer + sizeof(gGfxSPTaskOutputBuffer)); - #endif gGfxSPTask->task.t.data_ptr = (u64 *) &gGfxPool->buffer; gGfxSPTask->task.t.data_size = entries * sizeof(Gfx); gGfxSPTask->task.t.yield_data_ptr = (u64 *) gGfxSPTaskYieldBuffer; @@ -562,7 +560,7 @@ void init_controllers(void) { if (gControllerBits & (1 << port)) { // the game allows you to have just 1 controller plugged // into any port in order to play the game. this was probably - // so if any of the ports didnt work, you can have controllers + // so if any of the ports didn't work, you can have controllers // plugged into any of them and it will work. gControllers[cont].port = port; gControllers[cont].statusData = &gControllerStatuses[port]; diff --git a/src/game/game_init.h b/src/game/game_init.h index 10dd2f86..59c5bdde 100644 --- a/src/game/game_init.h +++ b/src/game/game_init.h @@ -1,8 +1,21 @@ -#ifndef _GAME_INIT_H_ -#define _GAME_INIT_H_ +#ifndef GAME_INIT_H +#define GAME_INIT_H +#include +#include +#include +#include + +#include "types.h" #include "memory.h" +#define GFX_POOL_SIZE 64000 + +struct GfxPool { + Gfx buffer[GFX_POOL_SIZE]; + struct SPTask spTask; +}; + struct DemoInput { u8 timer; // time until next input. if this value is 0, it means the demo is over @@ -38,11 +51,6 @@ extern struct DemoInput *gCurrDemoInput; extern u16 gDemoInputListID; extern struct DemoInput gRecordedDemoInput; -extern void init_controllers(void); -extern void setup_game_memory(void); -extern void thread5_game_loop(void *); -extern u16 func_802495B0(u32); - // this area is the demo input + the header. when the demo is loaded in, there is a header the size // of a single word next to the input list. this word is the current ID count. extern struct MarioAnimation D_80339D10; @@ -51,29 +59,18 @@ extern struct MarioAnimation gDemo; extern u8 gMarioAnims[]; extern u8 gDemoInputs[]; -#define GFX_POOL_SIZE 64000 - -struct GfxPool { - Gfx buffer[GFX_POOL_SIZE]; - struct SPTask spTask; -}; - extern u16 frameBufferIndex; extern u32 gGlobalTimer; -// extern ? my_rdp_init(?); -// extern ? my_rsp_init(?); -// extern ? clear_z_buffer(?); -// extern ? display_frame_buffer(?); -extern void clear_frame_buffer(s32); -extern void clear_viewport(Vp *, s32); -// extern ? draw_screen_borders(?); +void setup_game_memory(void); +void thread5_game_loop(UNUSED void *arg); +void clear_frame_buffer(s32 color); +void clear_viewport(Vp *viewport, s32 color); void make_viewport_clip_rect(Vp *viewport); -extern void init_render_image(void); -extern void end_master_display_list(void); -//extern void draw_reset_bars(void); Target_64 only. Not used -extern void rendering_init(void); -extern void config_gfx_pool(void); -extern void display_and_vsync(void); +void init_render_image(void); +void end_master_display_list(void); +void rendering_init(void); +void config_gfx_pool(void); +void display_and_vsync(void); -#endif +#endif // GAME_INIT_H diff --git a/src/game/geo_misc.c b/src/game/geo_misc.c index afd5e289..72dd0bf0 100644 --- a/src/game/geo_misc.c +++ b/src/game/geo_misc.c @@ -1,4 +1,4 @@ -#include +#include #include "sm64.h" #include "geo_misc.h" @@ -6,9 +6,13 @@ #include "area.h" #include "engine/math_util.h" #include "level_update.h" -#include "mario_actions_cutscene.h" +#include "levels/castle_inside/header.h" +#include "levels/ending/header.h" +#include "levels/rr/header.h" #include "mario.h" +#include "mario_actions_cutscene.h" #include "memory.h" +#include "object_list_processor.h" #include "rendering_graph_node.h" #include "save_file.h" #include "segment2.h" @@ -24,15 +28,7 @@ */ #define NUM_FLYING_CARPET_VERTICES 21 -extern s16 flying_carpet_static_vertex_data[NUM_FLYING_CARPET_VERTICES]; - -extern Gfx dl_castle_lobby_wing_cap_light[]; - -extern Gfx dl_flying_carpet_begin[]; -extern Gfx dl_flying_carpet_model_half[]; -extern Gfx dl_flying_carpet_end[]; - -extern Gfx dl_cake_end_screen[]; +extern const s16 flying_carpet_static_vertex_data[NUM_FLYING_CARPET_VERTICES]; static s16 sCurAreaTimer = 1; static s16 sPrevAreaTimer = 0; @@ -47,7 +43,6 @@ s8 gFlyingCarpetState; * Texture coordinates are s10.5 fixed-point, which means you should left-shift the actual coordinates by 5. */ void make_vertex(Vtx *vtx, s32 n, f32 x, f32 y, f32 z, s16 tx, s16 ty, u8 r, u8 g, u8 b, u8 a) { - vtx[n].v.ob[0] = x; vtx[n].v.ob[1] = y; vtx[n].v.ob[2] = z; @@ -191,13 +186,6 @@ Gfx *geo_exec_flying_carpet_create(s32 callContext, struct GraphNode *node, UNUS return displayList; } -#ifdef VERSION_EU -// TODO: Symbolize these -extern Gfx dl_cake_end_screen_eu_070296F8[]; -extern Gfx dl_cake_end_screen_eu_07029768[]; -extern Gfx dl_cake_end_screen_eu_070297D8[]; -#endif - /** * Create a display list for the end screen with Peach's delicious cake. */ diff --git a/src/game/geo_misc.h b/src/game/geo_misc.h index fde7095e..31fa879e 100644 --- a/src/game/geo_misc.h +++ b/src/game/geo_misc.h @@ -1,7 +1,8 @@ -#ifndef _TRANSPARENT_TEXTURE_H -#define _TRANSPARENT_TEXTURE_H +#ifndef GEO_MISC_H +#define GEO_MISC_H -#include "types.h" +#include +#include enum FlyingCarpetState { @@ -16,11 +17,10 @@ extern void make_vertex( Vtx *vtx, s32 n, f32 x, f32 y, f32 z, s16 tx, s16 ty, u8 r, u8 g, u8 b, u8 a ); extern s16 round_float(f32); -extern Gfx *geo_exec_inside_castle_light(s32 callContext, struct GraphNode *node, f32 mtx[4][4]); -extern Gfx *geo_exec_flying_carpet_timer_update(s32 callContext, struct GraphNode *node, - f32 mtx[4][4]); -extern Gfx *geo_exec_flying_carpet_create(s32 callContext, struct GraphNode *node, f32 mtx[4][4]); -extern Gfx *geo_exec_cake_end_screen(s32 callContext, struct GraphNode *node, f32 mtx[4][4]); +extern Gfx *geo_exec_inside_castle_light(s32 callContext, struct GraphNode *node, UNUSED f32 mtx[4][4]); +extern Gfx *geo_exec_flying_carpet_timer_update(s32 callContext, struct GraphNode *node, UNUSED f32 mtx[4][4]); +extern Gfx *geo_exec_flying_carpet_create(s32 callContext, struct GraphNode *node, UNUSED f32 mtx[4][4]); +extern Gfx *geo_exec_cake_end_screen(s32 callContext, struct GraphNode *node, UNUSED f32 mtx[4][4]); #define gLoadBlockTexture(dl, width, height, format, image) \ { \ @@ -32,5 +32,4 @@ extern Gfx *geo_exec_cake_end_screen(s32 callContext, struct GraphNode *node, f3 gDPLoadBlock((dl), G_TX_LOADTILE, 0, 0, (width) * (height) - 1, CALC_DXT((width), G_IM_SIZ_16b_BYTES)) \ } - -#endif /* _TRANSPARENT_TEXTURE_H */ +#endif // GEO_MISC_H diff --git a/src/game/hud.c b/src/game/hud.c index cf3dee0f..5ee51152 100644 --- a/src/game/hud.c +++ b/src/game/hud.c @@ -1,7 +1,8 @@ -#include #include +#include #include "sm64.h" +#include "actors/common1.h" #include "gfx_dimensions.h" #include "game_init.h" #include "level_update.h" diff --git a/src/game/hud.h b/src/game/hud.h index 975819af..cbcbdeb8 100644 --- a/src/game/hud.h +++ b/src/game/hud.h @@ -1,7 +1,8 @@ #ifndef HUD_H #define HUD_H -#include "types.h" +#include +#include enum PowerMeterAnimation { POWER_METER_HIDDEN, @@ -20,14 +21,8 @@ enum CameraHUDLut { GLYPH_CAM_ARROW_DOWN }; -// Segment 3 -extern u8 *power_meter_health_segments_lut[]; -extern Gfx* dl_power_meter_base; -extern Gfx* dl_power_meter_health_segments_begin; -extern Gfx* dl_power_meter_health_segments_end; - // Functions -extern void set_hud_camera_status(s16 status); -extern void render_hud(void); +void set_hud_camera_status(s16 status); +void render_hud(void); -#endif /* HUD_H */ +#endif // HUD_H diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index 7c28c293..7ae9f1e7 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -1,24 +1,27 @@ #include -#include "sm64.h" -#include "gfx_dimensions.h" -#include "memory.h" -#include "types.h" +#include "actors/common1.h" +#include "area.h" #include "audio/external.h" -#include "seq_ids.h" -#include "dialog_ids.h" -#include "game_init.h" -#include "save_file.h" -#include "level_update.h" #include "camera.h" -#include "text_strings.h" +#include "course_table.h" +#include "dialog_ids.h" +#include "engine/math_util.h" +#include "eu_translation.h" +#include "game_init.h" +#include "gfx_dimensions.h" +#include "ingame_menu.h" +#include "level_update.h" +#include "levels/castle_grounds/header.h" +#include "memory.h" +#include "print.h" +#include "save_file.h" #include "segment2.h" #include "segment7.h" -#include "eu_translation.h" -#include "ingame_menu.h" -#include "print.h" -#include "engine/math_util.h" -#include "course_table.h" +#include "seq_ids.h" +#include "sm64.h" +#include "text_strings.h" +#include "types.h" #include "macros.h" #include "pc/cheats.h" #ifdef BETTERCAMERA @@ -28,18 +31,6 @@ #include "options_menu.h" #endif -extern Gfx *gDisplayListHead; -extern s16 gCurrCourseNum; -extern s16 gCurrSaveFileNum; - -extern Gfx coin_seg3_dl_03007940[]; -extern Gfx coin_seg3_dl_03007968[]; -extern Gfx coin_seg3_dl_03007990[]; -extern Gfx coin_seg3_dl_030079B8[]; - -extern u8 main_menu_seg7_table_0700ABD0[]; -extern Gfx castle_grounds_seg7_dl_0700EA58[]; - u16 gDialogColorFadeTimer; s8 gLastDialogLineNum; s32 gDialogVariable; @@ -118,7 +109,7 @@ s16 gDialogScrollOffsetY = 0; s8 gDialogBoxType = DIALOG_TYPE_ROTATE; s16 gDialogID = -1; s16 gLastDialogPageStrPos = 0; -s16 gDialogTextPos = 0; // EU: D_802FD64C +s16 gDialogTextPos = 0; #ifdef VERSION_EU s32 gInGameLanguage = 0; #endif @@ -361,9 +352,9 @@ enum MultiStringIDs { STRING_THE, STRING_YOU }; * 1: 'you' */ #ifdef VERSION_US -void render_multi_text_string(s8 multiTextID) // US: 802D76C8 +void render_multi_text_string(s8 multiTextID) #elif defined(VERSION_EU) -void render_multi_text_string(s16 *xPos, s16 *yPos, s8 multiTextID) // EU: 802AD650 +void render_multi_text_string(s16 *xPos, s16 *yPos, s8 multiTextID) #endif { s8 i; @@ -423,7 +414,7 @@ void print_generic_string(s16 x, s16 y, const u8 *str) { case DIALOG_CHAR_LOWER_A_UMLAUT: render_lowercase_diacritic(&xCoord, &yCoord, ASCII_TO_DIALOG('a'), str[strPos] & 0xF); break; - case DIALOG_CHAR_UPPER_A_UMLAUT: // @bug grave and circumflux (0x64-0x65) are absent here + case DIALOG_CHAR_UPPER_A_UMLAUT: // @bug grave and circumflex (0x64-0x65) are absent here render_uppercase_diacritic(&xCoord, &yCoord, ASCII_TO_DIALOG('A'), str[strPos] & 0xF); break; case DIALOG_CHAR_LOWER_E_GRAVE: @@ -1028,12 +1019,12 @@ void change_and_flash_dialog_text_color_lines(s8 colorMode, s8 lineNum) { #ifdef VERSION_EU void render_generic_dialog_char_at_pos(struct DialogEntry *dialog, s16 x, s16 y, u8 c) { - s16 width; // sp26 - s16 height; // sp24 + s16 width; + s16 height; s16 tmpX; s16 tmpY; - s16 xCoord; // sp1E - s16 yCoord; // sp1C + s16 xCoord; + s16 yCoord; void **fontLUT; void *packedTexture; void *unpackedTexture; @@ -1821,18 +1812,13 @@ void render_dialog_entries(void) { render_dialog_box_type(dialog, dialog->linesPerBox); gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, - 0, ensure_nonnegative(DIAG_VAL2 - dialog->width), #ifdef VERSION_EU - SCREEN_WIDTH, - ensure_nonnegative((240 - dialog->width) + ((dialog->linesPerBox * 80) / DIAG_VAL4) / gDialogBoxScale)); #else - SCREEN_WIDTH, - ensure_nonnegative(240 + ((dialog->linesPerBox * 80) / DIAG_VAL4) - dialog->width)); #endif #if defined(VERSION_JP) || defined(VERSION_SH) @@ -2008,10 +1994,6 @@ void do_cutscene_handler(void) { gCutsceneMsgTimer++; } -#ifndef VERSION_JP -extern Gfx castle_grounds_seg7_us_dl_0700F2E8[]; -#endif - #if defined(VERSION_JP) || defined(VERSION_SH) #define PEACH_MESSAGE_TIMER 170 #else @@ -2189,7 +2171,7 @@ void render_pause_red_coins(void) { } #ifdef VERSION_EU -u8 gTextCourseArr[][7] = { // D_802FDA10 +u8 gTextCourseArr[][7] = { { TEXT_COURSE }, { TEXT_COURSE_FR }, { TEXT_COURSE_DE } @@ -3108,10 +3090,9 @@ s16 render_menus_and_dialogs() { gDialogColorFadeTimer = (s16) gDialogColorFadeTimer + 0x1000; } else if (gDialogID != -1) { - // Peach message "Dear Mario" new game dialog + // The Peach "Dear Mario" message needs to be repositioned separately if (gDialogID == 20) { - print_peach_letter_message(); // the peach message needs to be - // repositioned seperately + print_peach_letter_message(); return mode; } diff --git a/src/game/ingame_menu.h b/src/game/ingame_menu.h index 85bca098..1435e164 100644 --- a/src/game/ingame_menu.h +++ b/src/game/ingame_menu.h @@ -1,7 +1,7 @@ #ifndef INGAME_MENU_H #define INGAME_MENU_H -#include "types.h" +#include #define ASCII_TO_DIALOG(asc) \ (((asc) >= '0' && (asc) <= '9') ? ((asc) - '0') : \ @@ -114,40 +114,39 @@ extern s16 gCutsceneMsgXOffset; extern s16 gCutsceneMsgYOffset; extern s8 gRedCoinsCollected; -extern void create_dl_identity_matrix(void); -extern void create_dl_translation_matrix(s8 pushOp, f32 x, f32 y, f32 z); -extern void create_dl_ortho_matrix(void); -extern void print_generic_string(s16 x, s16 y, const u8 *str); -extern void print_hud_lut_string(s8 fontLut, s16 x, s16 y, const u8 *str); -extern void print_menu_generic_string(s16 x, s16 y, const u8 *str); -extern void handle_menu_scrolling(s8 scrollDirection, s8 *currentIndex, s8 minIndex, s8 maxIndex); +void create_dl_identity_matrix(void); +void create_dl_translation_matrix(s8 pushOp, f32 x, f32 y, f32 z); +void create_dl_ortho_matrix(void); +void print_generic_string(s16 x, s16 y, const u8 *str); +void print_hud_lut_string(s8 hudLUT, s16 x, s16 y, const u8 *str); +void print_menu_generic_string(s16 x, s16 y, const u8 *str); +void handle_menu_scrolling(s8 scrollDirection, s8 *currentIndex, s8 minIndex, s8 maxIndex); #if defined(VERSION_US) || defined(VERSION_EU) -extern s16 get_str_x_pos_from_center(s16 centerPos, u8 *str, f32 scale); +s16 get_str_x_pos_from_center(s16 centerPos, u8 *str, f32 scale); #endif -#if defined(VERSION_JP) || defined(VERSION_EU) #ifdef VERSION_JP -// remap JP get_str_x_pos_from_center() calls to get_str_x_pos_from_center_scale() #define get_str_x_pos_from_center get_str_x_pos_from_center_scale #endif -extern s16 get_str_x_pos_from_center_scale(s16 centerPos, u8 *str, f32 scale); +#if defined(VERSION_JP) || defined(VERSION_EU) +s16 get_str_x_pos_from_center_scale(s16 centerPos, u8 *str, f32 scale); #endif -extern void print_hud_my_score_coins(s32 useCourseCoinScore, s8 fileNum, s8 courseNum, s16 x, s16 y); -extern void int_to_str(s32 num, u8 *dst); -extern s16 get_dialog_id(void); -extern void create_dialog_box(s16 dialog); -extern void create_dialog_box_with_var(s16 dialog, s32 dialogVar); -extern void create_dialog_inverted_box(s16 dialog); -extern void create_dialog_box_with_response(s16 dialog); -extern void reset_dialog_render_state(void); -extern void set_menu_mode(s16 mode); -extern void reset_cutscene_msg_fade(void); -extern void dl_rgba16_begin_cutscene_msg_fade(void); -extern void dl_rgba16_stop_cutscene_msg_fade(void); -extern void print_credits_str_ascii(s16 x, s16 y, const char *str); -extern void set_cutscene_message(s16 xOffset, s16 yOffset, s16 msgIndex, s16 msgDuration); -extern void do_cutscene_handler(void); -extern void render_hud_cannon_reticle(void); -extern void reset_red_coins_collected(void); -extern s16 render_menus_and_dialogs(void); +void print_hud_my_score_coins(s32 useCourseCoinScore, s8 fileNum, s8 courseNum, s16 x, s16 y); +void int_to_str(s32 num, u8 *dst); +s16 get_dialog_id(void); +void create_dialog_box(s16 dialog); +void create_dialog_box_with_var(s16 dialog, s32 dialogVar); +void create_dialog_inverted_box(s16 dialog); +void create_dialog_box_with_response(s16 dialog); +void reset_dialog_render_state(void); +void set_menu_mode(s16 mode); +void reset_cutscene_msg_fade(void); +void dl_rgba16_begin_cutscene_msg_fade(void); +void dl_rgba16_stop_cutscene_msg_fade(void); +void print_credits_str_ascii(s16 x, s16 y, const char *str); +void set_cutscene_message(s16 xOffset, s16 yOffset, s16 msgIndex, s16 msgDuration); +void do_cutscene_handler(void); +void render_hud_cannon_reticle(void); +void reset_red_coins_collected(void); +s16 render_menus_and_dialogs(void); -#endif /* INGAME_MENU_H */ +#endif // INGAME_MENU_H diff --git a/src/game/interaction.c b/src/game/interaction.c index 199911fb..7a9c5203 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -1,25 +1,27 @@ -#include +#include -#include "sm64.h" -#include "interaction.h" -#include "camera.h" -#include "level_update.h" -#include "engine/math_util.h" -#include "memory.h" #include "area.h" -#include "save_file.h" +#include "actors/common1.h" +#include "audio/external.h" +#include "behavior_actions.h" +#include "behavior_data.h" +#include "camera.h" +#include "course_table.h" +#include "dialog_ids.h" +#include "engine/math_util.h" #include "engine/surface_collision.h" -#include "sound_init.h" #include "game_init.h" +#include "interaction.h" +#include "level_update.h" #include "mario.h" +#include "mario_step.h" +#include "memory.h" #include "obj_behaviors.h" #include "object_helpers.h" -#include "behavior_actions.h" -#include "audio/external.h" -#include "behavior_data.h" -#include "dialog_ids.h" +#include "save_file.h" #include "seq_ids.h" -#include "course_table.h" +#include "sm64.h" +#include "sound_init.h" #include "thread6.h" #define INT_GROUND_POUND_OR_TWIRL (1 << 0) // 0x01 @@ -44,7 +46,6 @@ u8 sDelayInvincTimer; s16 sInvulnerable; -extern u8 warp_pipe_seg3_collision_03009AC8[]; u32 interact_coin(struct MarioState *, u32, struct Object *); u32 interact_water_ring(struct MarioState *, u32, struct Object *); u32 interact_star_or_key(struct MarioState *, u32, struct Object *); @@ -149,7 +150,7 @@ u32 get_mario_cap_flag(struct Object *capObject) { return 0; } /** - * Returns true if the passed in object has a moving angle yaw + * Returns true if the passed in object has a moving angle yaw * in the angular range given towards Mario. */ u32 object_facing_mario(struct MarioState *m, struct Object *o, s16 angleRange) { @@ -637,7 +638,7 @@ void push_mario_out_of_object(struct MarioState *m, struct Object *o, f32 paddin find_floor(newMarioX, m->pos[1], newMarioZ, &floor); if (floor != NULL) { - //! Doesn't update mario's referenced floor (allows oob death when + //! Doesn't update Mario's referenced floor (allows oob death when // an object pushes you into a steep slope while in a ground action) m->pos[0] = newMarioX; m->pos[2] = newMarioZ; @@ -1439,7 +1440,7 @@ u32 interact_koopa_shell(struct MarioState *m, UNUSED u32 interactType, struct O play_shell_music(); mario_drop_held_object(m); - //! Puts mario in ground action even when in air, making it easy to + //! Puts Mario in ground action even when in air, making it easy to // escape air actions into crouch slide (shell cancel) return set_mario_action(m, ACT_RIDING_SHELL_GROUND, 0); } @@ -1762,7 +1763,7 @@ void mario_process_interactions(struct MarioState *m) { m->invincTimer -= 1; } - //! If the kick/punch flags are set and an object collision changes mario's + //! If the kick/punch flags are set and an object collision changes Mario's // action, he will get the kick/punch wall speed anyway. check_kick_or_punch_wall(m); m->flags &= ~MARIO_PUNCHING & ~MARIO_KICKING & ~MARIO_TRIPPING; diff --git a/src/game/interaction.h b/src/game/interaction.h index 611022da..4d1aba96 100644 --- a/src/game/interaction.h +++ b/src/game/interaction.h @@ -1,5 +1,7 @@ -#ifndef _INTERACTION_H -#define _INTERACTION_H +#ifndef INTERACTION_H +#define INTERACTION_H + +#include #include "types.h" @@ -57,7 +59,7 @@ //INTERACT_BOUNCE_TOP #define INT_SUBTYPE_TWIRL_BOUNCE 0x00000080 -// INTERACT_STAR_OR_KEY +// INTERACT_STAR_OR_KEY #define INT_SUBTYPE_NO_EXIT 0x00000400 #define INT_SUBTYPE_GRAND_STAR 0x00000800 @@ -96,40 +98,20 @@ #define INT_STATUS_TOUCHED_BOB_OMB (1 << 23) /* 0x00800000 */ -struct BullyCollisionData { - /*0x00*/ f32 conversionRatio; - /*0x04*/ f32 radius; - /*0x08*/ f32 posX; - /*0x0C*/ f32 posZ; - /*0x10*/ f32 velX; - /*0x14*/ f32 velZ; -}; +s16 mario_obj_angle_to_object(struct MarioState *m, struct Object *o); +void mario_stop_riding_object(struct MarioState *m); +void mario_grab_used_object(struct MarioState *m); +void mario_drop_held_object(struct MarioState *m); +void mario_throw_held_object(struct MarioState *m); +void mario_stop_riding_and_holding(struct MarioState *m); +u32 does_mario_have_hat(struct MarioState *m); +void mario_blow_off_cap(struct MarioState *m, f32 capSpeed); +u32 mario_lose_cap_to_enemy(u32 arg); +void mario_retrieve_cap(void); +struct Object *mario_get_collided_object(struct MarioState *m, u32 interactType); +u32 mario_check_object_grab(struct MarioState *m); +u32 get_door_save_file_flag(struct Object *door); +void mario_process_interactions(struct MarioState *m); +void mario_handle_special_floors(struct MarioState *m); -extern u8 D_03009AC8[]; - -extern s16 mario_obj_angle_to_object(struct MarioState *, struct Object *); -extern void mario_stop_riding_object(struct MarioState *); -extern void mario_grab_used_object(struct MarioState *); -extern void mario_drop_held_object(struct MarioState *); -extern void mario_throw_held_object(struct MarioState *); -extern void mario_stop_riding_and_holding(struct MarioState *); -extern u32 does_mario_have_hat(struct MarioState *); -extern void mario_blow_off_cap(struct MarioState *, f32); -extern u32 mario_lose_cap_to_enemy(u32); -extern void mario_retrieve_cap(void); -extern struct Object *mario_get_collided_object(struct MarioState *, u32); -extern u32 mario_check_object_grab(struct MarioState *); -extern u32 get_door_save_file_flag(struct Object *); -extern void mario_process_interactions(struct MarioState *); -extern void mario_handle_special_floors(struct MarioState *); -extern BAD_RETURN(s32) init_bully_collision_data( - struct BullyCollisionData *data, - f32 posX, - f32 posZ, - f32 forwardVel, - s16 yaw, - f32 conversionRatio, - f32 radius); -extern void transfer_bully_speed(struct BullyCollisionData *, struct BullyCollisionData *); - -#endif /* _INTERACTION_H */ +#endif // INTERACTION_H diff --git a/src/game/level_geo.c b/src/game/level_geo.c index 65261c7f..4c98e705 100644 --- a/src/game/level_geo.c +++ b/src/game/level_geo.c @@ -11,9 +11,9 @@ /** * Geo function that generates a displaylist for environment effects such as - * snow or jetstream bubbles. + * snow or jet stream bubbles. */ -Gfx *geo_envfx_main(s32 callContext, struct GraphNode *node, f32 c[4][4]) { +Gfx *geo_envfx_main(s32 callContext, struct GraphNode *node, Mat4 mtxf) { Vec3s marioPos; Vec3s camFrom; Vec3s camTo; @@ -37,7 +37,7 @@ Gfx *geo_envfx_main(s32 callContext, struct GraphNode *node, f32 c[4][4]) { Mtx *mtx = alloc_display_list(sizeof(*mtx)); gfx = alloc_display_list(2 * sizeof(*gfx)); - mtxf_to_mtx(mtx, c); + mtxf_to_mtx(mtx, mtxf); gSPMatrix(&gfx[0], VIRTUAL_TO_PHYSICAL(mtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); gSPBranchList(&gfx[1], VIRTUAL_TO_PHYSICAL(particleList)); execNode->fnNode.node.flags = (execNode->fnNode.node.flags & 0xFF) | 0x400; diff --git a/src/game/level_geo.h b/src/game/level_geo.h index f131fa7a..a99f9ddd 100644 --- a/src/game/level_geo.h +++ b/src/game/level_geo.h @@ -1,5 +1,8 @@ -#ifndef _LEVEL_GEO_H -#define _LEVEL_GEO_H +#ifndef LEVEL_GEO_H +#define LEVEL_GEO_H + +#include +#include struct Struct802761D0 { @@ -8,7 +11,7 @@ struct Struct802761D0 u8 filler4[0x18-0x4]; }; -extern Gfx *geo_envfx_main(s32 a, struct GraphNode *b, f32 c[4][4]); -extern Gfx *geo_skybox_main(s32 a, struct GraphNode *b, UNUSED Mat4 *c); +Gfx *geo_envfx_main(s32 callContext, struct GraphNode *node, Mat4 mtxf); +Gfx *geo_skybox_main(s32 callContext, struct GraphNode *node, UNUSED Mat4 *mtx); -#endif /* _LEVEL_GEO_H */ +#endif // LEVEL_GEO_H diff --git a/src/game/level_update.c b/src/game/level_update.c index bbbebed0..72a6a607 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -24,14 +24,16 @@ #ifdef VERSION_EU #include "memory.h" #include "eu_translation.h" +#include "segment_symbols.h" #endif #include "level_table.h" #include "course_table.h" #include "thread6.h" #include "../../include/libc/stdlib.h" -#include "../pc/pc_main.h" +#include "pc/pc_main.h" #include "pc/cliopts.h" +#include "pc/configfile.h" #define PLAY_MODE_NORMAL 0 #define PLAY_MODE_PAUSED 2 @@ -84,7 +86,7 @@ const char *credits03[] = { "2SYSTEM PROGRAMMERS", "YASUNARI NISHIDA", "YOSHINOR const char *credits04[] = { "3PROGRAMMERS", "HAJIME YAJIMA", "DAIKI IWAMOTO", "TOSHIO IWAWAKI" }; const char *credits05[] = { "4CAMERA PROGRAMMER", "MARIO FACE PROGRAMMER", "TAKUMI KAWAGOE", "GILES GODDARD" -}; // US combines camera programmer and mario face programmer +}; // US combines camera programmer and Mario face programmer const char *credits06[] = { "2COURSE DIRECTORS", "YOICHI YAMADA", "YASUHISA YAMAMURA" }; const char *credits07[] = { "2COURSE DESIGNERS", "KENTA USUI", "NAOKI MORI" }; const char *credits08[] = { "3COURSE DESIGNERS", "YOSHIKI HARUHANA", "MAKOTO MIYANAGA", @@ -101,18 +103,18 @@ const char *credits15[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KA const char *credits16[] = { "5SCREEN TEXT WRITER", "TRANSLATION", "LESLIE SWAN", "MINA AKINO", "HIRO YAMADA" }; // ...in order to make room for these 2 new lines #else // VERSION_EU -const char *credits09[] = { "7SOUND COMPOSER", "SOUND EFFECTS", "SOUND PROGRAMMER", "KOJI KONDO", - "YOJI INAGAKI", "HIDEAKI SHIMIZU" }; -const char *credits10[] = { "63-D ANIMATORS", "ADDITIONAL GRAPHICS", "YOSHIAKI KOIZUMI", "SATORU TAKIZAWA", +const char *credits09[] = { "7SOUND COMPOSER", "SOUND EFFECTS", "SOUND PROGRAMMER", "KOJI KONDO", + "YOJI INAGAKI", "HIDEAKI SHIMIZU" }; +const char *credits10[] = { "63-D ANIMATORS", "ADDITIONAL GRAPHICS", "YOSHIAKI KOIZUMI", "SATORU TAKIZAWA", "MASANAO ARIMOTO" }; const char *credits11[] = { "3TECHNICAL SUPPORT", "TAKAO SAWANO", "HIROHITO YOSHIMOTO", "HIROTO YADA" }; const char *credits12[] = { "1TECHNICAL SUPPORT", "SGI N64 PROJECT STAFF" }; const char *credits13[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KATO" }; const char *credits14[] = { "5SCREEN TEXT WRITER", "ENGLISH TRANSLATION", "LESLIE SWAN", "MINA AKINO", "HIRO YAMADA" }; -const char *credits15[] = { "4SCREEN TEXT WRITER", "FRENCH TRANSLATION", "JULIEN BARDAKOFF", +const char *credits15[] = { "4SCREEN TEXT WRITER", "FRENCH TRANSLATION", "JULIEN BARDAKOFF", "KENJI HARAGUCHI" }; -const char *credits16[] = { "4SCREEN TEXT WRITER", "GERMAN TRANSLATION", "THOMAS GOERG", +const char *credits16[] = { "4SCREEN TEXT WRITER", "GERMAN TRANSLATION", "THOMAS GOERG", "THOMAS SPINDLER" }; #endif const char *credits17[] = { "4MARIO VOICE", "PEACH VOICE", "CHARLES MARTINET", "LESLIE SWAN" }; @@ -177,12 +179,6 @@ s8 D_8032C9E0 = 0; u8 unused3[4]; u8 unused4[2]; -// For configfile intro skipping -extern unsigned int configSkipIntro; - - -void basic_update(s16 *arg); - u16 level_control_timer(s32 timerOp) { switch (timerOp) { case TIMER_CONTROL_SHOW: @@ -311,7 +307,7 @@ void set_mario_initial_cap_powerup(struct MarioState *m) { void set_mario_initial_action(struct MarioState *m, u32 spawnType, u32 actionArg) { switch (spawnType) { - case MARIO_SPAWN_UNKNOWN_01: + case MARIO_SPAWN_DOOR_WARP: set_mario_action(m, ACT_WARP_DOOR_SPAWN, actionArg); break; case MARIO_SPAWN_UNKNOWN_02: @@ -320,49 +316,49 @@ void set_mario_initial_action(struct MarioState *m, u32 spawnType, u32 actionArg case MARIO_SPAWN_UNKNOWN_03: set_mario_action(m, ACT_EMERGE_FROM_PIPE, 0); break; - case MARIO_SPAWN_UNKNOWN_04: + case MARIO_SPAWN_TELEPORT: set_mario_action(m, ACT_TELEPORT_FADE_IN, 0); break; - case MARIO_SPAWN_UNKNOWN_10: + case MARIO_SPAWN_INSTANT_ACTIVE: set_mario_action(m, ACT_IDLE, 0); break; - case MARIO_SPAWN_UNKNOWN_12: + case MARIO_SPAWN_AIRBORNE: set_mario_action(m, ACT_SPAWN_NO_SPIN_AIRBORNE, 0); break; - case MARIO_SPAWN_UNKNOWN_13: + case MARIO_SPAWN_HARD_AIR_KNOCKBACK: set_mario_action(m, ACT_HARD_BACKWARD_AIR_KB, 0); break; - case MARIO_SPAWN_UNKNOWN_14: + case MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE: set_mario_action(m, ACT_SPAWN_SPIN_AIRBORNE, 0); break; case MARIO_SPAWN_DEATH: set_mario_action(m, ACT_FALLING_DEATH_EXIT, 0); break; - case MARIO_SPAWN_UNKNOWN_16: + case MARIO_SPAWN_SPIN_AIRBORNE: set_mario_action(m, ACT_SPAWN_SPIN_AIRBORNE, 0); break; - case MARIO_SPAWN_UNKNOWN_17: + case MARIO_SPAWN_FLYING: set_mario_action(m, ACT_FLYING, 2); break; - case MARIO_SPAWN_UNKNOWN_11: + case MARIO_SPAWN_SWIMMING: set_mario_action(m, ACT_WATER_IDLE, 1); break; - case MARIO_SPAWN_UNKNOWN_20: + case MARIO_SPAWN_PAINTING_STAR_COLLECT: set_mario_action(m, ACT_EXIT_AIRBORNE, 0); break; case MARIO_SPAWN_PAINTING_DEATH: set_mario_action(m, ACT_DEATH_EXIT, 0); break; - case MARIO_SPAWN_UNKNOWN_22: + case MARIO_SPAWN_AIRBORNE_STAR_COLLECT: set_mario_action(m, ACT_FALLING_EXIT_AIRBORNE, 0); break; - case MARIO_SPAWN_UNKNOWN_23: + case MARIO_SPAWN_AIRBORNE_DEATH: set_mario_action(m, ACT_UNUSED_DEATH_EXIT, 0); break; - case MARIO_SPAWN_UNKNOWN_24: + case MARIO_SPAWN_LAUNCH_STAR_COLLECT: set_mario_action(m, ACT_SPECIAL_EXIT_AIRBORNE, 0); break; - case MARIO_SPAWN_UNKNOWN_25: + case MARIO_SPAWN_LAUNCH_DEATH: set_mario_action(m, ACT_SPECIAL_DEATH_EXIT, 0); break; } @@ -383,7 +379,7 @@ void init_mario_after_warp(void) { gPlayerSpawnInfos[0].startAngle[1] = spawnNode->object->oMoveAngleYaw; gPlayerSpawnInfos[0].startAngle[2] = 0; - if (marioSpawnType == MARIO_SPAWN_UNKNOWN_01) { + if (marioSpawnType == MARIO_SPAWN_DOOR_WARP) { init_door_warp(&gPlayerSpawnInfos[0], sWarpDest.arg); } @@ -407,16 +403,16 @@ void init_mario_after_warp(void) { case MARIO_SPAWN_UNKNOWN_03: play_transition(WARP_TRANSITION_FADE_FROM_STAR, 0x10, 0x00, 0x00, 0x00); break; - case MARIO_SPAWN_UNKNOWN_01: + case MARIO_SPAWN_DOOR_WARP: play_transition(WARP_TRANSITION_FADE_FROM_CIRCLE, 0x10, 0x00, 0x00, 0x00); break; - case MARIO_SPAWN_UNKNOWN_04: + case MARIO_SPAWN_TELEPORT: play_transition(WARP_TRANSITION_FADE_FROM_COLOR, 0x14, 0xFF, 0xFF, 0xFF); break; - case MARIO_SPAWN_UNKNOWN_16: + case MARIO_SPAWN_SPIN_AIRBORNE: play_transition(WARP_TRANSITION_FADE_FROM_COLOR, 0x1A, 0xFF, 0xFF, 0xFF); break; - case MARIO_SPAWN_UNKNOWN_14: + case MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE: play_transition(WARP_TRANSITION_FADE_FROM_CIRCLE, 0x10, 0x00, 0x00, 0x00); break; case MARIO_SPAWN_UNKNOWN_27: @@ -640,7 +636,7 @@ void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg3) { #define PAINTING_WARP_INDEX_END 0x2D // Value less than Surface 0xFD /** - * Check if mario is above and close to a painting warp floor, and return the + * Check if Mario is above and close to a painting warp floor, and return the * corresponding warp node. */ struct WarpNode *get_painting_warp_node(void) { @@ -658,7 +654,7 @@ struct WarpNode *get_painting_warp_node(void) { } /** - * Check is mario has entered a painting, and if so, initiate a warp. + * Check is Mario has entered a painting, and if so, initiate a warp. */ void initiate_painting_warp(void) { if (gCurrentArea->paintingWarpNodes != NULL && gMarioState->floor != NULL) { @@ -696,7 +692,7 @@ void initiate_painting_warp(void) { /** * If there is not already a delayed warp, schedule one. The source node is - * based on the warp operation and sometimes mario's used object. + * based on the warp operation and sometimes Mario's used object. * Return the time left until the delayed warp is initiated. */ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) { @@ -948,7 +944,7 @@ void update_hud_values(void) { } /** - * Update objects, hud, and camera. This update function excludes things like + * Update objects, HUD, and camera. This update function excludes things like * endless staircase, warps, pausing, etc. This is used when entering a painting, * presumably to allow painting and camera updating while avoiding triggering the * warp twice. @@ -1119,8 +1115,7 @@ s32 play_mode_change_level(void) { } /** - * Unused play mode. Doesn't call transition update and doesn't reset transition - * at the end. + * Unused play mode. Doesn't call transition update and doesn't reset transition at the end. */ static s32 play_mode_unused(void) { if (--sTransitionTimer == -1) { @@ -1234,8 +1229,7 @@ s32 init_level(void) { } /** - * Initialize the current level if initOrUpdate is 0, or update the level if it - * is 1. + * Initialize the current level if initOrUpdate is 0, or update the level if it is 1. */ s32 lvl_init_or_update(s16 initOrUpdate, UNUSED s32 unused) { s32 result = 0; diff --git a/src/game/level_update.h b/src/game/level_update.h index a6100de2..ecf9c3a3 100644 --- a/src/game/level_update.h +++ b/src/game/level_update.h @@ -1,5 +1,7 @@ -#ifndef _LEVEL_UPDATE_H -#define _LEVEL_UPDATE_H +#ifndef LEVEL_UPDATE_H +#define LEVEL_UPDATE_H + +#include #include "types.h" @@ -27,25 +29,25 @@ #define WARP_OP_TRIGGERS_LEVEL_SELECT 0x10 -#define MARIO_SPAWN_UNKNOWN_01 0x01 -#define MARIO_SPAWN_UNKNOWN_02 0x02 -#define MARIO_SPAWN_UNKNOWN_03 0x03 -#define MARIO_SPAWN_UNKNOWN_04 0x04 -#define MARIO_SPAWN_UNKNOWN_10 0x10 -#define MARIO_SPAWN_UNKNOWN_11 0x11 -#define MARIO_SPAWN_UNKNOWN_12 0x12 -#define MARIO_SPAWN_UNKNOWN_13 0x13 -#define MARIO_SPAWN_UNKNOWN_14 0x14 -#define MARIO_SPAWN_DEATH 0x15 -#define MARIO_SPAWN_UNKNOWN_16 0x16 -#define MARIO_SPAWN_UNKNOWN_17 0x17 -#define MARIO_SPAWN_UNKNOWN_20 0x20 -#define MARIO_SPAWN_PAINTING_DEATH 0x21 -#define MARIO_SPAWN_UNKNOWN_22 0x22 -#define MARIO_SPAWN_UNKNOWN_23 0x23 -#define MARIO_SPAWN_UNKNOWN_24 0x24 -#define MARIO_SPAWN_UNKNOWN_25 0x25 -#define MARIO_SPAWN_UNKNOWN_27 0x27 +#define MARIO_SPAWN_DOOR_WARP 0x01 +#define MARIO_SPAWN_UNKNOWN_02 0x02 +#define MARIO_SPAWN_UNKNOWN_03 0x03 +#define MARIO_SPAWN_TELEPORT 0x04 +#define MARIO_SPAWN_INSTANT_ACTIVE 0x10 +#define MARIO_SPAWN_SWIMMING 0x11 +#define MARIO_SPAWN_AIRBORNE 0x12 +#define MARIO_SPAWN_HARD_AIR_KNOCKBACK 0x13 +#define MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE 0x14 +#define MARIO_SPAWN_DEATH 0x15 +#define MARIO_SPAWN_SPIN_AIRBORNE 0x16 +#define MARIO_SPAWN_FLYING 0x17 +#define MARIO_SPAWN_PAINTING_STAR_COLLECT 0x20 +#define MARIO_SPAWN_PAINTING_DEATH 0x21 +#define MARIO_SPAWN_AIRBORNE_STAR_COLLECT 0x22 +#define MARIO_SPAWN_AIRBORNE_DEATH 0x23 +#define MARIO_SPAWN_LAUNCH_STAR_COLLECT 0x24 +#define MARIO_SPAWN_LAUNCH_DEATH 0x25 +#define MARIO_SPAWN_UNKNOWN_27 0x27 struct CreditsEntry @@ -121,10 +123,10 @@ void load_level_init_text(u32 arg); s16 level_trigger_warp(struct MarioState *m, s32 warpOp); void level_set_transition(s16 length, void (*updateFunction)(s16 *)); -s32 lvl_init_or_update(s16 initOrUpdate, s32); -s32 lvl_init_from_save_file(s16, s32 levelNum); -s32 lvl_set_current_level(s16, s32 levelNum); -s32 lvl_play_the_end_screen_sound(s16, s32); +s32 lvl_init_or_update(s16 initOrUpdate, UNUSED s32 unused); +s32 lvl_init_from_save_file(UNUSED s16 arg0, s32 levelNum); +s32 lvl_set_current_level(UNUSED s16 arg0, s32 levelNum); +s32 lvl_play_the_end_screen_sound(UNUSED s16 arg0, UNUSED s32 arg1); +void basic_update(UNUSED s16 *arg); - -#endif +#endif // LEVEL_UPDATE_H diff --git a/src/game/macro_special_objects.c b/src/game/macro_special_objects.c index d9318971..17e4e6c4 100644 --- a/src/game/macro_special_objects.c +++ b/src/game/macro_special_objects.c @@ -1,4 +1,4 @@ -#include +#include #include "sm64.h" #include "object_helpers.h" @@ -174,7 +174,7 @@ void spawn_macro_objects(s16 areaIndex, s16 *macroObjList) { void spawn_macro_objects_hardcoded(s16 areaIndex, s16 *macroObjList) { UNUSED u8 pad[8]; - // This version of macroObjList has the preset and Y-Rotation seperated, + // This version of macroObjList has the preset and Y-Rotation separated, // and lacks behavior params. Might be an early version of the macro object list? s16 macroObjX; s16 macroObjY; diff --git a/src/game/macro_special_objects.h b/src/game/macro_special_objects.h index 37851cc9..c2ba81f4 100644 --- a/src/game/macro_special_objects.h +++ b/src/game/macro_special_objects.h @@ -1,21 +1,20 @@ #ifndef MACRO_SPECIAL_OBJECTS_H #define MACRO_SPECIAL_OBJECTS_H +#include + #include "types.h" -/*.bss*/ -extern struct Object gMacroObjectDefaultParent; - /* Functions */ -extern s16 convert_rotation(s16 inRotation); +s16 convert_rotation(s16 inRotation); -extern void spawn_macro_abs_yrot_2params(u32 model, const BehaviorScript *behavior, s16 x, s16 y, s16 z, s16 ry, s16 params); -extern void spawn_macro_abs_yrot_param1(u32 model, const BehaviorScript *behavior, s16 x, s16 y, s16 z, s16 ry, s16 params); -extern void spawn_macro_abs_special(u32 model, const BehaviorScript *behavior, s16 x, s16 y, s16 z, s16 unkA, s16 unkB, s16 unkC); +void spawn_macro_abs_yrot_2params(u32 model, const BehaviorScript *behavior, s16 x, s16 y, s16 z, s16 ry, s16 params); +void spawn_macro_abs_yrot_param1(u32 model, const BehaviorScript *behavior, s16 x, s16 y, s16 z, s16 ry, s16 params); +void spawn_macro_abs_special(u32 model, const BehaviorScript *behavior, s16 x, s16 y, s16 z, s16 unkA, s16 unkB, s16 unkC); -extern void spawn_macro_objects(s16 areaIndex, s16 * macroObjList); -extern void spawn_macro_objects_hardcoded(s16 areaIndex, s16 * macroObjList); -extern void spawn_special_objects(s16 areaIndex, s16 ** specialObjList); -extern u32 get_special_objects_size(s16 *data); +void spawn_macro_objects(s16 areaIndex, s16 *macroObjList); +void spawn_macro_objects_hardcoded(s16 areaIndex, s16 *macroObjList); +void spawn_special_objects(s16 areaIndex, s16 **specialObjList); +u32 get_special_objects_size(s16 *data); -#endif /* MACRO_SPECIAL_OBJECTS_H */ +#endif // MACRO_SPECIAL_OBJECTS_H diff --git a/src/game/main.c b/src/game/main.c index 78bf55aa..88855ee5 100644 --- a/src/game/main.c +++ b/src/game/main.c @@ -2,7 +2,6 @@ #include #include "sm64.h" -#include "prevent_bss_reordering.h" #include "audio/external.h" #include "game_init.h" #include "memory.h" @@ -248,7 +247,7 @@ void handle_vblank(void) { receive_new_tasks(); // First try to kick off an audio task. If the gfx task is currently - // running, we need to asychronously interrupt it -- handle_sp_complete + // running, we need to asynchronously interrupt it -- handle_sp_complete // will pick up on what we're doing and start the audio task for us. // If there is already an audio task running, there is nothing to do. // If there is no audio task available, try a gfx task instead. diff --git a/src/game/main.h b/src/game/main.h index 5746164f..0bf659ca 100644 --- a/src/game/main.h +++ b/src/game/main.h @@ -1,5 +1,5 @@ -#ifndef _MAIN_H_ -#define _MAIN_H_ +#ifndef MAIN_H +#define MAIN_H struct RumbleData { u8 unk00; @@ -54,11 +54,6 @@ extern struct StructSH8031D9B0 gCurrRumbleSettings; extern struct VblankHandler *gVblankHandler1; extern struct VblankHandler *gVblankHandler2; extern struct SPTask *gActiveSPTask; -extern struct SPTask *D_8032C62C; -extern struct SPTask *D_8032C630; -extern OSMesg D_8032C634; -extern OSMesg D_8032C638; -extern s8 D_8032C63C; extern u32 sNumVblanks; extern s8 gResetTimer; extern s8 D_8032C648; @@ -67,9 +62,8 @@ extern s8 D_8032C650; extern s8 gShowProfiler; extern s8 gShowDebugText; -extern void set_vblank_handler(s32 a, struct VblankHandler *b, OSMesgQueue *queue, OSMesg *msg); -extern void dispatch_audio_sptask(struct SPTask *spTask); -extern void send_display_list(struct SPTask *a); -// extern void main(void); +void set_vblank_handler(s32 index, struct VblankHandler *handler, OSMesgQueue *queue, OSMesg *msg); +void dispatch_audio_sptask(struct SPTask *spTask); +void send_display_list(struct SPTask *spTask); -#endif +#endif // MAIN_H diff --git a/src/game/main_entry.h b/src/game/main_entry.h deleted file mode 100644 index 5496c088..00000000 --- a/src/game/main_entry.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _MAIN_ENTRY_H -#define _MAIN_ENTRY_H - -#include "types.h" - -extern u8 _entrySegmentRomStart[]; -extern u8 _entrySegmentRomEnd[]; - -#endif /* _MAIN_ENTRY_H */ diff --git a/src/game/mario.c b/src/game/mario.c index 9da30d59..f409c163 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1,35 +1,37 @@ -#include +#include #include "sm64.h" -#include "mario.h" #include "area.h" +#include "audio/data.h" #include "audio/external.h" #include "behavior_actions.h" #include "behavior_data.h" #include "camera.h" -#include "mario_misc.h" -#include "game_init.h" #include "engine/graph_node.h" +#include "engine/math_util.h" +#include "engine/surface_collision.h" +#include "game_init.h" #include "interaction.h" +#include "level_table.h" #include "level_update.h" -#include "memory.h" #include "main.h" -#include "mario_actions_object.h" +#include "mario.h" +#include "mario_actions_airborne.h" #include "mario_actions_automatic.h" #include "mario_actions_cutscene.h" -#include "mario_actions_submerged.h" -#include "mario_actions_airborne.h" #include "mario_actions_moving.h" +#include "mario_actions_object.h" #include "mario_actions_stationary.h" +#include "mario_actions_submerged.h" +#include "mario_misc.h" #include "mario_step.h" -#include "engine/math_util.h" +#include "memory.h" #include "object_fields.h" #include "object_helpers.h" +#include "object_list_processor.h" #include "print.h" #include "save_file.h" #include "sound_init.h" -#include "engine/surface_collision.h" -#include "level_table.h" #include "thread6.h" #include "pc/configfile.h" #include "pc/cheats.h" @@ -350,7 +352,7 @@ void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits) { } /** - * Plays action and mario sounds relevant to what was passed into the function. + * Plays action and Mario sounds relevant to what was passed into the function. */ void play_mario_sound(struct MarioState *m, s32 actionSound, s32 marioSound) { if (actionSound == SOUND_ACTION_TERRAIN_JUMP) { @@ -388,7 +390,7 @@ void mario_set_forward_vel(struct MarioState *m, f32 forwardVel) { } /** - * Returns the slipperines class of Mario's floor. + * Returns the slipperiness class of Mario's floor. */ s32 mario_get_floor_class(struct MarioState *m) { s32 floorClass; @@ -765,7 +767,7 @@ void set_steep_jump_action(struct MarioState *m) { } /** - * Set's Marios vertical speed from his forward speed. + * Sets Mario's vertical speed from his forward speed. */ static void set_mario_y_vel_based_on_fspeed(struct MarioState *m, f32 initialVelY, f32 multiplier) { // get_additive_y_vel_for_jumps is always 0 and a stubbed function. @@ -1119,9 +1121,8 @@ s32 hurt_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg, s } /** - * Checks a variety of inputs for common transitions between - * many different actions. A common variant of the - * below function. + * Checks a variety of inputs for common transitions between many different + * actions. A common variant of the below function. */ s32 check_common_action_exits(struct MarioState *m) { if (m->input & INPUT_A_PRESSED) { @@ -1141,9 +1142,8 @@ s32 check_common_action_exits(struct MarioState *m) { } /** - * Checks a variety of inputs for common transitions between - * many different object holding actions. A holding variant of the - * above function. + * Checks a variety of inputs for common transitions between many different + * object holding actions. A holding variant of the above function. */ s32 check_common_hold_action_exits(struct MarioState *m) { if (m->input & INPUT_A_PRESSED) { @@ -1940,7 +1940,7 @@ void init_mario_from_save_file(void) { gMarioState->numLives = 4; gMarioState->health = 0x880; - gMarioState->unkB8 = gMarioState->numStars; + gMarioState->prevNumStarsForDialog = gMarioState->numStars; gMarioState->unkB0 = 0xBD; gHudDisplay.coins = 0; diff --git a/src/game/mario.h b/src/game/mario.h index 204cffc2..ad0d005a 100644 --- a/src/game/mario.h +++ b/src/game/mario.h @@ -1,56 +1,54 @@ -#ifndef _MARIO_H -#define _MARIO_H +#ifndef MARIO_H +#define MARIO_H +#include + +#include "macros.h" #include "types.h" -extern u32 gAudioRandom; +s32 is_anim_at_end(struct MarioState *m); +s32 is_anim_past_end(struct MarioState *m); +s16 set_mario_animation(struct MarioState *m, s32 targetAnimID); +s16 set_mario_anim_with_accel(struct MarioState *m, s32 targetAnimID, s32 accel); +void set_anim_to_frame(struct MarioState *m, s16 animFrame); +s32 is_anim_past_frame(struct MarioState *m, s16 animFrame); +s16 find_mario_anim_flags_and_translation(struct Object *o, s32 yaw, Vec3s translation); +void update_mario_pos_for_anim(struct MarioState *m); +s16 return_mario_anim_y_translation(struct MarioState *m); +void play_sound_if_no_flag(struct MarioState *m, u32 soundBits, u32 flags); +void play_mario_jump_sound(struct MarioState *m); +void adjust_sound_for_speed(struct MarioState *m); +void play_sound_and_spawn_particles(struct MarioState *m, u32 soundBits, u32 waveParticleType); +void play_mario_action_sound(struct MarioState *m, u32 soundBits, u32 waveParticleType); +void play_mario_landing_sound(struct MarioState *m, u32 soundBits); +void play_mario_landing_sound_once(struct MarioState *m, u32 soundBits); +void play_mario_heavy_landing_sound(struct MarioState *m, u32 soundBits); +void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits); +void play_mario_sound(struct MarioState *m, s32 primarySoundBits, s32 scondarySoundBits); +void mario_set_forward_vel(struct MarioState *m, f32 speed); +s32 mario_get_floor_class(struct MarioState *m); +u32 mario_get_terrain_sound_addend(struct MarioState *m); +struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius); +f32 vec3f_find_ceil(Vec3f pos, f32 height, struct Surface **ceil); +s32 mario_facing_downhill(struct MarioState *m, s32 turnYaw); +u32 mario_floor_is_slippery(struct MarioState *m); +s32 mario_floor_is_slope(struct MarioState *m); +s32 mario_floor_is_steep(struct MarioState *m); +f32 find_floor_height_relative_polar(struct MarioState *m, s16 angleFromMario, f32 distFromMario); +s16 find_floor_slope(struct MarioState *m, s16 yawOffset); +void update_mario_sound_and_camera(struct MarioState *m); +void set_steep_jump_action(struct MarioState *m); +u32 set_mario_action(struct MarioState *, u32 action, u32 actionArg); +s32 set_jump_from_landing(struct MarioState *m); +s32 set_jumping_action(struct MarioState *m, u32 action, u32 actionArg); +s32 drop_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg); +s32 hurt_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg, s16 hurtCounter); +s32 check_common_action_exits(struct MarioState *m); +s32 check_common_hold_action_exits(struct MarioState *m); +s32 transition_submerged_to_walking(struct MarioState *m); +s32 set_water_plunge_action(struct MarioState *m); +s32 execute_mario_action(UNUSED struct Object *o); +void init_mario(void); +void init_mario_from_save_file(void); -extern struct Object *gMarioObject; -extern struct Object *gLuigiObject; - -extern s32 is_anim_at_end(struct MarioState *m); -extern s32 is_anim_past_end(struct MarioState *m); -extern s16 set_mario_animation(struct MarioState *m, s32 targetAnimID); -extern s16 set_mario_anim_with_accel(struct MarioState *m, s32 targetAnimID, s32 accel); -extern void set_anim_to_frame(struct MarioState *m, s16 animFrame); -extern s32 is_anim_past_frame(struct MarioState *m, s16 animFrame); -extern s16 find_mario_anim_flags_and_translation(struct Object *o, s32 yaw, Vec3s translation); -extern void update_mario_pos_for_anim(struct MarioState *m); -extern s16 return_mario_anim_y_translation(struct MarioState *m); -extern void play_sound_if_no_flag(struct MarioState *m, u32 soundBits, u32 flags); -extern void play_mario_jump_sound(struct MarioState *m); -extern void adjust_sound_for_speed(struct MarioState *m); -extern void play_sound_and_spawn_particles(struct MarioState *m, u32 soundBits, u32 waveParticleType); -extern void play_mario_action_sound(struct MarioState *m, u32 soundBits, u32 waveParticleType); -extern void play_mario_landing_sound(struct MarioState *m, u32 soundBits); -extern void play_mario_landing_sound_once(struct MarioState *m, u32 soundBits); -extern void play_mario_heavy_landing_sound(struct MarioState *m, u32 soundBits); -extern void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits); -extern void play_mario_sound(struct MarioState *m, s32 primarySoundBits, s32 scondarySoundBits); -extern void mario_set_forward_vel(struct MarioState *m, f32 speed); -extern s32 mario_get_floor_class(struct MarioState *m); -extern u32 mario_get_terrain_sound_addend(struct MarioState *m); -extern struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius); -extern f32 vec3f_find_ceil(Vec3f pos, f32 height, struct Surface **ceil); -extern s32 mario_facing_downhill(struct MarioState *m, s32 turnYaw); -extern u32 mario_floor_is_slippery(struct MarioState *m); -extern s32 mario_floor_is_slope(struct MarioState *m); -extern s32 mario_floor_is_steep(struct MarioState *m); -extern f32 find_floor_height_relative_polar(struct MarioState *m, s16 angleFromMario, f32 distFromMario); -extern s16 find_floor_slope(struct MarioState *m, s16 yawOffset); -extern void update_mario_sound_and_camera(struct MarioState *m); -extern void set_steep_jump_action(struct MarioState *m); -extern u32 set_mario_action(struct MarioState *, u32 action, u32 actionArg); -extern s32 set_jump_from_landing(struct MarioState *m); -extern s32 set_jumping_action(struct MarioState *m, u32 action, u32 actionArg); -extern s32 drop_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg); -extern s32 hurt_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg, s16 hurtCounter); -extern s32 check_common_action_exits(struct MarioState *m); -extern s32 check_common_hold_action_exits(struct MarioState *m); -extern s32 transition_submerged_to_walking(struct MarioState *m); -extern s32 set_water_plunge_action(struct MarioState *m); -extern s32 execute_mario_action(struct Object *o); -extern void init_mario(void); -extern void init_mario_from_save_file(void); - -#endif /* _MARIO_H */ +#endif // MARIO_H diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 9289fd6c..e8c1e214 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -1,17 +1,18 @@ -#include +#include #include "sm64.h" #include "area.h" -#include "level_update.h" +#include "audio/data.h" +#include "audio/external.h" +#include "camera.h" +#include "engine/graph_node.h" #include "engine/math_util.h" +#include "game_init.h" #include "interaction.h" +#include "level_update.h" #include "mario.h" #include "mario_step.h" -#include "game_init.h" -#include "camera.h" #include "save_file.h" -#include "audio/external.h" -#include "engine/graph_node.h" #include "thread6.h" #ifdef BETTERCAMERA #include "bettercamera.h" diff --git a/src/game/mario_actions_airborne.h b/src/game/mario_actions_airborne.h index 70763201..116a20d0 100644 --- a/src/game/mario_actions_airborne.h +++ b/src/game/mario_actions_airborne.h @@ -1,8 +1,10 @@ -#ifndef _MARIO_ACTIONS_AIRBORNE_H -#define _MARIO_ACTIONS_AIRBORNE_H +#ifndef MARIO_ACTIONS_AIRBORNE_H +#define MARIO_ACTIONS_AIRBORNE_H -struct MarioState; +#include + +#include "types.h" s32 mario_execute_airborne_action(struct MarioState *m); -#endif /* _MARIO_ACTIONS_AIRBORNE_H */ +#endif // MARIO_ACTIONS_AIRBORNE_H diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index bc94f489..a74f4a18 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -1,4 +1,4 @@ -#include +#include #include "sm64.h" #include "behavior_data.h" @@ -399,7 +399,7 @@ s32 act_start_hanging(struct MarioState *m) { return set_mario_action(m, ACT_GROUND_POUND, 0); } - //! Crash if mario's referenced ceiling is NULL (same for other hanging actions) + //! Crash if Mario's referenced ceiling is NULL (same for other hanging actions) if (m->ceil->type != SURFACE_HANGABLE) { return set_mario_action(m, ACT_FREEFALL, 0); } diff --git a/src/game/mario_actions_automatic.h b/src/game/mario_actions_automatic.h index 0ce45a84..46855b32 100644 --- a/src/game/mario_actions_automatic.h +++ b/src/game/mario_actions_automatic.h @@ -1,6 +1,10 @@ -#ifndef _MARIO_ACTIONS_AUTOMATIC_H -#define _MARIO_ACTIONS_AUTOMATIC_H +#ifndef MARIO_ACTIONS_AUTOMATIC_H +#define MARIO_ACTIONS_AUTOMATIC_H + +#include + +#include "types.h" s32 mario_execute_automatic_action(struct MarioState *m); -#endif /* _MARIO_ACTIONS_AUTOMATIC_H */ +#endif // MARIO_ACTIONS_AUTOMATIC_H diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 30c0033a..72e76929 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -1,34 +1,35 @@ -#include -#include +#include + #include "prevent_bss_reordering.h" #include "sm64.h" -#include "gfx_dimensions.h" -#include "game_init.h" -#include "sound_init.h" -#include "level_update.h" -#include "interaction.h" -#include "mario.h" -#include "mario_step.h" -#include "mario_actions_moving.h" -#include "save_file.h" #include "area.h" -#include "camera.h" -#include "object_helpers.h" -#include "moving_texture.h" -#include "ingame_menu.h" +#include "audio/data.h" #include "audio/external.h" -#include "seq_ids.h" -#include "engine/math_util.h" -#include "engine/graph_node.h" -#include "engine/surface_collision.h" -#include "engine/behavior_script.h" #include "behavior_data.h" -#include "object_list_processor.h" -#include "level_table.h" +#include "camera.h" #include "dialog_ids.h" +#include "engine/behavior_script.h" +#include "engine/graph_node.h" +#include "engine/math_util.h" +#include "engine/surface_collision.h" +#include "game_init.h" +#include "gfx_dimensions.h" +#include "ingame_menu.h" +#include "interaction.h" +#include "level_table.h" +#include "level_update.h" +#include "mario.h" +#include "mario_actions_moving.h" +#include "mario_step.h" +#include "moving_texture.h" +#include "object_helpers.h" +#include "object_list_processor.h" +#include "save_file.h" +#include "seq_ids.h" +#include "sound_init.h" #include "thread6.h" #include "../../include/libc/stdlib.h" -#include "../pc/pc_main.h" +#include "pc/pc_main.h" // TODO: put this elsewhere enum SaveOption { SAVE_OPT_SAVE_AND_CONTINUE = 1, SAVE_OPT_SAVE_AND_QUIT, SAVE_OPT_SAVE_EXIT_GAME, SAVE_OPT_CONTINUE_DONT_SAVE }; @@ -157,8 +158,6 @@ void print_displaying_credits_entry(void) { } #endif - // smart dev here, thinking ahead for when the cosmic ray hits the rdram - // chips 23 years later and nearly causes upwarp 2 while (numLines-- > 0) { print_credits_str_ascii(CREDIT_TEXT_X_RIGHT - get_credits_str_width(*currStrPtr), strY, *currStrPtr); @@ -230,7 +229,8 @@ static void stub_is_textbox_active(u16 *a0) { * get_star_collection_dialog: Determine what dialog should show when Mario * collects a star. * Determines if Mario has collected enough stars to get a dialog for it, and - * if so, return the dialog ID. Otherwise, return 0 + * if so, return the dialog ID. Otherwise, return 0. A dialog is returned if + * numStars has reached a milestone and prevNumStarsForDialog has not reached it. */ s32 get_star_collection_dialog(struct MarioState *m) { s32 i; @@ -239,13 +239,13 @@ s32 get_star_collection_dialog(struct MarioState *m) { for (i = 0; i < 6; i++) { numStarsRequired = sStarsNeededForDialog[i]; - if (m->unkB8 < numStarsRequired && m->numStars >= numStarsRequired) { + if (m->prevNumStarsForDialog < numStarsRequired && m->numStars >= numStarsRequired) { dialogID = i + DIALOG_141; break; } } - m->unkB8 = m->numStars; + m->prevNumStarsForDialog = m->numStars; return dialogID; } @@ -253,7 +253,6 @@ s32 get_star_collection_dialog(struct MarioState *m) { void handle_save_menu(struct MarioState *m) { s32 dialogID; // wait for the menu to show up - // mario_finished_animation(m) ? (not my file, not my problem) if (is_anim_past_end(m) && gSaveOptSelectIndex != 0) { // save and continue / save and quit if (gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_CONTINUE || gSaveOptSelectIndex == SAVE_OPT_SAVE_EXIT_GAME || gSaveOptSelectIndex == SAVE_OPT_SAVE_AND_QUIT) { @@ -346,7 +345,7 @@ s32 mario_ready_to_speak(void) { return isReadyToSpeak; } -// (can) place mario in dialog? +// (can) place Mario in dialog? // initiate dialog? // return values: // 0 = not in dialog @@ -427,7 +426,7 @@ s32 act_reading_npc_dialog(struct MarioState *m) { return FALSE; } -// puts mario in a state where he's waiting for (npc) dialog; doesn't do much +// puts Mario in a state where he's waiting for (npc) dialog; doesn't do much s32 act_waiting_for_dialog(struct MarioState *m) { set_mario_animation(m, m->heldObj == NULL ? MARIO_ANIM_FIRST_PERSON : MARIO_ANIM_IDLE_WITH_LIGHT_OBJ); @@ -436,7 +435,7 @@ s32 act_waiting_for_dialog(struct MarioState *m) { return FALSE; } -// makes mario disappear and triggers warp +// makes Mario disappear and triggers warp s32 act_disappeared(struct MarioState *m) { set_mario_animation(m, MARIO_ANIM_A_POSE); stop_and_set_height_to_floor(m); @@ -463,7 +462,7 @@ s32 act_reading_automatic_dialog(struct MarioState *m) { // always look up for automatic dialogs m->actionTimer -= 1024; } else { - // set mario dialog + // set Mario dialog if (m->actionState == 9) { actionArg = m->actionArg; if (GET_HIGH_U16_OF_32(actionArg) == 0) { @@ -492,7 +491,7 @@ s32 act_reading_automatic_dialog(struct MarioState *m) { if (m->prevAction == ACT_STAR_DANCE_WATER) { set_mario_action(m, ACT_WATER_IDLE, 0); // 100c star? } else { - // make mario walk into door after star dialog + // make Mario walk into door after star dialog set_mario_action(m, m->prevAction == ACT_UNLOCKING_STAR_DOOR ? ACT_WALKING : ACT_IDLE, 0); } @@ -883,8 +882,8 @@ s32 act_entering_star_door(struct MarioState *m) { targetAngle += 0x5556; // ~120 degrees / 1/3 rot (total 150d / 5/12) } - // targetDX and targetDZ are the offsets to add to mario's position to - // have mario stand 150 units in front of the door + // targetDX and targetDZ are the offsets to add to Mario's position to + // have Mario stand 150 units in front of the door targetDX = m->usedObj->oPosX + 150.0f * sins(targetAngle) - m->pos[0]; targetDZ = m->usedObj->oPosZ + 150.0f * coss(targetAngle) - m->pos[2]; @@ -895,7 +894,7 @@ s32 act_entering_star_door(struct MarioState *m) { m->faceAngle[1] = atan2s(targetDZ, targetDX); } - // set mario's animation + // set Mario's animation if (m->actionTimer < 15) { set_mario_animation(m, MARIO_ANIM_FIRST_PERSON); } @@ -1066,7 +1065,7 @@ s32 act_spawn_spin_landing(struct MarioState *m) { s32 act_exit_airborne(struct MarioState *m) { if (15 < m->actionTimer++ && launch_mario_until_land(m, ACT_EXIT_LAND_SAVE_DIALOG, MARIO_ANIM_GENERAL_FALL, -32.0f)) { - // heal mario + // heal Mario m->healCounter = 31; } // rotate him to face away from the entrance @@ -1077,10 +1076,10 @@ s32 act_exit_airborne(struct MarioState *m) { s32 act_falling_exit_airborne(struct MarioState *m) { if (launch_mario_until_land(m, ACT_EXIT_LAND_SAVE_DIALOG, MARIO_ANIM_GENERAL_FALL, 0.0f)) { - // heal mario + // heal Mario m->healCounter = 31; } - // rotate mario to face away from the entrance + // rotate Mario to face away from the entrance m->marioObj->header.gfx.angle[1] += 0x8000; m->particleFlags |= PARTICLE_SPARKLES; return FALSE; @@ -1119,8 +1118,7 @@ s32 act_exit_land_save_dialog(struct MarioState *m) { animFrame = set_mario_animation(m, MARIO_ANIM_THROW_CATCH_KEY); switch (animFrame) { case -1: - spawn_obj_at_mario_rel_yaw(m, MODEL_BOWSER_KEY_CUTSCENE, bhvBowserKeyCourseExit, - -32768); + spawn_obj_at_mario_rel_yaw(m, MODEL_BOWSER_KEY_CUTSCENE, bhvBowserKeyCourseExit, -32768); //! fall through case 67: play_sound(SOUND_ACTION_KEY_SWISH, m->marioObj->header.gfx.cameraToObject); @@ -1233,15 +1231,15 @@ s32 act_special_exit_airborne(struct MarioState *m) { } if (launch_mario_until_land(m, ACT_EXIT_LAND_SAVE_DIALOG, MARIO_ANIM_SINGLE_JUMP, -24.0f)) { - // heal mario + // heal Mario m->healCounter = 31; m->actionArg = 1; } m->particleFlags |= PARTICLE_SPARKLES; - // rotate mario to face away from the entrance + // rotate Mario to face away from the entrance marioObj->header.gfx.angle[1] += 0x8000; - // show mario + // show Mario marioObj->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; return FALSE; @@ -1260,7 +1258,7 @@ s32 act_special_death_exit(struct MarioState *m) { m->numLives--; m->healCounter = 31; } - // show mario + // show Mario marioObj->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; // one unit of health m->health = 0x0100; @@ -1405,7 +1403,7 @@ s32 act_teleport_fade_out(struct MarioState *m) { play_sound_if_no_flag(m, SOUND_ACTION_TELEPORT, MARIO_ACTION_SOUND_PLAYED); set_mario_animation(m, m->prevAction == ACT_CROUCHING ? MARIO_ANIM_CROUCHING : MARIO_ANIM_FIRST_PERSON); - + if (m->actionTimer == 0) { queue_rumble_data(30, 70); func_sh_8024C89C(2); @@ -1459,7 +1457,6 @@ s32 act_teleport_fade_in(struct MarioState *m) { return FALSE; } -// act shocked :omega: s32 act_shocked(struct MarioState *m) { play_sound_if_no_flag(m, SOUND_MARIO_WAAAOOOW, MARIO_ACTION_SOUND_PLAYED); play_sound(SOUND_MOVING_SHOCKED, m->marioObj->header.gfx.cameraToObject); @@ -1508,7 +1505,7 @@ s32 act_squished(struct MarioState *m) { m->squishTimer = 0xFF; if (spaceUnderCeil >= 10.1f) { - // mario becomes a pancake + // Mario becomes a pancake squishAmount = spaceUnderCeil / 160.0f; vec3f_set(m->marioObj->header.gfx.scale, 2.0f - squishAmount, squishAmount, 2.0f - squishAmount); @@ -1573,7 +1570,7 @@ s32 act_squished(struct MarioState *m) { } } - // squished for more than 10 seconds, so kill mario + // squished for more than 10 seconds, so kill Mario if (m->actionArg++ > 300) { // 0 units of health m->health = 0x00FF; @@ -1809,7 +1806,7 @@ static s32 act_intro_cutscene(struct MarioState *m) { return FALSE; } -// jumbo star cutscene: mario lands after grabbing the jumbo star +// jumbo star cutscene: Mario lands after grabbing the jumbo star static void jumbo_star_cutscene_falling(struct MarioState *m) { if (m->actionState == 0) { m->input |= INPUT_A_DOWN; @@ -1836,7 +1833,7 @@ static void jumbo_star_cutscene_falling(struct MarioState *m) { } } -// jumbo star cutscene: mario takes off +// jumbo star cutscene: Mario takes off static s32 jumbo_star_cutscene_taking_off(struct MarioState *m) { struct Object *marioObj = m->marioObj; s32 animFrame; @@ -1889,7 +1886,7 @@ static s32 jumbo_star_cutscene_taking_off(struct MarioState *m) { return FALSE; } -// jumbo star cutscene: mario flying +// jumbo star cutscene: Mario flying static s32 jumbo_star_cutscene_flying(struct MarioState *m) { Vec3f targetPos; UNUSED struct Object *marioObj = m->marioObj; @@ -1907,7 +1904,7 @@ static s32 jumbo_star_cutscene_flying(struct MarioState *m) { // fall through case 1: if (anim_spline_poll(targetPos)) { - // lol does this twice + // does this twice set_mario_action(m, ACT_FREEFALL, 0); m->actionState++; } else { @@ -1980,8 +1977,8 @@ void generate_yellow_sparkles(s16 x, s16 y, s16 z, f32 radius) { sSparkleGenPhi += 0x6000; } -// not sure what this does, returns the height of the floor, but idk about the -// other stuff (animation related?) +// not sure what this does, returns the height of the floor. +// (animation related?) static f32 end_obj_set_visual_pos(struct Object *o) { struct Surface *surf; Vec3s sp24; @@ -1998,7 +1995,7 @@ static f32 end_obj_set_visual_pos(struct Object *o) { return find_floor(sp20, sp1C, sp18, &surf); } -// make mario fall and soften wing cap gravity +// make Mario fall and soften wing cap gravity static void end_peach_cutscene_mario_falling(struct MarioState *m) { if (m->actionTimer == 1) { m->statusForCamera->cameraEvent = CAM_EVENT_START_ENDING; @@ -2016,7 +2013,7 @@ static void end_peach_cutscene_mario_falling(struct MarioState *m) { } } -// set mario on the ground, wait and spawn the jumbo star outside the castle. +// set Mario on the ground, wait and spawn the jumbo star outside the castle. static void end_peach_cutscene_mario_landing(struct MarioState *m) { set_mario_animation(m, MARIO_ANIM_GENERAL_LAND); stop_and_set_height_to_floor(m); @@ -2055,7 +2052,7 @@ static void end_peach_cutscene_summon_jumbo_star(struct MarioState *m) { #ifdef VERSION_EU #define TIMER_FADE_IN_PEACH 201 #define TIMER_DESCEND_PEACH 280 -#else +#else #define TIMER_FADE_IN_PEACH 276 #define TIMER_DESCEND_PEACH 355 #endif @@ -2113,7 +2110,7 @@ static void end_peach_cutscene_spawn_peach(struct MarioState *m) { #ifdef VERSION_EU #define TIMER_RUN_TO_PEACH 531 -#else +#else #define TIMER_RUN_TO_PEACH 584 #endif @@ -2145,7 +2142,7 @@ static void end_peach_cutscene_descend_peach(struct MarioState *m) { #undef TIMER_RUN_TO_PEACH -// mario runs to peach +// Mario runs to peach static void end_peach_cutscene_run_to_peach(struct MarioState *m) { struct Surface *surf; @@ -2231,7 +2228,7 @@ static void end_peach_cutscene_dialog_1(struct MarioState *m) { #ifdef VERSION_EU #define TIMER_SOMETHING_SPECIAL 150 #define TIMER_PEACH_KISS 260 -#else +#else #define TIMER_SOMETHING_SPECIAL 130 #define TIMER_PEACH_KISS 200 #endif @@ -2521,7 +2518,7 @@ static s32 act_end_peach_cutscene(struct MarioState *m) { #define TIMER_CREDITS_SHOW 51 #define TIMER_CREDITS_PROGRESS 80 #define TIMER_CREDITS_WARP 160 -#else +#else #define TIMER_CREDITS_SHOW 61 #define TIMER_CREDITS_PROGRESS 90 #define TIMER_CREDITS_WARP 200 @@ -2532,7 +2529,7 @@ static s32 act_credits_cutscene(struct MarioState *m) { s32 height; m->statusForCamera->cameraEvent = CAM_EVENT_START_CREDITS; - // checks if mario is underwater (JRB, DDD, SA, etc.) + // checks if Mario is underwater (JRB, DDD, SA, etc.) if (m->pos[1] < m->waterLevel - 100) { if (m->area->camera->mode != CAMERA_MODE_BEHIND_MARIO) { set_camera_mode(m->area->camera, CAMERA_MODE_BEHIND_MARIO, 1); diff --git a/src/game/mario_actions_cutscene.h b/src/game/mario_actions_cutscene.h index 27c0f215..276826cf 100644 --- a/src/game/mario_actions_cutscene.h +++ b/src/game/mario_actions_cutscene.h @@ -1,14 +1,17 @@ -#ifndef _MARIO_ACTIONS_CUTSCENE_H -#define _MARIO_ACTIONS_CUTSCENE_H +#ifndef MARIO_ACTIONS_CUTSCENE_H +#define MARIO_ACTIONS_CUTSCENE_H +#include + +#include "macros.h" #include "types.h" -extern void print_displaying_credits_entry(void); -extern void bhv_end_peach_loop(void); -extern void bhv_end_toad_loop(void); -extern s32 geo_switch_peach_eyes(s32 run, struct GraphNode *node, UNUSED s32 a2); -extern s32 mario_ready_to_speak(void); -extern s32 set_mario_npc_dialog(s32); -extern s32 mario_execute_cutscene_action(struct MarioState *); +void print_displaying_credits_entry(void); +void bhv_end_peach_loop(void); +void bhv_end_toad_loop(void); +s32 geo_switch_peach_eyes(s32 run, struct GraphNode *node, UNUSED s32 a2); +s32 mario_ready_to_speak(void); +s32 set_mario_npc_dialog(s32 actionArg); +s32 mario_execute_cutscene_action(struct MarioState *m); -#endif /* _MARIO_ACTIONS_CUTSCENE_H */ +#endif // MARIO_ACTIONS_CUTSCENE_H diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index 52d44c34..01eb8148 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -1,4 +1,4 @@ -#include +#include #include "sm64.h" #include "mario.h" @@ -261,7 +261,7 @@ s32 update_sliding(struct MarioState *m, f32 stopSpeed) { oldSpeed = sqrtf(m->slideVelX * m->slideVelX + m->slideVelZ * m->slideVelZ); - //! This is attempting to use trig derivatives to rotate mario's speed. + //! This is attempting to use trig derivatives to rotate Mario's speed. // It is slightly off/asymmetric since it uses the new X speed, but the old // Z speed. m->slideVelX += m->slideVelZ * (m->intendedMag / 32.0f) * sideward * 0.05f; @@ -1570,7 +1570,7 @@ s32 act_dive_slide(struct MarioState *m) { play_mario_landing_sound_once(m, SOUND_ACTION_TERRAIN_BODY_HIT_GROUND); //! If the dive slide ends on the same frame that we pick up on object, - // mario will not be in the dive slide action for the call to + // Mario will not be in the dive slide action for the call to // mario_check_object_grab, and so will end up in the regular picking action, // rather than the picking up after dive action. @@ -1759,8 +1759,8 @@ u32 common_landing_action(struct MarioState *m, s16 animation, u32 airAction) { s32 common_landing_cancels(struct MarioState *m, struct LandingAction *landingAction, s32 (*setAPressAction)(struct MarioState *, u32, u32)) { - //! Everything here, incuding floor steepness, is checked before checking - // if mario is actually on the floor. This leads to e.g. remote sliding. + //! Everything here, including floor steepness, is checked before checking + // if Mario is actually on the floor. This leads to e.g. remote sliding. if (m->floor->normal.y < 0.2923717f) { return mario_push_off_steep_floor(m, landingAction->verySteepAction, 0); diff --git a/src/game/mario_actions_moving.h b/src/game/mario_actions_moving.h index e625af35..4ee9b71f 100644 --- a/src/game/mario_actions_moving.h +++ b/src/game/mario_actions_moving.h @@ -1,12 +1,11 @@ -#ifndef _MARIO_ACTIONS_MOVING -#define _MARIO_ACTIONS_MOVING +#ifndef MARIO_ACTIONS_MOVING +#define MARIO_ACTIONS_MOVING +#include -struct MarioState; +#include "types.h" - -void play_step_sound(struct MarioState *m, s16 arg1, s16 arg2); +void play_step_sound(struct MarioState *m, s16 frame1, s16 frame2); s32 mario_execute_moving_action(struct MarioState *m); - -#endif /* _MARIO_ACTIONS_MOVING */ +#endif // MARIO_ACTIONS_MOVING diff --git a/src/game/mario_actions_object.c b/src/game/mario_actions_object.c index d01a6c67..e34192a5 100644 --- a/src/game/mario_actions_object.c +++ b/src/game/mario_actions_object.c @@ -1,4 +1,4 @@ -#include +#include #include "sm64.h" #include "mario_actions_object.h" @@ -217,7 +217,7 @@ s32 act_dive_picking_up(struct MarioState *m) { } //! Hands-free holding. Landing on a slope or being pushed off a ledge while - // landing from a dive grab sets mario's action to a non-holding action + // landing from a dive grab sets Mario's action to a non-holding action // without dropping the object, causing the hands-free holding glitch. if (m->input & INPUT_OFF_FLOOR) { return set_mario_action(m, ACT_FREEFALL, 0); diff --git a/src/game/mario_actions_object.h b/src/game/mario_actions_object.h index 80a17370..d398eabe 100644 --- a/src/game/mario_actions_object.h +++ b/src/game/mario_actions_object.h @@ -1,9 +1,11 @@ -#ifndef _MARIO_ACTIONS_OBJECT_H -#define _MARIO_ACTIONS_OBJECT_H +#ifndef MARIO_ACTIONS_OBJECT_H +#define MARIO_ACTIONS_OBJECT_H -struct MarioState; +#include + +#include "types.h" s32 mario_update_punch_sequence(struct MarioState *m); s32 mario_execute_object_action(struct MarioState *m); -#endif /* _MARIO_ACTIONS_OBJECT_H */ +#endif // MARIO_ACTIONS_OBJECT_H diff --git a/src/game/mario_actions_stationary.c b/src/game/mario_actions_stationary.c index e7ef3583..440610f8 100644 --- a/src/game/mario_actions_stationary.c +++ b/src/game/mario_actions_stationary.c @@ -1,19 +1,21 @@ -#include +#include #include "sm64.h" -#include "engine/math_util.h" -#include "mario.h" -#include "interaction.h" -#include "mario_step.h" -#include "mario_actions_stationary.h" #include "area.h" +#include "audio/data.h" #include "audio/external.h" -#include "memory.h" #include "behavior_data.h" -#include "sound_init.h" -#include "level_update.h" -#include "save_file.h" #include "camera.h" +#include "engine/math_util.h" +#include "interaction.h" +#include "level_update.h" +#include "mario.h" +#include "mario_actions_stationary.h" +#include "mario_step.h" +#include "memory.h" +#include "save_file.h" +#include "sound_init.h" +#include "surface_terrains.h" #include "thread6.h" s32 check_common_idle_cancels(struct MarioState *m) { @@ -152,12 +154,11 @@ s32 act_idle(struct MarioState *m) { // and that he's gone through 10 cycles before sleeping. // actionTimer is used to track how many cycles have passed. if (++m->actionState == 3) { - f32 sp24 = m->pos[1] - find_floor_height_relative_polar(m, -0x8000, 60.0f); - if (sp24 < -24.0f || 24.0f < sp24 || m->floor->flags & 1) { + f32 deltaYOfFloorBehindMario = m->pos[1] - find_floor_height_relative_polar(m, -0x8000, 60.0f); + if (deltaYOfFloorBehindMario < -24.0f || 24.0f < deltaYOfFloorBehindMario || m->floor->flags & SURFACE_FLAG_DYNAMIC) { m->actionState = 0; } else { - // If Mario hasn't turned his head 10 times yet, stay idle instead of going to - // sleep. + // If Mario hasn't turned his head 10 times yet, stay idle instead of going to sleep. m->actionTimer++; if (m->actionTimer < 10) { m->actionState = 0; diff --git a/src/game/mario_actions_stationary.h b/src/game/mario_actions_stationary.h index bb988deb..a4633c7c 100644 --- a/src/game/mario_actions_stationary.h +++ b/src/game/mario_actions_stationary.h @@ -1,53 +1,52 @@ -#ifndef _MARIO_ACTIONS_STATIONARY -#define _MARIO_ACTIONS_STATIONARY +#ifndef MARIO_ACTIONS_STATIONARY +#define MARIO_ACTIONS_STATIONARY + +#include #include "types.h" #define INPUT_UNKNOWN_A41F 0xA41F -extern s32 check_common_idle_cancels(struct MarioState *); -extern s32 check_common_hold_idle_cancels(struct MarioState *); -extern s32 act_idle(struct MarioState *); -extern void play_anim_sound(struct MarioState *, u32, s32, u32); -extern s32 act_start_sleeping(struct MarioState *); -extern s32 act_sleeping(struct MarioState *); -extern s32 act_waking_up(struct MarioState *); -extern s32 act_shivering(struct MarioState *); -extern s32 act_coughing(struct MarioState *); -extern s32 func_802615C4(struct MarioState *); -extern s32 func_802616C4(struct MarioState *); -extern s32 act_standing_against_wall(struct MarioState *); -extern s32 act_in_quicksand(struct MarioState *); -extern s32 act_crouching(struct MarioState *); -extern s32 act_panting(struct MarioState *); -extern s32 func_80261C74(struct MarioState *); -extern void stopping_step(struct MarioState *, s32, u32); -extern s32 act_braking_stop(struct MarioState *); -extern s32 act_butt_slide_stop(struct MarioState *); -extern s32 act_hold_butt_slide_stop(struct MarioState *); -extern s32 act_slide_kick_slide_stop(struct MarioState *); -extern s32 act_start_crouching(struct MarioState *); -extern s32 act_stop_crouching(struct MarioState *); -extern s32 act_start_crawling(struct MarioState *); -extern s32 act_stop_crawling(struct MarioState *); -extern s32 act_shockwave_bounce(struct MarioState *); -extern s32 landing_step(struct MarioState *, s32, u32); -extern s32 check_common_landing_cancels(struct MarioState *, u32); -extern s32 act_jump_land_stop(struct MarioState *); -extern s32 act_double_jump_land_stop(struct MarioState *); -extern s32 act_side_flip_land_stop(struct MarioState *); -extern s32 act_freefall_land_stop(struct MarioState *); -extern s32 act_triple_jump_land_stop(struct MarioState *); -extern s32 act_backflip_land_stop(struct MarioState *); -extern s32 act_lava_boost_land(struct MarioState *); -extern s32 act_long_jump_land_stop(struct MarioState *); -extern s32 act_hold_jump_land_stop(struct MarioState *); -extern s32 act_hold_freefall_land_stop(struct MarioState *); -extern s32 act_air_throw_land(struct MarioState *); -extern s32 act_twirl_land(struct MarioState *); -extern s32 act_ground_pound_land(struct MarioState *); -extern s32 act_first_person(struct MarioState *); -extern s32 check_common_stationary_cancels(struct MarioState *); -extern s32 mario_execute_stationary_action(struct MarioState *); +s32 check_common_idle_cancels(struct MarioState *m); +s32 check_common_hold_idle_cancels(struct MarioState *m); +s32 act_idle(struct MarioState *m); +void play_anim_sound(struct MarioState *m, u32 actionState, s32 animFrame, u32 sound); +s32 act_start_sleeping(struct MarioState *m); +s32 act_sleeping(struct MarioState *m); +s32 act_waking_up(struct MarioState *m); +s32 act_shivering(struct MarioState *m); +s32 act_coughing(struct MarioState *m); +s32 act_standing_against_wall(struct MarioState *m); +s32 act_in_quicksand(struct MarioState *m); +s32 act_crouching(struct MarioState *m); +s32 act_panting(struct MarioState *m); +void stopping_step(struct MarioState *m, s32 animID, u32 action); +s32 act_braking_stop(struct MarioState *m); +s32 act_butt_slide_stop(struct MarioState *m); +s32 act_hold_butt_slide_stop(struct MarioState *m); +s32 act_slide_kick_slide_stop(struct MarioState *m); +s32 act_start_crouching(struct MarioState *m); +s32 act_stop_crouching(struct MarioState *m); +s32 act_start_crawling(struct MarioState *m); +s32 act_stop_crawling(struct MarioState *m); +s32 act_shockwave_bounce(struct MarioState *m); +s32 landing_step(struct MarioState *m, s32 arg1, u32 action); +s32 check_common_landing_cancels(struct MarioState *m, u32 action); +s32 act_jump_land_stop(struct MarioState *m); +s32 act_double_jump_land_stop(struct MarioState *m); +s32 act_side_flip_land_stop(struct MarioState *m); +s32 act_freefall_land_stop(struct MarioState *m); +s32 act_triple_jump_land_stop(struct MarioState *m); +s32 act_backflip_land_stop(struct MarioState *m); +s32 act_lava_boost_land(struct MarioState *m); +s32 act_long_jump_land_stop(struct MarioState *m); +s32 act_hold_jump_land_stop(struct MarioState *m); +s32 act_hold_freefall_land_stop(struct MarioState *m); +s32 act_air_throw_land(struct MarioState *m); +s32 act_twirl_land(struct MarioState *m); +s32 act_ground_pound_land(struct MarioState *m); +s32 act_first_person(struct MarioState *m); +s32 check_common_stationary_cancels(struct MarioState *m); +s32 mario_execute_stationary_action(struct MarioState *m); -#endif /* _MARIO_ACTIONS_STATIONARY */ +#endif // MARIO_ACTIONS_STATIONARY diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c index a2af592b..f03e4a93 100644 --- a/src/game/mario_actions_submerged.c +++ b/src/game/mario_actions_submerged.c @@ -1,4 +1,4 @@ -#include +#include #include "sm64.h" #include "level_update.h" diff --git a/src/game/mario_actions_submerged.h b/src/game/mario_actions_submerged.h index 946a6b01..addef2fc 100644 --- a/src/game/mario_actions_submerged.h +++ b/src/game/mario_actions_submerged.h @@ -1,8 +1,10 @@ -#ifndef _MARIO_ACTIONS_SUBMERGED_H -#define _MARIO_ACTIONS_SUBMERGED_H +#ifndef MARIO_ACTIONS_SUBMERGED_H +#define MARIO_ACTIONS_SUBMERGED_H -struct MarioState; +#include + +#include "types.h" s32 mario_execute_submerged_action(struct MarioState *m); -#endif /* _MARIO_ACTIONS_SUBMERGED_H */ +#endif // MARIO_ACTIONS_SUBMERGED_H diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index 1059edbc..6095b6e5 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -1,28 +1,28 @@ -#include +#include #include "sm64.h" #include "area.h" #include "audio/external.h" -#include "camera.h" -#include "mario_misc.h" #include "behavior_actions.h" #include "behavior_data.h" +#include "camera.h" +#include "dialog_ids.h" #include "engine/behavior_script.h" -#include "game_init.h" #include "engine/graph_node.h" -#include "envfx_snow.h" -#include "level_update.h" #include "engine/math_util.h" +#include "envfx_snow.h" +#include "game_init.h" +#include "goddard/renderer.h" +#include "interaction.h" +#include "level_update.h" +#include "mario_misc.h" #include "memory.h" #include "object_helpers.h" -#include "goddard/renderer.h" +#include "object_list_processor.h" #include "rendering_graph_node.h" #include "save_file.h" -#include "sound_init.h" #include "skybox.h" -#include "interaction.h" -#include "object_list_processor.h" -#include "dialog_ids.h" +#include "sound_init.h" #define TOAD_STAR_1_REQUIREMENT 12 #define TOAD_STAR_2_REQUIREMENT 25 @@ -62,8 +62,8 @@ static s8 gMarioBlinkAnimation[7] = { 1, 2, 1, 0, 1, 2, 1 }; * There are 3 scale animations in groups of 6 frames. * The first animation starts at frame index 3 and goes down, the others start at frame index 5. * The values get divided by 10 before assigning, so e.g. 12 gives a scale factor 1.2. - * All combined, this means e.g. the first animation scales Mario's fist by {2.4, 1.6, 1.2, 1.0} on - * succesive frames. + * All combined, this means e.g. the first animation scales Mario's fist by {2.4, 1.6, 1.2, 1.0} on + * successive frames. */ static s8 gMarioAttackScaleAnimation[3 * 6] = { 10, 12, 16, 24, 10, 10, 10, 14, 20, 30, 10, 10, 10, 16, 20, 26, 26, 20, @@ -73,9 +73,9 @@ struct MarioBodyState gBodyStates[2]; // 2nd is never accessed in practice, most struct GraphNodeObject gMirrorMario; // copy of Mario's geo node for drawing mirror Mario // This whole file is weirdly organized. It has to be the same file due -// to rodata boundries and function aligns, which means the programmer -// treated this like a "misc" file for vaguely mario related things -// (message NPC related things, the mario head geo, and mario geo +// to rodata boundaries and function aligns, which means the programmer +// treated this like a "misc" file for vaguely Mario related things +// (message NPC related things, the Mario head geo, and Mario geo // functions) /** @@ -297,8 +297,7 @@ void bhv_unlock_door_star_loop(void) { } /** - * Generate a display list that sets the correct blend mode and color for - * mirror Mario. + * Generate a display list that sets the correct blend mode and color for mirror Mario. */ static Gfx *make_gfx_mario_alpha(struct GraphNodeGenerated *node, s16 alpha) { Gfx *gfx; diff --git a/src/game/mario_misc.h b/src/game/mario_misc.h index 7b4ed951..25c0caba 100644 --- a/src/game/mario_misc.h +++ b/src/game/mario_misc.h @@ -1,28 +1,31 @@ -#ifndef _MARIO_MISC_H -#define _MARIO_MISC_H +#ifndef MARIO_MISC_H +#define MARIO_MISC_H +#include + +#include "macros.h" #include "types.h" extern struct GraphNodeObject gMirrorMario; extern struct MarioBodyState gBodyStates[2]; -extern Gfx *geo_draw_mario_head_goddard(s32 a, struct GraphNode *b, Mat4 *c); -extern void bhv_toad_message_loop(void); -extern void bhv_toad_message_init(void); -extern void bhv_unlock_door_star_init(void); -extern void bhv_unlock_door_star_loop(void); -extern Gfx *geo_mirror_mario_set_alpha(s32 a, struct GraphNode *b, UNUSED Mat4 *c); -extern Gfx *geo_switch_mario_stand_run(s32 run, struct GraphNode *node, UNUSED Mat4 *c); -extern Gfx *geo_switch_mario_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *c); -extern Gfx *geo_mario_tilt_torso(s32 a, struct GraphNode *b, UNUSED Mat4 *c); -extern Gfx *geo_mario_head_rotation(s32 a, struct GraphNode *b, UNUSED Mat4 *c); -extern Gfx *geo_switch_mario_hand(s32 run, struct GraphNode *node, UNUSED Mat4 *c); -extern Gfx *geo_mario_hand_foot_scaler(s32 a, struct GraphNode *b, UNUSED Mat4 *c); -extern Gfx *geo_switch_mario_cap_effect(s32 run, struct GraphNode *node, UNUSED Mat4 *c); -extern Gfx *geo_switch_mario_cap_on_off(s32 run, struct GraphNode *node, UNUSED Mat4 *c); -extern Gfx *geo_mario_rotate_wing_cap_wings(s32 a, struct GraphNode *b, UNUSED Mat4 *c); -extern Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 *c); -extern Gfx *geo_render_mirror_mario(s32 a, struct GraphNode *b, UNUSED Mat4 *c); -extern Gfx *geo_mirror_mario_backface_culling(s32 a, struct GraphNode *b, UNUSED Mat4 *c); +Gfx *geo_draw_mario_head_goddard(s32 callContext, struct GraphNode *node, Mat4 *c); +void bhv_toad_message_loop(void); +void bhv_toad_message_init(void); +void bhv_unlock_door_star_init(void); +void bhv_unlock_door_star_loop(void); +Gfx *geo_mirror_mario_set_alpha(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_switch_mario_stand_run(s32 callContext, struct GraphNode *node, UNUSED Mat4 *mtx); +Gfx *geo_switch_mario_eyes(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_mario_tilt_torso(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_mario_head_rotation(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_switch_mario_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_mario_hand_foot_scaler(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_switch_mario_cap_effect(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_switch_mario_cap_on_off(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_mario_rotate_wing_cap_wings(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 *mtx); +Gfx *geo_render_mirror_mario(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); +Gfx *geo_mirror_mario_backface_culling(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c); -#endif /* _MARIO_MISC_H */ +#endif // MARIO_MISC_H diff --git a/src/game/mario_step.c b/src/game/mario_step.c index 226f93ed..ba8315ca 100644 --- a/src/game/mario_step.c +++ b/src/game/mario_step.c @@ -358,7 +358,7 @@ u32 check_ledge_grab(struct MarioState *m, struct Surface *wall, Vec3f intendedP displacementX = nextPos[0] - intendedPos[0]; displacementZ = nextPos[2] - intendedPos[2]; - // Only ledge grab if the wall displaced mario in the opposite direction of + // Only ledge grab if the wall displaced Mario in the opposite direction of // his velocity. if (displacementX * m->vel[0] + displacementZ * m->vel[2] > 0.0f) { return 0; @@ -437,7 +437,7 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr } //! When ceilHeight - floorHeight <= 160, the step result says that - // mario landed, but his movement is cancelled and his referenced floor + // Mario landed, but his movement is cancelled and his referenced floor // isn't updated (pedro spots) m->pos[1] = floorHeight; return AIR_STEP_LANDED; diff --git a/src/game/mario_step.h b/src/game/mario_step.h index 3842ca50..c723c048 100644 --- a/src/game/mario_step.h +++ b/src/game/mario_step.h @@ -1,22 +1,36 @@ -#ifndef _MARIO_STEP_H -#define _MARIO_STEP_H +#ifndef MARIO_STEP_H +#define MARIO_STEP_H + +#include #include "types.h" +struct BullyCollisionData { + /*0x00*/ f32 conversionRatio; + /*0x04*/ f32 radius; + /*0x08*/ f32 posX; + /*0x0C*/ f32 posZ; + /*0x10*/ f32 velX; + /*0x14*/ f32 velZ; +}; + extern struct Surface gWaterSurfacePseudoFloor; -extern f32 get_additive_y_vel_for_jumps(void); -extern void stub_mario_step_1(struct MarioState *); -extern void stub_mario_step_2(void); +f32 get_additive_y_vel_for_jumps(void); +void stub_mario_step_1(struct MarioState *); +void stub_mario_step_2(void); -extern void mario_bonk_reflection(struct MarioState *, u32); -extern u32 mario_update_quicksand(struct MarioState *, f32); -extern u32 mario_push_off_steep_floor(struct MarioState *, u32, u32); -extern u32 mario_update_moving_sand(struct MarioState *); -extern u32 mario_update_windy_ground(struct MarioState *); -extern void stop_and_set_height_to_floor(struct MarioState *); -extern s32 stationary_ground_step(struct MarioState *); -extern s32 perform_ground_step(struct MarioState *); -extern s32 perform_air_step(struct MarioState *, u32); +void mario_bonk_reflection(struct MarioState *, u32); +void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollisionData *obj2); +BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ, + f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius); +u32 mario_update_quicksand(struct MarioState *, f32); +u32 mario_push_off_steep_floor(struct MarioState *, u32, u32); +u32 mario_update_moving_sand(struct MarioState *); +u32 mario_update_windy_ground(struct MarioState *); +void stop_and_set_height_to_floor(struct MarioState *); +s32 stationary_ground_step(struct MarioState *); +s32 perform_ground_step(struct MarioState *); +s32 perform_air_step(struct MarioState *, u32); -#endif /* _MARIO_STEP_H */ +#endif // MARIO_STEP_H diff --git a/src/game/memory.c b/src/game/memory.c index 14c332cc..14862cca 100644 --- a/src/game/memory.c +++ b/src/game/memory.c @@ -1,19 +1,17 @@ -#include +#include #include #include "sm64.h" #define INCLUDED_FROM_MEMORY_C +#include "buffers/buffers.h" #include "decompress.h" #include "game_init.h" #include "main.h" -#include "segments.h" #include "memory.h" - -extern u8 _engineSegmentRomStart[]; -extern u8 _engineSegmentRomEnd[]; -extern u8 gDecompressionHeap[]; +#include "segment_symbols.h" +#include "segments.h" // round up to the next multiple #define ALIGN4(val) (((val) + 0x3) & ~0x3) @@ -80,7 +78,7 @@ void *segmented_to_virtual(const void *addr) { return (void *) addr; } -void *virtual_to_segmented(u32 segment, const void *addr) { +void *virtual_to_segmented(UNUSED u32 segment, const void *addr) { return (void *) addr; } @@ -432,7 +430,7 @@ s32 load_patchable_table(struct MarioAnimation *a, u32 index) { u32 size; if (index < sp20->count) { - do { + do { addr = sp20->srcAddr + sp20->anim[index].offset; size = sp20->anim[index].size; } while (0); diff --git a/src/game/memory.h b/src/game/memory.h index 993c505a..50339f88 100644 --- a/src/game/memory.h +++ b/src/game/memory.h @@ -1,6 +1,9 @@ -#ifndef _MEMORY_H_ -#define _MEMORY_H_ +#ifndef MEMORY_H +#define MEMORY_H +#include + +#include "types.h" #define MEMORY_POOL_LEFT 0 #define MEMORY_POOL_RIGHT 1 @@ -58,4 +61,4 @@ void *alloc_display_list(u32 size); void func_80278A78(struct MarioAnimation *a, void *b, struct Animation *target); s32 load_patchable_table(struct MarioAnimation *a, u32 b); -#endif +#endif // MEMORY_H diff --git a/src/game/moving_texture.c b/src/game/moving_texture.c index 29b56c99..4946508b 100644 --- a/src/game/moving_texture.c +++ b/src/game/moving_texture.c @@ -301,8 +301,7 @@ struct MovtexObject gMovtexColored2[] = { * Sets the initial water level in Wet-Dry World based on how high Mario * jumped into the painting. */ -Gfx *geo_wdw_set_initial_water_level(s32 callContext, UNUSED struct GraphNode *node, - UNUSED f32 mtx[4][4]) { +Gfx *geo_wdw_set_initial_water_level(s32 callContext, UNUSED struct GraphNode *node, UNUSED Mat4 mtx) { s32 i; UNUSED u8 unused[] = { 1, 0, 4, 0, 7, 0, 10, 0 }; s16 wdwWaterHeight; @@ -332,7 +331,7 @@ Gfx *geo_wdw_set_initial_water_level(s32 callContext, UNUSED struct GraphNode *n * Textures update when gMovtexCounterPrev != gMovtexCounter. * This ensures water / sand flow stops when the game pauses. */ -Gfx *geo_movtex_pause_control(s32 callContext, UNUSED struct GraphNode *node, UNUSED f32 mtx[4][4]) { +Gfx *geo_movtex_pause_control(s32 callContext, UNUSED struct GraphNode *node, UNUSED Mat4 mtx) { if (callContext != GEO_CONTEXT_RENDER) { gMovtexCounterPrev = gAreaUpdateCounter - 1; gMovtexCounter = gAreaUpdateCounter; @@ -621,7 +620,7 @@ void movtex_change_texture_format(u32 quadCollectionId, Gfx **gfx) { * of the corresponding water region. The node's parameter determines which quad * collection is drawn, see moving_texture.h. */ -Gfx *geo_movtex_draw_water_regions(s32 callContext, struct GraphNode *node, UNUSED f32 mtx[4][4]) { +Gfx *geo_movtex_draw_water_regions(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx) { Gfx *gfxHead = NULL; Gfx *gfx = NULL; Gfx *subList; @@ -831,7 +830,7 @@ Gfx *movtex_gen_list(s16 *movtexVerts, struct MovtexObject *movtexList, s8 attrL /** * Function for a geo node that draws a MovtexObject in the gMovtexNonColored list. */ -Gfx *geo_movtex_draw_nocolor(s32 callContext, struct GraphNode *node, UNUSED f32 mtx[4][4]) { +Gfx *geo_movtex_draw_nocolor(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx) { s32 i; s16 *movtexVerts; struct GraphNodeGenerated *asGenerated; @@ -859,7 +858,7 @@ Gfx *geo_movtex_draw_nocolor(s32 callContext, struct GraphNode *node, UNUSED f32 /** * Function for a geo node that draws a MovtexObject in the gMovtexColored list. */ -Gfx *geo_movtex_draw_colored(s32 callContext, struct GraphNode *node, UNUSED f32 mtx[4][4]) { +Gfx *geo_movtex_draw_colored(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx) { s32 i; s16 *movtexVerts; struct GraphNodeGenerated *asGenerated; @@ -890,7 +889,7 @@ Gfx *geo_movtex_draw_colored(s32 callContext, struct GraphNode *node, UNUSED f32 * instances (like TTC treadmills) so you don't want the animation speed to * increase the more instances there are. */ -Gfx *geo_movtex_draw_colored_no_update(s32 callContext, struct GraphNode *node, UNUSED f32 mtx[4][4]) { +Gfx *geo_movtex_draw_colored_no_update(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx) { s32 i; s16 *movtexVerts; struct GraphNodeGenerated *asGenerated; @@ -917,8 +916,7 @@ Gfx *geo_movtex_draw_colored_no_update(s32 callContext, struct GraphNode *node, * Exact copy of geo_movtex_draw_colored_no_update, but now using the gMovtexColored2 array. * Used for the sand pits in SSL, both outside and inside the pyramid. */ -Gfx *geo_movtex_draw_colored_2_no_update(s32 callContext, struct GraphNode *node, - UNUSED f32 mtx[4][4]) { +Gfx *geo_movtex_draw_colored_2_no_update(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx) { s32 i; s16 *movtexVerts; struct GraphNodeGenerated *asGenerated; @@ -953,7 +951,7 @@ Gfx *geo_movtex_draw_colored_2_no_update(s32 callContext, struct GraphNode *node * model to update multiple times. * Note that the final TTC only has one big treadmill though. */ -Gfx *geo_movtex_update_horizontal(s32 callContext, struct GraphNode *node, UNUSED f32 mtx[4][4]) { +Gfx *geo_movtex_update_horizontal(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx) { void *movtexVerts; if (callContext == GEO_CONTEXT_RENDER) { diff --git a/src/game/moving_texture.h b/src/game/moving_texture.h index 6305d129..9d2e3db1 100644 --- a/src/game/moving_texture.h +++ b/src/game/moving_texture.h @@ -1,6 +1,9 @@ -#ifndef _MOVING_TEXTURE_H -#define _MOVING_TEXTURE_H +#ifndef MOVING_TEXTURE_H +#define MOVING_TEXTURE_H +#include + +#include "macros.h" #include "types.h" #define ROTATE_CLOCKWISE 0 @@ -108,15 +111,14 @@ extern f32 gPaintingMarioYEntry; #define MOVTEX_TREADMILL_BIG (0 | MOVTEX_AREA_TTC) #define MOVTEX_TREADMILL_SMALL (1 | MOVTEX_AREA_TTC) -extern Gfx *geo_wdw_set_initial_water_level(s32 callContext, struct GraphNode *node, f32 mtx[4][4]); -extern Gfx *geo_movtex_pause_control(s32 callContext, struct GraphNode *node, f32 mtx[4][4]); -extern Gfx *geo_movtex_draw_water_regions(s32 callContext, struct GraphNode *node, f32 mtx[4][4]); -extern Gfx *geo_movtex_draw_nocolor(s32 callContext, struct GraphNode *node, f32 mtx[4][4]); -extern Gfx *geo_movtex_draw_colored(s32 callContext, struct GraphNode *node, f32 mtx[4][4]); -extern Gfx *geo_movtex_draw_colored_no_update(s32 callContext, struct GraphNode *node, - f32 mtx[4][4]); -extern Gfx *geo_movtex_draw_colored_2_no_update(s32 callContext, struct GraphNode *node, - f32 mtx[4][4]); -extern Gfx *geo_movtex_update_horizontal(s32 callContext, struct GraphNode *node, f32 mtx[4][4]); +Gfx *geo_wdw_set_initial_water_level(s32 callContext, UNUSED struct GraphNode *node, UNUSED Mat4 mtx); +Gfx *geo_movtex_pause_control(s32 callContext, UNUSED struct GraphNode *node, UNUSED Mat4 mtx); +Gfx *geo_movtex_draw_water_regions(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); +Gfx *geo_movtex_draw_nocolor(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); +Gfx *geo_movtex_draw_colored(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); +Gfx *geo_movtex_draw_colored_no_update(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); +Gfx *geo_movtex_draw_colored_2_no_update(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); +Gfx *geo_movtex_update_horizontal(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); +Gfx *geo_movtex_draw_colored_no_update(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); -#endif /* _MOVING_TEXTURE_H */ +#endif // MOVING_TEXTURE_H diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c index 68cebe5d..58339bd1 100644 --- a/src/game/obj_behaviors.c +++ b/src/game/obj_behaviors.c @@ -1,33 +1,35 @@ -#include +#include #include "sm64.h" -#include "obj_behaviors.h" -#include "rendering_graph_node.h" -#include "memory.h" -#include "engine/behavior_script.h" -#include "engine/surface_collision.h" -#include "engine/math_util.h" -#include "object_helpers.h" -#include "behavior_data.h" -#include "mario.h" -#include "game_init.h" -#include "camera.h" -#include "mario_actions_cutscene.h" -#include "object_list_processor.h" -#include "save_file.h" #include "area.h" -#include "mario_misc.h" -#include "level_update.h" #include "audio/external.h" #include "behavior_actions.h" -#include "spawn_object.h" -#include "spawn_sound.h" +#include "behavior_data.h" +#include "camera.h" +#include "course_table.h" +#include "dialog_ids.h" +#include "engine/behavior_script.h" +#include "engine/math_util.h" +#include "engine/surface_collision.h" #include "envfx_bubbles.h" +#include "game_init.h" #include "ingame_menu.h" #include "interaction.h" #include "level_table.h" -#include "dialog_ids.h" -#include "course_table.h" +#include "level_update.h" +#include "levels/bob/header.h" +#include "levels/ttm/header.h" +#include "mario.h" +#include "mario_actions_cutscene.h" +#include "mario_misc.h" +#include "memory.h" +#include "obj_behaviors.h" +#include "object_helpers.h" +#include "object_list_processor.h" +#include "rendering_graph_node.h" +#include "save_file.h" +#include "spawn_object.h" +#include "spawn_sound.h" /** * @file obj_behaviors.c @@ -642,7 +644,7 @@ s32 obj_flicker_and_disappear(struct Object *obj, s16 lifeSpan) { obj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; } } else { - obj->activeFlags = 0; + obj->activeFlags = ACTIVE_FLAG_DEACTIVATED; return TRUE; } @@ -734,7 +736,7 @@ s32 obj_lava_death(void) { struct Object *deathSmoke; if (o->oTimer >= 31) { - o->activeFlags = 0; + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; return TRUE; } else { // Sinking effect @@ -774,8 +776,7 @@ s8 sDebugSequenceTracker = 0; s8 sDebugTimer = 0; /** - * Unused presumably debug function that tracks for a sequence of inputs, - * perhaps for the Konami code sequence of inputs. + * Unused presumably debug function that tracks for a sequence of inputs. */ s32 UNUSED debug_sequence_tracker(s16 debugInputSequence[]) { // If end of sequence reached, return true. diff --git a/src/game/obj_behaviors.h b/src/game/obj_behaviors.h index a78ee2e1..02a0567f 100644 --- a/src/game/obj_behaviors.h +++ b/src/game/obj_behaviors.h @@ -1,16 +1,13 @@ -#ifndef _OBJ_BEHAVIORS_H -#define _OBJ_BEHAVIORS_H +#ifndef OBJ_BEHAVIORS_H +#define OBJ_BEHAVIORS_H + +#include -#include "types.h" -#include "object_helpers.h" #include "engine/surface_collision.h" - -extern u8 bob_seg7_metal_ball_path0[]; -extern u8 ttm_seg7_trajectory_070170A0[]; -extern u8 bob_seg7_metal_ball_path1[]; +#include "macros.h" +#include "types.h" void set_yoshi_as_not_dead(void); - s32 coin_step(s16 *collisionFlagsPtr); void moving_coin_flicker(void); void coin_collected(void); @@ -43,7 +40,7 @@ void bhv_bobomb_loop(void); void bhv_bobomb_fuse_smoke_init(void); void bhv_bobomb_buddy_init(void); void bobomb_buddy_act_idle(void); -void bobomb_buddy_cannon_dialog(s16 arg0, s16 arg1); +void bobomb_buddy_cannon_dialog(s16 dialogFirstText, s16 dialogSecondText); void bobomb_buddy_act_talk(void); void bobomb_buddy_act_turn_to_talk(void); void bobomb_buddy_actions(void); @@ -53,7 +50,6 @@ void cannon_door_act_opening(void); void bhv_cannon_closed_loop(void); void bhv_whirlpool_init(void); void whirlpool_set_hitbox(void); -void WhirlpoolOrientGraph(void); void bhv_whirlpool_loop(void); void bhv_jet_stream_loop(void); void bhv_homing_amp_init(void); @@ -70,11 +66,11 @@ void bhv_butterfly_loop(void); void bhv_hoot_init(void); f32 hoot_find_next_floor(struct FloorGeometry **arg0, f32 arg1); void hoot_floor_bounce(void); -void hoot_free_step(s16 arg0, s32 arg1); +void hoot_free_step(s16 fastOscY, s32 speed); void hoot_player_set_yaw(void); -void hoot_carry_step(s32 arg0, UNUSED f32 arg1, UNUSED f32 arg2); -void hoot_surface_collision(f32 arg0, UNUSED f32 arg1, f32 arg2); -void hoot_act_ascent(f32 arg0, f32 arg1); +void hoot_carry_step(s32 speed, UNUSED f32 xPrev, UNUSED f32 zPrev); +void hoot_surface_collision(f32 xPrev, UNUSED f32 yPrev, f32 zPrev); +void hoot_act_ascent(f32 xPrev, f32 zPrev); void hoot_action_loop(void); void hoot_turn_to_home(void); void hoot_awake_loop(void); @@ -98,7 +94,7 @@ void bully_check_mario_collision(void); void bully_act_chase_mario(void); void bully_act_knockback(void); void bully_act_back_up(void); -void bully_backup_check(s16 arg0); +void bully_backup_check(s16 collisionFlags); void bully_play_stomping_sound(void); void bully_step(void); void bully_spawn_coin(void); @@ -164,6 +160,6 @@ void bhv_free_bowling_ball_roll_loop(void); /* likely unused */ void bhv_free_bowling_ball_loop(void); /* likely unused */ void bhv_rr_cruiser_wing_init(void); void bhv_rr_cruiser_wing_loop(void); -extern void spawn_default_star(f32, f32, f32); +void spawn_default_star(f32 sp20, f32 sp24, f32 sp28); -#endif /* _OBJ_BEHAVIORS_H */ +#endif // OBJ_BEHAVIORS_H diff --git a/src/game/obj_behaviors_2.c b/src/game/obj_behaviors_2.c index eb52683c..28461d5d 100644 --- a/src/game/obj_behaviors_2.c +++ b/src/game/obj_behaviors_2.c @@ -1,109 +1,49 @@ -#include +#include #include "sm64.h" -#include "behavior_actions.h" -#include "engine/behavior_script.h" -#include "camera.h" -#include "game_init.h" -#include "engine/math_util.h" -#include "object_helpers.h" -#include "mario_actions_cutscene.h" -#include "behavior_data.h" -#include "mario.h" -#include "engine/surface_collision.h" -#include "obj_behaviors_2.h" +#include "actors/common0.h" +#include "actors/group11.h" +#include "actors/group17.h" #include "audio/external.h" -#include "seq_ids.h" +#include "behavior_actions.h" +#include "behavior_data.h" +#include "camera.h" #include "dialog_ids.h" +#include "engine/behavior_script.h" +#include "engine/math_util.h" +#include "engine/surface_collision.h" +#include "engine/surface_load.h" +#include "game_init.h" +#include "geo_misc.h" +#include "interaction.h" +#include "level_table.h" #include "level_update.h" +#include "levels/bitdw/header.h" +#include "levels/bitfs/header.h" +#include "levels/bits/header.h" +#include "levels/bob/header.h" +#include "levels/ccm/header.h" +#include "levels/hmc/header.h" +#include "levels/jrb/header.h" +#include "levels/lll/header.h" +#include "levels/rr/header.h" +#include "levels/ssl/header.h" +#include "levels/thi/header.h" +#include "levels/ttc/header.h" +#include "levels/vcutm/header.h" +#include "mario.h" +#include "mario_actions_cutscene.h" #include "memory.h" +#include "obj_behaviors.h" +#include "obj_behaviors_2.h" +#include "object_constants.h" +#include "object_helpers.h" +#include "object_list_processor.h" #include "platform_displacement.h" #include "rendering_graph_node.h" -#include "engine/surface_load.h" -#include "obj_behaviors.h" -#include "object_constants.h" -#include "interaction.h" -#include "object_list_processor.h" -#include "spawn_sound.h" -#include "geo_misc.h" #include "save_file.h" -#include "level_table.h" - -extern struct Animation *wiggler_seg5_anims_0500C874[]; -extern struct Animation *spiny_egg_seg5_anims_050157E4[]; -extern struct ObjectNode *gObjectLists; -extern u8 jrb_seg7_trajectory_unagi_1[]; -extern u8 jrb_seg7_trajectory_unagi_2[]; -extern u8 dorrie_seg6_collision_0600FBB8[]; -extern u8 dorrie_seg6_collision_0600F644[]; -extern u8 ssl_seg7_collision_070284B0[]; -extern u8 ssl_seg7_collision_07028274[]; -extern u8 ssl_seg7_collision_07028370[]; -extern u8 ssl_seg7_collision_070282F8[]; -extern u8 ccm_seg7_trajectory_penguin_race[]; -extern u8 bob_seg7_trajectory_koopa[]; -extern u8 thi_seg7_trajectory_koopa[]; -extern u8 rr_seg7_collision_07029038[]; -extern u8 ccm_seg7_collision_070163F8[]; -extern u8 checkerboard_platform_seg8_collision_0800D710[]; -extern u8 bitfs_seg7_collision_070157E0[]; -extern u8 rr_seg7_trajectory_0702EC3C[]; -extern u8 rr_seg7_trajectory_0702ECC0[]; -extern u8 ccm_seg7_trajectory_0701669C[]; -extern u8 bitfs_seg7_trajectory_070159AC[]; -extern u8 hmc_seg7_trajectory_0702B86C[]; -extern u8 lll_seg7_trajectory_0702856C[]; -extern u8 lll_seg7_trajectory_07028660[]; -extern u8 rr_seg7_trajectory_0702ED9C[]; -extern u8 rr_seg7_trajectory_0702EEE0[]; -extern u8 bitdw_seg7_collision_0700F70C[]; -extern u8 bits_seg7_collision_0701ADD8[]; -extern u8 bits_seg7_collision_0701AE5C[]; -extern u8 bob_seg7_collision_bridge[]; -extern u8 bitfs_seg7_collision_07015928[]; -extern u8 rr_seg7_collision_07029750[]; -extern u8 rr_seg7_collision_07029858[]; -extern u8 vcutm_seg7_collision_0700AC44[]; -extern u8 bits_seg7_collision_0701ACAC[]; -extern u8 bits_seg7_collision_0701AC28[]; -extern u8 bitdw_seg7_collision_0700F7F0[]; -extern u8 bitdw_seg7_collision_0700F898[]; -extern u8 ttc_seg7_collision_07014F70[]; -extern u8 ttc_seg7_collision_07015008[]; -extern u8 ttc_seg7_collision_070152B4[]; -extern u8 ttc_seg7_collision_070153E0[]; -extern u8 ttc_seg7_collision_07015584[]; -extern u8 ttc_seg7_collision_07015650[]; -extern u8 ttc_seg7_collision_07015754[]; -extern u8 ttc_seg7_collision_070157D8[]; -extern u8 bits_seg7_collision_0701A9A0[]; -extern u8 bits_seg7_collision_0701AA0C[]; -extern u8 bitfs_seg7_collision_07015714[]; -extern u8 bitfs_seg7_collision_07015768[]; -extern u8 rr_seg7_collision_070295F8[]; -extern u8 rr_seg7_collision_0702967C[]; -extern u8 bitdw_seg7_collision_0700F688[]; -extern u8 bits_seg7_collision_0701AA84[]; -extern u8 rr_seg7_collision_07029508[]; -extern u8 bits_seg7_collision_0701B734[]; -extern u8 bits_seg7_collision_0701B59C[]; -extern u8 bits_seg7_collision_0701B404[]; -extern u8 bits_seg7_collision_0701B26C[]; -extern u8 bits_seg7_collision_0701B0D4[]; -extern u8 bitdw_seg7_collision_0700FD9C[]; -extern u8 bitdw_seg7_collision_0700FC7C[]; -extern u8 bitdw_seg7_collision_0700FB5C[]; -extern u8 bitdw_seg7_collision_0700FA3C[]; -extern u8 bitdw_seg7_collision_0700F91C[]; -extern u8 rr_seg7_collision_0702A6B4[]; -extern u8 rr_seg7_collision_0702A32C[]; -extern u8 rr_seg7_collision_07029FA4[]; -extern u8 rr_seg7_collision_07029C1C[]; -extern u8 rr_seg7_collision_07029924[]; -extern u8 bits_seg7_collision_0701AD54[]; -extern u8 bitfs_seg7_collision_070157E0[]; -extern u8 bitfs_seg7_collision_07015124[]; -extern struct Animation *spiny_seg5_anims_05016EAC[]; +#include "seq_ids.h" +#include "spawn_sound.h" #define POS_OP_SAVE_POSITION 0 #define POS_OP_COMPUTE_VELOCITY 1 @@ -111,6 +51,19 @@ extern struct Animation *spiny_seg5_anims_05016EAC[]; #define o gCurrentObject +/* BSS (declared to force order) */ +extern s32 sNumActiveFirePiranhaPlants; +extern s32 sNumKilledFirePiranhaPlants; +extern f32 sObjSavedPosX; +extern f32 sObjSavedPosY; +extern f32 sObjSavedPosZ; +extern struct Object *sMontyMoleHoleList; +extern s32 sMontyMoleKillStreak; +extern f32 sMontyMoleLastKilledPosX; +extern f32 sMontyMoleLastKilledPosY; +extern f32 sMontyMoleLastKilledPosZ; +extern struct Object *sMasterTreadmill; + /** * The treadmill that plays sounds and controls the others on random setting. */ @@ -121,7 +74,6 @@ f32 sObjSavedPosX; f32 sObjSavedPosY; f32 sObjSavedPosZ; -void shelled_koopa_attack_handler(s32 attackType); void wiggler_jumped_on_attack_handler(void); void huge_goomba_weakly_attacked(void); @@ -139,9 +91,9 @@ static s16 obj_get_pitch_from_vel(void) { /** * Show dialog proposing a race. - * If the player accepts the race, then leave time stop enabled and mario in the + * If the player accepts the race, then leave time stop enabled and Mario in the * text action so that the racing object can wait before starting the race. - * If the player declines the race, then disable time stop and allow mario to + * If the player declines the race, then disable time stop and allow Mario to * move again. */ static s32 obj_update_race_proposition_dialog(s16 dialogID) { @@ -911,13 +863,13 @@ static s32 obj_move_for_one_second(s32 endAction) { * oDistanceToMario the same. * * The point of this function is to avoid having to write extra code to get - * the object to return to home. When mario is far away and the object is far - * from home, it could theoretically re-use the "approach mario" logic to approach + * the object to return to home. When Mario is far away and the object is far + * from home, it could theoretically re-use the "approach Mario" logic to approach * its home instead. * However, most objects that use this function handle the far-from-home case * separately anyway. * This function causes seemingly erroneous behavior in some objects that try to - * attack mario (e.g. fly guy shooting fire or lunging), especially when combined + * attack Mario (e.g. fly guy shooting fire or lunging), especially when combined * with partial updates. */ static void treat_far_home_as_mario(f32 threshold) { diff --git a/src/game/obj_behaviors_2.h b/src/game/obj_behaviors_2.h index d0069c75..74c97b2c 100644 --- a/src/game/obj_behaviors_2.h +++ b/src/game/obj_behaviors_2.h @@ -1,5 +1,7 @@ -#ifndef _OBJ_BEHAVIORS_2_H -#define _OBJ_BEHAVIORS_2_H +#ifndef OBJ_BEHAVIORS_2_H +#define OBJ_BEHAVIORS_2_H + +#include #include "types.h" @@ -13,21 +15,9 @@ #define ATTACK_HANDLER_SPECIAL_HUGE_GOOMBA_WEAKLY_ATTACKED 7 #define ATTACK_HANDLER_SQUISHED_WITH_BLUE_COIN 8 -/* BSS (declared to force order) */ -extern s32 sNumActiveFirePiranhaPlants; -extern s32 sNumKilledFirePiranhaPlants; -extern f32 sObjSavedPosX; -extern f32 sObjSavedPosY; -extern f32 sObjSavedPosZ; -extern struct Object *sMontyMoleHoleList; -extern s32 sMontyMoleKillStreak; -extern f32 sMontyMoleLastKilledPosX; -extern f32 sMontyMoleLastKilledPosY; -extern f32 sMontyMoleLastKilledPosZ; -extern struct Object *sMasterTreadmill; +void shelled_koopa_attack_handler(s32 attackType); +void obj_spit_fire(s16 relativePosX, s16 relativePosY, s16 relativePosZ, f32 scale, s32 model, + f32 startSpeed, f32 endSpeed, s16 movePitch); +void obj_set_speed_to_zero(void); -extern void shelled_koopa_attack_handler(s32); -extern void obj_spit_fire(s16, s16, s16, f32, s32, f32, f32, s16); -extern void obj_set_speed_to_zero(void); - -#endif /* _OBJ_BEHAVIORS_2_H */ +#endif // OBJ_BEHAVIORS_2_H diff --git a/src/game/object_collision.c b/src/game/object_collision.c index 5c83526a..71f3268b 100644 --- a/src/game/object_collision.c +++ b/src/game/object_collision.c @@ -1,11 +1,11 @@ -#include +#include #include "sm64.h" -#include "mario.h" #include "debug.h" -#include "spawn_object.h" -#include "object_list_processor.h" #include "interaction.h" +#include "mario.h" +#include "object_list_processor.h" +#include "spawn_object.h" struct Object *debug_print_obj_collision(struct Object *a) { struct Object *sp24; diff --git a/src/game/object_collision.h b/src/game/object_collision.h index 0ecacab1..3357d197 100644 --- a/src/game/object_collision.h +++ b/src/game/object_collision.h @@ -1,16 +1,6 @@ -#ifndef _OBJECT_COLLISION_H -#define _OBJECT_COLLISION_H +#ifndef OBJECT_COLLISION_H +#define OBJECT_COLLISION_H -#include "types.h" +void detect_object_collisions(void); -// extern ? debug_print_obj_collision(?); -// extern ? detect_object_hitbox_overlap(?); -// extern ? detect_object_hurtbox_overlap(?); -// extern ? clear_object_collision(?); -// extern ? check_collision_in_list(?); -// extern ? check_player_object_collision(?); -// extern ? check_pushable_object_collision(?); -// extern ? check_destructive_object_collision(?); -extern void detect_object_collisions(void); - -#endif /* _OBJECT_COLLISION_H */ +#endif // OBJECT_COLLISION_H diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index e05f7743..cd27f089 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -1,56 +1,45 @@ -#include +#include #include "sm64.h" +#include "area.h" +#include "behavior_actions.h" #include "behavior_data.h" -#include "engine/behavior_script.h" #include "camera.h" #include "debug.h" +#include "dialog_ids.h" +#include "engine/behavior_script.h" +#include "engine/geo_layout.h" +#include "engine/math_util.h" +#include "engine/surface_collision.h" +#include "game_init.h" #include "helper_macros.h" +#include "ingame_menu.h" +#include "interaction.h" +#include "level_table.h" +#include "level_update.h" #include "mario.h" #include "mario_actions_cutscene.h" -#include "engine/math_util.h" #include "memory.h" -#include "level_update.h" +#include "obj_behaviors.h" +#include "object_helpers.h" #include "object_list_processor.h" #include "rendering_graph_node.h" #include "spawn_object.h" #include "spawn_sound.h" -#include "engine/surface_collision.h" -#include "area.h" -#include "engine/geo_layout.h" -#include "ingame_menu.h" -#include "game_init.h" -#include "obj_behaviors.h" -#include "interaction.h" -#include "object_list_processor.h" -#include "level_table.h" -#include "dialog_ids.h" - -#include "object_helpers.h" s8 D_8032F0A0[] = { 0xF8, 0x08, 0xFC, 0x04 }; s16 D_8032F0A4[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; static s8 sLevelsWithRooms[] = { LEVEL_BBH, LEVEL_CASTLE, LEVEL_HMC, -1 }; -// These can be static: -extern void create_transformation_from_matrices(Mat4, Mat4, Mat4); -extern void obj_set_gfx_pos_from_pos(struct Object *); -extern void obj_translate_local(struct Object *, s16, s16); -extern void obj_copy_pos(struct Object *, struct Object *); -extern void obj_copy_angle(struct Object *, struct Object *); -extern struct Object *cur_obj_find_nearest_object_with_behavior(const BehaviorScript *, f32 *); -extern void cur_obj_move_y(f32, f32, f32); static s32 clear_move_flag(u32 *, s32); -extern void spawn_mist_particles_variable(s32, s32, f32); -extern void spawn_triangle_break_particles(s32, s32, f32, s32); #define o gCurrentObject -Gfx *geo_update_projectile_pos_from_parent(s32 run, UNUSED struct GraphNode *node, f32 mtx[4][4]) { +Gfx *geo_update_projectile_pos_from_parent(s32 callContext, UNUSED struct GraphNode *node, Mat4 mtx) { Mat4 sp20; struct Object *sp1C; - if (run == TRUE) { + if (callContext == GEO_CONTEXT_RENDER) { sp1C = (struct Object *) gCurGraphNodeObject; // TODO: change global type to Object pointer if (sp1C->prevObj) { create_transformation_from_matrices(sp20, mtx, gCurGraphNodeCamera->matrixPtr); @@ -61,93 +50,98 @@ Gfx *geo_update_projectile_pos_from_parent(s32 run, UNUSED struct GraphNode *nod return NULL; } -Gfx *geo_update_layer_transparency(s32 run, struct GraphNode *node, UNUSED void *context) { - Gfx *sp3C, *sp38; - struct Object *sp34; - struct GraphNodeGenerated *sp30; +Gfx *geo_update_layer_transparency(s32 callContext, struct GraphNode *node, UNUSED void *context) { + Gfx *dlStart, *dlHead; + struct Object *objectGraphNode; + struct GraphNodeGenerated *currentGraphNode; UNUSED struct GraphNodeGenerated *sp2C; - s32 sp28; + s32 objectOpacity; - sp3C = NULL; + dlStart = NULL; - if (run == TRUE) { - sp34 = (struct Object *) gCurGraphNodeObject; // TODO: change this to object pointer? - sp30 = (struct GraphNodeGenerated *) node; + if (callContext == GEO_CONTEXT_RENDER) { + objectGraphNode = (struct Object *) gCurGraphNodeObject; // TODO: change this to object pointer? + currentGraphNode = (struct GraphNodeGenerated *) node; sp2C = (struct GraphNodeGenerated *) node; if (gCurGraphNodeHeldObject) { - sp34 = gCurGraphNodeHeldObject->objNode; + objectGraphNode = gCurGraphNodeHeldObject->objNode; } - sp28 = sp34->oOpacity; - sp3C = alloc_display_list(sizeof(Gfx) * 3); + objectOpacity = objectGraphNode->oOpacity; + dlStart = alloc_display_list(sizeof(Gfx) * 3); - sp38 = sp3C; + dlHead = dlStart; - if (sp28 == 0xFF) { - if (sp30->parameter == 20) { - sp30->fnNode.node.flags = 0x600 | (sp30->fnNode.node.flags & 0xFF); + if (objectOpacity == 0xFF) { + if (currentGraphNode->parameter == 20) { + currentGraphNode->fnNode.node.flags = + 0x600 | (currentGraphNode->fnNode.node.flags & 0xFF); } else { - sp30->fnNode.node.flags = 0x100 | (sp30->fnNode.node.flags & 0xFF); + currentGraphNode->fnNode.node.flags = + 0x100 | (currentGraphNode->fnNode.node.flags & 0xFF); } - sp34->oAnimState = 0; + objectGraphNode->oAnimState = 0; } else { - if (sp30->parameter == 20) { - sp30->fnNode.node.flags = 0x600 | (sp30->fnNode.node.flags & 0xFF); + if (currentGraphNode->parameter == 20) { + currentGraphNode->fnNode.node.flags = + 0x600 | (currentGraphNode->fnNode.node.flags & 0xFF); } else { - sp30->fnNode.node.flags = 0x500 | (sp30->fnNode.node.flags & 0xFF); + currentGraphNode->fnNode.node.flags = + 0x500 | (currentGraphNode->fnNode.node.flags & 0xFF); } - sp34->oAnimState = 1; + objectGraphNode->oAnimState = 1; #ifdef VERSION_JP - if (sp30->parameter == 10) { + if (currentGraphNode->parameter == 10) { if (gDebugInfo[DEBUG_PAGE_ENEMYINFO][3]) { - gDPSetAlphaCompare(sp38++, G_AC_DITHER); + gDPSetAlphaCompare(dlHead++, G_AC_DITHER); } } else { - if (sp34->activeFlags & ACTIVE_FLAG_UNK7) { - gDPSetAlphaCompare(sp38++, G_AC_DITHER); + if (objectGraphNode->activeFlags & ACTIVE_FLAG_DITHERED_ALPHA) { + gDPSetAlphaCompare(dlHead++, G_AC_DITHER); } } #else // gDebugInfo accesses were removed in all non-JP versions. - if (sp28 == 0 && segmented_to_virtual(bhvBowser) == sp34->behavior) { - sp34->oAnimState = 2; + if (objectOpacity == 0 && segmented_to_virtual(bhvBowser) == objectGraphNode->behavior) { + objectGraphNode->oAnimState = 2; } // the debug info check was removed in US. so we need to // perform the only necessary check instead of the debuginfo // one. - if (sp30->parameter != 10) { - if (sp34->activeFlags & ACTIVE_FLAG_UNK7) { - gDPSetAlphaCompare(sp38++, G_AC_DITHER); + if (currentGraphNode->parameter != 10) { + if (objectGraphNode->activeFlags & ACTIVE_FLAG_DITHERED_ALPHA) { + gDPSetAlphaCompare(dlHead++, G_AC_DITHER); } } #endif } - gDPSetEnvColor(sp38++, 255, 255, 255, sp28); - gSPEndDisplayList(sp38); + gDPSetEnvColor(dlHead++, 255, 255, 255, objectOpacity); + gSPEndDisplayList(dlHead); } - return sp3C; + return dlStart; } /** - * @bug Every geo function declares the 3 parameters of run, node, and the matrix array. - * This one (see also geo_switch_area) doesn't. When executed, the node function - * executor passes the 3rd argument to a function that doesn't declare it. This is - * undefined behavior, but harmless in practice due to the o32 calling convention. + * @bug Every geo function declares the 3 parameters of callContext, node, and + * the matrix array. This one (see also geo_switch_area) doesn't. When executed, + * the node function executor passes the 3rd argument to a function that doesn't + * declare it. This is undefined behavior, but harmless in practice due to the + * o32 calling convention. */ #ifdef AVOID_UB -Gfx *geo_switch_anim_state(s32 run, struct GraphNode *node, UNUSED void *context) { +Gfx *geo_switch_anim_state(s32 callContext, struct GraphNode *node, UNUSED void *context) { #else -Gfx *geo_switch_anim_state(s32 run, struct GraphNode *node) { +Gfx *geo_switch_anim_state(s32 callContext, struct GraphNode *node) { #endif struct Object *obj; struct GraphNodeSwitchCase *switchCase; - if (run == TRUE) { + if (callContext == GEO_CONTEXT_RENDER) { obj = (struct Object *) gCurGraphNodeObject; // TODO: change global type to Object pointer // move to a local var because GraphNodes are passed in all geo functions. @@ -173,9 +167,9 @@ Gfx *geo_switch_anim_state(s32 run, struct GraphNode *node) { //! @bug Same issue as geo_switch_anim_state. #ifdef AVOID_UB -Gfx *geo_switch_area(s32 run, struct GraphNode *node, UNUSED void *context) { +Gfx *geo_switch_area(s32 callContext, struct GraphNode *node, UNUSED void *context) { #else -Gfx *geo_switch_area(s32 run, struct GraphNode *node) { +Gfx *geo_switch_area(s32 callContext, struct GraphNode *node) { #endif s16 sp26; struct Surface *sp20; @@ -183,7 +177,7 @@ Gfx *geo_switch_area(s32 run, struct GraphNode *node) { (struct Object *) gCurGraphNodeObject; // TODO: change global type to Object pointer struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node; - if (run == TRUE) { + if (callContext == GEO_CONTEXT_RENDER) { if (gMarioObject == NULL) { switchCase->selectedCase = 0; } else { @@ -474,9 +468,8 @@ struct Object *spawn_object_abs_with_rot(struct Object *parent, s16 uselessArg, * The rz argument is never used, and the z offset is used for z-rotation instead. This is most likely * a copy-paste typo by one of the programmers. */ -struct Object *spawn_object_rel_with_rot(struct Object *parent, u32 model, - const BehaviorScript *behavior, s16 xOff, - s16 yOff, s16 zOff, s16 rx, s16 ry, UNUSED s16 rz) { +struct Object *spawn_object_rel_with_rot(struct Object *parent, u32 model, const BehaviorScript *behavior, + s16 xOff, s16 yOff, s16 zOff, s16 rx, s16 ry, UNUSED s16 rz) { struct Object *newObj = spawn_object_at_origin(parent, 0, model, behavior); newObj->oFlags |= OBJ_FLAG_TRANSFORM_RELATIVE_TO_PARENT; obj_set_parent_relative_pos(newObj, xOff, yOff, zOff); @@ -586,9 +579,8 @@ static void obj_build_relative_transform(struct Object *obj) { obj_translate_local(obj, O_POS_INDEX, O_PARENT_RELATIVE_POS_INDEX); } -struct Object *spawn_object_relative(s16 behaviorParam, s16 relativePosX, s16 relativePosY, - s16 relativePosZ, struct Object *parent, s32 model, - const BehaviorScript *behavior) { +struct Object *spawn_object_relative(s16 behaviorParam, s16 relativePosX, s16 relativePosY, s16 relativePosZ, + struct Object *parent, s32 model, const BehaviorScript *behavior) { struct Object *obj = spawn_object_at_origin(parent, 0, model, behavior); obj_copy_pos_and_angle(obj, parent); @@ -748,9 +740,9 @@ void cur_obj_init_animation_with_accel_and_sound(s32 animIndex, f32 accel) { o->oSoundStateID = animIndex; } -void obj_init_animation_with_sound(struct Object *obj, struct Animation **animations, s32 animIndex) { - struct Animation **anims = animations; - obj->oAnimations = animations; +void obj_init_animation_with_sound(struct Object *obj, const struct Animation * const* animations, s32 animIndex) { + struct Animation **anims = (struct Animation **)animations; + obj->oAnimations = (struct Animation **)animations; geo_obj_init_animation(&obj->header.gfx, &anims[animIndex]); obj->oSoundStateID = animIndex; } @@ -866,7 +858,7 @@ struct Object *cur_obj_find_nearest_object_with_behavior(const BehaviorScript *b while (obj != (struct Object *) listHead) { if (obj->behavior == behaviorAddr) { - if (obj->activeFlags != ACTIVE_FLAGS_DEACTIVATED && obj != o) { + if (obj->activeFlags != ACTIVE_FLAG_DEACTIVATED && obj != o) { f32 objDist = dist_between_objects(o, obj); if (objDist < minDist) { closestObj = obj; @@ -934,10 +926,9 @@ struct Object *cur_obj_find_nearby_held_actor(const BehaviorScript *behavior, f3 while ((struct Object *) listHead != obj) { if (obj->behavior == behaviorAddr) { - if (obj->activeFlags != ACTIVE_FLAGS_DEACTIVATED) { - // This includes the dropped and thrown states. By combining - // instant release, this allows us to activate mama penguin - // remotely + if (obj->activeFlags != ACTIVE_FLAG_DEACTIVATED) { + // This includes the dropped and thrown states. By combining instant + // release, this allows us to activate mama penguin remotely if (obj->oHeldState != HELD_FREE) { if (dist_between_objects(o, obj) < maxDist) { foundObj = obj; @@ -1107,7 +1098,7 @@ static void cur_obj_move_after_thrown_or_dropped(f32 forwardVel, f32 velY) { void cur_obj_get_thrown_or_placed(f32 forwardVel, f32 velY, s32 thrownAction) { if (o->behavior == segmented_to_virtual(bhvBowser)) { // Interestingly, when bowser is thrown, he is offset slightly to - // mario's right + // Mario's right cur_obj_set_pos_relative_to_parent(-41.684f, 85.859f, 321.577f); } else { } @@ -1157,7 +1148,7 @@ void obj_mark_for_deletion(struct Object *obj) { // setting it to 0 could potentially enable unexpected behavior. After an // object is marked for deletion, it still updates on that frame (I think), // so this is worth looking into. - obj->activeFlags = ACTIVE_FLAGS_DEACTIVATED; + obj->activeFlags = ACTIVE_FLAG_DEACTIVATED; } void cur_obj_disable(void) { @@ -1668,7 +1659,7 @@ f32 cur_obj_abs_y_dist_to_home(void) { return dist; } -s32 cur_obj_advance_looping_anim() { +s32 cur_obj_advance_looping_anim(void) { s32 spC = o->header.gfx.unk38.animFrame; s32 sp8 = o->header.gfx.unk38.curAnim->unk08; s32 sp4; @@ -1900,14 +1891,14 @@ s16 cur_obj_angle_to_home(void) { return angle; } -void obj_set_gfx_pos_at_obj_pos(struct Object *a0, struct Object *a1) { - a0->header.gfx.pos[0] = a1->oPosX; - a0->header.gfx.pos[1] = a1->oPosY + a1->oGraphYOffset; - a0->header.gfx.pos[2] = a1->oPosZ; +void obj_set_gfx_pos_at_obj_pos(struct Object *obj1, struct Object *obj2) { + obj1->header.gfx.pos[0] = obj2->oPosX; + obj1->header.gfx.pos[1] = obj2->oPosY + obj2->oGraphYOffset; + obj1->header.gfx.pos[2] = obj2->oPosZ; - a0->header.gfx.angle[0] = a1->oMoveAnglePitch & 0xFFFF; - a0->header.gfx.angle[1] = a1->oMoveAngleYaw & 0xFFFF; - a0->header.gfx.angle[2] = a1->oMoveAngleRoll & 0xFFFF; + obj1->header.gfx.angle[0] = obj2->oMoveAnglePitch & 0xFFFF; + obj1->header.gfx.angle[1] = obj2->oMoveAngleYaw & 0xFFFF; + obj1->header.gfx.angle[2] = obj2->oMoveAngleRoll & 0xFFFF; } /** @@ -1973,13 +1964,13 @@ void obj_build_transform_relative_to_parent(struct Object *obj) { cur_obj_scale(1.0f); } -void obj_create_transform_from_self(struct Object *a0) { - a0->oFlags &= ~OBJ_FLAG_TRANSFORM_RELATIVE_TO_PARENT; - a0->oFlags |= OBJ_FLAG_SET_THROW_MATRIX_FROM_TRANSFORM; +void obj_create_transform_from_self(struct Object *obj) { + obj->oFlags &= ~OBJ_FLAG_TRANSFORM_RELATIVE_TO_PARENT; + obj->oFlags |= OBJ_FLAG_SET_THROW_MATRIX_FROM_TRANSFORM; - a0->transform[3][0] = a0->oPosX; - a0->transform[3][1] = a0->oPosY; - a0->transform[3][2] = a0->oPosZ; + obj->transform[3][0] = obj->oPosX; + obj->transform[3][1] = obj->oPosY; + obj->transform[3][2] = obj->oPosZ; } void cur_obj_rotate_move_angle_using_vel(void) { @@ -2224,7 +2215,7 @@ void cur_obj_push_mario_away(f32 radius) { f32 marioDist = sqrtf(sqr(marioRelX) + sqr(marioRelZ)); if (marioDist < radius) { - //! If this function pushes mario out of bounds, it will trigger mario's + //! If this function pushes Mario out of bounds, it will trigger Mario's // oob failsafe gMarioStates[0].pos[0] += (radius - marioDist) / radius * marioRelX; gMarioStates[0].pos[2] += (radius - marioDist) / radius * marioRelZ; @@ -2357,7 +2348,6 @@ static struct Object *spawn_star_with_no_lvl_exit(s32 sp20, s32 sp24) { } // old unused initializer for 2d star spawn behavior. -// speculation: was 2d spawn handler from spaceworld 1995. // uses behavior parameters not used in the current sparkle code. void spawn_base_star_with_no_lvl_exit(void) { spawn_star_with_no_lvl_exit(0, 0); @@ -2515,8 +2505,8 @@ s32 cur_obj_hide_if_mario_far_away_y(f32 distY) { } } -Gfx *geo_offset_klepto_held_object(s32 run, struct GraphNode *node, UNUSED f32 mtx[4][4]) { - if (run == TRUE) { +Gfx *geo_offset_klepto_held_object(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx) { + if (callContext == GEO_CONTEXT_RENDER) { ((struct GraphNodeTranslationRotation *) node->next)->translation[0] = 300; ((struct GraphNodeTranslationRotation *) node->next)->translation[1] = 300; ((struct GraphNodeTranslationRotation *) node->next)->translation[2] = 0; @@ -2525,8 +2515,8 @@ Gfx *geo_offset_klepto_held_object(s32 run, struct GraphNode *node, UNUSED f32 m return NULL; } -s32 geo_offset_klepto_debug(s32 a0, struct GraphNode *a1, UNUSED s32 sp8) { - if (a0 == 1) { +s32 geo_offset_klepto_debug(s32 callContext, struct GraphNode *a1, UNUSED s32 sp8) { + if (callContext == GEO_CONTEXT_RENDER) { ((struct GraphNode_802A45E4 *) a1->next)->unk18 = gDebugInfo[4][0]; ((struct GraphNode_802A45E4 *) a1->next)->unk1A = gDebugInfo[4][1]; ((struct GraphNode_802A45E4 *) a1->next)->unk1C = gDebugInfo[4][2]; @@ -2554,12 +2544,12 @@ void disable_time_stop(void) { gTimeStopState &= ~TIME_STOP_ENABLED; } -void set_time_stop_flags(s32 flag) { - gTimeStopState |= flag; +void set_time_stop_flags(s32 flags) { + gTimeStopState |= flags; } -void clear_time_stop_flags(s32 flag) { - gTimeStopState = gTimeStopState & (flag ^ 0xFFFFFFFF); +void clear_time_stop_flags(s32 flags) { + gTimeStopState = gTimeStopState & (flags ^ 0xFFFFFFFF); } s32 cur_obj_can_mario_activate_textbox(f32 radius, f32 height, UNUSED s32 unused) { @@ -2601,8 +2591,8 @@ s32 cur_obj_update_dialog(s32 actionArg, s32 dialogFlags, s32 dialogID, UNUSED s switch (o->oDialogState) { #ifdef VERSION_JP case DIALOG_UNK1_ENABLE_TIME_STOP: - //! We enable time stop even if mario is not ready to speak. This - // allows us to move during time stop as long as mario never enters + //! We enable time stop even if Mario is not ready to speak. This + // allows us to move during time stop as long as Mario never enters // an action that can be interrupted with text. if (gMarioState->health >= 0x100) { gTimeStopState |= TIME_STOP_ENABLED; @@ -2613,7 +2603,7 @@ s32 cur_obj_update_dialog(s32 actionArg, s32 dialogFlags, s32 dialogID, UNUSED s #else case DIALOG_UNK1_ENABLE_TIME_STOP: // Patched :( - // Wait for mario to be ready to speak, and then enable time stop + // Wait for Mario to be ready to speak, and then enable time stop if (mario_ready_to_speak() || gMarioState->action == ACT_READING_NPC_DIALOG) { gTimeStopState |= TIME_STOP_ENABLED; o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; @@ -2621,7 +2611,7 @@ s32 cur_obj_update_dialog(s32 actionArg, s32 dialogFlags, s32 dialogID, UNUSED s } else { break; } - // Fall through so that mario's action is interrupted immediately + // Fall through so that Mario's action is interrupted immediately // after time is stopped #endif @@ -2678,8 +2668,8 @@ s32 cur_obj_update_dialog_with_cutscene(s32 actionArg, s32 dialogFlags, s32 cuts switch (o->oDialogState) { #ifdef VERSION_JP case DIALOG_UNK2_ENABLE_TIME_STOP: - //! We enable time stop even if mario is not ready to speak. This - // allows us to move during time stop as long as mario never enters + //! We enable time stop even if Mario is not ready to speak. This + // allows us to move during time stop as long as Mario never enters // an action that can be interrupted with text. if (gMarioState->health >= 0x0100) { gTimeStopState |= TIME_STOP_ENABLED; @@ -2690,7 +2680,7 @@ s32 cur_obj_update_dialog_with_cutscene(s32 actionArg, s32 dialogFlags, s32 cuts break; #else case DIALOG_UNK2_ENABLE_TIME_STOP: - // Wait for mario to be ready to speak, and then enable time stop + // Wait for Mario to be ready to speak, and then enable time stop if (mario_ready_to_speak() || gMarioState->action == ACT_READING_NPC_DIALOG) { gTimeStopState |= TIME_STOP_ENABLED; o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; @@ -2699,7 +2689,7 @@ s32 cur_obj_update_dialog_with_cutscene(s32 actionArg, s32 dialogFlags, s32 cuts } else { break; } - // Fall through so that mario's action is interrupted immediately + // Fall through so that Mario's action is interrupted immediately // after time is stopped #endif diff --git a/src/game/object_helpers.h b/src/game/object_helpers.h index 577f8f66..895604fc 100644 --- a/src/game/object_helpers.h +++ b/src/game/object_helpers.h @@ -1,6 +1,9 @@ #ifndef OBJECT_HELPERS_H #define OBJECT_HELPERS_H +#include + +#include "macros.h" #include "types.h" // used for chain chomp and wiggler @@ -64,273 +67,155 @@ struct SpawnParticlesInfo /*0x10*/ f32 sizeRange; }; -// extern ? D_80336610; -extern struct GraphNode **gLoadedGraphNodes; -// extern ? sLevelsWithRooms; -// extern ? sMrIParticleActions; -// extern ? D_8032F124; -// extern ? sMrIActions; -// extern ? D_8032F134; -// extern const char* D_803366B0; -// extern ? sKingBobombActions; -// extern s16 gMarioShotFromCannon; -// extern ? sOpenedCannonActions; -// extern ? D_803366B4; -// extern ? D_803366BC; -// extern ? D_803366C4; -// extern ? sChuckyaActions; -// extern ? D_803366C8; -// extern ? D_8032F260; -// extern ? D_8032F273; -// extern ? D_8032F271; -// extern ? D_8032F270; -// extern ? D_8032F284; -// extern ? D_8032F294; -// extern ? sCoinInsideBooActions; -// extern s16 D_8035FEE4; -// extern ? sGrindelThwompActions; -// extern ? sTumblingBridgeParams; -// extern ? sTumblingBridgeActions; -// extern ? sElevatorActions; -// extern ? D_8032F3CC; -// extern ? D_8032F3E0; -// extern ? D_8032F3F4; -// extern ? D_8032F3FC; -// extern ? sUkikiCageActions; -// extern ? D_8032F420; -// extern ? D_8032F430; -// extern ? D_8032F440; -// extern ? D_8032F450; -// extern ? sHeaveHoActions; -// extern ? D_8032F498; -// extern ? sJumpingBoxActions; -// extern ? D_8032F4B0; -// extern ? D_8035FF10; -// extern ? sBetaBooKeyActions; -// extern ? D_8032F4CC; -// extern ? sBulletBillActions; -// extern ? sBowserTailAnchorActions; -extern void* D_060576FC; -// extern ? D_8032F50C; -// extern ? D_8032F510; -// extern ? sBowserActions; -// extern ? D_8032F5B8; -// extern ? sFallingBowserPlatformActions; -// extern ? D_8032F738; -// extern ? D_8032F728; -// extern ? D_8032F754; -extern s8 gDddPaintingStatus; -// extern ? D_8035FEE8; -// extern ? sCageUkikiPath; -// extern ? sUkikiActions; -// extern ? sUkikiSoundStates; -// extern ? D_803366D8; -// extern ? D_803366E4; -// extern ? D_803366F0; -// extern ? sRotatingCwFireBarsActions; -// extern ? D_8032F8E0; -// extern ? sToxBoxActions; -// extern ? sPiranhaPlantActions; -// extern ? D_8032FB4C; -// extern ? sBowserPuzzlePieceActions; -// extern ? sTuxiesMotherActions; -// extern ? sSmallPenguinActions; -// extern ? D_0301C2B0; -// extern ? D_0600E264; -// extern ? sFishActions; -// extern ? sFishGroupActions; -// extern ? sBirdChirpChirpActions; -// extern ? sCheepCheepActions; -// extern ? D_8032FC30; -// extern ? sExclamationBoxContents; -// extern ? sExclamationBoxActions; -// extern ? D_8032FCD8; -// extern ? D_8032FCE8; -// extern ? D_803366FC; -// extern ? D_8032FCF8; -// extern ? sTweesterActions; -// extern ? sCourtyardBooTripletPositions; -// extern ? sBooActions; -// extern ? D_8032FD14; -// extern ? sBooGivingStarActions; -// extern ? sBooWithCageActions; -// extern ? D_8032FD74; -// extern ? sWhompActions; -// extern ? D_8032FDAC; -// extern ? D_8032FDF4; -// extern ? D_8032FE3C; -// extern ? D_8032FE4C; -// extern ? D_80336704; -// extern ? D_8033670C; - -extern Gfx *geo_update_projectile_pos_from_parent(s32 run, UNUSED struct GraphNode *node, f32 mtx[4][4]); -extern Gfx *geo_update_layer_transparency(s32 run, struct GraphNode *node, UNUSED void *context); +Gfx *geo_update_projectile_pos_from_parent(s32 callContext, UNUSED struct GraphNode *node, Mat4 mtx); +Gfx *geo_update_layer_transparency(s32 callContext, struct GraphNode *node, UNUSED void *context); #ifdef AVOID_UB -extern Gfx *geo_switch_anim_state(s32 run, struct GraphNode *node, void *context); -extern Gfx *geo_switch_area(s32 run, struct GraphNode *node, void *context); +Gfx *geo_switch_anim_state(s32 callContext, struct GraphNode *node, UNUSED void *context); +Gfx *geo_switch_area(s32 callContext, struct GraphNode *node, UNUSED void *context); #else -extern Gfx *geo_switch_anim_state(s32 run, struct GraphNode *node); -extern Gfx *geo_switch_area(s32 run, struct GraphNode *node); +Gfx *geo_switch_anim_state(s32 callContext, struct GraphNode *node); +Gfx *geo_switch_area(s32 callContext, struct GraphNode *node); #endif -extern void obj_update_pos_from_parent_transformation(Mat4, struct Object *); -void obj_apply_scale_to_matrix(struct Object *, Mat4, Mat4); -extern void create_transformation_from_matrices(Mat4,Mat4,Mat4); -void obj_set_held_state(struct Object *, const BehaviorScript *); -extern f32 lateral_dist_between_objects(struct Object *, struct Object *); -extern f32 dist_between_objects(struct Object *, struct Object *); -extern void cur_obj_forward_vel_approach_upward(f32,f32); -extern s32 approach_f32_signed(f32*,f32,f32); -extern f32 approach_f32_symmetric(f32,f32,f32); -extern s16 approach_s16_symmetric(s16 arg0, s16 arg1, s16 arg2); -extern s32 cur_obj_rotate_yaw_toward(s16,s16); -extern s16 obj_angle_to_object(struct Object *, struct Object *); -extern s16 obj_turn_toward_object(struct Object *, struct Object *, s16, s16); -extern void obj_set_parent_relative_pos(struct Object*,s16,s16,s16); -extern void obj_set_pos(struct Object*,s16,s16,s16); -extern void obj_set_angle(struct Object*,s16,s16,s16); -extern struct Object *spawn_object_abs_with_rot(struct Object *, s16, u32, const BehaviorScript *, s16, s16, s16, s16, s16, s16); -extern struct Object *spawn_object_rel_with_rot(struct Object *sp20, u32 sp24, const BehaviorScript *sp28, s16 sp2E, s16 sp32, s16 sp36, s16 sp3A, s16 sp3E, s16 sp42); -// extern ? spawn_obj_with_transform_flags(?); -extern struct Object *spawn_water_droplet(struct Object *, struct WaterDropletParams *); -extern struct Object *spawn_object_at_origin(struct Object *, s32, u32, const BehaviorScript *); -extern struct Object *spawn_object(struct Object *, s32, const BehaviorScript *); -extern struct Object* try_to_spawn_object(s16,f32,struct Object*,s32,const BehaviorScript *); -extern struct Object* spawn_object_with_scale(struct Object*,s32,const BehaviorScript *,f32); -// extern ? obj_build_relative_transform(?); -extern struct Object* spawn_object_relative(s16, s16, s16, s16, struct Object *, s32, const BehaviorScript *); -extern struct Object* spawn_object_relative_with_scale(s16,s16,s16,s16,f32,struct Object *,s32,const BehaviorScript *); -// extern ? cur_obj_move_using_vel(?); -extern void obj_copy_graph_y_offset(struct Object*,struct Object*); -extern void obj_copy_pos_and_angle(struct Object *, struct Object *); -extern void obj_copy_pos(struct Object*,struct Object*); -// extern ? obj_copy_angle(?); -extern void obj_set_gfx_pos_from_pos(struct Object*); -// extern ? spawn_obj_with_transform_flags(?); -extern void linear_mtxf_mul_vec3f(f32 [4][4], Vec3f, Vec3f); -extern void linear_mtxf_transpose_mul_vec3f(f32 [4][4], Vec3f, Vec3f); -// extern ? obj_apply_scale_to_transform(?); -void obj_copy_scale(struct Object *toObj, struct Object *fromObj); -extern void obj_scale_xyz(struct Object* obj, f32 xScale, f32 yScale, f32 zScale); -extern void obj_scale(struct Object *, f32); -extern void cur_obj_scale(f32); -extern void cur_obj_init_animation_with_sound(s32); -extern void cur_obj_init_animation_with_accel_and_sound(s32, f32); -extern void cur_obj_init_animation(s32 arg0); -void obj_init_animation_with_sound(struct Object *a0, struct Animation **a1, s32 a2); -// extern ? obj_enable_rendering_and_become_tangible(?); -extern void cur_obj_enable_rendering(void); -// extern ? obj_disable_rendering_and_become_intangible(?); -extern void cur_obj_disable_rendering(void); -extern void cur_obj_unhide(void); -extern void cur_obj_hide(void); -extern void cur_obj_set_pos_relative(struct Object *MarioObj, f32, f32, f32); -// extern ? cur_obj_set_pos_relative_to_parent(?); -extern void cur_obj_enable_rendering_2(void); -// extern ? obj_unused_init_on_floor(?); -extern void obj_set_face_angle_to_move_angle(struct Object *); +void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1); +void obj_apply_scale_to_matrix(struct Object *obj, Mat4 dst, Mat4 src); +void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2); +void obj_set_held_state(struct Object *obj, const BehaviorScript *heldBehavior); +f32 lateral_dist_between_objects(struct Object *obj1, struct Object *obj2); +f32 dist_between_objects(struct Object *obj1, struct Object *obj2); +void cur_obj_forward_vel_approach_upward(f32 target, f32 increment); +s32 approach_f32_signed(f32 *value, f32 target, f32 increment); +f32 approach_f32_symmetric(f32 value, f32 target, f32 increment); +s16 approach_s16_symmetric(s16 value, s16 target, s16 increment); +s32 cur_obj_rotate_yaw_toward(s16 target, s16 increment); +s16 obj_angle_to_object(struct Object *obj1, struct Object *obj2); +s16 obj_turn_toward_object(struct Object *obj, struct Object *target, s16 angleIndex, s16 turnAmount); +void obj_set_parent_relative_pos(struct Object *obj, s16 relX, s16 relY, s16 relZ); +void obj_set_pos(struct Object *obj, s16 x, s16 y, s16 z); +void obj_set_angle(struct Object *obj, s16 pitch, s16 yaw, s16 roll); +struct Object *spawn_object_abs_with_rot(struct Object *parent, s16 uselessArg, u32 model, + const BehaviorScript *behavior, + s16 x, s16 y, s16 z, s16 rx, s16 ry, s16 rz); +struct Object *spawn_object_rel_with_rot(struct Object *parent, u32 model, const BehaviorScript *behavior, + s16 xOff, s16 yOff, s16 zOff, s16 rx, s16 ry, UNUSED s16 rz); +struct Object *spawn_obj_with_transform_flags(struct Object *sp20, s32 model, const BehaviorScript *sp28); +struct Object *spawn_water_droplet(struct Object *parent, struct WaterDropletParams *params); +struct Object *spawn_object_at_origin(struct Object *, s32, u32, const BehaviorScript *); +struct Object *spawn_object_at_origin(struct Object *parent, UNUSED s32 unusedArg, u32 model, const BehaviorScript *behavior); +struct Object *spawn_object(struct Object *parent, s32 model, const BehaviorScript *behavior); +struct Object *try_to_spawn_object(s16 offsetY, f32 scale, struct Object *parent, s32 model, const BehaviorScript *behavior); +struct Object *spawn_object_with_scale(struct Object *parent, s32 model, const BehaviorScript *behavior, f32 scale); +struct Object *spawn_object_relative(s16 behaviorParam, s16 relativePosX, s16 relativePosY, s16 relativePosZ, + struct Object *parent, s32 model, const BehaviorScript *behavior); +struct Object *spawn_object_relative_with_scale(s16 behaviorParam, s16 relativePosX, s16 relativePosY, + s16 relativePosZ, f32 scale, struct Object *parent, + s32 model, const BehaviorScript *behavior); +void cur_obj_move_using_vel(void); +void obj_copy_graph_y_offset(struct Object *dst, struct Object *src); +void obj_copy_pos_and_angle(struct Object *dst, struct Object *src); +void obj_copy_pos(struct Object *dst, struct Object *src); +void obj_copy_angle(struct Object *dst, struct Object *src); +void obj_set_gfx_pos_from_pos(struct Object *obj); +void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); +void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); +void obj_apply_scale_to_transform(struct Object *obj); +void obj_copy_scale(struct Object *dst, struct Object *src); +void obj_scale_xyz(struct Object* obj, f32 xScale, f32 yScale, f32 zScale); +void obj_scale(struct Object *obj, f32 scale); +void cur_obj_scale(f32 scale); +void cur_obj_init_animation_with_sound(s32 animIndex); +void cur_obj_init_animation_with_accel_and_sound(s32 animIndex, f32 accel); +void cur_obj_init_animation(s32 animIndex); +void obj_init_animation_with_sound(struct Object *obj, const struct Animation * const* animations, s32 animIndex); +void cur_obj_enable_rendering(void); +void cur_obj_disable_rendering(void); +void cur_obj_unhide(void); +void cur_obj_hide(void); +void cur_obj_set_pos_relative(struct Object *other, f32 dleft, f32 dy, f32 dforward); +void cur_obj_set_pos_relative_to_parent(f32 dleft, f32 dy, f32 dforward); +void cur_obj_enable_rendering_2(void); +void obj_set_face_angle_to_move_angle(struct Object *obj); u32 get_object_list_from_behavior(const BehaviorScript *behavior); -extern struct Object *cur_obj_nearest_object_with_behavior(const BehaviorScript *); -f32 cur_obj_dist_to_nearest_object_with_behavior(const BehaviorScript*); -extern struct Object *cur_obj_find_nearest_object_with_behavior(const BehaviorScript *, f32 *); -extern struct Object *find_unimportant_object(void); -// extern ? count_unimportant_objects(?); -extern s32 count_objects_with_behavior(const BehaviorScript *behavior); -struct Object* cur_obj_find_nearby_held_actor(const BehaviorScript *,f32); -// extern ? obj_reset_timer_and_subaction(?); -void cur_obj_change_action(s32); -void cur_obj_set_vel_from_mario_vel(f32,f32); +struct Object *cur_obj_nearest_object_with_behavior(const BehaviorScript *behavior); +f32 cur_obj_dist_to_nearest_object_with_behavior(const BehaviorScript* behavior); +struct Object *cur_obj_find_nearest_object_with_behavior(const BehaviorScript * behavior, f32 *dist); +struct Object *find_unimportant_object(void); +s32 count_unimportant_objects(void); +s32 count_objects_with_behavior(const BehaviorScript *behavior); +struct Object *cur_obj_find_nearby_held_actor(const BehaviorScript *behavior, f32 maxDist); +void cur_obj_change_action(s32 action); +void cur_obj_set_vel_from_mario_vel(f32 f12,f32 f14); BAD_RETURN(s16) cur_obj_reverse_animation(void); -extern BAD_RETURN(s32) cur_obj_extend_animation_if_at_end(void); -extern s32 cur_obj_check_if_near_animation_end(void); -extern s32 cur_obj_check_if_at_animation_end(void); -extern s32 cur_obj_check_anim_frame(s32); -extern s32 cur_obj_check_anim_frame_in_range(s32, s32); -// extern ? cur_obj_check_frame_prior_current_frame(?); +BAD_RETURN(s32) cur_obj_extend_animation_if_at_end(void); +s32 cur_obj_check_if_near_animation_end(void); +s32 cur_obj_check_if_at_animation_end(void); +s32 cur_obj_check_anim_frame(s32 frame); +s32 cur_obj_check_anim_frame_in_range(s32 startFrame, s32 rangeLength); +s32 cur_obj_check_frame_prior_current_frame(s16 *a0); s32 mario_is_in_air_action(void); s32 mario_is_dive_sliding(void); -void cur_obj_set_y_vel_and_animation(f32,s32); -void cur_obj_unrender_and_reset_state(s32,s32); -// extern ? obj_move_after_thrown_or_dropped(?); -void cur_obj_get_thrown_or_placed(f32,f32,s32); -extern void cur_obj_get_dropped(void); -extern void cur_obj_set_model(s32); -// extern ? mario_set_flag(?); -s32 cur_obj_clear_interact_status_flag(s32); -extern void obj_mark_for_deletion(struct Object *); +void cur_obj_set_y_vel_and_animation(f32 sp18, s32 sp1C); +void cur_obj_unrender_and_reset_state(s32 sp18, s32 sp1C); +void cur_obj_get_thrown_or_placed(f32 forwardVel, f32 velY, s32 thrownAction); +void cur_obj_get_dropped(void); +void cur_obj_set_model(s32 modelID); +void mario_set_flag(s32 flag); +s32 cur_obj_clear_interact_status_flag(s32 flag); +void obj_mark_for_deletion(struct Object *obj); void cur_obj_disable(void); -extern void cur_obj_become_intangible(void); -extern void cur_obj_become_tangible(void); -extern void obj_become_tangible(struct Object*); +void cur_obj_become_intangible(void); +void cur_obj_become_tangible(void); +void obj_become_tangible(struct Object *obj); void cur_obj_update_floor_height(void); -struct Surface* cur_obj_update_floor_height_and_get_floor(void); -// extern ? apply_drag_to_value(?); -void cur_obj_apply_drag_xz(f32); -// extern ? cur_obj_move_xz(?); -// extern ? cur_obj_move_update_underwater_flags(?); -// extern ? cur_obj_move_update_ground_air_flags(?); -// extern ? cur_obj_move_y_and_get_water_level(?); -void cur_obj_move_y(f32,f32,f32); -// extern ? clear_move_flag(?); -// extern ? cur_obj_unused_resolve_wall_collisions(?); -extern s16 abs_angle_diff(s16, s16); -extern void cur_obj_move_xz_using_fvel_and_yaw(void); -extern void cur_obj_move_y_with_terminal_vel(void); +struct Surface *cur_obj_update_floor_height_and_get_floor(void); +void cur_obj_apply_drag_xz(f32 dragStrength); +void cur_obj_move_y(f32 gravity, f32 bounciness, f32 buoyancy); +void cur_obj_unused_resolve_wall_collisions(f32 offsetY, f32 radius); +s16 abs_angle_diff(s16 x0, s16 x1); +void cur_obj_move_xz_using_fvel_and_yaw(void); +void cur_obj_move_y_with_terminal_vel(void); void cur_obj_compute_vel_xz(void); -f32 increment_velocity_toward_range(f32,f32,f32,f32); -extern s32 obj_check_if_collided_with_object(struct Object *, struct Object *); -void cur_obj_set_behavior(const BehaviorScript *); -void obj_set_behavior(struct Object *, const BehaviorScript *); -extern s32 cur_obj_has_behavior(const BehaviorScript *); -s32 obj_has_behavior(struct Object *, const BehaviorScript *); +f32 increment_velocity_toward_range(f32 value, f32 center, f32 zeroThreshold, f32 increment); +s32 obj_check_if_collided_with_object(struct Object *obj1, struct Object *obj2); +void cur_obj_set_behavior(const BehaviorScript *behavior); +void obj_set_behavior(struct Object *obj, const BehaviorScript *behavior); +s32 cur_obj_has_behavior(const BehaviorScript *behavior); +s32 obj_has_behavior(struct Object *obj, const BehaviorScript *behavior); f32 cur_obj_lateral_dist_from_mario_to_home(void); -extern f32 cur_obj_lateral_dist_to_home(void); -// extern ? obj_outside_home_square(?); -// extern ? obj_outside_home_rectangle(?); -extern void cur_obj_set_pos_to_home(void); +f32 cur_obj_lateral_dist_to_home(void); +void cur_obj_set_pos_to_home(void); void cur_obj_set_pos_to_home_and_stop(void); -extern void cur_obj_shake_y(f32); -void cur_obj_start_cam_event(struct Object *obj, s32 cameraEvent); -// extern ? set_mario_interact_hoot_if_in_range(?); -void obj_set_billboard(struct Object *a0); -void obj_set_cylboard(struct Object *a0); -void cur_obj_set_hitbox_radius_and_height(f32,f32); -void cur_obj_set_hurtbox_radius_and_height(f32,f32); -// extern ? obj_spawn_loot_coins(?); -// extern ? obj_spawn_loot_blue_coins(?); -extern void obj_spawn_loot_yellow_coins(struct Object *, s32, f32); +void cur_obj_shake_y(f32 amount); +void cur_obj_start_cam_event(UNUSED struct Object *obj, s32 cameraEvent); +void set_mario_interact_hoot_if_in_range(UNUSED s32 sp0, UNUSED s32 sp4, f32 sp8); +void obj_set_billboard(struct Object *obj); +void cur_obj_set_hitbox_radius_and_height(f32 radius, f32 height); +void cur_obj_set_hurtbox_radius_and_height(f32 radius, f32 height); +void obj_spawn_loot_blue_coins(struct Object *obj, s32 numCoins, f32 sp28, s16 posJitter); +void obj_spawn_loot_yellow_coins(struct Object *obj, s32 numCoins, f32 sp28); void cur_obj_spawn_loot_coin_at_mario_pos(void); -// extern ? obj_abs_y_dist_to_home(?); -// extern ? cur_obj_advance_looping_anim(?); -// extern ? obj_detect_steep_floor(?); +s32 cur_obj_advance_looping_anim(void); s32 cur_obj_resolve_wall_collisions(void); -// extern ? obj_update_floor(?); -// extern ? obj_update_floor_and_resolve_wall_collisions(?); -extern void cur_obj_update_floor_and_walls(void); -extern void cur_obj_move_standard(s16); -// extern ? obj_within_12k_bounds(?); +void cur_obj_update_floor_and_walls(void); +void cur_obj_move_standard(s16 steepSlopeAngleDegrees); void cur_obj_move_using_vel_and_gravity(void); void cur_obj_move_using_fvel_and_gravity(void); -// extern ? set_object_pos_relative(?); s16 cur_obj_angle_to_home(void); -void obj_set_gfx_pos_at_obj_pos(struct Object*,struct Object*); -extern void obj_translate_local(struct Object*,s16,s16); -extern void obj_build_transform_from_pos_and_angle(struct Object *, s16, s16); -extern void obj_set_throw_matrix_from_transform(struct Object *); -extern void obj_build_transform_relative_to_parent(struct Object *); -// extern ? obj_create_transform_from_self(?); -// extern ? obj_rotate_move_angle_using_vel(?); +void obj_set_gfx_pos_at_obj_pos(struct Object *obj1, struct Object *obj2); +void obj_translate_local(struct Object *obj, s16 posIndex, s16 localTranslateIndex); +void obj_build_transform_from_pos_and_angle(struct Object *obj, s16 posIndex, s16 angleIndex); +void obj_set_throw_matrix_from_transform(struct Object *obj); +void obj_build_transform_relative_to_parent(struct Object *obj); +void obj_create_transform_from_self(struct Object *obj); void cur_obj_rotate_face_angle_using_vel(void); -// extern ? obj_set_face_angle_to_move_angle(?); -extern s32 cur_obj_follow_path(UNUSED s32); -extern void chain_segment_init(struct ChainSegment *); -extern f32 random_f32_around_zero(f32); -void obj_scale_random(struct Object*,f32,f32); -extern void obj_translate_xyz_random(struct Object *, f32); -extern void obj_translate_xz_random(struct Object *, f32); -// extern ? obj_build_vel_from_transform(?); +s32 cur_obj_follow_path(UNUSED s32 unused); +void chain_segment_init(struct ChainSegment *segment); +f32 random_f32_around_zero(f32 diameter); +void obj_scale_random(struct Object *obj, f32 rangeLength, f32 minScale); +void obj_translate_xyz_random(struct Object *obj, f32 rangeLength); +void obj_translate_xz_random(struct Object *obj, f32 rangeLength); void cur_obj_set_pos_via_transform(void); -void cur_obj_spawn_particles(struct SpawnParticlesInfo *sp28); -extern s16 cur_obj_reflect_move_angle_off_wall(void); +void cur_obj_spawn_particles(struct SpawnParticlesInfo *info); +s16 cur_obj_reflect_move_angle_off_wall(void); #define WAYPOINT_FLAGS_END -1 #define WAYPOINT_FLAGS_INITIALIZED 0x8000 @@ -351,71 +236,66 @@ struct GraphNode_802A45E4 { /*0x22*/ s16 unk22; }; -extern void obj_set_hitbox(struct Object* obj, struct ObjectHitbox *arg1); -s32 signum_positive(s32); -extern f32 absf(f32); -extern s32 absi(s32 a0); -s32 cur_obj_wait_then_blink(s32 a0, s32 a1); +void obj_set_hitbox(struct Object *obj, struct ObjectHitbox *hitbox); +s32 signum_positive(s32 x); +f32 absf(f32 x); +s32 absi(s32 a0); +s32 cur_obj_wait_then_blink(s32 timeUntilBlinking, s32 numBlinks); s32 cur_obj_is_mario_ground_pounding_platform(void); -extern void spawn_mist_particles(void); -extern void spawn_mist_particles_with_sound(u32 sp18); -void cur_obj_push_mario_away(f32); -void cur_obj_push_mario_away_from_cylinder(f32 sp20, f32 sp24); -// extern ? bhv_dust_smoke_loop(?); -s32 cur_obj_set_direction_table(s8*); +void spawn_mist_particles(void); +void spawn_mist_particles_with_sound(u32 sp18); +void cur_obj_push_mario_away(f32 radius); +void cur_obj_push_mario_away_from_cylinder(f32 radius, f32 extentY); +s32 cur_obj_set_direction_table(s8 *a0); s32 cur_obj_progress_direction_table(void); -// extern ? stub_obj_helpers_3(?); -extern void cur_obj_scale_over_time(s32,s32,f32,f32); +void stub_obj_helpers_3(UNUSED s32 sp0, UNUSED s32 sp4); +void cur_obj_scale_over_time(s32 a0, s32 a1, f32 sp10, f32 sp14); void cur_obj_set_pos_to_home_with_debug(void); -extern s32 cur_obj_is_mario_on_platform(void); -// extern ? obj_shake_y_until(?); -s32 cur_obj_move_up_and_down(s32); -void cur_obj_call_action_function(void(*[])(void)); -// extern ? spawn_star_with_no_lvl_exit(?); -// extern ? spawn_base_star_with_no_lvl_exit(?); -s32 bit_shift_left(s32); +s32 cur_obj_is_mario_on_platform(void); +s32 cur_obj_move_up_and_down(s32 a0); +void cur_obj_call_action_function(void (*actionFunctions[])(void)); +void spawn_base_star_with_no_lvl_exit(void); +s32 bit_shift_left(s32 a0); s32 cur_obj_mario_far_away(void); -s32 is_mario_moving_fast_or_in_air(s32); -s32 is_item_in_array(s8,s8*); -extern void bhv_init_room(void); // 802A3978 -extern void cur_obj_enable_rendering_if_mario_in_room(void); -s32 cur_obj_set_hitbox_and_die_if_attacked(struct ObjectHitbox*,s32,s32); +s32 is_mario_moving_fast_or_in_air(s32 speedThreshold); +s32 is_item_in_array(s8 item, s8 *array); +void cur_obj_enable_rendering_if_mario_in_room(void); +s32 cur_obj_set_hitbox_and_die_if_attacked(struct ObjectHitbox *hitbox, s32 deathSound, s32 noLootCoins); void obj_explode_and_spawn_coins(f32 sp18, s32 sp1C); -void obj_set_collision_data(struct Object*, const void*); +void obj_set_collision_data(struct Object *obj, const void *segAddr); void cur_obj_if_hit_wall_bounce_away(void); -s32 cur_obj_hide_if_mario_far_away_y(f32); -extern Gfx *geo_offset_klepto_held_object(s32 run, struct GraphNode *node, UNUSED f32 mtx[4][4]); -// extern ? geo_offset_klepto_debug(?); -s32 obj_is_hidden(struct Object*); -extern void enable_time_stop(void); -extern void disable_time_stop(void); -void set_time_stop_flags(s32); -void clear_time_stop_flags(s32); -s32 cur_obj_can_mario_activate_textbox(f32,f32,s32); -extern s32 cur_obj_can_mario_activate_textbox_2(f32 sp18, f32 sp1C); -// extern ? obj_end_dialog(?); -s32 cur_obj_update_dialog(s32 arg0, s32 dialogFlags, s32 dialogID, s32 unused); -s32 cur_obj_update_dialog_with_cutscene(s32 arg0, s32 dialogFlags, s32 cutsceneTable, s32 dialogID); -s32 cur_obj_has_model(u16); -extern void cur_obj_align_gfx_with_floor(void); -// extern ? mario_is_within_rectangle(?); +s32 cur_obj_hide_if_mario_far_away_y(f32 distY); +Gfx *geo_offset_klepto_held_object(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); +s32 geo_offset_klepto_debug(s32 a0, struct GraphNode *a1, UNUSED s32 sp8); +s32 obj_is_hidden(struct Object *obj); +void enable_time_stop(void); +void disable_time_stop(void); +void set_time_stop_flags(s32 flags); +void clear_time_stop_flags(s32 flags); +s32 cur_obj_can_mario_activate_textbox(f32 radius, f32 height, UNUSED s32 unused); +s32 cur_obj_can_mario_activate_textbox_2(f32 radius, f32 height); +s32 cur_obj_update_dialog(s32 actionArg, s32 dialogFlags, s32 dialogID, UNUSED s32 unused); +s32 cur_obj_update_dialog_with_cutscene(s32 actionArg, s32 dialogFlags, s32 cutsceneTable, s32 dialogID); +s32 cur_obj_has_model(u16 modelID); +void cur_obj_align_gfx_with_floor(void); +s32 mario_is_within_rectangle(s16 minX, s16 maxX, s16 minZ, s16 maxZ); void cur_obj_shake_screen(s32 shake); -extern s32 obj_attack_collided_from_other_object(struct Object *obj); +s32 obj_attack_collided_from_other_object(struct Object *obj); s32 cur_obj_was_attacked_or_ground_pounded(void); -void obj_copy_behavior_params(struct Object*,struct Object*); -void cur_obj_init_animation_and_anim_frame(s32,s32); -s32 cur_obj_init_animation_and_check_if_near_end(s32); -void cur_obj_init_animation_and_extend_if_at_end(s32); +void obj_copy_behavior_params(struct Object *dst, struct Object *src); +void cur_obj_init_animation_and_anim_frame(s32 animIndex, s32 animFrame); +s32 cur_obj_init_animation_and_check_if_near_end(s32 animIndex); +void cur_obj_init_animation_and_extend_if_at_end(s32 animIndex); s32 cur_obj_check_grabbed_mario(void); s32 player_performed_grab_escape_action(void); -// extern ? cur_obj_unused_play_footstep_sound(?); -// extern ? enable_time_stop_including_mario(?); -extern void disable_time_stop_including_mario(void); +void cur_obj_unused_play_footstep_sound(s32 animFrame1, s32 animFrame2, s32 sound); +void enable_time_stop_including_mario(void); +void disable_time_stop_including_mario(void); s32 cur_obj_check_interacted(void); void cur_obj_spawn_loot_blue_coin(void); #ifndef VERSION_JP -void cur_obj_spawn_star_at_y_offset(f32 f12, f32 f14, f32 a2, f32 a3); +void cur_obj_spawn_star_at_y_offset(f32 targetX, f32 targetY, f32 targetZ, f32 offsetY); #endif -#endif /* OBJECT_HELPERS_H */ +#endif // OBJECT_HELPERS_H diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 3bb3ca65..7113e7c8 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -1,24 +1,24 @@ -#include +#include #include "sm64.h" -#include "behavior_data.h" -#include "engine/behavior_script.h" #include "area.h" +#include "behavior_data.h" #include "camera.h" -#include "engine/graph_node.h" -#include "interaction.h" #include "debug.h" -#include "profiler.h" -#include "spawn_object.h" +#include "engine/behavior_script.h" +#include "engine/graph_node.h" #include "engine/surface_collision.h" -#include "memory.h" +#include "engine/surface_load.h" +#include "interaction.h" #include "level_update.h" +#include "mario.h" +#include "memory.h" #include "object_collision.h" #include "object_helpers.h" -#include "platform_displacement.h" -#include "engine/surface_load.h" #include "object_list_processor.h" -#include "mario.h" +#include "platform_displacement.h" +#include "profiler.h" +#include "spawn_object.h" /** @@ -86,7 +86,7 @@ struct ObjectNode *gObjectLists; struct ObjectNode gFreeObjectList; /** - * The object representing mario. + * The object representing Mario. */ struct Object *gMarioObject; @@ -218,7 +218,7 @@ struct ParticleProperties sParticleTypes[] = { }; /** - * Copy position, velocity, and angle variables from MarioState to the mario + * Copy position, velocity, and angle variables from MarioState to the Mario * object. */ void copy_mario_state_to_object(void) { @@ -272,7 +272,7 @@ void bhv_mario_update(void) { gCurrentObject->oMarioParticleFlags = particleFlags; // Mario code updates MarioState's versions of position etc, so we need - // to sync it with the mario object + // to sync it with the Mario object copy_mario_state_to_object(); i = 0; @@ -308,7 +308,7 @@ s32 update_objects_starting_at(struct ObjectNode *objList, struct ObjectNode *fi /** * Update objects in objList starting with firstObj while time stop is active. - * This means that only certain select objects will be updated, such as mario, + * This means that only certain select objects will be updated, such as Mario, * doors, unimportant objects, and the object that initiated time stop. * The exact set of objects that are updated depends on which flags are set * in gTimeStopState. @@ -457,8 +457,8 @@ void spawn_objects_from_info(UNUSED s32 unused, struct SpawnInfo *spawnInfo) { gWDWWaterLevelChanging = FALSE; gMarioOnMerryGoRound = 0; - //! (Spawning Displacement) On the Japanese version, mario's platform object - // isn't cleared when transitioning between areas. This can cause mario to + //! (Spawning Displacement) On the Japanese version, Mario's platform object + // isn't cleared when transitioning between areas. This can cause Mario to // receive displacement after spawning. #ifndef VERSION_JP clear_mario_platform(); @@ -519,12 +519,11 @@ void spawn_objects_from_info(UNUSED s32 unused, struct SpawnInfo *spawnInfo) { } } -void stub_obj_list_processor_1() { +void stub_obj_list_processor_1(void) { } /** - * Clear objects, dynamic surfaces, and some miscellaneous level data used by - * objects. + * Clear objects, dynamic surfaces, and some miscellaneous level data used by objects. */ void clear_objects(void) { s32 i; @@ -548,7 +547,7 @@ void clear_objects(void) { stub_obj_list_processor_1(); for (i = 0; i < OBJECT_POOL_CAPACITY; i++) { - gObjectPool[i].activeFlags = ACTIVE_FLAGS_DEACTIVATED; + gObjectPool[i].activeFlags = ACTIVE_FLAG_DEACTIVATED; geo_reset_object_node(&gObjectPool[i].header.gfx); } @@ -648,7 +647,7 @@ void update_objects(UNUSED s32 unused) { cycleCounts[2] = get_clock_difference(cycleCounts[0]); update_terrain_objects(); - // If mario was touching a moving platform at the end of last frame, apply + // If Mario was touching a moving platform at the end of last frame, apply // displacement now //! If the platform object unloaded and a different object took its place, // displacement could be applied incorrectly @@ -666,7 +665,7 @@ void update_objects(UNUSED s32 unused) { cycleCounts[5] = get_clock_difference(cycleCounts[0]); unload_deactivated_objects(); - // Check if mario is on a platform object and save this object + // Check if Mario is on a platform object and save this object cycleCounts[6] = get_clock_difference(cycleCounts[0]); update_mario_platform(); diff --git a/src/game/object_list_processor.h b/src/game/object_list_processor.h index fde29d65..205ec3f1 100644 --- a/src/game/object_list_processor.h +++ b/src/game/object_list_processor.h @@ -1,9 +1,11 @@ -#ifndef _OBJECT_LIST_PROCESSOR_H -#define _OBJECT_LIST_PROCESSOR_H +#ifndef OBJECT_LIST_PROCESSOR_H +#define OBJECT_LIST_PROCESSOR_H -struct Object; -struct SpawnInfo; +#include +#include "area.h" +#include "macros.h" +#include "types.h" /** * Flags for gTimeStopState. These control which objects are processed each frame @@ -34,7 +36,7 @@ struct SpawnInfo; */ enum ObjectList { - OBJ_LIST_PLAYER, // (0) mario + OBJ_LIST_PLAYER, // (0) Mario OBJ_LIST_UNUSED_1, // (1) (unused) OBJ_LIST_DESTRUCTIVE, // (2) things that can be used to destroy other objects, like // bob-ombs and corkboxes @@ -51,7 +53,7 @@ enum ObjectList OBJ_LIST_SURFACE, // (9) surface objects. objects that specifically have surface // collision and not object collision. (thwomp, whomp, etc) OBJ_LIST_POLELIKE, // (10) polelike objects. objects that attract or otherwise - // "cling" mario similar to a pole action. (hoot, + // "cling" Mario similar to a pole action. (hoot, // whirlpool, trees/poles, etc) OBJ_LIST_SPAWNER, // (11) spawners OBJ_LIST_UNIMPORTANT, // (12) unimportant objects. objects that will not load @@ -121,10 +123,10 @@ extern s16 gMarioOnMerryGoRound; void bhv_mario_update(void); void set_object_respawn_info_bits(struct Object *obj, u8 bits); -void unload_objects_from_area(s32 unused, s32 areaIndex); -void spawn_objects_from_info(s32 unused, struct SpawnInfo *spawnInfo); +void unload_objects_from_area(UNUSED s32 unused, s32 areaIndex); +void spawn_objects_from_info(UNUSED s32 unused, struct SpawnInfo *spawnInfo); void clear_objects(void); -void update_objects(s32 unused); +void update_objects(UNUSED s32 unused); -#endif /* _OBJECT_LIST_PROCESSOR_H */ +#endif // OBJECT_LIST_PROCESSOR_H diff --git a/src/game/paintings.c b/src/game/paintings.c index e53dd45f..6cae19c0 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -1,16 +1,21 @@ -#include +#include #include "sm64.h" +#include "area.h" +#include "engine/graph_node.h" +#include "engine/surface_collision.h" #include "game_init.h" +#include "geo_misc.h" +#include "levels/castle_inside/header.h" +#include "levels/hmc/header.h" +#include "levels/ttm/header.h" #include "mario.h" #include "memory.h" -#include "save_file.h" -#include "engine/surface_collision.h" -#include "engine/graph_node.h" -#include "geo_misc.h" -#include "area.h" -#include "segment2.h" +#include "moving_texture.h" +#include "object_list_processor.h" #include "paintings.h" +#include "save_file.h" +#include "segment2.h" /** * @file paintings.c @@ -37,20 +42,20 @@ * Painting state machine: * Paintings spawn in the PAINTING_IDLE state * From IDLE, paintings can change to PAINTING_RIPPLE or PAINTING_ENTERED - * - This state checks for ENTERED because if mario waits long enough, a PROXIMITY painting could + * - This state checks for ENTERED because if Mario waits long enough, a PROXIMITY painting could * reset to IDLE * * Paintings in the PAINTING_RIPPLE state are passively rippling. - * For RIPPLE_TRIGGER_PROXIMITY paintings, this means mario bumped the wall in front of the + * For RIPPLE_TRIGGER_PROXIMITY paintings, this means Mario bumped the wall in front of the * painting. * * Paintings that use RIPPLE_TRIGGER_CONTINUOUS try to transition to this state as soon as possible, - * usually when mario enters the room. + * usually when Mario enters the room. * * A PROXIMITY painting will automatically reset to IDLE if its ripple magnitude becomes small * enough. * - * Paintings in the PAINTING_ENTERED state have been entered by mario. + * Paintings in the PAINTING_ENTERED state have been entered by Mario. * A CONTINUOUS painting will automatically reset to RIPPLE if its ripple magnitude becomes small * enough. */ @@ -86,12 +91,12 @@ #define ENTER_RIGHT 0x1 /** - * Use the 1/4th part of the painting that is nearest to mario's current floor. + * Use the 1/4th part of the painting that is nearest to Mario's current floor. */ #define NEAREST_4TH 30 /** - * Use mario's relative x position. + * Use Mario's relative x position. * @see painting_mario_x */ #define MARIO_X 40 @@ -102,13 +107,13 @@ #define MIDDLE_X 50 /** - * Use mario's relative y position. + * Use Mario's relative y position. * @see painting_mario_y */ #define MARIO_Y 60 /** - * Use mario's relative z position. + * Use Mario's relative z position. * @see painting_mario_z */ #define MARIO_Z 70 @@ -129,10 +134,12 @@ */ #define RESET_TIMER 100 -/// A copy of the type of floor mario is standing on. +/// A copy of the type of floor Mario is standing on. s16 gPaintingMarioFloorType; -// A copy of mario's position -f32 gPaintingMarioXPos, gPaintingMarioYPos, gPaintingMarioZPos; +// A copy of Mario's position +f32 gPaintingMarioXPos; +f32 gPaintingMarioYPos; +f32 gPaintingMarioZPos; /** * When a painting is rippling, this mesh is generated each frame using the Painting's parameters. @@ -202,11 +209,11 @@ void stop_other_paintings(s16 *idptr, struct Painting *paintingGroup[]) { } /** - * @return mario's y position inside the painting (bounded). + * @return Mario's y position inside the painting (bounded). */ f32 painting_mario_y(struct Painting *painting) { //! Unnecessary use of double constants - // Add 50 to make the ripple closer to mario's center of mass. + // Add 50 to make the ripple closer to Mario's center of mass. f32 relY = gPaintingMarioYPos - painting->posY + 50.0; if (relY < 0.0) { @@ -218,7 +225,7 @@ f32 painting_mario_y(struct Painting *painting) { } /** - * @return mario's z position inside the painting (bounded). + * @return Mario's z position inside the painting (bounded). */ f32 painting_mario_z(struct Painting *painting) { f32 relZ = painting->posZ - gPaintingMarioZPos; @@ -250,7 +257,7 @@ f32 painting_ripple_y(struct Painting *painting, s8 ySource) { } /** - * Return the quarter of the painting that is closest to the floor mario entered. + * Return the quarter of the painting that is closest to the floor Mario entered. */ f32 painting_nearest_4th(struct Painting *painting) { f32 firstQuarter = painting->size / 4.0; // 1/4 of the way across the painting @@ -275,7 +282,7 @@ f32 painting_nearest_4th(struct Painting *painting) { } /** - * @return mario's x position inside the painting (bounded). + * @return Mario's x position inside the painting (bounded). */ f32 painting_mario_x(struct Painting *painting) { f32 relX = gPaintingMarioXPos - painting->posX; @@ -306,7 +313,7 @@ f32 painting_ripple_x(struct Painting *painting, s8 xSource) { } /** - * Set the painting's state, causing it to start a passive ripple or a ripple from mario entering. + * Set the painting's state, causing it to start a passive ripple or a ripple from Mario entering. * * @param state The state to enter * @param painting,paintingGroup identifies the painting that is changing state @@ -350,7 +357,7 @@ void painting_state(s8 state, struct Painting *painting, struct Painting *painti * Idle update function for wall paintings that use RIPPLE_TRIGGER_PROXIMITY. */ void wall_painting_proximity_idle(struct Painting *painting, struct Painting *paintingGroup[]) { - // Check for mario triggering a ripple + // Check for Mario triggering a ripple if (painting->floorEntered & RIPPLE_LEFT) { painting_state(PAINTING_RIPPLE, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); } else if (painting->floorEntered & RIPPLE_MIDDLE) { @@ -358,7 +365,7 @@ void wall_painting_proximity_idle(struct Painting *painting, struct Painting *pa } else if (painting->floorEntered & RIPPLE_RIGHT) { painting_state(PAINTING_RIPPLE, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); - // Check for mario entering + // Check for Mario entering } else if (painting->floorEntered & ENTER_LEFT) { painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); } else if (painting->floorEntered & ENTER_MIDDLE) { @@ -385,7 +392,7 @@ void wall_painting_proximity_rippling(struct Painting *painting, struct Painting * Idle update function for wall paintings that use RIPPLE_TRIGGER_CONTINUOUS. */ void wall_painting_continuous_idle(struct Painting *painting, struct Painting *paintingGroup[]) { - // Check for mario triggering a ripple + // Check for Mario triggering a ripple if (painting->floorEntered & RIPPLE_LEFT) { painting_state(PAINTING_RIPPLE, painting, paintingGroup, MIDDLE_X, MIDDLE_Y, RESET_TIMER); } else if (painting->floorEntered & RIPPLE_MIDDLE) { @@ -393,7 +400,7 @@ void wall_painting_continuous_idle(struct Painting *painting, struct Painting *p } else if (painting->floorEntered & RIPPLE_RIGHT) { painting_state(PAINTING_RIPPLE, painting, paintingGroup, MIDDLE_X, MIDDLE_Y, RESET_TIMER); - // Check for mario entering + // Check for Mario entering } else if (painting->floorEntered & ENTER_LEFT) { painting_state(PAINTING_ENTERED, painting, paintingGroup, NEAREST_4TH, MARIO_Y, RESET_TIMER); } else if (painting->floorEntered & ENTER_MIDDLE) { @@ -422,7 +429,7 @@ void wall_painting_continuous_rippling(struct Painting *painting, struct Paintin * No floor paintings use RIPPLE_TRIGGER_PROXIMITY in the game. */ void floor_painting_proximity_idle(struct Painting *painting, struct Painting *paintingGroup[]) { - // Check for mario triggering a ripple + // Check for Mario triggering a ripple if (painting->floorEntered & RIPPLE_LEFT) { painting_state(PAINTING_RIPPLE, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); } else if (painting->floorEntered & RIPPLE_MIDDLE) { @@ -430,7 +437,7 @@ void floor_painting_proximity_idle(struct Painting *painting, struct Painting *p } else if (painting->floorEntered & RIPPLE_RIGHT) { painting_state(PAINTING_RIPPLE, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); - // Only check for mario entering if he jumped below the surface + // Only check for Mario entering if he jumped below the surface } else if (painting->marioWentUnder) { if (painting->currFloor & ENTER_LEFT) { painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); @@ -463,11 +470,11 @@ void floor_painting_proximity_rippling(struct Painting *painting, struct Paintin * Idle update function for floor paintings that use RIPPLE_TRIGGER_CONTINUOUS. * * Both floor paintings (HMC and CotMC) are hidden behind a door, which hides the ripple's start up. - * The floor just inside the doorway is RIPPLE_LEFT, so the painting starts rippling as soon as mario + * The floor just inside the doorway is RIPPLE_LEFT, so the painting starts rippling as soon as Mario * enters the room. */ void floor_painting_continuous_idle(struct Painting *painting, struct Painting *paintingGroup[]) { - // Check for mario triggering a ripple + // Check for Mario triggering a ripple if (painting->floorEntered & RIPPLE_LEFT) { painting_state(PAINTING_RIPPLE, painting, paintingGroup, MIDDLE_X, MIDDLE_Y, RESET_TIMER); } else if (painting->floorEntered & RIPPLE_MIDDLE) { @@ -475,7 +482,7 @@ void floor_painting_continuous_idle(struct Painting *painting, struct Painting * } else if (painting->floorEntered & RIPPLE_RIGHT) { painting_state(PAINTING_RIPPLE, painting, paintingGroup, MIDDLE_X, MIDDLE_Y, RESET_TIMER); - // Check for mario entering + // Check for Mario entering } else if (painting->currFloor & ENTER_LEFT) { painting_state(PAINTING_ENTERED, painting, paintingGroup, MARIO_X, MARIO_Z, RESET_TIMER); } else if (painting->currFloor & ENTER_MIDDLE) { @@ -501,7 +508,7 @@ void floor_painting_continuous_rippling(struct Painting *painting, struct Painti } /** - * Check for mario entering one of the special floors associated with the painting. + * Check for Mario entering one of the special floors associated with the painting. */ void painting_update_floors(struct Painting *painting) { s16 paintingId = painting->id; @@ -546,14 +553,14 @@ void painting_update_floors(struct Painting *painting) { painting->floorEntered = (painting->lastFloor ^ painting->currFloor) & painting->currFloor; painting->marioWasUnder = painting->marioIsUnder; - // Check if mario has fallen below the painting (used for floor paintings) + // Check if Mario has fallen below the painting (used for floor paintings) if (gPaintingMarioYPos < painting->posY) { painting->marioIsUnder = TRUE; } else { painting->marioIsUnder = FALSE; } - // mario "went under" if he was not under last frame, but is under now + // Mario "went under" if he was not under last frame, but is under now painting->marioWentUnder = (painting->marioWasUnder ^ painting->marioIsUnder) & painting->marioIsUnder; } @@ -583,7 +590,7 @@ void painting_update_ripple_state(struct Painting *painting) { // if the painting is doing the entry ripple but the ripples are as small as those from the // passive ripple, make it do a passive ripple - // If mario goes below the surface but doesn't warp, the painting will eventually reset. + // If Mario goes below the surface but doesn't warp, the painting will eventually reset. if (painting->state == PAINTING_ENTERED && painting->currRippleMag <= painting->passiveRippleMag) { painting->state = PAINTING_RIPPLE; @@ -747,7 +754,7 @@ s8 normalize_component(f32 comp) { /** * Approximates the painting mesh's vertex normals by averaging the normals of all triangles sharing a - * vertex. Used for gouraud lighting. + * vertex. Used for Gouraud lighting. * * After each triangle's surface normal is calculated, the `neighborTris` table describes which triangles * each vertex should use when calculating the average normal vector. @@ -1044,7 +1051,7 @@ Gfx *display_painting_not_rippling(struct Painting *painting) { } /** - * Clear mario-related state and clear gRipplingPainting. + * Clear Mario-related state and clear gRipplingPainting. */ void reset_painting(struct Painting *painting) { painting->lastFloor = 0; @@ -1055,14 +1062,31 @@ void reset_painting(struct Painting *painting) { painting->marioWentUnder = 0; gRipplingPainting = NULL; + + // Make sure all variables are reset correctly. + // With segmented memory the segments that contain the relevant + // Painting structs are reloaded from ROM upon level load. + painting->state = PAINTING_IDLE; + painting->currRippleMag = 0.0f; + painting->rippleDecay = 1.0f; + painting->currRippleRate = 0.0f; + painting->dispersionFactor = 0.0f; + painting->rippleTimer = 0.0f; + painting->rippleX = 0.0f; + painting->rippleY = 0.0f; + if (painting == &ddd_painting) { + // Move DDD painting to initial position, in case the animation + // that moves the painting stops during level unload. + painting->posX = 3456.0f; + } } /** * Controls the x coordinate of the DDD painting. * - * Before mario gets the "Board Bowser's Sub" star in DDD, the painting spawns at frontPos. + * Before Mario gets the "Board Bowser's Sub" star in DDD, the painting spawns at frontPos. * - * If mario just got the star, the painting's x coordinate moves to backPos at a rate of `speed` units. + * If Mario just got the star, the painting's x coordinate moves to backPos at a rate of `speed` units. * * When the painting reaches backPos, a save flag is set so that the painting will spawn at backPos * whenever it loads. @@ -1227,9 +1251,9 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con } /** - * Update the painting system's local copy of mario's current floor and position. + * Update the painting system's local copy of Mario's current floor and position. */ -Gfx *geo_painting_update(s32 callContext, UNUSED struct GraphNode *node, UNUSED f32 c[4][4]) { +Gfx *geo_painting_update(s32 callContext, UNUSED struct GraphNode *node, UNUSED Mat4 c) { struct Surface *surface; // Reset the update counter @@ -1240,7 +1264,7 @@ Gfx *geo_painting_update(s32 callContext, UNUSED struct GraphNode *node, UNUSED gLastPaintingUpdateCounter = gPaintingUpdateCounter; gPaintingUpdateCounter = gAreaUpdateCounter; - // Store mario's floor and position + // Store Mario's floor and position find_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &surface); gPaintingMarioFloorType = surface->type; gPaintingMarioXPos = gMarioObject->oPosX; diff --git a/src/game/paintings.h b/src/game/paintings.h index a5d1a164..f88c4b24 100644 --- a/src/game/paintings.h +++ b/src/game/paintings.h @@ -1,11 +1,11 @@ #ifndef PAINTINGS_H #define PAINTINGS_H -#include "types.h" +#include +#include -/** - * @file paintings.h - */ +#include "macros.h" +#include "types.h" /// Use to properly set a GraphNodeGenerated's parameter to point to the right painting #define PAINTING_ID(id, grp) id | (grp << 8) @@ -40,11 +40,11 @@ struct Painting /// Either PAINTING_IMAGE or PAINTING_ENV_MAP s8 textureType; - /// The floor mario was on last frame + /// The floor Mario was on last frame s8 lastFloor; - /// The floor mario is currently on + /// The floor Mario is currently on s8 currFloor; - /// The floor mario just entered + /// The floor Mario just entered s8 floorEntered; /// The painting's state, see top of paintings.c @@ -105,11 +105,11 @@ struct Painting /// The painting's transparency. Determines what layer the painting is in. u8 alpha; - /// True if mario was under the painting's y coordinate last frame + /// True if Mario was under the painting's y coordinate last frame s8 marioWasUnder; - /// True if mario is currently under the painting's y coordinate + /// True if Mario is currently under the painting's y coordinate s8 marioIsUnder; - /// True if mario just went under the painting's y coordinate on this frame + /// True if Mario just went under the painting's y coordinate on this frame s8 marioWentUnder; /// Uniformly scales the painting to a multiple of PAINTING_SIZE. @@ -117,32 +117,6 @@ struct Painting f32 size; }; -extern struct Painting cotmc_painting; - -extern struct Painting bob_painting; -extern struct Painting ccm_painting; -extern struct Painting wf_painting; -extern struct Painting jrb_painting; -extern struct Painting lll_painting; -extern struct Painting ssl_painting; -extern struct Painting hmc_painting; -extern struct Painting ddd_painting; -extern struct Painting wdw_painting; -extern struct Painting thi_tiny_painting; -extern struct Painting ttm_painting; -extern struct Painting ttc_painting; -extern struct Painting sl_painting; -extern struct Painting thi_huge_painting; - -extern struct Painting ttm_slide_painting; - -extern u16 gAreaUpdateCounter; -extern f32 gPaintingMarioYEntry; - -// defined in file -extern s16 gPaintingMarioFloorType; -extern f32 gPaintingMarioXPos, gPaintingMarioYPos, gPaintingMarioZPos; - /** * Contains the position and normal of a vertex in the painting's generated mesh. */ @@ -151,12 +125,17 @@ struct PaintingMeshVertex { /*0x06*/ s8 norm[3]; }; +extern s16 gPaintingMarioFloorType; +extern f32 gPaintingMarioXPos; +extern f32 gPaintingMarioYPos; +extern f32 gPaintingMarioZPos; + extern struct PaintingMeshVertex *gPaintingMesh; extern Vec3f *gPaintingTriNorms; extern struct Painting *gRipplingPainting; extern s8 gDddPaintingStatus; -extern Gfx *geo_painting_draw(s32 run, struct GraphNode *node, void *context); -extern Gfx *geo_painting_update(s32 run, struct GraphNode *node, f32 c[4][4]); +Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *context); +Gfx *geo_painting_update(s32 callContext, UNUSED struct GraphNode *node, UNUSED Mat4 c); -#endif /* PAINTINGS_H */ +#endif // PAINTINGS_H diff --git a/src/game/platform_displacement.c b/src/game/platform_displacement.c index 24363226..29a741c2 100644 --- a/src/game/platform_displacement.c +++ b/src/game/platform_displacement.c @@ -1,14 +1,13 @@ -#include +#include -#include "sm64.h" -#include "platform_displacement.h" #include "engine/math_util.h" -#include "object_helpers.h" -#include "mario.h" -#include "engine/behavior_script.h" -#include "level_update.h" #include "engine/surface_collision.h" +#include "level_update.h" +#include "object_fields.h" +#include "object_helpers.h" #include "object_list_processor.h" +#include "platform_displacement.h" +#include "types.h" u16 D_8032FEC0 = 0; @@ -17,7 +16,7 @@ u32 unused_8032FEC4[4] = { 0 }; struct Object *gMarioPlatform = NULL; /** - * Determine if mario is standing on a platform object, meaning that he is + * Determine if Mario is standing on a platform object, meaning that he is * within 4 units of the floor. Set his referenced platform object accordingly. */ void update_mario_platform(void) { @@ -33,7 +32,7 @@ void update_mario_platform(void) { return; } - //! If mario moves onto a rotating platform in a PU, the find_floor call + //! If Mario moves onto a rotating platform in a PU, the find_floor call // will detect the platform and he will end up receiving a large amount // of displacement since he is considered to be far from the platform's // axis of rotation. @@ -68,7 +67,7 @@ void update_mario_platform(void) { } /** - * Get mario's position and store it in x, y, and z. + * Get Mario's position and store it in x, y, and z. */ void get_mario_pos(f32 *x, f32 *y, f32 *z) { *x = gMarioStates[0].pos[0]; @@ -77,7 +76,7 @@ void get_mario_pos(f32 *x, f32 *y, f32 *z) { } /** - * Set mario's position. + * Set Mario's position. */ void set_mario_pos(f32 x, f32 y, f32 z) { gMarioStates[0].pos[0] = x; @@ -86,7 +85,7 @@ void set_mario_pos(f32 x, f32 y, f32 z) { } /** - * Apply one frame of platform rotation to mario or an object using the given + * Apply one frame of platform rotation to Mario or an object using the given * platform. If isMario is 0, use gCurrentObject. */ void apply_platform_displacement(u32 isMario, struct Object *platform) { @@ -167,7 +166,7 @@ void apply_platform_displacement(u32 isMario, struct Object *platform) { } /** - * If mario's platform is not null, apply platform displacement. + * If Mario's platform is not null, apply platform displacement. */ void apply_mario_platform_displacement(void) { struct Object *platform; @@ -180,7 +179,7 @@ void apply_mario_platform_displacement(void) { #ifndef VERSION_JP /** - * Set mario's platform to NULL. + * Set Mario's platform to NULL. */ void clear_mario_platform(void) { gMarioPlatform = NULL; diff --git a/src/game/platform_displacement.h b/src/game/platform_displacement.h index e46d8562..556192b5 100644 --- a/src/game/platform_displacement.h +++ b/src/game/platform_displacement.h @@ -1,15 +1,17 @@ -#ifndef _PLATFORM_DISPLACEMENT_H -#define _PLATFORM_DISPLACEMENT_H +#ifndef PLATFORM_DISPLACEMENT_H +#define PLATFORM_DISPLACEMENT_H + +#include #include "types.h" -extern void update_mario_platform(void); -extern void get_mario_pos(f32 *, f32 *, f32 *); -extern void set_mario_pos(f32, f32, f32); -extern void apply_platform_displacement(u32, struct Object *); -extern void apply_mario_platform_displacement(void); +void update_mario_platform(void); +void get_mario_pos(f32 *x, f32 *y, f32 *z); +void set_mario_pos(f32 x, f32 y, f32 z); +void apply_platform_displacement(u32 isMario, struct Object *platform); +void apply_mario_platform_displacement(void); #ifndef VERSION_JP -extern void clear_mario_platform(void); +void clear_mario_platform(void); #endif -#endif /* _PLATFORM_DISPLACEMENT_H */ +#endif // PLATFORM_DISPLACEMENT_H diff --git a/src/game/print.c b/src/game/print.c index 56ab66d3..f7a83865 100644 --- a/src/game/print.c +++ b/src/game/print.c @@ -1,16 +1,11 @@ -#include +#include +#include -#include "sm64.h" -#include "gfx_dimensions.h" +#include "config.h" #include "game_init.h" -#include "mario.h" #include "memory.h" -#include "save_file.h" -#include "main.h" -#include "engine/surface_collision.h" -#include "geo_misc.h" -#include "segment2.h" #include "print.h" +#include "segment2.h" /** * This file handles printing and formatting the colorful text that @@ -256,8 +251,7 @@ void print_text(s32 x, s32 y, const char *str) { } /** - * Prints text in the colorful lettering centered - * at given X, Y coordinates. + * Prints text in the colorful lettering centered at given X, Y coordinates. */ void print_text_centered(s32 x, s32 y, const char *str) { char c = 0; diff --git a/src/game/print.h b/src/game/print.h index 8dd1901b..95597e8a 100644 --- a/src/game/print.h +++ b/src/game/print.h @@ -1,7 +1,7 @@ -#ifndef _PRINT_H -#define _PRINT_H +#ifndef PRINT_H +#define PRINT_H -#include "types.h" +#include #define TEXRECT_MIN_X 10 #define TEXRECT_MAX_X 300 @@ -25,9 +25,9 @@ #define GLYPH_DOUBLE_QUOTE 57 #define GLYPH_UMLAUT 58 -extern void print_text_fmt_int(s32 x, s32 y, const char *str, s32 n); -extern void print_text(s32 x, s32 y, const char *str); -extern void print_text_centered(s32 x, s32 y, const char *str); -extern void render_text_labels(void); +void print_text_fmt_int(s32 x, s32 y, const char *str, s32 n); +void print_text(s32 x, s32 y, const char *str); +void print_text_centered(s32 x, s32 y, const char *str); +void render_text_labels(void); -#endif /* _PRINT_H */ +#endif // PRINT_H diff --git a/src/game/profiler.c b/src/game/profiler.c index ad64cb3c..9f968c6a 100644 --- a/src/game/profiler.c +++ b/src/game/profiler.c @@ -1,4 +1,6 @@ -#include +#include +#include +#include #include "sm64.h" #include "profiler.h" @@ -39,7 +41,7 @@ void profiler_log_thread4_time(void) { // log the times for gfxTimes: RSP completes, and RDP completes. void profiler_log_gfx_time(enum ProfilerGfxEvent eventID) { - if (eventID == 0) { + if (eventID == TASKS_QUEUED) { gCurrentFrameIndex2 ^= 1; gProfilerFrameData[gCurrentFrameIndex2].numVblankTimes = 0; } @@ -57,38 +59,38 @@ void profiler_log_vblank_time(void) { } // draw the specified profiler given the information passed. -void draw_profiler_bar(OSTime clock_base, OSTime clock_start, OSTime clock_end, s16 pos_y, u16 color) { - s64 duration_start, duration_end; - s32 rect_x1, rect_x2; +void draw_profiler_bar(OSTime clockBase, OSTime clockStart, OSTime clockEnd, s16 posY, u16 color) { + s64 durationStart, durationEnd; + s32 rectX1, rectX2; // set the duration to start, and floor to 0 if the result is below 0. - if ((duration_start = clock_start - clock_base) < 0) { - duration_start = 0; + if ((durationStart = clockStart - clockBase) < 0) { + durationStart = 0; } // like the above, but with end. - if ((duration_end = clock_end - clock_base) < 0) { - duration_end = 0; + if ((durationEnd = clockEnd - clockBase) < 0) { + durationEnd = 0; } // calculate the x coordinates of where start and end begins, respectively. - rect_x1 = ((((duration_start * 1000000) / osClockRate * 3) / 1000) + 30); - rect_x2 = ((((duration_end * 1000000) / osClockRate * 3) / 1000) + 30); + rectX1 = ((((durationStart * 1000000) / osClockRate * 3) / 1000) + 30); + rectX2 = ((((durationEnd * 1000000) / osClockRate * 3) / 1000) + 30); - //! I believe this is supposed to cap rect_x1 and rect_x2 to 320, but the + //! I believe this is supposed to cap rectX1 and rectX2 to 320, but the // code seems to use the wrong variables... it's possible that the variable // names were very similar within a single letter. - if (rect_x1 > 319) { - clock_start = 319; + if (rectX1 > 319) { + clockStart = 319; } - if (rect_x2 > 319) { - clock_end = 319; + if (rectX2 > 319) { + clockEnd = 319; } // perform the render if start is less than end. in most cases, it should be. - if (rect_x1 < rect_x2) { + if (rectX1 < rectX2) { gDPPipeSync(gDisplayListHead++); gDPSetFillColor(gDisplayListHead++, color << 16 | color); - gDPFillRectangle(gDisplayListHead++, rect_x1, pos_y, rect_x2, pos_y + 2); + gDPFillRectangle(gDisplayListHead++, rectX1, posY, rectX2, posY + 2); } } @@ -137,27 +139,27 @@ void draw_reference_profiler_bars(void) { void draw_profiler_mode_1(void) { s32 i; struct ProfilerFrameData *profiler; - OSTime clock_base; + OSTime clockBase; // the profiler logs 2 frames of data: last frame and current frame. Indexes are used // to keep track of the current frame, so the index is xor'd to retrieve the last frame's // data. profiler = &gProfilerFrameData[gCurrentFrameIndex1 ^ 1]; - // calculate the clock_base. - clock_base = profiler->soundTimes[0] - (16433 * osClockRate / 1000000); + // calculate the clockBase. + clockBase = profiler->soundTimes[0] - (16433 * osClockRate / 1000000); // draw the profiler for the time it takes for level scripts to execute. (yellow) - draw_profiler_bar(clock_base, profiler->gameTimes[0], profiler->gameTimes[1], 212, + draw_profiler_bar(clockBase, profiler->gameTimes[0], profiler->gameTimes[1], 212, GPACK_RGBA5551(255, 255, 40, 1)); // draw the profiler for the time it takes for the game to render (between level scripts and // pre-display lists). (orange) - draw_profiler_bar(clock_base, profiler->gameTimes[1], profiler->gameTimes[2], 212, + draw_profiler_bar(clockBase, profiler->gameTimes[1], profiler->gameTimes[2], 212, GPACK_RGBA5551(255, 120, 40, 1)); // draw the profiler for the time it takes for the display lists to send. (blue) - draw_profiler_bar(clock_base, profiler->gameTimes[2], profiler->gameTimes[3], 212, + draw_profiler_bar(clockBase, profiler->gameTimes[2], profiler->gameTimes[3], 212, GPACK_RGBA5551(40, 192, 230, 1)); // we need to get the amount of finished numSoundTimes pairs, so get rid of the odd bit to get the @@ -166,7 +168,7 @@ void draw_profiler_mode_1(void) { // draw the sound update times. (red) for (i = 0; i < profiler->numSoundTimes; i += 2) { - draw_profiler_bar(clock_base, profiler->soundTimes[i], profiler->soundTimes[i + 1], 212, + draw_profiler_bar(clockBase, profiler->soundTimes[i], profiler->soundTimes[i + 1], 212, GPACK_RGBA5551(255, 40, 40, 1)); } @@ -174,10 +176,10 @@ void draw_profiler_mode_1(void) { // it is theoretically possible they might not. In all cases, the RDP should finish later than RSP. // Thus, this is not really a bug in practice, but should still be noted that the C doesn't check // this. - draw_profiler_bar(clock_base, profiler->gfxTimes[0], profiler->gfxTimes[1], 216, + draw_profiler_bar(clockBase, profiler->gfxTimes[0], profiler->gfxTimes[1], 216, GPACK_RGBA5551(255, 255, 40, 1)); // (orange) - draw_profiler_bar(clock_base, profiler->gfxTimes[1], profiler->gfxTimes[2], 216, + draw_profiler_bar(clockBase, profiler->gfxTimes[1], profiler->gfxTimes[2], 216, GPACK_RGBA5551(255, 120, 40, 1)); // like earlier, toss the odd bit. @@ -185,7 +187,7 @@ void draw_profiler_mode_1(void) { // render the vblank time pairs. (red) for (i = 0; i < profiler->numVblankTimes; i += 2) { - draw_profiler_bar(clock_base, profiler->vblankTimes[i], profiler->vblankTimes[i + 1], 216, + draw_profiler_bar(clockBase, profiler->vblankTimes[i], profiler->vblankTimes[i + 1], 216, GPACK_RGBA5551(255, 40, 40, 1)); } @@ -209,29 +211,29 @@ void draw_profiler_mode_0(void) { s32 i; struct ProfilerFrameData *profiler; - u64 clock_start; - u64 level_script_duration; - u64 render_duration; - u64 task_start; - u64 rsp_duration; - u64 rdp_duration; + u64 clockStart; + u64 levelScriptDuration; + u64 renderDuration; + u64 taskStart; + u64 rspDuration; + u64 rdpDuration; u64 vblank; - u64 sound_duration; + u64 soundDuration; // get the last frame profiler. gCurrentFrameIndex1 has the current frame being processed, so // xor it to get the last frame profiler. profiler = &gProfilerFrameData[gCurrentFrameIndex1 ^ 1]; - // was thread 5 ran before thread 4? set the lower one to be the clock_start. - clock_start = profiler->gameTimes[0] <= profiler->soundTimes[0] ? profiler->gameTimes[0] + // was thread 5 ran before thread 4? set the lower one to be the clockStart. + clockStart = profiler->gameTimes[0] <= profiler->soundTimes[0] ? profiler->gameTimes[0] : profiler->soundTimes[0]; // set variables for duration of tasks. - level_script_duration = profiler->gameTimes[1] - clock_start; - render_duration = profiler->gameTimes[2] - profiler->gameTimes[1]; - task_start = 0; - rsp_duration = profiler->gfxTimes[1] - profiler->gfxTimes[0]; - rdp_duration = profiler->gfxTimes[2] - profiler->gfxTimes[0]; + levelScriptDuration = profiler->gameTimes[1] - clockStart; + renderDuration = profiler->gameTimes[2] - profiler->gameTimes[1]; + taskStart = 0; + rspDuration = profiler->gfxTimes[1] - profiler->gfxTimes[0]; + rdpDuration = profiler->gfxTimes[2] - profiler->gfxTimes[0]; vblank = 0; // like above functions, toss the odd bit. @@ -240,15 +242,15 @@ void draw_profiler_mode_0(void) { // sound duration seems to be rendered with empty space and not actually drawn. for (i = 0; i < profiler->numSoundTimes; i += 2) { // calculate sound duration of max - min - sound_duration = profiler->soundTimes[i + 1] - profiler->soundTimes[i]; - task_start += sound_duration; + soundDuration = profiler->soundTimes[i + 1] - profiler->soundTimes[i]; + taskStart += soundDuration; // was the sound time minimum less than level script execution? if (profiler->soundTimes[i] < profiler->gameTimes[1]) { - // overlay the level_script_duration onto the profiler by subtracting the sound_duration. - level_script_duration -= sound_duration; + // overlay the levelScriptDuration onto the profiler by subtracting the soundDuration. + levelScriptDuration -= soundDuration; } else if (profiler->soundTimes[i] < profiler->gameTimes[2]) { - // overlay the render_duration onto the profiler by subtracting the sound_duration. - render_duration -= sound_duration; + // overlay the renderDuration onto the profiler by subtracting the soundDuration. + renderDuration -= soundDuration; } } @@ -266,25 +268,25 @@ void draw_profiler_mode_0(void) { // Draw top profilers. // draw sound duration as the first bar. (red) - clock_start = 0; - draw_profiler_bar(0, clock_start, clock_start + task_start, 212, GPACK_RGBA5551(255, 40, 40, 1)); + clockStart = 0; + draw_profiler_bar(0, clockStart, clockStart + taskStart, 212, GPACK_RGBA5551(255, 40, 40, 1)); // draw level script execution duration. (yellow) - clock_start += task_start; - draw_profiler_bar(0, clock_start, clock_start + level_script_duration, 212, + clockStart += taskStart; + draw_profiler_bar(0, clockStart, clockStart + levelScriptDuration, 212, GPACK_RGBA5551(255, 255, 40, 1)); // draw render duration. (orange) - clock_start += level_script_duration; - draw_profiler_bar(0, clock_start, clock_start + render_duration, 212, + clockStart += levelScriptDuration; + draw_profiler_bar(0, clockStart, clockStart + renderDuration, 212, GPACK_RGBA5551(255, 120, 40, 1)); // Draw bottom profilers. // rdp duration (orange) - draw_profiler_bar(0, 0, rdp_duration, 216, GPACK_RGBA5551(255, 120, 40, 1)); + draw_profiler_bar(0, 0, rdpDuration, 216, GPACK_RGBA5551(255, 120, 40, 1)); // rsp duration (yellow) - draw_profiler_bar(0, 0, rsp_duration, 216, GPACK_RGBA5551(255, 255, 40, 1)); + draw_profiler_bar(0, 0, rspDuration, 216, GPACK_RGBA5551(255, 255, 40, 1)); // vblank duration (red) draw_profiler_bar(0, 0, vblank, 216, GPACK_RGBA5551(255, 40, 40, 1)); diff --git a/src/game/profiler.h b/src/game/profiler.h index 1031e5e1..0bb66a58 100644 --- a/src/game/profiler.h +++ b/src/game/profiler.h @@ -1,5 +1,8 @@ -#ifndef _PROFILER_H -#define _PROFILER_H +#ifndef PROFILER_H +#define PROFILER_H + +#include +#include #include "types.h" @@ -45,4 +48,4 @@ void profiler_log_gfx_time(enum ProfilerGfxEvent eventID); void profiler_log_vblank_time(void); void draw_profiler(void); -#endif /* _PROFILER_H */ +#endif // PROFILER_H diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index a96eafbf..18e70e4a 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -1,15 +1,15 @@ -#include +#include -#include "sm64.h" +#include "area.h" +#include "engine/math_util.h" +#include "game_init.h" #include "gfx_dimensions.h" #include "main.h" -#include "print.h" -#include "engine/math_util.h" -#include "area.h" -#include "shadow.h" #include "memory.h" -#include "game_init.h" +#include "print.h" #include "rendering_graph_node.h" +#include "shadow.h" +#include "sm64.h" /** * This file contains the code that processes the scene graph for rendering. @@ -506,7 +506,11 @@ static void geo_process_background(struct GraphNodeBackground *node) { if (list != 0) { geo_append_display_list((void *) VIRTUAL_TO_PHYSICAL(list), node->fnNode.node.flags >> 8); } else if (gCurGraphNodeMasterList != NULL) { +#ifndef F3DEX_GBI_2E + Gfx *gfxStart = alloc_display_list(sizeof(Gfx) * 7); +#else Gfx *gfxStart = alloc_display_list(sizeof(Gfx) * 8); +#endif Gfx *gfx = gfxStart; gDPPipeSync(gfx++); @@ -702,7 +706,7 @@ static void geo_process_shadow(struct GraphNodeShadow *node) { /** * Check whether an object is in view to determine whether it should be drawn. - * This is known as frustrum culling. + * This is known as frustum culling. * It checks whether the object is far away, very close / behind the camera, * or horizontally out of view. It does not check whether it is vertically * out of view. It assumes a sphere of 300 units around the object's position @@ -717,7 +721,7 @@ static void geo_process_shadow(struct GraphNodeShadow *node) { * static camera instead of a moving camera through a static world, which in * this case simplifies calculations. Note that the perspective matrix is not * on the matrix stack, so there are still calculations with the fov to compute - * the slope of the lines of the frustrum. + * the slope of the lines of the frustum. * * z- * @@ -753,6 +757,8 @@ static int obj_is_in_view(struct GraphNodeObject *node, Mat4 matrix) { // the amount of units between the center of the screen and the horizontal edge // given the distance from the object to the camera. + // This multiplication should really be performed on 4:3 as well, + // but the issue will be more apparent on widescreen. hScreenEdge *= GFX_DIMENSIONS_ASPECT_RATIO; if (geo != NULL && geo->type == GRAPH_NODE_TYPE_CULLING_RADIUS) { diff --git a/src/game/rendering_graph_node.h b/src/game/rendering_graph_node.h index 92e13181..097c7876 100644 --- a/src/game/rendering_graph_node.h +++ b/src/game/rendering_graph_node.h @@ -1,6 +1,8 @@ #ifndef RENDERING_GRAPH_NODE_H #define RENDERING_GRAPH_NODE_H +#include + #include "engine/graph_node.h" extern struct GraphNodeRoot *gCurGraphNodeRoot; @@ -25,7 +27,7 @@ extern u16 gAreaUpdateCounter; // translation types the type is set to this #define ANIM_TYPE_ROTATION 5 -void geo_process_node_and_siblings(struct GraphNode *rootGraphNode); -void geo_process_root(); +void geo_process_node_and_siblings(struct GraphNode *firstNode); +void geo_process_root(struct GraphNodeRoot *node, Vp *b, Vp *c, s32 clearColor); #endif // RENDERING_GRAPH_NODE_H diff --git a/src/game/save_file.c b/src/game/save_file.c index 934b122e..ad700a18 100644 --- a/src/game/save_file.c +++ b/src/game/save_file.c @@ -611,7 +611,7 @@ u32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex) { /** * Add to the bitset of obtained stars in the specified course. - * If course is -1, add ot the bitset of obtained castle secret stars. + * If course is -1, add to the bitset of obtained castle secret stars. */ void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, u32 starFlags) { if (courseIndex == -1) { @@ -743,7 +743,7 @@ s32 check_warp_checkpoint(struct WarpNode *warpNode) { warpNode->destNode = gWarpCheckpoint.warpNode; isWarpCheckpointActive = TRUE; } else { - // Disable the warp checkpoint just incase the other 2 conditions failed? + // Disable the warp checkpoint just in case the other 2 conditions failed? gWarpCheckpoint.courseNum = COURSE_NONE; } diff --git a/src/game/save_file.h b/src/game/save_file.h index 6271b116..3ee5a19a 100644 --- a/src/game/save_file.h +++ b/src/game/save_file.h @@ -1,5 +1,7 @@ -#ifndef _SAVE_FILE_H_ -#define _SAVE_FILE_H_ +#ifndef SAVE_FILE_H +#define SAVE_FILE_H + +#include #include "types.h" #include "area.h" @@ -72,8 +74,6 @@ struct SaveBuffer struct MainMenuSaveData menuData[2]; }; -struct WarpNode; - extern u8 gLastCompletedCourseNum; extern u8 gLastCompletedStarNum; extern s8 sUnusedGotGlobalCoinHiScore; @@ -146,8 +146,8 @@ u16 save_file_get_sound_mode(void); void save_file_move_cap_to_default_location(void); void disable_warp_checkpoint(void); -void check_if_should_set_warp_checkpoint(struct WarpNode *a); -s32 check_warp_checkpoint(struct WarpNode *a); +void check_if_should_set_warp_checkpoint(struct WarpNode *warpNode); +s32 check_warp_checkpoint(struct WarpNode *warpNode); #ifdef VERSION_EU enum EuLanguages { @@ -160,4 +160,4 @@ void eu_set_language(u16 language); u16 eu_get_language(void); #endif -#endif // _SAVE_FILE_H_ +#endif // SAVE_FILE_H diff --git a/src/game/screen_transition.c b/src/game/screen_transition.c index c009abea..b49ddaf5 100644 --- a/src/game/screen_transition.c +++ b/src/game/screen_transition.c @@ -1,16 +1,17 @@ -#include +#include +#include -#include "sm64.h" -#include "gfx_dimensions.h" #include "area.h" -#include "game/game_init.h" -#include "engine/math_util.h" -#include "engine/graph_node.h" -#include "screen_transition.h" -#include "memory.h" -#include "geo_misc.h" -#include "segment2.h" #include "camera.h" +#include "engine/graph_node.h" +#include "engine/math_util.h" +#include "game/game_init.h" +#include "geo_misc.h" +#include "gfx_dimensions.h" +#include "memory.h" +#include "screen_transition.h" +#include "segment2.h" +#include "sm64.h" u8 sTransitionColorFadeCount[4] = { 0 }; u16 sTransitionTextureFadeCount[2] = { 0 }; @@ -183,7 +184,7 @@ s32 render_textured_transition(s8 fadeTimer, s8 transTime, struct WarpTransition gDPPipeSync(gDisplayListHead++); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2); - gDPSetTextureFilter(gDisplayListHead++, G_TF_BILERP); + gDPSetTextureFilter(gDisplayListHead++, G_TF_BILERP); switch (transTexType) { case TRANS_TYPE_MIRROR: gDPLoadTextureBlock(gDisplayListHead++, sTextureTransitionID[texID], G_IM_FMT_IA, G_IM_SIZ_8b, 32, 64, 0, @@ -241,10 +242,8 @@ int render_screen_transition(s8 fadeTimer, s8 transType, u8 transTime, struct Wa } Gfx *render_cannon_circle_base(void) { - Vtx *verts = alloc_display_list(8 * sizeof(*verts)); Gfx *dlist = alloc_display_list(20 * sizeof(*dlist)); - Gfx *g = dlist; if (verts != NULL && dlist != NULL) { @@ -253,6 +252,7 @@ Gfx *render_cannon_circle_base(void) { make_vertex(verts, 2, SCREEN_WIDTH, SCREEN_HEIGHT, -1, 1152, 192, 0, 0, 0, 255); make_vertex(verts, 3, 0, SCREEN_HEIGHT, -1, -1152, 192, 0, 0, 0, 255); + // Render black rectangles outside the 4:3 area. make_vertex(verts, 4, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), 0, -1, 0, 0, 0, 0, 0, 255); make_vertex(verts, 5, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), 0, -1, 0, 0, 0, 0, 0, 255); make_vertex(verts, 6, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), SCREEN_HEIGHT, -1, 0, 0, 0, 0, 0, 255); @@ -281,7 +281,7 @@ Gfx *render_cannon_circle_base(void) { return dlist; } -Gfx *geo_cannon_circle_base(s32 callContext, struct GraphNode *node, UNUSED f32 mtx[4][4]) { +Gfx *geo_cannon_circle_base(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx) { struct GraphNodeGenerated *graphNode = (struct GraphNodeGenerated *) node; Gfx *dlist = NULL; diff --git a/src/game/screen_transition.h b/src/game/screen_transition.h index a56f9aee..aeee7fc8 100644 --- a/src/game/screen_transition.h +++ b/src/game/screen_transition.h @@ -1,6 +1,10 @@ #ifndef SCREEN_TRANSITION_H #define SCREEN_TRANSITION_H +#include +#include + +#include "macros.h" #include "types.h" enum TextureTransitionID @@ -17,7 +21,7 @@ enum TextureTransitionType TRANS_TYPE_CLAMP }; -extern int render_screen_transition(s8 fadeTimer, s8 transType, u8 transTime, struct WarpTransitionData *transData); -extern Gfx *geo_cannon_circle_base(s32 callContext, struct GraphNode *node, UNUSED f32 mtx[4][4]); +int render_screen_transition(s8 fadeTimer, s8 transType, u8 transTime, struct WarpTransitionData *transData); +Gfx *geo_cannon_circle_base(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); -#endif /* SCREEN_TRANSITION_H */ +#endif // SCREEN_TRANSITION_H diff --git a/src/game/segment2.h b/src/game/segment2.h index e1a9c346..7eecce54 100644 --- a/src/game/segment2.h +++ b/src/game/segment2.h @@ -1,10 +1,8 @@ #ifndef SEGMENT2_H #define SEGMENT2_H -#include "types.h" - -extern u8 _segment2_mio0SegmentRomStart[]; -extern u8 _segment2_mio0SegmentRomEnd[]; +#include +#include extern u8 seg2_course_name_table[]; extern u8 seg2_act_name_table[]; @@ -66,4 +64,4 @@ extern Gfx dl_billboard_num_7[]; extern Gfx dl_billboard_num_8[]; extern Gfx dl_billboard_num_9[]; -#endif /* SEGMENT2_H */ +#endif // SEGMENT2_H diff --git a/src/game/segment7.h b/src/game/segment7.h index 7c93e197..6692ac6b 100644 --- a/src/game/segment7.h +++ b/src/game/segment7.h @@ -1,7 +1,8 @@ -#ifndef SEGMENT_7_H -#define SEGMENT_7_H +#ifndef SEGMENT7_H +#define SEGMENT7_H -#include "types.h" +#include +#include // from main menu segment 7 extern u8 dl_menu_idle_hand[]; @@ -28,4 +29,4 @@ extern Gfx *intro_seg7_dl_0700C6A0; extern f32 intro_seg7_table_0700C790[]; extern f32 intro_seg7_table_0700C880[]; -#endif /* SEGMENT_7_H */ +#endif // SEGMENT7_H diff --git a/src/game/shadow.c b/src/game/shadow.c index 5b74545d..5ff6beda 100644 --- a/src/game/shadow.c +++ b/src/game/shadow.c @@ -1,22 +1,17 @@ -#include +#include +#include #include -#include "sm64.h" -#include "shadow.h" - -#include "area.h" -#include "engine/graph_node.h" #include "engine/math_util.h" #include "engine/surface_collision.h" -#include "mario_animation_ids.h" -#include "mario.h" -#include "memory.h" -#include "rendering_graph_node.h" -#include "object_list_processor.h" -#include "segment2.h" -#include "save_file.h" #include "geo_misc.h" #include "level_table.h" +#include "memory.h" +#include "object_list_processor.h" +#include "rendering_graph_node.h" +#include "segment2.h" +#include "shadow.h" +#include "sm64.h" /** * @file shadow.c diff --git a/src/game/shadow.h b/src/game/shadow.h index 33d3a865..36b3ef06 100644 --- a/src/game/shadow.h +++ b/src/game/shadow.h @@ -1,8 +1,8 @@ -#ifndef _SHADOW_H -#define _SHADOW_H +#ifndef SHADOW_H +#define SHADOW_H -#include -#include "types.h" +#include +#include /** * Shadow types. Shadows are circles, squares, or hardcoded rectangles, and @@ -48,7 +48,6 @@ extern s8 gMarioOnIceOrCarpet; * Given the (x, y, z) location of an object, create a shadow below that object * with the given initial solidity and "shadowType" (described above). */ -extern Gfx *create_shadow_below_xyz( - f32 xPos, f32 yPos, f32 zPos, s16 shadowScale, u8 shadowSolidity, s8 shadowType); +Gfx *create_shadow_below_xyz(f32 xPos, f32 yPos, f32 zPos, s16 shadowScale, u8 shadowSolidity, s8 shadowType); -#endif /* _SHADOW_H */ +#endif // SHADOW_H diff --git a/src/game/skybox.c b/src/game/skybox.c index d1f49908..c57feacc 100644 --- a/src/game/skybox.c +++ b/src/game/skybox.c @@ -1,14 +1,14 @@ -#include +#include -#include "sm64.h" -#include "gfx_dimensions.h" -#include "engine/math_util.h" -#include "memory.h" #include "area.h" +#include "engine/math_util.h" +#include "geo_misc.h" +#include "gfx_dimensions.h" +#include "level_update.h" +#include "memory.h" #include "save_file.h" #include "segment2.h" -#include "level_update.h" -#include "geo_misc.h" +#include "sm64.h" /** diff --git a/src/game/skybox.h b/src/game/skybox.h index 3f4e6cd9..39220447 100644 --- a/src/game/skybox.h +++ b/src/game/skybox.h @@ -1,9 +1,11 @@ -#ifndef _SKYBOX_H -#define _SKYBOX_H +#ifndef SKYBOX_H +#define SKYBOX_H -#include "types.h" +#include +#include -extern Gfx *create_skybox_facing_camera(s8 a, s8 background, f32 fov, f32 posX, f32 posY, f32 posZ, - f32 focX, f32 focY, f32 focZ); +Gfx *create_skybox_facing_camera(s8 player, s8 background, f32 fov, + f32 posX, f32 posY, f32 posZ, + f32 focX, f32 focY, f32 focZ); -#endif /* _SKYBOX_H */ +#endif // SKYBOX_H diff --git a/src/game/sound_init.c b/src/game/sound_init.c index ce1042c4..e8627562 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -1,19 +1,19 @@ #include -#include "sm64.h" -#include "seq_ids.h" +#include "area.h" +#include "audio/external.h" +#include "engine/graph_node.h" +#include "engine/math_util.h" +#include "level_table.h" #include "level_update.h" #include "main.h" -#include "engine/math_util.h" -#include "area.h" -#include "profiler.h" -#include "audio/external.h" -#include "print.h" -#include "save_file.h" -#include "sound_init.h" -#include "engine/graph_node.h" #include "paintings.h" -#include "level_table.h" +#include "print.h" +#include "profiler.h" +#include "save_file.h" +#include "seq_ids.h" +#include "sm64.h" +#include "sound_init.h" #include "thread6.h" #define MUSIC_NONE 0xFFFF diff --git a/src/game/sound_init.h b/src/game/sound_init.h index 47e7d0a5..a03c5d84 100644 --- a/src/game/sound_init.h +++ b/src/game/sound_init.h @@ -1,7 +1,9 @@ -#ifndef _SOUND_INIT_H -#define _SOUND_INIT_H +#ifndef SOUND_INIT_H +#define SOUND_INIT_H -#include "types.h" +#include + +#include "macros.h" #define SOUND_MENU_FLAG_HANDAPPEAR 0x01 #define SOUND_MENU_FLAG_HANDISAPPEAR 0x02 @@ -16,25 +18,25 @@ #define SOUND_MENU_MODE_MONO 1 #define SOUND_MENU_MODE_HEADSET 2 -extern void reset_volume(void); -extern void raise_background_noise(s32); -extern void lower_background_noise(s32); -extern void disable_background_sound(void); -extern void enable_background_sound(void); -extern void set_sound_mode(u16); -extern void play_menu_sounds(s16 a); -extern void play_painting_eject_sound(void); -extern void play_infinite_stairs_music(void); -extern void set_background_music(u16, u16, s16); -extern void fadeout_music(s16); -extern void fadeout_level_music(s16 fadeTimer); -extern void play_cutscene_music(u16); -extern void play_shell_music(void); -extern void stop_shell_music(void); -extern void play_cap_music(u16); -extern void fadeout_cap_music(void); -extern void stop_cap_music(void); -extern void audio_game_loop_tick(void); -extern void thread4_sound(void *); +void reset_volume(void); +void raise_background_noise(s32 a); +void lower_background_noise(s32 a); +void disable_background_sound(void); +void enable_background_sound(void); +void set_sound_mode(u16 soundMode); +void play_menu_sounds(s16 soundMenuFlags); +void play_painting_eject_sound(void); +void play_infinite_stairs_music(void); +void set_background_music(u16 a, u16 seqArgs, s16 fadeTimer); +void fadeout_music(s16 fadeOutTime); +void fadeout_level_music(s16 fadeTimer); +void play_cutscene_music(u16 seqArgs); +void play_shell_music(void); +void stop_shell_music(void); +void play_cap_music(u16 seqArgs); +void fadeout_cap_music(void); +void stop_cap_music(void); +void audio_game_loop_tick(void); +void thread4_sound(UNUSED void *arg); -#endif /* _SOUND_INIT_H */ +#endif // SOUND_INIT_H diff --git a/src/game/spawn_object.c b/src/game/spawn_object.c index 79f930f2..ee77f564 100644 --- a/src/game/spawn_object.c +++ b/src/game/spawn_object.c @@ -1,18 +1,17 @@ -#include +#include -#include "sm64.h" -#include "engine/math_util.h" -#include "area.h" +#include "audio/external.h" #include "engine/geo_layout.h" #include "engine/graph_node.h" -#include "object_helpers.h" -#include "engine/behavior_script.h" +#include "engine/math_util.h" #include "engine/surface_collision.h" -#include "audio/external.h" -#include "level_update.h" -#include "spawn_object.h" -#include "object_list_processor.h" #include "level_table.h" +#include "object_constants.h" +#include "object_fields.h" +#include "object_helpers.h" +#include "object_list_processor.h" +#include "spawn_object.h" +#include "types.h" /** * An unused linked list struct that seems to have been replaced by ObjectNode. @@ -28,7 +27,7 @@ struct LinkedList { * Appears to have been replaced by init_free_object_list. */ void unused_init_free_list(struct LinkedList *usedList, struct LinkedList **pFreeList, - struct LinkedList *pool, s32 itemSize, s32 poolLength) { + struct LinkedList *pool, s32 itemSize, s32 poolLength) { s32 i; struct LinkedList *node = pool; @@ -55,7 +54,7 @@ void unused_init_free_list(struct LinkedList *usedList, struct LinkedList **pFre * Appears to have been replaced by try_allocate_object. */ struct LinkedList *unused_try_allocate(struct LinkedList *destList, - struct LinkedList *freeList) { + struct LinkedList *freeList) { struct LinkedList *node = freeList->next; if (node != NULL) { @@ -185,7 +184,7 @@ static void unused_delete_leaf_nodes(struct Object *obj) { * Free the given object. */ void unload_object(struct Object *obj) { - obj->activeFlags = ACTIVE_FLAGS_DEACTIVATED; + obj->activeFlags = ACTIVE_FLAG_DEACTIVATED; obj->prevObj = NULL; obj->header.gfx.throwMatrix = NULL; @@ -294,8 +293,7 @@ struct Object *allocate_object(struct ObjectNode *objList) { } /** - * If the object is close to being on the floor, move it to be exactly on the - * floor. + * If the object is close to being on the floor, move it to be exactly on the floor. */ static void snap_object_to_floor(struct Object *obj) { struct Surface *surface; @@ -309,8 +307,7 @@ static void snap_object_to_floor(struct Object *obj) { } /** - * Spawn an object at the origin with the behavior script at virtual address - * bhvScript. + * Spawn an object at the origin with the behavior script at virtual address bhvScript. */ struct Object *create_object(const BehaviorScript *bhvScript) { s32 objListIndex; @@ -359,5 +356,5 @@ struct Object *create_object(const BehaviorScript *bhvScript) { */ void mark_obj_for_deletion(struct Object *obj) { //! Same issue as obj_mark_for_deletion - obj->activeFlags = ACTIVE_FLAGS_DEACTIVATED; + obj->activeFlags = ACTIVE_FLAG_DEACTIVATED; } diff --git a/src/game/spawn_object.h b/src/game/spawn_object.h index 536a979e..acb9cd03 100644 --- a/src/game/spawn_object.h +++ b/src/game/spawn_object.h @@ -1,8 +1,7 @@ -#ifndef _SPAWN_OBJECT_H -#define _SPAWN_OBJECT_H +#ifndef SPAWN_OBJECT_H +#define SPAWN_OBJECT_H -struct ObjectNode; -struct Object; +#include "types.h" void init_free_object_list(void); void clear_object_lists(struct ObjectNode *objLists); @@ -10,4 +9,4 @@ void unload_object(struct Object *obj); struct Object *create_object(const BehaviorScript *bhvScript); void mark_obj_for_deletion(struct Object *obj); -#endif /* _SPAWN_OBJECT_H */ +#endif // SPAWN_OBJECT_H diff --git a/src/game/spawn_sound.c b/src/game/spawn_sound.c index d23be075..b94dd82d 100644 --- a/src/game/spawn_sound.c +++ b/src/game/spawn_sound.c @@ -1,13 +1,13 @@ -#include +#include -#include "sm64.h" -#include "engine/behavior_script.h" -#include "object_helpers.h" #include "audio/external.h" -#include "spawn_sound.h" -#include "object_list_processor.h" #include "behavior_data.h" +#include "engine/behavior_script.h" #include "engine/graph_node.h" +#include "object_helpers.h" +#include "object_list_processor.h" +#include "sm64.h" +#include "spawn_sound.h" #include "thread6.h" /* @@ -19,7 +19,7 @@ void exec_anim_sound_state(struct SoundState *soundStates) { s32 stateIdx = gCurrentObject->oSoundStateID; switch (soundStates[stateIdx].playSound) { - // since we have an array of sound states cooresponding to + // since we have an array of sound states corresponding to // various behaviors, not all entries intend to play sounds. the // boolean being 0 for unused entries skips these states. case FALSE: @@ -55,9 +55,9 @@ void create_sound_spawner(s32 soundMagic) { } /* - * The following 2 functions are relevent to the sound state function + * The following 2 functions are relevant to the sound state function * above. While only cur_obj_play_sound_2 is used, they may have been intended as - * seperate left/right leg functions that went unused. + * separate left/right leg functions that went unused. */ void cur_obj_play_sound_1(s32 soundMagic) { if (gCurrentObject->header.gfx.node.flags & GRAPH_RENDER_ACTIVE) { @@ -90,7 +90,7 @@ void cur_obj_play_sound_2(s32 soundMagic) { * might show that the developers were testing several ranges, or certain * objects had different ranges, or had these for other unknown purposes. * Technically, these functions are only educated guesses. Trust these - * interpretations at your own discrection. + * interpretations at your own discretion. */ int calc_dist_to_volume_range_1(f32 distance) // range from 60-124 { diff --git a/src/game/spawn_sound.h b/src/game/spawn_sound.h index 6a0bf664..c00a13be 100644 --- a/src/game/spawn_sound.h +++ b/src/game/spawn_sound.h @@ -1,7 +1,7 @@ -#ifndef _SPAWN_SOUND_H -#define _SPAWN_SOUND_H +#ifndef SPAWN_SOUND_H +#define SPAWN_SOUND_H -#include "types.h" +#include struct SoundState { @@ -16,9 +16,9 @@ struct SoundState s32 soundMagic; }; -extern void cur_obj_play_sound_1(s32); -extern void cur_obj_play_sound_2(s32); -extern void create_sound_spawner(s32); -extern void exec_anim_sound_state(struct SoundState *soundStates); +void cur_obj_play_sound_1(s32 soundMagic); +void cur_obj_play_sound_2(s32 soundMagic); +void create_sound_spawner(s32 soundMagic); +void exec_anim_sound_state(struct SoundState *soundStates); -#endif +#endif // SPAWN_SOUND_H diff --git a/src/game/thread6.c b/src/game/thread6.c index fbc9f93a..6cb7a834 100644 --- a/src/game/thread6.c +++ b/src/game/thread6.c @@ -274,4 +274,4 @@ void rumble_thread_update_vi(void) { } // osSendMesg(&gRumbleThreadVIMesgQueue, (OSMesg) 0x56525443, OS_MESG_NOBLOCK); -} \ No newline at end of file +} diff --git a/src/game/thread6.h b/src/game/thread6.h index a13cb142..a19f6746 100644 --- a/src/game/thread6.h +++ b/src/game/thread6.h @@ -1,20 +1,20 @@ -#ifndef _THREAD_6_H -#define _THREAD_6_H +#ifndef THREAD6_H +#define THREAD6_H extern s32 gRumblePakTimer; -extern void init_rumble_pak_scheduler_queue(void); -extern void block_until_rumble_pak_free(void); -extern void release_rumble_pak_control(void); -extern void queue_rumble_data(s16 a0, s16 a1); -extern void func_sh_8024C89C(s16 a0); -extern u8 is_rumble_finished_and_queue_empty(void); -extern void reset_rumble_timers(void); -extern void reset_rumble_timers_2(s32 a0); -extern void func_sh_8024CA04(void); -extern void cancel_rumble(void); -extern void create_thread_6(void); -extern void rumble_thread_update_vi(void); -extern void thread6_rumble_loop(void *a0); +void init_rumble_pak_scheduler_queue(void); +void block_until_rumble_pak_free(void); +void release_rumble_pak_control(void); +void queue_rumble_data(s16 a0, s16 a1); +void func_sh_8024C89C(s16 a0); +u8 is_rumble_finished_and_queue_empty(void); +void reset_rumble_timers(void); +void reset_rumble_timers_2(s32 a0); +void func_sh_8024CA04(void); +void cancel_rumble(void); +void create_thread_6(void); +void rumble_thread_update_vi(void); +void thread6_rumble_loop(void *a0); -#endif // _THREAD_6_H +#endif // THREAD6_H diff --git a/src/goddard/bad_declarations.h b/src/goddard/bad_declarations.h index e7a76e0b..cb66e2ba 100644 --- a/src/goddard/bad_declarations.h +++ b/src/goddard/bad_declarations.h @@ -1,5 +1,5 @@ -#ifndef BAD_DECLARATIONS_H -#define BAD_DECLARATIONS_H +#ifndef GD_BAD_DECLARATIONS_H +#define GD_BAD_DECLARATIONS_H #include "gd_types.h" @@ -37,4 +37,4 @@ extern struct ObjLabel *make_label(); #endif /* !AVOID_UB */ -#endif /* BAD_DECLARATIONS_H */ +#endif // GD_BAD_DECLARATIONS_H diff --git a/src/goddard/debug_utils.c b/src/goddard/debug_utils.c index 6bd07643..10984bbb 100644 --- a/src/goddard/debug_utils.c +++ b/src/goddard/debug_utils.c @@ -1,8 +1,9 @@ -#include +#include #include -#include -#include "gd_types.h" + #include "debug_utils.h" +#include "gd_types.h" +#include "macros.h" #include "renderer.h" // types diff --git a/src/goddard/debug_utils.h b/src/goddard/debug_utils.h index a522b558..89e41d4e 100644 --- a/src/goddard/debug_utils.h +++ b/src/goddard/debug_utils.h @@ -1,8 +1,10 @@ #ifndef GD_DEBUGGING_UTILS_H #define GD_DEBUGGING_UTILS_H -#include +#include + #include "gd_types.h" +#include "macros.h" #define GD_NUM_MEM_TRACKERS 32 #define GD_NUM_TIMERS 32 @@ -67,8 +69,8 @@ extern void restart_timer(const char *); extern void split_timer(const char *); extern void stop_timer(const char *); extern f32 get_scaled_timer_total(const char *); -extern void fatal_print(const char *); -extern void fatal_printf(const char *, ...); +extern void fatal_print(const char *) NORETURN; +extern void fatal_printf(const char *, ...) NORETURN; extern void add_to_stacktrace(const char *); extern void imout(void); extern f32 func_8018D560(void); @@ -88,4 +90,4 @@ extern void gd_fclose(struct GdFile *); extern u32 gd_get_file_size(struct GdFile *); extern s32 gd_fread_line(char *, u32, struct GdFile *); -#endif /* GD_DEBUGGING_UTILS_H */ +#endif // GD_DEBUGGING_UTILS_H diff --git a/src/goddard/draw_objects.c b/src/goddard/draw_objects.c index 63ba0404..e6d24d28 100644 --- a/src/goddard/draw_objects.c +++ b/src/goddard/draw_objects.c @@ -1,17 +1,17 @@ -#include -#include +#include #include -#include "gd_types.h" +#include "debug_utils.h" +#include "dynlist_proc.h" #include "gd_macros.h" #include "gd_main.h" -#include "objects.h" -#include "dynlist_proc.h" -#include "old_menu.h" -#include "debug_utils.h" #include "gd_math.h" -#include "shape_helper.h" +#include "gd_types.h" +#include "macros.h" +#include "objects.h" +#include "old_menu.h" #include "renderer.h" +#include "shape_helper.h" #include "draw_objects.h" #include "gfx_dimensions.h" @@ -480,10 +480,10 @@ void draw_face(struct ObjFace *face) { //! as the struct requests fields passed the end of an ObjVertex. //! The bad code is statically unreachable, so... if (hasTextCoords) { - set_Vtx_tc_buf(((struct BetaVtx *) vtx)->s, ((struct BetaVtx *) vtx)->t); + set_vtx_tc_buf(((struct BetaVtx *) vtx)->s, ((struct BetaVtx *) vtx)->t); } - gbiVtx = make_Vtx_if_new(x, y, z, vtx->alpha); + gbiVtx = make_vtx_if_new(x, y, z, vtx->alpha); if (gbiVtx != NULL) { vtx->gbiVerts = make_vtx_link(vtx->gbiVerts, gbiVtx); diff --git a/src/goddard/draw_objects.h b/src/goddard/draw_objects.h index 7a57f2d7..d2430537 100644 --- a/src/goddard/draw_objects.h +++ b/src/goddard/draw_objects.h @@ -1,7 +1,10 @@ #ifndef GD_DRAW_OBJECTS_H #define GD_DRAW_OBJECTS_H +#include + #include "gd_types.h" +#include "macros.h" // data extern struct ObjCamera *gViewUpdateCamera; @@ -12,25 +15,25 @@ extern u8 gUnref_801B9B30[0x88]; extern struct ObjGroup *gGdLightGroup; // ObjGroup* of ObjLights // functions -extern void draw_light(struct ObjLight *); -extern void draw_material(struct ObjMaterial *); -extern struct GdColour *gd_get_colour(s32); -extern void draw_face(struct ObjFace *); -extern void draw_label(struct ObjLabel *); -extern void draw_net(struct ObjNet *); -extern void draw_gadget(struct ObjGadget *); -extern void draw_camera(struct ObjCamera *); -extern void func_80179B9C(struct GdVec3f *, struct ObjCamera *, struct ObjView *); -extern void nop_obj_draw(struct GdObj *); -extern void draw_particle(struct GdObj *); -extern void draw_bone(struct GdObj *); -extern void draw_joint(struct GdObj *); -extern void draw_group(struct ObjGroup *); -extern void draw_plane(struct GdObj *); -extern void apply_obj_draw_fn(struct GdObj *); -extern void create_gddl_for_shapes(struct ObjGroup *); -extern void map_face_materials(struct ObjGroup *, struct ObjGroup *); -extern void map_vertices(struct ObjGroup *, struct ObjGroup *); -extern void update_view(struct ObjView *); +void draw_light(struct ObjLight *light); +void draw_material(struct ObjMaterial *mtl); +struct GdColour *gd_get_colour(s32 idx); +void draw_face(struct ObjFace *face); +void draw_label(struct ObjLabel *label); +void draw_net(struct ObjNet *self); +void draw_gadget(struct ObjGadget *gdgt); +void draw_camera(struct ObjCamera *cam); +void func_80179B9C(struct GdVec3f *pos, struct ObjCamera *cam, struct ObjView *view); +void nop_obj_draw(UNUSED struct GdObj *nop); +void draw_particle(struct GdObj *obj); +void draw_bone(struct GdObj *obj); +void draw_joint(struct GdObj *obj); +void draw_group(struct ObjGroup *grp); +void draw_plane(struct GdObj *obj); +void apply_obj_draw_fn(struct GdObj *obj); +void create_gddl_for_shapes(struct ObjGroup *grp); +void map_face_materials(struct ObjGroup *faces, struct ObjGroup *mtls); +void map_vertices(struct ObjGroup *facegrp, struct ObjGroup *vtxgrp); +void update_view(struct ObjView *view); -#endif /* GD_DRAW_OBJECTS_H */ +#endif // GD_DRAW_OBJECTS_H diff --git a/src/goddard/dynlist_proc.c b/src/goddard/dynlist_proc.c index 2ffa327a..7621f0e0 100644 --- a/src/goddard/dynlist_proc.c +++ b/src/goddard/dynlist_proc.c @@ -1,21 +1,21 @@ -#include -#include +#include #include -#include "gd_types.h" -#include "bad_declarations.h" -#include "gd_main.h" -#include "draw_objects.h" -#include "objects.h" -#include "particles.h" -#include "dynlist_proc.h" -#include "old_menu.h" +#include "bad_declarations.h" #include "debug_utils.h" -#include "joints.h" -#include "skin.h" +#include "draw_objects.h" +#include "dynlist_proc.h" +#include "gd_main.h" #include "gd_math.h" -#include "shape_helper.h" +#include "gd_types.h" +#include "joints.h" +#include "macros.h" +#include "objects.h" +#include "old_menu.h" +#include "particles.h" #include "renderer.h" +#include "shape_helper.h" +#include "skin.h" /** * @file dynlist_proc.c diff --git a/src/goddard/dynlist_proc.h b/src/goddard/dynlist_proc.h index 6e78ba81..251fb261 100644 --- a/src/goddard/dynlist_proc.h +++ b/src/goddard/dynlist_proc.h @@ -1,7 +1,8 @@ #ifndef GD_DYNLIST_PROCESSOR_H #define GD_DYNLIST_PROCESSOR_H -#include +#include + #include "gd_types.h" // types @@ -56,43 +57,43 @@ enum DObjTypes { }; // functions -extern void push_dynobj_stash(void); -extern void pop_dynobj_stash(void); -extern void reset_dynlist(void); -extern struct GdObj *proc_dynlist(struct DynList *dylist); -extern void d_copystr_to_idbuf(char *); -extern struct GdObj *d_makeobj(enum DObjTypes type, DynId id); -extern void d_set_shapeptrptr(struct ObjShape **); -extern struct GdObj *d_use_obj(DynId); -extern void set_cur_dynobj(); //set_cur_dynobj(struct GdObj *); -extern void d_start_group(DynId); -extern void d_end_group(DynId); -extern void dynid_is_int(s32); -extern void d_set_init_pos(f32, f32, f32); -extern void d_get_init_pos(struct GdVec3f*); -extern void d_get_init_rot(struct GdVec3f*); -extern void d_set_rel_pos(f32, f32, f32); -extern void d_get_rel_pos(struct GdVec3f*); -extern struct ObjGroup* d_get_att_objgroup(void); -extern void d_get_scale(struct GdVec3f*); -extern void d_set_world_pos(f32, f32, f32); -extern void d_get_world_pos(struct GdVec3f *); -extern void d_set_scale(f32, f32, f32); -extern void d_add_valptr(DynId, u32, s32, size_t); -extern void d_add_valproc(union ObjVarVal * (*)(union ObjVarVal *, union ObjVarVal)); -extern void d_set_flags(s32); -extern void d_set_parm_f(enum DParmF, f32); -extern void d_set_parm_ptr(enum DParmPtr, void *); -extern void d_set_obj_draw_flag(enum ObjDrawingFlags); -extern void d_set_type(s32); -extern void d_set_colour_num(s32); -extern void d_set_diffuse(f32, f32, f32); -extern struct GdPlaneF* d_get_plane(void); -extern void d_get_matrix(Mat4f*); -extern Mat4f* d_get_rot_mtx_ptr(void); -extern void d_set_idn_mtx(Mat4f*); -extern Mat4f* d_get_matrix_ptr(void); -extern Mat4f* d_get_idn_mtx_ptr(void); -extern f32 d_calc_world_dist_btwn(struct GdObj *, struct GdObj *); +void push_dynobj_stash(void); +void pop_dynobj_stash(void); +void reset_dynlist(void); +struct GdObj *proc_dynlist(struct DynList *dylist); +void d_copystr_to_idbuf(char *str); +struct GdObj *d_makeobj(enum DObjTypes type, DynId id); +void d_set_shapeptrptr(struct ObjShape **shpPtrptr); +struct GdObj *d_use_obj(DynId id); +void set_cur_dynobj(struct GdObj *obj); +void d_start_group(DynId id); +void d_end_group(DynId id); +void dynid_is_int(s32 isIntBool); +void d_set_init_pos(f32 x, f32 y, f32 z); +void d_get_init_pos(struct GdVec3f *dst); +void d_get_init_rot(struct GdVec3f *dst); +void d_set_rel_pos(f32 x, f32 y, f32 z); +void d_get_rel_pos(struct GdVec3f *dst); +struct ObjGroup *d_get_att_objgroup(void); +void d_get_scale(struct GdVec3f *dst); +void d_set_world_pos(f32 x, f32 y, f32 z); +void d_get_world_pos(struct GdVec3f *dst); +void d_set_scale(f32 x, f32 y, f32 z); +void d_add_valptr(DynId objId, u32 vflags, s32 type, size_t offset); +void d_add_valproc(union ObjVarVal * (*)(union ObjVarVal *, union ObjVarVal)); +void d_set_flags(s32 flags); +void d_set_parm_f(enum DParmF param, f32 val); +void d_set_parm_ptr(enum DParmPtr param, void *ptr); +void d_set_obj_draw_flag(enum ObjDrawingFlags flag); +void d_set_type(s32 type); +void d_set_colour_num(s32 colornum); +void d_set_diffuse(f32 r, f32 g, f32 b); +struct GdPlaneF* d_get_plane(void); +void d_get_matrix(Mat4f *dst); +Mat4f *d_get_rot_mtx_ptr(void); +void d_set_idn_mtx(Mat4f *src); +Mat4f *d_get_matrix_ptr(void); +Mat4f *d_get_idn_mtx_ptr(void); +f32 d_calc_world_dist_btwn(struct GdObj *obj1, struct GdObj *obj2); -#endif /* GD_DYNLIST_PROCESSOR_H */ +#endif // GD_DYNLIST_PROCESSOR_H diff --git a/src/goddard/dynlists/anim_group_1.c b/src/goddard/dynlists/anim_group_1.c index 1d045ab5..a3906796 100644 --- a/src/goddard/dynlists/anim_group_1.c +++ b/src/goddard/dynlists/anim_group_1.c @@ -1,4 +1,5 @@ -#include +#include + #include "animdata.h" #include "../gd_types.h" diff --git a/src/goddard/dynlists/anim_group_2.c b/src/goddard/dynlists/anim_group_2.c index fa3c2cdb..eb4ad001 100644 --- a/src/goddard/dynlists/anim_group_2.c +++ b/src/goddard/dynlists/anim_group_2.c @@ -1,4 +1,5 @@ -#include +#include + #include "animdata.h" #include "../gd_types.h" diff --git a/src/goddard/dynlists/anim_mario_eyebrows_1.c b/src/goddard/dynlists/anim_mario_eyebrows_1.c index b09d64bf..c52ebaf7 100644 --- a/src/goddard/dynlists/anim_mario_eyebrows_1.c +++ b/src/goddard/dynlists/anim_mario_eyebrows_1.c @@ -1,4 +1,5 @@ -#include +#include + #include "animdata.h" #include "../gd_types.h" diff --git a/src/goddard/dynlists/anim_mario_lips_1.c b/src/goddard/dynlists/anim_mario_lips_1.c index f0309207..334f1679 100644 --- a/src/goddard/dynlists/anim_mario_lips_1.c +++ b/src/goddard/dynlists/anim_mario_lips_1.c @@ -1,4 +1,5 @@ -#include +#include + #include "animdata.h" #include "../gd_types.h" diff --git a/src/goddard/dynlists/anim_mario_lips_2.c b/src/goddard/dynlists/anim_mario_lips_2.c index 44bb3bb4..02e19207 100644 --- a/src/goddard/dynlists/anim_mario_lips_2.c +++ b/src/goddard/dynlists/anim_mario_lips_2.c @@ -1,4 +1,5 @@ -#include +#include + #include "animdata.h" #include "../gd_types.h" diff --git a/src/goddard/dynlists/anim_mario_mustache_left.c b/src/goddard/dynlists/anim_mario_mustache_left.c index 1f6aae19..61fd74f3 100644 --- a/src/goddard/dynlists/anim_mario_mustache_left.c +++ b/src/goddard/dynlists/anim_mario_mustache_left.c @@ -1,4 +1,5 @@ -#include +#include + #include "animdata.h" #include "../gd_types.h" diff --git a/src/goddard/dynlists/anim_mario_mustache_right.c b/src/goddard/dynlists/anim_mario_mustache_right.c index 02628d94..6d20451d 100644 --- a/src/goddard/dynlists/anim_mario_mustache_right.c +++ b/src/goddard/dynlists/anim_mario_mustache_right.c @@ -1,4 +1,5 @@ -#include +#include + #include "animdata.h" #include "../gd_types.h" diff --git a/src/goddard/dynlists/animdata.h b/src/goddard/dynlists/animdata.h index f287c901..5e0d01cf 100644 --- a/src/goddard/dynlists/animdata.h +++ b/src/goddard/dynlists/animdata.h @@ -1,5 +1,5 @@ -#ifndef _GD_ANIMATION_DATA_ -#define _GD_ANIMATION_DATA_ +#ifndef GD_ANIMDATA_H +#define GD_ANIMDATA_H #include "../gd_types.h" #define END_ANIMDATA_INFO_ARR { -1, GD_ANIM_EMPTY, NULL } @@ -30,4 +30,4 @@ extern struct AnimDataInfo anim_mario_intro[3]; extern struct AnimDataInfo anim_silver_star[3]; extern struct AnimDataInfo anim_red_star[3]; -#endif /* _GD_ANIMATION_DATA_ */ +#endif // GD_ANIMDATA_H diff --git a/src/goddard/dynlists/dynlist_macros.h b/src/goddard/dynlists/dynlist_macros.h index 9221d95b..9c0c727c 100644 --- a/src/goddard/dynlists/dynlist_macros.h +++ b/src/goddard/dynlists/dynlist_macros.h @@ -1,5 +1,5 @@ -#ifndef _DYN_LIST_MACROS_H_ -#define _DYN_LIST_MACROS_H_ +#ifndef GD_DYNLIST_MACROS_H +#define GD_DYNLIST_MACROS_H /* DynListCmd Macros */ /* Necessary start command for the dynlist. List will not process otherwise. */ @@ -215,7 +215,7 @@ #define CopyStrToIdBuf(w1) \ { 43, {(void *)(w1)}, {0}, {0.0, 0.0, 0.0} } -/* Set f32 paramter PARAM to VALUE. TODO: Ennumerate parameters */ +/* Set f32 paramter PARAM to VALUE. TODO: Enumerate parameters */ /* Supported Objs: shapes, vertices, gadgets */ #define SetParamF(w2, x) \ { 44, {0}, {(void *)(w2)}, {(x), 0.0, 0.0} } @@ -263,4 +263,4 @@ #define MakeNetFromShapeDblPtr(w1) \ { 55, {(void *)(w1)}, {0}, {0.0, 0.0, 0.0} } -#endif /* _DYN_LIST_MACROS_H_ */ +#endif // GD_DYNLIST_MACROS_H diff --git a/src/goddard/dynlists/dynlist_mario_face.c b/src/goddard/dynlists/dynlist_mario_face.c index 4d3f3e00..262f1ca9 100644 --- a/src/goddard/dynlists/dynlist_mario_face.c +++ b/src/goddard/dynlists/dynlist_mario_face.c @@ -1,4 +1,5 @@ -#include +#include + #include "dynlist_macros.h" #include "dynlists.h" #include "../dynlist_proc.h" diff --git a/src/goddard/dynlists/dynlist_mario_master.c b/src/goddard/dynlists/dynlist_mario_master.c index dd24599b..716e07b4 100644 --- a/src/goddard/dynlists/dynlist_mario_master.c +++ b/src/goddard/dynlists/dynlist_mario_master.c @@ -1,4 +1,5 @@ -#include +#include + #include "dynlist_macros.h" #include "dynlists.h" #include "animdata.h" diff --git a/src/goddard/dynlists/dynlist_test_cube.c b/src/goddard/dynlists/dynlist_test_cube.c index 8ccd3f42..cf3f43ec 100644 --- a/src/goddard/dynlists/dynlist_test_cube.c +++ b/src/goddard/dynlists/dynlist_test_cube.c @@ -1,5 +1,6 @@ // early unused test dynlist -#include +#include + #include "dynlist_macros.h" #include "dynlists.h" #include "../dynlist_proc.h" diff --git a/src/goddard/dynlists/dynlist_unused.c b/src/goddard/dynlists/dynlist_unused.c index 7872f527..249fcfec 100644 --- a/src/goddard/dynlists/dynlist_unused.c +++ b/src/goddard/dynlists/dynlist_unused.c @@ -1,7 +1,9 @@ -#include +#include + #include "dynlist_macros.h" #include "dynlists.h" #include "../dynlist_proc.h" + // maybe move types into the dynlists.h file? struct DynList dynlist_unused[62] = { StartList(), diff --git a/src/goddard/dynlists/dynlists.h b/src/goddard/dynlists/dynlists.h index 5c6f9460..d6973075 100644 --- a/src/goddard/dynlists/dynlists.h +++ b/src/goddard/dynlists/dynlists.h @@ -1,5 +1,5 @@ -#ifndef _DYN_LISTS_H_ -#define _DYN_LISTS_H_ +#ifndef GD_DYNLISTS_H +#define GD_DYNLISTS_H #include "../gd_types.h" @@ -13,4 +13,4 @@ extern struct DynList dynlist_mario_eyebrow_left[16]; extern struct DynList dynlist_mario_mustache[16]; extern struct DynList dynlist_mario_master[1026]; -#endif /* _DYN_LISTS_H */ +#endif // GD_DYNLISTS_H diff --git a/src/goddard/dynlists/dynlists_mario_eyebrows_mustache.c b/src/goddard/dynlists/dynlists_mario_eyebrows_mustache.c index 8a399704..7c406087 100644 --- a/src/goddard/dynlists/dynlists_mario_eyebrows_mustache.c +++ b/src/goddard/dynlists/dynlists_mario_eyebrows_mustache.c @@ -1,4 +1,5 @@ -#include +#include + #include "dynlist_macros.h" #include "dynlists.h" #include "../dynlist_proc.h" diff --git a/src/goddard/dynlists/dynlists_mario_eyes.c b/src/goddard/dynlists/dynlists_mario_eyes.c index 71eb19a8..4881f903 100644 --- a/src/goddard/dynlists/dynlists_mario_eyes.c +++ b/src/goddard/dynlists/dynlists_mario_eyes.c @@ -1,4 +1,5 @@ -#include +#include + #include "dynlist_macros.h" #include "dynlists.h" #include "../dynlist_proc.h" diff --git a/src/goddard/gd_macros.h b/src/goddard/gd_macros.h index a1e07a29..9b65978d 100644 --- a/src/goddard/gd_macros.h +++ b/src/goddard/gd_macros.h @@ -1,5 +1,5 @@ -#ifndef GD_COMMON_MACROS_H -#define GD_COMMON_MACROS_H +#ifndef GD_MACROS_H +#define GD_MACROS_H /** * @file gd_macros.h @@ -14,4 +14,4 @@ #define SQ(val) ((val) * (val)) #define ALIGN(VAL_, ALIGNMENT_) (((VAL_) + ((ALIGNMENT_) - 1)) & ~((ALIGNMENT_) - 1)) -#endif /* GD_COMMON_MACROS_H */ +#endif // GD_MACROS_H diff --git a/src/goddard/gd_main.c b/src/goddard/gd_main.c index a9f1a84b..bdf5b8a6 100644 --- a/src/goddard/gd_main.c +++ b/src/goddard/gd_main.c @@ -1,9 +1,10 @@ -#include -#include +#include + +#include "debug_utils.h" #include "gd_main.h" #include "gd_memory.h" +#include "macros.h" #include "objects.h" -#include "debug_utils.h" #include "renderer.h" /* This file was spilt out of debug_memory.asm based on rodata. diff --git a/src/goddard/gd_main.h b/src/goddard/gd_main.h index 3e58d85d..7ec51f48 100644 --- a/src/goddard/gd_main.h +++ b/src/goddard/gd_main.h @@ -1,8 +1,7 @@ #ifndef GD_MAIN_H #define GD_MAIN_H -#include - +#include // In various files of the Goddard subsystem, there are miscellaneous // unused rodata strings. These are likely byproducts of a printf macro @@ -86,4 +85,4 @@ extern s32 gGdUseVtxNormal; extern struct GdControl gGdCtrl; extern struct GdControl gGdCtrlPrev; -#endif /* GD_MAIN_H */ +#endif // GD_MAIN_H diff --git a/src/goddard/gd_math.c b/src/goddard/gd_math.c index 7f24f7e1..0050a753 100644 --- a/src/goddard/gd_math.c +++ b/src/goddard/gd_math.c @@ -1,10 +1,11 @@ -#include -#include -#include "gd_types.h" +#include + +#include "debug_utils.h" #include "gd_macros.h" #include "gd_main.h" #include "gd_math.h" -#include "debug_utils.h" +#include "gd_types.h" +#include "macros.h" #include "renderer.h" /** diff --git a/src/goddard/gd_math.h b/src/goddard/gd_math.h index 59ed83d3..fff705b9 100644 --- a/src/goddard/gd_math.h +++ b/src/goddard/gd_math.h @@ -1,8 +1,10 @@ #ifndef GD_MATH_H #define GD_MATH_H -#include +#include + #include "gd_types.h" +#include "macros.h" struct Row4 { f32 c0, c1, c2, c3; @@ -19,33 +21,36 @@ enum GdRotAxis { }; // Needed for gd_math.c itself. -extern void gd_adjunct_mat4f(Mat4f *, Mat4f *); -extern f32 gd_mat4f_det(Mat4f *); -extern f32 gd_3x3_det(f32, f32, f32, f32, f32, f32, f32, f32, f32); -extern f32 gd_2x2_det(f32, f32, f32, f32); +void gd_adjunct_mat4f(Mat4f *src, Mat4f *dst); +f32 gd_mat4f_det(Mat4f *mtx); +f32 gd_3x3_det(f32 r0c0, f32 r0c1, f32 r0c2, + f32 r1c0, f32 r1c1, f32 r1c2, + f32 r2c0, f32 r2c1, f32 r2c2); +f32 gd_2x2_det(f32 a, f32 b, f32 c, f32 d); -extern void gd_mat4f_lookat(Mat4f *, f32, f32, f32, f32, f32, f32, f32, f32, f32); -extern void gd_scale_mat4f_by_vec3f(Mat4f *, struct GdVec3f *); -extern void gd_rot_mat_about_vec(Mat4f *, struct GdVec3f *); -extern void gd_add_vec3f_to_mat4f_offset(Mat4f *, struct GdVec3f *); -extern void gd_create_origin_lookat(Mat4f *, struct GdVec3f *, f32); -extern f32 gd_clamp_f32(f32, f32); -extern void gd_clamp_vec3f(struct GdVec3f *, f32); -extern void gd_rot_2d_vec(f32, f32 *, f32 *); -extern void gd_absrot_mat4(Mat4f *, s32, f32); -extern f32 gd_vec3f_magnitude(struct GdVec3f *); -extern s32 gd_normalize_vec3f(struct GdVec3f *); -extern void gd_cross_vec3f(struct GdVec3f *a, struct GdVec3f *b, struct GdVec3f *dst); -extern f32 gd_dot_vec3f(struct GdVec3f *, struct GdVec3f *); -extern void gd_inverse_mat4f(Mat4f *, Mat4f *); -extern void gd_create_rot_mat_angular(Mat4f *, struct GdVec3f *, f32); -extern void gd_set_identity_mat4(Mat4f *); -extern void gd_copy_mat4f(const Mat4f *, Mat4f *); -extern void gd_rotate_and_translate_vec3f(struct GdVec3f *, const Mat4f *); -extern void gd_mat4f_mult_vec3f(struct GdVec3f *, const Mat4f *); -extern void gd_mult_mat4f(const Mat4f *, const Mat4f *, Mat4f *); -extern void gd_print_vec(const char *, const struct GdVec3f *); -extern void gd_print_plane(const char *, const struct GdPlaneF *); -extern void gd_print_mtx(const char *, const Mat4f *); +void gd_mat4f_lookat(Mat4f *mtx, f32 xFrom, f32 yFrom, f32 zFrom, f32 xTo, f32 yTo, f32 zTo, + f32 zColY, f32 yColY, f32 xColY); +void gd_scale_mat4f_by_vec3f(Mat4f *mtx, struct GdVec3f *vec); +void gd_rot_mat_about_vec(Mat4f *mtx, struct GdVec3f *vec); +void gd_add_vec3f_to_mat4f_offset(Mat4f *mtx, struct GdVec3f *vec); +void gd_create_origin_lookat(Mat4f *mtx, struct GdVec3f *vec, f32 roll); +f32 gd_clamp_f32(f32 a, f32 b); +void gd_clamp_vec3f(struct GdVec3f *vec, f32 limit); +void gd_rot_2d_vec(f32 deg, f32 *x, f32 *y); +void gd_absrot_mat4(Mat4f *mtx, s32 axisnum, f32 ang); +f32 gd_vec3f_magnitude(struct GdVec3f *vec); +s32 gd_normalize_vec3f(struct GdVec3f *vec); +void gd_cross_vec3f(struct GdVec3f *a, struct GdVec3f *b, struct GdVec3f *dst); +f32 gd_dot_vec3f(struct GdVec3f *a, struct GdVec3f *b); +void gd_inverse_mat4f(Mat4f *src, Mat4f *dst); +void gd_create_rot_mat_angular(Mat4f *mtx, struct GdVec3f *vec, f32 ang); +void gd_set_identity_mat4(Mat4f *mtx); +void gd_copy_mat4f(const Mat4f *src, Mat4f *dst); +void gd_rotate_and_translate_vec3f(struct GdVec3f *vec, const Mat4f *mtx); +void gd_mat4f_mult_vec3f(struct GdVec3f *vec, const Mat4f *mtx); +void gd_mult_mat4f(const Mat4f *mA, const Mat4f *mB, Mat4f *dst); +void gd_print_vec(UNUSED const char *prefix, const struct GdVec3f *vec); +void gd_print_plane(UNUSED const char *prefix, const struct GdPlaneF *p); +void gd_print_mtx(UNUSED const char *prefix, const Mat4f *mtx); -#endif /* GD_MATH_H */ +#endif // GD_MATH_H diff --git a/src/goddard/gd_memory.c b/src/goddard/gd_memory.c index b2de3adb..5d0d1509 100644 --- a/src/goddard/gd_memory.c +++ b/src/goddard/gd_memory.c @@ -1,6 +1,7 @@ -#include -#include "gd_memory.h" +#include + #include "debug_utils.h" +#include "gd_memory.h" #include "renderer.h" /** diff --git a/src/goddard/gd_memory.h b/src/goddard/gd_memory.h index a4973e50..ea6e6ff7 100644 --- a/src/goddard/gd_memory.h +++ b/src/goddard/gd_memory.h @@ -1,7 +1,7 @@ #ifndef GD_MEMORY_H #define GD_MEMORY_H -#include +#include /// A structure that holds information about memory allocation on goddard's heap. struct GMemBlock { @@ -32,4 +32,4 @@ extern struct GMemBlock *gd_add_mem_to_heap(u32 size, void *addr, u8 permanence) extern void init_mem_block_lists(void); extern void mem_stats(void); -#endif /* GD_MEMORY_H */ +#endif // GD_MEMORY_H diff --git a/src/goddard/gd_tex_dl.h b/src/goddard/gd_tex_dl.h deleted file mode 100644 index 0cbdd0c7..00000000 --- a/src/goddard/gd_tex_dl.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef GD_TEXTURE_DL_H -#define GD_TEXTURE_DL_H - -#include - -/** - * @file gd_tex_dl.h - * - * Data arrays that were probably in u16 C arrays in `renderer`, - * but it is easier to leave these as ALIGNED8 u8 arrays in C. - */ - -extern Gfx *redStarDlArray[]; -extern Gfx *silverStarDlArray[]; -extern Gfx *redSparkleDlArray[]; -extern Gfx *silverSparkleDlArray[]; -extern Gfx marioHeadDl801B5170[]; -extern Gfx marioHeadDl801B5188[]; -extern Gfx marioHeadDl801B5100[]; -extern f32 D_801B520C; -extern u16 textureHandOpen[]; -extern u16 textureHandClosed[]; -extern Gfx marioHeadDl801B52D8[]; - -#endif /* GD_TEXTURE_DL_H */ diff --git a/src/goddard/gd_types.h b/src/goddard/gd_types.h index 82ce794a..0857cc06 100644 --- a/src/goddard/gd_types.h +++ b/src/goddard/gd_types.h @@ -629,4 +629,4 @@ struct ObjUnk200000 { /* 0x34 */ struct ObjFace *unk34; //not sure; guessing for Unknown801781DC }; /* sizeof = 0x38*/ -#endif /* GD_TYPES_H */ +#endif // GD_TYPES_H diff --git a/src/goddard/joints.c b/src/goddard/joints.c index 55786a66..7d4e49e6 100644 --- a/src/goddard/joints.c +++ b/src/goddard/joints.c @@ -1,23 +1,23 @@ -#include -#include +#include + #ifdef VERSION_EU #include "prevent_bss_reordering.h" #endif - -#include "gd_types.h" -#include "gd_macros.h" -#include "joints.h" -#include "gd_main.h" -#include "sfx.h" -#include "draw_objects.h" -#include "objects.h" -#include "skin_movement.h" -#include "dynlist_proc.h" #include "debug_utils.h" -#include "skin.h" +#include "draw_objects.h" +#include "dynlist_proc.h" +#include "gd_macros.h" +#include "gd_main.h" #include "gd_math.h" +#include "gd_types.h" +#include "joints.h" +#include "macros.h" +#include "objects.h" #include "renderer.h" +#include "sfx.h" +#include "skin.h" +#include "skin_movement.h" // data static s32 D_801A82D0 = 0; @@ -120,7 +120,7 @@ void Proc8018E520(struct ObjJoint *self) { } /* 23D3B8 -> 23D62C */ -void Proc8018EBE8(struct ObjJoint *self) { +void func_8018EBE8(struct ObjJoint *self) { Mat4f *sp5C; struct GdVec3f sp50; struct GdVec3f sp44; @@ -138,7 +138,7 @@ void Proc8018EBE8(struct ObjJoint *self) { } } - set_cur_dynobj(self); + set_cur_dynobj((struct GdObj *)self); sp5C = d_get_rot_mtx_ptr(); sp44.x = (*sp5C)[3][0]; sp44.y = (*sp5C)[3][1]; @@ -168,7 +168,7 @@ void Proc8018EBE8(struct ObjJoint *self) { } /* 23D62C -> 23D748; not called */ -void Unknown8018EE5C(struct ObjJoint *j1, struct ObjJoint *j2, struct ObjJoint *j3) { +void func_8018EE5C(struct ObjJoint *j1, struct ObjJoint *j2, struct ObjJoint *j3) { struct GdVec3f vec; struct ObjJoint *curj; @@ -301,7 +301,7 @@ void func_8018F328(struct ObjBone *b) { } /* 23DC9C -> 23DCF0 */ -void Unknown8018F4CC(struct ObjJoint *j) { +void func_8018F4CC(struct ObjJoint *j) { if (j->unk1BC & 0x1000) { j->unkB4.x = D_801BA968.x; j->unkB4.y = D_801BA968.y; @@ -370,7 +370,7 @@ void func_8018F520(struct ObjBone *b) { D_801BA968.z = b->mat70[2][2]; D_801BA964 = &b->mat70; - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown8018F4CC, b->unk10C); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_8018F4CC, b->unk10C); } /* 23E06C -> 23E238 */ @@ -400,11 +400,11 @@ void func_8018F89C(struct ObjBone *b) { D_801BA968.z = -b->mat70[2][2]; D_801BA964 = &b->mat70; - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown8018F4CC, b->unk10C); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_8018F4CC, b->unk10C); } /* 23E238 -> 23E298 */ -void Unknown8018FA68(struct ObjBone *b) { +void func_8018FA68(struct ObjBone *b) { if (b->unk104 & (0x8 | 0x2)) { func_8018F89C(b); } else { @@ -505,11 +505,11 @@ struct ObjBone *make_bone(s32 a0, struct ObjJoint *j1, struct ObjJoint *j2, UNUS } /* 23E6E4 -> 23E6F8; not called */ -void Unknown8018FF14(UNUSED u32 a0) { +void func_8018FF14(UNUSED u32 a0) { } /* 23E6F8 -> 23E758; not called */ -void Unknown8018FF28(struct ObjJoint *a0, struct ObjJoint *a1) { +void func_8018FF28(struct ObjJoint *a0, struct ObjJoint *a1) { if (a1->unk1BC & 0x1) { a0->unk84.x -= a1->unk84.x; a0->unk84.y -= a1->unk84.y; @@ -518,7 +518,7 @@ void Unknown8018FF28(struct ObjJoint *a0, struct ObjJoint *a1) { } /* 23E758 -> 23E7B8; not called */ -void Unknown8018FF88(s32 size) { +void func_8018FF88(s32 size) { s32 i; for (i = 0; i < size - 1; i++) { @@ -763,7 +763,7 @@ void func_801909B4(void) { } /* 23F1F0 -> 23F324; not called */ -void Unknown80190A20(void) { +void func_80190A20(void) { struct ObjJoint *j; // sp3c UNUSED u32 pad38; struct GdVec3f vec; // sp2C @@ -851,7 +851,7 @@ void func_80190B54(struct ObjJoint *a0, struct ObjJoint *a1, struct GdVec3f *a2) } /* 23F638 -> 23F70C; not called */ -void Unknown80190E68(struct GdObj *obj, f32 x, f32 y, f32 z) { +void func_80190E68(struct GdObj *obj, f32 x, f32 y, f32 z) { struct ObjJoint *sp44; struct GdObj *sp40; struct GdVec3f vec; // sp34 @@ -914,7 +914,7 @@ f32 func_80190F3C(struct ObjJoint *a0, f32 a1, f32 a2, f32 a3) { } /* 23F978 -> 23F9F0 */ -void Unknown801911A8(struct ObjJoint *j) { +void func_801911A8(struct ObjJoint *j) { j->unkCC.x = j->unkC0.x; // storing "shape offset"? j->unkCC.y = j->unkC0.y; j->unkCC.z = j->unkC0.z; @@ -923,7 +923,7 @@ void Unknown801911A8(struct ObjJoint *j) { } /* 23F9F0 -> 23FB90 */ -void Unknown80191220(struct ObjJoint *j) { +void func_80191220(struct ObjJoint *j) { j->unk48.x = j->unk54.x; // storing "attached offset"? j->unk48.y = j->unk54.y; j->unk48.z = j->unk54.z; @@ -944,13 +944,13 @@ void Unknown80191220(struct ObjJoint *j) { } /* 23FB90 -> 23FBC0 */ -void Unknown801913C0(struct ObjJoint *j) { +void func_801913C0(struct ObjJoint *j) { UNUSED u32 pad[4]; func_80181894(j); } /* 23FBC0 -> 23FCC8 */ -void Unknown801913F0(struct ObjJoint *j) { +void func_801913F0(struct ObjJoint *j) { j->unk78.x = j->unk14.x; j->unk78.y = j->unk14.y; j->unk78.z = j->unk14.z; @@ -967,11 +967,11 @@ void Unknown801913F0(struct ObjJoint *j) { } /* 23FCC8 -> 23FCDC */ -void Unknown801914F8(UNUSED struct ObjJoint *j) { +void func_801914F8(UNUSED struct ObjJoint *j) { } /* 23FCDC -> 23FDD4; not called */ -void Unknown8019150C(Mat4f *a0, struct GdVec3f *a1) { +void func_8019150C(Mat4f *a0, struct GdVec3f *a1) { struct GdVec3f sp1C; sp1C.x = (*a0)[3][0] / 10.0; //? 10.0f @@ -1014,7 +1014,7 @@ void func_80191604(struct ObjJoint *j) { } /* 23FFF4 -> 2400C4 */ -void Unknown80191824(struct ObjJoint *j) { +void func_80191824(struct ObjJoint *j) { UNUSED struct ObjNet *sp14; UNUSED u32 pad00[4]; @@ -1031,7 +1031,7 @@ void Unknown80191824(struct ObjJoint *j) { } /* 2400C4 -> 2401EC; not called */ -void Unknown801918F4(struct ObjJoint *j) { +void func_801918F4(struct ObjJoint *j) { f32 sp4; j->unk78.x = j->unk3C.x; @@ -1058,7 +1058,7 @@ void Unknown801918F4(struct ObjJoint *j) { } /* 2401EC -> 2403C8; not called */ -void Unknown80191A1C(struct ObjBone *a0) { +void func_80191A1C(struct ObjBone *a0) { f32 sp3C; f32 sp38 = 0.0f; struct GdObj *argjoint; @@ -1094,7 +1094,7 @@ void Unknown80191A1C(struct ObjBone *a0) { } /* 2403C8 -> 240530 */ -void Unknown80191BF8(struct ObjJoint *j) { +void func_80191BF8(struct ObjJoint *j) { f32 sp1C; f32 sp18 = -2.0f; @@ -1112,7 +1112,7 @@ void Unknown80191BF8(struct ObjJoint *j) { } /* 240530 -> 240624 */ -void Unknown80191D60(struct ObjJoint *j) { +void func_80191D60(struct ObjJoint *j) { j->unk78.x += j->unk3C.x - j->unk14.x; j->unk78.y += j->unk3C.y - j->unk14.y; j->unk78.z += j->unk3C.z - j->unk14.z; @@ -1127,7 +1127,7 @@ void Unknown80191D60(struct ObjJoint *j) { } /* 240624 -> 240658 */ -void Unknown80191E54(struct ObjJoint *j) { +void func_80191E54(struct ObjJoint *j) { j->unk3C.x = j->unk14.x; j->unk3C.y = j->unk14.y; j->unk3C.z = j->unk14.z; @@ -1135,9 +1135,9 @@ void Unknown80191E54(struct ObjJoint *j) { /* 240658 -> 2406B8 */ void func_80191E88(struct ObjGroup *grp) { - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown80191BF8, grp); - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown80191D60, grp); - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown80191E54, grp); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_80191BF8, grp); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_80191D60, grp); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_80191E54, grp); } /* 2406B8 -> 2406E0; orig name: func_80191EE8 */ diff --git a/src/goddard/joints.h b/src/goddard/joints.h index fa6e59ae..719f4745 100644 --- a/src/goddard/joints.h +++ b/src/goddard/joints.h @@ -1,30 +1,31 @@ -#ifndef GD_JOINTS_H_ -#define GD_JOINTS_H_ +#ifndef GD_JOINTS_H +#define GD_JOINTS_H + +#include -#include #include "gd_types.h" // bss extern s32 sTargetWeightID; // functions -extern void Proc8018EBE8(struct ObjJoint *); -extern struct ObjJoint * make_joint(s32, f32, f32, f32); -extern struct ObjJoint * make_joint_withshape(struct ObjShape *, s32, f32, f32, f32); -extern void func_8018F328(struct ObjBone *); -extern void Unknown8018FA68(struct ObjBone *); -extern s32 set_skin_weight(struct ObjJoint *, s32, struct ObjVertex *, f32); -extern void func_8018FB58(struct ObjBone *); -extern void add_joint2bone(struct ObjBone *, struct ObjJoint *); -extern struct ObjBone * make_bone(s32, struct ObjJoint *, struct ObjJoint *, s32); -extern void Unknown801911A8(struct ObjJoint *); -extern void Unknown80191220(struct ObjJoint *); -extern void Unknown801913C0(struct ObjJoint *); -extern void Unknown801913F0(struct ObjJoint *); -extern void Unknown801914F8(struct ObjJoint *); -extern void func_80191604(struct ObjJoint *); -extern void Unknown80191824(struct ObjJoint *); -extern void func_80191E88(struct ObjGroup *); -extern void reset_joint_counts(void); +void func_8018EBE8(struct ObjJoint *self); +struct ObjJoint *make_joint(s32 flags, f32 x, f32 y, f32 z); +struct ObjJoint *make_joint_withshape(struct ObjShape *shape, s32 flags, f32 x, f32 y, f32 z); +void func_8018F328(struct ObjBone *b); +void func_8018FA68(struct ObjBone *b); +s32 set_skin_weight(struct ObjJoint *j, s32 id, struct ObjVertex *vtx, f32 weight); +void func_8018FB58(struct ObjBone *b); +void add_joint2bone(struct ObjBone *b, struct ObjJoint *j); +struct ObjBone *make_bone(s32 a0, struct ObjJoint *j1, struct ObjJoint *j2, s32 a3); +void func_801911A8(struct ObjJoint *j); +void func_80191220(struct ObjJoint *j); +void func_801913C0(struct ObjJoint *j); +void func_801913F0(struct ObjJoint *j); +void func_801914F8(struct ObjJoint *j); +void func_80191604(struct ObjJoint *j); +void func_80191824(struct ObjJoint *j); +void func_80191E88(struct ObjGroup *grp); +void reset_joint_counts(void); -#endif /* GD_JOINTS_H_ */ +#endif // GD_JOINTS_H diff --git a/src/goddard/objects.c b/src/goddard/objects.c index 8fee024e..46000fd1 100644 --- a/src/goddard/objects.c +++ b/src/goddard/objects.c @@ -1,24 +1,24 @@ -#include +#include #include #include -#include -#include "gd_types.h" -#include "gd_macros.h" - -#include "gd_main.h" -#include "sfx.h" -#include "draw_objects.h" #include "objects.h" -#include "particles.h" -#include "dynlist_proc.h" -#include "old_menu.h" + #include "debug_utils.h" -#include "joints.h" -#include "skin.h" +#include "draw_objects.h" +#include "dynlist_proc.h" +#include "gd_macros.h" +#include "gd_main.h" #include "gd_math.h" -#include "shape_helper.h" +#include "gd_types.h" +#include "joints.h" +#include "macros.h" +#include "old_menu.h" +#include "particles.h" #include "renderer.h" +#include "sfx.h" +#include "shape_helper.h" +#include "skin.h" // structs struct Unk801B9E68 { @@ -328,7 +328,7 @@ struct GdObj *make_object(enum ObjTypeFlag objType) { return newObj; } -/* @ 22AEA0 for 0xD0; orig name: Unknown8017C6D0 */ +/* @ 22AEA0 for 0xD0; orig name: func_8017C6D0 */ struct ObjZone *make_zone(struct ObjGroup *a0, struct GdPlaneF *a1, struct ObjGroup *a2) { struct ObjZone *newZone = (struct ObjZone *) make_object(OBJ_TYPE_ZONES); @@ -349,7 +349,7 @@ struct ObjZone *make_zone(struct ObjGroup *a0, struct GdPlaneF *a1, struct ObjGr } /* @ 22AF70 for 0x60 */ -struct ObjUnk200000 *Unknown8017C7A0(struct ObjVertex *a0, struct ObjFace *a1) { +struct ObjUnk200000 *func_8017C7A0(struct ObjVertex *a0, struct ObjFace *a1) { struct ObjUnk200000 *sp1C = (struct ObjUnk200000 *) make_object(OBJ_TYPE_UNK200000); sp1C->unk30 = a0; @@ -968,7 +968,7 @@ void show_details(enum ObjTypeFlag type) { } } /* @ 22C9B8 for 0x24 */ -s32 Unknown8017E1E8(void) { +s32 func_8017E1E8(void) { s32 sp4 = 0; return sp4; } @@ -999,7 +999,7 @@ void func_8017E2B8(void) { } /* @ 22CAC0 for 0xF0 */ -struct GdObj *UnknownRecursive8017E2F0(struct GdObj *obj, enum ObjTypeFlag type) { +struct GdObj *func_8017E2F0(struct GdObj *obj, enum ObjTypeFlag type) { UNUSED u32 sp2C; enum ObjTypeFlag curObjType; struct Links *curGroupLink; @@ -1010,7 +1010,7 @@ struct GdObj *UnknownRecursive8017E2F0(struct GdObj *obj, enum ObjTypeFlag type) case OBJ_TYPE_GROUPS: curGroupLink = ((struct ObjGroup *) obj)->link1C; while (curGroupLink != NULL) { - UnknownRecursive8017E2F0(curGroupLink->obj, type); + func_8017E2F0(curGroupLink->obj, type); curGroupLink = curGroupLink->next; } break; @@ -1190,7 +1190,7 @@ void func_8017E9EC(struct ObjNet *a0) { } /* @ 22D264 for 0x90 */ -s32 Unknown8017EA94(struct GdVec3f *vec, Mat4f matrix) { +s32 func_8017EA94(struct GdVec3f *vec, Mat4f matrix) { if (vec->x >= matrix[2][2] && vec->x <= matrix[3][1] && vec->z >= matrix[3][0] && vec->z <= matrix[3][3]) { return 1; @@ -1200,7 +1200,7 @@ s32 Unknown8017EA94(struct GdVec3f *vec, Mat4f matrix) { } /* @ 22D2F4 for 0x1DC */ -s32 Unknown8017EB24(struct GdObj *a0, struct GdObj *a1) { +s32 func_8017EB24(struct GdObj *a0, struct GdObj *a1) { struct GdVec3f sp44; struct GdVec3f sp38; struct GdPlaneF *sp34; @@ -1240,7 +1240,7 @@ s32 Unknown8017EB24(struct GdObj *a0, struct GdObj *a1) { } /* @ 22D4D0 for 0xCC */ -s32 Unknown8017ED00(struct GdObj *a0, struct GdPlaneF *a1) { +s32 func_8017ED00(struct GdObj *a0, struct GdPlaneF *a1) { struct GdVec3f sp1C; set_cur_dynobj(a0); @@ -1260,7 +1260,7 @@ s32 Unknown8017ED00(struct GdObj *a0, struct GdPlaneF *a1) { } /* @ 22D59C for 0x90 */ -s32 Unknown8017EDCC(struct GdVec3f *a0, struct GdPlaneF *a1) { +s32 func_8017EDCC(struct GdVec3f *a0, struct GdPlaneF *a1) { if (a0->x >= a1->p0.x) { if (a0->x <= a1->p1.x) { if (a0->z >= a1->p0.z) { @@ -1274,7 +1274,7 @@ s32 Unknown8017EDCC(struct GdVec3f *a0, struct GdPlaneF *a1) { return 0; } -/* @ 22D62C for 0x1F8; orig name: Unknown8017EE5C */ +/* @ 22D62C for 0x1F8; orig name: func_8017EE5C */ s32 gd_plane_point_within(struct GdPlaneF *a0, struct GdPlaneF *a1) { if (a0->p0.x >= a1->p0.x) { if (a0->p0.x <= a1->p1.x) { @@ -1373,7 +1373,7 @@ s32 func_8017F054(struct GdObj *a0, struct GdObj *a1) { } /* @ 22D9E0 for 0x1BC */ -s32 UnknownRecursive8017F210(struct GdObj *a0, struct GdObj *a1) { +s32 func_8017F210(struct GdObj *a0, struct GdObj *a1) { struct Links *sp6C; struct ObjGroup *sp68; UNUSED u32 sp64; @@ -1417,7 +1417,7 @@ s32 UnknownRecursive8017F210(struct GdObj *a0, struct GdObj *a1) { if (sp68 != NULL) { sp6C = sp68->link1C; while (sp6C != NULL) { - count += UnknownRecursive8017F210(sp6C->obj, a0); + count += func_8017F210(sp6C->obj, a0); sp6C = sp6C->next; } } @@ -1425,7 +1425,7 @@ s32 UnknownRecursive8017F210(struct GdObj *a0, struct GdObj *a1) { } /* @ 22DB9C for 0x38; a0 might be ObjUnk200000* */ -void Unknown8017F3CC(struct Unk8017F3CC *a0) { +void func_8017F3CC(struct Unk8017F3CC *a0) { gd_rotate_and_translate_vec3f(&a0->unk20, D_801B9E48); } @@ -1460,7 +1460,7 @@ void func_8017F424(struct GdTriangleF *a0, struct GdTriangleF *a1, f32 a2) { d_set_idn_mtx(&sp40); } -/* @ 22DD94 for 0x1060; orig name: Unknown8017F5C4 */ +/* @ 22DD94 for 0x1060; orig name: func_8017F5C4 */ void move_animator(struct ObjAnimator *animObj) { struct AnimDataInfo *animData; // array? Mat4f *mtxArr; @@ -1695,7 +1695,7 @@ void move_animator(struct ObjAnimator *animObj) { } } -/* @ 22EDF4 for 0x300; orig name: Unknown80180624 */ +/* @ 22EDF4 for 0x300; orig name: func_80180624 */ void drag_picked_object(struct GdObj *inputObj) { UNUSED u32 spE4; UNUSED u32 spE0; @@ -1772,7 +1772,7 @@ void find_and_drag_picked_object(struct ObjGroup *group) { apply_to_obj_types_in_group(OBJ_TYPE_ALL, (applyproc_t) drag_picked_object, group); } -/* @ 22F180 for 0x624; orig name: Unknown801809B0 */ +/* @ 22F180 for 0x624; orig name: func_801809B0 */ void move_camera(struct ObjCamera *cam) { struct GdObj *spEC; struct GdVec3f spE0; @@ -1898,7 +1898,7 @@ void move_cameras_in_grp(struct ObjGroup *group) { } /* @ 22F7DC for 0x36C*/ -void Unknown8018100C(struct ObjLight *light) { +void func_8018100C(struct ObjLight *light) { Mat4f mtx; UNUSED u32 pad1C[3]; @@ -1959,7 +1959,7 @@ void Unknown8018100C(struct ObjLight *light) { /* @ 22FB48 for 0x38; orig name: func_80181378 */ void move_lights_in_grp(struct ObjGroup *group) { - apply_to_obj_types_in_group(OBJ_TYPE_LIGHTS, (applyproc_t) Unknown8018100C, group); + apply_to_obj_types_in_group(OBJ_TYPE_LIGHTS, (applyproc_t) func_8018100C, group); } /* @ 22FB80 for 0xAC; orig name: func_801813B0 */ diff --git a/src/goddard/objects.h b/src/goddard/objects.h index 5bcf6242..9719f7db 100644 --- a/src/goddard/objects.h +++ b/src/goddard/objects.h @@ -1,8 +1,10 @@ #ifndef GD_OBJECTS_H #define GD_OBJECTS_H -#include +#include + #include "gd_types.h" +#include "macros.h" // types // Type to erase for func arg to `apply_to_obj_types_in_group`. Maybe one day this @@ -46,61 +48,61 @@ extern struct GdObj* gGdObjectList; extern struct ObjGroup* gGdViewsGroup; // functions -extern void func_8017BCB0(void); -extern void func_8017BD20(void*); -extern void func_8017BE60(struct GdPlaneF*); -extern void func_8017BED0(struct ObjGroup *, struct GdObj *); -extern const char* get_obj_name_str(enum ObjTypeFlag); -extern struct GdObj * make_object(enum ObjTypeFlag); -extern struct ObjZone * make_zone(struct ObjGroup *, struct GdPlaneF *, struct ObjGroup *); -extern struct ObjUnk200000 * Unknown8017C7A0(struct ObjVertex *, struct ObjFace *); -extern struct Links * make_link_to_obj(struct Links*, struct GdObj*); -extern struct VtxLink * make_vtx_link(struct VtxLink *, Vtx *); -extern struct ObjValPtrs* make_valptrs(struct GdObj *, s32, enum ValPtrType, size_t); -extern void reset_plane(struct ObjPlane*); -extern struct ObjPlane* make_plane(s32, struct ObjFace*); -extern struct ObjCamera* make_camera(s32, struct GdObj*); -extern struct ObjMaterial* make_material(UNUSED s32, char*, s32); -extern struct ObjLight* make_light(s32, char*, s32); -extern struct ObjView* make_view(const char *, s32, s32, s32, s32, s32, s32, struct ObjGroup*); -extern struct ObjAnimator* make_animator(void); -extern struct ObjWeight* make_weight(UNUSED s32, s32, struct ObjVertex*, f32); -extern struct ObjGroup* make_group_of_type(enum ObjTypeFlag, struct GdObj*, struct GdObj*); -extern void sprint_obj_id(char*, struct GdObj*); -extern struct ObjGroup* make_group(s32 count, ...); -extern void addto_group(struct ObjGroup*, struct GdObj*); -extern void addto_groupfirst(struct ObjGroup*, struct GdObj*); -extern s32 group_contains_obj(struct ObjGroup*, struct GdObj*); -extern void show_details(enum ObjTypeFlag); -extern s32 Unknown8017E1E8(void); -extern s32 func_8017E20C(void); -extern void gd_loadtexture(struct GdObj*); -extern void func_8017E2B8(void); -extern struct GdObj* UnknownRecursive8017E2F0(struct GdObj*, enum ObjTypeFlag); -extern s32 apply_to_obj_types_in_group(s32, applyproc_t, struct ObjGroup *); -extern void func_8017E584(struct ObjNet*, struct GdVec3f*, struct GdVec3f*); -extern void func_8017E838(struct ObjNet*, struct GdVec3f*, struct GdVec3f*); -extern void func_8017E9EC(struct ObjNet*); -extern s32 Unknown8017EA94(struct GdVec3f*, Mat4f); -extern s32 Unknown8017EB24(struct GdObj*, struct GdObj*); -extern s32 Unknown8017ED00(struct GdObj*, struct GdPlaneF*); -extern s32 Unknown8017EDCC(struct GdVec3f*, struct GdPlaneF*); -extern s32 gd_plane_point_within(struct GdPlaneF*, struct GdPlaneF*); -extern s32 func_8017F054(struct GdObj*, struct GdObj*); -extern s32 UnknownRecursive8017F210(struct GdObj*, struct GdObj*); -extern void func_8017F404(f32, struct GdObj*, struct GdObj*); -extern void func_8017F424(struct GdTriangleF*, struct GdTriangleF*, f32); -extern void move_animator(struct ObjAnimator*); -extern void drag_picked_object(struct GdObj*); -extern void move_animators(struct ObjGroup *); -extern void find_and_drag_picked_object(struct ObjGroup *); -extern void move_camera(struct ObjCamera*); -extern void move_cameras_in_grp(struct ObjGroup*); -extern void Unknown8018100C(struct ObjLight*); -extern void move_lights_in_grp(struct ObjGroup*); -extern void move_lights_in_grp(struct ObjGroup*); -extern void proc_view_movement(struct ObjView *); -extern void reset_nets_and_gadgets(struct ObjGroup *); -extern void null_obj_lists(void); +void func_8017BCB0(void); +void func_8017BD20(void *a0); +void func_8017BE60(struct GdPlaneF *a0); +void func_8017BED0(UNUSED struct ObjGroup *a0, UNUSED struct GdObj *a1); +const char *get_obj_name_str(enum ObjTypeFlag objFlag); +struct GdObj *make_object(enum ObjTypeFlag objFlag); +struct ObjZone *make_zone(struct ObjGroup *a0, struct GdPlaneF *a1, struct ObjGroup *a2); +struct ObjUnk200000 *func_8017C7A0(struct ObjVertex *a0, struct ObjFace *a1); +struct Links *make_link_to_obj(struct Links *head, struct GdObj *a1); +struct VtxLink *make_vtx_link(struct VtxLink *prevLink, Vtx *data); +struct ObjValPtrs *make_valptrs(struct GdObj *obj, s32 flags, enum ValPtrType type, size_t offset); +void reset_plane(struct ObjPlane *plane); +struct ObjPlane *make_plane(s32 inZone, struct ObjFace *a1); +struct ObjCamera *make_camera(s32 a0, struct GdObj *a1); +struct ObjMaterial *make_material(UNUSED s32 a0, char *name, s32 id); +struct ObjLight *make_light(s32 flags, char *name, s32 id); +struct ObjView *make_view(const char *name, s32 flags, s32 a2, s32 ulx, s32 uly, s32 lrx, s32 lry, + struct ObjGroup *parts); +struct ObjAnimator *make_animator(void); +struct ObjWeight *make_weight(UNUSED s32 a0, s32 id, struct ObjVertex *vtx, f32 weight); +struct ObjGroup *make_group_of_type(enum ObjTypeFlag, struct GdObj*, struct GdObj*); +void sprint_obj_id(char*, struct GdObj*); +struct ObjGroup* make_group(s32 count, ...); +void addto_group(struct ObjGroup *group, struct GdObj *obj); +void addto_groupfirst(struct ObjGroup *group, struct GdObj *obj); +s32 group_contains_obj(struct ObjGroup *group, struct GdObj *obj); +void show_details(enum ObjTypeFlag type); +s32 func_8017E1E8(void); +s32 func_8017E20C(void); +void gd_loadtexture(struct GdObj *obj); +void func_8017E2B8(void); +struct GdObj *func_8017E2F0(struct GdObj *obj, enum ObjTypeFlag type); +s32 apply_to_obj_types_in_group(s32 types, applyproc_t fn, struct ObjGroup *group); +void func_8017E584(struct ObjNet *a0, struct GdVec3f *a1, struct GdVec3f *a2); +void func_8017E838(struct ObjNet *a0, struct GdVec3f *a1, struct GdVec3f *a2); +void func_8017E9EC(struct ObjNet *a0); +s32 func_8017EA94(struct GdVec3f *vec, Mat4f matrix); +s32 func_8017EB24(struct GdObj *a0, struct GdObj *a1); +s32 func_8017ED00(struct GdObj *a0, struct GdPlaneF *a1); +s32 func_8017EDCC(struct GdVec3f *a0, struct GdPlaneF *a1); +s32 gd_plane_point_within(struct GdPlaneF *a0, struct GdPlaneF *a1); +s32 func_8017F054(struct GdObj *a0, struct GdObj *a1); +s32 func_8017F210(struct GdObj *a0, struct GdObj *a1); +void func_8017F404(UNUSED f32 a0, UNUSED struct GdObj *a1, UNUSED struct GdObj *a2); +void func_8017F424(struct GdTriangleF *a0, struct GdTriangleF *a1, f32 a2); +void move_animator(struct ObjAnimator *animObj); +void drag_picked_object(struct GdObj *inputObj); +void move_animators(struct ObjGroup *group); +void find_and_drag_picked_object(struct ObjGroup *group); +void move_camera(struct ObjCamera *cam); +void move_cameras_in_grp(struct ObjGroup *group); +void func_8018100C(struct ObjLight *light); +void move_lights_in_grp(struct ObjGroup *group); +void proc_view_movement(struct ObjView *view); +void reset_nets_and_gadgets(struct ObjGroup *group); +void null_obj_lists(void); -#endif /* GD_OBJECTS_H */ +#endif // GD_OBJECTS_H diff --git a/src/goddard/old_menu.c b/src/goddard/old_menu.c index 27c1dac8..f6269438 100644 --- a/src/goddard/old_menu.c +++ b/src/goddard/old_menu.c @@ -1,12 +1,12 @@ -#include -#include +#include #include -#include "gd_types.h" -#include "old_menu.h" -#include "objects.h" -#include "dynlist_proc.h" #include "debug_utils.h" +#include "dynlist_proc.h" +#include "gd_types.h" +#include "macros.h" +#include "objects.h" +#include "old_menu.h" #include "renderer.h" /** @@ -62,7 +62,7 @@ void Unknown8018B7A8(void *a0) { void Proc8018B83C(void *a0) { struct ObjGroup *argGroup = a0; apply_to_obj_types_in_group(OBJ_TYPE_GADGETS, (applyproc_t) func_8018BCB8, argGroup); - apply_to_obj_types_in_group(OBJ_TYPE_VIEWS, (applyproc_t) Proc801A43DC, gGdViewsGroup); + apply_to_obj_types_in_group(OBJ_TYPE_VIEWS, (applyproc_t) func_801A43DC, gGdViewsGroup); } /* 23A068 -> 23A0D0; orig name: Unknown8018B898 */ @@ -85,11 +85,11 @@ void *Unknown8018B900(struct ObjGroup *grp) { apply_to_obj_types_in_group(OBJ_TYPE_GROUPS, (applyproc_t) cat_grp_name_to_buf, grp); defaultSettingMenu = func_801A43F0(sMenuStrBuf, &Proc8018B83C); controlerMenu = func_801A43F0( - "Control Type %t %F| U-64 Analogue Joystick %x1 | Keyboard %x2 | Mouse %x3", &Proc801A4410); + "Control Type %t %F| U-64 Analogue Joystick %x1 | Keyboard %x2 | Mouse %x3", &func_801A4410); mainMenu = func_801A43F0("Dynamics %t |\t\t\tReset Positions %f |\t\t\tSet Defaults %m |\t\t\tSet " "Controller %m |\t\t\tRe-Calibrate Controller %f |\t\t\tQuit %f", - &func_8017E2B8, defaultSettingMenu, controlerMenu, &Proc801A4424, &gd_exit); + &func_8017E2B8, defaultSettingMenu, controlerMenu, &func_801A4424, &gd_exit); return mainMenu; } diff --git a/src/goddard/old_menu.h b/src/goddard/old_menu.h index 84cef180..85ed7419 100644 --- a/src/goddard/old_menu.h +++ b/src/goddard/old_menu.h @@ -1,17 +1,19 @@ #ifndef GD_OLD_MENU_H #define GD_OLD_MENU_H -#include -#include "gd_types.h" +#include -extern void get_objvalue(union ObjVarVal *, enum ValPtrType, void *, size_t); -extern struct ObjGadget *make_gadget(s32, s32); -extern void reset_gadget(struct ObjGadget *); -extern void reset_gadgets_in_grp(struct ObjGroup *); +#include "gd_types.h" +#include "macros.h" + +void get_objvalue(union ObjVarVal *dst, enum ValPtrType type, void *base, size_t offset); +struct ObjGadget *make_gadget(UNUSED s32 a0, s32 a1); +void reset_gadget(struct ObjGadget *gdgt); +void reset_gadgets_in_grp(struct ObjGroup *grp); // see bad_declarations.h #ifndef GD_USE_BAD_DECLARATIONS -extern struct ObjLabel *make_label(struct ObjValPtrs *, char *, s32, f32, f32, f32); +struct ObjLabel *make_label(struct ObjValPtrs *ptr, char *str, s32 a2, f32 x, f32 y, f32 z); #endif -#endif /* GD_OLD_MENU_H */ +#endif // GD_OLD_MENU_H diff --git a/src/goddard/particles.c b/src/goddard/particles.c index a54dfacc..aa353b9b 100644 --- a/src/goddard/particles.c +++ b/src/goddard/particles.c @@ -1,14 +1,15 @@ -#include -#include -#include "gd_types.h" +#include + +#include "debug_utils.h" #include "draw_objects.h" +#include "dynlist_proc.h" +#include "gd_math.h" +#include "gd_types.h" +#include "macros.h" #include "objects.h" #include "particles.h" -#include "dynlist_proc.h" -#include "debug_utils.h" -#include "skin.h" -#include "gd_math.h" #include "renderer.h" +#include "skin.h" // static types typedef union { @@ -236,9 +237,9 @@ struct Connection *func_801825FC(struct ObjVertex *vtx1, struct ObjVertex *vtx2) sp34->unk1C.vtx = vtx1; sp34->unk20.vtx = vtx2; push_dynobj_stash(); - set_cur_dynobj(vtx1); + set_cur_dynobj((struct GdObj *)vtx1); d_get_world_pos(&sp28); - set_cur_dynobj(vtx2); + set_cur_dynobj((struct GdObj *)vtx2); d_get_world_pos(&sp1C); sp28.x -= sp1C.x; sp28.y -= sp1C.y; diff --git a/src/goddard/particles.h b/src/goddard/particles.h index c32202c3..3ea34999 100644 --- a/src/goddard/particles.h +++ b/src/goddard/particles.h @@ -1,12 +1,13 @@ #ifndef GD_PARTICLES_H #define GD_PARTICLES_H -#include +#include + #include "gd_types.h" // functions -extern void func_801823A0(struct ObjNet *); -extern struct ObjParticle *make_particle(u32, s32, f32, f32, f32); -extern void move_particles_in_grp(struct ObjGroup *); +void func_801823A0(struct ObjNet *net); +struct ObjParticle *make_particle(u32 a, s32 b, f32 x, f32 y, f32 z); +void move_particles_in_grp(struct ObjGroup *group); -#endif /* GD_PARTICLES_H */ +#endif // GD_PARTICLES_H diff --git a/src/goddard/renderer.c b/src/goddard/renderer.c index 4fa77986..3d2a8356 100644 --- a/src/goddard/renderer.c +++ b/src/goddard/renderer.c @@ -1,26 +1,25 @@ #include -#include #include #include #ifndef VERSION_EU #include "prevent_bss_reordering.h" #endif -#include "gd_types.h" -#include "gd_macros.h" -#include "dynlists/dynlists.h" - -#include "renderer.h" -#include "gd_main.h" -#include "gd_memory.h" -#include "sfx.h" -#include "draw_objects.h" -#include "objects.h" -#include "dynlist_proc.h" #include "debug_utils.h" -#include "skin.h" +#include "draw_objects.h" +#include "dynlist_proc.h" +#include "dynlists/dynlists.h" +#include "gd_macros.h" +#include "gd_main.h" #include "gd_math.h" +#include "gd_memory.h" +#include "gd_types.h" +#include "macros.h" +#include "objects.h" +#include "renderer.h" +#include "sfx.h" #include "shape_helper.h" +#include "skin.h" #include "config.h" #include "gfx_dimensions.h" @@ -129,7 +128,7 @@ static struct ObjGroup *sCarSceneGrp; // @ 801BB0B8 static s32 D_801BB0BC; // vtx's to load into RPD? Vtx len in GD Dl and in the lower bank (AF30) static struct ObjView *sYoshiSceneView; // @ 801BB0C0 static s32 D_801BB0C4; // first offset into D_801BAF30 -static struct ObjView *sMSceneView; // @ 801BB0C8; mario scene view +static struct ObjView *sMSceneView; // @ 801BB0C8; Mario scene view static s32 D_801BB0CC; // Vtx start in GD Dl static struct ObjView *sCarSceneView; // @ 801BB0D0 static s32 sUpdateYoshiScene; // @ 801BB0D4; update dl Vtx from ObjVertex? @@ -1231,7 +1230,7 @@ void gdm_maketestdl(s32 id) { case 1: reset_nets_and_gadgets(sYoshiSceneGrp); break; - case 2: // normal mario head + case 2: // normal Mario head if (sMarioSceneGrp == NULL) { load_mario_head(animate_mario_head_normal); sMarioSceneGrp = gMarioFaceGrp; // gMarioFaceGrp set by load_mario_head @@ -1239,7 +1238,7 @@ void gdm_maketestdl(s32 id) { } sMSceneView = make_view_withgrp("mscene", sMarioSceneGrp); break; - case 3: // game over mario head + case 3: // game over Mario head if (sMarioSceneGrp == NULL) { load_mario_head(animate_mario_head_gameover); sMarioSceneGrp = gMarioFaceGrp; @@ -1716,10 +1715,8 @@ u32 Unknown8019EC88(Gfx *dl, UNUSED s32 arg1) { } /* 24D4C4 -> 24D63C; orig name: func_8019ECF4 */ -void mat4_to_mtx(const Mat4f *src, Mtx *dst) { - - guMtxF2L(src, dst); - +void mat4_to_mtx(Mat4f *src, Mtx *dst) { + guMtxF2L(*src, dst); } /* 24D63C -> 24D6E4; orig name: func_8019EE6C */ @@ -1790,8 +1787,7 @@ void func_8019F2C4(f32 arg0, s8 arg1) { } /* 24DAE8 -> 24E1A8 */ -void func_8019F318(struct ObjCamera *cam, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, - f32 arg7) { +void func_8019F318(struct ObjCamera *cam, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7) { LookAt *lookat; // 5c arg7 *= RAD_PER_DEG; @@ -1879,7 +1875,7 @@ void check_tri_display(s32 vtxcount) { } /* 24E230 -> 24E6C0; orig name: func_8019FA60 */ -Vtx *make_Vtx_if_new(f32 x, f32 y, f32 z, f32 alpha) { +Vtx *make_vtx_if_new(f32 x, f32 y, f32 z, f32 alpha) { Vtx *vtx = NULL; // 1c s32 i; // 18 @@ -1929,9 +1925,9 @@ void add_tri_to_dl(f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2, f32 x3, f32 y Vtx *vtx; // 24 vtx = &DL_CURRENT_VTX(sCurrentGdDl); - make_Vtx_if_new(x1, y1, z1, 1.0f); - make_Vtx_if_new(x2, y2, z2, 1.0f); - make_Vtx_if_new(x3, y3, z3, 1.0f); + make_vtx_if_new(x1, y1, z1, 1.0f); + make_vtx_if_new(x2, y2, z2, 1.0f); + make_vtx_if_new(x3, y3, z3, 1.0f); gSPVertex(next_gfx(), osVirtualToPhysical(vtx), 3, 0); gSP1Triangle(next_gfx(), 0, 1, 2, 0); @@ -2779,7 +2775,7 @@ void gd_init_controllers(void) { } /* 252BAC -> 252BC0 */ -void Proc801A43DC(UNUSED struct GdObj *obj) { +void func_801A43DC(UNUSED struct GdObj *obj) { } /* 252BC0 -> 252BE0 */ @@ -2788,18 +2784,18 @@ void *func_801A43F0(UNUSED const char *menufmt, ...) { } /* 252BE0 -> 252BF0 */ -void Proc801A4410(UNUSED void *arg0) { +void func_801A4410(UNUSED void *arg0) { } /* 252BF0 -> 252C08 */ -void Proc801A4424(UNUSED void *arg0) { +void func_801A4424(UNUSED void *arg0) { } /* 252C08 -> 252C70 */ -void func_801A4438(f32 arg0, f32 arg1, f32 arg2) { - D_801BB0E8.x = arg0 - (sActiveView->lowerRight.x / 2.0f); - D_801BB0E8.y = (sActiveView->lowerRight.y / 2.0f) - arg1; - D_801BB0E8.z = arg2; +void func_801A4438(f32 x, f32 y, f32 z) { + D_801BB0E8.x = x - (sActiveView->lowerRight.x / 2.0f); + D_801BB0E8.y = (sActiveView->lowerRight.y / 2.0f) - y; + D_801BB0E8.z = z; } /* 252C70 -> 252DB4 */ @@ -3287,7 +3283,7 @@ void Unknown801A5AE0(s32 arg0) { } /* 254328 -> 2543B8; orig name: func_801A5B58 */ -void set_Vtx_tc_buf(f32 tcS, f32 tcT) { +void set_vtx_tc_buf(f32 tcS, f32 tcT) { sVtxCvrtTCBuf[0] = (s16)(tcS * 512.0f); sVtxCvrtTCBuf[1] = (s16)(tcT * 512.0f); } diff --git a/src/goddard/renderer.h b/src/goddard/renderer.h index 95cd13ef..8cc2741a 100644 --- a/src/goddard/renderer.h +++ b/src/goddard/renderer.h @@ -1,8 +1,11 @@ #ifndef GD_RENDERER_H #define GD_RENDERER_H -#include +#include +#include + #include "gd_types.h" +#include "macros.h" // types /// Properties types used in [gd_setproperty](@ref gd_setproperty); most are stubbed out. @@ -25,87 +28,90 @@ enum GdProperty { extern s32 gGdFrameBuf; // functions -extern u32 get_alloc_mem_amt(void); -extern s32 gd_get_ostime(void); -extern f32 get_time_scale(void); -extern f64 gd_sin_d(f64); -extern f64 gd_cos_d(f64); -extern f64 gd_sqrt_d(f64); -extern void gd_printf(const char *, ...); -extern void gd_exit(s32); -extern void gd_free(void *); -extern void *gd_allocblock(u32); -extern void *gd_malloc(u32, u8); -extern void *gd_malloc_perm(u32); -extern void *gd_malloc_temp(u32); -extern void func_8019BD0C(s32, s32); -extern void gd_add_to_heap(void *, u32); -extern void gdm_init(void *, u32); -extern void gdm_setup(void); -extern void gdm_maketestdl(s32); -extern void gd_vblank(void); -extern void gd_copy_p1_contpad(OSContPad *); -extern s32 gd_sfx_to_play(void); -extern void *gdm_gettestdl(s32); -extern void gd_draw_rect(f32, f32, f32, f32); -extern void gd_draw_border_rect(f32, f32, f32, f32); -extern void gd_set_fill(struct GdColour *); -extern void stash_current_gddl(void); -extern void pop_gddl_stash(void); -extern s32 gd_startdisplist(s32); -extern s32 gd_enddlsplist_parent(); -extern void add_mat4_load_to_dl(Mat4f *); -extern void idn_mtx_push_gddl(void); -extern void pop_mtx_gddl(void); -extern void translate_mtx_gddl(f32, f32, f32); -extern void translate_load_mtx_gddl(f32, f32, f32); -extern void func_8019F258(f32, f32, f32); -extern void func_8019F2C4(f32, s8); -extern void func_8019F318(struct ObjCamera *a, f32, f32, f32, f32, f32, f32, f32); -extern void check_tri_display(s32); -extern Vtx *make_Vtx_if_new(f32, f32, f32, f32); -extern void func_8019FEF0(void); -extern void add_tri_to_dl(f32, f32, f32, f32, f32, f32, f32, f32, f32); -extern void func_801A0038(void); -extern void func_801A0070(void); -extern void func_801A02B8(f32); -extern void set_light_id(s32); -extern void set_light_num(s32); -extern s32 create_mtl_gddl(s32); -extern void branch_to_gddl(s32); -extern void func_801A0478(s32, struct ObjCamera *, struct GdVec3f *, struct GdVec3f *, struct GdVec3f *, struct GdColour *); -extern s32 func_801A086C(s32, struct GdColour *, s32); -extern void set_Vtx_norm_buf_1(struct GdVec3f *); -extern void set_Vtx_norm_buf_2(struct GdVec3f *); -extern void set_gd_mtx_parameters(s32); -extern void gd_set_one_cycle(void); -extern void gddl_is_loading_stub_dl(s32); -extern void start_view_dl(struct ObjView *); -extern void border_active_view(void); -extern void gd_shading(s32); -extern s32 gd_getproperty(s32, void *); -extern void gd_setproperty(enum GdProperty, f32, f32, f32); -extern void gd_create_ortho_matrix(f32, f32, f32, f32, f32, f32); -extern void gd_create_perspective_matrix(f32, f32, f32, f32); -extern s32 setup_view_buffers(const char *, struct ObjView *, s32, s32, s32, s32); -extern void gd_init_controllers(void); -extern void Proc801A43DC(struct GdObj *); //apply to OBJ_TYPE_VIEWS -extern void *func_801A43F0(const char *, ...); // TUI code..? query_user? doesn't actually return anything... maybe it returned a "menu *"? -extern void Proc801A4410(void *); // function looks like it got various controller/input attributes..? -extern void Proc801A4424(void *); // TUI stuff? -extern void func_801A4438(f32, f32, f32); -extern void func_801A48C4(u32); -extern void func_801A48D8(char *); -extern void set_active_view(struct ObjView *); -extern void func_801A520C(void); -extern void gd_init(void); -extern void func_801A5998(s8 *); /* convert LE bytes to BE word? */ -extern void func_801A59AC(void *); -extern void func_801A59C0(s8 *); /* convert LE bytes to BE f32? */ -extern void init_pick_buf(s16 *, s32); -extern void store_in_pickbuf(s16); -extern s32 get_cur_pickbuf_offset(s16 *); -extern void set_Vtx_tc_buf(f32, f32); -extern struct GdObj *load_dynlist(struct DynList *); +u32 get_alloc_mem_amt(void); +s32 gd_get_ostime(void); +f32 get_time_scale(void); +f64 gd_sin_d(f64 x); +f64 gd_cos_d(f64 x); +f64 gd_sqrt_d(f64 x); +void gd_printf(const char *format, ...); +void gd_exit(UNUSED s32 code) NORETURN; +void gd_free(void *ptr); +void *gd_allocblock(u32 size); +void *gd_malloc(u32 size, u8 perm); +void *gd_malloc_perm(u32 size); +void *gd_malloc_temp(u32 size); +void func_8019BD0C(s32 dlNum, s32 gfxIdx); +void gd_add_to_heap(void *addr, u32 size); +void gdm_init(void *blockpool, u32 size); +void gdm_setup(void); +void gdm_maketestdl(s32 id); +void gd_vblank(void); +void gd_copy_p1_contpad(OSContPad *p1cont); +s32 gd_sfx_to_play(void); +void *gdm_gettestdl(s32 id); +void gd_draw_rect(f32 ulx, f32 uly, f32 lrx, f32 lry); +void gd_draw_border_rect(f32 ulx, f32 uly, f32 lrx, f32 lry); +void gd_set_fill(struct GdColour *colour); +void stash_current_gddl(void); +void pop_gddl_stash(void); +s32 gd_startdisplist(s32 memarea); +s32 gd_enddlsplist_parent(void); +void add_mat4_load_to_dl(Mat4f *mtx); +void idn_mtx_push_gddl(void); +void pop_mtx_gddl(void); +void translate_mtx_gddl(f32 x, f32 y, f32 z); +void translate_load_mtx_gddl(f32 x, f32 y, f32 z); +void func_8019F258(f32 x, f32 y, f32 z); +void func_8019F2C4(f32 arg0, s8 arg1); +void func_8019F318(struct ObjCamera *cam, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7); +void check_tri_display(s32 vtxcount); +Vtx *make_vtx_if_new(f32 x, f32 y, f32 z, f32 alpha); +void func_8019FEF0(void); +void add_tri_to_dl(f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2, f32 x3, f32 y3, f32 z3); +void func_801A0038(void); +void func_801A0070(void); +void func_801A02B8(f32 arg0); +void set_light_id(s32 index); +void set_light_num(s32 n); +s32 create_mtl_gddl(s32 mtlType); +void branch_to_gddl(s32 dlNum); +void func_801A0478(s32, struct ObjCamera *, struct GdVec3f *, struct GdVec3f *, struct GdVec3f *, struct GdColour *); +void func_801A0478(s32 idx, struct ObjCamera *cam, UNUSED struct GdVec3f *arg2, UNUSED struct GdVec3f *arg3, + struct GdVec3f *arg4, struct GdColour *colour); +s32 func_801A086C(s32 id, struct GdColour *colour, s32 material); +void set_Vtx_norm_buf_1(struct GdVec3f *norm); +void set_Vtx_norm_buf_2(struct GdVec3f *norm); +void set_gd_mtx_parameters(s32 params); +void gd_set_one_cycle(void); +void gddl_is_loading_stub_dl(UNUSED s32 dlLoad); +void start_view_dl(struct ObjView *view); +void border_active_view(void); +void gd_shading(s32 model); +s32 gd_getproperty(s32 prop, UNUSED void *arg1); +void gd_setproperty(enum GdProperty prop, f32 f1, f32 f2, f32 f3); +void gd_create_ortho_matrix(f32 l, f32 r, f32 b, f32 t, f32 n, f32 f); +void gd_create_perspective_matrix(f32 fovy, f32 aspect, f32 near, f32 far); +s32 setup_view_buffers(const char *name, struct ObjView *view, UNUSED s32 ulx, UNUSED s32 uly, + UNUSED s32 lrx, UNUSED s32 lry); +void gd_init_controllers(void); +void func_801A43DC(struct GdObj *obj); //apply to OBJ_TYPE_VIEWS +void *func_801A43F0(UNUSED const char *menufmt, ...); // TUI code..? query_user? doesn't actually return anything... maybe it returned a "menu *"? +void func_801A4410(void *arg0); // function looks like it got various controller/input attributes..? +void func_801A4424(void *arg0); // TUI stuff? +void func_801A4438(f32 x, f32 y, f32 z); +void func_801A48C4(u32 arg0); +void func_801A48D8(UNUSED char *s); +void set_active_view(struct ObjView *v); +void func_801A520C(void); +void gd_init(void); +void func_801A5998(s8 *arg0); /* convert LE bytes to BE word? */ +void func_801A59AC(UNUSED void *arg0); +void func_801A59C0(UNUSED s8 *arg0); /* convert LE bytes to BE f32? */ +void init_pick_buf(s16 *buf, s32 len); +void store_in_pickbuf(s16 data); +s32 get_cur_pickbuf_offset(UNUSED s16 *arg0); +void set_vtx_tc_buf(f32 tcS, f32 tcT); +struct GdObj *load_dynlist(struct DynList *dynlist); -#endif /* GD_RENDERER_H */ +#endif // GD_RENDERER_H diff --git a/src/goddard/sfx.c b/src/goddard/sfx.c index 3be0fe90..03a6afad 100644 --- a/src/goddard/sfx.c +++ b/src/goddard/sfx.c @@ -1,27 +1,24 @@ -#include +#include + #include "sfx.h" -static u32 sSfxToPlay; // @ 801B9B20 -static u32 sLastPlayedSfx; // @ 801B9B24 +static u32 sSfxToPlay; +static u32 sLastPlayedSfx; -/* orig name: func_801780A0 */ void gd_reset_sfx(void) { sLastPlayedSfx = GD_SFX_NONE; sSfxToPlay = GD_SFX_NONE; } -/* orig name: func_801780C0 */ u32 gd_new_sfx_to_play(void) { return ~sLastPlayedSfx & sSfxToPlay; } -/* orig name: func_801780EC */ void gd_sfx_played(void) { sLastPlayedSfx = sSfxToPlay; sSfxToPlay = GD_SFX_NONE; } -/* orig name: func_80178114 */ /* Add GdSfx to queue to be played. Note that only the SFX * with the lowest value from the enum is played on a given frame **/ void gd_play_sfx(enum GdSfx sfx) { diff --git a/src/goddard/sfx.h b/src/goddard/sfx.h index d0b6f6fd..d75ca38a 100644 --- a/src/goddard/sfx.h +++ b/src/goddard/sfx.h @@ -1,7 +1,7 @@ -#ifndef GD_MARIO_HEAD_SFX_H -#define GD_MARIO_HEAD_SFX_H +#ifndef GD_SFX_H +#define GD_SFX_H -#include +#include // Sfx for Mario Head Screen enum GdSfx { @@ -17,9 +17,9 @@ enum GdSfx { }; // functions -extern void gd_reset_sfx(void); -extern u32 gd_new_sfx_to_play(void); -extern void gd_sfx_played(void); -extern void gd_play_sfx(enum GdSfx sfx); +void gd_reset_sfx(void); +u32 gd_new_sfx_to_play(void); +void gd_sfx_played(void); +void gd_play_sfx(enum GdSfx sfx); -#endif /* GD_MARIO_HEAD_SFX_H */ +#endif // GD_SFX_H diff --git a/src/goddard/shape_helper.c b/src/goddard/shape_helper.c index 90b14d35..adca3b94 100644 --- a/src/goddard/shape_helper.c +++ b/src/goddard/shape_helper.c @@ -1,21 +1,20 @@ -#include -#include +#include -#include "gd_types.h" -#include "shape_helper.h" -#include "gd_main.h" +#include "debug_utils.h" #include "draw_objects.h" +#include "dynlist_proc.h" +#include "dynlists/dynlist_macros.h" +#include "dynlists/dynlists.h" +#include "gd_main.h" +#include "gd_math.h" +#include "gd_types.h" +#include "joints.h" +#include "macros.h" #include "objects.h" #include "particles.h" -#include "dynlist_proc.h" -#include "debug_utils.h" -#include "joints.h" -#include "skin.h" -#include "gd_math.h" #include "renderer.h" - -#include "dynlists/dynlists.h" -#include "dynlists/dynlist_macros.h" +#include "shape_helper.h" +#include "skin.h" #ifndef VERSION_EU #include @@ -886,7 +885,7 @@ struct ObjMaterial *find_or_add_new_mtl(struct ObjGroup *group, UNUSED s32 a1, f } newMtl = make_material(0, NULL, 1); - set_cur_dynobj(newMtl); + set_cur_dynobj((struct GdObj *)newMtl); d_set_diffuse(r, g, b); addto_group(group, (struct GdObj *) newMtl); @@ -1418,7 +1417,7 @@ s32 load_mario_head(void (*aniFn)(struct ObjAnimator *)) { sp34 = d_use_obj("N112l"); sp30->unk1F8 = make_group(1, sp34); - sp30->fn2C = &Proc8018EBE8; + sp30->fn2C = &func_8018EBE8; sp30->unk1D0 = sp28; sp30->header.drawFlags &= ~OBJ_IS_GRABBALE; @@ -1426,7 +1425,7 @@ s32 load_mario_head(void (*aniFn)(struct ObjAnimator *)) { sp34 = d_use_obj("N96l"); sp30->unk1F8 = make_group(1, sp34); - sp30->fn2C = &Proc8018EBE8; + sp30->fn2C = &func_8018EBE8; sp30->unk1D0 = sp28; sp30->header.drawFlags &= ~OBJ_IS_GRABBALE; diff --git a/src/goddard/shape_helper.h b/src/goddard/shape_helper.h index adfb67df..81ae06a8 100644 --- a/src/goddard/shape_helper.h +++ b/src/goddard/shape_helper.h @@ -1,7 +1,8 @@ -#ifndef SHAPE_HELPER_H -#define SHAPE_HELPER_H +#ifndef GD_SHAPE_HELPER_H +#define GD_SHAPE_HELPER_H + +#include -#include #include "gd_types.h" // data @@ -13,20 +14,20 @@ extern struct ObjShape *gShapeRedStar; extern struct ObjShape *gShapeSilverStar; // functions -extern void calc_face_normal(struct ObjFace *); -extern struct ObjVertex *gd_make_vertex(f32, f32, f32); -extern void add_3_vtx_to_face(struct ObjFace *, struct ObjVertex *, struct ObjVertex *, struct ObjVertex *); -extern struct ObjShape *make_shape(s32, const char *); -extern void scale_verts_in_shape(struct ObjShape *, f32, f32, f32); -extern struct ObjNet *make_netfromshape(struct ObjShape *); -extern void animate_mario_head_gameover(struct ObjAnimator *); -extern void animate_mario_head_normal(struct ObjAnimator *); -extern s32 load_mario_head(void (*aniFn)(struct ObjAnimator *)); -extern void load_shapes2(void); +void calc_face_normal(struct ObjFace *face); +struct ObjVertex *gd_make_vertex(f32 x, f32 y, f32 z); +void add_3_vtx_to_face(struct ObjFace *face, struct ObjVertex *vtx1, struct ObjVertex *vtx2, struct ObjVertex *vtx3); +struct ObjShape *make_shape(s32 flag, const char *name); +void scale_verts_in_shape(struct ObjShape *shape, f32 x, f32 y, f32 z); +struct ObjNet *make_netfromshape(struct ObjShape *shape); +void animate_mario_head_gameover(struct ObjAnimator *self); +void animate_mario_head_normal(struct ObjAnimator *self); +s32 load_mario_head(void (*aniFn)(struct ObjAnimator *)); +void load_shapes2(void); // see bad_declarations.h #ifndef GD_USE_BAD_DECLARATIONS -extern struct ObjFace* make_face_with_colour(f32, f32, f32); +struct ObjFace* make_face_with_colour(f32 r, f32 g, f32 b); #endif -#endif /* SHAPE_HELPER_H */ +#endif // GD_SHAPE_HELPER_H diff --git a/src/goddard/skin.c b/src/goddard/skin.c index 59779177..7b285a10 100644 --- a/src/goddard/skin.c +++ b/src/goddard/skin.c @@ -1,15 +1,16 @@ -#include -#include -#include "gd_types.h" -#include "skin.h" -#include "gd_main.h" -#include "objects.h" -#include "skin_movement.h" -#include "particles.h" +#include + #include "debug_utils.h" -#include "joints.h" +#include "gd_main.h" #include "gd_math.h" +#include "gd_types.h" +#include "joints.h" +#include "macros.h" +#include "objects.h" +#include "particles.h" #include "renderer.h" +#include "skin.h" +#include "skin_movement.h" // bss struct ObjNet *gGdSkinNet; // @ 801BAAF0 @@ -70,14 +71,14 @@ void reset_net(struct ObjNet *net) { if ((grp = net->unk1C8) != NULL) { apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_80191604, grp); - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown80191220, grp); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_80191220, grp); apply_to_obj_types_in_group(OBJ_TYPE_BONES, (applyproc_t) func_8018FB58, grp); - apply_to_obj_types_in_group(OBJ_TYPE_BONES, (applyproc_t) Unknown8018FA68, grp); + apply_to_obj_types_in_group(OBJ_TYPE_BONES, (applyproc_t) func_8018FA68, grp); } } /* 240A64 -> 240ACC */ -void Unknown80192294(struct ObjNet *net) { +void func_80192294(struct ObjNet *net) { UNUSED s32 sp1C = 0; if (net->unk1E8 == NULL) { @@ -88,7 +89,7 @@ void Unknown80192294(struct ObjNet *net) { } /* 240ACC -> 240B84 */ -void Unknown801922FC(struct ObjNet *net) { +void func_801922FC(struct ObjNet *net) { struct ObjGroup *group; // 24 UNUSED u32 pad18[2]; @@ -100,7 +101,7 @@ void Unknown801922FC(struct ObjNet *net) { func_80181760(net->unk1A8->vtxGroup); } if ((group = net->unk1C8) != NULL) { - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown80181B88, group); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_80181B88, group); } } } @@ -197,7 +198,7 @@ void func_801926A4(struct ObjNet *net) { } /* 2412A0 -> 24142C; not called */ -void Unknown80192AD0(struct ObjNet *net) { +void func_80192AD0(struct ObjNet *net) { UNUSED u32 pad64; struct ObjGroup *sp60; UNUSED u32 pad20[0x10]; @@ -222,7 +223,7 @@ void Unknown80192AD0(struct ObjNet *net) { net->unk200.z = -4.0f; gd_rotate_and_translate_vec3f(&net->unk200, &sp18->mat128); - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown80191824, sp60); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_80191824, sp60); func_80191E88(sp60); apply_to_obj_types_in_group(OBJ_TYPE_BONES, (applyproc_t) func_8018F328, net->unk20C); } @@ -235,7 +236,7 @@ void move_bonesnet(struct ObjNet *net) { add_to_stacktrace("move_bonesnet"); gd_set_identity_mat4(&D_801B9DC8); if ((sp24 = net->unk1C8) != NULL) { - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown801913C0, sp24); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_801913C0, sp24); } imout(); } @@ -282,17 +283,17 @@ void func_80192CCC(struct ObjNet *net) { func_80192528(net); if ((group = net->unk1C8) != NULL) { - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown80191220, group); - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown801913F0, group); - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown801914F8, group); - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown801911A8, group); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_80191220, group); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_801913F0, group); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_801914F8, group); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_801911A8, group); } func_801926A4(net); gd_mult_mat4f(&net->mat128, &D_801B9DC8, &net->mat128); if (group != NULL) { - apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) Unknown801913C0, group); - apply_to_obj_types_in_group(OBJ_TYPE_BONES, (applyproc_t) Unknown8018FA68, group); + apply_to_obj_types_in_group(OBJ_TYPE_JOINTS, (applyproc_t) func_801913C0, group); + apply_to_obj_types_in_group(OBJ_TYPE_BONES, (applyproc_t) func_8018FA68, group); } } @@ -303,7 +304,6 @@ void convert_gd_verts_to_Vn(struct ObjGroup *grp) { u8 nx, ny, nz; // 24, 25, 26 UNUSED u32 pad20; register struct VtxLink *vtxlink; // a1 - register s16 x; // a3 register s16 y; // t0 register s16 z; // t1 @@ -323,12 +323,10 @@ void convert_gd_verts_to_Vn(struct ObjGroup *grp) { nz = (u8)(vtx->normal.z * 255.0f); for (vtxlink = vtx->gbiVerts; vtxlink != NULL; vtxlink = vtxlink->prev) { - vn = vtxlink->data; vn->n.ob[0] = x; vn->n.ob[1] = y; vn->n.ob[2] = z; - vn->n.n[0] = nx; vn->n.n[1] = ny; vn->n.n[2] = nz; @@ -340,7 +338,6 @@ void convert_gd_verts_to_Vn(struct ObjGroup *grp) { void convert_gd_verts_to_Vtx(struct ObjGroup *grp) { UNUSED u32 pad24[6]; register struct VtxLink *vtxlink; // a1 - register s16 x; // a3 register s16 y; // t0 register s16 z; // t1 @@ -356,7 +353,6 @@ void convert_gd_verts_to_Vtx(struct ObjGroup *grp) { z = (s16) vtx->pos.z; for (vtxlink = vtx->gbiVerts; vtxlink != NULL; vtxlink = vtxlink->prev) { - vtxlink->data->v.ob[0] = x; vtxlink->data->v.ob[1] = y; vtxlink->data->v.ob[2] = z; @@ -402,7 +398,7 @@ void func_801934D0(struct ObjNet *net) { } } -/* 241D6C -> 241E94; orig name: Unknown8019359C */ +/* 241D6C -> 241E94; orig name: func_8019359C */ void move_net(struct ObjNet *net) { gGdSkinNet = net; @@ -439,14 +435,14 @@ void move_net(struct ObjNet *net) { void move_nets(struct ObjGroup *group) { add_to_stacktrace("move_nets"); restart_timer("move_nets"); - apply_to_obj_types_in_group(OBJ_TYPE_NETS, (applyproc_t) Unknown80192294, group); + apply_to_obj_types_in_group(OBJ_TYPE_NETS, (applyproc_t) func_80192294, group); apply_to_obj_types_in_group(OBJ_TYPE_NETS, (applyproc_t) move_net, group); split_timer("move_nets"); imout(); } /* 241F0C -> 242018 */ -void Unknown8019373C(struct ObjNet *net) { +void func_8019373C(struct ObjNet *net) { register struct Links *link; // s0 struct ObjVertex *vtx; // 20 @@ -469,12 +465,12 @@ void Unknown8019373C(struct ObjNet *net) { /* 242018 -> 24208C */ void func_80193848(struct ObjGroup *group) { apply_to_obj_types_in_group(OBJ_TYPE_NETS, (applyproc_t) reset_net, group); - apply_to_obj_types_in_group(OBJ_TYPE_NETS, (applyproc_t) Unknown80192294, group); - apply_to_obj_types_in_group(OBJ_TYPE_NETS, (applyproc_t) Unknown801922FC, group); - apply_to_obj_types_in_group(OBJ_TYPE_NETS, (applyproc_t) Unknown8019373C, group); + apply_to_obj_types_in_group(OBJ_TYPE_NETS, (applyproc_t) func_80192294, group); + apply_to_obj_types_in_group(OBJ_TYPE_NETS, (applyproc_t) func_801922FC, group); + apply_to_obj_types_in_group(OBJ_TYPE_NETS, (applyproc_t) func_8019373C, group); } -/* 24208C -> 2422E0; not called; orig name: Unknown801938BC */ +/* 24208C -> 2422E0; not called; orig name: func_801938BC */ void gd_print_net(struct ObjNet *net) { gd_printf("Flags:%x\n", net->unk34); gd_print_vec("World:", &net->unk14); diff --git a/src/goddard/skin.h b/src/goddard/skin.h index e4c8f2a1..428b3639 100644 --- a/src/goddard/skin.h +++ b/src/goddard/skin.h @@ -1,18 +1,20 @@ #ifndef GD_SKIN_H #define GD_SKIN_H -#include +#include + #include "gd_types.h" // bss extern struct ObjNet* gGdSkinNet; // @ 801BAAF0 // functions -extern void reset_net(struct ObjNet *); -extern struct ObjNet * make_net(s32, struct ObjShape *, struct ObjGroup *, struct ObjGroup *, struct ObjGroup *); -extern void convert_net_verts(struct ObjNet *); -extern void move_nets(struct ObjGroup *); -extern void func_80193848(struct ObjGroup *); -extern void reset_net_count(void); +void reset_net(struct ObjNet *net); +struct ObjNet *make_net(UNUSED s32 a0, struct ObjShape *shapedata, struct ObjGroup *a2, + struct ObjGroup *a3, struct ObjGroup *a4); +void convert_net_verts(struct ObjNet *net); +void move_nets(struct ObjGroup *group); +void func_80193848(struct ObjGroup *group); +void reset_net_count(void); -#endif /* GD_SKIN_H */ +#endif // GD_SKIN_H diff --git a/src/goddard/skin_movement.c b/src/goddard/skin_movement.c index fc94447c..0163215a 100644 --- a/src/goddard/skin_movement.c +++ b/src/goddard/skin_movement.c @@ -1,12 +1,13 @@ -#include -#include -#include "gd_types.h" -#include "objects.h" -#include "skin_movement.h" +#include + #include "debug_utils.h" -#include "joints.h" -#include "skin.h" #include "gd_math.h" +#include "gd_types.h" +#include "joints.h" +#include "macros.h" +#include "objects.h" +#include "skin.h" +#include "skin_movement.h" /* bss */ struct ObjWeight *sSkinNetCurWeight; @@ -14,7 +15,7 @@ static Mat4f D_801B9EA8; // TODO: rename to sHead2Mtx? static struct ObjJoint *D_801B9EE8; /* @ 22FDB0 for 0x180 */ -void Unknown801815E0(Mat4f *mtx) { +void func_801815E0(Mat4f *mtx) { struct GdVec3f scratchVec; scratchVec.x = (*mtx)[0][0]; @@ -107,7 +108,7 @@ void func_80181894(struct ObjJoint *joint) { } /* @ 2301A0 for 0x110 */ -void Unknown801819D0(struct ObjVertex *vtx) { +void func_801819D0(struct ObjVertex *vtx) { struct GdVec3f localVec; UNUSED u8 pad24[0x10]; @@ -126,7 +127,7 @@ void Unknown801819D0(struct ObjVertex *vtx) { } } -/* @ 2302B0 for 0xA8; orig name: Unknown80181AE0 */ +/* @ 2302B0 for 0xA8; orig name: func_80181AE0 */ void reset_weight(struct ObjWeight *weight) { UNUSED u32 vtxCount; UNUSED u32 pad20; @@ -136,7 +137,7 @@ void reset_weight(struct ObjWeight *weight) { sTargetWeightID = 0; if ((skinGroup = gGdSkinNet->skinGrp) != NULL) { vtxCount = - apply_to_obj_types_in_group(OBJ_TYPE_VERTICES, (applyproc_t) Unknown801819D0, skinGroup); + apply_to_obj_types_in_group(OBJ_TYPE_VERTICES, (applyproc_t) func_801819D0, skinGroup); } else { fatal_printf("reset_weight(): Skin net has no SkinGroup"); } @@ -147,7 +148,7 @@ void reset_weight(struct ObjWeight *weight) { } /* @ 230358 for 0x78; rename to reset_joint_weight? */ -void Unknown80181B88(struct ObjJoint *joint) { +void func_80181B88(struct ObjJoint *joint) { struct ObjGroup *group; gd_inverse_mat4f(&joint->matE8, &D_801B9EA8); diff --git a/src/goddard/skin_movement.h b/src/goddard/skin_movement.h index cade259d..fbfa9385 100644 --- a/src/goddard/skin_movement.h +++ b/src/goddard/skin_movement.h @@ -1,11 +1,11 @@ -#ifndef SKIN_MOVEMENT_H -#define SKIN_MOVEMENT_H +#ifndef GD_SKIN_MOVEMENT_H +#define GD_SKIN_MOVEMENT_H #include "gd_types.h" -extern void func_80181760(struct ObjGroup *); -extern void move_skin(struct ObjNet *); -extern void func_80181894(struct ObjJoint *); -extern void Unknown80181B88(struct ObjJoint *); +void func_80181760(struct ObjGroup *a0); +void move_skin(struct ObjNet *net); +void func_80181894(struct ObjJoint *joint); +void func_80181B88(struct ObjJoint *joint); -#endif /* SKIN_MOVEMENT_H */ +#endif // GD_SKIN_MOVEMENT_H diff --git a/src/menu/debug_level_select.h b/src/menu/debug_level_select.h index e4e78259..8ec23ebb 100644 --- a/src/menu/debug_level_select.h +++ b/src/menu/debug_level_select.h @@ -1,7 +1,7 @@ #ifndef DEBUG_LEVEL_SELECT_H #define DEBUG_LEVEL_SELECT_H -#include "types.h" +#include extern const Gfx debug_level_select_dl_07000858[]; extern const Gfx debug_level_select_dl_07001100[]; @@ -14,4 +14,4 @@ extern const Gfx debug_level_select_dl_07005558[]; extern const Gfx debug_level_select_dl_070059F8[]; extern const Gfx debug_level_select_dl_070063B0[]; -#endif +#endif // DEBUG_LEVEL_SELECT_H diff --git a/src/menu/file_select.c b/src/menu/file_select.c index 3637d7d9..df28306a 100644 --- a/src/menu/file_select.c +++ b/src/menu/file_select.c @@ -1,24 +1,25 @@ -#include +#include +#include -#include "sm64.h" #include "audio/external.h" -#include "game/game_init.h" -#include "game/ingame_menu.h" -#include "game/object_helpers.h" -#include "game/area.h" -#include "game/save_file.h" -#include "game/spawn_object.h" -#include "game/object_list_processor.h" -#include "game/segment2.h" -#include "game/segment7.h" -#include "game/print.h" +#include "behavior_data.h" +#include "dialog_ids.h" #include "engine/behavior_script.h" #include "engine/graph_node.h" #include "engine/math_util.h" -#include "behavior_data.h" -#include "text_strings.h" #include "file_select.h" -#include "dialog_ids.h" +#include "game/area.h" +#include "game/game_init.h" +#include "game/ingame_menu.h" +#include "game/object_helpers.h" +#include "game/object_list_processor.h" +#include "game/print.h" +#include "game/save_file.h" +#include "game/segment2.h" +#include "game/segment7.h" +#include "game/spawn_object.h" +#include "sm64.h" +#include "text_strings.h" #include "eu_translation.h" #ifdef VERSION_EU @@ -2768,7 +2769,7 @@ static void print_file_select_strings(void) { /** * Geo function that prints file select strings and the cursor. */ -Gfx *geo_file_select_strings_and_menu_cursor(s32 callContext, UNUSED struct GraphNode *node, UNUSED f32 mtx[4][4]) { +Gfx *geo_file_select_strings_and_menu_cursor(s32 callContext, UNUSED struct GraphNode *node, UNUSED Mat4 mtx) { if (callContext == GEO_CONTEXT_RENDER) { print_file_select_strings(); print_menu_cursor(); diff --git a/src/menu/file_select.h b/src/menu/file_select.h index 0d3593b8..359677eb 100644 --- a/src/menu/file_select.h +++ b/src/menu/file_select.h @@ -1,6 +1,9 @@ #ifndef FILE_SELECT_H #define FILE_SELECT_H +#include +#include + #include "types.h" #define MENU_LAYER_MAIN 1 @@ -124,17 +127,14 @@ enum SoundModeMenuActionPhase { SOUND_MODE_PHASE_MAIN }; -extern u32 gGlobalTimer; +void beh_yellow_background_menu_init(void); +void beh_yellow_background_menu_loop(void); +void bhv_menu_button_init(void); +void bhv_menu_button_loop(void); +void bhv_menu_button_manager_init(void); +void bhv_menu_button_manager_loop(void); +Gfx *geo_file_select_strings_and_menu_cursor(s32 callContext, UNUSED struct GraphNode *node, UNUSED Mat4 mtx); +s32 lvl_init_menu_values_and_cursor_pos(UNUSED s32 arg, UNUSED s32 unused); +s32 lvl_update_obj_and_load_file_selected(UNUSED s32 arg, UNUSED s32 unused); -extern void beh_yellow_background_menu_init(void); -extern void beh_yellow_background_menu_loop(void); -extern void bhv_menu_button_init(void); -extern void bhv_menu_button_loop(void); -extern void bhv_menu_button_manager_init(void); -extern void bhv_menu_button_manager_loop(void); -extern Gfx *geo_file_select_strings_and_menu_cursor(s32 callContext, struct GraphNode *node, - f32 mtx[4][4]); -extern s32 lvl_init_menu_values_and_cursor_pos(s32 arg, s32 unused); -extern s32 lvl_update_obj_and_load_file_selected(s32 arg, s32 unused); - -#endif /* FILE_SELECT_H */ +#endif // FILE_SELECT_H diff --git a/src/menu/intro_geo.c b/src/menu/intro_geo.c index aebae6f2..37c6752a 100644 --- a/src/menu/intro_geo.c +++ b/src/menu/intro_geo.c @@ -1,11 +1,13 @@ -#include "ultra64.h" -#include "sm64.h" -#include "prevent_bss_reordering.h" -#include "types.h" +#include + #include "game/memory.h" #include "game/segment2.h" #include "game/segment7.h" #include "intro_geo.h" +#include "sm64.h" +#include "textures.h" +#include "types.h" +#include "prevent_bss_reordering.h" #include "gfx_dimensions.h" @@ -24,17 +26,6 @@ struct GraphNodeMore { /*0x18*/ u32 unk18; }; -// title screen segment A -extern Gfx title_screen_bg_dl_0A000118[]; -extern Gfx title_screen_bg_dl_0A000100[]; -extern Gfx title_screen_bg_dl_0A000130[]; -extern Gfx title_screen_bg_dl_0A000148[]; -extern Gfx title_screen_bg_dl_0A000160[]; -extern Gfx title_screen_bg_dl_0A000178[]; -extern Gfx title_screen_bg_dl_0A000190[]; -extern const u8 *const mario_title_texture_table[]; -extern const u8 *const game_over_texture_table[]; - // intro geo bss s32 gGameOverFrameCounter; s32 gGameOverTableIndex; @@ -42,8 +33,8 @@ s16 gTitleZoomCounter; s32 gTitleFadeCounter; // intro screen background display lists for each of four 80x20 textures -Gfx *introBackgroundDlRows[] = { title_screen_bg_dl_0A000130, title_screen_bg_dl_0A000148, - title_screen_bg_dl_0A000160, title_screen_bg_dl_0A000178 }; +const Gfx *introBackgroundDlRows[] = { title_screen_bg_dl_0A000130, title_screen_bg_dl_0A000148, + title_screen_bg_dl_0A000160, title_screen_bg_dl_0A000178 }; // intro screen background texture X offsets float introBackgroundOffsetX[] = { diff --git a/src/menu/intro_geo.h b/src/menu/intro_geo.h index a972397c..6fa6c84f 100644 --- a/src/menu/intro_geo.h +++ b/src/menu/intro_geo.h @@ -1,12 +1,15 @@ -#ifndef _INTRO_GEO_H -#define _INTRO_GEO_H +#ifndef INTRO_GEO_H +#define INTRO_GEO_H -#include "engine/graph_node.h" +#include +#include -Gfx *geo_title_screen(s32 a0, struct GraphNode *a1, UNUSED void *context); -Gfx *geo_fade_transition(s32 a0, struct GraphNode *a1, UNUSED void *context); -Gfx *intro_backdrop_one_image(s32 index, s8 *backdrop_table); -Gfx *geo_intro_backdrop(s32 a0, struct GraphNode *a1, UNUSED void *context); -Gfx *geo_game_over_tile(s32 a0, struct GraphNode *a1, UNUSED void *context); +#include "types.h" -#endif /* _INTRO_GEO_H */ +Gfx *geo_title_screen(s32 sp50, struct GraphNode *sp54, UNUSED void *context); +Gfx *geo_fade_transition(s32 sp40, struct GraphNode *sp44, UNUSED void *context); +Gfx *intro_backdrop_one_image(s32 index, s8 *backgroundTable); +Gfx *geo_intro_backdrop(s32 sp48, struct GraphNode *sp4c, UNUSED void *context); +Gfx *geo_game_over_tile(s32 sp40, struct GraphNode *sp44, UNUSED void *context); + +#endif // INTRO_GEO_H diff --git a/src/menu/level_select_menu.c b/src/menu/level_select_menu.c index b9505df9..b48478d3 100644 --- a/src/menu/level_select_menu.c +++ b/src/menu/level_select_menu.c @@ -1,18 +1,18 @@ -#include +#include -#include "sm64.h" #include "audio/external.h" +#include "engine/math_util.h" +#include "game/area.h" #include "game/game_init.h" +#include "game/level_update.h" #include "game/main.h" #include "game/memory.h" -#include "game/area.h" -#include "game/save_file.h" -#include "game/level_update.h" -#include "game/sound_init.h" #include "game/print.h" -#include "seq_ids.h" -#include "engine/math_util.h" +#include "game/save_file.h" +#include "game/sound_init.h" #include "level_table.h" +#include "seq_ids.h" +#include "sm64.h" #define PRESS_START_DEMO_TIMER 800 @@ -47,7 +47,7 @@ int run_press_start_demo_timer(s32 timer) { // start the demo. 800 frames has passed while // player is idle on PRESS START screen. - // start the mario demo animation for the demo list. + // start the Mario demo animation for the demo list. load_patchable_table(&gDemo, gDemoInputListID); // if the next demo sequence ID is the count limit, reset it back to @@ -222,7 +222,7 @@ s32 lvl_intro_update(s16 arg1, UNUSED s32 arg2) { break; case 3: retVar = level_select_input_loop(); - break; // useless break needed to match + break; } return retVar; } diff --git a/src/menu/level_select_menu.h b/src/menu/level_select_menu.h index f53fe562..fcb2b9ac 100644 --- a/src/menu/level_select_menu.h +++ b/src/menu/level_select_menu.h @@ -1,8 +1,10 @@ -#ifndef _LEVEL_SELECT_MENU_H -#define _LEVEL_SELECT_MENU_H +#ifndef LEVEL_SELECT_MENU_H +#define LEVEL_SELECT_MENU_H -#include "types.h" +#include -extern s32 lvl_intro_update(s16 arg1, s32 arg2); +#include "macros.h" -#endif /* _LEVEL_SELECT_MENU_H */ +s32 lvl_intro_update(s16 arg1, UNUSED s32 arg2); + +#endif // LEVEL_SELECT_MENU_H diff --git a/src/menu/star_select.c b/src/menu/star_select.c index 0333ddab..f3ee91f8 100644 --- a/src/menu/star_select.c +++ b/src/menu/star_select.c @@ -1,24 +1,24 @@ -#include +#include -#include "sm64.h" #include "audio/external.h" -#include "game/game_init.h" -#include "game/memory.h" -#include "game/area.h" -#include "game/save_file.h" -#include "game/object_helpers.h" -#include "game/ingame_menu.h" -#include "game/level_update.h" -#include "game/segment2.h" -#include "game/segment7.h" -#include "game/object_list_processor.h" +#include "behavior_data.h" #include "engine/behavior_script.h" #include "engine/graph_node.h" -#include "behavior_data.h" -#include "text_strings.h" -#include "star_select.h" #include "eu_translation.h" -#include +#include "game/area.h" +#include "game/game_init.h" +#include "game/ingame_menu.h" +#include "game/level_update.h" +#include "game/memory.h" +#include "game/object_helpers.h" +#include "game/object_list_processor.h" +#include "game/save_file.h" +#include "game/segment2.h" +#include "game/segment7.h" +#include "sm64.h" +#include "star_select.h" +#include "text_strings.h" +#include "prevent_bss_reordering.h" /** * @file star_select.c @@ -409,7 +409,7 @@ s32 lvl_init_act_selector_values_and_stars(UNUSED s32 arg, UNUSED s32 unused) { /** * Loads act selector button actions with selected act value checks. - * Also updates objects and returns act number selected after is choosen. + * Also updates objects and returns act number selected after is chosen. */ s32 lvl_update_obj_and_load_act_button_actions(UNUSED s32 arg, UNUSED s32 unused) { if (sActSelectorMenuTimer >= 11) { diff --git a/src/menu/star_select.h b/src/menu/star_select.h index b0d68e87..6388b3f6 100644 --- a/src/menu/star_select.h +++ b/src/menu/star_select.h @@ -1,6 +1,11 @@ #ifndef STAR_SELECT_H #define STAR_SELECT_H +#include +#include + +#include "types.h" + enum StarSelectorTypes { STAR_SELECTOR_NOT_SELECTED, @@ -9,11 +14,11 @@ enum StarSelectorTypes }; #ifdef AVOID_UB -extern Gfx *geo_act_selector_strings(s16 callContext, struct GraphNode *node, void *context); +Gfx *geo_act_selector_strings(s16 callContext, UNUSED struct GraphNode *node, UNUSED void *context); #else -extern Gfx *geo_act_selector_strings(s16 callContext, struct GraphNode *node); +Gfx *geo_act_selector_strings(s16 callContext, UNUSED struct GraphNode *node); #endif -extern s32 lvl_init_act_selector_values_and_stars(s32 arg, s32 unused); -extern s32 lvl_update_obj_and_load_act_button_actions(s32 arg, s32 unused); +s32 lvl_init_act_selector_values_and_stars(UNUSED s32 arg, UNUSED s32 unused); +s32 lvl_update_obj_and_load_act_button_actions(UNUSED s32 arg, UNUSED s32 unused); -#endif /* STAR_SELECT_H */ +#endif // STAR_SELECT_H diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 2a85b7a6..d5151216 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -87,7 +87,7 @@ bool configCameraInvertY = false; bool configEnableCamera = false; bool configCameraMouse = false; #endif -unsigned int configSkipIntro = 0; +bool configSkipIntro = 0; bool configHUD = true; #ifdef DISCORDRPC bool configDiscordRPC = true; @@ -135,10 +135,10 @@ static const struct ConfigOption options[] = { {.name = "bettercam_pan_level", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraPan}, {.name = "bettercam_degrade", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraDegrade}, #endif - {.name = "skip_intro", .type = CONFIG_TYPE_UINT, .uintValue = &configSkipIntro}, // Add this back! -#ifdef DISCORDRPC - {.name = "discordrpc_enable", .type = CONFIG_TYPE_BOOL, .boolValue = &configDiscordRPC}, -#endif + {.name = "skip_intro", .type = CONFIG_TYPE_BOOL, .uintValue = &configSkipIntro}, + #ifdef DISCORDRPC + {.name = "discordrpc_enable", .type = CONFIG_TYPE_BOOL, .boolValue = &configDiscordRPC}, + #endif }; // Reads an entire line from a file (excluding the newline character) and returns an allocated string diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 18e4b919..51064306 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -54,6 +54,7 @@ extern bool configEnableCamera; extern bool configCameraMouse; #endif extern bool configHUD; +extern bool configSkipIntro; #ifdef DISCORDRPC extern bool configDiscordRPC; #endif diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index 9fa7dbfd..6e5d52b2 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -1748,7 +1748,10 @@ void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, co 0x01141045, 0x07a00a00, 0x05200200, - 0x03200200 + 0x03200200, + 0x09200200, + 0x0920038d, + 0x09200045 }; for (size_t i = 0; i < sizeof(precomp_shaders) / sizeof(uint32_t); i++) @@ -1807,4 +1810,4 @@ void gfx_shutdown(void) { if (gfx_wapi->shutdown) gfx_wapi->shutdown(); gfx_wapi = NULL; } -} \ No newline at end of file +} diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index af07b57a..885004df 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -204,7 +204,7 @@ void main_func(void) { #endif char window_title[96] = - "Super Mario 64 PC port (" RAPI_NAME ")" + "Super Mario 64 EX (" RAPI_NAME ")" #ifdef NIGHTLY " nightly " GIT_HASH #endif diff --git a/tools/.gitignore b/tools/.gitignore index 9bd9bbd2..469b3062 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -1,16 +1,16 @@ +/aifc_decode +/aiff_extract_codebook +/armips +/extract_data_for_mio /mio0 /n64cksum /n64graphics -/textconv -/patch_libultra_math -/iplfontutil /n64graphics_ci -/aifc_decode -/aiff_extract_codebook -/vadpcm_enc -/tabledesign -/extract_data_for_mio +/patch_libultra_math /skyconv +/tabledesign +/textconv +/vadpcm_enc !/ido5.3_compiler/lib/*.so !/ido5.3_compiler/usr/lib/*.so !/ido5.3_compiler/usr/lib/*.so.1 diff --git a/tools/Makefile b/tools/Makefile index b8c84775..d663fb0a 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,74 +1,56 @@ -UNAME := $(shell uname) -DEBUG ?= 0 - -ifeq ($(UNAME),Darwin) - OSX_BUILD := -DOSX_BUILD -endif - -ifeq ($(DEBUG),1) - OPT_FLAG := -g -else - OPT_FLAG := -O2 -endif - CC := gcc CXX := g++ -CFLAGS := -Llib -Iinclude -I../include -I . -Wall -Wextra -Wno-unused-parameter $(OSX_BUILD) -pedantic -std=c99 $(OPT_FLAG) -s -PROGRAMS := n64graphics n64graphics_ci mio0 n64cksum textconv patch_libultra_math iplfontutil aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv +CFLAGS := -I../include -I. -Wall -Wextra -Wno-unused-parameter -pedantic -std=c99 -O2 -s +LDFLAGS := -lm +PROGRAMS := n64graphics n64graphics_ci mio0 n64cksum textconv patch_libultra_math aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv + +default: all n64graphics_SOURCES := n64graphics.c utils.c n64graphics_CFLAGS := -DN64GRAPHICS_STANDALONE n64graphics_ci_SOURCES := n64graphics_ci_dir/n64graphics_ci.c n64graphics_ci_dir/exoquant/exoquant.c n64graphics_ci_dir/utils.c -n64graphics_ci_CFLAGS := $(OPT_FLAG) mio0_SOURCES := libmio0.c mio0_CFLAGS := -DMIO0_STANDALONE -n64cksum_SOURCES := n64cksum.c libmio0.c libsm64.c utils.c +n64cksum_SOURCES := n64cksum.c utils.c +n64cksum_CFLAGS := -DN64CKSUM_STANDALONE textconv_SOURCES := textconv.c utf8.c hashtable.c patch_libultra_math_SOURCES := patch_libultra_math.c -iplfontutil_SOURCES := iplfontutil.c -iplfontutil_CFLAGS := $(OPT_FLAG) - aifc_decode_SOURCES := aifc_decode.c -aifc_decode_CFLAGS := $(OPT_FLAG) aiff_extract_codebook_SOURCES := aiff_extract_codebook.c tabledesign_SOURCES := sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/tabledesign.c -tabledesign_CFLAGS := -Wno-uninitialized -Iaudiofile -Laudiofile -laudiofile -lstdc++ -lm +tabledesign_CFLAGS := -Iaudiofile -Wno-uninitialized +tabledesign_LDFLAGS := -Laudiofile -laudiofile -lstdc++ -lm vadpcm_enc_SOURCES := sdk-tools/adpcm/vadpcm_enc.c sdk-tools/adpcm/vpredictor.c sdk-tools/adpcm/quant.c sdk-tools/adpcm/util.c sdk-tools/adpcm/vencode.c vadpcm_enc_CFLAGS := -Wno-unused-result -Wno-uninitialized -Wno-sign-compare -Wno-absolute-value extract_data_for_mio_SOURCES := extract_data_for_mio.c -extract_data_for_mio_CFLAGS := $(OPT_FLAG) skyconv_SOURCES := skyconv.c n64graphics.c utils.c -skyconv_CFLAGS := $(OPT_FLAG) -lm LIBAUDIOFILE := audiofile/libaudiofile.a -all: $(LIBAUDIOFILE) $(PROGRAMS) - $(LIBAUDIOFILE): @$(MAKE) -C audiofile +all: $(LIBAUDIOFILE) $(PROGRAMS) $(CXX_PROGRAMS) + clean: - $(RM) $(PROGRAMS) - $(RM) gen_asset_list + $(RM) $(PROGRAMS) $(CXX_PROGRAMS) $(MAKE) -C audiofile clean define COMPILE $(1): $($1_SOURCES) - $(CC) $(CFLAGS) $(OSX_BUILD) $$^ -lm -o $$@ $($1_CFLAGS) + $(CC) $(CFLAGS) $($1_CFLAGS) $$^ -o $$@ $(LDFLAGS) $($1_LDFLAGS) endef -# Separate build for debugging gen_asset_list.cpp -gen_asset_list: - $(CXX) -std=c++17 gen_asset_list.cpp -lstdc++fs $(OPT_FLAG) -Wall -o gen_asset_list - $(foreach p,$(PROGRAMS),$(eval $(call COMPILE,$(p)))) + +.PHONY: all clean default diff --git a/tools/disassemble_sound.py b/tools/disassemble_sound.py index 3767d15c..603b8e25 100755 --- a/tools/disassemble_sound.py +++ b/tools/disassemble_sound.py @@ -481,11 +481,16 @@ def write_aifc(entry, out): def write_aiff(entry, filename): - with tempfile.NamedTemporaryFile(suffix=".aifc", delete=False) as temp: + temp = tempfile.NamedTemporaryFile(suffix=".aifc", delete=False) + try: write_aifc(entry, temp) temp.flush() + temp.close() aifc_decode = os.path.join(os.path.dirname(__file__), "aifc_decode") subprocess.run([aifc_decode, temp.name, filename], check=True) + finally: + temp.close() + os.remove(temp.name) # Modified from https://stackoverflow.com/a/25935321/1359139, cc by-sa 3.0 diff --git a/tools/iplfontutil.c b/tools/iplfontutil.c deleted file mode 100644 index 937b6f91..00000000 --- a/tools/iplfontutil.c +++ /dev/null @@ -1,179 +0,0 @@ -#include -#include -#include - -#define STBI_NO_LINEAR -#define STBI_NO_PSD -#define STBI_NO_TGA -#define STBI_NO_HDR -#define STBI_NO_PIC -#define STBI_NO_PNM -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include -#define STB_IMAGE_IMPLEMENTATION -#include - -#define GETBIT(buf, idx) ((buf[(idx)/8] >> (7-((idx)%8))) & 1) -#define SETBIT(buf, idx) buf[(idx)/8] |= (1 << (7-((idx)%8))) - -#define IPL3_FONT_NCHARS 50 -#define IPL3_FONT_CHAR_W 13 -#define IPL3_FONT_CHAR_H 14 -#define IPL3_FONT_CHAR_NPIXELS (IPL3_FONT_CHAR_W * IPL3_FONT_CHAR_H) -#define IPL3_FONT_CHAR_NBITS (IPL3_FONT_CHAR_NPIXELS + 2) -#define IPL3_FONT_CHAR_NBYTES (IPL3_FONT_CHAR_NBITS / 8) - -#define IPL3_FONT_FILE_SIZE ((IPL3_FONT_NCHARS * IPL3_FONT_CHAR_NBYTES) + 0x12) - -int ipl3font_decode(const char *binPath, const char *imgPath) -{ - FILE *binfp = fopen(binPath, "rb"); - - if(binfp == NULL) - { - printf("error: could not open %s for input\n", binPath); - return EXIT_FAILURE; - } - - fseek(binfp, 0, SEEK_END); - size_t binSize = ftell(binfp); - - if(binSize != IPL3_FONT_FILE_SIZE) - { - printf("error: font bin size invalid (must be 0x%X bytes)\n", IPL3_FONT_FILE_SIZE); - fclose(binfp); - return EXIT_FAILURE; - } - - rewind(binfp); - - char *binBuf = (char *) malloc(binSize); - if(fread(binBuf, 1, binSize, binfp) != binSize) - { - printf("error: failed to read from %s\n", binPath); - fclose(binfp); - return EXIT_FAILURE; - } - fclose(binfp); - - uint32_t outSize = IPL3_FONT_NCHARS * IPL3_FONT_CHAR_NPIXELS * sizeof(uint32_t); - uint32_t *outRgba32 = (uint32_t *) malloc(outSize); - int outIdx = 0; - - for(int nChar = 0; nChar < IPL3_FONT_NCHARS; nChar++) - { - for(int nRow = 0; nRow < IPL3_FONT_CHAR_H; nRow++) - { - for(int nCol = 0; nCol < IPL3_FONT_CHAR_W; nCol++) - { - int idx = (nChar * IPL3_FONT_CHAR_NBITS) + (nRow * IPL3_FONT_CHAR_W) + nCol; - int bit = GETBIT(binBuf, idx); - outRgba32[outIdx++] = (bit == 1) ? 0xFFFFFFFF : 0xFF000000; - } - } - } - - int stbres = stbi_write_png(imgPath, - IPL3_FONT_CHAR_W, - IPL3_FONT_NCHARS * IPL3_FONT_CHAR_H, - 4, - outRgba32, - IPL3_FONT_CHAR_W * sizeof(uint32_t)); - - if(stbres == 0) - { - printf("error: failed to write %s\n", imgPath); - free(outRgba32); - free(binBuf); - return EXIT_FAILURE; - } - - free(outRgba32); - free(binBuf); - return EXIT_SUCCESS; -} - -int ipl3font_encode(const char *imgPath, const char *binPath) -{ - int x, y, channels_in_file; - uint32_t *inRgba32 = (uint32_t *) stbi_load(imgPath, &x, &y, &channels_in_file, 4); - - if(inRgba32 == NULL) - { - printf("error: failed to load %s\n", imgPath); - return EXIT_FAILURE; - } - - if(x != IPL3_FONT_CHAR_W || y != IPL3_FONT_NCHARS * IPL3_FONT_CHAR_H) - { - printf("error: invalid ipl3 font image dimensions (must be %dx%d)\n", - IPL3_FONT_CHAR_W, IPL3_FONT_NCHARS * IPL3_FONT_CHAR_H); - stbi_image_free(inRgba32); - return EXIT_FAILURE; - } - - char *out = calloc(IPL3_FONT_FILE_SIZE, 1); - - int inIdx = 0; - - for(int nChar = 0; nChar < IPL3_FONT_NCHARS; nChar++) - { - for(int nRow = 0; nRow < IPL3_FONT_CHAR_H; nRow++) - { - for(int nCol = 0; nCol < IPL3_FONT_CHAR_W; nCol++) - { - // source pixels that are not 0xFFFFFFFF are ignored - if(inRgba32[inIdx++] == 0xFFFFFFFF) - { - int idx = (nChar * IPL3_FONT_CHAR_NBITS) + (nRow * IPL3_FONT_CHAR_W) + nCol; - SETBIT(out, idx); - } - } - } - } - - FILE * outfp = fopen(binPath, "wb"); - - if(outfp == NULL) - { - printf("error: failed to write to %s\n", binPath); - stbi_image_free(inRgba32); - free(out); - return EXIT_FAILURE; - } - - fwrite(out, 1, IPL3_FONT_FILE_SIZE, outfp); - fclose(outfp); - - stbi_image_free(inRgba32); - free(out); - - return EXIT_SUCCESS; -} - -int main(int argc, const char *argv[]) -{ - if(argc < 4) - { - printf("error: no paths\n"); - printf("iplfontutil e \n"); - printf("iplfontutil d \n"); - return EXIT_FAILURE; - } - - const char *mode = argv[1]; - - if(strcmp(mode, "e") == 0) - { - return ipl3font_encode(argv[2], argv[3]); - } - else if(strcmp(mode, "d") == 0) - { - return ipl3font_decode(argv[2], argv[3]); - } - else - { - printf("error: unknown mode\n"); - return EXIT_FAILURE; - } -} diff --git a/tools/libsm64.c b/tools/libsm64.c deleted file mode 100644 index 575b8c7f..00000000 --- a/tools/libsm64.c +++ /dev/null @@ -1,439 +0,0 @@ -#include -#include -#include - -#include "libmio0.h" -#include "libsm64.h" -#include "utils.h" - -// TODO: make these configurable -#define IN_START_ADDR 0x000D0000 -#define OUT_START_ADDR 0x00800000 - -// MIPS instruction decoding -#define OPCODE(IBUF_) ((IBUF_)[0] & 0xFC) -#define RS(IBUF_) ( (((IBUF_)[0] & 0x3) < 3) | (((IBUF_)[1] & 0xE0) > 5) ) -#define RT(IBUF_) ((IBUF_)[1] & 0x1F) - -typedef struct -{ - unsigned int old; // MIO0 address in original ROM - unsigned int old_end; // ending MIO0 address in original ROM - unsigned int new; // starting MIO0 address in extended ROM - unsigned int new_end; // ending MIO0 address in extended ROM - unsigned int addr; // ASM address for referenced pointer - unsigned int a1_addiu; // ASM offset for ADDIU for A1 - unsigned char command; // command type: 0x1A or 0x18 (or 0xFF for ASM) -} ptr_t; - -// find a pointer in the list and return index -// ptr: address to find in table old values -// table: list of addresses to MIO0 data -// count: number of addresses in table -// returns index in table if found, -1 otherwise -static int find_ptr(unsigned int ptr, ptr_t table[], int count) -{ - int i; - for (i = 0; i < count; i++) { - if (ptr == table[i].old) { - return i; - } - } - return -1; -} - -// find locations of existing MIO0 data -// buf: buffer containing SM64 data -// length: length of buf -// table: table to store MIO0 addresses in -// returns number of MIO0 files stored in table old values -static int find_mio0(unsigned char *buf, unsigned int length, ptr_t table[]) -{ - unsigned int addr; - int count = 0; - - // MIO0 data is on 16-byte boundaries - for (addr = IN_START_ADDR; addr < length; addr += 16) { - if (!memcmp(&buf[addr], "MIO0", 4)) { - table[count].old = addr; - count++; - } - } - return count; -} - -// find pointers to MIO0 files and stores command type -// buf: buffer containing SM64 data -// length: length of buf -// table: list of addresses to MIO0 data -// count: number of addresses in table -static void find_pointers(unsigned char *buf, unsigned int length, ptr_t table[], int count) -{ - unsigned int addr; - unsigned int ptr; - int idx; - - for (addr = IN_START_ADDR; addr < length; addr += 4) { - if ((buf[addr] == 0x18 || buf[addr] == 0x1A) && buf[addr+1] == 0x0C && buf[addr+2] == 0x00) { - ptr = read_u32_be(&buf[addr+4]); - idx = find_ptr(ptr, table, count); - if (idx >= 0) { - table[idx].command = buf[addr]; - table[idx].old_end = read_u32_be(&buf[addr+8]); - } - } - } -} - -static unsigned int la2int(unsigned char *buf, unsigned int lui, unsigned int addiu) -{ - unsigned short addr_low, addr_high; - addr_high = read_u16_be(&buf[lui + 0x2]); - addr_low = read_u16_be(&buf[addiu + 0x2]); - // ADDIU sign extends which causes the encoded high val to be +1 if low MSb is set - if (addr_low & 0x8000) { - addr_high--; - } - return (addr_high << 16) | addr_low; -} - -// find references to the MIO0 blocks in ASM and store type -// buf: buffer containing SM64 data -// length: length of buf -// table: list of addresses to MIO0 data -// count: number of addresses in table -static void find_asm_pointers(unsigned char *buf, ptr_t table[], int count) -{ - // find the ASM references - // looking for some code that follows one of the below patterns: - // lui a1, start_upper lui a1, start_upper - // lui a2, end_upper lui a2, end_upper - // addiu a2, a2, end_lower addiu a2, a2, end_lower - // addiu a1, a1, start_lower jal function - // jal function addiu a1, a1, start_lower - unsigned int addr; - unsigned int ptr; - unsigned int end; - int idx; - for (addr = 0; addr < IN_START_ADDR; addr += 4) { - if (OPCODE(&buf[addr]) == 0x3C && OPCODE(&buf[addr+4]) == 0x3C && OPCODE(&buf[addr+8]) == 0x24) { - unsigned int a1_addiu = 0; - if (OPCODE(&buf[addr+0xc]) == 0x24) { - a1_addiu = 0xc; - } else if (OPCODE(&buf[addr+0x10]) == 0x24) { - a1_addiu = 0x10; - } - if (a1_addiu) { - if ( (RT(&buf[addr]) == RT(&buf[addr+a1_addiu])) - && (RT(&buf[addr+4]) == RT(&buf[addr+8])) ) { - ptr = la2int(buf, addr, addr + a1_addiu); - end = la2int(buf, addr + 4, addr + 0x8); - idx = find_ptr(ptr, table, count); - if (idx >= 0) { - INFO("Found ASM reference to %X at %X\n", ptr, addr); - table[idx].command = 0xFF; - table[idx].addr = addr; - table[idx].new_end = end; - table[idx].a1_addiu = a1_addiu; - } - } - } - } - } -} - -// adjust pointers to from old to new locations -// buf: buffer containing SM64 data -// length: length of buf -// table: list of addresses to MIO0 data -// count: number of addresses in table -static void sm64_adjust_pointers(unsigned char *buf, unsigned int length, ptr_t table[], int count) -{ - unsigned int addr; - unsigned int old_ptr; - int idx; - for (addr = IN_START_ADDR; addr < length; addr += 4) { - if ((buf[addr] == 0x17 || buf[addr] == 0x18 || buf[addr] == 0x1A) && buf[addr+1] == 0x0C && buf[addr+2] < 0x02) { - old_ptr = read_u32_be(&buf[addr+4]); - idx = find_ptr(old_ptr, table, count); - if (idx >= 0) { - INFO("Old pointer at %X = ", addr); - INFO_HEX(&buf[addr], 12); - INFO("\n"); - write_u32_be(&buf[addr+4], table[idx].new); - write_u32_be(&buf[addr+8], table[idx].new_end); - if (buf[addr] != table[idx].command) { - buf[addr] = table[idx].command; - } - INFO("NEW pointer at %X = ", addr); - INFO_HEX(&buf[addr], 12); - INFO("\n"); - } - } - } -} - -// adjust 'pointer' encoded in ASM LUI and ADDIU instructions -static void sm64_adjust_asm(unsigned char *buf, ptr_t table[], int count) -{ - unsigned int addr; - int i; - unsigned short addr_low, addr_high; - for (i = 0; i < count; i++) { - if (table[i].command == 0xFF) { - addr = table[i].addr; - INFO("Old ASM reference at %X = ", addr); - INFO_HEX(&buf[addr], 0x14); - INFO("\n"); - addr_low = table[i].new & 0xFFFF; - addr_high = (table[i].new >> 16) & 0xFFFF; - // ADDIU sign extends which causes the summed high to be 1 less if low MSb is set - if (addr_low & 0x8000) { - addr_high++; - } - write_u16_be(&buf[addr + 0x2], addr_high); - write_u16_be(&buf[addr + table[i].a1_addiu+2], addr_low); - - addr_low = table[i].new_end & 0xFFFF; - addr_high = (table[i].new_end >> 16) & 0xFFFF; - if (addr_low & 0x8000) { - addr_high++; - } - write_u16_be(&buf[addr + 0x6], addr_high); - write_u16_be(&buf[addr + 0xa], addr_low); - INFO("NEW ASM reference at %X = ", addr); - INFO_HEX(&buf[addr], 0x14); - INFO(" [%06X - %06X]\n", table[i].new, table[i].new_end); - } - } -} - -// compute N64 ROM checksums -// buf: buffer with extended SM64 data -// cksum: two element array to write CRC1 and CRC2 to -// TODO: this could be hand optimized -static void sm64_calc_checksums(unsigned char *buf, unsigned int cksum[]) { - unsigned int t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; - unsigned int s0, s6; - unsigned int a0, a1, a2, a3, at; - unsigned int lo; - unsigned int v0, v1; - unsigned int ra; - - // derived from the SM64 boot code - s6 = 0x3f; - a0 = 0x1000; // 59c: 8d640008 lw a0,8(t3) - a1 = s6; // 5a0: 02c02825 move a1,s6 - at = 0x5d588b65; // 5a4: 3c015d58 lui at,0x5d58 - // 5a8: 34218b65 ori at,at,0x8b65 - lo = a1 * at; // 5ac: 00a10019 multu a1,at 16 F8CA 4DDB - - ra = 0x100000; // 5bc: 3c1f0010 lui ra,0x10 - v1 = 0; // 5c0: 00001825 move v1,zero - t0 = 0; // 5c4: 00004025 move t0,zero - t1 = a0; // 5c8: 00804825 move t1,a0 - t5 = 32; // 5cc: 240d0020 li t5,32 - v0 = lo; // 5d0: 00001012 mflo v0 - v0++; // 5d4: 24420001 addiu v0,v0,1 - a3 = v0; // 5d8: 00403825 move a3,v0 - t2 = v0; // 5dc: 00405025 move t2,v0 - t3 = v0; // 5e0: 00405825 move t3,v0 - s0 = v0; // 5e4: 00408025 move s0,v0 - a2 = v0; // 5e8: 00403025 move a2,v0 - t4 = v0; // 5ec: 00406025 move t4,v0 - - do { - v0 = read_u32_be(&buf[t1]); // 5f0: 8d220000 lw v0,0(t1) - v1 = a3 + v0; // 5f4: 00e21821 addu v1,a3,v0 - at = (v1 < a3); // 5f8: 0067082b sltu at,v1,a3 - a1 = v1; // 600: 00602825 move a1,v1 branch delay slot - if (at) { // 5fc: 10200002 beqz at,0x608 - t2++; // 604: 254a0001 addiu t2,t2,1 - } - v1 = v0 & 0x1F; // 608: 3043001f andi v1,v0,0x1f - t7 = t5 - v1; // 60c: 01a37823 subu t7,t5,v1 - t8 = v0 >> t7; // 610: 01e2c006 srlv t8,v0,t7 - t6 = v0 << v1; // 614: 00627004 sllv t6,v0,v1 - a0 = t6 | t8; // 618: 01d82025 or a0,t6,t8 - at = (a2 < v0); // 61c: 00c2082b sltu at,a2,v0 - a3 = a1; // 620: 00a03825 move a3,a1 - t3 ^= v0; // 624: 01625826 xor t3,t3,v0 - s0 += a0; // 62c: 02048021 addu s0,s0,a0 branch delay slot - if (at) { // 628: 10200004 beqz at,0x63c - t9 = a3 ^ v0; // 630: 00e2c826 xor t9,a3,v0 - // 634: 10000002 b 0x640 - a2 ^= t9; // 638: 03263026 xor a2,t9,a2 branch delay - } else { - a2 ^= a0; // 63c: 00c43026 xor a2,a2,a0 - } - t0 += 4; // 640: 25080004 addiu t0,t0,4 - t7 = v0 ^ s0; // 644: 00507826 xor t7,v0,s0 - t1 += 4; // 648: 25290004 addiu t1,t1,4 - t4 += t7; // 650: 01ec6021 addu t4,t7,t4 branch delay - } while (t0 != ra); // 64c: 151fffe8 bne t0,ra,0x5f0 - t6 = a3 ^ t2; // 654: 00ea7026 xor t6,a3,t2 - a3 = t6 ^ t3; // 658: 01cb3826 xor a3,t6,t3 - t8 = s0 ^ a2; // 65c: 0206c026 xor t8,s0,a2 - s0 = t8 ^ t4; // 660: 030c8026 xor s0,t8,t4 - - cksum[0] = a3; - cksum[1] = s0; -} - -rom_type sm64_rom_type(unsigned char *buf, unsigned int length) -{ - const unsigned char bs[] = {0x37, 0x80, 0x40, 0x12}; - const unsigned char be[] = {0x80, 0x37, 0x12, 0x40}; - const unsigned char le[] = {0x40, 0x12, 0x37, 0x80}; - if (!memcmp(buf, bs, sizeof(bs)) && length == (8*MB)) { - return ROM_SM64_BS; - } - if (!memcmp(buf, bs, sizeof(le)) && length == (8*MB)) { - return ROM_SM64_LE; - } - if (!memcmp(buf, be, sizeof(be))) { - if (length == 8*MB) { - return ROM_SM64_BE; - } else if (length > 8*MB) { - return ROM_SM64_BE_EXT; - } - } - return ROM_INVALID; -} - -rom_version sm64_rom_version(unsigned char *buf) -{ - typedef struct {const unsigned char cksum1[4]; const rom_version version;} version_entry; - const version_entry version_table[] = - { - { {0x63, 0x5a, 0x2b, 0xff}, VERSION_SM64_U}, - { {0xa0, 0x3c, 0xf0, 0x36}, VERSION_SM64_E}, - { {0x4e, 0xaa, 0x3d, 0x0e}, VERSION_SM64_J}, - { {0xd6, 0xfb, 0xa4, 0xa8}, VERSION_SM64_SHINDOU}, - }; - for (unsigned int i = 0; i < DIM(version_table); i++) { - if (!memcmp(&buf[0x10], version_table[i].cksum1, 4)) { - return version_table[i].version; - } - } - return VERSION_UNKNOWN; -} - -void sm64_decompress_mio0(const sm64_config *config, - unsigned char *in_buf, - unsigned int in_length, - unsigned char *out_buf) -{ -#define MAX_PTRS 128 -#define COMPRESSED_LENGTH 2 - mio0_header_t head; - int bit_length; - int move_offset; - unsigned int in_addr; - unsigned int out_addr = OUT_START_ADDR; - unsigned int align_add = config->alignment - 1; - unsigned int align_mask = ~align_add; - ptr_t ptr_table[MAX_PTRS]; - int ptr_count; - int i; - - // find MIO0 locations and pointers - ptr_count = find_mio0(in_buf, in_length, ptr_table); - find_pointers(in_buf, in_length, ptr_table, ptr_count); - find_asm_pointers(in_buf, ptr_table, ptr_count); - - // extract each MIO0 block and prepend fake MIO0 header for 0x1A command and ASM references - for (i = 0; i < ptr_count; i++) { - in_addr = ptr_table[i].old; - if (!memcmp(&in_buf[in_addr], "MIO0", 4)) { - unsigned int end; - int length; - int is_mio0 = 0; - // align output address - out_addr = (out_addr + align_add) & align_mask; - length = mio0_decode(&in_buf[in_addr], &out_buf[out_addr], &end); - if (length > 0) { - // dump MIO0 data and decompressed data to file - if (config->dump) { - char filename[FILENAME_MAX]; - sprintf(filename, MIO0_DIR "/%08X.mio", in_addr); - write_file(filename, &in_buf[in_addr], end); - sprintf(filename, MIO0_DIR "/%08X", in_addr); - write_file(filename, &out_buf[out_addr], length); - } - // 0x1A commands and ASM references need fake MIO0 header - // relocate data and add MIO0 header with all uncompressed data - if (ptr_table[i].command == 0x1A || ptr_table[i].command == 0xFF) { - bit_length = (length + 7) / 8 + 2; - move_offset = MIO0_HEADER_LENGTH + bit_length + COMPRESSED_LENGTH; - memmove(&out_buf[out_addr + move_offset], &out_buf[out_addr], length); - head.dest_size = length; - head.comp_offset = move_offset - COMPRESSED_LENGTH; - head.uncomp_offset = move_offset; - mio0_encode_header(&out_buf[out_addr], &head); - memset(&out_buf[out_addr + MIO0_HEADER_LENGTH], 0xFF, head.comp_offset - MIO0_HEADER_LENGTH); - memset(&out_buf[out_addr + head.comp_offset], 0x0, 2); - length += head.uncomp_offset; - is_mio0 = 1; - } else if (ptr_table[i].command == 0x18) { - // 0x18 commands become 0x17 - ptr_table[i].command = 0x17; - } - // use output from decoder to find end of ASM referenced MIO0 blocks - if (ptr_table[i].old_end == 0x00) { - ptr_table[i].old_end = in_addr + end; - } - INFO("MIO0 file %08X-%08X decompressed to %08X-%08X as raw data%s\n", - in_addr, ptr_table[i].old_end, out_addr, out_addr + length, - is_mio0 ? " with a MIO0 header" : ""); - if (config->fill) { - INFO("Filling old MIO0 with 0x01 from %X length %X\n", in_addr, end); - memset(&out_buf[in_addr], 0x01, end); - } - // keep track of new pointers - ptr_table[i].new = out_addr; - ptr_table[i].new_end = out_addr + length; - out_addr += length + config->padding; - } else { - ERROR("Error decoding MIO0 block at %X\n", in_addr); - } - } - } - - INFO("Ending offset: %X\n", out_addr); - - // adjust pointers and ASM pointers to new values - sm64_adjust_pointers(out_buf, in_length, ptr_table, ptr_count); - sm64_adjust_asm(out_buf, ptr_table, ptr_count); -} - -void sm64_update_checksums(unsigned char *buf) -{ - unsigned int cksum_offsets[] = {0x10, 0x14}; - unsigned int read_cksum[2]; - unsigned int calc_cksum[2]; - int i; - - // assume CIC-NUS-6102 - INFO("BootChip: CIC-NUS-6102\n"); - - // calculate new N64 header checksum - sm64_calc_checksums(buf, calc_cksum); - - // mimic the n64sums output - for (i = 0; i < 2; i++) { - read_cksum[i] = read_u32_be(&buf[cksum_offsets[i]]); - INFO("CRC%d: 0x%08X ", i+1, read_cksum[i]); - INFO("Calculated: 0x%08X ", calc_cksum[i]); - if (calc_cksum[i] == read_cksum[i]) { - INFO("(Good)\n"); - } else { - INFO("(Bad)\n"); - } - } - - // write checksums into header - INFO("Writing back calculated Checksum\n"); - write_u32_be(&buf[cksum_offsets[0]], calc_cksum[0]); - write_u32_be(&buf[cksum_offsets[1]], calc_cksum[1]); -} diff --git a/tools/libsm64.h b/tools/libsm64.h deleted file mode 100644 index 9209970c..00000000 --- a/tools/libsm64.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef LIBSM64_H_ -#define LIBSM64_H_ - -#define MIO0_DIR "mio0files" - -// typedefs -typedef enum -{ - ROM_INVALID, // not valid SM64 ROM - ROM_SM64_BS, // SM64 byte-swapped (BADC) - ROM_SM64_BE, // SM64 big-endian (ABCD) - ROM_SM64_LE, // SM64 little-endian - ROM_SM64_BE_EXT, // SM64 big-endian, extended -} rom_type; - -typedef enum -{ - VERSION_UNKNOWN, - VERSION_SM64_U, - VERSION_SM64_E, - VERSION_SM64_J, - VERSION_SM64_SHINDOU, -} rom_version; - -typedef struct -{ - char *in_filename; - char *ext_filename; - unsigned int ext_size; - unsigned int padding; - unsigned int alignment; - char fill; - char dump; -} sm64_config; - -// determine ROM type based on data -// buf: buffer containing raw SM64 ROM file data -// length: length of 'buf' -// returns SM64 ROM type or invalid -rom_type sm64_rom_type(unsigned char *buf, unsigned int length); - -// determine SM64 ROM type based on cksum data -// buf: buffer containing raw SM64 ROM file data -// returns SM64 ROM version or unknown -rom_version sm64_rom_version(unsigned char *buf); - -// find and decompress all MIO0 blocks -// config: configuration to determine alignment, padding and size -// in_buf: buffer containing entire contents of SM64 data in big endian -// length: length of in_buf -// out_buf: buffer containing extended SM64 -void sm64_decompress_mio0(const sm64_config *config, - unsigned char *in_buf, - unsigned int in_length, - unsigned char *out_buf); - -// update N64 header checksums -// buf: buffer containing ROM data -// checksums are written into the buffer -void sm64_update_checksums(unsigned char *buf); - -#endif // LIBSM64_H_ diff --git a/tools/n64cksum.c b/tools/n64cksum.c index f377f9a3..dd7f0133 100644 --- a/tools/n64cksum.c +++ b/tools/n64cksum.c @@ -1,11 +1,95 @@ #include #include -#include "libsm64.h" +#include "n64cksum.h" #include "utils.h" #define N64CKSUM_VERSION "0.1" +// compute N64 ROM checksums +// buf: buffer with extended SM64 data +// cksum: two element array to write CRC1 and CRC2 to +void n64cksum_calc_6102(unsigned char *buf, unsigned int cksum[]) { + uint32_t t2, t3, t4, t6, t7, t8, s0; + uint32_t a0, a1, a2, a3; + uint32_t v0, v1; + uint32_t seed, end_offset, cur_offset, buf_offset; + + // derived from the SM64 boot code + seed = 0xF8CA4DDB; // 0x3f * 0x5d588b65; + end_offset = 0x100000; + cur_offset = 0; + buf_offset = 0x1000; + seed++; + a3 = seed; + t2 = seed; + t3 = seed; + s0 = seed; + a2 = seed; + t4 = seed; + + do { + v0 = read_u32_be(&buf[buf_offset]); + v1 = a3 + v0; + a1 = v1; + if (v1 < a3) { + t2++; + } + v1 = v0 & 0x1F; + t7 = 32 - v1; + t8 = v0 >> t7; + t6 = v0 << v1; + a0 = t6 | t8; + a3 = a1; + t3 ^= v0; + s0 += a0; + if (a2 < v0) { + a2 ^= a3 ^ v0; + } else { + a2 ^= a0; + } + cur_offset += 4; + t7 = v0 ^ s0; + buf_offset += 4; + t4 += t7; + } while (cur_offset != end_offset); + + cksum[0] = (a3 ^ t2) ^ t3; + cksum[1] = (s0 ^ a2) ^ t4; +} + +void n64cksum_update_checksums(uint8_t *buf) +{ + unsigned int cksum_offsets[] = {0x10, 0x14}; + uint32_t read_cksum[2]; + uint32_t calc_cksum[2]; + int i; + + // assume CIC-NUS-6102 + INFO("BootChip: CIC-NUS-6102\n"); + + // calculate new N64 header checksum + n64cksum_calc_6102(buf, calc_cksum); + + // mimic the n64sums output + for (i = 0; i < 2; i++) { + read_cksum[i] = read_u32_be(&buf[cksum_offsets[i]]); + INFO("CRC%d: 0x%08X ", i+1, read_cksum[i]); + INFO("Calculated: 0x%08X ", calc_cksum[i]); + if (calc_cksum[i] == read_cksum[i]) { + INFO("(Good)\n"); + } else { + INFO("(Bad)\n"); + } + } + + // write checksums into header + INFO("Writing back calculated Checksum\n"); + write_u32_be(&buf[cksum_offsets[0]], calc_cksum[0]); + write_u32_be(&buf[cksum_offsets[1]], calc_cksum[1]); +} + +#ifdef N64CKSUM_STANDALONE static void print_usage(void) { ERROR("Usage: n64cksum ROM [ROM_OUT]\n" @@ -42,7 +126,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - sm64_update_checksums(rom_data); + n64cksum_update_checksums(rom_data); write_length = write_file(file_out, rom_data, length); @@ -55,3 +139,4 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; } +#endif // N64CKSUM_STANDALONE diff --git a/tools/n64cksum.h b/tools/n64cksum.h new file mode 100644 index 00000000..cf6b9ba4 --- /dev/null +++ b/tools/n64cksum.h @@ -0,0 +1,16 @@ +#ifndef N64CKSUM_H_ +#define N64CKSUM_H_ + +#include + +// compute N64 ROM checksums +// buf: buffer with extended SM64 data +// cksum: two element array to write CRC1 and CRC2 to +void n64cksum_calc_6102(unsigned char *buf, unsigned int cksum[]); + +// update N64 header checksums +// buf: buffer containing ROM data +// checksums are written into the buffer +void n64cksum_update_checksums(uint8_t *buf); + +#endif // N64CKSUM_H_ diff --git a/tools/n64graphics.c b/tools/n64graphics.c index e07069dc..814dc56d 100644 --- a/tools/n64graphics.c +++ b/tools/n64graphics.c @@ -21,14 +21,18 @@ #define SCALE_3_8(VAL_) ((VAL_) * 0x24) #define SCALE_8_3(VAL_) ((VAL_) / 0x24) -typedef enum -{ - IMG_FORMAT_RGBA, - IMG_FORMAT_IA, - IMG_FORMAT_I, - IMG_FORMAT_CI, -} img_format; +typedef struct +{ + enum + { + IMG_FORMAT_RGBA, + IMG_FORMAT_IA, + IMG_FORMAT_I, + IMG_FORMAT_CI, + } format; + int depth; +} img_format; //--------------------------------------------------------- // N64 RGBA/IA/I/CI -> internal RGBA/IA @@ -151,7 +155,10 @@ ia *raw2i(const uint8_t *raw, int width, int height, int depth) bits >>= 4; } img[i].intensity = SCALE_4_8(bits); - img[i].alpha = 0xFF; + img[i].alpha = img[i].intensity; // alpha copy intensity + // TODO: modes + // img[i].alpha = 0xFF; // alpha = 1 + // img[i].alpha = img[i].intensity ? 0xFF : 0x00; // binary } break; default: @@ -162,33 +169,33 @@ ia *raw2i(const uint8_t *raw, int width, int height, int depth) return img; } -// extract RGBA from CI raw data and palette -// TODO: different palette depths -rgba *rawci2rgba(const uint8_t *rawci, const uint8_t *palette, int width, int height, int depth) +// convert CI raw data and palette to raw data (either RGBA16 or IA16) +uint8_t *ci2raw(const uint8_t *rawci, const uint8_t *palette, int width, int height, int ci_depth) { - uint8_t *raw_rgba; - rgba *img = NULL; + uint8_t *raw; int raw_size; // first convert to raw RGBA - raw_size = 2 * width * height; - raw_rgba = malloc(raw_size); - if (!raw_rgba) { + raw_size = sizeof(uint16_t) * width * height; + raw = malloc(raw_size); + if (!raw) { ERROR("Error allocating %u bytes\n", raw_size); return NULL; } for (int i = 0; i < width * height; i++) { - raw_rgba[2*i] = palette[2*rawci[i]]; - raw_rgba[2*i+1] = palette[2*rawci[i]+1]; + int pal_idx = rawci[i]; + if (ci_depth == 4) { + int byte_idx = i / 2; + int nibble = 1 - (i % 2); + int shift = 4 * nibble; + pal_idx = (rawci[byte_idx] >> shift) & 0xF; + } + raw[2*i] = palette[2*pal_idx]; + raw[2*i+1] = palette[2*pal_idx+1]; } - // then convert to RGBA image data - img = raw2rgba(raw_rgba, width, height, depth); - - free(raw_rgba); - - return img; + return raw; } @@ -199,7 +206,7 @@ rgba *rawci2rgba(const uint8_t *rawci, const uint8_t *palette, int width, int he int rgba2raw(uint8_t *raw, const rgba *img, int width, int height, int depth) { - int size = width * height * depth / 8; + int size = (width * height * depth + 7) / 8; INFO("Converting RGBA%d %dx%d to raw\n", depth, width, height); if (depth == 16) { @@ -229,7 +236,7 @@ int rgba2raw(uint8_t *raw, const rgba *img, int width, int height, int depth) int ia2raw(uint8_t *raw, const ia *img, int width, int height, int depth) { - int size = width * height * depth / 8; + int size = (width * height * depth + 7) / 8; INFO("Converting IA%d %dx%d to raw\n", depth, width, height); switch (depth) { @@ -281,7 +288,7 @@ int ia2raw(uint8_t *raw, const ia *img, int width, int height, int depth) int i2raw(uint8_t *raw, const ia *img, int width, int height, int depth) { - int size = width * height * depth / 8; + int size = (width * height * depth + 7) / 8; INFO("Converting I%d %dx%d to raw\n", depth, width, height); switch (depth) { @@ -494,6 +501,70 @@ ia *png2ia(const char *png_filename, int *width, int *height) return img; } +// find index of palette color +// return -1 if not found +static int pal_find_color(const palette_t *pal, uint16_t val) +{ + for (int i = 0; i < pal->used; i++) { + if (pal->data[i] == val) { + return i; + } + } + return -1; +} + +// find value in palette, or add if not there +// returns palette index entered or -1 if palette full +static int pal_add_color(palette_t *pal, uint16_t val) +{ + int idx; + idx = pal_find_color(pal, val); + if (idx < 0) { + if (pal->used == pal->max) { + ERROR("Error: trying to use more than %d\n", pal->max); + } else { + idx = pal->used; + pal->data[pal->used] = val; + pal->used++; + } + } + return idx; +} + +// convert from raw (RGBA16 or IA16) format to CI + palette +// returns 1 on success +int raw2ci(uint8_t *rawci, palette_t *pal, const uint8_t *raw, int raw_len, int ci_depth) +{ + // assign colors to palette + pal->used = 0; + memset(pal->data, 0, sizeof(pal->data)); + int ci_idx = 0; + for (int i = 0; i < raw_len; i += sizeof(uint16_t)) { + uint16_t val = read_u16_be(&raw[i]); + int pal_idx = pal_add_color(pal, val); + if (pal_idx < 0) { + ERROR("Error adding color @ (%d): %d (used: %d/%d)\n", i, pal_idx, pal->used, pal->max); + return 0; + } else { + switch (ci_depth) { + case 8: + rawci[ci_idx] = (uint8_t)pal_idx; + break; + case 4: + { + int byte_idx = ci_idx / 2; + int nibble = 1 - (ci_idx % 2); + uint8_t mask = 0xF << (4 * (1 - nibble)); + rawci[byte_idx] = (rawci[byte_idx] & mask) | (pal_idx << (4 * nibble)); + break; + } + } + ci_idx++; + } + } + return 1; +} + const char *n64graphics_get_read_version(void) { return "stb_image 2.19"; @@ -505,7 +576,7 @@ const char *n64graphics_get_write_version(void) } #ifdef N64GRAPHICS_STANDALONE -#define N64GRAPHICS_VERSION "0.3" +#define N64GRAPHICS_VERSION "0.4" #include typedef enum @@ -518,65 +589,70 @@ typedef struct { char *img_filename; char *bin_filename; + char *pal_filename; tool_mode mode; - unsigned int offset; + unsigned int bin_offset; + unsigned int pal_offset; img_format format; - int depth; + img_format pal_format; int width; int height; - int truncate; + int bin_truncate; + int pal_truncate; } graphics_config; static const graphics_config default_config = { .img_filename = NULL, .bin_filename = NULL, + .pal_filename = NULL, .mode = MODE_EXPORT, - .offset = 0, - .format = IMG_FORMAT_RGBA, - .depth = 16, + .bin_offset = 0, + .pal_offset = 0, + .format = {IMG_FORMAT_RGBA, 16}, + .pal_format = {IMG_FORMAT_RGBA, 16}, .width = 32, .height = 32, - .truncate = 1, + .bin_truncate = 1, + .pal_truncate = 1, }; typedef struct { const char *name; img_format format; - int depth; } format_entry; static const format_entry format_table[] = { - {"rgba16", IMG_FORMAT_RGBA, 16}, - {"rgba32", IMG_FORMAT_RGBA, 32}, - {"ia1", IMG_FORMAT_IA, 1}, - {"ia4", IMG_FORMAT_IA, 4}, - {"ia8", IMG_FORMAT_IA, 8}, - {"ia16", IMG_FORMAT_IA, 16}, - {"i4", IMG_FORMAT_I, 4}, - {"i8", IMG_FORMAT_I, 8}, - {"ci8", IMG_FORMAT_CI, 8}, - {"ci16", IMG_FORMAT_CI, 16}, + {"rgba16", {IMG_FORMAT_RGBA, 16}}, + {"rgba32", {IMG_FORMAT_RGBA, 32}}, + {"ia1", {IMG_FORMAT_IA, 1}}, + {"ia4", {IMG_FORMAT_IA, 4}}, + {"ia8", {IMG_FORMAT_IA, 8}}, + {"ia16", {IMG_FORMAT_IA, 16}}, + {"i4", {IMG_FORMAT_I, 4}}, + {"i8", {IMG_FORMAT_I, 8}}, + {"ci8", {IMG_FORMAT_CI, 8}}, + {"ci4", {IMG_FORMAT_CI, 4}}, }; -static const char *format2str(img_format format, int depth) +static const char *format2str(const img_format *format) { for (unsigned i = 0; i < DIM(format_table); i++) { - if (format == format_table[i].format && depth == format_table[i].depth) { + if (format->format == format_table[i].format.format && format->depth == format_table[i].format.depth) { return format_table[i].name; } } return "unknown"; } -static int parse_format(graphics_config *config, const char *str) +static int parse_format(img_format *format, const char *str) { for (unsigned i = 0; i < DIM(format_table); i++) { if (!strcasecmp(str, format_table[i].name)) { - config->format = format_table[i].format; - config->depth = format_table[i].depth; + format->format = format_table[i].format.format; + format->depth = format_table[i].format.depth; return 1; } } @@ -585,24 +661,30 @@ static int parse_format(graphics_config *config, const char *str) static void print_usage(void) { - ERROR("Usage: n64graphics -e/-i BIN_FILE -g PNG_FILE [-o offset] [-f FORMAT] [-w WIDTH] [-h HEIGHT] [-V]\n" + ERROR("Usage: n64graphics -e/-i BIN_FILE -g IMG_FILE [-p PAL_FILE] [-o BIN_OFFSET] [-P PAL_OFFSET] [-f FORMAT] [-c CI_FORMAT] [-w WIDTH] [-h HEIGHT] [-V]\n" "\n" "n64graphics v" N64GRAPHICS_VERSION ": N64 graphics manipulator\n" "\n" "Required arguments:\n" - " -e BIN_FILE export from BIN_FILE to PNG_FILE\n" - " -i BIN_FILE import from PNG_FILE to BIN_FILE\n" - " -g PNG_FILE graphics file to import/export (.png)\n" + " -e BIN_FILE export from BIN_FILE to PNG_FILE\n" + " -i BIN_FILE import from PNG_FILE to BIN_FILE\n" + " -g IMG_FILE graphics file to import/export (.png)\n" "Optional arguments:\n" - " -o OFFSET starting offset in BIN_FILE (prevents truncation during import)\n" - " -f FORMAT texture format: rgba16, rgba32, ia1, ia4, ia8, ia16, i4, i8, ci8, ci16 (default: %s)\n" - " -w WIDTH export texture width (default: %d)\n" - " -h HEIGHT export texture height (default: %d)\n" - " -v verbose logging\n" - " -V print version information\n", - format2str(default_config.format, default_config.depth), + " -o BIN_OFFSET starting offset in BIN_FILE (prevents truncation during import)\n" + " -f FORMAT texture format: rgba16, rgba32, ia1, ia4, ia8, ia16, i4, i8, ci4, ci8 (default: %s)\n" + " -w WIDTH export texture width (default: %d)\n" + " -h HEIGHT export texture height (default: %d)\n" + "CI arguments:\n" + " -c CI_FORMAT CI palette format: rgba16, ia16 (default: %s)\n" + " -p PAL_FILE palette binary file to import/export from/to\n" + " -P PAL_OFFSET starting offset in PAL_FILE (prevents truncation during import)\n" + "Other arguments:\n" + " -v verbose logging\n" + " -V print version information\n", + format2str(&default_config.format), default_config.width, - default_config.height); + default_config.height, + format2str(&default_config.pal_format)); } static void print_version(void) @@ -619,6 +701,12 @@ static int parse_arguments(int argc, char *argv[], graphics_config *config) for (int i = 1; i < argc; i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { + case 'c': + if (++i >= argc) return 0; + if (!parse_format(&config->pal_format, argv[i])) { + return 0; + } + break; case 'e': if (++i >= argc) return 0; config->bin_filename = argv[i]; @@ -626,15 +714,10 @@ static int parse_arguments(int argc, char *argv[], graphics_config *config) break; case 'f': if (++i >= argc) return 0; - if (!parse_format(config, argv[i])) { + if (!parse_format(&config->format, argv[i])) { return 0; } break; - case 'i': - if (++i >= argc) return 0; - config->bin_filename = argv[i]; - config->mode = MODE_IMPORT; - break; case 'g': if (++i >= argc) return 0; config->img_filename = argv[i]; @@ -643,14 +726,24 @@ static int parse_arguments(int argc, char *argv[], graphics_config *config) if (++i >= argc) return 0; config->height = strtoul(argv[i], NULL, 0); break; + case 'i': + if (++i >= argc) return 0; + config->bin_filename = argv[i]; + config->mode = MODE_IMPORT; + break; case 'o': if (++i >= argc) return 0; - config->offset = strtoul(argv[i], NULL, 0); - config->truncate = 0; + config->bin_offset = strtoul(argv[i], NULL, 0); + config->bin_truncate = 0; break; - case 'w': + case 'p': if (++i >= argc) return 0; - config->width = strtoul(argv[i], NULL, 0); + config->pal_filename = argv[i]; + break; + case 'P': + if (++i >= argc) return 0; + config->pal_offset = strtoul(argv[i], NULL, 0); + config->pal_truncate = 0; break; case 'v': g_verbosity = 1; @@ -659,6 +752,10 @@ static int parse_arguments(int argc, char *argv[], graphics_config *config) print_version(); exit(0); break; + case 'w': + if (++i >= argc) return 0; + config->width = strtoul(argv[i], NULL, 0); + break; default: return 0; break; @@ -670,12 +767,27 @@ static int parse_arguments(int argc, char *argv[], graphics_config *config) return 1; } +// returns 1 if config is valid +static int valid_config(const graphics_config *config) +{ + if (!config->bin_filename || !config->img_filename) { + return 0; + } + if (config->format.format == IMG_FORMAT_CI) { + if (!config->pal_filename || (config->pal_format.depth != 16) || + (config->pal_format.format != IMG_FORMAT_RGBA && config->pal_format.format != IMG_FORMAT_IA)) { + return 0; + } + } + return 1; +} + int main(int argc, char *argv[]) { graphics_config config = default_config; rgba *imgr; ia *imgi; - FILE *fp; + FILE *bin_fp; uint8_t *raw; int raw_size; int length = 0; @@ -683,52 +795,126 @@ int main(int argc, char *argv[]) int res; int valid = parse_arguments(argc, argv, &config); - if (!valid || !config.bin_filename || !config.bin_filename) { + if (!valid || !valid_config(&config)) { print_usage(); exit(EXIT_FAILURE); } if (config.mode == MODE_IMPORT) { - if (config.truncate) { - fp = fopen(config.bin_filename, "wb"); + if (config.bin_truncate) { + bin_fp = fopen(config.bin_filename, "w"); } else { - fp = fopen(config.bin_filename, "r+b"); + bin_fp = fopen(config.bin_filename, "r+"); } - if (!fp) { + if (!bin_fp) { ERROR("Error opening \"%s\"\n", config.bin_filename); return -1; } - if (!config.truncate) { - fseek(fp, config.offset, SEEK_SET); + if (!config.bin_truncate) { + fseek(bin_fp, config.bin_offset, SEEK_SET); } - switch (config.format) { + switch (config.format.format) { case IMG_FORMAT_RGBA: imgr = png2rgba(config.img_filename, &config.width, &config.height); - raw_size = config.width * config.height * config.depth / 8; + raw_size = (config.width * config.height * config.format.depth + 7) / 8; raw = malloc(raw_size); if (!raw) { ERROR("Error allocating %u bytes\n", raw_size); } - length = rgba2raw(raw, imgr, config.width, config.height, config.depth); + length = rgba2raw(raw, imgr, config.width, config.height, config.format.depth); break; case IMG_FORMAT_IA: imgi = png2ia(config.img_filename, &config.width, &config.height); - raw_size = config.width * config.height * config.depth / 8; + raw_size = (config.width * config.height * config.format.depth + 7) / 8; raw = malloc(raw_size); if (!raw) { ERROR("Error allocating %u bytes\n", raw_size); } - length = ia2raw(raw, imgi, config.width, config.height, config.depth); + length = ia2raw(raw, imgi, config.width, config.height, config.format.depth); break; case IMG_FORMAT_I: imgi = png2ia(config.img_filename, &config.width, &config.height); - raw_size = config.width * config.height * config.depth / 8; + raw_size = (config.width * config.height * config.format.depth + 7) / 8; raw = malloc(raw_size); if (!raw) { ERROR("Error allocating %u bytes\n", raw_size); } - length = i2raw(raw, imgi, config.width, config.height, config.depth); + length = i2raw(raw, imgi, config.width, config.height, config.format.depth); break; + case IMG_FORMAT_CI: + { + palette_t pal; + FILE *pal_fp; + uint8_t *raw16; + int raw16_size; + int raw16_length; + uint8_t *ci; + int ci_length; + int pal_success; + int pal_length; + + if (config.pal_truncate) { + pal_fp = fopen(config.pal_filename, "w"); + } else { + pal_fp = fopen(config.pal_filename, "r+"); + } + if (!pal_fp) { + ERROR("Error opening \"%s\"\n", config.pal_filename); + return EXIT_FAILURE; + } + if (!config.pal_truncate) { + fseek(pal_fp, config.bin_offset, SEEK_SET); + } + + raw16_size = config.width * config.height * config.pal_format.depth / 8; + raw16 = malloc(raw16_size); + if (!raw16) { + ERROR("Error allocating %d bytes\n", raw16_size); + return EXIT_FAILURE; + } + switch (config.pal_format.format) { + case IMG_FORMAT_RGBA: + imgr = png2rgba(config.img_filename, &config.width, &config.height); + raw16_length = rgba2raw(raw16, imgr, config.width, config.height, config.pal_format.depth); + break; + case IMG_FORMAT_IA: + imgi = png2ia(config.img_filename, &config.width, &config.height); + raw16_length = ia2raw(raw16, imgi, config.width, config.height, config.pal_format.depth); + break; + default: + ERROR("Unsupported palette format: %s\n", format2str(&config.pal_format)); + exit(EXIT_FAILURE); + } + + // convert raw to palette + pal.max = (1 << config.format.depth); + ci_length = config.width * config.height * config.format.depth / 8; + ci = malloc(ci_length); + pal_success = raw2ci(ci, &pal, raw16, raw16_length, config.format.depth); + if (!pal_success) { + ERROR("Error converting palette\n"); + exit(EXIT_FAILURE); + } + + pal_length = pal.max * sizeof(pal.data[0]); + INFO("Writing 0x%X bytes to offset 0x%X of \"%s\"\n", pal_length, config.pal_offset, config.pal_filename); + flength = 0; + for (int i = 0; i < pal.max; i++) { + uint8_t entry[2]; + write_u16_be(entry, pal.data[i]); + flength += fwrite(entry, 1, sizeof(entry), pal_fp); + } + if (flength != pal_length) { + ERROR("Error writing %d bytes to \"%s\"\n", pal_length, config.pal_filename); + } + + raw = ci; + length = ci_length; + + free(raw16); + fclose(pal_fp); + break; + } default: return EXIT_FAILURE; } @@ -736,50 +922,97 @@ int main(int argc, char *argv[]) ERROR("Error converting to raw format\n"); return EXIT_FAILURE; } - INFO("Writing 0x%X bytes to offset 0x%X of \"%s\"\n", length, config.offset, config.bin_filename); - flength = fwrite(raw, 1, length, fp); + INFO("Writing 0x%X bytes to offset 0x%X of \"%s\"\n", length, config.bin_offset, config.bin_filename); + flength = fwrite(raw, 1, length, bin_fp); if (flength != length) { ERROR("Error writing %d bytes to \"%s\"\n", length, config.bin_filename); } - fclose(fp); + fclose(bin_fp); } else { - if (config.width <= 0 || config.height <= 0 || config.depth <= 0) { + if (config.width <= 0 || config.height <= 0 || config.format.depth <= 0) { ERROR("Error: must set position width and height for export\n"); return EXIT_FAILURE; } - fp = fopen(config.bin_filename, "rb"); - if (!fp) { + bin_fp = fopen(config.bin_filename, "r"); + if (!bin_fp) { ERROR("Error opening \"%s\"\n", config.bin_filename); return -1; } - raw_size = config.width * config.height * config.depth / 8; + raw_size = (config.width * config.height * config.format.depth + 7) / 8; raw = malloc(raw_size); - if (config.offset > 0) { - fseek(fp, config.offset, SEEK_SET); + if (config.bin_offset > 0) { + fseek(bin_fp, config.bin_offset, SEEK_SET); } - flength = fread(raw, 1, raw_size, fp); + flength = fread(raw, 1, raw_size, bin_fp); if (flength != raw_size) { ERROR("Error reading %d bytes from \"%s\"\n", raw_size, config.bin_filename); } - switch (config.format) { + switch (config.format.format) { case IMG_FORMAT_RGBA: - imgr = raw2rgba(raw, config.width, config.height, config.depth); + imgr = raw2rgba(raw, config.width, config.height, config.format.depth); res = rgba2png(config.img_filename, imgr, config.width, config.height); break; case IMG_FORMAT_IA: - imgi = raw2ia(raw, config.width, config.height, config.depth); + imgi = raw2ia(raw, config.width, config.height, config.format.depth); res = ia2png(config.img_filename, imgi, config.width, config.height); break; case IMG_FORMAT_I: - imgi = raw2i(raw, config.width, config.height, config.depth); + imgi = raw2i(raw, config.width, config.height, config.format.depth); res = ia2png(config.img_filename, imgi, config.width, config.height); break; + case IMG_FORMAT_CI: + { + FILE *pal_fp; + uint8_t *pal; + uint8_t *raw_fmt; + int pal_size; + + INFO("Extracting %s offset 0x%X, pal.offset 0x%0X, pal.format %s\n", format2str(&config.format), + config.bin_offset, config.pal_offset, format2str(&config.pal_format)); + + pal_fp = fopen(config.pal_filename, "r"); + if (!pal_fp) { + ERROR("Error opening \"%s\"\n", config.bin_filename); + return EXIT_FAILURE; + } + if (config.pal_offset > 0) { + fseek(pal_fp, config.pal_offset, SEEK_SET); + } + + pal_size = sizeof(uint16_t) * (1 << config.format.depth); + INFO("Palette size: %d\n", pal_size); + pal = malloc(pal_size); + flength = fread(pal, 1, pal_size, pal_fp); + if (flength != pal_size) { + ERROR("Error reading %d bytes from \"%s\"\n", pal_size, config.pal_filename); + } + raw_fmt = ci2raw(raw, pal, config.width, config.height, config.format.depth); + switch (config.pal_format.format) { + case IMG_FORMAT_RGBA: + INFO("Converting raw to RGBA16\n"); + imgr = raw2rgba(raw_fmt, config.width, config.height, config.pal_format.depth); + res = rgba2png(config.img_filename, imgr, config.width, config.height); + break; + case IMG_FORMAT_IA: + INFO("Converting raw to IA16\n"); + imgi = raw2ia(raw_fmt, config.width, config.height, config.pal_format.depth); + res = ia2png(config.img_filename, imgi, config.width, config.height); + break; + default: + ERROR("Unsupported palette format: %s\n", format2str(&config.pal_format)); + return EXIT_FAILURE; + } + free(raw_fmt); + free(pal); + break; + } default: return EXIT_FAILURE; } if (!res) { ERROR("Error writing to \"%s\"\n", config.img_filename); + return EXIT_FAILURE; } } diff --git a/tools/n64graphics.h b/tools/n64graphics.h index 2ba8e0ad..9ced50e7 100644 --- a/tools/n64graphics.h +++ b/tools/n64graphics.h @@ -18,6 +18,14 @@ typedef struct _ia uint8_t alpha; } ia; +// CI palette +typedef struct +{ + uint16_t data[256]; + int max; // max number of entries + int used; // number of entries used +} palette_t; + //--------------------------------------------------------- // N64 RGBA/IA/I/CI -> intermediate RGBA/IA //--------------------------------------------------------- @@ -31,10 +39,6 @@ ia *raw2ia(const uint8_t *raw, int width, int height, int depth); // N64 raw I4/I8 -> intermediate IA ia *raw2i(const uint8_t *raw, int width, int height, int depth); -// N64 raw CI + palette -> intermediate RGBA -rgba *rawci2rgba(const uint8_t *rawci, const uint8_t *palette, int width, int height, int depth); - - //--------------------------------------------------------- // intermediate RGBA/IA -> N64 RGBA/IA/I/CI // returns length written to 'raw' used or -1 on error @@ -49,9 +53,16 @@ int ia2raw(uint8_t *raw, const ia *img, int width, int height, int depth); // intermediate IA -> N64 raw I4/I8 int i2raw(uint8_t *raw, const ia *img, int width, int height, int depth); -// intermediate RGBA -> N64 raw CI + palette -// TODO -// int rgba2rawci(uint8_t *raw, uint8_t *out_palette, int *pal_len, const rgba *img, int width, int height, int depth); + +//--------------------------------------------------------- +// N64 CI <-> N64 RGBA16/IA16 +//--------------------------------------------------------- + +// N64 CI raw data and palette to raw data (either RGBA16 or IA16) +uint8_t *ci2raw(const uint8_t *rawci, const uint8_t *palette, int width, int height, int ci_depth); + +// convert from raw (RGBA16 or IA16) format to CI + palette +int raw2ci(uint8_t *rawci, palette_t *pal, const uint8_t *raw, int raw_len, int ci_depth); //--------------------------------------------------------- diff --git a/tools/rasm2armips.py b/tools/rasm2armips.py new file mode 100755 index 00000000..ae92d586 --- /dev/null +++ b/tools/rasm2armips.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python + +import argparse +import re +import sys + +def read_file(filepath): + with open(filepath) as f: + lines = f.readlines() + split_lines = [re.split(r'[ ,]+', l.strip().replace('$', '')) for l in lines] + return split_lines + +# jumps and branches with named targets +jumps = ['jal', 'j'] +branches = ['beq', 'bgez', 'bgtz', 'blez', 'bltz', 'bne'] +jump_branches = jumps + branches +# jumps and branches with delay slots +has_delay_slot = jump_branches + ['jr'] + +def decode_references(instructions): + refs = [] + for ins in instructions: + if ins[3] in jump_branches: + target = int(ins[-1], 0) + if target not in refs: + refs.append(target) + return refs + +def reassemble(args, instructions, refs): + print('.rsp') + print('\n.create DATA_FILE, 0x%04X' % 0x0000) + print('\n.close // DATA_FILE\n') + print('.create CODE_FILE, 0x%08X\n' % args.base) + delay_slot = False + for ins in instructions: + addr = int(ins[0], 0) + if (addr & 0xFFFF) in refs: + print('%s_%08x:' % (args.name, addr)) + sys.stdout.write(' ' * args.indent) + if delay_slot: + sys.stdout.write(' ') + delay_slot = False + if ins[3] in jumps: + target = int(ins[-1], 0) | (args.base & 0xFFFF0000) + ins[-1] = '%s_%08x' % (args.name, target) + elif ins[3] in branches: + if ins[3][-1] =='z' and ins[5] == 'zero': + del ins[5] # remove 'zero' operand from branch + target = (int(ins[-1], 0) & 0x1FFF) + (args.base & 0xFFFF0000) + ins[-1] = '%s_%08x' % (args.name, target) + elif ins[3] == 'vsar': # fixup last operand of vsar + reg_map = {'ACC_H': 0, 'ACC_M': 1, 'ACC_L': 2} + reg = ins[4].split(r'[')[0] + num = reg_map[ins[-1]] + ins[-1] = '%s[%d]' % (reg, num) + if ins[3] in has_delay_slot: + delay_slot = True + if len(ins) > 4: # with args + print('%-5s %s' % (ins[3], ', '.join(ins[4:]))) + else: + print('%s' % ins[3]) + print('\n.close // CODE_FILE') + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('input_file', help="input assembly file generated from `rasm2 -D -e -a rsp -B -o 0x04001000 -f`") + parser.add_argument('-b', type=int, help="base address of file", dest='base', default=0x04001000) + parser.add_argument('-i', type=int, help="amount of indentation", dest='indent', default=4) + parser.add_argument('-n', help="name to prefex labels with", dest='name', default='f3d') + args = parser.parse_args() + + lines = read_file(args.input_file) + refs = decode_references(lines) + reassemble(args, lines, refs) + +main() diff --git a/tools/skyconv.c b/tools/skyconv.c index 778295db..4c2245a1 100644 --- a/tools/skyconv.c +++ b/tools/skyconv.c @@ -213,6 +213,11 @@ static void assign_tile_positions() { } } +// Provide a replacement for realpath on Windows +#ifdef _WIN32 +#define realpath(path, resolved_path) _fullpath(resolved_path, path, PATH_MAX) +#endif + /* write pngs to disc */ void write_tiles() { const ImageProps props = IMAGE_PROPERTIES[type][true]; @@ -498,6 +503,7 @@ static void usage() { // Modified from n64split static int parse_arguments(int argc, char *argv[]) { + programName = argv[0]; for (int i = 1; i < argc; ++i) { if (strcmp(argv[i], "--combine") == 0) { if (++i >= argc || mode != InvalidMode) {