diff --git a/include/defines.h b/include/defines.h index 3a5ac8bac..e2172b4e2 100644 --- a/include/defines.h +++ b/include/defines.h @@ -350,6 +350,12 @@ enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE }; #define LIGHTNING_EFFECT 0x40000000 // being hit by lightning #define BOO_EFFECT 0x80000000 // being a boo + +/** + * @brief durations of effects + */ +#define STAR_EFFECT_DURATION 0xA + /** * @brief shell state * diff --git a/src/audio/external.c b/src/audio/external.c index 34f83e646..0086da553 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -1096,7 +1096,7 @@ void func_800C3724(void) { if (func_800C357C_eu(-0x10000000, -0x10000000) == 0) { D_801930D0[seqPlayerIndex].unk_041 = 0; return; - } + } #endif if (D_801930D0[seqPlayerIndex].unk_040 != 0) { D_801930D0[seqPlayerIndex].unk_040--; @@ -1427,12 +1427,12 @@ void func_800C4888(u8 bankId) { if ((sSoundBanks[bankId][soundIndex].soundStatus == 1) && ((sSoundBanks[bankId][soundIndex].soundBits & 0x08000000) == 0x08000000)) { sSoundBanks[bankId][soundIndex].freshness -= 1; } - + if (sSoundBanks[bankId][soundIndex].freshness == 0) { delete_sound_from_bank(bankId, soundIndex); } else if (sSoundBanks[bankId][soundIndex].soundStatus != 0) { entry = &sSoundBanks[bankId][soundIndex]; - + if (&D_800EA1C8 == entry[0].unk00) { entry->distance = 0.0f; } else { @@ -2900,8 +2900,8 @@ void func_800C8F80(u8 arg0, u32 soundBits) { } } -void func_800C9018(u8 arg0, u32 soundBits) { - func_800C5578(&D_800E9F7C[arg0].pos, soundBits); +void func_800C9018(u8 playerIndex, u32 soundBits) { + func_800C5578(&D_800E9F7C[playerIndex].pos, soundBits); } void func_800C9060(u8 playerId, u32 soundBits) { @@ -2942,9 +2942,9 @@ void func_800C90F4(u8 playerId, u32 soundBits) { } } -void func_800C9250(u8 arg0) { - func_800C90F4(arg0, - (gPlayers[arg0].characterId * 0x10) + (gAudioRandom & 1) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x01)); +void func_800C9250(u8 playerIndex) { + func_800C90F4(playerIndex, + (gPlayers[playerIndex].characterId * 0x10) + (gAudioRandom & 1) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x01)); } void func_800C92CC(u8 playerId, u32 soundBits) { @@ -3263,8 +3263,8 @@ void func_800CA118(u8 arg0) { } } -void func_800CA24C(u8 arg0) { - D_800EA0EC[arg0] = 2; +void func_800CA24C(u8 playerIndex) { + D_800EA0EC[playerIndex] = 2; } void func_800CA270() { @@ -3311,10 +3311,10 @@ void func_800CA414(u16 arg0, u16 arg1) { D_800EA104 = 1; } -void func_800CA49C(u8 arg0) { +void func_800CA49C(u8 playerIndex) { if (D_800EA108 == 0) { if (D_800EA1C0 >= 2) { - func_800C9060(arg0, 0x1900FF3A); + func_800C9060(playerIndex, 0x1900FF3A); } else if (D_800EA164 != 0) { func_800C3448(0x100100FF); // 0x19000000 func_800C3448(0x110100FF); @@ -3358,18 +3358,18 @@ void func_800CA59C(u8 playerId) { } } -void func_800CA730(u8 arg0) { - if (D_800EA0EC[arg0] == 0) { - if ((D_800EA108 == 0) && (D_800EA10C[arg0] != 0)) { - play_sound(gPlayers[arg0].characterId * 0x10 + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x08), - &D_800E9F7C[arg0].pos, arg0, &D_800EA1D4, &D_800EA1D4, (s8*) &D_800E9F7C[arg0].unk_14); - if (D_800EA10C[arg0] != 0) { +void func_800CA730(u8 playerIndex) { + if (D_800EA0EC[playerIndex] == 0) { + if ((D_800EA108 == 0) && (D_800EA10C[playerIndex] != 0)) { + play_sound(gPlayers[playerIndex].characterId * 0x10 + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x08), + &D_800E9F7C[playerIndex].pos, playerIndex, &D_800EA1D4, &D_800EA1D4, (s8*) &D_800E9F7C[playerIndex].unk_14); + if (D_800EA10C[playerIndex] != 0) { if ((s32) D_800EA1C0 >= 2) { - func_800C9018(arg0, SOUND_ARG_LOAD(0x01, 0x00, 0xFF, 0x2C)); + func_800C9018(playerIndex, SOUND_ARG_LOAD(0x01, 0x00, 0xFF, 0x2C)); } else { - D_800EA10C[arg0] = 0; + D_800EA10C[playerIndex] = 0; if (D_800EA104 != 0) { - func_800C9018(arg0, SOUND_ARG_LOAD(0x01, 0x00, 0xFF, 0x2C)); + func_800C9018(playerIndex, SOUND_ARG_LOAD(0x01, 0x00, 0xFF, 0x2C)); } else if ((D_800EA10C[0] == 0) && (D_800EA10C[1] == 0)) { if (D_8018FC08 != 0) { if (((u32) (gSequencePlayers[1].enabled)) == 0) { @@ -3393,19 +3393,19 @@ void func_800CA730(u8 arg0) { D_800EA164 = 0; } } - D_800EA10C[arg0] = 0; + D_800EA10C[playerIndex] = 0; } } } -void func_800CA984(u8 arg0) { +void func_800CA984(u8 playerIndex) { u8 i; struct Unk_8018EFD8* temp_v0_2; if ((D_800EA108 == 0) && (D_800EA0F0 == 0)) { for (i = 0; i < D_800EA1C0 + 1; i++) { temp_v0_2 = - func_800C1C88(arg0, gPlayers[arg0].pos, D_800EA1C8, &gPlayers[arg0].unk_098, (u8) i, SOUND_ITEM_STAR); + func_800C1C88(playerIndex, gPlayers[playerIndex].pos, D_800EA1C8, &gPlayers[playerIndex].unk_098, (u8) i, SOUND_ITEM_STAR); if (temp_v0_2) { play_sound(SOUND_ITEM_STAR, &temp_v0_2->unk18, i, &D_800EA1D4, &D_800EA1D4, &D_800EA1DC); } @@ -3419,17 +3419,17 @@ void func_800CAACC(u8 playerId) { } } -void func_800CAB4C(u8 arg0) { +void func_800CAB4C(u8 playerIndex) { UNUSED u8* temp_v1; UNUSED u8 temp_v0; if (D_800EA108 == 0) { - switch (D_800EA0EC[arg0]) { + switch (D_800EA0EC[playerIndex]) { case 2: - D_800EA0EC[arg0] = 1; + D_800EA0EC[playerIndex] = 1; case 0: func_800C36C4(0, 1U, 0x55U, 5); - func_800C9060(arg0, 0x1900F013U); + func_800C9060(playerIndex, 0x1900F013U); play_sound(SOUND_ITEM_THUNDERBOLT, &D_800EA1C8, 0U, &D_800EA1D4, &D_800EA1D4, &D_800EA1DC); break; default: @@ -3468,11 +3468,11 @@ void func_800CAD40(UNUSED s32 arg0) { } } -void func_800CADD0(u8 arg0, f32 arg1) { +void func_800CADD0(u8 playerIndex, f32 arg1) { if (D_800EA108 == 0) { - switch (D_800EA0EC[arg0]) { + switch (D_800EA0EC[playerIndex]) { case 2: - D_800EA0EC[arg0] = 1; + D_800EA0EC[playerIndex] = 1; // Purposeful fallthrough case 0: arg1 = (arg1 * 0.55f) + 0.45f; @@ -3482,9 +3482,9 @@ void func_800CADD0(u8 arg0, f32 arg1) { if (arg1 < 0.0f) { arg1 = 0.0f; } - D_800EA110[arg0] = arg1; - play_sound(0x1900A209U, &D_800E9F7C[arg0].pos, arg0, &D_800EA1D4, &D_800EA110[arg0], - (s8*) &D_800E9F7C[arg0].unk_14); + D_800EA110[playerIndex] = arg1; + play_sound(0x1900A209U, &D_800E9F7C[playerIndex].pos, playerIndex, &D_800EA1D4, &D_800EA110[playerIndex], + (s8*) &D_800E9F7C[playerIndex].unk_14); break; default: break; @@ -3516,30 +3516,30 @@ void func_800CAEC4(u8 playerId, f32 arg1) { } } -void func_800CAFC0(u8 arg0) { +void func_800CAFC0(u8 playerIndex) { if (D_800EA108 == 0) { - switch (D_800EA0EC[arg0]) { + switch (D_800EA0EC[playerIndex]) { case 2: - D_800EA0EC[arg0] = 1; + D_800EA0EC[playerIndex] = 1; case 0: func_800C36C4(0, 1, 0x55U, 5); - func_800C9060(arg0, 0x19009E59U); - func_800C8F80(arg0, 0x0100FA4C); - D_800EA170[arg0] = 1; + func_800C9060(playerIndex, 0x19009E59U); + func_800C8F80(playerIndex, 0x0100FA4C); + D_800EA170[playerIndex] = 1; break; } } } -void func_800CB064(u8 arg0) { +void func_800CB064(u8 playerIndex) { if (D_800EA108 == 0) { - if (D_800EA170[arg0] == 1) { + if (D_800EA170[playerIndex] == 1) { if ((u8) D_800EA168 == 0) { func_800C36C4(0, 1U, 0x7FU, 0x19); } - func_800C90F4(arg0, gPlayers[arg0].characterId * 0x10 + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x08)); - func_800C9018(arg0, SOUND_ARG_LOAD(0x01, 0x00, 0xFA, 0x4C)); - D_800EA170[arg0] = 0; + func_800C90F4(playerIndex, gPlayers[playerIndex].characterId * 0x10 + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x08)); + func_800C9018(playerIndex, SOUND_ARG_LOAD(0x01, 0x00, 0xFA, 0x4C)); + D_800EA170[playerIndex] = 0; } } } diff --git a/src/code_8003DC40.c b/src/code_8003DC40.c index 5c3230574..87c557f97 100644 --- a/src/code_8003DC40.c +++ b/src/code_8003DC40.c @@ -71,7 +71,7 @@ void func_8003E048(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 if (player->collision.orientationVector[1] <= 0.8829f) { arg3[0] = ((player->unk_206 / 182) * 0xB4); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - player_decelerate(player, 4.0f); + player_decelerate_alternative(player, 4.0f); player->unk_DAC = 0.5f; if ((player->effects & BOOST_EFFECT) != 0) { remove_boost_effect(player); @@ -99,7 +99,7 @@ void func_8003E37C(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 arg3[0] = ((player->unk_206 / 182) * 0xB4); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); if (((player->speed / 18.0f) * 216.0f) >= 8.0f) { - player_decelerate(player, 5.0f); + player_decelerate_alternative(player, 5.0f); } player->unk_DAC = 0.5f; if ((player->effects & BOOST_EFFECT) != 0) { @@ -127,7 +127,7 @@ void func_8003E6EC(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 if (player->collision.orientationVector[1] <= 0.8829f) { arg3[0] = ((player->unk_206 / 182) * 0xB4); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - player_decelerate(player, 4.0f); + player_decelerate_alternative(player, 4.0f); func_8003DC40(player); } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000)) { @@ -149,7 +149,7 @@ void func_8003E9EC(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 if (player->collision.orientationVector[1] <= 0.8357f) { arg3[0] = ((player->unk_206 / 182) * 0x78); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - player_decelerate(player, 4.0f); + player_decelerate_alternative(player, 4.0f); func_8003DC40(player); } else { if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || @@ -184,7 +184,7 @@ void func_8003EE2C(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 if (player->collision.orientationVector[1] <= 0.8357f) { arg3[0] = ((player->unk_206 / 182) * 0x78); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - player_decelerate(player, 4.0f); + player_decelerate_alternative(player, 4.0f); func_8003DC40(player); } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000)) { @@ -209,7 +209,7 @@ void func_8003F138(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 if (player->collision.orientationVector[1] <= 0.8357f) { arg3[0] = ((player->unk_206 / 182) * 0xC8); arg3[2] = (-(player->slopeAccel / 182) * 0xC8); - player_decelerate(player, 4.0f); + player_decelerate_alternative(player, 4.0f); player->unk_DAC = 0.5f; arg3[0] = 0; } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 259420310..88d7d76fa 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -3843,11 +3843,11 @@ void func_80061754(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s32 arg3, U player->unk_258[0x1E + arg1].unk_00C = sp48 + 1.0f; } -void func_8006199C(Player* player, s16 arg1, s32 arg2, s8 arg3, s8 arg4) { +void func_8006199C(Player* player, s16 arg1, s32 arg2, s8 playerIndex, s8 arg4) { if ((arg1 == 0) && ((player->unk_258[0x1E + arg2].unk_01E > 0) || (player->unk_258[0x1E + arg2].unk_01C == 0))) { - func_80061754(player, arg1, arg2, (s32) arg3, arg4); + func_80061754(player, arg1, arg2, (s32) playerIndex, arg4); } else if (player->unk_258[0x1E + arg2].unk_01E > 0) { - func_80061754(player, arg1, arg2, (s32) arg3, arg4); + func_80061754(player, arg1, arg2, (s32) playerIndex, arg4); } } @@ -4973,7 +4973,7 @@ void func_800652D4(Vec3f arg0, Vec3s arg1, f32 arg2) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } -void func_8006538C(Player* player, s8 arg1, s16 arg2, s8 arg3) { +void func_8006538C(Player* player, s8 playerIndex, s16 arg2, s8 arg3) { Vec3f spB4; Vec3s spAC; s32 primColors[] = { MAKE_RGB(0xFB, 0xFF, 0xFB), MAKE_RGB(0xFF, 0xFB, 0x86) }; @@ -4993,7 +4993,7 @@ void func_8006538C(Player* player, s8 arg1, s16 arg2, s8 arg3) { spAC[0] = 0; spAC[1] = player->unk_048[arg3]; spAC[2] = 0; - if ((player->effects & STAR_EFFECT) && (((s32) gCourseTimer - D_8018D930[arg1]) < 9)) { + if ((player->effects & STAR_EFFECT) && (((s32) gCourseTimer - gPlayerStarEffectStartTime[playerIndex]) < STAR_EFFECT_DURATION - 1)) { primRed = (primColors[1] >> 0x10) & 0xFF; primGreen = (primColors[1] >> 0x08) & 0xFF; primBlue = (primColors[1] >> 0x00) & 0xFF; @@ -5029,7 +5029,7 @@ void func_8006538C(Player* player, s8 arg1, s16 arg2, s8 arg3) { } } -void func_800658A0(Player* player, UNUSED s8 arg1, s16 arg2, s8 arg3) { +void func_800658A0(Player* player, UNUSED s8 playerIndex, s16 arg2, s8 arg3) { Vec3f sp54; Vec3s sp4C; s16 red; @@ -5059,7 +5059,7 @@ void func_800658A0(Player* player, UNUSED s8 arg1, s16 arg2, s8 arg3) { } } -void func_80065AB0(Player* player, UNUSED s8 arg1, s16 arg2, s8 arg3) { +void func_80065AB0(Player* player, UNUSED s8 playerIndex, s16 arg2, s8 arg3) { Vec3f spB4; Vec3s spAC; s32 var_s0; @@ -5112,7 +5112,7 @@ void func_80065AB0(Player* player, UNUSED s8 arg1, s16 arg2, s8 arg3) { } } -void func_80065F0C(Player* player, UNUSED s8 arg1, s16 arg2, s8 arg3) { +void func_80065F0C(Player* player, UNUSED s8 playerIndex, s16 arg2, s8 arg3) { Vec3f spDC; Vec3s spD4; s16 primRed; @@ -5166,7 +5166,7 @@ void func_80065F0C(Player* player, UNUSED s8 arg1, s16 arg2, s8 arg3) { } } -void func_800664E0(Player* player, UNUSED s8 arg1, s16 arg2, s8 arg3) { +void func_800664E0(Player* player, UNUSED s8 playerIndex, s16 arg2, s8 arg3) { Vec3f sp54; Vec3s sp4C; s16 red; @@ -5827,31 +5827,31 @@ void func_8006A280(Player* player, UNUSED s8 arg1, s16 arg2, s8 arg3) { } } -void func_8006A50C(Player* player, f32 arg1, f32 arg2, s8 arg3, s8 arg4, s16 arg5) { +void init_balloon(Player* player, f32 arg1, f32 arg2, s8 playerIndex, s8 balloonIndex, s16 rotation) { f32 someX; f32 someY; f32 someZ; - gPlayerBalloonStatus[arg3][arg4] = 0; - D_8018D650[arg3][arg4] = 0.1f; - D_8018D6B0[arg3][arg4] = 0.0f; - D_8018D710[arg3][arg4] = 0.0f; - D_8018D770[arg3][arg4] = 0; - D_8018D7A0[arg3][arg4] = 0; - D_8018D7D0[arg3][arg4] = 0; - D_8018D800[arg3][arg4] = 5; - D_8018D830[arg3][arg4] = 1; - D_8018D620[arg3][arg4] = -player->rotation[1] - player->unk_0C0; + gPlayerBalloonStatus[playerIndex][balloonIndex] = BALLOON_STATUS_GONE; + D_8018D650[playerIndex][balloonIndex] = 0.1f; + D_8018D6B0[playerIndex][balloonIndex] = 0.0f; + D_8018D710[playerIndex][balloonIndex] = 0.0f; + D_8018D770[playerIndex][balloonIndex] = 0; + D_8018D7A0[playerIndex][balloonIndex] = 0; + D_8018D7D0[playerIndex][balloonIndex] = 0; + D_8018D800[playerIndex][balloonIndex] = 5; + D_8018D830[playerIndex][balloonIndex] = 1; + D_8018D620[playerIndex][balloonIndex] = -player->rotation[1] - player->unk_0C0; func_80062B18(&someX, &someY, &someZ, arg1, 4.0f, arg2 + -3.8, -player->rotation[1], 0); - D_8018D4D0[arg3][arg4] = player->pos[0] + someX; - D_8018D590[arg3][arg4] = player->pos[2] + someZ; - D_8018D530[arg3][arg4] = (player->pos[1] - player->boundingBoxSize) + someY; - gPlayerBalloonStatus[arg3][arg4] |= 1; - D_8018D860[arg3][arg4] = arg5; - D_8018D890[arg3][arg4] = 0; + gPlayerBalloonPosX[playerIndex][balloonIndex] = player->pos[0] + someX; + gPlayerBalloonPosZ[playerIndex][balloonIndex] = player->pos[2] + someZ; + gPlayerBalloonPosY[playerIndex][balloonIndex] = (player->pos[1] - player->boundingBoxSize) + someY; + gPlayerBalloonStatus[playerIndex][balloonIndex] |= BALLOON_STATUS_PRESENT; + gPlayerBalloonRotation[playerIndex][balloonIndex] = rotation; // Sprite rotation + D_8018D890[playerIndex][balloonIndex] = 0; } -void func_8006A7C0(Player* player, f32 arg1, f32 arg2, s8 arg3, s8 arg4) { +void func_8006A7C0(Player* player, f32 arg1, f32 arg2, s8 playerIndex, s8 balloonIndex) { f32 sp80[] = { 9.0f, 10.0f, 9.0f, 8.0f, 10.0f, 9.5f, 9.5f, 11.0f, }; @@ -5864,80 +5864,80 @@ void func_8006A7C0(Player* player, f32 arg1, f32 arg2, s8 arg3, s8 arg4) { UNUSED s32 stackPadding2; sp6C = (-(player->speed / 18.0f) * 216.0f) / 10.0f; - if ((gPlayerBalloonStatus[arg3][arg4] & 2) != 2) { - D_8018D650[arg3][arg4] += -0.003 + (-player->speed * 0.0006); - if (D_8018D650[arg3][arg4] >= 0.05) { - D_8018D650[arg3][arg4] = 0.05f; + if ((gPlayerBalloonStatus[playerIndex][balloonIndex] & BALLOON_STATUS_DEPARTING) != BALLOON_STATUS_DEPARTING) { + D_8018D650[playerIndex][balloonIndex] += -0.003 + (-player->speed * 0.0006); + if (D_8018D650[playerIndex][balloonIndex] >= 0.05) { + D_8018D650[playerIndex][balloonIndex] = 0.05f; } - if (D_8018D650[arg3][arg4] <= -0.05) { - D_8018D650[arg3][arg4] = -0.05f; + if (D_8018D650[playerIndex][balloonIndex] <= -0.05) { + D_8018D650[playerIndex][balloonIndex] = -0.05f; } - D_8018D6B0[arg3][arg4] += D_8018D650[arg3][arg4]; - if (D_8018D6B0[arg3][arg4] >= 0.06) { - D_8018D6B0[arg3][arg4] = 0.06f; + D_8018D6B0[playerIndex][balloonIndex] += D_8018D650[playerIndex][balloonIndex]; + if (D_8018D6B0[playerIndex][balloonIndex] >= 0.06) { + D_8018D6B0[playerIndex][balloonIndex] = 0.06f; } - if (D_8018D6B0[arg3][arg4] <= -0.06) { - D_8018D6B0[arg3][arg4] = -0.06f; + if (D_8018D6B0[playerIndex][balloonIndex] <= -0.06) { + D_8018D6B0[playerIndex][balloonIndex] = -0.06f; } - D_8018D710[arg3][arg4] += D_8018D6B0[arg3][arg4]; - if (D_8018D710[arg3][arg4] < 0.0f) { - D_8018D650[arg3][arg4] = random_int(0x000BU) / 10; - D_8018D6B0[arg3][arg4] = 0.0f; - D_8018D710[arg3][arg4] = 0.0f; + D_8018D710[playerIndex][balloonIndex] += D_8018D6B0[playerIndex][balloonIndex]; + if (D_8018D710[playerIndex][balloonIndex] < 0.0f) { + D_8018D650[playerIndex][balloonIndex] = random_int(0x000BU) / 10; + D_8018D6B0[playerIndex][balloonIndex] = 0.0f; + D_8018D710[playerIndex][balloonIndex] = 0.0f; } - D_8018D620[arg3][arg4] = -player->rotation[1] - player->unk_0C0; - move_s16_towards(&D_8018D890[arg3][arg4], player->speed * 182.0f, 0.1f); + D_8018D620[playerIndex][balloonIndex] = -player->rotation[1] - player->unk_0C0; + move_s16_towards(&D_8018D890[playerIndex][balloonIndex], player->speed * 182.0f, 0.1f); } - if (D_8018D830[arg3][arg4] == 1) { - D_8018D770[arg3][arg4] += D_8018D800[arg3][arg4] - player->speed; + if (D_8018D830[playerIndex][balloonIndex] == 1) { + D_8018D770[playerIndex][balloonIndex] += D_8018D800[playerIndex][balloonIndex] - player->speed; } else { - D_8018D770[arg3][arg4] += D_8018D800[arg3][arg4] + player->speed; + D_8018D770[playerIndex][balloonIndex] += D_8018D800[playerIndex][balloonIndex] + player->speed; } - if (D_8018D770[arg3][arg4] >= 0xB) { - D_8018D770[arg3][arg4] = 0x000B; + if (D_8018D770[playerIndex][balloonIndex] >= 0xB) { + D_8018D770[playerIndex][balloonIndex] = 0x000B; } - if (D_8018D770[arg3][arg4] < -0xA) { - D_8018D770[arg3][arg4] = -0x000B; + if (D_8018D770[playerIndex][balloonIndex] < -0xA) { + D_8018D770[playerIndex][balloonIndex] = -0x000B; } - D_8018D7A0[arg3][arg4] += D_8018D770[arg3][arg4]; - if (D_8018D7A0[arg3][arg4] >= 0x29) { - D_8018D7A0[arg3][arg4] = 0x0029; + D_8018D7A0[playerIndex][balloonIndex] += D_8018D770[playerIndex][balloonIndex]; + if (D_8018D7A0[playerIndex][balloonIndex] >= 0x29) { + D_8018D7A0[playerIndex][balloonIndex] = 0x0029; } - if (D_8018D7A0[arg3][arg4] < -0x28) { - D_8018D7A0[arg3][arg4] = -0x0029; + if (D_8018D7A0[playerIndex][balloonIndex] < -0x28) { + D_8018D7A0[playerIndex][balloonIndex] = -0x0029; } - D_8018D7D0[arg3][arg4] += D_8018D7A0[arg3][arg4]; - if (D_8018D7D0[arg3][arg4] >= 0x38E) { - D_8018D800[arg3][arg4] = -random_int(8U); - if (D_8018D830[arg3][arg4] != 1) { - D_8018D830[arg3][arg4] = 1; + D_8018D7D0[playerIndex][balloonIndex] += D_8018D7A0[playerIndex][balloonIndex]; + if (D_8018D7D0[playerIndex][balloonIndex] >= 0x38E) { + D_8018D800[playerIndex][balloonIndex] = -random_int(8U); + if (D_8018D830[playerIndex][balloonIndex] != 1) { + D_8018D830[playerIndex][balloonIndex] = 1; } } - if (D_8018D7D0[arg3][arg4] < -0x38D) { - D_8018D800[arg3][arg4] = random_int(8U); - if (D_8018D830[arg3][arg4] != -1) { - D_8018D830[arg3][arg4] = -1; + if (D_8018D7D0[playerIndex][balloonIndex] < -0x38D) { + D_8018D800[playerIndex][balloonIndex] = random_int(8U); + if (D_8018D830[playerIndex][balloonIndex] != -1) { + D_8018D830[playerIndex][balloonIndex] = -1; } } - func_80062B18(&someX, &someY, &someZ, arg1, sp80[player->characterId] - D_8018D710[arg3][arg4], - arg2 + -3.2 + (sp6C * 1), -D_8018D620[arg3][arg4], -player->unk_206 * 2); - if ((gPlayerBalloonStatus[arg3][arg4] & 2) != 2) { - D_8018D530[arg3][arg4] = (player->pos[1] - player->boundingBoxSize) + someY; - D_8018D4D0[arg3][arg4] = player->pos[0] + someX; - D_8018D590[arg3][arg4] = player->pos[2] + someZ; - D_8018D8D0[arg3][arg4] = 0; + func_80062B18(&someX, &someY, &someZ, arg1, sp80[player->characterId] - D_8018D710[playerIndex][balloonIndex], + arg2 + -3.2 + (sp6C * 1), -D_8018D620[playerIndex][balloonIndex], -player->unk_206 * 2); + if ((gPlayerBalloonStatus[playerIndex][balloonIndex] & BALLOON_STATUS_DEPARTING) != BALLOON_STATUS_DEPARTING) { + gPlayerBalloonPosY[playerIndex][balloonIndex] = (player->pos[1] - player->boundingBoxSize) + someY; + gPlayerBalloonPosX[playerIndex][balloonIndex] = player->pos[0] + someX; + gPlayerBalloonPosZ[playerIndex][balloonIndex] = player->pos[2] + someZ; + gPlayerBalloonDepartingTimer[playerIndex][balloonIndex] = 0; } else { - D_8018D530[arg3][arg4] += 0.2; - D_8018D8D0[arg3][arg4] += 1; - move_s16_towards(&D_8018D890[arg3][arg4], 0, 0.1f); - move_s16_towards(&D_8018D860[arg3][arg4], 0, 0.1f); - if (D_8018D8D0[arg3][arg4] >= 0x78) { - func_8006B974((s32) player, arg3, arg4); + gPlayerBalloonPosY[playerIndex][balloonIndex] += 0.2; // Balloon is departing, so it rises + gPlayerBalloonDepartingTimer[playerIndex][balloonIndex] += 1; // Increment the timer + move_s16_towards(&D_8018D890[playerIndex][balloonIndex], 0, 0.1f); + move_s16_towards(&gPlayerBalloonRotation[playerIndex][balloonIndex], 0, 0.1f); + if (gPlayerBalloonDepartingTimer[playerIndex][balloonIndex] >= 0x78) { // Gone after 120 frames + set_player_balloon_to_gone((s32) player, playerIndex, balloonIndex); } } } -void render_battle_balloon(Player* player, s8 arg1, s16 arg2, s8 arg3) { +void render_battle_balloon(Player* player, s8 playerIndex, s16 balloonIndex, s8 screenId) { Mat4 sp140; Vec3f sp134; Vec3s sp12C; @@ -5967,14 +5967,14 @@ void render_battle_balloon(Player* player, s8 arg1, s16 arg2, s8 arg3) { envRed = (envColors[player->characterId] >> 0x10) & 0xFF; envGreen = (envColors[player->characterId] >> 0x08) & 0xFF; envBlue = (envColors[player->characterId] >> 0x00) & 0xFF; - temp_t1 = (((player->unk_048[arg3] + player->rotation[1] + player->unk_0C0) & 0xFFFF) / 128); + temp_t1 = (((player->unk_048[screenId] + player->rotation[1] + player->unk_0C0) & 0xFFFF) / 128); temp_t1 <<= 7; - if (arg3 == arg1) { + if (screenId == playerIndex) { var_f20 = 0.3f; } else { // wut? - xdiff = (var_f20 = player->pos[0] - cameras[arg3].pos[0]); - zdiff = player->pos[2] - cameras[arg3].pos[2]; + xdiff = (var_f20 = player->pos[0] - cameras[screenId].pos[0]); + zdiff = player->pos[2] - cameras[screenId].pos[2]; if (gActiveScreenMode != 3) { var_f20 = sqrtf((xdiff * xdiff) + (zdiff * zdiff)) / 300.0f; } else { @@ -5987,13 +5987,13 @@ void render_battle_balloon(Player* player, s8 arg1, s16 arg2, s8 arg3) { var_f20 = 0.3f; } } - sp134[0] = D_8018D4D0[arg1][arg2]; - sp134[1] = D_8018D530[arg1][arg2]; - sp134[2] = D_8018D590[arg1][arg2]; - sp12C[0] = -((D_8018D890[arg1][arg2] * 4) * coss(temp_t1)); - sp12C[1] = player->unk_048[arg3]; - sp12C[2] = D_8018D7D0[arg1][arg2] - (D_8018D860[arg1][arg2] * coss(temp_t1)) - - ((D_8018D890[arg1][arg2] * 8) * sins(temp_t1)); + sp134[0] = gPlayerBalloonPosX[playerIndex][balloonIndex]; + sp134[1] = gPlayerBalloonPosY[playerIndex][balloonIndex]; + sp134[2] = gPlayerBalloonPosZ[playerIndex][balloonIndex]; + sp12C[0] = -((D_8018D890[playerIndex][balloonIndex] * 4) * coss(temp_t1)); + sp12C[1] = player->unk_048[screenId]; + sp12C[2] = D_8018D7D0[playerIndex][balloonIndex] - (gPlayerBalloonRotation[playerIndex][balloonIndex] * coss(temp_t1)) - + ((D_8018D890[playerIndex][balloonIndex] * 8) * sins(temp_t1)); mtxf_translate_rotate(sp140, sp134, sp12C); mtxf_scale2(sp140, var_f20); convert_to_fixed_point_matrix(&gGfxPool->mtxEffect[gMatrixEffectCount], sp140); @@ -6024,23 +6024,23 @@ void render_battle_balloon(Player* player, s8 arg1, s16 arg2, s8 arg3) { gMatrixEffectCount++; } -void func_8006B7E4(Player* player, s8 arg1) { - func_8006A50C(player, 0.0f, 0.0f, arg1, (s8) 0, (s16) 0); - func_8006A50C(player, 1.5f, 2.0f, arg1, (s8) 1, (s16) 0x1C70); - func_8006A50C(player, -1.5f, 2.0f, arg1, (s8) 2, (s16) -0x1C70); - gPlayerBalloonCount[arg1] = 2; +void init_all_player_balloons(Player* player, s8 playerIndex) { + init_balloon(player, 0.0f, 0.0f, playerIndex, (s8) 0, (s16) 0); + init_balloon(player, 1.5f, 2.0f, playerIndex, (s8) 1, (s16) 0x1C70); + init_balloon(player, -1.5f, 2.0f, playerIndex, (s8) 2, (s16) -0x1C70); + gPlayerBalloonCount[playerIndex] = 2; } -void func_8006B87C(UNUSED Player* player, s8 playerIndex) { +void clear_all_player_balloons(UNUSED Player* player, s8 playerIndex) { gPlayerBalloonStatus[playerIndex][0] = BALLOON_STATUS_GONE; gPlayerBalloonStatus[playerIndex][1] = BALLOON_STATUS_GONE; gPlayerBalloonStatus[playerIndex][2] = BALLOON_STATUS_GONE; } -void func_8006B8B4(Player* player, s8 playerIndex) { +void pop_player_balloon(Player* player, s8 playerIndex) { if (gPlayerBalloonCount[playerIndex] >= 0) { - gPlayerBalloonStatus[playerIndex][gPlayerBalloonCount[playerIndex]] &= ~1; - gPlayerBalloonStatus[playerIndex][gPlayerBalloonCount[playerIndex]] |= 2; + gPlayerBalloonStatus[playerIndex][gPlayerBalloonCount[playerIndex]] &= ~BALLOON_STATUS_PRESENT; + gPlayerBalloonStatus[playerIndex][gPlayerBalloonCount[playerIndex]] |= BALLOON_STATUS_DEPARTING; gPlayerBalloonCount[playerIndex]--; func_800C9060(playerIndex, SOUND_ARG_LOAD(0x19, 0x00, 0x90, 0x51)); if (gPlayerBalloonCount[playerIndex] < 0) { @@ -6049,36 +6049,36 @@ void func_8006B8B4(Player* player, s8 playerIndex) { } } -void func_8006B974(UNUSED s32 arg0, s8 playerIndex, s8 balloonIndex) { +void set_player_balloon_to_gone(UNUSED s32 arg0, s8 playerIndex, s8 balloonIndex) { if (gPlayerBalloonCount[playerIndex] >= 0) { gPlayerBalloonStatus[playerIndex][balloonIndex] = BALLOON_STATUS_GONE; } } -void func_8006B9CC(Player* player, s8 arg1) { - if (gPlayerBalloonStatus[arg1][0] != 0) { - func_8006A7C0(player, 0.0f, 0.0f, arg1, 0); +void func_8006B9CC(Player* player, s8 playerIndex) { + if (gPlayerBalloonStatus[playerIndex][0] != BALLOON_STATUS_GONE) { + func_8006A7C0(player, 0.0f, 0.0f, playerIndex, 0); } - if (gPlayerBalloonStatus[arg1][1] != 0) { + if (gPlayerBalloonStatus[playerIndex][1] != BALLOON_STATUS_GONE) { - func_8006A7C0(player, 1.8f, 2.6f, arg1, 1); + func_8006A7C0(player, 1.8f, 2.6f, playerIndex, 1); } - if (gPlayerBalloonStatus[arg1][2] != 0) { - func_8006A7C0(player, -1.8f, 2.6f, arg1, 2); + if (gPlayerBalloonStatus[playerIndex][2] != BALLOON_STATUS_GONE) { + func_8006A7C0(player, -1.8f, 2.6f, playerIndex, 2); } } -void func_8006BA94(Player* player, s8 playerIndex, s8 arg2) { +void render_remaining_battle_balloons(Player* player, s8 playerIndex, s8 screenId) { if (gPlayerBalloonStatus[playerIndex][0] != BALLOON_STATUS_GONE) { - render_battle_balloon(player, playerIndex, 0, arg2); + render_battle_balloon(player, playerIndex, 0, screenId); } if (gPlayerBalloonStatus[playerIndex][1] != BALLOON_STATUS_GONE) { - render_battle_balloon(player, playerIndex, 1, arg2); + render_battle_balloon(player, playerIndex, 1, screenId); } if (gPlayerBalloonStatus[playerIndex][2] != BALLOON_STATUS_GONE) { - render_battle_balloon(player, playerIndex, 2, arg2); + render_battle_balloon(player, playerIndex, 2, screenId); } } @@ -6281,7 +6281,7 @@ void func_8006C6AC(Player* player, s16 arg1, s8 arg2, s8 arg3) { } } -void func_8006C9B8(Player* player, s16 arg1, s8 arg2, s8 arg3) { +void func_8006C9B8(Player* player, s16 arg1, s8 playerIndex, s8 arg3) { UNUSED s32 stackPadding; s32 sp28; sp28 = arg1 - 1; @@ -6291,39 +6291,39 @@ void func_8006C9B8(Player* player, s16 arg1, s8 arg2, s8 arg3) { if (player->unk_258[30 + arg1].unk_01C == 1) { switch (player->unk_258[30 + arg1].unk_012) { case 1: - func_800644E8(player, arg1, arg2, arg3); + func_800644E8(player, arg1, playerIndex, arg3); break; case 2: - func_800649F4(player, arg1, arg2, arg3); + func_800649F4(player, arg1, playerIndex, arg3); break; case 3: - func_80064C74(player, arg1, arg2, arg3); + func_80064C74(player, arg1, playerIndex, arg3); break; case 4: - func_800647C8(player, arg1, arg2, arg3); + func_800647C8(player, arg1, playerIndex, arg3); break; case 5: - func_80064B30(player, arg1, arg2, arg3); + func_80064B30(player, arg1, playerIndex, arg3); break; case 6: - func_800648E4(player, arg1, arg2, arg3); + func_800648E4(player, arg1, playerIndex, arg3); break; case 7: - func_80064988(player, arg1, arg2, arg3); + func_80064988(player, arg1, playerIndex, arg3); break; case 8: - func_80064C74(player, arg1, arg2, arg3); + func_80064C74(player, arg1, playerIndex, arg3); break; case 9: - func_80064664(player, arg1, arg2, arg3); + func_80064664(player, arg1, playerIndex, arg3); break; default: @@ -6331,7 +6331,7 @@ void func_8006C9B8(Player* player, s16 arg1, s8 arg2, s8 arg3) { } } else { if (player->unk_044 & 0x1000) { - func_80061430(player, arg1, sp28, arg2, arg3); + func_80061430(player, arg1, sp28, playerIndex, arg3); player->unk_044 &= ~0x0100; return; } @@ -6339,47 +6339,47 @@ void func_8006C9B8(Player* player, s16 arg1, s8 arg2, s8 arg3) { ((player->unk_0E0 < 2) && (player->effects & UNKNOWN_EFFECT_0x1000000))) || ((player->unk_0E0 < 2) && (player->effects & HIT_BY_ITEM_EFFECT))) || (player->effects & 0x400)) { - func_8006199C(player, arg1, sp28, arg2, arg3); + func_8006199C(player, arg1, sp28, playerIndex, arg3); player->unk_046 &= ~0x0008; player->unk_044 &= ~0x0100; return; } if ((player->unk_0CA & 0x2000) == 0x2000) { - func_80061A34(player, arg1, sp28, arg2, arg3); + func_80061A34(player, arg1, sp28, playerIndex, arg3); player->unk_046 &= ~0x0008; player->unk_044 &= ~0x0100; return; } - if ((player->effects & STAR_EFFECT) && ((((s32) gCourseTimer) - D_8018D930[arg2]) < 9)) { - func_800615AC(player, arg1, sp28, arg2, arg3); + if ((player->effects & STAR_EFFECT) && ((((s32) gCourseTimer) - gPlayerStarEffectStartTime[playerIndex]) < STAR_EFFECT_DURATION - 1)) { + func_800615AC(player, arg1, sp28, playerIndex, arg3); player->unk_046 &= ~0x0008; player->unk_044 &= ~0x0100; return; } if ((player->unk_046 & 8) == 8) { - func_800612F8(player, arg1, sp28, arg2, arg3); + func_800612F8(player, arg1, sp28, playerIndex, arg3); player->unk_044 &= ~0x0100; return; } if (((player->unk_046 & 0x20) == 0x20) && (((player->speed / 18.0f) * 216.0f) >= 20.0f)) { - func_80061D4C(player, arg1, sp28, arg2, arg3); + func_80061D4C(player, arg1, sp28, playerIndex, arg3); player->unk_046 &= ~0x0008; player->unk_044 &= ~0x0100; return; } if ((player->effects & BOOST_EFFECT) && (player->type & PLAYER_HUMAN)) { - func_800621BC(player, arg1, sp28, arg2, arg3); + func_800621BC(player, arg1, sp28, playerIndex, arg3); return; } if (((player->effects & 0x200000) || (player->effects & BOOST_RAMP_ASPHALT_EFFECT)) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { - func_80061EF4(player, arg1, sp28, arg2, arg3); + func_80061EF4(player, arg1, sp28, playerIndex, arg3); player->unk_046 &= ~0x0008; player->unk_044 &= ~0x0100; return; } if ((player->unk_044 & 0x100) == 0x100) { - func_800624D8(player, arg1, sp28, arg2, arg3); + func_800624D8(player, arg1, sp28, playerIndex, arg3); player->unk_046 &= ~0x0008; } } @@ -6451,48 +6451,48 @@ void func_8006CEC0(Player* arg0, s16 arg1, s8 arg2, s8 arg3) { } } -void func_8006D194(Player* player, s8 arg1, s8 arg2) { +void func_8006D194(Player* player, s8 playerIndex, s8 arg2) { if (player->unk_258[0x14].unk_01C == 1) { switch (player->unk_258[0x14].unk_012) { case 2: - func_80064DEC(player, arg1, arg2, 0); + func_80064DEC(player, playerIndex, arg2, 0); break; case 3: - func_800650FC(player, arg1, arg2, 0); + func_800650FC(player, playerIndex, arg2, 0); break; case 4: - func_80064EA4(player, arg1, arg2, 0); + func_80064EA4(player, playerIndex, arg2, 0); break; case 5: - func_80064F88(player, arg1, arg2, 0); + func_80064F88(player, playerIndex, arg2, 0); break; case 6: - func_80065030(player, arg1, arg2, 0); + func_80065030(player, playerIndex, arg2, 0); break; } } else { if ((player->unk_0B6 & 0x40) == 0x40) { - func_800628C0(player, arg1, arg2, 0); + func_800628C0(player, playerIndex, arg2, 0); } if ((player->unk_0B6 & 0x800) == 0x800) { - func_80062968(player, arg1, arg2, 0); + func_80062968(player, playerIndex, arg2, 0); } if ((player->unk_0B6 & 0x1000) == 0x1000) { - func_80062914(player, arg1, arg2, 0); + func_80062914(player, playerIndex, arg2, 0); } if ((player->unk_0B6 & 0x80) == 0x80) { - func_80062A18(player, arg1, arg2, 0); + func_80062A18(player, playerIndex, arg2, 0); } if ((player->unk_0B6 & 0x100) == 0x100) { - func_800629BC(player, arg1, arg2, 0); + func_800629BC(player, playerIndex, arg2, 0); } } if (player->unk_258[0x15].unk_01C == 1) { if (player->unk_258[0x15].unk_012 == 5) { - func_800651F4(player, arg1, arg2, 1); + func_800651F4(player, playerIndex, arg2, 1); } } else if ((player->unk_0B6 & 0x20) == 0x20) { - func_80062AA8(player, arg1, arg2, 1); + func_80062AA8(player, playerIndex, arg2, 1); } } @@ -6623,19 +6623,19 @@ void func_8006D474(Player* player, s8 playerId, s8 screenId) { } } if ((gModeSelection == BATTLE) && (player->unk_002 & (2 << (screenId * 4)))) { - func_8006BA94(player, playerId, screenId); + render_remaining_battle_balloons(player, playerId, screenId); } } -void func_8006DC54(Player* player, s8 arg1, s8 arg2) { +void func_8006DC54(Player* player, s8 playerIndex, s8 screenId) { s16 i; s32 bitwiseMask; - bitwiseMask = 8 << (arg2 * 4); + bitwiseMask = 8 << (screenId * 4); if (bitwiseMask == (player->unk_002 & bitwiseMask)) { for (i = 0; i < 10; i++) { if (player->unk_258[i].unk_012 == 7) { - func_800658A0(player, arg1, i, arg2); + func_800658A0(player, playerIndex, i, screenId); } } } @@ -6781,24 +6781,25 @@ void func_8006E058(void) { } } -void func_8006E420(Player* player, s8 arg1, s8 arg2) { +void func_8006E420(Player* player, s8 playerIndex, s8 arg2) { + // arg2 is always 0 s16 temp_s0; if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) { if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - func_8006D194(player, arg1, arg2); + func_8006D194(player, playerIndex, arg2); } for (temp_s0 = 0; temp_s0 < 10; ++temp_s0) { - func_8006CEC0(player, temp_s0, arg1, arg2); + func_8006CEC0(player, temp_s0, playerIndex, arg2); if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) || (gGamestate == ENDING)) { - func_8006C9B8(player, temp_s0, arg1, arg2); + func_8006C9B8(player, temp_s0, playerIndex, arg2); } - func_8006C6AC(player, temp_s0, arg1, arg2); + func_8006C6AC(player, temp_s0, playerIndex, arg2); } if (gModeSelection == BATTLE) { - func_8006B9CC(player, arg1); + func_8006B9CC(player, playerIndex); } } } @@ -6816,42 +6817,42 @@ void render_kart_particle_on_screen_one(Player* player, s8 playerId, s8 screenId } } -void render_kart_particle_on_screen_two(Player* player, s8 arg1, s8 arg2) { +void render_kart_particle_on_screen_two(Player* player, s8 playerIndex, s8 screenId) { if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) { if ((player->effects & BOO_EFFECT) == BOO_EFFECT) { - if (arg1 == arg2) { - func_8006D474(player, arg1, arg2); + if (playerIndex == screenId) { + func_8006D474(player, playerIndex, screenId); } } else { - func_8006D474(player, arg1, arg2); + func_8006D474(player, playerIndex, screenId); } - func_8006DC54(player, arg1, arg2); + func_8006DC54(player, playerIndex, screenId); } } -void render_kart_particle_on_screen_three(Player* player, s8 arg1, s8 arg2) { +void render_kart_particle_on_screen_three(Player* player, s8 playerIndex, s8 screenId) { if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) { if ((player->effects & BOO_EFFECT) == BOO_EFFECT) { - if (arg1 == arg2) { - func_8006D474(player, arg1, arg2); + if (playerIndex == screenId) { + func_8006D474(player, playerIndex, screenId); } } else { - func_8006D474(player, arg1, arg2); + func_8006D474(player, playerIndex, screenId); } - func_8006DC54(player, arg1, arg2); + func_8006DC54(player, playerIndex, screenId); } } -void render_kart_particle_on_screen_four(Player* player, s8 arg1, s8 arg2) { +void render_kart_particle_on_screen_four(Player* player, s8 playerIndex, s8 screenId) { if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) { if ((player->effects & BOO_EFFECT) == BOO_EFFECT) { - if (arg1 == arg2) { - func_8006D474(player, arg1, arg2); + if (playerIndex == screenId) { + func_8006D474(player, playerIndex, screenId); } } else { - func_8006D474(player, arg1, arg2); + func_8006D474(player, playerIndex, screenId); } - func_8006DC54(player, arg1, arg2); + func_8006DC54(player, playerIndex, screenId); } } diff --git a/src/code_80057C60.h b/src/code_80057C60.h index 59392b910..5a4240f78 100644 --- a/src/code_80057C60.h +++ b/src/code_80057C60.h @@ -219,16 +219,16 @@ void func_80069DB8(Player*, s8, s16, s8); void func_8006A01C(Player*, s8, s16, s8); void func_8006A280(Player*, s8, s16, s8); -void func_8006A50C(Player*, f32, f32, s8, s8, s16); +void init_balloon(Player*, f32, f32, s8, s8, s16); void func_8006A7C0(Player*, f32, f32, s8, s8); void render_battle_balloon(Player*, s8, s16, s8); -void func_8006B7E4(Player*, s8); -void func_8006B87C(Player*, s8); -void func_8006B8B4(Player*, s8); -void func_8006B974(s32, s8, s8); +void init_all_player_balloons(Player*, s8); +void clear_all_player_balloons(Player*, s8); +void pop_player_balloon(Player*, s8); +void set_player_balloon_to_gone(s32, s8, s8); void func_8006B9CC(Player*, s8); -void func_8006BA94(Player*, s8, s8); +void render_remaining_battle_balloons(Player*, s8, s8); void render_balloon(Vec3f, f32, s16, s16); void func_8006C0C8(Vec3f, f32, s32, s16); @@ -627,9 +627,9 @@ extern u8* D_8018D4BC; extern u8* D_8018D4C0; extern u8* D_8018D4C4; extern u8* D_8018D4C8; -extern Vec3f D_8018D4D0[]; -extern Vec3f D_8018D530[]; -extern Vec3f D_8018D590[]; +extern Vec3f gPlayerBalloonPosX[]; +extern Vec3f gPlayerBalloonPosY[]; +extern Vec3f gPlayerBalloonPosZ[]; extern u16 gPlayerBalloonStatus[8][3]; extern Vec3s D_8018D620[]; extern Vec3f D_8018D650[]; @@ -642,10 +642,10 @@ extern Vec3s D_8018D7D0[]; extern Vec3s D_8018D800[]; extern Vec3s D_8018D830[]; -extern Vec3s D_8018D860[]; +extern Vec3s gPlayerBalloonRotation[]; // Sprite rotation for each player balloon extern Vec3s D_8018D890[]; extern s16 gPlayerBalloonCount[]; // D_8018D8C0 -extern Vec3s D_8018D8D0[]; +extern Vec3s gPlayerBalloonDepartingTimer[]; /** @endcond */ diff --git a/src/code_80057C60_var.c b/src/code_80057C60_var.c index a9b6559a6..7052d494c 100644 --- a/src/code_80057C60_var.c +++ b/src/code_80057C60_var.c @@ -213,9 +213,9 @@ u8* D_8018D4BC; u8* D_8018D4C0; u8* D_8018D4C4; u8* D_8018D4C8; -Vec3f D_8018D4D0[8]; -Vec3f D_8018D530[8]; -Vec3f D_8018D590[8]; +Vec3f gPlayerBalloonPosX[8]; +Vec3f gPlayerBalloonPosY[8]; +Vec3f gPlayerBalloonPosZ[8]; u16 gPlayerBalloonStatus[8][3]; Vec3s D_8018D620[8]; Vec3f D_8018D650[8]; @@ -227,7 +227,7 @@ Vec3s D_8018D7D0[8]; Vec3s D_8018D800[8]; Vec3s D_8018D830[8]; -Vec3s D_8018D860[8]; +Vec3s gPlayerBalloonRotation[8]; Vec3s D_8018D890[8]; s16 gPlayerBalloonCount[8]; -Vec3s D_8018D8D0[8]; +Vec3s gPlayerBalloonDepartingTimer[8]; diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index 68848af17..03073c1e3 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -382,7 +382,7 @@ void func_8006F8CC(void) { D_801657E8 = 1; D_80165800[0] = D_80165800[1] = 1; if (gPlayerCount == 4) { - if (gModeSelection != 3) { + if (gModeSelection != BATTLE) { D_801657E4 = 1; D_801657F0 = 1; D_801657F8 = 1; @@ -395,7 +395,7 @@ void func_8006F8CC(void) { D_801657E8 = 0; D_801657F8 = 1; } else if (gPlayerCount == 2) { - if (gModeSelection != (s32) 3) { + if (gModeSelection != (s32) BATTLE) { D_801657E4 = 1; D_801657F0 = 1; D_80165800[0] = D_80165800[1] = 0; @@ -441,7 +441,7 @@ void func_8006FA94(void) { switch (gPlayerCount) { case 1: - if (gModeSelection == 0) { + if (gModeSelection == GRAND_PRIX) { D_8018D114 = 0; D_8018D178 = 150; D_8018D180 = 240; @@ -452,13 +452,13 @@ void func_8006FA94(void) { } break; case 2: - if (gScreenModeSelection == 1) { - if (gModeSelection == 0) { + if (gScreenModeSelection == SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL) { + if (gModeSelection == GRAND_PRIX) { D_8018D114 = 2; D_8018D178 = 150; D_8018D180 = 240; D_8018D2AC = 60; - } else if (gModeSelection == 2) { + } else if (gModeSelection == VERSUS) { D_8018D114 = 3; D_8018D178 = 30; D_8018D180 = 30; @@ -469,16 +469,16 @@ void func_8006FA94(void) { D_8018D180 = 40; D_8018D2AC = 60; } - } else if (gModeSelection == 0) { + } else if (gModeSelection == GRAND_PRIX) { D_8018D114 = 5; - } else if (gModeSelection == 2) { + } else if (gModeSelection == VERSUS) { D_8018D114 = 6; } else { D_8018D114 = 7; } break; case 3: - if (gModeSelection == 2) { + if (gModeSelection == VERSUS) { D_8018D114 = 8; D_8018D178 = 0x00000064; D_8018D180 = 0x00000096; @@ -491,7 +491,7 @@ void func_8006FA94(void) { } break; case 4: - if (gModeSelection == 2) { + if (gModeSelection == VERSUS) { D_8018D114 = 0x0000000A; D_8018D178 = 0x0000001E; D_8018D180 = 0x0000001E; diff --git a/src/code_80086E70.c b/src/code_80086E70.c index 263ab0964..50619609a 100644 --- a/src/code_80086E70.c +++ b/src/code_80086E70.c @@ -1087,13 +1087,13 @@ void func_80089538(s32 objectIndex, s32 playerId, f32 arg2, f32 arg3, u32 soundB s32 func_800895E4(s32 objectIndex) { Player* player; - s32 var_s1; + s32 playerIndex; s32 var_s6; var_s6 = 0; player = gPlayerOne; if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { - for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++) { + for (playerIndex = 0; playerIndex < D_8018D158; playerIndex++, player++) { if ((gObjectList[objectIndex].state != 0) && (has_collided_horizontally_with_player(objectIndex, player) != 0)) { if (is_obj_flag_status_active(objectIndex, 0x04000000) != 0) { @@ -1108,11 +1108,11 @@ s32 func_800895E4(s32 objectIndex) { void func_800896D4(s32 objectIndex, f32 arg1, f32 arg2) { Player* player; - s32 var_s1; + s32 playerIndex; player = gPlayerOne; if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { - for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++) { + for (playerIndex = 0; playerIndex < D_8018D158; playerIndex++, player++) { if ((gObjectList[objectIndex].state != 0) && !(player->effects & (STAR_EFFECT | BOO_EFFECT)) && (has_collided_horizontally_with_player(objectIndex, player) != 0)) { func_8008933C(player, objectIndex, arg1, arg2 * 1.1); @@ -1126,12 +1126,12 @@ void func_800896D4(s32 objectIndex, f32 arg1, f32 arg2) { void func_80089820(s32 objectIndex, f32 arg1, f32 arg2, u32 arg3) { Player* player; - s32 var_s1; + s32 playerIndex; player = gPlayerOne; set_object_flag_status_false(objectIndex, 0x02000000); if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { - for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++) { + for (playerIndex = 0; playerIndex < D_8018D158; playerIndex++, player++) { if ((gObjectList[objectIndex].state != 0) && !(player->effects & BOO_EFFECT)) { if ((player->type & PLAYER_EXISTS) && !(player->type & PLAYER_INVISIBLE_OR_BOMB) && (has_collided_horizontally_with_player(objectIndex, player) != 0)) { @@ -1143,7 +1143,7 @@ void func_80089820(s32 objectIndex, f32 arg1, f32 arg2, u32 arg3) { } if ((func_8008933C(player, objectIndex, arg1, arg2 * 1.1) >= 4.0) && ((player->type & PLAYER_CPU) != PLAYER_CPU)) { - func_800C9060(var_s1, arg3); + func_800C9060(playerIndex, arg3); } } } @@ -1154,11 +1154,11 @@ void func_80089820(s32 objectIndex, f32 arg1, f32 arg2, u32 arg3) { void func_80089A04(s32 objectIndex, f32 arg1, f32 arg2) { Player* player; - s32 var_s1; + s32 playerIndex; player = gPlayerOne; if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { - for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++) { + for (playerIndex = 0; playerIndex < D_8018D158; playerIndex++, player++) { if ((gObjectList[objectIndex].state != 0) && !(player->effects & (BOO_EFFECT | STAR_EFFECT)) && (has_collided_with_player(objectIndex, player) != 0)) { func_8008933C(player, objectIndex, arg1, arg2 * 1.1); @@ -1173,14 +1173,14 @@ void func_80089A04(s32 objectIndex, f32 arg1, f32 arg2) { s32 func_80089B50(s32 objectIndex) { Player* player; s32 sp40; - s32 var_s1; + s32 playerIndex; s32 test; test = 0; sp40 = 0; player = gPlayerOne; if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { - for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++, test++) { + for (playerIndex = 0; playerIndex < D_8018D158; playerIndex++, player++, test++) { if ((gObjectList[objectIndex].state != 0) && !(player->effects & (BOO_EFFECT | UNKNOWN_EFFECT_0x1000000)) && (player->type & PLAYER_EXISTS) && !(player->type & PLAYER_INVISIBLE_OR_BOMB) && (has_collided_horizontally_with_player(objectIndex, player) != 0)) { @@ -1201,13 +1201,13 @@ s32 func_80089B50(s32 objectIndex) { s32 func_80089CBC(s32 objectIndex, f32 arg1) { Player* player; - s32 var_s1; + s32 playerIndex; s32 var_s7; var_s7 = 0; player = gPlayerOne; if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { - for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++) { + for (playerIndex = 0; playerIndex < D_8018D158; playerIndex++, player++) { if ((gObjectList[objectIndex].state != 0) && !(player->effects & (BOO_EFFECT | UNKNOWN_EFFECT_0x1000000))) { if ((player->type & PLAYER_EXISTS) && !(player->type & PLAYER_INVISIBLE_OR_BOMB) && (has_collided_with_player_and_within_height(objectIndex, player, arg1) != 0)) { @@ -1227,13 +1227,13 @@ s32 func_80089CBC(s32 objectIndex, f32 arg1) { s32 func_80089E18(s32 objectIndex) { Player* player; - s32 var_s1; + s32 playerIndex; s32 var_s6; var_s6 = 0; player = gPlayerOne; if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { - for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++) { + for (playerIndex = 0; playerIndex < D_8018D158; playerIndex++, player++) { if ((gObjectList[objectIndex].state != 0) && !(player->effects & 0x800000C0) && (has_collided_horizontally_with_player(objectIndex, player) != 0)) { if (player->effects & STAR_EFFECT) { @@ -1249,13 +1249,13 @@ s32 func_80089E18(s32 objectIndex) { s32 func_80089F24(s32 objectIndex) { Player* player; - s32 var_s1; + s32 playerIndex; s32 var_s7; var_s7 = 0; player = gPlayerOne; if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { - for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++) { + for (playerIndex = 0; playerIndex < D_8018D158; playerIndex++, player++) { if ((gObjectList[objectIndex].state != 0) && !(player->effects & 0x800002C0)) { if ((player->type & PLAYER_EXISTS) && !(player->type & PLAYER_INVISIBLE_OR_BOMB) && (has_collided_horizontally_with_player(objectIndex, player) != 0)) { diff --git a/src/cpu_vehicles_camera_path.c b/src/cpu_vehicles_camera_path.c index 07f8d8642..83d32524a 100644 --- a/src/cpu_vehicles_camera_path.c +++ b/src/cpu_vehicles_camera_path.c @@ -971,7 +971,7 @@ bool func_800088D8(s32 playerId, s16 arg1, s16 arg2) { D_80163128[playerId] = -1; D_80163150[playerId] = -1; - if (gModeSelection == 1) { + if (gModeSelection == TIME_TRIALS) { return 1; } if (arg1 < 0) { @@ -1053,7 +1053,7 @@ bool func_800088D8(s32 playerId, s16 arg1, s16 arg2) { var_v0++; } } - + var_a0_4 = 0; for (i = 0; i < gPlayerCount; i++) { if (gGPCurrentRaceRankByPlayerId[i] < arg2) { @@ -1064,7 +1064,7 @@ bool func_800088D8(s32 playerId, s16 arg1, s16 arg2) { // FAKE var_t1 = (arg2 - (var_v0 & 0xFFFF)) - var_a0_4; arg2 -= var_v0; - + if ((var_v0 > 0) || (var_a0_4 > 0)) { var_t1++; } @@ -1269,7 +1269,7 @@ void update_player_path_completion(s32 playerId, Player* player) { if ((var_v1 != 0) && (playerZ <= gPathStartZ)) { if (gPathStartZ < previousPlayerZ) { gLapCountByPlayerId[playerId]++; - if ((gModeSelection == 0) && (gLapCountByPlayerId[playerId] == 5)) { + if ((gModeSelection == GRAND_PRIX) && (gLapCountByPlayerId[playerId] == 5)) { if (gGPCurrentRaceRankByPlayerIdDup[playerId] == 7) { // clang-format off for (var_v0 = 0; var_v0 < NUM_PLAYERS; var_v0++) { gLapCountByPlayerId[var_v0]--; } // has to be one line to match @@ -1299,7 +1299,7 @@ void update_player_path_completion(s32 playerId, Player* player) { } if ((player->type & PLAYER_HUMAN) && !(player->type & PLAYER_CPU)) { detect_wrong_player_direction(playerId, player); - if ((gModeSelection == 0) && (gPlayerCount == 2) && (playerId == 0)) { + if ((gModeSelection == GRAND_PRIX) && (gPlayerCount == 2) && (playerId == 0)) { if (gGPCurrentRaceRankByPlayerIdDup[PLAYER_ONE] < gGPCurrentRaceRankByPlayerIdDup[PLAYER_TWO]) { gBestRankedHumanPlayer = PLAYER_ONE; } else { @@ -1824,7 +1824,7 @@ void func_8000B140(s32 playerId) { } } j = 0; - i = 0; + i = 0; while (i < 8) { if (i != playerId) { player = &gPlayers[i]; @@ -1844,7 +1844,7 @@ void func_8000B140(s32 playerId) { sp74[j] = temp_f2 - temp_f0_2; j++; } - + } } } @@ -1863,9 +1863,9 @@ void func_8000B140(s32 playerId) { for (i = 0; i < j; i++) { temp_f2 = gTrackPositionFactor[sp9C[i]]; if ((temp_f2 > (-1.0f)) && (temp_f2 < 1.0f)) { - + temp_f12 = temp_ft2 = ((0.2f * (20.0f / (spB0[i] + 20.0f))) * ((sp74[i]) + 10.0f)) / 20.0f; - + if ((var_f18 == 1.0f) && (var_f20 == (-1.0f))) { var_f18 = temp_f2 - temp_f12; var_f20 = temp_f2 + temp_f12; @@ -2904,7 +2904,7 @@ void func_80017054(Camera* camera, UNUSED Player* player, UNUSED s32 index, s32 camera->pos[0] = sp98; camera->pos[2] = sp90; camera->pos[1] = sp94 + 10.0; - + D_801645F8[cameraId] = sp98; D_80164618[cameraId] = sp94; D_80164638[cameraId] = sp90; @@ -3507,20 +3507,20 @@ void func_80019B50(s32 cameraIndex, u16 arg1) { D_801646C0[cameraIndex] = (s16) var_v0; } -void func_80019C50(s32 arg0) { - switch (D_80164678[arg0]) { +void func_80019C50(s32 playerIndex) { + switch (D_80164678[playerIndex]) { case 0: - if (D_80164608[arg0] == 1) { - D_80164678[arg0] = 1; - func_800C9060(arg0, SOUND_ARG_LOAD(0x19, 0x00, 0x90, 0x4F)); - D_80164670[arg0] = D_80164678[arg0]; + if (D_80164608[playerIndex] == 1) { + D_80164678[playerIndex] = 1; + func_800C9060(playerIndex, SOUND_ARG_LOAD(0x19, 0x00, 0x90, 0x4F)); + D_80164670[playerIndex] = D_80164678[playerIndex]; } break; case 1: - if (D_80164608[arg0] == 1) { - D_80164678[arg0] = 0; - func_800C9060(arg0, SOUND_ARG_LOAD(0x19, 0x00, 0x90, 0x50)); - D_80164670[arg0] = D_80164678[arg0]; + if (D_80164608[playerIndex] == 1) { + D_80164678[playerIndex] = 0; + func_800C9060(playerIndex, SOUND_ARG_LOAD(0x19, 0x00, 0x90, 0x50)); + D_80164670[playerIndex] = D_80164678[playerIndex]; } break; } @@ -3879,7 +3879,7 @@ void cpu_use_item_strategy(s32 playerId) { CpuItemStrategyData* cpuStrategy = &cpu_ItemStrategy[playerId]; TrackPathPoint* pathPoint; bool isValidBanana1; - bool isValidBanana2; + bool isValidBanana2; // Only used in this function #define BANANA_ACTOR(actor) ((struct BananaActor*)(actor)) diff --git a/src/cpu_vehicles_camera_path/behaviour_utils.inc.c b/src/cpu_vehicles_camera_path/behaviour_utils.inc.c index 015d96e48..1851bbb52 100644 --- a/src/cpu_vehicles_camera_path/behaviour_utils.inc.c +++ b/src/cpu_vehicles_camera_path/behaviour_utils.inc.c @@ -136,35 +136,35 @@ void cpu_behaviour(s32 playerIndex) { } } -void func_80011EC0(s32 arg0, Player* player, s32 arg2, UNUSED u16 arg3) { - if ((((player->speed / 18.0f) * 216.0f) >= 45.0f) && (D_801630E8[arg0] == 0)) { +void func_80011EC0(s32 playerIndex, Player* player, s32 arg2, UNUSED u16 arg3) { + if ((((player->speed / 18.0f) * 216.0f) >= 45.0f) && (D_801630E8[playerIndex] == 0)) { switch (gCurrentTrackSectionTypesPath[sSomeNearestPathPoint]) { case RIGHT_LEANING_CURVE: case RIGHT_CURVE: - if ((arg2 >= -9) && (D_80162FF8[arg0] == 0)) { - if ((gTrackPositionFactor[arg0] > -0.8) && (gTrackPositionFactor[arg0] < 0.5)) { + if ((arg2 >= -9) && (D_80162FF8[playerIndex] == 0)) { + if ((gTrackPositionFactor[playerIndex] > -0.8) && (gTrackPositionFactor[playerIndex] < 0.5)) { kart_hop(player); player->effects |= UNKNOWN_EFFECT_0x10; - D_801630E8[arg0] = 1; + D_801630E8[playerIndex] = 1; break; } } - D_801630E8[arg0] = 2; + D_801630E8[playerIndex] = 2; break; case LEFT_LEANING_CURVE: case LEFT_CURVE: - if ((arg2 < 0xA) && (D_80162FF8[arg0] == 0)) { - if ((gTrackPositionFactor[arg0] > -0.5) && (gTrackPositionFactor[arg0] < 0.8)) { + if ((arg2 < 0xA) && (D_80162FF8[playerIndex] == 0)) { + if ((gTrackPositionFactor[playerIndex] > -0.5) && (gTrackPositionFactor[playerIndex] < 0.8)) { kart_hop(player); player->effects |= UNKNOWN_EFFECT_0x10; - D_801630E8[arg0] = -1; + D_801630E8[playerIndex] = -1; break; } } - D_801630E8[arg0] = -2; + D_801630E8[playerIndex] = -2; break; } } else { - D_801630E8[arg0] = 3; + D_801630E8[playerIndex] = 3; } } diff --git a/src/cpu_vehicles_camera_path/cpu_speed_control.inc.c b/src/cpu_vehicles_camera_path/cpu_speed_control.inc.c index f7e92b6cd..2d5bfad1d 100644 --- a/src/cpu_vehicles_camera_path/cpu_speed_control.inc.c +++ b/src/cpu_vehicles_camera_path/cpu_speed_control.inc.c @@ -12,13 +12,13 @@ void func_80007D04(s32 playerId, Player* player) { if (val2 > 400 && val1 >= 6) { player->effects &= ~UNKNOWN_EFFECT_0x200000; - player_accelerate(player); + player_accelerate_alternative(player); D_801634C0[playerId] = 4; return; } } else { player->effects |= UNKNOWN_EFFECT_0x200000; - player_accelerate(player); + player_accelerate_alternative(player); D_801634C0[playerId] = 3; return; } @@ -64,19 +64,19 @@ void func_80007D04(s32 playerId, Player* player) { if (temp_t2 < temp_t1) { player->effects |= UNKNOWN_EFFECT_0x200000; - player_accelerate(player); + player_accelerate_alternative(player); D_801634C0[playerId] = 1; } else if (temp_t2 < (temp_t1 + var_v0 + 0x32)) { player->effects &= ~UNKNOWN_EFFECT_0x200000; - player_accelerate(player); + player_accelerate_alternative(player); D_801634C0[playerId] = 3; } else if (D_801631E0[playerId] == false) { player->effects &= ~UNKNOWN_EFFECT_0x200000; - player_accelerate(player); + player_accelerate_alternative(player); D_801634C0[playerId] = 2; } else { player->effects &= ~UNKNOWN_EFFECT_0x200000; - player_decelerate(player, 1.0f); + player_decelerate_alternative(player, 1.0f); D_801634C0[playerId] = -1; } } @@ -93,35 +93,35 @@ void func_80007FA4(s32 playerId, Player* player, f32 arg2) { if (playerId == 3) { if ((dist < 25.0f) && (D_80163410[playerId] < 5)) { D_80163410[playerId] = 4; - (arg2 < ((2.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : player_decelerate(player, 1.0f); + (arg2 < ((2.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : player_decelerate_alternative(player, 1.0f); } else if ((dist < 3600.0f) && (D_80163410[playerId] < 4)) { D_80163410[playerId] = 3; - (arg2 < ((5.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : player_decelerate(player, 5.0f); + (arg2 < ((5.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : player_decelerate_alternative(player, 5.0f); } else { - (arg2 < ((20.0 * 18.0) / 216.0)) ? func_80038BE4(player, 10) : player_decelerate(player, 1.0f); + (arg2 < ((20.0 * 18.0) / 216.0)) ? func_80038BE4(player, 10) : player_decelerate_alternative(player, 1.0f); } } else { if ((dist < 25.0f) && (D_80163410[playerId] < 5)) { D_80163410[playerId] = 4; test = 2; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : player_decelerate(player, 1.0f); + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : player_decelerate_alternative(player, 1.0f); } else if ((dist < 4900.0f) && (D_80163410[playerId] < 4)) { D_80163410[playerId] = 3; test = 5; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : player_decelerate(player, 15.0f); + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : player_decelerate_alternative(player, 15.0f); } else if ((dist < 22500.0f) && (D_80163410[playerId] < 3)) { D_80163410[playerId] = 2; test = 20; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 5) : player_decelerate(player, 1.0f); + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 5) : player_decelerate_alternative(player, 1.0f); } else if ((dist < 90000.0f) && (D_80163410[playerId] < 2)) { D_80163410[playerId] = 1; test = 30; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 6) : player_decelerate(player, 1.0f); + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 6) : player_decelerate_alternative(player, 1.0f); } else if (D_80163410[playerId] == 0) { test = 35; - (arg2 < (((test ^ 0) * 18.0) / 216.0)) ? func_80038BE4(player, 2) : player_decelerate(player, 1.0f); + (arg2 < (((test ^ 0) * 18.0) / 216.0)) ? func_80038BE4(player, 2) : player_decelerate_alternative(player, 1.0f); } else { - player_decelerate(player, 1.0f); + player_decelerate_alternative(player, 1.0f); } } } @@ -139,7 +139,7 @@ void regulate_cpu_speed(s32 playerId, f32 targetSpeed, Player* player) { if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { func_80007FA4(playerId, player, speed); } else if ((bStopAICrossing[playerId] == true) && !(player->effects & (STAR_EFFECT | BOO_EFFECT))) { - player_decelerate(player, 10.0f); + player_decelerate_alternative(player, 10.0f); if (player->currentSpeed == 0.0) { player->velocity[0] = 0.0f; player->velocity[2] = 0.0f; @@ -159,34 +159,34 @@ void regulate_cpu_speed(s32 playerId, f32 targetSpeed, Player* player) { } if (speed < var_f0) { player->effects &= ~UNKNOWN_EFFECT_0x200000; - player_accelerate(player); + player_accelerate_alternative(player); } else if (player->type & PLAYER_CINEMATIC_MODE) { if (speed < targetSpeed) { player->effects &= ~UNKNOWN_EFFECT_0x200000; - player_accelerate(player); + player_accelerate_alternative(player); } else { player->effects &= ~UNKNOWN_EFFECT_0x200000; - player_decelerate(player, 1.0f); + player_decelerate_alternative(player, 1.0f); } } else if ((D_801631E0[playerId] == true) && (D_80163330[playerId] != 1)) { if (func_800088D8(playerId, gLapCountByPlayerId[playerId], gGPCurrentRaceRankByPlayerIdDup[playerId]) == 1) { player->effects |= UNKNOWN_EFFECT_0x200000; - player_accelerate(player); + player_accelerate_alternative(player); } else { player->effects &= ~UNKNOWN_EFFECT_0x200000; - player_decelerate(player, 1.0f); + player_decelerate_alternative(player, 1.0f); } } else { var_a1 = 1; switch (gSpeedCPUBehaviour[playerId]) { /* switch 1; irregular */ case SPEED_CPU_BEHAVIOUR_FAST: /* switch 1 */ player->effects &= ~UNKNOWN_EFFECT_0x200000; - player_accelerate(player); + player_accelerate_alternative(player); break; case SPEED_CPU_BEHAVIOUR_MAX: /* switch 1 */ player->effects |= UNKNOWN_EFFECT_0x200000; - player_accelerate(player); + player_accelerate_alternative(player); break; case SPEED_CPU_BEHAVIOUR_SLOW: /* switch 1 */ if (((speed / 18.0f) * 216.0f) > 20.0f) { @@ -202,23 +202,23 @@ void regulate_cpu_speed(s32 playerId, f32 targetSpeed, Player* player) { if (var_a1 != 1) { if (speed < targetSpeed) { if ((gDemoMode == 1) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) { - player_accelerate(player); + player_accelerate_alternative(player); } else if (D_80163330[playerId] == 1) { func_80007D04(playerId, player); } else if (func_800088D8(playerId, gLapCountByPlayerId[playerId], gGPCurrentRaceRankByPlayerIdDup[playerId]) == true) { player->effects |= UNKNOWN_EFFECT_0x200000; - player_accelerate(player); + player_accelerate_alternative(player); } else { player->effects &= ~UNKNOWN_EFFECT_0x200000; - player_decelerate(player, 1.0f); + player_decelerate_alternative(player, 1.0f); } } else { player->effects &= ~UNKNOWN_EFFECT_0x200000; if (targetSpeed > 1.0f) { - player_decelerate(player, 2.0f); + player_decelerate_alternative(player, 2.0f); } else { - player_decelerate(player, 5.0f); + player_decelerate_alternative(player, 5.0f); } } } diff --git a/src/effects.c b/src/effects.c index 7ae37db98..77cfb9d05 100644 --- a/src/effects.c +++ b/src/effects.c @@ -21,8 +21,8 @@ s32 D_8018D900[8]; s16 D_8018D920[8]; -s32 D_8018D930[8]; -s32 D_8018D950[8]; +s32 gPlayerStarEffectStartTime[8]; +s32 gPlayerBooEffectStartTime[8]; s32 D_8018D970[8]; s32 D_8018D990[8]; @@ -143,20 +143,20 @@ void func_8008C310(Player* player) { UNUSED void func_unnamed34(void) { } -void clean_effect(Player* player, s8 arg1) { +void clean_effect(Player* player, s8 playerIndex) { if ((player->effects & 0x400) == 0x400) { - func_8008C6D0(player, arg1); + func_8008C6D0(player, playerIndex); } if (((player->effects & 0x80) == 0x80) || (player->effects & 0x40) == 0x40) { - func_8008C8C4(player, arg1); + func_8008C8C4(player, playerIndex); } if ((player->effects & 0x800) == 0x800) { - func_8008D0E4(player, arg1); + func_8008D0E4(player, playerIndex); } if ((player->unk_044 & 0x4000) != 0) { - func_8008D3B0(player, arg1); + func_8008D3B0(player, playerIndex); } if ((player->effects & BOOST_EFFECT) == BOOST_EFFECT) { remove_boost_effect(player); @@ -168,10 +168,10 @@ void clean_effect(Player* player, s8 arg1) { func_8008D97C(player); } if ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) { - func_8008E884(player, arg1); + func_8008E884(player, playerIndex); } if ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) { - remove_hit_by_item_effect(player, arg1); + remove_hit_by_item_effect(player, playerIndex); } if ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT) { remove_boost_ramp_asphalt_effect(player); @@ -183,19 +183,19 @@ void clean_effect(Player* player, s8 arg1) { func_8008F3E0(player); } if ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000) { - func_8008F5A4(player, arg1); + func_8008F5A4(player, playerIndex); } if ((player->effects & UNKNOWN_EFFECT_0x10000000) == UNKNOWN_EFFECT_0x10000000) { - func_8008FEDC(player, arg1); + func_8008FEDC(player, playerIndex); } player->unk_044 = (s16) (player->unk_044 & 0xFFFE); player->effects = (s32) (player->effects & ~0x20); } -void func_8008C528(Player* player, s8 arg1) { +void func_8008C528(Player* player, s8 playerIndex) { UNUSED s32 sp24; s32 temp_v1; - clean_effect(player, arg1); + clean_effect(player, playerIndex); func_8008C310(player); temp_v1 = player->characterId; player->unk_0C2 = 0; @@ -211,17 +211,17 @@ void func_8008C528(Player* player, s8 arg1) { player->unk_042 = 0; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - func_800C90F4(arg1, (temp_v1 * 0x10) + 0x29008005); - func_800C9060(arg1, SOUND_ACTION_EXPLOSION); + func_800C90F4(playerIndex, (temp_v1 * 0x10) + 0x29008005); + func_800C9060(playerIndex, SOUND_ACTION_EXPLOSION); } else { - play_cpu_sound_effect(arg1, player); + play_cpu_sound_effect(playerIndex, player); } player->soundEffects = (s32) (player->soundEffects & ~4); } -void func_8008C62C(Player* player, s8 arg1) { +void func_8008C62C(Player* player, s8 playerIndex) { - player_decelerate(player, 5.0f); + player_decelerate_alternative(player, 5.0f); player->unk_0A8 += (s16) 0xA0; player->unk_042 += (s16) 0x71C; if (player->unk_0A8 >= 0x2000) { @@ -229,15 +229,15 @@ void func_8008C62C(Player* player, s8 arg1) { player->unk_236 = (s16) (player->unk_236 - 1); if (player->unk_236 == 0) { player->unk_0A8 = 0x2000; - func_8008C6D0(player, arg1); + func_8008C6D0(player, playerIndex); if (gModeSelection == BATTLE) { - func_8006B8B4(player, arg1); + pop_player_balloon(player, playerIndex); } } } } -void func_8008C6D0(Player* player, s8 arg1) { +void func_8008C6D0(Player* player, s8 playerIndex) { player->unk_206 = 0; player->slopeAccel = 0; @@ -248,51 +248,51 @@ void func_8008C6D0(Player* player, s8 arg1) { player->unk_236 = 0; player->unk_078 = 0; player->currentSpeed = 0.0f; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; player->unk_042 = 0; } -void func_8008C73C(Player* player, s8 arg1) { - clean_effect(player, arg1); - if (((player->effects & 0x80) != 0x80) && ((player->effects & 0x40) != 0x40)) { - player->effects &= ~0x10; +void func_8008C73C(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); + if (((player->effects & UNKNOWN_EFFECT_0x80) != UNKNOWN_EFFECT_0x80) && ((player->effects & UNKNOWN_EFFECT_0x40) != UNKNOWN_EFFECT_0x40)) { + player->effects &= ~UNKNOWN_EFFECT_0x10; if ((player->unk_0C0 / 182) >= 0) { - player->effects |= 0x40; + player->effects |= UNKNOWN_EFFECT_0x40; } else { - player->effects |= 0x80; + player->effects |= UNKNOWN_EFFECT_0x80; } player->unk_0B6 |= 0x80; // clang-format off player->unk_0C0 = 0; player->unk_07C = 0; player->unk_078 = 0; player->unk_0AE = player->rotation[1]; player->unk_0B2 = 2; // clang-format on - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; - D_80165280[arg1] = player->currentSpeed; - gTimerBoostTripleACombo[arg1] = 0; - gIsPlayerTripleAButtonCombo[arg1] = false; - gCountASwitch[arg1] = 0; - gFrameSinceLastACombo[arg1] = 0; - D_8018D920[arg1] = 0; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; + gPlayerCurrentSpeed[playerIndex] = player->currentSpeed; + gTimerBoostTripleACombo[playerIndex] = 0; + gIsPlayerTripleAButtonCombo[playerIndex] = false; + gCountASwitch[playerIndex] = 0; + gFrameSinceLastACombo[playerIndex] = 0; + D_8018D920[playerIndex] = 0; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008003); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008003); } else { - play_cpu_sound_effect(arg1, player); + play_cpu_sound_effect(playerIndex, player); } } } void func_8008C8C4(Player* player, s8 playerId) { - player->effects &= ~0x80; - player->effects &= ~0x40; + player->effects &= ~UNKNOWN_EFFECT_0x80; + player->effects &= ~UNKNOWN_EFFECT_0x40; player->unk_0A8 = 0; player->rotation[1] = player->unk_0AE; player->unk_07C = 0; @@ -315,7 +315,7 @@ void func_8008C8C4(Player* player, s8 playerId) { } } -void func_8008C9EC(Player* player, s8 arg1) { +void func_8008C9EC(Player* player, s8 playerIndex) { s16 stackPadding1; s16 stackPadding2; s16 sp30[5] = { 1092, 1092, 2184, 1638, 1820 }; @@ -323,54 +323,54 @@ void func_8008C9EC(Player* player, s8 arg1) { player->unk_206 = 0; player->slopeAccel = 0; if ((player->unk_046 & 0x40) == 0x40) { - player_decelerate(player, 100.0f); + player_decelerate_alternative(player, 100.0f); } else { if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - player_decelerate(player, 1.0f); + player_decelerate_alternative(player, 1.0f); } else { - player_decelerate(player, 4.0f); + player_decelerate_alternative(player, 4.0f); } if (!(player->type & PLAYER_HUMAN)) { - player_decelerate(player, 30.0f); + player_decelerate_alternative(player, 30.0f); } } if ((player->effects & 0x80) == 0x80) { player->rotation[1] -= sp30[player->unk_0B2]; - D_8018D920[arg1] -= sp30[player->unk_0B2]; - stackPadding1 = (u16) D_8018D920[arg1] / (0x10000 / (0x168 / (sp30[player->unk_0B2] / 182))); + D_8018D920[playerIndex] -= sp30[player->unk_0B2]; + stackPadding1 = (u16) D_8018D920[playerIndex] / (0x10000 / (0x168 / (sp30[player->unk_0B2] / 182))); if (stackPadding1 == 0) { player->unk_0B2--; if (player->unk_0B2 <= 0) { if (gModeSelection == BATTLE) { - func_8006B8B4(player, arg1); + pop_player_balloon(player, playerIndex); } - func_8008C8C4(player, arg1); + func_8008C8C4(player, playerIndex); } } } else { player->rotation[1] += sp30[player->unk_0B2]; - D_8018D920[arg1] -= sp30[player->unk_0B2]; - stackPadding2 = (u16) D_8018D920[arg1] / (0x10000 / (0x168 / (sp30[player->unk_0B2] / 182))); + D_8018D920[playerIndex] -= sp30[player->unk_0B2]; + stackPadding2 = (u16) D_8018D920[playerIndex] / (0x10000 / (0x168 / (sp30[player->unk_0B2] / 182))); if (stackPadding2 == 0) { player->unk_0B2--; if (player->unk_0B2 <= 0) { - func_8008C8C4(player, arg1); + func_8008C8C4(player, playerIndex); if (gModeSelection == BATTLE) { - func_8006B8B4(player, arg1); + pop_player_balloon(player, playerIndex); } } } } - if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { - gTimerBoostTripleACombo[arg1] = 0x00000078; + if ((gIsPlayerTripleAButtonCombo[playerIndex] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + gTimerBoostTripleACombo[playerIndex] = 0x00000078; if (player->currentSpeed <= 90.0f) { player->currentSpeed = 90.0f; } } } -void func_8008CDC0(Player* player, s8 arg1) { - clean_effect(player, arg1); +void func_8008CDC0(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); player->soundEffects &= ~1; player->unk_0B4 = 0; @@ -381,13 +381,13 @@ void func_8008CDC0(Player* player, s8 arg1) { if (((player->unk_07C >> 0x10) >= 0x14) || ((player->unk_07C >> 0x10) < -0x13) || (((player->speed / 18.0f) * 216.0f) <= 30.0f) || ((player->effects & 8) != 0) || (((player->type & PLAYER_HUMAN) == 0) && ((player->effects & UNKNOWN_EFFECT_0x1000) == 0))) { - func_8008C73C(player, arg1); + func_8008C73C(player, playerIndex); } else { player->effects |= 0x800; } } -void func_8008CEB0(Player* player, s8 arg1) { +void func_8008CEB0(Player* player, s8 playerIndex) { f32 var_f0; s16 var_v1; s16 var_a3; @@ -408,13 +408,13 @@ void func_8008CEB0(Player* player, s8 arg1) { if (var_f0 <= 1.0f) { player->effects &= ~0x800; if ((player->effects & 0x40000) != 0x40000) { - func_8008C73C(player, arg1); + func_8008C73C(player, playerIndex); var_v1 = 0; } else { player->unk_0B6 |= 0x20; player->effects &= ~0x40000; if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008008); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008008); var_v1 = 0; } } @@ -432,17 +432,17 @@ void func_8008CEB0(Player* player, s8 arg1) { player->unk_0B4 = var_v1; player->unk_0AC = var_a3; if (player->effects & 8) { - func_8008C73C(player, arg1); + func_8008C73C(player, playerIndex); player->effects &= ~0x800; } } -void func_8008D0E4(Player* player, UNUSED s8 arg1) { +void func_8008D0E4(Player* player, UNUSED s8 playerIndex) { player->effects &= ~0x800; } -void func_8008D0FC(Player* player, s8 arg1) { - clean_effect(player, arg1); +void func_8008D0FC(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); player->soundEffects &= ~0x80; player->unk_0B4 = 0; @@ -452,7 +452,7 @@ void func_8008D0FC(Player* player, s8 arg1) { player->unk_044 |= 0x4000; } -void func_8008D170(Player* player, s8 arg1) { +void func_8008D170(Player* player, s8 playerIndex) { f32 var_f0; s16 var_v1; s16 var_a3; @@ -473,13 +473,13 @@ void func_8008D170(Player* player, s8 arg1) { if (var_f0 <= 1.3) { player->unk_044 &= ~0x4000; if ((player->effects & 0x40000) != 0x40000) { - func_8008C73C(player, arg1); + func_8008C73C(player, playerIndex); var_v1 = 0; } else { player->unk_0B6 |= 0x20; player->effects &= ~0x40000; if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008008); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008008); var_v1 = 0; } } @@ -497,18 +497,18 @@ void func_8008D170(Player* player, s8 arg1) { player->unk_0B4 = var_v1; player->unk_0AC = var_a3; if (player->effects & 8) { - func_8008C73C(player, arg1); + func_8008C73C(player, playerIndex); player->unk_044 &= ~0x4000; } } -void func_8008D3B0(Player* player, UNUSED s8 arg1) { +void func_8008D3B0(Player* player, UNUSED s8 playerIndex) { player->unk_044 &= 0xBFFF; } -void apply_boost_sound_effect(Player* player, s8 arg1) { +void apply_boost_sound_effect(Player* player, s8 playerIndex) { - clean_effect(player, arg1); + clean_effect(player, playerIndex); player->effects |= BOOST_EFFECT; player->soundEffects &= ~BOOST_SOUND_EFFECT; @@ -518,13 +518,13 @@ void apply_boost_sound_effect(Player* player, s8 arg1) { if (D_8015F890 != 1) { if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - func_800C9250(arg1); - func_800C9060(arg1, 0x1900A40B); + func_800C9250(playerIndex); + func_800C9060(playerIndex, 0x1900A40B); } } else { if (player == gPlayerOne) { - func_800C9250(arg1); - func_800C9060(arg1, 0x1900A40B); + func_800C9250(playerIndex); + func_800C9060(playerIndex, 0x1900A40B); } } @@ -553,8 +553,8 @@ void remove_boost_effect(Player* player) { player->boostPower = 0.0f; } -void func_8008D570(Player* player, s8 arg1) { - clean_effect(player, arg1); +void func_8008D570(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); player->unk_0AE = player->rotation[1]; player->effects |= 0x80000; @@ -567,20 +567,20 @@ void func_8008D570(Player* player, s8 arg1) { player->unk_0C0 = 0; player->unk_07C = 0; player->unk_078 = 0; - D_8018D920[arg1] = 0; + D_8018D920[playerIndex] = 0; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - func_800C9060(arg1, 0x19008002); + func_800C9060(playerIndex, 0x19008002); } if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x2900800C); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x2900800C); } } -void func_8008D698(Player* player, s8 arg1) { +void func_8008D698(Player* player, s8 playerIndex) { s16 temp; if (player->unk_0B2 == 0) { @@ -588,8 +588,8 @@ void func_8008D698(Player* player, s8 arg1) { temp = 0; } else { player->rotation[1] -= 1820; - D_8018D920[arg1] -= 1820; - temp = ((u16) D_8018D920[arg1] / 1820); + D_8018D920[playerIndex] -= 1820; + temp = ((u16) D_8018D920[playerIndex] / 1820); } if (temp == 0) { --player->unk_0B2; @@ -612,8 +612,8 @@ void func_8008D760(Player* player) { player->type &= 0xFF7F; } -void func_8008D7B0(Player* player, s8 arg1) { - clean_effect(player, arg1); +void func_8008D7B0(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); player->unk_0AE = player->rotation[1]; player->effects |= 0x800000; @@ -622,7 +622,7 @@ void func_8008D7B0(Player* player, s8 arg1) { player->kartHopJerk = D_800E3770[player->characterId]; player->kartHopAcceleration = 0.0f; player->kartHopVelocity = D_800E3750[player->characterId]; - D_8018D920[arg1] = 0; + D_8018D920[playerIndex] = 0; player->unk_0B2 = 4; player->unk_0C0 = 0; player->unk_07C = 0; @@ -630,11 +630,11 @@ void func_8008D7B0(Player* player, s8 arg1) { if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008003); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008003); } } -void func_8008D8B4(Player* player, s8 arg1) { +void func_8008D8B4(Player* player, s8 playerIndex) { s16 temp; if (player->unk_0B2 == 0) { @@ -642,8 +642,8 @@ void func_8008D8B4(Player* player, s8 arg1) { temp = 0; } else { player->rotation[1] -= 1820; - D_8018D920[arg1] -= 1820; - temp = ((u16) (D_8018D920[arg1]) / 1820); + D_8018D920[playerIndex] -= 1820; + temp = ((u16) (D_8018D920[playerIndex]) / 1820); } if (temp == 0) { --player->unk_0B2; @@ -687,19 +687,19 @@ void func_8008D9C0(Player* player) { } } -void apply_hit_sound_effect(Player* player, s8 arg1) { - clean_effect(player, arg1); +void apply_hit_sound_effect(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); if ((player->effects & HIT_EFFECT) == 0) { player->unk_DB4.unk2 = 0; player->unk_238 = 0; player->unk_DB4.unk10 = 4.5f; - D_8018D990[arg1] = 0; + D_8018D990[playerIndex] = 0; player->effects &= ~0x08000010; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; player->unk_D98 = 1; player->unk_D9C = 0.0f; player->unk_DA0 = 65.0f; @@ -709,17 +709,17 @@ void apply_hit_sound_effect(Player* player, s8 arg1) { } if (((player->type & PLAYER_HUMAN) != 0) && ((player->effects & HIT_EFFECT) == 0)) { - func_800C90F4(arg1, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x05)); + func_800C90F4(playerIndex, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x05)); } player->effects |= HIT_EFFECT; if (((player->type) & 0x1000) != 0) { - play_cpu_sound_effect(arg1, player); + play_cpu_sound_effect(playerIndex, player); } } } -void apply_hit_effect(Player* player, s8 arg1) { +void apply_hit_effect(Player* player, s8 playerIndex) { player->unk_0C2 = 0; player->unk_0A8 = 0; player->unk_07C = 0; @@ -727,10 +727,10 @@ void apply_hit_effect(Player* player, s8 arg1) { player->unk_08C = 0.0f; player->currentSpeed = 0.0f; // clang-format off - if ((player->collision.surfaceDistance[2] >= 600.0f) || ((player->effects & UNKNOWN_EFFECT_0x1000) != 0)) { D_8018D990[arg1] = 3; } // placed block on same line to match + if ((player->collision.surfaceDistance[2] >= 600.0f) || ((player->effects & UNKNOWN_EFFECT_0x1000) != 0)) { D_8018D990[playerIndex] = 3; } // placed block on same line to match // clang-format on - switch (D_8018D990[arg1]) { + switch (D_8018D990[playerIndex]) { case 0: player->unk_DB4.unk10 = 4.5f; if (player->unk_238 < 0x3D) { @@ -739,20 +739,20 @@ void apply_hit_effect(Player* player, s8 arg1) { if ((player->unk_046 & 0x80) != 0) { if ((player->soundEffects & 0x100) == 0) { - D_8018D990[arg1] = 1; + D_8018D990[playerIndex] = 1; player->unk_238 = 0; if ((player->type & PLAYER_HUMAN) != 0) { - func_800C9060(arg1, 0x1901904B); + func_800C9060(playerIndex, 0x1901904B); break; } } } else { ++player->unk_238; if (player->unk_238 >= 0x1E) { - D_8018D990[arg1] = 1; + D_8018D990[playerIndex] = 1; player->unk_238 = 0; if ((player->type & PLAYER_HUMAN) != 0) { - func_800C9060(arg1, 0x1901904B); + func_800C9060(playerIndex, 0x1901904B); break; } } @@ -767,12 +767,12 @@ void apply_hit_effect(Player* player, s8 arg1) { if ((player->unk_046 & 0x80) != 0) { if (player->unk_238 >= 0x32) { - D_8018D990[arg1] = 2; + D_8018D990[playerIndex] = 2; player->unk_238 = 0; player->unk_046 &= 0xFF7F; } } else if (player->unk_238 >= 0x50) { - D_8018D990[arg1] = 2; + D_8018D990[playerIndex] = 2; player->unk_238 = 0; } @@ -790,19 +790,19 @@ void apply_hit_effect(Player* player, s8 arg1) { case 2: ++player->unk_238; if (player->unk_238 >= 0x259) { - D_8018D990[arg1] = 3; + D_8018D990[playerIndex] = 3; player->unk_238 = 0; } if (player->collision.surfaceDistance[2] >= 600.0f) { - D_8018D990[arg1] = 3; + D_8018D990[playerIndex] = 3; } player->unk_DB4.unk10 = 4.5f; player->pos[1] -= 0.085; if ((player->effects & 8) != 8) { - D_8018D990[arg1] = 3; + D_8018D990[playerIndex] = 3; player->unk_238 = 0; } @@ -815,20 +815,20 @@ void apply_hit_effect(Player* player, s8 arg1) { player->effects |= 0x08000000; player->size = 1.0f; player->boundingBoxSize = gKartBoundingBoxSizeTable[player->characterId]; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; if ((player->type & PLAYER_HUMAN) != 0) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008008); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008008); } break; } } -void apply_hit_rotating_sound_effect(Player* player, s8 arg1) { - clean_effect(player, arg1); +void apply_hit_rotating_sound_effect(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); player->soundEffects &= ~HIT_ROTATING_SOUND_EFFECT; player->effects |= 0x40020000; @@ -836,32 +836,32 @@ void apply_hit_rotating_sound_effect(Player* player, s8 arg1) { player->unk_08C *= 0.6; player->unk_0B0 = 0; player->size = 1.0f; - D_8018D930[arg1] = gCourseTimer; + gPlayerStarEffectStartTime[playerIndex] = gCourseTimer; player->unk_0AE = player->rotation[1]; player->unk_0B2 = 2; player->unk_0C0 = 0; player->unk_07C = 0; player->unk_078 = 0; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; - D_8018D920[arg1] = 0; + D_8018D920[playerIndex] = 0; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008003); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008003); } else { - play_cpu_sound_effect(arg1, player); + play_cpu_sound_effect(playerIndex, player); } if (gModeSelection == BATTLE) { - func_8006B8B4(player, arg1); + pop_player_balloon(player, playerIndex); } } -void apply_lightning_effect(Player* player, s8 arg1) { +void apply_lightning_effect(Player* player, s8 playerIndex) { s16 test; if (((player->effects & 0x8000) == 0x8000) && ((player->effects & HIT_EFFECT) != HIT_EFFECT)) { player->effects &= ~0x20000; @@ -869,16 +869,16 @@ void apply_lightning_effect(Player* player, s8 arg1) { player->unk_07C = 0; player->unk_0C0 = 0; player->rotation[1] = player->unk_0AE; - remove_lightning_effect(player, arg1); - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; - apply_hit_sound_effect(player, arg1); + remove_lightning_effect(player, playerIndex); + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; + apply_hit_sound_effect(player, playerIndex); } else if ((player->effects & 0x20000) == 0x20000) { player->rotation[1] -= 0x5B0; - D_8018D920[arg1] -= 0x5B0; - test = (u16) D_8018D920[arg1] / 1456; + D_8018D920[playerIndex] -= 0x5B0; + test = (u16) D_8018D920[playerIndex] / 1456; if (test == 0) { player->unk_0B2--; if (player->unk_0B2 <= 0) { @@ -887,33 +887,33 @@ void apply_lightning_effect(Player* player, s8 arg1) { player->unk_07C = 0; player->unk_0C0 = 0; player->rotation[1] = player->unk_0AE; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; } } - player_decelerate(player, 1.0f); + player_decelerate_alternative(player, 1.0f); } else { player->unk_0B0 += 1; player->unk_08C = (f32) ((f64) player->unk_08C * 0.6); if ((player->unk_0B0 == 1) && (player->type & PLAYER_HUMAN)) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008005); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008005); } if ((player->unk_0B0 >= 0) && (player->unk_0B0 < 0x1CC)) { move_f32_towards(&player->size, 0.7f, 0.1f); move_f32_towards(&player->boundingBoxSize, (f32) ((f64) gKartBoundingBoxSizeTable[player->characterId] * 0.9), 0.1f); } else { - remove_lightning_effect(player, arg1); + remove_lightning_effect(player, playerIndex); if (player->type & PLAYER_HUMAN) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008008); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008008); } } } } -void remove_lightning_effect(Player* player, UNUSED s8 arg1) { +void remove_lightning_effect(Player* player, UNUSED s8 playerIndex) { move_f32_towards(&player->size, 1.0f, 0.1f); move_f32_towards(&player->boundingBoxSize, gKartBoundingBoxSizeTable[player->characterId], 0.1f); @@ -931,7 +931,7 @@ void remove_lightning_effect(Player* player, UNUSED s8 arg1) { player->effects &= ~0x20000; } -void func_8008E4A4(Player* player, s8 arg1) { +void func_8008E4A4(Player* player, s8 playerIndex) { player->unk_206 = 0; player->slopeAccel = 0; player->unk_0C0 = 0; @@ -952,18 +952,18 @@ void func_8008E4A4(Player* player, s8 arg1) { player->effects &= ~UNKNOWN_EFFECT_0x1000000; player->unk_0A8 = 0; player->unk_236 = 0; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; player->unk_042 = 0; player->type &= ~0x80; - if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[playerIndex] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } if (gModeSelection == BATTLE) { - func_8006B8B4(player, arg1); + pop_player_balloon(player, playerIndex); } } else { player->unk_0A8 += 0x80; @@ -973,16 +973,16 @@ void func_8008E4A4(Player* player, s8 arg1) { if (player->unk_236 == 0) { player->effects &= ~UNKNOWN_EFFECT_0x1000000; player->unk_236 = 0; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; player->unk_042 = 0; if (gModeSelection == BATTLE) { - func_8006B8B4(player, arg1); + pop_player_balloon(player, playerIndex); } - if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[playerIndex] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } @@ -992,8 +992,8 @@ void func_8008E4A4(Player* player, s8 arg1) { } } -void apply_reverse_sound_effect(Player* player, s8 arg1) { - clean_effect(player, arg1); +void apply_reverse_sound_effect(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); func_8008C310(player); player->unk_0A8 = 0; @@ -1011,40 +1011,40 @@ void apply_reverse_sound_effect(Player* player, s8 arg1) { if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { if (((gModeSelection == VERSUS) && ((player->type & PLAYER_CPU) != 0)) && (!gDemoMode)) { - func_800CA24C(arg1); + func_800CA24C(playerIndex); } if (1) {} - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008005); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008005); if (((gModeSelection == VERSUS) && ((player->type & PLAYER_CPU) != 0)) && (!gDemoMode)) { - func_800CA24C(arg1); + func_800CA24C(playerIndex); } - func_800C9060(arg1, SOUND_ACTION_EXPLOSION); + func_800C9060(playerIndex, SOUND_ACTION_EXPLOSION); } else { - play_cpu_sound_effect(arg1, player); + play_cpu_sound_effect(playerIndex, player); } player->soundEffects &= ~(REVERSE_SOUND_EFFECT | 0x80000); player->unk_0B6 |= 0x40; - gTimerBoostTripleACombo[arg1] = 0; - gIsPlayerTripleAButtonCombo[arg1] = false; - gCountASwitch[arg1] = 0; - gFrameSinceLastACombo[arg1] = 0; + gTimerBoostTripleACombo[playerIndex] = 0; + gIsPlayerTripleAButtonCombo[playerIndex] = false; + gCountASwitch[playerIndex] = 0; + gFrameSinceLastACombo[playerIndex] = 0; } -void func_8008E884(Player* player, s8 arg1) { +void func_8008E884(Player* player, s8 playerIndex) { player->effects &= ~UNKNOWN_EFFECT_0x1000000; player->unk_0A8 = 0; player->unk_236 = 0; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; player->unk_042 = 0; } -void apply_hit_by_item_effect(Player* player, s8 arg1) { +void apply_hit_by_item_effect(Player* player, s8 playerIndex) { player->unk_206 = 0; player->slopeAccel = 0; player->unk_0C0 = 0; @@ -1063,18 +1063,18 @@ void apply_hit_by_item_effect(Player* player, s8 arg1) { player->effects &= ~HIT_BY_ITEM_EFFECT; player->unk_0A8 = 0; player->unk_236 = 0; - D_80165190[3][arg1] = 1; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; + D_80165190[3][playerIndex] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; player->unk_042 = 0; - if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[playerIndex] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } if (gModeSelection == BATTLE) { - func_8006B8B4(player, arg1); + pop_player_balloon(player, playerIndex); } } else { player->unk_0A8 = (s16) (player->unk_0A8 + 0x90); @@ -1084,25 +1084,25 @@ void apply_hit_by_item_effect(Player* player, s8 arg1) { if (player->unk_236 == 0) { player->effects &= ~HIT_BY_ITEM_EFFECT; player->unk_236 = 0; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; player->unk_042 = 0; - if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[playerIndex] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } if (gModeSelection == BATTLE) { - func_8006B8B4(player, arg1); + pop_player_balloon(player, playerIndex); } } } } } -void apply_hit_by_item_sound_effect(Player* player, s8 arg1) { - clean_effect(player, arg1); +void apply_hit_by_item_sound_effect(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); func_8008C310(player); player->unk_0A8 = 0; @@ -1118,30 +1118,30 @@ void apply_hit_by_item_sound_effect(Player* player, s8 arg1) { if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008005); - func_800C9060(arg1, SOUND_ACTION_EXPLOSION); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008005); + func_800C9060(playerIndex, SOUND_ACTION_EXPLOSION); } else { - play_cpu_sound_effect(arg1, player); + play_cpu_sound_effect(playerIndex, player); } player->effects |= HIT_BY_ITEM_EFFECT; player->unk_0B6 |= 0x40; player->soundEffects &= ~0x01000002; - gTimerBoostTripleACombo[arg1] = 0; - gIsPlayerTripleAButtonCombo[arg1] = false; - gCountASwitch[arg1] = 0; - gFrameSinceLastACombo[arg1] = 0; + gTimerBoostTripleACombo[playerIndex] = 0; + gIsPlayerTripleAButtonCombo[playerIndex] = false; + gCountASwitch[playerIndex] = 0; + gFrameSinceLastACombo[playerIndex] = 0; } -void remove_hit_by_item_effect(Player* player, s8 arg1) { +void remove_hit_by_item_effect(Player* player, s8 playerIndex) { player->effects &= ~HIT_BY_ITEM_EFFECT; player->unk_0A8 = 0; player->unk_236 = 0; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; player->unk_042 = 0; } @@ -1235,8 +1235,8 @@ void remove_boost_ramp_wood_effect(Player* player) { player->boostPower = 0.0f; } -void func_8008F104(Player* player, s8 arg1) { - clean_effect(player, arg1); +void func_8008F104(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); player->unk_0AE = player->rotation[1]; player->unk_0B2 = 2; @@ -1244,11 +1244,11 @@ void func_8008F104(Player* player, s8 arg1) { player->unk_07C = 0; player->effects |= 0x4000; player->unk_078 = 0; - D_8018D920[arg1] = -0x8000; + D_8018D920[playerIndex] = -0x8000; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008003); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008003); } } @@ -1322,7 +1322,7 @@ void func_8008F3F4(Player* player, UNUSED s8 arg1) { } } -void func_8008F494(Player* player, s8 arg1) { +void func_8008F494(Player* player, s8 playerIndex) { if ((((player->effects & UNKNOWN_EFFECT_0x80) != 0) || ((player->effects & UNKNOWN_EFFECT_0x40) != 0) || ((player->effects & UNKNOWN_EFFECT_0x1000000)) || ((player->effects & HIT_BY_ITEM_EFFECT)) || ((player->effects & 0x400) != 0)) && @@ -1330,8 +1330,8 @@ void func_8008F494(Player* player, s8 arg1) { player->unk_044 |= 0x8000; } - clean_effect(player, arg1); - func_8008F86C(player, arg1); + clean_effect(player, playerIndex); + func_8008F86C(player, playerIndex); player->unk_0A8 = 0; player->effects |= UNKNOWN_EFFECT_0x10000; @@ -1341,14 +1341,14 @@ void func_8008F494(Player* player, s8 arg1) { if (((player->type & PLAYER_HUMAN) != 0) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) == 0) && ((player->unk_0CA & 2) == 0) && ((player->unk_0DE & 1) == 0) && ((player->unk_0DE & 2) == 0)) { - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008004); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008004); } } -void func_8008F5A4(Player* player, s8 arg1) { +void func_8008F5A4(Player* player, s8 playerIndex) { if ((player->unk_044 & 0x8000) != 0) { - func_8006B8B4(player, arg1); + pop_player_balloon(player, playerIndex); player->unk_044 &= ~0x8000; } @@ -1362,103 +1362,103 @@ void func_8008F5A4(Player* player, s8 arg1) { player->unk_078 = 0; player->currentSpeed = 0.0f; - D_80165190[0][arg1] = 1; - D_80165190[1][arg1] = 1; - D_80165190[2][arg1] = 1; - D_80165190[3][arg1] = 1; + D_80165190[0][playerIndex] = 1; + D_80165190[1][playerIndex] = 1; + D_80165190[2][playerIndex] = 1; + D_80165190[3][playerIndex] = 1; player->unk_042 = 0; } -void apply_star_effect(Player* player, s8 arg1) { - if (((s32) gCourseTimer - D_8018D930[arg1]) >= 9) { - D_8018D900[arg1] = 1; +void apply_star_effect(Player* player, s8 playerIndex) { + if (((s32) gCourseTimer - gPlayerStarEffectStartTime[playerIndex]) >= STAR_EFFECT_DURATION - 1) { + D_8018D900[playerIndex] = 1; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - if (D_8018D900[arg1] == 1) { - func_800CA730(arg1); - D_8018D900[arg1] = 0; + if (D_8018D900[playerIndex] == 1) { + func_800CA730(playerIndex); + D_8018D900[playerIndex] = 0; } - } else if (D_8018D900[arg1] == 1) { - func_800CAACC((u8) arg1); - D_8018D900[arg1] = 0; + } else if (D_8018D900[playerIndex] == 1) { + func_800CAACC((u8) playerIndex); + D_8018D900[playerIndex] = 0; } } - if (((s32) gCourseTimer - D_8018D930[arg1]) >= 0xA) { + if (((s32) gCourseTimer - gPlayerStarEffectStartTime[playerIndex]) >= STAR_EFFECT_DURATION) { player->effects &= ~STAR_EFFECT; } } // Star item -void apply_star_sound_effect(Player* player, s8 arg1) { - clean_effect(player, arg1); +void apply_star_sound_effect(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); player->effects |= STAR_EFFECT; player->soundEffects &= ~STAR_SOUND_EFFECT; - D_8018D930[arg1] = gCourseTimer; - D_8018D900[arg1] = 1; + gPlayerStarEffectStartTime[playerIndex] = gCourseTimer; + D_8018D900[playerIndex] = 1; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - if (D_8018D900[arg1] == 1) { - func_800CA59C(arg1); - D_8018D900[arg1] = 2; + if (D_8018D900[playerIndex] == 1) { + func_800CA59C(playerIndex); + D_8018D900[playerIndex] = 2; } // This may be in charge of ending the star sound. Still unknown though. - } else if (D_8018D900[arg1] == 1) { - func_800CA984(arg1); - D_8018D900[arg1] = 2; + } else if (D_8018D900[playerIndex] == 1) { + func_800CA984(playerIndex); + D_8018D900[playerIndex] = 2; } } -void func_8008F86C(Player* player, s8 arg1) { +void func_8008F86C(Player* player, s8 playerIndex) { player->effects &= ~STAR_EFFECT; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - func_800CA730(arg1); + func_800CA730(playerIndex); return; } - func_800CAACC(arg1); + func_800CAACC(playerIndex); } -void apply_boo_effect(Player* arg0, s8 arg1) { - s32 tmp; - tmp = ((s32) gCourseTimer) - D_8018D950[arg1]; - if (tmp < 7) { +void apply_boo_effect(Player* arg0, s8 playerIndex) { + s32 time_elapsed; + time_elapsed = ((s32) gCourseTimer) - gPlayerBooEffectStartTime[playerIndex]; + if (time_elapsed < 7) { arg0->unk_0C6 -= 2; if (arg0->unk_0C6 < 0x61) { arg0->unk_0C6 = 0x60; } - D_8018D970[arg1] -= 2; - if (D_8018D970[arg1] <= 0) { - D_8018D970[arg1] = 0; + D_8018D970[playerIndex] -= 2; + if (D_8018D970[playerIndex] <= 0) { + D_8018D970[playerIndex] = 0; } } else { arg0->unk_0C6 += 4; if (arg0->unk_0C6 >= 0xF0) { arg0->unk_0C6 = 0xFF; - D_8018D970[arg1] = 0xFF; + D_8018D970[playerIndex] = 0xFF; arg0->effects &= ~0x80000000; if ((arg0->type & 0x4000) != 0) { - func_800CB064(arg1); + func_800CB064(playerIndex); } } - D_8018D970[arg1] += 8; - if (D_8018D970[arg1] >= 0xF0) { - D_8018D970[arg1] = 0xFF; + D_8018D970[playerIndex] += 8; + if (D_8018D970[playerIndex] >= 0xF0) { + D_8018D970[playerIndex] = 0xFF; arg0->unk_0C6 = 0xFF; arg0->effects &= ~0x80000000; if ((arg0->type & 0x4000) != 0) { - func_800CB064(arg1); + 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) { @@ -1471,15 +1471,15 @@ 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; + D_8018D970[playerIndex] = 0xFF; if ((player->type & PLAYER_HUMAN) != 0) { - func_800CAFC0(arg1); + func_800CAFC0(playerIndex); } } @@ -1562,8 +1562,8 @@ void func_8008FDA8(Player* player, UNUSED s8 arg1) { } } -void func_8008FDF4(Player* player, UNUSED s8 arg1) { - clean_effect(player, arg1); +void func_8008FDF4(Player* player, s8 playerIndex) { + clean_effect(player, playerIndex); player->effects &= ~0x10; player->kartHopJerk = D_800E37F0[player->characterId]; @@ -1573,7 +1573,7 @@ void func_8008FDF4(Player* player, UNUSED s8 arg1) { player->effects |= UNKNOWN_EFFECT_0x10000000; } -void func_8008FE84(Player* player, UNUSED s8 arg1) { +void func_8008FE84(Player* player, UNUSED s8 playerIndex) { player->effects &= ~0x10; if ((player->effects & 8) != 8) { player->effects &= ~UNKNOWN_EFFECT_0x10000000; @@ -1582,7 +1582,7 @@ void func_8008FE84(Player* player, UNUSED s8 arg1) { } } -void func_8008FEDC(Player* player, UNUSED s8 arg1) { +void func_8008FEDC(Player* player, UNUSED s8 playerIndex) { player->effects &= ~UNKNOWN_EFFECT_0x10000000; player->kartHopJerk = 0.0f; player->kartHopVelocity = 0.0f; @@ -1936,7 +1936,7 @@ void func_80090970(Player* player, s8 playerId, s8 arg2) { func_800C9018(playerId, SOUND_ARG_LOAD(0x01, 0x00, 0xFA, 0x28)); } if (gModeSelection == BATTLE) { - func_8006B8B4(player, playerId); + pop_player_balloon(player, playerId); } player->unk_0CA &= ~0x0002; player->unk_0DE &= ~0x0004; diff --git a/src/effects.h b/src/effects.h index 8ade7f3cb..bcf854298 100644 --- a/src/effects.h +++ b/src/effects.h @@ -125,8 +125,8 @@ void func_800CB064(u8); extern s32 D_8018D900[]; extern s16 D_8018D920[]; -extern s32 D_8018D930[]; -extern s32 D_8018D950[]; +extern s32 gPlayerStarEffectStartTime[]; +extern s32 gPlayerBooEffectStartTime[]; extern s32 D_8018D970[]; extern s32 D_8018D990[]; @@ -141,7 +141,7 @@ extern f32 D_800E3790[]; extern f32 D_800E37D0[]; extern f32 D_800E37F0[]; extern s16 D_80165190[4][8]; -extern f32 D_80165280[]; +extern f32 gPlayerCurrentSpeed[]; extern s32 gFrameSinceLastACombo[]; #endif diff --git a/src/main.c b/src/main.c index 230947899..25d052f4d 100644 --- a/src/main.c +++ b/src/main.c @@ -603,7 +603,7 @@ void race_logic_loop(void) { } func_802909F0(); evaluate_collision_for_players_and_actors(); - func_800382DC(); + handle_a_press_for_all_players_during_race(); func_8001EE98(gPlayerOneCopy, camera1, 0); func_80028F70(); func_8028F474(); @@ -665,7 +665,7 @@ void race_logic_loop(void) { } func_802909F0(); evaluate_collision_for_players_and_actors(); - func_800382DC(); + handle_a_press_for_all_players_during_race(); func_8001EE98(gPlayerOneCopy, camera1, 0); func_80029060(); func_8001EE98(gPlayerTwoCopy, camera2, 1); @@ -711,7 +711,7 @@ void race_logic_loop(void) { } func_802909F0(); evaluate_collision_for_players_and_actors(); - func_800382DC(); + handle_a_press_for_all_players_during_race(); func_8001EE98(gPlayerOneCopy, camera1, 0); func_80029060(); func_8001EE98(gPlayerTwoCopy, camera2, 1); @@ -779,7 +779,7 @@ void race_logic_loop(void) { } func_802909F0(); evaluate_collision_for_players_and_actors(); - func_800382DC(); + handle_a_press_for_all_players_during_race(); func_8001EE98(gPlayerOneCopy, camera1, 0); func_80029158(); func_8001EE98(gPlayerTwo, camera2, 1); diff --git a/src/menu_items.c b/src/menu_items.c index 23d883bd9..b9b21d99a 100644 --- a/src/menu_items.c +++ b/src/menu_items.c @@ -10924,12 +10924,12 @@ void func_800ACC50(MenuItem* arg0) { void func_800ACF40(MenuItem* arg0) { Unk_D_800E70A0* temp_v0_2; - s32 temp_a2; + s32 somePlayerIndex; s32 temp_a1; s32 var_v1; UNUSED s32 stackPadding0; - temp_a2 = arg0->type - 0xB1; + somePlayerIndex = arg0->type - 0xB1; temp_a1 = D_800EFD64[gCharacterSelections[arg0->type - 0xB1]]; switch (arg0->state) { case 0: @@ -10938,7 +10938,7 @@ void func_800ACF40(MenuItem* arg0) { arg0->state = 1; break; case 1: - temp_v0_2 = &D_800E7300[((gPlayerCount - 2) * 4) + temp_a2]; + temp_v0_2 = &D_800E7300[((gPlayerCount - 2) * 4) + somePlayerIndex]; func_800A9208(arg0, temp_v0_2->column); func_800A9278(arg0, temp_v0_2->row); if (arg0->column == temp_v0_2->column) { @@ -10950,12 +10950,12 @@ void func_800ACF40(MenuItem* arg0) { var_v1 = 0; switch (gModeSelection) { case 2: - if (gGPCurrentRaceRankByPlayerId[temp_a2] != 0) { + if (gGPCurrentRaceRankByPlayerId[somePlayerIndex] != 0) { var_v1 = 1; } break; case 3: - if (temp_a2 != gPlayerWinningIndex) { + if (somePlayerIndex != gPlayerWinningIndex) { var_v1 = 1; } break; @@ -10964,18 +10964,18 @@ void func_800ACF40(MenuItem* arg0) { arg0->param2++; if (arg0->param2 >= 0x1F) { if (find_menu_items_dupe(0x000000B0)->state >= 2) { - func_8009A640(arg0->D_8018DEE0_index, 0, temp_a2, + func_8009A640(arg0->D_8018DEE0_index, 0, somePlayerIndex, segmented_to_virtual_dupe_2(gCharacterCelebrateAnimation[temp_a1])); arg0->state = 3; - func_800CA24C(temp_a2); - func_800C90F4(temp_a2, (gCharacterSelections[temp_a2] * 0x10) + 0x29008007); + func_800CA24C(somePlayerIndex); + func_800C90F4(somePlayerIndex, (gCharacterSelections[somePlayerIndex] * 0x10) + 0x29008007); } } } break; case 3: if (D_8018DEE0[arg0->D_8018DEE0_index].sequenceIndex >= D_800E8440[temp_a1]) { - func_8009A640(arg0->D_8018DEE0_index, 0, temp_a2, segmented_to_virtual_dupe_2(D_800E83A0[temp_a1])); + func_8009A640(arg0->D_8018DEE0_index, 0, somePlayerIndex, segmented_to_virtual_dupe_2(D_800E83A0[temp_a1])); arg0->state = 4; } break; diff --git a/src/player_controller.c b/src/player_controller.c index 6d379c932..c5d5282c1 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -1083,18 +1083,18 @@ void func_8002A5F4(Vec3f arg0, f32 arg1, Vec3f arg2, f32 arg3, f32 arg4) { } } -void func_8002A704(Player* player, s8 arg1) { +void func_8002A704(Player* player, s8 playerIndex) { player->effects |= BOOST_EFFECT; player->soundEffects &= ~0x02000000; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800C90F4(0U, (player->characterId * 0x10) + 0x29008001); - func_800C9060(arg1, 0x1900A40BU); + func_800C9060(playerIndex, 0x1900A40BU); } player->boostTimer = 0x0050; } -void func_8002A79C(Player* player, s8 arg1) { +void func_8002A79C(Player* player, s8 playerIndex) { if (((player->effects & UNKNOWN_EFFECT_0x100) != UNKNOWN_EFFECT_0x100) && ((player->effects & UNKNOWN_EFFECT_0x10) != UNKNOWN_EFFECT_0x10) && (player->unk_22A >= 2)) { player->effects |= UNKNOWN_EFFECT_0x100; @@ -1103,10 +1103,10 @@ void func_8002A79C(Player* player, s8 arg1) { player->unk_228 = 0; if (D_8015F890 != 1) { if ((player->type & PLAYER_HUMAN) && !(player->type & PLAYER_INVISIBLE_OR_BOMB)) { - func_800C9250(arg1); + func_800C9250(playerIndex); } } else if (player == gPlayerOne) { - func_800C9250(arg1); + func_800C9250(playerIndex); } } else if ((player->effects & UNKNOWN_EFFECT_0x100) == UNKNOWN_EFFECT_0x100) { player->unk_23A += 1; @@ -1119,14 +1119,14 @@ void func_8002A79C(Player* player, s8 arg1) { } } -void func_8002A8A4(Player* player, s8 arg1) { +void func_8002A8A4(Player* player, s8 playerIndex) { if (((s16) player->unk_0C0 / 182) > 0) { if (((s32) player->unk_07C >> 0x10) < -9) { if (player->unk_228 < 0x65) { player->unk_228++; } if ((player->unk_228 == 0x0064) && (player->type & PLAYER_HUMAN)) { - func_800C9060(arg1, 0x1900851EU); + func_800C9060(playerIndex, 0x1900851EU); } } else { if ((player->unk_228 >= 0x12) && (player->unk_228 < 0x64)) { @@ -1146,7 +1146,7 @@ void func_8002A8A4(Player* player, s8 arg1) { player->unk_228++; } if ((player->unk_228 == 0x0064) && (player->type & PLAYER_HUMAN)) { - func_800C9060(arg1, 0x1900851EU); + func_800C9060(playerIndex, 0x1900851EU); } } else { if ((player->unk_228 >= 0x12) && (player->unk_228 < 0x64)) { @@ -1519,7 +1519,7 @@ UNUSED void func_8002B8A4(Player* player_one, Player* player_two) { // clang-format on } -void func_8002B9CC(Player* player, s8 arg1, UNUSED s32 arg2) { +void func_8002B9CC(Player* player, s8 playerIndex, UNUSED s32 arg2) { f32 temp_f0; f32 temp_f2; f32 temp_f14; @@ -1527,25 +1527,25 @@ void func_8002B9CC(Player* player, s8 arg1, UNUSED s32 arg2) { s16 temp2; if ((player->unk_046 & 2) == 2) { - temp_f0 = D_8018CE10[arg1].unk_04[0]; + temp_f0 = D_8018CE10[playerIndex].unk_04[0]; temp_f2 = 0; - temp_f14 = D_8018CE10[arg1].unk_04[2]; + temp_f14 = D_8018CE10[playerIndex].unk_04[2]; if (sqrtf((temp_f0 * temp_f0) + (temp_f2 * temp_f2) + (temp_f14 * temp_f14)) >= 6.5) { player->unk_08C /= 4; player->currentSpeed /= 4; if (!(player->effects & 0x80) && !(player->effects & 0x40)) { - func_8008C73C(player, arg1); + func_8008C73C(player, playerIndex); } } } 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 = D_80165070[playerIndex][0] - player->velocity[0]; + temp_f2 = D_80165070[playerIndex][1] - player->velocity[1]; + temp_f14 = D_80165070[playerIndex][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; if (!(player->effects & 0x80) && !(player->effects & 0x40)) { - func_8008C73C(player, arg1); + func_8008C73C(player, playerIndex); } } temp = (-(s16) get_angle_between_points(player->pos, &player->oldPos[0])); @@ -1647,7 +1647,7 @@ void func_8002BD58(Player* player) { } } -void func_8002BF4C(Player* player, s8 arg1) { +void func_8002BF4C(Player* player, s8 playerIndex) { UNUSED s32 pad[3]; UNUSED s32 uselessAssignment; s32 i; @@ -1679,11 +1679,11 @@ void func_8002BF4C(Player* player, s8 arg1) { player->effects |= 0x200000; if ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB) { uselessAssignment = player->type & PLAYER_INVISIBLE_OR_BOMB; - func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008001); + func_800C90F4(playerIndex, (player->characterId * 0x10) + 0x29008001); } if ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB) { uselessAssignment = var_a2; - func_800C9060(arg1, 0x19008011); + func_800C9060(playerIndex, 0x19008011); } } break; @@ -1767,29 +1767,29 @@ void func_8002C17C(Player* player, s8 playerId) { } } -void func_8002C4F8(Player* player, s8 arg1) { - D_801652A0[arg1] = func_802AAB4C(player); - if (player->pos[1] <= D_801652A0[arg1]) { +void func_8002C4F8(Player* player, s8 playerIndex) { + D_801652A0[playerIndex] = func_802AAB4C(player); + if (player->pos[1] <= D_801652A0[playerIndex]) { player->unk_0DE |= 0x0002; } else { player->unk_0DE &= ~0x0002; } - if (player->boundingBoxSize < (D_801652A0[arg1] - player->pos[1])) { + if (player->boundingBoxSize < (D_801652A0[playerIndex] - player->pos[1])) { player->unk_0DE |= 1; player->unk_0DE &= ~0x0002; } else { player->unk_0DE &= ~0x0001; } - if (player->boundingBoxSize < (D_801652A0[arg1] - player->pos[1])) { + if (player->boundingBoxSize < (D_801652A0[playerIndex] - player->pos[1])) { if ((player->unk_0DE & 4) != 4) { player->unk_0DE |= 8; player->unk_0DE |= 4; if ((gCurrentCourseId != COURSE_KOOPA_BEACH) && (gCurrentCourseId != COURSE_SKYSCRAPER) && (gCurrentCourseId != COURSE_RAINBOW_ROAD) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { if ((gCurrentCourseId == COURSE_BOWSER_CASTLE) || (gCurrentCourseId == COURSE_BIG_DONUT)) { - func_800C9060((u8) arg1, 0x1900801CU); + func_800C9060((u8) playerIndex, 0x1900801CU); } else { - func_800C9060((u8) arg1, 0x19008008U); + func_800C9060((u8) playerIndex, 0x19008008U); } } } @@ -1798,7 +1798,7 @@ void func_8002C4F8(Player* player, s8 arg1) { (gCurrentCourseId == COURSE_RAINBOW_ROAD)) { player->unk_0DE &= ~0x000C; } - if ((player->boundingBoxSize < (D_801652A0[arg1] - player->pos[1])) && + if ((player->boundingBoxSize < (D_801652A0[playerIndex] - player->pos[1])) && (player->collision.surfaceDistance[2] >= 600.0f)) { player->unk_0CA |= 1; } @@ -1817,14 +1817,14 @@ void func_8002C4F8(Player* player, s8 arg1) { func_80090778(player); func_80090868(player); } - func_8002C17C(player, arg1); + func_8002C17C(player, playerIndex); } -void func_8002C7E4(Player* player, s8 arg1, s8 arg2) { +void func_8002C7E4(Player* player, s8 playerIndex, s8 arg2) { if ((player->unk_046 & 1) != 1) { if ((player->effects & 0x8000) == 0x8000) { if ((player->effects & BOOST_EFFECT) != BOOST_EFFECT) { - func_8002B9CC(player, arg1, arg2); + func_8002B9CC(player, playerIndex, arg2); } player->unk_044 &= ~0x0001; player->unk_046 |= 1; @@ -1891,7 +1891,7 @@ void func_8002C954(Player* player, s8 playerId, Vec3f arg2) { player->unk_256 = 0; } if ((player->slopeAccel >= 0) && (((player->speed / 18.0f) * 216.0f) > 5.0f)) { - player_decelerate(player, 18.0f); + player_decelerate_alternative(player, 18.0f); } if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { xdist = D_80165070[playerId][0] - arg2[0]; @@ -1920,15 +1920,15 @@ void func_8002C954(Player* player, s8 playerId, Vec3f arg2) { } } -void apply_effect(Player* player, s8 arg1, s8 arg2) { +void apply_effect(Player* player, s8 playerIndex, s8 arg2) { if (((player->unk_0CA & 2) == 2) || ((player->unk_0CA & 8) == 8)) { - func_80090970(player, arg1, arg2); + func_80090970(player, playerIndex, arg2); } if ((player->effects & 0x800) == 0x800) { - func_8008CEB0(player, arg1); + func_8008CEB0(player, playerIndex); } if (player->unk_044 & 0x4000) { - func_8008D170(player, arg1); + func_8008D170(player, playerIndex); } if ((player->effects & BOOST_EFFECT) == BOOST_EFFECT) { apply_boost_effect(player); @@ -1940,59 +1940,59 @@ void apply_effect(Player* player, s8 arg1, s8 arg2) { apply_boost_ramp_wood_effect(player); } if ((s32) (player->effects & HIT_EFFECT) == HIT_EFFECT) { - apply_hit_effect(player, arg1); + apply_hit_effect(player, playerIndex); } if ((player->effects & LIGHTNING_EFFECT) == LIGHTNING_EFFECT) { - apply_lightning_effect(player, arg1); + apply_lightning_effect(player, playerIndex); } if ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000) { - func_8008F3F4(player, arg1); + func_8008F3F4(player, playerIndex); } if ((player->effects & STAR_EFFECT) == STAR_EFFECT) { - apply_star_effect(player, arg1); + apply_star_effect(player, playerIndex); } if ((player->effects & BOO_EFFECT) == BOO_EFFECT) { - apply_boo_effect(player, arg1); + apply_boo_effect(player, playerIndex); } if (((player->effects & 0x20000000) == 0x20000000) && (player->unk_228 >= 0x64)) { - player_decelerate(player, 4.0f); + player_decelerate_alternative(player, 4.0f); } if (((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40)) { - func_8008C9EC(player, arg1); + func_8008C9EC(player, playerIndex); } if ((player->effects & 0x400) == 0x400) { - func_8008C62C(player, arg1); + func_8008C62C(player, playerIndex); } if ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) { - func_8008E4A4(player, arg1); + func_8008E4A4(player, playerIndex); } if ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) { - apply_hit_by_item_effect(player, arg1); + apply_hit_by_item_effect(player, playerIndex); } if ((player->effects & 0x4000) == 0x4000) { - func_8008F1B8(player, arg1); + func_8008F1B8(player, playerIndex); } if ((player->effects & 0x80000) == 0x80000) { - func_8008D698(player, arg1); + func_8008D698(player, playerIndex); } if ((player->effects & 0x800000) == 0x800000) { - func_8008D8B4(player, arg1); - player_decelerate(player, 10.0f); + func_8008D8B4(player, playerIndex); + player_decelerate_alternative(player, 10.0f); } if (D_800DC510 != 5) { if (player->soundEffects & 0x04000000) { - func_8008FC64(player, arg1); + func_8008FC64(player, playerIndex); } if (player->soundEffects & 0x08000000) { - func_8008FCDC(player, arg1); + func_8008FCDC(player, playerIndex); } } if (player->unk_044 & 0x800) { - func_80091298(player, arg1); + func_80091298(player, playerIndex); } } -void func_8002D028(Player* player, s8 arg1) { +void func_8002D028(Player* player, s8 playerIndex) { Vec3f sp4C; f32 temp_f18; s16 temp_t1; @@ -2001,9 +2001,9 @@ void func_8002D028(Player* player, s8 arg1) { f32 thing0; UNUSED s32 pad; - sp4C[0] = D_80165210[D_80165270[arg1]]; + sp4C[0] = D_80165210[D_80165270[playerIndex]]; sp4C[1] = 0; - sp4C[2] = D_80165230[D_80165270[arg1]]; + sp4C[2] = D_80165230[D_80165270[playerIndex]]; temp = -(s16) get_angle_between_points(player->pos, sp4C); temp2 = player->rotation[1]; @@ -2018,9 +2018,9 @@ void func_8002D028(Player* player, s8 arg1) { temp = (-thing0 * 182); } - temp_t1 = (D_80165020[arg1] + ((s16) ((temp * 0x35) / (thing0 * 182)))) / 2; + temp_t1 = (D_80165020[playerIndex] + ((s16) ((temp * 0x35) / (thing0 * 182)))) / 2; apply_cpu_turn(player, (s16) temp_t1); - D_80165020[arg1] = (s16) temp_t1; + D_80165020[playerIndex] = (s16) temp_t1; temp_f18 = sqrtf((sp4C[0] - player->pos[0]) * (sp4C[0] - player->pos[0]) + (sp4C[2] - player->pos[2]) * (sp4C[2] - player->pos[2])); @@ -2556,13 +2556,13 @@ void func_8002E594(Player* player, UNUSED Camera* camera, s8 screenId, s8 player if (sp74 < 0.0f) { func_8003F734(player, sp48, sp54, &sp74, &spD0, &spCC, &spC8); func_8002C954(player, playerId, sp54); - player_decelerate(player, 6.0f); + player_decelerate_alternative(player, 6.0f); } sp74 = player->collision.surfaceDistance[1]; if (sp74 < 0.0f) { func_8003FBAC(player, sp48, sp54, &sp74, &spD0, &spCC, &spC8); func_8002C954(player, playerId, sp54); - player_decelerate(player, 6.0f); + player_decelerate_alternative(player, 6.0f); } sp74 = player->collision.surfaceDistance[0]; if (sp74 >= 0.0f) { @@ -2811,7 +2811,7 @@ void func_8002F730(Player* player, UNUSED Camera* camera, UNUSED s8 screenId, s8 } } -void func_8002FCA8(Player* player, s8 arg1) { +void func_8002FCA8(Player* player, s8 playerIndex) { f32 var_f0; f32 var_f12; s32 temp_lo; @@ -2832,7 +2832,7 @@ void func_8002FCA8(Player* player, s8 arg1) { var_f0 += D_800E2AB0[player->characterId][player->tyres[FRONT_LEFT].surfaceType]; } } - if (D_801652C0[arg1] & 4) { + if (D_801652C0[playerIndex] & 4) { var_v1 = 2; } else { var_v1 = 0; @@ -2902,7 +2902,7 @@ void func_8002FE84(Player* player, f32 arg1) { } } -f32 func_80030150(Player* player, s8 arg1) { +f32 func_80030150(Player* player, s8 playerIndex) { f32 var_f0; s16 temp_lo; f32 var_f2; @@ -2977,8 +2977,8 @@ f32 func_80030150(Player* player, s8 arg1) { if ((player->unk_0DE & 2) == 2) { var_f0 += 0.15; } - if (((D_801652A0[arg1] - player->tyres[BACK_LEFT].baseHeight) >= 3.5) || - ((D_801652A0[arg1] - player->tyres[BACK_RIGHT].baseHeight) >= 3.5)) { + if (((D_801652A0[playerIndex] - player->tyres[BACK_LEFT].baseHeight) >= 3.5) || + ((D_801652A0[playerIndex] - player->tyres[BACK_RIGHT].baseHeight) >= 3.5)) { var_f0 += 0.05; } } @@ -3211,7 +3211,7 @@ void detect_triple_a_combo_a_pressed(Player* player) { } } -void player_accelerate(Player* player) { +void player_accelerate_alternative(Player* player) { s32 player_index; player_index = get_player_index_for_player(player); @@ -3324,7 +3324,7 @@ void player_accelerate(Player* player) { } } -void player_decelerate(Player* player, f32 speed) { +void player_decelerate_alternative(Player* player, f32 speed) { s32 player_index; player_index = get_player_index_for_player(player); @@ -3471,39 +3471,39 @@ void detect_triple_b_combo_b_pressed(Player* player) { } void func_800323E4(Player* player) { - s32 var_v1; + s32 playerIndex; f32 test; f32 var_f2; var_f2 = 0.0f; if (player == gPlayerOne) { - var_v1 = 0; + playerIndex = 0; } if (player == gPlayerTwo) { - var_v1 = 1; + playerIndex = 1; } if (player == gPlayerThree) { - var_v1 = 2; + playerIndex = 2; } if (player == gPlayerFour) { - var_v1 = 3; + playerIndex = 3; } if (player == gPlayerFive) { - var_v1 = 4; + playerIndex = 4; } if (player == gPlayerSix) { - var_v1 = 5; + playerIndex = 5; } if (player == gPlayerSeven) { - var_v1 = 6; + playerIndex = 6; } if (player == gPlayerEight) { - var_v1 = 7; + playerIndex = 7; } player->effects |= 1; // This check will never be true, why is it here? if ((player->effects & 0x20) == 0x20) { - player_decelerate(player, 1.0f); + player_decelerate_alternative(player, 1.0f); player->unk_20C = var_f2; } else { if ((s32) player->tyres[BACK_RIGHT].surfaceType < 0xF) { @@ -3521,31 +3521,31 @@ void func_800323E4(Player* player) { player->unk_20C = 2.0f; } } - if (gIsPlayerTripleBButtonCombo[var_v1] == true) { + if (gIsPlayerTripleBButtonCombo[playerIndex] == true) { if (player->unk_20C >= 2.0f) { - player_decelerate(player, (1.0f - var_f2) * 5.0f); + player_decelerate_alternative(player, (1.0f - var_f2) * 5.0f); } else { - player_decelerate(player, (1.0f - var_f2) * 3.0f); + player_decelerate_alternative(player, (1.0f - var_f2) * 3.0f); } } else { if (((player->speed / 18.0f) * 216.0f) <= 20.0f) { - player_decelerate(player, (1.0f - var_f2) * 4.0f); + player_decelerate_alternative(player, (1.0f - var_f2) * 4.0f); } if (player->unk_20C >= 2.0f) { - player_decelerate(player, (1.0f - var_f2) * 2.5); + player_decelerate_alternative(player, (1.0f - var_f2) * 2.5); } else { - player_decelerate(player, (1.0f - var_f2) * 1.2); + player_decelerate_alternative(player, (1.0f - var_f2) * 1.2); } } } } -void func_80032700(Player* player) { - s32 temp_v0; +void player_accelerate_during_start_sequence(Player* player) { + s32 playerIndex; s32 var_v0; - s32 test; + s32 time_delta; - temp_v0 = get_player_index_for_player(player); + playerIndex = get_player_index_for_player(player); if ((player->currentSpeed >= 0.0) && (player->currentSpeed < (player->topSpeed * 0.1))) { player->currentSpeed += gKartAccelerationTables[player->characterId][0] * 3.0; } @@ -3577,13 +3577,13 @@ void func_80032700(Player* player) { player->currentSpeed += gKartAccelerationTables[player->characterId][9] * 2.5; } if (D_801656F0 == 1) { - test = gRaceFrameCounter - D_801652E0[temp_v0]; + time_delta = gRaceFrameCounter - D_801652E0[playerIndex]; if (gModeSelection == TIME_TRIALS) { var_v0 = 0x14; } else { var_v0 = 8; } - if ((test < var_v0) && ((player->unk_044 & 0x20) != 0x20)) { + if ((time_delta < var_v0) && ((player->unk_044 & 0x20) != 0x20)) { player->soundEffects |= 0x02000000; } else if ((player->topSpeed * 0.9f) <= player->currentSpeed) { if ((player->soundEffects & 0x02000000) != 0x02000000) { @@ -3596,8 +3596,8 @@ void func_80032700(Player* player) { player->unk_098 = (player->currentSpeed * player->currentSpeed) / 25.0f; } -void func_80032CB0(Player* player, f32 arg1) { - player->currentSpeed -= arg1; +void player_decelerate_during_start_sequence(Player* player, f32 speedReduction) { + player->currentSpeed -= speedReduction; if (player->currentSpeed <= 0.0f) { player->currentSpeed = 0.0f; } @@ -3615,7 +3615,7 @@ void func_80032CB0(Player* player, f32 arg1) { player->unk_098 = (player->currentSpeed * player->currentSpeed) / 25.0f; } -void func_80032D94(Player* player) { +void player_accelerate(Player* player) { UNUSED s32 player_index; player_index = get_player_index_for_player(player); @@ -3655,8 +3655,8 @@ void func_80032D94(Player* player) { player->unk_098 = (player->currentSpeed * player->currentSpeed) / 25.0f; } -void func_80033280(Player* player, f32 arg1) { - player->currentSpeed -= arg1; +void player_decelerate(Player* player, f32 speedReduction) { + player->currentSpeed -= speedReduction; if (player->currentSpeed <= 0.0f) { player->currentSpeed = 0.0f; } @@ -3666,54 +3666,54 @@ void func_80033280(Player* player, f32 arg1) { player->unk_098 = (player->currentSpeed * player->currentSpeed) / 25.0f; } -void func_800332E8(Player* player, s32 arg1) { - if ((D_80165280[arg1] >= 0.0) && (D_80165280[arg1] < ((f64) player->topSpeed * 0.1))) { - D_80165280[arg1] += gKartAccelerationTables[player->characterId][0] * 3.2; +void player_accelerate_global(Player* player, s32 playerIndex) { + if ((gPlayerCurrentSpeed[playerIndex] >= 0.0) && (gPlayerCurrentSpeed[playerIndex] < ((f64) player->topSpeed * 0.1))) { + gPlayerCurrentSpeed[playerIndex] += gKartAccelerationTables[player->characterId][0] * 3.2; } - if (((player->topSpeed * 0.1) <= D_80165280[arg1]) && (D_80165280[arg1] < (player->topSpeed * 0.2))) { - D_80165280[arg1] += gKartAccelerationTables[player->characterId][1] * 3.2; + if (((player->topSpeed * 0.1) <= gPlayerCurrentSpeed[playerIndex]) && (gPlayerCurrentSpeed[playerIndex] < (player->topSpeed * 0.2))) { + gPlayerCurrentSpeed[playerIndex] += gKartAccelerationTables[player->characterId][1] * 3.2; } - if (((player->topSpeed * 0.2) <= D_80165280[arg1]) && (D_80165280[arg1] < (player->topSpeed * 0.3))) { - D_80165280[arg1] += gKartAccelerationTables[player->characterId][2] * 3.2; + if (((player->topSpeed * 0.2) <= gPlayerCurrentSpeed[playerIndex]) && (gPlayerCurrentSpeed[playerIndex] < (player->topSpeed * 0.3))) { + gPlayerCurrentSpeed[playerIndex] += gKartAccelerationTables[player->characterId][2] * 3.2; } - if (((player->topSpeed * 0.3) <= D_80165280[arg1]) && (D_80165280[arg1] < (player->topSpeed * 0.4))) { - D_80165280[arg1] += gKartAccelerationTables[player->characterId][3] * 3.2; + if (((player->topSpeed * 0.3) <= gPlayerCurrentSpeed[playerIndex]) && (gPlayerCurrentSpeed[playerIndex] < (player->topSpeed * 0.4))) { + gPlayerCurrentSpeed[playerIndex] += gKartAccelerationTables[player->characterId][3] * 3.2; } - if (((player->topSpeed * 0.4) <= D_80165280[arg1]) && (D_80165280[arg1] < (player->topSpeed * 0.5))) { - D_80165280[arg1] += gKartAccelerationTables[player->characterId][4] * 3.2; + if (((player->topSpeed * 0.4) <= gPlayerCurrentSpeed[playerIndex]) && (gPlayerCurrentSpeed[playerIndex] < (player->topSpeed * 0.5))) { + gPlayerCurrentSpeed[playerIndex] += gKartAccelerationTables[player->characterId][4] * 3.2; } - if (((player->topSpeed * 0.5) <= D_80165280[arg1]) && (D_80165280[arg1] < (player->topSpeed * 0.6))) { - D_80165280[arg1] += gKartAccelerationTables[player->characterId][5] * 3.2; + if (((player->topSpeed * 0.5) <= gPlayerCurrentSpeed[playerIndex]) && (gPlayerCurrentSpeed[playerIndex] < (player->topSpeed * 0.6))) { + gPlayerCurrentSpeed[playerIndex] += gKartAccelerationTables[player->characterId][5] * 3.2; } - if (((player->topSpeed * 0.6) <= D_80165280[arg1]) && (D_80165280[arg1] < (player->topSpeed * 0.7))) { - D_80165280[arg1] += gKartAccelerationTables[player->characterId][6] * 3.2; + if (((player->topSpeed * 0.6) <= gPlayerCurrentSpeed[playerIndex]) && (gPlayerCurrentSpeed[playerIndex] < (player->topSpeed * 0.7))) { + gPlayerCurrentSpeed[playerIndex] += gKartAccelerationTables[player->characterId][6] * 3.2; } - if (((player->topSpeed * 0.7) <= D_80165280[arg1]) && (D_80165280[arg1] < (player->topSpeed * 0.8))) { - D_80165280[arg1] += gKartAccelerationTables[player->characterId][7] * 2.8; + if (((player->topSpeed * 0.7) <= gPlayerCurrentSpeed[playerIndex]) && (gPlayerCurrentSpeed[playerIndex] < (player->topSpeed * 0.8))) { + gPlayerCurrentSpeed[playerIndex] += gKartAccelerationTables[player->characterId][7] * 2.8; } - if (((player->topSpeed * 0.8) <= D_80165280[arg1]) && (D_80165280[arg1] < (player->topSpeed * 0.9))) { - D_80165280[arg1] += gKartAccelerationTables[player->characterId][8] * 2.8; + if (((player->topSpeed * 0.8) <= gPlayerCurrentSpeed[playerIndex]) && (gPlayerCurrentSpeed[playerIndex] < (player->topSpeed * 0.9))) { + gPlayerCurrentSpeed[playerIndex] += gKartAccelerationTables[player->characterId][8] * 2.8; } - if (((player->topSpeed * 0.9) <= D_80165280[arg1]) && (D_80165280[arg1] <= (player->topSpeed * 1.0))) { - D_80165280[arg1] += gKartAccelerationTables[player->characterId][9] * 2.8; + if (((player->topSpeed * 0.9) <= gPlayerCurrentSpeed[playerIndex]) && (gPlayerCurrentSpeed[playerIndex] <= (player->topSpeed * 1.0))) { + gPlayerCurrentSpeed[playerIndex] += gKartAccelerationTables[player->characterId][9] * 2.8; } player->unk_044 |= 0x20; - if (D_80165280[arg1] < 0.0f) { - D_80165280[arg1] = 0.0f; + if (gPlayerCurrentSpeed[playerIndex] < 0.0f) { + gPlayerCurrentSpeed[playerIndex] = 0.0f; } - player->unk_098 = (D_80165280[arg1] * D_80165280[arg1]) / 25.0f; + player->unk_098 = (gPlayerCurrentSpeed[playerIndex] * gPlayerCurrentSpeed[playerIndex]) / 25.0f; } -void func_800337CC(Player* player, f32 arg1, s32 arg2) { +void player_decelerate_global(Player* player, f32 speedReduction, s32 playerIndex) { player->unk_044 &= ~0x20; - D_80165280[arg2] -= arg1; - if (D_80165280[arg2] <= 0.0f) { - D_80165280[arg2] = 0.0f; + gPlayerCurrentSpeed[playerIndex] -= speedReduction; + if (gPlayerCurrentSpeed[playerIndex] <= 0.0f) { + gPlayerCurrentSpeed[playerIndex] = 0.0f; } - if (player->topSpeed <= D_80165280[arg2]) { - D_80165280[arg2] = player->topSpeed; + if (player->topSpeed <= gPlayerCurrentSpeed[playerIndex]) { + gPlayerCurrentSpeed[playerIndex] = player->topSpeed; } - player->unk_098 = (D_80165280[arg2] * D_80165280[arg2]) / 25.0f; + player->unk_098 = (gPlayerCurrentSpeed[playerIndex] * gPlayerCurrentSpeed[playerIndex]) / 25.0f; } void func_80033850(Player* arg0, f32 arg1) { @@ -4198,11 +4198,11 @@ void apply_cpu_turn(Player* player, s16 targetAngle) { } } -void func_80036C5C(Player* arg0) { - if (((arg0->speed / 18.0f) * 216.0f) > 20.0f) { - arg0->unk_204 = 0; - arg0->effects |= UNKNOWN_EFFECT_0x10; - arg0->unk_0B6 |= 0x800; +void func_80036C5C(Player* player) { + if (((player->speed / 18.0f) * 216.0f) > 20.0f) { + player->unk_204 = 0; + player->effects |= UNKNOWN_EFFECT_0x10; + player->unk_0B6 |= 0x800; } } @@ -4494,7 +4494,7 @@ void func_80037BB4(Player* player, Vec3f arg1) { } } -void func_80037CFC(Player* player, struct Controller* controller, s8 arg2) { +void func_80037CFC(Player* player, struct Controller* controller, s8 playerIndex) { if (((player->effects & 0x80) != 0x80) && ((player->effects & 0x40) != 0x40) && ((player->effects & 0x400) != 0x400) && ((player->effects & 0x4000) != 0x4000) && ((player->effects & UNKNOWN_EFFECT_0x1000000) != UNKNOWN_EFFECT_0x1000000) && @@ -4507,13 +4507,13 @@ void func_80037CFC(Player* player, struct Controller* controller, s8 arg2) { kart_hop(player); if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - func_800C9060(arg2, 0x19008000); + func_800C9060(playerIndex, 0x19008000); } } if ((player->effects & 8) != 8) { - func_80033AE0(player, controller, arg2); + func_80033AE0(player, controller, playerIndex); } else if (((player->effects & 2) == 2) && (player->collision.surfaceDistance[2] <= 5.0f)) { - func_80033AE0(player, controller, arg2); + func_80033AE0(player, controller, playerIndex); } player->effects &= ~1; if ((!(player->effects & BOOST_RAMP_ASPHALT_EFFECT)) && (!(player->effects & BOOST_RAMP_WOOD_EFFECT))) { @@ -4534,13 +4534,13 @@ void func_80037CFC(Player* player, struct Controller* controller, s8 arg2) { } if ((player->unk_044 & 1) != 1) { if (controller->button & A_BUTTON) { - player_accelerate(player); + player_accelerate_alternative(player); detect_triple_a_combo_a_pressed(player); } else { if (gModeSelection == BATTLE) { - player_decelerate(player, 2.0f); + player_decelerate_alternative(player, 2.0f); } else { - player_decelerate(player, 1.0f); + player_decelerate_alternative(player, 1.0f); } detect_triple_a_combo_a_released(player); } @@ -4570,9 +4570,9 @@ void func_80037CFC(Player* player, struct Controller* controller, s8 arg2) { } else { if ((player->effects & 0x4000) == 0x4000) { if (controller->button & A_BUTTON) { - player_accelerate(player); + player_accelerate_alternative(player); } else { - player_decelerate(player, 5.0f); + player_decelerate_alternative(player, 5.0f); } } if (((((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40)) || @@ -4580,45 +4580,47 @@ void func_80037CFC(Player* player, struct Controller* controller, s8 arg2) { ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT)) { if (controller->button & A_BUTTON) { detect_triple_a_combo_a_pressed(player); - func_800332E8(player, arg2); + player_accelerate_global(player, playerIndex); return; } detect_triple_a_combo_a_released(player); - func_800337CC(player, 5.0f, arg2); + player_decelerate_global(player, 5.0f, playerIndex); } } } -void func_800381AC(Player* player, struct Controller* controller, s8 arg2) { +void handle_a_press_for_player_during_race(Player* player, struct Controller* controller, s8 playerIndex) { if (((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_CPU) != PLAYER_CPU)) { + // If not start sequence if ((player->type & PLAYER_START_SEQUENCE) != PLAYER_START_SEQUENCE) { if (((player->unk_0CA & 2) == 2) || ((player->unk_0CA & 8) == 8)) { if (controller->button & A_BUTTON) { - func_80032D94(player); + player_accelerate(player); } else { - func_80033280(player, 5.0f); + player_decelerate(player, 5.0f); } } else { - func_80037CFC(player, controller, arg2); + func_80037CFC(player, controller, playerIndex); } D_80164A89 = 1; + // If start sequence and unknown condition } else if (D_8018D168 == 1) { if (D_801656F0 == 1) { - if (D_801652E0[arg2] == 0) { - D_801652E0[arg2] = gRaceFrameCounter; + if (D_801652E0[playerIndex] == 0) { + D_801652E0[playerIndex] = gRaceFrameCounter; } } if (controller->button & A_BUTTON) { - func_80032700(player); + player_accelerate_during_start_sequence(player); } else { - func_80032CB0(player, 5.0f); + player_decelerate_during_start_sequence(player, 5.0f); } } } } -void func_800382DC(void) { +void handle_a_press_for_all_players_during_race(void) { u16 temp_v0_3; u16 temp_v0_4; u16 temp_v0_5; @@ -4628,31 +4630,31 @@ void func_800382DC(void) { case SCREEN_MODE_1P: switch (gModeSelection) { case GRAND_PRIX: - func_800381AC(gPlayerOne, gControllerOne, 0); + handle_a_press_for_player_during_race(gPlayerOne, gControllerOne, 0); return; case TIME_TRIALS: if (D_8015F890 != 1) { - func_800381AC(gPlayerOne, gControllerOne, 0); + handle_a_press_for_player_during_race(gPlayerOne, gControllerOne, 0); temp_v0_3 = gPlayerTwo->type; if (((temp_v0_3 & 0x100) == 0x100) && ((temp_v0_3 & 0x800) != 0x800)) { - func_800381AC(gPlayerTwo, gControllerSix, 1); + handle_a_press_for_player_during_race(gPlayerTwo, gControllerSix, 1); } temp_v0_4 = gPlayerThree->type; if (((temp_v0_4 & 0x100) == 0x100) && ((temp_v0_4 & 0x800) != 0x800)) { - func_800381AC(gPlayerThree, gControllerSeven, 2); + handle_a_press_for_player_during_race(gPlayerThree, gControllerSeven, 2); return; } } else { if ((gPlayerOne->type & 0x800) != 0x800) { - func_800381AC(gPlayerOne, gControllerEight, 0); + handle_a_press_for_player_during_race(gPlayerOne, gControllerEight, 0); } temp_v0_5 = gPlayerTwo->type; if (((temp_v0_5 & 0x100) == 0x100) && ((temp_v0_5 & 0x800) != 0x800)) { - func_800381AC(gPlayerTwo, gControllerSix, 1); + handle_a_press_for_player_during_race(gPlayerTwo, gControllerSix, 1); } temp_v0_6 = gPlayerThree->type; if (((temp_v0_6 & 0x100) == 0x100) && ((temp_v0_6 & 0x800) != 0x800)) { - func_800381AC(gPlayerThree, gControllerSeven, 2); + handle_a_press_for_player_during_race(gPlayerThree, gControllerSeven, 2); return; } return; @@ -4663,15 +4665,15 @@ void func_800382DC(void) { break; case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: - func_800381AC(gPlayerOne, gControllerOne, 0); - func_800381AC(gPlayerTwo, gControllerTwo, 1); + handle_a_press_for_player_during_race(gPlayerOne, gControllerOne, 0); + handle_a_press_for_player_during_race(gPlayerTwo, gControllerTwo, 1); return; case SCREEN_MODE_3P_4P_SPLITSCREEN: - func_800381AC(gPlayerOne, gControllerOne, 0); - func_800381AC(gPlayerTwo, gControllerTwo, 1); - func_800381AC(gPlayerThree, gControllerThree, 2); + handle_a_press_for_player_during_race(gPlayerOne, gControllerOne, 0); + handle_a_press_for_player_during_race(gPlayerTwo, gControllerTwo, 1); + handle_a_press_for_player_during_race(gPlayerThree, gControllerThree, 2); if (gPlayerCountSelection1 == 4) { - func_800381AC(gPlayerFour, gControllerFour, 3); + handle_a_press_for_player_during_race(gPlayerFour, gControllerFour, 3); } break; } diff --git a/src/player_controller.h b/src/player_controller.h index 52e704daf..475b52833 100644 --- a/src/player_controller.h +++ b/src/player_controller.h @@ -73,17 +73,17 @@ f32 func_80030150(Player*, s8); void func_80030A34(Player*); void detect_triple_a_combo_a_released(Player*); void detect_triple_a_combo_a_pressed(Player*); -void player_accelerate(Player*); -void player_decelerate(Player*, f32); +void player_accelerate_alternative(Player*); +void player_decelerate_alternative(Player*, f32); void detect_triple_b_combo_b_released(Player*); void detect_triple_b_combo_b_pressed(Player*); void func_800323E4(Player*); -void func_80032700(Player*); -void func_80032CB0(Player*, f32); -void func_80032D94(Player*); -void func_80033280(Player*, f32); -void func_800332E8(Player*, s32); -void func_800337CC(Player*, f32, s32); +void player_accelerate_during_start_sequence(Player*); +void player_decelerate_during_start_sequence(Player*, f32); +void player_accelerate(Player*); +void player_decelerate(Player*, f32); +void player_accelerate_global(Player*, s32); +void player_decelerate_global(Player*, f32, s32); void func_80033850(Player*, f32); void func_80033884(Player*, s32*, s32*, s32, s32, s32, s32); void func_80033940(Player*, s32*, s32, s32, f32); @@ -104,8 +104,8 @@ void func_80037A4C(Player*, Vec3f, Vec3f); void func_80037BB4(Player* player, Vec3f); void func_80037CFC(Player*, struct Controller*, s8); -void func_800381AC(Player*, struct Controller*, s8); -void func_800382DC(void); +void handle_a_press_for_player_during_race(Player*, struct Controller*, s8); +void handle_a_press_for_all_players_during_race(void); s16 func_80038534(struct Controller*); s16 func_800388B0(struct Controller*); void func_80038BE4(Player*, s16); diff --git a/src/render_player.c b/src/render_player.c index 42d8e7ceb..d9431dd72 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -951,25 +951,25 @@ void func_8002276C(void) { } } -void func_80022A98(Player* player, s8 arg1) { +void func_80022A98(Player* player, s8 playerIndex) { if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) { - func_80026A48(player, arg1); - func_800235AC(player, arg1); + func_80026A48(player, playerIndex); + func_800235AC(player, playerIndex); if (((player->effects & HIT_EFFECT) == HIT_EFFECT) || ((player->effects & 0x08000000) == 0x08000000)) { if ((player->effects & HIT_EFFECT) == HIT_EFFECT) { - func_80022B50(player, arg1); + func_80022B50(player, playerIndex); } if ((player->effects & 0x08000000) == 0x08000000) { - func_80022BC4(player, arg1); + func_80022BC4(player, playerIndex); } } else { - func_80022DB4(player, arg1); + func_80022DB4(player, playerIndex); } func_80030A34(player); } } -void func_80022B50(Player* player, UNUSED s8 arg1) { +void func_80022B50(Player* player, UNUSED s8 playerIndex) { f32 temp_f0; s16 var_v0; @@ -984,7 +984,7 @@ void func_80022B50(Player* player, UNUSED s8 arg1) { player->unk_DB4.unk2 = var_v0; } -void func_80022BC4(Player* player, UNUSED s8 arg1) { +void func_80022BC4(Player* player, UNUSED s8 playerIndex) { f32 temp_f0 = player->unk_DB4.unk10; s16 temp_v0 = player->unk_DB4.unk2; s16 temp_f16; @@ -1029,7 +1029,7 @@ void func_80022D60(UNUSED Player* player, s8 playerId, UNUSED s8 screenId, s8 ar D_800DDBB4[playerId][arg3 + 0x3].v.ob[1] = 21; } -void func_80022DB4(Player* player, UNUSED s8 arg1) { +void func_80022DB4(Player* player, UNUSED s8 playerIndex) { f32 temp_f0 = player->unk_DB4.unkC; s16 temp_v0 = player->unk_DB4.unk18; s16 temp_f16; @@ -1067,39 +1067,39 @@ void func_80022E84(Player* player, s8 playerId, UNUSED s8 screenId, s8 arg3) { /** * Sets player shading/colour. */ -void change_player_color_effect_rgb(UNUSED Player* player, s8 arg1, s32 arg2, f32 alpha) { - gPlayerRedEffect[arg1] = - (s16) ((f32) gPlayerRedEffect[arg1] - ((gPlayerRedEffect[arg1] - ((arg2 >> 16) & 0xFF)) * alpha)); +void change_player_color_effect_rgb(UNUSED Player* player, s8 playerIndex, s32 arg2, f32 alpha) { + gPlayerRedEffect[playerIndex] = + (s16) ((f32) gPlayerRedEffect[playerIndex] - ((gPlayerRedEffect[playerIndex] - ((arg2 >> 16) & 0xFF)) * alpha)); - gPlayerGreenEffect[arg1] = - (s16) ((f32) gPlayerGreenEffect[arg1] - ((gPlayerGreenEffect[arg1] - ((arg2 >> 8) & 0xFF)) * alpha)); + gPlayerGreenEffect[playerIndex] = + (s16) ((f32) gPlayerGreenEffect[playerIndex] - ((gPlayerGreenEffect[playerIndex] - ((arg2 >> 8) & 0xFF)) * alpha)); - gPlayerBlueEffect[arg1] = - (s16) ((f32) gPlayerBlueEffect[arg1] - ((gPlayerBlueEffect[arg1] - (arg2 & 0xFF)) * alpha)); + gPlayerBlueEffect[playerIndex] = + (s16) ((f32) gPlayerBlueEffect[playerIndex] - ((gPlayerBlueEffect[playerIndex] - (arg2 & 0xFF)) * alpha)); } -void change_player_color_effect_cmy(UNUSED Player* player, s8 arg1, s32 arg2, f32 arg3) { - move_u16_towards(&gPlayerCyanEffect[arg1], (arg2 >> 16) & 0xFF, arg3); - move_u16_towards(&gPlayerMagentaEffect[arg1], (arg2 >> 8) & 0xFF, arg3); - move_u16_towards(&gPlayerYellowEffect[arg1], arg2 & 0xFF, arg3); +void change_player_color_effect_cmy(UNUSED Player* player, s8 playerIndex, s32 arg2, f32 arg3) { + move_u16_towards(&gPlayerCyanEffect[playerIndex], (arg2 >> 16) & 0xFF, arg3); + move_u16_towards(&gPlayerMagentaEffect[playerIndex], (arg2 >> 8) & 0xFF, arg3); + move_u16_towards(&gPlayerYellowEffect[playerIndex], arg2 & 0xFF, arg3); } /** * Activates in the tunnel to shade the player a bit darker * Sort of an atmospheric effect. */ -bool is_player_under_light_luigi_raceway(Player* player, s8 arg1) { +bool is_player_under_light_luigi_raceway(Player* player, s8 playerIndex) { switch (gCurrentCourseId) { case COURSE_LUIGI_RACEWAY: - if (((gNearestPathPointByPlayerId[arg1] >= 0x14F) && (gNearestPathPointByPlayerId[arg1] < 0x158)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x15E) && (gNearestPathPointByPlayerId[arg1] < 0x164)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x169) && (gNearestPathPointByPlayerId[arg1] < 0x170)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x174) && (gNearestPathPointByPlayerId[arg1] < 0x17A)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x17E) && - (gNearestPathPointByPlayerId[arg1] < 0x184))) { // under a light in the tunnel - change_player_color_effect_rgb(player, arg1, COLOR_LIGHT, 0.3f); - change_player_color_effect_cmy(player, arg1, 0xE0, 0.3f); - D_80164B80[arg1] = 0; + if (((gNearestPathPointByPlayerId[playerIndex] >= 0x14F) && (gNearestPathPointByPlayerId[playerIndex] < 0x158)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x15E) && (gNearestPathPointByPlayerId[playerIndex] < 0x164)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x169) && (gNearestPathPointByPlayerId[playerIndex] < 0x170)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x174) && (gNearestPathPointByPlayerId[playerIndex] < 0x17A)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x17E) && + (gNearestPathPointByPlayerId[playerIndex] < 0x184))) { // under a light in the tunnel + change_player_color_effect_rgb(player, playerIndex, COLOR_LIGHT, 0.3f); + change_player_color_effect_cmy(player, playerIndex, 0xE0, 0.3f); + D_80164B80[playerIndex] = 0; return true; } return false; @@ -1109,161 +1109,161 @@ bool is_player_under_light_luigi_raceway(Player* player, s8 arg1) { } } -void render_light_environment_on_player(Player* player, s8 arg1) { +void render_light_environment_on_player(Player* player, s8 playerIndex) { switch (gCurrentCourseId) { case COURSE_BOWSER_CASTLE: - if (((gNearestPathPointByPlayerId[arg1] >= 0x15) && (gNearestPathPointByPlayerId[arg1] < 0x2A)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x14D) && (gNearestPathPointByPlayerId[arg1] < 0x15C)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x1D1) && (gNearestPathPointByPlayerId[arg1] < 0x1E4)) || + if (((gNearestPathPointByPlayerId[playerIndex] >= 0x15) && (gNearestPathPointByPlayerId[playerIndex] < 0x2A)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x14D) && (gNearestPathPointByPlayerId[playerIndex] < 0x15C)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x1D1) && (gNearestPathPointByPlayerId[playerIndex] < 0x1E4)) || (player->collision.surfaceDistance[2] >= 500.0f)) { // over lava - change_player_color_effect_rgb(player, arg1, COLOR_LAVA, 0.3f); - change_player_color_effect_cmy(player, arg1, 0x004040, 0.3f); - D_80164B80[arg1] = 0; - } else if (((gNearestPathPointByPlayerId[arg1] >= 0xF1) && (gNearestPathPointByPlayerId[arg1] < 0xF5)) || - ((gNearestPathPointByPlayerId[arg1] >= 0xFB) && (gNearestPathPointByPlayerId[arg1] < 0xFF)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x105) && (gNearestPathPointByPlayerId[arg1] < 0x109)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x10F) && (gNearestPathPointByPlayerId[arg1] < 0x113)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x145) && (gNearestPathPointByPlayerId[arg1] < 0x14A)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x15E) && - (gNearestPathPointByPlayerId[arg1] < 0x163))) { // under a lamp - change_player_color_effect_rgb(player, arg1, COLOR_LIGHT, 0.3f); - change_player_color_effect_cmy(player, arg1, 0xE0, 0.3f); - D_80164B80[arg1] = 0; + change_player_color_effect_rgb(player, playerIndex, COLOR_LAVA, 0.3f); + change_player_color_effect_cmy(player, playerIndex, 0x004040, 0.3f); + D_80164B80[playerIndex] = 0; + } else if (((gNearestPathPointByPlayerId[playerIndex] >= 0xF1) && (gNearestPathPointByPlayerId[playerIndex] < 0xF5)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0xFB) && (gNearestPathPointByPlayerId[playerIndex] < 0xFF)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x105) && (gNearestPathPointByPlayerId[playerIndex] < 0x109)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x10F) && (gNearestPathPointByPlayerId[playerIndex] < 0x113)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x145) && (gNearestPathPointByPlayerId[playerIndex] < 0x14A)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x15E) && + (gNearestPathPointByPlayerId[playerIndex] < 0x163))) { // under a lamp + change_player_color_effect_rgb(player, playerIndex, COLOR_LIGHT, 0.3f); + change_player_color_effect_cmy(player, playerIndex, 0xE0, 0.3f); + D_80164B80[playerIndex] = 0; } else { // normal color - change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 0.3f); - change_player_color_effect_cmy(player, arg1, 0, 0.3f); - D_80164B80[arg1] = 0; + change_player_color_effect_rgb(player, playerIndex, COLOR_BLACK, 0.3f); + change_player_color_effect_cmy(player, playerIndex, 0, 0.3f); + D_80164B80[playerIndex] = 0; } break; case COURSE_BANSHEE_BOARDWALK: - if (((gNearestPathPointByPlayerId[arg1] >= 0xD) && (gNearestPathPointByPlayerId[arg1] < 0x15)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x29) && (gNearestPathPointByPlayerId[arg1] < 0x39)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x46) && (gNearestPathPointByPlayerId[arg1] < 0x4E)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x5F) && (gNearestPathPointByPlayerId[arg1] < 0x67)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x7B) && (gNearestPathPointByPlayerId[arg1] < 0x86)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x9D) && (gNearestPathPointByPlayerId[arg1] < 0xA6)) || - ((gNearestPathPointByPlayerId[arg1] >= 0xB9) && (gNearestPathPointByPlayerId[arg1] < 0xC3)) || - ((gNearestPathPointByPlayerId[arg1] >= 0xB9) && (gNearestPathPointByPlayerId[arg1] < 0xC3)) || - ((gNearestPathPointByPlayerId[arg1] >= 0xD7) && (gNearestPathPointByPlayerId[arg1] < 0xE1)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x10E) && (gNearestPathPointByPlayerId[arg1] < 0x119)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x154) && (gNearestPathPointByPlayerId[arg1] < 0x15F)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x1EF) && (gNearestPathPointByPlayerId[arg1] < 0x1F7)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x202) && (gNearestPathPointByPlayerId[arg1] < 0x209)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x216) && (gNearestPathPointByPlayerId[arg1] < 0x21D)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x230) && (gNearestPathPointByPlayerId[arg1] < 0x23A)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x24C) && (gNearestPathPointByPlayerId[arg1] < 0x256)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x288) && (gNearestPathPointByPlayerId[arg1] < 0x269)) || - ((gNearestPathPointByPlayerId[arg1] >= 0x274) && - (gNearestPathPointByPlayerId[arg1] < 0x27E))) { // under a lamp - change_player_color_effect_rgb(player, arg1, COLOR_LIGHT, 0.3f); - change_player_color_effect_cmy(player, arg1, 0x0000E0, 0.3f); - D_80164B80[arg1] = 0; + if (((gNearestPathPointByPlayerId[playerIndex] >= 0xD) && (gNearestPathPointByPlayerId[playerIndex] < 0x15)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x29) && (gNearestPathPointByPlayerId[playerIndex] < 0x39)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x46) && (gNearestPathPointByPlayerId[playerIndex] < 0x4E)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x5F) && (gNearestPathPointByPlayerId[playerIndex] < 0x67)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x7B) && (gNearestPathPointByPlayerId[playerIndex] < 0x86)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x9D) && (gNearestPathPointByPlayerId[playerIndex] < 0xA6)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0xB9) && (gNearestPathPointByPlayerId[playerIndex] < 0xC3)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0xB9) && (gNearestPathPointByPlayerId[playerIndex] < 0xC3)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0xD7) && (gNearestPathPointByPlayerId[playerIndex] < 0xE1)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x10E) && (gNearestPathPointByPlayerId[playerIndex] < 0x119)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x154) && (gNearestPathPointByPlayerId[playerIndex] < 0x15F)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x1EF) && (gNearestPathPointByPlayerId[playerIndex] < 0x1F7)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x202) && (gNearestPathPointByPlayerId[playerIndex] < 0x209)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x216) && (gNearestPathPointByPlayerId[playerIndex] < 0x21D)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x230) && (gNearestPathPointByPlayerId[playerIndex] < 0x23A)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x24C) && (gNearestPathPointByPlayerId[playerIndex] < 0x256)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x288) && (gNearestPathPointByPlayerId[playerIndex] < 0x269)) || + ((gNearestPathPointByPlayerId[playerIndex] >= 0x274) && + (gNearestPathPointByPlayerId[playerIndex] < 0x27E))) { // under a lamp + change_player_color_effect_rgb(player, playerIndex, COLOR_LIGHT, 0.3f); + change_player_color_effect_cmy(player, playerIndex, 0x0000E0, 0.3f); + D_80164B80[playerIndex] = 0; } else { - change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 0.3f); - change_player_color_effect_cmy(player, arg1, 0, 0.3f); - D_80164B80[arg1] = 0; + change_player_color_effect_rgb(player, playerIndex, COLOR_BLACK, 0.3f); + change_player_color_effect_cmy(player, playerIndex, 0, 0.3f); + D_80164B80[playerIndex] = 0; } break; default: - change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 0.3f); - change_player_color_effect_cmy(player, arg1, 0, 0.3f); - D_80164B80[arg1] = 0; + change_player_color_effect_rgb(player, playerIndex, COLOR_BLACK, 0.3f); + change_player_color_effect_cmy(player, playerIndex, 0, 0.3f); + D_80164B80[playerIndex] = 0; break; } } -void func_800235AC(Player* player, s8 arg1) { - s32 temp; +void func_800235AC(Player* player, s8 playerIndex) { + s32 time_elapsed; if (((player->type & PLAYER_INVISIBLE_OR_BOMB) == PLAYER_INVISIBLE_OR_BOMB) && (player == gPlayerThree)) { - change_player_color_effect_rgb(player, arg1, COLOR_LIGHT, 0.3f); - change_player_color_effect_cmy(player, arg1, 0xE0, 0.3f); - D_80164B80[arg1] = 0; + change_player_color_effect_rgb(player, playerIndex, COLOR_LIGHT, 0.3f); + change_player_color_effect_cmy(player, playerIndex, 0xE0, 0.3f); + D_80164B80[playerIndex] = 0; return; } if (((player->unk_0CA & 0x10) == 0x10) && ((player->unk_0CA & 4) == 4)) { - change_player_color_effect_rgb(player, arg1, 0x646464, 0.5f); - change_player_color_effect_cmy(player, arg1, 0xFF0000, 0.1f); + change_player_color_effect_rgb(player, playerIndex, 0x646464, 0.5f); + change_player_color_effect_cmy(player, playerIndex, 0xFF0000, 0.1f); return; } if ((player->unk_0CA & 4) == 4) { - change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 1.0f); - change_player_color_effect_cmy(player, arg1, 0, 1.0f); + change_player_color_effect_rgb(player, playerIndex, COLOR_BLACK, 1.0f); + change_player_color_effect_cmy(player, playerIndex, 0, 1.0f); return; } if ((player->unk_0CA & 0x10) == 0x10) { - change_player_color_effect_rgb(player, arg1, 0x646464, 0.5f); - change_player_color_effect_cmy(player, arg1, 0xFF0000, 0.1f); + change_player_color_effect_rgb(player, playerIndex, 0x646464, 0.5f); + change_player_color_effect_cmy(player, playerIndex, 0xFF0000, 0.1f); return; } if ((player->unk_0CA & 0x20) == 0x20) { - change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 0.1f); - change_player_color_effect_cmy(player, arg1, 0, 0.1f); + change_player_color_effect_rgb(player, playerIndex, COLOR_BLACK, 0.1f); + change_player_color_effect_cmy(player, playerIndex, 0, 0.1f); return; } if (((player->effects & LIGHTNING_EFFECT) == LIGHTNING_EFFECT) && ((s32) player->unk_0B0 < 0x78)) { - D_80164B80[arg1] += 5; - if (D_80164B80[arg1] >= 0x1E) { - D_80164B80[arg1] = 0; + D_80164B80[playerIndex] += 5; + if (D_80164B80[playerIndex] >= 0x1E) { + D_80164B80[playerIndex] = 0; } - if ((D_80164B80[arg1] >= 0) && (D_80164B80[arg1] < 0xB)) { - change_player_color_effect_rgb(player, arg1, 0x808080, 0.8f); - change_player_color_effect_cmy(player, arg1, 0, 0.8f); + if ((D_80164B80[playerIndex] >= 0) && (D_80164B80[playerIndex] < 0xB)) { + change_player_color_effect_rgb(player, playerIndex, 0x808080, 0.8f); + change_player_color_effect_cmy(player, playerIndex, 0, 0.8f); } - if ((D_80164B80[arg1] >= 0xB) && (D_80164B80[arg1] < 0x15)) { - change_player_color_effect_rgb(player, arg1, 0x70, 0.8f); - change_player_color_effect_cmy(player, arg1, 0, 0.8f); + if ((D_80164B80[playerIndex] >= 0xB) && (D_80164B80[playerIndex] < 0x15)) { + change_player_color_effect_rgb(player, playerIndex, 0x70, 0.8f); + change_player_color_effect_cmy(player, playerIndex, 0, 0.8f); } - if ((D_80164B80[arg1] >= 0x15) && (D_80164B80[arg1] < 0x1F)) { - change_player_color_effect_rgb(player, arg1, 0x8F8F00, 0.8f); - change_player_color_effect_cmy(player, arg1, 0, 0.8f); + if ((D_80164B80[playerIndex] >= 0x15) && (D_80164B80[playerIndex] < 0x1F)) { + change_player_color_effect_rgb(player, playerIndex, 0x8F8F00, 0.8f); + change_player_color_effect_cmy(player, playerIndex, 0, 0.8f); } return; } if ((player->effects & STAR_EFFECT) != 0) { - temp = (s32) gCourseTimer - D_8018D930[arg1]; - if (temp <= 8) { + time_elapsed = (s32) gCourseTimer - gPlayerStarEffectStartTime[playerIndex]; + if (time_elapsed <= 8) { - if (temp >= 7) { - D_80164B80[arg1] += 10; + if (time_elapsed >= 7) { + D_80164B80[playerIndex] += 10; } else { - D_80164B80[arg1] += 5; + D_80164B80[playerIndex] += 5; } - if (D_80164B80[arg1] >= 40) { - D_80164B80[arg1] = 0; + if (D_80164B80[playerIndex] >= 40) { + D_80164B80[playerIndex] = 0; } - if ((D_80164B80[arg1] >= 0) && (D_80164B80[arg1] <= 10)) { - change_player_color_effect_rgb(player, arg1, 0x70, 0.8f); - change_player_color_effect_cmy(player, arg1, 0, 0.8f); + if ((D_80164B80[playerIndex] >= 0) && (D_80164B80[playerIndex] <= 10)) { + change_player_color_effect_rgb(player, playerIndex, 0x70, 0.8f); + change_player_color_effect_cmy(player, playerIndex, 0, 0.8f); } - if ((D_80164B80[arg1] >= 0xB) && (D_80164B80[arg1] <= 20)) { - change_player_color_effect_rgb(player, arg1, 0x707000, 0.8f); - change_player_color_effect_cmy(player, arg1, 0, 0.8f); + if ((D_80164B80[playerIndex] >= 0xB) && (D_80164B80[playerIndex] <= 20)) { + change_player_color_effect_rgb(player, playerIndex, 0x707000, 0.8f); + change_player_color_effect_cmy(player, playerIndex, 0, 0.8f); } - if ((D_80164B80[arg1] >= 0x15) && (D_80164B80[arg1] <= 30)) { - change_player_color_effect_rgb(player, arg1, 0x700000, 0.8f); - change_player_color_effect_cmy(player, arg1, 0, 0.8f); + if ((D_80164B80[playerIndex] >= 0x15) && (D_80164B80[playerIndex] <= 30)) { + change_player_color_effect_rgb(player, playerIndex, 0x700000, 0.8f); + change_player_color_effect_cmy(player, playerIndex, 0, 0.8f); } - if (D_80164B80[arg1] >= 0x1F) { - change_player_color_effect_rgb(player, arg1, 0x7000, 0.8f); - change_player_color_effect_cmy(player, arg1, 0, 0.8f); + if (D_80164B80[playerIndex] >= 0x1F) { + change_player_color_effect_rgb(player, playerIndex, 0x7000, 0.8f); + change_player_color_effect_cmy(player, playerIndex, 0, 0.8f); } return; } } - if (is_player_under_light_luigi_raceway(player, arg1) != true) { + if (is_player_under_light_luigi_raceway(player, playerIndex) != true) { if (((player->tyres[BACK_RIGHT].unk_14 & 1) == 1) || ((player->tyres[BACK_RIGHT].unk_14 & 2) == 2) || ((player->tyres[FRONT_LEFT].unk_14 & 3) == 3)) { - change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 0.3f); - change_player_color_effect_cmy(player, arg1, 0x6F6F6F, 0.3f); + change_player_color_effect_rgb(player, playerIndex, COLOR_BLACK, 0.3f); + change_player_color_effect_cmy(player, playerIndex, 0x6F6F6F, 0.3f); return; } - render_light_environment_on_player(player, arg1); + render_light_environment_on_player(player, playerIndex); if ((player->unk_0CA & 0x1000) == 0x1000) { - change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 0.3f); - change_player_color_effect_cmy(player, arg1, 0xF0F0F0, 0.3f); + change_player_color_effect_rgb(player, playerIndex, COLOR_BLACK, 0.3f); + change_player_color_effect_cmy(player, playerIndex, 0xF0F0F0, 0.3f); } } } @@ -1742,7 +1742,7 @@ void render_player(Player* player, s8 playerId, s8 screenId) { } } -void func_80026A48(Player* player, s8 arg1) { +void func_80026A48(Player* player, s8 playerIndex) { f32 temp_f0; if (((player->effects & 0x4000) == 0x4000) && ((player->type & PLAYER_START_SEQUENCE) == 0)) { @@ -1754,7 +1754,7 @@ void func_80026A48(Player* player, s8 arg1) { } temp_f0 = ((player->speed * (1.0f + player->unk_104)) / 18.0f) * 216.0f; - if ((temp_f0 <= 1.0f) || (gIsPlayerTripleBButtonCombo[arg1] == true)) { + if ((temp_f0 <= 1.0f) || (gIsPlayerTripleBButtonCombo[playerIndex] == true)) { player->tyreSpeed = 0; } else { player->tyreSpeed += D_800DDE74[(s32) (temp_f0 / 12.0f)]; diff --git a/src/render_player.h b/src/render_player.h index f4e2067f2..829a6db91 100644 --- a/src/render_player.h +++ b/src/render_player.h @@ -85,7 +85,7 @@ extern u16 gPlayerMagentaEffect[]; extern u16 gPlayerYellowEffect[]; extern s32 D_80164B80[]; -extern s32 D_8018D930[]; +extern s32 gPlayerStarEffectStartTime[]; extern Gfx common_square_plain_render[]; extern Gfx D_0D008D58[]; diff --git a/src/spawn_players.c b/src/spawn_players.c index dc88b8ca4..0112ac0db 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -30,7 +30,7 @@ f32 D_80165210[8]; f32 D_80165230[8]; UNUSED f32 D_80165250[8]; s16 D_80165270[8]; -f32 D_80165280[8]; +f32 gPlayerCurrentSpeed[8]; f32 D_801652A0[8]; s32 D_801652C0[8]; s32 D_801652E0[8]; @@ -282,7 +282,7 @@ void spawn_player(Player* player, s8 playerIndex, f32 startingRow, f32 startingC D_80165070[playerIndex][0] = 0.0f; D_80165070[playerIndex][1] = 0.0f; D_80165070[playerIndex][2] = 0.0f; - D_80165280[playerIndex] = 0.0f; + gPlayerCurrentSpeed[playerIndex] = 0.0f; D_801652A0[playerIndex] = 0.0f; gPlayerIsThrottleActive[playerIndex] = 0; D_80165400[playerIndex] = 0; @@ -356,9 +356,9 @@ void spawn_player(Player* player, s8 playerIndex, f32 startingRow, f32 startingC D_8018CE10[playerIndex].unk_04[2] = 0.0f; func_80295BF8(playerIndex); func_8005D6C0(player); - func_8006B87C(player, playerIndex); + clear_all_player_balloons(player, playerIndex); if (gModeSelection == BATTLE) { - func_8006B7E4(player, playerIndex); + init_all_player_balloons(player, playerIndex); } calculate_orientation_matrix(player->unk_150, player->unk_058, player->unk_05C, player->unk_060, player->rotation[1]); diff --git a/src/spawn_players.h b/src/spawn_players.h index 9f83b20cb..23c9c14a2 100644 --- a/src/spawn_players.h +++ b/src/spawn_players.h @@ -28,7 +28,7 @@ void func_8003DB5C(void); extern f32 D_80165210[]; extern f32 D_80165230[]; extern s16 D_80165270[]; -extern f32 D_80165280[]; +extern f32 gPlayerCurrentSpeed[]; extern f32 D_801652A0[]; extern s32 D_801652C0[]; extern s32 D_801652E0[]; diff --git a/src/update_objects.c b/src/update_objects.c index 91a0368e5..2dfea8758 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -4318,7 +4318,7 @@ void func_8007C684(s32 objectIndex) { } } -void func_8007C7B4(s32 someIndex, s32 arg1) { +void func_8007C7B4(s32 someIndex, s32 playerIndex) { s32 temp_a0; s32 objectIndex; s16 temp_s1_2; @@ -4329,7 +4329,7 @@ void func_8007C7B4(s32 someIndex, s32 arg1) { for (temp_a0 = 0; temp_a0 < 5; temp_a0++) { objectIndex = indexObjectList3[someIndex + temp_a0]; init_object(objectIndex, 1); - gObjectList[objectIndex].unk_0D1 = arg1; + gObjectList[objectIndex].unk_0D1 = playerIndex; temp_s1_2 = random_int(0x003CU) - 0x1E; temp_s4 = random_int(0x0014U) - 0xA; temp_s5 = random_int(0x0050U) - 0x28; @@ -4340,7 +4340,7 @@ void func_8007C7B4(s32 someIndex, s32 arg1) { gObjectList[objectIndex].origin_pos[1] = (f32) temp_s4; gObjectList[objectIndex].origin_pos[2] = (f32) temp_s5; } - func_800C9060(arg1, 0x1900705AU); + func_800C9060(playerIndex, 0x1900705AU); if (someIndex == 0) { D_8018CFF0 = 1; @@ -6378,14 +6378,14 @@ void func_80081AFC(s32 objectIndex, s32 arg1) { void func_80081D34(s32 objectIndex) { Player* player; Camera* var_s4; - s32 var_s2; + s32 playerIndex; s32 var_s5; Object* object; var_s5 = 0; player = gPlayerOne; var_s4 = camera1; - for (var_s2 = 0; var_s2 < D_8018D158; var_s2++, player++, var_s4++) { + for (playerIndex = 0; playerIndex < D_8018D158; playerIndex++, player++, var_s4++) { if ((is_obj_flag_status_active(objectIndex, 0x00000200) != 0) && !(player->effects & 0x80000000) && (has_collided_with_player(objectIndex, player) != 0)) { if ((player->type & PLAYER_EXISTS) && !(player->type & 0x100)) { @@ -6395,7 +6395,7 @@ void func_80081D34(s32 objectIndex) { func_80072180(); } if (player->effects & 0x200) { - func_800C9060(var_s2, 0x1900A046U); + func_800C9060(playerIndex, 0x1900A046U); } else { player->soundEffects |= 2; }