diff options
| -rw-r--r-- | include/functions.h | 3 | ||||
| -rw-r--r-- | spec | 10 | ||||
| -rw-r--r-- | src/audio/code_8019AF00.c | 97 | ||||
| -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 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Boss_06/z_boss_06.c | 5 | ||||
| -rw-r--r-- | src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c | 38 |
8 files changed, 120 insertions, 183 deletions
diff --git a/include/functions.h b/include/functions.h index 1654a0240..63a34368e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1333,7 +1333,10 @@ void Audio_RestorePrevBgm(void); void Audio_UpdateEnemyBgmVolume(f32 dist); u8 func_801A3950(u8 seqPlayerIndex, u8 resetChannelIO); u8 func_801A39F8(void); +void func_801A5118(void); s32 func_801A46F8(void); +void func_801A4FD8(void); +void AudioVoice_ResetData(void); void AudioSfx_MuteBanks(u16 muteMask); void AudioSfx_LowerBgmVolume(u8 channelIndex); @@ -646,11 +646,7 @@ beginseg include "build/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.o" include "build/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.o" include "build/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.o" - #ifdef NON_MATCHING - include "build/src/overlays/gamestates/ovl_file_choose/ovl_file_choose_reloc.o" - #else - include "build/data/ovl_file_choose/ovl_file_choose.reloc.o" - #endif + include "build/src/overlays/gamestates/ovl_file_choose/ovl_file_choose_reloc.o" endseg beginseg @@ -2315,11 +2311,7 @@ beginseg name "ovl_Boss_06" compress include "build/src/overlays/actors/ovl_Boss_06/z_boss_06.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Boss_06/ovl_Boss_06_reloc.o" -#else - include "build/data/ovl_Boss_06/ovl_Boss_06.reloc.o" -#endif endseg beginseg diff --git a/src/audio/code_8019AF00.c b/src/audio/code_8019AF00.c index 3f684cbf9..039c8f5c5 100644 --- a/src/audio/code_8019AF00.c +++ b/src/audio/code_8019AF00.c @@ -3424,26 +3424,18 @@ void AudioOcarina_PlayCustomSequence(void) { } // Unused -// Regalloc Swap https://decomp.me/scratch/QEovr -#ifdef NON_MATCHING s32 AudioOcarina_CreateCustomSequence(void) { OcarinaNote* prevNote; u16 i; - u16 phi_s4; - u16 temp_a0; // delay1 - u16 phi_a2; // delay2 + u16 delay = 0; u8 absPitch; - s8 phi_a0; // adjBendIndex - s8 phi_s2; // prevBend - u8 phi_t1; // vibrato - u8 phi_t5; // isLegato - u16 temp_t4; // prevNoteLength - - phi_a2 = 0; - phi_t1 = 0; - phi_s2 = 0; - phi_t5 = 0; - phi_s4 = 0; + s8 adjBendIndex; + u8 prevVibrato = 0; + s8 prevBend = 0; + u8 isLegato = false; + u16 phi_s4 = 0; + u16 temp1; // prevNoteLength, reused temp + u16 temp2; sCustomSequencePc = 39; // .channel chan_loop @@ -3454,41 +3446,41 @@ s32 AudioOcarina_CreateCustomSequence(void) { for (; (prevNote->length != 0) && (sCustomSequencePc < 394); i++) { - temp_a0 = ((prevNote->length * 48) / 30); + temp1 = ((prevNote->length * 48) / 30); - if (phi_t1 != prevNote->vibrato) { + if (prevVibrato != prevNote->vibrato) { sCustomSequenceScript[sCustomSequencePc++] = 0xFD; // delay cmd - if (phi_a2 >= 0x80) { + if (delay >= 0x80) { // Store as compressed u16 - sCustomSequenceScript[sCustomSequencePc++] = (((phi_a2 >> 8) & 0xFF) & 0x7F) + 0x80; // delay arg - sCustomSequenceScript[sCustomSequencePc++] = phi_a2 & 0xFF; // delay arg + sCustomSequenceScript[sCustomSequencePc++] = (((delay >> 8) & 0xFF) & 0x7F) + 0x80; // delay arg + sCustomSequenceScript[sCustomSequencePc++] = delay & 0xFF; // delay arg } else { // Store as u8 - sCustomSequenceScript[sCustomSequencePc++] = phi_a2; // delay arg + sCustomSequenceScript[sCustomSequencePc++] = delay; // delay arg } sCustomSequenceScript[sCustomSequencePc++] = 0xD8; // vibdepth cmd sCustomSequenceScript[sCustomSequencePc++] = prevNote->vibrato; // vibdepth arg - phi_a2 = temp_a0; - phi_t1 = prevNote->vibrato; + delay = temp1; + prevVibrato = prevNote->vibrato; } else { - phi_a2 += temp_a0; + delay += temp1; } prevNote = &sScarecrowsLongSongNotes[i]; } - if (phi_a2 != 0) { + if (delay != 0) { sCustomSequenceScript[sCustomSequencePc++] = 0xFD; // delay cmd - if (phi_a2 >= 0x80) { + if (delay >= 0x80) { // Store as compressed u16 - sCustomSequenceScript[sCustomSequencePc++] = (((phi_a2 >> 8) & 0xFF) & 0x7F) + 0x80; // delay arg - sCustomSequenceScript[sCustomSequencePc++] = phi_a2 & 0xFF; // delay arg + sCustomSequenceScript[sCustomSequencePc++] = (((delay >> 8) & 0xFF) & 0x7F) + 0x80; // delay arg + sCustomSequenceScript[sCustomSequencePc++] = delay & 0xFF; // delay arg } else { // Store as u8 - sCustomSequenceScript[sCustomSequencePc++] = phi_a2; // delay arg + sCustomSequenceScript[sCustomSequencePc++] = delay; // delay arg } } @@ -3514,46 +3506,42 @@ s32 AudioOcarina_CreateCustomSequence(void) { sCustomSequenceScript[sCustomSequencePc++] = 0xC9; // shortgate cmd sCustomSequenceScript[sCustomSequencePc++] = 0; // shortgate arg - if (1) {} - if (1) {} // TODO: Needed? - prevNote = &sScarecrowsLongSongNotes[0]; for (i = 1; ((prevNote->pitch == OCARINA_PITCH_NONE) && (prevNote->length != 0)); i++) { prevNote = &sScarecrowsLongSongNotes[i]; } - for (; ((temp_t4 = prevNote->length) != 0) && (sCustomSequencePc < 394); i++) { - + for (; ((temp1 = prevNote->length) != 0) && (sCustomSequencePc < 394); i++) { if (prevNote->pitch == sScarecrowsLongSongNotes[i].pitch) { - if ((sScarecrowsLongSongNotes[i].length != 0) && (phi_t5 == 0)) { + if ((sScarecrowsLongSongNotes[i].length != 0) && !isLegato) { sCustomSequenceScript[sCustomSequencePc++] = 0xC4; // legato cmd - phi_t5 = 1; + isLegato = true; } - } else if ((phi_t5 == 1) && (sScarecrowsLongSongNotes[i].pitch != OCARINA_PITCH_NONE) && + } else if ((isLegato == true) && (sScarecrowsLongSongNotes[i].pitch != OCARINA_PITCH_NONE) && (sScarecrowsLongSongNotes[i].pitch != OCARINA_PITCH_C4)) { sCustomSequenceScript[sCustomSequencePc++] = 0xC5; // nolegato cmd - phi_t5 = 0; + isLegato = false; } - if (phi_s2 != prevNote->bend) { + if (prevBend != prevNote->bend) { sCustomSequenceScript[sCustomSequencePc++] = 0xCE; // bendfine cmd if (ABS_ALT(prevNote->bend) > 64) { - phi_a0 = 127; + adjBendIndex = 127; } else if (prevNote->bend < 0) { - phi_a0 = -prevNote->bend; + adjBendIndex = -prevNote->bend; } else { - phi_a0 = ((prevNote->bend * 127) / 64); + adjBendIndex = ((prevNote->bend * 127) / 64); } if (prevNote->bend < 0) { - phi_a0 *= -1; + adjBendIndex *= -1; } - sCustomSequenceScript[sCustomSequencePc++] = phi_a0; // bendfine arg + sCustomSequenceScript[sCustomSequencePc++] = adjBendIndex; // bendfine arg - phi_s2 = prevNote->bend; + prevBend = prevNote->bend; } absPitch = prevNote->pitch + 39; // convert ocarina pitch to absolute pitch, + PITCH_C4 (Middle C) @@ -3564,20 +3552,18 @@ s32 AudioOcarina_CreateCustomSequence(void) { } // delay/duration - temp_a0 = ((temp_t4 * 48) + phi_s4) / 30; + temp2 = ((temp1 * 48) + phi_s4) / 30; - if (temp_a0 < 0x80) { + if (temp2 < 0x80) { // Store as u8 - sCustomSequenceScript[sCustomSequencePc++] = temp_a0; // shortdvg/ldelay arg + sCustomSequenceScript[sCustomSequencePc++] = temp2; // shortdvg/ldelay arg } else { // Store as compressed u16 - sCustomSequenceScript[sCustomSequencePc++] = (((temp_a0 >> 8) & 0xFF) & 0x7F) + 0x80; // shortdvg/ldelay arg - sCustomSequenceScript[sCustomSequencePc++] = temp_a0 & 0xFF; // shortdvg/ldelay arg + sCustomSequenceScript[sCustomSequencePc++] = (((temp2 >> 8) & 0xFF) & 0x7F) + 0x80; // shortdvg/ldelay arg + sCustomSequenceScript[sCustomSequencePc++] = temp2 & 0xFF; // shortdvg/ldelay arg } - if (1) {} - - phi_s4 = ((temp_t4 * 48) + phi_s4) - (temp_a0 * 30); + phi_s4 = ((temp1 * 48) + phi_s4) - (temp2 * 30); prevNote = &sScarecrowsLongSongNotes[i]; } @@ -3592,9 +3578,6 @@ s32 AudioOcarina_CreateCustomSequence(void) { return 0; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_CreateCustomSequence.s") -#endif void AudioOcarina_ResetInstrument(void) { if (sOcarinaInstrumentId != OCARINA_INSTRUMENT_OFF) { 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; diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 887c3fcc6..94b10fcfb 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -182,8 +182,6 @@ void func_809F24A8(Boss06* this) { this->unk_1AC = 0.0f; } -#ifdef NON_MATCHING -// The 1 constant from the switch branch is reused in case 2 for some reason. void func_809F24C8(Boss06* this, PlayState* play) { s16 sp4E = 0; Player* player = GET_PLAYER(play); @@ -344,9 +342,6 @@ void func_809F24C8(Boss06* this, PlayState* play) { Play_SetCameraAtEye(play, this->subCamId, &this->subCamAt, &this->subCamEye); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_06/func_809F24C8.s") -#endif void func_809F2B64(Boss06* this, PlayState* play) { this->actionFunc = func_809F2C44; diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c index 3957466b1..9ec0a396f 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c @@ -659,22 +659,19 @@ s16 D_80814650[] = { 940, 944 }; * fileSelect->windowContentVtx[956] -> Warning labels */ -#ifdef NON_MATCHING -// regalloc at the beginning is fixed by removing FAKE: labelled code void FileSelect_SetWindowContentVtx(GameState* thisx) { FileSelectState* this = (FileSelectState*)thisx; u16 vtxId; s16 j; - s16 index; + s16 i; s16 spAC; - s16 i; // a3 u16 spA4[3]; u16* ptr; - s32 posY; // sp9C - s32 relPosY; // sp98 + s32 posY; + s32 relPosY; s32 tempPosY; - s32 posX; // s1 - s32 temp_t5; + s32 posX; + s32 index; this->windowContentVtx = GRAPH_ALLOC(this->state.gfxCtx, 960 * sizeof(Vtx)); @@ -696,9 +693,6 @@ void FileSelect_SetWindowContentVtx(GameState* thisx) { this->windowContentVtx[vtxId + 0].v.ob[2] = this->windowContentVtx[vtxId + 1].v.ob[2] = this->windowContentVtx[vtxId + 2].v.ob[2] = this->windowContentVtx[vtxId + 3].v.ob[2] = 0; - //! FAKE: - if (index && index && index) {} - // flag this->windowContentVtx[vtxId + 0].v.flag = this->windowContentVtx[vtxId + 1].v.flag = this->windowContentVtx[vtxId + 2].v.flag = this->windowContentVtx[vtxId + 3].v.flag = 0; @@ -1193,7 +1187,7 @@ void FileSelect_SetWindowContentVtx(GameState* thisx) { /* Time Digits */ posX += 6; - temp_t5 = vtxId; + index = vtxId; for (i = 0; i < 5; i++, vtxId += 4, posX += 8) { @@ -1220,17 +1214,17 @@ void FileSelect_SetWindowContentVtx(GameState* thisx) { } // Adjust the colon to the right - this->windowContentVtx[temp_t5 + 8].v.ob[0] = this->windowContentVtx[temp_t5 + 10].v.ob[0] = - this->windowContentVtx[temp_t5 + 8].v.ob[0] + 3; + this->windowContentVtx[index + 8].v.ob[0] = this->windowContentVtx[index + 10].v.ob[0] = + this->windowContentVtx[index + 8].v.ob[0] + 3; - this->windowContentVtx[temp_t5 + 9].v.ob[0] = this->windowContentVtx[temp_t5 + 11].v.ob[0] = - this->windowContentVtx[temp_t5 + 8].v.ob[0] + 0xC; + this->windowContentVtx[index + 9].v.ob[0] = this->windowContentVtx[index + 11].v.ob[0] = + this->windowContentVtx[index + 8].v.ob[0] + 0xC; - this->windowContentVtx[temp_t5 + 0x1C].v.ob[0] = this->windowContentVtx[temp_t5 + 0x1E].v.ob[0] = - this->windowContentVtx[temp_t5 + 8].v.ob[0] + 1; + this->windowContentVtx[index + 0x1C].v.ob[0] = this->windowContentVtx[index + 0x1E].v.ob[0] = + this->windowContentVtx[index + 8].v.ob[0] + 1; - this->windowContentVtx[temp_t5 + 0x1D].v.ob[0] = this->windowContentVtx[temp_t5 + 0x1F].v.ob[0] = - this->windowContentVtx[temp_t5 + 0x1C].v.ob[0] + 0xC; + this->windowContentVtx[index + 0x1D].v.ob[0] = this->windowContentVtx[index + 0x1F].v.ob[0] = + this->windowContentVtx[index + 0x1C].v.ob[0] + 0xC; vtxId += 20; } @@ -1312,10 +1306,6 @@ void FileSelect_SetWindowContentVtx(GameState* thisx) { this->windowContentVtx[vtxId + 5].v.tc[0] = this->windowContentVtx[vtxId + 7].v.tc[0] = 0x1000; } -#else -void FileSelect_SetWindowContentVtx(GameState* thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_SetWindowContentVtx.s") -#endif u16 D_80814654[] = { 0x88, |
