diff --git a/code/include/rnd/item_override.h b/code/include/rnd/item_override.h index 31d77bb..1400272 100644 --- a/code/include/rnd/item_override.h +++ b/code/include/rnd/item_override.h @@ -453,6 +453,8 @@ namespace rnd { bool ItemOverride_CheckTingleMaps(u16, game::GlobalContext*); u32 ItemOverride_GetGaboraExtData(); u32 ItemOverride_GetOshExtData(); + void ItemOverride_SetSkullCollected(u16, game::SceneId); + u8 ItemOverride_IsSkullCollected(game::act::Actor*, game::SceneId); u8 ItemOverride_OverrideSkullToken(game::act::Actor*); u8 ItemOverride_CheckBossStatus(); } diff --git a/code/mm.ld b/code/mm.ld index a704722..63514b1 100644 --- a/code/mm.ld +++ b/code/mm.ld @@ -85,24 +85,6 @@ SECTIONS{ *(.patch_FastTransformPatchFive) } - .patch_UpdateBossLairExtData 0x29CF30 : { - *(.patch_UpdateBossLairExtData) - } - - /*2bec9c GOOD DREAM */ - /* - .patch_RemoveMeetMaskCutScene 0x2bec9c : { - *(.patch_RemoveMeetMaskCutScene) - } */ - - .patch_GiveTempSwordForHandD 0x2B523C : { - *(.patch_GiveTempSwordForHandD) - } - - .patch_RemoveTempSwordForHandD 0x2DDAF0 : { - *(.patch_RemoveTempSwordForHandD) - } - .patch_KeepBowOnEpona 0x188794 : { *(.patch_KeepBowOnEpona) } @@ -135,7 +117,7 @@ SECTIONS{ *(.patch_DoNotResetPermFlags) } - .patch_DoNotRemoveTradeItems 0x1c9AA8 : { + .patch_DoNotRemoveTradeItems 0x1C9AA8 : { *(.patch_DoNotRemoveTradeItems) } @@ -351,10 +333,24 @@ SECTIONS{ *(.patch_TwinmoldConsistentDamage) } + .patch_UpdateBossLairExtData 0x29CF30 : { + *(.patch_UpdateBossLairExtData) + } + + /*2bec9c GOOD DREAM */ + /* + .patch_RemoveMeetMaskCutScene 0x2bec9c : { + *(.patch_RemoveMeetMaskCutScene) + } */ + .patch_FasterBlockMovement 0x2AC634 : { *(.patch_FasterBlockMovement) } + .patch_GiveTempSwordForHandD 0x2B523C : { + *(.patch_GiveTempSwordForHandD) + } + .patch_GaboraCheckExtDataNotSword 0x2CBB14 : { *(.patch_GaboraCheckExtDataNotSword) } @@ -395,10 +391,18 @@ SECTIONS{ *(.patch_TingleCheckStoneTowerMap) } + .patch_RemoveTempSwordForHandD 0x2DDAF0 : { + *(.patch_RemoveTempSwordForHandD) + } + .patch_RemoveGoronMaskCheckDarmani 0x2DE788 : { *(.patch_RemoveGoronMaskCheckDarmani) } + .patch_RemoveSkulltulaSpawnIfCollectedItem 0x2E8384 : { + *(.patch_RemoveSkulltulaSpawnIfCollectedItem) + } + .patch_SaveExtDataOnOwl 0x317004 : { *(.patch_SaveExtDataOnOwl) } diff --git a/code/source/asm/item_override_hooks.s b/code/source/asm/item_override_hooks.s index 5c7751b..4eba3bf 100644 --- a/code/source/asm/item_override_hooks.s +++ b/code/source/asm/item_override_hooks.s @@ -159,6 +159,18 @@ doNotSpawnDarmani: nop b 0x2DE96C +.global hook_RemoveSkulltulaSpawnIfCollectedItem +hook_RemoveSkulltulaSpawnIfCollectedItem: + push {r0-r12,lr} + cpy r0,r4 + cpy r1,r6 + mov r1,#0x148 + ldrsh r1, [r1,r6] + bl ItemOverride_IsSkullCollected + cmp r0, #0x0 + pop {r0-r12,lr} + bx lr + .global hook_CheckOshExtData hook_CheckOshExtData: push {lr} diff --git a/code/source/asm/item_override_patches.s b/code/source/asm/item_override_patches.s index 946bea6..71f75c0 100644 --- a/code/source/asm/item_override_patches.s +++ b/code/source/asm/item_override_patches.s @@ -57,6 +57,11 @@ patch_RemoveAddingSkulltulaTokenIfOverridden: patch_RemoveGoronMaskCheckDarmani: b hook_DarmaniRewardCheck +.section .patch_RemoveSkulltulaSpawnIfCollectedItem +.global patch_RemoveSkulltulaSpawnIfCollectedItem +patch_RemoveSkulltulaSpawnIfCollectedItem: + bl hook_RemoveSkulltulaSpawnIfCollectedItem + .section .patch_CheckOshExtData .global patch_CheckOshExtData patch_CheckOshExtData: diff --git a/code/source/rnd/item_override.cpp b/code/source/rnd/item_override.cpp index 369c0d3..e2ba238 100644 --- a/code/source/rnd/item_override.cpp +++ b/code/source/rnd/item_override.cpp @@ -36,6 +36,13 @@ namespace rnd { static u8 rSatisfiedPendingFrames = 0; + static u8 skulltulaMapSSH[30] = {0x03, 0x07, 0x0B, 0x13, 0x15, 0x1B, 0x1F, 0x23, 0x25, 0x29, + 0x2D, 0x31, 0x37, 0x3B, 0x3F, 0x41, 0x45, 0x49, 0x4F, 0x53, + 0x56, 0x5B, 0x5D, 0x62, 0x67, 0x69, 0x6D, 0x71, 0x76, 0x79}; + static u8 skulltulaMapOSH[30] = {0x07, 0x0B, 0x0F, 0x13, 0x17, 0x1B, 0x1F, 0x23, 0x27, 0x2B, + 0x2D, 0x33, 0x37, 0x3B, 0x3F, 0x42, 0x46, 0x4A, 0x4F, 0x53, + 0x57, 0x59, 0x5D, 0x61, 0x65, 0x69, 0x6D, 0x73, 0x77, 0x7B}; + void ItemOverride_Init(void) { #ifdef ENABLE_DEBUG // Manual overide example code @@ -45,8 +52,8 @@ namespace rnd { rItemOverrides[0].value.looksLikeItemId = 0x56; rItemOverrides[1].key.scene = 0x6F; rItemOverrides[1].key.type = ItemOverride_Type::OVR_COLLECTABLE; - rItemOverrides[1].value.getItemId = 0x01; - rItemOverrides[1].value.looksLikeItemId = 0x01; + rItemOverrides[1].value.getItemId = 0x46; + rItemOverrides[1].value.looksLikeItemId = 0x46; rItemOverrides[2].key.scene = 0x12; rItemOverrides[2].key.type = ItemOverride_Type::OVR_COLLECTABLE; rItemOverrides[2].value.getItemId = 0x37; @@ -1048,9 +1055,46 @@ namespace rnd { return (u32)gExtSaveData.givenItemChecks.enOshGivenItem; } + void ItemOverride_SetSkullCollected(u16 params, game::SceneId scene) { + for (u8 i = 0; i < 30; i++) { + if (scene == game::SceneId::SwampSpiderHouse) { + if (skulltulaMapSSH[i] == (params & 0xFF)) { + gExtSaveData.chestRewarded[(u8)game::SceneId::SwampSpiderHouse][i] = 1; + return; + } + } else if (scene == game::SceneId::OceansideSpiderHouse) { + if (skulltulaMapOSH[i] == (params & 0xFF)) { + gExtSaveData.chestRewarded[(u8)game::SceneId::OceansideSpiderHouse][i] = 1; + return; + } + } + } + } + + u8 ItemOverride_IsSkullCollected(game::act::Actor * actor, game::SceneId scene) { + #if defined ENABLE_DEBUG || defined DEBUG_PRINT + rnd::util::Print("%s: Our scene is %#06x\n", __func__, scene); + #endif + for (u8 i = 0; i < 30; i++) { + if (scene == game::SceneId::SwampSpiderHouse) { + if (skulltulaMapSSH[i] == (actor->params & 0xFF)) { + return gExtSaveData.chestRewarded[(u8)game::SceneId::SwampSpiderHouse][i]; + } + } else if (scene == game::SceneId::OceansideSpiderHouse) { + // Special case - since OSH has one chest, let's remove + if ((i+1) == 30) break; + if (skulltulaMapOSH[i+1] == (actor->params & 0xFF)) { + return gExtSaveData.chestRewarded[(u8)game::SceneId::OceansideSpiderHouse][i+1]; + } + } + } + return 0; + } + u8 ItemOverride_OverrideSkullToken(game::act::Actor* actor) { game::GlobalContext* gctx = GetContext().gctx; s16 getItemId = gctx->scene == game::SceneId::SwampSpiderHouse ? 0x44 : 0x6D; + ItemOverride_SetSkullCollected(actor->params, gctx->scene); ItemOverride_GetItem(gctx, actor, gctx->GetPlayerActor(), getItemId); if (rActiveItemRow != NULL) { ItemOverride_GetItemTextAndItemID(gctx->GetPlayerActor());