From e8fab6b649579719eafcc0b860743f7e980fa4be Mon Sep 17 00:00:00 2001 From: Jed Grabman Date: Fri, 17 Apr 2026 11:25:09 -0400 Subject: [PATCH 1/9] First pass on converting degrees --- include/defines.h | 5 +- src/actors/banana/update.inc.c | 2 +- src/actors/fake_item_box/update.inc.c | 16 ++-- src/actors/item_box/update.inc.c | 20 ++--- src/actors/mario_sign/update.inc.c | 2 +- src/actors/train/render.inc.c | 20 ++--- src/actors/train/update.inc.c | 4 +- src/actors/wario_sign/update.inc.c | 2 +- src/actors/yoshi_egg/update.inc.c | 2 +- src/camera.c | 12 +-- src/code_8003DC40.c | 82 ++++++++++---------- src/code_80057C60.c | 48 ++++++------ src/code_8006E9C0.c | 8 +- src/cpu_vehicles_camera_path.c | 8 +- src/effects.c | 38 +++++----- src/player_controller.c | 104 +++++++++++++------------- src/racing/actors_extended.c | 8 +- src/render_player.c | 2 +- src/update_objects.c | 4 +- 19 files changed, 195 insertions(+), 192 deletions(-) diff --git a/include/defines.h b/include/defines.h index 66523f42a8..cb08415716 100644 --- a/include/defines.h +++ b/include/defines.h @@ -329,7 +329,10 @@ enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE }; * @brief Max representable time, 100 minutes measured in centiseconds */ #define MAX_TIME 0x927C0 -#define DEGREES_CONVERSION_FACTOR 182 + +#define ONE_DEGREE (f32) 65536.0f / 360.0f +#define DEGREES(degree) (s16) ((f32) degree * ONE_DEGREE) +#define DEGREES_360 65536 // player->unk_046 diff --git a/src/actors/banana/update.inc.c b/src/actors/banana/update.inc.c index c94f141eae..1f079f2d88 100644 --- a/src/actors/banana/update.inc.c +++ b/src/actors/banana/update.inc.c @@ -174,7 +174,7 @@ void update_actor_banana(struct BananaActor* banana) { banana->velocity[1] = -5.0f; } banana->pos[1] += banana->velocity[1]; - banana->rot[0] += 0x16C; + banana->rot[0] += DEGREES(2); banana->rot[1] -= 0x5B0; banana->rot[2] += 0x38E; banana->unk_04 -= 1; diff --git a/src/actors/fake_item_box/update.inc.c b/src/actors/fake_item_box/update.inc.c index f86e35a5d1..a6cedead86 100644 --- a/src/actors/fake_item_box/update.inc.c +++ b/src/actors/fake_item_box/update.inc.c @@ -21,9 +21,9 @@ void update_actor_fake_item_box(struct FakeItemBox* fake_item_box) { switch (fake_item_box->state) { case 0: fake_item_box->boundingBoxSize = fake_item_box->sizeScaling * 5.5f; - fake_item_box->rot[0] -= 0xB6; - fake_item_box->rot[1] += 0x16C; - fake_item_box->rot[2] -= 0xB6; + fake_item_box->rot[0] -= DEGREES(1); + fake_item_box->rot[1] += DEGREES(2); + fake_item_box->rot[2] -= DEGREES(1); temp_f14 = temp_v0_4->pos[0] - fake_item_box->pos[0]; temp_f16 = temp_v0_4->pos[1] - fake_item_box->pos[1]; @@ -71,9 +71,9 @@ void update_actor_fake_item_box(struct FakeItemBox* fake_item_box) { fake_item_box->someTimer--; } } - fake_item_box->rot[0] -= 0xB6; - fake_item_box->rot[1] += 0x16C; - fake_item_box->rot[2] -= 0xB6; + fake_item_box->rot[0] -= DEGREES(1); + fake_item_box->rot[1] += DEGREES(2); + fake_item_box->rot[2] -= DEGREES(1); break; case 2: @@ -81,9 +81,9 @@ void update_actor_fake_item_box(struct FakeItemBox* fake_item_box) { destroy_actor((struct Actor*) fake_item_box); } else { fake_item_box->someTimer++; - fake_item_box->rot[0] += 0x444; + fake_item_box->rot[0] += DEGREES(6); fake_item_box->rot[1] -= 0x2D8; - fake_item_box->rot[2] += 0x16C; + fake_item_box->rot[2] += DEGREES(2); } break; default: diff --git a/src/actors/item_box/update.inc.c b/src/actors/item_box/update.inc.c index 47513ef8a1..b49936256b 100644 --- a/src/actors/item_box/update.inc.c +++ b/src/actors/item_box/update.inc.c @@ -10,9 +10,9 @@ void update_actor_item_box_hot_air_balloon(struct ItemBox* itemBox) { switch (itemBox->state) { case 5: - itemBox->rot[0] += 0xB6; - itemBox->rot[1] -= 0x16C; - itemBox->rot[2] += 0xB6; + itemBox->rot[0] += DEGREES(1); + itemBox->rot[1] -= DEGREES(2); + itemBox->rot[2] += DEGREES(1); break; case 3: if (itemBox->someTimer == 0x14) { @@ -20,9 +20,9 @@ void update_actor_item_box_hot_air_balloon(struct ItemBox* itemBox) { itemBox->flags = -0x4000; } else { itemBox->someTimer++; - itemBox->rot[0] += 0x444; + itemBox->rot[0] += DEGREES(6); itemBox->rot[1] -= 0x2D8; - itemBox->rot[2] += 0x16C; + itemBox->rot[2] += DEGREES(2); } break; } @@ -48,9 +48,9 @@ void update_actor_item_box(struct ItemBox* itemBox) { } break; case 2: - itemBox->rot[0] += 0xB6; - itemBox->rot[1] -= 0x16C; - itemBox->rot[2] += 0xB6; + itemBox->rot[0] += DEGREES(1); + itemBox->rot[1] -= DEGREES(2); + itemBox->rot[2] += DEGREES(1); break; case 3: if (itemBox->someTimer == 20) { @@ -59,9 +59,9 @@ void update_actor_item_box(struct ItemBox* itemBox) { itemBox->flags = 0xC000; } else { itemBox->someTimer++; - itemBox->rot[0] += 0x444; + itemBox->rot[0] += DEGREES(6); itemBox->rot[1] -= 0x2D8; - itemBox->rot[2] += 0x16C; + itemBox->rot[2] += DEGREES(2); } break; } diff --git a/src/actors/mario_sign/update.inc.c b/src/actors/mario_sign/update.inc.c index 6a061eddde..3f1aabacde 100644 --- a/src/actors/mario_sign/update.inc.c +++ b/src/actors/mario_sign/update.inc.c @@ -14,7 +14,7 @@ void update_actor_mario_sign(struct Actor* arg0) { arg0->rot[1] += 1820; } } else { - arg0->rot[1] += 182; + arg0->rot[1] += DEGREES(1); } } } diff --git a/src/actors/train/render.inc.c b/src/actors/train/render.inc.c index c5b8dfc7cd..27f7b1669e 100644 --- a/src/actors/train/render.inc.c +++ b/src/actors/train/render.inc.c @@ -80,7 +80,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x16C)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(2))); vec3f_set(sp160, 17.0f, 6.0f, 16.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -93,7 +93,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x16C)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(2))); vec3f_set(sp160, -17.0f, 6.0f, 16.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -106,7 +106,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x444)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(6))); vec3f_set(sp160, 17.0f, 12.0f, -12.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -119,7 +119,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22D70); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x444)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(6))); vec3f_set(sp160, -17.0f, 12.0f, -12.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -220,7 +220,7 @@ void render_actor_train_tender(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x444)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(6))); vec3f_set(sp160, 17.0f, 6.0f, -8.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -232,7 +232,7 @@ void render_actor_train_tender(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x444)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(6))); vec3f_set(sp160, -17.0f, 6.0f, -8.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -310,7 +310,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x222)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(3))); vec3f_set(sp160, 17.0f, 6.0f, 12.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -322,7 +322,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x222)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(3))); vec3f_set(sp160, -17.0f, 6.0f, 12.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -358,7 +358,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x16C)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(2))); vec3f_set(sp160, 17.0f, 6.0f, -24.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -370,7 +370,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x16C)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(2))); vec3f_set(sp160, -17.0f, 6.0f, -24.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); diff --git a/src/actors/train/update.inc.c b/src/actors/train/update.inc.c index 101cd4c5ae..95398a4595 100644 --- a/src/actors/train/update.inc.c +++ b/src/actors/train/update.inc.c @@ -8,7 +8,7 @@ * @param arg0 */ void update_actor_train_engine(struct TrainCar* arg0) { - arg0->wheelRot -= 0x666; + arg0->wheelRot -= DEGREES(9); if (arg0->unk_08 != 0.0f) { arg0->unk_08 = 0.0f; @@ -34,5 +34,5 @@ void update_actor_train_tender(struct TrainCar* tender) { * @param arg0 */ void update_actor_train_passenger_car(struct TrainCar* arg0) { - arg0->wheelRot -= 0x666; + arg0->wheelRot -= DEGREES(9); } diff --git a/src/actors/wario_sign/update.inc.c b/src/actors/wario_sign/update.inc.c index 645b797747..9492cf244c 100644 --- a/src/actors/wario_sign/update.inc.c +++ b/src/actors/wario_sign/update.inc.c @@ -7,5 +7,5 @@ * @param arg0 */ void update_actor_wario_sign(struct Actor* arg0) { - arg0->rot[1] += 0xB6; + arg0->rot[1] += DEGREES(1); } diff --git a/src/actors/yoshi_egg/update.inc.c b/src/actors/yoshi_egg/update.inc.c index 87c217a2dc..8b7834c513 100644 --- a/src/actors/yoshi_egg/update.inc.c +++ b/src/actors/yoshi_egg/update.inc.c @@ -22,5 +22,5 @@ void update_actor_yoshi_egg(struct YoshiValleyEgg* egg) { } egg->eggRot -= 0x4FA; } - egg->eggRot -= 0x222; + egg->eggRot -= DEGREES(3); } diff --git a/src/camera.c b/src/camera.c index 914689f95e..cebaef95f5 100644 --- a/src/camera.c +++ b/src/camera.c @@ -714,20 +714,20 @@ void func_8001E45C(Camera* camera, Player* player, s8 arg2) { if ((player->effects & DRIFT_OUTSIDE_EFFECT) == DRIFT_OUTSIDE_EFFECT) { move_s16_towards(&camera->unk_B0, -0x0B60, 0.1f); } else { - move_s16_towards(&camera->unk_B0, -0x0888, 0.1f); + move_s16_towards(&camera->unk_B0, -DEGREES(12), 0.1f); } } else { var_a3 = (player->unk_078 / 2) + 0xA5; if ((player->effects & DRIFT_OUTSIDE_EFFECT) == DRIFT_OUTSIDE_EFFECT) { move_s16_towards(&camera->unk_B0, 0x0B60, 0.1f); } else { - move_s16_towards(&camera->unk_B0, 0x0888, 0.1f); + move_s16_towards(&camera->unk_B0, DEGREES(12), 0.1f); } } } } else { move_s16_towards(&camera->unk_B0, 0, 0.05f); - var_a3 = ((s16) camera->unk_2C / 182) - ((s16) player->rotation[1] / 182); + var_a3 = ((s16) camera->unk_2C / DEGREES(1)) - ((s16) player->rotation[1] / DEGREES(1)); if (player->unk_078 == 0) { if ((player->effects & AB_SPIN_EFFECT) == AB_SPIN_EFFECT) { var_a3 = 0x02D8; @@ -840,20 +840,20 @@ void func_8001EA0C(Camera* camera, Player* player, s8 arg2) { if ((player->effects & DRIFT_OUTSIDE_EFFECT) == DRIFT_OUTSIDE_EFFECT) { move_s16_towards(&camera->unk_B0, -0x0B60, 0.1f); } else { - move_s16_towards(&camera->unk_B0, -0x0888, 0.1f); + move_s16_towards(&camera->unk_B0, -DEGREES(12), 0.1f); } } else { var_a3 = (player->unk_078 / 2) + 0xA5; if ((player->effects & DRIFT_OUTSIDE_EFFECT) == DRIFT_OUTSIDE_EFFECT) { move_s16_towards(&camera->unk_B0, 0x0B60, 0.1f); } else { - move_s16_towards(&camera->unk_B0, 0x0888, 0.1f); + move_s16_towards(&camera->unk_B0, DEGREES(12), 0.1f); } } } } else { move_s16_towards(&camera->unk_B0, 0, 0.05f); - var_a3 = ((s16) camera->unk_2C / 182) - ((s16) player->rotation[1] / 182); + var_a3 = ((s16) camera->unk_2C / DEGREES(1)) - ((s16) player->rotation[1] / DEGREES(1)); if (player->unk_078 == 0) { if ((player->effects & AB_SPIN_EFFECT) == AB_SPIN_EFFECT) { var_a3 = 0x02D8; diff --git a/src/code_8003DC40.c b/src/code_8003DC40.c index b1d11eb099..5220f75668 100644 --- a/src/code_8003DC40.c +++ b/src/code_8003DC40.c @@ -21,15 +21,15 @@ UNUSED void func_8003DC50(Player* player, Vec3f arg1) { if (player) {}; if (player->unk_230 <= player->unk_23C) { if (player->collision.unk48[1] >= 0.1736) { - arg1[0] = (player->unk_206 / 182) * 0x78; - arg1[2] = -(player->slopeAccel / 182) * 0x78; + arg1[0] = (player->unk_206 / DEGREES(1)) * 0x78; + arg1[2] = -(player->slopeAccel / DEGREES(1)) * 0x78; } else { arg1[0] = thing1; arg1[2] = thing2; } } else if (player->collision.unk48[1] >= 0.1736) { - arg1[0] = (player->unk_206 / 182) * 0x78; - arg1[2] = -(player->slopeAccel / 182) * 0x78; + arg1[0] = (player->unk_206 / DEGREES(1)) * 0x78; + arg1[2] = -(player->slopeAccel / DEGREES(1)) * 0x78; } else { arg1[0] = thing1; arg1[2] = thing2; @@ -45,15 +45,15 @@ UNUSED void func_8003DE4C(Player* player, Vec3f arg1) { if (player) {}; if (player->unk_230 <= player->unk_23C) { if (player->collision.unk54[1] >= 0.1736) { - arg1[0] = (player->unk_206 / 182) * 0x78; - arg1[2] = -(player->slopeAccel / 182) * 0x78; + arg1[0] = (player->unk_206 / DEGREES(1)) * 0x78; + arg1[2] = -(player->slopeAccel / DEGREES(1)) * 0x78; } else { arg1[0] = thing1; arg1[2] = thing2; } } else if (player->collision.unk54[1] >= 0.1736) { - arg1[0] = (player->unk_206 / 182) * 0x78; - arg1[2] = -(player->slopeAccel / 182) * 0x78; + arg1[0] = (player->unk_206 / DEGREES(1)) * 0x78; + arg1[2] = -(player->slopeAccel / DEGREES(1)) * 0x78; } else { arg1[0] = thing1; arg1[2] = thing2; @@ -69,8 +69,8 @@ void func_8003E048(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 1, 2); if (player->collision.orientationVector[1] <= 0.8829f) { - arg3[0] = ((player->unk_206 / 182) * 0xB4); - arg3[2] = (-(player->slopeAccel / 182) * 0xB4); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0xB4); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0xB4); player_decelerate_alternative(player, 4.0f); player->unk_DAC = 0.5f; if ((player->effects & MUSHROOM_EFFECT) != 0) { @@ -80,11 +80,11 @@ void func_8003E048(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 } } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || ((player->effects & TERRAIN_TUMBLE_EFFECT) == TERRAIN_TUMBLE_EFFECT)) { - arg3[0] = ((player->unk_206 / 182) * 0x32); - arg3[2] = (-(player->slopeAccel / 182) * 0x3C); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0x32); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x3C); } else { arg3[0] = 0.0f; - arg3[2] = (-(player->slopeAccel / 182) * 0x32); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x32); } arg3[1] = 0.0f; mtxf_transform_vec3f_mat3(arg3, player->orientationMatrix); @@ -96,8 +96,8 @@ void func_8003E37C(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 0.5f, 2); if ((player->collision.orientationVector[1] <= 0.7318f) || (player->surfaceType == CLIFF)) { - arg3[0] = ((player->unk_206 / 182) * 0xB4); - arg3[2] = (-(player->slopeAccel / 182) * 0xB4); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0xB4); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0xB4); if (((player->speed / 18.0f) * 216.0f) >= 8.0f) { player_decelerate_alternative(player, 5.0f); } @@ -109,11 +109,11 @@ void func_8003E37C(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 } } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || ((player->effects & TERRAIN_TUMBLE_EFFECT) == TERRAIN_TUMBLE_EFFECT)) { - arg3[0] = ((player->unk_206 / 182) * 0x32); - arg3[2] = (-(player->slopeAccel / 182) * 0x32); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0x32); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x32); } else { arg3[0] = 0.0f; - arg3[2] = (-(player->slopeAccel / 182) * 0x32); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x32); } arg3[1] = 0.0f; mtxf_transform_vec3f_mat3(arg3, player->orientationMatrix); @@ -125,17 +125,17 @@ void func_8003E6EC(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 0.5f, 2); if (player->collision.orientationVector[1] <= 0.8829f) { - arg3[0] = ((player->unk_206 / 182) * 0xB4); - arg3[2] = (-(player->slopeAccel / 182) * 0xB4); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0xB4); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0xB4); player_decelerate_alternative(player, 4.0f); func_8003DC40(player); } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || ((player->effects & TERRAIN_TUMBLE_EFFECT) == TERRAIN_TUMBLE_EFFECT)) { - arg3[0] = ((player->unk_206 / 182) * 0x32); - arg3[2] = (-(player->slopeAccel / 182) * 0x3C); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0x32); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x3C); } else { arg3[0] = 0.0f; - arg3[2] = (-(player->slopeAccel / 182) * 0x32); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x32); } arg3[1] = 0.0f; mtxf_transform_vec3f_mat3(arg3, player->orientationMatrix); @@ -147,8 +147,8 @@ void func_8003E9EC(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 1.2f, 2); if (player->collision.orientationVector[1] <= 0.8357f) { - arg3[0] = ((player->unk_206 / 182) * 0x78); - arg3[2] = (-(player->slopeAccel / 182) * 0xB4); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0x78); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0xB4); player_decelerate_alternative(player, 4.0f); func_8003DC40(player); } else { @@ -158,18 +158,18 @@ void func_8003E9EC(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 (player->tyres[BACK_RIGHT].surfaceType == ASPHALT) || (player->tyres[FRONT_RIGHT].surfaceType == ASPHALT) || (player->tyres[FRONT_LEFT].surfaceType == ASPHALT)) { - arg3[0] = ((player->unk_206 / 182) * 5); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 5); } else { - arg3[0] = ((player->unk_206 / 182) * 0x28); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0x28); } - arg3[2] = (-(player->slopeAccel / 182) * 0x28); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x28); } else { arg3[0] = 0.0f; - arg3[2] = (-(player->slopeAccel / 182) * 0x32); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x32); } if ((player->effects & TERRAIN_TUMBLE_EFFECT) != 0) { - arg3[0] = ((player->unk_206 / 182) * 0x78); - arg3[2] = (-(player->slopeAccel / 182) * 0xB4); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0x78); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0xB4); } } arg3[1] = 0.0f; @@ -182,17 +182,17 @@ void func_8003EE2C(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 *arg7 += arg1[2] * player->collision.surfaceDistance[2] * 1; func_8002A5F4(arg1, *arg4, arg2, 0.5f, 2); if (player->collision.orientationVector[1] <= 0.8357f) { - arg3[0] = ((player->unk_206 / 182) * 0x78); - arg3[2] = (-(player->slopeAccel / 182) * 0xB4); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0x78); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0xB4); player_decelerate_alternative(player, 4.0f); func_8003DC40(player); } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || ((player->effects & TERRAIN_TUMBLE_EFFECT) == TERRAIN_TUMBLE_EFFECT)) { - arg3[0] = ((player->unk_206 / 182) * 0x32); - arg3[2] = (-(player->slopeAccel / 182) * 0x3C); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0x32); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x3C); } else { arg3[0] = 0.0f; - arg3[2] = (-(player->slopeAccel / 182) * 0x32); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x32); } arg3[1] = 0.0f; mtxf_transform_vec3f_mat3(arg3, player->orientationMatrix); @@ -207,19 +207,19 @@ void func_8003F138(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 player->kartProps &= ~BACK_UP; } if (player->collision.orientationVector[1] <= 0.8357f) { - arg3[0] = ((player->unk_206 / 182) * 0xC8); - arg3[2] = (-(player->slopeAccel / 182) * 0xC8); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0xC8); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0xC8); player_decelerate_alternative(player, 4.0f); player->unk_DAC = 0.5f; arg3[0] = 0; } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || ((player->effects & TERRAIN_TUMBLE_EFFECT) == TERRAIN_TUMBLE_EFFECT)) { - arg3[0] = ((player->unk_206 / 182) * 0x78); - arg3[2] = (-(player->slopeAccel / 182) * 0x78); + arg3[0] = ((player->unk_206 / DEGREES(1)) * 0x78); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x78); arg3[0] = 0; } else { arg3[0] = 0.0f; - arg3[2] = (-(player->slopeAccel / 182) * 0x32); + arg3[2] = (-(player->slopeAccel / DEGREES(1)) * 0x32); } arg3[1] = 0.0f; arg3[2] = 0.0f; diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 557c48ae99..217c6423fb 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -1723,7 +1723,7 @@ void func_8005AB60(void) { break; case 1: s16_step_towards(&playerHUD[PLAYER_ONE].speedometerX, 0x106, 0x10); - if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 0xB6, 0x10) != 0) { + if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 182, 0x10) != 0) { playerHUD[PLAYER_ONE].unk_78++; playerHUD[PLAYER_ONE].unk_79 = 1; } @@ -1736,7 +1736,7 @@ void func_8005AB60(void) { break; case 3: s16_step_towards(&playerHUD[PLAYER_ONE].speedometerX, 0x106, 4); - if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 0xB6, 4) != 0) { + if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 182, 4) != 0) { playerHUD[PLAYER_ONE].unk_78++; } break; @@ -1748,7 +1748,7 @@ void func_8005AB60(void) { break; case 5: s16_step_towards(&playerHUD[PLAYER_ONE].speedometerX, 0x106, 4); - if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 0xB6, 4) != 0) { + if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 182, 4) != 0) { playerHUD[PLAYER_ONE].unk_78++; } break; @@ -1760,7 +1760,7 @@ void func_8005AB60(void) { break; case 7: s16_step_towards(&playerHUD[PLAYER_ONE].speedometerX, 0x106, 2); - if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 0xB6, 2) != 0) { + if (s16_step_towards(&playerHUD[PLAYER_ONE].speedometerY, 182, 2) != 0) { playerHUD[PLAYER_ONE].unk_78++; } break; @@ -2859,7 +2859,7 @@ void set_drift_particles(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 ar player->tyres[BACK_RIGHT].surfaceType, 0); } - temp_lo = player->unk_0C0 / 182; + temp_lo = player->unk_0C0 / DEGREES(1); if ((temp_lo >= 7) || (temp_lo < -6)) { init_particle_player(&player->particlePool1[arg1], DRIFT_PARTICLE, 0.35f); if (player->driftState == 0) { @@ -3087,7 +3087,7 @@ void setup_tyre_particles(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UN if ((arg1 == 0) && ((player->particlePool1[arg2].timer > 0) || (player->particlePool1[arg2].isAlive == 0))) { if (((((player->speed / 18.0f) * 216.0f) >= 30.0f) && - ((((player->unk_0C0 / 182) > 0x14) || ((player->unk_0C0 / 182) < (-0x14))))) || + ((((player->unk_0C0 / DEGREES(1)) > 0x14) || ((player->unk_0C0 / DEGREES(1)) < (-0x14))))) || ((player->previousSpeed - player->speed) >= 0.04)) { set_particle_position_and_rotation(player, &player->particlePool1[arg1], tyre_x, tyre_y, tyre_z, (s8) surfaceType, (s8) var_t3); init_particle_player(&player->particlePool1[arg1], GROUND_PARTICLE, 0.46f); @@ -3096,7 +3096,7 @@ void setup_tyre_particles(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UN } } else if ((player->particlePool1[arg2].timer > 0) && (((((player->speed / 18.0f) * 216.0f) >= 30.0f) && - (((player->unk_0C0 / 182) >= 0x15) || ((player->unk_0C0 / 182) < -0x14))) || + (((player->unk_0C0 / DEGREES(1)) >= 0x15) || ((player->unk_0C0 / DEGREES(1)) < -0x14))) || ((player->previousSpeed - player->speed) >= 0.04))) { set_particle_position_and_rotation(player, &player->particlePool1[arg1], tyre_x, tyre_y, tyre_z, (s8) surfaceType, (s8) var_t3); init_particle_player(&player->particlePool1[arg1], GROUND_PARTICLE, 0.46f); @@ -3652,8 +3652,8 @@ void func_80060BCC(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 set_particle_position_and_rotation(player, &player->particlePool1[arg1], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0); init_particle_player(&player->particlePool1[arg1], 0x0B, 0.4f); set_particle_colour(&player->particlePool1[arg1], RGB32(0xFF, 0xFF, 0xFF), 0x00FF); - player->particlePool1[arg1].pos[2] = player->pos[2] + (coss(sp54 * 0xB6) * -1.8); - player->particlePool1[arg1].pos[0] = player->pos[0] + (sins(sp54 * 0xB6) * -1.8); + player->particlePool1[arg1].pos[2] = player->pos[2] + (coss(sp54 * DEGREES(1)) * -1.8); + player->particlePool1[arg1].pos[0] = player->pos[0] + (sins(sp54 * DEGREES(1)) * -1.8); player->particlePool1[arg1].pos[1] = (player->pos[1] - player->boundingBoxSize) + sp4C + 2.0f; player->particlePool1[arg1].unk_018 = sp44 + 1.0f; player->particlePool1[arg1].scale = (sp48 + 2.0f) / 10.0f; @@ -3661,8 +3661,8 @@ void func_80060BCC(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 set_particle_position_and_rotation(player, &player->particlePool1[arg1], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0); init_particle_player(&player->particlePool1[arg1], 0x0B, 0.4f); set_particle_colour(&player->particlePool1[arg1], RGB32(0xFF, 0xFF, 0xFF), 0x00FF); - player->particlePool1[arg1].pos[2] = player->pos[2] + (coss(sp54 * 0xB6) * -1.8); - player->particlePool1[arg1].pos[0] = player->pos[0] + (sins(sp54 * 0xB6) * -1.8); + player->particlePool1[arg1].pos[2] = player->pos[2] + (coss(sp54 * DEGREES(1)) * -1.8); + player->particlePool1[arg1].pos[0] = player->pos[0] + (sins(sp54 * DEGREES(1)) * -1.8); player->particlePool1[arg1].pos[1] = (player->pos[1] - player->boundingBoxSize) + sp4C + 2.0f; player->particlePool1[arg1].unk_018 = sp44 + 1.0f; player->particlePool1[arg1].scale = (sp48 + 2.0f) / 10.0f; @@ -3762,7 +3762,7 @@ void func_800615AC(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UN UNUSED s32 stackPadding0; UNUSED s32 stackPadding1; f32 temp_f0; - f32 sp28[10] = { -182.0f, 182.0f, 364.0f, -364.0f, 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f }; + f32 sp28[10] = { (f32) DEGREES(-1), (f32) DEGREES(1), (f32) DEGREES(2), (f32) -DEGREES(2), 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f }; if (random_int(3U) == 2.0f) { player->particlePool3[arg1].isAlive = 1; @@ -3808,8 +3808,8 @@ void func_80061754(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s32 arg3, U player->particlePool3[arg1].green += temp_s1; player->particlePool3[arg1].blue += temp_s1; } - player->particlePool3[arg1].pos[2] = player->pos[2] + (coss(sp54 * 0xB6) * -5.0f); - player->particlePool3[arg1].pos[0] = player->pos[0] + (sins(sp54 * 0xB6) * -5.0f); + player->particlePool3[arg1].pos[2] = player->pos[2] + (coss(sp54 * DEGREES(1)) * -5.0f); + player->particlePool3[arg1].pos[0] = player->pos[0] + (sins(sp54 * DEGREES(1)) * -5.0f); player->particlePool3[arg1].pos[1] = (player->pos[1] - player->boundingBoxSize) + sp4C + 2.0f; player->particlePool3[arg1].unk_018 = sp44 + 1.0f; player->particlePool3[arg1].scale = sp48 + 1.0f; @@ -3838,16 +3838,16 @@ void func_80061A34(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 set_particle_position_and_rotation(player, &player->particlePool3[arg1], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0); init_particle_player(&player->particlePool3[arg1], 7, 1.0f); set_particle_colour(&player->particlePool3[arg1], RGB32(0xFF, 0xFF, 0xFF), 0x00FF); - player->particlePool3[arg1].pos[2] = player->pos[2] + (coss(sp54 * 0xB6) * -2.0); - player->particlePool3[arg1].pos[0] = player->pos[0] + (sins(sp54 * 0xB6) * -2.0); + player->particlePool3[arg1].pos[2] = player->pos[2] + (coss(sp54 * DEGREES(1)) * -2.0); + player->particlePool3[arg1].pos[0] = player->pos[0] + (sins(sp54 * DEGREES(1)) * -2.0); player->particlePool3[arg1].pos[1] = (player->pos[1] - player->boundingBoxSize) + sp4C + 2.0f; player->particlePool3[arg1].scale = (sp48 + 2.0f) / 10.0f; } else if (player->particlePool3[arg2].timer > 0) { set_particle_position_and_rotation(player, &player->particlePool3[arg1], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0); init_particle_player(&player->particlePool3[arg1], 7, 1.0f); set_particle_colour(&player->particlePool3[arg1], RGB32(0xFF, 0xFF, 0xFF), 0x00FF); - player->particlePool3[arg1].pos[2] = player->pos[2] + (coss(sp54 * 0xB6) * -2.0); - player->particlePool3[arg1].pos[0] = player->pos[0] + (sins(sp54 * 0xB6) * -2.0); + player->particlePool3[arg1].pos[2] = player->pos[2] + (coss(sp54 * DEGREES(1)) * -2.0); + player->particlePool3[arg1].pos[0] = player->pos[0] + (sins(sp54 * DEGREES(1)) * -2.0); player->particlePool3[arg1].pos[1] = (player->pos[1] - player->boundingBoxSize) + (f32) sp4C + 2.0f; player->particlePool3[arg1].scale = (sp48 + 2.0f) / 10.0f; } @@ -3858,7 +3858,7 @@ void func_80061D4C(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UN UNUSED s32 stackPadding0; UNUSED s32 stackPadding1; UNUSED s32 stackPadding2; - f32 sp20[10] = { -182.0f, 182.0f, 364.0f, -364.0f, 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f }; + f32 sp20[10] = { (f32) DEGREES(-1), (f32) DEGREES(1), (f32) DEGREES(2), (f32) -DEGREES(2), 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f }; if (random_int(3U) == 2.0f) { player->particlePool3[arg1].isAlive = 1; @@ -3904,9 +3904,9 @@ void func_80061EF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 set_particle_colour(&player->particlePool3[arg1], RGB32(0xFF, 0xFF, 0xFF), 0x0060); player->particlePool3[arg1].rotation = 0; if (player->particlePool3[arg1].unk_010 == 1) { - player->particlePool3[arg1].rotation += 0x888; + player->particlePool3[arg1].rotation += DEGREES(12); } else { - player->particlePool3[arg1].rotation -= 0x888; + player->particlePool3[arg1].rotation -= DEGREES(12); } player->particlePool3[arg1].pos[2] = player->pos[2] + @@ -3920,9 +3920,9 @@ void func_80061EF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 set_particle_colour(&player->particlePool3[arg1], RGB32(0xFF, 0xFF, 0xFF), 0x0060); player->particlePool3[arg1].rotation = 0; if (player->particlePool3[arg1].unk_010 == 1) { - player->particlePool3[arg1].rotation += 0x888; + player->particlePool3[arg1].rotation += DEGREES(12); } else { - player->particlePool3[arg1].rotation -= 0x888; + player->particlePool3[arg1].rotation -= DEGREES(12); } player->particlePool3[arg1].pos[2] = player->pos[2] + @@ -5870,7 +5870,7 @@ void update_player_one_balloon_position(Player* player, f32 arg1, f32 arg2, s8 p D_8018D710[playerId][balloonId] = 0.0f; } D_8018D620[playerId][balloonId] = -player->rotation[1] - player->unk_0C0; - move_s16_towards(&D_8018D890[playerId][balloonId], player->speed * 182.0f, 0.1f); + move_s16_towards(&D_8018D890[playerId][balloonId], player->speed * (f32) DEGREES(1), 0.1f); } if (D_8018D830[playerId][balloonId] == 1) { D_8018D770[playerId][balloonId] += D_8018D800[playerId][balloonId] - player->speed; diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index 437580da1e..0be154d51b 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -1052,7 +1052,7 @@ void init_hud_one_player(void) { D_8018D3C4 = 0x00000032; D_8018D3BC = 0x0028; D_8018D3C0 = 0x00000050; - D_801657A2 = 0x0333; + D_801657A2 = (4.5f * DEGREES(1)); switch (gModeSelection) { /* irregular */ case 0: D_8018D158 = 8; @@ -1121,7 +1121,7 @@ void init_hud_two_player_vertical(void) { D_8018D3C4 = 0x1E; D_8018D3BC = 0x18; D_8018D3C0 = 0x28; - D_801657A2 = 0x666; + D_801657A2 = DEGREES(9); switch (gModeSelection) { /* irregular */ case GRAND_PRIX: D_8018D158 = 8; @@ -1195,7 +1195,7 @@ void init_hud_two_player_horizontal() { D_8018D3C4 = 0x1E; D_8018D3BC = 0x18; D_8018D3C0 = 0x28; - D_801657A2 = 0x666; + D_801657A2 = DEGREES(9); switch (gModeSelection) { /* irregular */ case GRAND_PRIX: D_8018D158 = 8; @@ -1312,5 +1312,5 @@ void init_hud_three_four_player(void) { D_8018D3C4 = 0x00000014; D_8018D3BC = 0x00000010; D_8018D3C0 = 0x0000001E; - D_801657A2 = 0x0888; + D_801657A2 = DEGREES(12); } diff --git a/src/cpu_vehicles_camera_path.c b/src/cpu_vehicles_camera_path.c index 5774acdac4..5352dfd287 100644 --- a/src/cpu_vehicles_camera_path.c +++ b/src/cpu_vehicles_camera_path.c @@ -680,8 +680,8 @@ void detect_wrong_player_direction(s32 playerId, Player* player) { pathIndex = (s16) gPathIndexByPlayerId[playerId]; pathPoint = gNearestPathPointByPlayerId[playerId]; - playerAngle = (s16) ((s16) player->rotation[1] / DEGREES_CONVERSION_FACTOR); - pathPointAngle = (s16) ((s16) gPathExpectedRotation[pathIndex][pathPoint] / DEGREES_CONVERSION_FACTOR); + playerAngle = (s16) ((s16) player->rotation[1] / DEGREES(1)); + pathPointAngle = (s16) ((s16) gPathExpectedRotation[pathIndex][pathPoint] / DEGREES(1)); rotationDifference = playerAngle - pathPointAngle; @@ -1669,8 +1669,8 @@ void update_player(s32 playerId) { gOffsetPosition[2] = (gPreviousPlayerAiOffsetZ[playerId] + gOffsetPosition[2]) * 0.5f; // average gPreviousPlayerAiOffsetX[playerId] = gOffsetPosition[0]; gPreviousPlayerAiOffsetZ[playerId] = gOffsetPosition[2]; - minAngle = onePointFive * 182.0f; - maxAngle = -onePointFive * 182.0f; + minAngle = onePointFive * (f32) DEGREES(1); + maxAngle = -onePointFive * (f32) DEGREES(1); angle = -get_xz_angle_between_points(player->pos, gOffsetPosition); angle -= (newAngle = player->rotation[1]); diff --git a/src/effects.c b/src/effects.c index e319637080..dc32cc8a5a 100644 --- a/src/effects.c +++ b/src/effects.c @@ -263,7 +263,7 @@ void add_spinout_effect(Player* player, s8 playerIndex) { ((player->effects & DRIVING_SPINOUT_EFFECT) != DRIVING_SPINOUT_EFFECT)) { player->effects &= ~DRIFTING_EFFECT; - if ((player->unk_0C0 / DEGREES_CONVERSION_FACTOR) >= 0) { + if ((player->unk_0C0 / DEGREES(1)) >= 0) { player->effects |= DRIVING_SPINOUT_EFFECT; } else { player->effects |= BANANA_SPINOUT_EFFECT; @@ -340,7 +340,7 @@ void func_8008C9EC(Player* player, s8 playerIndex) { if ((player->effects & BANANA_SPINOUT_EFFECT) == BANANA_SPINOUT_EFFECT) { player->rotation[1] -= sp30[player->unk_0B2]; D_8018D920[playerIndex] -= sp30[player->unk_0B2]; - stackPadding1 = (u16) D_8018D920[playerIndex] / (0x10000 / (0x168 / (sp30[player->unk_0B2] / 182))); + stackPadding1 = (u16) D_8018D920[playerIndex] / (0x10000 / (0x168 / (sp30[player->unk_0B2] / DEGREES(1)))); if (stackPadding1 == 0) { player->unk_0B2--; if (player->unk_0B2 <= 0) { @@ -353,7 +353,7 @@ void func_8008C9EC(Player* player, s8 playerIndex) { } else { player->rotation[1] += sp30[player->unk_0B2]; D_8018D920[playerIndex] -= sp30[player->unk_0B2]; - stackPadding2 = (u16) D_8018D920[playerIndex] / (0x10000 / (0x168 / (sp30[player->unk_0B2] / 182))); + stackPadding2 = (u16) D_8018D920[playerIndex] / (0x10000 / (0x168 / (sp30[player->unk_0B2] / DEGREES(1)))); if (stackPadding2 == 0) { player->unk_0B2--; if (player->unk_0B2 <= 0) { @@ -602,7 +602,7 @@ void func_8008D698(Player* player, s8 playerIndex) { } else { player->rotation[1] -= 1820; D_8018D920[playerIndex] -= 1820; - temp = ((u16) D_8018D920[playerIndex] / 1820); + temp = ((u16) D_8018D920[playerIndex] / DEGREES(10)); } if (temp == 0) { --player->unk_0B2; @@ -656,7 +656,7 @@ void func_8008D8B4(Player* player, s8 playerIndex) { } else { player->rotation[1] -= 1820; D_8018D920[playerIndex] -= 1820; - temp = ((u16) (D_8018D920[playerIndex]) / 1820); + temp = ((u16) (D_8018D920[playerIndex]) / DEGREES(10)); } if (temp == 0) { --player->unk_0B2; @@ -951,7 +951,7 @@ void func_8008E4A4(Player* player, s8 playerIndex) { player->unk_0C0 = 0; player->steerPosition = 0; player->unk_0C2 = 0xF; - player->unk_042 += 0xAAA; + player->unk_042 += DEGREES(15); player->unk_08C = 0.0f; player->currentSpeed = 0.0f; player->velocity[0] = 0.0f; @@ -1065,7 +1065,7 @@ void apply_hit_by_star_effect(Player* player, s8 playerIndex) { player->unk_0C0 = 0; player->steerPosition = 0; player->unk_0C2 = 0xF; - player->unk_042 += 0xAAA; + player->unk_042 += DEGREES(15); player->unk_08C /= 2; player->currentSpeed = 0.0f; player->effects &= ~(BANANA_SPINOUT_EFFECT | DRIVING_SPINOUT_EFFECT); @@ -1274,10 +1274,10 @@ void func_8008F1B8(Player* player, s8 arg1) { player->unk_08C = (player->unk_210 * 0.05); if (player->unk_0B2 < 0) { if ((player->kartProps & EARLY_SPINOUT_LEFT) == EARLY_SPINOUT_LEFT) { - player->rotation[1] += 182; - D_8018D920[arg1] += 182; + player->rotation[1] += DEGREES(1); + D_8018D920[arg1] += DEGREES(1); - temp = ((u16) D_8018D920[arg1] / 182); + temp = ((u16) D_8018D920[arg1] / DEGREES(1)); if (temp == 180) { player->effects &= ~EARLY_START_SPINOUT_EFFECT; player->type &= ~PLAYER_UNKNOWN_0x80; @@ -1285,9 +1285,9 @@ void func_8008F1B8(Player* player, s8 arg1) { } } else { - player->rotation[1] -= 182; - D_8018D920[arg1] -= 182; - temp = ((u16) D_8018D920[arg1] / 182); + player->rotation[1] -= DEGREES(1); + D_8018D920[arg1] -= DEGREES(1); + temp = ((u16) D_8018D920[arg1] / DEGREES(1)); if (temp == 180) { player->effects &= ~EARLY_START_SPINOUT_EFFECT; player->type &= ~PLAYER_UNKNOWN_0x80; @@ -1296,9 +1296,9 @@ void func_8008F1B8(Player* player, s8 arg1) { } } else { if ((player->unk_0B2 & 1) != 0) { - player->rotation[1] -= 364; - D_8018D920[arg1] -= 364; - temp = ((u16) D_8018D920[arg1] / 364); + player->rotation[1] -= DEGREES(2); + D_8018D920[arg1] -= DEGREES(2); + temp = ((u16) D_8018D920[arg1] / DEGREES(2)); if (temp < 71) { --player->unk_0B2; } @@ -1306,9 +1306,9 @@ void func_8008F1B8(Player* player, s8 arg1) { player->kartProps &= ~EARLY_SPINOUT_RIGHT; return; } - player->rotation[1] += 364; - D_8018D920[arg1] += 364; - temp = ((u16) D_8018D920[arg1] / 364); + player->rotation[1] += DEGREES(2); + D_8018D920[arg1] += DEGREES(2); + temp = ((u16) D_8018D920[arg1] / DEGREES(2)); if (temp >= 110) { --player->unk_0B2; } diff --git a/src/player_controller.c b/src/player_controller.c index a7a4927ee1..874439dd7c 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -698,19 +698,19 @@ void func_80029200(Player* player, s8 screenId) { if (((s32) player->slopeAccel < -0x4F9) && ((s32) player->slopeAccel >= -0x71B)) { player->animGroupSelector[screenId] = 1; } - if ((player->slopeAccel < -0x221) && (player->slopeAccel >= -0x4F9)) { + if ((player->slopeAccel <= -DEGREES(3)) && (player->slopeAccel >= -0x4F9)) { player->animGroupSelector[screenId] = 2; } - if ((player->slopeAccel < -0x16B) && (player->slopeAccel >= -0x221)) { + if ((player->slopeAccel <= -DEGREES(2)) && (player->slopeAccel > -DEGREES(3))) { player->animGroupSelector[screenId] = 3; } - if ((player->slopeAccel < 0x16C) && (player->slopeAccel >= -0x16B)) { + if ((player->slopeAccel < DEGREES(2)) && (player->slopeAccel > -DEGREES(2))) { player->animGroupSelector[screenId] = 4; } - if ((player->slopeAccel >= 0x16C) && (player->slopeAccel < 0x222)) { + if ((player->slopeAccel >= DEGREES(2)) && (player->slopeAccel < DEGREES(3))) { player->animGroupSelector[screenId] = 5; } - if ((player->slopeAccel >= 0x222) && (player->slopeAccel < 0x4FA)) { + if ((player->slopeAccel >= DEGREES(3)) && (player->slopeAccel < 0x4FA)) { player->animGroupSelector[screenId] = 6; } if ((player->slopeAccel >= 0x4FA) && (player->slopeAccel < 0x71C)) { @@ -783,11 +783,11 @@ void func_8002934C(Player* player, Camera* camera, s8 screenId, s8 playerId) { var_a1 = 0x208; var_t0 = 0; } else { - var_a1 = 0x666; + var_a1 = DEGREES(9); var_t0 = 0xF; } } else { - var_a1 = 0x666; + var_a1 = DEGREES(9); var_t0 = 0; } if (((player->effects & UNKNOWN_EFFECT_0x80000) == UNKNOWN_EFFECT_0x80000) || @@ -1146,7 +1146,7 @@ void func_8002A79C(Player* player, s8 playerIndex) { } void func_8002A8A4(Player* player, s8 playerIndex) { - if (((s16) player->unk_0C0 / DEGREES_CONVERSION_FACTOR) > 0) { + if (((s16) player->unk_0C0 / DEGREES(1)) > 0) { if (((s32) player->steerPosition >> 16) <= -10) { if (player->unk_228 < 0x65) { player->unk_228++; @@ -1241,7 +1241,7 @@ void func_8002AAC0(Player* player) { void func_8002AB70(Player* player) { UNUSED s32 pad[2]; if (((player->effects & MIDAIR_EFFECT) != MIDAIR_EFFECT) && (player->unk_08C > 0.0f)) { - if (((player->slopeAccel / 182) < -1) && ((player->slopeAccel / 182) >= -0x14) && + if (((player->slopeAccel / DEGREES(1)) < -1) && ((player->slopeAccel / DEGREES(1)) >= -0x14) && (((player->speed / 18.0f) * 216.0f) >= 20.0f)) { move_f32_towards(&player->kartGravity, 500.0f, 1.0f); move_f32_towards(&player->unk_DAC, 3.0f, 0.05f); @@ -1327,7 +1327,7 @@ void func_8002AE38(Player* player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 ar var_v1 = 0; } if ((player->currentSpeed >= 200.0f) && (var_v1 == 2) && - (((player->unk_0C0 / 182) >= 0x10) || ((player->unk_0C0 / 182) < -0xF))) { + (((player->unk_0C0 / DEGREES(1)) >= 0x10) || ((player->unk_0C0 / DEGREES(1)) < -0xF))) { player->unk_0C0 = atan2s(arg2 - arg4, arg3 - arg5) - atan2s(arg2 - sp28, arg3 - temp_f16); } else { player->unk_0C0 = (atan2s(arg2 - arg4, arg3 - arg5) - atan2s(arg2 - sp28, arg3 - temp_f16)) * 2; @@ -1607,7 +1607,7 @@ void func_8002B9CC(Player* player, s8 playerIndex, UNUSED s32 arg2) { temp = (-(s16) get_xz_angle_between_points(player->pos, &player->oldPos[0])); temp2 = (player->rotation[1] - player->unk_0C0); temp = temp - temp2; - player->unk_234 = temp / 182; + player->unk_234 = temp / DEGREES(1); } } @@ -1618,7 +1618,7 @@ void func_8002BB9C(Player* player, f32* arg1, f32* arg2, UNUSED s8 arg3, UNUSED s16 var_v0; s16 t0; UNUSED s32 pad; - s16 sp30[10] = { 0x0000, 0x00b6, 0x016c, 0x0222, 0x02d8, 0x038e, 0x0444, 0x04fa, 0x05b0, 0x0666 }; + s16 sp30[10] = { 0, DEGREES(1), 0x016c, 3 * DEGREES(1), 0x02d8, 0x038e, 6 * DEGREES(1), 0x04fa, 0x05b0, 9 * DEGREES(1) }; if (((u16) player->unk_256) <= 0) { return; @@ -1649,7 +1649,7 @@ void func_8002BB9C(Player* player, f32* arg1, f32* arg2, UNUSED s8 arg3, UNUSED var_v0 = -(s16) get_xz_angle_between_points(sp58, sp4C); t0 = player->rotation[1]; var_v0 = 0x10000 + (t0 - var_v0); - var_v0 /= 182; + var_v0 /= DEGREES(1); if (var_v0 < 0x97 && (var_v0 > -0x97)) { return; @@ -2071,14 +2071,14 @@ void func_8002D028(Player* player, s8 playerIndex) { thing0 = 8; - if (temp > ((s16) (thing0 * 182))) { - temp = (thing0 * 182); + if (temp > ((s16) (thing0 * DEGREES(1)))) { + temp = (thing0 * DEGREES(1)); } - if (temp < ((s16) (-thing0 * 182))) { - temp = (-thing0 * 182); + if (temp < ((s16) (-thing0 * DEGREES(1)))) { + temp = (-thing0 * DEGREES(1)); } - temp_t1 = (D_80165020[playerIndex] + ((s16) ((temp * 0x35) / (thing0 * 182)))) / 2; + temp_t1 = (D_80165020[playerIndex] + ((s16) ((temp * 0x35) / (thing0 * DEGREES(1))))) / 2; apply_cpu_turn(player, (s16) temp_t1); D_80165020[playerIndex] = (s16) temp_t1; @@ -2923,7 +2923,7 @@ void func_8002FCA8(Player* player, s8 playerIndex) { var_v1 = 0; } if ((player->currentSpeed >= 200.0f) && (var_v1 == 2)) { - temp_lo = (s16) player->unk_0C0 / 182; + temp_lo = (s16) player->unk_0C0 / DEGREES(1); if ((temp_lo > 0xF) || (temp_lo < -0xF)) { var_f0 += 1.0; } @@ -2959,7 +2959,7 @@ void func_8002FE84(Player* player, f32 arg1) { var_f0 = 0.0f; player->unk_098 = arg1; - temp_lo = player->slopeAccel / 182; + temp_lo = player->slopeAccel / DEGREES(1); if ((temp_lo > 0x11) || (temp_lo < -0x11)) { var_f0 += (temp_lo * 0.0125) / 1.2; } else { @@ -2974,7 +2974,7 @@ void func_8002FE84(Player* player, f32 arg1) { // just above this comment var_f0 += D_800E2E90[player->characterId][player->tyres[BACK_LEFT].surfaceType] * (0.7 * 1.0); } - test = player->unk_0C0 / 182; + test = player->unk_0C0 / DEGREES(1); if (test < 0) { var_f0 += -test * 0.004; } else { @@ -3018,7 +3018,7 @@ f32 func_80030150(Player* player, s8 playerIndex) { } if (((player->effects & MIDAIR_EFFECT) != MIDAIR_EFFECT) && ((player->lakituProps & HELD_BY_LAKITU) != HELD_BY_LAKITU)) { - temp_lo = player->slopeAccel / 182; + temp_lo = player->slopeAccel / DEGREES(1); if (var_f2 >= 20.0f) { if ((temp_lo > 0x11) || (temp_lo < -0x11)) { var_f0 -= ((temp_lo * 0.0126) / 3.0); @@ -3032,14 +3032,14 @@ f32 func_80030150(Player* player, s8 playerIndex) { } } if (((player->effects & DRIFTING_EFFECT) == DRIFTING_EFFECT) || (player->driftDuration > 0)) { - var_v0 = (s16) player->unk_0C0 / 182; + var_v0 = (s16) player->unk_0C0 / DEGREES(1); if (var_v0 < 0) { var_f0 += -var_v0 * 0.004; } else { var_f0 += var_v0 * 0.004; } } else { - var_v0 = (s16) player->unk_0C0 / 182; + var_v0 = (s16) player->unk_0C0 / DEGREES(1); if (var_v0 < 0) { var_f0 += -var_v0 * (0.01 + gKartTurnSpeedReductionTable0[player->characterId]); } else { @@ -3076,7 +3076,7 @@ f32 func_80030150(Player* player, s8 playerIndex) { } else { player->unk_0A0 = 0.0f; player->unk_0E8 = 0.0f; - if (((s16) player->slopeAccel / 182) < 0) { + if (((s16) player->slopeAccel / DEGREES(1)) < 0) { var_f0 += -0.85; if (player->effects & LIGHTNING_EFFECT) { var_f0 += -0.55; @@ -3306,93 +3306,93 @@ void player_accelerate_alternative(Player* player) { if (gIsPlayerTripleAButtonCombo[player_index] == false) { if ((0.0 <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.1))) { player->currentSpeed += - gKartAccelerationTables[player->characterId][0] + (0.05 * (player->slopeAccel / 182)); + gKartAccelerationTables[player->characterId][0] + (0.05 * (player->slopeAccel / DEGREES(1))); } if (((player->topSpeed * 0.1) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.2))) { player->currentSpeed += - gKartAccelerationTables[player->characterId][1] + (0.05 * (player->slopeAccel / 182)); + gKartAccelerationTables[player->characterId][1] + (0.05 * (player->slopeAccel / DEGREES(1))); } if (((player->topSpeed * 0.2) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.3))) { player->currentSpeed += - gKartAccelerationTables[player->characterId][2] + (0.05 * (player->slopeAccel / 182)); + gKartAccelerationTables[player->characterId][2] + (0.05 * (player->slopeAccel / DEGREES(1))); } if (((player->topSpeed * 0.3) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.4))) { player->currentSpeed += - gKartAccelerationTables[player->characterId][3] + (0.05 * (player->slopeAccel / 182)); + gKartAccelerationTables[player->characterId][3] + (0.05 * (player->slopeAccel / DEGREES(1))); } if (((player->topSpeed * 0.4) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.5))) { player->currentSpeed += - gKartAccelerationTables[player->characterId][4] + (0.05 * (player->slopeAccel / 182)); + gKartAccelerationTables[player->characterId][4] + (0.05 * (player->slopeAccel / DEGREES(1))); } if (((player->topSpeed * 0.5) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.6))) { player->currentSpeed += - gKartAccelerationTables[player->characterId][5] + (0.05 * (player->slopeAccel / 182)); + gKartAccelerationTables[player->characterId][5] + (0.05 * (player->slopeAccel / DEGREES(1))); } if (((player->topSpeed * 0.6) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.7))) { player->currentSpeed += - gKartAccelerationTables[player->characterId][6] + (0.05 * (player->slopeAccel / 182)); + gKartAccelerationTables[player->characterId][6] + (0.05 * (player->slopeAccel / DEGREES(1))); } if (((player->topSpeed * 0.7) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.8))) { player->currentSpeed += - gKartAccelerationTables[player->characterId][7] + (0.05 * (player->slopeAccel / 182)); + gKartAccelerationTables[player->characterId][7] + (0.05 * (player->slopeAccel / DEGREES(1))); } if (((player->topSpeed * 0.8) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.9))) { player->currentSpeed += - gKartAccelerationTables[player->characterId][8] + (0.05 * (player->slopeAccel / 182)); + gKartAccelerationTables[player->characterId][8] + (0.05 * (player->slopeAccel / DEGREES(1))); } if (((player->topSpeed * 0.9) <= player->currentSpeed) && (player->currentSpeed <= (player->topSpeed * 1.0))) { player->currentSpeed += - gKartAccelerationTables[player->characterId][9] + (0.05 * (player->slopeAccel / 182)); + gKartAccelerationTables[player->characterId][9] + (0.05 * (player->slopeAccel / DEGREES(1))); } } else { if ((0.0 <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.1))) { player->currentSpeed += - (gKartAccelerationTables[player->characterId][0] + (0.05 * (player->slopeAccel / 182))) * + (gKartAccelerationTables[player->characterId][0] + (0.05 * (player->slopeAccel / DEGREES(1)))) * gKartTripleABoost[player->characterId]; } if (((player->topSpeed * 0.1) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.2))) { player->currentSpeed += - (gKartAccelerationTables[player->characterId][1] + (0.05 * (player->slopeAccel / 182))) * + (gKartAccelerationTables[player->characterId][1] + (0.05 * (player->slopeAccel / DEGREES(1)))) * gKartTripleABoost[player->characterId]; } if (((player->topSpeed * 0.2) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.3))) { player->currentSpeed += - (gKartAccelerationTables[player->characterId][2] + (0.05 * (player->slopeAccel / 182))) * + (gKartAccelerationTables[player->characterId][2] + (0.05 * (player->slopeAccel / DEGREES(1)))) * gKartTripleABoost[player->characterId]; } if (((player->topSpeed * 0.3) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.4))) { player->currentSpeed += - (gKartAccelerationTables[player->characterId][3] + (0.05 * (player->slopeAccel / 182))) * + (gKartAccelerationTables[player->characterId][3] + (0.05 * (player->slopeAccel / DEGREES(1)))) * gKartTripleABoost[player->characterId]; } if (((player->topSpeed * 0.4) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.5))) { player->currentSpeed += - (gKartAccelerationTables[player->characterId][4] + (0.05 * (player->slopeAccel / 182))) * + (gKartAccelerationTables[player->characterId][4] + (0.05 * (player->slopeAccel / DEGREES(1)))) * gKartTripleABoost[player->characterId]; } if (((player->topSpeed * 0.5) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.6))) { player->currentSpeed += - (gKartAccelerationTables[player->characterId][5] + (0.05 * (player->slopeAccel / 182))) * + (gKartAccelerationTables[player->characterId][5] + (0.05 * (player->slopeAccel / DEGREES(1)))) * gKartTripleABoost[player->characterId]; } if (((player->topSpeed * 0.6) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.7))) { player->currentSpeed += - (gKartAccelerationTables[player->characterId][6] + (0.05 * (player->slopeAccel / 182))) * + (gKartAccelerationTables[player->characterId][6] + (0.05 * (player->slopeAccel / DEGREES(1)))) * gKartTripleABoost[player->characterId]; } if (((player->topSpeed * 0.7) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.8))) { player->currentSpeed += - (gKartAccelerationTables[player->characterId][7] + (0.05 * (player->slopeAccel / 182))) * + (gKartAccelerationTables[player->characterId][7] + (0.05 * (player->slopeAccel / DEGREES(1)))) * gKartTripleABoost[player->characterId]; } if (((player->topSpeed * 0.8) <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.9))) { player->currentSpeed += - (gKartAccelerationTables[player->characterId][8] + (0.05 * (player->slopeAccel / 182))) * + (gKartAccelerationTables[player->characterId][8] + (0.05 * (player->slopeAccel / DEGREES(1)))) * gKartTripleABoost[player->characterId]; } if (((player->topSpeed * 0.9) <= player->currentSpeed) && (player->currentSpeed <= (player->topSpeed * 1.0))) { player->currentSpeed += - (gKartAccelerationTables[player->characterId][9] + (0.05 * (player->slopeAccel / 182))) * + (gKartAccelerationTables[player->characterId][9] + (0.05 * (player->slopeAccel / DEGREES(1)))) * gKartTripleABoost[player->characterId]; } } @@ -3925,17 +3925,17 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 playerIndex 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8 }; if (((((player->effects & HOP_EFFECT) != HOP_EFFECT) && - ((((player->unk_0C0 / 182) <= 6) && ((player->unk_0C0 / 182) >= (-6))) || + ((((player->unk_0C0 / DEGREES(1)) <= 6) && ((player->unk_0C0 / DEGREES(1)) >= (-6))) || ((controller->button & R_TRIG) != R_TRIG))) || (((player->speed / 18.0f) * 216.0f) <= 20.0f)) || ((player->effects & ENEMY_BONK_EFFECT) == ENEMY_BONK_EFFECT)) { func_80036CB4(player); } - if ((player->unk_0C0 / DEGREES_CONVERSION_FACTOR) < (-5)) { + if ((player->unk_0C0 / DEGREES(1)) < (-5)) { player->kartProps |= LEFT_TURN; player->kartProps &= ~RIGHT_TURN; D_801652C0[playerIndex]++; - } else if ((player->unk_0C0 / DEGREES_CONVERSION_FACTOR) > 5) { + } else if ((player->unk_0C0 / DEGREES(1)) > 5) { player->kartProps |= RIGHT_TURN; player->kartProps &= ~LEFT_TURN; D_801652C0[playerIndex]++; @@ -4186,7 +4186,7 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 playerIndex } } } else if (((player->effects & MIDAIR_EFFECT) != MIDAIR_EFFECT) && ((player->effects & HOP_EFFECT) != HOP_EFFECT)) { - if ((((s16) player->unk_0C0) / DEGREES_CONVERSION_FACTOR) > 0) { + if ((((s16) player->unk_0C0) / DEGREES(1)) > 0) { // linear map, sets -53 to 40 and 53 to 53 var_s1_2 = (((s32) (((player->steerPosition >> 16) * 13) + (13 * 53))) / (2 * 53)) + 40; if ((player->steerPosition >> 16) <= -40) { @@ -4294,7 +4294,7 @@ void apply_cpu_turn(Player* player, s16 targetAngle) { player->unk_078 = (player->steerPosition >> 16) * (var_f0 + 1.5); } } else if ((player->effects & MIDAIR_EFFECT) != MIDAIR_EFFECT) { - if (((s16) player->unk_0C0 / DEGREES_CONVERSION_FACTOR) > 0) { + if (((s16) player->unk_0C0 / DEGREES(1)) > 0) { var_v0 = player->steerPosition >> 16; } else { var_v0 = player->steerPosition >> 16; @@ -4331,12 +4331,12 @@ void func_80036CB4(Player* player) { s32 steer_position_new; if (((player->effects & DRIFTING_EFFECT) == DRIFTING_EFFECT) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { - if ((player->unk_0C0 / DEGREES_CONVERSION_FACTOR) > 0) { + if ((player->unk_0C0 / DEGREES(1)) > 0) { // linear map, sets -53 to 40 and 53 to 53 steer_position_new = ((((player->steerPosition >> 16) * 13) + (13*53)) / (2*53)) + 40; player->steerPosition = steer_position_new << 16; } - if ((player->unk_0C0 / DEGREES_CONVERSION_FACTOR) < 0) { + if ((player->unk_0C0 / DEGREES(1)) < 0) { // linear map, sets -53 to -53 and 53 to -40 steer_position_new = ((((player->steerPosition >> 16) * 13) + (13*53)) / (2*53)) - 53; player->steerPosition = steer_position_new << 16; diff --git a/src/racing/actors_extended.c b/src/racing/actors_extended.c index 859cba6ac4..d030fe483e 100644 --- a/src/racing/actors_extended.c +++ b/src/racing/actors_extended.c @@ -356,7 +356,7 @@ void update_actor_triple_shell(TripleShellParent* parent, s16 shellType) { break; case SPAWN_SECOND_SHELL: if (parent->rotVelocity > 0) { - if (someRotAngle >= 0xD556) { + if (someRotAngle >= (DEGREES_360 - DEGREES(60))) { if (init_triple_shell(parent, &gPlayers[playerId], shellType, 1U) != -1) { func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x12)); parent->shellsAvailable += 1; @@ -364,7 +364,7 @@ void update_actor_triple_shell(TripleShellParent* parent, s16 shellType) { parent->state = SPAWN_THIRD_SHELL; } } else { - if (someRotAngle < 0x2AAA) { + if (someRotAngle < DEGREES(60)) { if (init_triple_shell(parent, &gPlayers[playerId], shellType, 1U) != -1) { func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x12)); parent->shellsAvailable += 1; @@ -375,14 +375,14 @@ void update_actor_triple_shell(TripleShellParent* parent, s16 shellType) { break; case SPAWN_THIRD_SHELL: if (parent->rotVelocity > 0) { - if ((someRotAngle >= 0x2AAB) && (someRotAngle < 0x31C7)) { + if ((someRotAngle > DEGREES(60)) && (someRotAngle < DEGREES(70))) { if (init_triple_shell(parent, &gPlayers[playerId], shellType, 2U) != -1) { func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x12)); parent->shellsAvailable += 1; } parent->state = 3; } - } else if ((someRotAngle < 0xD555) && (someRotAngle >= 0xCE39)) { + } else if ((someRotAngle < (DEGREES_360 - DEGREES(60) - 1)) && (someRotAngle >= (DEGREES_360 - DEGREES(70)))) { if (init_triple_shell(parent, &gPlayers[playerId], shellType, 2U) != -1) { func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x12)); parent->shellsAvailable += 1; diff --git a/src/render_player.c b/src/render_player.c index 1106406c96..c5668aca37 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -1635,7 +1635,7 @@ void func_80025DE8(Player* player, s8 playerId, s8 screenId, s8 flipOffset) { sp9C[0] = player->pos[0] + (sins(-player->rotation[1]) * -1.5); sp9C[1] = ((player->pos[1] - player->boundingBoxSize) + player->unk_108) + 0.1; sp9C[2] = player->pos[2] + (coss(-player->rotation[1]) * -1.5); - sp94[0] = -0x00B6; + sp94[0] = DEGREES(-1); sp94[1] = player->unk_048[screenId]; sp94[2] = player->unk_050[screenId]; diff --git a/src/update_objects.c b/src/update_objects.c index 929c49d0fd..ead1cc35a1 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -2856,8 +2856,8 @@ void course_update_clouds(s32 arg0) { break; } - D_8018D208 = ((D_8018D200 / 2) * 0xB6) + 0x71C; - D_8018D210 = (-(D_8018D200 / 2) * 0xB6) - 0x71C; + D_8018D208 = ((D_8018D200 / 2) * DEGREES(1)) + 0x71C; + D_8018D210 = (-(D_8018D200 / 2) * DEGREES(1)) - 0x71C; D_8018D1E8 = 1.7578125 / D_8018D200; D_8018D218 = 0xA0; #if !ENABLE_CUSTOM_COURSE_ENGINE From 6ef5580946d51c5c4977016e4327ca13858b0425 Mon Sep 17 00:00:00 2001 From: Jed Grabman Date: Fri, 17 Apr 2026 11:44:20 -0400 Subject: [PATCH 2/9] Document degrees < 10 --- src/actors/banana/update.inc.c | 4 ++-- src/actors/blue_and_red_shells/update.inc.c | 2 +- src/actors/fake_item_box/update.inc.c | 2 +- src/actors/green_shell/update.inc.c | 2 +- src/actors/item_box/render.inc.c | 2 +- src/actors/item_box/update.inc.c | 4 ++-- src/actors/train/render.inc.c | 8 ++++---- src/actors/train/update.inc.c | 2 +- src/actors/yoshi_egg/update.inc.c | 2 +- src/effects.c | 4 ++-- src/player_controller.c | 10 +++++----- src/racing/actors_extended.c | 6 +++--- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/actors/banana/update.inc.c b/src/actors/banana/update.inc.c index 1f079f2d88..d850abeedf 100644 --- a/src/actors/banana/update.inc.c +++ b/src/actors/banana/update.inc.c @@ -175,8 +175,8 @@ void update_actor_banana(struct BananaActor* banana) { } banana->pos[1] += banana->velocity[1]; banana->rot[0] += DEGREES(2); - banana->rot[1] -= 0x5B0; - banana->rot[2] += 0x38E; + banana->rot[1] -= DEGREES(8); + banana->rot[2] += DEGREES(5); banana->unk_04 -= 1; if (banana->unk_04 == 0) { destroy_actor((struct Actor*) banana); diff --git a/src/actors/blue_and_red_shells/update.inc.c b/src/actors/blue_and_red_shells/update.inc.c index 4835c53efa..d913eb3f03 100644 --- a/src/actors/blue_and_red_shells/update.inc.c +++ b/src/actors/blue_and_red_shells/update.inc.c @@ -454,7 +454,7 @@ void update_actor_red_blue_shell(struct ShellActor* shell) { if (shell->velocity[1] < -5.0f) { shell->velocity[1] = -5.0f; } - shell->rotAngle += 0x5B0; + shell->rotAngle += DEGREES(8); shell->someTimer -= 1; shell->pos[1] += shell->velocity[1]; if (shell->someTimer == 0) { diff --git a/src/actors/fake_item_box/update.inc.c b/src/actors/fake_item_box/update.inc.c index a6cedead86..da4b44fc31 100644 --- a/src/actors/fake_item_box/update.inc.c +++ b/src/actors/fake_item_box/update.inc.c @@ -82,7 +82,7 @@ void update_actor_fake_item_box(struct FakeItemBox* fake_item_box) { } else { fake_item_box->someTimer++; fake_item_box->rot[0] += DEGREES(6); - fake_item_box->rot[1] -= 0x2D8; + fake_item_box->rot[1] -= DEGREES(4); fake_item_box->rot[2] += DEGREES(2); } break; diff --git a/src/actors/green_shell/update.inc.c b/src/actors/green_shell/update.inc.c index 7231af1832..90ebb980c8 100644 --- a/src/actors/green_shell/update.inc.c +++ b/src/actors/green_shell/update.inc.c @@ -186,7 +186,7 @@ void update_actor_green_shell(struct ShellActor* shell) { if (shell->velocity[1] < -5.0f) { shell->velocity[1] = -5.0f; } - shell->rotAngle += 0x5B0; + shell->rotAngle += DEGREES(8); shell->someTimer -= 1; shell->pos[1] += shell->velocity[1]; if (shell->someTimer == 0) { diff --git a/src/actors/item_box/render.inc.c b/src/actors/item_box/render.inc.c index d0288a6376..89708af455 100644 --- a/src/actors/item_box/render.inc.c +++ b/src/actors/item_box/render.inc.c @@ -75,7 +75,7 @@ void render_actor_item_box(Camera* camera, struct ItemBox* item_box) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); } else if ((item_box->rot[1] >= 0x6AA5) && (item_box->rot[1] < 0x754E)) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - } else if ((item_box->rot[1] >= 0x38E1) && (item_box->rot[1] < 0x438A)) { + } else if ((item_box->rot[1] > 0x38E0) && (item_box->rot[1] < 0x438A)) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); } else if ((item_box->rot[1] >= 0xC711) && (item_box->rot[1] < 0xD1BA)) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); diff --git a/src/actors/item_box/update.inc.c b/src/actors/item_box/update.inc.c index b49936256b..0a453005f8 100644 --- a/src/actors/item_box/update.inc.c +++ b/src/actors/item_box/update.inc.c @@ -21,7 +21,7 @@ void update_actor_item_box_hot_air_balloon(struct ItemBox* itemBox) { } else { itemBox->someTimer++; itemBox->rot[0] += DEGREES(6); - itemBox->rot[1] -= 0x2D8; + itemBox->rot[1] -= DEGREES(4); itemBox->rot[2] += DEGREES(2); } break; @@ -60,7 +60,7 @@ void update_actor_item_box(struct ItemBox* itemBox) { } else { itemBox->someTimer++; itemBox->rot[0] += DEGREES(6); - itemBox->rot[1] -= 0x2D8; + itemBox->rot[1] -= DEGREES(4); itemBox->rot[2] += DEGREES(2); } break; diff --git a/src/actors/train/render.inc.c b/src/actors/train/render.inc.c index 27f7b1669e..079655412f 100644 --- a/src/actors/train/render.inc.c +++ b/src/actors/train/render.inc.c @@ -132,7 +132,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22D70); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x2D8)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(4))); vec3f_set(sp160, 17.0f, 12.0f, -34.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -145,7 +145,7 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22D70); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x2D8)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(4))); vec3f_set(sp160, -17.0f, 12.0f, -34.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -334,7 +334,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x5B0)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(8))); vec3f_set(sp160, 17.0f, 6.0f, -8.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); @@ -346,7 +346,7 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) { gSPDisplayList(gDisplayListHead++, d_course_kalimari_desert_dl_22DB8); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - mtxf_rotate_x(sp120, (s16) (actor->wheelRot + 0x5B0)); + mtxf_rotate_x(sp120, (s16) (actor->wheelRot + DEGREES(8))); vec3f_set(sp160, -17.0f, 6.0f, -8.0f); mtxf_translate(spE0, sp160); mtxf_multiplication(spA0, sp120, spE0); diff --git a/src/actors/train/update.inc.c b/src/actors/train/update.inc.c index 95398a4595..25eda1ebab 100644 --- a/src/actors/train/update.inc.c +++ b/src/actors/train/update.inc.c @@ -23,7 +23,7 @@ void update_actor_train_engine(struct TrainCar* arg0) { * @param tender */ void update_actor_train_tender(struct TrainCar* tender) { - tender->wheelRot -= 0x4FA; + tender->wheelRot -= DEGREES(7); } /** diff --git a/src/actors/yoshi_egg/update.inc.c b/src/actors/yoshi_egg/update.inc.c index 8b7834c513..dde9c86d3a 100644 --- a/src/actors/yoshi_egg/update.inc.c +++ b/src/actors/yoshi_egg/update.inc.c @@ -20,7 +20,7 @@ void update_actor_yoshi_egg(struct YoshiValleyEgg* egg) { egg->pathCenter[1] = 0.0f; egg->flags &= ~(1 << 10); } - egg->eggRot -= 0x4FA; + egg->eggRot -= DEGREES(7); } egg->eggRot -= DEGREES(3); } diff --git a/src/effects.c b/src/effects.c index dc32cc8a5a..4d88d76c6f 100644 --- a/src/effects.c +++ b/src/effects.c @@ -890,8 +890,8 @@ void apply_lightning_effect(Player* player, s8 playerIndex) { D_80165190[3][playerIndex] = 1; trigger_squish(player, playerIndex); } else if ((player->effects & LIGHTNING_STRIKE_EFFECT) == LIGHTNING_STRIKE_EFFECT) { - player->rotation[1] -= 0x5B0; - D_8018D920[playerIndex] -= 0x5B0; + player->rotation[1] -= DEGREES(8); + D_8018D920[playerIndex] -= DEGREES(8); test = (u16) D_8018D920[playerIndex] / 1456; if (test == 0) { player->unk_0B2--; diff --git a/src/player_controller.c b/src/player_controller.c index 874439dd7c..b5009a66e4 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -698,7 +698,7 @@ void func_80029200(Player* player, s8 screenId) { if (((s32) player->slopeAccel < -0x4F9) && ((s32) player->slopeAccel >= -0x71B)) { player->animGroupSelector[screenId] = 1; } - if ((player->slopeAccel <= -DEGREES(3)) && (player->slopeAccel >= -0x4F9)) { + if ((player->slopeAccel <= -DEGREES(3)) && (player->slopeAccel > -DEGREES(7))) { player->animGroupSelector[screenId] = 2; } if ((player->slopeAccel <= -DEGREES(2)) && (player->slopeAccel > -DEGREES(3))) { @@ -710,10 +710,10 @@ void func_80029200(Player* player, s8 screenId) { if ((player->slopeAccel >= DEGREES(2)) && (player->slopeAccel < DEGREES(3))) { player->animGroupSelector[screenId] = 5; } - if ((player->slopeAccel >= DEGREES(3)) && (player->slopeAccel < 0x4FA)) { + if ((player->slopeAccel >= DEGREES(3)) && (player->slopeAccel < DEGREES(7))) { player->animGroupSelector[screenId] = 6; } - if ((player->slopeAccel >= 0x4FA) && (player->slopeAccel < 0x71C)) { + if ((player->slopeAccel >= DEGREES(7)) && (player->slopeAccel < 0x71C)) { player->animGroupSelector[screenId] = 7; } if (player->slopeAccel >= 0x71C) { @@ -1618,7 +1618,7 @@ void func_8002BB9C(Player* player, f32* arg1, f32* arg2, UNUSED s8 arg3, UNUSED s16 var_v0; s16 t0; UNUSED s32 pad; - s16 sp30[10] = { 0, DEGREES(1), 0x016c, 3 * DEGREES(1), 0x02d8, 0x038e, 6 * DEGREES(1), 0x04fa, 0x05b0, 9 * DEGREES(1) }; + s16 sp30[10] = { 0, DEGREES(1), DEGREES(2), DEGREES(3), DEGREES(4), DEGREES(5), DEGREES(6), DEGREES(7), DEGREES(8), DEGREES(9) }; if (((u16) player->unk_256) <= 0) { return; @@ -2085,7 +2085,7 @@ void func_8002D028(Player* player, s8 playerIndex) { temp_f18 = sqrtf((sp4C[0] - player->pos[0]) * (sp4C[0] - player->pos[0]) + (sp4C[2] - player->pos[2]) * (sp4C[2] - player->pos[2])); if (temp_f18 <= 8.0f) { - adjust_angle(&player->rotation[1], -0x8000, 0x016C); + adjust_angle(&player->rotation[1], -0x8000, DEGREES(2)); if ((player->rotation[1] < (-0x7F41)) || (player->rotation[1] > 0x7F41)) { player->type &= ~PLAYER_STAGING; } diff --git a/src/racing/actors_extended.c b/src/racing/actors_extended.c index d030fe483e..79fda531d7 100644 --- a/src/racing/actors_extended.c +++ b/src/racing/actors_extended.c @@ -427,7 +427,7 @@ void update_actor_triple_shell(TripleShellParent* parent, s16 shellType) { if (parent->unk_08 > 0.0f) { if (parent->shellIndices[0] > 0.0f) { shell = (struct ShellActor*) &gActorList[(s16) parent->shellIndices[0]]; - if ((shell->rotAngle < 0x38E) || (shell->rotAngle >= -0x38D)) { + if ((shell->rotAngle < DEGREES(5)) || (shell->rotAngle > -DEGREES(5))) { someVelocity[0] = 0; someVelocity[1] = 0; someVelocity[2] = 8; @@ -479,7 +479,7 @@ void update_actor_triple_shell(TripleShellParent* parent, s16 shellType) { } if (parent->shellIndices[2] > 0.0f) { shell = (struct ShellActor*) &gActorList[(s16) parent->shellIndices[2]]; - if ((shell->rotAngle < -0x38E) || (shell->rotAngle >= -0x71B)) { + if ((shell->rotAngle < -DEGREES(5)) || (shell->rotAngle >= -0x71B)) { someVelocity[0] = 0; someVelocity[1] = 0; someVelocity[2] = 8; @@ -543,7 +543,7 @@ s32 use_triple_shell_item(Player* player, s16 tripleShellType) { } parent = (TripleShellParent*) &gActorList[actorIndex]; parent->state = 0; - parent->rotVelocity = 0x05B0; + parent->rotVelocity = DEGREES(8); parent->rotAngle = -0x8000; parent->playerId = player - gPlayerOne; parent->shellsAvailable = 0; From f4079151a0b21073cb2a789dfe1d8a0e3186fd50 Mon Sep 17 00:00:00 2001 From: Jed Grabman Date: Fri, 17 Apr 2026 17:34:49 -0400 Subject: [PATCH 3/9] Update most rotation values to degrees --- include/defines.h | 2 +- src/actors/blue_and_red_shells/update.inc.c | 10 +++++----- src/actors/fake_item_box/render.inc.c | 8 ++++---- src/actors/green_shell/update.inc.c | 10 +++++----- src/actors/item_box/render.inc.c | 8 ++++---- src/actors/paddle_boat/update.inc.c | 2 +- src/actors/yoshi_egg/update.inc.c | 2 +- src/code_80057C60.c | 12 +++++------ .../vehicle_utils.inc.c | 2 +- src/effects.c | 10 +++++----- src/main.c | 8 ++++---- src/player_controller.c | 12 +++++------ src/racing/actors.c | 8 ++++---- src/racing/actors_extended.c | 12 +++++------ src/racing/render_courses.c | 18 ++++++++--------- src/render_objects.c | 4 ++-- src/render_player.c | 20 +++++++++---------- src/update_objects.c | 10 +++++----- 18 files changed, 79 insertions(+), 79 deletions(-) diff --git a/include/defines.h b/include/defines.h index cb08415716..eaf36392ef 100644 --- a/include/defines.h +++ b/include/defines.h @@ -331,7 +331,7 @@ enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE }; #define MAX_TIME 0x927C0 #define ONE_DEGREE (f32) 65536.0f / 360.0f -#define DEGREES(degree) (s16) ((f32) degree * ONE_DEGREE) +#define DEGREES(degree) ((u16) ((f32) degree * ONE_DEGREE)) #define DEGREES_360 65536 // player->unk_046 diff --git a/src/actors/blue_and_red_shells/update.inc.c b/src/actors/blue_and_red_shells/update.inc.c index d913eb3f03..e0511acb22 100644 --- a/src/actors/blue_and_red_shells/update.inc.c +++ b/src/actors/blue_and_red_shells/update.inc.c @@ -242,7 +242,7 @@ void update_actor_red_blue_shell(struct ShellActor* shell) { destroy_destructable_actor((struct Actor*) shell); } - shell->rotVelocity += 0x71C; + shell->rotVelocity += DEGREES(10); switch (shell->state) { case HELD_SHELL: player = &gPlayers[shell->playerId]; @@ -277,16 +277,16 @@ void update_actor_red_blue_shell(struct ShellActor* shell) { controller->buttonDepressed &= ~Z_TRIG; shell->state = RELEASED_SHELL; if (player->unk_0C0 > 0) { - shell->rotAngle = 0x78E3; + shell->rotAngle = DEGREES(170); } else { - shell->rotAngle = -0x78E4; + shell->rotAngle = -DEGREES(170) - 1; } } break; case RELEASED_SHELL: player = &gPlayers[shell->playerId]; if (shell->rotAngle > 0) { - shell->rotAngle -= 0x71C; + shell->rotAngle -= DEGREES(10); if (shell->rotAngle < 0) { shell->state = MOVING_SHELL; func_800C9060(shell->playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x04)); @@ -300,7 +300,7 @@ void update_actor_red_blue_shell(struct ShellActor* shell) { } } } else { - shell->rotAngle += 0x71C; + shell->rotAngle += DEGREES(10); if (shell->rotAngle > 0) { shell->state = MOVING_SHELL; func_800C9060(shell->playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x04)); diff --git a/src/actors/fake_item_box/render.inc.c b/src/actors/fake_item_box/render.inc.c index 36e4cf9e0a..3c012fb39e 100644 --- a/src/actors/fake_item_box/render.inc.c +++ b/src/actors/fake_item_box/render.inc.c @@ -60,13 +60,13 @@ void render_actor_fake_item_box(Camera* camera, struct FakeItemBox* fakeItemBox) gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); - if ((fakeItemBox->rot[1] < 0xAA1) && (fakeItemBox->rot[1] > 0)) { + if ((fakeItemBox->rot[1] < (15 * DEGREES(1) - 9)) && (fakeItemBox->rot[1] > 0)) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - } else if ((fakeItemBox->rot[1] >= 0x6AA5) && (fakeItemBox->rot[1] < 0x754E)) { + } else if ((fakeItemBox->rot[1] > (150 * DEGREES(1))) && (fakeItemBox->rot[1] < (165 * DEGREES(1)))) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - } else if ((fakeItemBox->rot[1] >= 0x38E1) && (fakeItemBox->rot[1] < 0x438A)) { + } else if ((fakeItemBox->rot[1] > (80 * DEGREES(1))) && (fakeItemBox->rot[1] < (95 * DEGREES(1)))) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - } else if ((fakeItemBox->rot[1] >= 0xC711) && (fakeItemBox->rot[1] < 0xD1BA)) { + } else if ((fakeItemBox->rot[1] > (280 * DEGREES(1))) && (fakeItemBox->rot[1] < (295 * DEGREES(1)))) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); } else { gDPSetBlendMask(gDisplayListHead++, 0xFF); diff --git a/src/actors/green_shell/update.inc.c b/src/actors/green_shell/update.inc.c index 90ebb980c8..a042b8aa8f 100644 --- a/src/actors/green_shell/update.inc.c +++ b/src/actors/green_shell/update.inc.c @@ -35,7 +35,7 @@ void update_actor_green_shell(struct ShellActor* shell) { (y < gCourseMinY)) { destroy_destructable_actor((struct Actor*) shell); } - shell->rotVelocity += 0x71C; + shell->rotVelocity += DEGREES(10); switch (shell->state) { case HELD_SHELL: player = &gPlayers[shell->playerId]; @@ -79,9 +79,9 @@ void update_actor_green_shell(struct ShellActor* shell) { } else { shell->state = 1; if (player->unk_0C0 > 0) { - shell->rotAngle = 0x78E3; + shell->rotAngle = DEGREES(170); } else { - shell->rotAngle = -0x78E4; + shell->rotAngle = -DEGREES(170) - 1; } } } @@ -90,7 +90,7 @@ void update_actor_green_shell(struct ShellActor* shell) { case RELEASED_SHELL: player = &gPlayers[shell->playerId]; if (shell->rotAngle > 0) { - shell->rotAngle -= 0xE38; + shell->rotAngle -= DEGREES(20); if (shell->rotAngle < 0) { shell->state = 2; shell->someTimer = 0x001E; @@ -100,7 +100,7 @@ void update_actor_green_shell(struct ShellActor* shell) { add_green_shell_in_unexpired_actor_list((struct Actor*) shell - gActorList); } } else { - shell->rotAngle += 0xE38; + shell->rotAngle += DEGREES(20); if (shell->rotAngle > 0) { shell->state = 2; shell->someTimer = 0x001E; diff --git a/src/actors/item_box/render.inc.c b/src/actors/item_box/render.inc.c index 89708af455..6549eee2be 100644 --- a/src/actors/item_box/render.inc.c +++ b/src/actors/item_box/render.inc.c @@ -71,13 +71,13 @@ void render_actor_item_box(Camera* camera, struct ItemBox* item_box) { gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); - if ((item_box->rot[1] < 0xAA1) && (item_box->rot[1] > 0)) { + if ((item_box->rot[1] < (15 * DEGREES(1) - 9)) && (item_box->rot[1] > 0)) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - } else if ((item_box->rot[1] >= 0x6AA5) && (item_box->rot[1] < 0x754E)) { + } else if ((item_box->rot[1] > (150 * DEGREES(1))) && (item_box->rot[1] < (165 * DEGREES(1)))) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - } else if ((item_box->rot[1] > 0x38E0) && (item_box->rot[1] < 0x438A)) { + } else if ((item_box->rot[1] > (80 * DEGREES(1))) && (item_box->rot[1] < (95 * DEGREES(1)))) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - } else if ((item_box->rot[1] >= 0xC711) && (item_box->rot[1] < 0xD1BA)) { + } else if ((item_box->rot[1] > (280 * DEGREES(1))) && (item_box->rot[1] < (295 * DEGREES(1)))) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); } else { gDPSetBlendMask(gDisplayListHead++, 0xFF); diff --git a/src/actors/paddle_boat/update.inc.c b/src/actors/paddle_boat/update.inc.c index 7a72cf3193..93f42a7b70 100644 --- a/src/actors/paddle_boat/update.inc.c +++ b/src/actors/paddle_boat/update.inc.c @@ -9,5 +9,5 @@ * @param boat */ void update_actor_paddle_boat(struct PaddleWheelBoat* boat) { - boat->wheelRot += 0x38E; + boat->wheelRot += DEGREES(5); } diff --git a/src/actors/yoshi_egg/update.inc.c b/src/actors/yoshi_egg/update.inc.c index dde9c86d3a..45cac74aaf 100644 --- a/src/actors/yoshi_egg/update.inc.c +++ b/src/actors/yoshi_egg/update.inc.c @@ -6,7 +6,7 @@ * @param egg */ void update_actor_yoshi_egg(struct YoshiValleyEgg* egg) { - egg->pathRot += 0x5B; + egg->pathRot += 0x5B; // half a degree egg->pos[0] = egg->pathCenter[0] + (sins(egg->pathRot) * egg->pathRadius); egg->pos[2] = egg->pathCenter[2] + (coss(egg->pathRot) * egg->pathRadius); if ((egg->flags & 0x400) != 0) { diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 217c6423fb..6ca8aed0a5 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -3725,7 +3725,7 @@ void func_800612F8(Player* player, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s8 a for (var_s2 = 0; var_s2 < 10; var_s2++) { player->particlePool3[var_s2].isAlive = 1; player->particlePool3[var_s2].unk_028 = player->pos[1] + 5.0f; - player->particlePool3[var_s2].rotation = (0x1C70 * var_s2) - player->rotation[1]; + player->particlePool3[var_s2].rotation = ((DEGREES(40) - 1) * var_s2) - player->rotation[1]; player->particlePool3[var_s2].unk_024 = (random_int(0x0064U) / 100.0f) + 1.5; player->particlePool3[var_s2].green = 0; player->particlePool3[var_s2].type = 1; @@ -3743,7 +3743,7 @@ void func_80061430(Player* player, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s8 a for (var_s2 = 0; var_s2 < 7; var_s2++) { player->particlePool3[var_s2].isAlive = 1; player->particlePool3[var_s2].unk_028 = player->pos[1] - 4.0f; - player->particlePool3[var_s2].rotation = (0x1C70 * var_s2) - player->rotation[1]; + player->particlePool3[var_s2].rotation = ((DEGREES(40) - 1) * var_s2) - player->rotation[1]; // ??? player->particlePool3[var_s2].unk_024 = (random_int(0x0064U) / 100.0f) + 1.9; player->particlePool3[var_s2].unk_024 = (random_int(0x0064U) / 100.0f) + 1.5; @@ -3762,7 +3762,7 @@ void func_800615AC(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UN UNUSED s32 stackPadding0; UNUSED s32 stackPadding1; f32 temp_f0; - f32 sp28[10] = { (f32) DEGREES(-1), (f32) DEGREES(1), (f32) DEGREES(2), (f32) -DEGREES(2), 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f }; + f32 sp28[10] = { (f32) -DEGREES(1), (f32) DEGREES(1), (f32) DEGREES(2), (f32) -DEGREES(2), 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f }; if (random_int(3U) == 2.0f) { player->particlePool3[arg1].isAlive = 1; @@ -3858,7 +3858,7 @@ void func_80061D4C(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UN UNUSED s32 stackPadding0; UNUSED s32 stackPadding1; UNUSED s32 stackPadding2; - f32 sp20[10] = { (f32) DEGREES(-1), (f32) DEGREES(1), (f32) DEGREES(2), (f32) -DEGREES(2), 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f }; + f32 sp20[10] = { (f32) -DEGREES(1), (f32) DEGREES(1), (f32) DEGREES(2), (f32) -DEGREES(2), 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f }; if (random_int(3U) == 2.0f) { player->particlePool3[arg1].isAlive = 1; @@ -4008,7 +4008,7 @@ void func_80062484(Player* player, Particle* arg1, s32 arg2) { arg1->pos[1] = player->unk_074 + 1.0f; arg1->pos[2] = player->pos[2]; arg1->pos[0] = player->pos[0]; - arg1->rotation = (arg2 * 0x1998) - player->rotation[1]; + arg1->rotation = (arg2 * (36 * DEGREES(1))) - player->rotation[1]; arg1->type = 4; arg1->timer = 0; } @@ -5259,7 +5259,7 @@ void func_80066BAC(Player* player, UNUSED s8 arg1, s16 arg2, s8 arg3) { spDC[2] = player->pos[2] + (coss(player->unk_048[arg3]) * -10.0f); spDC[0] = player->pos[0] + (sins(player->unk_048[arg3]) * -10.0f); if (player->collision.surfaceDistance[2] >= 300.0f) { - spD4[0] = cameras[arg3].rot[0] - 0x4000; + spD4[0] = cameras[arg3].rot[0] - DEGREES(90); } else { spD4[0] = 0; } diff --git a/src/cpu_vehicles_camera_path/vehicle_utils.inc.c b/src/cpu_vehicles_camera_path/vehicle_utils.inc.c index d359e10708..f69da9ebd5 100644 --- a/src/cpu_vehicles_camera_path/vehicle_utils.inc.c +++ b/src/cpu_vehicles_camera_path/vehicle_utils.inc.c @@ -44,7 +44,7 @@ void spawn_vehicle_on_road(VehicleStuff* vehicle) { func_8000D6D0(vehicle->position, (s16*) &vehicle->pathPointIndex, vehicle->speed, vehicle->someMultiplierTheSequel, 0, 3); vehicle->rotation[0] = 0; - vehicle->rotation[1] = -0x8000; + vehicle->rotation[1] = -DEGREES(180); vehicle->rotation[2] = 0; } else { func_8000D940(vehicle->position, (s16*) &vehicle->pathPointIndex, vehicle->speed, diff --git a/src/effects.c b/src/effects.c index 4d88d76c6f..c6230d9e79 100644 --- a/src/effects.c +++ b/src/effects.c @@ -225,7 +225,7 @@ void func_8008C62C(Player* player, s8 playerIndex) { player_decelerate_alternative(player, 5.0f); player->unk_0A8 += (s16) 0xA0; - player->unk_042 += (s16) 0x71C; + player->unk_042 += (s16) DEGREES(10); if (player->unk_0A8 >= 0x2000) { player->unk_0A8 = 0; player->unk_236 = (s16) (player->unk_236 - 1); @@ -1323,7 +1323,7 @@ void func_8008F3E0(Player* player) { void func_8008F3F4(Player* player, UNUSED s8 arg1) { player->unk_0A8 += 0x80; - player->unk_042 += 0x71C; + player->unk_042 += DEGREES(10); player->steerPosition = 0; player->currentSpeed = 0.0f; player->unk_08C /= 2; @@ -2083,9 +2083,9 @@ void func_80091298(Player* player, s8 arg1) { if (player->unk_0B2 == 0) { var_v1 = 0; } else { - player->rotation[1] -= 0xE38; - D_8018D920[arg1] -= 0xE38; - var_v1 = (u16) D_8018D920[arg1] / 3640; + player->rotation[1] -= DEGREES(20); + D_8018D920[arg1] -= DEGREES(20); + var_v1 = (u16) D_8018D920[arg1] / DEGREES(20); } if (((var_v1 == 9) && (player->unk_0B2 == 1)) || ((var_v1 == 0) && (player->unk_0B2 == 2)) || (player->unk_0B2 == 0)) { diff --git a/src/main.c b/src/main.c index 60a4cc66db..d6e2f76a12 100644 --- a/src/main.c +++ b/src/main.c @@ -631,13 +631,13 @@ void race_logic_loop(void) { rotY = camera1->rot[1]; gDebugPathCount = D_800DC5EC->pathCounter; - if (rotY < 0x2000) { + if (rotY < DEGREES(45)) { func_80057A50(40, 100, "SOUTH ", gDebugPathCount); - } else if (rotY < 0x6000) { + } else if (rotY < DEGREES(135)) { func_80057A50(40, 100, "EAST ", gDebugPathCount); - } else if (rotY < 0xA000) { + } else if (rotY < (DEGREES_360 - DEGREES(135))) { func_80057A50(40, 100, "NORTH ", gDebugPathCount); - } else if (rotY < 0xE000) { + } else if (rotY < (DEGREES_360 - DEGREES(45))) { func_80057A50(40, 100, "WEST ", gDebugPathCount); } else { func_80057A50(40, 100, "SOUTH ", gDebugPathCount); diff --git a/src/player_controller.c b/src/player_controller.c index b5009a66e4..3ffcc6cc6f 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -695,7 +695,7 @@ void func_80029200(Player* player, s8 screenId) { if ((s32) player->slopeAccel < -0x71B) { player->animGroupSelector[screenId] = 0; } - if (((s32) player->slopeAccel < -0x4F9) && ((s32) player->slopeAccel >= -0x71B)) { + if (((s32) player->slopeAccel < -0x4F9) && ((s32) player->slopeAccel > -DEGREES(10))) { player->animGroupSelector[screenId] = 1; } if ((player->slopeAccel <= -DEGREES(3)) && (player->slopeAccel > -DEGREES(7))) { @@ -713,10 +713,10 @@ void func_80029200(Player* player, s8 screenId) { if ((player->slopeAccel >= DEGREES(3)) && (player->slopeAccel < DEGREES(7))) { player->animGroupSelector[screenId] = 6; } - if ((player->slopeAccel >= DEGREES(7)) && (player->slopeAccel < 0x71C)) { + if ((player->slopeAccel >= DEGREES(7)) && (player->slopeAccel < DEGREES(10))) { player->animGroupSelector[screenId] = 7; } - if (player->slopeAccel >= 0x71C) { + if (player->slopeAccel >= DEGREES(10)) { player->animGroupSelector[screenId] = 8; } } @@ -2085,8 +2085,8 @@ void func_8002D028(Player* player, s8 playerIndex) { temp_f18 = sqrtf((sp4C[0] - player->pos[0]) * (sp4C[0] - player->pos[0]) + (sp4C[2] - player->pos[2]) * (sp4C[2] - player->pos[2])); if (temp_f18 <= 8.0f) { - adjust_angle(&player->rotation[1], -0x8000, DEGREES(2)); - if ((player->rotation[1] < (-0x7F41)) || (player->rotation[1] > 0x7F41)) { + adjust_angle(&player->rotation[1], -DEGREES(180), DEGREES(2)); + if ((player->rotation[1] <= (-179 * DEGREES(1))) || (player->rotation[1] >= (179 * DEGREES(1)))) { player->type &= ~PLAYER_STAGING; } player->unk_08C = 0; @@ -2285,7 +2285,7 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player player->rotation[1]); } else { calculate_orientation_matrix(player->orientationMatrix, player->unk_058, player->unk_05C, player->unk_060, - player->rotation[1] + 0x8000); + player->rotation[1] + DEGREES(180)); } player->effects |= MIDAIR_EFFECT; player->unk_0C2 += 1; diff --git a/src/racing/actors.c b/src/racing/actors.c index 92b13e784f..d55d449273 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -889,7 +889,7 @@ void spawn_foliage(struct ActorSpawnData* arg0) { var_s3 = (struct ActorSpawnData*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); vec3f_set(velocity, 0.0f, 0.0f, 0.0f); - rotation[0] = 0x4000; + rotation[0] = DEGREES(90); rotation[1] = 0; rotation[2] = 0; @@ -1125,7 +1125,7 @@ void spawn_course_actors(void) { rrxing = (struct RailroadCrossing*) &gActorList[add_actor_to_empty_slot(position, rotation, velocity, ACTOR_RAILROAD_CROSSING)]; rrxing->crossingId = 1; - vec3s_set(rotation, 0, -0x2000, 0); + vec3s_set(rotation, 0, -DEGREES(45), 0); vec3f_set(position, -2459.0f, 2.0f, 2263.0f); position[0] *= gCourseDirection; rrxing = (struct RailroadCrossing*) &gActorList[add_actor_to_empty_slot(position, rotation, velocity, @@ -2456,8 +2456,8 @@ void render_course_actors(struct UnkStruct_800DC5EC* arg0) { struct Actor* actor; UNUSED Vec3f sp4C = { 0.0f, 5.0f, 10.0f }; - f32 sp48 = sins(camera->rot[1] - 0x8000); // unk26; - f32 temp_f0 = coss(camera->rot[1] - 0x8000); + f32 sp48 = sins(camera->rot[1] - DEGREES(180)); // unk26; + f32 temp_f0 = coss(camera->rot[1] - DEGREES(180)); D_801502C0[0][0] = temp_f0; D_801502C0[0][2] = -sp48; diff --git a/src/racing/actors_extended.c b/src/racing/actors_extended.c index 79fda531d7..a00c622ede 100644 --- a/src/racing/actors_extended.c +++ b/src/racing/actors_extended.c @@ -453,7 +453,7 @@ void update_actor_triple_shell(TripleShellParent* parent, s16 shellType) { } if (parent->shellIndices[1] > 0.0f) { shell = (struct ShellActor*) &gActorList[(s16) parent->shellIndices[1]]; - if ((shell->rotAngle < 0xAA1) || (shell->rotAngle >= 0x38F)) { + if ((shell->rotAngle < (DEGREES(15) - 9)) || (shell->rotAngle > DEGREES(5))) { someVelocity[0] = 0; someVelocity[1] = 0; someVelocity[2] = 8; @@ -479,7 +479,7 @@ void update_actor_triple_shell(TripleShellParent* parent, s16 shellType) { } if (parent->shellIndices[2] > 0.0f) { shell = (struct ShellActor*) &gActorList[(s16) parent->shellIndices[2]]; - if ((shell->rotAngle < -DEGREES(5)) || (shell->rotAngle >= -0x71B)) { + if ((shell->rotAngle < -DEGREES(5)) || (shell->rotAngle > -DEGREES(10))) { someVelocity[0] = 0; someVelocity[1] = 0; someVelocity[2] = 8; @@ -544,7 +544,7 @@ s32 use_triple_shell_item(Player* player, s16 tripleShellType) { parent = (TripleShellParent*) &gActorList[actorIndex]; parent->state = 0; parent->rotVelocity = DEGREES(8); - parent->rotAngle = -0x8000; + parent->rotAngle = - DEGREES(180); parent->playerId = player - gPlayerOne; parent->shellsAvailable = 0; parent->unk_08 = 0.0f; @@ -589,7 +589,7 @@ s32 init_triple_shell(TripleShellParent* parent, Player* player, s16 shellType, break; } shell->rotVelocity = 0; - shell->rotAngle = -0x8000; + shell->rotAngle = -DEGREES(180); shell->playerId = player - gPlayerOne; shell->parentIndex = (struct Actor*) parent - gActorList; shell->shellId = shellId; @@ -632,7 +632,7 @@ s32 use_green_shell_item(Player* player) { func_802B4E30((struct Actor*) shell); shell->state = HELD_SHELL; shell->rotVelocity = 0; - shell->rotAngle = -0x8000; + shell->rotAngle = -DEGREES(180); shell->playerId = player - gPlayerOne; return actorIndex; } @@ -672,7 +672,7 @@ s32 use_red_shell_item(Player* player) { func_802B4E30((struct Actor*) shell); shell->state = HELD_SHELL; shell->rotVelocity = 0; - shell->rotAngle = player->rotation[1] - 0x8000; + shell->rotAngle = player->rotation[1] - DEGREES(180); shell->playerId = player - gPlayerOne; return actorIndex; } diff --git a/src/racing/render_courses.c b/src/racing/render_courses.c index c9f171699b..b3b64e53c2 100644 --- a/src/racing/render_courses.c +++ b/src/racing/render_courses.c @@ -85,26 +85,26 @@ void render_course_segments(uintptr_t addr, struct UnkStruct_800DC5EC* arg1) { u16 rot; if (gIsMirrorMode) { rot = (u16) camera->rot[1]; - if (rot < 0x2000) { + if (rot < DEGREES(45)) { direction = SOUTH; - } else if (rot < 0x6000) { + } else if (rot < DEGREES(135)) { direction = WEST; - } else if (rot < 0xA000) { + } else if (rot < (DEGREES_360 - DEGREES(135))) { direction = NORTH; - } else if (rot < 0xE000) { + } else if (rot < (DEGREES_360 - DEGREES(45))) { direction = EAST; } else { direction = SOUTH; } } else { rot = (u16) camera->rot[1]; - if (rot < 0x2000) { + if (rot < DEGREES(45)) { direction = SOUTH; - } else if (rot < 0x6000) { + } else if (rot < DEGREES(135)) { direction = EAST; - } else if (rot < 0xA000) { + } else if (rot < (DEGREES_360 - DEGREES(135))) { direction = NORTH; - } else if (rot < 0xE000) { + } else if (rot < (DEGREES_360 - DEGREES(45))) { direction = WEST; } else { direction = SOUTH; @@ -1510,7 +1510,7 @@ void course_generate_collision_mesh(void) { } parse_course_displaylists((uintptr_t) &d_course_choco_mountain_addr); // D_8015F590 is only used here, so this seems meaningless - vec_unit_z_rotX_rotY(0x238E, 0x31C7, D_8015F590); + vec_unit_z_rotX_rotY(DEGREES(50), DEGREES(70), D_8015F590); func_80295C6C(); D_8015F8E4 = -80.0f; break; diff --git a/src/render_objects.c b/src/render_objects.c index 21ac663f18..66cba01ac0 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -2480,9 +2480,9 @@ void draw_minimap_character(s32 arg0, s32 playerId, s32 characterId) { // huh? if (characterId != 8) { if ((gGPCurrentRaceRankByPlayerId[playerId] == 0) && (gModeSelection != 3) && (gModeSelection != 1)) { - func_80046424(x, y, player->rotation[1] + 0x8000, 1.0f, (u8*)&common_texture_minimap_kart_mario[characterId * 64], common_vtx_player_minimap_icon, 8, 8, 8, 8); + func_80046424(x, y, player->rotation[1] + DEGREES(180), 1.0f, (u8*)&common_texture_minimap_kart_mario[characterId * 64], common_vtx_player_minimap_icon, 8, 8, 8, 8); } else { - func_800463B0(x, y, player->rotation[1] + 0x8000, 1.0f, (u8*)&common_texture_minimap_kart_mario[characterId * 64], common_vtx_player_minimap_icon, 8, 8, 8, 8); + func_800463B0(x, y, player->rotation[1] + DEGREES(180), 1.0f, (u8*)&common_texture_minimap_kart_mario[characterId * 64], common_vtx_player_minimap_icon, 8, 8, 8, 8); } } else { if (gGPCurrentRaceRankByPlayerId[playerId] == 0) { diff --git a/src/render_player.c b/src/render_player.c index c5668aca37..1ccce9c80b 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -125,8 +125,8 @@ u16 check_player_camera_collision(Player* player, Camera* camera, f32 arg2, f32 sp58 = (arg2 * sins((camera->rot[1] - var_v0))) + camera->pos[0]; sp48 = (arg2 * coss((camera->rot[1] + var_v0))) + camera->pos[2]; sp54 = (arg2 * sins((camera->rot[1] + var_v0))) + camera->pos[0]; - sp44 = (arg3 * coss((camera->rot[1] + 0x5FFA))) + camera->pos[2]; - sp50 = (arg3 * sins((camera->rot[1] + 0x5FFA))) + camera->pos[0]; + sp44 = (arg3 * coss((camera->rot[1] + (135 * DEGREES(1))))) + camera->pos[2]; + sp50 = (arg3 * sins((camera->rot[1] + (135 * DEGREES(1))))) + camera->pos[0]; sp64 = ((sp4C - player->pos[2]) * (sp54 - player->pos[0])) - ((sp48 - player->pos[2]) * (sp58 - player->pos[0])); sp60 = ((sp48 - player->pos[2]) * (sp50 - player->pos[0])) - ((sp44 - player->pos[2]) * (sp54 - player->pos[0])); @@ -152,12 +152,12 @@ u16 func_8001FD78(Player* player, f32 posX, UNUSED f32 arg2, f32 posZ) { ret = false; - sp58 = (70.0f * coss(((player->unk_0C0 - player->rotation[1]) - 0x71C))) + player->pos[2]; - sp64 = (70.0f * sins(((player->unk_0C0 - player->rotation[1]) - 0x71C))) + player->pos[0]; - sp54 = (70.0f * coss(((player->unk_0C0 - player->rotation[1]) + 0x71C))) + player->pos[2]; - sp60 = (70.0f * sins(((player->unk_0C0 - player->rotation[1]) + 0x71C))) + player->pos[0]; - sp50 = (10.0f * coss(((player->unk_0C0 - player->rotation[1]) + 0x1C70))) + player->pos[2]; - sp5c = (10.0f * sins(((player->unk_0C0 - player->rotation[1]) + 0x1C70))) + player->pos[0]; + sp58 = (70.0f * coss(((player->unk_0C0 - player->rotation[1]) - DEGREES(10)))) + player->pos[2]; + sp64 = (70.0f * sins(((player->unk_0C0 - player->rotation[1]) - DEGREES(10)))) + player->pos[0]; + sp54 = (70.0f * coss(((player->unk_0C0 - player->rotation[1]) + DEGREES(10)))) + player->pos[2]; + sp60 = (70.0f * sins(((player->unk_0C0 - player->rotation[1]) + DEGREES(10)))) + player->pos[0]; + sp50 = (10.0f * coss(((player->unk_0C0 - player->rotation[1]) + (DEGREES(40) - 1)))) + player->pos[2]; + sp5c = (10.0f * sins(((player->unk_0C0 - player->rotation[1]) + (DEGREES(40) - 1)))) + player->pos[0]; temp_f14 = ((sp58 - posZ) * (sp60 - posX)) - ((sp54 - posZ) * (sp64 - posX)); thing0 = ((sp54 - posZ) * (sp5c - posX)) - ((sp50 - posZ) * (sp60 - posX)); @@ -1445,7 +1445,7 @@ void render_kart(Player* player, s8 playerId, s8 arg2, s8 flipOffset) { thing = (u16) (player->unk_048[arg2] + player->rotation[1] + player->unk_0C0); temp_v1 = player->unk_0CC[arg2] * sins(thing); if ((player->effects & MIDAIR_EFFECT) == MIDAIR_EFFECT) { - sp14C[0] = cameras[arg2].rot[0] - 0x4000; + sp14C[0] = cameras[arg2].rot[0] - DEGREES(90); } else { sp14C[0] = -temp_v1 * 0.8; } @@ -1635,7 +1635,7 @@ void func_80025DE8(Player* player, s8 playerId, s8 screenId, s8 flipOffset) { sp9C[0] = player->pos[0] + (sins(-player->rotation[1]) * -1.5); sp9C[1] = ((player->pos[1] - player->boundingBoxSize) + player->unk_108) + 0.1; sp9C[2] = player->pos[2] + (coss(-player->rotation[1]) * -1.5); - sp94[0] = DEGREES(-1); + sp94[0] = -DEGREES(1); sp94[1] = player->unk_048[screenId]; sp94[2] = player->unk_050[screenId]; diff --git a/src/update_objects.c b/src/update_objects.c index ead1cc35a1..cc91a35dcc 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -2583,7 +2583,7 @@ void func_80077F64(s32 objectIndex, Camera* camera) { switch (gObjectList[objectIndex].unk_0AE) { /* irregular */ case 1: - gObjectList[objectIndex].direction_angle[1] = (camera->rot[1] + random_int(0x4000U)) - 0x2000; + gObjectList[objectIndex].direction_angle[1] = (camera->rot[1] + random_int(0x4000U)) - DEGREES(45); object_origin_pos_randomize_around_y(objectIndex, 0x00B4, 0x0014U); rand = random_int(0x0064U); @@ -2856,8 +2856,8 @@ void course_update_clouds(s32 arg0) { break; } - D_8018D208 = ((D_8018D200 / 2) * DEGREES(1)) + 0x71C; - D_8018D210 = (-(D_8018D200 / 2) * DEGREES(1)) - 0x71C; + D_8018D208 = ((D_8018D200 / 2) * DEGREES(1)) + DEGREES(10); + D_8018D210 = (-(D_8018D200 / 2) * DEGREES(1)) - DEGREES(10); D_8018D1E8 = 1.7578125 / D_8018D200; D_8018D218 = 0xA0; #if !ENABLE_CUSTOM_COURSE_ENGINE @@ -4213,7 +4213,7 @@ void wrapper_update_boos(void) { // Updates the display status on an object based on its relative direction to the camera void func_8007C360(s32 objectIndex, Camera* camera) { u16 rot = camera->rot[1]; - u16 temp = ((u16) (gObjectList[objectIndex].direction_angle[1] - rot + 0x8000) * 0x24) / 0x10000; + u16 temp = ((u16) (gObjectList[objectIndex].direction_angle[1] - rot + DEGREES(180)) * 0x24) / 0x10000; // can not use DEGREES(180) if (temp < 0x13) { set_object_flag_status_false(objectIndex, 0x80); @@ -4551,7 +4551,7 @@ void func_8007D070(void) { temp_s2 = random_int(0x012CU); temp_s3 = random_int(0x1000U) - 0x800; temp_t5 = random_int(0x000FU) - 5; - gObjectList[objectIndex].direction_angle[1] = D_8018CF1C->rotation[1] + 0x8000; + gObjectList[objectIndex].direction_angle[1] = D_8018CF1C->rotation[1] + DEGREES(180); temp_t2 = (D_8018CF14->rot[1] + temp_s3); gObjectList[objectIndex].origin_pos[0] = D_8018CF1C->pos[0] + (sins(temp_t2) * temp_s2); gObjectList[objectIndex].origin_pos[1] = temp_t5; From cfcacd02732724e761caae6b86d6d68c36899970 Mon Sep 17 00:00:00 2001 From: Jed Grabman Date: Fri, 17 Apr 2026 18:01:57 -0400 Subject: [PATCH 4/9] Simplify DEGREES usage --- include/defines.h | 4 +--- src/code_80057C60.c | 4 ++-- src/main.c | 4 ++-- src/racing/actors_extended.c | 4 ++-- src/racing/render_courses.c | 8 ++++---- src/update_objects.c | 2 +- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/include/defines.h b/include/defines.h index eaf36392ef..81f0f44ab7 100644 --- a/include/defines.h +++ b/include/defines.h @@ -330,9 +330,7 @@ enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE }; */ #define MAX_TIME 0x927C0 -#define ONE_DEGREE (f32) 65536.0f / 360.0f -#define DEGREES(degree) ((u16) ((f32) degree * ONE_DEGREE)) -#define DEGREES_360 65536 +#define DEGREES(degree) ((u16) (degree * 65536.0f / 360.0f)) // player->unk_046 diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 6ca8aed0a5..27a4255a9c 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -3762,7 +3762,7 @@ void func_800615AC(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UN UNUSED s32 stackPadding0; UNUSED s32 stackPadding1; f32 temp_f0; - f32 sp28[10] = { (f32) -DEGREES(1), (f32) DEGREES(1), (f32) DEGREES(2), (f32) -DEGREES(2), 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f }; + f32 sp28[10] = { (f32) -DEGREES(1), (f32) DEGREES(1), (f32) DEGREES(2), (f32) -DEGREES(2), DEGREES(3), -DEGREES(3), DEGREES(4), -DEGREES(4), DEGREES(5), -DEGREES(5) }; if (random_int(3U) == 2.0f) { player->particlePool3[arg1].isAlive = 1; @@ -3858,7 +3858,7 @@ void func_80061D4C(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UN UNUSED s32 stackPadding0; UNUSED s32 stackPadding1; UNUSED s32 stackPadding2; - f32 sp20[10] = { (f32) -DEGREES(1), (f32) DEGREES(1), (f32) DEGREES(2), (f32) -DEGREES(2), 546.0f, -546.0f, 728.0f, -728.0f, 910.0f, -910.0f }; + f32 sp20[10] = { (f32) -DEGREES(1), (f32) DEGREES(1), (f32) DEGREES(2), (f32) -DEGREES(2), DEGREES(3), -DEGREES(3), DEGREES(4), -DEGREES(4), DEGREES(5), -DEGREES(5) }; if (random_int(3U) == 2.0f) { player->particlePool3[arg1].isAlive = 1; diff --git a/src/main.c b/src/main.c index d6e2f76a12..b97fa86999 100644 --- a/src/main.c +++ b/src/main.c @@ -635,9 +635,9 @@ void race_logic_loop(void) { func_80057A50(40, 100, "SOUTH ", gDebugPathCount); } else if (rotY < DEGREES(135)) { func_80057A50(40, 100, "EAST ", gDebugPathCount); - } else if (rotY < (DEGREES_360 - DEGREES(135))) { + } else if (rotY < DEGREES(225)) { func_80057A50(40, 100, "NORTH ", gDebugPathCount); - } else if (rotY < (DEGREES_360 - DEGREES(45))) { + } else if (rotY < DEGREES(315)) { func_80057A50(40, 100, "WEST ", gDebugPathCount); } else { func_80057A50(40, 100, "SOUTH ", gDebugPathCount); diff --git a/src/racing/actors_extended.c b/src/racing/actors_extended.c index a00c622ede..5e83756d05 100644 --- a/src/racing/actors_extended.c +++ b/src/racing/actors_extended.c @@ -356,7 +356,7 @@ void update_actor_triple_shell(TripleShellParent* parent, s16 shellType) { break; case SPAWN_SECOND_SHELL: if (parent->rotVelocity > 0) { - if (someRotAngle >= (DEGREES_360 - DEGREES(60))) { + if (someRotAngle > DEGREES(300)) { if (init_triple_shell(parent, &gPlayers[playerId], shellType, 1U) != -1) { func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x12)); parent->shellsAvailable += 1; @@ -382,7 +382,7 @@ void update_actor_triple_shell(TripleShellParent* parent, s16 shellType) { } parent->state = 3; } - } else if ((someRotAngle < (DEGREES_360 - DEGREES(60) - 1)) && (someRotAngle >= (DEGREES_360 - DEGREES(70)))) { + } else if ((someRotAngle < DEGREES(300)) && (someRotAngle > DEGREES(290))) { if (init_triple_shell(parent, &gPlayers[playerId], shellType, 2U) != -1) { func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x12)); parent->shellsAvailable += 1; diff --git a/src/racing/render_courses.c b/src/racing/render_courses.c index b3b64e53c2..50f5b850eb 100644 --- a/src/racing/render_courses.c +++ b/src/racing/render_courses.c @@ -89,9 +89,9 @@ void render_course_segments(uintptr_t addr, struct UnkStruct_800DC5EC* arg1) { direction = SOUTH; } else if (rot < DEGREES(135)) { direction = WEST; - } else if (rot < (DEGREES_360 - DEGREES(135))) { + } else if (rot < DEGREES(225)) { direction = NORTH; - } else if (rot < (DEGREES_360 - DEGREES(45))) { + } else if (rot < DEGREES(315)) { direction = EAST; } else { direction = SOUTH; @@ -102,9 +102,9 @@ void render_course_segments(uintptr_t addr, struct UnkStruct_800DC5EC* arg1) { direction = SOUTH; } else if (rot < DEGREES(135)) { direction = EAST; - } else if (rot < (DEGREES_360 - DEGREES(135))) { + } else if (rot < DEGREES(225)) { direction = NORTH; - } else if (rot < (DEGREES_360 - DEGREES(45))) { + } else if (rot < DEGREES(315)) { direction = WEST; } else { direction = SOUTH; diff --git a/src/update_objects.c b/src/update_objects.c index cc91a35dcc..f657dae144 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -4213,7 +4213,7 @@ void wrapper_update_boos(void) { // Updates the display status on an object based on its relative direction to the camera void func_8007C360(s32 objectIndex, Camera* camera) { u16 rot = camera->rot[1]; - u16 temp = ((u16) (gObjectList[objectIndex].direction_angle[1] - rot + DEGREES(180)) * 0x24) / 0x10000; // can not use DEGREES(180) + u16 temp = ((u16) (gObjectList[objectIndex].direction_angle[1] - rot + DEGREES(180)) * 0x24) / 0x10000; if (temp < 0x13) { set_object_flag_status_false(objectIndex, 0x80); From 6109d88cd1bb2f5e22f070ddf5aa3f4056051e58 Mon Sep 17 00:00:00 2001 From: Jed Grabman Date: Fri, 17 Apr 2026 18:55:50 -0400 Subject: [PATCH 5/9] A few additional DEGREES conversions --- src/actors/falling_rock/update.inc.c | 2 +- src/actors/mario_sign/update.inc.c | 2 +- src/code_80057C60.c | 22 +++++++++++----------- src/effects.c | 16 ++++++++-------- src/racing/actors.c | 2 +- src/spawn_players.c | 14 +++++++------- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/actors/falling_rock/update.inc.c b/src/actors/falling_rock/update.inc.c index 6d37306695..5f119b9f61 100644 --- a/src/actors/falling_rock/update.inc.c +++ b/src/actors/falling_rock/update.inc.c @@ -67,7 +67,7 @@ void update_actor_falling_rocks(struct FallingRock* rock) { if (rock->pos[1] < D_8015F8E4) { func_8029CF0C(d_course_choco_mountain_falling_rock_spawns, rock); } - rock->rot[0] += (s16) ((rock->velocity[2] * 5461.0f) / 20.0f); + rock->rot[0] += (s16) ((rock->velocity[2] * 5461.0f) / 20.0f); // DEGREES(30) is 5460 rock->rot[2] += (s16) ((rock->velocity[0] * 5461.0f) / 20.0f); rock->velocity[1] -= 0.1; if (rock->velocity[1] < (-2.0f)) { diff --git a/src/actors/mario_sign/update.inc.c b/src/actors/mario_sign/update.inc.c index 3f1aabacde..c7670e4a20 100644 --- a/src/actors/mario_sign/update.inc.c +++ b/src/actors/mario_sign/update.inc.c @@ -11,7 +11,7 @@ void update_actor_mario_sign(struct Actor* arg0) { arg0->pos[1] += 4.0f; if (arg0->pos[1] > 800.0f) { arg0->flags |= 0x800; - arg0->rot[1] += 1820; + arg0->rot[1] += DEGREES(10); } } else { arg0->rot[1] += DEGREES(1); diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 27a4255a9c..41343ee251 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -3966,9 +3966,9 @@ void func_800621BC(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 player->particlePool3[arg1].rotation = 0; if (player->particlePool3[arg1].unk_010 == 1) { - player->particlePool3[arg1].rotation += 2184; + player->particlePool3[arg1].rotation += DEGREES(12); } else { - player->particlePool3[arg1].rotation -= 2184; + player->particlePool3[arg1].rotation -= DEGREES(12); } player->particlePool3[arg1].pos[2] = @@ -3987,9 +3987,9 @@ void func_800621BC(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 set_particle_colour(&new_var2->particlePool3[arg1], RGB32(0xFF, 0xFF, 0x20), 0xFF); new_var2->particlePool3[arg1].rotation = 0; if (new_var2->particlePool3[arg1].unk_010 == 1) { - new_var2->particlePool3[arg1].rotation += 2184; + new_var2->particlePool3[arg1].rotation += DEGREES(12); } else { - new_var2->particlePool3[arg1].rotation -= 2184; + new_var2->particlePool3[arg1].rotation -= DEGREES(12); } new_var = new_var2; @@ -4787,7 +4787,7 @@ void func_80064B30(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { player->particlePool3[arg1].type = NO_PARTICLE; } - player->particlePool3[arg1].red += 1820; + player->particlePool3[arg1].red += DEGREES(10); if (player->particlePool3[arg1].timer >= 6) { player->particlePool3[arg1].alpha -= 16; if (player->particlePool3[arg1].alpha <= 0) { @@ -4799,9 +4799,9 @@ void func_80064B30(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { void func_80064C74(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (player->particlePool3[arg1].unk_010 == 1) { - player->particlePool3[arg1].rotation += 2184; + player->particlePool3[arg1].rotation += DEGREES(12); } else { - player->particlePool3[arg1].rotation -= 2184; + player->particlePool3[arg1].rotation -= DEGREES(12); } player->particlePool3[arg1].pos[2] = @@ -4898,9 +4898,9 @@ void func_800650FC(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 index) { player->particlePool2[index].pos[0] = (f32) player->pos[0]; player->particlePool2[index].pos[1] = (f32) (player->pos[1] + 4.0f); if ((player->effects & BANANA_SPINOUT_EFFECT) == BANANA_SPINOUT_EFFECT) { - player->particlePool2[index].rotation += 4732; + player->particlePool2[index].rotation += 26 * DEGREES(1); } else { - player->particlePool2[index].rotation -= 4732; + player->particlePool2[index].rotation -= 26 * DEGREES(1); } if (((player->effects & BANANA_SPINOUT_EFFECT) != BANANA_SPINOUT_EFFECT) && @@ -5315,7 +5315,7 @@ void func_80067280(Player* player, UNUSED s8 arg1, s16 arg2, s8 arg3) { sp7C[0] = player->particlePool3[arg2].pos[0]; sp7C[1] = player->particlePool3[arg2].pos[1]; sp7C[2] = player->particlePool3[arg2].pos[2]; - sp74[0] = -0x071C; + sp74[0] = -0x071C; // DEGREES(10)? sp74[2] = 0; if (player->particlePool3[arg2].unk_010 == 1) { sp74[1] = player->unk_048[arg3] - 0x2000; @@ -5891,7 +5891,7 @@ void update_player_one_balloon_position(Player* player, f32 arg1, f32 arg2, s8 p D_8018D7A0[playerId][balloonId] = -0x0029; } D_8018D7D0[playerId][balloonId] += D_8018D7A0[playerId][balloonId]; - if (D_8018D7D0[playerId][balloonId] >= 0x38E) { + if (D_8018D7D0[playerId][balloonId] >= 0x38E) { // 0x38E is DEGREES(5) possibly D_8018D800[playerId][balloonId] = -random_int(8U); if (D_8018D830[playerId][balloonId] != 1) { D_8018D830[playerId][balloonId] = 1; diff --git a/src/effects.c b/src/effects.c index c6230d9e79..0317fe117c 100644 --- a/src/effects.c +++ b/src/effects.c @@ -321,7 +321,7 @@ void remove_spinout_effects(Player* player, s8 playerId) { void func_8008C9EC(Player* player, s8 playerIndex) { s16 stackPadding1; s16 stackPadding2; - s16 sp30[5] = { 1092, 1092, 2184, 1638, 1820 }; + s16 sp30[5] = { DEGREES(6), DEGREES(6), DEGREES(12), DEGREES(9), DEGREES(10) }; player->unk_206 = 0; player->slopeAccel = 0; @@ -600,8 +600,8 @@ void func_8008D698(Player* player, s8 playerIndex) { player->rotation[1] = player->unk_0AE; temp = 0; } else { - player->rotation[1] -= 1820; - D_8018D920[playerIndex] -= 1820; + player->rotation[1] -= DEGREES(10); + D_8018D920[playerIndex] -= DEGREES(10); temp = ((u16) D_8018D920[playerIndex] / DEGREES(10)); } if (temp == 0) { @@ -654,8 +654,8 @@ void func_8008D8B4(Player* player, s8 playerIndex) { player->rotation[1] = player->unk_0AE; temp = 0; } else { - player->rotation[1] -= 1820; - D_8018D920[playerIndex] -= 1820; + player->rotation[1] -= DEGREES(10); + D_8018D920[playerIndex] -= DEGREES(10); temp = ((u16) (D_8018D920[playerIndex]) / DEGREES(10)); } if (temp == 0) { @@ -892,7 +892,7 @@ void apply_lightning_effect(Player* player, s8 playerIndex) { } else if ((player->effects & LIGHTNING_STRIKE_EFFECT) == LIGHTNING_STRIKE_EFFECT) { player->rotation[1] -= DEGREES(8); D_8018D920[playerIndex] -= DEGREES(8); - test = (u16) D_8018D920[playerIndex] / 1456; + test = (u16) D_8018D920[playerIndex] / DEGREES(8); if (test == 0) { player->unk_0B2--; if (player->unk_0B2 <= 0) { @@ -1976,14 +1976,14 @@ void func_80090970(Player* player, s8 playerId, s8 arg2) { } if (player->unk_D98 == 1) { player->unk_D9C += player->unk_DA0; - if (player->unk_D9C >= 1820.0f) { + if (player->unk_D9C >= (f32) DEGREES(10)) { player->unk_DA0 = 0.0f; player->unk_D98 *= -1; } } if (player->unk_D98 == -1) { player->unk_D9C -= player->unk_DA0; - if (player->unk_D9C <= -1820.0f) { + if (player->unk_D9C <= (f32) -DEGREES(10)) { player->unk_DA0 = 0.0f; player->unk_D98 *= -1; } diff --git a/src/racing/actors.c b/src/racing/actors.c index d55d449273..2977657500 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -708,7 +708,7 @@ void render_actor_shell(Camera* camera, Mat4 matrix, struct ShellActor* shell) { } else { phi_t3 = (uintptr_t) D_802BA050; } - temp_t8 = (u16) shell->rotVelocity / 4369; // Give a number between 0-15 + temp_t8 = (u16) shell->rotVelocity / DEGREES(24); // Give a number between 0-15 phi_t3 += sp58[temp_t8]; // Select sprite matrix[3][0] = shell->pos[0]; diff --git a/src/spawn_players.c b/src/spawn_players.c index d7d38255d8..a33f0c802b 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -821,21 +821,21 @@ void spawn_players_4p_battle(f32* arg0, f32* arg1, f32 arg2) { void func_8003BE30(void) { spawn_player(gPlayerOne, 0, -2770.774f, -345.187f, -34.6f, 0.0f, gCharacterIdByGPOverallRank[0], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); - spawn_player(gPlayerTwo, 1, -3691.506f, -6.822f, -6.95f, 36400.0f, gCharacterIdByGPOverallRank[1], + spawn_player(gPlayerTwo, 1, -3691.506f, -6.822f, -6.95f, (f32) (200 * DEGREES(1)), gCharacterIdByGPOverallRank[1], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); - spawn_player(gPlayerThree, 2, -3475.028f, -998.485f, -8.059f, 45500.0f, gCharacterIdByGPOverallRank[2], + spawn_player(gPlayerThree, 2, -3475.028f, -998.485f, -8.059f, (f32) (250 * DEGREES(1)), gCharacterIdByGPOverallRank[2], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); if (D_802874D8.unk1D >= 3) { - spawn_player(gPlayerFour, 3, -3025.772f, 110.039f, -23.224f, 28210.0f, D_802874D8.unk1E, + spawn_player(gPlayerFour, 3, -3025.772f, 110.039f, -23.224f, (f32) (155 * DEGREES(1)), D_802874D8.unk1E, PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); } else { - spawn_player(gPlayerFour, 3, -3025.772f, 110.039f, -23.224f, 28210.0f, gCharacterIdByGPOverallRank[3], + spawn_player(gPlayerFour, 3, -3025.772f, 110.039f, -23.224f, (f32) (155 * DEGREES(1)), gCharacterIdByGPOverallRank[3], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); } spawn_player(gPlayerFive, 4, -2770.774f, -345.187f, -34.6f, 0.0f, 0, 0x7000); - spawn_player(gPlayerSix, 5, -3691.506f, -6.822f, -6.95f, 36400.0f, 0, 0x7000); - spawn_player(gPlayerSeven, 6, -3475.028f, -998.485f, -8.059f, 45500.0f, 0, 0x7000); - spawn_player(gPlayerEight, 7, -3025.772f, 110.039f, -23.224f, 28210.0f, 0, 0x7000); + spawn_player(gPlayerSix, 5, -3691.506f, -6.822f, -6.95f, (f32) (200 * DEGREES(1)), 0, 0x7000); + spawn_player(gPlayerSeven, 6, -3475.028f, -998.485f, -8.059f, (f32) (250 * DEGREES(1)), 0, 0x7000); + spawn_player(gPlayerEight, 7, -3025.772f, 110.039f, -23.224f, (f32) (155 * DEGREES(1)), 0, 0x7000); D_80164A28 = 0; func_80039AE4(); } From 5cb45f8ec1eb272dfbf1dca2e812a5045cd98ee2 Mon Sep 17 00:00:00 2001 From: Jed Grabman Date: Sat, 18 Apr 2026 02:25:02 -0400 Subject: [PATCH 6/9] Documentation of DEGREES function --- include/defines.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/defines.h b/include/defines.h index 81f0f44ab7..8ca740beda 100644 --- a/include/defines.h +++ b/include/defines.h @@ -330,6 +330,12 @@ enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE }; */ #define MAX_TIME 0x927C0 +/* The code often converts from a 16-bit representation of an angle to the number of degrees, + or adjusts a value by a specified number of degrees. Note that 2**16 / 360 is not an + integer. It has a value of ~182.04, but is rounded to 182 by the DEGREES function. There is + some inconsistency with how the codebase handles this. e.g. 70 degrees might be represented as + DEGREES(70) or 70 * DEGREES(1), which are slightly different values due to rounding. As a practical + matter, this rounding is less than 0.1 degrees in all cases */ #define DEGREES(degree) ((u16) (degree * 65536.0f / 360.0f)) // player->unk_046 From 50394c4690ac4cf6aad4f0971d74a00acc58f063 Mon Sep 17 00:00:00 2001 From: Jed Grabman Date: Mon, 20 Apr 2026 23:51:32 -0400 Subject: [PATCH 7/9] Use fractional degrees Instead of using `DEGREES(15) - 9` use `DEGREES(14.95f)` to avoid mixing representations --- src/actors/fake_item_box/render.inc.c | 3 ++- src/actors/item_box/render.inc.c | 3 ++- src/racing/actors_extended.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/actors/fake_item_box/render.inc.c b/src/actors/fake_item_box/render.inc.c index 3c012fb39e..1f9d9f56b7 100644 --- a/src/actors/fake_item_box/render.inc.c +++ b/src/actors/fake_item_box/render.inc.c @@ -60,7 +60,8 @@ void render_actor_fake_item_box(Camera* camera, struct FakeItemBox* fakeItemBox) gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); - if ((fakeItemBox->rot[1] < (15 * DEGREES(1) - 9)) && (fakeItemBox->rot[1] > 0)) { + // unclear why it is 14.95 degrees instead of 15. Perhaps just a typo when entering the value as a s16. + if ((fakeItemBox->rot[1] < DEGREES(14.95f)) && (fakeItemBox->rot[1] > 0)) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); } else if ((fakeItemBox->rot[1] > (150 * DEGREES(1))) && (fakeItemBox->rot[1] < (165 * DEGREES(1)))) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); diff --git a/src/actors/item_box/render.inc.c b/src/actors/item_box/render.inc.c index 6549eee2be..b3b3e14ce6 100644 --- a/src/actors/item_box/render.inc.c +++ b/src/actors/item_box/render.inc.c @@ -71,7 +71,8 @@ void render_actor_item_box(Camera* camera, struct ItemBox* item_box) { gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); - if ((item_box->rot[1] < (15 * DEGREES(1) - 9)) && (item_box->rot[1] > 0)) { + // unclear why it is 14.95 degrees instead of 15. Perhaps just a typo when entering the value as a s16. + if ((item_box->rot[1] < DEGREES(14.95f)) && (item_box->rot[1] > 0)) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); } else if ((item_box->rot[1] > (150 * DEGREES(1))) && (item_box->rot[1] < (165 * DEGREES(1)))) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); diff --git a/src/racing/actors_extended.c b/src/racing/actors_extended.c index 5e83756d05..db63f7dfa4 100644 --- a/src/racing/actors_extended.c +++ b/src/racing/actors_extended.c @@ -453,7 +453,8 @@ void update_actor_triple_shell(TripleShellParent* parent, s16 shellType) { } if (parent->shellIndices[1] > 0.0f) { shell = (struct ShellActor*) &gActorList[(s16) parent->shellIndices[1]]; - if ((shell->rotAngle < (DEGREES(15) - 9)) || (shell->rotAngle > DEGREES(5))) { + // Unclear why it is 14.95 degrees instead of 15. Perhaps just a typo when entering the value as a s16. + if ((shell->rotAngle < DEGREES(14.95)) || (shell->rotAngle > DEGREES(5))) { someVelocity[0] = 0; someVelocity[1] = 0; someVelocity[2] = 8; From 816f7d91a802ede7312c9ceee25d2140df4e34ba Mon Sep 17 00:00:00 2001 From: Jed Grabman Date: Tue, 21 Apr 2026 00:21:17 -0400 Subject: [PATCH 8/9] Cleanup / document degrees off by 1 --- src/actors/blue_and_red_shells/update.inc.c | 1 + src/actors/green_shell/update.inc.c | 1 + src/code_80057C60.c | 4 ++-- src/render_player.c | 12 ++++++------ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/actors/blue_and_red_shells/update.inc.c b/src/actors/blue_and_red_shells/update.inc.c index e0511acb22..0671f85405 100644 --- a/src/actors/blue_and_red_shells/update.inc.c +++ b/src/actors/blue_and_red_shells/update.inc.c @@ -279,6 +279,7 @@ void update_actor_red_blue_shell(struct ShellActor* shell) { if (player->unk_0C0 > 0) { shell->rotAngle = DEGREES(170); } else { + // The minus 1 is almost certainly just due to rounding the other way shell->rotAngle = -DEGREES(170) - 1; } } diff --git a/src/actors/green_shell/update.inc.c b/src/actors/green_shell/update.inc.c index a042b8aa8f..ec61589ebf 100644 --- a/src/actors/green_shell/update.inc.c +++ b/src/actors/green_shell/update.inc.c @@ -81,6 +81,7 @@ void update_actor_green_shell(struct ShellActor* shell) { if (player->unk_0C0 > 0) { shell->rotAngle = DEGREES(170); } else { + // The minus 1 is almost certainly just due to rounding the other way shell->rotAngle = -DEGREES(170) - 1; } } diff --git a/src/code_80057C60.c b/src/code_80057C60.c index c1d39a200c..e923bd078d 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -3725,7 +3725,7 @@ void func_800612F8(Player* player, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s8 a for (var_s2 = 0; var_s2 < 10; var_s2++) { player->particlePool3[var_s2].isAlive = 1; player->particlePool3[var_s2].unk_028 = player->pos[1] + 5.0f; - player->particlePool3[var_s2].rotation = ((DEGREES(40) - 1) * var_s2) - player->rotation[1]; + player->particlePool3[var_s2].rotation = (40 * DEGREES(1) * var_s2) - player->rotation[1]; player->particlePool3[var_s2].unk_024 = (random_int(0x0064U) / 100.0f) + 1.5; player->particlePool3[var_s2].green = 0; player->particlePool3[var_s2].type = 1; @@ -3743,7 +3743,7 @@ void func_80061430(Player* player, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s8 a for (var_s2 = 0; var_s2 < 7; var_s2++) { player->particlePool3[var_s2].isAlive = 1; player->particlePool3[var_s2].unk_028 = player->pos[1] - 4.0f; - player->particlePool3[var_s2].rotation = ((DEGREES(40) - 1) * var_s2) - player->rotation[1]; + player->particlePool3[var_s2].rotation = (40 * DEGREES(1) * var_s2) - player->rotation[1]; // ??? player->particlePool3[var_s2].unk_024 = (random_int(0x0064U) / 100.0f) + 1.9; player->particlePool3[var_s2].unk_024 = (random_int(0x0064U) / 100.0f) + 1.5; diff --git a/src/render_player.c b/src/render_player.c index 1ccce9c80b..52a32430dd 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -152,12 +152,12 @@ u16 func_8001FD78(Player* player, f32 posX, UNUSED f32 arg2, f32 posZ) { ret = false; - sp58 = (70.0f * coss(((player->unk_0C0 - player->rotation[1]) - DEGREES(10)))) + player->pos[2]; - sp64 = (70.0f * sins(((player->unk_0C0 - player->rotation[1]) - DEGREES(10)))) + player->pos[0]; - sp54 = (70.0f * coss(((player->unk_0C0 - player->rotation[1]) + DEGREES(10)))) + player->pos[2]; - sp60 = (70.0f * sins(((player->unk_0C0 - player->rotation[1]) + DEGREES(10)))) + player->pos[0]; - sp50 = (10.0f * coss(((player->unk_0C0 - player->rotation[1]) + (DEGREES(40) - 1)))) + player->pos[2]; - sp5c = (10.0f * sins(((player->unk_0C0 - player->rotation[1]) + (DEGREES(40) - 1)))) + player->pos[0]; + sp58 = (70.0f * coss(((player->unk_0C0 - player->rotation[1]) - (10 * DEGREES(1))))) + player->pos[2]; + sp64 = (70.0f * sins(((player->unk_0C0 - player->rotation[1]) - (10 * DEGREES(1))))) + player->pos[0]; + sp54 = (70.0f * coss(((player->unk_0C0 - player->rotation[1]) + (10 * DEGREES(1))))) + player->pos[2]; + sp60 = (70.0f * sins(((player->unk_0C0 - player->rotation[1]) + (10 * DEGREES(1))))) + player->pos[0]; + sp50 = (10.0f * coss(((player->unk_0C0 - player->rotation[1]) + (40 * DEGREES(1))))) + player->pos[2]; + sp5c = (10.0f * sins(((player->unk_0C0 - player->rotation[1]) + (40 * DEGREES(1))))) + player->pos[0]; temp_f14 = ((sp58 - posZ) * (sp60 - posX)) - ((sp54 - posZ) * (sp64 - posX)); thing0 = ((sp54 - posZ) * (sp5c - posX)) - ((sp50 - posZ) * (sp60 - posX)); From 93a84a743b5c4c1117decb5fe2feb188a3033d25 Mon Sep 17 00:00:00 2001 From: Jed Grabman Date: Tue, 21 Apr 2026 00:48:32 -0400 Subject: [PATCH 9/9] Update documentation of DEGREES --- include/defines.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/include/defines.h b/include/defines.h index 8ca740beda..331dbcc511 100644 --- a/include/defines.h +++ b/include/defines.h @@ -330,12 +330,20 @@ enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE }; */ #define MAX_TIME 0x927C0 -/* The code often converts from a 16-bit representation of an angle to the number of degrees, - or adjusts a value by a specified number of degrees. Note that 2**16 / 360 is not an - integer. It has a value of ~182.04, but is rounded to 182 by the DEGREES function. There is - some inconsistency with how the codebase handles this. e.g. 70 degrees might be represented as - DEGREES(70) or 70 * DEGREES(1), which are slightly different values due to rounding. As a practical - matter, this rounding is less than 0.1 degrees in all cases */ +/* The codebase uses 16-bit representations of angles (either u16 or s16 depending on context). + Thus, values of [0, 2**16 - 1] (for u16) or [-2**15, 2**15 - 1] (for s16) represent evenly + spaced angles around a circle. (e.g. (u16) 0x8000 is 2**15, which represents half a circle, or 180 degrees) + + However, it is clear that the developers were thinking in terms of degrees and often worked + with values that corresponded to a specific number of degrees. The DEGREES macro converts + from the specified number of degrees to the 16-bit representation. This allows readers to + think in degrees while leaving the compiled machine code unaffected. + + Note that 2**16 / 360 is not an integer. It has a value of ~182.04, but is rounded to 182 + by the DEGREES function. There is some inconsistency with how the codebase handles this. + e.g. 70 degrees might be represented as DEGREES(70) or 70 * DEGREES(1), which are slightly + different values due to this rounding. As a practical matter, this rounding is less than + 0.1 degrees in all cases */ #define DEGREES(degree) ((u16) (degree * 65536.0f / 360.0f)) // player->unk_046