diff options
| author | coco875 <59367621+coco875@users.noreply.github.com> | 2025-01-26 02:43:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-25 18:43:30 -0700 |
| commit | 995c60c85cac45d23dbcbfea45f29ec4ed7618b6 (patch) | |
| tree | 55aa7092635da91e65a6bc1ff9f02134773e5122 /src/save.c | |
| parent | a37bb5afbd280949411ac9061ce54e92166325d8 (diff) | |
fix ghost (#175)
* fix ghost
* remove a semi colon
Diffstat (limited to 'src/save.c')
| -rw-r--r-- | src/save.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/save.c b/src/save.c index 8197375ba..fd5440f50 100644 --- a/src/save.c +++ b/src/save.c @@ -11,6 +11,7 @@ #include "staff_ghosts.h" #include "code_80057C60.h" #include "port/Game.h" +#include "buffers.h" /*** macros ***/ #define PFS_COMPANY_CODE(c0, c1) ((u16) (((c0) << 8) | ((c1)))) @@ -32,9 +33,7 @@ s8 sControllerPak2State = BAD; // default time trial records in little endian form const u8 D_800F2E60[4] = { 0xc0, 0x27, 0x09, 0x00 }; // osPfsFindFile -> gGameName ("MARIOKART64" in nosFont) -const u8 gGameName[] = { - 0x26, 0x1a, 0x2b, 0x22, 0x28, 0x24, 0x1a, 0x2b, 0x2d, 0x16, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 -}; +const u8 gGameName[] = "MARIOKART64"; // ext_name param to osPfsFindFile (four total bytes, but only one is setable) const u8 gExtCode[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -483,7 +482,7 @@ void func_800B559C(s32 arg0) { * But only unknown bytes 7 and 8 ever get set, so why the extra 3, and why in chunks of 17? **/ u8 func_800B578C(s32 arg0) { - u8* times = (u8*)&gSaveData.onlyBestTimeTrialRecords[arg0]; + u8* times = (u8*) &gSaveData.onlyBestTimeTrialRecords[arg0]; s32 checksum = 0; s32 i; s32 j; @@ -559,6 +558,7 @@ s32 validate_save_data_checksum_backup(void) { // Check if controller has a Controller Pak connected. // Return PAK if it does, otherwise return NO_PAK. s32 check_for_controller_pak(s32 controller) { + return PAK; u8 controllerBitpattern = 0; UNUSED s32 phi_v0; @@ -746,7 +746,7 @@ u8 func_800B60E8(s32 page) { u32 checksum = 0; u8* addr; - for (i = 0, addr = (u8*) &((u8*) gReplayGhostCompressed)[page * 256]; i < 256; i++) { + for (i = 0, addr = (u8*) &((u8*) sReplayGhostDecompressed)[page * 256]; i < 256; i++) { checksum += (*addr++ * (page + 1) + i); } return checksum; @@ -776,8 +776,9 @@ s32 func_800B6178(s32 arg0) { temp_s3->unk_07[var_s0] = var_s0; } } else { - var_v0 = osPfsReadWriteFile(&gControllerPak1FileHandle, gControllerPak1FileNote, 1U, (arg0 * 0x3C00) + 0x100, - 0x00003C00, (u8*) gReplayGhostCompressed); + var_v0 = + osPfsReadWriteFile(&gControllerPak1FileHandle, gControllerPak1FileNote, 1U, + (arg0 * (sizeof(u8) * 0x1000)) + 0x100, sizeof(u8) * 0x1000, (u8*) sReplayGhostBuffer); if (var_v0 == 0) { temp_s3->ghostDataSaved = 1; if (gGamestate == 4) { @@ -865,8 +866,10 @@ s32 func_800B64EC(s32 arg0) { return -1; } - temp_v0 = osPfsReadWriteFile(&gControllerPak1FileHandle, gControllerPak1FileNote, PFS_READ, (arg0 * 0x3C00) + 0x100, - 0x3C00, (u8*) gReplayGhostCompressed); + sReplayGhostDecompressed = (u32*) &D_802BFB80.arraySize8[0][D_80162DC8][3]; + temp_v0 = + osPfsReadWriteFile(&gControllerPak1FileHandle, gControllerPak1FileNote, PFS_READ, + (arg0 * (sizeof(u8) * 0x1000)) + 0x100, sizeof(u8) * 0x1000, (u8*) sReplayGhostDecompressed); if (temp_v0 == 0) { // clang-format off phi_s1 = (u8 *) &D_8018EE10[arg0]; temp_s0 = 0; while (1) { @@ -903,8 +906,9 @@ s32 func_800B65F4(s32 arg0, s32 arg1) { default: return -1; } - writeStatus = osPfsReadWriteFile(&gControllerPak2FileHandle, gControllerPak2FileNote, 0U, (arg0 * 0x3C00) + 0x100, - 0x00003C00, (u8*) gReplayGhostCompressed); + writeStatus = + osPfsReadWriteFile(&gControllerPak2FileHandle, gControllerPak2FileNote, 0U, + (arg0 * (sizeof(u8) * 0x1000)) + 0x100, sizeof(u8) * 0x1000, (u8*) sReplayGhostBuffer); if (writeStatus == 0) { temp_s3 = &((struct_8018EE10_entry*) gSomeDLBuffer)[arg0]; for (i = 0; i < 0x3C; i++) { @@ -1000,7 +1004,7 @@ s32 func_800B6A68(void) { s32 i; ret = osPfsAllocateFile(&gControllerPak1FileHandle, gCompanyCode, gGameCode, (u8*) &gGameName, (u8*) &gExtCode, - 0x7900, &gControllerPak1FileNote); + sizeof(u8) * 0x1000 * 2 + 0x100, &gControllerPak1FileNote); if (ret == 0) { for (i = 0; i < 2; i++) { func_800B69BC(i); |
