diff --git a/Makefile b/Makefile index 17b93a55ac..4153aef8cb 100644 --- a/Makefile +++ b/Makefile @@ -36,11 +36,11 @@ TARGET_BITS ?= 0 BETTERCAMERA ?= 0 # Disable no drawing distance by default NODRAWINGDISTANCE ?= 0 -# Disable texture fixes by default (helps with them purists) -TEXTURE_FIX ?= 0 +# Disable quality-of-life fixes by default (helps with them purists) +QOL_FIXES ?= 0 # Enable extended options menu by default EXT_OPTIONS_MENU ?= 1 -# Disable text-based save-files by default +# Disable text-based save files by default TEXTSAVES ?= 0 # Load textures from external PNG files EXTERNAL_TEXTURES ?= 0 @@ -74,7 +74,7 @@ ifeq ($(WINDOWS_BUILD),1) TARGET_BITS = 32 NO_BZERO_BCOPY := 1 else ifeq ($(CROSS),x86_64-w64-mingw32.static-) - TARGET_ARCH = i386pe + TARGET_ARCH = i386pep TARGET_BITS = 64 NO_BZERO_BCOPY := 1 endif @@ -94,22 +94,19 @@ ifeq ($(VERSION),jp) GRUCODE_CFLAGS := -DF3D_OLD GRUCODE_ASFLAGS := --defsym F3D_OLD=1 TARGET := sm64.jp -else -ifeq ($(VERSION),us) +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 -else -ifeq ($(VERSION),eu) +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 -else -ifeq ($(VERSION),sh) +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 @@ -121,9 +118,6 @@ ifeq ($(VERSION),sh) else $(error unknown version "$(VERSION)") endif -endif -endif -endif # 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 @@ -140,35 +134,27 @@ ifeq ($(GRUCODE),f3dex) # Fast3DEX GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 --defsym F3DEX_GBI=1 TARGET := $(TARGET).f3dex COMPARE := 0 -else -ifeq ($(GRUCODE), f3dex2) # Fast3DEX2 +else ifeq ($(GRUCODE), f3dex2) # Fast3DEX2 GRUCODE_CFLAGS := -DF3DEX_GBI_2 GRUCODE_ASFLAGS := --defsym F3DEX_GBI_SHARED=1 --defsym F3DEX_GBI_2=1 TARGET := $(TARGET).f3dex2 COMPARE := 0 -else -ifeq ($(GRUCODE), f3dex2e) # Fast3DEX2 Extended (PC default) +else ifeq ($(GRUCODE), f3dex2e) # Fast3DEX2 Extended (PC default) GRUCODE_CFLAGS := -DF3DEX_GBI_2E TARGET := $(TARGET).f3dex2e COMPARE := 0 -else -ifeq ($(GRUCODE),f3d_new) # Fast3D 2.0H (Shindou) +else ifeq ($(GRUCODE),f3d_new) # Fast3D 2.0H (Shindou) GRUCODE_CFLAGS := -DF3D_NEW GRUCODE_ASFLAGS := --defsym F3D_NEW=1 TARGET := $(TARGET).f3d_new COMPARE := 0 -else -ifeq ($(GRUCODE),f3dzex) # Fast3DZEX (2.0J / Animal Forest - Dōbutsu no Mori) +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 TARGET := $(TARGET).f3dzex COMPARE := 0 endif -endif -endif -endif -endif # Default build is for PC now VERSION_CFLAGS := $(VERSION_CFLAGS) -DNON_MATCHING -DAVOID_UB @@ -194,8 +180,7 @@ endif # on tools and assets, and we use directory globs further down # in the makefile that we want should cover assets.) -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(MAKECMDGOALS),distclean) +ifeq (,$(findstring clean,$(MAKECMDGOALS))) # Make sure assets exist NOEXTRACT ?= 0 @@ -212,7 +197,6 @@ ifeq ($(DUMMY),FAIL) $(error Failed to build tools) endif -endif endif ################ Target Executable and Sources ############### @@ -230,17 +214,12 @@ LIBULTRA := $(BUILD_DIR)/libultra.a ifeq ($(TARGET_WEB),1) EXE := $(BUILD_DIR)/$(TARGET).html - else - ifeq ($(WINDOWS_BUILD),1) - EXE := $(BUILD_DIR)/$(TARGET).exe - - else # Linux builds/binary namer - ifeq ($(TARGET_RPI),1) - EXE := $(BUILD_DIR)/$(TARGET).arm - else - EXE := $(BUILD_DIR)/$(TARGET) - endif - endif +else ifeq ($(WINDOWS_BUILD),1) +EXE := $(BUILD_DIR)/$(TARGET).exe +else ifeq ($(TARGET_RPI),1) # Linux builds/binary namer +EXE := $(BUILD_DIR)/$(TARGET).arm +else +EXE := $(BUILD_DIR)/$(TARGET) endif ELF := $(BUILD_DIR)/$(TARGET).elf @@ -270,13 +249,11 @@ MIPSBIT := -32 ifeq ($(VERSION),eu) OPT_FLAGS := -O2 -else -ifeq ($(VERSION),sh) +else ifeq ($(VERSION),sh) OPT_FLAGS := -O2 else OPT_FLAGS := -g endif -endif # Set BITS (32/64) to compile for OPT_FLAGS += $(BITS) @@ -468,6 +445,10 @@ ifeq ($(WINDOWS_BUILD),1) LD := $(CC) else ifeq ($(CROSS),x86_64-w64-mingw32.static-) LD := $(CC) + else ifeq ($(CROSS),mxe-i686-w64-mingw32.static-) + LD := $(CC) + else ifeq ($(CROSS),mxe-x86_64-w64-mingw32.static-) + LD := $(CC) else LD := $(CXX) endif @@ -479,8 +460,8 @@ ifeq ($(WINDOWS_BUILD),1) # fixes compilation in MXE on Linux and WSL OBJDUMP := $(CROSS)objdump else ifeq ($(OSX_BUILD),1) CPP := cpp-9 -P - OBJDUMP := i686-w64-mingw32-objdump OBJCOPY := i686-w64-mingw32-objcopy + OBJDUMP := i686-w64-mingw32-objdump else # Linux & other builds CPP := $(CROSS)cpp -P OBJCOPY := $(CROSS)objcopy @@ -491,16 +472,15 @@ PYTHON := python3 SDLCONFIG := $(CROSS)sdl2-config ifeq ($(WINDOWS_BUILD),1) -CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` -DUSE_SDL=2 +CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` -DUSE_SDL=2 CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(SDLCONFIG) --cflags` -DUSE_SDL=2 else ifeq ($(TARGET_WEB),1) -CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2 +CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2 CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv -s USE_SDL=2 -# Linux / Other builds below -else -CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` -DUSE_SDL=2 +else # Linux / Other builds below +CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(SDLCONFIG) --cflags` -DUSE_SDL=2 CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(SDLCONFIG) --cflags` -DUSE_SDL=2 endif @@ -513,6 +493,7 @@ ifeq ($(BETTERCAMERA),1) EXT_OPTIONS_MENU := 1 endif +# Check for text-based save option ifeq ($(TEXTSAVES),1) CC_CHECK += -DTEXTSAVES CFLAGS += -DTEXTSAVES @@ -524,10 +505,10 @@ ifeq ($(NODRAWINGDISTANCE),1) CFLAGS += -DNODRAWINGDISTANCE endif -# Check for texture fix option -ifeq ($(TEXTURE_FIX),1) - CC_CHECK += -DTEXTURE_FIX - CFLAGS += -DTEXTURE_FIX +# Check for QoL fix option +ifeq ($(QOL_FIXES),1) + CC_CHECK += -DQOL_FIXES + CFLAGS += -DQOL_FIXES endif # Check for extended options menu option @@ -568,21 +549,16 @@ ifeq ($(TARGET_WEB),1) LDFLAGS := -lm -lGL -lSDL2 -no-pie -s TOTAL_MEMORY=20MB -g4 --source-map-base http://localhost:8080/ -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']" else ifeq ($(WINDOWS_BUILD),1) LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(SDLCONFIG) --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -static - ifeq ($(CROSS),) - LDFLAGS += -no-pie - endif ifeq ($(WINDOWS_CONSOLE),1) LDFLAGS += -mconsole endif else ifeq ($(TARGET_RPI),1) # Linux / Other builds below LDFLAGS := $(OPT_FLAGS) -lm -lGLESv2 `$(SDLCONFIG) --libs` -no-pie -else -ifeq ($(OSX_BUILD),1) +else ifeq ($(OSX_BUILD),1) LDFLAGS := -lm -framework OpenGL `$(SDLCONFIG) --libs` -no-pie -lpthread `pkg-config --libs libusb-1.0 glfw3 glew` else LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -lm -lGL `$(SDLCONFIG) --libs` -no-pie -lpthread -endif endif # End of LDFLAGS # Prevent a crash with -sopt @@ -630,12 +606,21 @@ clean: $(RM) -r $(BUILD_DIR_BASE) cleantools: - $(MAKE) -s -C tools clean + $(MAKE) -C tools clean + +cleanall: + $(RM) -r $(BUILD_DIR_BASE) + $(MAKE) -C tools clean distclean: $(RM) -r $(BUILD_DIR_BASE) ./extract_assets.py --clean +distcleanall: + $(RM) -r $(BUILD_DIR_BASE) + ./extract_assets.py --clean + $(MAKE) -C tools clean + test: $(ROM) $(EMULATOR) $(EMU_FLAGS) $< @@ -673,8 +658,7 @@ $(BUILD_DIR)/levels/menu/leveldata.o: $(BUILD_DIR)/text/us/define_courses.inc.c $(BUILD_DIR)/levels/menu/leveldata.o: $(BUILD_DIR)/text/de/define_courses.inc.c $(BUILD_DIR)/levels/menu/leveldata.o: $(BUILD_DIR)/text/fr/define_courses.inc.c -else -ifeq ($(VERSION),sh) +else ifeq ($(VERSION),sh) TEXT_DIRS := text/jp $(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/jp/define_text.inc.c @@ -684,14 +668,13 @@ TEXT_DIRS := text/$(VERSION) # non-EU encoded text inserted into segment 0x02 $(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/$(VERSION)/define_text.inc.c endif -endif $(BUILD_DIR)/text/%/define_courses.inc.c: text/define_courses.inc.c text/%/courses.h $(CPP) $(VERSION_CFLAGS) $< -o $@ -I text/$*/ $(TEXTCONV) charmap.txt $@ $@ $(BUILD_DIR)/text/%/define_text.inc.c: text/define_text.inc.c text/%/courses.h text/%/dialogs.h - $(CPP) $(VERSION_CFLAGS) $< -o $@ -I text/$*/ + $(CPP) $(VERSION_CFLAGS) -Wno-trigraphs $< -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) @@ -884,7 +867,7 @@ $(BUILD_DIR)/%.o: %.s $(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS) -.PHONY: all clean distclean default diff test load libultra res +.PHONY: all clean cleantools cleanall distclean distcleanall default diff test load libultra res .PRECIOUS: $(BUILD_DIR)/bin/%.elf $(SOUND_BIN_DIR)/%.ctl $(SOUND_BIN_DIR)/%.tbl $(SOUND_SAMPLE_TABLES) $(SOUND_BIN_DIR)/%.s $(BUILD_DIR)/% .DELETE_ON_ERROR: diff --git a/Makefile.split b/Makefile.split index c7bdaa2e6c..662d294a44 100644 --- a/Makefile.split +++ b/Makefile.split @@ -145,13 +145,11 @@ define level_rules = $$(BUILD_DIR)/levels/$(1)/leveldata.elf: TEXTURE_BIN := $(2) endef -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(MAKECMDGOALS),distclean) +ifeq (,$(findstring clean,$(MAKECMDGOALS))) $(BUILD_DIR)/level_rules.mk: levels/level_rules.mk levels/level_defines.h $(CPP) $(VERSION_CFLAGS) -I . -o $@ $< include $(BUILD_DIR)/level_rules.mk endif -endif # -------------------------------------- # Extra Level Rules diff --git a/README.md b/README.md index f8b0d6a487..12ace2c66f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Please contribute **first** to the [nightly branch](https://github.com/sm64pc/sm * Native xinput controller support. On Linux, DualShock 4 has been confirmed to work plug-and-play. * Analog camera control and mouse look. (Activate with `make BETTERCAMERA=1`.) * An option to disable drawing distances. (Activate with `make NODRAWINGDISTANCE=1`.) - * Model and texture fixes. (Activate with `make TEXTURE_FIX=1`.) + * Quality-of-life fixes. (Activate with `make QOL_FIXES=1`.) * In-game control binding. * Skip introductory Peach & Lakitu cutscenes with the `--skip-intro` CLI option * Disabling the HUD. diff --git a/actors/burn_smoke/model.inc.c b/actors/burn_smoke/model.inc.c index bcf4fd6f4d..d62aee3ada 100644 --- a/actors/burn_smoke/model.inc.c +++ b/actors/burn_smoke/model.inc.c @@ -10,9 +10,9 @@ static const Vtx burn_smoke_seg4_vertex_040217C0[] = { // //! Wrong texture format. Called as rgba16, which makes the burn smoke appear // as a transparent black burn smoke. Probably meant to show up as white-ish -// burn smoke, but mistakened for being intended as black smoke. +// burn smoke, but mistaken for being intended as black smoke. // Due to debate in the Koopa shorts PR surrounding the fix to a similar bug, -// said fix is on a compile-time variable. Use TEXTURE_FIX=1 at compile time +// said fix is on a compile-time variable. Use QOL_FIXES=1 at compile time // to fix this. // 0x04021800 ALIGNED8 static const u8 burn_smoke_seg4_texture_04021800[] = { @@ -47,7 +47,7 @@ const Gfx burn_smoke_seg4_dl_04022048[] = { // 0x04022070 - 0x040220C8 const Gfx burn_smoke_seg4_dl_04022070[] = { gsSPDisplayList(burn_smoke_seg4_dl_04022000), - #ifdef TEXTURE_FIX + #ifdef QOL_FIXES gsDPLoadTextureBlock(burn_smoke_seg4_texture_04021800, G_IM_FMT_IA, G_IM_SIZ_16b, 32, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 5, 5, G_TX_NOLOD, G_TX_NOLOD), #else gsDPLoadTextureBlock(burn_smoke_seg4_texture_04021800, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0, G_TX_CLAMP, G_TX_CLAMP, 5, 5, G_TX_NOLOD, G_TX_NOLOD), diff --git a/actors/koopa/model.inc.c b/actors/koopa/model.inc.c index 6bf2418765..12f535dafd 100644 --- a/actors/koopa/model.inc.c +++ b/actors/koopa/model.inc.c @@ -55,7 +55,7 @@ static const Lights1 koopa_seg6_lights_06002630 = gdSPDefLights1( // the rest of its body. This is evident because once the mistake is corrected // it turns back to being white like the other polygons. // Due to debate in the PR surrounding the fix to this, said fix is on -// a compile-time variable. Use TEXTURE_FIX=1 at compile time to fix this. +// a compile-time variable. Use QOL_FIXES=1 at compile time to fix this. // 0x06002648 ALIGNED8 static const u8 koopa_seg6_texture_06002648[] = { #include "actors/koopa/koopa_shell_front.rgba16.inc.c" @@ -2079,7 +2079,7 @@ const Gfx koopa_seg6_dl_0600C498[] = { gsSPVertex(koopa_seg6_vertex_0600B560, 9, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP1Triangle( 6, 7, 8, 0x0), - #ifdef TEXTURE_FIX + #ifdef QOL_FIXES gsSPLight(&koopa_seg6_lights_06002630.l, 1), gsSPLight(&koopa_seg6_lights_06002630.a, 2), #else diff --git a/bin/segment2.c b/bin/segment2.c index 5d5398aa87..024dac0640 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2492,10 +2492,10 @@ ALIGNED8 const u8 texture_waterbox_lava[] = { }; // Unreferenced light group -static const Lights1 segment2_lights_unused = gdSPDefLights1( - 0x40, 0x40, 0x40, - 0xff, 0xff, 0xff, 0x28, 0x28, 0x28 -); +//static const Lights1 segment2_lights_unused = gdSPDefLights1( +// 0x40, 0x40, 0x40, +// 0xff, 0xff, 0xff, 0x28, 0x28, 0x28 +//); // 0x02014470 - 0x020144B0 static const Mtx matrix_identity = { diff --git a/build.sh b/build.sh index d5429ce563..0208650bfe 100644 --- a/build.sh +++ b/build.sh @@ -7,8 +7,8 @@ LIBAFLA=libaudiofile.la AUDDIR=./tools/audiofile-0.3.6 # Command line options -OPTIONS=("Analog Camera" "No Draw Distance" "Text-saves" "Smoke Texture Fix" "Clean build") -EXTRA=("BETTERCAMERA=1" "NODRAWINGDISTANCE=1" "TEXTSAVES=1" "TEXTURE_FIX=1" "clean") +OPTIONS=("Analog Camera" "No Draw Distance" "Text-saves" "Quality of Life Fixes" "Clean build") +EXTRA=("BETTERCAMERA=1" "NODRAWINGDISTANCE=1" "TEXTSAVES=1" "QOL_FIXES=1" "clean") # Colors RED=$(tput setaf 1) @@ -46,15 +46,6 @@ else printf "${YELLOW} Going up one directory.${RESET}\n\n" cd ../ - printf "${GREEN}Notepad will now open, please follow the instructions carefully.\n\n" - printf "${YELLOW}Locate the line: " - printf "${CYAN}tabledesign_CFLAGS := -Wno-uninitialized -laudiofile\n" - printf "${YELLOW}Then add at the end: ${CYAN}-lstdc++\n" - printf "${YELLOW}So it reads: " - printf "${CYAN}tabledesign_CFLAGS := -Wno-uninitialized -laudiofile -lstdc++\n\n" - notepad "Makefile" - read -n 1 -r -s -p $'\e[32mPRESS ENTER TO CONTINUE...\e[0m\n' - printf "${YELLOW} Executing: ${CYAN}make -j${RESET}\n\n" PATH=/mingw64/bin:/mingw32/bin:$PATH make -j @@ -90,7 +81,7 @@ PATH=/mingw32/bin:/mingw64/bin:$PATH make $CMDL -j -d if [ "${CMDL}" != " clean" ]; then - printf "\n${GREEN}If all went well you should have a compiled .EXE in the 'builds/us_pc/' folder.\n" + printf "\n${GREEN}If all went well, you should have a compiled .EXE in the 'builds/us_pc/' folder.\n" printf "${CYAN}Would you like to run the game? [y or n]: ${RESET}" read TEST @@ -98,5 +89,5 @@ if [ "${CMDL}" != " clean" ]; then exec ./build/us_pc/sm64.us.f3dex2e.exe fi else - printf "\nYour build is now clean\n" + printf "\nYour build is now clean.\n" fi \ No newline at end of file diff --git a/data/behavior_data.c b/data/behavior_data.c index 3b4af5a08f..c51bbea57e 100644 --- a/data/behavior_data.c +++ b/data/behavior_data.c @@ -3144,12 +3144,12 @@ const BehaviorScript bhvUnusedFakeStar[] = { }; // What is this? -static const BehaviorScript unused_1[] = { - BREAK(), - BREAK(), - BREAK(), - BREAK(), -}; +//static const BehaviorScript unused_1[] = { +// BREAK(), +// BREAK(), +// BREAK(), +// BREAK(), +//}; const BehaviorScript bhvStaticObject[] = { BEGIN(OBJ_LIST_DEFAULT), diff --git a/extract_assets.py b/extract_assets.py index 7c29358b53..706fc7284c 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 diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h index 1ebde7756d..9459168818 100644 --- a/include/PR/ultratypes.h +++ b/include/PR/ultratypes.h @@ -33,13 +33,9 @@ typedef double f64; #include #include -#if defined(__MINGW32__) +#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) #include <_mingw.h> -#if !defined(__MINGW64_VERSION_MAJOR) typedef long ssize_t; -#else -typedef ptrdiff_t ssize_t; -#endif #endif #endif // _ULTRA64_TYPES_H_ diff --git a/include/object_constants.h b/include/object_constants.h index 9e7623a9c5..205e8af603 100644 --- a/include/object_constants.h +++ b/include/object_constants.h @@ -887,6 +887,9 @@ #define KLEPTO_ANIM_STATE_HOLDING_NOTHING 0 #define KLEPTO_ANIM_STATE_HOLDING_CAP 1 #define KLEPTO_ANIM_STATE_HOLDING_STAR 2 + #ifdef QOL_FIXES + #define KLEPTO_ANIM_STATE_HOLDING_TRANSPARENT_STAR 3 + #endif /* Bird */ /* oAction */ diff --git a/include/object_fields.h b/include/object_fields.h index 5ba0e1cb6a..0370e68c6a 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -198,6 +198,11 @@ #define /*0x0FC*/ oBackAndForthPlatformUnkFC OBJECT_FIELD_F32(0x1D) #define /*0x100*/ oBackAndForthPlatformUnk100 OBJECT_FIELD_F32(0x1E) +/* Beta Trampoline */ +#ifdef QOL_FIXES +#define /*0x098*/ oBetaTrampolineAdditiveYVel OBJECT_FIELD_F32(0x04) +#endif + /* Bird */ #define /*0x0F4*/ oBirdSpeed OBJECT_FIELD_F32(0x1B) #define /*0x0F8*/ oBirdTargetPitch OBJECT_FIELD_S32(0x1C) diff --git a/include/stb/stb_image.h b/include/stb/stb_image.h index d9c21bc813..acc405597a 100644 --- a/include/stb/stb_image.h +++ b/include/stb/stb_image.h @@ -971,7 +971,8 @@ STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) { - memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields + bpc = 0; + memset(ri, bpc, sizeof(*ri)); // make sure it's initialized if we add new fields ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order ri->num_channels = 0; @@ -6342,11 +6343,12 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i int first_frame; int pi; int pcount; + req_comp = 0; // on first frame, any non-written pixels get the background colour (non-transparent) first_frame = 0; if (g->out == 0) { - if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header + if (!stbi__gif_header(s, g, comp,req_comp)) return 0; // stbi__g_failure_reason set by stbi__gif_header g->out = (stbi_uc *) stbi__malloc(4 * g->w * g->h); g->background = (stbi_uc *) stbi__malloc(4 * g->w * g->h); g->history = (stbi_uc *) stbi__malloc(g->w * g->h); @@ -6360,7 +6362,7 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame first_frame = 1; } else { - // second frame - how do we dispoase of the previous one? + // second frame - how do we dispose of the previous one? dispose = (g->eflags & 0x1C) >> 2; pcount = g->w * g->h; @@ -6565,6 +6567,7 @@ static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req stbi_uc *u = 0; stbi__gif g; memset(&g, 0, sizeof(g)); + STBI_NOTUSED(ri); u = stbi__gif_load_next(s, &g, comp, req_comp, 0); if (u == (stbi_uc *) s) u = 0; // end of animated gif marker diff --git a/include/types.h b/include/types.h index 870223eb8d..7ae974088c 100644 --- a/include/types.h +++ b/include/types.h @@ -291,7 +291,11 @@ struct MarioState /*0x0C*/ u32 action; /*0x10*/ u32 prevAction; /*0x14*/ u32 terrainSoundAddend; + #ifdef QOL_FIXES + /*0x18*/ u32 actionState; // makes the game harder. + #else /*0x18*/ u16 actionState; + #endif /*0x1A*/ u16 actionTimer; /*0x1C*/ u32 actionArg; /*0x20*/ f32 intendedMag; diff --git a/include/ultra64.h b/include/ultra64.h index e78ded499c..409a3cf76a 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -30,13 +30,4 @@ #include #include -#if defined(__MINGW32__) -#include <_mingw.h> -#if !defined(__MINGW64_VERSION_MAJOR) -#include -#define bzero(b,len) (memset((b), '\0', (len)), (void) 0) -#define bcopy(s1, s2, n) memmove((s2), (s1), (n)) -#endif -#endif - #endif diff --git a/lib/src/_Ldtob.c b/lib/src/_Ldtob.c index 3656bd45af..0b74280c04 100644 --- a/lib/src/_Ldtob.c +++ b/lib/src/_Ldtob.c @@ -26,7 +26,7 @@ const double D_80338670[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L #define _CSIGN 1 #define _ILONG 0 #define _MBMAX 8 -#define NAN 2 +#define _NAN 2 #define INF 1 #define FINITE -1 #define _DFRAC ((1 << _DOFF) - 1) @@ -166,14 +166,14 @@ static s16 _Ldunscale(s16 *pex, printf_struct *px) { short xchar = (ps[_D0] & _DMASK) >> _DOFF; if (xchar == _DMAX) { /* NaN or INF */ *pex = 0; - return (s16)(ps[_D0] & _DFRAC || ps[_D1] || ps[_D2] || ps[_D3] ? NAN : INF); + return (s16)(ps[_D0] & _DFRAC || ps[_D1] || ps[_D2] || ps[_D3] ? _NAN : INF); } else if (0 < xchar) { ps[_D0] = (ps[_D0] & ~_DMASK) | (_DBIAS << _DOFF); *pex = xchar - (_DBIAS - 1); return (FINITE); } if (0 > xchar) { - return NAN; + return _NAN; } else { *pex = 0; return (0); diff --git a/lib/src/osCreateThread.c b/lib/src/osCreateThread.c index b4e283f27c..bba54f5c01 100644 --- a/lib/src/osCreateThread.c +++ b/lib/src/osCreateThread.c @@ -2,10 +2,6 @@ void __osCleanupThread(void); -// Don't warn about pointer->u64 cast -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpointer-to-int-cast" - void osCreateThread(OSThread *thread, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri pri) { register u32 int_disabled; u32 tmp; @@ -30,5 +26,3 @@ void osCreateThread(OSThread *thread, OSId id, void (*entry)(void *), void *arg, D_8033489C = thread; __osRestoreInt(int_disabled); } - -#pragma GCC diagnostic pop diff --git a/src/audio/data.c b/src/audio/data.c index 711ee84797..53f3a2cc52 100644 --- a/src/audio/data.c +++ b/src/audio/data.c @@ -175,9 +175,9 @@ s8 gVibratoCurve[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, #endif struct AdsrEnvelope gDefaultEnvelope[] = { - { BE_TO_HOST16(4), BE_TO_HOST16(32000) }, // go from 0 to 32000 over the course of 16ms - { BE_TO_HOST16(1000), BE_TO_HOST16(32000) }, // stay there for 4.16 seconds - { BE_TO_HOST16(ADSR_HANG), 0 } // then continue staying there + { (s16)BE_TO_HOST16(4), (s16)BE_TO_HOST16(32000) }, // go from 0 to 32000 over the course of 16ms + { (s16)BE_TO_HOST16(1000), (s16)BE_TO_HOST16(32000) }, // stay there for 4.16 seconds + { (s16)BE_TO_HOST16(ADSR_HANG), 0 } // then continue staying there }; #ifdef VERSION_EU diff --git a/src/audio/external.c b/src/audio/external.c index a059c0b5a6..b8f20027f0 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -774,7 +774,7 @@ struct SPTask *create_next_audio_frame_task(void) { return NULL; } -void create_next_audio_buffer(s16 *samples, u32 num_samples) { +void create_next_audio_buffer(u16 *samples, u32 num_samples) { gAudioFrameCount++; if (sGameLoopTicked != 0) { update_game_sound(); diff --git a/src/audio/heap.c b/src/audio/heap.c index d1d694179f..f1dccc1c47 100644 --- a/src/audio/heap.c +++ b/src/audio/heap.c @@ -302,10 +302,10 @@ void temporary_pools_init(struct PoolSplit *a) { temporary_pool_clear(&gUnusedLoadedPool.temporary); } -#ifndef VERSION_EU -static void unused_803163D4() { -} -#endif +//#ifndef VERSION_EU +//static void unused_803163D4() { +//} +//#endif void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg3, s32 id) { // arg3 = 0, 1 or 2? @@ -649,7 +649,7 @@ s32 audio_shut_down_and_reset_step(void) { /** * Waits until a specified number of audio frames have been created */ -void wait_for_audio_frames(s32 frames) { +void wait_for_audio_frames(UNUSED s32 frames) { gAudioFrameCount = 0; } diff --git a/src/audio/load.c b/src/audio/load.c index 146863c1d2..250fe53038 100644 --- a/src/audio/load.c +++ b/src/audio/load.c @@ -24,7 +24,7 @@ void port_eu_init(void); struct Note *gNotes; #ifdef VERSION_EU -static u8 pad[4]; +UNUSED static u8 pad[4]; #endif struct SequencePlayer gSequencePlayers[SEQUENCE_PLAYERS]; @@ -384,7 +384,7 @@ void init_sample_dma_buffers(UNUSED s32 arg0) { #ifndef VERSION_EU // This function gets optimized out on US due to being static and never called -static +UNUSED static #endif void patch_sound(UNUSED struct AudioBankSound *sound, UNUSED u8 *memBase, UNUSED u8 *offsetBase) { @@ -875,13 +875,15 @@ void audio_init() { UNUSED s8 pad[32]; u8 buf[0x10]; #endif - s32 i, j, k; + s32 i, j; + s32 UNUSED k; UNUSED s32 lim1; // lim1 unused in EU #ifdef VERSION_EU u8 buf[0x10]; s32 UNUSED lim2, lim3; #else - s32 lim2, lim3; + s32 lim2; + s32 UNUSED lim3; #endif u32 size; UNUSED u64 *ptr64; diff --git a/src/audio/synthesis.c b/src/audio/synthesis.c index b332c9f08f..28c4103065 100644 --- a/src/audio/synthesis.c +++ b/src/audio/synthesis.c @@ -274,7 +274,8 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) { for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) { if (i == 1) { // self-assignment has no affect when added here, could possibly simplify a macro definition - chunkLen = bufLen; nextVolRampTable = nextVolRampTable; leftVolRamp = gLeftVolRampings[nextVolRampTable]; rightVolRamp = gRightVolRampings[nextVolRampTable & 0xFFFFFFFF]; + // remove it to fix a WebGL compiler warning + chunkLen = bufLen; leftVolRamp = gLeftVolRampings[nextVolRampTable]; rightVolRamp = gRightVolRampings[nextVolRampTable & 0xFFFFFFFF]; } else { if (bufLen / i >= gAudioBufferParameters.samplesPerUpdateMax) { chunkLen = gAudioBufferParameters.samplesPerUpdateMax; nextVolRampTable = 2; leftVolRamp = gLeftVolRampings[2]; rightVolRamp = gRightVolRampings[2]; @@ -366,7 +367,11 @@ u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s1 aMix(cmd++, 0, 0x8000 + gSynthesisReverbs[reverbIndex].reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH); } else { temp_t9 = (item->startPos % 8u) * 2; + #ifdef AVOID_UB + sp58 = ALIGN(item->lengths[0] + temp_t9, 4); + #else sp58 = ALIGN(item->lengths[0] + (sp58=temp_t9), 4); + #endif cmd = synthesis_load_reverb_ring_buffer(cmd, 0x20, (item->startPos - temp_t9 / 2), DEFAULT_LEN_1CH, reverbIndex); if (item->lengths[1] != 0) { diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index 539f3a328f..7653f45ac6 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -29,10 +29,10 @@ static u16 gRandomSeed16; // Unused function that directly jumps to a behavior command and resets the object's stack index. -static void goto_behavior_unused(const BehaviorScript *bhvAddr) { - gCurBhvCommand = segmented_to_virtual(bhvAddr); - gCurrentObject->bhvStackIndex = 0; -} +//static void goto_behavior_unused(const BehaviorScript *bhvAddr) { +// gCurBhvCommand = segmented_to_virtual(bhvAddr); +// gCurrentObject->bhvStackIndex = 0; +//} // Generate a pseudorandom integer from 0 to 65535 from the random seed, and update the seed. u16 random_u16(void) { @@ -105,11 +105,11 @@ static uintptr_t cur_obj_bhv_stack_pop(void) { return bhvAddr; } -static void stub_behavior_script_1(void) { - for (;;) { - ; - } -} +//static void stub_behavior_script_1(void) { +// for (;;) { +// ; +// } +//} // Command 0x22: Hides the current object. // Usage: HIDE() @@ -693,20 +693,20 @@ static s32 bhv_cmd_begin(void) { // It cannot be simply re-added to the table, as unlike all other bhv commands it takes a parameter. // Theoretically this command would have been of variable size. // Included below is a modified/repaired version of this function that would work properly. -static void bhv_cmd_set_int_random_from_table(s32 tableSize) { - u8 field = BHV_CMD_GET_2ND_U8(0); - s32 table[16]; - s32 i; +//static void bhv_cmd_set_int_random_from_table(s32 tableSize) { +// u8 field = BHV_CMD_GET_2ND_U8(0); +// s32 table[16]; +// s32 i; // This for loop would not work as intended at all... - for (i = 0; i <= tableSize / 2; i += 2) { - table[i] = BHV_CMD_GET_1ST_S16(i + 1); - table[i + 1] = BHV_CMD_GET_2ND_S16(i + 1); - } +// for (i = 0; i <= tableSize / 2; i += 2) { +// table[i] = BHV_CMD_GET_1ST_S16(i + 1); +// table[i + 1] = BHV_CMD_GET_2ND_S16(i + 1); +// } - cur_obj_set_int(field, table[(s32)(tableSize * random_float())]); +// cur_obj_set_int(field, table[(s32)(tableSize * random_float())]); // Does not increment gCurBhvCommand or return a bhv status -} +//} /** // Command 0x??: Sets the specified field to a random entry in the given table, up to size 16. diff --git a/src/engine/math_util.c b/src/engine/math_util.c index 3f027ed57d..da9c29caf8 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -12,110 +12,93 @@ Vec4s *gSplineKeyframe; float gSplineKeyframeFraction; int gSplineState; -// These functions have bogus return values. -// Disable the compiler warning. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wreturn-local-addr" - /// Copy vector 'src' to 'dest' -void *vec3f_copy(Vec3f dest, Vec3f src) { +void vec3f_copy(Vec3f dest, Vec3f src) { dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; - return &dest; //! warning: function returns address of local variable } /// Set vector 'dest' to (x, y, z) -void *vec3f_set(Vec3f dest, f32 x, f32 y, f32 z) { +void vec3f_set(Vec3f dest, f32 x, f32 y, f32 z) { dest[0] = x; dest[1] = y; dest[2] = z; - return &dest; //! warning: function returns address of local variable } /// Add vector 'a' to 'dest' -void *vec3f_add(Vec3f dest, Vec3f a) { +void vec3f_add(Vec3f dest, Vec3f a) { dest[0] += a[0]; dest[1] += a[1]; dest[2] += a[2]; - return &dest; //! warning: function returns address of local variable } /// Make 'dest' the sum of vectors a and b. -void *vec3f_sum(Vec3f dest, Vec3f a, Vec3f b) { +void vec3f_sum(Vec3f dest, Vec3f a, Vec3f b) { dest[0] = a[0] + b[0]; dest[1] = a[1] + b[1]; dest[2] = a[2] + b[2]; - return &dest; //! warning: function returns address of local variable } /// Multiply vector 'dest' by a -void *vec3f_mul(Vec3f dest, f32 a) +void vec3f_mul(Vec3f dest, f32 a) { dest[0] *= a; dest[1] *= a; dest[2] *= a; - return &dest; //! warning: function returns address of local variable } /// Copy vector src to dest -void *vec3s_copy(Vec3s dest, Vec3s src) { +void vec3s_copy(Vec3s dest, Vec3s src) { dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; - return &dest; //! warning: function returns address of local variable } /// Set vector 'dest' to (x, y, z) -void *vec3s_set(Vec3s dest, s16 x, s16 y, s16 z) { +void vec3s_set(Vec3s dest, s16 x, s16 y, s16 z) { dest[0] = x; dest[1] = y; dest[2] = z; - return &dest; //! warning: function returns address of local variable } /// Add vector a to 'dest' -void *vec3s_add(Vec3s dest, Vec3s a) { +void vec3s_add(Vec3s dest, Vec3s a) { dest[0] += a[0]; dest[1] += a[1]; dest[2] += a[2]; - return &dest; //! warning: function returns address of local variable } /// Make 'dest' the sum of vectors a and b. -void *vec3s_sum(Vec3s dest, Vec3s a, Vec3s b) { +void vec3s_sum(Vec3s dest, Vec3s a, Vec3s b) { dest[0] = a[0] + b[0]; dest[1] = a[1] + b[1]; dest[2] = a[2] + b[2]; - return &dest; //! warning: function returns address of local variable } /// Make 'dest' the difference of vectors a and b. -void *vec3f_dif(Vec3f dest, Vec3f a, Vec3f b) { +void vec3f_dif(Vec3f dest, Vec3f a, Vec3f b) { dest[0] = a[0] - b[0]; dest[1] = a[1] - b[1]; dest[2] = a[2] - b[2]; - return &dest; //! warning: function returns address of local variable } /// Convert short vector a to float vector 'dest' -void *vec3s_to_vec3f(Vec3f dest, Vec3s a) { +void vec3s_to_vec3f(Vec3f dest, Vec3s a) { dest[0] = a[0]; dest[1] = a[1]; dest[2] = a[2]; - return &dest; //! warning: function returns address of local variable } /** * Convert float vector a to a short vector 'dest' by rounding the components * to the nearest integer. */ -void *vec3f_to_vec3s(Vec3s dest, Vec3f a) { +void vec3f_to_vec3s(Vec3s dest, Vec3f a) { // add/subtract 0.5 in order to round to the nearest s32 instead of truncating dest[0] = a[0] + ((a[0] > 0) ? 0.5f : -0.5f); dest[1] = a[1] + ((a[1] > 0) ? 0.5f : -0.5f); dest[2] = a[2] + ((a[2] > 0) ? 0.5f : -0.5f); - return &dest; //! warning: function returns address of local variable } /** @@ -123,30 +106,33 @@ void *vec3f_to_vec3s(Vec3s dest, Vec3f a) { * It is similar to vec3f_cross, but it calculates the vectors (c-b) and (b-a) * at the same time. */ -void *find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c) { +void find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c) { dest[0] = (b[1] - a[1]) * (c[2] - b[2]) - (c[1] - b[1]) * (b[2] - a[2]); dest[1] = (b[2] - a[2]) * (c[0] - b[0]) - (c[2] - b[2]) * (b[0] - a[0]); dest[2] = (b[0] - a[0]) * (c[1] - b[1]) - (c[0] - b[0]) * (b[1] - a[1]); - return &dest; //! warning: function returns address of local variable } /// Make vector 'dest' the cross product of vectors a and b. -void *vec3f_cross(Vec3f dest, Vec3f a, Vec3f b) { +void vec3f_cross(Vec3f dest, Vec3f a, Vec3f b) { dest[0] = a[1] * b[2] - b[1] * a[2]; dest[1] = a[2] * b[0] - b[2] * a[0]; dest[2] = a[0] * b[1] - b[0] * a[1]; - return &dest; //! warning: function returns address of local variable } /// Scale vector 'dest' so it has length 1 -void *vec3f_normalize(Vec3f dest) { +void vec3f_normalize(Vec3f dest) { //! Possible division by zero - f32 invsqrt = 1.0f / sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]); + // Workaround done here + f32 invsqrt = 0.0f; + if (dest[0] == 0 && dest[1] == 0 && dest[2] == 0) { + invsqrt = 0.0f; + } else { + invsqrt = 1.0f / sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]); + } dest[0] *= invsqrt; dest[1] *= invsqrt; dest[2] *= invsqrt; - return &dest; //! warning: function returns address of local variable } /// Get length of vector 'a' @@ -161,8 +147,6 @@ f32 vec3f_dot(Vec3f a, Vec3f b) return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } -#pragma GCC diagnostic pop - /// Copy matrix 'src' to 'dest' void mtxf_copy(Mat4 dest, Mat4 src) { register s32 i; diff --git a/src/engine/math_util.h b/src/engine/math_util.h index f28799d29e..2a96f78c7a 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -33,22 +33,22 @@ extern f32 gCosineTable[]; #include "../../include/libc/stdlib.h" -void *vec3f_copy(Vec3f dest, Vec3f src); -void *vec3f_set(Vec3f dest, f32 x, f32 y, f32 z); -void *vec3f_add(Vec3f dest, Vec3f a); -void *vec3f_sum(Vec3f dest, Vec3f a, Vec3f b); -void *vec3f_dif(Vec3f dest, Vec3f a, Vec3f b); -void *vec3f_mul(Vec3f dest, f32 a); -void *vec3s_copy(Vec3s dest, Vec3s src); -void *vec3s_set(Vec3s dest, s16 x, s16 y, s16 z); -void *vec3s_add(Vec3s dest, Vec3s a); -void *vec3s_sum(Vec3s dest, Vec3s a, Vec3s b); -void *vec3s_sub(Vec3s dest, Vec3s a); -void *vec3s_to_vec3f(Vec3f dest, Vec3s a); -void *vec3f_to_vec3s(Vec3s dest, Vec3f a); -void *find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c); -void *vec3f_cross(Vec3f dest, Vec3f a, Vec3f b); -void *vec3f_normalize(Vec3f dest); +void vec3f_copy(Vec3f dest, Vec3f src); +void vec3f_set(Vec3f dest, f32 x, f32 y, f32 z); +void vec3f_add(Vec3f dest, Vec3f a); +void vec3f_sum(Vec3f dest, Vec3f a, Vec3f b); +void vec3f_dif(Vec3f dest, Vec3f a, Vec3f b); +void vec3f_mul(Vec3f dest, f32 a); +void vec3s_copy(Vec3s dest, Vec3s src); +void vec3s_set(Vec3s dest, s16 x, s16 y, s16 z); +void vec3s_add(Vec3s dest, Vec3s a); +void vec3s_sum(Vec3s dest, Vec3s a, Vec3s b); +void vec3s_sub(Vec3s dest, Vec3s a); +void vec3s_to_vec3f(Vec3f dest, Vec3s a); +void vec3f_to_vec3s(Vec3s dest, Vec3f a); +void find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c); +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]); diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index c0e97ddafe..eb8ef65829 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -10,6 +10,7 @@ #include "surface_load.h" #include "game/object_list_processor.h" #include "math_util.h" +#include "macros.h" /************************************************** * WALLS * @@ -373,7 +374,7 @@ f32 unused_obj_find_floor_height(struct Object *obj) { */ struct FloorGeometry sFloorGeo; -static u8 unused8038BE50[0x40]; +UNUSED static u8 unused8038BE50[0x40]; /** * Return the floor height underneath (xPos, yPos, zPos) and populate `floorGeo` diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index 7a7da511ba..41aac22252 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -291,8 +291,8 @@ static void add_surface(struct Surface *surface, s32 dynamic) { } } -static void stub_surface_load_1(void) { -} +//static void stub_surface_load_1(void) { +//} /** * Initializes a Surface struct using the given vertex data @@ -651,8 +651,8 @@ void clear_dynamic_surfaces(void) { } } -static void unused_80383604(void) { -} +//static void unused_80383604(void) { +//} /** * Applies an object's tranformation to the object's vertices. diff --git a/src/game/area.c b/src/game/area.c index d408190c71..08f7404740 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -107,10 +107,14 @@ void set_warp_transition_rgb(u8 red, u8 green, u8 blue) { gWarpTransBlue = blue; } +#if defined(VERSION_EU) && defined(TARGET_WEB) +UNUSED +#else static int scale_x_to_correct_aspect_center(int x) { f32 aspect = GFX_DIMENSIONS_ASPECT_RATIO; return x + (SCREEN_HEIGHT * aspect / 2) - (SCREEN_WIDTH / 2); } +#endif void print_intro_text(void) { #ifdef VERSION_EU diff --git a/src/game/behaviors/beta_trampoline.inc.c b/src/game/behaviors/beta_trampoline.inc.c index f9c248f57c..d6de717573 100644 --- a/src/game/behaviors/beta_trampoline.inc.c +++ b/src/game/behaviors/beta_trampoline.inc.c @@ -30,7 +30,11 @@ void bhv_beta_trampoline_spring_loop(void) { // must be replaced with 150 (the height of the trampoline). // Note that all of the numbers in this if/else block are doubles. if ((yDisplacement = o->oPosY - o->oHomeY) >= 0) { + #ifndef QOL_FIXES yScale = yDisplacement / 10.0 + 1.0; + #else + yScale = yDisplacement / 150.0f + 1.0; + #endif } else { // Otherwise (if the trampoline is compressed), // scale by 1 - (the displacement)/500. @@ -38,7 +42,12 @@ void bhv_beta_trampoline_spring_loop(void) { // must be replaced with 150 (the height of the trampoline), // as with the above code. yDisplacement = -yDisplacement; + #ifndef QOL_FIXES yScale = 1.0 - yDisplacement / 500.0; + #else + yScale = 1.0 - yDisplacement / 150.0f; + o->oPosY += 75.0f * (1.0f - yScale); + #endif } // Scale the spring @@ -73,9 +82,27 @@ void bhv_beta_trampoline_top_loop(void) { // when Mario's on it in this if statement? if (gMarioObject->platform == o) { o->oBetaTrampolineMarioOnTrampoline = TRUE; + #ifdef QOL_FIXES + o->oPosY = + (o->oPosY > (o->oHomeY - 150.0f + 75.0f)) ? + (o->oPosY - 10) : + (o->oHomeY - 150.0f + 65.0f); + + o->oBetaTrampolineAdditiveYVel = + ((o->oBehParams2ndByte >> 4) / 2.0f) + + ((o->oHomeY - o->oPosY) / ((o->oBehParams2ndByte & 0x0F) / 2.0f)); + #endif } else { o->oBetaTrampolineMarioOnTrampoline = FALSE; o->oPosY = o->oHomeY; + #ifdef QOL_FIXES + o->oPosY = + (o->oPosY < (o->oHomeY - 10.0f)) ? + (o->oPosY + 10.0f) : + o->oHomeY; + + o->oBetaTrampolineAdditiveYVel = 0; + #endif } // This function is from mario_step.c, and is empty. diff --git a/src/game/behaviors/bowling_ball.inc.c b/src/game/behaviors/bowling_ball.inc.c index 292b7c4db2..2ba71bde54 100644 --- a/src/game/behaviors/bowling_ball.inc.c +++ b/src/game/behaviors/bowling_ball.inc.c @@ -65,7 +65,7 @@ void bowling_ball_set_waypoints(void) { void bhv_bowling_ball_roll_loop(void) { s16 collisionFlags; - s32 sp18; + s32 sp18 = 0; bowling_ball_set_waypoints(); collisionFlags = object_step(); @@ -95,7 +95,7 @@ void bhv_bowling_ball_roll_loop(void) { } void bhv_bowling_ball_initializeLoop(void) { - s32 sp1c; + s32 sp1c = 0; bowling_ball_set_waypoints(); @@ -247,7 +247,11 @@ void bhv_free_bowling_ball_roll_loop(void) { cur_obj_play_sound_1(SOUND_ENV_UNKNOWN2); } + #ifndef QOL_FIXES if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) && !(collisionFlags & OBJ_COL_FLAGS_LANDED)) + #else + if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) && !(collisionFlags & OBJ_COL_FLAG_NO_Y_VEL)) // could mess with bowling ball behavior, but it fixes a compiler warning + #endif cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND1_LOWPRIO); if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 6000)) { diff --git a/src/game/behaviors/bowser.inc.c b/src/game/behaviors/bowser.inc.c index 38908d01e3..7621f2aa3f 100644 --- a/src/game/behaviors/bowser.inc.c +++ b/src/game/behaviors/bowser.inc.c @@ -181,13 +181,13 @@ void bowser_act_intro_walk(void) { } } -static void bowser_debug_actions(void) // unused -{ - if (gDebugInfo[5][1] != 0) { - o->oAction = D_8032F4FC[gDebugInfo[5][2] & 0xf]; - gDebugInfo[5][1] = 0; - } -} +//static void bowser_debug_actions(void) // unused +//{ +// if (gDebugInfo[5][1] != 0) { +// o->oAction = D_8032F4FC[gDebugInfo[5][2] & 0xf]; +// gDebugInfo[5][1] = 0; +// } +//} void bowser_bitdw_act_controller(void) { f32 rand = random_float(); diff --git a/src/game/behaviors/camera_lakitu.inc.c b/src/game/behaviors/camera_lakitu.inc.c index 0f70c3398f..d96d5be0b5 100644 --- a/src/game/behaviors/camera_lakitu.inc.c +++ b/src/game/behaviors/camera_lakitu.inc.c @@ -61,8 +61,8 @@ static void camera_lakitu_intro_act_spawn_cloud(void) { * Circle down to mario, show the dialog, then fly away. */ static void camera_lakitu_intro_act_show_dialog(void) { - s16 targetMovePitch; - s16 targetMoveYaw; + s16 targetMovePitch = 0; + s16 targetMoveYaw = 0; cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY); diff --git a/src/game/behaviors/castle_floor_trap.inc.c b/src/game/behaviors/castle_floor_trap.inc.c index 9eeddbb4c4..122798a426 100644 --- a/src/game/behaviors/castle_floor_trap.inc.c +++ b/src/game/behaviors/castle_floor_trap.inc.c @@ -26,7 +26,11 @@ void bhv_castle_floor_trap_open_detect(void) { void bhv_castle_floor_trap_open(void) { if (o->oTimer == 0) + #ifdef QOL_FIXES + create_sound_spawner(SOUND_GENERAL_CASTLE_TRAP_OPEN); + #else cur_obj_play_sound_2(SOUND_GENERAL_CASTLE_TRAP_OPEN); + #endif o->oAngleVelRoll -= 0x100; o->oFaceAngleRoll += o->oAngleVelRoll; if (o->oFaceAngleRoll < -0x4000) { diff --git a/src/game/behaviors/chuckya.inc.c b/src/game/behaviors/chuckya.inc.c index 4eab68c918..0b6bbf7b5c 100644 --- a/src/game/behaviors/chuckya.inc.c +++ b/src/game/behaviors/chuckya.inc.c @@ -71,7 +71,7 @@ s32 approach_forward_vel(f32 *arr, f32 spC, f32 sp10) { } void chuckya_act_0(void) { - s32 sp3C; + s32 sp3C = 0; UNUSED u8 pad[16]; s32 sp28; if (o->oTimer == 0) diff --git a/src/game/behaviors/klepto.inc.c b/src/game/behaviors/klepto.inc.c index 22ab3e8fb7..99674a4a53 100644 --- a/src/game/behaviors/klepto.inc.c +++ b/src/game/behaviors/klepto.inc.c @@ -75,7 +75,14 @@ static void klepto_anim_dive(void) { void bhv_klepto_init(void) { if (o->oBehParams2ndByte != 0) { + #ifdef QOL_FIXES + if(save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_SSL) & 1) + o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_TRANSPARENT_STAR; + else + o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_STAR; + #else o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_STAR; + #endif } else { o->oKleptoStartPosX = o->oPosX; o->oKleptoStartPosY = o->oPosY; @@ -364,7 +371,13 @@ void bhv_klepto_update(void) { spawn_object(o, MODEL_MARIOS_CAP, bhvNormalCap); } else if (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_STAR) { spawn_default_star(-5550.0f, 300.0f, -930.0f); + #ifndef QOL_FIXES } + #else + } else if (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_TRANSPARENT_STAR) { + spawn_default_star(-5550.0f, 300.0f, -930.0f); + } + #endif o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_NOTHING; o->oAction = KLEPTO_ACT_STRUCK_BY_MARIO; diff --git a/src/game/behaviors/manta_ray.inc.c b/src/game/behaviors/manta_ray.inc.c index 4ffc5bf191..4c56a3e25c 100644 --- a/src/game/behaviors/manta_ray.inc.c +++ b/src/game/behaviors/manta_ray.inc.c @@ -28,7 +28,7 @@ void bhv_manta_ray_init(void) { void manta_ray_move(void) { s16 sp1E; - s32 sp18; + s32 sp18 = 0; sp1E = o->header.gfx.unk38.animFrame; gCurrentObject->oPathedWaypointsS16 = &D_803316A8; diff --git a/src/game/behaviors/mips.inc.c b/src/game/behaviors/mips.inc.c index 358161290e..6979d591f4 100644 --- a/src/game/behaviors/mips.inc.c +++ b/src/game/behaviors/mips.inc.c @@ -110,7 +110,7 @@ void bhv_mips_act_wait_for_nearby_mario(void) { */ void bhv_mips_act_follow_path(void) { s16 collisionFlags = 0; - s32 followStatus; + s32 followStatus = 0; struct Waypoint **pathBase; struct Waypoint *waypoint; diff --git a/src/game/behaviors/pyramid_top.inc.c b/src/game/behaviors/pyramid_top.inc.c index 536ce96ff7..80a117db3f 100644 --- a/src/game/behaviors/pyramid_top.inc.c +++ b/src/game/behaviors/pyramid_top.inc.c @@ -96,6 +96,9 @@ void bhv_pyramid_top_loop(void) { if (o->oPyramidTopPillarsTouched == 4) { play_puzzle_jingle(); o->oAction = PYRAMID_TOP_ACT_SPINNING; + #ifdef QOL_FIXES + cutscene_pyramid_top_explode(); + #endif } break; @@ -113,6 +116,9 @@ void bhv_pyramid_top_loop(void) { } bhv_pyramid_top_explode(); + #ifdef QOL_FIXES + cutscene_pyramid_top_explode_end(); + #endif break; } } diff --git a/src/game/behaviors/snowman.inc.c b/src/game/behaviors/snowman.inc.c index 33857d0cf2..8c93ffc7a8 100644 --- a/src/game/behaviors/snowman.inc.c +++ b/src/game/behaviors/snowman.inc.c @@ -52,7 +52,7 @@ void adjust_rolling_face_pitch(f32 f12) { void snowmans_bottom_act_1(void) { UNUSED s16 sp26; - s32 sp20; + s32 sp20 = 0; UNUSED s16 sp1E; o->oPathedStartWaypoint = segmented_to_virtual(&ccm_seg7_trajectory_snowman); diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c index 2571f3d6cf..e35d345148 100644 --- a/src/game/behaviors/spawn_star.inc.c +++ b/src/game/behaviors/spawn_star.inc.c @@ -122,19 +122,19 @@ struct Object *spawn_star(struct Object *sp30, f32 sp34, f32 sp38, f32 sp3C) { } void spawn_default_star(f32 sp20, f32 sp24, f32 sp28) { - struct Object *sp1C; + struct Object *sp1C = NULL; sp1C = spawn_star(sp1C, sp20, sp24, sp28); sp1C->oBehParams2ndByte = 0; } void spawn_red_coin_cutscene_star(f32 sp20, f32 sp24, f32 sp28) { - struct Object *sp1C; + struct Object *sp1C = NULL; sp1C = spawn_star(sp1C, sp20, sp24, sp28); sp1C->oBehParams2ndByte = 1; } void spawn_no_exit_star(f32 sp20, f32 sp24, f32 sp28) { - struct Object *sp1C; + struct Object *sp1C = NULL; sp1C = spawn_star(sp1C, sp20, sp24, sp28); sp1C->oBehParams2ndByte = 1; sp1C->oInteractionSubtype |= INT_SUBTYPE_NO_EXIT; diff --git a/src/game/behaviors/ukiki.inc.c b/src/game/behaviors/ukiki.inc.c index 401abaa20f..fa506cfbb1 100644 --- a/src/game/behaviors/ukiki.inc.c +++ b/src/game/behaviors/ukiki.inc.c @@ -502,13 +502,13 @@ void ukiki_free_loop(void) { * * Possibly unused so AnimState could be used for wearing a hat? */ -static void ukiki_blink_timer(void) { - if (gGlobalTimer % 50 < 7) { - o->oAnimState = UKIKI_ANIM_STATE_EYE_CLOSED; - } else { - o->oAnimState = UKIKI_ANIM_STATE_DEFAULT; - } -} +//static void ukiki_blink_timer(void) { +// if (gGlobalTimer % 50 < 7) { +// o->oAnimState = UKIKI_ANIM_STATE_EYE_CLOSED; +// } else { +// o->oAnimState = UKIKI_ANIM_STATE_DEFAULT; +// } +//} /** * Called by the main behavior function for the cage ukiki whenever it is held. diff --git a/src/game/camera.c b/src/game/camera.c index 5ae68805be..3016285f62 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -700,6 +700,7 @@ f32 calc_y_to_curr_floor(f32 *posOff, f32 posMul, f32 posBound, f32 *focOff, f32 if (*focOff < -focBound) { *focOff = -focBound; } + return 0; } //Compiler gets mad if I put this any further above. thanks refresh 7 #ifdef BETTERCAMERA @@ -1707,11 +1708,12 @@ struct ParallelTrackingPoint sBBHLibraryParTrackPath[] = { { 0, { 0.0f, 0.0f, 0.0f }, 0.0f, 0.0f }, }; -s32 unused_update_mode_5_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNUSED Vec3f pos) { +UNUSED s32 unused_update_mode_5_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNUSED Vec3f pos) { + return 0; } -static void stub_camera_1(UNUSED s32 unused) { -} +//static void stub_camera_1(UNUSED s32 unused) { +//} void mode_boss_fight_camera(struct Camera *c) { c->nextYaw = update_boss_fight_camera(c, c->focus, c->pos); @@ -2033,6 +2035,7 @@ void mode_behind_mario_camera(struct Camera *c) { } s32 nop_update_water_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNUSED Vec3f pos) { + return 0; } /** @@ -4901,7 +4904,7 @@ void play_sound_if_cam_switched_to_lakitu_or_mario(void) { * Handles input for radial, outwards radial, parallel tracking, and 8 direction mode. */ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) { - s16 dummy; + s16 dummy = 0; if ((gCameraMovementFlags & CAM_MOVE_ENTERED_ROTATE_SURFACE) || !(gCameraMovementFlags & CAM_MOVE_ROTATE)) { @@ -5176,8 +5179,13 @@ u8 get_cutscene_from_mario_status(struct Camera *c) { //! doorStatus is never DOOR_ENTER_LOBBY when cameraEvent == 6, because //! doorStatus is only used for the star door in the lobby, which uses //! ACT_ENTERING_STAR_DOOR + // This seemingly errant behavior is removed when QOL_FIXES=1 + #ifndef QOL_FIXES if (c->mode == CAMERA_MODE_SPIRAL_STAIRS || c->mode == CAMERA_MODE_CLOSE || c->doorStatus == DOOR_ENTER_LOBBY) { + #else + if (c->mode == CAMERA_MODE_SPIRAL_STAIRS || c->mode == CAMERA_MODE_CLOSE) { + #endif cutscene = open_door_cutscene(CUTSCENE_DOOR_PULL_MODE, CUTSCENE_DOOR_PUSH_MODE); } else { cutscene = open_door_cutscene(CUTSCENE_DOOR_PULL, CUTSCENE_DOOR_PUSH); @@ -5369,13 +5377,13 @@ void set_focus_rel_mario(struct Camera *c, f32 leftRight, f32 yOff, f32 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; +//static void unused_set_pos_rel_mario(struct Camera *c, f32 leftRight, f32 yOff, f32 forwBack, s16 yawOff) { +// u16 yaw = sMarioCamState->faceAngle[1] + yawOff; - c->pos[0] = sMarioCamState->pos[0] + forwBack * sins(yaw) + leftRight * coss(yaw); - c->pos[1] = sMarioCamState->pos[1] + yOff; - c->pos[2] = sMarioCamState->pos[2] + forwBack * coss(yaw) - leftRight * sins(yaw); -} +// c->pos[0] = sMarioCamState->pos[0] + forwBack * sins(yaw) + leftRight * coss(yaw); +// c->pos[1] = sMarioCamState->pos[1] + yOff; +// c->pos[2] = sMarioCamState->pos[2] + forwBack * coss(yaw) - leftRight * sins(yaw); +//} /** * Rotates the offset `to` according to the pitch and yaw values in `rotation`. @@ -5418,7 +5426,7 @@ void determine_pushing_or_pulling_door(s16 *rotation) { if (sMarioCamState->action == ACT_PULLING_DOOR) { *rotation = 0; } else { - *rotation = DEGREES(180); + *rotation = (s16) DEGREES(180); } } @@ -7268,8 +7276,8 @@ void cutscene_unsoften_music(UNUSED struct Camera *c) { sequence_player_unlower(SEQ_PLAYER_LEVEL, 60); } -static void stub_camera_5(UNUSED struct Camera *c) { -} +//static void stub_camera_5(UNUSED struct Camera *c) { +//} BAD_RETURN(s32) cutscene_unused_start(UNUSED struct Camera *c) { } @@ -7754,8 +7762,8 @@ BAD_RETURN(s32) cutscene_dance_rotate_move_towards_mario(struct Camera *c) { /** * Speculated to be dance-related due to its proximity to the other dance functions */ -static BAD_RETURN(s32) cutscene_dance_unused(UNUSED struct Camera *c) { -} +//static BAD_RETURN(s32) cutscene_dance_unused(UNUSED struct Camera *c) { +//} /** * Slowly turn to the point 100 units in front of mario @@ -8667,9 +8675,9 @@ BAD_RETURN(s32) cutscene_death_stomach_goto_mario(struct Camera *c) { /** * Ah, yes */ -static void unused_water_death_move_to_side_of_mario(struct Camera *c) { - water_death_move_to_mario_side(c); -} +//static void unused_water_death_move_to_side_of_mario(struct Camera *c) { +// water_death_move_to_mario_side(c); +//} /** * Cutscene that plays when mario dies on his stomach. @@ -8941,13 +8949,13 @@ BAD_RETURN(s32) cutscene_enter_pyramid_top(struct Camera *c) { } } -static void unused_cutscene_goto_cvar(struct Camera *c) { - f32 dist; +//static void unused_cutscene_goto_cvar(struct Camera *c) { +// f32 dist; - dist = calc_abs_dist(sCutsceneVars[3].point, sMarioCamState->pos); - dist = calc_abs_dist(sCutsceneVars[9].point, sMarioCamState->pos) + 200.f; - cutscene_goto_cvar_pos(c, dist, 0x1000, 0x300, 0); -} +// dist = calc_abs_dist(sCutsceneVars[3].point, sMarioCamState->pos); +// dist = calc_abs_dist(sCutsceneVars[9].point, sMarioCamState->pos) + 200.f; +// cutscene_goto_cvar_pos(c, dist, 0x1000, 0x300, 0); +//} /** * cvar8 is mario's position and faceAngle @@ -9102,13 +9110,13 @@ BAD_RETURN(s32) cutscene_read_message_start(struct Camera *c) { sCutsceneVars[0].angle[0] = 0; } -static void unused_cam_to_mario(struct Camera *c) { - Vec3s dir; +//static void unused_cam_to_mario(struct Camera *c) { +// Vec3s dir; - vec3s_set(dir, 0, sMarioCamState->faceAngle[1], 0); - offset_rotated_coords(c->pos, sMarioCamState->pos, dir, 0, 100.f, 190.f); - offset_rotated_coords(c->focus, sMarioCamState->pos, dir, 0, 70.f, -20.f); -} +// vec3s_set(dir, 0, sMarioCamState->faceAngle[1], 0); +// offset_rotated_coords(c->pos, sMarioCamState->pos, dir, 0, 100.f, 190.f); +// offset_rotated_coords(c->focus, sMarioCamState->pos, dir, 0, 70.f, -20.f); +//} /** * Cutscene that plays when mario is reading a message (a sign or message on the wall) @@ -9236,12 +9244,19 @@ BAD_RETURN(s32) cutscene_exit_bowser_succ_focus_left(UNUSED struct Camera *c) { * Instead of focusing on the key, just start a pitch shake. Clever! * The shake lasts 32 frames. */ +#ifndef QOL_FIXES BAD_RETURN(s32) cutscene_exit_bowser_key_toss_shake(struct Camera *c) { //! Unnecessary check. + // Check removed when QOL_FIXES=1. if (c->cutscene == CUTSCENE_EXIT_BOWSER_SUCC) { set_camera_pitch_shake(0x800, 0x40, 0x800); } } +#else +BAD_RETURN(s32) cutscene_exit_bowser_key_toss_shake(UNUSED struct Camera *c) { + set_camera_pitch_shake(0x800, 0x40, 0x800); +} +#endif /** * Start a camera shake when mario lands on the ground. @@ -9572,8 +9587,8 @@ s32 intro_peach_move_camera_start_to_pipe(struct Camera *c, struct CutsceneSplin // The two splines used by this function are reflected in the horizontal plane for some reason, // so they are rotated every frame. Why do this, Nintendo? - rotate_in_xz(c->focus, c->focus, DEGREES(180)); - rotate_in_xz(c->pos, c->pos, DEGREES(180)); + rotate_in_xz(c->focus, c->focus, (s16)DEGREES(180)); + rotate_in_xz(c->pos, c->pos, (s16)DEGREES(180)); vec3f_set(offset, -1328.f, 260.f, 4664.f); vec3f_add(c->focus, offset); @@ -11312,9 +11327,16 @@ void play_cutscene(struct Camera *c) { if ((cutsceneDuration != 0) && !(gCutsceneTimer & CUTSCENE_STOP)) { //! @bug This should check for 0x7FFF (CUTSCENE_LOOP) //! instead, cutscenes that last longer than 0x3FFF frames will never end on their own + // Fixed when QOL_FIXES=1 + #ifndef QOL_FIXES if (gCutsceneTimer < 0x3FFF) { gCutsceneTimer += 1; } + #else + if (gCutsceneTimer < 0x7FFF) { + gCutsceneTimer += 1; + } + #endif //! Because gCutsceneTimer is often set to 0x7FFF (CUTSCENE_LOOP), this conditional can only //! check for == due to overflow if (gCutsceneTimer == cutsceneDuration) { diff --git a/src/game/camera.h b/src/game/camera.h index 42d78515b8..5741db6602 100644 --- a/src/game/camera.h +++ b/src/game/camera.h @@ -230,7 +230,7 @@ #define CUTSCENE_DANCE_FLY_AWAY 165 #define CUTSCENE_DANCE_CLOSEUP 166 #define CUTSCENE_KEY_DANCE 167 -#define CUTSCENE_SSL_PYRAMID_EXPLODE 168 // Never activated +#define CUTSCENE_SSL_PYRAMID_EXPLODE 168 // Never activated normally. Is now activated when QOL_FIXES=1. #define CUTSCENE_EXIT_SPECIAL_SUCC 169 #define CUTSCENE_NONPAINTING_DEATH 170 #define CUTSCENE_READ_MESSAGE 171 diff --git a/src/game/debug.c b/src/game/debug.c index 2a36460581..484cb19e6d 100644 --- a/src/game/debug.c +++ b/src/game/debug.c @@ -336,7 +336,7 @@ void reset_debug_objectinfo(void) { * C Right) and then toggles the debug flags from FF to 2; 2 is unused, * despite so this has no effect, being called. (unused) */ -static void check_debug_button_seq(void) { +UNUSED static void check_debug_button_seq(void) { s16 *buttonArr; s16 cButtonMask; @@ -366,7 +366,7 @@ static void check_debug_button_seq(void) { * Poll the debug info flags and controller for appropriate presses that * control sDebugPage's range. (unused) */ -static void try_change_debug_page(void) { +UNUSED static void try_change_debug_page(void) { if (gDebugInfoFlags & DEBUG_INFO_FLAG_DPRINT) { if ((gPlayer1Controller->buttonPressed & L_JPAD) && (gPlayer1Controller->buttonDown & (L_TRIG | R_TRIG))) { @@ -392,9 +392,10 @@ static void try_change_debug_page(void) { * on the fly. (unused) */ #ifndef VERSION_SH -static +UNUSED static void try_modify_debug_controls(void) { +#else +UNUSED void try_modify_debug_controls(void) { #endif -void try_modify_debug_controls(void) { s32 sp4; if (gPlayer1Controller->buttonPressed & Z_TRIG) { @@ -525,9 +526,10 @@ void try_do_mario_debug_object_spawn(void) { // TODO: figure out what this is #ifndef VERSION_SH -static +UNUSED static void debug_print_obj_move_flags(void) { +#else +UNUSED void debug_print_obj_move_flags(void) { #endif -void debug_print_obj_move_flags(void) { #ifndef VERSION_EU // TODO: Is there a better way to diff this? static EU doesn't seem to work. if (gCurrentObject->oMoveFlags & OBJ_MOVE_LANDED) { print_debug_top_down_objectinfo("BOUND %x", gCurrentObject->oMoveFlags); diff --git a/src/game/envfx_snow.c b/src/game/envfx_snow.c index ea2dfc4c50..52e3a939d6 100644 --- a/src/game/envfx_snow.c +++ b/src/game/envfx_snow.c @@ -272,12 +272,12 @@ void envfx_update_snow_blizzard(s32 snowCylinderX, s32 snowCylinderY, s32 snowCy * find it. The radius of 3000 units is quite large for that though, covering * more than half of the mirror room. */ -static s32 is_in_mystery_snow_area(s32 x, UNUSED s32 y, s32 z) { - if (sqr(x - 3380) + sqr(z + 520) < sqr(3000)) { - return 1; - } - return 0; -} +//static s32 is_in_mystery_snow_area(s32 x, UNUSED s32 y, s32 z) { +// if (sqr(x - 3380) + sqr(z + 520) < sqr(3000)) { +// return 1; +// } +// return 0; +//} /** * Update the position of underwater snow particles. Since they are stationary, diff --git a/src/game/game_init.c b/src/game/game_init.c index ffcf7a18e2..46a67da889 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -130,7 +130,7 @@ void clear_z_buffer(void) { gDPSetFillColor(gDisplayListHead++, GPACK_ZDZ(G_MAXFBZ, 0) << 16 | GPACK_ZDZ(G_MAXFBZ, 0)); - gDPFillRectangle(gDisplayListHead++, 0, BORDER_HEIGHT, SCREEN_WIDTH - 1, + gDPFillRectangle(gDisplayListHead++, GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(0), BORDER_HEIGHT, GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(0) - 1, SCREEN_HEIGHT - 1 - BORDER_HEIGHT); } @@ -315,7 +315,7 @@ void display_and_vsync(void) { // 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) { +UNUSED static void record_demo(void) { // record the player's button mask and current rawStickX and rawStickY. u8 buttonMask = ((gPlayer1Controller->buttonDown & (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON)) >> 8) diff --git a/src/game/hud.c b/src/game/hud.c index cf3dee0f9b..71a2140d6e 100644 --- a/src/game/hud.c +++ b/src/game/hud.c @@ -53,7 +53,7 @@ static struct PowerMeterHUD sPowerMeterHUD = { // when the power meter is hidden. s32 sPowerMeterVisibleTimer = 0; -static struct UnusedHUDStruct sUnusedHUDValues = { 0x00, 0x0A, 0x00 }; +//static struct UnusedHUDStruct sUnusedHUDValues = { 0x00, 0x0A, 0x00 }; static struct CameraHUD sCameraHUD = { CAM_STATUS_NONE }; diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index d7de9d4e63..e0a6797a14 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -218,7 +218,7 @@ void create_dl_ortho_matrix(void) { } #if defined(VERSION_JP) || defined(VERSION_SH) -static inline void alloc_ia8_text_from_i1(u8 *out, u16 *in, s16 width, s16 height) { +static void alloc_ia8_text_from_i1(u8 *out, u16 *in, s16 width, s16 height) { s32 inPos; u16 bitMask; u16 inWord; @@ -241,7 +241,7 @@ static inline void alloc_ia8_text_from_i1(u8 *out, u16 *in, s16 width, s16 heigh } } -static inline u8 *convert_ia8_char(u8 c, u16 *tex, s16 w, s16 h) { +static u8 *convert_ia8_char(u8 c, u16 *tex, s16 w, s16 h) { if (!charCache[c].used) { charCache[c].used = 1; alloc_ia8_text_from_i1(charCache[c].data, tex, w, h); @@ -280,7 +280,7 @@ void render_generic_char(u8 c) { #ifdef VERSION_EU static void alloc_ia4_tex_from_i1(u8 *out, u8 *in, s16 width, s16 height) { - u32 size = (u32) width * (u32) height; + UNUSED u32 size = (u32) width * (u32) height; s32 inPos; s16 outPos = 0; u8 bitMask; @@ -2968,13 +2968,14 @@ void render_save_confirmation(s16 x, s16 y, s8 *index, s16 sp6e) { TEXT_SAVE_AND_CONTINUE_FR }, { TEXT_SAVE_AND_CONTINUE_DE } }; + u8 textSaveAndQuitArr[][22] = { { TEXT_SAVE_AND_QUIT }, { TEXT_SAVE_AND_QUIT_FR }, { TEXT_SAVE_AND_QUIT_DE } }; - u8 textSaveExitGame[][26] = { // New function to exit game + u8 textSaveExitGame[][28] = { // New function to exit game { TEXT_SAVE_EXIT_GAME }, { TEXT_SAVE_EXIT_GAME_FR }, { TEXT_SAVE_EXIT_GAME_DE } diff --git a/src/game/interaction.c b/src/game/interaction.c index b8f3f881ed..5d2e327db8 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -524,35 +524,35 @@ void hit_object_from_below(struct MarioState *m, UNUSED struct Object *o) { set_camera_shake_from_hit(SHAKE_HIT_FROM_BELOW); } -static u32 unused_determine_knockback_action(struct MarioState *m) { - u32 bonkAction; - s16 angleToObject = mario_obj_angle_to_object(m, m->interactObj); - s16 facingDYaw = angleToObject - m->faceAngle[1]; - - if (m->forwardVel < 16.0f) { - m->forwardVel = 16.0f; - } - - m->faceAngle[1] = angleToObject; - - if (facingDYaw >= -0x4000 && facingDYaw <= 0x4000) { - m->forwardVel *= -1.0f; - if (m->action & (ACT_FLAG_AIR | ACT_FLAG_ON_POLE | ACT_FLAG_HANGING)) { - bonkAction = ACT_BACKWARD_AIR_KB; - } else { - bonkAction = ACT_SOFT_BACKWARD_GROUND_KB; - } - } else { - m->faceAngle[1] += 0x8000; - if (m->action & (ACT_FLAG_AIR | ACT_FLAG_ON_POLE | ACT_FLAG_HANGING)) { - bonkAction = ACT_FORWARD_AIR_KB; - } else { - bonkAction = ACT_SOFT_FORWARD_GROUND_KB; - } - } - - return bonkAction; -} +//static u32 unused_determine_knockback_action(struct MarioState *m) { +// u32 bonkAction; +// s16 angleToObject = mario_obj_angle_to_object(m, m->interactObj); +// s16 facingDYaw = angleToObject - m->faceAngle[1]; + +// if (m->forwardVel < 16.0f) { +// m->forwardVel = 16.0f; +// } + +// m->faceAngle[1] = angleToObject; + +// if (facingDYaw >= -0x4000 && facingDYaw <= 0x4000) { +// m->forwardVel *= -1.0f; +// if (m->action & (ACT_FLAG_AIR | ACT_FLAG_ON_POLE | ACT_FLAG_HANGING)) { +// bonkAction = ACT_BACKWARD_AIR_KB; +// } else { +// bonkAction = ACT_SOFT_BACKWARD_GROUND_KB; +// } +// } else { +// m->faceAngle[1] += 0x8000; +// if (m->action & (ACT_FLAG_AIR | ACT_FLAG_ON_POLE | ACT_FLAG_HANGING)) { +// bonkAction = ACT_FORWARD_AIR_KB; +// } else { +// bonkAction = ACT_SOFT_FORWARD_GROUND_KB; +// } +// } + +// return bonkAction; +//} u32 determine_knockback_action(struct MarioState *m, UNUSED s32 arg) { u32 bonkAction; @@ -1297,12 +1297,12 @@ u32 interact_shock(struct MarioState *m, UNUSED u32 interactType, struct Object return FALSE; } -static u32 interact_stub(UNUSED struct MarioState *m, UNUSED u32 interactType, struct Object *o) { - if (!(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY)) { - sDelayInvincTimer = TRUE; - } - return FALSE; -} +//static u32 interact_stub(UNUSED struct MarioState *m, UNUSED u32 interactType, struct Object *o) { +// if (!(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY)) { +// sDelayInvincTimer = TRUE; +// } +// return FALSE; +//} u32 interact_mr_blizzard(struct MarioState *m, UNUSED u32 interactType, struct Object *o) { if (take_damage_and_knock_back(m, o)) { diff --git a/src/game/level_update.c b/src/game/level_update.c index 052959c454..9d00f14229 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1126,19 +1126,19 @@ s32 play_mode_change_level(void) { * 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) { - gHudDisplay.flags = HUD_DISPLAY_NONE; - - if (sWarpDest.type != WARP_TYPE_NOT_WARPING) { - return sWarpDest.levelNum; - } else { - return D_80339EE0; - } - } - - return 0; -} +//static s32 play_mode_unused(void) { +// if (--sTransitionTimer == -1) { +// gHudDisplay.flags = HUD_DISPLAY_NONE; + +// if (sWarpDest.type != WARP_TYPE_NOT_WARPING) { +// return sWarpDest.levelNum; +// } else { +// return D_80339EE0; +// } +// } + +// return 0; +//} s32 update_level(void) { s32 changeLevel; diff --git a/src/game/macro_special_objects.c b/src/game/macro_special_objects.c index d931897108..9e239f5dae 100644 --- a/src/game/macro_special_objects.c +++ b/src/game/macro_special_objects.c @@ -79,18 +79,18 @@ void spawn_macro_abs_special(u32 model, const BehaviorScript *behavior, s16 x, s newObj->oMacroUnk110 = (f32) unkC; } -static void spawn_macro_coin_unknown(const BehaviorScript *behavior, s16 a1[]) { - struct Object *sp3C; - s16 model; +//static void spawn_macro_coin_unknown(const BehaviorScript *behavior, s16 a1[]) { +// struct Object *sp3C; +// s16 model; - model = bhvYellowCoin == behavior ? MODEL_YELLOW_COIN : MODEL_NONE; +// model = bhvYellowCoin == behavior ? MODEL_YELLOW_COIN : MODEL_NONE; - sp3C = spawn_object_abs_with_rot(&gMacroObjectDefaultParent, 0, model, behavior, - a1[1], a1[2], a1[3], 0, convert_rotation(a1[0]), 0); +// sp3C = spawn_object_abs_with_rot(&gMacroObjectDefaultParent, 0, model, behavior, +// a1[1], a1[2], a1[3], 0, convert_rotation(a1[0]), 0); - sp3C->oUnk1A8 = a1[4]; - sp3C->oBehParams = (a1[4] & 0xFF) >> 16; -} +// sp3C->oUnk1A8 = a1[4]; +// sp3C->oBehParams = (a1[4] & 0xFF) >> 16; +//} struct LoadedPreset { /*0x00*/ const BehaviorScript *behavior; diff --git a/src/game/main.h b/src/game/main.h index 901b1c0ae7..92fb91a9f7 100644 --- a/src/game/main.h +++ b/src/game/main.h @@ -73,6 +73,6 @@ 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); +extern int main(void); #endif diff --git a/src/game/mario.c b/src/game/mario.c index e00d6e6028..3352b92ce1 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -33,6 +33,7 @@ #include "thread6.h" #include "pc/configfile.h" #include "pc/cheats.h" +#include "macros.h" #ifdef BETTERCAMERA #include "bettercamera.h" #endif @@ -1705,7 +1706,7 @@ void mario_update_hitbox_and_cap_model(struct MarioState *m) { * An unused and possibly a debug function. Z + another button input * sets Mario with a different cap. */ -static void debug_update_mario_cap(u16 button, s32 flags, u16 capTimer, u16 capMusic) { +UNUSED static void debug_update_mario_cap(u16 button, s32 flags, u16 capTimer, u16 capMusic) { // This checks for Z_TRIG instead of Z_DOWN flag // (which is also what other debug functions do), // so likely debug behavior rather than unused behavior. diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 451035ae8f..afb5ec08f9 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -67,17 +67,17 @@ s32 check_fall_damage(struct MarioState *m, u32 hardFallAction) { fallHeight = m->peakHeight - m->pos[1]; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wtype-limits" - - //! Never true + //! Never normally true + // Fixed when QOL_FIXES=1 + #ifdef QOL_FIXES if (m->actionState == ACT_GROUND_POUND) { damageHeight = 600.0f; } else { damageHeight = 1150.0f; } - -#pragma GCC diagnostic pop + #else + damageHeight = 1150.0f; // fixes a WebGL compiler warning when done this way + #endif if (m->action != ACT_TWIRLING && m->floor->type != SURFACE_BURNING) { if (m->vel[1] < -55.0f) { diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index ef413cd989..6dc78bfe0a 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -220,11 +220,11 @@ s32 geo_switch_peach_eyes(s32 run, struct GraphNode *node, UNUSED s32 a2) { } // unused -static void stub_is_textbox_active(u16 *a0) { - if (get_dialog_id() == -1) { - *a0 = 0; - } -} +//static void stub_is_textbox_active(u16 *a0) { +// if (get_dialog_id() == -1) { +// *a0 = 0; +// } +//} /** * get_star_collection_dialog: Determine what dialog should show when Mario diff --git a/src/game/mario_step.c b/src/game/mario_step.c index 226f93edd0..f9fa3e0af5 100644 --- a/src/game/mario_step.c +++ b/src/game/mario_step.c @@ -8,6 +8,7 @@ #include "game_init.h" #include "interaction.h" #include "mario_step.h" +#include "object_list_processor.h" static s16 sMovingSandSpeeds[] = { 12, 8, 4, 0 }; @@ -16,6 +17,8 @@ struct Surface gWaterSurfacePseudoFloor = { { 0.0f, 1.0f, 0.0f }, 0.0f, NULL, }; +static struct Object *sTrampoline; + /** * Always returns zero. This may have been intended * to be used for the beta trampoline. Its return value @@ -27,7 +30,11 @@ struct Surface gWaterSurfacePseudoFloor = { * and if so return a higher value than 0. */ f32 get_additive_y_vel_for_jumps(void) { + #ifndef QOL_FIXES return 0.0f; + #else + return (sTrampoline != NULL) ? sTrampoline->oBetaTrampolineAdditiveYVel : 0.0f; + #endif } /** @@ -50,6 +57,9 @@ void stub_mario_step_1(UNUSED struct MarioState *x) { * or to set a variable with its intended additive Y vel. */ void stub_mario_step_2(void) { + #ifdef QOL_FIXES + sTrampoline = gCurrentObject; + #endif } void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollisionData *obj2) { diff --git a/src/game/memory.c b/src/game/memory.c index 14c332cc3a..c7f24153c5 100644 --- a/src/game/memory.c +++ b/src/game/memory.c @@ -80,7 +80,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; } @@ -224,8 +224,7 @@ u32 main_pool_pop_state(void) { * function blocks until completion. */ static void dma_read(u8 *dest, u8 *srcStart, u8 *srcEnd) { - u32 size = ALIGN16(srcEnd - srcStart); - + UNUSED u32 size = ALIGN16(srcEnd - srcStart); memcpy(dest, srcStart, srcEnd - srcStart); } diff --git a/src/game/obj_behaviors_2.c b/src/game/obj_behaviors_2.c index eb52683cfb..1b3f61b675 100644 --- a/src/game/obj_behaviors_2.c +++ b/src/game/obj_behaviors_2.c @@ -688,10 +688,10 @@ static void obj_die_if_health_non_positive(void) { } } -static void obj_unused_die(void) { - o->oHealth = 0; - obj_die_if_health_non_positive(); -} +//static void obj_unused_die(void) { +// o->oHealth = 0; +// obj_die_if_health_non_positive(); +//} static void obj_set_knockback_action(s32 attackType) { switch (attackType) { diff --git a/src/game/object_collision.c b/src/game/object_collision.c index 5c83526ab3..be8c40c784 100644 --- a/src/game/object_collision.c +++ b/src/game/object_collision.c @@ -56,7 +56,7 @@ int detect_object_hitbox_overlap(struct Object *a, struct Object *b) { return 1; } - //! no return value + return 0; } int detect_object_hurtbox_overlap(struct Object *a, struct Object *b) { @@ -88,7 +88,7 @@ int detect_object_hurtbox_overlap(struct Object *a, struct Object *b) { return 1; } - //! no return value + return 0; } void clear_object_collision(struct Object *a) { diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index e05f77439f..6a0626fddf 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -1395,8 +1395,8 @@ void cur_obj_move_y(f32 gravity, f32 bounciness, f32 buoyancy) { } } -static void stub_obj_helpers_1(void) { -} +//static void stub_obj_helpers_1(void) { +//} static s32 clear_move_flag(u32 *bitSet, s32 flag) { if (*bitSet & flag) { @@ -2255,8 +2255,8 @@ void bhv_dust_smoke_loop(void) { o->oSmokeTimer++; } -static void stub_obj_helpers_2(void) { -} +//static void stub_obj_helpers_2(void) { +//} s32 cur_obj_set_direction_table(s8 *a0) { o->oToxBoxUnk1AC = a0; @@ -2404,8 +2404,8 @@ s32 is_item_in_array(s8 item, s8 *array) { return FALSE; } -static void stub_obj_helpers_5(void) { -} +//static void stub_obj_helpers_5(void) { +//} void bhv_init_room(void) { struct Surface *floor; diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 3bb3ca65a9..11fa20ad50 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -603,22 +603,22 @@ void unload_deactivated_objects(void) { /** * Unused profiling function. */ -static u16 unused_get_elapsed_time(u64 *cycleCounts, s32 index) { - u16 time; - f64 cycles; - - cycles = cycleCounts[index] - cycleCounts[index - 1]; - if (cycles < 0) { - cycles = 0; - } - - time = (u16)(((u64) cycles * 1000000 / osClockRate) / 16667.0 * 1000.0); - if (time > 999) { - time = 999; - } - - return time; -} +//static u16 unused_get_elapsed_time(u64 *cycleCounts, s32 index) { +// u16 time; +// f64 cycles; + +// cycles = cycleCounts[index] - cycleCounts[index - 1]; +// if (cycles < 0) { +// cycles = 0; +// } + +// time = (u16)(((u64) cycles * 1000000 / osClockRate) / 16667.0 * 1000.0); +// if (time > 999) { +// time = 999; +// } + +// return time; +//} /** * Update all objects. This includes script execution, object collision detection, diff --git a/src/game/options_menu.c b/src/game/options_menu.c index 4e08dbdb1d..7d57e107ec 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -59,6 +59,7 @@ static const u8 menuStr[][32] = { }; +#if defined(BETTERCAMERA) && defined(EXT_OPTIONS_MENU) static const u8 optsCameraStr[][32] = { { TEXT_OPT_CAMX }, { TEXT_OPT_CAMY }, @@ -70,6 +71,7 @@ static const u8 optsCameraStr[][32] = { { TEXT_OPT_MOUSE }, { TEXT_OPT_CAMD }, }; +#endif static const u8 optsVideoStr[][32] = { { TEXT_OPT_FSCREEN }, diff --git a/src/game/paintings.c b/src/game/paintings.c index e53dd45f4c..bb1c210fed 100644 --- a/src/game/paintings.c +++ b/src/game/paintings.c @@ -247,6 +247,7 @@ f32 painting_ripple_y(struct Painting *painting, s8 ySource) { return painting->size / 2.0; // some concentric ripples don't care about Mario break; } + return 0; } /** @@ -272,6 +273,7 @@ f32 painting_nearest_4th(struct Painting *painting) { } else if (painting->floorEntered & ENTER_RIGHT) { return thirdQuarter; } + return 0; } /** @@ -303,6 +305,7 @@ f32 painting_ripple_x(struct Painting *painting, s8 xSource) { return painting->size / 2.0; break; } + return 0; } /** diff --git a/src/game/screen_transition.c b/src/game/screen_transition.c index c009abea50..eae9fb320a 100644 --- a/src/game/screen_transition.c +++ b/src/game/screen_transition.c @@ -238,6 +238,7 @@ int render_screen_transition(s8 fadeTimer, s8 transType, u8 transTime, struct Wa return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR); break; } + return 0; } Gfx *render_cannon_circle_base(void) { diff --git a/src/game/shadow.c b/src/game/shadow.c index 5b74545d03..0db25c379e 100644 --- a/src/game/shadow.c +++ b/src/game/shadow.c @@ -190,8 +190,7 @@ f32 get_water_level_below_shadow(struct Shadow *s) { gShadowAboveWaterOrLava = TRUE; return waterLevel; } - //! @bug Missing return statement. This compiles to return `waterLevel` - //! incidentally. + return waterLevel; } /** diff --git a/src/game/sound_init.c b/src/game/sound_init.c index ec5dfcbc1c..0f052c517d 100644 --- a/src/game/sound_init.c +++ b/src/game/sound_init.c @@ -29,7 +29,7 @@ static u16 sCurrentMusic = MUSIC_NONE; static u16 sCurrentShellMusic = MUSIC_NONE; static u16 sCurrentCapMusic = MUSIC_NONE; static u8 sPlayingInfiniteStairs = FALSE; -static u8 unused8032C6D8[16] = { 0 }; +//static u8 unused8032C6D8[16] = { 0 }; static s16 sSoundMenuModeToSoundMode[] = { SOUND_MODE_STEREO, SOUND_MODE_MONO, SOUND_MODE_HEADSET }; // Only the 20th array element is used. static u32 menuSoundsExtra[] = { diff --git a/src/game/spawn_object.c b/src/game/spawn_object.c index 79f930f2f7..13c28666c7 100644 --- a/src/game/spawn_object.c +++ b/src/game/spawn_object.c @@ -163,23 +163,23 @@ void clear_object_lists(struct ObjectNode *objLists) { /** * Delete the leaf graph nodes under obj and obj's siblings. */ -static void unused_delete_leaf_nodes(struct Object *obj) { - struct Object *children; - struct Object *sibling; - struct Object *obj0 = obj; - - if ((children = (struct Object *) obj->header.gfx.node.children) != NULL) { - unused_delete_leaf_nodes(children); - } else { +//static void unused_delete_leaf_nodes(struct Object *obj) { +// struct Object *children; +// struct Object *sibling; +// struct Object *obj0 = obj; + +// if ((children = (struct Object *) obj->header.gfx.node.children) != NULL) { +// unused_delete_leaf_nodes(children); +// } else { // No children - mark_obj_for_deletion(obj); - } - - while ((sibling = (struct Object *) obj->header.gfx.node.next) != obj0) { - unused_delete_leaf_nodes(sibling); - obj = (struct Object *) sibling->header.gfx.node.next; - } -} +// mark_obj_for_deletion(obj); +// } + +// while ((sibling = (struct Object *) obj->header.gfx.node.next) != obj0) { +// unused_delete_leaf_nodes(sibling); +// obj = (struct Object *) sibling->header.gfx.node.next; +// } +//} /** * Free the given object. diff --git a/src/goddard/debug_utils.c b/src/goddard/debug_utils.c index 6bd076433c..3f906d2869 100644 --- a/src/goddard/debug_utils.c +++ b/src/goddard/debug_utils.c @@ -410,7 +410,7 @@ void fatal_printf(const char *fmt, ...) { gd_printf("%s", va_arg(vl, char *)); break; case 'c': - gd_printf("%c", va_arg(vl, char)); + gd_printf("%c", va_arg(vl, int)); break; case 'x': gd_printf("%x", va_arg(vl, s32)); diff --git a/src/goddard/draw_objects.c b/src/goddard/draw_objects.c index 63ba040461..c5bcf9e901 100644 --- a/src/goddard/draw_objects.c +++ b/src/goddard/draw_objects.c @@ -61,7 +61,7 @@ static struct GdColour sClrYellow = { 1.0, 1.0, 0.0 }; // @ 801A80DC static struct GdColour sLightColours[1] = { { 1.0, 1.0, 0.0 } }; // @ 801A80E8 static struct GdColour *sSelectedColour = &sClrRed; // @ 801A80F4 struct ObjCamera *gViewUpdateCamera = NULL; // @ 801A80F8 -static void *sUnref801A80FC = NULL; +UNUSED static void *sUnref801A80FC = NULL; static s32 sUnreadShapeFlag = 0; // @ 801A8100 struct GdColour *sColourPalette[5] = { // @ 801A8104 &sClrWhite, &sClrYellow, &sClrRed, &sClrBlack, &sClrBlack @@ -71,20 +71,20 @@ struct GdColour *sWhiteBlack[2] = { &sClrWhite, &sClrBlack, }; -static Mat4f sUnref801A8120 = { +UNUSED static Mat4f sUnref801A8120 = { { 1.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 1.0, 0.0 }, { 0.0, 0.0, 0.0, 1.0 } }; -static Mat4f sUnrefIden801A8160 = { +UNUSED static Mat4f sUnrefIden801A8160 = { { 1.0, 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0 }, { 0.0, 0.0, 1.0, 0.0 }, { 0.0, 0.0, 0.0, 1.0 } }; static s32 sLightDlCounter = 1; // @ 801A81A0 -static s32 sUnref801A81A4[4] = { 0 }; +UNUSED static s32 sUnref801A81A4[4] = { 0 }; // bss u8 gUnref_801B9B30[0x88]; struct ObjGroup *gGdLightGroup; // @ 801B9BB8; is this the main light group? only light group? -static u8 sUnref_801B9BBC[0x40]; +UNUSED static u8 sUnref_801B9BBC[0x40]; static enum SceneType sSceneProcessType; // @ 801B9C00 static s32 sUseSelectedColor; // @ 801B9C04 static s16 sPickBuffer[100]; ///< buffer of objects near click diff --git a/src/goddard/dynlist_proc.c b/src/goddard/dynlist_proc.c index 2ffa327a33..7c402fab63 100644 --- a/src/goddard/dynlist_proc.c +++ b/src/goddard/dynlist_proc.c @@ -604,7 +604,7 @@ char *print_int_dynid(DynId id) { * @returns pointer to created object */ struct GdObj *d_makeobj(enum DObjTypes type, DynId id) { - struct GdObj *dobj; + struct GdObj *dobj = NULL; UNUSED struct ObjGroup *dgroup; switch (type) { @@ -720,7 +720,7 @@ void d_attach(DynId id) { */ void d_attach_to(s32 flag, struct GdObj *obj) { UNUSED u32 pad4C; - struct ObjGroup *attgrp; + struct ObjGroup *attgrp = NULL; UNUSED u32 pad[2]; UNUSED struct DynObjInfo *curInfo = sDynListCurInfo; struct GdVec3f dynobjPos; // transformed into attach offset @@ -1799,7 +1799,7 @@ struct ObjGroup *d_get_att_objgroup(void) { fatal_printf("%s: Object '%s'(%x) does not support this function.", "dGetAttObjGroup()", sDynListCurInfo->name, sDynListCurObj->type); } - // No null return due to `fatal_printf()` being a non-returning function? + return NULL; } /** @@ -1821,7 +1821,7 @@ struct GdObj *d_get_att_to_obj(void) { fatal_printf("%s: Object '%s'(%x) does not support this function.", "dGetAttToObj()", sDynListCurInfo->name, sDynListCurObj->type); } - // No null return due to `fatal_printf()` being a non-returning function? + return NULL; } /** @@ -1909,6 +1909,7 @@ void d_set_att_to_offset(UNUSED u32 a) { if (sDynListCurObj == NULL) { fatal_printf("proc_dynlist(): No current object"); + return; } dynobj = sDynListCurObj; @@ -1969,7 +1970,7 @@ void d_get_att_offset(struct GdVec3f *dst) { * Get the attached object flags for the current dynamic object. */ s32 d_get_att_flags(void) { - s32 attflag; // sp24 + s32 attflag = 0; // sp24 if (sDynListCurObj == NULL) { fatal_printf("proc_dynlist(): No current object"); @@ -2090,7 +2091,7 @@ struct GdVec3f *d_get_world_pos_ptr(void) { fatal_printf("%s: Object '%s'(%x) does not support this function.", "dGetWorldPosPtr()", sDynListCurInfo->name, sDynListCurObj->type); } - // No null return due to `fatal_printf()` being a non-returning function? + return NULL; } /** @@ -3005,7 +3006,7 @@ Mat4f *d_get_rot_mtx_ptr(void) { fatal_printf("%s: Object '%s'(%x) does not support this function.", "dGetRMatrixPtr()", sDynListCurInfo->name, sDynListCurObj->type); } - // No null return due to `fatal_printf()` being a non-returning function? + return NULL; } /** @@ -3062,7 +3063,7 @@ Mat4f *d_get_matrix_ptr(void) { fatal_printf("%s: Object '%s'(%x) does not support this function.", "dGetMatrixPtr()", sDynListCurInfo->name, sDynListCurObj->type); } - // No null return due to `fatal_printf()` being a non-returning function? + return NULL; } /** @@ -3087,7 +3088,7 @@ Mat4f *d_get_idn_mtx_ptr(void) { fatal_printf("%s: Object '%s'(%x) does not support this function.", "dGetIMatrixPtr()", sDynListCurInfo->name, sDynListCurObj->type); } - // No null return due to `fatal_printf()` being a non-returning function? + return NULL; } /** diff --git a/src/goddard/dynlist_proc.h b/src/goddard/dynlist_proc.h index 6e78ba8148..d0bdd68d86 100644 --- a/src/goddard/dynlist_proc.h +++ b/src/goddard/dynlist_proc.h @@ -64,7 +64,7 @@ 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 set_cur_dynobj(struct GdObj *); extern void d_start_group(DynId); extern void d_end_group(DynId); extern void dynid_is_int(s32); diff --git a/src/goddard/gd_main.c b/src/goddard/gd_main.c index a9f1a84bc7..5fdd0a56a5 100644 --- a/src/goddard/gd_main.c +++ b/src/goddard/gd_main.c @@ -13,11 +13,11 @@ // data s32 gGdMoveScene = TRUE; // @ 801A8050 -static s32 sUnref801A8054 = TRUE; +UNUSED static s32 sUnref801A8054 = TRUE; f32 D_801A8058 = -600.0f; s32 gGdUseVtxNormal = TRUE; // @ 801A805C; instead of face normals -static s32 sUnrefScnWidth = 320; -static s32 sUnrefScnHeight = 240; +UNUSED static s32 sUnrefScnWidth = 320; +UNUSED static s32 sUnrefScnHeight = 240; // bss struct GdControl gGdCtrl; // @ 801B9920; processed controller info diff --git a/src/goddard/joints.c b/src/goddard/joints.c index 55786a66a9..c85ae671b2 100644 --- a/src/goddard/joints.c +++ b/src/goddard/joints.c @@ -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]; diff --git a/src/goddard/old_menu.c b/src/goddard/old_menu.c index 27c1dac880..26a0b90828 100644 --- a/src/goddard/old_menu.c +++ b/src/goddard/old_menu.c @@ -23,7 +23,7 @@ // bss static char sMenuStrBuf[0x100]; static struct GdVec3f sStaticVec; -static struct GdVec3f unusedVec; +UNUSED static struct GdVec3f unusedVec; static struct ObjGadget *sCurGadgetPtr; // forward declarations diff --git a/src/goddard/particles.c b/src/goddard/particles.c index a54dfacc74..9e7f469f61 100644 --- a/src/goddard/particles.c +++ b/src/goddard/particles.c @@ -25,7 +25,7 @@ struct Connection { }; // data -static void *sUnused801A81D0 = NULL; +UNUSED static void *sUnused801A81D0 = NULL; static s32 D_801A81D4[25] = { /* ID? X Y Z */ 9, 3, 12, -14, 25, 5, 16, -25, 42, 4, 15, -39, 55, @@ -236,9 +236,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/renderer.c b/src/goddard/renderer.c index 4fa779863d..889e601d1d 100644 --- a/src/goddard/renderer.c +++ b/src/goddard/renderer.c @@ -98,7 +98,7 @@ u8 EUpad2[0x64]; static OSMesg sGdMesgBuf[1]; // @ 801BE944 u8 EUpad3[0x34]; static OSMesg D_801BE97C; // msg buf for D_801BE8B0 queue -static OSIoMesg D_801BE980; +UNUSED static OSIoMesg D_801BE980; static struct ObjView *D_801BE994; // store if View flag 0x40 set u8 EUpad4[0x88]; @@ -111,10 +111,10 @@ static u8 D_801BAEA0; static struct ObjGadget *sTimerGadgets[GD_NUM_TIMERS]; // @ 801BAEA8 static u32 D_801BAF28; // RAM addr offset? static s16 D_801BAF30[13][8]; // [[s16; 8]; 13]? vert indices? -static u32 unref_801bb000[3]; +UNUSED static u32 unref_801bb000[3]; static u8 *sMemBlockPoolBase; // @ 801BB00C static u32 sAllocMemory; // @ 801BB010; malloc-ed bytes -static u32 unref_801bb014; +UNUSED static u32 unref_801bb014; static s32 D_801BB018; static s32 D_801BB01C; static void *D_801BB020[0x10]; // texture pointers @@ -134,11 +134,11 @@ static s32 D_801BB0CC; // Vtx start in GD Dl static struct ObjView *sCarSceneView; // @ 801BB0D0 static s32 sUpdateYoshiScene; // @ 801BB0D4; update dl Vtx from ObjVertex? static s32 sUpdateMarioScene; // @ 801BB0D8; update dl Vtx from ObjVertex? -static u32 unref_801bb0dc; +UNUSED static u32 unref_801bb0dc; static s32 sUpdateCarScene; // @ 801BB0E0; guess, not really used -static u32 unref_801bb0e4; +UNUSED static u32 unref_801bb0e4; static struct GdVec3f D_801BB0E8; -static u32 unref_801bb0f8[2]; +UNUSED static u32 unref_801bb0f8[2]; static Mtx sIdnMtx; // @ 801BB100 static Mat4f sInitIdnMat4; // @ 801BB140 static s8 sVtxCvrtNormBuf[3]; // @ 801BB180 @@ -169,21 +169,21 @@ static LookAt D_801BE7D0[3]; #ifndef VERSION_EU static OSMesgQueue D_801BE830; // controller msg queue static OSMesg D_801BE848[10]; -static u32 unref_801be870[16]; +UNUSED static u32 unref_801be870[16]; static OSMesgQueue D_801BE8B0; static OSMesgQueue sGdDMAQueue; // @ 801BE8C8 -static u32 unref_801be8e0[25]; +UNUSED static u32 unref_801be8e0[25]; static OSMesg sGdMesgBuf[1]; // @ 801BE944 -static u32 unref_801be948[13]; +UNUSED static u32 unref_801be948[13]; static OSMesg D_801BE97C; // msg buf for D_801BE8B0 queue -static OSIoMesg D_801BE980; +UNUSED static OSIoMesg D_801BE980; static struct ObjView *D_801BE994; // store if View flag 0x40 set #endif // data -static u32 unref_801a8670 = 0; +UNUSED static u32 unref_801a8670 = 0; static s32 D_801A8674 = 0; -static u32 unref_801a8678 = 0; +UNUSED static u32 unref_801a8678 = 0; static s32 D_801A867C = 0; static s32 D_801A8680 = 0; static f32 sTracked1FrameTime = 0.0f; // @ 801A8684 @@ -198,11 +198,11 @@ static struct GdTimer *D_801A86A4 = NULL; // timer for dlgen, dynamics, or rcp static struct GdTimer *D_801A86A8 = NULL; // timer for dlgen, dynamics, or rcp static struct GdTimer *D_801A86AC = NULL; // timer for dlgen, dynamics, or rcp s32 gGdFrameBuf = 0; // @ 801A86B0 -static u32 unref_801a86B4 = 0; +UNUSED static u32 unref_801a86B4 = 0; static struct ObjShape *sHandShape = NULL; // @ 801A86B8 static s32 D_801A86BC = 1; static s32 D_801A86C0 = 0; // gd_dl id for something? -static u32 unref_801a86C4 = 10; +UNUSED static u32 unref_801a86C4 = 10; static s32 sMtxParamType = G_MTX_PROJECTION; static struct GdVec3f D_801A86CC = { 1.0f, 1.0f, 1.0f }; static struct ObjView *sActiveView = NULL; // @ 801A86D8 current view? used when drawing dl @@ -213,10 +213,10 @@ static struct ObjView *sMenuView = NULL; // @ 801A86E8 static u32 sItemsInMenu = 0; // @ 801A86EC static s32 D_801A86F0 = 0; // frame buffer idx into D_801BD7A0? static s32 sNewZPresses = 0; // @ 801A86F4; timing activate cool down counter? -static u32 unref_801a86F8 = 0; +UNUSED static u32 unref_801a86F8 = 0; static struct GdDisplayList *sCurrentGdDl = NULL; // @ 801A86FC static u32 sGdDlCount = 0; // @ 801A8700 -static struct DynListBankInfo sDynLists[] = { // @ 801A8704 +UNUSED static struct DynListBankInfo sDynLists[] = { // @ 801A8704 { STD_LIST_BANK, dynlist_test_cube }, { STD_LIST_BANK, dynlist_unused }, { STD_LIST_BANK, dynlist_mario_master }, @@ -224,7 +224,7 @@ static struct DynListBankInfo sDynLists[] = { // @ 801A8704 }; // textures and display list data -static Gfx gd_texture1_dummy_aligner1[] = { // @ 801A8728 +UNUSED static Gfx gd_texture1_dummy_aligner1[] = { // @ 801A8728 gsSPEndDisplayList(), }; @@ -232,7 +232,7 @@ ALIGNED8 static u8 gd_texture_hand_open[] = { #include "textures/intro_raw/hand_open.rgba16.inc.c" }; -static Gfx gd_texture2_dummy_aligner1[] = { +UNUSED static Gfx gd_texture2_dummy_aligner1[] = { gsSPEndDisplayList() }; @@ -493,7 +493,10 @@ ALIGNED8 static u8 gd_texture_sparkle_4[] = { //! No reference to this texture. Two DL's uses the same previous texture // instead of using this texture. -// Fixed via setting TEXTURE_FIX to 1. +// Fixed via setting QOL_FIXES to 1. +#ifndef QOL_FIXES +UNUSED +#endif ALIGNED8 static u8 gd_texture_sparkle_5[] = { #include "textures/intro_raw/sparkle_5.rgba16.inc.c" }; @@ -570,8 +573,8 @@ static Gfx gd_dl_red_sparkle_4[] = { gsSPBranchList(gd_dl_sparkle), }; -#ifndef TEXTURE_FIX -static Gfx gd_dl_red_sparkle_4_dup[] ={ +#ifndef QOL_FIXES +static Gfx gd_dl_red_sparkle_4_dup[] = { gsDPPipeSync(), gsSPDisplayList(gd_dl_sparkle_red_color), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gd_texture_sparkle_4), // 4 again, correct texture would be 5 @@ -579,7 +582,7 @@ static Gfx gd_dl_red_sparkle_4_dup[] ={ }; #else -static Gfx gd_dl_red_sparkle_5[] ={ +static Gfx gd_dl_red_sparkle_5[] = { gsDPPipeSync(), gsSPDisplayList(gd_dl_sparkle_red_color), gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gd_texture_sparkle_5), @@ -622,7 +625,7 @@ static Gfx gd_dl_silver_sparkle_4[] = { gsSPBranchList(gd_dl_sparkle), }; -#ifndef TEXTURE_FIX +#ifndef QOL_FIXES static Gfx gd_dl_silver_sparkle_4_dup[] = { gsDPPipeSync(), gsSPDisplayList(gd_dl_sparkle_white_color), @@ -650,7 +653,7 @@ static Gfx *gd_red_sparkle_dl_array[] = { gd_dl_red_sparkle_1, gd_dl_red_sparkle_0, gd_dl_red_sparkle_0, -#ifndef TEXTURE_FIX +#ifndef QOL_FIXES gd_dl_red_sparkle_4_dup, gd_dl_red_sparkle_4_dup, #else @@ -670,7 +673,7 @@ static Gfx *gd_silver_sparkle_dl_array[] = { gd_dl_silver_sparkle_1, gd_dl_silver_sparkle_0, gd_dl_silver_sparkle_0, -#ifndef TEXTURE_FIX +#ifndef QOL_FIXES gd_dl_silver_sparkle_4_dup, gd_dl_silver_sparkle_4_dup, #else @@ -679,7 +682,7 @@ static Gfx *gd_silver_sparkle_dl_array[] = { #endif }; -static Gfx gd_texture3_dummy_aligner1[] = { +UNUSED static Gfx gd_texture3_dummy_aligner1[] = { gsSPEndDisplayList(), }; @@ -724,13 +727,13 @@ static Gfx gd_dl_rdp_init[] = { gsSPEndDisplayList(), }; -static u32 gd_unused_pad1 = 0; +UNUSED static u32 gd_unused_pad1 = 0; float sGdPerspTimer = 1.0; -static u32 gd_unused_pad2 = 0; +UNUSED static u32 gd_unused_pad2 = 0; -static Gfx gd_texture4_dummy_aligner1[] = { +UNUSED static Gfx gd_texture4_dummy_aligner1[] = { gsDPPipeSync(), gsSPEndDisplayList(), }; @@ -747,7 +750,7 @@ static Vtx_t gd_unused_mesh_vertex_group2[] = { {{ 3, -7, 0}, 0, { 0, 0}, { 0xFF, 0x00, 0x00, 0xFF}}, }; -static Gfx gd_dl_unused_mesh[] = { +UNUSED static Gfx gd_dl_unused_mesh[] = { gsDPPipeSync(), gsDPSetRenderMode(G_RM_OPA_SURF, G_RM_OPA_SURF2), gsSPClearGeometryMode(0xFFFFFFFF), @@ -1718,7 +1721,7 @@ 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); + guMtxF2L(*(Mat4f *)src, dst); } @@ -2784,7 +2787,7 @@ void Proc801A43DC(UNUSED struct GdObj *obj) { /* 252BC0 -> 252BE0 */ void *func_801A43F0(UNUSED const char *menufmt, ...) { - //! @bug no return; function was stubbed + return 0; } /* 252BE0 -> 252BF0 */ diff --git a/src/goddard/shape_helper.c b/src/goddard/shape_helper.c index 90b14d3515..9a0b35314d 100644 --- a/src/goddard/shape_helper.c +++ b/src/goddard/shape_helper.c @@ -66,10 +66,10 @@ static struct UnkData sUnref801A835C = { { { 1, 4, &sUnref801A835C }; -static s32 sUnref801A838C[6] = { 0 }; +UNUSED static s32 sUnref801A838C[6] = { 0 }; struct ObjShape *D_801A83A4 = NULL; -static s32 sUnref801A83A8[31] = { 0 }; -static struct DynList sSimpleDylist[8] = { +UNUSED static s32 sUnref801A83A8[31] = { 0 }; +UNUSED static struct DynList sSimpleDylist[8] = { StartList(), StartGroup("simpleg"), MakeDynObj(D_NET, "simple"), @@ -84,17 +84,17 @@ static struct DynList sDynlist801A84E4[3] = { SetFlag(0x1800), StopList(), }; -static struct DynList sDynlist801A85B3[5] = { +UNUSED static struct DynList sDynlist801A85B3[5] = { StartList(), JumpToList(sDynlist801A84E4), SetFlag(0x400), SetFriction(0.04, 0.01, 0.01), StopList(), }; -static struct DynList sDynlist801A85A4[4] = { +UNUSED static struct DynList sDynlist801A85A4[4] = { StartList(), JumpToList(sDynlist801A84E4), SetFriction(0.04, 0.01, 0.01), StopList(), }; -static struct DynList sDynlist801A8604[4] = { +UNUSED static struct DynList sDynlist801A8604[4] = { StartList(), JumpToList(sDynlist801A84E4), SetFriction(0.005, 0.005, 0.005), @@ -103,35 +103,35 @@ static struct DynList sDynlist801A8604[4] = { static f64 D_801A8668 = 0.0; // bss -static u8 sUnrefSpaceB00[0x2C]; // @ 801BAB00 +UNUSED static u8 sUnrefSpaceB00[0x2C]; // @ 801BAB00 static struct ObjGroup *sCubeShapeGroup; // @ 801BAB2C -static u8 sUnrefSpaceB30[0xC]; // @ 801BAB30 +UNUSED static u8 sUnrefSpaceB30[0xC]; // @ 801BAB30 static struct ObjShape *sCubeShape; // @ 801BAB3C -static u8 sUnrefSpaceB40[0x8]; // @ 801BAB40 +UNUSED static u8 sUnrefSpaceB40[0x8]; // @ 801BAB40 static char sGdLineBuf[0x100]; // @ 801BAB48 static s32 sGdLineBufCsr; // @ 801BAC48 static struct GdFile *sGdShapeFile; // @ 801BAC4C static struct ObjShape *sGdShapeListHead; // @ 801BAC50 static u32 sGdShapeCount; // @ 801BAC54 -static u8 sUnrefSpaceC58[0x8]; // @ 801BAC58 +UNUSED static u8 sUnrefSpaceC58[0x8]; // @ 801BAC58 static struct GdVec3f D_801BAC60; -static u32 sUnrefSpaceC6C; // @ 801BAC6C -static u32 sUnrefSpaceC70; // @ 801BAC70 +UNUSED static u32 sUnrefSpaceC6C; // @ 801BAC6C +UNUSED static u32 sUnrefSpaceC70; // @ 801BAC70 static struct ObjPlane *D_801BAC74; static struct ObjPlane *D_801BAC78; // sShapeNetHead? -static u8 sUnrefSpaceC80[0x1C]; // @ 801BAC80 +UNUSED static u8 sUnrefSpaceC80[0x1C]; // @ 801BAC80 static struct ObjFace *D_801BAC9C; static struct ObjFace *D_801BACA0; -static u8 sUnrefSpaceCA8[0x10]; // @ 801BACA8 +UNUSED static u8 sUnrefSpaceCA8[0x10]; // @ 801BACA8 /// factor for scaling vertices in an `ObjShape` when calling `scale_verts_in_shape()` static struct GdVec3f sVertexScaleFactor; /// factor for translating vertices in an `ObjShape` when calling `translate_verts_in_shape()` static struct GdVec3f sVertexTranslateOffset; -static u8 sUnrefSpaceCD8[0x30]; // @ 801BACD8 +UNUSED static u8 sUnrefSpaceCD8[0x30]; // @ 801BACD8 static struct ObjGroup *D_801BAD08; // group of planes from make_netfromshape -static u8 sUnrefSpaceD10[0x20]; // @ 801BAD10 +UNUSED static u8 sUnrefSpaceD10[0x20]; // @ 801BAD10 static struct GdVec3f D_801BAD30; // printed with "c=" -static u8 sUnrefSpaceD40[0x120]; // @ 801BAD40 +UNUSED static u8 sUnrefSpaceD40[0x120]; // @ 801BAD40 // Forward Declarations struct ObjMaterial *find_or_add_new_mtl(struct ObjGroup *, s32, f32, f32, f32); @@ -886,7 +886,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); diff --git a/src/menu/file_select.c b/src/menu/file_select.c index 3637d7d963..8e164ecda4 100644 --- a/src/menu/file_select.c +++ b/src/menu/file_select.c @@ -38,7 +38,10 @@ // the large length difference between options. // sSoundTextY unused (EU supports its existence). static s16 sSoundTextX; -static s16 sSoundTextY; +UNUSED static s16 sSoundTextY; +#elif VERSION_EU +UNUSED static s16 sSoundTextX; +UNUSED static s16 sSoundTextY; #endif //! @Bug (UB Array Access) For PAL, more buttons were added than the array was extended. @@ -62,8 +65,8 @@ static struct Object *sMainMenuButtons[NUM_BUTTONS]; // The current sound mode is automatically centered on US due to // the large length difference between options. // sSoundTextY is unused -static s16 sSoundTextX; -static s16 sSoundTextY; +UNUSED static s16 sSoundTextX; +UNUSED static s16 sSoundTextY; #endif // Used to defined yes/no fade colors after a file is selected in the erase menu. diff --git a/src/menu/level_select_menu.c b/src/menu/level_select_menu.c index b9505df91d..9594f78c43 100644 --- a/src/menu/level_select_menu.c +++ b/src/menu/level_select_menu.c @@ -69,7 +69,7 @@ int run_press_start_demo_timer(s32 timer) { return timer; } -extern int gDemoInputListID_2; +extern unsigned int gDemoInputListID_2; extern int gPressedStart; int start_demo(int timer) diff --git a/src/pc/README-n64-fast32-engine.md b/src/pc/README-n64-fast3d-engine.m similarity index 92% rename from src/pc/README-n64-fast32-engine.md rename to src/pc/README-n64-fast3d-engine.m index 4aa387d498..dc54ca6b85 100644 --- a/src/pc/README-n64-fast32-engine.md +++ b/src/pc/README-n64-fast3d-engine.m @@ -1,10 +1,10 @@ # About n64-fast32-engine -sm64pc supports OpenGL through [n64-fast32-engine](https://github.com/Emill/n64-fast3d-engine/), by [Emill](https://github.com/Emill/). +sm64pc supports OpenGL through [n64-fast3d-engine](https://github.com/Emill/n64-fast3d-engine/), by [Emill](https://github.com/Emill/). We recommend that you visit the repo if you wish for a better understanding on how this port was possible. -n64-fast32-engine is licensed under +n64-fast3d-engine is licensed under ``` Copyright (c) 2020, Emill diff --git a/src/pc/audio/audio_null.c b/src/pc/audio/audio_null.c index 4d0dd92347..e54e0f033e 100644 --- a/src/pc/audio/audio_null.c +++ b/src/pc/audio/audio_null.c @@ -1,4 +1,5 @@ #include "audio_api.h" +#include "macros.h" static bool audio_null_init(void) { return true; @@ -12,7 +13,7 @@ static int audio_null_get_desired_buffered(void) { return 0; } -static void audio_null_play(const uint8_t *buf, size_t len) { +static void audio_null_play(UNUSED const uint8_t *buf, UNUSED size_t len) { } static void audio_null_shutdown(void) { diff --git a/src/pc/cliopts.h b/src/pc/cliopts.h index 2d084eda8a..3fe548d684 100644 --- a/src/pc/cliopts.h +++ b/src/pc/cliopts.h @@ -1,5 +1,6 @@ #ifndef _CLIOPTS_H #define _CLIOPTS_H +#include "platform.h" #include "platform.h" diff --git a/src/pc/controller/controller_entry_point.c b/src/pc/controller/controller_entry_point.c index 90c10c1d5a..fd7237b78f 100644 --- a/src/pc/controller/controller_entry_point.c +++ b/src/pc/controller/controller_entry_point.c @@ -20,7 +20,7 @@ static struct ControllerAPI *controller_implementations[] = { &controller_keyboard, }; -s32 osContInit(OSMesgQueue *mq, u8 *controllerBits, OSContStatus *status) { +s32 osContInit(UNUSED OSMesgQueue *mq, u8 *controllerBits, UNUSED OSContStatus *status) { for (size_t i = 0; i < sizeof(controller_implementations) / sizeof(struct ControllerAPI *); i++) { controller_implementations[i]->init(); } @@ -28,7 +28,7 @@ s32 osContInit(OSMesgQueue *mq, u8 *controllerBits, OSContStatus *status) { return 0; } -s32 osContStartReadData(OSMesgQueue *mesg) { +s32 osContStartReadData(UNUSED OSMesgQueue *mesg) { return 0; } diff --git a/src/pc/controller/controller_sdl.c b/src/pc/controller/controller_sdl.c index cbdd6178f8..654d2c7b8b 100644 --- a/src/pc/controller/controller_sdl.c +++ b/src/pc/controller/controller_sdl.c @@ -42,7 +42,7 @@ static u32 joy_binds[MAX_JOYBINDS][2]; static u32 mouse_binds[MAX_JOYBINDS][2]; static bool joy_buttons[SDL_CONTROLLER_BUTTON_MAX ] = { false }; -static u32 mouse_buttons = 0; +UNUSED static u32 mouse_buttons = 0; static u32 last_mouse = VK_INVALID; static u32 last_joybutton = VK_INVALID; diff --git a/src/pc/gfx/gfx_opengl.c b/src/pc/gfx/gfx_opengl.c index 7909d341e3..a8cba73769 100644 --- a/src/pc/gfx/gfx_opengl.c +++ b/src/pc/gfx/gfx_opengl.c @@ -129,6 +129,7 @@ static const char *shader_item_to_str(uint32_t item, bool with_alpha, bool only_ return "texVal1.a"; } } + return 0; } static void append_formula(char *buf, size_t *len, uint8_t c[2][4], bool do_single, bool do_multiply, bool do_mix, bool with_alpha, bool only_alpha, bool opt_alpha) { diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index 5abe91e3e1..d96bfae90b 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -4,6 +4,12 @@ #include #include #include +#include "macros.h" + +#ifdef EXTERNAL_TEXTURES +#define STB_IMAGE_IMPLEMENTATION +#include +#endif #ifdef EXTERNAL_TEXTURES #define STB_IMAGE_IMPLEMENTATION @@ -200,12 +206,12 @@ static unsigned long get_time(void) { static void gfx_flush(void) { if (buf_vbo_len > 0) { - int num = buf_vbo_num_tris; - unsigned long t0 = get_time(); + UNUSED int num = buf_vbo_num_tris; + UNUSED unsigned long t0 = get_time(); gfx_rapi->draw_triangles(buf_vbo, buf_vbo_len, buf_vbo_num_tris); buf_vbo_len = 0; buf_vbo_num_tris = 0; - unsigned long t1 = get_time(); + UNUSED unsigned long t1 = get_time(); /*if (t1 - t0 > 1000) { printf("f: %d %d\n", num, (int)(t1 - t0)); }*/ @@ -290,7 +296,7 @@ static bool gfx_texture_cache_lookup(int tile, struct TextureHashmapNode **n, co size_t hash = (uintptr_t)orig_addr; hash = (hash >> 5) & 0x3ff; struct TextureHashmapNode **node = &gfx_texture_cache.hashmap[hash]; - while (*node != NULL && *node - gfx_texture_cache.pool < gfx_texture_cache.pool_pos) { + while (*node != NULL && *node - gfx_texture_cache.pool < (long)gfx_texture_cache.pool_pos) { if ((*node)->texture_addr == orig_addr && (*node)->fmt == fmt && (*node)->siz == siz) { gfx_rapi->select_texture(tile, (*node)->texture_id); *n = *node; @@ -325,8 +331,9 @@ static bool gfx_texture_cache_lookup(int tile, struct TextureHashmapNode **n, co static void import_texture_rgba32(int tile) { uint32_t width = rdp.texture_tile.line_size_bytes / 2; uint32_t height = (rdp.loaded_texture[tile].size_bytes / 2) / rdp.texture_tile.line_size_bytes; - gfx_rapi->upload_texture(rdp.loaded_texture[tile].addr, width, height); + gfx_rapi->upload_texture((uint8_t *)rdp.loaded_texture[tile].addr, width, height); } +#endif // EXTERNAL_TEXTURES static void import_texture_rgba16(int tile) { uint8_t rgba32_buf[8192]; @@ -493,7 +500,6 @@ static void import_texture_ci8(int tile) { gfx_rapi->upload_texture(rgba32_buf, width, height); } -#endif // EXTERNAL_TEXTURES static void import_texture(int tile) { uint8_t fmt = rdp.texture_tile.fmt; @@ -519,7 +525,7 @@ static void import_texture(int tile) { stbi_image_free(data); // don't need this anymore #else // the texture data is actual texture data - int t0 = get_time(); + UNUSED int t0 = get_time(); if (fmt == G_IM_FMT_RGBA) { if (siz == G_IM_SIZ_32b) { import_texture_rgba32(tile); @@ -558,7 +564,7 @@ static void import_texture(int tile) { } else { abort(); } - int t1 = get_time(); + UNUSED int t1 = get_time(); //printf("Time diff: %d\n", t1 - t0); #endif } @@ -1039,7 +1045,7 @@ static void gfx_sp_movemem(uint8_t index, uint8_t offset, const void* data) { } } -static void gfx_sp_moveword(uint8_t index, uint16_t offset, uint32_t data) { +static void gfx_sp_moveword(uint8_t index, UNUSED uint16_t offset, uint32_t data) { switch (index) { case G_MW_NUMLIGHT: #ifdef F3DEX_GBI_2 @@ -1058,12 +1064,12 @@ static void gfx_sp_moveword(uint8_t index, uint16_t offset, uint32_t data) { } } -static void gfx_sp_texture(uint16_t sc, uint16_t tc, uint8_t level, uint8_t tile, uint8_t on) { +static void gfx_sp_texture(uint16_t sc, uint16_t tc, UNUSED uint8_t level, UNUSED uint8_t tile, UNUSED uint8_t on) { rsp.texture_scaling_factor.s = sc; rsp.texture_scaling_factor.t = tc; } -static void gfx_dp_set_scissor(uint32_t mode, uint32_t ulx, uint32_t uly, uint32_t lrx, uint32_t lry) { +static void gfx_dp_set_scissor(UNUSED uint32_t mode, uint32_t ulx, uint32_t uly, uint32_t lrx, uint32_t lry) { float x = ulx / 4.0f * RATIO_X; float y = (SCREEN_HEIGHT - lry / 4.0f) * RATIO_Y; float width = (lrx - ulx) / 4.0f * RATIO_X; @@ -1077,12 +1083,12 @@ static void gfx_dp_set_scissor(uint32_t mode, uint32_t ulx, uint32_t uly, uint32 rdp.viewport_or_scissor_changed = true; } -static void gfx_dp_set_texture_image(uint32_t format, uint32_t size, uint32_t width, const void* addr) { +static void gfx_dp_set_texture_image(UNUSED uint32_t format, uint32_t size, UNUSED uint32_t width, const void* addr) { rdp.texture_to_load.addr = addr; rdp.texture_to_load.siz = size; } -static void gfx_dp_set_tile(uint8_t fmt, uint32_t siz, uint32_t line, uint32_t tmem, uint8_t tile, uint32_t palette, uint32_t cmt, uint32_t maskt, uint32_t shiftt, uint32_t cms, uint32_t masks, uint32_t shifts) { +static void gfx_dp_set_tile(uint8_t fmt, uint32_t siz, uint32_t line, uint32_t tmem, uint8_t tile, uint32_t palette, uint32_t cmt, UNUSED uint32_t maskt, UNUSED uint32_t shiftt, uint32_t cms, UNUSED uint32_t masks, UNUSED uint32_t shifts) { if (tile == G_TX_RENDERTILE) { SUPPORT_CHECK(palette == 0); // palette should set upper 4 bits of color index in 4b mode @@ -1111,13 +1117,13 @@ static void gfx_dp_set_tile_size(uint8_t tile, uint16_t uls, uint16_t ult, uint1 } } -static void gfx_dp_load_tlut(uint8_t tile, uint32_t high_index) { +static void gfx_dp_load_tlut(uint8_t tile, UNUSED uint32_t high_index) { SUPPORT_CHECK(tile == G_TX_LOADTILE); SUPPORT_CHECK(rdp.texture_to_load.siz == G_IM_SIZ_16b); rdp.palette = rdp.texture_to_load.addr; } -static void gfx_dp_load_block(uint8_t tile, uint32_t uls, uint32_t ult, uint32_t lrs, uint32_t dxt) { +static void gfx_dp_load_block(uint8_t tile, uint32_t uls, uint32_t ult, uint32_t lrs, UNUSED uint32_t dxt) { if (tile == 1) return; SUPPORT_CHECK(tile == G_TX_LOADTILE); SUPPORT_CHECK(uls == 0); @@ -1313,7 +1319,7 @@ static void gfx_draw_rectangle(int32_t ulx, int32_t uly, int32_t lrx, int32_t lr } } -static void gfx_dp_texture_rectangle(int32_t ulx, int32_t uly, int32_t lrx, int32_t lry, uint8_t tile, int16_t uls, int16_t ult, int16_t dsdx, int16_t dtdy, bool flip) { +static void gfx_dp_texture_rectangle(int32_t ulx, int32_t uly, int32_t lrx, int32_t lry, UNUSED uint8_t tile, int16_t uls, int16_t ult, int16_t dsdx, int16_t dtdy, bool flip) { uint32_t saved_combine_mode = rdp.combine_mode; if ((rdp.other_mode_h & (3U << G_MDSFT_CYCLETYPE)) == G_CYC_COPY) { // Per RDP Command Summary Set Tile's shift s and this dsdx should be set to 4 texels @@ -1393,7 +1399,7 @@ static void gfx_dp_set_z_image(void *z_buf_address) { rdp.z_buf_address = z_buf_address; } -static void gfx_dp_set_color_image(uint32_t format, uint32_t size, uint32_t width, void* address) { +static void gfx_dp_set_color_image(UNUSED uint32_t format, UNUSED uint32_t size, UNUSED uint32_t width, void* address) { rdp.color_image_address = address; } @@ -1413,7 +1419,7 @@ static inline void *seg_addr(uintptr_t w1) { #define C1(pos, width) ((cmd->words.w1 >> (pos)) & ((1U << width) - 1)) static void gfx_run_dl(Gfx* cmd) { - int dummy = 0; + UNUSED int dummy = 0; for (;;) { uint32_t opcode = cmd->words.w0 >> 24; @@ -1559,7 +1565,7 @@ static void gfx_run_dl(Gfx* cmd) { case G_TEXRECT: case G_TEXRECTFLIP: { - int32_t lrx, lry, tile, ulx, uly; + int32_t lrx, lry, tile = 0, ulx, uly; uint32_t uls, ult, dsdx, dtdy; #ifdef F3DEX_GBI_2E lrx = (int32_t)(C0(0, 24) << 8) >> 8; @@ -1686,11 +1692,11 @@ void gfx_run(Gfx *commands) { } dropped_frame = false; - double t0 = gfx_wapi->get_time(); + UNUSED double t0 = gfx_wapi->get_time(); gfx_rapi->start_frame(); gfx_run_dl(commands); gfx_flush(); - double t1 = gfx_wapi->get_time(); + UNUSED double t1 = gfx_wapi->get_time(); //printf("Process %f %f\n", t1, t1 - t0); gfx_wapi->swap_buffers_begin(); } diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index 58ef09af43..95e5bb813f 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -157,15 +157,16 @@ static void gfx_sdl_init(void) { configWindow.fullscreen = false; char window_title[96] = + "Super Mario 64 PC Port " #ifndef USE_GLES - "Super Mario 64 PC port (OpenGL)"; + "(OpenGL)" #else - "Super Mario 64 PC port (OpenGL_ES2)"; + "(OpenGL_ES2)" #endif - #ifdef NIGHTLY - strcat(window_title, " nightly " GIT_HASH); + " nightly " GIT_HASH #endif + ; // end the window title string wnd = SDL_CreateWindow( window_title, @@ -204,9 +205,12 @@ static void gfx_sdl_main_loop(void (*run_one_game_iter)(void)) { } static void gfx_sdl_get_dimensions(uint32_t *width, uint32_t *height) { - SDL_GetWindowSize(wnd, width, height); + int w, h; + SDL_GetWindowSize(wnd, &w, &h); + *width = w; *height = h; } +#ifndef TARGET_WEB static int translate_scancode(int scancode) { if (scancode < 512) { return inverted_scancode_table[scancode]; @@ -229,6 +233,7 @@ static void gfx_sdl_onkeydown(int scancode) { static void gfx_sdl_onkeyup(int scancode) { keyboard_on_key_up(translate_scancode(scancode)); } +#endif static void gfx_sdl_handle_events(void) { SDL_Event event; diff --git a/src/pc/mixer.c b/src/pc/mixer.c index 82103b2b6d..a21ffcf076 100644 --- a/src/pc/mixer.c +++ b/src/pc/mixer.c @@ -1,6 +1,8 @@ #include #include #include +#include +#include "macros.h" // Note: Some of this is stolen from Mupen64Plus rsp audio plugin. // See abi.h for documentation. @@ -146,14 +148,14 @@ static inline int16_t sample_mix(int16_t dst, int16_t src, int16_t gain) { return clamp_s16(dst + src_modified); } -void aClearBuffer(uint64_t *cmd, uint16_t dmem, uint16_t count) { +void aClearBuffer(UNUSED u64 *cmd, uint16_t dmem, uint16_t count) { dmem += DMEM_BASE; //assert(align(count, 16) == count); count = align(count, 16); memset(alist_buffer + dmem, 0, count); } -void aSetBuffer(uint64_t *cmd, uint8_t flags, uint16_t dmemin, uint16_t dmemout, uint16_t count) { +void aSetBuffer(UNUSED u64 *cmd, uint8_t flags, uint16_t dmemin, uint16_t dmemout, uint16_t count) { if (flags & A_AUX) { // Parameter names are not really correct for A_AUX alist_audio.dry_right = dmemin + DMEM_BASE; @@ -166,16 +168,16 @@ void aSetBuffer(uint64_t *cmd, uint8_t flags, uint16_t dmemin, uint16_t dmemout, } } -void aLoadBuffer(uint64_t *cmd, uint16_t *addr) { +void aLoadBuffer(UNUSED u64 *cmd, uint16_t *addr) { // addr &= ~7 memcpy(alist_buffer + alist_audio.in, addr, alist_audio.count); } -void aSaveBuffer(uint64_t *cmd, uint16_t *addr) { +void aSaveBuffer(UNUSED u64 *cmd, uint16_t *addr) { memcpy(addr, alist_buffer + alist_audio.out, alist_audio.count); } -void aDMEMMove(uint64_t *cmd, uint16_t dmemin, uint16_t dmemout, uint16_t count) { +void aDMEMMove(UNUSED u64 *cmd, uint16_t dmemin, uint16_t dmemout, uint16_t count) { dmemin += DMEM_BASE; dmemout += DMEM_BASE; //assert(align(count, 16) == count); @@ -183,7 +185,7 @@ void aDMEMMove(uint64_t *cmd, uint16_t dmemin, uint16_t dmemout, uint16_t count) memmove(alist_buffer + dmemout, alist_buffer + dmemin, count); } -void aMix(uint64_t *cmd, uint8_t flags, uint16_t gain, uint16_t dmemin, uint16_t dmemout) { +void aMix(UNUSED u64 *cmd, UNUSED uint8_t flags, uint16_t gain, uint16_t dmemin, uint16_t dmemout) { dmemin += DMEM_BASE; dmemout += DMEM_BASE; @@ -220,7 +222,7 @@ static inline int16_t ramp_step(struct ramp_t* ramp) { return (int16_t)(ramp->value >> 16); } -void aEnvMixer(uint64_t *cmd, uint8_t flags, uint16_t *addr) { +void aEnvMixer(UNUSED u64 *cmd, uint8_t flags, uint16_t *addr) { size_t n = (flags & A_AUX) ? 4 : 2; const int16_t *const in = (int16_t*)(alist_buffer + alist_audio.in); @@ -309,7 +311,7 @@ void aEnvMixer(uint64_t *cmd, uint8_t flags, uint16_t *addr) { s->ramp_values[1] = ramps[1].value; } -void aResample(uint64_t *cmd, uint8_t flags, uint16_t pitch, uint16_t *state_addr) { +void aResample(UNUSED u64 *cmd, uint8_t flags, uint16_t pitch, uint16_t *state_addr) { int16_t *dst = (int16_t*)(alist_buffer + alist_audio.out); int16_t *src = (int16_t*)(alist_buffer + alist_audio.in); size_t count = alist_audio.count >> 1; @@ -340,7 +342,7 @@ void aResample(uint64_t *cmd, uint8_t flags, uint16_t pitch, uint16_t *state_add state_addr[4] = pitch_accumulator; } -void aInterleave(uint64_t *cmd, uint16_t inL, uint16_t inR) { +void aInterleave(UNUSED u64 *cmd, uint16_t inL, uint16_t inR) { inL += DMEM_BASE; inR += DMEM_BASE; @@ -369,7 +371,7 @@ void aInterleave(uint64_t *cmd, uint16_t inL, uint16_t inR) { } // These two share the same opcode but parameters and what they do are different depending on flags -void aSetVolume(uint64_t *cmd, uint8_t flags, uint16_t vol, uint16_t voltgt, uint16_t volrate) { +void aSetVolume(UNUSED u64 *cmd, uint8_t flags, uint16_t vol, UNUSED uint16_t voltgt, uint16_t volrate) { if (flags & A_AUX) { // Parameter names are not really correct for A_AUX alist_audio.dry = vol; @@ -381,7 +383,7 @@ void aSetVolume(uint64_t *cmd, uint8_t flags, uint16_t vol, uint16_t voltgt, uin alist_audio.vol[lr] = vol; } } -void aSetVolume32(uint64_t *cmd, uint8_t flags, uint16_t voltgt, uint32_t volrate) { +void aSetVolume32(UNUSED u64 *cmd, uint8_t flags, uint16_t voltgt, uint32_t volrate) { size_t lr = (flags & A_LEFT) ? 0 : 1; assert(!(flags & A_VOL) && !(flags & A_AUX)); @@ -389,11 +391,11 @@ void aSetVolume32(uint64_t *cmd, uint8_t flags, uint16_t voltgt, uint32_t volrat alist_audio.rate[lr] = volrate; } -void aSetLoop(uint64_t *cmd, uint16_t *addr) { +void aSetLoop(UNUSED u64 *cmd, uint16_t *addr) { alist_audio.loop = addr; } -void aLoadADPCM(uint64_t *cmd, uint16_t count, uint16_t *addr) { +void aLoadADPCM(UNUSED u64 *cmd, uint16_t count, uint16_t *addr) { assert(align(count, 8) == count); memcpy(alist_audio.table, addr, count); } @@ -451,7 +453,7 @@ static void adpcm_compute_residuals(int16_t* dst, const int16_t* src, } } -void aADPCMdec(uint64_t *cmd, uint8_t flags, uint16_t *last_frame_addr) { +void aADPCMdec(UNUSED u64 *cmd, uint8_t flags, uint16_t *last_frame_addr) { int16_t *dst = (int16_t*)(alist_buffer + alist_audio.out); uint8_t *src = alist_buffer + alist_audio.in; size_t count = alist_audio.count; diff --git a/src/pc/mixer.h b/src/pc/mixer.h index 5fc3346345..3b0de2bf24 100644 --- a/src/pc/mixer.h +++ b/src/pc/mixer.h @@ -20,20 +20,20 @@ #undef aADPCMdec #define aSegment(pkt, s, b) -void aClearBuffer(uint64_t *cmd, uint16_t dmem, uint16_t count); -void aSetBuffer(uint64_t *cmd, uint8_t flags, uint16_t dmemin, uint16_t dmemout, uint16_t count); -void aLoadBuffer(uint64_t *cmd, uint16_t *addr); -void aSaveBuffer(uint64_t *cmd, uint16_t *addr); -void aDMEMMove(uint64_t *cmd, uint16_t dmemin, uint16_t dmemout, uint16_t count); -void aMix(uint64_t *cmd, uint8_t flags, uint16_t gain, uint16_t dmemin, uint16_t dmemout); -void aEnvMixer(uint64_t *cmd, uint8_t flags, uint16_t *addr); -void aResample(uint64_t *cmd, uint8_t flags, uint16_t pitch, uint16_t *state_addr); -void aInterleave(uint64_t *cmd, uint16_t inL, uint16_t inR); -void aSetVolume(uint64_t *cmd, uint8_t flags, uint16_t vol, uint16_t voltgt, uint16_t volrate); -void aSetVolume32(uint64_t *cmd, uint8_t flags, uint16_t voltgt, uint32_t volrate); -void aSetLoop(uint64_t *cmd, uint16_t *addr); -void aLoadADPCM(uint64_t *cmd, uint16_t count, uint16_t *addr); -void aADPCMdec(uint64_t *cmd, uint8_t flags, uint16_t *last_frame_addr); +void aClearBuffer(UNUSED u64 *cmd, uint16_t dmem, uint16_t count); +void aSetBuffer(UNUSED u64 *cmd, uint8_t flags, uint16_t dmemin, uint16_t dmemout, uint16_t count); +void aLoadBuffer(UNUSED u64 *cmd, uint16_t *addr); +void aSaveBuffer(UNUSED u64 *cmd, uint16_t *addr); +void aDMEMMove(UNUSED u64 *cmd, uint16_t dmemin, uint16_t dmemout, uint16_t count); +void aMix(UNUSED u64 *cmd, uint8_t flags, uint16_t gain, uint16_t dmemin, uint16_t dmemout); +void aEnvMixer(UNUSED u64 *cmd, uint8_t flags, uint16_t *addr); +void aResample(UNUSED u64 *cmd, uint8_t flags, uint16_t pitch, uint16_t *state_addr); +void aInterleave(UNUSED u64 *cmd, uint16_t inL, uint16_t inR); +void aSetVolume(UNUSED u64 *cmd, uint8_t flags, uint16_t vol, uint16_t voltgt, uint16_t volrate); +void aSetVolume32(UNUSED u64 *cmd, uint8_t flags, uint16_t voltgt, uint32_t volrate); +void aSetLoop(UNUSED u64 *cmd, uint16_t *addr); +void aLoadADPCM(UNUSED u64 *cmd, uint16_t count, uint16_t *addr); +void aADPCMdec(UNUSED u64 *cmd, uint8_t flags, uint16_t *last_frame_addr); #endif diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index ddb83ce4a5..00417903c6 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -41,10 +41,10 @@ extern void thread5_game_loop(void *arg); extern void create_next_audio_buffer(s16 *samples, u32 num_samples); void game_loop_one_iteration(void); -void dispatch_audio_sptask(struct SPTask *spTask) { +void dispatch_audio_sptask(UNUSED struct SPTask *spTask) { } -void set_vblank_handler(s32 index, struct VblankHandler *handler, OSMesgQueue *queue, OSMesg *msg) { +void set_vblank_handler(UNUSED s32 index, UNUSED struct VblankHandler *handler, UNUSED OSMesgQueue *queue, UNUSED OSMesg *msg) { } static bool inited = false; diff --git a/text/de/dialogs.h b/text/de/dialogs.h index fba15c161c..136c6bfa26 100644 --- a/text/de/dialogs.h +++ b/text/de/dialogs.h @@ -1251,8 +1251,17 @@ die Temperatur!")) DEFINE_DIALOG(DIALOG_098, 1, 1, 95, 200, _("\ Komm nur näher, hehehe!")) +#ifndef QOL_FIXES DEFINE_DIALOG(DIALOG_099, 1, 3, 95, 200, _("\ ")) +#else +DEFINE_DIALOG(DIALOG_099, 1, 3, 95, 200, _("\ +Eh he he...\n\ +Du gehörst mir, hee hee!\n\ +Ich gehe einfach durch\n\ +diese Wand. Kannst du\n\ +das auch? Heh, heh, heh!")) +#endif DEFINE_DIALOG(DIALOG_100, 1, 2, 95, 200, _("\ Jippiiiiieee, ich hab' sie!\n\ diff --git a/tools/Makefile b/tools/Makefile index d81f5f9a2a..6cc2e56017 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -4,7 +4,7 @@ ifeq ($(UNAME),Darwin) endif CC := gcc -CFLAGS := -Llib -I../include -I . -Wall -Wextra -Wno-unused-parameter $(OSX_BUILD) -pedantic -std=c99 -O3 -s +CFLAGS := -Llib -I../include -I . -Wall -Wextra $(OSX_BUILD) -pedantic -std=c99 -O3 -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 n64graphics_SOURCES := n64graphics.c utils.c @@ -30,10 +30,10 @@ aifc_decode_CFLAGS := -O2 # both runs and compiles faster than -O3 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 -laudiofile -lstdc++ +tabledesign_CFLAGS := -laudiofile -lstdc++ 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 +vadpcm_enc_CFLAGS := extract_data_for_mio_SOURCES := extract_data_for_mio.c extract_data_for_mio_CFLAGS := -O2 diff --git a/tools/patch_libultra_math.c b/tools/patch_libultra_math.c index e6bdcc0cfd..e6987ba9b9 100644 --- a/tools/patch_libultra_math.c +++ b/tools/patch_libultra_math.c @@ -79,6 +79,7 @@ struct ar_header { #define FLAGS_MIPS3 0x20 #define FLAGS_O32ABI 0x100000 int main(int argc, char **argv) { + argc = 0; FILE *f = fopen(argv[1], "r+"); if (f == NULL) { @@ -122,5 +123,5 @@ int main(int argc, char **argv) { fseek(f, filesize - sizeof(hdr), SEEK_CUR); } fclose(f); - return 0; + return argc; } diff --git a/tools/sdk-tools/adpcm/util.c b/tools/sdk-tools/adpcm/util.c index 22acdd7686..29fbb15d0d 100644 --- a/tools/sdk-tools/adpcm/util.c +++ b/tools/sdk-tools/adpcm/util.c @@ -10,12 +10,12 @@ static u32 getshort(FILE *ifile) u32 c1; u32 c2; - if ((c1 = getc(ifile)) == -1) + if ((c1 = getc(ifile)) == -1U) { return 0; } - if ((c2 = getc(ifile)) == -1) + if ((c2 = getc(ifile)) == -1U) { return 0; } @@ -30,7 +30,7 @@ u32 readbits(u32 nbits, FILE *ifile) u32 left; u32 mask; - if (nbits <= in_bit_pos + 1) + if (nbits <= (u32)in_bit_pos + 1) { mask = (1U << nbits) - 1; b = ((u32) input_word >> (in_bit_pos - nbits + 1)) & mask; @@ -60,13 +60,13 @@ char *ReadPString(FILE *ifile) u8 c; char *st; - fread(&c, 1, 1, ifile); + if (fread(&c, 1, 1, ifile)){}; st = malloc(c + 1); - fread(st, c, 1, ifile); + if (fread(st, c, 1, ifile)){}; st[c] = '\0'; if ((c & 1) == 0) { - fread(&c, 1, 1, ifile); + if (fread(&c, 1, 1, ifile)){}; } return st; } @@ -91,12 +91,12 @@ ALADPCMloop *readlooppoints(FILE *ifile, s16 *nloops) s32 i; ALADPCMloop *al; - fread(nloops, sizeof(s16), 1, ifile); + if (fread(nloops, sizeof(s16), 1, ifile)){}; BSWAP16(*nloops) al = malloc(*nloops * sizeof(ALADPCMloop)); for (i = 0; i < *nloops; i++) { - fread(&al[i], sizeof(ALADPCMloop), 1, ifile); + if (fread(&al[i], sizeof(ALADPCMloop), 1, ifile)){}; BSWAP32(al[i].start) BSWAP32(al[i].end) BSWAP32(al[i].count) diff --git a/tools/sdk-tools/adpcm/vadpcm_enc.c b/tools/sdk-tools/adpcm/vadpcm_enc.c index 0fd3a11f56..857273658c 100644 --- a/tools/sdk-tools/adpcm/vadpcm_enc.c +++ b/tools/sdk-tools/adpcm/vadpcm_enc.c @@ -15,7 +15,7 @@ int main(int argc, char **argv) s16 numMarkers; s16 *inBuffer; s16 ts; - s32 minLoopLength = 800; + u32 minLoopLength = 800; s32 ***coefTable = NULL; s32 *state; s32 order; @@ -31,10 +31,10 @@ int main(int argc, char **argv) s32 i; s32 j; s32 k; - s32 nFrames; + u32 nFrames; s32 offset; s32 cChunkPos; - s32 currentPos; + u32 currentPos; s32 soundPointer = 0; s32 startPointer = 0; s32 startSoundPointer = 0; @@ -53,8 +53,8 @@ int main(int argc, char **argv) SoundDataChunk SndDChunk; InstrumentChunk InstChunk; Loop *loops = NULL; - ALADPCMloop *aloops; - Marker *markers; + ALADPCMloop *aloops = NULL; + Marker *markers = NULL; CodeChunk cChunk; char filename[1024]; FILE *fhandle; @@ -92,7 +92,7 @@ int main(int argc, char **argv) break; case 'l': - sscanf(optarg, "%d", &minLoopLength); + sscanf(optarg, "%d", (s32 *)&minLoopLength); break; default: @@ -132,7 +132,7 @@ int main(int argc, char **argv) inBuffer = malloc(16 * sizeof(s16)); - fread(&FormChunk, sizeof(Chunk), 1, ifile); + if (fread(&FormChunk, sizeof(Chunk), 1, ifile)){}; BSWAP32(FormChunk.ckID) BSWAP32(FormChunk.ckSize) BSWAP32(FormChunk.formType) @@ -198,7 +198,7 @@ int main(int argc, char **argv) case 0x53534e44: // SSND offset = ftell(ifile); - fread(&SndDChunk, sizeof(SoundDataChunk), 1, ifile); + if (fread(&SndDChunk, sizeof(SoundDataChunk), 1, ifile)){}; BSWAP32(SndDChunk.offset) BSWAP32(SndDChunk.blockSize) // The assert error messages specify line numbers 219/220. Match @@ -214,16 +214,16 @@ int main(int argc, char **argv) case 0x4d41524b: // MARK offset = ftell(ifile); - fread(&numMarkers, sizeof(s16), 1, ifile); + if (fread(&numMarkers, sizeof(s16), 1, ifile)){}; BSWAP16(numMarkers) markers = malloc(numMarkers * sizeof(Marker)); for (i = 0; i < numMarkers; i++) { - fread(&markers[i], sizeof(Marker), 1, ifile); + if (fread(&markers[i], sizeof(Marker), 1, ifile)){}; BSWAP16(markers[i].MarkerID) BSWAP16(markers[i].positionH) BSWAP16(markers[i].positionL) - fread(&strnLen, 1, 1, ifile); + if (fread(&strnLen, 1, 1, ifile)){}; if ((strnLen & 1) != 0) { fseek(ifile, strnLen, SEEK_CUR); @@ -238,7 +238,7 @@ int main(int argc, char **argv) case 0x494e5354: // INST offset = ftell(ifile); - fread(&InstChunk, sizeof(InstrumentChunk), 1, ifile); + if (fread(&InstChunk, sizeof(InstrumentChunk), 1, ifile)){}; BSWAP16(InstChunk.sustainLoop.playMode) BSWAP16(InstChunk.sustainLoop.beginLoop) BSWAP16(InstChunk.sustainLoop.endLoop) @@ -414,10 +414,10 @@ int main(int argc, char **argv) } } left = aloops[i].end - currentPos; - fread(inBuffer, sizeof(s16), left, ifile); + if (fread(inBuffer, sizeof(s16), left, ifile)){}; BSWAP16_MANY(inBuffer, left) fseek(ifile, startPointer, SEEK_SET); - fread(inBuffer + left, sizeof(s16), 16 - left, ifile); + if (fread(inBuffer + left, sizeof(s16), 16 - left, ifile)){}; BSWAP16_MANY(inBuffer + left, 16 - left) vencodeframe(ofile, inBuffer, state, coefTable, order, npredictors, 16); nBytes += 9; @@ -429,7 +429,7 @@ int main(int argc, char **argv) } nFrames = (CommChunk.numFramesH << 16) + CommChunk.numFramesL; - if ((nloops > 0U) & truncate) + if ((nloops > 0) & truncate) { lookupMarker(&loopEnd, loops[nloops - 1].endLoop, markers, numMarkers); nFrames = (loopEnd + 16 < nFrames ? loopEnd + 16 : nFrames); @@ -446,7 +446,7 @@ int main(int argc, char **argv) nsam = 16; } - if (fread(inBuffer, 2, nsam, ifile) == nsam) + if (fread(inBuffer, 2, (u32)nsam, ifile) == (u32)nsam) { BSWAP16_MANY(inBuffer, nsam) vencodeframe(ofile, inBuffer, state, coefTable, order, npredictors, nsam); diff --git a/tools/sdk-tools/adpcm/vpredictor.c b/tools/sdk-tools/adpcm/vpredictor.c index 3c35e2fcb2..abfffd0a5b 100644 --- a/tools/sdk-tools/adpcm/vpredictor.c +++ b/tools/sdk-tools/adpcm/vpredictor.c @@ -9,8 +9,8 @@ s32 readcodebook(FILE *fhandle, s32 ****table, s32 *order, s32 *npredictors) s32 j; s32 k; - fscanf(fhandle, "%d", order); - fscanf(fhandle, "%d", npredictors); + if (fscanf(fhandle, "%d", order)){}; + if (fscanf(fhandle, "%d", npredictors)){}; *table = malloc(*npredictors * sizeof(s32 **)); for (i = 0; i < *npredictors; i++) { @@ -28,7 +28,7 @@ s32 readcodebook(FILE *fhandle, s32 ****table, s32 *order, s32 *npredictors) { for (k = 0; k < 8; k++) { - fscanf(fhandle, "%d", &table_entry[k][j]); + if (fscanf(fhandle, "%d", &table_entry[k][j])){}; } } @@ -63,9 +63,9 @@ s32 readaifccodebook(FILE *fhandle, s32 ****table, s16 *order, s16 *npredictors) s32 k; s16 ts; - fread(order, sizeof(s16), 1, fhandle); + if (fread(order, sizeof(s16), 1, fhandle)){}; BSWAP16(*order) - fread(npredictors, sizeof(s16), 1, fhandle); + if (fread(npredictors, sizeof(s16), 1, fhandle)){}; BSWAP16(*npredictors) *table = malloc(*npredictors * sizeof(s32 **)); for (i = 0; i < *npredictors; i++) @@ -84,7 +84,7 @@ s32 readaifccodebook(FILE *fhandle, s32 ****table, s16 *order, s16 *npredictors) { for (k = 0; k < 8; k++) { - fread(&ts, sizeof(s16), 1, fhandle); + if (fread(&ts, sizeof(s16), 1, fhandle)){}; BSWAP16(ts) table_entry[k][j] = ts; } diff --git a/tools/sdk-tools/tabledesign/estimate.c b/tools/sdk-tools/tabledesign/estimate.c index da2b4e88bc..7a0456f18f 100644 --- a/tools/sdk-tools/tabledesign/estimate.c +++ b/tools/sdk-tools/tabledesign/estimate.c @@ -244,7 +244,7 @@ void acvect(short *in, int n, int m, double *out) */ int lud(double **a, int n, int *indx, int *d) { - int i,imax,j,k; + int i,imax = 0,j,k; double big,dum,sum,temp; double min,max; double *vv; diff --git a/tools/utils.h b/tools/utils.h index 03f482d0a4..be1f486d19 100644 --- a/tools/utils.h +++ b/tools/utils.h @@ -70,7 +70,7 @@ typedef struct // global verbosity setting extern int g_verbosity; - +#undef ERROR #define ERROR(...) fprintf(stderr, __VA_ARGS__) #define INFO(...) if (g_verbosity) printf(__VA_ARGS__) #define INFO_HEX(...) if (g_verbosity) print_hex(__VA_ARGS__)