diff options
| author | Maciek Baron <1668712+MaciekBaron@users.noreply.github.com> | 2025-07-03 13:35:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-03 06:35:42 -0600 |
| commit | 99689a3f70d8cb38178f92b87ecdcdbbdb200429 (patch) | |
| tree | 031bbf96ac4c1d17b2f6213b1c6f271a71bb8e2d | |
| parent | 7937896598f3df46eb78c158bde787bc4f12ad7f (diff) | |
Document player alpha (#396)
* Document player alpha
* Fix typo
* Document further alpha things
* Document movement
* Fix indentation
| -rw-r--r-- | include/common_structs.h | 2 | ||||
| -rw-r--r-- | include/defines.h | 23 | ||||
| -rw-r--r-- | src/code_80057C60.c | 50 | ||||
| -rw-r--r-- | src/effects.c | 136 | ||||
| -rw-r--r-- | src/effects.h | 4 | ||||
| -rw-r--r-- | src/engine/objects/Lakitu.cpp | 4 | ||||
| -rw-r--r-- | src/player_controller.c | 441 | ||||
| -rw-r--r-- | src/racing/actors.c | 30 | ||||
| -rw-r--r-- | src/racing/math_util.c | 32 | ||||
| -rw-r--r-- | src/render_player.c | 12 | ||||
| -rw-r--r-- | src/render_player.h | 3 | ||||
| -rw-r--r-- | src/spawn_players.c | 8 |
12 files changed, 381 insertions, 364 deletions
diff --git a/include/common_structs.h b/include/common_structs.h index 4450d0e6c..058bb3770 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -314,7 +314,7 @@ typedef struct { /* 0x00C0 */ s16 unk_0C0; /* 0x00C2 */ s16 unk_0C2; /* 0x00C4 */ s16 slopeAccel; - /* 0x00C6 */ s16 unk_0C6; + /* 0x00C6 */ s16 alpha; /* 0x00C8 */ s16 unk_0C8; /* 0x00CA */ s16 unk_0CA; /* 0x00CC */ Vec4s unk_0CC; diff --git a/include/defines.h b/include/defines.h index 1c176c9bf..5895dc96c 100644 --- a/include/defines.h +++ b/include/defines.h @@ -380,6 +380,23 @@ enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE }; #define ALPHA_BOO_EFFECT 0x60 /** + * @brief durations of effects + */ + #define STAR_EFFECT_DURATION 0xA + #define BOO_EFFECT_DURATION 0x7 + + /** + * @brief alpha related values + */ + #define ALPHA_MAX 0xFF + #define ALPHA_MIN 0x0 + #define ALPHA_BOO_EFFECT 0x60 + +#define ALPHA_CHANGE_LARGE 8 +#define ALPHA_CHANGE_MEDIUM 4 +#define ALPHA_CHANGE_SMALL 2 + +/** * @brief shell state * */ @@ -407,9 +424,9 @@ enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE }; #endif // DEFINES_H /** - * + * * Laps - * + * */ #define MIN_LAPS 0 -#define MAX_LAPS 3
\ No newline at end of file +#define MAX_LAPS 3 diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 25a775c86..80fe9126e 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -6463,52 +6463,52 @@ void func_8006C9B8(Player* player, s16 arg1, s8 arg2, s8 arg3) { } } -void func_8006CEC0(Player* arg0, s16 arg1, s8 arg2, s8 arg3) { +void func_8006CEC0(Player* player, s16 arg1, s8 arg2, s8 arg3) { UNUSED u16 temp_v0_3; s32 sp20 = arg1; if (--sp20 < 0) { sp20 = 9; } - if (arg0->particlePool0[arg1].isAlive == 1) { - switch (arg0->particlePool0[arg1].type) { + if (player->particlePool0[arg1].isAlive == 1) { + switch (player->particlePool0[arg1].type) { case 1: - func_80062C74(arg0, arg1, arg2, arg3); + func_80062C74(player, arg1, arg2, arg3); break; case 3: - func_80064184(arg0, arg1, arg2, arg3); + func_80064184(player, arg1, arg2, arg3); break; case 5: - set_oob_splash_particle_position(arg0, arg1, arg2, arg3); + set_oob_splash_particle_position(player, arg1, arg2, arg3); break; case 6: - func_800631A8(arg0, arg1, arg2, arg3); + func_800631A8(player, arg1, arg2, arg3); break; case 7: - func_80063268(arg0, arg1, arg2, arg3); + func_80063268(player, arg1, arg2, arg3); break; } } else { - if ((arg0->unk_044 & 0x200) && (arg0->type & 0x4000)) { - func_80061224(arg0, arg1, sp20, arg2, arg3); + if ((player->unk_044 & 0x200) && (player->type & 0x4000)) { + func_80061224(player, arg1, sp20, arg2, arg3); return; - } else if (((arg0->effects & 0x40000000) == 0x40000000) && (arg0->unk_0B0 < 0x32)) { - func_80061094(arg0, arg1, sp20, arg2, arg3); + } else if (((player->effects & 0x40000000) == 0x40000000) && (player->unk_0B0 < 0x32)) { + func_80061094(player, arg1, sp20, arg2, arg3); return; - } else if ((arg0->type & 0x4000) == 0x4000) { - if ((arg0->unk_0DE & 8) == 8) { - func_80060F50(arg0, arg1, sp20, arg2, arg3); + } else if ((player->type & 0x4000) == 0x4000) { + if ((player->unk_0DE & 8) == 8) { + func_80060F50(player, arg1, sp20, arg2, arg3); return; - } else if ((arg0->unk_0DE & 2) || (arg0->unk_0DE & 1)) { - func_80060B14(arg0, arg1, sp20, arg2, arg3); + } else if ((player->unk_0DE & 2) || (player->unk_0DE & 1)) { + func_80060B14(player, arg1, sp20, arg2, arg3); return; } } switch (gActiveScreenMode) { case SCREEN_MODE_1P: - if (((arg0->effects & 0x04000000) != 0x04000000) && ((arg0->effects & 0x400) != 0x400) && - ((arg0->effects & 0x01000000) != 0x01000000)) { - if (((arg0->unk_0CA & 2) != 2) && ((arg0->unk_0CA & 0x10) != 0x10) && !(arg0->unk_0CA & 0x100)) { - func_80060504(arg0, arg1, sp20, arg2, arg3); + if (((player->effects & 0x04000000) != 0x04000000) && ((player->effects & 0x400) != 0x400) && + ((player->effects & 0x01000000) != 0x01000000)) { + if (((player->unk_0CA & 2) != 2) && ((player->unk_0CA & 0x10) != 0x10) && !(player->unk_0CA & 0x100)) { + func_80060504(player, arg1, sp20, arg2, arg3); } } break; @@ -6517,10 +6517,10 @@ void func_8006CEC0(Player* arg0, s16 arg1, s8 arg2, s8 arg3) { case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: case SCREEN_MODE_3P_4P_SPLITSCREEN: - if (((arg0->type & 0x4000) != 0) && ((arg0->effects & 0x04000000) != 0x04000000) && - ((arg0->effects & 0x400) != 0x400) && ((arg0->effects & 0x01000000) != 0x01000000)) { - if (((arg0->unk_0CA & 2) != 2) && ((arg0->unk_0CA & 0x10) != 0x10) && !(arg0->unk_0CA & 0x100)) { - func_80060504(arg0, arg1, sp20, arg2, arg3); + if (((player->type & 0x4000) != 0) && ((player->effects & 0x04000000) != 0x04000000) && + ((player->effects & 0x400) != 0x400) && ((player->effects & 0x01000000) != 0x01000000)) { + if (((player->unk_0CA & 2) != 2) && ((player->unk_0CA & 0x10) != 0x10) && !(player->unk_0CA & 0x100)) { + func_80060504(player, arg1, sp20, arg2, arg3); } } break; diff --git a/src/effects.c b/src/effects.c index a5bbd918e..1f972ad67 100644 --- a/src/effects.c +++ b/src/effects.c @@ -22,8 +22,8 @@ s32 D_8018D900[8]; s16 D_8018D920[8]; s32 gPlayerStarEffectStartTime[8]; -s32 D_8018D950[8]; -s32 D_8018D970[8]; +s32 gPlayerBooEffectStartTime[8]; +s32 gPlayerOtherScreensAlpha[8]; s32 D_8018D990[8]; UNUSED void func_unnamed(void) { @@ -1421,43 +1421,45 @@ void func_8008F86C(Player* player, s8 arg1) { func_800CAACC(arg1); } -void apply_boo_effect(Player* arg0, s8 arg1) { - s32 tmp; - tmp = ((s32) gCourseTimer) - D_8018D950[arg1]; - if (tmp < 7) { - arg0->unk_0C6 -= 2; +void apply_boo_effect(Player* player, s8 playerIndex) { + s32 time_elapsed; + time_elapsed = ((s32) gCourseTimer) - gPlayerBooEffectStartTime[playerIndex]; + if (time_elapsed < BOO_EFFECT_DURATION) { + player->alpha -= ALPHA_CHANGE_SMALL; - if (arg0->unk_0C6 < 0x61) { - arg0->unk_0C6 = 0x60; + if (player->alpha <= ALPHA_BOO_EFFECT) { + player->alpha = ALPHA_BOO_EFFECT; } - D_8018D970[arg1] -= 2; - if (D_8018D970[arg1] <= 0) { - D_8018D970[arg1] = 0; + // Player becomes invisible to other players + gPlayerOtherScreensAlpha[playerIndex] -= ALPHA_CHANGE_SMALL; + if (gPlayerOtherScreensAlpha[playerIndex] <= 0) { + gPlayerOtherScreensAlpha[playerIndex] = 0; } } else { - arg0->unk_0C6 += 4; - if (arg0->unk_0C6 >= 0xF0) { - arg0->unk_0C6 = 0xFF; - D_8018D970[arg1] = 0xFF; - arg0->effects &= ~0x80000000; - if ((arg0->type & 0x4000) != 0) { - func_800CB064(arg1); + // Player returns to normal visibility + player->alpha += ALPHA_CHANGE_MEDIUM; + if (player->alpha > ALPHA_MAX - (ALPHA_CHANGE_LARGE * 2)) { + player->alpha = ALPHA_MAX; + gPlayerOtherScreensAlpha[playerIndex] = ALPHA_MAX; + player->effects &= ~0x80000000; + if ((player->type & 0x4000) != 0) { + func_800CB064(playerIndex); } } - D_8018D970[arg1] += 8; - if (D_8018D970[arg1] >= 0xF0) { - D_8018D970[arg1] = 0xFF; - arg0->unk_0C6 = 0xFF; - arg0->effects &= ~0x80000000; - if ((arg0->type & 0x4000) != 0) { - func_800CB064(arg1); + gPlayerOtherScreensAlpha[playerIndex] += 8; + if (gPlayerOtherScreensAlpha[playerIndex] >= 0xF0) { + gPlayerOtherScreensAlpha[playerIndex] = ALPHA_MAX; + player->alpha = ALPHA_MAX; + player->effects &= ~0x80000000; + if ((player->type & 0x4000) != 0) { + func_800CB064(playerIndex); } } } } -void apply_boo_sound_effect(Player* player, s8 arg1) { +void apply_boo_sound_effect(Player* player, s8 playerIndex) { s16 temp_v1; if ((player->type & PLAYER_HUMAN) != 0) { @@ -1470,37 +1472,37 @@ void apply_boo_sound_effect(Player* player, s8 arg1) { } } - clean_effect(player, arg1); + clean_effect(player, playerIndex); player->effects |= BOO_EFFECT; player->soundEffects &= ~BOO_SOUND_EFFECT; - D_8018D950[arg1] = gCourseTimer; - D_8018D970[arg1] = 0xFF; + gPlayerBooEffectStartTime[playerIndex] = gCourseTimer; + gPlayerOtherScreensAlpha[playerIndex] = ALPHA_MAX; if ((player->type & PLAYER_HUMAN) != 0) { - func_800CAFC0(arg1); + func_800CAFC0(playerIndex); } } -void func_8008FB30(Player* arg0, s8 arg1) { - arg0->unk_0C6 += 8; - if (arg0->unk_0C6 >= 0xF0) { - arg0->unk_0C6 = 0xFF; - D_8018D970[arg1] = 0xFF; +void func_8008FB30(Player* player, s8 playerIndex) { + player->alpha += ALPHA_CHANGE_LARGE; + if (player->alpha > ALPHA_MAX - (ALPHA_CHANGE_LARGE * 2)) { + player->alpha = ALPHA_MAX; + gPlayerOtherScreensAlpha[playerIndex] = ALPHA_MAX; - arg0->effects &= ~0x80000000; - if ((arg0->type & 0x4000) != 0) { - func_800CB064(arg1); + player->effects &= ~0x80000000; + if ((player->type & 0x4000) != 0) { + func_800CB064(playerIndex); } } - D_8018D970[arg1] += 0x10; - if (D_8018D970[arg1] >= 0xE0) { - D_8018D970[arg1] = 0xFF; - arg0->unk_0C6 = 0xFF; - arg0->effects &= ~0x80000000; - if ((arg0->type & 0x4000) != 0) { - func_800CB064(arg1); + gPlayerOtherScreensAlpha[playerIndex] += 0x10; + if (gPlayerOtherScreensAlpha[playerIndex] >= 0xE0) { + gPlayerOtherScreensAlpha[playerIndex] = ALPHA_MAX; + player->alpha = ALPHA_MAX; + player->effects &= ~0x80000000; + if ((player->type & 0x4000) != 0) { + func_800CB064(playerIndex); } } } @@ -1515,25 +1517,25 @@ void func_8008FC1C(Player* player) { } } -void func_8008FC64(Player* player, s8 arg1) { - player->unk_0C6 -= 4; - if (player->unk_0C6 < 5) { - player->unk_0C6 = 0; +void func_8008FC64(Player* player, s8 playerIndex) { + player->alpha -= ALPHA_CHANGE_MEDIUM; + if (player->alpha <= ALPHA_CHANGE_MEDIUM) { + player->alpha = ALPHA_MIN; player->soundEffects &= 0xFBFFFFFF; player->soundEffects |= 0x08000000; player->type |= PLAYER_UNKNOWN_0x40; - func_8008FDA8(player, arg1); - func_800569F4(arg1); + func_8008FDA8(player, playerIndex); + func_800569F4(playerIndex); } } void func_8008FCDC(Player* player, s8 arg1) { - player->unk_0C6 += 2; - if (player->unk_0C6 >= 0xF0) { - player->unk_0C6 = 0xFF; + player->alpha += ALPHA_CHANGE_SMALL; + if (player->alpha > ALPHA_MAX - (ALPHA_CHANGE_LARGE * 2)) { + player->alpha = ALPHA_MAX; player->soundEffects &= ~0x08000000; } - func_80056A40(arg1, (u32) player->unk_0C6); + func_80056A40(arg1, (u32) player->alpha); } void func_8008FD4C(Player* player, UNUSED s8 arg1) { @@ -1842,7 +1844,7 @@ void func_80090970(Player* player, s8 playerId, s8 arg2) { if ((D_801652A0[playerId] + 40.0f) <= player->pos[1]) { player->unk_222 = 1; player->unk_0CA |= 4; - player->unk_0C6 = 0x00FF; + player->alpha = ALPHA_MAX; } } } else if ((player->unk_0CA & 2) == 2) { @@ -1851,7 +1853,7 @@ void func_80090970(Player* player, s8 playerId, s8 arg2) { if ((player->unk_074 + 40.0f) <= player->pos[1]) { player->unk_222 = 1; player->unk_0CA |= 4; - player->unk_0C6 = 0x00FF; + player->alpha = ALPHA_MAX; } } if ((player->effects & BOO_EFFECT) == BOO_EFFECT) { @@ -1864,17 +1866,17 @@ void func_80090970(Player* player, s8 playerId, s8 arg2) { } if ((player->unk_0CA & 1) == 1) { move_f32_towards(&player->pos[1], D_801652A0[playerId] + 40.0f, 0.02f); - player->unk_0C6 -= 8; - if (player->unk_0C6 < 9) { - player->unk_0C6 = 0; + player->alpha -= ALPHA_CHANGE_LARGE; + if (player->alpha <= ALPHA_CHANGE_LARGE) { + player->alpha = ALPHA_MIN; player->unk_222 = 2; player->unk_0CA &= ~0x0001; } } else { move_f32_towards(&player->pos[1], player->oldPos[1] + 40.0f, 0.02f); - player->unk_0C6 -= 8; - if (player->unk_0C6 < 9) { - player->unk_0C6 = 0; + player->alpha -= ALPHA_CHANGE_LARGE; + if (player->alpha <= ALPHA_CHANGE_LARGE) { + player->alpha = ALPHA_MIN; player->unk_222 = 2; } } @@ -1900,9 +1902,9 @@ void func_80090970(Player* player, s8 playerId, s8 arg2) { player->pos[2] = sp44[2]; player->pos[2] = player->pos[2] + coss((playerId * 0x1C70) - player->rotation[1]) * -5.0f; player->pos[0] = player->pos[0] + sins((playerId * 0x1C70) - player->rotation[1]) * -5.0f; - player->unk_0C6 += 8; - if (player->unk_0C6 >= 0xF0) { - player->unk_0C6 = 0x00FF; + player->alpha += ALPHA_CHANGE_LARGE; + if (player->alpha > ALPHA_MAX - (ALPHA_CHANGE_LARGE * 2)) { + player->alpha = ALPHA_MAX; player->unk_222 = 4; player->unk_0CA &= ~0x0004; player->unk_0C8 = 0; diff --git a/src/effects.h b/src/effects.h index 2ca3663b6..d89adb9db 100644 --- a/src/effects.h +++ b/src/effects.h @@ -126,8 +126,8 @@ void func_800CB064(u8); extern s32 D_8018D900[]; extern s16 D_8018D920[]; extern s32 gPlayerStarEffectStartTime[]; -extern s32 D_8018D950[]; -extern s32 D_8018D970[]; +extern s32 gPlayerBooEffectStartTime[]; +extern s32 gPlayerOtherScreensAlpha[]; extern s32 D_8018D990[]; /* This is where I'd put my static data, if I had any */ diff --git a/src/engine/objects/Lakitu.cpp b/src/engine/objects/Lakitu.cpp index 28159b7b3..8088e89c8 100644 --- a/src/engine/objects/Lakitu.cpp +++ b/src/engine/objects/Lakitu.cpp @@ -393,7 +393,7 @@ void OLakitu::func_80079860(s32 playerId) { void OLakitu::func_8007993C(s32 objectIndex, Player* player) { if (player->unk_0CA & 4) { func_800722A4(objectIndex, 2); - gObjectList[objectIndex].primAlpha = player->unk_0C6; + gObjectList[objectIndex].primAlpha = player->alpha; return; } func_800722CC(objectIndex, 2); @@ -784,7 +784,7 @@ void OLakitu::func_8007A778(s32 objectIndex) { Player* player = &gPlayers[_playerId]; Camera* camera = &cameras[_playerId]; u16 rot = 0x8000 - camera->rot[1]; - + gObjectList[objectIndex].pos[0] = (player->pos[0] + (coss(rot) * (gObjectList[objectIndex].origin_pos[0] + gObjectList[objectIndex].offset[0]))) - diff --git a/src/player_controller.c b/src/player_controller.c index bc23ea619..bfb791f11 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -963,89 +963,89 @@ void func_80029B4C(Player* player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { } } -void func_8002A194(Player* player, f32 arg1, f32 arg2, f32 arg3) { - UNUSED s32 pad[2]; - f32 temp_f12; - f32 var_f20; - s32 temp_v0; - s16 temp_v1; - s16 var_a1; - UNUSED s32 pad2; - f32 temp_f0; - - temp_v1 = -player->rotation[1] - player->unk_0C0; - if ((player->effects & LIGHTNING_EFFECT) == LIGHTNING_EFFECT) { - var_f20 = (((gCharacterSize[player->characterId] * 18) / 2) * (player->size * 1.5)) - 1; - } else { - var_f20 = (((gCharacterSize[player->characterId] * 18) / 2) * player->size) - 1; - } - - player->tyres[FRONT_LEFT].pos[2] = (coss(temp_v1 + 0x2000) * var_f20) + arg3; - temp_f12 = (sins(temp_v1 + 0x2000) * var_f20) + arg1; - player->tyres[FRONT_LEFT].pos[0] = temp_f12; - player->tyres[FRONT_LEFT].baseHeight = - calculate_surface_height(temp_f12, arg2, player->tyres[FRONT_LEFT].pos[2], player->collision.meshIndexZX); - - player->tyres[FRONT_RIGHT].pos[2] = (coss(temp_v1 - 0x2000) * var_f20) + arg3; - temp_f12 = (sins(temp_v1 - 0x2000) * var_f20) + arg1; - player->tyres[FRONT_RIGHT].pos[0] = temp_f12; - player->tyres[FRONT_RIGHT].baseHeight = - calculate_surface_height(temp_f12, arg2, player->tyres[FRONT_RIGHT].pos[2], player->collision.meshIndexZX); - - player->tyres[BACK_LEFT].pos[2] = (coss(temp_v1 + 0x6000) * var_f20) + arg3; - temp_f12 = (sins(temp_v1 + 0x6000) * var_f20) + arg1; - player->tyres[BACK_LEFT].pos[0] = temp_f12; - player->tyres[BACK_LEFT].baseHeight = - calculate_surface_height(temp_f12, arg2, player->tyres[BACK_LEFT].pos[2], player->collision.meshIndexZX); - - player->tyres[BACK_RIGHT].pos[2] = (coss(temp_v1 - 0x6000) * var_f20) + arg3; - player->tyres[BACK_RIGHT].pos[0] = (sins(temp_v1 - 0x6000) * var_f20) + arg1; - player->tyres[BACK_RIGHT].baseHeight = calculate_surface_height( - player->tyres[BACK_LEFT].pos[0], arg2, player->tyres[BACK_LEFT].pos[2], player->collision.meshIndexZX); - - if ((player->effects & 8) != 8) { - player->unk_230 = (player->tyres[BACK_LEFT].baseHeight + player->tyres[FRONT_LEFT].baseHeight) / 2; - player->unk_23C = (player->tyres[BACK_RIGHT].baseHeight + player->tyres[FRONT_RIGHT].baseHeight) / 2; - player->unk_1FC = (player->tyres[FRONT_RIGHT].baseHeight + player->tyres[FRONT_LEFT].baseHeight) / 2; - player->unk_1F8 = (player->tyres[BACK_RIGHT].baseHeight + player->tyres[BACK_LEFT].baseHeight) / 2; - } - player->surfaceType = (u8) get_surface_type(player->collision.meshIndexZX); - player->tyres[BACK_RIGHT].surfaceType = player->surfaceType; - player->tyres[BACK_LEFT].surfaceType = player->surfaceType; - player->tyres[FRONT_RIGHT].surfaceType = player->surfaceType; - player->tyres[FRONT_LEFT].surfaceType = player->surfaceType; - var_f20 = (gCharacterSize[player->characterId] * 18) + 1; - temp_f0 = (player->unk_23C - player->unk_230); - player->unk_206 = -func_802B7C40(temp_f0 / var_f20); - if ((player->effects & 8) != 8) { - temp_f0 = (player->unk_1F8 - player->unk_1FC); - move_s16_towards(&player->slopeAccel, func_802B7C40(temp_f0 / var_f20), 0.5f); - } else { - temp_f0 = player->oldPos[1] - arg2; - temp_v0 = func_802B7C40(temp_f0 / var_f20); - if (temp_f0 >= 0.0f) { - var_a1 = temp_v0 * 2; - } else { - var_a1 = temp_v0 * 0xA; - } - move_s16_towards(&player->slopeAccel, var_a1, 0.5f); - } - if (func_802ABD7C(player->collision.meshIndexZX) != 0) { - player->tyres[BACK_RIGHT].unk_14 |= 1; - } else { - player->tyres[BACK_RIGHT].unk_14 &= ~1; - } - if (player->surfaceType == BOOST_RAMP_ASPHALT) { - if (((player->effects & BOOST_RAMP_ASPHALT_EFFECT) != BOOST_RAMP_ASPHALT_EFFECT) && - ((player->effects & 8) != 8)) { - player->soundEffects |= BOOST_RAMP_ASPHALT_SOUND_EFFECT; - } - } - if (player->surfaceType == BOOST_RAMP_WOOD) { - if (((player->effects & BOOST_RAMP_WOOD_EFFECT) != BOOST_RAMP_WOOD_EFFECT) && ((player->effects & 8) != 8)) { - player->soundEffects |= BOOST_RAMP_WOOD_SOUND_EFFECT; - } - } +void func_8002A194(Player* player, f32 x, f32 y, f32 z) { + UNUSED s32 pad[2]; + f32 temp_f12; + f32 var_f20; + s32 temp_v0; + s16 temp_v1; + s16 var_a1; + UNUSED s32 pad2; + f32 temp_f0; + + temp_v1 = -player->rotation[1] - player->unk_0C0; + if ((player->effects & LIGHTNING_EFFECT) == LIGHTNING_EFFECT) { + var_f20 = (((gCharacterSize[player->characterId] * 18) / 2) * (player->size * 1.5)) - 1; + } else { + var_f20 = (((gCharacterSize[player->characterId] * 18) / 2) * player->size) - 1; + } + + player->tyres[FRONT_LEFT].pos[2] = (coss(temp_v1 + 0x2000) * var_f20) + z; + temp_f12 = (sins(temp_v1 + 0x2000) * var_f20) + x; + player->tyres[FRONT_LEFT].pos[0] = temp_f12; + player->tyres[FRONT_LEFT].baseHeight = + calculate_surface_height(temp_f12, y, player->tyres[FRONT_LEFT].pos[2], player->collision.meshIndexZX); + + player->tyres[FRONT_RIGHT].pos[2] = (coss(temp_v1 - 0x2000) * var_f20) + z; + temp_f12 = (sins(temp_v1 - 0x2000) * var_f20) + x; + player->tyres[FRONT_RIGHT].pos[0] = temp_f12; + player->tyres[FRONT_RIGHT].baseHeight = + calculate_surface_height(temp_f12, y, player->tyres[FRONT_RIGHT].pos[2], player->collision.meshIndexZX); + + player->tyres[BACK_LEFT].pos[2] = (coss(temp_v1 + 0x6000) * var_f20) + z; + temp_f12 = (sins(temp_v1 + 0x6000) * var_f20) + x; + player->tyres[BACK_LEFT].pos[0] = temp_f12; + player->tyres[BACK_LEFT].baseHeight = + calculate_surface_height(temp_f12, y, player->tyres[BACK_LEFT].pos[2], player->collision.meshIndexZX); + + player->tyres[BACK_RIGHT].pos[2] = (coss(temp_v1 - 0x6000) * var_f20) + z; + player->tyres[BACK_RIGHT].pos[0] = (sins(temp_v1 - 0x6000) * var_f20) + x; + player->tyres[BACK_RIGHT].baseHeight = calculate_surface_height( + player->tyres[BACK_LEFT].pos[0], y, player->tyres[BACK_LEFT].pos[2], player->collision.meshIndexZX); + + if ((player->effects & 8) != 8) { + player->unk_230 = (player->tyres[BACK_LEFT].baseHeight + player->tyres[FRONT_LEFT].baseHeight) / 2; + player->unk_23C = (player->tyres[BACK_RIGHT].baseHeight + player->tyres[FRONT_RIGHT].baseHeight) / 2; + player->unk_1FC = (player->tyres[FRONT_RIGHT].baseHeight + player->tyres[FRONT_LEFT].baseHeight) / 2; + player->unk_1F8 = (player->tyres[BACK_RIGHT].baseHeight + player->tyres[BACK_LEFT].baseHeight) / 2; + } + player->surfaceType = (u8) get_surface_type(player->collision.meshIndexZX); + player->tyres[BACK_RIGHT].surfaceType = player->surfaceType; + player->tyres[BACK_LEFT].surfaceType = player->surfaceType; + player->tyres[FRONT_RIGHT].surfaceType = player->surfaceType; + player->tyres[FRONT_LEFT].surfaceType = player->surfaceType; + var_f20 = (gCharacterSize[player->characterId] * 18) + 1; + temp_f0 = (player->unk_23C - player->unk_230); + player->unk_206 = -func_802B7C40(temp_f0 / var_f20); + if ((player->effects & 8) != 8) { + temp_f0 = (player->unk_1F8 - player->unk_1FC); + move_s16_towards(&player->slopeAccel, func_802B7C40(temp_f0 / var_f20), 0.5f); + } else { + temp_f0 = player->oldPos[1] - y; + temp_v0 = func_802B7C40(temp_f0 / var_f20); + if (temp_f0 >= 0.0f) { + var_a1 = temp_v0 * 2; + } else { + var_a1 = temp_v0 * 0xA; + } + move_s16_towards(&player->slopeAccel, var_a1, 0.5f); + } + if (func_802ABD7C(player->collision.meshIndexZX) != 0) { + player->tyres[BACK_RIGHT].unk_14 |= 1; + } else { + player->tyres[BACK_RIGHT].unk_14 &= ~1; + } + if (player->surfaceType == BOOST_RAMP_ASPHALT) { + if (((player->effects & BOOST_RAMP_ASPHALT_EFFECT) != BOOST_RAMP_ASPHALT_EFFECT) && + ((player->effects & 8) != 8)) { + player->soundEffects |= BOOST_RAMP_ASPHALT_SOUND_EFFECT; + } + } + if (player->surfaceType == BOOST_RAMP_WOOD) { + if (((player->effects & BOOST_RAMP_WOOD_EFFECT) != BOOST_RAMP_WOOD_EFFECT) && ((player->effects & 8) != 8)) { + player->soundEffects |= BOOST_RAMP_WOOD_SOUND_EFFECT; + } + } } // Near identical to adjust_pos_orthogonally in memory.c @@ -1537,9 +1537,9 @@ void func_8002B9CC(Player* player, s8 arg1, UNUSED s32 arg2) { } } } else { - temp_f0 = D_80165070[arg1][0] - player->velocity[0]; - temp_f2 = D_80165070[arg1][1] - player->velocity[1]; - temp_f14 = D_80165070[arg1][2] - player->velocity[2]; + temp_f0 = gPlayerLastVelocity[arg1][0] - player->velocity[0]; + temp_f2 = gPlayerLastVelocity[arg1][1] - player->velocity[1]; + temp_f14 = gPlayerLastVelocity[arg1][2] - player->velocity[2]; if (sqrtf((temp_f0 * temp_f0) + (temp_f2 * temp_f2) + (temp_f14 * temp_f14)) >= 4.2) { player->unk_08C /= 4; player->currentSpeed /= 4; @@ -1886,10 +1886,10 @@ void func_8002C954(Player* player, s8 playerId, Vec3f arg2) { player_decelerate(player, 18.0f); } if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - xdist = D_80165070[playerId][0] - arg2[0]; - var_f14 = D_80165070[playerId][1] - arg2[1]; + xdist = gPlayerLastVelocity[playerId][0] - arg2[0]; + var_f14 = gPlayerLastVelocity[playerId][1] - arg2[1]; ydist = var_f14; // okay - zdist = D_80165070[playerId][2] - arg2[2]; + zdist = gPlayerLastVelocity[playerId][2] - arg2[2]; var_f14 = sqrtf((xdist * xdist) + (ydist * ydist) + (zdist * zdist)) / 3; if (var_f14 >= 1.0) { var_f14 = 1.0f; @@ -2055,12 +2055,12 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player s32 temp3; f32 temp_f2_2; UNUSED s32 pad[8]; - f32 spB4; - f32 spB0; - f32 spAC; - f32 temp_var; + f32 gravityX; + f32 gravityY; + f32 gravityZ; + f32 surfaceDistance; UNUSED s32 pad2; - Vec3f sp98; + Vec3f newVelocity; Vec3f sp8C; UNUSED s32 pad3[3]; s32 sp7C = 0; @@ -2088,31 +2088,31 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player player->unk_064[2] *= -1.0f; } if ((player->tyres[BACK_LEFT].surfaceType == ASPHALT) && (player->tyres[BACK_RIGHT].surfaceType == ASPHALT)) { - spB4 = (-1 * (player->unk_064[0] + sp16C[0])) + - ((-player->collision.orientationVector[0] * player->kartGravity) * 0.925); - spB0 = (-player->collision.orientationVector[1] * player->kartGravity); - spAC = (-1 * (player->unk_064[2] + sp16C[2])) + - ((-player->collision.orientationVector[2] * player->kartGravity) * 0.925); + gravityX = (-1 * (player->unk_064[0] + sp16C[0])) + + ((-player->collision.orientationVector[0] * player->kartGravity) * 0.925); + gravityY = (-player->collision.orientationVector[1] * player->kartGravity); + gravityZ = (-1 * (player->unk_064[2] + sp16C[2])) + + ((-player->collision.orientationVector[2] * player->kartGravity) * 0.925); } else { temp3 = (((player->speed / 18.0f) * 216.0f) / 10.0f); if (temp3 >= 10) { temp3 = 10; } - spB4 = -1 * (player->unk_064[0] + sp16C[0]) + - ((-player->collision.orientationVector[0] * player->kartGravity) * sp104[temp3]); - spB0 = (-player->collision.orientationVector[1] * player->kartGravity); - spAC = -1 * (player->unk_064[2] + sp16C[2]) + - ((-player->collision.orientationVector[2] * player->kartGravity) * sp104[temp3]); + gravityX = -1 * (player->unk_064[0] + sp16C[0]) + + ((-player->collision.orientationVector[0] * player->kartGravity) * sp104[temp3]); + gravityY = (-player->collision.orientationVector[1] * player->kartGravity); + gravityZ = -1 * (player->unk_064[2] + sp16C[2]) + + ((-player->collision.orientationVector[2] * player->kartGravity) * sp104[temp3]); } if (((player->effects & 8) != 8) && ((player->effects & 0x20) == 0x20)) { - spB4 = 0 * (player->unk_064[0] + sp16C[0]); - spB0 = -1 * player->kartGravity / 4; - spAC = 0 * (player->unk_064[2] + sp16C[2]); + gravityX = 0 * (player->unk_064[0] + sp16C[0]); + gravityY = -1 * player->kartGravity / 4; + gravityZ = 0 * (player->unk_064[2] + sp16C[2]); } if ((player->effects & 8) == 8) { - spB4 = 0 * (player->unk_064[0] + sp16C[0]); - spB0 = -1 * player->kartGravity; - spAC = 0 * (player->unk_064[2] + sp16C[2]); + gravityX = 0 * (player->unk_064[0] + sp16C[0]); + gravityY = -1 * player->kartGravity; + gravityZ = 0 * (player->unk_064[2] + sp16C[2]); } temp_f2_2 = ((player->oldPos[2] - player->pos[2]) * coss(player->rotation[1] + player->unk_0C0)) + (-(player->oldPos[0] - player->pos[0]) * sins(player->rotation[1] + player->unk_0C0)); @@ -2129,50 +2129,50 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player } sp178[1] = 0.0f; mtxf_translate_vec3f_mat3(sp178, player->orientationMatrix); - spB4 += sp178[0]; - spAC += sp178[2]; + gravityX += sp178[0]; + gravityZ += sp178[2]; func_8002C7E4(player, playerId, screenId); sp184[2] = func_80030150(player, playerId); mtxf_translate_vec3f_mat3(sp184, player->orientationMatrix); - sp98[0] = player->velocity[0]; - sp98[1] = player->velocity[1]; - sp98[2] = player->velocity[2]; + newVelocity[0] = player->velocity[0]; + newVelocity[1] = player->velocity[1]; + newVelocity[2] = player->velocity[2]; if (((player->unk_10C < 3) && (((s32) player->unk_256) < 3)) || ((player->effects & BOOST_EFFECT) == BOOST_EFFECT)) { if (((player->unk_07C >> 16) >= 0x28) || ((player->unk_07C >> 16) < (-0x27))) { - sp98[0] += (((((f64) ((sp184[0] + spB4) + sp160[0])) - (sp98[0] * (0.12 * ((f64) player->kartFriction)))) / - 6000.0) / + newVelocity[0] += (((((f64) ((sp184[0] + gravityX) + sp160[0])) - (newVelocity[0] * (0.12 * ((f64) player->kartFriction)))) / + 6000.0) / (((((f64) player->unk_20C) * 0.6) + 1.0) + sp7C)); - sp98[2] += (((((f64) ((sp184[2] + spAC) + sp160[2])) - (sp98[2] * (0.12 * ((f64) player->kartFriction)))) / - 6000.0) / + newVelocity[2] += (((((f64) ((sp184[2] + gravityZ) + sp160[2])) - (newVelocity[2] * (0.12 * ((f64) player->kartFriction)))) / + 6000.0) / (((((f64) player->unk_20C) * 0.6) + 1.0) + sp7C)); } else { - sp98[0] += (((((f64) ((sp184[0] + spB4) + sp160[0])) - (sp98[0] * (0.12 * ((f64) player->kartFriction)))) / - 6000.0) / + newVelocity[0] += (((((f64) ((sp184[0] + gravityX) + sp160[0])) - (newVelocity[0] * (0.12 * ((f64) player->kartFriction)))) / + 6000.0) / (sp7C + 1)); - sp98[2] += (((((f64) ((sp184[2] + spAC) + sp160[2])) - (sp98[2] * (0.12 * ((f64) player->kartFriction)))) / - 6000.0) / + newVelocity[2] += (((((f64) ((sp184[2] + gravityZ) + sp160[2])) - (newVelocity[2] * (0.12 * ((f64) player->kartFriction)))) / + 6000.0) / (sp7C + 1)); } } else { - sp98[0] += - (((((f64) ((sp184[0] + spB4) + sp160[0])) - (sp98[0] * (0.12 * ((f64) player->kartFriction)))) / 6000.0) / - 30.0); - sp98[2] += - (((((f64) ((sp184[2] + spAC) + sp160[2])) - (sp98[2] * (0.12 * ((f64) player->kartFriction)))) / 6000.0) / - 30.0); - } - sp98[1] += - (((((f64) ((sp184[1] + spB0) + sp160[1])) - (sp98[1] * (0.12 * ((f64) player->kartFriction)))) / 6000.0) / - ((f64) player->unk_DAC)); + newVelocity[0] += + (((((f64) ((sp184[0] + gravityX) + sp160[0])) - (newVelocity[0] * (0.12 * ((f64) player->kartFriction)))) / 6000.0) / + 30.0); + newVelocity[2] += + (((((f64) ((sp184[2] + gravityZ) + sp160[2])) - (newVelocity[2] * (0.12 * ((f64) player->kartFriction)))) / 6000.0) / + 30.0); + } + newVelocity[1] += + (((((f64) ((sp184[1] + gravityY) + sp160[1])) - (newVelocity[1] * (0.12 * ((f64) player->kartFriction)))) / 6000.0) / + ((f64) player->unk_DAC)); if (((((player->unk_0CA & 2) == 2) || ((player->unk_0CA & 8) == 8)) || - ((player->effects & HIT_EFFECT) == HIT_EFFECT)) || + ((player->effects & HIT_EFFECT) == HIT_EFFECT)) || (player->unk_0CA & 1)) { - sp98[0] = 0.0f; - sp98[1] = 0.0f; - sp98[2] = 0.0f; + newVelocity[0] = 0.0f; + newVelocity[1] = 0.0f; + newVelocity[2] = 0.0f; } if ((player->unk_044 & 0x10) == 0x10) { player->unk_044 &= 0xFFEF; @@ -2190,7 +2190,7 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player nextZ = posZ + player->velocity[2] + D_8018CE10[playerId].unk_04[2]; if (((((player->unk_0CA & 2) != 2) && ((player->unk_0CA & 8) != 8)) && - ((player->effects & HIT_EFFECT) != HIT_EFFECT)) && + ((player->effects & HIT_EFFECT) != HIT_EFFECT)) && (!(player->unk_0CA & 1))) { func_8002AAC0(player); nextY += player->kartHopVelocity; @@ -2203,15 +2203,15 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player player->unk_05C = 1.0f; if ((player->unk_044 & 1) != 1) { calculate_orientation_matrix(player->orientationMatrix, player->unk_058, player->unk_05C, player->unk_060, - player->rotation[1]); + 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] + 0x8000); } player->effects |= 8; player->unk_0C2 += 1; - temp_var = player->collision.surfaceDistance[2]; - if (temp_var <= 0.0f) { + surfaceDistance = player->collision.surfaceDistance[2]; + if (surfaceDistance <= 0.0f) { player->effects = player->effects & (~2); player->effects = player->effects & (~8); if (player->unk_0C2 >= 35) { @@ -2222,12 +2222,12 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player player->unk_DB4.unk18 = 0; player->unk_0B6 |= 0x100; if ((((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && - ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT)) && + ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT)) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800C9060(playerId, 0x1900A60AU); } else if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && - ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { + ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800CADD0((u8) playerId, ((f32) player->unk_0C2) / 35.0f); } if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { @@ -2250,7 +2250,7 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player player->unk_DB4.unkC = 1.5f; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - if (((player->unk_0C2 < 0xB) && (player->unk_0C2 >= 4)) && (IsBowsersCastle())) { + if (((player->unk_0C2 < 0xB) && (player->unk_0C2 >= 4)) && (gCurrentCourseId == COURSE_BOWSER_CASTLE)) { func_800CADD0((u8) playerId, player->unk_0C2 / 14.0f); } else { func_800CADD0((u8) playerId, player->unk_0C2 / 25.0f); @@ -2260,24 +2260,24 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player player->unk_0C2 = 0; player->kartHopVelocity = player->unk_0C2; } - temp_var = player->collision.surfaceDistance[2]; - if (temp_var <= 0.0f) { - func_8003F46C(player, sp8C, sp98, sp178, &temp_var, &nextX, &nextY, &nextZ); + surfaceDistance = player->collision.surfaceDistance[2]; + if (surfaceDistance <= 0.0f) { + func_8003F46C(player, sp8C, newVelocity, sp178, &surfaceDistance, &nextX, &nextY, &nextZ); } - temp_var = player->collision.surfaceDistance[0]; - if (temp_var < 0.0f) { - func_8003F734(player, sp8C, sp98, &temp_var, &nextX, &nextY, &nextZ); - func_8002C954(player, playerId, sp98); + surfaceDistance = player->collision.surfaceDistance[0]; + if (surfaceDistance < 0.0f) { + func_8003F734(player, sp8C, newVelocity, &surfaceDistance, &nextX, &nextY, &nextZ); + func_8002C954(player, playerId, newVelocity); } - temp_var = player->collision.surfaceDistance[1]; - if (temp_var < 0.0f) { - func_8003FBAC(player, sp8C, sp98, &temp_var, &nextX, &nextY, &nextZ); - func_8002C954(player, playerId, sp98); + surfaceDistance = player->collision.surfaceDistance[1]; + if (surfaceDistance < 0.0f) { + func_8003FBAC(player, sp8C, newVelocity, &surfaceDistance, &nextX, &nextY, &nextZ); + func_8002C954(player, playerId, newVelocity); } - temp_var = player->collision.surfaceDistance[0]; - if (temp_var >= 0.0f) { - temp_var = player->collision.surfaceDistance[1]; - if (temp_var >= 0.0f) { + surfaceDistance = player->collision.surfaceDistance[0]; + if (surfaceDistance >= 0.0f) { + surfaceDistance = player->collision.surfaceDistance[1]; + if (surfaceDistance >= 0.0f) { player->unk_046 &= 0xFFDF; if (player->unk_256 != 0) { player->unk_256++; @@ -2293,46 +2293,43 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player func_8008F494(player, playerId); } } else if (((!(player->effects & 8)) && (func_802ABDB8(player->collision.meshIndexZX) == 0)) && - (player->effects & 0x10000)) { + (player->effects & 0x10000)) { func_8008F5A4(player, playerId); } player->unk_074 = calculate_surface_height(nextX, nextY, nextZ, player->collision.meshIndexZX); if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && (((gActiveScreenMode == SCREEN_MODE_1P) || (gActiveScreenMode == SCREEN_MODE_2P_SPLITSCREEN_VERTICAL)) || - (gActiveScreenMode == SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL))) { + (gActiveScreenMode == SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL))) { func_80029B4C(player, nextX, nextY, nextZ); } else { func_8002A194(player, nextX, nextY, nextZ); } func_8002AE38(player, playerId, posX, posZ, nextX, nextZ); - temp2 = (sp98[0] * sp98[0]) + (sp98[2] * sp98[2]); + temp2 = (newVelocity[0] * newVelocity[0]) + (newVelocity[2] * newVelocity[2]); player->previousSpeed = player->speed; player->speed = sqrtf(temp2); if ((player->unk_08C <= 0.0f) && (player->speed <= 0.08) && (D_8018CE10[playerId].unk_04[0] == 0.0f) && (D_8018CE10[playerId].unk_04[2] == 0.0f)) { - sp98[0] = sp98[0] + (-1 * sp98[0]); - sp98[2] = sp98[2] + (-1 * sp98[2]); + newVelocity[0] = newVelocity[0] + (-1 * newVelocity[0]); + newVelocity[2] = newVelocity[2] + (-1 * newVelocity[2]); } else { player->pos[0] = nextX; player->pos[2] = nextZ; } player->pos[1] = nextY; - if (CVarGetInteger("gNoWallColision", 0)) { - player->pos[1] = nextY < CVarGetFloat("gMinHeight", 0.0f) ? CVarGetFloat("gMinHeight", 0.0f) : nextY; - } if ((player->type & PLAYER_HUMAN) && (!(player->type & PLAYER_CPU))) { - func_8002BB9C(player, &nextX, &nextZ, screenId, playerId, sp98); + func_8002BB9C(player, &nextX, &nextZ, screenId, playerId, newVelocity); } player->unk_064[0] = sp178[0]; player->unk_064[2] = sp178[2]; - player->velocity[0] = sp98[0]; - player->velocity[1] = sp98[1]; - player->velocity[2] = sp98[2]; - D_80165070[playerId][0] = sp98[0]; - D_80165070[playerId][1] = sp98[1]; - D_80165070[playerId][2] = sp98[2]; + player->velocity[0] = newVelocity[0]; + player->velocity[1] = newVelocity[1]; + player->velocity[2] = newVelocity[2]; + gPlayerLastVelocity[playerId][0] = newVelocity[0]; + gPlayerLastVelocity[playerId][1] = newVelocity[1]; + gPlayerLastVelocity[playerId][2] = newVelocity[2]; if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { if (gKartTopSpeedTable[player->characterId] < player->speed) { temp = gKartTopSpeedTable[player->characterId] / player->speed; @@ -2619,31 +2616,31 @@ void func_8002E594(Player* player, UNUSED Camera* camera, s8 screenId, s8 player func_8002C4F8(player, playerId); } -void control_cpu_movement(Player* player, UNUSED Camera* camera, s8 arg2, s8 playerId) { +void control_cpu_movement(Player* player, UNUSED Camera* camera, s8 screenId, s8 playerId) { Vec3f spF4 = { 0.0f, 0.0f, 1.0f }; UNUSED Vec3f spE8 = { 0.0f, 0.0f, 0.0f }; Vec3f spDC = { 0.0f, 0.0f, 0.0f }; Vec3f spD0 = { 0.0f, 0.0f, 0.0f }; - f32 spCC; + f32 nextX; UNUSED s32 pad; - f32 spC4; + f32 nextZ; UNUSED s32 pad2[15]; f32 sp84; UNUSED s32 pad3; f32 sp7C; UNUSED s32 pad4[2]; - Vec3f sp68; + Vec3f newVelocity; UNUSED f32 pad5[7]; f32 toSqrt; - f32 temp_f0_2; - f32 test; + f32 topSpeedMultiplier; + f32 nextY; player->effects |= 0x1000; player->unk_044 |= 0x10; - test = gPlayerPathY[playerId]; + nextY = gPlayerPathY[playerId]; player->driftDuration = 0; - player->effects &= ~0x10; - func_8002B830(player, playerId, arg2); - apply_effect(player, playerId, arg2); + player->effects &= 0x10; + func_8002B830(player, playerId, screenId); + apply_effect(player, playerId, screenId); sp84 = 0 * player->unk_064[0] + spDC[0]; sp7C = 0 * player->unk_064[2] + spDC[2]; player->unk_10C = 0; @@ -2651,16 +2648,16 @@ void control_cpu_movement(Player* player, UNUSED Camera* camera, s8 arg2, s8 pla player->effects &= ~0x8000; spF4[2] = func_80030150(player, playerId); mtxf_translate_vec3f_mat3(spF4, player->orientationMatrix); - sp68[0] = player->velocity[0]; - sp68[1] = 0; - sp68[2] = player->velocity[2]; - sp68[0] += (((spF4[0] + sp84) + spD0[0]) - (sp68[0] * (0.12 * player->kartFriction))) / 6000.0; - sp68[2] += (((spF4[2] + sp7C) + spD0[2]) - (sp68[2] * (0.12 * player->kartFriction))) / 6000.0; + newVelocity[0] = player->velocity[0]; + newVelocity[1] = 0; + newVelocity[2] = player->velocity[2]; + newVelocity[0] += (((spF4[0] + sp84) + spD0[0]) - (newVelocity[0] * (0.12 * player->kartFriction))) / 6000.0; + newVelocity[2] += (((spF4[2] + sp7C) + spD0[2]) - (newVelocity[2] * (0.12 * player->kartFriction))) / 6000.0; player->oldPos[0] = player->pos[0]; - player->oldPos[1] = test; + player->oldPos[1] = nextY; player->oldPos[2] = player->pos[2]; - spCC = player->pos[0] + player->velocity[0]; - spC4 = player->pos[2] + player->velocity[2]; + nextX = player->pos[0] + player->velocity[0]; + nextZ = player->pos[2] + player->velocity[2]; player->unk_0C0 = 0; player->kartHopJerk = 0; player->kartHopAcceleration = 0; @@ -2672,25 +2669,25 @@ void control_cpu_movement(Player* player, UNUSED Camera* camera, s8 arg2, s8 pla player->effects &= ~8; player->slopeAccel = 0; player->unk_206 = 0; - toSqrt = (sp68[0] * sp68[0]) + (sp68[2] * sp68[2]); + toSqrt = (newVelocity[0] * newVelocity[0]) + (newVelocity[2] * newVelocity[2]); player->previousSpeed = player->speed; player->speed = sqrtf(toSqrt); - player->pos[0] = spCC; - player->pos[2] = spC4; - player->pos[1] = test; + player->pos[0] = nextX; + player->pos[2] = nextZ; + player->pos[1] = nextY; player->unk_064[0] = 0; player->unk_064[2] = 0; - player->velocity[0] = sp68[0]; - player->velocity[1] = sp68[1]; - player->velocity[2] = sp68[2]; - D_80165070[playerId][0] = sp68[0]; - D_80165070[playerId][1] = sp68[1]; - D_80165070[playerId][2] = sp68[2]; + player->velocity[0] = newVelocity[0]; + player->velocity[1] = newVelocity[1]; + player->velocity[2] = newVelocity[2]; + gPlayerLastVelocity[playerId][0] = newVelocity[0]; + gPlayerLastVelocity[playerId][1] = newVelocity[1]; + gPlayerLastVelocity[playerId][2] = newVelocity[2]; if (gKartTopSpeedTable[player->characterId] < player->speed) { - temp_f0_2 = gKartTopSpeedTable[player->characterId] / player->speed; - player->velocity[0] *= temp_f0_2; - player->velocity[1] *= temp_f0_2; - player->velocity[2] *= temp_f0_2; + topSpeedMultiplier = gKartTopSpeedTable[player->characterId] / player->speed; + player->velocity[0] *= topSpeedMultiplier; + player->velocity[1] *= topSpeedMultiplier; + player->velocity[2] *= topSpeedMultiplier; player->speed = gKartTopSpeedTable[player->characterId]; } } @@ -2788,9 +2785,9 @@ void func_8002F730(Player* player, UNUSED Camera* camera, UNUSED s8 screenId, s8 player->velocity[0] = sp68[0]; player->velocity[1] = sp68[1]; player->velocity[2] = sp68[2]; - D_80165070[playerId][0] = sp68[0]; - D_80165070[playerId][1] = sp68[1]; - D_80165070[playerId][2] = sp68[2]; + gPlayerLastVelocity[playerId][0] = sp68[0]; + gPlayerLastVelocity[playerId][1] = sp68[1]; + gPlayerLastVelocity[playerId][2] = sp68[2]; if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { if (gKartTopSpeedTable[player->characterId] < player->speed) { @@ -3707,10 +3704,10 @@ void func_800337CC(Player* player, f32 arg1, s32 arg2) { player->unk_098 = (D_80165280[arg2] * D_80165280[arg2]) / 25.0f; } -void func_80033850(Player* arg0, f32 arg1) { - arg0->unk_090 += arg1; - if (arg0->unk_090 >= 0.0f) { - arg0->unk_090 = 0.0f; +void func_80033850(Player* player, f32 arg1) { + player->unk_090 += arg1; + if (player->unk_090 >= 0.0f) { + player->unk_090 = 0.0f; } } @@ -4184,11 +4181,11 @@ void apply_cpu_turn(Player* player, s16 arg1) { } } -void func_80036C5C(Player* arg0) { - if (((arg0->speed / 18.0f) * 216.0f) > 20.0f) { - arg0->driftDuration = 0; - arg0->effects |= DRIFTING_EFFECT; - arg0->unk_0B6 |= 0x800; +void func_80036C5C(Player* player) { + if (((player->speed / 18.0f) * 216.0f) > 20.0f) { + player->driftDuration = 0; + player->effects |= DRIFTING_EFFECT; + player->unk_0B6 |= 0x800; } } @@ -4909,9 +4906,9 @@ void func_80038C6C(Player* player, UNUSED Camera* camera, s8 arg2, s8 playerId) player->velocity[1] = sp88[1]; player->velocity[2] = sp88[2]; - D_80165070[playerId][0] = sp88[0]; - D_80165070[playerId][1] = sp88[1]; - D_80165070[playerId][2] = sp88[2]; + gPlayerLastVelocity[playerId][0] = sp88[0]; + gPlayerLastVelocity[playerId][1] = sp88[1]; + gPlayerLastVelocity[playerId][2] = sp88[2]; if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { if (gKartTopSpeedTable[player->characterId] < player->speed) { diff --git a/src/racing/actors.c b/src/racing/actors.c index 17742bf03..87c6e8231 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -420,18 +420,18 @@ void func_80297760(struct Actor* arg0, Vec3f arg1) { arg1[1] = calculate_surface_height(arg1[0], arg1[1], arg1[2], arg0->unk30.meshIndexZX); } -void func_802977B0(Player* arg0) { - arg0->tyres[FRONT_RIGHT].unk_14 |= 2; - arg0->tyres[FRONT_LEFT].unk_14 |= 2; - arg0->tyres[BACK_RIGHT].unk_14 |= 2; - arg0->tyres[BACK_LEFT].unk_14 |= 2; +void func_802977B0(Player* player) { + player->tyres[FRONT_RIGHT].unk_14 |= 2; + player->tyres[FRONT_LEFT].unk_14 |= 2; + player->tyres[BACK_RIGHT].unk_14 |= 2; + player->tyres[BACK_LEFT].unk_14 |= 2; } -void func_802977E4(Player* arg0) { - arg0->tyres[FRONT_RIGHT].unk_14 &= ~2 & 0xFFFF; - arg0->tyres[FRONT_LEFT].unk_14 &= ~2 & 0xFFFF; - arg0->tyres[BACK_RIGHT].unk_14 &= ~2 & 0xFFFF; - arg0->tyres[BACK_LEFT].unk_14 &= ~2 & 0xFFFF; +void func_802977E4(Player* player) { + player->tyres[FRONT_RIGHT].unk_14 &= ~2 & 0xFFFF; + player->tyres[FRONT_LEFT].unk_14 &= ~2 & 0xFFFF; + player->tyres[BACK_RIGHT].unk_14 &= ~2 & 0xFFFF; + player->tyres[BACK_LEFT].unk_14 &= ~2 & 0xFFFF; } // Generate the red shell tlut by invert green the green one @@ -1740,29 +1740,29 @@ bool collision_tree(Player* player, struct Actor* actor) { return true; } -bool query_collision_player_vs_actor_item(Player* arg0, struct Actor* arg1) { +bool query_collision_player_vs_actor_item(Player* player, struct Actor* arg1) { f32 temp_f0; f32 dist; f32 yDist; f32 zDist; f32 xDist; - temp_f0 = arg0->boundingBoxSize + arg1->boundingBoxSize; - xDist = arg1->pos[0] - arg0->pos[0]; + temp_f0 = player->boundingBoxSize + arg1->boundingBoxSize; + xDist = arg1->pos[0] - player->pos[0]; if (temp_f0 < xDist) { return NO_COLLISION; } if (xDist < -temp_f0) { return NO_COLLISION; } - yDist = arg1->pos[1] - arg0->pos[1]; + yDist = arg1->pos[1] - player->pos[1]; if (temp_f0 < yDist) { return NO_COLLISION; } if (yDist < -temp_f0) { return NO_COLLISION; } - zDist = arg1->pos[2] - arg0->pos[2]; + zDist = arg1->pos[2] - player->pos[2]; if (temp_f0 < zDist) { return NO_COLLISION; } diff --git a/src/racing/math_util.c b/src/racing/math_util.c index 69d5c0cbc..05baecf3f 100644 --- a/src/racing/math_util.c +++ b/src/racing/math_util.c @@ -1205,7 +1205,7 @@ UNUSED void func_802B8414(uintptr_t addr, Mat4 arg1, s16 arg2, s16 arg3, s32 arg #ifdef MIPS_TO_C // generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-29-2023 -void func_802B8614(Player* arg0) { +void func_802B8614(Player* player) { f64 sp78; f64 sp70; f64 sp68; @@ -1224,16 +1224,16 @@ void func_802B8614(Player* arg0) { f64 temp_f4; f64 temp_f6; - temp_f6 = (f64) arg0->tyres[FRONT_RIGHT].pos[0]; + temp_f6 = (f64) player->tyres[FRONT_RIGHT].pos[0]; sp78 = temp_f6; - sp70 = (f64) arg0->tyres[FRONT_RIGHT].baseHeight; - sp68 = (f64) arg0->tyres[FRONT_RIGHT].pos[2]; - temp_f30 = (f64) arg0->tyres[FRONT_LEFT].pos[0]; - sp58 = (f64) arg0->tyres[FRONT_LEFT].baseHeight; - sp50 = (f64) arg0->tyres[FRONT_LEFT].pos[2]; - sp48 = (f64) arg0->tyres[BACK_RIGHT].pos[0]; - sp40 = (f64) arg0->tyres[BACK_RIGHT].baseHeight; - temp_f4 = (f64) arg0->tyres[BACK_RIGHT].pos[2]; + sp70 = (f64) player->tyres[FRONT_RIGHT].baseHeight; + sp68 = (f64) player->tyres[FRONT_RIGHT].pos[2]; + temp_f30 = (f64) player->tyres[FRONT_LEFT].pos[0]; + sp58 = (f64) player->tyres[FRONT_LEFT].baseHeight; + sp50 = (f64) player->tyres[FRONT_LEFT].pos[2]; + sp48 = (f64) player->tyres[BACK_RIGHT].pos[0]; + sp40 = (f64) player->tyres[BACK_RIGHT].baseHeight; + temp_f4 = (f64) player->tyres[BACK_RIGHT].pos[2]; temp_f2 = sp58 - sp70; sp38 = temp_f4; temp_f12 = temp_f4 - sp50; @@ -1242,14 +1242,14 @@ void func_802B8614(Player* arg0) { temp_f18 = sp48 - temp_f30; temp_f20 = temp_f30 - temp_f6; if (0.0 == 0.0) { - arg0->unk_058 = 0.0f; - arg0->unk_060 = 0.0f; - arg0->unk_05C = 1.0f; + player->unk_058 = 0.0f; + player->unk_060 = 0.0f; + player->unk_05C = 1.0f; return; } - arg0->unk_058 = (f32) ((f64) (f32) ((temp_f2 * temp_f12) - (temp_f14 * temp_f16)) / 0.0); - arg0->unk_05C = (f32) ((f64) (f32) ((temp_f14 * temp_f18) - (temp_f20 * temp_f12)) / 0.0); - arg0->unk_060 = (f32) ((f64) (f32) ((temp_f20 * temp_f16) - (temp_f2 * temp_f18)) / 0.0); + player->unk_058 = (f32) ((f64) (f32) ((temp_f2 * temp_f12) - (temp_f14 * temp_f16)) / 0.0); + player->unk_05C = (f32) ((f64) (f32) ((temp_f14 * temp_f18) - (temp_f20 * temp_f12)) / 0.0); + player->unk_060 = (f32) ((f64) (f32) ((temp_f20 * temp_f16) - (temp_f2 * temp_f18)) / 0.0); } #else GLOBAL_ASM("asm/non_matchings/racing/math_util/func_802B8614.s") diff --git a/src/render_player.c b/src/render_player.c index 18f695616..5dddb069b 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -59,7 +59,7 @@ u16 gPlayerYellowEffect[8]; UNUSED u16 gPlayerWhiteEffect[8]; s32 D_80164B80[296]; s16 D_80165020[40]; -Vec3f D_80165070[8]; +Vec3f gPlayerLastVelocity[8]; s16 gLastAnimFrameSelector[4][8]; s16 gLastAnimGroupSelector[4][8]; s16 D_80165150[4][8]; @@ -1664,7 +1664,7 @@ void render_kart(Player* player, s8 playerId, s8 screenId, s8 flipOffset) { gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); func_8004B614(gPlayerRedEffect[playerId], gPlayerGreenEffect[playerId], gPlayerBlueEffect[playerId], gPlayerCyanEffect[playerId], gPlayerMagentaEffect[playerId], gPlayerYellowEffect[playerId], - (s32) player->unk_0C6); + (s32) player->alpha); gDPSetRenderMode(gDisplayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), @@ -1679,7 +1679,7 @@ void render_kart(Player* player, s8 playerId, s8 screenId, s8 flipOffset) { gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); func_8004B614(gPlayerRedEffect[playerId], gPlayerGreenEffect[playerId], gPlayerBlueEffect[playerId], gPlayerCyanEffect[playerId], gPlayerMagentaEffect[playerId], gPlayerYellowEffect[playerId], - D_8018D970[playerId]); + gPlayerOtherScreensAlpha[playerId]); gDPSetRenderMode(gDisplayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), @@ -1696,7 +1696,7 @@ void render_kart(Player* player, s8 playerId, s8 screenId, s8 flipOffset) { gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); func_8004B614(gPlayerRedEffect[playerId], gPlayerGreenEffect[playerId], gPlayerBlueEffect[playerId], gPlayerCyanEffect[playerId], gPlayerMagentaEffect[playerId], gPlayerYellowEffect[playerId], - (s32) player->unk_0C6); + (s32) player->alpha); gDPSetAlphaCompare(gDisplayListHead++, G_AC_DITHER); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2); } else { @@ -1708,7 +1708,7 @@ void render_kart(Player* player, s8 playerId, s8 screenId, s8 flipOffset) { gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); func_8004B614(gPlayerRedEffect[playerId], gPlayerGreenEffect[playerId], gPlayerBlueEffect[playerId], gPlayerCyanEffect[playerId], gPlayerMagentaEffect[playerId], gPlayerYellowEffect[playerId], - (s32) player->unk_0C6); + (s32) player->alpha); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); } @@ -1868,7 +1868,7 @@ void render_player_ice_reflection(Player* player, s8 playerId, s8 screenId, s8 f gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); func_8004B614(gPlayerRedEffect[playerId], gPlayerGreenEffect[playerId], gPlayerBlueEffect[playerId], gPlayerCyanEffect[playerId], gPlayerMagentaEffect[playerId], gPlayerYellowEffect[playerId], - (s16) player->unk_0C6 / 2); + (s16) player->alpha / 2); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2); gDPLoadTextureBlock(gDisplayListHead++, sKartTexture, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, diff --git a/src/render_player.h b/src/render_player.h index 3d3d7204c..2cd79e638 100644 --- a/src/render_player.h +++ b/src/render_player.h @@ -271,7 +271,8 @@ extern u8* gKartWario189Wheel0[]; #endif extern s16 D_80165020[40]; -extern Vec3f D_80165070[8]; +// Used to calculate difference between previous and current player velocity. +extern Vec3f gPlayerLastVelocity[8]; extern s16 gLastAnimFrameSelector[4][8]; extern s16 gLastAnimGroupSelector[4][8]; extern s16 D_80165150[4][8]; diff --git a/src/spawn_players.c b/src/spawn_players.c index 83532896c..816e6566b 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -178,7 +178,7 @@ void spawn_player(Player* player, s8 playerIndex, f32 startingRow, f32 startingC player->unk_044 = 0; player->unk_046 = 0; player->soundEffects = 0; - player->unk_0C6 = 0xFF; + player->alpha = ALPHA_MAX; player->unk_206 = 0; player->slopeAccel = 0; @@ -300,9 +300,9 @@ void spawn_player(Player* player, s8 playerIndex, f32 startingRow, f32 startingC D_801652E0[playerIndex] = 0; D_801652C0[playerIndex] = 0; D_80165020[playerIndex] = 0; - D_80165070[playerIndex][0] = 0.0f; - D_80165070[playerIndex][1] = 0.0f; - D_80165070[playerIndex][2] = 0.0f; + gPlayerLastVelocity[playerIndex][0] = 0.0f; + gPlayerLastVelocity[playerIndex][1] = 0.0f; + gPlayerLastVelocity[playerIndex][2] = 0.0f; D_80165280[playerIndex] = 0.0f; D_801652A0[playerIndex] = 0.0f; gPlayerIsThrottleActive[playerIndex] = 0; |
