diff --git a/asm/bss_8001C4D0.s b/asm/bss_8001C4D0.s index f62db9cff1..922b95b892 100644 --- a/asm/bss_8001C4D0.s +++ b/asm/bss_8001C4D0.s @@ -67,7 +67,7 @@ glabel D_80164AD0 glabel gMatrixEffectCount .skip 20 -glabel D_80164B04 +glabel gPlayerPalette .skip 4 glabel D_80164B08 diff --git a/include/defines.h b/include/defines.h index e1c237e28a..14542b7045 100644 --- a/include/defines.h +++ b/include/defines.h @@ -336,5 +336,8 @@ #define SPAWN_THIRD_SHELL 2 #define GPACK_RGB888(r, g, b) (((r) << 16) | ((g) << 8) | (b)) +#define COLOR_LIGHT GPACK_RGB888(0x1C, 0x00, 0x00) +#define COLOR_LAVA GPACK_RGB888(0x34, 0x00, 0x00) +#define COLOR_BLACK GPACK_RGB888(0, 0, 0) #endif // DEFINES_H diff --git a/include/functions.h b/include/functions.h index 3d6820f7c0..2a856ab885 100644 --- a/include/functions.h +++ b/include/functions.h @@ -11,7 +11,6 @@ void func_80040030(u8* arg0, u8* arg1); void func_8000F2DC(void); void func_8000F628(void); void func_8006B7E4(Player* player, s8 arg1); -void func_800267AC(Player* player, s8 arg1, s8 arg2); void func_8005D290(void); diff --git a/src/camera.c b/src/camera.c index 02275b1ae2..0549976cb4 100644 --- a/src/camera.c +++ b/src/camera.c @@ -634,7 +634,7 @@ void func_8001E0C4(Camera *camera, Player *player, s8 arg2) { } else { var_a2 = (player->unk_078 / 3) + 0x87; } - func_800224F0(&camera->unk_2C, player->unk_02C[1], var_a2); + adjust_angle(&camera->unk_2C, player->unk_02C[1], var_a2); func_8001CA78(player, camera, sp60, &sp74, &sp70, &sp6C, camera->unk_2C, arg2); camera->someBitFlags &= ~0x0004; temp_t7 = func_802ADDC8(&camera->unk_54, test, sp74, sp70, sp6C); @@ -739,7 +739,7 @@ void func_8001E45C(Camera *camera, Player *player, s8 arg2) { (player->unk_110.unk3C[0] <= 0.0f) || (player->unk_110.unk3C[1] <= 0.0f) || ((player->effects & 0x20000) == 0x20000)) { func_8001CCEC(player, camera, sp64, &sp84, &sp80, &sp7C, &sp58, (s32) camera->unk_2C, (s32) arg2); } else { - func_800224F0(&camera->unk_2C, (s16) (player->unk_02C[1] + camera->unk_B0), var_a3); + adjust_angle(&camera->unk_2C, (s16) (player->unk_02C[1] + camera->unk_B0), var_a3); func_8001CCEC(player, camera, sp64, &sp84, &sp80, &sp7C, &sp58, (s32) camera->unk_2C, (s32) arg2); } temp = 3; @@ -861,7 +861,7 @@ void func_8001EA0C(Camera *camera, Player *player, s8 arg2) { (player->unk_110.unk3C[0] <= 0.0f) || (player->unk_110.unk3C[1] <= 0.0f) || ((player->effects & 0x20000) == 0x20000)) { func_8001D944(player, camera, sp64, &sp84, &sp80, &sp7C, &sp58, (s32) camera->unk_2C, (s32) arg2); } else { - func_800224F0(&camera->unk_2C, (s16) (player->unk_02C[1] + camera->unk_B0), var_a3); + adjust_angle(&camera->unk_2C, (s16) (player->unk_02C[1] + camera->unk_B0), var_a3); func_8001D944(player, camera, sp64, &sp84, &sp80, &sp7C, &sp58, (s32) camera->unk_2C, (s32) arg2); } temp = 3; diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index 3b2777ae9f..6ec8ee1b84 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -6361,14 +6361,14 @@ void func_80013D20(VehicleStuff *vehicle) { } else { var_a1 = func_8000D940(vehicle->position, &vehicle->waypointIndex, vehicle->someMultiplier, vehicle->someMultiplierTheSequel, 0); } - func_800224F0(&vehicle->rotation[1], var_a1, 100); + adjust_angle(&vehicle->rotation[1], var_a1, 100); temp_f0_3 = vehicle->position[0] - sp5C; temp_f2_2 = vehicle->position[2] - sp54; sp34[0] = vehicle->position[1]; sp34[1] = 0.0f; sp34[2] = sqrtf((temp_f0_3 * temp_f0_3) + (temp_f2_2 * temp_f2_2)); thing = get_angle_between_points(sp40, sp34); - func_800224F0(&vehicle->rotation[0], -thing, 100); + adjust_angle(&vehicle->rotation[0], -thing, 100); vehicle->velocity[0] = vehicle->position[0] - sp5C; vehicle->velocity[1] = vehicle->position[1] - sp58; vehicle->velocity[2] = vehicle->position[2] - sp54; @@ -7010,7 +7010,7 @@ void func_80015390(Camera *camera, UNUSED Player *player, UNUSED s32 arg2) { var_a2 = 0xA0 + (temp_s1->unk_078 / 16); } if (!((temp_s1->effects & 0x80) || (temp_s1->effects & 0x40))) { - func_800224F0(&camera->unk_2C, temp_s1->unk_02C[1], var_a2); + adjust_angle(&camera->unk_2C, temp_s1->unk_02C[1], var_a2); } func_8001D794(temp_s1, camera, sp64, &sp84, &sp80, &sp7C, camera->unk_2C); func_802ADDC8(&camera->unk_54, 10.0f, sp84, sp80, sp7C); diff --git a/src/code_8001F980.c b/src/code_8001F980.c index 6b14e27092..146a4a5f1c 100644 --- a/src/code_8001F980.c +++ b/src/code_8001F980.c @@ -21,14 +21,14 @@ #include "common_textures.h" #include "skybox_and_splitscreen.h" -s8 D_800DDB50[] = { +s8 gRenderingFramebufferByPlayer[] = { 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02 }; -s32 D_800DDB58 = 0; +s32 gPlayersToRenderCount = 0; // Can't find anything that actually references these... -void *D_800DDB5C[3] = { +UNUSED void *D_800DDB5C[3] = { gFramebuffer0, gFramebuffer1, gFramebuffer2 }; @@ -53,7 +53,7 @@ void func_8001F9E4(Player *player, Camera *camera, s8 arg2) { get_player_index_for_player(player); func_8001F980(&sp30, &sp2C); - + player->unk_002 &= ~(2 << (arg2 * 4)); player->unk_002 &= ~(8 << (arg2 * 4)); @@ -79,7 +79,7 @@ u16 check_player_camera_collision(Player *player, Camera *camera, f32 arg2, f32 s16 var_v0; u16 ret; - ret = 0; + ret = FALSE; switch (gActiveScreenMode) { /* irregular */ case SCREEN_MODE_1P: var_v0 = 0x293C; @@ -102,11 +102,13 @@ u16 check_player_camera_collision(Player *player, Camera *camera, f32 arg2, f32 sp54 = (arg2 * sins((camera->rot[1] + var_v0))) + camera->pos[0]; sp44 = (arg3 * coss((camera->rot[1] + 0x5FFA))) + camera->pos[2]; sp50 = (arg3 * sins((camera->rot[1] + 0x5FFA))) + camera->pos[0]; + sp64 = ((sp4C - player->pos[2]) * (sp54 - player->pos[0])) - ((sp48 - player->pos[2]) * (sp58 - player->pos[0])); sp60 = ((sp48 - player->pos[2]) * (sp50 - player->pos[0])) - ((sp44 - player->pos[2]) * (sp54 - player->pos[0])); sp5C = ((sp44 - player->pos[2]) * (sp58 - player->pos[0])) - ((sp4C - player->pos[2]) * (sp50 - player->pos[0])); + if (((sp64 >= 0) && (sp60 >= 0) && (sp5C >= 0)) || (((sp64) <= 0) && (sp60 <= 0) && (sp5C <= 0))) { - ret = 1; + ret = TRUE; } return ret; } @@ -123,23 +125,25 @@ u16 func_8001FD78(Player *player, f32 posX, UNUSED f32 arg2, f32 posZ) { f32 thing1; u16 ret; - ret = 0; + ret = FALSE; + sp58 = (70.0f * coss(((player->unk_0C0 - player->unk_02C[1]) - 0x71C))) + player->pos[2]; sp64 = (70.0f * sins(((player->unk_0C0 - player->unk_02C[1]) - 0x71C))) + player->pos[0]; sp54 = (70.0f * coss(((player->unk_0C0 - player->unk_02C[1]) + 0x71C))) + player->pos[2]; sp60 = (70.0f * sins(((player->unk_0C0 - player->unk_02C[1]) + 0x71C))) + player->pos[0]; sp50 = (10.0f * coss(((player->unk_0C0 - player->unk_02C[1]) + 0x1C70))) + player->pos[2]; sp5c = (10.0f * sins(((player->unk_0C0 - player->unk_02C[1]) + 0x1C70))) + player->pos[0]; + temp_f14 = ((sp58 - posZ) * (sp60 - posX)) - ((sp54 - posZ) * (sp64 - posX)); thing0 = ((sp54 - posZ) * (sp5c - posX)) - ((sp50 - posZ) * (sp60 - posX)); thing1 = ((sp50 - posZ) * (sp64 - posX)) - ((sp58 - posZ) * (sp5c - posX)); if (((temp_f14 >= 0) && (thing0 >= 0) && (thing1 >= 0)) || ((temp_f14 <= 0) && (thing0 <= 0) && (thing1 <= 0))) { - ret = 1; + ret = TRUE; } return ret; } -void func_80020000(Player *player, Camera *camera, s8 playerId, s8 arg3) { +void init_render_player(Player *player, Camera *camera, s8 playerId, s8 playerRenderId) { s32 pad[4]; s32 sp4C; s32 sp48; @@ -148,63 +152,64 @@ void func_80020000(Player *player, Camera *camera, s8 playerId, s8 arg3) { s32 temp_v0_2; if ((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) { - func_8001F9E4(player, camera, arg3); - temp_v0 = 2 << (arg3 << 2); + func_8001F9E4(player, camera, playerRenderId); + temp_v0 = 2 << (playerRenderId << 2); if (temp_v0 == (player->unk_002 & temp_v0)) { if (!(player->type & PLAYER_START_SEQUENCE)) { - func_8002934C(player, camera, arg3, playerId); + func_8002934C(player, camera, playerRenderId, playerId); } else { - func_8002934C(player, camera, arg3, playerId); + func_8002934C(player, camera, playerRenderId, playerId); player->slopeAccel = 0; player->unk_206 = 0; - player->unk_050[arg3] = 0; + player->unk_050[playerRenderId] = 0; } } func_8001F980(&sp4C, &sp48); - temp_v0_2 = 1 << (arg3 << 2); + temp_v0_2 = 1 << (playerRenderId << 2); if ((temp_v0 == (player->unk_002 & temp_v0)) && (temp_v0_2 == (player->unk_002 & temp_v0_2))) { if ((check_player_camera_collision(player, camera, D_80165570 + sp4C, D_80165572 + sp48) == 1) & 0xFFFF) { - D_80164AB0[D_800DDB58] = (s16) playerId; - D_80164AC0[D_800DDB58] = (s16) arg3; - D_80164AD0[D_800DDB58] = player; - D_800DDB58 += 1; - D_80165190[arg3][playerId] = 0; - D_801650D0[arg3][playerId] = player->animFrameSelector[arg3]; - D_80165110[arg3][playerId] = player->animGroupSelector[arg3]; - D_80165150[arg3][playerId] = player->unk_0A8; - D_801651D0[arg3][playerId] += 1; - if (D_801651D0[arg3][playerId] == 2) { - D_801651D0[arg3][playerId] = 0; + D_80164AB0[gPlayersToRenderCount] = (s16) playerId; + D_80164AC0[gPlayersToRenderCount] = (s16) playerRenderId; + D_80164AD0[gPlayersToRenderCount] = player; + gPlayersToRenderCount += 1; + D_80165190[playerRenderId][playerId] = 0; + D_801650D0[playerRenderId][playerId] = player->animFrameSelector[playerRenderId]; + D_80165110[playerRenderId][playerId] = player->animGroupSelector[playerRenderId]; + D_80165150[playerRenderId][playerId] = player->unk_0A8; + D_801651D0[playerRenderId][playerId] += 1; + if (D_801651D0[playerRenderId][playerId] == 2) { + D_801651D0[playerRenderId][playerId] = 0; } } else { if ((check_player_camera_collision(player, camera, D_80165574 + sp4C, D_80165576) == 1) & 0xFFFF) { - if ((sRenderingFramebuffer == D_800DDB50[playerId]) || ((D_801650D0[arg3][playerId] - player->animFrameSelector[arg3]) > 0x13) || ((D_801650D0[arg3][playerId] - player->animFrameSelector[arg3]) < -0x13) || (D_80165190[arg3][playerId] == (s16) 1U)) { - D_80164AB0[D_800DDB58] = (s16) playerId; - D_80164AC0[D_800DDB58] = (s16) arg3; - D_80164AD0[D_800DDB58] = player; - D_800DDB58 += 1; - D_801650D0[arg3][playerId] = player->animFrameSelector[arg3]; - D_80165110[arg3][playerId] = player->animGroupSelector[arg3]; - D_80165150[arg3][playerId] = player->unk_0A8; - D_80165190[arg3][playerId] = 0; - D_801651D0[arg3][playerId] += 1; - if (D_801651D0[arg3][playerId] == 2) { - D_801651D0[arg3][playerId] = 0; + if ((sRenderingFramebuffer == gRenderingFramebufferByPlayer[playerId]) || ((D_801650D0[playerRenderId][playerId] - player->animFrameSelector[playerRenderId]) > 0x13) || ((D_801650D0[playerRenderId][playerId] - player->animFrameSelector[playerRenderId]) < -0x13) || (D_80165190[playerRenderId][playerId] == (s16) 1U)) { + D_80164AB0[gPlayersToRenderCount] = (s16) playerId; + D_80164AC0[gPlayersToRenderCount] = (s16) playerRenderId; + D_80164AD0[gPlayersToRenderCount] = player; + gPlayersToRenderCount += 1; + D_801650D0[playerRenderId][playerId] = player->animFrameSelector[playerRenderId]; + D_80165110[playerRenderId][playerId] = player->animGroupSelector[playerRenderId]; + D_80165150[playerRenderId][playerId] = player->unk_0A8; + D_80165190[playerRenderId][playerId] = 0; + D_801651D0[playerRenderId][playerId] += 1; + if (D_801651D0[playerRenderId][playerId] == 2) { + D_801651D0[playerRenderId][playerId] = 0; } } } else { - if (((D_801650D0[arg3][playerId] - player->animFrameSelector[arg3]) > 0x13) || ((D_801650D0[arg3][playerId] - player->animFrameSelector[arg3]) < -0x13) || (D_80165190[arg3][playerId] == (s16) 1U)) { - D_80164AB0[D_800DDB58] = (s16) playerId; - D_80164AC0[D_800DDB58] = (s16) arg3; - D_80164AD0[D_800DDB58] = player; - D_800DDB58 += 1; - D_801650D0[arg3][playerId] = (s16) player->animFrameSelector[arg3]; - D_80165110[arg3][playerId] = player->animGroupSelector[arg3]; - D_80165150[arg3][playerId] = player->unk_0A8; - D_80165190[arg3][playerId] = 0; - D_801651D0[arg3][playerId] += 1; - if (D_801651D0[arg3][playerId] == 2) { - D_801651D0[arg3][playerId] = 0; + if (( + (D_801650D0[playerRenderId][playerId] - player->animFrameSelector[playerRenderId]) > 0x13) || ((D_801650D0[playerRenderId][playerId] - player->animFrameSelector[playerRenderId]) < -0x13) || (D_80165190[playerRenderId][playerId] == (s16) 1U)) { + D_80164AB0[gPlayersToRenderCount] = (s16) playerId; + D_80164AC0[gPlayersToRenderCount] = (s16) playerRenderId; + D_80164AD0[gPlayersToRenderCount] = player; + gPlayersToRenderCount += 1; + D_801650D0[playerRenderId][playerId] = (s16) player->animFrameSelector[playerRenderId]; + D_80165110[playerRenderId][playerId] = player->animGroupSelector[playerRenderId]; + D_80165150[playerRenderId][playerId] = player->unk_0A8; + D_80165190[playerRenderId][playerId] = 0; + D_801651D0[playerRenderId][playerId] += 1; + if (D_801651D0[playerRenderId][playerId] == 2) { + D_801651D0[playerRenderId][playerId] = 0; } } } @@ -229,7 +234,7 @@ void func_80020524(void) { } osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK); - for (i = 1; i < D_800DDB58; i++) { + for (i = 1; i < gPlayersToRenderCount; i++) { func_80027560(D_80164AD0[i], D_80164AB0[i], D_80164AC0[i], D_80164AC0[i], D_801651D0[D_80164AC0[i]][D_80164AB0[i]]); @@ -238,8 +243,8 @@ void func_80020524(void) { osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK); } - mio0decode(D_802DFB80[D_801651D0[D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]]][D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]].unk_00, - D_802BFB80[D_801651D0[D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]]][D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]].pixel_index_array); + mio0decode(D_802DFB80[D_801651D0[D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]]][D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]].unk_00, + D_802BFB80[D_801651D0[D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]]][D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]].pixel_index_array); } void func_8002088C(void) { @@ -257,14 +262,14 @@ void func_8002088C(void) { func_8006E634(gPlayerEight, 7, 1); } osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK); - for (var_s0 = 1; var_s0 < D_800DDB58; var_s0++) { + for (var_s0 = 1; var_s0 < gPlayersToRenderCount; var_s0++) { func_80027560(D_80164AD0[var_s0], D_80164AB0[var_s0], D_80164AC0[var_s0], D_80164AC0[var_s0], D_801651D0[D_80164AC0[var_s0]][D_80164AB0[var_s0]]); mio0decode(D_802DFB80[D_801651D0[D_80164AC0[var_s0 - 1]][D_80164AB0[var_s0 - 1]]][D_80164AC0[var_s0 - 1]][D_80164AB0[var_s0 - 1]].unk_00, D_802BFB80[D_801651D0[D_80164AC0[var_s0 - 1]][D_80164AB0[var_s0 - 1]]][D_80164AC0[var_s0 - 1]][D_80164AB0[var_s0 - 1]].pixel_index_array); osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK); } - mio0decode(D_802DFB80[D_801651D0[D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]]][D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]].unk_00, - D_802BFB80[D_801651D0[D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]]][D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]].pixel_index_array); + mio0decode(D_802DFB80[D_801651D0[D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]]][D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]].unk_00, + D_802BFB80[D_801651D0[D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]]][D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]].pixel_index_array); } void func_80020BF4(void) { @@ -276,14 +281,14 @@ void func_80020BF4(void) { func_8006E6BC(gPlayerThree, 2, 2); func_8006E6BC(gPlayerFour, 3, 2); osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK); - for (var_s0 = 1; var_s0 < D_800DDB58; var_s0++) { + for (var_s0 = 1; var_s0 < gPlayersToRenderCount; var_s0++) { func_80027560(D_80164AD0[var_s0], D_80164AB0[var_s0] + 4, D_80164AC0[var_s0], D_80164AC0[var_s0] - 2, D_801651D0[D_80164AC0[var_s0]][D_80164AB0[var_s0]]); mio0decode(D_802DFB80[D_801651D0[D_80164AC0[var_s0 - 1]][D_80164AB0[var_s0 - 1]]][D_80164AC0[var_s0 - 1] - 2][D_80164AB0[var_s0 - 1] + 4].unk_00, D_802BFB80[D_801651D0[D_80164AC0[var_s0 - 1]][D_80164AB0[var_s0 - 1]]][D_80164AC0[var_s0 - 1] - 2][D_80164AB0[var_s0 - 1] + 4].pixel_index_array); osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK); } - mio0decode(D_802DFB80[D_801651D0[D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]]][D_80164ABE[D_800DDB58] - 2][D_80164AAE[D_800DDB58] + 4].unk_00, - D_802BFB80[D_801651D0[D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]]][D_80164ABE[D_800DDB58] - 2][D_80164AAE[D_800DDB58] + 4].pixel_index_array); + mio0decode(D_802DFB80[D_801651D0[D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]]][D_80164ABE[gPlayersToRenderCount] - 2][D_80164AAE[gPlayersToRenderCount] + 4].unk_00, + D_802BFB80[D_801651D0[D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]]][D_80164ABE[gPlayersToRenderCount] - 2][D_80164AAE[gPlayersToRenderCount] + 4].pixel_index_array); } void func_80020F1C(void) { @@ -295,27 +300,27 @@ void func_80020F1C(void) { func_8006E744(gPlayerThree, 2, 3); func_8006E744(gPlayerFour, 3, 3); osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK); - for (var_s0 = 1; var_s0 < D_800DDB58; var_s0++) { + for (var_s0 = 1; var_s0 < gPlayersToRenderCount; var_s0++) { func_80027560(D_80164AD0[var_s0], D_80164AB0[var_s0] + 4, D_80164AC0[var_s0], D_80164AC0[var_s0] - 2, D_801651D0[D_80164AC0[var_s0]][D_80164AB0[var_s0]]); mio0decode(D_802DFB80[D_801651D0[D_80164AC0[var_s0 - 1]][D_80164AB0[var_s0 - 1]]][D_80164AC0[var_s0 - 1] - 2][D_80164AB0[var_s0 - 1] + 4].unk_00, D_802BFB80[D_801651D0[D_80164AC0[var_s0 - 1]][D_80164AB0[var_s0 - 1]]][D_80164AC0[var_s0 - 1] - 2][D_80164AB0[var_s0 - 1] + 4].pixel_index_array); osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK); } - mio0decode(D_802DFB80[D_801651D0[D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]]][D_80164ABE[D_800DDB58] - 2][D_80164AAE[D_800DDB58] + 4].unk_00, - D_802BFB80[D_801651D0[D_80164ABE[D_800DDB58]][D_80164AAE[D_800DDB58]]][D_80164ABE[D_800DDB58] - 2][D_80164AAE[D_800DDB58] + 4].pixel_index_array); + mio0decode(D_802DFB80[D_801651D0[D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]]][D_80164ABE[gPlayersToRenderCount] - 2][D_80164AAE[gPlayersToRenderCount] + 4].unk_00, + D_802BFB80[D_801651D0[D_80164ABE[gPlayersToRenderCount]][D_80164AAE[gPlayersToRenderCount]]][D_80164ABE[gPlayersToRenderCount] - 2][D_80164AAE[gPlayersToRenderCount] + 4].pixel_index_array); } -void func_80021244(Player *player, s8 arg1, s8 arg2) { +void try_render_player(Player *player, s8 playerId, s8 arg2) { if (((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) && ((player->type & 0x40) == 0)) { if ((player->unk_002 & 2 << (arg2 * 4)) == 2 << (arg2 * 4)) { - func_800267AC(player, arg1, arg2); + player_render(player, playerId, arg2); } } } -void func_800212B4(void) { +void render_players_on_screen_one(void) { UNUSED s32 pad; UNUSED char *sp3C[8] = { "S_MARIO", "S_LUIZI", "S_YOSSY", "S_KINOP", @@ -326,28 +331,28 @@ void func_800212B4(void) { "J_DONKY", "J_WARIO", "J_PEACH", "J_KUPPA", }; - D_800DDB58 = 0; - func_80020000(gPlayerOneCopy, camera1, 0U, 0U); - func_80020000(gPlayerTwo, camera1, 1U, 0U); - func_80020000(gPlayerThree, camera1, 2U, 0U); - func_80020000(gPlayerFour, camera1, 3U, 0U); + gPlayersToRenderCount = 0; + init_render_player(gPlayerOneCopy, camera1, 0U, 0U); + init_render_player(gPlayerTwo, camera1, 1U, 0U); + init_render_player(gPlayerThree, camera1, 2U, 0U); + init_render_player(gPlayerFour, camera1, 3U, 0U); if (gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) { - func_80020000(gPlayerFive, camera1, 4U, 0U); - func_80020000(gPlayerSix, camera1, 5U, 0U); - func_80020000(gPlayerSeven, camera1, 6U, 0U); - func_80020000(gPlayerEight, camera1, 7U, 0U); - } - func_80021244(gPlayerOne, 0U, 0U); - func_80021244(gPlayerTwo, 1U, 0U); - func_80021244(gPlayerThree, 2U, 0U); - func_80021244(gPlayerFour, 3U, 0U); + init_render_player(gPlayerFive, camera1, 4U, 0U); + init_render_player(gPlayerSix, camera1, 5U, 0U); + init_render_player(gPlayerSeven, camera1, 6U, 0U); + init_render_player(gPlayerEight, camera1, 7U, 0U); + } + try_render_player(gPlayerOne, 0U, 0U); + try_render_player(gPlayerTwo, 1U, 0U); + try_render_player(gPlayerThree, 2U, 0U); + try_render_player(gPlayerFour, 3U, 0U); if (gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) { - func_80021244(gPlayerFive, 4U, 0U); - func_80021244(gPlayerSix, 5U, 0U); - func_80021244(gPlayerSeven, 6U, 0U); - func_80021244(gPlayerEight, 7U, 0U); + try_render_player(gPlayerFive, 4U, 0U); + try_render_player(gPlayerSix, 5U, 0U); + try_render_player(gPlayerSeven, 6U, 0U); + try_render_player(gPlayerEight, 7U, 0U); } - if (D_800DDB58 != 0) { + if (gPlayersToRenderCount != 0) { func_80020524(); } else { func_8006E5AC(gPlayerOneCopy, 0, 0); @@ -361,12 +366,12 @@ void func_800212B4(void) { func_8006E5AC(gPlayerEight, 7, 0); } } - D_800DDB58 = 0; + gPlayersToRenderCount = 0; } // Hello, you've found the location of the bulk of the data section for this file -// For reasons beyound human comprehension it MUST be placed somewhere below -// func_800212B4 +// For reasons beyound human comprehension it MUST be placed somewhere below +// render_players_on_screen_one s32 junk[] = {0, 0, 0}; @@ -494,29 +499,29 @@ s32 D_800DDE74[] = { s32 maybeCompilerPadding = 0; -void func_800215DC(void) { - D_800DDB58 = 0; - func_80020000(gPlayerOneCopy, camera2, 0, 1); - func_80020000(gPlayerTwo, camera2, 1, 1); - func_80020000(gPlayerThree, camera2, 2, 1); - func_80020000(gPlayerFour, camera2, 3, 1); +void render_players_on_screen_two(void) { + gPlayersToRenderCount = 0; + init_render_player(gPlayerOneCopy, camera2, 0, 1); + init_render_player(gPlayerTwo, camera2, 1, 1); + init_render_player(gPlayerThree, camera2, 2, 1); + init_render_player(gPlayerFour, camera2, 3, 1); if (gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) { - func_80020000(gPlayerFive, camera2, 4, 1); - func_80020000(gPlayerSix, camera2, 5, 1); - func_80020000(gPlayerSeven, camera2, 6, 1); - func_80020000(gPlayerEight, camera2, 7, 1); - } - func_80021244(gPlayerOne, 0, 1); - func_80021244(gPlayerTwo, 1, 1); - func_80021244(gPlayerThree, 2, 1); - func_80021244(gPlayerFour, 3, 1); + init_render_player(gPlayerFive, camera2, 4, 1); + init_render_player(gPlayerSix, camera2, 5, 1); + init_render_player(gPlayerSeven, camera2, 6, 1); + init_render_player(gPlayerEight, camera2, 7, 1); + } + try_render_player(gPlayerOne, 0, 1); + try_render_player(gPlayerTwo, 1, 1); + try_render_player(gPlayerThree, 2, 1); + try_render_player(gPlayerFour, 3, 1); if (gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) { - func_80021244(gPlayerFive, 4, 1); - func_80021244(gPlayerSix, 5, 1); - func_80021244(gPlayerSeven, 6, 1); - func_80021244(gPlayerEight, 7, 1); + try_render_player(gPlayerFive, 4, 1); + try_render_player(gPlayerSix, 5, 1); + try_render_player(gPlayerSeven, 6, 1); + try_render_player(gPlayerEight, 7, 1); } - if (D_800DDB58 != 0) { + if (gPlayersToRenderCount != 0) { func_8002088C(); } else { func_8006E634(gPlayerOneCopy, 0, 1); @@ -530,20 +535,20 @@ void func_800215DC(void) { func_8006E634(gPlayerEight, 7, 1); } } - D_800DDB58 = 0; + gPlayersToRenderCount = 0; } -void func_8002186C(void) { - D_800DDB58 = 0; - func_80020000(gPlayerOneCopy, camera3, 0, 2); - func_80020000(gPlayerTwo, camera3, 1, 2); - func_80020000(gPlayerThree, camera3, 2, 2); - func_80020000(gPlayerFour, camera3, 3, 2); - func_80021244(gPlayerOne, 0, 2); - func_80021244(gPlayerTwo, 1, 2); - func_80021244(gPlayerThree, 2, 2); - func_80021244(gPlayerFour, 3, 2); - if (D_800DDB58 != 0) { +void render_players_on_screen_three(void) { + gPlayersToRenderCount = 0; + init_render_player(gPlayerOneCopy, camera3, 0, 2); + init_render_player(gPlayerTwo, camera3, 1, 2); + init_render_player(gPlayerThree, camera3, 2, 2); + init_render_player(gPlayerFour, camera3, 3, 2); + try_render_player(gPlayerOne, 0, 2); + try_render_player(gPlayerTwo, 1, 2); + try_render_player(gPlayerThree, 2, 2); + try_render_player(gPlayerFour, 3, 2); + if (gPlayersToRenderCount != 0) { func_80020BF4(); } else { func_8006E6BC(gPlayerOneCopy, 0, 2); @@ -551,20 +556,20 @@ void func_8002186C(void) { func_8006E6BC(gPlayerThree, 2, 2); func_8006E6BC(gPlayerFour, 3, 2); } - D_800DDB58 = 0; + gPlayersToRenderCount = 0; } -void func_800219BC(void) { - D_800DDB58 = 0; - func_80020000(gPlayerOneCopy, camera4, 0, 3); - func_80020000(gPlayerTwo, camera4, 1, 3); - func_80020000(gPlayerThree, camera4, 2, 3); - func_80020000(gPlayerFour, camera4, 3, 3); - func_80021244(gPlayerOne, 0, 3); - func_80021244(gPlayerTwo, 1, 3); - func_80021244(gPlayerThree, 2, 3); - func_80021244(gPlayerFour, 3, 3); - if (D_800DDB58 != 0) { +void render_players_on_screen_four(void) { + gPlayersToRenderCount = 0; + init_render_player(gPlayerOneCopy, camera4, 0, 3); + init_render_player(gPlayerTwo, camera4, 1, 3); + init_render_player(gPlayerThree, camera4, 2, 3); + init_render_player(gPlayerFour, camera4, 3, 3); + try_render_player(gPlayerOne, 0, 3); + try_render_player(gPlayerTwo, 1, 3); + try_render_player(gPlayerThree, 2, 3); + try_render_player(gPlayerFour, 3, 3); + if (gPlayersToRenderCount != 0) { func_80020F1C(); } else { func_8006E744(gPlayerOneCopy, 0, 3); @@ -572,7 +577,7 @@ void func_800219BC(void) { func_8006E744(gPlayerThree, 2, 3); func_8006E744(gPlayerFour, 3, 3); } - D_800DDB58 = 0; + gPlayersToRenderCount = 0; } void func_80021B0C(void) { @@ -588,16 +593,16 @@ void func_80021B0C(void) { } if (gGamestate == ENDING_SEQUENCE) { if (gPlayerOne->unk_044 & 0x2000) { - func_80024374(gPlayerOne, 0, 0); + render_player_shadow_credits(gPlayerOne, 0, 0); } if (gPlayerTwo->unk_044 & 0x2000) { - func_80024374(gPlayerTwo, 1, 0); + render_player_shadow_credits(gPlayerTwo, 1, 0); } if (gPlayerThree->unk_044 & 0x2000) { - func_80024374(gPlayerThree, 2, 0); + render_player_shadow_credits(gPlayerThree, 2, 0); } if (gPlayerFour->unk_044 & 0x2000) { - func_80024374(gPlayerFour, 3, 0); + render_player_shadow_credits(gPlayerFour, 3, 0); } } } @@ -714,32 +719,33 @@ void convert_to_fixed_point_matrix(Mtx *fixedPointMatrix, Mat4 arg1) { fixedPointMatrix->m[3][3] = ((s32) (arg1[3][2] * someMultiplier) << 0x10) | ((s32) (arg1[3][3] * someMultiplier) & 0xFFFF); } -s32 func_800224F0(s16 *arg0, s16 arg1, s16 arg2) { +bool adjust_angle(s16 *angle, s16 targetAngle, s16 step) { s16 temp_v0; - temp_v0 = arg1 - *arg0; - if (arg2 < 0) { - arg2 *= -1; + temp_v0 = targetAngle - *angle; + if (step < 0) { // abs of step + step *= -1; } + if (temp_v0 > 0) { - temp_v0 -= arg2; + temp_v0 -= step; if (temp_v0 >= 0) { - *arg0 = arg1 - temp_v0; + *angle = targetAngle - temp_v0; } else { - *arg0 = arg1; + *angle = targetAngle; } } else { - temp_v0 += arg2; + temp_v0 += step; if (temp_v0 <= 0) { - *arg0 = arg1 - temp_v0; + *angle = targetAngle - temp_v0; } else { - *arg0 = arg1; + *angle = targetAngle; } } - if (arg1 == *arg0) { - return 0; + if (targetAngle == *angle) { + return FALSE; } - return 1; + return TRUE; } void move_s32_towards(s32 *startingValue, s32 targetValue, f32 somePercent) { @@ -978,12 +984,12 @@ void func_80022E84(Player *player, s8 arg1, UNUSED s8 arg2, s8 arg3) { /** * Sets player shading/colour. */ -void change_player_color_effect_rgb(UNUSED Player *player, s8 arg1, s32 arg2, f32 arg3) { - gPlayerRedEffect[arg1] = (s16) ((f32)gPlayerRedEffect[arg1] - ((gPlayerRedEffect[arg1] - ((arg2 >> 16) & 0xFF)) * arg3)); +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)); - gPlayerGreenEffect[arg1] = (s16) ((f32)gPlayerGreenEffect[arg1] - ((gPlayerGreenEffect[arg1] - ((arg2 >> 8) & 0xFF)) * arg3)); + gPlayerGreenEffect[arg1] = (s16) ((f32)gPlayerGreenEffect[arg1] - ((gPlayerGreenEffect[arg1] - ((arg2 >> 8) & 0xFF)) * alpha)); - gPlayerBlueEffect[arg1] = (s16) ((f32)gPlayerBlueEffect[arg1] - ((gPlayerBlueEffect[arg1] - (arg2 & 0xFF)) * arg3)); + gPlayerBlueEffect[arg1] = (s16) ((f32)gPlayerBlueEffect[arg1] - ((gPlayerBlueEffect[arg1] - (arg2 & 0xFF)) * alpha)); } void change_player_color_effect_cmy(UNUSED Player *player, s8 arg1, s32 arg2, f32 arg3) { @@ -999,12 +1005,12 @@ void change_player_color_effect_cmy(UNUSED Player *player, s8 arg1, s32 arg2, f3 bool is_player_under_light_luigi_raceway(Player *player, s8 arg1) { switch (gCurrentCourseId) { case COURSE_LUIGI_RACEWAY: - if (((gNearestWaypointByPlayerId[arg1] >= 0x14F) && (gNearestWaypointByPlayerId[arg1] < 0x158)) - || ((gNearestWaypointByPlayerId[arg1] >= 0x15E) && (gNearestWaypointByPlayerId[arg1] < 0x164)) - || ((gNearestWaypointByPlayerId[arg1] >= 0x169) && (gNearestWaypointByPlayerId[arg1] < 0x170)) - || ((gNearestWaypointByPlayerId[arg1] >= 0x174) && (gNearestWaypointByPlayerId[arg1] < 0x17A)) + if (((gNearestWaypointByPlayerId[arg1] >= 0x14F) && (gNearestWaypointByPlayerId[arg1] < 0x158)) + || ((gNearestWaypointByPlayerId[arg1] >= 0x15E) && (gNearestWaypointByPlayerId[arg1] < 0x164)) + || ((gNearestWaypointByPlayerId[arg1] >= 0x169) && (gNearestWaypointByPlayerId[arg1] < 0x170)) + || ((gNearestWaypointByPlayerId[arg1] >= 0x174) && (gNearestWaypointByPlayerId[arg1] < 0x17A)) || ((gNearestWaypointByPlayerId[arg1] >= 0x17E) && (gNearestWaypointByPlayerId[arg1] < 0x184))) { // under a light in the tunnel - change_player_color_effect_rgb(player, arg1, GPACK_RGB888(0x1C, 0x00, 0x00), 0.3f); + 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; return TRUE; @@ -1016,14 +1022,14 @@ bool is_player_under_light_luigi_raceway(Player *player, s8 arg1) { } } -void func_800231D8(Player *player, s8 arg1) { +void render_light_environment_on_player(Player *player, s8 arg1) { switch(gCurrentCourseId) { case COURSE_BOWSER_CASTLE: if (((gNearestWaypointByPlayerId[arg1] >= 0x15) && (gNearestWaypointByPlayerId[arg1] < 0x2A)) || ((gNearestWaypointByPlayerId[arg1] >= 0x14D) && (gNearestWaypointByPlayerId[arg1] < 0x15C)) || ((gNearestWaypointByPlayerId[arg1] >= 0x1D1) && (gNearestWaypointByPlayerId[arg1] < 0x1E4)) || (player->unk_110.unk3C[2] >= 500.0f)) { // over lava - change_player_color_effect_rgb(player, arg1, GPACK_RGB888(0x34, 0x00, 0x00), 0.3f); + 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 (((gNearestWaypointByPlayerId[arg1] >= 0xF1) && (gNearestWaypointByPlayerId[arg1] < 0xF5)) @@ -1032,11 +1038,11 @@ void func_800231D8(Player *player, s8 arg1) { || ((gNearestWaypointByPlayerId[arg1] >= 0x10F) && (gNearestWaypointByPlayerId[arg1] < 0x113)) || ((gNearestWaypointByPlayerId[arg1] >= 0x145) && (gNearestWaypointByPlayerId[arg1] < 0x14A)) || ((gNearestWaypointByPlayerId[arg1] >= 0x15E) && (gNearestWaypointByPlayerId[arg1] < 0x163))) { // under a lamp - change_player_color_effect_rgb(player, arg1, 0x1C0000, 0.3f); + 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; } else { // normal color - change_player_color_effect_rgb(player, arg1, 0, 0.3f); + 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; } @@ -1060,17 +1066,17 @@ void func_800231D8(Player *player, s8 arg1) { || ((gNearestWaypointByPlayerId[arg1] >= 0x24C) && (gNearestWaypointByPlayerId[arg1] < 0x256)) || ((gNearestWaypointByPlayerId[arg1] >= 0x288) && (gNearestWaypointByPlayerId[arg1] < 0x269)) || ((gNearestWaypointByPlayerId[arg1] >= 0x274) && (gNearestWaypointByPlayerId[arg1] < 0x27E))) { // under a lamp - change_player_color_effect_rgb(player, arg1, 0x1C0000, 0.3f); + 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; - } else { // normal color - change_player_color_effect_rgb(player, arg1, 0, 0.3f); + } 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; } break; - default: // normal color - change_player_color_effect_rgb(player, arg1, 0, 0.3f); + 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; break; @@ -1081,7 +1087,7 @@ void func_800235AC(Player *player, s8 arg1) { s32 temp; if (((player->type & 0x100) == 0x100) && (player == gPlayerThree)) { - change_player_color_effect_rgb(player, arg1, 0x1C0000, 0.3f); + 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; return; @@ -1093,7 +1099,7 @@ void func_800235AC(Player *player, s8 arg1) { return; } if ((player->unk_0CA & 4) == 4) { - change_player_color_effect_rgb(player, arg1, 0, 1.0f); + change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 1.0f); change_player_color_effect_cmy(player, arg1, 0, 1.0f); return; } @@ -1103,7 +1109,7 @@ void func_800235AC(Player *player, s8 arg1) { return; } if ((player->unk_0CA & 0x20) == 0x20) { - change_player_color_effect_rgb(player, arg1, 0, 0.1f); + change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 0.1f); change_player_color_effect_cmy(player, arg1, 0, 0.1f); return; } @@ -1129,7 +1135,7 @@ void func_800235AC(Player *player, s8 arg1) { } if ((player->effects & 0x200) != 0) { temp = (s32)gCourseTimer - D_8018D930[arg1]; - if (temp <= 8) { + if (temp <= 8) { if (temp >= 7) { D_80164B80[arg1] += 10; @@ -1162,13 +1168,13 @@ void func_800235AC(Player *player, s8 arg1) { if (((player->boundingBoxCorners[3].unk_14 & 1) == 1) || ((player->boundingBoxCorners[3].unk_14 & 2) == 2) || ((player->boundingBoxCorners[0].unk_14 & 3) == 3)) { - change_player_color_effect_rgb(player, arg1, 0x000000, 0.3f); + change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 0.3f); change_player_color_effect_cmy(player, arg1, 0x6F6F6F, 0.3f); return; } - func_800231D8(player, arg1); + render_light_environment_on_player(player, arg1); if ((player->unk_0CA & 0x1000) == 0x1000) { - change_player_color_effect_rgb(player, arg1, 0, 0.3f); + change_player_color_effect_rgb(player, arg1, COLOR_BLACK, 0.3f); change_player_color_effect_cmy(player, arg1, 0xF0F0F0, 0.3f); } } @@ -1185,7 +1191,7 @@ void func_80023BF0(Player *player, s8 arg1, s8 arg2, s8 arg3) { } } -void func_80023C84(Player *player, s8 arg1, s8 arg2) { +void render_player_shadow(Player *player, s8 arg1, s8 arg2) { Mat4 sp118; UNUSED Mat4 pad; Vec3f spCC; @@ -1200,7 +1206,7 @@ void func_80023C84(Player *player, s8 arg1, s8 arg2) { temp_t9 = (u16)(player->unk_048[arg2] + player->unk_02C[1] + player->unk_0C0) / 128; // << 7) & 0xFFFF; spC0 = -player->unk_02C[1] - player->unk_0C0; - + spB0 = -coss(temp_t9 << 7) * 2; spAC = -sins(temp_t9 << 7) * 2; @@ -1220,11 +1226,11 @@ void func_80023C84(Player *player, s8 arg1, s8 arg2) { spB4[0] = player->unk_110.unk60[0]; spB4[2] = player->unk_110.unk60[2]; spB4[1] = player->unk_110.unk60[1]; - + spCC[0] = player->pos[0] + ((spB0 * sins(spC0)) + (spAC * coss(spC0))); spCC[1] = player->unk_074 + 1.0f; spCC[2] = player->pos[2] + ((spB0 * coss(spC0)) - (spAC * sins(spC0))); - set_transform_matrix(sp118, spB4, spCC, (spC0 + player->unk_042), gCharacterSize[player->characterId] * player->size + set_transform_matrix(sp118, spB4, spCC, (spC0 + player->unk_042), gCharacterSize[player->characterId] * player->size * var_f2); } else { spC4[0] = player->slopeAccel; @@ -1240,6 +1246,7 @@ void func_80023C84(Player *player, s8 arg1, s8 arg2) { convert_to_fixed_point_matrix(&gGfxPool->mtxShadow[arg1 + (arg2 * 8)], sp118); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxShadow[arg1 + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gDisplayListHead++, D_0D008D58); gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE); gDPLoadTextureBlock(gDisplayListHead++, D_8018D474, G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR @@ -1247,17 +1254,19 @@ void func_80023C84(Player *player, s8 arg1, s8 arg2) { func_8004B414(0, 0, 0, 0xFF); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E51D0[0], 4, 0); + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gDPLoadTextureBlock(gDisplayListHead++, (D_8018D474 + SOME_TEXTURE_POINTER_MATH), G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); func_8004B414(0, 0, 0, 0xFF); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E5210[0], 4, 0); + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); } -void func_80024374(Player *player, s8 arg1, s8 arg2) { +void render_player_shadow_credits(Player *player, s8 playerId, s8 arg2) { Mat4 sp118; UNUSED Mat4 pad; Vec3f spCC; @@ -1282,12 +1291,14 @@ void func_80024374(Player *player, s8 arg1, s8 arg2) { spCC[0] = player->pos[0] + ((spB0 * sins(spC0)) + (spAC * coss(spC0))); spCC[2] = player->pos[2] + ((spB0 * coss(spC0)) - (spAC * sins(spC0))); - spCC[1] = gObjectList[D_80183EA0[arg1]].pos[1] + sp94[arg1]; + spCC[1] = gObjectList[D_80183EA0[playerId]].pos[1] + sp94[playerId]; mtxf_translate_rotate(sp118, spCC, spC4); mtxf_scale2(sp118, gCharacterSize[player->characterId] * player->size); - convert_to_fixed_point_matrix(&gGfxPool->mtxShadow[arg1 + (arg2 * 8)], sp118); - gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxShadow[arg1 + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + convert_to_fixed_point_matrix(&gGfxPool->mtxShadow[playerId + (arg2 * 8)], sp118); + + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxShadow[playerId + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gDisplayListHead++, D_0D008D58); gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE); gDPLoadTextureBlock(gDisplayListHead++, D_8018D474, G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, @@ -1295,17 +1306,19 @@ void func_80024374(Player *player, s8 arg1, s8 arg2) { func_8004B414(0, 0, 0, 0x000000D0); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E51D0[0], 4, 0); + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gDPLoadTextureBlock(gDisplayListHead++, (D_8018D474 + SOME_TEXTURE_POINTER_MATH), G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); func_8004B414(0, 0, 0, 0x000000D0); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E5210[0], 4, 0); + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); } -void player_render(Player *player, s8 arg1, s8 arg2, s8 arg3) { +void kart_render(Player *player, s8 playerId, s8 arg2, s8 arg3) { s32 pad; Mat4 sp1A4; s32 pad2[17]; @@ -1348,63 +1361,97 @@ void player_render(Player *player, s8 arg1, s8 arg2, s8 arg3) { } } #ifdef AVOID_UB - D_80164B04 = &D_802F1F80[D_801651D0[arg2][arg1]][arg2][arg1]; + gPlayerPalette = &D_802F1F80[D_801651D0[arg2][playerId]][arg2][playerId]; #else - D_80164B04 = &D_802F1F80[D_801651D0[arg2][arg1]][arg2][arg1 * 0x100]; + gPlayerPalette = &D_802F1F80[D_801651D0[arg2][playerId]][arg2][playerId * 0x100]; #endif if ((arg2 == 0) || (arg2 == 1)) { - D_80164B08 = &D_802BFB80[D_801651D0[arg2][arg1]][arg2][arg1].pixel_index_array[0]; - D_80164B0C = &D_802BFB80[D_801651D0[arg2][arg1]][arg2][arg1].pixel_index_array[0x7C0]; + D_80164B08 = &D_802BFB80[D_801651D0[arg2][playerId]][arg2][playerId].pixel_index_array[0]; + D_80164B0C = &D_802BFB80[D_801651D0[arg2][playerId]][arg2][playerId].pixel_index_array[0x7C0]; } else { - D_80164B08 = &D_802BFB80[D_801651D0[arg2][arg1]][arg2 - 1][arg1 - 4].pixel_index_array[0]; - D_80164B0C = &D_802BFB80[D_801651D0[arg2][arg1]][arg2 - 1][arg1 - 4].pixel_index_array[0x7C0]; + D_80164B08 = &D_802BFB80[D_801651D0[arg2][playerId]][arg2 - 1][playerId - 4].pixel_index_array[0]; + D_80164B0C = &D_802BFB80[D_801651D0[arg2][playerId]][arg2 - 1][playerId - 4].pixel_index_array[0x7C0]; } mtxf_translate_rotate(sp1A4, sp154, sp14C); mtxf_scale2(sp1A4, gCharacterSize[player->characterId] * player->size); - convert_to_fixed_point_matrix(&gGfxPool->mtxKart[arg1 + (arg2 * 8)], sp1A4); + convert_to_fixed_point_matrix(&gGfxPool->mtxKart[playerId + (arg2 * 8)], sp1A4); + if ((player->effects & 0x80000000) == 0x80000000) { - if (arg2 == arg1) { - gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxKart[arg1 + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + if (arg2 == playerId) { + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxKart[playerId + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gDisplayListHead++, common_setting_render_character); - gDPLoadTLUT_pal256(gDisplayListHead++, D_80164B04); + gDPLoadTLUT_pal256(gDisplayListHead++, gPlayerPalette); gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); - func_8004B614(gPlayerRedEffect[arg1], gPlayerGreenEffect[arg1], gPlayerBlueEffect[arg1], gPlayerCyanEffect[arg1], gPlayerMagentaEffect[arg1], gPlayerYellowEffect[arg1], (s32) player->unk_0C6); + func_8004B614( + gPlayerRedEffect[playerId], + gPlayerGreenEffect[playerId], + gPlayerBlueEffect[playerId], + gPlayerCyanEffect[playerId], + gPlayerMagentaEffect[playerId], + gPlayerYellowEffect[playerId], + (s32) player->unk_0C6 + ); gDPSetRenderMode(gDisplayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); } else { - gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxKart[arg1 + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxKart[playerId + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gDisplayListHead++, common_setting_render_character); - gDPLoadTLUT_pal256(gDisplayListHead++, D_80164B04); + gDPLoadTLUT_pal256(gDisplayListHead++, gPlayerPalette); gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); - func_8004B614(gPlayerRedEffect[arg1], gPlayerGreenEffect[arg1], gPlayerBlueEffect[arg1], gPlayerCyanEffect[arg1], gPlayerMagentaEffect[arg1], gPlayerYellowEffect[arg1], D_8018D970[arg1]); + func_8004B614( + gPlayerRedEffect[playerId], + gPlayerGreenEffect[playerId], + gPlayerBlueEffect[playerId], + gPlayerCyanEffect[playerId], + gPlayerMagentaEffect[playerId], + gPlayerYellowEffect[playerId], + D_8018D970[playerId] + ); gDPSetRenderMode(gDisplayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); } } else if (((player->unk_0CA & 4) == 4) || (player->statusEffects & 0x08000000) || (player->statusEffects & 0x04000000)) { - gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxKart[arg1 + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxKart[playerId + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gDisplayListHead++, common_setting_render_character); - gDPLoadTLUT_pal256(gDisplayListHead++, D_80164B04); + gDPLoadTLUT_pal256(gDisplayListHead++, gPlayerPalette); gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); - func_8004B614(gPlayerRedEffect[arg1], gPlayerGreenEffect[arg1], gPlayerBlueEffect[arg1], gPlayerCyanEffect[arg1], gPlayerMagentaEffect[arg1], gPlayerYellowEffect[arg1], (s32) player->unk_0C6); + func_8004B614( + gPlayerRedEffect[playerId], + gPlayerGreenEffect[playerId], + gPlayerBlueEffect[playerId], + gPlayerCyanEffect[playerId], + gPlayerMagentaEffect[playerId], + gPlayerYellowEffect[playerId], + (s32) player->unk_0C6 + ); gDPSetAlphaCompare(gDisplayListHead++, G_AC_DITHER); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2); } else { - gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxKart[arg1 + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxKart[playerId + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gDisplayListHead++, common_setting_render_character); - gDPLoadTLUT_pal256(gDisplayListHead++, D_80164B04); + gDPLoadTLUT_pal256(gDisplayListHead++, gPlayerPalette); gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); - func_8004B614(gPlayerRedEffect[arg1], gPlayerGreenEffect[arg1], gPlayerBlueEffect[arg1], gPlayerCyanEffect[arg1], gPlayerMagentaEffect[arg1], gPlayerYellowEffect[arg1], (s32) player->unk_0C6); + func_8004B614( + gPlayerRedEffect[playerId], + gPlayerGreenEffect[playerId], + gPlayerBlueEffect[playerId], + gPlayerCyanEffect[playerId], + gPlayerMagentaEffect[playerId], + gPlayerYellowEffect[playerId], + (s32) player->unk_0C6); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); } + gDPLoadTextureBlock(gDisplayListHead++, D_80164B08, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPVertex(gDisplayListHead++, &D_800DDBB4[arg1][arg3], 4, 0); + gSPVertex(gDisplayListHead++, &D_800DDBB4[playerId][arg3], 4, 0); gSPDisplayList(gDisplayListHead++, common_square_plain_render); + gDPLoadTextureBlock(gDisplayListHead++, D_80164B0C, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPVertex(gDisplayListHead++, &D_800DDBB4[arg1][arg3 + 4], 4, 0); + gSPVertex(gDisplayListHead++, &D_800DDBB4[playerId][arg3 + 4], 4, 0); gSPDisplayList(gDisplayListHead++, common_square_plain_render); gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); gDPSetAlphaCompare(gDisplayListHead++, G_AC_NONE); } -void ghost_render(Player *player, s8 arg1, s8 arg2, s8 arg3) { +void ghost_render(Player *player, s8 playerId, s8 arg2, s8 arg3) { s32 pad; Mat4 sp12C; s32 pad2[17]; @@ -1432,37 +1479,49 @@ void ghost_render(Player *player, s8 arg1, s8 arg2, s8 arg3) { spDC[0] = player->pos[0] + spD0; spDC[2] = player->pos[2] + spC8; #ifdef AVOID_UB - D_80164B04 = &D_802F1F80[D_801651D0[arg2][arg1]][arg2][arg1]; + gPlayerPalette = &D_802F1F80[D_801651D0[arg2][playerId]][arg2][playerId]; #else - D_80164B04 = &D_802F1F80[D_801651D0[arg2][arg1]][arg2][arg1 * 0x100]; + gPlayerPalette = &D_802F1F80[D_801651D0[arg2][playerId]][arg2][playerId * 0x100]; #endif if ((arg2 == 0) || (arg2 == 1)) { - D_80164B08 = &D_802BFB80[D_801651D0[arg2][arg1]][arg2][arg1].pixel_index_array[0]; - D_80164B0C = &D_802BFB80[D_801651D0[arg2][arg1]][arg2][arg1].pixel_index_array[0x7C0]; + D_80164B08 = &D_802BFB80[D_801651D0[arg2][playerId]][arg2][playerId].pixel_index_array[0]; + D_80164B0C = &D_802BFB80[D_801651D0[arg2][playerId]][arg2][playerId].pixel_index_array[0x7C0]; } else { - D_80164B08 = &D_802BFB80[D_801651D0[arg2][arg1]][arg2 - 1][arg1 - 4].pixel_index_array[0]; - D_80164B0C = &D_802BFB80[D_801651D0[arg2][arg1]][arg2 - 1][arg1 - 4].pixel_index_array[0x7C0]; + D_80164B08 = &D_802BFB80[D_801651D0[arg2][playerId]][arg2 - 1][playerId - 4].pixel_index_array[0]; + D_80164B0C = &D_802BFB80[D_801651D0[arg2][playerId]][arg2 - 1][playerId - 4].pixel_index_array[0x7C0]; } + mtxf_translate_rotate(sp12C, spDC, spD4); mtxf_scale2(sp12C, gCharacterSize[player->characterId] * player->size); - convert_to_fixed_point_matrix(&gGfxPool->mtxKart[arg1 + (arg2 * 8)], sp12C); - gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxKart[arg1 + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + convert_to_fixed_point_matrix(&gGfxPool->mtxKart[playerId + (arg2 * 8)], sp12C); + + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxKart[playerId + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gDisplayListHead++, common_setting_render_character); - gDPLoadTLUT_pal256(gDisplayListHead++, D_80164B04); + gDPLoadTLUT_pal256(gDisplayListHead++, gPlayerPalette); gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); - func_8004B614(gPlayerRedEffect[arg1], gPlayerGreenEffect[arg1], gPlayerBlueEffect[arg1], gPlayerCyanEffect[arg1], gPlayerMagentaEffect[arg1], gPlayerYellowEffect[arg1], spC2); + func_8004B614( + gPlayerRedEffect[playerId], + gPlayerGreenEffect[playerId], + gPlayerBlueEffect[playerId], + gPlayerCyanEffect[playerId], + gPlayerMagentaEffect[playerId], + gPlayerYellowEffect[playerId], + spC2 + ); gDPSetRenderMode(gDisplayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); + gDPLoadTextureBlock(gDisplayListHead++, D_80164B08, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPVertex(gDisplayListHead++, &D_800DDBB4[arg1][arg3], 4, 0); + gSPVertex(gDisplayListHead++, &D_800DDBB4[playerId][arg3], 4, 0); gSPDisplayList(gDisplayListHead++, common_square_plain_render); + gDPLoadTextureBlock(gDisplayListHead++, D_80164B0C, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPVertex(gDisplayListHead++, &D_800DDBB4[arg1][arg3 + 4], 4, 0); + gSPVertex(gDisplayListHead++, &D_800DDBB4[playerId][arg3 + 4], 4, 0); gSPDisplayList(gDisplayListHead++, common_square_plain_render); gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); gDPSetAlphaCompare(gDisplayListHead++, G_AC_NONE); } -void func_80025DE8(Player *player, s8 arg1, s8 arg2, s8 arg3) { +void func_80025DE8(Player *player, s8 playerId, s8 arg2, s8 arg3) { Mat4 spA8; Vec3f sp9C; Vec3s sp94; @@ -1473,25 +1532,37 @@ void func_80025DE8(Player *player, s8 arg1, s8 arg2, s8 arg3) { sp94[0] = -0x00B6; sp94[1] = player->unk_048[arg2]; sp94[2] = player->unk_050[arg2]; + mtxf_translate_rotate(spA8, sp9C, sp94); mtxf_scale2(spA8, gCharacterSize[player->characterId] * player->size); convert_to_fixed_point_matrix(&gGfxPool->mtxEffect[gMatrixEffectCount], spA8); + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxEffect[gMatrixEffectCount]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gDisplayListHead++, D_0D008D10); gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); - func_8004B614((s32) gPlayerRedEffect[arg1], (s32) gPlayerGreenEffect[arg1], (s32) gPlayerBlueEffect[arg1], (s32) gPlayerCyanEffect[arg1], (s32) gPlayerMagentaEffect[arg1], (s32) gPlayerYellowEffect[arg1], 0x00000040); + func_8004B614( + gPlayerRedEffect[playerId], + gPlayerGreenEffect[playerId], + gPlayerBlueEffect[playerId], + gPlayerCyanEffect[playerId], + gPlayerMagentaEffect[playerId], + gPlayerYellowEffect[playerId], + 0x00000040 + ); gDPSetRenderMode(gDisplayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); + gDPLoadTextureBlock(gDisplayListHead++, D_80164B08, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPVertex(gDisplayListHead++, &D_800DDBB4[arg1][arg3], 4, 0); + gSPVertex(gDisplayListHead++, &D_800DDBB4[playerId][arg3], 4, 0); gSPDisplayList(gDisplayListHead++, common_square_plain_render); + gDPLoadTextureBlock(gDisplayListHead++, D_80164B0C, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPVertex(gDisplayListHead++, &D_800DDBB4[arg1][arg3 + 4], 4, 0); + gSPVertex(gDisplayListHead++, &D_800DDBB4[playerId][arg3 + 4], 4, 0); gSPDisplayList(gDisplayListHead++, common_square_plain_render); gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); gMatrixEffectCount += 1; } -void player_ice_reflection_render(Player *player, s8 arg1, s8 arg2, s8 arg3) { +void player_ice_reflection_render(Player *player, s8 playerId, s8 arg2, s8 arg3) { Mat4 spA8; Vec3f sp9C; Vec3s sp94; @@ -1507,58 +1578,68 @@ void player_ice_reflection_render(Player *player, s8 arg1, s8 arg2, s8 arg3) { } else { arg3 = 0; } + mtxf_translate_rotate(spA8, sp9C, sp94); mtxf_scale2(spA8, gCharacterSize[player->characterId] * player->size); convert_to_fixed_point_matrix(&gGfxPool->mtxEffect[gMatrixEffectCount], spA8); + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxEffect[gMatrixEffectCount]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gDisplayListHead++, common_setting_render_character); gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); - func_8004B614((s32) gPlayerRedEffect[arg1], (s32) gPlayerGreenEffect[arg1], (s32) gPlayerBlueEffect[arg1], (s32) gPlayerCyanEffect[arg1], (s32) gPlayerMagentaEffect[arg1], (s32) gPlayerYellowEffect[arg1], (s16) player->unk_0C6 / 2); + func_8004B614( + gPlayerRedEffect[playerId], + gPlayerGreenEffect[playerId], + gPlayerBlueEffect[playerId], + gPlayerCyanEffect[playerId], + gPlayerMagentaEffect[playerId], + gPlayerYellowEffect[playerId], + (s16) player->unk_0C6 / 2 + ); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2); gDPLoadTextureBlock(gDisplayListHead++, D_80164B08, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPVertex(gDisplayListHead++, &D_800DDBB4[arg1][arg3], 4, 0); + gSPVertex(gDisplayListHead++, &D_800DDBB4[playerId][arg3], 4, 0); gSPDisplayList(gDisplayListHead++, common_square_plain_render); gDPLoadTextureBlock(gDisplayListHead++, D_80164B0C, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPVertex(gDisplayListHead++, &D_800DDBB4[arg1][arg3 + 4], 4, 0); + gSPVertex(gDisplayListHead++, &D_800DDBB4[playerId][arg3 + 4], 4, 0); gSPDisplayList(gDisplayListHead++, common_square_plain_render); gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); gMatrixEffectCount += 1; } -void func_800267AC(Player *player, s8 arg1, s8 arg2) { +void player_render(Player *player, s8 playerId, s8 arg2) { s32 pad[2]; s32 temp_t1; s32 var_v1; OSMesg *sp34; - func_80026B4C(player, arg1, arg2, D_801651D0[arg2][arg1]); + func_80026B4C(player, playerId, arg2, D_801651D0[arg2][playerId]); if (!(player->unk_002 & (4 << (arg2 * 4)))) { var_v1 = 0; } else { var_v1 = 8; } - func_80023BF0(player, arg1, arg2, var_v1); + func_80023BF0(player, playerId, arg2, var_v1); temp_t1 = 8 << (arg2 * 4); if ((temp_t1 == (player->unk_002 & temp_t1)) && (player->unk_110.unk3C[2] <= 50.0f) && (player->unk_0F8 != 9)) { if ((player->effects & 0x80000000) == 0x80000000) { - if (arg1 == arg2) { - func_80023C84(player, arg1, arg2); + if (playerId == arg2) { + render_player_shadow(player, playerId, arg2); } } else { - func_80023C84(player, arg1, arg2); + render_player_shadow(player, playerId, arg2); } } if ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB) { - player_render(player, arg1, arg2, var_v1); + kart_render(player, playerId, arg2, var_v1); } else { - ghost_render(player, arg1, arg2, var_v1); + ghost_render(player, playerId, arg2, var_v1); } osRecvMesg(&gDmaMesgQueue, &sp34, OS_MESG_BLOCK); if ((temp_t1 == (player->unk_002 & temp_t1)) && (player->unk_0F8 == 9) && ((player->unk_0CA & 1) != 1) && (player->unk_110.unk3C[2] <= 30.0f)) { - player_ice_reflection_render(player, arg1, arg2, var_v1); + player_ice_reflection_render(player, playerId, arg2, var_v1); } if (player->boostPower >= 2.0f) { - func_80025DE8(player, arg1, arg2, var_v1); + func_80025DE8(player, playerId, arg2, var_v1); } } @@ -1591,27 +1672,27 @@ void func_80026A48(Player *player, s8 arg1) { #define D_802F1F80_WHEEL(a, b, c) &D_802F1F80[a][b][(c * 0x100) + 0xC0] #endif -void func_80026B4C(Player *player, s8 arg1, s8 arg2, s8 arg3) { - s16 temp_t0 = D_801650D0[arg2][arg1]; - s16 temp_t1 = D_80165110[arg2][arg1]; +void func_80026B4C(Player *player, s8 playerId, s8 arg2, s8 arg3) { + s16 temp_t0 = D_801650D0[arg2][playerId]; + s16 temp_t1 = D_80165110[arg2][playerId]; s16 temp_t2 = player->unk_240; s16 temp_num = 0x40; // setting this as a variable gets rid of regalloc - + if (((player->effects & 0x4000) == 0x4000) && ((player->type & PLAYER_START_SEQUENCE) == 0)) { if (((player->effects & 0x80) != 0x80) && ((player->effects & 0x40) != 0x40) && ((player->effects & 0x20000) != 0x20000) && ((player->effects & 0x80000) != 0x80000) && ((player->effects & 0x800000) != 0x800000) && ((player->unk_044 & 0x800) == 0)) { if (temp_t0 <= 20) { - func_80027C74(player, D_800DDE34[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, arg1), 0x80); + func_80027C74(player, D_800DDE34[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, playerId), 0x80); } else { - func_80027C74(player, D_800DDE54[player->characterId][temp_t1] + (temp_t0 - 21) * (temp_num * 4) + ((temp_t2 >> 8) * 0x40) + 0x600, D_802F1F80_WHEEL(arg3, arg2, arg1), 0x80); + func_80027C74(player, D_800DDE54[player->characterId][temp_t1] + (temp_t0 - 21) * (temp_num * 4) + ((temp_t2 >> 8) * 0x40) + 0x600, D_802F1F80_WHEEL(arg3, arg2, playerId), 0x80); } } else { if (temp_t0 == 0) { - func_80027C74(player, D_800DDE34[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, arg1), 0x80); + func_80027C74(player, D_800DDE34[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, playerId), 0x80); } else { - func_80027C74(player, D_800DDE54[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, arg1), 0x80); + func_80027C74(player, D_800DDE54[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, playerId), 0x80); } } } else { @@ -1620,15 +1701,15 @@ void func_80026B4C(Player *player, s8 arg1, s8 arg2, s8 arg3) { && ((player->effects & 0x20000) != 0x20000) && ((player->unk_044 & 0x800) == 0)) { if (temp_t0 <= 20) { - func_80027C74(player, D_800DDE34[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, arg1), 0x80); + func_80027C74(player, D_800DDE34[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, playerId), 0x80); } else { - func_80027C74(player, D_800DDE54[player->characterId][temp_t1] + (temp_t0 - 21) * (temp_num * 4) + ((temp_t2 >> 8) * 0x40) + 0x600, D_802F1F80_WHEEL(arg3, arg2, arg1), 0x80); + func_80027C74(player, D_800DDE54[player->characterId][temp_t1] + (temp_t0 - 21) * (temp_num * 4) + ((temp_t2 >> 8) * 0x40) + 0x600, D_802F1F80_WHEEL(arg3, arg2, playerId), 0x80); } } else { if (temp_t0 == 0) { - func_80027C74(player, D_800DDE34[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, arg1), 0x80); + func_80027C74(player, D_800DDE34[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, playerId), 0x80); } else { - func_80027C74(player, D_800DDE54[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, arg1), 0x80); + func_80027C74(player, D_800DDE54[player->characterId][temp_t1] + (temp_t0 * temp_num * 4) + ((temp_t2 >> 8) * 0x40), D_802F1F80_WHEEL(arg3, arg2, playerId), 0x80); } } } diff --git a/src/code_8001F980.h b/src/code_8001F980.h index 703a74796f..a83dc4d473 100644 --- a/src/code_8001F980.h +++ b/src/code_8001F980.h @@ -13,16 +13,16 @@ void func_8001F980(s32*, s32*); void func_8001F9E4(Player*, Camera*, s8); u16 check_player_camera_collision(Player*, Camera*, f32, f32); u16 func_8001FD78(Player*, f32, f32, f32); -void func_80020000(Player*, Camera*, s8, s8); +void init_render_player(Player*, Camera*, s8, s8); void func_80020524(void); void func_8002088C(void); void func_80020BF4(void); void func_80020F1C(void); -void func_80021244(Player*, s8, s8); -void func_800212B4(void); -void func_800215DC(void); -void func_8002186C(void); -void func_800219BC(void); +void try_render_player(Player*, s8, s8); +void render_players_on_screen_one(void); +void render_players_on_screen_two(void); +void render_players_on_screen_three(void); +void render_players_on_screen_four(void); void func_80021B0C(void); void func_80021C78(void); void func_80021D40(void); @@ -32,7 +32,7 @@ void func_80021F50(Mat4, Vec3f); void mtxf_scale2(Mat4, f32); void func_80021FF8(Mtx*, Mat4); void convert_to_fixed_point_matrix(Mtx*, Mat4); -s32 func_800224F0(s16*, s16, s16); +s32 adjust_angle(s16*, s16, s16); void move_s32_towards(s32*, s32, f32); void move_f32_towards(f32*, f32, f32); void move_s16_towards(s16*, s16, f32); @@ -49,16 +49,16 @@ void func_80022E84(Player*, s8, s8, s8); void change_player_color_effect_rgb(Player*, s8, s32, f32); void change_player_color_effect_cmy(Player*, s8, s32, f32); s32 is_player_under_light_luigi_raceway(Player*, s8); -void func_800231D8(Player*, s8); +void render_light_environment_on_player(Player*, s8); void func_800235AC(Player*, s8); void func_80023BF0(Player*, s8, s8, s8); -void func_80023C84(Player*, s8, s8); -void func_80024374(Player*, s8, s8); -void player_render(Player*, s8, s8, s8); +void render_player_shadow(Player*, s8, s8); +void render_player_shadow_credits(Player*, s8, s8); +void kart_render(Player*, s8, s8, s8); void ghost_render(Player*, s8, s8, s8); void func_80025DE8(Player*, s8, s8, s8); void player_ice_reflection_render(Player*, s8, s8, s8); -void func_800267AC(Player*, s8, s8); +void player_render(Player*, s8, s8); void func_80026A48(Player*, s8); void func_80026B4C(Player*, s8, s8, s8); void func_80030A34(Player*); @@ -67,7 +67,7 @@ void func_80027024(s32, s32, s32); /* This is where I'd put my static data, if I had any */ -extern struct_D_802F1F80 *D_80164B04; +extern struct_D_802F1F80 *gPlayerPalette; extern u8 *D_80164B08; extern u8 *D_80164B0C; @@ -91,7 +91,7 @@ extern s32 D_8018D930[]; extern Gfx common_square_plain_render[]; extern Gfx D_0D008D58[]; -extern s32 D_800DDB58; +extern s32 gPlayersToRenderCount; extern void *D_800DDB5C[]; extern Vtx *D_800DDBB4[]; extern f32 gCharacterSize[]; diff --git a/src/ending/code_80281C40.c b/src/ending/code_80281C40.c index 0780f99814..dd387d256e 100644 --- a/src/ending/code_80281C40.c +++ b/src/ending/code_80281C40.c @@ -76,7 +76,7 @@ void func_80281D00(void) { mtxf_identity(matrix); render_set_position(matrix, 0); gSPDisplayList(gDisplayListHead++, VIRTUAL_TO_PHYSICAL2(&D_80284F70)); - func_800212B4(); + render_players_on_screen_one(); gSPDisplayList(gDisplayListHead++, VIRTUAL_TO_PHYSICAL2(&D_80284EE0)); update_actors_loop(); func_80058090(0); diff --git a/src/player_controller.c b/src/player_controller.c index d4b66887fa..a6a0fb13e0 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -2177,7 +2177,7 @@ void func_8002D028(Player *player, s8 arg1) { temp_f18 = sqrtf((sp4C[0] - player->pos[0]) * (sp4C[0] - player->pos[0])+ (sp4C[2] - player->pos[2]) * (sp4C[2] - player->pos[2])); if (temp_f18 <= 8.0f) { - func_800224F0(&player->unk_02C[1], -0x8000, 0x016C); + adjust_angle(&player->unk_02C[1], -0x8000, 0x016C); if ((player->unk_02C[1] < (-0x7F41)) || (player->unk_02C[1] > 0x7F41)) { player->type &= ~0x0200; } diff --git a/src/racing/skybox_and_splitscreen.c b/src/racing/skybox_and_splitscreen.c index 6e7079a6a1..c6bfbd0f87 100644 --- a/src/racing/skybox_and_splitscreen.c +++ b/src/racing/skybox_and_splitscreen.c @@ -802,7 +802,7 @@ void func_802A59A4(void) { } render_course_actors(D_800DC5EC); func_80058090(0); - func_800212B4(); + render_players_on_screen_one(); func_8029122C(D_800DC5EC, 0); func_80021B0C(); func_802A2F34(D_800DC5EC); @@ -851,7 +851,7 @@ void func_802A5CB4(void) { } render_course_actors(D_800DC5EC); func_80058090(1); - func_800212B4(); + render_players_on_screen_one(); func_8029122C(D_800DC5EC, 0); func_80021B0C(); func_802A2F34(D_800DC5EC); @@ -898,7 +898,7 @@ void func_802A5FAC(void) { } render_course_actors(D_800DC5F0); func_80058090(2); - func_800215DC(); + render_players_on_screen_two(); func_8029122C(D_800DC5F0, 1); func_80021C78(); func_802A2F34(D_800DC5F0); @@ -947,7 +947,7 @@ void func_802A62A4(void) { } render_course_actors(D_800DC5EC); func_80058090(3); - func_800212B4(); + render_players_on_screen_one(); func_8029122C(D_800DC5EC, 0); func_80021B0C(); func_802A2F34(D_800DC5EC); @@ -996,7 +996,7 @@ void func_802A65B8(void) { } render_course_actors(D_800DC5F0); func_80058090(4); - func_800215DC(); + render_players_on_screen_two(); func_8029122C(D_800DC5F0, 1); func_80021C78(); func_802A2F34(D_800DC5F0); @@ -1043,7 +1043,7 @@ void func_802A68CC(void) { } render_course_actors(D_800DC5EC); func_80058090(8); - func_800212B4(); + render_players_on_screen_one(); func_8029122C(D_800DC5EC, 0); func_80021B0C(); func_802A2F34(D_800DC5EC); @@ -1090,7 +1090,7 @@ void func_802A6BB0(void) { } render_course_actors(D_800DC5F0); func_80058090(9); - func_800215DC(); + render_players_on_screen_two(); func_8029122C(D_800DC5F0, 1); func_80021C78(); func_802A2F34(D_800DC5F0); @@ -1137,7 +1137,7 @@ void func_802A6E94(void) { } render_course_actors(D_800DC5F4); func_80058090(10); - func_8002186C(); + render_players_on_screen_three(); func_8029122C(D_800DC5F4, 2); func_80021D40(); func_802A2F34(D_800DC5F4); @@ -1192,7 +1192,7 @@ void func_802A7178(void) { } render_course_actors(D_800DC5F8); func_80058090(11); - func_800219BC(); + render_players_on_screen_four(); func_8029122C(D_800DC5F8, 3); func_80021DA8(); func_802A2F34(D_800DC5F8); diff --git a/src/spawn_players.c b/src/spawn_players.c index 3e70ddcb7a..6d16716e2f 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -19,6 +19,7 @@ #include "podium_ceremony_actors.h" #include "main.h" #include "menus.h" +#include "code_8001F980.h" // arg4 is height? Or something like that? void spawn_player(Player *player, s8 playerIndex, f32 startingRow, f32 startingColumn, f32 arg4, f32 arg5, u16 characterId, s16 playerType) { @@ -1040,7 +1041,7 @@ void func_8003CD98(Player *player, Camera *camera, s8 playerId, s8 arg3) { D_80165110[arg3][playerId] = player->animGroupSelector[arg3]; D_80165150[arg3][playerId] = player->unk_0A8; D_801651D0[arg3][playerId] = 0; - func_800267AC(player, playerId, arg3); + player_render(player, playerId, arg3); } }