Skip to content

Commit

Permalink
Merge pull request #86 from gymnast86/logic
Browse files Browse the repository at this point in the history
Logic:Skip dungeon end cutscenes and minor logic fix
  • Loading branch information
gamestabled authored Mar 30, 2021
2 parents faea56f + 2ed67ab commit 08ba12c
Show file tree
Hide file tree
Showing 14 changed files with 293 additions and 35 deletions.
34 changes: 33 additions & 1 deletion code/oot.ld
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SECTIONS
.patch_SariasSongItemGive 0x12C84C : {
*(.patch_SariasSongItemGive)
}

.patch_SariasSongLocation 0x12C8F8 : {
*(.patch_SariasSongLocation)
}
Expand Down Expand Up @@ -176,6 +176,10 @@ SECTIONS
*(.patch_JabuJabuItemGive)
}

.patch_JabuJabuCutsceneOverride 0x1A192C : {
*(.patch_JabuJabuCutsceneOverride)
}

.patch_KingZoraSecondTunic 0x1B6A18 : {
*(.patch_KingZoraSecondTunic)
}
Expand Down Expand Up @@ -204,14 +208,26 @@ SECTIONS
*(.patch_ForestTempleItemGive)
}

.patch_ForestTempleCutsceneOverride 0x1E3F98 : {
*(.patch_ForestTempleCutsceneOverride)
}

.patch_FireTempleItemGive 0x1E4010 : {
*(.patch_FireTempleItemGive)
}

.patch_FireTempleCutsceneOverride 0x1E4024 : {
*(.patch_FireTempleCutsceneOverride)
}

.patch_WaterTempleItemGive 0x1E40D8 : {
*(.patch_WaterTempleItemGive)
}

.patch_WaterTempleCutsceneOverride 0x1E40EC : {
*(.patch_WaterTempleCutsceneOverride)
}

.patch_SpiritTempleBitMask 0x1E4154 : {
*(.patch_SpiritTempleBitMask)
}
Expand All @@ -220,6 +236,10 @@ SECTIONS
*(.patch_SpiritTempleItemGive)
}

.patch_SpiritTempleCutsceneOverride 0x1E417C : {
*(.patch_SpiritTempleCutsceneOverride)
}

.patch_ShadowTempleBitMask 0x1E41DC : {
*(.patch_ShadowTempleBitMask)
}
Expand All @@ -228,6 +248,10 @@ SECTIONS
*(.patch_ShadowTempleItemGive)
}

.patch_ShadowTempleCutsceneOverride 0x1E4204 : {
*(.patch_ShadowTempleCutsceneOverride)
}

.patch_DaruniaCheckStrength 0x1E489C : {
*(.patch_DaruniaCheckStrength)
}
Expand Down Expand Up @@ -612,10 +636,18 @@ SECTIONS
*(.patch_DodongosCavernItemGive)
}

.patch_DodongosCavernCutsceneOverride 0x3F57C4 : {
*(.patch_DodongosCavernCutsceneOverride)
}

.patch_DekuTreeItemGive 0x3F582C : {
*(.patch_DekuTreeItemGive)
}

.patch_DekuTreeCutsceneOverride 0x3F5840 : {
*(.patch_DekuTreeCutsceneOverride)
}

.patch_InitSceneClearExtendedObjects 0x449218 : {
*(.patch_InitSceneClearExtendedObjects)
}
Expand Down
68 changes: 67 additions & 1 deletion code/src/cutscenes.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void Cutscene_OverrideSongOfStorms(void) {

void Cutscene_OverrideFairyReward(BgDyYoseizo* fairy) {
s16 fairyIdx = fairy->unk_D2C;

if (gGlobalContext->sceneNum == 0x3D) {
if (!(gSaveContext.itemGetInf[1] & (0x100 << fairyIdx))) {
ItemOverride_PushDelayedOverride(0x10 + fairyIdx);
Expand All @@ -170,3 +170,69 @@ void Cutscene_OverrideFairyReward(BgDyYoseizo* fairy) {
gSaveContext.magic = gSaveContext.magicLevel * 0x30;
Actor_Kill(&fairy->actor);
}

//skip dungeon exit cutscenes
void Cutscene_OverrideDekuTree(void) {
gGlobalContext->nextEntranceIndex = 0x457;
gGlobalContext->sceneLoadFlag = 0x14;
gGlobalContext->fadeOutTransition = 0xA;
gSaveContext.nextCutsceneIndex = 0x0;
ItemOverride_PushDungeonReward(DUNGEON_DEKU_TREE);
}

void Custcene_OverrideDodongosCavern(void) {
gGlobalContext->nextEntranceIndex = 0x47A;
gGlobalContext->sceneLoadFlag = 0x14;
gGlobalContext->fadeOutTransition = 0xA;
gSaveContext.nextCutsceneIndex = 0x0;
ItemOverride_PushDungeonReward(DUNGEON_DODONGOS_CAVERN);
}

void Custcene_OverrideJabuJabusBelly(void) {
gGlobalContext->nextEntranceIndex = 0x221;
gGlobalContext->sceneLoadFlag = 0x14;
gGlobalContext->fadeOutTransition = 0xA;
gSaveContext.nextCutsceneIndex = 0x0;
ItemOverride_PushDungeonReward(DUNGEON_JABUJABUS_BELLY);
}

void Custcene_OverrideForestTemple(void) {
gGlobalContext->nextEntranceIndex = 0x608;
gGlobalContext->sceneLoadFlag = 0x14;
gGlobalContext->fadeOutTransition = 0x3;
gSaveContext.nextCutsceneIndex = 0x0;
ItemOverride_PushDungeonReward(DUNGEON_FOREST_TEMPLE);
}

void Cutscene_OverrideFireTemple(void) {
gGlobalContext->nextEntranceIndex = 0x564;
gGlobalContext->sceneLoadFlag = 0x14;
gGlobalContext->fadeOutTransition = 0x3;
gSaveContext.nextCutsceneIndex = 0x0;
ItemOverride_PushDungeonReward(DUNGEON_FIRE_TEMPLE);
}

void Custcene_OverrideWaterTemple(void) {
gGlobalContext->nextEntranceIndex = 0x60C;
gGlobalContext->sceneLoadFlag = 0x14;
gGlobalContext->fadeOutTransition = 0x3;
gSaveContext.nextCutsceneIndex = 0x0;
ItemOverride_PushDungeonReward(DUNGEON_WATER_TEMPLE);
gSaveContext.eventChkInf[6] |= 0x0200; //Raise Lake Hylia's Water
}

void Custcene_OverrideSpiritTemple(void) {
gGlobalContext->nextEntranceIndex = 0x610;
gGlobalContext->sceneLoadFlag = 0x14;
gGlobalContext->fadeOutTransition = 0x3;
gSaveContext.nextCutsceneIndex = 0x0;
ItemOverride_PushDungeonReward(DUNGEON_SPIRIT_TEMPLE);
}

void Custcene_OverrideShadowTemple(void) {
gGlobalContext->nextEntranceIndex = 0x580;
gGlobalContext->sceneLoadFlag = 0x14;
gGlobalContext->fadeOutTransition = 0x3;
gSaveContext.nextCutsceneIndex = 0x0;
ItemOverride_PushDungeonReward(DUNGEON_SHADOW_TEMPLE);
}
15 changes: 8 additions & 7 deletions code/src/dungeon_rewards.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{ .textId = textId_, .bitMask = bitMask_, .objectId = objectId_, \
.objectModelIdx = objectModelIdx_, .itemId = itemId_, .actorParam = actorParam_ }

u32 rDungeonRewardOverrides[LIGHT_MEDALLION + 1] = {
u32 rDungeonRewardOverrides[LIGHT_MEDALLION + 1] = {
KOKIRI_EMERALD,
GORON_RUBY,
ZORA_SAPPHIRE,
Expand Down Expand Up @@ -44,19 +44,20 @@ static const DungeonRewardInfo rDungeonRewardTable[] = {
};

u32 DungeonReward_GetOverrideText(u32 incomingTextId) {
for (u32 i = KOKIRI_EMERALD; i <= LIGHT_MEDALLION; ++i) {
if (rDungeonRewardTable[i].textId == incomingTextId) {
return rDungeonRewardTable[rDungeonRewardOverrides[i]].textId;
}
}
// commenting out for now
// for (u32 i = KOKIRI_EMERALD; i <= LIGHT_MEDALLION; ++i) {
// if (rDungeonRewardTable[i].textId == incomingTextId) {
// return rDungeonRewardTable[rDungeonRewardOverrides[i]].textId;
// }
// }
return incomingTextId;
}

void DungeonReward_OverrideItemGive(GlobalContext* globalCtx, u8 incomingItem) {
if ((incomingItem >= ITEM_MEDALLION_FOREST) && (incomingItem < ITEM_KOKIRI_EMERALD)) {
Item_Give(globalCtx, rDungeonRewardTable[rDungeonRewardOverrides[(incomingItem - ITEM_MEDALLION_FOREST) + FOREST_MEDALLION]].itemId);
} else if ((incomingItem >= ITEM_KOKIRI_EMERALD) && (incomingItem <= ITEM_ZORA_SAPPHIRE)) {
Item_Give(globalCtx, rDungeonRewardTable[rDungeonRewardOverrides[incomingItem - ITEM_KOKIRI_EMERALD]].itemId);
Item_Give(globalCtx, rDungeonRewardTable[rDungeonRewardOverrides[incomingItem - ITEM_KOKIRI_EMERALD]].itemId);
}
}

Expand Down
41 changes: 41 additions & 0 deletions code/src/entrance.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "entrance.h"
#include "settings.h"
#include "string.h"
#include "item_override.h"

void Scene_Init(void) {
memcpy(&gSceneTable[0], gSettingsContext.dekuTreeDungeonMode == DUNGEONMODE_MQ ? &gMQDungeonSceneTable[0] : &gDungeonSceneTable[0], sizeof(Scene));
Expand Down Expand Up @@ -41,6 +42,46 @@ void Entrance_Init(void) {
gEntranceTable[0x43F].field = 0x4183;
}

// Delete the title card for Kokiri Forest from Deku Tree Death Cutscene
for (index = 0x457; index < 0x45A; ++index) {
gEntranceTable[index].field = 0x0202;
}

// Delete the title card for Death Mountain Trail from Goron Ruby Cutscene
for (index = 0x47A; index < 0x47D; ++index) {
gEntranceTable[index].field = 0x0202;
}

// Delete the title card for Zora's Fountain from Inside Jabu Jabu's Belly
for (index = 0x221; index < 0x224; ++index) {
gEntranceTable[index].field = 0x0102;
}

// Delete the title card for Sacred Forest Meadow from Forest Temple Blue Warp
for (index = 0x608; index < 0x60B; ++index) {
gEntranceTable[index].field = 0x0102;
}

// Delete the title card for Death Mountain Crater from Fire Temple Blue Warp
for (index = 0x564; index < 0x567; ++index) {
gEntranceTable[index].field = 0x0102;
}

// Delete the title card for Lake Hylia from Water Temple Blue Warp
for (index = 0x60C; index < 0x60F; ++index) {
gEntranceTable[index].field = 0x0102;
}

// Delete the title card for Desert Colossus from Spirit Temple Blue Warp
for (index = 0x610; index < 0x613; ++index) {
gEntranceTable[index].field = 0x0102;
}

// Delete the title card for Graveyard from Shadow Temple Blue Warp
for (index = 0x580; index < 0x583; ++index) {
gEntranceTable[index].field = 0x0102;
}

// Delete the title card for Desert Colossus from Requiem
for (index = 0x1ED; index < 0x1F1; ++index) {
gEntranceTable[index].field = 0x0102;
Expand Down
9 changes: 9 additions & 0 deletions code/src/item_effect.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,12 @@ void ItemEffect_GiveChildKokiriSword(SaveContext* saveCtx, s16 arg1, s16 arg2) {
//Put the Kokiri Sword on Child B button when Link goes back child
saveCtx->childEquips.buttonItems[0] = ITEM_SWORD_KOKIRI;
}

void ItemEffect_GiveStone(SaveContext* saveCtx, s16 mask, s16 arg2) {
s32 trueMask = mask << 16;
saveCtx->questItems |= trueMask;
}

void ItemEffect_GiveMedallion(SaveContext* saveCtx, s16 mask, s16 arg2) {
saveCtx->questItems |= mask;
}
2 changes: 2 additions & 0 deletions code/src/item_effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ void ItemEffect_FillWalletUpgrade(SaveContext* saveCtx, s16 arg1, s16 arg2);
void ItemEffect_OpenMaskShop(SaveContext* saveCtx, s16 arg1, s16 arg2);
void ItemEffect_PlaceMagicArrowsInInventory(SaveContext* saveCtx, s16 arg1, s16 arg2);
void ItemEffect_GiveChildKokiriSword(SaveContext* saveCtx, s16 arg1, s16 arg2);
void ItemEffect_GiveStone(SaveContext* saveCtx, s16 mask, s16 arg2);
void ItemEffect_GiveMedallion(SaveContext* saveCtx, s16 mask, s16 arg2);

#endif //_ITEM_EFFECT_H_
9 changes: 9 additions & 0 deletions code/src/item_override.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,12 @@ void ItemOverride_CheckZeldasLetter() {
EventSet(0x40);
}
}

void ItemOverride_PushDungeonReward(u8 dungeon) {
ItemOverride_Key key = { .all = 0 };
key.scene = 0xFF;
key.type = OVR_TEMPLE;
key.flag = dungeon;
ItemOverride override = ItemOverride_LookupByKey(key);
ItemOverride_PushPendingOverride(override);
}
2 changes: 2 additions & 0 deletions code/src/item_override.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum ItemOverride_Type {
OVR_SKULL = 3,
OVR_GROTTO_SCRUB = 4,
OVR_DELAYED = 5,
OVR_TEMPLE = 6,
};

typedef union {
Expand Down Expand Up @@ -43,5 +44,6 @@ ItemOverride ItemOverride_LookupByKey(ItemOverride_Key key);
ItemOverride ItemOverride_Lookup(Actor* actor, u8 scene, u8 item_id);
void ItemOverride_PushDelayedOverride(u8 flag);
void ItemOverride_CheckZeldasLetter();
void ItemOverride_PushDungeonReward(u8 dungeon);

#endif
11 changes: 11 additions & 0 deletions code/src/item_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ static ItemRow rItemTable[] = {
[0xC9] = ITEM_ROW(0x53, 0, 0x41, 0x0048, 0x00F3, 0x00, 0x00, 0x3E, ItemUpgrade_None, ItemEffect_BeanPack, -1, -1), // Magic Bean Pack
// [0xCA] = ITEM_ROW(0x53, 0, 0x41, 0x9003, 0x0193, 0x00, 0x00, 0x35, ItemUpgrade_None, give_triforce_piece, -1, -1), // Triforce piece

[0xCB] = ITEM_ROW(0x53, 0, 0x41, 0x0080, 0x019C, 0x00, 0x00, 0x88, ItemUpgrade_None, ItemEffect_GiveStone, 0x0004, -1), // Kokiri Emerald
[0xCC] = ITEM_ROW(0x53, 0, 0x41, 0x0081, 0x019D, 0x00, 0x00, 0x89, ItemUpgrade_None, ItemEffect_GiveStone, 0x0008, -1), // Goron Ruby
[0xCD] = ITEM_ROW(0x53, 0, 0x41, 0x0082, 0x019E, 0x00, 0x00, 0x8A, ItemUpgrade_None, ItemEffect_GiveStone, 0x0010, -1), // Zora Sapphire

[0xCE] = ITEM_ROW(0x53, 0, 0x41, 0x003E, 0x00BA, 0x01, 0x00, 0x0C, ItemUpgrade_None, ItemEffect_GiveMedallion, 0x0001, -1), // Forest Medallion
[0xCF] = ITEM_ROW(0x53, 0, 0x41, 0x003C, 0x00BA, 0x02, 0x00, 0x0D, ItemUpgrade_None, ItemEffect_GiveMedallion, 0x0002, -1), // Fire Medallion
[0xD0] = ITEM_ROW(0x53, 0, 0x41, 0x003D, 0x00BA, 0x03, 0x00, 0x0E, ItemUpgrade_None, ItemEffect_GiveMedallion, 0x0004, -1), // Water Medallion
[0xD1] = ITEM_ROW(0x53, 0, 0x41, 0x003F, 0x00BA, 0x04, 0x00, 0x0F, ItemUpgrade_None, ItemEffect_GiveMedallion, 0x0008, -1), // Spirit Medallion
[0xD2] = ITEM_ROW(0x53, 0, 0x41, 0x0041, 0x00BA, 0x05, 0x00, 0x10, ItemUpgrade_None, ItemEffect_GiveMedallion, 0x0010, -1), // Shadow Medallion
[0xD3] = ITEM_ROW(0x53, 0, 0x41, 0x0040, 0x00BA, 0x00, 0x00, 0x11, ItemUpgrade_None, ItemEffect_GiveMedallion, 0x0020, -1), // Light Medallion

};

ItemRow* ItemTable_GetItemRow(u16 itemId) {
Expand Down
Loading

0 comments on commit 08ba12c

Please sign in to comment.