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

View File

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

View File

@@ -348,11 +348,11 @@ AddReceivedItemExpandedGetItem:
AND.b #$0F : TAX AND.b #$0F : TAX
LDA.l DungeonKeys, X : INC : STA.l DungeonKeys, X ; Increment Key Count LDA.l DungeonKeys, X : INC : STA.l DungeonKeys, X ; Increment Key Count
CPX.b #$00 : BNE ++ CPX.b #$00 : BNE ++
STA.l HyruleCastleKeys ; copy HC to sewers STA.l HyruleCastleKeys ; copy HC to sewers
++ : CPX.b #$01 : BNE ++ ++ : CPX.b #$01 : BNE ++
STA.l SewerKeys ; copy sewers to HC STA.l SewerKeys ; copy sewers to HC
++ ++
LDA.l GenericKeys : BEQ + LDA.l GenericKeys : BEQ +
.generic .generic

View File

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

View File

@@ -115,21 +115,24 @@ CountChestKeyLong: ; called from ItemDowngradeFix in itemdowngrade.asm
RTL RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
CountChestKey: ; called by neighbor functions CountChestKey: ; called by neighbor functions
PHA : PHX PHA : PHX
CPY.b #$24 : BEQ + ; small key for this dungeon - use DungeonID CPY.b #$24 : BEQ + ; small key for this dungeon - use DungeonID
CPY.b #$A0 : !BLT .end ; Ignore most items CPY.b #$A0 : !BLT .end ; Ignore most items
CPY.b #$AE : !BGE .end ; Ignore reserved key and generic key 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 TAX : BRA .count ; use Key id instead of DungeonID (Keysanity)
INC +
++ TAX : BRA .count ; use Key id instead of DungeonID (Keysanity) LDA.w DungeonID : LSR : TAX
+ LDA.w DungeonID : LSR .count
BNE + LDA.l DungeonCollectedKeys, X : INC : STA.l DungeonCollectedKeys, X
INC ; combines HC and Sewer counts
+ TAX CPX.b #$00 : BNE +
.count STA.l HCCollectedKeys ; copy HC to sewers
LDA.l DungeonCollectedKeys, X : INC : STA.l DungeonCollectedKeys, X +
.end CPX.b #$01 : BNE +
PLX : PLA STA.l SewerCollectedKeys ; copy sewers to HC
+
.end
PLX : PLA
RTS RTS
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
CountBonkItem: ; called from GetBonkItem in bookofmudora.asm CountBonkItem: ; called from GetBonkItem in bookofmudora.asm