diff --git a/src/actors/kiwano_fruit/update.inc.c b/src/actors/kiwano_fruit/update.inc.c index 66a52b0c7..5332d8e5f 100644 --- a/src/actors/kiwano_fruit/update.inc.c +++ b/src/actors/kiwano_fruit/update.inc.c @@ -58,7 +58,7 @@ void update_actor_kiwano_fruit(struct KiwanoFruit* fruit) { player->velocity[2] -= temp_f14 * 0.7f; func_800C9060(player - gPlayerOne, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x18)); if (gModeSelection != GRAND_PRIX) { - gPostTTReplayCannotSave = 1; + gPostTimeTrialReplayCannotSave = 1; } } } diff --git a/src/menu_items.c b/src/menu_items.c index 0a33f77d4..edf8e9ad2 100644 --- a/src/menu_items.c +++ b/src/menu_items.c @@ -7346,7 +7346,7 @@ void func_800A3E60(MenuItem* arg0) { text_rainbow_effect(arg0->state - 5, var_s1, 1); switch (var_s1) { /* switch 3; irregular */ case 4: /* switch 3 */ - if (gPostTTReplayCannotSave == 1) { + if (gPostTimeTrialReplayCannotSave == 1) { var_v1 = 1; } break; @@ -11062,7 +11062,7 @@ void func_800AD2E8(MenuItem* arg0) { arg0->param2 = 0; arg0->column = 0; arg0->state = gTimeTrialsResultCursorSelection; - if ((arg0->state == 9) && (gPostTTReplayCannotSave == 1)) { + if ((arg0->state == 9) && (gPostTimeTrialReplayCannotSave == 1)) { arg0->state--; } D_800DC5EC->screenStartX = 0x00F0; @@ -11079,7 +11079,7 @@ void func_800AD2E8(MenuItem* arg0) { if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x800) { if (arg0->state >= 6) { arg0->state--; - if ((gPostTTReplayCannotSave == 1) && (arg0->state == 9)) { + if ((gPostTimeTrialReplayCannotSave == 1) && (arg0->state == 9)) { arg0->state--; } play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11092,7 +11092,7 @@ void func_800AD2E8(MenuItem* arg0) { if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x400) { if (arg0->state < 0xA) { arg0->state++; - if ((gPostTTReplayCannotSave == 1) && (arg0->state == 9)) { + if ((gPostTimeTrialReplayCannotSave == 1) && (arg0->state == 9)) { arg0->state++; } if ((arg0->state == 0x0000000A) && (bPlayerGhostDisabled != 0)) { @@ -11821,7 +11821,7 @@ void func_800AEF14(MenuItem* arg0) { void func_800AEF74(MenuItem* arg0) { switch (arg0->state) { /* irregular */ case 0: - if (gPostTTReplayCannotSave == 1) { + if (gPostTimeTrialReplayCannotSave == 1) { arg0->state = 1; arg0->param1 = 0; } else if (playerHUD[PLAYER_ONE].raceCompleteBool == (s8) 1) { diff --git a/src/racing/actors.c b/src/racing/actors.c index d49949b7a..42b3bd057 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -1660,7 +1660,7 @@ bool collision_yoshi_egg(Player* player, struct YoshiValleyEgg* egg) { } else { trigger_squish(player, player - gPlayerOne); if ((gModeSelection == TIME_TRIALS) && ((player->type & PLAYER_CPU) == 0)) { - gPostTTReplayCannotSave = 1; + gPostTimeTrialReplayCannotSave = 1; } } } else { @@ -2201,7 +2201,7 @@ void evaluate_collision_between_player_actor(Player* player, struct Actor* actor if (query_collision_player_vs_actor_item(player, actor) == COLLISION) { func_800C98B8(actor->pos, actor->velocity, SOUND_ACTION_EXPLOSION); if ((gModeSelection == TIME_TRIALS) && !(player->type & PLAYER_CPU)) { - gPostTTReplayCannotSave = 1; + gPostTimeTrialReplayCannotSave = 1; } if (player->effects & STAR_EFFECT) { actor->velocity[1] = 10.0f; diff --git a/src/racing/actors.h b/src/racing/actors.h index 41884f49a..095bf33c7 100644 --- a/src/racing/actors.h +++ b/src/racing/actors.h @@ -145,7 +145,7 @@ extern Gfx toads_turnpike_dl_9[]; extern Gfx toads_turnpike_dl_10[]; extern Gfx toads_turnpike_dl_11[]; -extern s32 gPostTTReplayCannotSave; +extern s32 gPostTimeTrialReplayCannotSave; extern Gfx D_0D001750[]; extern Gfx D_0D001780[]; diff --git a/src/racing/race_logic.h b/src/racing/race_logic.h index fc9972d9e..3ab60a14e 100644 --- a/src/racing/race_logic.h +++ b/src/racing/race_logic.h @@ -39,6 +39,5 @@ void func_80290B14(void); extern f32 gLapCompletionPercentByPlayerId[]; extern s32 gGPCurrentRaceRankByPlayerId[]; // D_801643B8 (position for each player) -extern u16 COURSE_GHOST_LOCKED; #endif diff --git a/src/replays.c b/src/replays.c index 328ae7267..5071c8bc6 100644 --- a/src/replays.c +++ b/src/replays.c @@ -5,7 +5,7 @@ * 2. Player ghosts, which were driven by a player and can be raced against * 3. Staff ghosts, which can be unlocked on the raceway tracks with a fast enough time * All 3 use the same system for storing / replaying the inputs to reproduce a time trial - * See process_post_TT_replay for additional technical details + * See process_post_time_trial_replay for additional technical details */ #include @@ -29,8 +29,8 @@ extern s32 mio0encode(s32 input, s32, s32); extern s32 func_80040174(void*, s32, s32); -u8* D_80162D80; -s16 D_80162D84; +u8* sReplayGhostBuffer; +s16 sReplayGhostBufferSize; s16 D_80162D86; static u16 sPlayerGhostButtonsPrev; @@ -66,13 +66,13 @@ s32 D_80162DE8; UNUSED static s32 sUnusedReplayCounter; s32 gPauseTriggered; UNUSED static s32 bUnusedCourseGhostDisabled; -s32 gPostTTReplayCannotSave; +s32 gPostTimeTrialReplayCannotSave; s32 D_80162DFC; s32 D_80162E00; -u32* D_800DC710 = (u32*) &D_802BFB80.arraySize8[0][2][3]; -u32* D_800DC714 = (u32*) &D_802BFB80.arraySize8[1][1][3]; +u32* sReplayGhostEncoded = (u32*) &D_802BFB80.arraySize8[0][2][3]; +u32* gReplayGhostCompressed = (u32*) &D_802BFB80.arraySize8[1][1][3]; extern s32 gLapCountByPlayerId[]; @@ -90,7 +90,7 @@ void load_course_ghost(void) { sCourseGhostReplayIdx = 0; } -void load_post_tt_replay(void) { +void load_post_time_trial_replay(void) { sPostTTReplay = (u32*) &D_802BFB80.arraySize8[0][D_80162DD0][3]; sPostTTFramesRemaining = *sPostTTReplay & REPLAY_FRAME_COUNTER; sPostTTReplayIdx = 0; @@ -168,17 +168,18 @@ void set_staff_ghost(void) { s32 func_800051C4(void) { s32 phi_v0; - if (D_80162D84 != 0) { + if (sReplayGhostBufferSize != 0) { // func_80040174 in mio0_decode.s - func_80040174((void*) D_80162D80, (D_80162D84 * 4) + 0x20, (s32) D_800DC710); - phi_v0 = mio0encode((s32) D_800DC710, (D_80162D84 * 4) + 0x20, (s32) D_800DC714); + func_80040174((void*) sReplayGhostBuffer, (sReplayGhostBufferSize * 4) + 0x20, (s32) sReplayGhostEncoded); + phi_v0 = + mio0encode((s32) sReplayGhostEncoded, (sReplayGhostBufferSize * 4) + 0x20, (s32) gReplayGhostCompressed); return phi_v0 + 0x1e; } } void func_8000522C(void) { sPlayerGhostReplay = (u32*) &D_802BFB80.arraySize8[0][D_80162DC8][3]; - mio0decode((u8*) D_800DC714, (u8*) sPlayerGhostReplay); + mio0decode((u8*) gReplayGhostCompressed, (u8*) sPlayerGhostReplay); sPlayerGhostFramesRemaining = (s32) (*sPlayerGhostReplay & REPLAY_FRAME_COUNTER); sPlayerGhostReplayIdx = 0; D_80162E00 = 1; @@ -195,8 +196,8 @@ void func_800052A4(void) { D_80162DCC = 0; } temp_v0 = sPlayerInputIdx; - D_80162D80 = (void*) &D_802BFB80.arraySize8[0][D_80162DC8][3]; - D_80162D84 = temp_v0; + sReplayGhostBuffer = (void*) &D_802BFB80.arraySize8[0][D_80162DC8][3]; + sReplayGhostBufferSize = temp_v0; D_80162D86 = temp_v0; } @@ -213,12 +214,12 @@ void func_80005310(void) { sPrevCourseId = (u16) gCurrentCourseId; gPauseTriggered = 0; sUnusedReplayCounter = 0; - gPostTTReplayCannotSave = 0; + gPostTimeTrialReplayCannotSave = 0; if (gModeSelection == TIME_TRIALS && gActiveScreenMode == SCREEN_MODE_1P) { if (D_8015F890 == 1) { - load_post_tt_replay(); + load_post_time_trial_replay(); if (D_80162DD8 == 0) { load_player_ghost(); } @@ -264,7 +265,7 @@ void func_80005310(void) { bit 31: B bit 32: A */ -void process_post_TT_replay(void) { +void process_post_time_trial_replay(void) { u32 inputs; u32 stickBytes; UNUSED u16 unk; @@ -323,7 +324,7 @@ void process_post_TT_replay(void) { } } -// See process_post_TT_replay comment +// See process_post_time_trial_replay comment void process_course_ghost_replay(void) { u32 inputs; u32 stickBytes; @@ -381,7 +382,7 @@ void process_course_ghost_replay(void) { } } -// See process_post_TT_replay comment +// See process_post_time_trial_replay comment void process_player_ghost_replay(void) { u32 inputs; u32 stickBytes; @@ -442,7 +443,7 @@ void process_player_ghost_replay(void) { } } -// See process_post_TT_replay comment +// See process_post_time_trial_replay comment void save_player_replay(void) { s16 buttons; u32 inputs; @@ -454,7 +455,7 @@ void save_player_replay(void) { /* Input file is too long or picked up by lakitu or Out of bounds Not sure if there is any way to be considered out of bounds without lakitu getting called */ if (((sPlayerInputIdx >= 0x1000) || ((gPlayerOne->unk_0CA & 2) != 0)) || ((gPlayerOne->unk_0CA & 8) != 0)) { - gPostTTReplayCannotSave = 1; + gPostTimeTrialReplayCannotSave = 1; return; } @@ -516,7 +517,7 @@ void func_80005AE8(Player* ply) { void func_80005B18(void) { if (gModeSelection == TIME_TRIALS) { - if ((gLapCountByPlayerId[0] == 3) && (D_80162DDC == 0) && (gPostTTReplayCannotSave != 1)) { + if ((gLapCountByPlayerId[0] == 3) && (D_80162DDC == 0) && (gPostTimeTrialReplayCannotSave != 1)) { if (bPlayerGhostDisabled == 1) { D_80162DD0 = D_80162DCC; func_800052A4(); @@ -539,8 +540,8 @@ void func_80005B18(void) { func_80005AE8(gPlayerTwo); func_80005AE8(gPlayerThree); } else { - D_80162D80 = D_802BFB80.arraySize8[0][D_80162DC8][3].pixel_index_array; - D_80162D84 = D_80162D86; + sReplayGhostBuffer = D_802BFB80.arraySize8[0][D_80162DC8][3].pixel_index_array; + sReplayGhostBufferSize = D_80162D86; D_80162DD0 = D_80162DCC; D_80162DE8 = gPlayerOne->characterId; D_80162DD8 = 0; @@ -550,9 +551,9 @@ void func_80005B18(void) { func_80005AE8(gPlayerThree); } } else { - if ((gLapCountByPlayerId[0] == 3) && (D_80162DDC == 0) && (gPostTTReplayCannotSave == 1)) { - D_80162D80 = D_802BFB80.arraySize8[0][D_80162DC8][3].pixel_index_array; - D_80162D84 = D_80162D86; + if ((gLapCountByPlayerId[0] == 3) && (D_80162DDC == 0) && (gPostTimeTrialReplayCannotSave == 1)) { + sReplayGhostBuffer = D_802BFB80.arraySize8[0][D_80162DC8][3].pixel_index_array; + sReplayGhostBufferSize = D_80162D86; D_80162DDC = 1; } if ((gPlayerOne->type & 0x800) == 0x800) { @@ -588,7 +589,7 @@ void func_80005E6C(void) { process_course_ghost_replay(); // 2 } if ((gPlayerOne->type & PLAYER_CINEMATIC_MODE) != PLAYER_CINEMATIC_MODE) { - process_post_TT_replay(); // 1 + process_post_time_trial_replay(); // 1 return; } func_80005AE8(gPlayerTwo); @@ -607,5 +608,5 @@ void replays_loop(void) { } /* This only gets triggered when the previous if-statements are not met Seems like just for pausing */ - gPostTTReplayCannotSave = 1; + gPostTimeTrialReplayCannotSave = 1; } diff --git a/src/replays.h b/src/replays.h index 5204c4b4f..32c9f4c4e 100644 --- a/src/replays.h +++ b/src/replays.h @@ -6,14 +6,14 @@ void func_80005B18(void); void load_course_ghost(void); -void load_post_tt_replay(void); +void load_post_time_trial_replay(void); void load_player_ghost(void); void set_staff_ghost(void); s32 func_800051C4(void); void func_8000522C(void); void func_800052A4(void); void func_80005310(void); -void process_replay_replay(void); +void process_post_time_trial_replay(void); void process_course_ghost_replay(void); void process_player_ghost_replay(void); void func_8000599C(void); @@ -36,6 +36,6 @@ extern s32 D_80162DE0; extern s32 D_80162DE4; extern s32 D_80162DE8; extern s32 gPauseTriggered; -extern s32 gPostTTReplayCannotSave; +extern s32 gPostTimeTrialReplayCannotSave; #endif /* STAFF_GHOSTS_H */ diff --git a/src/save.c b/src/save.c index 14e572788..12d4631f7 100644 --- a/src/save.c +++ b/src/save.c @@ -734,7 +734,7 @@ u8 func_800B60E8(s32 page) { u32 checksum = 0; u8* addr; - for (i = 0, addr = (u8*) &((u8*) D_800DC714)[page * 256]; i < 256; i++) { + for (i = 0, addr = (u8*) &((u8*) gReplayGhostCompressed)[page * 256]; i < 256; i++) { checksum += (*addr++ * (page + 1) + i); } return checksum; @@ -765,7 +765,7 @@ s32 func_800B6178(s32 arg0) { } } else { var_v0 = osPfsReadWriteFile(&gControllerPak1FileHandle, gControllerPak1FileNote, 1U, (arg0 * 0x3C00) + 0x100, - 0x00003C00, (u8*) D_800DC714); + 0x00003C00, (u8*) gReplayGhostCompressed); if (var_v0 == 0) { temp_s3->ghostDataSaved = 1; if (gGamestate == RACING) { @@ -854,7 +854,7 @@ s32 func_800B64EC(s32 arg0) { } temp_v0 = osPfsReadWriteFile(&gControllerPak1FileHandle, gControllerPak1FileNote, PFS_READ, (arg0 * 0x3C00) + 0x100, - 0x3C00, (u8*) D_800DC714); + 0x3C00, (u8*) gReplayGhostCompressed); if (temp_v0 == 0) { // clang-format off phi_s1 = (u8 *) &D_8018EE10[arg0]; temp_s0 = 0; while (1) { @@ -892,7 +892,7 @@ s32 func_800B65F4(s32 arg0, s32 arg1) { return -1; } writeStatus = osPfsReadWriteFile(&gControllerPak2FileHandle, gControllerPak2FileNote, 0U, (arg0 * 0x3C00) + 0x100, - 0x00003C00, (u8*) D_800DC714); + 0x00003C00, (u8*) gReplayGhostCompressed); if (writeStatus == 0) { temp_s3 = &((struct_8018EE10_entry*) gSomeDLBuffer)[arg0]; for (i = 0; i < 0x3C; i++) { diff --git a/src/save.h b/src/save.h index d6e4b2bde..328ed2897 100644 --- a/src/save.h +++ b/src/save.h @@ -87,7 +87,7 @@ s32 func_800B6A68(void); /* data */ // these might not be in this file, but for now... -extern u32* D_800DC714; +extern u32* gReplayGhostCompressed; extern struct_8018EE10_entry D_8018EE10[]; extern u16 gCompanyCode; diff --git a/src/update_objects.c b/src/update_objects.c index f65429072..c142fd6ca 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -198,7 +198,7 @@ void func_80072180(void) { if (gModeSelection == TIME_TRIALS) { if (((gPlayerOne->type & PLAYER_EXISTS) != 0) && ((gPlayerOne->type & (PLAYER_INVISIBLE_OR_BOMB | PLAYER_CPU)) == 0)) { - gPostTTReplayCannotSave = 1; + gPostTimeTrialReplayCannotSave = 1; } } } diff --git a/src/update_objects.h b/src/update_objects.h index bc2127942..e9381a8b7 100644 --- a/src/update_objects.h +++ b/src/update_objects.h @@ -385,7 +385,7 @@ extern u16* gHudLapTextures[]; extern u16* gPortraitTLUTs[]; extern u8* gPortraitTextures[]; -extern s32 gPostTTReplayCannotSave; +extern s32 gPostTimeTrialReplayCannotSave; extern s16 D_8016347C; extern s32 D_80165594; extern s32 D_80165598;