From 29176fa1946150784705f34d5b7641f81eda1dd0 Mon Sep 17 00:00:00 2001 From: cassidoxa Date: Wed, 30 Aug 2023 20:47:06 -0400 Subject: [PATCH] Absorb torch keys if they belong to the dungeon they're in. --- bookofmudora.asm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bookofmudora.asm b/bookofmudora.asm index 21f79a3..9dd0c4f 100644 --- a/bookofmudora.asm +++ b/bookofmudora.asm @@ -60,7 +60,7 @@ RTL ;-------------------------------------------------------------------------------- GiveBonkItem: JSR LoadBonkItem - CMP.b #$24 : BNE .notKey + JSR.w AbsorbKeyCheck : BCC .notKey .key PHY : LDY.b #$24 : JSL.l AddInventory : PLY ; do inventory processing for a small key LDA.l CurrentSmallKeys : INC A : STA.l CurrentSmallKeys @@ -84,3 +84,19 @@ LoadBonkItem: LDA.b #$24 ; default to small key ++ RTS +;-------------------------------------------------------------------------------- +AbsorbKeyCheck: + PHA + CMP.b #$24 : BEQ .key + CMP.b #$A0 : BCC .not_key + CMP.b #$B0 : BCS .not_key + AND.b #$0F : ASL + CMP.w DungeonID : BNE .not_key + .key + PLA + SEC + RTS + .not_key + PLA + CLC +RTS