Keysanity vanilla small keys do not update pause menu immediately
Opened this issue · 2 comments
In key-sanity, vanilla small keys in chests do not immediately show up on the menu. They only appear after certain types of transitions like leaving the dungeon, or once a key is spent.
This is because small keys in their vanilla dungeons are converted to item 0x24 by code in Location.php. That code is desirable because it avoids the textbox.
However picking up of item 0x24 from a chest has not actually been hooked. The sprite version from pots and enemies is hooked, and the dungeon specific items are, but not the vanilla 0x24.
I'd recommend the following hook (perhaps needs a better name, I just went with the nearby label in the disassembly):
org $09873F ; <- 04873F - ancilla_init.asm : 960 (ADC [$00] : STA [$00] )
JSL.l AddToStock
With an implementation in stats.asm nearby the existing IncrementSmallKey
AddToStock:
ADC [$00] : STA [$00] ; thing we wrote over
PHP : PHA
; if [$00] == $7EF36F (Small key count address)
LDA $00 : CMP #$6F : BNE + : LDA $01 : CMP #$F3 : BNE + : LDA $02 : CMP #$7E : BNE +
JSL.l UpdateKeys
+
PLA : PLP
RTL
I am literally targeting the exact spot where $7EF36F is incremented, just like the existing IncrementSmallKey hook does.
Fixed but with a smaller (5 instructions & 0 hooks) footprint.
Actually, this report was about item #$24 appearing in chests, and the keysanity dungeon item grid in the menu.
When you open a chest containing that vinilla small key item the per-dungeon key count is not updated, so the key does not show up in the keysanity dungeon item grid, until you do one of the following: Leave the dungeon, get a pot/enemy key, spend a key, or die. Those actions cause the dungeon key count to be written back to the dungeon-specific key count location.
I've tested what was pushed last night, and it definitely does not address this.
In Discord you had previously proposed to fix this without a new hook (and with only about 5 instructions, too) by checking for the #$24 item in the PostItemAnimation event, and calling UpdateKeys to update the dungeon-specific key count. That would work just fine.