diff --git a/asm/non_matchings/code_80091750/add_8018D9E0_entry.s b/asm/non_matchings/code_80091750/add_8018D9E0_entry.s index 3b99cd70d0..f24c3d8b93 100644 --- a/asm/non_matchings/code_80091750/add_8018D9E0_entry.s +++ b/asm/non_matchings/code_80091750/add_8018D9E0_entry.s @@ -1025,8 +1025,8 @@ glabel L8009F388 /* 0A000C 8009F40C 8FBF001C */ lw $ra, 0x1c($sp) /* 0A0010 8009F410 804F0000 */ lb $t7, ($v0) .L8009F414: -/* 0A0014 8009F414 3C198019 */ lui $t9, %hi(gCupCourseSelection) # $t9, 0x8019 -/* 0A0018 8009F418 8339EE0B */ lb $t9, %lo(gCupCourseSelection)($t9) +/* 0A0014 8009F414 3C198019 */ lui $t9, %hi(gCourseIndexInCup) # $t9, 0x8019 +/* 0A0018 8009F418 8339EE0B */ lb $t9, %lo(gCourseIndexInCup)($t9) /* 0A001C 8009F41C 000F7080 */ sll $t6, $t7, 2 /* 0A0020 8009F420 0C02D567 */ jal func_800B559C /* 0A0024 8009F424 01D92021 */ addu $a0, $t6, $t9 diff --git a/asm/non_matchings/code_80091750/func_800AB314.s b/asm/non_matchings/code_80091750/func_800AB314.s index 3dfafc7865..664099db71 100644 --- a/asm/non_matchings/code_80091750/func_800AB314.s +++ b/asm/non_matchings/code_80091750/func_800AB314.s @@ -27,10 +27,10 @@ glabel func_800AB314 /* 0ABF74 800AB374 24040001 */ li $a0, 1 /* 0ABF78 800AB378 24030003 */ li $v1, 3 /* 0ABF7C 800AB37C 108F003A */ beq $a0, $t7, .L800AB468 -/* 0ABF80 800AB380 3C028019 */ lui $v0, %hi(gCupCourseSelection) # $v0, 0x8019 +/* 0ABF80 800AB380 3C028019 */ lui $v0, %hi(gCourseIndexInCup) # $v0, 0x8019 /* 0ABF84 800AB384 ACC00004 */ sw $zero, 4($a2) /* 0ABF88 800AB388 ACC00020 */ sw $zero, 0x20($a2) -/* 0ABF8C 800AB38C 2442EE0B */ addiu $v0, %lo(gCupCourseSelection) # addiu $v0, $v0, -0x11f5 +/* 0ABF8C 800AB38C 2442EE0B */ addiu $v0, %lo(gCourseIndexInCup) # addiu $v0, $v0, -0x11f5 /* 0ABF90 800AB390 80580000 */ lb $t8, ($v0) /* 0ABF94 800AB394 8FB90024 */ lw $t9, 0x24($sp) /* 0ABF98 800AB398 8FAB0024 */ lw $t3, 0x24($sp) diff --git a/asm/non_matchings/code_80091750/func_800AC458.s b/asm/non_matchings/code_80091750/func_800AC458.s index c32a088ba0..9b3a8d883d 100644 --- a/asm/non_matchings/code_80091750/func_800AC458.s +++ b/asm/non_matchings/code_80091750/func_800AC458.s @@ -255,7 +255,7 @@ glabel L800AC7CC /* 0AD3DC 800AC7DC ACEF001C */ sw $t7, 0x1c($a3) /* 0AD3E0 800AC7E0 8318D9D8 */ lb $t8, %lo(D_8018D9D8)($t8) /* 0AD3E4 800AC7E4 25EAFFFB */ addiu $t2, $t7, -5 -/* 0AD3E8 800AC7E8 3C0D8019 */ lui $t5, %hi(gCupCourseSelection) # $t5, 0x8019 +/* 0AD3E8 800AC7E8 3C0D8019 */ lui $t5, %hi(gCourseIndexInCup) # $t5, 0x8019 /* 0AD3EC 800AC7EC 53000003 */ beql $t8, $zero, .L800AC7FC /* 0AD3F0 800AC7F0 8CEB001C */ lw $t3, 0x1c($a3) /* 0AD3F4 800AC7F4 ACEA001C */ sw $t2, 0x1c($a3) @@ -265,7 +265,7 @@ glabel L800AC7CC /* 0AD400 800AC800 8FBF0014 */ lw $ra, 0x14($sp) /* 0AD404 800AC804 ACEC0004 */ sw $t4, 4($a3) /* 0AD408 800AC808 ACE0001C */ sw $zero, 0x1c($a3) -/* 0AD40C 800AC80C 81ADEE0B */ lb $t5, %lo(gCupCourseSelection)($t5) +/* 0AD40C 800AC80C 81ADEE0B */ lb $t5, %lo(gCourseIndexInCup)($t5) /* 0AD410 800AC810 24010003 */ li $at, 3 /* 0AD414 800AC814 00002825 */ move $a1, $zero /* 0AD418 800AC818 15A10053 */ bne $t5, $at, .L800AC968 diff --git a/asm/non_matchings/save/func_800B5218.s b/asm/non_matchings/save/func_800B5218.s index 95b9148d2a..a1ab62bae3 100644 --- a/asm/non_matchings/save/func_800B5218.s +++ b/asm/non_matchings/save/func_800B5218.s @@ -1,8 +1,8 @@ glabel func_800B5218 /* 0B5E18 800B5218 3C0E8019 */ lui $t6, %hi(gCupSelection) # $t6, 0x8019 /* 0B5E1C 800B521C 81CEEE09 */ lb $t6, %lo(gCupSelection)($t6) -/* 0B5E20 800B5220 3C188019 */ lui $t8, %hi(gCupCourseSelection) # $t8, 0x8019 -/* 0B5E24 800B5224 8318EE0B */ lb $t8, %lo(gCupCourseSelection)($t8) +/* 0B5E20 800B5220 3C188019 */ lui $t8, %hi(gCourseIndexInCup) # $t8, 0x8019 +/* 0B5E24 800B5224 8318EE0B */ lb $t8, %lo(gCourseIndexInCup)($t8) /* 0B5E28 800B5228 3C09800F */ lui $t1, %hi(gCharacterSelections) # $t1, 0x800f /* 0B5E2C 800B522C 812986A8 */ lb $t1, %lo(gCharacterSelections)($t1) /* 0B5E30 800B5230 27BDFFB8 */ addiu $sp, $sp, -0x48 diff --git a/include/defines.h b/include/defines.h index 4e79f629ce..cc93a3025c 100644 --- a/include/defines.h +++ b/include/defines.h @@ -165,12 +165,14 @@ enum PlayerId { * the battle courses could be displayed in the same * way race courses are. */ -#define MUSHROOM_CUP 0 -#define FLOWER_CUP 1 -#define STAR_CUP 2 -#define SPECIAL_CUP 3 -#define BATTLE_CUP 4 -#define NUM_CUPS 5 +enum { MUSHROOM_CUP, FLOWER_CUP, STAR_CUP, SPECIAL_CUP, BATTLE_CUP, NUM_CUPS }; + +#define NUM_COURSES_PER_CUP 4 + +/** + * @brief Options for gCourseIndexInCup + */ +enum { COURSE_ONE, COURSE_TWO, COURSE_THREE, COURSE_FOUR }; /** * @brief Character IDs @@ -297,12 +299,6 @@ enum PlayerId { #define DEMO_SIX 5 // Mario Luigi Peach Toad, Sherbert Land, Versus #define NUM_DEMOS 6 -#define CUP_COURSE_ONE 0 -#define CUP_COURSE_TWO 1 -#define CUP_COURSE_THREE 2 -#define CUP_COURSE_FOUR 3 -#define NUM_COURSES_PER_CUP 4 - /** * @brief Item IDs */ diff --git a/src/code_800029B0.c b/src/code_800029B0.c index 8be4d25ec2..53072f0f1b 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -185,7 +185,7 @@ void setup_race(void) { gCourseDirection = 1.0f; } if (gModeSelection == GRAND_PRIX) { - gCurrentCourseId = gCupCourseOrder[gCupSelection][gCupCourseSelection]; + gCurrentCourseId = gCupCourseOrder[gCupSelection][gCourseIndexInCup]; } gActiveScreenMode = gScreenModeSelection; if (gCurrentCourseId != gCurrentlyLoadedCourseId) { diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index 99f3017da8..9e8209cfa3 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -2928,24 +2928,24 @@ void set_bomb_kart_spawn_positions(void) { s32 var_s3; TrackWaypoint* temp_v0; UNUSED BombKart* var_s0; - BombKartSpawn* temp_s1; + BombKartSpawn* bombKartSpawn; for (var_s3 = 0; var_s3 < NUM_BOMB_KARTS_VERSUS; var_s3++) { - temp_s1 = &gBombKartSpawns[gCurrentCourseId][var_s3]; + bombKartSpawn = &gBombKartSpawns[gCurrentCourseId][var_s3]; switch (gCurrentCourseId) { case COURSE_YOSHI_VALLEY: - startingXPos = temp_s1->startingXPos; - startingZPos = temp_s1->startingZPos; + startingXPos = bombKartSpawn->startingXPos; + startingZPos = bombKartSpawn->startingZPos; startingYPos = spawn_actor_on_surface(startingXPos, 2000.0f, startingZPos); break; case COURSE_AWARD_CEREMONY: - temp_v0 = &D_80164550[3][temp_s1->waypointIndex]; + temp_v0 = &D_80164550[3][bombKartSpawn->waypointIndex]; startingXPos = temp_v0->posX; startingYPos = temp_v0->posY; startingZPos = temp_v0->posZ; break; default: - temp_v0 = &D_80164550[0][temp_s1->waypointIndex]; + temp_v0 = &D_80164550[0][bombKartSpawn->waypointIndex]; startingXPos = temp_v0->posX; startingYPos = temp_v0->posY; startingZPos = temp_v0->posZ; @@ -2966,11 +2966,11 @@ void set_bomb_kart_spawn_positions(void) { gBombKarts[var_s3].wheel4Pos[0] = startingXPos; gBombKarts[var_s3].wheel4Pos[1] = startingYPos; gBombKarts[var_s3].wheel4Pos[2] = startingZPos; - gBombKarts[var_s3].waypointIndex = temp_s1->waypointIndex; - gBombKarts[var_s3].unk_3C = temp_s1->unk_04; + gBombKarts[var_s3].waypointIndex = bombKartSpawn->waypointIndex; + gBombKarts[var_s3].unk_3C = bombKartSpawn->unk_04; gBombKarts[var_s3].bounceTimer = 0; gBombKarts[var_s3].circleTimer = 0; - gBombKarts[var_s3].state = temp_s1->startingState; + gBombKarts[var_s3].state = bombKartSpawn->startingState; gBombKarts[var_s3].unk_4A = 0; gBombKarts[var_s3].unk_4C = 1; gBombKarts[var_s3].yPos = startingYPos; @@ -5431,7 +5431,7 @@ void func_80014DE4(s32 arg0) { D_801646CC = 0; D_80164678[arg0] = D_80164670[arg0]; - if ((gModeSelection != 1) && ((gCupCourseSelection == 0) || (gDemoMode == (u16) 1))) { + if ((gModeSelection != 1) && ((gCourseIndexInCup == COURSE_ONE) || (gDemoMode == (u16) 1))) { D_80164678[arg0] = 0; } else if ((D_80164678[arg0] != 0) && (D_80164678[arg0] != (s16) 1) && (D_80164678[arg0] != 2) && (D_80164678[arg0] != 3)) { diff --git a/src/code_80091750.c b/src/code_80091750.c index d3ce49d231..3f6624db6d 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -1254,7 +1254,7 @@ void func_80091EE4(void) { tmp = func_800B5F30(); if ((D_8018EDFB != 0) && (tmp == 0)) { - temp_s2 = (gCupSelection * 4) + gCupCourseSelection; + temp_s2 = (gCupSelection * 4) + gCourseIndexInCup; func_800B6708(); for (temp_s0 = 0; temp_s0 < 2; ++temp_s0) { @@ -4832,7 +4832,7 @@ void func_8009CE64(s32 arg0) { } gCupSelection = gCupSelectionByCourseId[gCurrentCourseId]; D_800DC540 = (s32) gCupSelection; - gCupCourseSelection = (s8) gPerCupIndexByCourseId[gCurrentCourseId]; + gCourseIndexInCup = (s8) gPerCupIndexByCourseId[gCurrentCourseId]; break; case 3: /* switch 3 */ switch (gMenuSelection) { @@ -4914,7 +4914,7 @@ void func_8009CE64(s32 arg0) { } gCupSelection = gCupSelectionByCourseId[gCurrentCourseId]; D_800DC540 = gCupSelection; - gCupCourseSelection = gPerCupIndexByCourseId[gCurrentCourseId]; + gCourseIndexInCup = gPerCupIndexByCourseId[gCurrentCourseId]; switch (gDebugGotoScene) { /* switch 6; irregular */ case 1: /* switch 6 */ break; @@ -5625,7 +5625,7 @@ void add_8018D9E0_entry(s32 type, s32 column, s32 row, s8 priority) { } } if ((var_ra->unk1C == 0) || (var_ra->unk20 != 0)) { - func_800B559C((gCupSelection * 4) + gCupCourseSelection); + func_800B559C((gCupSelection * 4) + gCourseIndexInCup); } break; case 0xE6: @@ -7046,7 +7046,7 @@ void func_800A2EB8(struct_8018D9E0_entry* arg0) { func_80093324(arg0->column + 0x1E, arg0->row + 0x19, "results", 0, 1.0f, 1.0f); set_text_color(TEXT_BLUE_GREEN_RED_CYCLE_2); func_80093324(arg0->column + 0x2C, arg0->row + 0x28, "round", 0, 0.7f, 0.7f); - convert_number_to_ascii(gCupCourseSelection + 1, sp68); + convert_number_to_ascii(gCourseIndexInCup + 1, sp68); func_80093324(arg0->column + 0x57, arg0->row + 0x28, &sp68[1], 0, 0.7f, 0.7f); for (var_s2 = 0; var_s2 < 4; var_s2++) { if (gGPCurrentRacePlayerIdByRank[var_s2] < gPlayerCount) { @@ -7125,7 +7125,7 @@ void func_800A34A8(struct_8018D9E0_entry* arg0) { func_80093324(arg0->column + 0x19, 0x19 - arg0->row, "driver's points", 0, 0.8f, 0.8f); set_text_color(5); func_80093324(arg0->column + 0x36, 0x28 - arg0->row, "round", 0, 0.7f, 0.7f); - convert_number_to_ascii(gCupCourseSelection + 1, sp78); + convert_number_to_ascii(gCourseIndexInCup + 1, sp78); func_80093324(arg0->column + 0x61, (0x28 & 0xFFFFFFFF) - arg0->row, &sp78[1], 0, 0.7f, 0.7f); for (rank = 0; rank < 4; rank++) { test = arg0->cursor; @@ -7258,8 +7258,8 @@ void func_800A3C84(struct_8018D9E0_entry* arg0) { s32 rowOffset; set_text_color(TEXT_BLUE_GREEN_RED_CYCLE_1); - draw_text(arg0->column + 0x43, arg0->row + 0x19, - gCourseNamesDup[gCupCourseOrder[gCupSelection][gCupCourseSelection]], 0, 0.6f, 0.6f); + draw_text(arg0->column + 0x43, arg0->row + 0x19, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCourseIndexInCup]], + 0, 0.6f, 0.6f); set_text_color(TEXT_YELLOW); draw_text(arg0->column + 0x46, arg0->row + 0x28, D_800E7730, 0, 0.75f, 0.75f); for (recordType = 0, rowOffset = 0; recordType < TIME_TRIAL_3LAP_RECORD_5; recordType += 1, rowOffset += 0xF) { @@ -7298,8 +7298,8 @@ void func_800A3E60(struct_8018D9E0_entry* arg0) { } set_text_color(4); - draw_text(arg0->column + 0x55, 0x19 - arg0->row, - gCourseNamesDup[gCupCourseOrder[gCupSelection][gCupCourseSelection]], 0, 0.6f, 0.6f); + draw_text(arg0->column + 0x55, 0x19 - arg0->row, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCourseIndexInCup]], + 0, 0.6f, 0.6f); set_text_color(3); draw_text(arg0->column + 0x55, 0x28 - arg0->row, D_800E7730, 0, 0.75f, 0.75f); for (var_s1 = 0; var_s1 < 4; var_s1++) { @@ -7596,7 +7596,7 @@ void render_pause_menu_time_trials(struct_8018D9E0_entry* arg0) { gDisplayListHead = draw_box(gDisplayListHead, 0, 0, 0x0000013F, 0x000000EF, 0, 0, 0, 0x0000008C); set_text_color(TEXT_YELLOW); - draw_text(0x000000A0, 0x00000050, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCupCourseSelection]], 0, 1.0f, + draw_text(0x000000A0, 0x00000050, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCourseIndexInCup]], 0, 1.0f, 1.0f); set_text_color(TEXT_RED); draw_text(0x0000009D, 0x00000060, D_800E7728[0], 0, 0.8f, 0.8f); @@ -7684,7 +7684,7 @@ void render_pause_grand_prix(struct_8018D9E0_entry* arg0) { set_text_color(TEXT_YELLOW); draw_text(160 + temp_s0, temp_s3->row - 50, D_800E76CC[gCCSelection], 0, 1.0f, 1.0f); set_text_color(TEXT_YELLOW); - draw_text(160, temp_s3->row - 30, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCupCourseSelection]], 0, 1.0f, + draw_text(160, temp_s3->row - 30, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCourseIndexInCup]], 0, 1.0f, 1.0f); for (var_s0 = 0; var_s0 < 2; var_s0++) { text_rainbow_effect(arg0->cursor - 31, var_s0, TEXT_YELLOW); @@ -7799,7 +7799,7 @@ void func_800A5738(struct_8018D9E0_entry* arg0) { gDisplayListHead = draw_box(gDisplayListHead, 0, 0, 0x0000013F, 0x000000EF, 0, 0, 0, var_s1); gDPSetPrimColor(gDisplayListHead++, 0, 0, 0x00, 0x00, 0x00, var_s2); set_text_color(3); - func_80093754(0x000000A0, 0x00000050, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCupCourseSelection]], 0, + func_80093754(0x000000A0, 0x00000050, gCourseNamesDup[gCupCourseOrder[gCupSelection][gCourseIndexInCup]], 0, 1.0f, 1.0f); switch (arg0->cursor) { /* switch 1 */ case 1: /* switch 1 */ @@ -8973,8 +8973,8 @@ void func_800A8A98(struct_8018D9E0_entry* arg0) { gDPPipeSync(gDisplayListHead++); gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); gDPSetCombineMode(gDisplayListHead++, G_CC_DECALRGBA, G_CC_DECALRGBA); - for (someIndex = 0; someIndex < 4; someIndex++) { - if ((someIndex == gCupCourseSelection) && (D_8018EDEC >= 2) && (gModeSelection != GRAND_PRIX)) { + for (someIndex = 0; someIndex < NUM_COURSES_PER_CUP; someIndex++) { + if ((someIndex == gCourseIndexInCup) && (D_8018EDEC >= 2) && (gModeSelection != GRAND_PRIX)) { if ((D_8018EDEC == 2) || (D_8018EDEC == 4)) { gDisplayListHead = draw_flash_select_case_slow( gDisplayListHead, D_800E7208[someIndex][0].column + temp_s2, D_800E7208[someIndex][0].row + temp_s3, @@ -9060,7 +9060,7 @@ void func_800A8F48(UNUSED struct_8018D9E0_entry* arg0) { break; case 2: default: - if (func_800B639C((gCupSelection * 4) + gCupCourseSelection) >= 0) { + if (func_800B639C((gCupSelection * 4) + gCourseIndexInCup) >= 0) { gDisplayListHead = func_80098FC8(gDisplayListHead, 0x00000057, 0x00000070, 0x00000096, 0x00000081); gDisplayListHead = func_8009BA74(gDisplayListHead, D_02004A0C, 0x00000057, 0x00000070); } @@ -10221,7 +10221,7 @@ void func_800AB314(struct_8018D9E0_entry* arg0) { arg0->cursor = 0; arg0->unk20 = 0; for (var_a1 = 0; var_a1 < 4; var_a1++) { - if (gCupCourseSelection == var_a1) { + if (gCourseIndexInCup == var_a1) { sp24[var_a1]->visible = one; if (arg0->unk1C != var_a1) { arg0->unk1C = var_a1; @@ -10724,7 +10724,7 @@ void func_800AC458(struct_8018D9E0_entry* arg0) { if (arg0->unk1C <= 0) { arg0->cursor = 0x0000000A; arg0->unk1C = 0; - if (gCupCourseSelection == 3) { + if (gCourseIndexInCup == 3) { for (var_a1 = 0; var_a1 < 8; var_a1++) { if (D_80164478[gCharacterIdByGPOverallRank[var_a1]] < gPlayerCount) { func_800B536C(var_a1); @@ -11123,7 +11123,7 @@ void func_800AD2E8(struct_8018D9E0_entry* arg0) { break; case 0: /* switch 4 */ func_800B6708(); - arg0->cursor = func_800B6348((gCupSelection * 4) + gCupCourseSelection) + 0x11; + arg0->cursor = func_800B6348((gCupSelection * 4) + gCourseIndexInCup) + 0x11; var_v1 = 1; play_sound2(SOUND_MENU_SELECT); break; @@ -11170,7 +11170,7 @@ void func_800AD2E8(struct_8018D9E0_entry* arg0) { if (osPfsFindFile(&gControllerPak1FileHandle, gCompanyCode, gGameCode, (u8*) gGameName, (u8*) gExtCode, &gControllerPak1FileNote) == 0) { func_800B6708(); - arg0->cursor = func_800B6348((gCupSelection * 4) + gCupCourseSelection) + 0x11; + arg0->cursor = func_800B6348((gCupSelection * 4) + gCourseIndexInCup) + 0x11; play_sound2(SOUND_MENU_SELECT); return; } @@ -11220,7 +11220,7 @@ void func_800AD2E8(struct_8018D9E0_entry* arg0) { case 17: /* switch 1 */ case 18: /* switch 1 */ arg0->unk20 = arg0->cursor - 0x11; - if (func_800B639C((gCupSelection * 4) + gCupCourseSelection) != arg0->unk20) { + if (func_800B639C((gCupSelection * 4) + gCourseIndexInCup) != arg0->unk20) { if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x800) { if (arg0->cursor >= 0x12) { arg0->cursor--; @@ -11527,7 +11527,7 @@ void func_800AE218(struct_8018D9E0_entry* arg0) { break; case PFS_NO_ERROR: /* switch 3 */ func_800B6708(); - arg0->cursor = func_800B6348((gCupSelection * 4) + gCupCourseSelection) + 0x1E; + arg0->cursor = func_800B6348((gCupSelection * 4) + gCourseIndexInCup) + 0x1E; var_v1 = 1; break; case PFS_ERR_NEW_PACK: /* switch 3 */ @@ -11576,7 +11576,7 @@ void func_800AE218(struct_8018D9E0_entry* arg0) { if (osPfsFindFile(&gControllerPak1FileHandle, gCompanyCode, gGameCode, (u8*) gGameName, (u8*) gExtCode, &gControllerPak1FileNote) == 0) { func_800B6708(); - arg0->cursor = func_800B6348((gCupSelection * 4) + gCupCourseSelection) + 0x1E; + arg0->cursor = func_800B6348((gCupSelection * 4) + gCourseIndexInCup) + 0x1E; play_sound2(SOUND_MENU_SELECT); return; } @@ -11622,7 +11622,7 @@ void func_800AE218(struct_8018D9E0_entry* arg0) { case 30: /* switch 1 */ case 31: /* switch 1 */ arg0->unk20 = (u32) arg0->cursor - 0x1E; - if (func_800B639C((gCupSelection * 4) + gCupCourseSelection) != arg0->unk20) { + if (func_800B639C((gCupSelection * 4) + gCourseIndexInCup) != arg0->unk20) { if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x800) { if (arg0->cursor >= 0x1F) { arg0->cursor--; diff --git a/src/menus.c b/src/menus.c index 9b87cf75e2..beb97af6d7 100644 --- a/src/menus.c +++ b/src/menus.c @@ -53,7 +53,7 @@ s32 gMenuDelayTimer; s8 D_8018EE08; s8 gCupSelection; s8 D_8018EE0A; -s8 gCupCourseSelection; +s8 gCourseIndexInCup; s8 D_8018EE0C; struct_8018EE10_entry D_8018EE10[2]; @@ -820,7 +820,7 @@ void logo_intro_menu_act(struct Controller* arg0, UNUSED u16 arg1) { gGamestateNext = 4; // Enter race state gCCSelection = CC_100; gCupSelection = 1; - gCupCourseSelection = 0; + gCourseIndexInCup = 0; gCurrentCourseId = 0; gScreenModeSelection = SCREEN_MODE_1P; gCharacterSelections[0] = 0; @@ -1692,7 +1692,7 @@ void course_select_menu_act(struct Controller* arg0, u16 arg1) { } D_800DC540 = gCupSelection; - gCurrentCourseId = gCupCourseOrder[gCupSelection][gCupCourseSelection]; + gCurrentCourseId = gCupCourseOrder[gCupSelection][gCourseIndexInCup]; if ((buttonAndStickPress & B_BUTTON) != 0) { func_8009E208(); play_sound2(SOUND_MENU_GO_BACK); @@ -1703,7 +1703,7 @@ void course_select_menu_act(struct Controller* arg0, u16 arg1) { } else { D_8018EDEC = 3; play_sound2(SOUND_MENU_SELECT); - gCurrentCourseId = gCupCourseOrder[gCupSelection][CUP_COURSE_ONE]; + gCurrentCourseId = gCupCourseOrder[gCupSelection][COURSE_ONE]; gMenuTimingCounter = 0; } func_800B44AC(); @@ -1711,18 +1711,18 @@ void course_select_menu_act(struct Controller* arg0, u16 arg1) { break; case 2: case 4: - if (((buttonAndStickPress & D_JPAD) != 0) && (gCupCourseSelection < CUP_COURSE_FOUR)) { - ++gCupCourseSelection; + if (((buttonAndStickPress & D_JPAD) != 0) && (gCourseIndexInCup < COURSE_FOUR)) { + ++gCourseIndexInCup; func_800B44AC(); play_sound2(SOUND_MENU_CURSOR_MOVE); } - if (((buttonAndStickPress & U_JPAD) != 0) && (gCupCourseSelection > CUP_COURSE_ONE)) { - --gCupCourseSelection; + if (((buttonAndStickPress & U_JPAD) != 0) && (gCourseIndexInCup > COURSE_ONE)) { + --gCourseIndexInCup; func_800B44AC(); play_sound2(SOUND_MENU_CURSOR_MOVE); } - gCurrentCourseId = gCupCourseOrder[gCupSelection][gCupCourseSelection]; + gCurrentCourseId = gCupCourseOrder[gCupSelection][gCourseIndexInCup]; if ((buttonAndStickPress & B_BUTTON) != 0) { if (D_8018EDEC == 2) { D_8018EDEC = 1; @@ -1813,7 +1813,7 @@ void func_800B3F74(s32 menuSelection) { gIsMirrorMode = 0; gEnableDebugMode = DEBUG_MODE; gCupSelection = MUSHROOM_CUP; - gCupCourseSelection = 0; + gCourseIndexInCup = 0; gTimeTrialDataCourseIndex = 0; if (gPlayerCount <= 0) { gPlayerCount = 1; @@ -1941,7 +1941,7 @@ void func_800B3F74(s32 menuSelection) { play_sound2(SOUND_MENU_SELECT_MAP); D_8018EE0A = 0; if (gModeSelection == GRAND_PRIX) { - gCupCourseSelection = 0; + gCourseIndexInCup = 0; } for (i = 0; i < ARRAY_COUNT(gGPPointsByCharacterId); i++) { diff --git a/src/menus.h b/src/menus.h index b433b08897..374d18c9a6 100644 --- a/src/menus.h +++ b/src/menus.h @@ -71,7 +71,7 @@ extern s32 gMenuDelayTimer; extern s8 D_8018EE08; extern s8 gCupSelection; extern s8 D_8018EE0A; -extern s8 gCupCourseSelection; +extern s8 gCourseIndexInCup; extern s8 D_8018EE0C; extern struct_8018EE10_entry D_8018EE10[]; diff --git a/src/racing/race_logic.c b/src/racing/race_logic.c index 7130439e85..c18fef7618 100644 --- a/src/racing/race_logic.c +++ b/src/racing/race_logic.c @@ -144,16 +144,16 @@ void func_8028E3A0(void) { if (D_80150120) { - if (gCupCourseSelection == CUP_COURSE_FOUR) { + if (gCourseIndexInCup == COURSE_FOUR) { gGotoMode = ENDING; } else { D_800DC544++; - gCupCourseSelection++; + gCourseIndexInCup++; gGotoMode = RACING; } } else { D_800DC544++; - gCupCourseSelection++; + gCourseIndexInCup++; gGotoMode = RACING; } } diff --git a/src/save.c b/src/save.c index dd3df054d4..b182aede16 100644 --- a/src/save.c +++ b/src/save.c @@ -245,10 +245,9 @@ u32 func_800B4DF4(u8* arr) { // Get a time trial record, infer course index s32 func_800B4E24(s32 recordIndex) { - return func_800B4DF4( - gSaveData.allCourseTimeTrialRecords.cupRecords[(((gCupSelection * 4) + gCupCourseSelection) / 4)] - .courseRecords[(((gCupSelection * 4) + gCupCourseSelection) % 4)] - .records[recordIndex]); + return func_800B4DF4(gSaveData.allCourseTimeTrialRecords.cupRecords[(((gCupSelection * 4) + gCourseIndexInCup) / 4)] + .courseRecords[(((gCupSelection * 4) + gCourseIndexInCup) % 4)] + .records[recordIndex]); } // Get a time trial record, but take the course index as an argument @@ -260,10 +259,9 @@ u32 func_800B4EB4(s32 recordIndex, s32 courseIndex) { // Get Best Lap record of the inferred course index s32 func_800B4F2C(void) { - return func_800B4DF4( - gSaveData.allCourseTimeTrialRecords.cupRecords[(((gCupSelection * 4) + gCupCourseSelection) / 4)] - .courseRecords[(((gCupSelection * 4) + gCupCourseSelection) % 4)] - .records[TIME_TRIAL_1LAP_RECORD]); + return func_800B4DF4(gSaveData.allCourseTimeTrialRecords.cupRecords[(((gCupSelection * 4) + gCourseIndexInCup) / 4)] + .courseRecords[(((gCupSelection * 4) + gCourseIndexInCup) % 4)] + .records[TIME_TRIAL_1LAP_RECORD]); } // Get the best single lap time record of the given course index @@ -280,7 +278,7 @@ s32 func_800B5020(u32 time, s32 charId) { s32 j; CourseTimeTrialRecords* tt; - course = gCupSelection * 4 + gCupCourseSelection; + course = gCupSelection * 4 + gCourseIndexInCup; tt = &gSaveData.allCourseTimeTrialRecords.cupRecords[course / 4].courseRecords[course % 4]; i = 0; @@ -327,7 +325,7 @@ s32 func_800B5218(void) { s32 checkLapIndex; s32 character; s32 lapBitmask; - recordIndex = (gCupSelection * 4) + gCupCourseSelection; + recordIndex = (gCupSelection * 4) + gCourseIndexInCup; recordPointer = &gSaveData.allCourseTimeTrialRecords.cupRecords[recordIndex / 4].courseRecords[recordIndex % 4].records[0][0]; lapBitmask = 1; @@ -786,7 +784,7 @@ s32 func_800B6178(s32 arg0) { if (var_v0 == 0) { temp_s3->ghostDataSaved = 1; if (gGamestate == 4) { - temp_s3->courseIndex = (gCupSelection * 4) + gCupCourseSelection; + temp_s3->courseIndex = (gCupSelection * 4) + gCourseIndexInCup; } temp_s3->unk_00 = D_80162DFC; temp_s3->characterId = (u8) D_80162DE0; @@ -835,7 +833,7 @@ s32 func_800B63F0(s32 arg0) { func_80005AE8(gPlayerThree); phi_s3 = 0; - if (((gCupSelection * 4) + gCupCourseSelection) != D_8018EE10[arg0].courseIndex) { + if (((gCupSelection * 4) + gCourseIndexInCup) != D_8018EE10[arg0].courseIndex) { phi_s3 = 2; } else if (D_80162DFC != D_8018EE10[arg0].unk_00) { phi_s3 = 3; diff --git a/src/spawn_players.c b/src/spawn_players.c index 3523b34744..dc8e8b8e8e 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -465,7 +465,7 @@ void func_80039DA4(void) { 0, 1, 2, 3, 4, 5, 6, 7, }; - if (((gCupCourseSelection == CUP_COURSE_ONE) && (D_8016556E == 0)) || (gDemoMode == 1) || + if (((gCourseIndexInCup == COURSE_ONE) && (D_8016556E == 0)) || (gDemoMode == 1) || (gDebugMenuSelection == DEBUG_MENU_EXITED)) { for (i = 0; i < NUM_PLAYERS; i++) { D_80165270[i] = sp2C[i]; @@ -483,7 +483,7 @@ UNUSED s16 D_800E43A8 = 0; void spawn_players_gp_one_player(f32* arg0, f32* arg1, f32 arg2) { func_80039DA4(); - if (((gCupCourseSelection == CUP_COURSE_ONE) && (D_8016556E == 0)) || (gDemoMode == 1) || + if (((gCourseIndexInCup == COURSE_ONE) && (D_8016556E == 0)) || (gDemoMode == 1) || (gDebugMenuSelection == DEBUG_MENU_EXITED)) { s16 rand; s16 i; @@ -607,7 +607,7 @@ void spawn_players_versus_one_player(f32* arg0, f32* arg1, f32 arg2) { void spawn_players_gp_two_player(f32* arg0, f32* arg1, f32 arg2) { func_80039DA4(); - if ((gCupCourseSelection == CUP_COURSE_ONE) || (gDemoMode == 1) || (gDebugMenuSelection == DEBUG_MENU_EXITED)) { + if ((gCourseIndexInCup == COURSE_ONE) || (gDemoMode == 1) || (gDebugMenuSelection == DEBUG_MENU_EXITED)) { s16 rand; s16 i;