Skip to content

Commit

Permalink
Update dungeon item keys to show properly in spoiler menu.
Browse files Browse the repository at this point in the history
Update override for dungeon keys to not always give woodfall.

Update some override conditions to use actual values.
  • Loading branch information
PhlexPlexico committed Dec 21, 2023
1 parent 288ab21 commit 6f7449b
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 34 deletions.
4 changes: 4 additions & 0 deletions code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ SECTIONS{
*(.patch_CheckDungeonItems)
}

.patch_CheckDungeonSmallKeys 0x233F4C : {
*(.patch_CheckDungeonSmallKeys)
}

.patch_DisableMilkTimer 0x234BFC : {
*(.patch_DisableMilkTimer)
}
Expand Down
11 changes: 11 additions & 0 deletions code/source/asm/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ hook_CheckDungeonItems:
ldrh r2, [r2, #82]
bx lr

.global hook_CheckDungeonSmallKeys
hook_CheckDungeonSmallKeys:
push {r0-r12, lr}
ldr r1,.rCustomDungeonItemRetrieved_addr
ldr r1,[r1]
cmp r1,#0x1
pop {r0-r12, lr}
beq 0x233F60
ldrh r0, [r2, #0x52]
bx lr

.global hook_SaveFile_Load
hook_SaveFile_Load:
push {r0-r12, lr}
Expand Down
5 changes: 5 additions & 0 deletions code/source/asm/patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ patch_CheckCurrentInventoryOverrideItem:
patch_CheckDungeonItems:
bl hook_CheckDungeonItems

.section .patch_CheckDungeonSmallKeys
.global patch_CheckDungeonSmallKeys
patch_CheckDungeonSmallKeys:
bl hook_CheckDungeonSmallKeys

.section .patch_DisableMilkTimer
.global patch_DisableMilkTimer
patch_DisableMilkTimer:
Expand Down
61 changes: 31 additions & 30 deletions code/source/rnd/gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,61 +257,61 @@ namespace rnd {
u8 yPos = 30;
for (u32 dungeonId = 0; dungeonId <= DUNGEON_STONE_TOWER; ++dungeonId) {
bool hasBossKey = 0;
if ((dungeonId = DUNGEON_WOODFALL)) {
if ((dungeonId == DUNGEON_WOODFALL)) {
hasBossKey = saveData.inventory.woodfall_dungeon_items.boss_key.Value();
}
if ((dungeonId = DUNGEON_SNOWHEAD)) {
if ((dungeonId == DUNGEON_SNOWHEAD)) {
hasBossKey = saveData.inventory.snowhead_dungeon_items.boss_key.Value();
}
if ((dungeonId = DUNGEON_GREAT_BAY)) {
if ((dungeonId == DUNGEON_GREAT_BAY)) {
hasBossKey = saveData.inventory.great_bay_dungeon_items.boss_key.Value();
}
if ((dungeonId = DUNGEON_STONE_TOWER)) {
if ((dungeonId == DUNGEON_STONE_TOWER)) {
hasBossKey = saveData.inventory.stone_tower_dungeon_items.boss_key.Value();
}
bool hasCompass = 0;
if ((dungeonId = DUNGEON_WOODFALL)) {
hasBossKey = saveData.inventory.woodfall_dungeon_items.compass.Value();
if ((dungeonId == DUNGEON_WOODFALL)) {
hasCompass = saveData.inventory.woodfall_dungeon_items.compass.Value();
}
if ((dungeonId = DUNGEON_SNOWHEAD)) {
hasBossKey = saveData.inventory.snowhead_dungeon_items.compass.Value();
if ((dungeonId == DUNGEON_SNOWHEAD)) {
hasCompass = saveData.inventory.snowhead_dungeon_items.compass.Value();
}
if ((dungeonId = DUNGEON_GREAT_BAY)) {
hasBossKey = saveData.inventory.great_bay_dungeon_items.compass.Value();
if ((dungeonId == DUNGEON_GREAT_BAY)) {
hasCompass = saveData.inventory.great_bay_dungeon_items.compass.Value();
}
if ((dungeonId = DUNGEON_STONE_TOWER)) {
hasBossKey = saveData.inventory.stone_tower_dungeon_items.compass.Value();
if ((dungeonId == DUNGEON_STONE_TOWER)) {
hasCompass = saveData.inventory.stone_tower_dungeon_items.compass.Value();
}
bool hasMap = 0;
if ((dungeonId = DUNGEON_WOODFALL)) {
hasBossKey = saveData.inventory.woodfall_dungeon_items.map.Value();
if ((dungeonId == DUNGEON_WOODFALL)) {
hasMap = saveData.inventory.woodfall_dungeon_items.map.Value();
}
if ((dungeonId = DUNGEON_SNOWHEAD)) {
hasBossKey = saveData.inventory.snowhead_dungeon_items.map.Value();
if ((dungeonId == DUNGEON_SNOWHEAD)) {
hasMap = saveData.inventory.snowhead_dungeon_items.map.Value();
}
if ((dungeonId = DUNGEON_GREAT_BAY)) {
hasBossKey = saveData.inventory.great_bay_dungeon_items.map.Value();
if ((dungeonId == DUNGEON_GREAT_BAY)) {
hasMap = saveData.inventory.great_bay_dungeon_items.map.Value();
}
if ((dungeonId = DUNGEON_STONE_TOWER)) {
hasBossKey = saveData.inventory.stone_tower_dungeon_items.map.Value();
if ((dungeonId == DUNGEON_STONE_TOWER)) {
hasMap = saveData.inventory.stone_tower_dungeon_items.map.Value();
}

Draw_DrawString(24, yPos, COLOR_WHITE, DungeonNames[dungeonId]);

// Small Keys
if (dungeonId <= DUNGEON_STONE_TOWER) {
u8 keysHave = 0;
if ((dungeonId = DUNGEON_WOODFALL)) {
keysHave = saveData.inventory.woodfall_temple_keys;
if ((dungeonId == DUNGEON_WOODFALL)) {
keysHave = saveData.inventory.woodfall_temple_keys == 255 ? 0 : saveData.inventory.woodfall_temple_keys;
}
if ((dungeonId = DUNGEON_SNOWHEAD)) {
keysHave = saveData.inventory.snowhead_temple_keys;
if ((dungeonId == DUNGEON_SNOWHEAD)) {
keysHave = saveData.inventory.snowhead_temple_keys == 255 ? 0 : saveData.inventory.snowhead_temple_keys;
}
if ((dungeonId = DUNGEON_GREAT_BAY)) {
keysHave = saveData.inventory.great_bay_temple_keys;
if ((dungeonId == DUNGEON_GREAT_BAY)) {
keysHave = saveData.inventory.great_bay_temple_keys == 255 ? 0 : saveData.inventory.great_bay_temple_keys;
}
if ((dungeonId = DUNGEON_STONE_TOWER)) {
keysHave = saveData.inventory.stone_tower_temple_keys;
if ((dungeonId == DUNGEON_STONE_TOWER)) {
keysHave = saveData.inventory.stone_tower_temple_keys == 255 ? 0 : saveData.inventory.stone_tower_temple_keys;
}
Draw_DrawFormattedString(208, yPos, keysHave > 0 ? COLOR_WHITE : COLOR_DARK_GRAY, "%d", keysHave);
Draw_DrawString(214, yPos, COLOR_WHITE, "/");
Expand All @@ -335,8 +335,9 @@ namespace rnd {
Draw_DrawIcon(240, yPos, hasBossKey ? COLOR_ICON_BOSS_KEY : COLOR_DARK_GRAY, ICON_BOSS_KEY);
}

if (dungeonId >= DUNGEON_PIRATE_FORTRESS) {
// Map and Compassz
// Map and Compasses
if (dungeonId <= DUNGEON_STONE_TOWER) {

Draw_DrawIcon(260, yPos, hasMap ? COLOR_ICON_MAP : COLOR_DARK_GRAY, ICON_MAP);
Draw_DrawIcon(280, yPos, hasCompass ? COLOR_ICON_COMPASS : COLOR_DARK_GRAY, ICON_COMPASS);

Expand Down
1 change: 1 addition & 0 deletions code/source/rnd/item_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ namespace rnd {
u16 resolvedGetItemId = ItemTable_ResolveUpgrades(override.value.getItemId);

ItemRow* itemRow = ItemTable_GetItemRow(resolvedGetItemId);
// XXX: Maybe create function for progressive items so that the item drawn is correct?
u8 looksLikeItemId = override.value.looksLikeItemId;

if (override.value.getItemId == 0x12) { // Ice trap
Expand Down
8 changes: 4 additions & 4 deletions code/source/rnd/item_upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace rnd {
}

GetItemID ItemUpgrade_BombBag(game::SaveData* saveCtx, GetItemID GetItemId) {
switch (saveCtx->inventory.inventory_count_register.bomb_bag_upgrade) {
switch (saveCtx->inventory.inventory_count_register.bomb_bag_upgrade.Value()) {
case game::BombBag::NoBag:
return GetItemID::GI_BOMB_BAG_20; // Bomb Bag
case game::BombBag::BombBag20:
Expand All @@ -21,7 +21,7 @@ namespace rnd {
}

GetItemID ItemUpgrade_Quiver(game::SaveData* saveCtx, GetItemID GetItemId) {
switch (saveCtx->inventory.inventory_count_register.quiver_upgrade) {
switch (saveCtx->inventory.inventory_count_register.quiver_upgrade.Value()) {
case game::Quiver::NoQuiver:
return GetItemID::GI_HEROS_BOW; // Bow
case game::Quiver::Quiver30:
Expand All @@ -32,7 +32,7 @@ namespace rnd {
}

GetItemID ItemUpgrade_Wallet(game::SaveData* saveCtx, GetItemID GetItemId) {
switch (saveCtx->inventory.inventory_count_register.wallet_upgrade) {
switch (saveCtx->inventory.inventory_count_register.wallet_upgrade.Value()) {
case 0:
return GetItemID::GI_ADULT_WALLET; // Adult's Wallet
case 1:
Expand Down Expand Up @@ -79,7 +79,7 @@ namespace rnd {
}

GetItemID ItemUpgrade_BombsToRupee(game::SaveData* saveCtx, GetItemID getItemId) {
return (saveCtx->inventory.inventory_count_register.bomb_bag_upgrade == game::BombBag::NoBag) ?
return (saveCtx->inventory.inventory_count_register.bomb_bag_upgrade.Value() == game::BombBag::NoBag) ?
GetItemID::GI_RUPEE_BLUE : // Blue Rupee
getItemId;
}
Expand Down

0 comments on commit 6f7449b

Please sign in to comment.