From b08880f7a7fdc49ca104fb86f5ffd4fd4a2aa221 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 27 Mar 2022 12:37:02 -0300 Subject: `z_sram_NES` with 2 NON_MATCHINGs and 1 NON_EQUIVALENTs (#531) * Rename Sram_InitDebugSave * Sram_InitDebugSave * err * Sram_IncrementDay * non_matchings * func_80146F5C and protos * func_80146EE8 * func_80145698 * func_80143A54 * Split SaveContext * problems with bss * Fix bss * more * a small bunch * Fix warnings * almost everything * two attempts * at least compiles * import data * bss * format * stuff? * Progress? * More progress * clean up data a little * More progress * disaster * re split data * A bit less of a disaster * Fix renamed stuff * data stuff * fix conflicts * format * CycleSceneFlags * some enums * cleanup * Fix merge issues * format * some changes * format * Lots of progress on z_sram_NES, but no matches yet * SaveContent Documentation * Oops * Oops2 * Document more SaveContext * Oops, don't need that anymore * add small comment * Another comment * dekuPlaygroundPlayerName * Fix merge issues * format * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * remove magic number * format * fix merge issues * bss * format * macro cleanup * review * merge issues * review * cleanup * UNK_TYPE1 * Fix * Remove comment * small change * conflicts * review * fix * fixes * format * Update actorCtx renames part * Match func_80143B0C thanks to Petrie and Anon * minor cleaning pass * format * cleanup * more minor cleanups * Macros for accessing gSaveContext.save.stolenItems * Introduce STOLEN_ITEM_NONE and remove CLEAR_STOLEN_ITEM_ * format * Update include/macros.h Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * Update src/code/z_sram_NES.c Co-authored-by: Derek Hensley * @hensldm review * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Rename QUEST_SONG_NEW_WAVE * Add scene name comments to D_801C5FC0 * rename horseData.yaw * Update include/functions.h Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update src/code/z_sram_NES.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * // = CUR_UPG_VALUE(UPG_WALLET); * run actorfixer and format * fix bss * Fix merge problems and run format * Some improvements to func_801457CC by anon * bss * format * run actorfixer * actorfixer, bss and format * Use original names for the RESPAWN_MODE enum because the current ones are bad * QUEST_SONG_BOSSA_NOVA * some minor fixes on the SaveContext struct according to the debug rom * Merge Inventory.items and Inventory.masks * a * simplify saveBuf accesses * A few func renames * actorfixer * bss * fixes * bss * actorfixer * actorfixer and format * actorfixer * whoops * whops * bss Co-authored-by: engineer124 Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: Derek Hensley --- src/code/code_8012EC80.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'src/code/code_8012EC80.c') diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index f60d98568..5dee17fb5 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -504,7 +504,7 @@ void Inventory_ChangeEquipment(s16 value) { u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { Player* player = GET_PLAYER(globalCtx); - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { SET_EQUIP_VALUE(EQUIP_SHIELD, 0); Player_SetEquipmentData(globalCtx, player); return true; @@ -514,12 +514,12 @@ u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { } void Inventory_ChangeUpgrade(s16 upgrade, u32 value) { - u32 upgrades = gSaveContext.inventory.upgrades; + u32 upgrades = gSaveContext.save.inventory.upgrades; upgrades &= gUpgradeNegMasks[upgrade]; upgrades |= value << gUpgradeShifts[upgrade]; - gSaveContext.inventory.upgrades = upgrades; + gSaveContext.save.inventory.upgrades = upgrades; } s32 Inventory_IsMapVisible(s16 sceneNum) { @@ -546,7 +546,7 @@ s32 Inventory_IsMapVisible(s16 sceneNum) { } } - if (gSaveContext.scenesVisible[index] & gBitFlags[sceneNum - (index << 5)]) { + if (gSaveContext.save.scenesVisible[index] & gBitFlags[sceneNum - (index << 5)]) { return true; } @@ -659,23 +659,23 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { index = 6; } - gSaveContext.scenesVisible[index] = - gSaveContext.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIndices)[i] - (index << 5)]; + gSaveContext.save.scenesVisible[index] = + gSaveContext.save.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIndices)[i] - (index << 5)]; i++; } if ((*tingleMapSceneIndices) == sScenesPerTingleMap[0]) { - gSaveContext.mapsVisible |= 3; + gSaveContext.save.mapsVisible |= 3; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[1]) { - gSaveContext.mapsVisible |= 0x1C; + gSaveContext.save.mapsVisible |= 0x1C; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[2]) { - gSaveContext.mapsVisible |= 0xE0; + gSaveContext.save.mapsVisible |= 0xE0; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[3]) { - gSaveContext.mapsVisible |= 0x100; + gSaveContext.save.mapsVisible |= 0x100; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[4]) { - gSaveContext.mapsVisible |= 0x1E00; + gSaveContext.save.mapsVisible |= 0x1E00; } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[5]) { - gSaveContext.mapsVisible |= 0x6000; + gSaveContext.save.mapsVisible |= 0x6000; } } @@ -688,32 +688,34 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { void Inventory_SaveDekuPlaygroundHighScore(s16 timerId) { s16 i; - gSaveContext.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.unk_3DE0[timerId]; + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.unk_3DE0[timerId]; for (i = 0; i < 8; i++) { - gSaveContext.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = gSaveContext.playerName[i]; + gSaveContext.save.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = + gSaveContext.save.playerData.playerName[i]; } } void Inventory_IncrementSkullTokenCount(s16 sceneIndex) { if (sceneIndex == SCENE_KINSTA1) { // Swamp Spider House (increment high bits of skullTokenCount) - gSaveContext.skullTokenCount = ((u16)(((gSaveContext.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | - (gSaveContext.skullTokenCount & 0xFFFF); + gSaveContext.save.skullTokenCount = + ((u16)(((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | + (gSaveContext.save.skullTokenCount & 0xFFFF); } else { // Ocean Spider House (increment low bits of skullTokenCount) - gSaveContext.skullTokenCount = - (((u16)gSaveContext.skullTokenCount + 1) & 0xFFFF) | (gSaveContext.skullTokenCount & 0xFFFF0000); + gSaveContext.save.skullTokenCount = + (((u16)gSaveContext.save.skullTokenCount + 1) & 0xFFFF) | (gSaveContext.save.skullTokenCount & 0xFFFF0000); } } s16 Inventory_GetSkullTokenCount(s16 sceneIndex) { if (sceneIndex == SCENE_KINSTA1) { // Swamp Spider House - return (gSaveContext.skullTokenCount & 0xFFFF0000) >> 0x10; + return (gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10; } else { // Ocean Spider House - return gSaveContext.skullTokenCount & 0xFFFF; + return gSaveContext.save.skullTokenCount & 0xFFFF; } } @@ -723,5 +725,6 @@ void Inventory_SaveLotteryCodeGuess(GlobalContext* globalCtx) { lotteryCodeGuess = ((globalCtx->msgCtx.unk12054[0] & 0xF) << 8); // First Digit lotteryCodeGuess |= ((globalCtx->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit lotteryCodeGuess |= (globalCtx->msgCtx.unk12054[2] & 0xF); // Third Digit - gSaveContext.lotteryCodeGuess = (gSaveContext.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); + gSaveContext.save.lotteryCodeGuess = + (gSaveContext.save.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); } -- cgit v1.2.3