From 233afa1e383d8789e602f74b482fe804fa1ac230 Mon Sep 17 00:00:00 2001 From: "randall.rupper" Date: Fri, 18 Sep 2020 11:06:02 -0600 Subject: [PATCH] Chest Key counters --- bookofmudora.asm | 2 ++ events.asm | 5 +++++ itemdowngrade.asm | 14 ++++++++++---- stats.asm | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/bookofmudora.asm b/bookofmudora.asm index 9728f1b..84b9610 100644 --- a/bookofmudora.asm +++ b/bookofmudora.asm @@ -61,9 +61,11 @@ GiveBonkItem: PHY : LDY.b #$24 : JSL.l AddInventory : PLY ; do inventory processing for a small key LDA $7EF36F : INC A : STA $7EF36F LDA.b #$2F : JSL.l Sound_SetSfx3PanLong + JSL CountBonkItem RTL .notKey PHY : TAY : JSL.l Link_ReceiveItem : PLY + JSL CountBonkItem RTL ;-------------------------------------------------------------------------------- LoadBonkItem: diff --git a/events.asm b/events.asm index 4c3c5d8..dfda530 100644 --- a/events.asm +++ b/events.asm @@ -131,6 +131,11 @@ OnNewFile: DEX : DEX BPL - + LDX #$000E : - + LDA $7EF37C, X : STA $7EF4E0, X + DEX : DEX + BPL - + SEP #$20 ; set 8-bit accumulator ;LDA #$FF : STA !RNG_ITEM_LOCK_IN ; reset rng item lock-in LDA.l PreopenCurtains : BEQ + diff --git a/itemdowngrade.asm b/itemdowngrade.asm index 86a8cba..a6f45f4 100644 --- a/itemdowngrade.asm +++ b/itemdowngrade.asm @@ -2,6 +2,12 @@ ; Item Downgrade Fix ;-------------------------------------------------------------------------------- ItemDowngradeFix: + JSR ItemDowngradeFixMain + JSL CountChestKeyLong +RTL + + +ItemDowngradeFixMain: JSL.l AddInventory BMI .dontWrite ; thing we wrote over part 1 @@ -27,7 +33,7 @@ ItemDowngradeFix: .done STA [$00] ; thing we wrote over part 2 .dontWrite -RTL +RTS .isPowerGloves .isBlueShield .isRedShield @@ -36,7 +42,7 @@ RTL .isBowAndArrows CMP [$00] : !BGE .done ; finished if we're upgrading LDA [$00] ; reload old value -RTL +RTS .isSilverArrowBow .isRedBoomerang .isMagicPowder @@ -47,10 +53,10 @@ RTL LDA [$00] : BNE + ; don't upgrade if we already have the toggle for it PLA STA [$00] - RTL + RTS + PLA -RTL +RTS .isFightersSword .isMasterSword .isTemperedSword diff --git a/stats.asm b/stats.asm index c453821..832c51f 100644 --- a/stats.asm +++ b/stats.asm @@ -257,6 +257,40 @@ DecrementSmallKeys: JSL.l UpdateKeys RTL ;-------------------------------------------------------------------------------- +CountChestKeyLong: ; called from ItemDowngradeFix in itemdowngrade.asm + JSR CountChestKey +RTL +;-------------------------------------------------------------------------------- +CountChestKey: ; called by neighbor functions + PHA : PHX + CPY #$24 : BEQ + ; small key for this dungeon - use $040C + CPY #$A0 : !BLT .end ; Ignore most items + CPY #$AE : !BGE .end ; Ignore reserved key and generic key + TYA : AND.B #$0F : BNE ++ ; If this is a sewers key, instead count it as an HC key + INC + ++ TAX : BRA .count ; use Key id instead of $040C (Keysanity) + + LDA $040C : LSR : TAX + .count + LDA $7EF4E0, X : INC : STA $7EF4E0, X + .end + PLX : PLA +RTS +;-------------------------------------------------------------------------------- +CountBonkItem: ; called from GetBonkItem in bookofmudora.asm + LDA $A0 ; check room ID - only bonk keys in 2 rooms so we're just checking the lower byte + CMP #115 : BNE + ; Desert Bonk Key + LDA.L BonkKey_Desert : BRA ++ + + : CMP #140 : BNE + ; GTower Bonk Key + LDA.L BonkKey_GTower : BRA ++ + + LDA.B #$24 ; default to small key + ++ + CMP #$24 : BNE + + PHY + TAY : JSR CountChestKey + PLY + + +RTL +;-------------------------------------------------------------------------------- IncrementAgahnim2Sword: PHA LDA !LOCK_STATS : BNE +