diff --git a/src/code_80057C60.c b/src/code_80057C60.c index d9807e954..1618bf57f 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -1246,10 +1246,14 @@ void func_80059AC8(void) { if (gIsGamePaused == false) { func_8008C1D8(&D_80165678); gRaceFrameCounter++; - for (i = 0; i < NUM_PLAYERS; i++) { + for (i = 0; i < gPlayerCount; i++) { D_8018CF68[i] = func_8008A890(&camera1[i]); + } + + for (i = 0; i < NUM_PLAYERS; i++) { func_800892E0(i); } + switch (gScreenModeSelection) { case SCREEN_MODE_1P: if (gGamestate != CREDITS_SEQUENCE) { diff --git a/src/menu_items.c b/src/menu_items.c index 4e1af1f8e..a231fde18 100644 --- a/src/menu_items.c +++ b/src/menu_items.c @@ -340,7 +340,7 @@ char* gDebugCharacterNames[] = { char* D_800E76A8[] = { "MARIO", "LUIGI", "YOSHI", "TOAD", "D.K.", "WARIO", "PEACH", "BOWSER", - "ーーーー", // NOT HYPHENS!!! These are EUC-JP characters (0xa1 0xbc) + "\xA1\xBC\xA1\xBC\xA1\xBC\xA1\xBC", // NOT HYPHENS!!! These are EUC-JP characters (0xa1 0xbc) }; char* D_800E76CC[] = { @@ -821,47 +821,25 @@ MenuTexture* gGlyphTextureLUT[] = { D_020029B4, D_0200301C, D_020029DC, D_02003044, D_02002A04, D_0200306C, D_02002A2C, D_02003094, D_02002A54, D_020030BC, D_02002A7C, D_020030E4, D_02002AA4, D_0200310C, D_020033B4, D_02002ACC, D_02003134, D_02002AF4, D_0200315C, D_02002B1C, D_02003184, D_02002B44, D_02002B6C, D_02002B94, D_02002BBC, D_02002BE4, D_02002C0C, - D_020031AC, -}; - -MenuTexture* D_800E7FF0[] = { - D_02003274, D_02002C34, D_020031D4, D_0200329C, D_02002C5C, D_020031FC, D_020032C4, D_02002C84, D_02003224, + D_020031AC, D_02003274, D_02002C34, D_020031D4, D_0200329C, D_02002C5C, D_020031FC, D_020032C4, D_02002C84, D_02003224, D_020032EC, D_02002CAC, D_0200324C, D_02003314, D_02002CD4, D_02002CFC, D_02002D24, D_02002D4C, D_02002D74, D_0200333C, D_02002D9C, D_02003364, D_02002DC4, D_0200338C, D_02002DEC, D_02002E14, D_02002E3C, D_02002E64, D_02002E8C, D_02002EB4, D_02002EDC, D_02002F04, D_02002F2C, D_020033DC, D_02003404, D_0200342C, D_02003454, D_0200347C, D_020034A4, D_020034CC, D_020034F4, D_0200351C, D_02003544, D_0200356C, D_02003BD4, -}; - -MenuTexture* D_800E80A0[] = { D_02003594, D_02003BFC, D_020035BC, D_02003C24, D_020035E4, D_02003C4C, D_0200360C, D_02003C74, D_02003634, D_02003C9C, D_0200365C, D_02003CC4, D_02003684, D_02003CEC, D_020036AC, D_02003D14, D_020036D4, D_02003D3C, D_020036FC, D_02003D64, D_02003724, D_02003D8C, D_02004034, D_0200374C, D_02003DB4, D_02003774, D_02003DDC, D_0200379C, D_02003E04, -}; - -MenuTexture* D_800E8114[] = { D_020037C4, D_020037EC, D_02003814, D_0200383C, D_02003864, D_0200388C, D_02003E2C, D_02003EF4, D_020038B4, D_02003E54, D_02003F1C, D_020038DC, D_02003E7C, D_02003F44, D_02003904, D_02003EA4, D_02003F6C, D_0200392C, D_02003ECC, D_02003F94, D_02003954, D_0200397C, D_020039A4, D_020039CC, -}; - -MenuTexture* D_800E8174[] = { D_020039F4, D_02003FBC, -}; - -MenuTexture* D_800E817C[] = { D_02003A1C, D_02003FE4, D_02003A44, D_0200400C, D_02003A6C, D_02003A94, D_02003ABC, D_02003AE4, D_02003B0C, D_02003B34, D_02003B5C, D_02003B84, D_02003BAC, D_0200405C, D_02004084, D_020040AC, D_020040D4, D_020040FC, D_020043CC, D_02004444, D_0200437C, D_020043F4, D_02004124, D_0200414C, D_02004174, D_0200419C, -}; - -MenuTexture* D_800E81E4[] = { D_020041C4, D_020041EC, D_02004214, D_0200423C, D_02004264, D_0200428C, D_020042B4, D_020042DC, D_02004354, D_020043A4, D_0200441C, D_0200446C, D_02004494, D_020044BC, D_02004304, D_0200432C, D_020044E4, D_0200450C, -}; - -MenuTexture* D_800E822C[] = { D_02004534, D_0200455C, }; diff --git a/src/render_player.c b/src/render_player.c index 0856f184e..4aa6e01b8 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -722,7 +722,7 @@ const char** wheelPtr[] = { donkeykong_kart_wheels, wario_kart_wheels, peach_kart_wheels, bowser_kart_wheels, }; -s32 D_800DDE74[] = { 96, 128, 192, 256, 288, 384, 512, 544, 576, 0}; +s32 D_800DDE74[] = { 96, 128, 192, 256, 288, 384, 512, 544, 576, 0, 0}; void render_players_on_screen_two(void) { gPlayersToRenderCount = 0; diff --git a/src/save.c b/src/save.c index 1b80372cd..8197375ba 100644 --- a/src/save.c +++ b/src/save.c @@ -746,7 +746,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; @@ -777,7 +777,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 == 4) { @@ -866,7 +866,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) { @@ -904,7 +904,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 d5431fc6d..c685fb854 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/staff_ghosts.c b/src/staff_ghosts.c index f2fca0490..2287bc54a 100644 --- a/src/staff_ghosts.c +++ b/src/staff_ghosts.c @@ -17,14 +17,14 @@ #include "port/Game.h" #include "courses/staff_ghost_data.h" -u8* D_80162D80; -s16 D_80162D84; +u8* sReplayGhostBuffer; +s16 sReplayGhostBufferSize; s16 D_80162D86; u16 D_80162D88; u32 D_80162D8C; s16 D_80162D90; -u32* D_80162D94; +u32* sReplayGhostDecompressed; u16 D_80162D98; u32 D_80162D9C; @@ -59,8 +59,8 @@ 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[]; @@ -71,8 +71,17 @@ void func_80004EF0(void) { u8* ghost = (u8*) D_80162DC4; + size_t size = 0; + if (ghost == d_luigi_raceway_staff_ghost) { + size = 187 * sizeof(StaffGhost); + } else if (ghost == d_mario_raceway_staff_ghost) { + size = 208 * sizeof(StaffGhost); + } else if (ghost == d_royal_raceway_staff_ghost) { + size = 377 * sizeof(StaffGhost); + } + // Manual memcpy required for byte swap - for (int i = 0; i < 0x4000; i += 4) { + for (int i = 0; i < size; i += 4) { dest[i] = ghost[i + 3]; dest[i + 1] = ghost[i + 2]; dest[i + 2] = ghost[i + 1]; @@ -91,8 +100,8 @@ void func_80004FB0(void) { } void func_80004FF8(void) { - D_80162D94 = (u32*) &D_802BFB80.arraySize8[0][D_80162DC8][3]; - D_80162D8C = (s32) *D_80162D94 & 0xFF0000; + sReplayGhostDecompressed = (u32*) &D_802BFB80.arraySize8[0][D_80162DC8][3]; + D_80162D8C = (s32) *sReplayGhostDecompressed & 0xFF0000; D_80162D90 = 0; } /** @@ -117,18 +126,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) { - D_80162D94 = (u32*) &D_802BFB80.arraySize8[0][D_80162DC8][3]; - mio0decode((u8*) D_800DC714, (u8*) D_80162D94); - D_80162D8C = (s32) (*D_80162D94 & 0xFF0000); + sReplayGhostDecompressed = (u32*) &D_802BFB80.arraySize8[0][D_80162DC8][3]; + mio0decode((u8*) gReplayGhostCompressed, (u8*) sReplayGhostDecompressed); + D_80162D8C = (s32) (*sReplayGhostDecompressed & 0xFF0000); D_80162D90 = 0; D_80162E00 = 1; } @@ -144,8 +153,8 @@ void func_800052A4(void) { D_80162DCC = 0; } temp_v0 = D_80162DB8; - 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; } @@ -320,7 +329,7 @@ void func_800057DC(void) { func_80005AE8(gPlayerTwo); return; } - temp_a0 = D_80162D94[D_80162D90]; + temp_a0 = sReplayGhostDecompressed[D_80162D90]; temp_v0 = temp_a0 & 0xFF; if (temp_v0 < 0x80U) { phi_v1 = (s16) (temp_v0 & 0xFF); @@ -362,7 +371,7 @@ void func_800057DC(void) { if (D_80162D8C == 0) { D_80162D90++; - D_80162D8C = (s32) (D_80162D94[D_80162D90] & 0xFF0000); + D_80162D8C = (s32) (sReplayGhostDecompressed[D_80162D90] & 0xFF0000); } else { D_80162D8C += (s32) 0xFFFF0000; } @@ -461,8 +470,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; @@ -473,8 +482,8 @@ void func_80005B18(void) { } } else { if ((gLapCountByPlayerId[0] == 3) && (D_80162DDC == 0) && (D_80162DF8 == 1)) { - 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_80162DDC = 1; } if ((gPlayerOne->type & 0x800) == 0x800) {