Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/buffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ typedef struct {
extern u16 gRandomSeed16;
extern u8 randomSeedPadding[216];
extern union_D_802BFB80 D_802BFB80;
extern struct_D_802DFB80 gEncodedKartTexture[][2][8];
extern struct_D_802DFB80 gEncodedKartTexture[][4][8];

/**
* It would be nice to define gPlayerPalettesList as "struct_D_802F1F80 gPlayerPalettesList[2][4][8]".
Expand Down
2 changes: 1 addition & 1 deletion src/buffers/buffers.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
ALIGNED8 union_D_802BFB80 D_802BFB80;
// [nothing][screen][player]
ALIGNED8 struct_D_802DFB80 gEncodedKartTexture[2][2][8];
ALIGNED8 struct_D_802DFB80 gEncodedKartTexture[2][4][8];
#ifdef AVOID_UB
// [buffer][screen][player] Buffer might be two separate buffers or something?
ALIGNED8 struct_D_802F1F80 gPlayerPalettesList[2][4][8];
Expand Down
66 changes: 33 additions & 33 deletions src/code_80057C60.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,30 +769,20 @@ void func_8005902C(void) {

void func_800590D4(void) {
if (D_8018D2A4 != 0) {
if (gModeSelection != BATTLE) {
switch (gPlayerCountSelection1) {
case 1:
if (gModeSelection != TIME_TRIALS) {
func_8004E800(PLAYER_ONE);
break;
}
break;
case 2:
func_8004E800(PLAYER_ONE);
func_8004E800(PLAYER_TWO);
break;
case 3:
func_8004E998(PLAYER_ONE);
func_8004E998(PLAYER_TWO);
func_8004E998(PLAYER_THREE);
break;
case 4:
func_8004E998(PLAYER_ONE);
func_8004E998(PLAYER_TWO);
func_8004E998(PLAYER_THREE);
func_8004E998(PLAYER_FOUR);
break;
}
switch(gModeSelection) {
case BATTLE:
case TIME_TRIALS:
break;
case GRAND_PRIX:
for (size_t i = 0; i < gPlayerCountSelection1; i++) {
func_8004E800(i);
}
break;
case VERSUS:
for (size_t i = 0; i < gPlayerCountSelection1; i++) {
func_8004E998(i);
}
break;
}
}
}
Expand Down Expand Up @@ -6565,17 +6555,27 @@ void func_8006E058(void) {

break;
case SCREEN_MODE_3P_4P_SPLITSCREEN:
if ((VERSUS == gModeSelection) || (BATTLE == gModeSelection)) {
func_8006E420(gPlayerOne, 0, 0);
func_8006E420(gPlayerTwo, 1, 0);
func_8006E420(gPlayerThree, 2, 0);

if (gPlayerCountSelection1 == 4) {
switch(gModeSelection) {
case GRAND_PRIX:
func_8006E420(gPlayerOne, 0, 0);
func_8006E420(gPlayerTwo, 1, 0);
func_8006E420(gPlayerThree, 2, 0);
func_8006E420(gPlayerFour, 3, 0);
}
func_8006E420(gPlayerFive, 4, 0);
func_8006E420(gPlayerSix, 5, 0);
func_8006E420(gPlayerSeven, 6, 0);
func_8006E420(gPlayerEight, 7, 0);
break;
case VERSUS:
case BATTLE:
func_8006E420(gPlayerOne, 0, 0);
func_8006E420(gPlayerTwo, 1, 0);
func_8006E420(gPlayerThree, 2, 0);
if (gPlayerCountSelection1 == 4) {
func_8006E420(gPlayerFour, 3, 0);
}
break;
}

break;
}
}

Expand Down
14 changes: 8 additions & 6 deletions src/data/textures.c
Original file line number Diff line number Diff line change
Expand Up @@ -4230,21 +4230,23 @@ MenuTexture seg2_menu_2p_column[5] = {
* @brief MenuTexture for the first colone three player
*
*/
MenuTexture seg2_menu_3p_column[4] = {
MenuTexture seg2_menu_3p_column[5] = {
{ 1, texture_menu_3p_game, 64, 54, 0, 0, 0x0 },
{ 1, texture_mode_vs, 64, 18, 0, 65, 0x0 },
{ 1, texture_mode_battle, 64, 18, 0, 83, 0x0 },
{ 1, texture_mode_mario_gp, 64, 18, 0, 65, 0x0 },
{ 1, texture_mode_vs, 64, 18, 0, 83, 0x0 },
{ 1, texture_mode_battle, 64, 18, 0, 101, 0x0 },
{ 0, NULL, 0, 0, 0, 0, 0 },
};

/**
* @brief MenuTexture for the first colone four player
*
*/
MenuTexture seg2_menu_4p_column[4] = {
MenuTexture seg2_menu_4p_column[5] = {
{ 1, texture_menu_4p_game, 64, 54, 0, 0, 0x0 },
{ 1, texture_mode_vs, 64, 18, 0, 65, 0x0 },
{ 1, texture_mode_battle, 64, 18, 0, 83, 0x0 },
{ 1, texture_mode_mario_gp, 64, 18, 0, 65, 0x0 },
{ 1, texture_mode_vs, 64, 18, 0, 83, 0x0 },
{ 1, texture_mode_battle, 64, 18, 0, 101, 0x0 },
{ 0, NULL, 0, 0, 0, 0, 0 },
};

Expand Down
2 changes: 1 addition & 1 deletion src/menu_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -5414,7 +5414,7 @@ void func_8009CE64(s32 arg0) {
switch (gModeSelection) {
case 0:
case 1:
gModeSelection = 2;
gModeSelection = VERSUS;
break;
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/menus.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,31 +100,31 @@ const s8 sScreenModePlayerTable[] = { SCREEN_MODE_1P, SCREEN_MODE_2P_SPLITSCREEN
const s8 sScreenModePlayerCount[] = { 1, 2, 2, 3, 4 };

// Set indexed slots numbers for one-two-three-four mode selection
const s8 gPlayerModeSelection[] = { 1, 2, 1, 1 };
const s8 gPlayerModeSelection[] = { 1, 2, 2, 2 };

// Limit for each index column in one-two-three-four mode selection
const s8 sGameModePlayerColumnDefault[][3] = {
{ 2, 1, 0 }, // 1p (GP options, TT options, ...)
{ 2, 2, 0 }, // 2p (GP options, VS options, Battle)
{ 2, 0, 0 }, // 3p (VS options, Battle, ...)
{ 2, 0, 0 }, // 4p (VS options, Battle, ...)
{ 2, 2, 0 }, // 3p (GP options, VS options, Battle, ...)
{ 2, 2, 0 }, // 4p (GP options, VS options, Battle, ...)
};

// Limit for each index column in one-two-three-four mode selection
// for extra mode (mirror mode), hence the extra value (3 instead of 2)
const s8 sGameModePlayerColumnExtra[][3] = {
{ 3, 1, 0 }, // 1p (GP options, TT options, ...)
{ 3, 3, 0 }, // 2p (GP options, VS options, Battle)
{ 3, 0, 0 }, // 3p (VS options, Battle, ...)
{ 3, 0, 0 }, // 4p (VS options, Battle, ...)
{ 3, 3, 0 }, // 3p (GP options, VS options, Battle, ...)
{ 3, 3, 0 }, // 4p (GP options, VS options, Battle, ...)
};

// Modes to select in one-two-three-four mode selection
const s32 gGameModePlayerSelection[][3] = {
{ GRAND_PRIX, TIME_TRIALS, 0x00000000 }, // 1p game modes
{ GRAND_PRIX, VERSUS, BATTLE }, // 2p game modes
{ VERSUS, BATTLE, 0x00000000 }, // 3p game modes
{ VERSUS, BATTLE, 0x00000000 }, // 4p game modes
{ GRAND_PRIX, VERSUS, BATTLE }, // 3p game modes
{ GRAND_PRIX, VERSUS, BATTLE }, // 4p game modes
};

// Map from character grid position id to character id
Expand Down
9 changes: 8 additions & 1 deletion src/player_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,14 @@ void func_80028F70(void) {
}
break;
case SCREEN_MODE_3P_4P_SPLITSCREEN:
for (size_t i = 0; i < 4; i++) {
size_t players;
if (gModeSelection == GRAND_PRIX) {
players = 8;
} else { // VERSUS, BATTLE
players = 4;
}

for (size_t i = 0; i < players; i++) {
func_80028E70(&gPlayers[i], camera1, i, 0);
}
break;
Expand Down
23 changes: 23 additions & 0 deletions src/racing/race_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ void func_8028E678(void) {
case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL:
D_8015F894 = 6;
break;
case SCREEN_MODE_3P_4P_SPLITSCREEN:
D_8015F894 = 5;
break;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be verified that it does not interfere with other game modes.

The background black fill is missing on screens 3/4. but it works.

}
break;
case 5:
Expand Down Expand Up @@ -990,6 +993,26 @@ void func_8028FCBC(void) {
gRaceState = RACE_FINISHED;
}
break;
case SCREEN_MODE_3P_4P_SPLITSCREEN:
if (((gPlayerOne->type & PLAYER_CINEMATIC_MODE) != 0) &&
((gPlayerTwo->type & PLAYER_CINEMATIC_MODE) != 0) &&
((gPlayerThree->type & PLAYER_CINEMATIC_MODE) != 0) &&
((gPlayerFour->type & PLAYER_CINEMATIC_MODE) != 0)) {

size_t bestRank = gPlayers[0].currentRank;
gPlayerWinningIndex = 0;
for (size_t i = 1; i < gPlayerCountSelection1; i++) {
if (gPlayers[i].currentRank < bestRank) {
bestRank = gPlayers[i].currentRank;
gPlayerWinningIndex = i;
}
}

func_8028E298();
D_802BA038 = 600;
gRaceState = RACE_FINISHED;
}
break;
}
break;
case VERSUS:
Expand Down
58 changes: 31 additions & 27 deletions src/render_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ void render_players(Camera* camera, s32 screenIdx) {
init_render_player(gPlayerTwo, camera, PLAYER_TWO, screenIdx);
init_render_player(gPlayerThree, camera, PLAYER_THREE, screenIdx);
init_render_player(gPlayerFour, camera, PLAYER_FOUR, screenIdx);
if (gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) {
if ((gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) ||
(gModeSelection == GRAND_PRIX)) {
init_render_player(gPlayerFive, camera, PLAYER_FIVE, screenIdx);
init_render_player(gPlayerSix, camera, PLAYER_SIX, screenIdx);
init_render_player(gPlayerSeven, camera, PLAYER_SEVEN, screenIdx);
Expand All @@ -371,7 +372,8 @@ void render_players(Camera* camera, s32 screenIdx) {
try_rendering_player(gPlayerTwo, PLAYER_TWO, screenIdx);
try_rendering_player(gPlayerThree, PLAYER_THREE, screenIdx);
try_rendering_player(gPlayerFour, PLAYER_FOUR, screenIdx);
if (gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) {
if ((gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) ||
(gModeSelection == GRAND_PRIX)) {
try_rendering_player(gPlayerFive, PLAYER_FIVE, screenIdx);
try_rendering_player(gPlayerSix, PLAYER_SIX, screenIdx);
try_rendering_player(gPlayerSeven, PLAYER_SEVEN, screenIdx);
Expand All @@ -384,7 +386,8 @@ void render_players(Camera* camera, s32 screenIdx) {
render_kart_particles(gPlayerTwo, PLAYER_TWO, screenIdx);
render_kart_particles(gPlayerThree, PLAYER_THREE, screenIdx);
render_kart_particles(gPlayerFour, PLAYER_FOUR, screenIdx);
if (gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) {
if ((gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) ||
(gModeSelection == GRAND_PRIX)) {
render_kart_particles(gPlayerFive, PLAYER_FIVE, screenIdx);
render_kart_particles(gPlayerSix, PLAYER_SIX, screenIdx);
render_kart_particles(gPlayerSeven, PLAYER_SEVEN, screenIdx);
Expand Down Expand Up @@ -545,7 +548,8 @@ void func_80021B0C(void) {
func_8006E7CC(gPlayerTwo, 1, 0);
func_8006E7CC(gPlayerThree, 2, 0);
func_8006E7CC(gPlayerFour, 3, 0);
if (gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) {
if ((gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) ||
(gModeSelection == GRAND_PRIX)) {
func_8006E7CC(gPlayerFive, 4, 0);
func_8006E7CC(gPlayerSix, 5, 0);
func_8006E7CC(gPlayerSeven, 6, 0);
Expand Down Expand Up @@ -829,15 +833,27 @@ void func_8002276C(void) {
}
break;
case SCREEN_MODE_3P_4P_SPLITSCREEN:
if ((VERSUS == gModeSelection) || (BATTLE == gModeSelection)) {
func_80022A98(gPlayerOne, 0);
func_80022A98(gPlayerTwo, 1);
func_80022A98(gPlayerThree, 2);
if (gPlayerCountSelection1 == 4) {
switch (gModeSelection) {
case GRAND_PRIX: /* switch 1 */
func_80022A98(gPlayerOne, 0);
func_80022A98(gPlayerTwo, 1);
func_80022A98(gPlayerThree, 2);
func_80022A98(gPlayerFour, 3);
}
func_80022A98(gPlayerFive, 4);
func_80022A98(gPlayerSix, 5);
func_80022A98(gPlayerSeven, 6);
func_80022A98(gPlayerEight, 7);
break;
case VERSUS:
case BATTLE:
func_80022A98(gPlayerOne, 0);
func_80022A98(gPlayerTwo, 1);
func_80022A98(gPlayerThree, 2);
if (gPlayerCountSelection1 == 4) {
func_80022A98(gPlayerFour, 3);
}
break;
}
break;
}
}

Expand Down Expand Up @@ -1344,17 +1360,9 @@ void render_kart(Player* player, s8 playerId, s8 screenId, s8 flipOffset) {
}
load_kart_palette(player, playerId, screenId, D_801651D0[screenId][playerId]);
gPlayerPalette = &gPlayerPalettesList[D_801651D0[screenId][playerId]][screenId][playerId];
// When screenId >= 2 (in 3/4 player mode), adjust indices to fit gEncodedKartTexture[2][2][8] dimensions
if ((screenId == 0) || (screenId == 1)) {
load_kart_texture(player, playerId, screenId, screenId, D_801651D0[screenId][playerId]);
} else {
load_kart_texture(player, playerId - 4, screenId, screenId - 1, D_801651D0[screenId][playerId]);
}
if ((screenId == 0) || (screenId == 1)) {
sKartTexture = gEncodedKartTexture[D_801651D0[screenId][playerId]][screenId][playerId].unk_00;
} else {
sKartTexture = gEncodedKartTexture[D_801651D0[screenId][playerId]][screenId - 1][playerId - 4].unk_00;
}

load_kart_texture(player, playerId, screenId, screenId, D_801651D0[screenId][playerId]);
sKartTexture = gEncodedKartTexture[D_801651D0[screenId][playerId]][screenId][playerId].unk_00;
mtxf_translate_rotate(mtx, sp154, sp14C);
mtxf_scale(mtx, gCharacterSize[player->characterId] * player->size);
convert_to_fixed_point_matrix(GetKartMatrix(playerId + (screenId * 8)), mtx);
Expand Down Expand Up @@ -1460,11 +1468,7 @@ void render_ghost(Player* player, s8 playerId, s8 screenId, s8 flipOffset) {
gPlayerPalette =
(struct_D_802F1F80*) &gPlayerPalettesList[D_801651D0[screenId][playerId]][screenId][playerId * 0x100];
#endif
if ((screenId == 0) || (screenId == 1)) {
sKartTexture = gEncodedKartTexture[D_801651D0[screenId][playerId]][screenId][playerId].unk_00;
} else {
sKartTexture = gEncodedKartTexture[D_801651D0[screenId][playerId]][screenId - 1][playerId - 4].unk_00;
}
sKartTexture = gEncodedKartTexture[D_801651D0[screenId][playerId]][screenId][playerId].unk_00;

mtxf_translate_rotate(mtx, spDC, spD4);
mtxf_scale(mtx, gCharacterSize[player->characterId] * player->size);
Expand Down
Loading
Loading