From a4cb43bbb973769408a5a4c3d68037736afd293c Mon Sep 17 00:00:00 2001 From: Agent X <44549182+Agent-11@users.noreply.github.com> Date: Wed, 1 Nov 2023 20:17:55 -0400 Subject: [PATCH] Tear out External Data and make Free Cam always compile --- Makefile | 114 ++-------------- developer/cpp-check.sh | 2 +- developer/proto-4.sh | 4 +- developer/proto-8.sh | 4 +- src/audio/load.c | 23 +--- src/game/behaviors/fish.inc.c | 3 - src/game/camera.c | 199 ++++++++++------------------ src/game/camera.h | 2 - src/game/game_init.c | 4 - src/game/ingame_menu.c | 13 +- src/game/mario.c | 13 +- src/game/mario_actions_airborne.c | 86 +++--------- src/game/rendering_graph_node.c | 2 +- src/pc/configfile.c | 12 +- src/pc/configfile.h | 5 - src/pc/controller/controller_sdl1.c | 8 +- src/pc/controller/controller_sdl2.c | 20 +-- src/pc/djui/djui_panel_camera.c | 2 - src/pc/djui/djui_panel_display.c | 4 - src/pc/gfx/gfx_pc.c | 141 -------------------- src/pc/lua/utils/smlua_misc_utils.c | 60 --------- src/pc/pc_main.c | 9 -- 22 files changed, 112 insertions(+), 618 deletions(-) diff --git a/Makefile b/Makefile index 5941920e..907b37e2 100644 --- a/Makefile +++ b/Makefile @@ -34,18 +34,8 @@ OSX_BUILD ?= 0 TARGET_ARCH ?= native TARGET_BITS ?= 0 -# Enable better camera by default -BETTERCAMERA ?= 1 -# Enable no drawing distance by default -NODRAWINGDISTANCE ?= 1 # Disable texture fixes by default (helps with them purists) TEXTURE_FIX ?= 0 -# Enable extended options menu by default -EXT_OPTIONS_MENU ?= 1 -# Disable text-based save-files by default -TEXTSAVES ?= 0 -# Load resources from external files -EXTERNAL_DATA ?= 0 # Enable Discord Game SDK (used for Discord invites) DISCORD_SDK ?= 1 # Enable CoopNet SDK (used for CoopNet server hosting) @@ -67,8 +57,8 @@ HEADLESS ?= 0 ICON ?= 1 # Use .app (mac only) USE_APP ?= 1 -# Various workarounds for weird toolchains +# Various workarounds for weird toolchains NO_BZERO_BCOPY ?= 0 NO_LDIV ?= 0 @@ -83,11 +73,6 @@ AUDIO_API ?= SDL2 # Controller backends (can have multiple, space separated): SDL2, SDL1 CONTROLLER_API ?= SDL2 -# Misc settings for EXTERNAL_DATA - -BASEDIR ?= res -BASEPACK ?= base.zip - # Automatic settings for PC port(s) WINDOWS_BUILD ?= 0 @@ -1055,24 +1040,6 @@ ifeq ($(DOCKERBUILD),1) CFLAGS += -DDOCKERBUILD endif -# Check for Puppycam option -ifeq ($(BETTERCAMERA),1) - CC_CHECK_CFLAGS += -DBETTERCAMERA - CFLAGS += -DBETTERCAMERA - EXT_OPTIONS_MENU := 1 -endif - -#ifeq ($(TEXTSAVES),1) -# CC_CHECK_CFLAGS += -DTEXTSAVES -# CFLAGS += -DTEXTSAVES -#endif - -# Check for no drawing distance option -#ifeq ($(NODRAWINGDISTANCE),1) - CC_CHECK_CFLAGS += -DNODRAWINGDISTANCE - CFLAGS += -DNODRAWINGDISTANCE -#endif - # Check for Discord SDK option ifeq ($(DISCORD_SDK),1) CC_CHECK_CFLAGS += -DDISCORD_SDK @@ -1103,12 +1070,6 @@ ifeq ($(TEXTURE_FIX),1) CFLAGS += -DTEXTURE_FIX endif -# Check for extended options menu option -ifeq ($(EXT_OPTIONS_MENU),1) - CC_CHECK_CFLAGS += -DEXT_OPTIONS_MENU - CFLAGS += -DEXT_OPTIONS_MENU -endif - # Check for no bzero/bcopy workaround option ifeq ($(NO_BZERO_BCOPY),1) CC_CHECK_CFLAGS += -DNO_BZERO_BCOPY @@ -1127,16 +1088,6 @@ ifeq ($(LEGACY_GL),1) CFLAGS += -DLEGACY_GL endif -# Load external textures -ifeq ($(EXTERNAL_DATA),1) - CC_CHECK_CFLAGS += -DEXTERNAL_DATA -DFS_BASEDIR="\"$(BASEDIR)\"" - CFLAGS += -DEXTERNAL_DATA -DFS_BASEDIR="\"$(BASEDIR)\"" - # tell skyconv to write names instead of actual texture data and save the split tiles so we can use them later - SKYTILE_DIR := $(BUILD_DIR)/textures/skybox_tiles - SKYCONV_ARGS := --store-names --write-tiles "$(SKYTILE_DIR)" - $(shell mkdir -p $(SKYTILE_DIR)) -endif - #==============================================================================# # Miscellaneous Tools # #==============================================================================# @@ -1189,40 +1140,6 @@ endef # Main Targets # #==============================================================================# - - -ifeq ($(EXTERNAL_DATA),1) - -BASEPACK_PATH := $(BUILD_DIR)/$(BASEDIR)/$(BASEPACK) -BASEPACK_LST := $(BUILD_DIR)/basepack.lst - -# depend on resources as well -all: $(BASEPACK_PATH) - -# phony target for building resources -res: $(BASEPACK_PATH) - -# prepares the basepack.lst -$(BASEPACK_LST): $(EXE) - @$(PRINT) "$(GREEN)Making basepack list.$(NO_COL)\n" - @mkdir -p $(BUILD_DIR)/$(BASEDIR) - @echo -n > $(BASEPACK_LST) - @echo "$(BUILD_DIR)/sound/bank_sets sound/bank_sets" >> $(BASEPACK_LST) - @echo "$(BUILD_DIR)/sound/sequences.bin sound/sequences.bin" >> $(BASEPACK_LST) - @echo "$(BUILD_DIR)/sound/sound_data.ctl sound/sound_data.ctl" >> $(BASEPACK_LST) - @echo "$(BUILD_DIR)/sound/sound_data.tbl sound/sound_data.tbl" >> $(BASEPACK_LST) - @$(foreach f, $(wildcard $(SKYTILE_DIR)/*), echo $(f) gfx/$(f:$(BUILD_DIR)/%=%) >> $(BASEPACK_LST);) - @find actors -name \*.png -exec echo "{} gfx/{}" >> $(BASEPACK_LST) \; - @find levels -name \*.png -exec echo "{} gfx/{}" >> $(BASEPACK_LST) \; - @find textures -name \*.png -exec echo "{} gfx/{}" >> $(BASEPACK_LST) \; - -# prepares the resource ZIP with base data -$(BASEPACK_PATH): $(BASEPACK_LST) - @$(PRINT) "$(GREEN)Packing basepack zip file.$(NO_COL)\n" - $(V)$(PYTHON) $(TOOLS_DIR)/mkzip.py $(BASEPACK_LST) $(BASEPACK_PATH) - -endif - #all: $(ROM) all: $(EXE) @@ -1342,33 +1259,24 @@ $(BUILD_DIR)/src/game/ingame_menu.o: $(BUILD_DIR)/include/text_strings.h #==============================================================================# TEXTURE_ENCODING := u8 -ifeq ($(EXTERNAL_DATA),1) - $(BUILD_DIR)/%: %.png - $(call print,Dummying:,$<,$@) - $(V)$(PYTHON) $(TOOLS_DIR)/zeroterm.py "$(patsubst %.png,%,$^)" > $@ -else - # Convert PNGs to RGBA32, RGBA16, IA16, IA8, IA4, IA1, I8, I4 binary files - $(BUILD_DIR)/%: %.png +# Convert PNGs to RGBA32, RGBA16, IA16, IA8, IA4, IA1, I8, I4 binary files +$(BUILD_DIR)/%: %.png $(call print,Converting:,$<,$@) $(V)$(N64GRAPHICS) -s raw -i $@ -g $< -f $(lastword $(subst ., ,$@)) - $(BUILD_DIR)/%.inc.c: %.png +$(BUILD_DIR)/%.inc.c: %.png $(call print,Converting:,$<,$@) $(V)$(N64GRAPHICS) -s $(TEXTURE_ENCODING) -i $@ -g $< -f $(lastword ,$(subst ., ,$(basename $<))) -endif - -ifeq ($(EXTERNAL_DATA),0) - # Color Index CI8 - $(BUILD_DIR)/%.ci8: %.ci8.png +# Color Index CI8 +$(BUILD_DIR)/%.ci8: %.ci8.png $(call print,Converting:,$<,$@) $(V)$(N64GRAPHICS_CI) -i $@ -g $< -f ci8 - # Color Index CI4 - $(BUILD_DIR)/%.ci4: %.ci4.png +# Color Index CI4 +$(BUILD_DIR)/%.ci4: %.ci4.png $(call print,Converting:,$<,$@) $(V)$(N64GRAPHICS_CI) -i $@ -g $< -f ci4 -endif #==============================================================================# # Compressed Segment Generation # @@ -1464,12 +1372,6 @@ $(SOUND_BIN_DIR)/%.m64: $(SOUND_BIN_DIR)/%.o # Generated Source Code Files # #==============================================================================# -ifeq ($(EXTERNAL_DATA),1) - $(SOUND_BIN_DIR)/%.inc.c: $(SOUND_BIN_DIR)/% - $(call print,Dummying:,$<,$@) - $(V)$(PYTHON) $(TOOLS_DIR)/zeroterm.py "$(patsubst $(BUILD_DIR)/%,%,$^)" | hexdump -v -e '1/1 "0x%X,"' > $@ -endif - # Convert binary file to a comma-separated list of byte values for inclusion in C code $(BUILD_DIR)/%.inc.c: $(BUILD_DIR)/% $(call print,Piping:,$<,$@) diff --git a/developer/cpp-check.sh b/developer/cpp-check.sh index 99733d30..f027f13d 100755 --- a/developer/cpp-check.sh +++ b/developer/cpp-check.sh @@ -7,7 +7,7 @@ else fi INCLUDES="-Iinclude -Isrc -I. -Ilib/lua/include" -DEFINES="-DRAPI_GL=1 -DWAPI_SDL2=1 -DAAPI_SDL2=1 -DCAPI_SDL2=1 -DHAVE_SDL2=1 -DVERSION_US -D_LANGUAGE_C -DNIGHTLY -DNON_MATCHING -DAVOID_UB -DF3DEX_GBI_2E -DCOOP -DIMMEDIATELOAD -DBETTERCAMERA -DNODRAWINGDISTANCE -DDISCORD_SDK -DTEXTURE_FIX -DEXT_OPTIONS_MENU" +DEFINES="-DRAPI_GL=1 -DWAPI_SDL2=1 -DAAPI_SDL2=1 -DCAPI_SDL2=1 -DHAVE_SDL2=1 -DVERSION_US -D_LANGUAGE_C -DNIGHTLY -DNON_MATCHING -DAVOID_UB -DF3DEX_GBI_2E -DDISCORD_SDK" PARAMS="--language=c --quiet --platform=unix64 -v src -j8" cppcheck -DLLONG_MAX $INCLUDES $DEFINES $EXTRA $PARAMS diff --git a/developer/proto-4.sh b/developer/proto-4.sh index 23712171..3c54ef06 100755 --- a/developer/proto-4.sh +++ b/developer/proto-4.sh @@ -1,9 +1,9 @@ #!/bin/bash set -e if [ $# -eq 0 ]; then - make BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 STRICT=1 -j + make DEBUG=1 DEVELOPMENT=1 STRICT=1 -j else - make BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 -j + make DEBUG=1 DEVELOPMENT=1 -j fi # find file diff --git a/developer/proto-8.sh b/developer/proto-8.sh index f00af4c9..7ccaff36 100755 --- a/developer/proto-8.sh +++ b/developer/proto-8.sh @@ -1,9 +1,9 @@ #!/bin/bash set -e if [ $# -eq 0 ]; then - make BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 STRICT=1 -j + make DEBUG=1 DEVELOPMENT=1 STRICT=1 -j else - make BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 -j + make DEBUG=1 DEVELOPMENT=1 -j fi # find file diff --git a/src/audio/load.c b/src/audio/load.c index 93ce2104..23b092fa 100644 --- a/src/audio/load.c +++ b/src/audio/load.c @@ -1791,21 +1791,6 @@ u8 gShindouSequencesHeader[] = { }; #endif -#ifdef EXTERNAL_DATA -# define LOAD_DATA(x) load_sound_res((const char *)x) -# include -# include -static inline void *load_sound_res(const char *path) { - void *data = fs_load_file(path, NULL); - if (!data) sys_fatal("could not load sound data from '%s'", path); - // FIXME: figure out where it is safe to free this shit - // can't free it immediately after in audio_init() - return data; -} -#else -# define LOAD_DATA(x) x -#endif - // (void) must be omitted from parameters void audio_init() { #if defined(VERSION_EU) @@ -1956,7 +1941,7 @@ void audio_init() { init_sequence_players(); #else gSeqFileHeader = (ALSeqFile *) buf; - data = LOAD_DATA(gMusicData); + data = gMusicData; audio_dma_copy_immediate((uintptr_t) data, gSeqFileHeader, 0x10); gSequenceCount = gSeqFileHeader->seqCount; #if defined(VERSION_EU) @@ -1971,7 +1956,7 @@ void audio_init() { // Load header for CTL (assets/sound_data.ctl.s, i.e. ADSR) gAlCtlHeader = (ALSeqFile *) buf; - data = LOAD_DATA(gSoundDataADSR); + data = gSoundDataADSR; audio_dma_copy_immediate((uintptr_t) data, gAlCtlHeader, 0x10); size = gAlCtlHeader->seqCount * sizeof(ALSeqData) + 4; size = ALIGN16(size); @@ -1987,12 +1972,12 @@ void audio_init() { size = ALIGN16(size); gAlTbl = soundAlloc(&gAudioInitPool, size); - data = LOAD_DATA(gSoundDataRaw); + data = gSoundDataRaw; audio_dma_copy_immediate((uintptr_t) data, gAlTbl, size); alSeqFileNew(gAlTbl, data); // Load bank sets for each sequence (assets/bank_sets.s) - data = LOAD_DATA(gBankSetsData); + data = gBankSetsData; gAlBankSets = soundAlloc(&gAudioInitPool, 160); audio_dma_copy_immediate((uintptr_t)data, gAlBankSets, 160); diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c index 911af713..47bb2737 100644 --- a/src/game/behaviors/fish.inc.c +++ b/src/game/behaviors/fish.inc.c @@ -52,13 +52,10 @@ static void fish_spawner_act_spawn(void) { * Mario is more than 2000 units higher. */ void fish_spawner_act_idle(void) { - // TODO: should this be re-enabled? -/*#ifndef NODRAWINGDISTANCE struct Object *player = nearest_player_to_object(o); if ((gCurrLevelNum != LEVEL_SA) && (player->oPosY - o->oPosY > 2000.0f)) { o->oAction = FISH_SPAWNER_ACT_RESPAWN; } -#endif*/ } /** diff --git a/src/game/camera.c b/src/game/camera.c index eb50c0a8..dc1343c2 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -723,10 +723,9 @@ BAD_RETURN(f32) calc_y_to_curr_floor(f32 *posOff, f32 posMul, f32 posBound, f32 *focOff = -focBound; } } -//Compiler gets mad if I put this any further above. thanks refresh 7 -#ifdef BETTERCAMERA + +// compiler gets mad if I put this any further above. thanks refresh 7 #include "bettercamera.inc.h" -#endif void focus_on_mario(Vec3f focus, Vec3f pos, f32 posYOff, f32 focYOff, f32 dist, s16 pitch, s16 yaw) { Vec3f marioPos; @@ -2690,7 +2689,6 @@ s32 exit_c_up(struct Camera *c) { gCameraMovementFlags |= CAM_MOVE_STARTED_EXITING_C_UP; transition_next_state(c, 15); } else { -#ifdef BETTERCAMERA newcam_init_settings(); if (newcam_active == 1) { // Retrieve the previous position and focus @@ -2712,11 +2710,6 @@ s32 exit_c_up(struct Camera *c) { gCameraMovementFlags &= ~(CAM_MOVE_STARTED_EXITING_C_UP | CAM_MOVE_C_UP_MODE); vec3f_set_dist_and_angle(checkFoc, c->pos, curDist, curPitch, curYaw + checkYaw); } -#else - // Let the next camera mode handle it - gCameraMovementFlags &= ~(CAM_MOVE_STARTED_EXITING_C_UP | CAM_MOVE_C_UP_MODE); - vec3f_set_dist_and_angle(checkFoc, c->pos, curDist, curPitch, curYaw + checkYaw); -#endif } play_sound_cbutton_down(); } @@ -2936,9 +2929,7 @@ static bool allow_romhack_camera_override_mode(u8 mode) { case CAMERA_MODE_WATER_SURFACE: case CAMERA_MODE_INSIDE_CANNON: case CAMERA_MODE_BOSS_FIGHT: -#ifdef BETTERCAMERA case CAMERA_MODE_NEWCAM: -#endif case CAMERA_MODE_ROM_HACK: return false; default: @@ -2970,62 +2961,56 @@ void set_camera_mode(struct Camera *c, s16 mode, s16 frames) { return; } -#ifdef BETTERCAMERA if (mode == CAMERA_MODE_C_UP && gLakituState.mode == CAMERA_MODE_NEWCAM) { newcam_init_settings_override(false); } - if (mode != CAMERA_MODE_NEWCAM && gLakituState.mode != CAMERA_MODE_NEWCAM) - { -#endif - if (mode == CAMERA_MODE_WATER_SURFACE && gCurrLevelArea == AREA_TTM_OUTSIDE) { - } else { - // Clear movement flags that would affect the transition - gCameraMovementFlags &= (u16)~(CAM_MOVE_RESTRICT | CAM_MOVE_ROTATE); - gCameraMovementFlags |= CAM_MOVING_INTO_MODE; - if (mode == CAMERA_MODE_NONE) { - mode = CAMERA_MODE_CLOSE; + if (mode != CAMERA_MODE_NEWCAM && gLakituState.mode != CAMERA_MODE_NEWCAM) { + if (mode != CAMERA_MODE_WATER_SURFACE && gCurrLevelArea != AREA_TTM_OUTSIDE) { + // Clear movement flags that would affect the transition + gCameraMovementFlags &= (u16)~(CAM_MOVE_RESTRICT | CAM_MOVE_ROTATE); + gCameraMovementFlags |= CAM_MOVING_INTO_MODE; + if (mode == CAMERA_MODE_NONE) { + mode = CAMERA_MODE_CLOSE; + } + sCUpCameraPitch = 0; + sModeOffsetYaw = 0; + sLakituDist = 0; + sLakituPitch = 0; + sAreaYawChange = 0; + + sModeInfo.newMode = (mode != -1) ? mode : sModeInfo.lastMode; + sModeInfo.lastMode = c->mode; + sModeInfo.max = frames; + sModeInfo.frame = 1; + + c->mode = sModeInfo.newMode; + gLakituState.mode = c->mode; + + vec3f_copy(end->focus, c->focus); + vec3f_sub(end->focus, sMarioCamState->pos); + + vec3f_copy(end->pos, c->pos); + vec3f_sub(end->pos, sMarioCamState->pos); + + if (sModeInfo.newMode != CAMERA_MODE_NONE && (u32)sModeInfo.newMode < sizeof(sModeTransitions) / sizeof(sModeTransitions[0])) { + sAreaYaw = sModeTransitions[sModeInfo.newMode](c, end->focus, end->pos); + } + + // End was updated by sModeTransitions + vec3f_sub(end->focus, sMarioCamState->pos); + vec3f_sub(end->pos, sMarioCamState->pos); + + vec3f_copy(start->focus, gLakituState.curFocus); + vec3f_sub(start->focus, sMarioCamState->pos); + + vec3f_copy(start->pos, gLakituState.curPos); + vec3f_sub(start->pos, sMarioCamState->pos); + + vec3f_get_dist_and_angle(start->focus, start->pos, &start->dist, &start->pitch, &start->yaw); + vec3f_get_dist_and_angle(end->focus, end->pos, &end->dist, &end->pitch, &end->yaw); } - sCUpCameraPitch = 0; - sModeOffsetYaw = 0; - sLakituDist = 0; - sLakituPitch = 0; - sAreaYawChange = 0; - - sModeInfo.newMode = (mode != -1) ? mode : sModeInfo.lastMode; - sModeInfo.lastMode = c->mode; - sModeInfo.max = frames; - sModeInfo.frame = 1; - - c->mode = sModeInfo.newMode; - gLakituState.mode = c->mode; - - vec3f_copy(end->focus, c->focus); - vec3f_sub(end->focus, sMarioCamState->pos); - - vec3f_copy(end->pos, c->pos); - vec3f_sub(end->pos, sMarioCamState->pos); - - if (sModeInfo.newMode != CAMERA_MODE_NONE && (u32)sModeInfo.newMode < sizeof(sModeTransitions) / sizeof(sModeTransitions[0])) { - sAreaYaw = sModeTransitions[sModeInfo.newMode](c, end->focus, end->pos); - } - - // End was updated by sModeTransitions - vec3f_sub(end->focus, sMarioCamState->pos); - vec3f_sub(end->pos, sMarioCamState->pos); - - vec3f_copy(start->focus, gLakituState.curFocus); - vec3f_sub(start->focus, sMarioCamState->pos); - - vec3f_copy(start->pos, gLakituState.curPos); - vec3f_sub(start->pos, sMarioCamState->pos); - - vec3f_get_dist_and_angle(start->focus, start->pos, &start->dist, &start->pitch, &start->yaw); - vec3f_get_dist_and_angle(end->focus, end->pos, &end->dist, &end->pitch, &end->yaw); } -#ifdef BETTERCAMERA - } -#endif } /** @@ -3041,11 +3026,7 @@ void update_lakitu(struct Camera *c) { s16 newYaw; UNUSED u8 unused1[8]; -#ifdef BETTERCAMERA u8 allowPauseCheck = (c->mode != CAMERA_MODE_NEWCAM); -#else - u8 allowPauseCheck = TRUE; -#endif if (allowPauseCheck && (gCameraMovementFlags & CAM_MOVE_PAUSE_SCREEN)) { } else { @@ -3117,12 +3098,7 @@ void update_lakitu(struct Camera *c) { gLakituState.roll += sHandheldShakeRoll; gLakituState.roll += gLakituState.keyDanceRoll; - if (c->mode != CAMERA_MODE_C_UP && c->cutscene == 0 -#ifdef BETTERCAMERA - && c->mode != CAMERA_MODE_NEWCAM -#endif - ) - { + if (c->mode != CAMERA_MODE_C_UP && c->cutscene == 0 && c->mode != CAMERA_MODE_NEWCAM) { gCheckingSurfaceCollisionsForCamera = TRUE; distToFloor = find_floor(gLakituState.pos[0], gLakituState.pos[1] + 20.0f, @@ -3179,11 +3155,7 @@ void update_camera(struct Camera *c) { if (c->cutscene == 0) { // Only process R_TRIG if 'fixed' is not selected in the menu - if (cam_select_alt_mode(0) == CAM_SELECTION_MARIO -#ifdef BETTERCAMERA - && c->mode != CAMERA_MODE_NEWCAM -#endif - ) { + if (cam_select_alt_mode(0) == CAM_SELECTION_MARIO && c->mode != CAMERA_MODE_NEWCAM) { if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & R_TRIG) { bool returnValue = true; if (set_cam_angle(0) == CAM_ANGLE_LAKITU) { @@ -3228,22 +3200,16 @@ void update_camera(struct Camera *c) { c->mode = gLakituState.mode; c->defMode = gLakituState.defMode; -#ifdef BETTERCAMERA - if (c->mode != CAMERA_MODE_NEWCAM) - { -#endif - camera_course_processing(c); - stub_camera_3(c); - sCButtonsPressed = find_c_buttons_pressed(sCButtonsPressed, gPlayer1Controller->buttonPressed,gPlayer1Controller->buttonDown); -#ifdef BETTERCAMERA + if (c->mode != CAMERA_MODE_NEWCAM) { + camera_course_processing(c); + stub_camera_3(c); + sCButtonsPressed = find_c_buttons_pressed(sCButtonsPressed, gPlayer1Controller->buttonPressed,gPlayer1Controller->buttonDown); } - if (gMarioStates[0].action == ACT_SHOT_FROM_CANNON && newcam_active) - { + if (gMarioStates[0].action == ACT_SHOT_FROM_CANNON && newcam_active) { gMarioStates[0].area->camera->mode = CAMERA_MODE_NEWCAM; gLakituState.mode = CAMERA_MODE_NEWCAM; } -#endif if (c->cutscene != 0) { sYawSpeed = 0; @@ -3281,11 +3247,9 @@ void update_camera(struct Camera *c) { mode_cannon_camera(c); break; -#ifdef BETTERCAMERA case CAMERA_MODE_NEWCAM: newcam_loop(c); break; -#endif default: mode_mario_camera(c); @@ -3351,11 +3315,9 @@ void update_camera(struct Camera *c) { mode_rom_hack_camera(c); break; -#ifdef BETTERCAMERA case CAMERA_MODE_NEWCAM: newcam_loop(c); break; -#endif } } } @@ -3662,10 +3624,8 @@ void init_camera(struct Camera *c) { c->yaw = gLakituState.yaw; c->nextYaw = gLakituState.yaw; -#ifdef BETTERCAMERA newcam_init(c, 0); newcam_init_settings(); -#endif } /** @@ -5784,10 +5744,10 @@ void set_camera_mode_8_directions(struct Camera *c) { s8DirModeBaseYaw = 0; s8DirModeYawOffset = 0; } -#ifdef BETTERCAMERA - if (newcam_active == 1) + + if (newcam_active == 1) { c->mode = CAMERA_MODE_NEWCAM; -#endif + } } /** @@ -5808,10 +5768,10 @@ void set_camera_mode_close_cam(u8 *mode) { sStatusFlags &= ~CAM_FLAG_SMOOTH_MOVEMENT; *mode = CAMERA_MODE_CLOSE; } -#ifdef BETTERCAMERA - if (newcam_active == 1) + + if (newcam_active == 1) { *mode = CAMERA_MODE_NEWCAM; -#endif + } } /** @@ -5837,10 +5797,10 @@ void set_camera_mode_radial(struct Camera *c, s16 transitionTime) { } sModeOffsetYaw = 0; } -#ifdef BETTERCAMERA - if (newcam_active == 1) + + if (newcam_active == 1) { c->mode = CAMERA_MODE_NEWCAM; -#endif + } } /** @@ -7297,9 +7257,7 @@ void update_camera_yaw(struct Camera *c) { if (!c) { return; } c->nextYaw = calculate_yaw(c->focus, c->pos); c->yaw = c->nextYaw; -#ifdef BETTERCAMERA newcam_apply_outside_values(c,0); -#endif } void cutscene_reset_spline(void) { @@ -9694,14 +9652,9 @@ BAD_RETURN(s32) cutscene_non_painting_end(struct Camera *c) { if (c->defMode == CAMERA_MODE_CLOSE) { c->mode = CAMERA_MODE_CLOSE; - } else -#ifdef BETTERCAMERA - if (c->defMode == CAMERA_MODE_NEWCAM) { + } else if (c->defMode == CAMERA_MODE_NEWCAM) { c->mode = CAMERA_MODE_NEWCAM; - } - else -#endif - { + } else { c->mode = CAMERA_MODE_FREE_ROAM; } @@ -10484,9 +10437,7 @@ BAD_RETURN(s32) cutscene_sliding_doors_follow_mario(struct Camera *c) { BAD_RETURN(s32) cutscene_sliding_doors_open(struct Camera *c) { UNUSED u32 pad[2]; -#ifdef BETTERCAMERA newcam_apply_outside_values(c,1); -#endif reset_pan_distance(c); cutscene_event(cutscene_sliding_doors_open_start, c, 0, 8); cutscene_event(cutscene_sliding_doors_open_set_cvars, c, 8, 8); @@ -10699,12 +10650,11 @@ BAD_RETURN(s32) cutscene_unused_exit_focus_mario(struct Camera *c) { */ BAD_RETURN(s32) cutscene_exit_painting_end(struct Camera *c) { if (!c) { return; } -#ifdef BETTERCAMERA - if (newcam_active == 1) + if (newcam_active == 1) { c->mode = CAMERA_MODE_NEWCAM; - else -#endif + } else { c->mode = CAMERA_MODE_CLOSE; + } c->cutscene = 0; gCutsceneTimer = CUTSCENE_STOP; sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT; @@ -10874,24 +10824,13 @@ BAD_RETURN(s32) cutscene_door_follow_mario(struct Camera *c) { */ BAD_RETURN(s32) cutscene_door_end(struct Camera *c) { if (!c) { return; } -#ifndef BETTERCAMERA - if (c->defMode == CAMERA_MODE_FREE_ROAM) { - c->mode = CAMERA_MODE_FREE_ROAM; - } else { - c->mode = CAMERA_MODE_CLOSE; - } -#else if (c->defMode == CAMERA_MODE_CLOSE) { c->mode = CAMERA_MODE_CLOSE; - } else - if (c->defMode == CAMERA_MODE_NEWCAM) { + } else if (c->defMode == CAMERA_MODE_NEWCAM) { c->mode = CAMERA_MODE_NEWCAM; - } - else - { + } else { c->mode = CAMERA_MODE_FREE_ROAM; } -#endif c->cutscene = 0; gCutsceneTimer = CUTSCENE_STOP; diff --git a/src/game/camera.h b/src/game/camera.h index 07d1fd7f..c140ee62 100644 --- a/src/game/camera.h +++ b/src/game/camera.h @@ -123,9 +123,7 @@ extern u8 gOverrideAllowToxicGasCamera; #define CAMERA_MODE_8_DIRECTIONS 0x0E // AKA Parallel Camera, Bowser Courses & Rainbow Ride #define CAMERA_MODE_FREE_ROAM 0x10 #define CAMERA_MODE_SPIRAL_STAIRS 0x11 -#ifdef BETTERCAMERA #define CAMERA_MODE_NEWCAM 0x12 -#endif #define CAMERA_MODE_ROM_HACK 0x13 #define CAM_MOVE_RETURN_TO_MIDDLE 0x0001 diff --git a/src/game/game_init.c b/src/game/game_init.c index f8f1ad3c..e6f475af 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -24,9 +24,7 @@ #include "src/pc/djui/djui_panel_pause.h" #include "rumble_init.h" #include -#ifdef BETTERCAMERA #include "bettercamera.h" -#endif #include "hud.h" // FIXME: I'm not sure all of these variables belong in this file, but I don't @@ -545,10 +543,8 @@ void init_controllers(void) { } } -#ifdef BETTERCAMERA // load bettercam settings from the config file newcam_init_settings(); -#endif } void setup_game_memory(void) { diff --git a/src/game/ingame_menu.c b/src/game/ingame_menu.c index 499c55ce..4869db61 100644 --- a/src/game/ingame_menu.c +++ b/src/game/ingame_menu.c @@ -36,9 +36,6 @@ #include "hud.h" #include "pc/lua/smlua_hooks.h" #include "game/camera.h" -#ifdef BETTERCAMERA -#include "bettercamera.h" -#endif #include "level_info.h" u16 gDialogColorFadeTimer; @@ -142,7 +139,7 @@ u8 gMenuHoldKeyIndex = 0; u8 gMenuHoldKeyTimer = 0; s32 gDialogResponse = 0; -#if !defined(EXTERNAL_DATA) && (defined(VERSION_JP) || defined(VERSION_SH) || defined(VERSION_EU)) +#if (defined(VERSION_JP) || defined(VERSION_SH) || defined(VERSION_EU)) #ifdef VERSION_EU #define CHCACHE_BUFLEN (8 * 8) // EU only converts 8x8 #else @@ -316,16 +313,12 @@ 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) { -#ifdef EXTERNAL_DATA - return (u8 *)tex; // the data's just a name -#else if (!tex) return NULL; if (!charCache[c].used) { charCache[c].used = 1; alloc_ia8_text_from_i1(charCache[c].data, tex, w, h); } return charCache[c].data; -#endif } #endif @@ -377,16 +370,12 @@ static void alloc_ia4_tex_from_i1(u8 *out, u8 *in, s16 width, s16 height) { } static u8 *convert_ia4_char(u8 c, u8 *tex, s16 w, s16 h) { -#ifdef EXTERNAL_DATA - return tex; // the data's just a name -#else if (!tex) return NULL; if (!charCache[c].used) { charCache[c].used = 1; alloc_ia4_tex_from_i1(charCache[c].data, tex, w, h); } return charCache[c].data; -#endif } void render_generic_char_at_pos(s16 xPos, s16 yPos, u8 c) { diff --git a/src/game/mario.c b/src/game/mario.c index 50628e53..8f02cb41 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -43,9 +43,7 @@ #include "pc/network/network.h" #include "pc/lua/smlua.h" #include "pc/network/socket/socket.h" -#ifdef BETTERCAMERA #include "bettercamera.h" -#endif #define MAX_HANG_PREVENTION 64 @@ -1571,14 +1569,11 @@ void update_mario_joystick_inputs(struct MarioState *m) { if ((sCurrPlayMode == PLAY_MODE_PAUSED) || m->playerIndex != 0) { return; } if (m->intendedMag > 0.0f) { -#ifndef BETTERCAMERA - m->intendedYaw = atan2s(-controller->stickY, controller->stickX) + m->area->camera->yaw; -#else - if (gLakituState.mode != CAMERA_MODE_NEWCAM) + if (gLakituState.mode != CAMERA_MODE_NEWCAM) { m->intendedYaw = atan2s(-controller->stickY, controller->stickX) + m->area->camera->yaw; - else - m->intendedYaw = atan2s(-controller->stickY, controller->stickX)-newcam_yaw+0x4000; -#endif + } else { + m->intendedYaw = atan2s(-controller->stickY, controller->stickX) - newcam_yaw + 0x4000; + } m->input |= INPUT_NONZERO_ANALOG; } else { m->intendedYaw = m->faceAngle[1]; diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 72d41715..9064fb90 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -13,9 +13,7 @@ #include "mario_step.h" #include "save_file.h" #include "rumble_init.h" -#ifdef BETTERCAMERA #include "bettercamera.h" -#endif #include "behavior_table.h" #include "object_helpers.h" #include "pc/debuglog.h" @@ -1769,19 +1767,14 @@ s32 act_shot_from_cannon(struct MarioState *m) { case AIR_STEP_LANDED: set_mario_action(m, ACT_DIVE_SLIDE, 0); m->faceAngle[0] = 0; -#ifndef BETTERCAMERA - if (allowCameraChange) { set_camera_mode(m->area->camera, m->area->camera->defMode, 1); } -#else if (allowCameraChange) { - if (newcam_active == 0) + if (newcam_active == 0) { set_camera_mode(m->area->camera, m->area->camera->defMode, 1); - else - { + } else { m->area->camera->mode = CAMERA_MODE_NEWCAM; gLakituState.mode = CAMERA_MODE_NEWCAM; } } -#endif queue_rumble_data_mario(m, 5, 80); break; @@ -1795,19 +1788,14 @@ s32 act_shot_from_cannon(struct MarioState *m) { set_mario_particle_flags(m, PARTICLE_VERTICAL_STAR, FALSE); set_mario_action(m, ACT_BACKWARD_AIR_KB, 0); -#ifndef BETTERCAMERA - if (allowCameraChange) { set_camera_mode(m->area->camera, m->area->camera->defMode, 1); } -#else if (allowCameraChange) { - if (newcam_active == 0) + if (newcam_active == 0) { set_camera_mode(m->area->camera, m->area->camera->defMode, 1); - else - { + } else { m->area->camera->mode = CAMERA_MODE_NEWCAM; gLakituState.mode = CAMERA_MODE_NEWCAM; } } -#endif break; case AIR_STEP_HIT_LAVA_WALL: @@ -1838,17 +1826,12 @@ s32 act_flying(struct MarioState *m) { if (m->input & INPUT_Z_PRESSED) { if (m->area->camera->mode == CAMERA_MODE_BEHIND_MARIO) { if (m->playerIndex == 0) { -#ifndef BETTERCAMERA - set_camera_mode(m->area->camera, m->area->camera->defMode, 1); -#else - if (newcam_active == 0) + if (newcam_active == 0) { set_camera_mode(m->area->camera, m->area->camera->defMode, 1); - else - { + } else { m->area->camera->mode = CAMERA_MODE_NEWCAM; gLakituState.mode = CAMERA_MODE_NEWCAM; } -#endif } } return set_mario_action(m, ACT_GROUND_POUND, 1); @@ -1857,17 +1840,12 @@ s32 act_flying(struct MarioState *m) { if (!(m->flags & MARIO_WING_CAP)) { if (m->area->camera->mode == CAMERA_MODE_BEHIND_MARIO) { if (m->playerIndex == 0) { -#ifndef BETTERCAMERA - set_camera_mode(m->area->camera, m->area->camera->defMode, 1); -#else - if (newcam_active == 0) + if (newcam_active == 0) { set_camera_mode(m->area->camera, m->area->camera->defMode, 1); - else - { + } else { m->area->camera->mode = CAMERA_MODE_NEWCAM; gLakituState.mode = CAMERA_MODE_NEWCAM; } -#endif } } return set_mario_action(m, ACT_FREEFALL, 0); @@ -1875,19 +1853,15 @@ s32 act_flying(struct MarioState *m) { if (m->area->camera->mode != CAMERA_MODE_BEHIND_MARIO) { if (m->playerIndex == 0) { -#ifndef BETTERCAMERA - set_camera_mode(m->area->camera, CAMERA_MODE_BEHIND_MARIO, 1); -#else if (newcam_active == 0) { set_camera_mode(m->area->camera, CAMERA_MODE_BEHIND_MARIO, 1); // note: EX sets it to the following line instead, but I have // no idea why... possibly copy/paste error? - //set_camera_mode(m->area->camera, m->area->camera->defMode, 1); + // set_camera_mode(m->area->camera, m->area->camera->defMode, 1); } else { m->area->camera->mode = CAMERA_MODE_NEWCAM; gLakituState.mode = CAMERA_MODE_NEWCAM; } -#endif } } @@ -1932,17 +1906,12 @@ s32 act_flying(struct MarioState *m) { m->faceAngle[0] = 0; if (m->playerIndex == 0) { -#ifndef BETTERCAMERA - set_camera_mode(m->area->camera, m->area->camera->defMode, 1); -#else - if (newcam_active == 0) + if (newcam_active == 0) { set_camera_mode(m->area->camera, m->area->camera->defMode, 1); - else - { + } else { m->area->camera->mode = CAMERA_MODE_NEWCAM; gLakituState.mode = CAMERA_MODE_NEWCAM; } -#endif } queue_rumble_data_mario(m, 5, 60); break; @@ -1964,17 +1933,12 @@ s32 act_flying(struct MarioState *m) { set_mario_action(m, ACT_BACKWARD_AIR_KB, 0); if (m->playerIndex == 0) { -#ifndef BETTERCAMERA - set_camera_mode(m->area->camera, m->area->camera->defMode, 1); -#else - if (newcam_active == 0) + if (newcam_active == 0) { set_camera_mode(m->area->camera, m->area->camera->defMode, 1); - else - { + } else { m->area->camera->mode = CAMERA_MODE_NEWCAM; gLakituState.mode = CAMERA_MODE_NEWCAM; } -#endif } } else { if (m->actionTimer++ == 0) { @@ -2061,17 +2025,12 @@ s32 act_flying_triple_jump(struct MarioState *m) { #ifndef VERSION_JP if (m->input & (INPUT_B_PRESSED | INPUT_Z_PRESSED)) { if (m->playerIndex == 0 && m->area->camera->mode == CAMERA_MODE_BEHIND_MARIO) { -#ifndef BETTERCAMERA - set_camera_mode(m->area->camera, m->area->camera->defMode, 1); -#else - if (newcam_active == 0) + if (newcam_active == 0) { set_camera_mode(m->area->camera, m->area->camera->defMode, 1); - else - { + } else { m->area->camera->mode = CAMERA_MODE_NEWCAM; gLakituState.mode = CAMERA_MODE_NEWCAM; } -#endif } if (m->input & INPUT_B_PRESSED) { return set_mario_action(m, ACT_DIVE, 0); @@ -2110,17 +2069,12 @@ s32 act_flying_triple_jump(struct MarioState *m) { if (m->vel[1] < 4.0f) { if (m->playerIndex == 0 && m->area->camera->mode != CAMERA_MODE_BEHIND_MARIO) { -#ifndef BETTERCAMERA - set_camera_mode(m->area->camera, CAMERA_MODE_BEHIND_MARIO, 1); -#else - if (newcam_active == 0) + if (newcam_active == 0) { set_camera_mode(m->area->camera, m->area->camera->defMode, 1); - else - { + } else { m->area->camera->mode = CAMERA_MODE_NEWCAM; gLakituState.mode = CAMERA_MODE_NEWCAM; } -#endif } if (m->forwardVel < 32.0f) { @@ -2130,12 +2084,6 @@ s32 act_flying_triple_jump(struct MarioState *m) { set_mario_action(m, ACT_FLYING, 1); } -#ifndef BETTERCAMERA - if (m->playerIndex == 0 && m->actionTimer++ == 10 && m->area->camera->mode != CAMERA_MODE_BEHIND_MARIO) { - set_camera_mode(m->area->camera, CAMERA_MODE_BEHIND_MARIO, 1); - } -#endif - update_air_without_turn(m); switch (perform_air_step(m, 0)) { diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index cda25fb7..a31effce 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -1153,7 +1153,7 @@ static s32 obj_is_in_view(struct GraphNodeObject *node, Mat4 matrix) { // visibly pop in or out at the edge of the screen. // // Half of the fov in in-game angle units instead of degrees. - s16 halfFov = (gOverrideFOV != 0 ? gOverrideFOV : gCurGraphNodeCamFrustum->fov / 2.0f + 1.0f) * 32768.0f / 180.0f + 0.5f; + s16 halfFov = (not_zero(gCurGraphNodeCamFrustum->fov, gOverrideFOV) / 2.0f + 1.0f) * 32768.0f / 180.0f + 0.5f; f32 divisor = coss(halfFov); if (divisor == 0) { divisor = 1; } diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 9ef11449..855ec667 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -103,11 +103,7 @@ unsigned int configKeyNextPage[MAX_BINDS] = { 0x0018, VK_INVALID, VK_INVALID unsigned int configKeyDisconnect[MAX_BINDS] = { 0x003C, VK_INVALID, VK_INVALID }; unsigned int configStickDeadzone = 16; // 16*DEADZONE_STEP=4960 (the original default deadzone) unsigned int configRumbleStrength = 50; -#ifdef EXTERNAL_DATA -bool configPrecacheRes = false; -#endif -#ifdef BETTERCAMERA -// BetterCamera settings +// better camera settings unsigned int configCameraXSens = 10; unsigned int configCameraYSens = 10; unsigned int configCameraAggr = 0; @@ -118,7 +114,6 @@ bool configCameraInvertY = true; bool configEnableCamera = false; bool configCameraAnalog = false; bool configCameraMouse = false; -#endif bool configSkipIntro = 0; bool configEnableCheats = 0; bool configBubbleDeath = true; @@ -208,10 +203,6 @@ static const struct ConfigOption options[] = { {.name = "key_disconnect", .type = CONFIG_TYPE_BIND, .uintValue = configKeyDisconnect}, {.name = "stick_deadzone", .type = CONFIG_TYPE_UINT, .uintValue = &configStickDeadzone}, {.name = "rumble_strength", .type = CONFIG_TYPE_UINT, .uintValue = &configRumbleStrength}, - #ifdef EXTERNAL_DATA - {.name = "precache", .type = CONFIG_TYPE_BOOL, .boolValue = &configPrecacheRes}, - #endif - #ifdef BETTERCAMERA {.name = "bettercam_enable", .type = CONFIG_TYPE_BOOL, .boolValue = &configEnableCamera}, {.name = "bettercam_analog", .type = CONFIG_TYPE_BOOL, .boolValue = &configCameraAnalog}, {.name = "bettercam_mouse_look", .type = CONFIG_TYPE_BOOL, .boolValue = &configCameraMouse}, @@ -222,7 +213,6 @@ static const struct ConfigOption options[] = { {.name = "bettercam_aggression", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraAggr}, {.name = "bettercam_pan_level", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraPan}, {.name = "bettercam_degrade", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraDegrade}, - #endif {.name = "skip_intro", .type = CONFIG_TYPE_BOOL, .boolValue = &configSkipIntro}, {.name = "enable_cheats", .type = CONFIG_TYPE_BOOL, .boolValue = &configEnableCheats}, // debug diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 6ce283d3..ce808ba4 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -64,10 +64,6 @@ extern unsigned int configStickDeadzone; extern unsigned int configRumbleStrength; extern unsigned int configGamepadNumber; extern bool configBackgroundGamepad; -#ifdef EXTERNAL_DATA -extern bool configPrecacheRes; -#endif -#ifdef BETTERCAMERA extern unsigned int configCameraXSens; extern unsigned int configCameraYSens; extern unsigned int configCameraAggr; @@ -78,7 +74,6 @@ extern bool configCameraInvertY; extern bool configEnableCamera; extern bool configCameraMouse; extern bool configCameraAnalog; -#endif extern bool configHUD; extern bool configSkipIntro; extern bool configEnableCheats; diff --git a/src/pc/controller/controller_sdl1.c b/src/pc/controller/controller_sdl1.c index aef34108..7b2899ac 100644 --- a/src/pc/controller/controller_sdl1.c +++ b/src/pc/controller/controller_sdl1.c @@ -42,9 +42,7 @@ enum { MAX_AXES, }; -#ifdef BETTERCAMERA extern u8 newcam_mouse; -#endif static bool init_ok; static SDL_Joystick *sdl_joy; @@ -126,12 +124,10 @@ static void controller_sdl_init(void) { if (i >= num_joy_axes) joy_axis_binds[i] = -1; } - -#ifdef BETTERCAMERA + if (newcam_mouse == 1) SDL_WM_GrabInput(SDL_GRAB_ON); SDL_GetRelativeMouseState(&mouse_x, &mouse_y); -#endif controller_sdl_bind(); @@ -154,7 +150,6 @@ static inline int16_t get_axis(const int i) { static void controller_sdl_read(OSContPad *pad) { if (!init_ok) return; -#ifdef BETTERCAMERA if (newcam_mouse == 1 && sCurrPlayMode != 2) SDL_WM_GrabInput(SDL_GRAB_ON); else @@ -171,7 +166,6 @@ static void controller_sdl_read(OSContPad *pad) { // remember buttons that changed from 0 to 1 last_mouse = (mouse_buttons ^ mouse) & mouse; mouse_buttons = mouse; -#endif if (!sdl_joy) return; diff --git a/src/pc/controller/controller_sdl2.c b/src/pc/controller/controller_sdl2.c index ea0841e7..21d0b097 100644 --- a/src/pc/controller/controller_sdl2.c +++ b/src/pc/controller/controller_sdl2.c @@ -35,9 +35,7 @@ #define MAX_JOYBUTTONS 32 // arbitrary; includes virtual keys for triggers #define AXIS_THRESHOLD (30 * 256) -#ifdef BETTERCAMERA extern u8 newcam_mouse; -#endif static bool init_ok = false; static bool haptics_enabled = false; @@ -128,11 +126,9 @@ static void controller_sdl_init(void) { free(gcdata); } -#ifdef BETTERCAMERA if (newcam_mouse == 1) SDL_SetRelativeMouseMode(SDL_TRUE); SDL_GetRelativeMouseState(&mouse_x, &mouse_y); -#endif controller_sdl_bind(); @@ -179,7 +175,6 @@ static void controller_sdl_read(OSContPad *pad) { return; } -#ifdef BETTERCAMERA if (!gDjuiHudLockMouse) { if (newcam_mouse == 1 && (!is_game_paused() || sCurrPlayMode != 2) && !gDjuiInMainMenu) { SDL_SetRelativeMouseMode(SDL_TRUE); @@ -200,22 +195,9 @@ static void controller_sdl_read(OSContPad *pad) { // remember buttons that changed from 0 to 1 last_mouse = (mouse_buttons ^ mouse) & mouse; mouse_buttons = mouse; -#endif + if (!ignore_lock && (!is_game_paused() || sCurrPlayMode != 2) && !gDjuiInMainMenu) { SDL_SetRelativeMouseMode(gDjuiHudLockMouse ? SDL_TRUE : SDL_FALSE); - -#ifndef BETTERCAMERA - u32 mouse = SDL_GetRelativeMouseState(&mouse_x, &mouse_y); - - if (!gInteractableOverridePad) { - for (u32 i = 0; i < num_mouse_binds; ++i) - if (mouse & SDL_BUTTON(mouse_binds[i][0])) - pad->button |= mouse_binds[i][1]; - } - // remember buttons that changed from 0 to 1 - last_mouse = (mouse_buttons ^ mouse) & mouse; - mouse_buttons = mouse; -#endif } if (configBackgroundGamepad != sBackgroundGamepad) { diff --git a/src/pc/djui/djui_panel_camera.c b/src/pc/djui/djui_panel_camera.c index e7f35b64..34714226 100644 --- a/src/pc/djui/djui_panel_camera.c +++ b/src/pc/djui/djui_panel_camera.c @@ -15,9 +15,7 @@ void djui_panel_camera_create(struct DjuiBase* caller) { { djui_checkbox_create(body, DLANG(CAMERA, FREE_CAMERA), &configEnableCamera, djui_panel_camera_value_changed); djui_checkbox_create(body, DLANG(CAMERA, ANALOG_CAMERA), &configCameraAnalog, djui_panel_camera_value_changed); -#ifdef BETTERCAMERA djui_checkbox_create(body, DLANG(CAMERA, MOUSE_LOOK), &configCameraMouse, djui_panel_camera_value_changed); -#endif djui_checkbox_create(body, DLANG(CAMERA, INVERT_X), &configCameraInvertX, djui_panel_camera_value_changed); djui_checkbox_create(body, DLANG(CAMERA, INVERT_Y), &configCameraInvertY, djui_panel_camera_value_changed); djui_slider_create(body, DLANG(CAMERA, X_SENSITIVITY), &configCameraXSens, 1, 100, djui_panel_camera_value_changed); diff --git a/src/pc/djui/djui_panel_display.c b/src/pc/djui/djui_panel_display.c index 420a6e7b..610cec88 100644 --- a/src/pc/djui/djui_panel_display.c +++ b/src/pc/djui/djui_panel_display.c @@ -64,10 +64,6 @@ void djui_panel_display_create(struct DjuiBase* caller) { djui_checkbox_create(body, DLANG(DISPLAY, FORCE_4BY3), &configForce4By3, djui_panel_display_apply); - #ifdef EXTERNAL_DATA - djui_checkbox_create(body, DLANG(DISPLAY, PRELOAD_TEXTURES), &configPrecacheRes, NULL); - #endif - djui_checkbox_create(body, DLANG(DISPLAY, VSYNC), &configWindow.vsync, djui_panel_display_apply); djui_checkbox_create(body, DLANG(DISPLAY, UNCAPPED_FRAMERATE), &configUncappedFramerate, djui_panel_display_uncapped_change); diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index 0ddcac92..2afb381c 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -214,15 +214,6 @@ static void gfx_update_loaded_texture(uint8_t tile_number, uint32_t size_bytes, void ext_gfx_run_dl(Gfx* cmd); ////////////////////////////////// -#ifdef EXTERNAL_DATA -static inline size_t string_hash(const uint8_t *str) { - size_t h = 0; - for (const uint8_t *p = str; *p; p++) - h = 31 * h + *p; - return h; -} -#endif - static unsigned long get_time(void) { return 0; } @@ -370,13 +361,8 @@ void gfx_texture_cache_clear(void) { } static bool gfx_texture_cache_lookup(int tile, struct TextureHashmapNode **n, const uint8_t *orig_addr, uint32_t fmt, uint32_t siz) { - #ifdef EXTERNAL_DATA // hash and compare the data (i.e. the texture name) itself - size_t hash = string_hash(orig_addr); - #define CMPADDR(x, y) (x && !sys_strcasecmp((const char *)x, (const char *)y)) - #else // hash and compare the address size_t hash = (uintptr_t)orig_addr; #define CMPADDR(x, y) x == y - #endif hash = (hash >> HASH_SHIFT) & HASH_MASK; @@ -595,102 +581,6 @@ static void import_texture_ci8(int tile) { gfx_rapi->upload_texture(rgba32_buf, width, height); } - -#ifdef EXTERNAL_DATA - -static inline void load_texture(const char *fullpath) { - int w, h; - u64 imgsize = 0; - - u8 *imgdata = fs_load_file(fullpath, (uint64_t*) &imgsize); - if (imgdata) { - // TODO: implement stbi_callbacks or some shit instead of loading the whole texture - u8 *data = stbi_load_from_memory(imgdata, imgsize, &w, &h, NULL, 4); - free(imgdata); - if (data) { - gfx_rapi->upload_texture(data, w, h); - stbi_image_free(data); // don't need this anymore - return; - } - } - - fprintf(stderr, "Could not load texture: `%s`\n", fullpath); - // replace with missing texture - gfx_rapi->upload_texture(missing_texture, MISSING_W, MISSING_H); -} - - -// this is taken straight from n64graphics -static bool texname_to_texformat(const char *name, u8 *fmt, u8 *siz) { - static const struct { - const char *name; - const u8 format; - const u8 size; - } fmt_table[] = { - { "rgba16", G_IM_FMT_RGBA, G_IM_SIZ_16b }, - { "rgba32", G_IM_FMT_RGBA, G_IM_SIZ_32b }, - { "ia1", G_IM_FMT_IA, G_IM_SIZ_8b }, // uhh - { "ia4", G_IM_FMT_IA, G_IM_SIZ_4b }, - { "ia8", G_IM_FMT_IA, G_IM_SIZ_8b }, - { "ia16", G_IM_FMT_IA, G_IM_SIZ_16b }, - { "i4", G_IM_FMT_I, G_IM_SIZ_4b }, - { "i8", G_IM_FMT_I, G_IM_SIZ_8b }, - { "ci8", G_IM_FMT_I, G_IM_SIZ_8b }, - { "ci16", G_IM_FMT_I, G_IM_SIZ_16b }, - }; - - char *fstr = strrchr(name, '.'); - if (!fstr) return false; // no format string? - fstr++; - - for (unsigned i = 0; i < sizeof(fmt_table) / sizeof(fmt_table[0]); ++i) { - if (!sys_strcasecmp(fstr, fmt_table[i].name)) { - *fmt = fmt_table[i].format; - *siz = fmt_table[i].size; - return true; - } - } - - return false; -} - -// calls import_texture() on every texture in the res folder -// we can get the format and size from the texture files -// and then cache them using gfx_texture_cache_lookup -static bool preload_texture(UNUSED void *user, const char *path) { - // strip off the extension - char texname[SYS_MAX_PATH]; - strncpy(texname, path, sizeof(texname)); - texname[sizeof(texname)-1] = 0; - char *dot = strrchr(texname, '.'); - if (dot) *dot = 0; - - // get the format and size from filename - u8 fmt, siz; - if (!texname_to_texformat(texname, &fmt, &siz)) { - fprintf(stderr, "Unknown texture format: `%s`, skipping\n", texname); - return true; // just skip it, might be a stray skybox or something - } - - char *actualname = texname; - // strip off the prefix // TODO: make a fs_ function for this shit - if (!strncmp(FS_TEXTUREDIR "/", actualname, 4)) actualname += 4; - // this will be stored in the hashtable, so make a copy - actualname = sys_strdup(actualname); - assert(actualname); - - struct TextureHashmapNode *n; - if (!gfx_texture_cache_lookup(0, &n, (unsigned char*)actualname, fmt, siz)) { - //fprintf(stdout, "Loading new texture: `%s.`\n", actualname); - load_texture(path); // new texture, load it - } - - - return true; -} - -#endif // EXTERNAL_DATA - static void import_texture(int tile) { extern s32 dynos_tex_import(void **output, void *ptr, s32 tile, void *grapi, void **hashmap, void *pool, s32 *poolpos, s32 poolsize); if (dynos_tex_import((void **) &rendering_state.textures[tile], (void *) rdp.loaded_texture[tile].addr, tile, gfx_rapi, (void **) gfx_texture_cache.hashmap, (void *) gfx_texture_cache.pool, (int *) &gfx_texture_cache.pool_pos, MAX_CACHED_TEXTURES)) { return; } @@ -707,30 +597,6 @@ static void import_texture(int tile) { return; } -#ifdef EXTERNAL_DATA - // the "texture data" is actually a C string with the path to our texture in it - // load it from an external image in our data path - const char* texid = (const char*)rdp.loaded_texture[tile].addr; - - // make sure the texture id is a printable ascii string - bool texidIsPrintable = true; - char* c = (char*)texid; - u16 length = 0; - while (c != NULL && *c != '\0') { - if (*c < 33 || *c > 126) { - texidIsPrintable = false; - break; - } - length++; - c++; - } - if (texidIsPrintable && length > 0) { - char texname[SYS_MAX_PATH]; - snprintf(texname, sizeof(texname), FS_TEXTUREDIR "/%s.png", texid); - load_texture(texname); - return; - } -#endif // the texture data is actual texture data //int t0 = get_time(); if (fmt == G_IM_FMT_RGBA) { @@ -1914,13 +1780,6 @@ void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, co gfx_cc_precomp(); } -#ifdef EXTERNAL_DATA -void gfx_precache_textures(void) { - // preload all textures - fs_walk(FS_TEXTUREDIR, preload_texture, NULL, true); -} -#endif - struct GfxRenderingAPI *gfx_get_current_rendering_api(void) { return gfx_rapi; } diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 4965b933..a82b3296 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -305,163 +305,103 @@ void camera_allow_toxic_gas_camera(u8 allow) { } bool camera_config_is_free_cam_enabled(void) { -#ifdef BETTERCAMERA return sOverrideEnableCamera.override ? sOverrideEnableCamera.value : configEnableCamera; -#else - return false; -#endif } bool camera_config_is_analog_cam_enabled(void) { -#ifdef BETTERCAMERA return sOverrideCameraAnalog.override ? sOverrideCameraAnalog.value : configCameraAnalog; -#else - return false; -#endif } bool camera_config_is_mouse_look_enabled(void) { -#ifdef BETTERCAMERA return sOverrideCameraMouse.override ? sOverrideCameraMouse.value : configCameraMouse; -#else - return false; -#endif } bool camera_config_is_x_inverted(void) { -#ifdef BETTERCAMERA return sOverrideCameraInvertX.override ? sOverrideCameraInvertX.value : configCameraInvertX; -#else - return false; -#endif } bool camera_config_is_y_inverted(void) { -#ifdef BETTERCAMERA return sOverrideCameraInvertY.override ? sOverrideCameraInvertY.value : configCameraInvertY; -#else - return false; -#endif } u32 camera_config_get_x_sensitivity(void) { -#ifdef BETTERCAMERA return sOverrideCameraXSens.override ? sOverrideCameraXSens.value : configCameraXSens; -#else - return 0; -#endif } u32 camera_config_get_y_sensitivity(void) { -#ifdef BETTERCAMERA return sOverrideCameraYSens.override ? sOverrideCameraYSens.value : configCameraYSens; -#else - return 0; -#endif } u32 camera_config_get_aggression(void) { -#ifdef BETTERCAMERA return sOverrideCameraAggr.override ? sOverrideCameraAggr.value : configCameraAggr; -#else - return 0; -#endif } u32 camera_config_get_pan_level(void) { -#ifdef BETTERCAMERA return sOverrideCameraPan.override ? sOverrideCameraPan.value : configCameraPan; -#else - return 0; -#endif } u32 camera_config_get_deceleration(void) { -#ifdef BETTERCAMERA return sOverrideCameraDegrade.override ? sOverrideCameraDegrade.value : configCameraDegrade; -#else - return 0; -#endif } void camera_config_enable_free_cam(bool enable) { -#ifdef BETTERCAMERA sOverrideEnableCamera.value = enable; sOverrideEnableCamera.override = true; newcam_init_settings(); -#endif } void camera_config_enable_analog_cam(bool enable) { -#ifdef BETTERCAMERA sOverrideCameraAnalog.value = enable; sOverrideCameraAnalog.override = true; newcam_init_settings(); -#endif } void camera_config_enable_mouse_look(bool enable) { -#ifdef BETTERCAMERA sOverrideCameraMouse.value = enable; sOverrideCameraMouse.override = true; newcam_init_settings(); -#endif } void camera_config_invert_x(bool invert) { -#ifdef BETTERCAMERA sOverrideCameraInvertX.value = invert; sOverrideCameraInvertX.override = true; newcam_init_settings(); -#endif } void camera_config_invert_y(bool invert) { -#ifdef BETTERCAMERA sOverrideCameraInvertY.value = invert; sOverrideCameraInvertY.override = true; newcam_init_settings(); -#endif } void camera_config_set_x_sensitivity(u32 value) { -#ifdef BETTERCAMERA sOverrideCameraXSens.value = MIN(MAX(value, 1), 100); sOverrideCameraXSens.override = true; newcam_init_settings(); -#endif } void camera_config_set_y_sensitivity(u32 value) { -#ifdef BETTERCAMERA sOverrideCameraYSens.value = MIN(MAX(value, 1), 100); sOverrideCameraYSens.override = true; newcam_init_settings(); -#endif } void camera_config_set_aggression(u32 value) { -#ifdef BETTERCAMERA sOverrideCameraAggr.value = MIN(MAX(value, 0), 100); sOverrideCameraAggr.override = true; newcam_init_settings(); -#endif } void camera_config_set_pan_level(u32 value) { -#ifdef BETTERCAMERA sOverrideCameraPan.value = MIN(MAX(value, 0), 100); sOverrideCameraPan.override = true; newcam_init_settings(); -#endif } void camera_config_set_deceleration(u32 value) { -#ifdef BETTERCAMERA sOverrideCameraDegrade.value = MIN(MAX(value, 0), 100); sOverrideCameraDegrade.override = true; newcam_init_settings(); -#endif } /// diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 81deaf20..1e275f6a 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -329,15 +329,6 @@ void main_func(void) { network_init(NT_NONE, false); } -#ifdef EXTERNAL_DATA - // precache data if needed - if (configPrecacheRes) { - fprintf(stdout, "precaching data\n"); - fflush(stdout); - gfx_precache_textures(); - } -#endif - gGameInited = true; while (true) {