From 2bd08f1719c298bfe0e95ee17abf54d50264dcd1 Mon Sep 17 00:00:00 2001 From: quentin452 <42176772+quentin452@users.noreply.github.com> Date: Thu, 2 May 2024 18:12:37 +0200 Subject: [PATCH] MERGE PR 403 https://github.com/sm64pc/sm64ex/pull/403 --- include/text_options_strings.h.in | 2 ++ src/game/bettercamera.inc.h | 51 ++++++++++++++++++++----------- src/game/options_menu.c | 7 +++-- src/pc/configfile.c | 2 ++ src/pc/configfile.h | 1 + 5 files changed, 42 insertions(+), 21 deletions(-) diff --git a/include/text_options_strings.h.in b/include/text_options_strings.h.in index 411ffed80..c195b0c12 100644 --- a/include/text_options_strings.h.in +++ b/include/text_options_strings.h.in @@ -60,6 +60,7 @@ #define TEXT_OPT_DRAWDIST _("DRAW DISTANCE") #define TEXT_OPT_APPLY _("APPLY") #define TEXT_OPT_RESETWND _("RESET WINDOW") +#define TEXT_OPT_BOWSERCAM _("BOWSER LEVEL 8-WAY CAMERA") #define TEXT_BIND_A _("A BUTTON") #define TEXT_BIND_B _("B BUTTON") @@ -126,6 +127,7 @@ #define TEXT_OPT_DRAWDIST _("Draw Distance") #define TEXT_OPT_APPLY _("Apply") #define TEXT_OPT_RESETWND _("Reset Window") +#define TEXT_OPT_BOWSERCAM _("Bowser Level 8-way Camera") #define TEXT_BIND_A _("A Button") #define TEXT_BIND_B _("B Button") diff --git a/src/game/bettercamera.inc.h b/src/game/bettercamera.inc.h index 7256a1305..f56933922 100644 --- a/src/game/bettercamera.inc.h +++ b/src/game/bettercamera.inc.h @@ -129,6 +129,7 @@ u16 newcam_modeflags; s16 newcam_saved_mode = -1; s16 newcam_saved_defmode = -1; +u8 bowser_cam_changed; /// This is called at every level initialisation. void newcam_init(struct Camera *c, u8 dv) { newcam_tilt = 1500; @@ -138,24 +139,6 @@ void newcam_init(struct Camera *c, u8 dv) { /// This here will dictate what modes the camera will start in at the beginning of a level. Below /// are some examples. switch (gCurrLevelNum) { - case LEVEL_BITDW: - newcam_yaw = 0x4000; - newcam_mode = NC_MODE_8D; - newcam_tilt = 4000; - newcam_distance_target = newcam_distance_values[2]; - break; - case LEVEL_BITFS: - newcam_yaw = 0x4000; - newcam_mode = NC_MODE_8D; - newcam_tilt = 4000; - newcam_distance_target = newcam_distance_values[2]; - break; - case LEVEL_BITS: - newcam_yaw = 0x4000; - newcam_mode = NC_MODE_8D; - newcam_tilt = 4000; - newcam_distance_target = newcam_distance_values[2]; - break; case LEVEL_WF: newcam_yaw = 0x4000; newcam_tilt = 2000; @@ -187,6 +170,15 @@ void newcam_init(struct Camera *c, u8 dv) { newcam_mode = NC_MODE_SLIDE; break; } + if ((gCurrLevelNum == LEVEL_BITDW) || (gCurrLevelNum == LEVEL_BITFS) + || (gCurrLevelNum == LEVEL_BITS)) { + newcam_yaw = 0x4000; + if (configBowserCam) { + newcam_mode = NC_MODE_8D; + } + newcam_tilt = 4000; + newcam_distance_target = newcam_distance_values[2]; + } // clear these out when entering a new level to prevent "camera mode buffering" newcam_saved_defmode = -1; @@ -245,6 +237,29 @@ void newcam_init_settings(void) { newcam_degrade = (f32) configCameraDegrade; newcam_toggle(configEnableCamera); + + if (bowser_cam_changed != configBowserCam) { + bowser_cam_changed = configBowserCam; + if ((gCurrLevelNum == LEVEL_BITDW) || (gCurrLevelNum == LEVEL_BITFS) + || (gCurrLevelNum == LEVEL_BITS)) { + if (configEnableCamera) { + newcam_saved_defmode = -1; + newcam_saved_mode = -1; + if (configBowserCam) { + newcam_yaw = 0x4000; + newcam_mode = NC_MODE_8D; + newcam_tilt = 4000; + newcam_distance_target = newcam_distance_values[2]; + newcam_tilt_acc = 0; + newcam_yaw_acc = 0; + } else { + newcam_mode = NC_MODE_NORMAL; + } + newcam_intendedmode = newcam_mode; + newcam_modeflags = newcam_mode; + } + } + } } /** Mathematic calculations. This stuffs so basic even *I* understand it lol diff --git a/src/game/options_menu.c b/src/game/options_menu.c index 090186428..bac9b6d33 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -58,9 +58,9 @@ static const u8 menuStr[][32] = { }; static const u8 optsCameraStr[][32] = { - { TEXT_OPT_CAMX }, { TEXT_OPT_CAMY }, { TEXT_OPT_INVERTX }, { TEXT_OPT_INVERTY }, - { TEXT_OPT_CAMC }, { TEXT_OPT_CAMP }, { TEXT_OPT_ANALOGUE }, { TEXT_OPT_MOUSE }, - { TEXT_OPT_CAMD }, { TEXT_OPT_CAMON }, + { TEXT_OPT_CAMX }, { TEXT_OPT_CAMY }, { TEXT_OPT_INVERTX }, { TEXT_OPT_INVERTY }, + { TEXT_OPT_CAMC }, { TEXT_OPT_CAMP }, { TEXT_OPT_ANALOGUE }, { TEXT_OPT_MOUSE }, + { TEXT_OPT_CAMD }, { TEXT_OPT_CAMON }, { TEXT_OPT_BOWSERCAM }, }; static const u8 optsVideoStr[][32] = { @@ -201,6 +201,7 @@ static struct Option optsCamera[] = { DEF_OPT_SCROLL(optsCameraStr[4], &configCameraAggr, 0, 100, 1), DEF_OPT_SCROLL(optsCameraStr[5], &configCameraPan, 0, 100, 1), DEF_OPT_SCROLL(optsCameraStr[8], &configCameraDegrade, 0, 100, 1), + DEF_OPT_TOGGLE(optsCameraStr[10], &configBowserCam), }; static struct Option optsControls[] = { diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 6b3fd7401..56d82f5ea 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -87,6 +87,7 @@ bool configCameraInvertY = false; bool configEnableCamera = false; bool configCameraAnalog = true; bool configCameraMouse = false; +bool configBowserCam = true; bool configSkipIntro = 0; bool configHUD = true; unsigned int configDrawDistance = 100; @@ -140,6 +141,7 @@ 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 }, + { .name = "bettercam_bowser_cam", .type = CONFIG_TYPE_BOOL, .boolValue = &configBowserCam }, { .name = "skip_intro", .type = CONFIG_TYPE_BOOL, .boolValue = &configSkipIntro }, #ifdef DISCORDRPC { .name = "discordrpc_enable", .type = CONFIG_TYPE_BOOL, .boolValue = &configDiscordRPC }, diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 7376c5fd0..ece8a2d17 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -53,6 +53,7 @@ extern bool configCameraInvertY; extern bool configEnableCamera; extern bool configCameraMouse; extern bool configCameraAnalog; +extern bool configBowserCam; extern bool configHUD; extern unsigned int configDrawDistance; extern bool configSkipIntro;