From f565fc93be95340b15b23cb62fc723af4e7c97c9 Mon Sep 17 00:00:00 2001 From: aerinon Date: Tue, 25 Aug 2020 12:05:49 -0600 Subject: [PATCH 1/4] Adds Chest Key counters to $7EF4E0-F --- bookofmudora.asm | 2 ++ itemdowngrade.asm | 14 ++++++++++---- stats.asm | 30 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/bookofmudora.asm b/bookofmudora.asm index 2321ca3..3eedcd7 100644 --- a/bookofmudora.asm +++ b/bookofmudora.asm @@ -58,9 +58,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 + JSR CountBonkKey RTL .notKey PHY : TAY : JSL.l Link_ReceiveItem : PLY + JSR CountBonkKey RTL ;-------------------------------------------------------------------------------- LoadBonkItem: diff --git a/itemdowngrade.asm b/itemdowngrade.asm index 86a8cba..2a754a7 100644 --- a/itemdowngrade.asm +++ b/itemdowngrade.asm @@ -2,6 +2,12 @@ ; Item Downgrade Fix ;-------------------------------------------------------------------------------- ItemDowngradeFix: + JSR ItemDowngradeFixMain + JSR CountChestKey +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..73186b8 100644 --- a/stats.asm +++ b/stats.asm @@ -257,6 +257,36 @@ DecrementSmallKeys: JSL.l UpdateKeys RTL ;-------------------------------------------------------------------------------- +CountChestKey: ; called from ItemDowngradeFix in itemdowngrade.asm (also from CountBonkItem below) + 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 + + +RTS +;-------------------------------------------------------------------------------- IncrementAgahnim2Sword: PHA LDA !LOCK_STATS : BNE + From cdd4199cf99a690cf84d1b83bcb5807f805d4a92 Mon Sep 17 00:00:00 2001 From: aerinon Date: Wed, 26 Aug 2020 16:50:19 -0600 Subject: [PATCH 2/4] Fixed jumps and return to be proper for the banks the code is in --- bookofmudora.asm | 4 ++-- itemdowngrade.asm | 3 +-- stats.asm | 8 ++++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bookofmudora.asm b/bookofmudora.asm index 3eedcd7..3030d34 100644 --- a/bookofmudora.asm +++ b/bookofmudora.asm @@ -58,11 +58,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 - JSR CountBonkKey + JSL CountBonkItem RTL .notKey PHY : TAY : JSL.l Link_ReceiveItem : PLY - JSR CountBonkKey + JSL CountBonkItem RTL ;-------------------------------------------------------------------------------- LoadBonkItem: diff --git a/itemdowngrade.asm b/itemdowngrade.asm index 2a754a7..1655a62 100644 --- a/itemdowngrade.asm +++ b/itemdowngrade.asm @@ -3,10 +3,9 @@ ;-------------------------------------------------------------------------------- ItemDowngradeFix: JSR ItemDowngradeFixMain - JSR CountChestKey + JSL CountChestKeyLong RTL - ItemDowngradeFixMain: JSL.l AddInventory BMI .dontWrite ; thing we wrote over part 1 diff --git a/stats.asm b/stats.asm index 73186b8..832c51f 100644 --- a/stats.asm +++ b/stats.asm @@ -257,7 +257,11 @@ DecrementSmallKeys: JSL.l UpdateKeys RTL ;-------------------------------------------------------------------------------- -CountChestKey: ; called from ItemDowngradeFix in itemdowngrade.asm (also from CountBonkItem below) +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 @@ -285,7 +289,7 @@ CountBonkItem: ; called from GetBonkItem in bookofmudora.asm TAY : JSR CountChestKey PLY + -RTS +RTL ;-------------------------------------------------------------------------------- IncrementAgahnim2Sword: PHA From d58fa5d5b73fddb82bf858b191c7c5e143b197fe Mon Sep 17 00:00:00 2001 From: aerinon Date: Fri, 28 Aug 2020 12:15:31 -0600 Subject: [PATCH 3/4] Starting keys accounted for --- events.asm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/events.asm b/events.asm index a85ba7c..82da82e 100644 --- a/events.asm +++ b/events.asm @@ -126,6 +126,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 + From 397da02e3f44577fcdfebfffa44cd0d031026c58 Mon Sep 17 00:00:00 2001 From: aerinon Date: Fri, 28 Aug 2020 12:23:27 -0600 Subject: [PATCH 4/4] Converted file to tabs for consistency --- events.asm | 8 ++++---- itemdowngrade.asm | 4 ++-- stats.asm | 48 +++++++++++++++++++++++------------------------ 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/events.asm b/events.asm index 82da82e..6f72a51 100644 --- a/events.asm +++ b/events.asm @@ -126,10 +126,10 @@ OnNewFile: DEX : DEX BPL - - LDX #$000E : - - LDA $7EF37C, X : STA $7EF4E0, X - 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 diff --git a/itemdowngrade.asm b/itemdowngrade.asm index 1655a62..aab1763 100644 --- a/itemdowngrade.asm +++ b/itemdowngrade.asm @@ -2,8 +2,8 @@ ; Item Downgrade Fix ;-------------------------------------------------------------------------------- ItemDowngradeFix: - JSR ItemDowngradeFixMain - JSL CountChestKeyLong + JSR ItemDowngradeFixMain + JSL CountChestKeyLong RTL ItemDowngradeFixMain: diff --git a/stats.asm b/stats.asm index 832c51f..0afb25c 100644 --- a/stats.asm +++ b/stats.asm @@ -258,37 +258,37 @@ DecrementSmallKeys: RTL ;-------------------------------------------------------------------------------- CountChestKeyLong: ; called from ItemDowngradeFix in itemdowngrade.asm - JSR CountChestKey + 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 + 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 + 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 - + + 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: