diff options
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/z_message.c | 10 | ||||
| -rw-r--r-- | src/code/z_message_staff.c | 17 | ||||
| -rw-r--r-- | src/code/z_sram_NES.c | 123 |
3 files changed, 62 insertions, 88 deletions
diff --git a/src/code/z_message.c b/src/code/z_message.c index ff16d258a..4d3379136 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -5212,10 +5212,6 @@ s16 D_801D0464[] = { 0x1B8E, }; -#ifdef NON_MATCHING -// Down to a single compiler-managed stack variable -// Also contains in-function data -// https://decomp.me/scratch/QcQ0a void Message_Update(PlayState* play) { static u8 D_801D0468 = 0; MessageContext* msgCtx = &play->msgCtx; @@ -5731,7 +5727,7 @@ void Message_Update(PlayState* play) { ((play->activeCamId == CAM_ID_MAIN) || ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF))) && (play->msgCtx.ocarinaMode == OCARINA_MODE_END)) { - if ((gSaveContext.prevHudVisibility == HUD_VISIBILITY_IDLE) || + if (((u32)gSaveContext.prevHudVisibility == HUD_VISIBILITY_IDLE) || (gSaveContext.prevHudVisibility == HUD_VISIBILITY_NONE) || (gSaveContext.prevHudVisibility == HUD_VISIBILITY_NONE_ALT)) { gSaveContext.prevHudVisibility = HUD_VISIBILITY_ALL; @@ -6002,10 +5998,6 @@ void Message_Update(PlayState* play) { break; } } -#else -u8 D_801D0468 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_Update.s") -#endif void Message_SetTables(PlayState* play) { play->msgCtx.messageEntryTableNes = D_801C6B98; diff --git a/src/code/z_message_staff.c b/src/code/z_message_staff.c index ff1d56408..6b94d7719 100644 --- a/src/code/z_message_staff.c +++ b/src/code/z_message_staff.c @@ -35,12 +35,9 @@ f32 sCreditsFontWidths[144] = { 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, }; -#ifdef NON_MATCHING -// https://decomp.me/scratch/yc8Or -// v0/v1 swap between `character` and `i` void Message_DrawTextCredits(PlayState* play, Gfx** gfxP) { MessageContext* msgCtx = &play->msgCtx; - u16 lookAheadCharacter; + u16 pad; u16 j; u16 i; u16 sfxHi; @@ -122,14 +119,13 @@ void Message_DrawTextCredits(PlayState* play, Gfx** gfxP) { ((msgCtx->msgMode >= MSGMODE_OCARINA_STARTING) && (msgCtx->msgMode <= MSGMODE_26)))) { j = i; while (true) { - lookAheadCharacter = msgCtx->decodedBuffer.schar[j]; - if (lookAheadCharacter == 6) { + character = msgCtx->decodedBuffer.schar[j]; + if (character == 6) { j += 2; continue; } - if ((lookAheadCharacter != 9) && (lookAheadCharacter != 0xA) && (lookAheadCharacter != 0xB) && - (lookAheadCharacter != 0xC) && (lookAheadCharacter != 0xD) && (lookAheadCharacter != 4) && - (lookAheadCharacter != 2)) { + if ((character != 9) && (character != 0xA) && (character != 0xB) && (character != 0xC) && + (character != 0xD) && (character != 4) && (character != 2)) { j++; continue; } @@ -329,9 +325,6 @@ void Message_DrawTextCredits(PlayState* play, Gfx** gfxP) { *gfxP = gfx; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/Message_DrawTextCredits.s") -#endif void Message_DecodeCredits(PlayState* play) { u16 curChar; diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 83e271edc..5f9e11878 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -1375,18 +1375,17 @@ void func_80145698(SramContext* sramCtx) { } // Verifies save and use backup if corrupted? -#ifdef NON_EQUIVALENT void func_801457CC(GameState* gameState, SramContext* sramCtx) { FileSelectState* fileSelect = (FileSelectState*)gameState; u16 sp7A; - u16 oldCheckSum; // s2 + u16 oldCheckSum; u16 sp76; - u16 sp64; // sp74? + u16 sp64; u16 phi_s2; - u16 phi_s7; + u16 pad; u16 sp6E; - u16 newCheckSum; // v0 - u16 phi_a0; // maskCount + u16 newCheckSum; + u16 maskCount; if (gSaveContext.flashSaveAvailable) { D_801F6AF0 = gSaveContext.save.time; @@ -1424,23 +1423,23 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, gFlashSaveSizes[sp64]); // test checksum of main save - oldCheckSum = gSaveContext.save.saveInfo.checksum; + phi_s2 = gSaveContext.save.saveInfo.checksum; gSaveContext.save.saveInfo.checksum = 0; newCheckSum = Sram_CalcChecksum(&gSaveContext, gFlashSaveSizes[sp64]); - gSaveContext.save.saveInfo.checksum = oldCheckSum; + gSaveContext.save.saveInfo.checksum = phi_s2; - if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (oldCheckSum != newCheckSum)) { + if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (newCheckSum != phi_s2)) { // checksum didnt match, try backup save sp6E = 1; if ((gSaveContext.save.saveInfo.playerData.newf[0] == 'Z') && - (gSaveContext.save.saveInfo.playerData.newf[1] == 'E')) { - phi_s2 = false; - } - - // phi_s2 = false; + (gSaveContext.save.saveInfo.playerData.newf[1] == 'E') && + (gSaveContext.save.saveInfo.playerData.newf[2] == 'L') && + (gSaveContext.save.saveInfo.playerData.newf[3] == 'D') && + (gSaveContext.save.saveInfo.playerData.newf[4] == 'A')) {} // read backup save from flash + phi_s2 = false; if (SysFlashrom_ReadData(sramCtx->saveBuf, gFlashSaveStartPages[sp64 + 1], gFlashSaveNumPages[sp64 + 1]) != 0) { // backup save didn't work @@ -1453,9 +1452,8 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { oldCheckSum = gSaveContext.save.saveInfo.checksum; gSaveContext.save.saveInfo.checksum = 0; - //! FAKE: (s32)sp64 if (phi_s2 || CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || - (oldCheckSum != Sram_CalcChecksum(&gSaveContext, gFlashSaveSizes[(s32)sp64]))) { + (oldCheckSum != Sram_CalcChecksum(&gSaveContext, gFlashSaveSizes[sp64]))) { // backup save didn't work bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); @@ -1465,9 +1463,8 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { } gSaveContext.save.saveInfo.checksum = 0; - // FAKE: Needed? - gSaveContext.save.saveInfo.checksum = - Sram_CalcChecksum(&gSaveContext, gFlashSaveSizes[sp64 & 0xFFFFFFFF]); + //! FAKE: [sp64 + 0]? + gSaveContext.save.saveInfo.checksum = Sram_CalcChecksum(&gSaveContext, gFlashSaveSizes[sp64 + 0]); for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.newf); sp7A++) { fileSelect->newf[sp76][sp7A] = gSaveContext.save.saveInfo.playerData.newf[sp7A]; @@ -1490,14 +1487,14 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { fileSelect->rupees[sp76] = gSaveContext.save.saveInfo.playerData.rupees; fileSelect->walletUpgrades[sp76] = CUR_UPG_VALUE(UPG_WALLET); - for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { - if (gSaveContext.save.saveInfo.inventory.items[sp7A + 24] != 0xFF) { - phi_a0++; + for (sp7A = 0, maskCount = 0; sp7A < 24; sp7A++) { + if (gSaveContext.save.saveInfo.inventory.items[sp7A + 24] == ITEM_NONE) { + continue; } + maskCount++; } - fileSelect->maskCount[sp76] = phi_a0; - fileSelect->heartPieceCount[sp76] = - ((gSaveContext.save.saveInfo.inventory.questItems & 0xF0000000) >> 0x1C); + fileSelect->maskCount[sp76] = maskCount; + fileSelect->heartPieceCount[sp76] = GET_QUEST_HEART_PIECE_COUNT; } if (sp6E == 1) { @@ -1506,20 +1503,20 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { Sram_SyncWriteToFlash(sramCtx, gFlashSaveStartPages[sp64], gFlashSpecialSaveNumPages[sp64]); } else if (!sp6E) { // main save - phi_s7 = gSaveContext.save.saveInfo.checksum; + oldCheckSum = gSaveContext.save.saveInfo.checksum; if (SysFlashrom_ReadData(sramCtx->saveBuf, gFlashSaveStartPages[sp64 + 1], gFlashSaveNumPages[sp64 + 1]) != 0) { - oldCheckSum = 1; + phi_s2 = 1; } else { Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); - oldCheckSum = gSaveContext.save.saveInfo.checksum; + phi_s2 = gSaveContext.save.saveInfo.checksum; gSaveContext.save.saveInfo.checksum = 0; sp7A = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); } - if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (oldCheckSum != sp7A) || - (oldCheckSum != phi_s7)) { + if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (sp7A != phi_s2) || + (oldCheckSum != phi_s2)) { SysFlashrom_ReadData(sramCtx->saveBuf, gFlashSaveStartPages[sp64], gFlashSaveNumPages[sp64]); Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); @@ -1539,24 +1536,26 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, gFlashSaveSizes[sp64]); } else { Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, gFlashSaveSizes[sp64]); - oldCheckSum = gSaveContext.save.saveInfo.checksum; + phi_s2 = gSaveContext.save.saveInfo.checksum; // test checksum of main save gSaveContext.save.saveInfo.checksum = 0; newCheckSum = Sram_CalcChecksum(&gSaveContext, gFlashSaveSizes[sp64]); - gSaveContext.save.saveInfo.checksum = oldCheckSum; + gSaveContext.save.saveInfo.checksum = phi_s2; - if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (oldCheckSum != newCheckSum)) { + if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (newCheckSum != phi_s2)) { // checksum didnt match, try backup save sp6E = 1; if ((gSaveContext.save.saveInfo.playerData.newf[0] == 'Z') && - (gSaveContext.save.saveInfo.playerData.newf[1] == 'E')) { - phi_s2 = false; - } + (gSaveContext.save.saveInfo.playerData.newf[1] == 'E') && + (gSaveContext.save.saveInfo.playerData.newf[2] == 'L') && + (gSaveContext.save.saveInfo.playerData.newf[3] == 'D') && + (gSaveContext.save.saveInfo.playerData.newf[4] == 'A')) {} + phi_s2 = false; // read backup save from flash if (SysFlashrom_ReadData(sramCtx->saveBuf, gFlashSaveStartPages[sp64 + 1], - gFlashSaveNumPages[sp64 + 1])) { + gFlashSaveNumPages[sp64 + 1]) != 0) { // backup save didn't work phi_s2 = true; } @@ -1577,9 +1576,8 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { } gSaveContext.save.saveInfo.checksum = 0; - // FAKE: Needed? - gSaveContext.save.saveInfo.checksum = - Sram_CalcChecksum(&gSaveContext, gFlashSaveSizes[sp64 & 0xFFFFFFFF]); + // FAKE: [sp64 + 0]? + gSaveContext.save.saveInfo.checksum = Sram_CalcChecksum(&gSaveContext, gFlashSaveSizes[sp64 + 0]); for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.newf); sp7A++) { fileSelect->newf[sp76][sp7A] = gSaveContext.save.saveInfo.playerData.newf[sp7A]; @@ -1589,7 +1587,8 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { fileSelect->threeDayResetCount[sp76] = gSaveContext.save.saveInfo.playerData.threeDayResetCount; for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.playerName); sp7A++) { - fileSelect->fileNames[sp76][sp7A] = gSaveContext.save.saveInfo.playerData.playerName[sp7A]; + fileSelect->fileNames[sp76][sp7A] = + (u32)gSaveContext.save.saveInfo.playerData.playerName[sp7A]; } fileSelect->healthCapacity[sp76] = gSaveContext.save.saveInfo.playerData.healthCapacity; @@ -1602,14 +1601,14 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { fileSelect->rupees[sp76] = gSaveContext.save.saveInfo.playerData.rupees; fileSelect->walletUpgrades[sp76] = CUR_UPG_VALUE(UPG_WALLET); - for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { - if (gSaveContext.save.saveInfo.inventory.items[sp7A + 24] != 0xFF) { - phi_a0++; + for (sp7A = 0, maskCount = 0; sp7A < 24; sp7A++) { + if (gSaveContext.save.saveInfo.inventory.items[sp7A + 24] == ITEM_NONE) { + continue; } + maskCount++; } - fileSelect->maskCount[sp76] = phi_a0; - fileSelect->heartPieceCount[sp76] = - ((gSaveContext.save.saveInfo.inventory.questItems & 0xF0000000) >> 0x1C); + fileSelect->maskCount[sp76] = maskCount; + fileSelect->heartPieceCount[sp76] = GET_QUEST_HEART_PIECE_COUNT; } if (sp6E == 1) { @@ -1618,20 +1617,20 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { Sram_SyncWriteToFlash(sramCtx, gFlashSaveStartPages[sp64 + 1], gFlashSaveNumPages[sp64 + 1]); } else if (!sp6E) { // main save - phi_s7 = gSaveContext.save.saveInfo.checksum; + oldCheckSum = gSaveContext.save.saveInfo.checksum; if (SysFlashrom_ReadData(sramCtx->saveBuf, gFlashSaveStartPages[sp64 + 1], - gFlashSaveNumPages[sp64 + 1])) { - oldCheckSum = 1; + gFlashSaveNumPages[sp64 + 1]) != 0) { + phi_s2 = 1; } else { Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, gFlashSaveSizes[sp64]); - oldCheckSum = gSaveContext.save.saveInfo.checksum; + phi_s2 = gSaveContext.save.saveInfo.checksum; gSaveContext.save.saveInfo.checksum = 0; sp7A = Sram_CalcChecksum(&gSaveContext, gFlashSaveSizes[sp64]); } - if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (oldCheckSum != sp7A) || - (oldCheckSum != phi_s7)) { + if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (sp7A != phi_s2) || + (oldCheckSum != phi_s2)) { SysFlashrom_ReadData(sramCtx->saveBuf, gFlashSaveStartPages[sp64], gFlashSaveNumPages[sp64]); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, gFlashSaveSizes[sp64]); @@ -1673,9 +1672,6 @@ void func_801457CC(GameState* gameState, SramContext* sramCtx) { gSaveContext.options.language = LANGUAGE_ENG; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_801457CC.s") -#endif void Sram_EraseSave(FileSelectState* fileSelect2, SramContext* sramCtx, s32 fileNum) { FileSelectState* fileSelect = fileSelect2; @@ -1694,8 +1690,6 @@ void Sram_EraseSave(FileSelectState* fileSelect2, SramContext* sramCtx, s32 file gSaveContext.flashSaveAvailable = D_801F6AF2; } -#ifdef NON_MATCHING -// v0/v1 void Sram_CopySave(FileSelectState* fileSelect2, SramContext* sramCtx) { FileSelectState* fileSelect = fileSelect2; u16 i; @@ -1737,13 +1731,11 @@ void Sram_CopySave(FileSelectState* fileSelect2, SramContext* sramCtx) { // clear buffer bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); // read to buffer - SysFlashrom_ReadData(&sramCtx->saveBuf[0], gFlashSaveStartPages[fileSelect->selectedFileIndex * 2], - gFlashSaveNumPages[fileSelect->selectedFileIndex * 2]); - if (1) {} + if (SysFlashrom_ReadData(&sramCtx->saveBuf[0], gFlashSaveStartPages[fileSelect->selectedFileIndex * 2], + gFlashSaveNumPages[fileSelect->selectedFileIndex * 2])) {} - SysFlashrom_ReadData(&sramCtx->saveBuf[0x2000], gFlashSaveStartPages[fileSelect->selectedFileIndex * 2 + 1], - gFlashSaveNumPages[fileSelect->selectedFileIndex * 2 + 1]); - if (1) {} + if (SysFlashrom_ReadData(&sramCtx->saveBuf[0x2000], gFlashSaveStartPages[fileSelect->selectedFileIndex * 2 + 1], + gFlashSaveNumPages[fileSelect->selectedFileIndex * 2 + 1])) {} // copy buffer to save context Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); @@ -1780,9 +1772,6 @@ void Sram_CopySave(FileSelectState* fileSelect2, SramContext* sramCtx) { gSaveContext.save.time = D_801F6AF0; gSaveContext.flashSaveAvailable = D_801F6AF2; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_CopySave.s") -#endif void Sram_InitSave(FileSelectState* fileSelect2, SramContext* sramCtx) { s32 phi_v0; |
