Compass and map HUD display modes properly skip or draw

Minor key count refactor, count HC and Sewers as both in all cases
This commit is contained in:
cassidoxa
2023-03-12 17:20:54 -04:00
parent c0986d6bbc
commit 7968ddf020
5 changed files with 52 additions and 51 deletions

View File

@@ -13,13 +13,12 @@ RTL
DrawCompassCounts:
PHX
LDA.l CompassMode : BIT.w #$0002 : BNE + ; if CompassMode==2, we don't check for the compass
LDA.l CompassField : AND.w DungeonItemMasks, X ; Load compass values to A, mask with dungeon item masks
LDA.l CompassMode : BEQ .done
BIT.w #$0002 : BNE + ; if CompassMode==2, we don't check for the compass
LDA.l CompassField : AND.l DungeonItemMasks, X ; Load compass values to A, mask with dungeon item masks
BEQ .done ; skip if we don't have compass
+
TXA : LSR : TAX : BNE +
INC ; Count sewer as Hyrule Castle
+
TXA : LSR : TAX
LDA.l CompassTotalsWRAM, X : AND.w #$00FF
SEP #$20
JSR HudHexToDec2Digit
@@ -41,13 +40,12 @@ RTS
DrawMapCounts:
PHX
LDA.l MapHUDMode : BIT.w #$0002 : BNE + ; if MapHUDMode==2, we don't check for map
LDA.l MapField : AND.w DungeonItemMasks, X ; Load map values to A, mask with dungeon item masks
LDA.l MapHUDMode : BEQ .done
BIT.w #$0002 : BNE + ; if MapHUDMode==2, we don't check for map
LDA.l MapField : AND.l DungeonItemMasks, X ; Load map values to A, mask with dungeon item masks
BEQ .done ; skip if we don't have map
+
TXA : LSR : TAX : BNE +
INC ; Count sewer as Hyrule Castle
+
TXA : LSR : TAX
LDA.l MapTotalsWRAM, X : AND.w #$00FF
SEP #$20
JSR HudHexToDec2Digit
@@ -66,7 +64,7 @@ DrawMapCounts:
RTS
DungeonItemMasks: ; these are dungeon correlations to $7EF364 - $7EF369 so it knows where to store compasses, etc
dw $8000, $4000, $2000, $1000, $0800, $0400, $0200, $0100
dw $C000, $C000, $2000, $1000, $0800, $0400, $0200, $0100
dw $0080, $0040, $0020, $0010, $0008, $0004
;--------------------------------------------------------------------------------
InitDungeonCounts:

View File

@@ -379,7 +379,7 @@ AddInventory:
LDX.b #$02
JSR .incrementMail
+ CPY.b #$24 : BNE + ; Small Key
JSR .incrementKey
JSR .incrementVanillaKey
JMP .done
+ CPY.b #$25 : BNE + ; Compass
JSL MaybeFlagCompassTotalPickup
@@ -615,6 +615,10 @@ RTS
JSR .incrementKey
RTL
.incrementVanillaKey
LDA.l SmallKeyCounter : INC : STA.l SmallKeyCounter
JSL.l UpdateKeys
.incrementKey
LDA.l SmallKeyCounter : INC : STA.l SmallKeyCounter
RTS

View File

@@ -188,11 +188,8 @@ UpdateKeys:
PHX : PHP
SEP #$30 ; set 8-bit accumulator & index registers
LDA.w DungeonID : CMP.b TSWQ : !BLT .skip
LSR : TAX ; get dungeon index and store to X
LDA.l CurrentSmallKeys ; load current key count
STA.l DungeonKeys, X ; save to main counts
LDA.l DungeonKeys, X : INC : STA.l DungeonKeys, X
CPX.b #$00 : BNE +
STA.l HyruleCastleKeys ; copy HC to sewers
@@ -200,7 +197,6 @@ UpdateKeys:
STA.l SewerKeys ; copy sewers to HC
+
.skip
JSL.l PostItemGet
PLP : PLX
RTL
;$37C = Sewer Passage

View File

@@ -119,15 +119,18 @@ CountChestKey: ; called by neighbor functions
CPY.b #$24 : BEQ + ; small key for this dungeon - use DungeonID
CPY.b #$A0 : !BLT .end ; Ignore most items
CPY.b #$AE : !BGE .end ; Ignore reserved key and generic key
TYA : AND.B #$0F : BNE ++ ; If this is an HC key, instead count it as a sewers key
INC
++ TAX : BRA .count ; use Key id instead of DungeonID (Keysanity)
+ LDA.w DungeonID : LSR
BNE +
INC ; combines HC and Sewer counts
+ TAX
TAX : BRA .count ; use Key id instead of DungeonID (Keysanity)
+
LDA.w DungeonID : LSR : TAX
.count
LDA.l DungeonCollectedKeys, X : INC : STA.l DungeonCollectedKeys, X
CPX.b #$00 : BNE +
STA.l HCCollectedKeys ; copy HC to sewers
+
CPX.b #$01 : BNE +
STA.l SewerCollectedKeys ; copy sewers to HC
+
.end
PLX : PLA
RTS