diff --git a/enhancements/reonu_cam.patch b/enhancements/reonu_cam.patch new file mode 100644 index 00000000..4e210fe9 --- /dev/null +++ b/enhancements/reonu_cam.patch @@ -0,0 +1,183 @@ +diff --git a/src/game/camera.c b/src/game/camera.c +index 13d3fe2..be49880 100644 +--- a/src/game/camera.c ++++ b/src/game/camera.c +@@ -259,6 +259,7 @@ s16 sCameraSoundFlags; + * Stores what C-Buttons are pressed this frame. + */ + u16 sCButtonsPressed; ++u16 stoppedMovingCamera; + /** + * A copy of gDialogID, the dialog displayed during the cutscene. + */ +@@ -433,6 +434,9 @@ u8 sFramesSinceCutsceneEnded = 0; + * 3 = Dialog doesn't have a response + */ + u8 sCutsceneDialogResponse = 0; ++u8 stickReset = 1; ++u8 cButtonCounter; ++u8 lastCameraMove; + struct PlayerCameraState *sMarioCamState = &gPlayerCameraState[0]; + struct PlayerCameraState *sLuigiCamState = &gPlayerCameraState[1]; + u32 unused8032D008 = 0; +@@ -442,6 +446,9 @@ Vec3f sUnusedModeBasePosition_3 = { 646.0f, 143.0f, -1513.0f }; + Vec3f sUnusedModeBasePosition_4 = { 646.0f, 143.0f, -1513.0f }; + Vec3f sUnusedModeBasePosition_5 = { 646.0f, 143.0f, -1513.0f }; + ++#define MOVED_LEFT 1 ++#define MOVED_RIGHT 2 ++ + s32 update_radial_camera(struct Camera *c, Vec3f, Vec3f); + s32 update_outward_radial_camera(struct Camera *c, Vec3f, Vec3f); + s32 update_behind_mario_camera(struct Camera *c, Vec3f, Vec3f); +@@ -1176,14 +1183,39 @@ void mode_8_directions_camera(struct Camera *c) { + + radial_camera_input(c, 0.f); + +- if (gPlayer1Controller->buttonPressed & R_CBUTTONS) { +- s8DirModeYawOffset += DEGREES(45); +- play_sound_cbutton_side(); +- } +- if (gPlayer1Controller->buttonPressed & L_CBUTTONS) { +- s8DirModeYawOffset -= DEGREES(45); +- play_sound_cbutton_side(); ++ if (gPlayer1Controller->buttonDown & L_CBUTTONS) { ++ s8DirModeYawOffset -= DEGREES(4); ++ cButtonCounter++; ++ stoppedMovingCamera = 0; ++ lastCameraMove = MOVED_LEFT; ++ ++ } ++ else if (gPlayer1Controller->buttonDown & R_CBUTTONS) { ++ s8DirModeYawOffset += DEGREES(4); ++ cButtonCounter++; ++ stoppedMovingCamera = 0; ++ lastCameraMove = MOVED_RIGHT; ++ } ++ else if (gPlayer2Controller->rawStickX) { ++ s8DirModeYawOffset += DEGREES(gPlayer2Controller->rawStickX * 4 / 64); ++ } else { ++ stoppedMovingCamera = 1; ++ } ++ ++ if (stoppedMovingCamera == 1) { ++ if ((cButtonCounter < 5) && (cButtonCounter > 0)) { ++ if (lastCameraMove == MOVED_RIGHT) { ++ s8DirModeYawOffset += DEGREES(45); ++ cButtonCounter = 0; ++ } else { ++ s8DirModeYawOffset -= DEGREES(45); ++ cButtonCounter = 0; ++ } ++ } else { ++ cButtonCounter = 0; ++ } + } ++ + + lakitu_zoom(400.f, 0x900); + c->nextYaw = update_8_directions_camera(c, c->focus, pos); +@@ -2760,7 +2792,7 @@ s32 mode_c_up_camera(struct Camera *c) { + sPanDistance = 0.f; + + // Exit C-Up mode +- if (gPlayer1Controller->buttonPressed & (A_BUTTON | B_BUTTON | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS)) { ++ if ((gPlayer1Controller->buttonPressed & (A_BUTTON | B_BUTTON | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS)) || (gPlayer2Controller->rawStickY < -10)) { + exit_c_up(c); + } + return 0; +@@ -3015,14 +3047,11 @@ void update_camera(struct Camera *c) { + // Only process R_TRIG if 'fixed' is not selected in the menu + if (cam_select_alt_mode(0) == CAM_SELECTION_MARIO) { + if (gPlayer1Controller->buttonPressed & R_TRIG) { +- if (set_cam_angle(0) == CAM_ANGLE_LAKITU) { +- set_cam_angle(CAM_ANGLE_MARIO); +- } else { +- set_cam_angle(CAM_ANGLE_LAKITU); +- } ++ s8DirModeYawOffset = gMarioState->faceAngle[1]-0x8000; ++ play_sound_rbutton_changed(); + } + } +- play_sound_if_cam_switched_to_lakitu_or_mario(); ++ //play_sound_if_cam_switched_to_lakitu_or_mario(); + } + + // Initialize the camera +@@ -3865,7 +3894,7 @@ s32 find_c_buttons_pressed(u16 currentState, u16 buttonsPressed, u16 buttonsDown + currentState &= ~R_CBUTTONS; + } + +- if (buttonsPressed & U_CBUTTONS) { ++ if ((buttonsPressed & U_CBUTTONS)) { + currentState |= U_CBUTTONS; + currentState &= ~D_CBUTTONS; + } +@@ -4816,19 +4845,19 @@ void play_camera_buzz_if_c_sideways(void) { + } + + void play_sound_cbutton_up(void) { +- play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); ++ //play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); + } + + void play_sound_cbutton_down(void) { +- play_sound(SOUND_MENU_CAMERA_ZOOM_OUT, gGlobalSoundSource); ++ //play_sound(SOUND_MENU_CAMERA_ZOOM_OUT, gGlobalSoundSource); + } + + void play_sound_cbutton_side(void) { +- play_sound(SOUND_MENU_CAMERA_TURN, gGlobalSoundSource); ++ //play_sound(SOUND_MENU_CAMERA_TURN, gGlobalSoundSource); + } + + void play_sound_button_change_blocked(void) { +- play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); ++ //play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); + } + + void play_sound_rbutton_changed(void) { +@@ -4925,7 +4954,7 @@ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) { + } + + // Zoom in / enter C-Up +- if (gPlayer1Controller->buttonPressed & U_CBUTTONS) { ++ if (((gPlayer1Controller->buttonPressed & U_CBUTTONS) || (gPlayer2Controller->rawStickY > 40)) && (stickReset)) { + if (gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT) { + gCameraMovementFlags &= ~CAM_MOVE_ZOOMED_OUT; + play_sound_cbutton_up(); +@@ -4935,7 +4964,7 @@ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) { + } + + // Zoom out +- if (gPlayer1Controller->buttonPressed & D_CBUTTONS) { ++ if ((gPlayer1Controller->buttonPressed & D_CBUTTONS) || (gPlayer2Controller->rawStickY < -40)) { + if (gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT) { + gCameraMovementFlags |= CAM_MOVE_ALREADY_ZOOMED_OUT; + #ifndef VERSION_JP +@@ -4946,7 +4975,11 @@ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) { + play_sound_cbutton_down(); + } + } +- ++ if ((gPlayer2Controller->rawStickY > 40) || (gPlayer2Controller->rawStickY < -40)) { ++ stickReset = 0; ++ } else { ++ stickReset = 1; ++ } + //! returning uninitialized variable + return dummy; + } +diff --git a/src/game/hud.c b/src/game/hud.c +index f11b626..003a634 100644 +--- a/src/game/hud.c ++++ b/src/game/hud.c +@@ -506,7 +506,7 @@ void render_hud(void) { + + if (hudDisplayFlags & HUD_DISPLAY_FLAG_CAMERA_AND_POWER) { + render_hud_power_meter(); +- render_hud_camera_status(); ++ //render_hud_camera_status(); + } + + if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER) { diff --git a/include/config.h b/include/config.h index 0e2c915e..4b004a50 100644 --- a/include/config.h +++ b/include/config.h @@ -60,6 +60,8 @@ #define DISABLE_LIVES // Disable AA (Recommended: it changes nothing on emulator, and it makes console run better) #define DISABLE_AA +// Fix instant warp offset not working when warping across different areas +#define INSTANT_WARP_OFFSET_FIX // Uncomment this if you want global star IDs (useful for creating an open world hack ala MVC) //#define GLOBAL_STAR_IDS // Uncomment this if you want to skip the title screen (Super Mario 64 logo) diff --git a/src/game/level_update.c b/src/game/level_update.c index da3cc880..c5f70407 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -29,6 +29,8 @@ #include "course_table.h" #include "rumble_init.h" +#include "config.h" + #define PLAY_MODE_NORMAL 0 #define PLAY_MODE_PAUSED 2 #define PLAY_MODE_CHANGE_AREA 3 @@ -557,7 +559,11 @@ void check_instant_warp(void) { gMarioState->marioObj->oPosX = gMarioState->pos[0]; gMarioState->marioObj->oPosY = gMarioState->pos[1]; gMarioState->marioObj->oPosZ = gMarioState->pos[2]; - + #ifdef INSTANT_WARP_OFFSET_FIX + gMarioObject->header.gfx.pos[0] = gMarioState->pos[0]; + gMarioObject->header.gfx.pos[1] = gMarioState->pos[1]; + gMarioObject->header.gfx.pos[2] = gMarioState->pos[2]; + #endif cameraAngle = gMarioState->area->camera->yaw; change_area(warp->area);