This commit is contained in:
AltimorTASDK 2023-10-12 20:21:01 -04:00 committed by GitHub
commit ad2c46b459
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 235 additions and 220 deletions

View file

@ -426,12 +426,12 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius) {
f32 avgY;
f32 minY = -radius * 3;
point0[0] = pos[0] + radius * sins(yaw + 0x2AAA);
point0[2] = pos[2] + radius * coss(yaw + 0x2AAA);
point1[0] = pos[0] + radius * sins(yaw + 0x8000);
point1[2] = pos[2] + radius * coss(yaw + 0x8000);
point2[0] = pos[0] + radius * sins(yaw + 0xD555);
point2[2] = pos[2] + radius * coss(yaw + 0xD555);
point0[0] = pos[0] + radius * sins(yaw + DEGREES(60));
point0[2] = pos[2] + radius * coss(yaw + DEGREES(60));
point1[0] = pos[0] + radius * sins(yaw + DEGREES(180));
point1[2] = pos[2] + radius * coss(yaw + DEGREES(180));
point2[0] = pos[0] + radius * sins(yaw + DEGREES(300));
point2[2] = pos[2] + radius * coss(yaw + DEGREES(300));
point0[1] = find_floor(point0[0], pos[1] + 150, point0[2], &sp74);
point1[1] = find_floor(point1[0], pos[1] + 150, point1[2], &sp74);
@ -718,14 +718,14 @@ s16 atan2s(f32 y, f32 x) {
if (y >= x) {
ret = atan2_lookup(x, y);
} else {
ret = 0x4000 - atan2_lookup(y, x);
ret = DEGREES(90) - atan2_lookup(y, x);
}
} else {
y = -y;
if (y < x) {
ret = 0x4000 + atan2_lookup(y, x);
ret = DEGREES(90) + atan2_lookup(y, x);
} else {
ret = 0x8000 - atan2_lookup(x, y);
ret = DEGREES(180) - atan2_lookup(x, y);
}
}
} else {
@ -733,13 +733,13 @@ s16 atan2s(f32 y, f32 x) {
if (y < 0) {
y = -y;
if (y >= x) {
ret = 0x8000 + atan2_lookup(x, y);
ret = DEGREES(180) + atan2_lookup(x, y);
} else {
ret = 0xC000 - atan2_lookup(y, x);
ret = DEGREES(270) - atan2_lookup(y, x);
}
} else {
if (y < x) {
ret = 0xC000 + atan2_lookup(y, x);
ret = DEGREES(270) + atan2_lookup(y, x);
} else {
ret = -atan2_lookup(x, y);
}

View file

@ -5,6 +5,26 @@
#include "types.h"
#define COS_1 0.99984770f
#define COS_5 0.99619470f
#define COS_10 0.98480770f
#define COS_15 0.96592580f
#define COS_20 0.93969260f
#define COS_25 0.90630780f
#define COS_30 0.86602540f
#define COS_38 0.78801080f
#define COS_60 0.50000000f
#define COS_73 0.29237170f
#define COS_80 0.17364818f
#define COS_90 0.00000000f
/**
* Converts an angle in degrees to sm64's s16 angle units. For example, DEGREES(90) == 0x4000
* This should be used mainly to make math, physics, action, and camera code clearer at first glance.
* Shouldn't be used for angular velocities which are often small arbitrary s16 values.
*/
#define DEGREES(x) (int)((x) * 0x10000 / 360)
/*
* The sine and cosine tables overlap, but "#define gCosineTable (gSineTable +
* 0x400)" doesn't give expected codegen; gSineTable and gCosineTable need to

View file

@ -808,7 +808,7 @@ s16 look_down_slopes(s16 camYaw) {
struct Surface *floor;
f32 floorDY;
// Default pitch
s16 pitch = 0x05B0;
s16 pitch = DEGREES(8);
// x and z offsets towards the camera
f32 xOff = sMarioCamState->pos[0] + sins(camYaw) * 40.f;
f32 zOff = sMarioCamState->pos[2] + coss(camYaw) * 40.f;
@ -818,7 +818,7 @@ s16 look_down_slopes(s16 camYaw) {
if (floor != NULL) {
if (floor->type != SURFACE_WALL_MISC && floorDY > 0) {
if (floor->normal.z == 0.f && floorDY < 100.f) {
pitch = 0x05B0;
pitch = DEGREES(8);
} else {
// Add the slope's angle of declination to the pitch
pitch += atan2s(40.f, floorDY);
@ -848,7 +848,7 @@ void pan_ahead_of_player(struct Camera *c) {
vec3f_get_dist_and_angle(c->pos, sMarioCamState->pos, &dist, &pitch, &yaw);
// The camera will pan ahead up to about 30% of the camera's distance to Mario.
pan[2] = sins(0xC00) * dist;
pan[2] = sins(DEGREES(16.875)) * dist;
rotate_in_xz(pan, pan, sMarioCamState->faceAngle[1]);
// rotate in the opposite direction
@ -1073,11 +1073,11 @@ void radial_camera_move(struct Camera *c) {
}
// Bound sModeOffsetYaw within (-120, 120) degrees
if (sModeOffsetYaw > 0x5554) {
sModeOffsetYaw = 0x5554;
if (sModeOffsetYaw >= DEGREES(120)) {
sModeOffsetYaw = DEGREES(120) - 1;
}
if (sModeOffsetYaw < -0x5554) {
sModeOffsetYaw = -0x5554;
if (sModeOffsetYaw <= DEGREES(-120)) {
sModeOffsetYaw = DEGREES(-120) + 1;
}
}
@ -1153,7 +1153,7 @@ void mode_radial_camera(struct Camera *c) {
radial_camera_move(c);
if (c->mode == CAMERA_MODE_RADIAL) {
lakitu_zoom(400.f, 0x900);
lakitu_zoom(400.f, DEGREES(12.65625));
}
c->nextYaw = update_radial_camera(c, c->focus, pos);
c->pos[0] = pos[0];
@ -1185,7 +1185,7 @@ void mode_8_directions_camera(struct Camera *c) {
play_sound_cbutton_side();
}
lakitu_zoom(400.f, 0x900);
lakitu_zoom(400.f, DEGREES(12.65625));
c->nextYaw = update_8_directions_camera(c, c->focus, pos);
c->pos[0] = pos[0];
c->pos[2] = pos[2];
@ -1227,7 +1227,7 @@ void mode_outward_radial_camera(struct Camera *c) {
}
radial_camera_input_default(c);
radial_camera_move(c);
lakitu_zoom(400.f, 0x900);
lakitu_zoom(400.f, DEGREES(12.65625));
c->nextYaw = update_outward_radial_camera(c, c->focus, pos);
c->pos[0] = pos[0];
c->pos[2] = pos[2];
@ -1831,7 +1831,7 @@ s32 update_behind_mario_camera(struct Camera *c, Vec3f focus, Vec3f pos) {
if (dist < maxDist) {
camera_approach_f32_symmetric_bool(&dist, maxDist, 5.f);
}
goalYawOff = -0x3FF8;
goalYawOff = DEGREES(-90) + 0x8;
sCSideButtonYaw = 30;
yawSpeed = 2;
}
@ -1843,7 +1843,7 @@ s32 update_behind_mario_camera(struct Camera *c, Vec3f focus, Vec3f pos) {
if (dist < maxDist) {
camera_approach_f32_symmetric_bool(&dist, maxDist, 5.f);
}
goalYawOff = 0x3FF8;
goalYawOff = DEGREES(90) - 0x8;
sCSideButtonYaw = 30;
yawSpeed = 2;
}
@ -1855,7 +1855,7 @@ s32 update_behind_mario_camera(struct Camera *c, Vec3f focus, Vec3f pos) {
if (dist < maxDist) {
camera_approach_f32_symmetric_bool(&dist, maxDist, 5.f);
}
goalPitch = -0x3000;
goalPitch = DEGREES(-67.5);
sBehindMarioSoundTimer = 30;
pitchInc = 0x800;
}
@ -1867,7 +1867,7 @@ s32 update_behind_mario_camera(struct Camera *c, Vec3f focus, Vec3f pos) {
if (dist < maxDist) {
camera_approach_f32_symmetric_bool(&dist, maxDist, 5.f);
}
goalPitch = 0x3000;
goalPitch = DEGREES(67.5);
sBehindMarioSoundTimer = 30;
pitchInc = 0x800;
}
@ -1957,7 +1957,7 @@ s16 update_slide_camera(struct Camera *c) {
s16 camPitch;
s16 camYaw;
UNUSED struct MarioState *marioState = &gMarioStates[0];
s16 goalPitch = 0x1555;
s16 goalPitch = DEGREES(30);
s16 goalYaw = sMarioCamState->faceAngle[1] + DEGREES(180);
// Zoom in when inside the CCM shortcut
@ -1980,7 +1980,7 @@ s16 update_slide_camera(struct Camera *c) {
// In hoot mode, zoom further out and rotate faster
if (sMarioCamState->action == ACT_RIDING_HOOT) {
maxCamDist = 1000.f;
goalPitch = 0x2800;
goalPitch = DEGREES(56.25);
camera_approach_s16_symmetric_bool(&camYaw, goalYaw, 0x100);
} else {
camera_approach_s16_symmetric_bool(&camYaw, goalYaw, 0x80);
@ -1998,7 +1998,7 @@ s16 update_slide_camera(struct Camera *c) {
if (pitchScale > 1.f) {
pitchScale = 1.f;
}
camPitch += 0x1000 * pitchScale;
camPitch += DEGREES(22.5) * pitchScale;
vec3f_set_dist_and_angle(c->pos, c->focus, distCamToFocus, camPitch, camYaw);
// Slide mode
@ -2045,7 +2045,7 @@ void mode_water_surface_camera(struct Camera *c) {
*/
s32 update_mario_camera(UNUSED struct Camera *c, Vec3f focus, Vec3f pos) {
s16 yaw = sMarioCamState->faceAngle[1] + sModeOffsetYaw + DEGREES(180);
focus_on_mario(focus, pos, 125.f, 125.f, gCameraZoomDist, 0x05B0, yaw);
focus_on_mario(focus, pos, 125.f, 125.f, gCameraZoomDist, DEGREES(8), yaw);
return sMarioCamState->faceAngle[1];
}
@ -2163,7 +2163,7 @@ s16 update_default_camera(struct Camera *c) {
if (xzDist >= 250) {
sStatusFlags &= ~CAM_FLAG_BEHIND_MARIO_POST_DOOR;
}
if (ABS((sMarioCamState->faceAngle[1] - yaw) / 2) < 0x1800) {
if (ABS((sMarioCamState->faceAngle[1] - yaw) / 2) < DEGREES(33.75)) {
sStatusFlags &= ~CAM_FLAG_BEHIND_MARIO_POST_DOOR;
yaw = sCameraYawAfterDoorCutscene + DEGREES(180);
dist = 800.f;
@ -2617,9 +2617,9 @@ s32 exit_c_up(struct Camera *c) {
if (searching == 1) {
checkYaw = -checkYaw;
if (checkYaw < 0) {
checkYaw -= 0x1000;
checkYaw -= DEGREES(22.5);
} else {
checkYaw += 0x1000;
checkYaw += DEGREES(22.5);
}
}
}
@ -2666,20 +2666,20 @@ void move_mario_head_c_up(UNUSED struct Camera *c) {
sModeOffsetYaw -= (s16)(gPlayer1Controller->stickX * 10.f);
// Bound looking up to nearly 80 degrees.
if (sCUpCameraPitch > 0x38E3) {
sCUpCameraPitch = 0x38E3;
if (sCUpCameraPitch > DEGREES(80)) {
sCUpCameraPitch = DEGREES(80);
}
// Bound looking down to -45 degrees
if (sCUpCameraPitch < -0x2000) {
sCUpCameraPitch = -0x2000;
if (sCUpCameraPitch < DEGREES(-45)) {
sCUpCameraPitch = DEGREES(-45);
}
// Bound the camera yaw to +-120 degrees
if (sModeOffsetYaw > 0x5555) {
sModeOffsetYaw = 0x5555;
if (sModeOffsetYaw > DEGREES(120)) {
sModeOffsetYaw = DEGREES(120);
}
if (sModeOffsetYaw < -0x5555) {
sModeOffsetYaw = -0x5555;
if (sModeOffsetYaw < DEGREES(-120)) {
sModeOffsetYaw = DEGREES(-120);
}
// Give Mario's neck natural-looking constraints
@ -4297,8 +4297,8 @@ s16 reduce_by_dist_from_camera(s16 value, f32 maxDist, f32 posX, f32 posY, f32 p
maxDist = 2000.f;
}
result = value * (1.f - dist / maxDist);
if (pitch < -0x1800 || pitch > 0x400 ||
yaw < -0x1800 || yaw > 0x1800) {
if (pitch < DEGREES(-33.75) || pitch > DEGREES(5.625) ||
yaw < DEGREES(-33.75) || yaw > DEGREES(33.75)) {
result /= 2;
}
}
@ -4751,7 +4751,7 @@ s32 offset_yaw_outward_radial(struct Camera *c, s16 areaYaw) {
areaCenter[2] = c->areaCenZ;
distFromAreaCenter = calc_abs_dist(areaCenter, sMarioCamState->pos);
if (800.f > distFromAreaCenter) {
yawGoal = 0x3800;
yawGoal = DEGREES(78.75);
}
break;
case AREA_SSL_PYRAMID:
@ -4778,7 +4778,7 @@ s32 offset_yaw_outward_radial(struct Camera *c, s16 areaYaw) {
}
// When the final yaw is out of [-60,60] degrees, approach yawGoal faster than dYaw will ever be,
// making the camera lock in one direction until yawGoal drops below 60 (or Mario presses a C button)
if (yaw < -DEGREES(60)) {
if (yaw < DEGREES(-60)) {
//! Maybe they meant to reverse yawGoal's sign?
camera_approach_s16_symmetric_bool(&yaw, -yawGoal, 0x200);
}
@ -4874,7 +4874,7 @@ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) {
// Rotate Right and left
if (gPlayer1Controller->buttonPressed & R_CBUTTONS) {
if (sModeOffsetYaw > -0x800) {
if (sModeOffsetYaw > DEGREES(-11.25)) {
// The camera is now rotating right
if (!(gCameraMovementFlags & CAM_MOVE_ROTATE_RIGHT)) {
gCameraMovementFlags |= CAM_MOVE_ROTATE_RIGHT;
@ -4882,7 +4882,7 @@ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) {
if (c->mode == CAMERA_MODE_RADIAL) {
// if > ~48 degrees, we're rotating for the second time.
if (sModeOffsetYaw > 0x22AA) {
if (sModeOffsetYaw > DEGREES(48.75)) {
s2ndRotateFlags |= CAM_MOVE_ROTATE_RIGHT;
}
@ -4904,14 +4904,14 @@ s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) {
}
}
if (gPlayer1Controller->buttonPressed & L_CBUTTONS) {
if (sModeOffsetYaw < 0x800) {
if (sModeOffsetYaw < DEGREES(11.25)) {
if (!(gCameraMovementFlags & CAM_MOVE_ROTATE_LEFT)) {
gCameraMovementFlags |= CAM_MOVE_ROTATE_LEFT;
}
if (c->mode == CAMERA_MODE_RADIAL) {
// if < ~48 degrees, we're rotating for the second time.
if (sModeOffsetYaw < -0x22AA) {
if (sModeOffsetYaw < -DEGREES(48.75)) {
s2ndRotateFlags |= CAM_MOVE_ROTATE_LEFT;
}
@ -5013,7 +5013,7 @@ void handle_c_button_movement(struct Camera *c) {
}
// Rotate left or right
cSideYaw = 0x1000;
cSideYaw = DEGREES(22.5);
if (gPlayer1Controller->buttonPressed & R_CBUTTONS) {
if (gCameraMovementFlags & CAM_MOVE_ROTATE_LEFT) {
gCameraMovementFlags &= ~CAM_MOVE_ROTATE_LEFT;
@ -5680,7 +5680,7 @@ BAD_RETURN(s32) cam_cotmc_exit_waterfall(UNUSED struct Camera *c) {
BAD_RETURN(s32) cam_sl_snowman_head_8dir(struct Camera *c) {
sStatusFlags |= CAM_FLAG_BLOCK_AREA_PROCESSING;
transition_to_camera_mode(c, CAMERA_MODE_8_DIRECTIONS, 60);
s8DirModeBaseYaw = 0x1D27;
s8DirModeBaseYaw = DEGREES(41);
}
/**
@ -5775,8 +5775,8 @@ BAD_RETURN(s32) cam_thi_move_cam_through_tunnel(UNUSED struct Camera *c) {
*/
BAD_RETURN(s32) cam_thi_look_through_tunnel(UNUSED struct Camera *c) {
// ~82.5 degrees
if (sModeOffsetYaw > 0x3AAA) {
sModeOffsetYaw = 0x3AAA;
if (sModeOffsetYaw > DEGREES(82.5)) {
sModeOffsetYaw = DEGREES(82.5);
}
}
@ -7776,18 +7776,18 @@ BAD_RETURN(s32) cutscene_dance_closeup_start(struct Camera *c) {
UNUSED u8 filler[8];
if ((gLastCompletedStarNum == 4) && (gCurrCourseNum == COURSE_JRB)) {
star_dance_bound_yaw(c, 0x0, 0x4000);
star_dance_bound_yaw(c, DEGREES(0), DEGREES(90));
}
if ((gLastCompletedStarNum == 1) && (gCurrCourseNum == COURSE_DDD)) {
star_dance_bound_yaw(c, 0x8000, 0x5000);
star_dance_bound_yaw(c, DEGREES(180), DEGREES(112.5));
}
if ((gLastCompletedStarNum == 5) && (gCurrCourseNum == COURSE_WDW)) {
star_dance_bound_yaw(c, 0x8000, 0x800);
star_dance_bound_yaw(c, DEGREES(180), DEGREES(11.25));
}
vec3f_copy(sCutsceneVars[9].point, c->focus);
//! cvar8 is unused in the closeup cutscene
sCutsceneVars[8].angle[0] = 0x2000;
sCutsceneVars[8].angle[0] = DEGREES(45);
}
/**
@ -7831,7 +7831,7 @@ BAD_RETURN(s32) cutscene_dance_closeup_fly_closer(struct Camera *c) {
vec3f_get_dist_and_angle(sMarioCamState->pos, c->pos, &dist, &pitch, &yaw);
approach_f32_asymptotic_bool(&dist, 240.f, 0.4f);
approach_s16_asymptotic_bool(&yaw, c->yaw, 8);
approach_s16_asymptotic_bool(&pitch, 0x1000, 5);
approach_s16_asymptotic_bool(&pitch, DEGREES(22.5), 5);
vec3f_set_dist_and_angle(sMarioCamState->pos, c->pos, dist, pitch, yaw);
}
@ -7891,16 +7891,16 @@ BAD_RETURN(s32) cutscene_dance_fly_away_start(struct Camera *c) {
// Restrict the camera yaw in tight spaces
if ((gLastCompletedStarNum == 6) && (gCurrCourseNum == COURSE_CCM)) {
star_dance_bound_yaw(c, 0x5600, 0x800);
star_dance_bound_yaw(c, DEGREES(120.9375), DEGREES(11.25));
}
if ((gLastCompletedStarNum == 2) && (gCurrCourseNum == COURSE_TTM)) {
star_dance_bound_yaw(c, 0x0, 0x800);
star_dance_bound_yaw(c, DEGREES(0), DEGREES(11.25));
}
if ((gLastCompletedStarNum == 1) && (gCurrCourseNum == COURSE_SL)) {
star_dance_bound_yaw(c, 0x2000, 0x800);
star_dance_bound_yaw(c, DEGREES(45), DEGREES(11.25));
}
if ((gLastCompletedStarNum == 3) && (gCurrCourseNum == COURSE_RR)) {
star_dance_bound_yaw(c, 0x0, 0x800);
star_dance_bound_yaw(c, DEGREES(0), DEGREES(11.25));
}
}
@ -7910,7 +7910,7 @@ BAD_RETURN(s32) cutscene_dance_fly_away_approach_mario(struct Camera *c) {
vec3f_get_dist_and_angle(sMarioCamState->pos, c->pos, &dist, &pitch, &yaw);
approach_f32_asymptotic_bool(&dist, 600.f, 0.3f);
approach_s16_asymptotic_bool(&pitch, 0x1000, 16);
approach_s16_asymptotic_bool(&pitch, DEGREES(22.5), 16);
approach_s16_asymptotic_bool(&yaw, c->yaw, 8);
vec3f_set_dist_and_angle(sMarioCamState->pos, c->pos, dist, pitch, yaw);
}
@ -8466,11 +8466,11 @@ void cutscene_goto_cvar_pos(struct Camera *c, f32 goalDist, s16 goalPitch, s16 r
pan_camera(c, rotPitch, rotYaw);
vec3f_get_dist_and_angle(c->pos, c->focus, &nextDist, &nextPitch, &nextYaw);
if (nextPitch < -0x3000) {
nextPitch = -0x3000;
if (nextPitch < DEGREES(-67.5)) {
nextPitch = DEGREES(-67.5);
}
if (nextPitch > 0x3000) {
nextPitch = 0x3000;
if (nextPitch > DEGREES(67.5)) {
nextPitch = DEGREES(67.5);
}
vec3f_set_dist_and_angle(c->pos, c->focus, nextDist, nextPitch, nextYaw);
@ -9899,8 +9899,8 @@ BAD_RETURN(s32) cutscene_sliding_doors_open_start(struct Camera *c) {
// If the camera is too close, warp it backwards set it to a better angle.
if (dist < 500.f) {
dist = 500.f;
yaw = sMarioCamState->faceAngle[1] + 0x8800;
pitch = 0x800;
yaw = sMarioCamState->faceAngle[1] + DEGREES(191.25);
pitch = DEGREES(11.25);
}
vec3f_set_dist_and_angle(sMarioCamState->pos, c->pos, dist, pitch, yaw);

View file

@ -19,12 +19,6 @@
#define ABS(x) ((x) > 0.f ? (x) : -(x))
#define ABS2(x) ((x) >= 0.f ? (x) : -(x))
/**
* Converts an angle in degrees to sm64's s16 angle units. For example, DEGREES(90) == 0x4000
* This should be used mainly to make camera code clearer at first glance.
*/
#define DEGREES(x) ((x) * 0x10000 / 360)
#define LEVEL_AREA_INDEX(levelNum, areaNum) (((levelNum) << 4) + (areaNum))
/**

View file

@ -559,12 +559,12 @@ s32 mario_facing_downhill(struct MarioState *m, s32 turnYaw) {
// This is never used in practice, as turnYaw is
// always passed as zero.
if (turnYaw && m->forwardVel < 0.0f) {
faceAngleYaw += 0x8000;
faceAngleYaw += DEGREES(180);
}
faceAngleYaw = m->floorAngle - faceAngleYaw;
return (-0x4000 < faceAngleYaw) && (faceAngleYaw < 0x4000);
return (DEGREES(-90) < faceAngleYaw) && (faceAngleYaw < DEGREES(90));
}
/**
@ -574,26 +574,25 @@ u32 mario_floor_is_slippery(struct MarioState *m) {
f32 normY;
if ((m->area->terrainType & TERRAIN_MASK) == TERRAIN_SLIDE
&& m->floor->normal.y < 0.9998477f //~cos(1 deg)
) {
&& m->floor->normal.y < COS_1) { // ~cos(1 deg)
return TRUE;
}
switch (mario_get_floor_class(m)) {
case SURFACE_VERY_SLIPPERY:
normY = 0.9848077f; //~cos(10 deg)
normY = COS_10; //~cos(10 deg)
break;
case SURFACE_SLIPPERY:
normY = 0.9396926f; //~cos(20 deg)
normY = COS_20; //~cos(20 deg)
break;
default:
normY = 0.7880108f; //~cos(38 deg)
normY = COS_38; //~cos(38 deg)
break;
case SURFACE_NOT_SLIPPERY:
normY = 0.0f;
normY = COS_90;
break;
}
@ -607,25 +606,25 @@ s32 mario_floor_is_slope(struct MarioState *m) {
f32 normY;
if ((m->area->terrainType & TERRAIN_MASK) == TERRAIN_SLIDE
&& m->floor->normal.y < 0.9998477f) { // ~cos(1 deg)
&& m->floor->normal.y < COS_1) { // ~cos(1 deg)
return TRUE;
}
switch (mario_get_floor_class(m)) {
case SURFACE_VERY_SLIPPERY:
normY = 0.9961947f; // ~cos(5 deg)
normY = COS_5; // ~cos(5 deg)
break;
case SURFACE_SLIPPERY:
normY = 0.9848077f; // ~cos(10 deg)
normY = COS_10; // ~cos(10 deg)
break;
default:
normY = 0.9659258f; // ~cos(15 deg)
normY = COS_15; // ~cos(15 deg)
break;
case SURFACE_NOT_SLIPPERY:
normY = 0.9396926f; // ~cos(20 deg)
normY = COS_20; // ~cos(20 deg)
break;
}
@ -646,19 +645,19 @@ s32 mario_floor_is_steep(struct MarioState *m) {
if (!mario_facing_downhill(m, FALSE)) {
switch (mario_get_floor_class(m)) {
case SURFACE_VERY_SLIPPERY:
normY = 0.9659258f; // ~cos(15 deg)
normY = COS_15; // ~cos(15 deg)
break;
case SURFACE_SLIPPERY:
normY = 0.9396926f; // ~cos(20 deg)
normY = COS_20; // ~cos(20 deg)
break;
default:
normY = 0.8660254f; // ~cos(30 deg)
normY = COS_30; // ~cos(30 deg)
break;
case SURFACE_NOT_SLIPPERY:
normY = 0.8660254f; // ~cos(30 deg)
normY = COS_30; // ~cos(30 deg)
break;
}
@ -744,7 +743,7 @@ void set_steep_jump_action(struct MarioState *m) {
if (m->forwardVel > 0.0f) {
//! ((s16)0x8000) has undefined behavior. Therefore, this downcast has
// undefined behavior if m->floorAngle >= 0.
s16 angleTemp = m->floorAngle + 0x8000;
s16 angleTemp = m->floorAngle + DEGREES(180);
s16 faceAngleTemp = m->faceAngle[1] - angleTemp;
f32 y = sins(faceAngleTemp) * m->forwardVel;
@ -843,7 +842,7 @@ static u32 set_mario_action_airborne(struct MarioState *m, u32 action, u32 actio
case ACT_STEEP_JUMP:
m->marioObj->header.gfx.animInfo.animID = -1;
set_mario_y_vel_based_on_fspeed(m, 42.0f, 0.25f);
m->faceAngle[0] = -0x2000;
m->faceAngle[0] = DEGREES(-45);
break;
case ACT_LAVA_BOOST:

View file

@ -120,7 +120,7 @@ s32 should_get_stuck_in_ground(struct MarioState *m) {
if (floor != NULL && (terrainType == TERRAIN_SNOW || terrainType == TERRAIN_SAND)
&& type != SURFACE_BURNING && SURFACE_IS_NOT_HARD(type)) {
if (!(flags & 0x01) && m->peakHeight - m->pos[1] > 1000.0f && floor->normal.y >= 0.8660254f) {
if (!(flags & 0x01) && m->peakHeight - m->pos[1] > 1000.0f && floor->normal.y >= COS_30) {
return TRUE;
}
}
@ -242,8 +242,8 @@ void update_air_without_turn(struct MarioState *m) {
m->slideVelX = m->forwardVel * sins(m->faceAngle[1]);
m->slideVelZ = m->forwardVel * coss(m->faceAngle[1]);
m->slideVelX += sidewaysSpeed * sins(m->faceAngle[1] + 0x4000);
m->slideVelZ += sidewaysSpeed * coss(m->faceAngle[1] + 0x4000);
m->slideVelX += sidewaysSpeed * sins(m->faceAngle[1] + DEGREES(90));
m->slideVelZ += sidewaysSpeed * coss(m->faceAngle[1] + DEGREES(90));
m->vel[0] = m->slideVelX;
m->vel[2] = m->slideVelZ;
@ -262,7 +262,7 @@ void update_lava_boost_or_twirling(struct MarioState *m) {
m->faceAngle[1] += sins(intendedDYaw) * intendedMag * 1024.0f;
if (m->forwardVel < 0.0f) {
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
m->forwardVel *= -1.0f;
}
@ -336,7 +336,7 @@ void update_flying(struct MarioState *m) {
update_flying_pitch(m);
update_flying_yaw(m);
m->forwardVel -= 2.0f * ((f32) m->faceAngle[0] / 0x4000) + 0.1f;
m->forwardVel -= 2.0f * ((f32) m->faceAngle[0] / DEGREES(90)) + 0.1f;
m->forwardVel -= 0.5f * (1.0f - coss(m->angleVel[1]));
if (m->forwardVel < 0.0f) {
@ -353,11 +353,11 @@ void update_flying(struct MarioState *m) {
m->faceAngle[0] += m->angleVel[0];
if (m->faceAngle[0] > 0x2AAA) {
m->faceAngle[0] = 0x2AAA;
if (m->faceAngle[0] > DEGREES(60)) {
m->faceAngle[0] = DEGREES(60);
}
if (m->faceAngle[0] < -0x2AAA) {
m->faceAngle[0] = -0x2AAA;
if (m->faceAngle[0] < DEGREES(-60)) {
m->faceAngle[0] = DEGREES(-60);
}
m->vel[0] = m->forwardVel * coss(m->faceAngle[0]) * sins(m->faceAngle[1]);
@ -393,7 +393,7 @@ u32 common_air_action_step(struct MarioState *m, u32 landAction, s32 animation,
queue_rumble_data(5, 40);
#endif
mario_bonk_reflection(m, FALSE);
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
if (m->wall != NULL) {
set_mario_action(m, ACT_AIR_HIT_WALL, 0);
@ -605,7 +605,7 @@ s32 act_side_flip(struct MarioState *m) {
if (common_air_action_step(m, ACT_SIDE_FLIP_LAND, MARIO_ANIM_SLIDEFLIP, AIR_STEP_CHECK_LEDGE_GRAB)
!= AIR_STEP_GRABBED_LEDGE) {
m->marioObj->header.gfx.angle[1] += 0x8000;
m->marioObj->header.gfx.angle[1] += DEGREES(180);
}
// This must be one line to match on -O2
@ -742,17 +742,17 @@ s32 act_dive(struct MarioState *m) {
switch (perform_air_step(m, 0)) {
case AIR_STEP_NONE:
if (m->vel[1] < 0.0f && m->faceAngle[0] > -0x2AAA) {
if (m->vel[1] < 0.0f && m->faceAngle[0] > DEGREES(-60)) {
m->faceAngle[0] -= 0x200;
if (m->faceAngle[0] < -0x2AAA) {
m->faceAngle[0] = -0x2AAA;
if (m->faceAngle[0] < DEGREES(-60)) {
m->faceAngle[0] = DEGREES(-60);
}
}
m->marioObj->header.gfx.angle[0] = -m->faceAngle[0];
break;
case AIR_STEP_LANDED:
if (should_get_stuck_in_ground(m) && m->faceAngle[0] == -0x2AAA) {
if (should_get_stuck_in_ground(m) && m->faceAngle[0] == DEGREES(-60)) {
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
@ -1146,7 +1146,7 @@ u32 common_air_knockback_step(struct MarioState *m, u32 landAction, u32 hardFall
s32 check_wall_kick(struct MarioState *m) {
if ((m->input & INPUT_A_PRESSED) && m->wallKickTimer != 0 && m->prevAction == ACT_AIR_HIT_WALL) {
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
return set_mario_action(m, ACT_WALL_KICK_AIR, 0);
}
@ -1233,11 +1233,11 @@ s32 act_thrown_forward(struct MarioState *m) {
if (common_air_knockback_step(m, landAction, ACT_HARD_FORWARD_GROUND_KB, 0x002D, m->forwardVel)
== AIR_STEP_NONE) {
pitch = atan2s(m->forwardVel, -m->vel[1]);
if (pitch > 0x1800) {
pitch = 0x1800;
if (pitch > DEGREES(33.75)) {
pitch = DEGREES(33.75);
}
m->marioObj->header.gfx.angle[0] = pitch + 0x1800;
m->marioObj->header.gfx.angle[0] = pitch + DEGREES(33.75);
}
m->forwardVel *= 0.98f;
@ -1314,7 +1314,7 @@ s32 act_air_hit_wall(struct MarioState *m) {
if (++(m->actionTimer) <= 2) {
if (m->input & INPUT_A_PRESSED) {
m->vel[1] = 52.0f;
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
return set_mario_action(m, ACT_WALL_KICK_AIR, 0);
}
} else if (m->forwardVel >= 38.0f) {
@ -1441,7 +1441,7 @@ s32 act_butt_slide_air(struct MarioState *m) {
switch (perform_air_step(m, 0)) {
case AIR_STEP_LANDED:
if (m->actionState == 0 && m->vel[1] < 0.0f && m->floor->normal.y >= 0.9848077f) {
if (m->actionState == 0 && m->vel[1] < 0.0f && m->floor->normal.y >= COS_10) {
m->vel[1] = -m->vel[1] / 2.0f;
m->actionState = 1;
} else {
@ -1480,7 +1480,7 @@ s32 act_hold_butt_slide_air(struct MarioState *m) {
switch (perform_air_step(m, 0)) {
case AIR_STEP_LANDED:
if (m->actionState == 0 && m->vel[1] < 0.0f && m->floor->normal.y >= 0.9848077f) {
if (m->actionState == 0 && m->vel[1] < 0.0f && m->floor->normal.y >= COS_10) {
m->vel[1] = -m->vel[1] / 2.0f;
m->actionState = 1;
} else {
@ -1593,8 +1593,8 @@ s32 act_slide_kick(struct MarioState *m) {
case AIR_STEP_NONE:
if (m->actionState == 0) {
m->marioObj->header.gfx.angle[0] = atan2s(m->forwardVel, -m->vel[1]);
if (m->marioObj->header.gfx.angle[0] > 0x1800) {
m->marioObj->header.gfx.angle[0] = 0x1800;
if (m->marioObj->header.gfx.angle[0] > DEGREES(33.75)) {
m->marioObj->header.gfx.angle[0] = DEGREES(33.75);
}
}
break;
@ -1813,8 +1813,8 @@ s32 act_flying(struct MarioState *m) {
}
m->faceAngle[0] -= 0x200;
if (m->faceAngle[0] < -0x2AAA) {
m->faceAngle[0] = -0x2AAA;
if (m->faceAngle[0] < DEGREES(-60)) {
m->faceAngle[0] = DEGREES(-60);
}
m->marioObj->header.gfx.angle[0] = -m->faceAngle[0];
@ -1827,7 +1827,7 @@ s32 act_flying(struct MarioState *m) {
break;
}
if (m->faceAngle[0] > 0x800 && m->forwardVel >= 48.0f) {
if (m->faceAngle[0] > DEGREES(11.25) && m->forwardVel >= 48.0f) {
m->particleFlags |= PARTICLE_DUST;
}
@ -1863,7 +1863,7 @@ s32 act_riding_hoot(struct MarioState *m) {
m->pos[1] = m->usedObj->oPosY - 92.5f;
m->pos[2] = m->usedObj->oPosZ;
m->faceAngle[1] = 0x4000 - m->usedObj->oMoveAngleYaw;
m->faceAngle[1] = DEGREES(90) - m->usedObj->oMoveAngleYaw;
if (m->actionState == 0) {
set_mario_animation(m, MARIO_ANIM_HANG_ON_CEILING);
@ -1875,7 +1875,7 @@ s32 act_riding_hoot(struct MarioState *m) {
vec3f_set(m->vel, 0.0f, 0.0f, 0.0f);
vec3f_set(m->marioObj->header.gfx.pos, m->pos[0], m->pos[1], m->pos[2]);
vec3s_set(m->marioObj->header.gfx.angle, 0, 0x4000 - m->faceAngle[1], 0);
vec3s_set(m->marioObj->header.gfx.angle, 0, DEGREES(90) - m->faceAngle[1], 0);
return FALSE;
}

View file

@ -116,7 +116,7 @@ s32 act_holding_pole(struct MarioState *m) {
#ifdef VERSION_JP
if (m->input & INPUT_A_PRESSED) {
add_tree_leaf_particles(m);
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
return set_mario_action(m, ACT_WALL_KICK_AIR, 0);
}
@ -134,7 +134,7 @@ s32 act_holding_pole(struct MarioState *m) {
if (m->input & INPUT_A_PRESSED) {
add_tree_leaf_particles(m);
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
return set_mario_action(m, ACT_WALL_KICK_AIR, 0);
}
#endif
@ -200,7 +200,7 @@ s32 act_climbing_pole(struct MarioState *m) {
if (m->input & INPUT_A_PRESSED) {
add_tree_leaf_particles(m);
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
return set_mario_action(m, ACT_WALL_KICK_AIR, 0);
}
@ -549,7 +549,7 @@ s32 act_ledge_grab(struct MarioState *m) {
m->actionTimer++;
}
if (m->floor->normal.y < 0.9063078f) {
if (m->floor->normal.y < COS_25) {
return let_go_of_ledge(m);
}
@ -573,7 +573,7 @@ s32 act_ledge_grab(struct MarioState *m) {
&& !(m->input & INPUT_A_DOWN)
#endif
) {
if (intendedDYaw >= -0x4000 && intendedDYaw <= 0x4000) {
if (intendedDYaw >= DEGREES(-90) && intendedDYaw <= DEGREES(90)) {
if (hasSpaceForMario) {
return set_mario_action(m, ACT_LEDGE_CLIMB_SLOW_1, 0);
}
@ -582,7 +582,7 @@ s32 act_ledge_grab(struct MarioState *m) {
}
}
heightAboveFloor = m->pos[1] - find_floor_height_relative_polar(m, -0x8000, 30.0f);
heightAboveFloor = m->pos[1] - find_floor_height_relative_polar(m, DEGREES(-180), 30.0f);
if (hasSpaceForMario && heightAboveFloor < 100.0f) {
return set_mario_action(m, ACT_LEDGE_CLIMB_FAST, 0);
}
@ -711,18 +711,18 @@ s32 act_in_cannon(struct MarioState *m) {
m->faceAngle[0] -= (s16)(m->controller->stickY * 10.0f);
marioObj->oMarioCannonInputYaw -= (s16)(m->controller->stickX * 10.0f);
if (m->faceAngle[0] > 0x38E3) {
m->faceAngle[0] = 0x38E3;
if (m->faceAngle[0] > DEGREES(80)) {
m->faceAngle[0] = DEGREES(80);
}
if (m->faceAngle[0] < 0) {
m->faceAngle[0] = 0;
}
if (marioObj->oMarioCannonInputYaw > 0x4000) {
marioObj->oMarioCannonInputYaw = 0x4000;
if (marioObj->oMarioCannonInputYaw > DEGREES(90)) {
marioObj->oMarioCannonInputYaw = DEGREES(90);
}
if (marioObj->oMarioCannonInputYaw < -0x4000) {
marioObj->oMarioCannonInputYaw = -0x4000;
if (marioObj->oMarioCannonInputYaw < DEGREES(-90)) {
marioObj->oMarioCannonInputYaw = DEGREES(-90);
}
m->faceAngle[1] = marioObj->oMarioCannonObjectYaw + marioObj->oMarioCannonInputYaw;

View file

@ -261,7 +261,7 @@ void handle_save_menu(struct MarioState *m) {
// not quitting
if (gSaveOptSelectIndex != MENU_OPT_SAVE_AND_QUIT) {
disable_time_stop();
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
// figure out what dialog to show, if we should
dialogID = get_star_collection_dialog(m);
if (dialogID) {
@ -779,7 +779,7 @@ s32 act_unlocking_key_door(struct MarioState *m) {
m->pos[2] = m->usedObj->oPosZ + sins(m->faceAngle[1]) * 75.0f;
if (m->actionArg & 2) {
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
}
if (m->actionTimer == 0) {
@ -819,7 +819,7 @@ s32 act_unlocking_star_door(struct MarioState *m) {
case 0:
m->faceAngle[1] = m->usedObj->oMoveAngleYaw;
if (m->actionArg & 2) {
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
}
m->marioObj->oMarioReadingSignDPosX = m->pos[0];
m->marioObj->oMarioReadingSignDPosZ = m->pos[2];
@ -898,7 +898,7 @@ s32 act_entering_star_door(struct MarioState *m) {
m->faceAngle[1] = m->usedObj->oMoveAngleYaw;
if (m->actionArg & 2) {
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
}
m->pos[0] += 12.0f * sins(m->faceAngle[1]);
@ -939,7 +939,7 @@ s32 act_going_through_door(struct MarioState *m) {
}
} else if (is_anim_at_end(m)) {
if (m->actionArg & 2) {
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
}
set_mario_action(m, ACT_IDLE, 0);
}
@ -1054,7 +1054,7 @@ s32 act_exit_airborne(struct MarioState *m) {
m->healCounter = 31;
}
// rotate him to face away from the entrance
m->marioObj->header.gfx.angle[1] += 0x8000;
m->marioObj->header.gfx.angle[1] += DEGREES(180);
m->particleFlags |= PARTICLE_SPARKLES;
return FALSE;
}
@ -1065,7 +1065,7 @@ s32 act_falling_exit_airborne(struct MarioState *m) {
m->healCounter = 31;
}
// rotate Mario to face away from the entrance
m->marioObj->header.gfx.angle[1] += 0x8000;
m->marioObj->header.gfx.angle[1] += DEGREES(180);
m->particleFlags |= PARTICLE_SPARKLES;
return FALSE;
}
@ -1149,7 +1149,7 @@ s32 act_exit_land_save_dialog(struct MarioState *m) {
break;
}
m->marioObj->header.gfx.angle[1] += 0x8000;
m->marioObj->header.gfx.angle[1] += DEGREES(180);
return FALSE;
}
@ -1227,7 +1227,7 @@ s32 act_special_exit_airborne(struct MarioState *m) {
m->particleFlags |= PARTICLE_SPARKLES;
// rotate Mario to face away from the entrance
marioObj->header.gfx.angle[1] += 0x8000;
marioObj->header.gfx.angle[1] += DEGREES(180);
// show Mario
marioObj->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE;
@ -1545,12 +1545,12 @@ s32 act_squished(struct MarioState *m) {
}
// steep floor
if (m->floor != NULL && m->floor->normal.y < 0.5f) {
if (m->floor != NULL && m->floor->normal.y < COS_60) {
surfAngle = atan2s(m->floor->normal.z, m->floor->normal.x);
underSteepSurf = TRUE;
}
// steep ceiling
if (m->ceil != NULL && -0.5f < m->ceil->normal.y) {
if (m->ceil != NULL && -COS_60 < m->ceil->normal.y) {
surfAngle = atan2s(m->ceil->normal.z, m->ceil->normal.x);
underSteepSurf = TRUE;
}
@ -1813,7 +1813,7 @@ static void jumbo_star_cutscene_falling(struct MarioState *m) {
m->input |= INPUT_A_DOWN;
m->flags |= (MARIO_WING_CAP | MARIO_CAP_ON_HEAD);
m->faceAngle[1] = -0x8000;
m->faceAngle[1] = DEGREES(-180);
m->pos[0] = 0.0f;
m->pos[2] = 0.0f;
@ -2663,7 +2663,7 @@ static s32 act_end_waving_cutscene(struct MarioState *m) {
set_mario_animation(m, MARIO_ANIM_CREDITS_WAVING);
stop_and_set_height_to_floor(m);
m->marioObj->header.gfx.angle[1] += 0x8000;
m->marioObj->header.gfx.angle[1] += DEGREES(180);
m->marioObj->header.gfx.pos[0] -= 60.0f;
m->marioBodyState->handState = MARIO_HAND_RIGHT_OPEN;

View file

@ -119,12 +119,12 @@ void check_ledge_climb_down(struct MarioState *m) {
wallAngle = atan2s(wall->normal.z, wall->normal.x);
wallDYaw = wallAngle - m->faceAngle[1];
if (wallDYaw > -0x4000 && wallDYaw < 0x4000) {
if (wallDYaw > DEGREES(-90) && wallDYaw < DEGREES(90)) {
m->pos[0] = wallCols.x - 20.0f * wall->normal.x;
m->pos[2] = wallCols.z - 20.0f * wall->normal.z;
m->faceAngle[0] = 0;
m->faceAngle[1] = wallAngle + 0x8000;
m->faceAngle[1] = wallAngle + DEGREES(180);
set_mario_action(m, ACT_LEDGE_CLIMB_DOWN, 0);
set_mario_animation(m, MARIO_ANIM_CLIMB_DOWN_LEDGE);
@ -176,22 +176,22 @@ void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor) {
facingDYaw = m->faceAngle[1] - m->slideYaw;
newFacingDYaw = facingDYaw;
//! -0x4000 not handled - can slide down a slope while facing perpendicular to it
if (newFacingDYaw > 0 && newFacingDYaw <= 0x4000) {
//! -0x4000 / -90 degrees not handled - can slide down a slope while facing perpendicular to it
if (newFacingDYaw > 0 && newFacingDYaw <= DEGREES(90)) {
if ((newFacingDYaw -= 0x200) < 0) {
newFacingDYaw = 0;
}
} else if (newFacingDYaw > -0x4000 && newFacingDYaw < 0) {
} else if (newFacingDYaw > DEGREES(-90) && newFacingDYaw < 0) {
if ((newFacingDYaw += 0x200) > 0) {
newFacingDYaw = 0;
}
} else if (newFacingDYaw > 0x4000 && newFacingDYaw < 0x8000) {
if ((newFacingDYaw += 0x200) > 0x8000) {
newFacingDYaw = 0x8000;
} else if (newFacingDYaw > DEGREES(90) && newFacingDYaw < DEGREES(180)) {
if ((newFacingDYaw += 0x200) > DEGREES(180)) {
newFacingDYaw = DEGREES(180);
}
} else if (newFacingDYaw > -0x8000 && newFacingDYaw < -0x4000) {
if ((newFacingDYaw -= 0x200) < -0x8000) {
newFacingDYaw = -0x8000;
} else if (newFacingDYaw > DEGREES(-180) && newFacingDYaw < DEGREES(-90)) {
if ((newFacingDYaw -= 0x200) < DEGREES(-180)) {
newFacingDYaw = DEGREES(-180);
}
}
@ -211,7 +211,7 @@ void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor) {
m->slideVelZ = m->slideVelZ * 100.0f / m->forwardVel;
}
if (newFacingDYaw < -0x4000 || newFacingDYaw > 0x4000) {
if (newFacingDYaw < DEGREES(-90) || newFacingDYaw > DEGREES(90)) {
m->forwardVel *= -1.0f;
}
}
@ -311,7 +311,7 @@ void apply_slope_accel(struct MarioState *m) {
break;
}
if (floorDYaw > -0x4000 && floorDYaw < 0x4000) {
if (floorDYaw > DEGREES(-90) && floorDYaw < DEGREES(90)) {
m->forwardVel += slopeAccel * steepness;
} else {
m->forwardVel -= slopeAccel * steepness;
@ -375,7 +375,7 @@ void update_shell_speed(struct MarioState *m) {
m->forwardVel += 1.1f;
} else if (m->forwardVel <= targetSpeed) {
m->forwardVel += 1.1f - m->forwardVel / 58.0f;
} else if (m->floor->normal.y >= 0.95f) {
} else if (m->floor->normal.y >= 0.95f) { // ~cos(18.194872 deg)
m->forwardVel -= 1.0f;
}
@ -451,7 +451,7 @@ void update_walking_speed(struct MarioState *m) {
m->forwardVel += 1.1f;
} else if (m->forwardVel <= targetSpeed) {
m->forwardVel += 1.1f - m->forwardVel / 43.0f;
} else if (m->floor->normal.y >= 0.95f) {
} else if (m->floor->normal.y >= 0.95f) { // ~cos(18.194872 deg)
m->forwardVel -= 1.0f;
}
@ -479,7 +479,7 @@ s32 should_begin_sliding(struct MarioState *m) {
s32 analog_stick_held_back(struct MarioState *m) {
s16 intendedDYaw = m->intendedYaw - m->faceAngle[1];
return intendedDYaw < -0x471C || intendedDYaw > 0x471C;
return intendedDYaw < DEGREES(-100) || intendedDYaw > DEGREES(100);
}
s32 check_ground_dive_or_punch(struct MarioState *m) {
@ -506,7 +506,7 @@ s32 begin_braking_action(struct MarioState *m) {
return set_mario_action(m, ACT_STANDING_AGAINST_WALL, 0);
}
if (m->forwardVel >= 16.0f && m->floor->normal.y >= 0.17364818f) {
if (m->forwardVel >= 16.0f && m->floor->normal.y >= COS_80) {
return set_mario_action(m, ACT_BRAKING, 0);
}
@ -685,7 +685,7 @@ void push_or_sidle_wall(struct MarioState *m, Vec3f startPos) {
dWallAngle = wallAngle - m->faceAngle[1];
}
if (m->wall == NULL || dWallAngle <= -0x71C8 || dWallAngle >= 0x71C8) {
if (m->wall == NULL || dWallAngle < DEGREES(-160) || dWallAngle > DEGREES(160)) {
m->flags |= MARIO_UNKNOWN_31;
set_mario_animation(m, MARIO_ANIM_PUSHING);
play_step_sound(m, 6, 18);
@ -702,9 +702,9 @@ void push_or_sidle_wall(struct MarioState *m, Vec3f startPos) {
}
m->actionState = 1;
m->actionArg = wallAngle + 0x8000;
m->marioObj->header.gfx.angle[1] = wallAngle + 0x8000;
m->marioObj->header.gfx.angle[2] = find_floor_slope(m, 0x4000);
m->actionArg = wallAngle + DEGREES(180);
m->marioObj->header.gfx.angle[1] = wallAngle + DEGREES(180);
m->marioObj->header.gfx.angle[2] = find_floor_slope(m, DEGREES(90));
}
}
@ -720,15 +720,15 @@ void tilt_body_walking(struct MarioState *m, s16 startYaw) {
s16 val02 = -(s16)(dYaw * m->forwardVel / 12.0f);
s16 val00 = (s16)(m->forwardVel * 170.0f);
if (val02 > 0x1555) {
val02 = 0x1555;
if (val02 > DEGREES(30)) {
val02 = DEGREES(30);
}
if (val02 < -0x1555) {
val02 = -0x1555;
if (val02 < DEGREES(-30)) {
val02 = DEGREES(-30);
}
if (val00 > 0x1555) {
val00 = 0x1555;
if (val00 > DEGREES(30)) {
val00 = DEGREES(30);
}
if (val00 < 0) {
val00 = 0;
@ -752,15 +752,15 @@ void tilt_body_ground_shell(struct MarioState *m, s16 startYaw) {
s16 val04 = -(s16)(dYaw * m->forwardVel / 12.0f);
s16 val02 = (s16)(m->forwardVel * 170.0f);
if (val04 > 0x1800) {
val04 = 0x1800;
if (val04 > DEGREES(33.75)) {
val04 = DEGREES(33.75);
}
if (val04 < -0x1800) {
val04 = -0x1800;
if (val04 < DEGREES(-33.75)) {
val04 = DEGREES(-33.75);
}
if (val02 > 0x1000) {
val02 = 0x1000;
if (val02 > DEGREES(22.5)) {
val02 = DEGREES(22.5);
}
if (val02 < 0) {
val02 = 0;
@ -1030,7 +1030,7 @@ s32 act_finish_turning_around(struct MarioState *m) {
set_mario_action(m, ACT_WALKING, 0);
}
m->marioObj->header.gfx.angle[1] += 0x8000;
m->marioObj->header.gfx.angle[1] += DEGREES(180);
return FALSE;
}
@ -1400,7 +1400,7 @@ void common_slide_action(struct MarioState *m, u32 endAction, u32 airAction, s32
slideSpeed = 4.0f;
}
m->slideYaw = wallAngle - (s16)(m->slideYaw - wallAngle) + 0x8000;
m->slideYaw = wallAngle - (s16)(m->slideYaw - wallAngle) + DEGREES(180);
m->vel[0] = m->slideVelX = slideSpeed * sins(m->slideYaw);
m->vel[2] = m->slideVelZ = slideSpeed * coss(m->slideYaw);
@ -1760,7 +1760,7 @@ s32 common_landing_cancels(struct MarioState *m, struct LandingAction *landingAc
//! Everything here, including floor steepness, is checked before checking
// if Mario is actually on the floor. This leads to e.g. remote sliding.
if (m->floor->normal.y < 0.2923717f) {
if (m->floor->normal.y < COS_73) {
return mario_push_off_steep_floor(m, landingAction->verySteepAction, 0);
}
@ -1813,7 +1813,7 @@ s32 act_side_flip_land(struct MarioState *m) {
}
if (common_landing_action(m, MARIO_ANIM_SLIDEFLIP_LAND, ACT_FREEFALL) != GROUND_STEP_HIT_WALL) {
m->marioObj->header.gfx.angle[1] += 0x8000;
m->marioObj->header.gfx.angle[1] += DEGREES(180);
}
return FALSE;
}

View file

@ -19,7 +19,7 @@
s32 check_common_idle_cancels(struct MarioState *m) {
mario_drop_held_object(m);
if (m->floor->normal.y < 0.29237169f) {
if (m->floor->normal.y < COS_73) {
return mario_push_off_steep_floor(m, ACT_FREEFALL, 0);
}
@ -60,7 +60,7 @@ s32 check_common_idle_cancels(struct MarioState *m) {
}
s32 check_common_hold_idle_cancels(struct MarioState *m) {
if (m->floor->normal.y < 0.29237169f) {
if (m->floor->normal.y < COS_73) {
return mario_push_off_steep_floor(m, ACT_HOLD_FREEFALL, 0);
}
@ -153,7 +153,7 @@ s32 act_idle(struct MarioState *m) {
// and that he's gone through 10 cycles before sleeping.
// actionTimer is used to track how many cycles have passed.
if (++m->actionState == 3) {
f32 deltaYOfFloorBehindMario = m->pos[1] - find_floor_height_relative_polar(m, -0x8000, 60.0f);
f32 deltaYOfFloorBehindMario = m->pos[1] - find_floor_height_relative_polar(m, DEGREES(-180), 60.0f);
if (deltaYOfFloorBehindMario < -24.0f || 24.0f < deltaYOfFloorBehindMario || m->floor->flags & SURFACE_FLAG_DYNAMIC) {
m->actionState = 0;
} else {
@ -265,7 +265,7 @@ s32 act_sleeping(struct MarioState *m) {
return set_mario_action(m, ACT_WAKING_UP, m->actionState);
}
if (m->pos[1] - find_floor_height_relative_polar(m, -0x8000, 60.0f) > 24.0f) {
if (m->pos[1] - find_floor_height_relative_polar(m, DEGREES(-180), 60.0f) > 24.0f) {
return set_mario_action(m, ACT_WAKING_UP, m->actionState);
}
@ -888,7 +888,7 @@ s32 act_side_flip_land_stop(struct MarioState *m) {
}
landing_step(m, MARIO_ANIM_SLIDEFLIP_LAND, ACT_IDLE);
m->marioObj->header.gfx.angle[1] += 0x8000;
m->marioObj->header.gfx.angle[1] += DEGREES(180);
return FALSE;
}
@ -1070,7 +1070,7 @@ s32 act_first_person(struct MarioState *m) {
&& save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1) >= 10) {
s16 sp1A = m->statusForCamera->headRotation[0];
s16 sp18 = ((m->statusForCamera->headRotation[1] * 4) / 3) + m->faceAngle[1];
if (sp1A == -0x1800 && (sp18 < -0x6FFF || sp18 >= 0x7000)) {
if (sp1A == DEGREES(-33.75) && (sp18 <= DEGREES(-157.5) || sp18 >= DEGREES(157.5))) {
level_trigger_warp(m, WARP_OP_UNKNOWN_01);
}
}

View file

@ -143,7 +143,7 @@ static void apply_water_current(struct MarioState *m, Vec3f step) {
s16 pitchToWhirlpool = atan2s(lateralDist, dy);
s16 yawToWhirlpool = atan2s(dz, dx);
yawToWhirlpool -= (s16)(0x2000 * 1000.0f / (distance + 1000.0f));
yawToWhirlpool -= (s16)(DEGREES(45) * 1000.0f / (distance + 1000.0f));
if (whirlpool->strength >= 0) {
if (gCurrLevelNum == LEVEL_DDD && gCurrAreaIndex == 2) {
@ -341,7 +341,7 @@ static s32 act_water_idle(struct MarioState *m) {
return set_mario_action(m, ACT_BREASTSTROKE, 0);
}
if (m->faceAngle[0] < -0x1000) {
if (m->faceAngle[0] < DEGREES(-22.5)) {
val = 0x30000;
}
@ -446,29 +446,31 @@ static void common_swimming_step(struct MarioState *m, s16 swimStrength) {
switch (perform_water_step(m)) {
case WATER_STEP_HIT_FLOOR:
floorPitch = -find_floor_slope(m, -0x8000);
floorPitch = -find_floor_slope(m, DEGREES(-180));
if (m->faceAngle[0] < floorPitch) {
m->faceAngle[0] = floorPitch;
}
break;
case WATER_STEP_HIT_CEILING:
if (m->faceAngle[0] > -0x3000) {
if (m->faceAngle[0] > DEGREES(-67.5)) {
m->faceAngle[0] -= 0x100;
}
break;
case WATER_STEP_HIT_WALL:
if (m->controller->stickY == 0.0f) {
// These angles were likely specified as arbitrary s16 values,
// but are converted to degrees for consistency.
if (m->faceAngle[0] > 0.0f) {
m->faceAngle[0] += 0x200;
if (m->faceAngle[0] > 0x3F00) {
m->faceAngle[0] = 0x3F00;
if (m->faceAngle[0] > DEGREES(88.59375)) {
m->faceAngle[0] = DEGREES(88.59375);
}
} else {
m->faceAngle[0] -= 0x200;
if (m->faceAngle[0] < -0x3F00) {
m->faceAngle[0] = -0x3F00;
if (m->faceAngle[0] < DEGREES(-88.59375)) {
m->faceAngle[0] = DEGREES(-88.59375);
}
}
}
@ -780,7 +782,7 @@ static s32 check_water_grab(struct MarioState *m) {
f32 dz = object->oPosZ - m->pos[2];
s16 dAngleToObject = atan2s(dz, dx) - m->faceAngle[1];
if (dAngleToObject >= -0x2AAA && dAngleToObject <= 0x2AAA) {
if (dAngleToObject >= DEGREES(-60) && dAngleToObject <= DEGREES(60)) {
m->usedObj = object;
mario_grab_used_object(m);
m->marioBodyState->grabPos = GRAB_POS_LIGHT_OBJ;
@ -1059,13 +1061,13 @@ static s32 act_caught_in_whirlpool(struct MarioState *m) {
if (distance <= 28.0f) {
newDistance = 16.0f;
angleChange = 0x1800;
angleChange = DEGREES(33.75);
} else if (distance < 256.0f) {
newDistance = distance - (12.0f - distance / 32.0f);
angleChange = (s16)(0x1C00 - distance * 20.0f);
angleChange = (s16)(DEGREES(39.375) - distance * 20.0f);
} else {
newDistance = distance - 4.0f;
angleChange = 0x800;
angleChange = DEGREES(11.25);
}
m->vel[1] = -640.0f / (newDistance + 16.0f);
@ -1085,7 +1087,7 @@ static s32 act_caught_in_whirlpool(struct MarioState *m) {
m->pos[2] = whirlpool->oPosZ - dx * sinAngleChange + dz * cosAngleChange;
m->pos[1] = whirlpool->oPosY + marioObj->oMarioWhirlpoolPosY;
m->faceAngle[1] = atan2s(dz, dx) + 0x8000;
m->faceAngle[1] = atan2s(dz, dx) + DEGREES(180);
set_mario_animation(m, MARIO_ANIM_GENERAL_FALL);
vec3f_copy(m->marioObj->header.gfx.pos, m->pos);
@ -1120,7 +1122,7 @@ static void update_metal_water_walking_speed(struct MarioState *m) {
m->forwardVel += 1.1f;
} else if (m->forwardVel <= val) {
m->forwardVel += 1.1f - m->forwardVel / 43.0f;
} else if (m->floor->normal.y >= 0.95f) {
} else if (m->floor->normal.y >= 0.95f) { // ~cos(18.194872 deg)
m->forwardVel -= 1.0f;
}

View file

@ -220,9 +220,9 @@ static void star_door_unlock_spawn_particles(s16 angleOffset) {
struct Object *sparkleParticle = spawn_object(gCurrentObject, 0, bhvSparkleSpawn);
sparkleParticle->oPosX +=
100.0f * sins((gCurrentObject->oUnlockDoorStarTimer * 0x2800) + angleOffset);
100.0f * sins((gCurrentObject->oUnlockDoorStarTimer * DEGREES(56.25)) + angleOffset);
sparkleParticle->oPosZ +=
100.0f * coss((gCurrentObject->oUnlockDoorStarTimer * 0x2800) + angleOffset);
100.0f * coss((gCurrentObject->oUnlockDoorStarTimer * DEGREES(56.25)) + angleOffset);
// Particles are spawned lower each frame
sparkleParticle->oPosY -= gCurrentObject->oUnlockDoorStarTimer * 10.0f;
}
@ -231,9 +231,9 @@ void bhv_unlock_door_star_init(void) {
gCurrentObject->oUnlockDoorStarState = UNLOCK_DOOR_STAR_RISING;
gCurrentObject->oUnlockDoorStarTimer = 0;
gCurrentObject->oUnlockDoorStarYawVel = 0x1000;
gCurrentObject->oPosX += 30.0f * sins(gMarioState->faceAngle[1] - 0x4000);
gCurrentObject->oPosX += 30.0f * sins(gMarioState->faceAngle[1] - DEGREES(90));
gCurrentObject->oPosY += 160.0f;
gCurrentObject->oPosZ += 30.0f * coss(gMarioState->faceAngle[1] - 0x4000);
gCurrentObject->oPosZ += 30.0f * coss(gMarioState->faceAngle[1] - DEGREES(90));
gCurrentObject->oMoveAngleYaw = 0x7800;
obj_scale(gCurrentObject, 0.5f);
}
@ -273,8 +273,8 @@ void bhv_unlock_door_star_loop(void) {
break;
case UNLOCK_DOOR_STAR_SPAWNING_PARTICLES:
// Spawn two particles, opposite sides of the star.
star_door_unlock_spawn_particles(0);
star_door_unlock_spawn_particles(0x8000);
star_door_unlock_spawn_particles(DEGREES(0));
star_door_unlock_spawn_particles(DEGREES(180));
if (gCurrentObject->oUnlockDoorStarTimer++ == 20) {
gCurrentObject->oUnlockDoorStarTimer = 0;
gCurrentObject->oUnlockDoorStarState++; // Sets state to UNLOCK_DOOR_STAR_DONE

View file

@ -75,7 +75,7 @@ BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 p
f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius) {
if (forwardVel < 0.0f) {
forwardVel *= -1.0f;
yaw += 0x8000;
yaw += DEGREES(180);
}
data->radius = radius;
@ -100,7 +100,7 @@ void mario_bonk_reflection(struct MarioState *m, u32 negateSpeed) {
if (negateSpeed) {
mario_set_forward_vel(m, -m->forwardVel);
} else {
m->faceAngle[1] += 0x8000;
m->faceAngle[1] += DEGREES(180);
}
}
@ -158,12 +158,12 @@ u32 mario_update_quicksand(struct MarioState *m, f32 sinkingSpeed) {
u32 mario_push_off_steep_floor(struct MarioState *m, u32 action, u32 actionArg) {
s16 floorDYaw = m->floorAngle - m->faceAngle[1];
if (floorDYaw > -0x4000 && floorDYaw < 0x4000) {
if (floorDYaw > DEGREES(-90) && floorDYaw < DEGREES(90)) {
m->forwardVel = 16.0f;
m->faceAngle[1] = m->floorAngle;
} else {
m->forwardVel = -16.0f;
m->faceAngle[1] = m->floorAngle + 0x8000;
m->faceAngle[1] = m->floorAngle + DEGREES(180);
}
return set_mario_action(m, action, actionArg);
@ -199,7 +199,7 @@ u32 mario_update_windy_ground(struct MarioState *m) {
pushSpeed = m->forwardVel > 0.0f ? -m->forwardVel * 0.5f : -8.0f;
if (pushDYaw > -0x4000 && pushDYaw < 0x4000) {
if (pushDYaw > DEGREES(-90) && pushDYaw < DEGREES(90)) {
pushSpeed *= -1.0f;
}
@ -306,10 +306,10 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
if (upperWall != NULL) {
s16 wallDYaw = atan2s(upperWall->normal.z, upperWall->normal.x) - m->faceAngle[1];
if (wallDYaw >= 0x2AAA && wallDYaw <= 0x5555) {
if (wallDYaw >= DEGREES(60) && wallDYaw <= DEGREES(120)) {
return GROUND_STEP_NONE;
}
if (wallDYaw <= -0x2AAA && wallDYaw >= -0x5555) {
if (wallDYaw <= DEGREES(-60) && wallDYaw >= DEGREES(-120)) {
return GROUND_STEP_NONE;
}
@ -381,7 +381,7 @@ u32 check_ledge_grab(struct MarioState *m, struct Surface *wall, Vec3f intendedP
m->floorAngle = atan2s(ledgeFloor->normal.z, ledgeFloor->normal.x);
m->faceAngle[0] = 0;
m->faceAngle[1] = atan2s(wall->normal.z, wall->normal.x) + 0x8000;
m->faceAngle[1] = atan2s(wall->normal.z, wall->normal.x) + DEGREES(180);
return TRUE;
}
@ -491,7 +491,7 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
return AIR_STEP_HIT_LAVA_WALL;
}
if (wallDYaw < -0x6000 || wallDYaw > 0x6000) {
if (wallDYaw < DEGREES(-135) || wallDYaw > DEGREES(135)) {
m->flags |= MARIO_UNKNOWN_30;
return AIR_STEP_HIT_WALL;
}