diff --git a/include/sm64.h b/include/sm64.h index 87c16546..5b9deb8f 100644 --- a/include/sm64.h +++ b/include/sm64.h @@ -54,7 +54,7 @@ #define INPUT_OFF_FLOOR 0x0004 #define INPUT_ABOVE_SLIDE 0x0008 #define INPUT_FIRST_PERSON 0x0010 -#define INPUT_UNKNOWN_5 0x0020 +#define INPUT_ZERO_MOVEMENT 0x0020 #define INPUT_SQUISHED 0x0040 #define INPUT_A_DOWN 0x0080 #define INPUT_IN_POISON_GAS 0x0100 diff --git a/src/game/bettercamera.inc.h b/src/game/bettercamera.inc.h index 46a26fcc..884ffaf7 100644 --- a/src/game/bettercamera.inc.h +++ b/src/game/bettercamera.inc.h @@ -643,9 +643,11 @@ static void newcam_stick_input(void) { //Main loop. void newcam_loop(struct Camera *c) { - newcam_stick_input(); - newcam_rotate_button(); - newcam_zoom_button(); + if (sCurrPlayMode != PLAY_MODE_PAUSED) { + newcam_stick_input(); + newcam_rotate_button(); + newcam_zoom_button(); + } newcam_position_cam(); newcam_find_fixed(); if (gMarioObject) diff --git a/src/game/camera.c b/src/game/camera.c index 196165b2..53814e8c 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -1183,11 +1183,11 @@ void mode_8_directions_camera(struct Camera *c) { radial_camera_input(c, 0.f); - if (gPlayer1Controller->buttonPressed & R_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & R_CBUTTONS) { s8DirModeYawOffset += DEGREES(45); play_sound_cbutton_side(); } - if (gPlayer1Controller->buttonPressed & L_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & L_CBUTTONS) { s8DirModeYawOffset -= DEGREES(45); play_sound_cbutton_side(); } @@ -2499,7 +2499,7 @@ s32 update_slide_or_0f_camera(UNUSED struct Camera *c, Vec3f focus, Vec3f pos) { } static UNUSED void unused_mode_0f_camera(struct Camera *c) { - if (gPlayer1Controller->buttonPressed & U_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & U_CBUTTONS) { gCameraMovementFlags |= CAM_MOVE_C_UP_MODE; } c->nextYaw = update_slide_camera(c); @@ -2514,7 +2514,7 @@ void mode_slide_camera(struct Camera *c) { sMarioGeometry.currFloorType == SURFACE_NO_CAM_COL_SLIPPERY) { mode_lakitu_camera(c); } else { - if (gPlayer1Controller->buttonPressed & U_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & U_CBUTTONS) { gCameraMovementFlags |= CAM_MOVE_C_UP_MODE; } c->nextYaw = update_slide_camera(c); @@ -2767,7 +2767,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 ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & (A_BUTTON | B_BUTTON | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS)) { exit_c_up(c); } return 0; @@ -2792,7 +2792,7 @@ void mode_cannon_camera(struct Camera *c) { sLakituPitch = 0; gCameraMovementFlags &= ~CAM_MOVING_INTO_MODE; c->nextYaw = update_in_cannon(c, c->focus, c->pos); - if (gPlayer1Controller->buttonPressed & A_BUTTON) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & A_BUTTON) { set_camera_mode(c, CAMERA_MODE_BEHIND_MARIO, 1); sPanDistance = 0.f; sCannonYOffset = 0.f; @@ -3037,7 +3037,7 @@ void update_camera(struct Camera *c) { && c->mode != CAMERA_MODE_NEWCAM #endif ) { - if (gPlayer1Controller->buttonPressed & R_TRIG) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & R_TRIG) { if (set_cam_angle(0) == CAM_ANGLE_LAKITU) { set_cam_angle(CAM_ANGLE_MARIO); } else { @@ -3214,7 +3214,7 @@ void update_camera(struct Camera *c) { || (sMarioCamState->action) == ACT_GETTING_BLOWN) { // If this is the first frame that R_TRIG is held, play the "click" sound - if (c->cutscene == 0 && (gPlayer1Controller->buttonPressed & R_TRIG) + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && c->cutscene == 0 && (gPlayer1Controller->buttonPressed & R_TRIG) && cam_select_alt_mode(0) == CAM_SELECTION_FIXED) { sCameraSoundFlags |= CAM_SOUND_FIXED_ACTIVE; play_sound_rbutton_changed(); @@ -3236,7 +3236,7 @@ void update_camera(struct Camera *c) { } } } else { - if ((gPlayer1Controller->buttonPressed & R_TRIG) && cam_select_alt_mode(0) == CAM_SELECTION_FIXED) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && (gPlayer1Controller->buttonPressed & R_TRIG) && cam_select_alt_mode(0) == CAM_SELECTION_FIXED) { play_sound_button_change_blocked(); } } @@ -3895,6 +3895,7 @@ void shake_camera_handheld(Vec3f pos, Vec3f focus) { * Updates C Button input state and stores it in `currentState` */ s32 find_c_buttons_pressed(u16 currentState, u16 buttonsPressed, u16 buttonsDown) { + if (sCurrPlayMode == PLAY_MODE_PAUSED) { return 0; } buttonsPressed &= CBUTTON_MASK; buttonsDown &= CBUTTON_MASK; @@ -4903,7 +4904,7 @@ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) { if ((gCameraMovementFlags & CAM_MOVE_ENTERED_ROTATE_SURFACE) || !(gCameraMovementFlags & CAM_MOVE_ROTATE)) { // If C-L or C-R are pressed, the camera is rotating - if (gPlayer1Controller->buttonPressed & (L_CBUTTONS | R_CBUTTONS)) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & (L_CBUTTONS | R_CBUTTONS)) { gCameraMovementFlags &= ~CAM_MOVE_ENTERED_ROTATE_SURFACE; // @bug this does not clear the rotation flags set by the surface. It's possible to set // both ROTATE_LEFT and ROTATE_RIGHT, locking the camera. @@ -4912,7 +4913,7 @@ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) { } // Rotate Right and left - if (gPlayer1Controller->buttonPressed & R_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & R_CBUTTONS) { if (sModeOffsetYaw > -0x800) { // The camera is now rotating right if (!(gCameraMovementFlags & CAM_MOVE_ROTATE_RIGHT)) { @@ -4942,7 +4943,7 @@ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) { play_sound_cbutton_up(); } } - if (gPlayer1Controller->buttonPressed & L_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & L_CBUTTONS) { if (sModeOffsetYaw < 0x800) { if (!(gCameraMovementFlags & CAM_MOVE_ROTATE_LEFT)) { gCameraMovementFlags |= CAM_MOVE_ROTATE_LEFT; @@ -4974,7 +4975,7 @@ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) { } // Zoom in / enter C-Up - if (gPlayer1Controller->buttonPressed & U_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & U_CBUTTONS) { if (gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT) { gCameraMovementFlags &= ~CAM_MOVE_ZOOMED_OUT; play_sound_cbutton_up(); @@ -4984,7 +4985,7 @@ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) { } // Zoom out - if (gPlayer1Controller->buttonPressed & D_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & D_CBUTTONS) { if (gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT) { gCameraMovementFlags |= CAM_MOVE_ALREADY_ZOOMED_OUT; #ifndef VERSION_JP @@ -5022,7 +5023,7 @@ void handle_c_button_movement(struct Camera *c) { s16 cSideYaw; // Zoom in - if (gPlayer1Controller->buttonPressed & U_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & U_CBUTTONS) { if (c->mode != CAMERA_MODE_FIXED && (gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT)) { gCameraMovementFlags &= ~CAM_MOVE_ZOOMED_OUT; play_sound_cbutton_up(); @@ -5037,7 +5038,7 @@ void handle_c_button_movement(struct Camera *c) { } if (c->mode != CAMERA_MODE_FIXED) { // Zoom out - if (gPlayer1Controller->buttonPressed & D_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & D_CBUTTONS) { if (gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT) { gCameraMovementFlags |= CAM_MOVE_ALREADY_ZOOMED_OUT; sZoomAmount = gCameraZoomDist + 400.f; @@ -5053,7 +5054,7 @@ void handle_c_button_movement(struct Camera *c) { // Rotate left or right cSideYaw = 0x1000; - if (gPlayer1Controller->buttonPressed & R_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & R_CBUTTONS) { if (gCameraMovementFlags & CAM_MOVE_ROTATE_LEFT) { gCameraMovementFlags &= ~CAM_MOVE_ROTATE_LEFT; } else { @@ -5064,7 +5065,7 @@ void handle_c_button_movement(struct Camera *c) { sCSideButtonYaw = -cSideYaw; } } - if (gPlayer1Controller->buttonPressed & L_CBUTTONS) { + if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & L_CBUTTONS) { if (gCameraMovementFlags & CAM_MOVE_ROTATE_RIGHT) { gCameraMovementFlags &= ~CAM_MOVE_ROTATE_RIGHT; } else { diff --git a/src/game/level_update.c b/src/game/level_update.c index 0e1c3a2a..497abef8 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1189,7 +1189,7 @@ s32 update_level(void) { changeLevel = play_mode_normal(); break; case PLAY_MODE_PAUSED: - changeLevel = play_mode_paused(); + changeLevel = play_mode_normal() | play_mode_paused(); break; case PLAY_MODE_CHANGE_AREA: changeLevel = play_mode_change_area(); diff --git a/src/game/mario.c b/src/game/mario.c index 40c6d6fb..290840f2 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1317,7 +1317,7 @@ void debug_print_speed_action_normal(struct MarioState *m) { */ void update_mario_button_inputs(struct MarioState *m) { // don't update remote inputs - if (m != &gMarioStates[0]) { return; } + if (m->playerIndex != 0) { return; } if (m->controller->buttonPressed & A_BUTTON) { m->input |= INPUT_A_PRESSED; @@ -1369,7 +1369,7 @@ void update_mario_joystick_inputs(struct MarioState *m) { } // don't update remote inputs past this point - if (m != &gMarioStates[0]) { return; } + if ((sCurrPlayMode == PLAY_MODE_PAUSED) || m->playerIndex != 0) { return; } if (m->intendedMag > 0.0f) { #ifndef BETTERCAMERA @@ -1452,11 +1452,20 @@ void update_mario_inputs(struct MarioState *m) { m->particleFlags = 0; if (m->playerIndex == 0) { m->input = 0; } + u8 localIsPaused = (m->playerIndex == 0) && (sCurrPlayMode == PLAY_MODE_PAUSED); + m->collidedObjInteractTypes = m->marioObj->collidedObjInteractTypes; m->flags &= 0xFFFFFF; update_mario_button_inputs(m); update_mario_joystick_inputs(m); + + // prevent any inputs when paused + if ((m->playerIndex == 0) && (sCurrPlayMode == PLAY_MODE_PAUSED)) { + m->input = 0; + m->intendedMag = 0; + } + update_mario_geometry_inputs(m); debug_print_speed_action_normal(m); @@ -1469,7 +1478,7 @@ void update_mario_inputs(struct MarioState *m) { /*End of moonjump cheat */ if (m->playerIndex == 0) { - if (gCameraMovementFlags & CAM_MOVE_C_UP_MODE) { + if (!localIsPaused && gCameraMovementFlags & CAM_MOVE_C_UP_MODE) { if (m->action & ACT_FLAG_ALLOW_FIRST_PERSON) { m->input |= INPUT_FIRST_PERSON; } else { @@ -1478,7 +1487,7 @@ void update_mario_inputs(struct MarioState *m) { } if (!(m->input & (INPUT_NONZERO_ANALOG | INPUT_A_PRESSED))) { - m->input |= INPUT_UNKNOWN_5; + m->input |= INPUT_ZERO_MOVEMENT; } if (m->marioObj->oInteractStatus diff --git a/src/game/mario_actions_automatic.c b/src/game/mario_actions_automatic.c index 0012a2e8..5e5f9256 100644 --- a/src/game/mario_actions_automatic.c +++ b/src/game/mario_actions_automatic.c @@ -481,7 +481,7 @@ s32 act_hang_moving(struct MarioState *m) { if (is_anim_past_end(m)) { m->actionArg ^= 1; - if (m->input & INPUT_UNKNOWN_5) { + if (m->input & INPUT_ZERO_MOVEMENT) { return set_mario_action(m, ACT_HANGING, m->actionArg); } } diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index c6605fde..67d97a25 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -810,7 +810,7 @@ s32 act_walking(struct MarioState *m) { return TRUE; } - if (m->input & INPUT_UNKNOWN_5) { + if (m->input & INPUT_ZERO_MOVEMENT) { return begin_braking_action(m); } @@ -907,7 +907,7 @@ s32 act_hold_walking(struct MarioState *m) { return set_jumping_action(m, ACT_HOLD_JUMP, 0); } - if (m->input & INPUT_UNKNOWN_5) { + if (m->input & INPUT_ZERO_MOVEMENT) { return set_mario_action(m, ACT_HOLD_DECELERATING, 0); } @@ -949,7 +949,7 @@ s32 act_hold_heavy_walking(struct MarioState *m) { return drop_and_set_mario_action(m, ACT_BEGIN_SLIDING, 0); } - if (m->input & INPUT_UNKNOWN_5) { + if (m->input & INPUT_ZERO_MOVEMENT) { return set_mario_action(m, ACT_HOLD_HEAVY_IDLE, 0); } @@ -982,7 +982,7 @@ s32 act_turning_around(struct MarioState *m) { return set_jumping_action(m, ACT_SIDE_FLIP, 0); } - if (m->input & INPUT_UNKNOWN_5) { + if (m->input & INPUT_ZERO_MOVEMENT) { return set_mario_action(m, ACT_BRAKING, 0); } @@ -1276,7 +1276,7 @@ s32 act_crawling(struct MarioState *m) { return TRUE; } - if (m->input & INPUT_UNKNOWN_5) { + if (m->input & INPUT_ZERO_MOVEMENT) { return set_mario_action(m, ACT_STOP_CRAWLING, 0); } diff --git a/src/game/mario_actions_submerged.c b/src/game/mario_actions_submerged.c index b71cf548..9b1cceb7 100644 --- a/src/game/mario_actions_submerged.c +++ b/src/game/mario_actions_submerged.c @@ -1239,7 +1239,7 @@ static s32 act_metal_water_walking(struct MarioState *m) { return set_mario_action(m, ACT_METAL_WATER_JUMP, 0); } - if (m->input & INPUT_UNKNOWN_5) { + if (m->input & INPUT_ZERO_MOVEMENT) { return set_mario_action(m, ACT_METAL_WATER_STANDING, 0); } @@ -1279,7 +1279,7 @@ static s32 act_hold_metal_water_walking(struct MarioState *m) { return set_mario_action(m, ACT_HOLD_METAL_WATER_JUMP, 0); } - if (m->input & INPUT_UNKNOWN_5) { + if (m->input & INPUT_ZERO_MOVEMENT) { return set_mario_action(m, ACT_HOLD_METAL_WATER_STANDING, 0); } diff --git a/src/pc/network/network.c b/src/pc/network/network.c index b4e80f43..7f047935 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -106,7 +106,7 @@ void network_update(void) { // figure out which update loop to run if (gInsidePainting && sCurrPlayMode == PLAY_MODE_CHANGE_LEVEL) { network_update_inside_painting(); - } else if (sCurrPlayMode == PLAY_MODE_NORMAL) { + } else if (sCurrPlayMode == PLAY_MODE_NORMAL || sCurrPlayMode == PLAY_MODE_PAUSED) { network_update_player(); network_update_objects(); }