From 7dc71cf1ac8b3eb19be601625364444890860a33 Mon Sep 17 00:00:00 2001 From: cassidoxa Date: Thu, 7 Sep 2023 11:53:24 -0400 Subject: [PATCH 1/8] Fix some stats counting --- inventory.asm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inventory.asm b/inventory.asm index cf660f8..c07eb52 100644 --- a/inventory.asm +++ b/inventory.asm @@ -159,15 +159,15 @@ AddInventory: JSR.w IncrementByOne JSR.w StampItem JSR.w IncrementYAItems - REP #$20 + REP #$30 LDA.l TotalItemCounter : INC : TAY - LDA.l BootsEquipment : BNE + + LDA.l BootsEquipment : AND.w #$00FF : BNE + TYA : STA.l PreBootsLocations + - LDA.l MirrorEquipment : BNE + + LDA.l MirrorEquipment : AND.w #$00FF : BNE + TYA : STA.l PreMirrorLocations + - LDA.l FluteEquipment : BNE + + LDA.l FluteEquipment : AND.w #$00FF : BNE + TYA : STA.l PreFluteLocations + TYA From 790f3f0ba3ff80048d36ef96b0b787152ee42808 Mon Sep 17 00:00:00 2001 From: cassidoxa Date: Thu, 7 Sep 2023 16:29:45 -0400 Subject: [PATCH 2/8] Fix HUD item icon not refreshing after last bomb spent Rename UpdateHUD to UpdateHUDFlag, replace with UpdateHUD vanilla JSR label --- entrances.asm | 2 +- events.asm | 6 +++--- hooks.asm | 12 ++++++++++-- inventory.asm | 4 ++-- newhud.asm | 10 +++++----- newitems.asm | 2 +- pendantcrystalhud.asm | 4 ++-- ram.asm | 2 +- retro.asm | 2 +- stats.asm | 4 ++-- timer.asm | 2 +- vanillalabels.asm | 4 +++- 12 files changed, 32 insertions(+), 22 deletions(-) diff --git a/entrances.asm b/entrances.asm index 59c729a..6431555 100644 --- a/entrances.asm +++ b/entrances.asm @@ -155,7 +155,7 @@ JML.l AllowStartFromExitReturn STZ.b SubSubModule STZ.w DeathReloadFlag STZ.w RespawnFlag - INC.w UpdateHUD + INC.w UpdateHUDFlag JSL Equipment_SearchForEquippedItemLong JSL HUD_RebuildLong2 diff --git a/events.asm b/events.asm index c23e480..8741f09 100644 --- a/events.asm +++ b/events.asm @@ -22,7 +22,7 @@ JML.l ReturnFromOnDrawHud OnDungeonEntrance: STA.l PegColor ; thing we wrote over JSL MaybeFlagDungeonTotalsEntrance - INC.w UpdateHUD + INC.w UpdateHUDFlag RTL ;-------------------------------------------------------------------------------- OnDungeonBossExit: @@ -46,7 +46,7 @@ OnDungeonExit: STA.w DungeonID : STZ.w Map16ChangeIndex ; thing we wrote over PHA : PHP - INC.w UpdateHUD + INC.w UpdateHUDFlag JSL.l HUD_RebuildLong JSL.l FloodGateResetInner JSL.l SetSilverBowMode @@ -226,7 +226,7 @@ OnOWTransition: PHP SEP #$20 ; set 8-bit accumulator LDA.b #$FF : STA.l RNGLockIn ; clear lock-in - INC.w UpdateHUD + INC.w UpdateHUDFlag PLP RTL ;-------------------------------------------------------------------------------- diff --git a/hooks.asm b/hooks.asm index ff23d62..61f712f 100644 --- a/hooks.asm +++ b/hooks.asm @@ -1406,8 +1406,7 @@ org $8DFB29 : BRA UpdateHUDBuffer_update_item_check_arrows ;-------------------------------------------------------------------------------- org $8DF1AB : JSR.w RebuildHUD_update org $8DDFC8 : JSR.w RebuildHUD_update -org $8DDB88 ; Don't rebuild HUD twice on icon refresh -NOP #3 ; Not sure why this is here +org $8DDB85 : JSR.w RebuildHUD_IconExpanded ;-------------------------------------------------------------------------------- org $87A205 : JSL.l RebuildHUD_update_long org $8AEF62 : JSL.l RebuildHUD_update_long @@ -1422,6 +1421,15 @@ warnpc $8E8000 ;-------------------------------------------------------------------------------- org $8DEDE8 JSL.l DrawHeartPiecesMenu : BRA DrawEquipment_in_a_dungeon +;-------------------------------------------------------------------------------- +org $8DAFDD +RebuildHUD_IconExpanded: +JSR.w UpdateHUD +JSR.w RebuildHUD +INC.w UpdateHUDFlag +RTS + +warnpc $8DB080 ;================================================================================ ; 300 Rupee NPC diff --git a/inventory.asm b/inventory.asm index c07eb52..d32baef 100644 --- a/inventory.asm +++ b/inventory.asm @@ -365,7 +365,7 @@ Link_ReceiveItem_HUDRefresh: + JSL.l HUD_RefreshIconLong ; thing we wrote over - INC.w UpdateHUD + INC.w UpdateHUDFlag JSL.l PostItemGet RTL ;-------------------------------------------------------------------------------- @@ -380,7 +380,7 @@ HandleBombAbsorbtion: LDA.b #$04 : STA.w ItemCursor ; set selected item to bombs LDA.b #$01 : STA.w CurrentYItem ; set selected item to bombs JSL.l HUD_RebuildLong - INC.w UpdateHUD + INC.w UpdateHUDFlag + RTL ;-------------------------------------------------------------------------------- diff --git a/newhud.asm b/newhud.asm index 680d400..16e94b1 100644 --- a/newhud.asm +++ b/newhud.asm @@ -65,7 +65,7 @@ NewHUD_DrawArrows: ;================================================================================ NewHUD_DrawGoal: REP #$20 - LDA.w UpdateHUD : BEQ .no_goal + LDA.w UpdateHUDFlag : BEQ .no_goal LDA.l GoalItemRequirement : BEQ .no_goal LDA.l GoalItemIcon : STA.w HUDGoalIndicator @@ -122,7 +122,7 @@ NewHUD_DrawKeys: ;================================================================================ NewHUD_DrawDungeonCounters: - LDA.w UpdateHUD : BEQ NewHUD_DrawPrizeIcon + LDA.w UpdateHUDFlag : BEQ NewHUD_DrawPrizeIcon LDA.l CompassMode : ORA.l MapHUDMode : BIT.b #$03 : BEQ NewHUD_DrawPrizeIcon LDX.b IndoorsFlag : BNE + JMP.w NewHUD_DrawMagicMeter @@ -147,7 +147,7 @@ NewHUD_DrawPrizeIcon: LDA.b GameMode CMP.b #$12 : BEQ .no_prize CMP.b #$0E : BEQ + - LDA.w UpdateHUD : BEQ NewHUD_DrawItemCounter + LDA.w UpdateHUDFlag : BEQ NewHUD_DrawItemCounter + LDA.w DungeonID CMP.b #$1A : BCS .no_prize @@ -197,7 +197,7 @@ NewHUD_DrawPrizeIcon: ;================================================================================ NewHUD_DrawItemCounter: REP #$20 - LDA.w UpdateHUD : BEQ NewHUD_DrawMagicMeter + LDA.w UpdateHUDFlag : BEQ NewHUD_DrawMagicMeter LDA.l ItemCounterHUD : AND.w #$00FF : BEQ NewHUD_DrawMagicMeter LDA.w #!SlashTile : STA.w HUDGoalIndicator+$08 LDA.l TotalItemCount : CMP.w #1000 : BCS .item_four_digits @@ -263,7 +263,7 @@ NewHUD_DrawMagicMeter: ;================================================================================ NewHUD_DoneDrawing: - STZ.w UpdateHUD + STZ.w UpdateHUDFlag PLB RTL diff --git a/newitems.asm b/newitems.asm index 5bd3b6b..2d2f824 100644 --- a/newitems.asm +++ b/newitems.asm @@ -429,7 +429,7 @@ ItemBehavior: .single_arrow LDA.l ArrowMode : BEQ + LDA.l CurrentArrows : INC : STA.l CurrentArrows ; Should be sole write to this address - INC.w UpdateHUD ; in retro/rupee bow mode. + INC.w UpdateHUDFlag ; in retro/rupee bow mode. + RTS diff --git a/pendantcrystalhud.asm b/pendantcrystalhud.asm index 30ed118..56959b1 100644 --- a/pendantcrystalhud.asm +++ b/pendantcrystalhud.asm @@ -17,7 +17,7 @@ RTL ;================================================================================ HUDRebuildIndoorHole: PHA - INC.w UpdateHUD + INC.w UpdateHUDFlag LDA.l GenericKeys : BEQ .normal .generic PLA @@ -30,7 +30,7 @@ RTL RTL ;================================================================================ HUDRebuildIndoor: - INC.w UpdateHUD + INC.w UpdateHUDFlag LDA.l GenericKeys : BEQ .normal .generic LDA.b #$00 : STA.l RoomDarkness diff --git a/ram.asm b/ram.asm index e68c886..1968efc 100644 --- a/ram.asm +++ b/ram.asm @@ -388,7 +388,7 @@ DelayTimer = $7E1CE9 ; ; TextID = $7E1CF0 ; Message ID and page. Word length. ; -UpdateHUD = $7E1E03 ; Flag used to mark HUD updates and avoid heavy code segments. +UpdateHUDFlag = $7E1E03 ; Flag used to mark HUD updates and avoid heavy code segments. ; ToastBuffer = $7E1E0E ; Multiworld buffer. Word length. ; diff --git a/retro.asm b/retro.asm index 5752b98..c2c178c 100644 --- a/retro.asm +++ b/retro.asm @@ -11,7 +11,7 @@ LoadBombCount16: .infinite RTL StoreBombCount: - INC.w UpdateHUD + INC.w UpdateHUDFlag PHA : LDA.l InfiniteBombs : BEQ .finite .infinite PLA : LDA.b #$01 : RTL diff --git a/stats.asm b/stats.asm index dd56e4f..a45fdf1 100644 --- a/stats.asm +++ b/stats.asm @@ -83,7 +83,7 @@ IncrementSmallKeys: JSL.l UpdateKeys PHY : LDY.b #24 : JSL.l AddInventory : PLY JSL.l HUD_RebuildLong - INC.w UpdateHUD + INC.w UpdateHUDFlag PLX RTL ;-------------------------------------------------------------------------------- @@ -106,7 +106,7 @@ IncrementSmallKeysNoPrimary: ++ PLP + - INC.w UpdateHUD + INC.w UpdateHUDFlag JSL.l HUD_RebuildLong PLX RTL diff --git a/timer.asm b/timer.asm index 7fef763..e37d3b8 100644 --- a/timer.asm +++ b/timer.asm @@ -179,7 +179,7 @@ CheckOHKO: RTS .change STA.l OHKOCached - INC.w UpdateHUD + INC.w UpdateHUDFlag REP #$20 SEC RTS diff --git a/vanillalabels.asm b/vanillalabels.asm index 295e813..4e53dcf 100644 --- a/vanillalabels.asm +++ b/vanillalabels.asm @@ -108,7 +108,6 @@ Equipment_SearchForEquippedItemLong = $8DE395 HUD_RebuildLong = $8DFA78 HUD_RebuildIndoor_Palace = $8DFA88 HUD_RebuildLong2 = $8DFA88 -RebuildHUD_update = $8DFAA5 Messaging_Text = $8EEE10 AfterDeathCounterOutput = $8E8FD Overworld_TileAttr = $8FFD94 @@ -153,12 +152,15 @@ Ancilla29_MilestoneItemReceipt_skip_crystal_sfx = $88CAE5 Ancilla29_MilestoneItemReceipt_no_sparkle = $88CB2E Ancilla_SetOAM_XY = $88F6F3 Ancilla_AddAncilla = $899CCE +UpdateHUD = $8DDFA9 DrawProgressIcons = $8DE9C8 ItemMenu_DrawEquippedYItem = $8DEB3A ItemMenu_DrawEquippedYItem_exit = $8DECE6 ItemMenu_DrawEquipment_dungeonitems = $8DEDCC DrawEquipment = $8DED29 DrawEquipment_in_a_dungeon = $8DEDFE +RebuildHUD = $8DFA90 +RebuildHUD_update = $8DFAA5 UpdateHUDBuffer_update_item_check_arrows = $8DFB41 RenderText_DecompressAndDrawSingle = $8EF4FB DecompressFontGFX = $8EF572 From 0f72e6fcec8caab73e71ba1d35744b4609daee14 Mon Sep 17 00:00:00 2001 From: cassidoxa Date: Fri, 8 Sep 2023 00:21:24 -0400 Subject: [PATCH 3/8] Better solution --- hooks.asm | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hooks.asm b/hooks.asm index 61f712f..c08a240 100644 --- a/hooks.asm +++ b/hooks.asm @@ -1406,7 +1406,8 @@ org $8DFB29 : BRA UpdateHUDBuffer_update_item_check_arrows ;-------------------------------------------------------------------------------- org $8DF1AB : JSR.w RebuildHUD_update org $8DDFC8 : JSR.w RebuildHUD_update -org $8DDB85 : JSR.w RebuildHUD_IconExpanded +org $8DDB85 +JSR.w RebuildHUD : BRA + : NOP : + ;-------------------------------------------------------------------------------- org $87A205 : JSL.l RebuildHUD_update_long org $8AEF62 : JSL.l RebuildHUD_update_long @@ -1422,14 +1423,6 @@ warnpc $8E8000 org $8DEDE8 JSL.l DrawHeartPiecesMenu : BRA DrawEquipment_in_a_dungeon ;-------------------------------------------------------------------------------- -org $8DAFDD -RebuildHUD_IconExpanded: -JSR.w UpdateHUD -JSR.w RebuildHUD -INC.w UpdateHUDFlag -RTS - -warnpc $8DB080 ;================================================================================ ; 300 Rupee NPC From 71e86f7c1aebeade85550b7456782f22d9cc5bc5 Mon Sep 17 00:00:00 2001 From: cassidoxa Date: Fri, 8 Sep 2023 00:35:06 -0400 Subject: [PATCH 4/8] Set our hud update flag on quickswap --- quickswap.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickswap.asm b/quickswap.asm index f8080d9..5e06faf 100644 --- a/quickswap.asm +++ b/quickswap.asm @@ -10,7 +10,7 @@ QuickSwap: LDA.l QuickSwapFlag : BEQ .done LDA.w ItemCursor : BEQ .done ; Skip everything if we don't have any items - + INC.w UpdateHUDFlag LDY.b #$14 PHX XBA ; restore the stashed value From 57e537f12d82fa91aa260f19f36b0c4e29b75d84 Mon Sep 17 00:00:00 2001 From: cassidoxa Date: Fri, 8 Sep 2023 08:56:23 -0400 Subject: [PATCH 5/8] Fix HUD rebuild when releasing fairy --- hooks.asm | 12 +++++++++--- vanillalabels.asm | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hooks.asm b/hooks.asm index c08a240..0a4ad48 100644 --- a/hooks.asm +++ b/hooks.asm @@ -1406,18 +1406,24 @@ org $8DFB29 : BRA UpdateHUDBuffer_update_item_check_arrows ;-------------------------------------------------------------------------------- org $8DF1AB : JSR.w RebuildHUD_update org $8DDFC8 : JSR.w RebuildHUD_update -org $8DDB85 -JSR.w RebuildHUD : BRA + : NOP : + +org $8DDB85 : JSR.w RefreshIcon_UpdateHUD : BRA + : NOP : + ;-------------------------------------------------------------------------------- org $87A205 : JSL.l RebuildHUD_update_long -org $8AEF62 : JSL.l RebuildHUD_update_long org $87A1A4 : JSL.l RebuildHUD_update_long org $87A1CF : JSL.l RebuildHUD_update_long +org $87A21D : JSL.l RebuildHUD_update_long org $87A235 : JSL.l RebuildHUD_update_long +org $8AEF62 : JSL.l RebuildHUD_update_long ;-------------------------------------------------------------------------------- org $8DFFE1 RebuildHUD_update_long: JSR.w RebuildHUD_update : RTL + +RefreshIcon_UpdateHUD: +INC.w UpdateHUDFlag +JSR.w RebuildHUD +JSR.w UpdateEquippedItem +RTS warnpc $8E8000 ;-------------------------------------------------------------------------------- org $8DEDE8 diff --git a/vanillalabels.asm b/vanillalabels.asm index 4e53dcf..3b77d99 100644 --- a/vanillalabels.asm +++ b/vanillalabels.asm @@ -153,6 +153,7 @@ Ancilla29_MilestoneItemReceipt_no_sparkle = $88CB2E Ancilla_SetOAM_XY = $88F6F3 Ancilla_AddAncilla = $899CCE UpdateHUD = $8DDFA9 +UpdateEquippedItem = $8DDFAF DrawProgressIcons = $8DE9C8 ItemMenu_DrawEquippedYItem = $8DEB3A ItemMenu_DrawEquippedYItem_exit = $8DECE6 From 8af9c17cfe2230752e055c60a45fd19795232339 Mon Sep 17 00:00:00 2001 From: cassidoxa Date: Fri, 8 Sep 2023 13:57:26 -0400 Subject: [PATCH 6/8] Fix stumpy double item --- npcitems.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/npcitems.asm b/npcitems.asm index 3206fe5..b4a7fa5 100644 --- a/npcitems.asm +++ b/npcitems.asm @@ -51,8 +51,8 @@ ItemCheck_TreeKid: RTL ItemCheck_TreeKid2: - LDA.l NpcFlags : AND.b #$08 : CMP.b #$08 - TDC ; ?? TODO + LDA.l NpcFlags : AND.b #$08 + LSR #2 RTL ItemCheck_TreeKid3: From f6842204d0a84af474b3dbed4c8a049726b3691c Mon Sep 17 00:00:00 2001 From: cassidoxa Date: Fri, 8 Sep 2023 15:30:37 -0400 Subject: [PATCH 7/8] Fix BowTracking docs --- sram.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sram.asm b/sram.asm index 9bc5846..9e86afd 100644 --- a/sram.asm +++ b/sram.asm @@ -177,7 +177,7 @@ InventoryTracking: skip 2 ; - - - - - - o q b r m p n s k f (bitfield) ; p = Magic Powder | n = Mushroom Past | s = Shovel ; k = Inactive Flute | f = Active Flute | o = Any bomb acquired ; q = Quickswap locked -BowTracking: skip 2 ; b s p f - - - - - - - - - - - - (bitfield) +BowTracking: skip 2 ; - - - - - - - - b s p f - - - - (bitfield) ; b = Any Bow | s = Silver Arrows Upgrade | p = Second Progressive Bow ; f = First progressive bow ; The front end writes two distinct progressive bow items. p From 70758bf5c03c237d5ed4913baa4c613dd693a815 Mon Sep 17 00:00:00 2001 From: cassidoxa Date: Fri, 8 Sep 2023 15:43:31 -0400 Subject: [PATCH 8/8] Set silvers bit with silvers restriction --- newitems.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/newitems.asm b/newitems.asm index 2d2f824..a173e04 100644 --- a/newitems.asm +++ b/newitems.asm @@ -276,8 +276,8 @@ ItemBehavior: RTS .silversbow + LDA.l BowTracking : ORA.b #$40 : STA.l BowTracking LDA.l SilverArrowsUseRestriction : BNE + - LDA.l BowTracking : ORA.b #$40 : STA.l BowTracking LDA.b #03 : STA.l BowEquipment ; set bow to silver + LDA.b #$01 : STA.l BowEquipment @@ -338,8 +338,8 @@ ItemBehavior: RTS .silver_bow + LDA.b #$40 : ORA.l BowTracking : STA.l BowTracking LDA.l SilverArrowsUseRestriction : BNE .noequip - LDA.b #$40 : ORA.l BowTracking : STA.l BowTracking LDA.l SilverArrowsAutoEquip : AND.b #$01 : BEQ .noequip LDA.l CurrentArrows : BNE + ; check arrows LDA.b #$03 : BRA ++ ; bow without arrow @@ -414,8 +414,8 @@ ItemBehavior: RTS .silver_arrows + LDA.l BowTracking : ORA.b #$40 : STA.l BowTracking LDA.l SilverArrowsUseRestriction : BNE ++ - LDA.l BowTracking : ORA.b #$40 : STA.l BowTracking LDA.l SilverArrowsAutoEquip : AND.b #$01 : BEQ ++ LDA.l BowEquipment : BEQ ++ : CMP.b #$03 : !BGE + !ADD.b #$02 : STA.l BowEquipment ; switch to silver bow