draw bombs and arrow counts only when equipped

This commit is contained in:
scawful
2023-01-09 17:19:41 -06:00
parent 7de0540de5
commit 8f2f7d3199

View File

@@ -80,7 +80,7 @@ HUD_Update:
; filling in the full and partially filled hearts (actual health)
JSR HUD_UpdateHearts
.ignoreHealth ; *$6FC09 ALTERNATE ENTRY POINT ; reentry hook
.ignoreHealth ; *$6FC09 ALTERNATE ENTRY POINT ; reentry hook
REP #$30
@@ -119,11 +119,14 @@ HUD_Update:
; The tile index for the third rupee digit
LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC7A0
; Check if the user has bombs equipped
LDX $0202
LDA $7EF33F, X : AND.w #$00FF
CPX.w #$0004 : BNE .not_bombs
; Number of bombs Link has.
LDA $7EF343 : AND.w #$00FF
JSR HexToDecimal
REP #$30
; The tile index for the first bomb digit
@@ -132,34 +135,43 @@ HUD_Update:
; The tile index for the second bomb digit
LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC7B2
; ; Number of Arrows Link has.
; LDA $7EF377 : AND.w #$00FF
.not_bombs
; Check if the user has arrows equipped
LDX $0202
LDA $7EF33F, X : AND.w #$00FF
CPX.w #$0001 : BNE .not_arrows
; ; converts hex to up to 3 decimal digits
; JSR HexToDecimal
; Number of Arrows Link has.
LDA $7EF377 : AND.w #$00FF
; REP #$30
; converts hex to up to 3 decimal digits
JSR HexToDecimal
REP #$30
; ; The tile index for the first arrow digit
; LDA $04 : AND.w #$00FF : ORA.w #$2400 : STA $7EC75E
; The tile index for the first arrow digit
LDA $04 : AND.w #$00FF : ORA.w #$2400 : STA $7EC7B0
; ; The tile index for the second arrow digit
; LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC760
; The tile index for the second arrow digit
LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC7B2
; LDA.w #$007F : STA $05
; ; Load number of Keys Link has
; LDA $7EF36F : AND.w #$00FF : CMP.w #$00FF : BEQ .noKeys
; JSR HexToDecimal
; .noKeys
; REP #$30
; ; The key digit, which is optionally drawn.
; ; Also check to see if the key spot is blank
; LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC764
; CMP.w #$247F : BNE .dontBlankKeyIcon
; ; If the key digit is blank, also blank out the key icon.
; STA $7EC724
; .dontBlankKeyIcon
; SEP #$30
.not_arrows
LDA.w #$007F : STA $05
; Load number of Keys Link has
LDA $7EF36F : AND.w #$00FF : CMP.w #$00FF : BEQ .noKeys
JSR HexToDecimal
.noKeys
REP #$30
; The key digit, which is optionally drawn.
; Also check to see if the key spot is blank
LDA $05 : AND.w #$00FF : ORA.w #$2400 : STA $7EC764
CMP.w #$247F : BNE .dontBlankKeyIcon
; If the key digit is blank, also blank out the key icon.
STA $7EC724
.dontBlankKeyIcon
SEP #$30
RTL
}
@@ -521,18 +533,15 @@ HudItems:
HUD_UpdateItemBox:
{
SEP #$30
; Dost thou haveth the the bow?
LDA $7EF340 : BEQ .havethNoBow
LDX.b #$04
; check how many arrows the player has
LDA $7EF377 : BNE .drawBowItemIcon
LDX.b #$03
BRA .drawBowItemIcon
.drawBowItemIcon
; values of X correspond to how the icon will end up drawn:
; 0x01 - normal bow with no arrows
; 0x02 - normal bow with arrows
@@ -541,31 +550,20 @@ HUD_UpdateItemBox:
TXA : STA $7EF340
.havethNoBow
REP #$30
LDX $0202 : BEQ .noEquippedItem
LDA Menu_ItemIndex, X : AND.w #$00FF
LDA $7EF33F, X : AND.w #$00FF
CPX.w #$0004 : BNE .bombsNotEquipped
LDA.w #$0001
.bombsNotEquipped
CPX.w #$0010 : BNE .bottleNotEquipped
TXY : TAX : LDA $7EF35B, X : AND.w #$00FF : TYX
.bottleNotEquipped
STA $02
TXA : DEC A : ASL A : TAX
LDA $FA93, X : STA $04
LDA $02 : ASL #3 : TAY
; These addresses form the item box graphics.
@@ -585,59 +583,39 @@ HUD_UpdateHearts:
{
; Draws hearts in a painfully slow loop
; I used DMA to speed it up in my custom code
; (but still needs fixing to work on 1/1/1 hardware)
LDX.w #$0000
.nextHeart
LDA $00 : CMP.w #$0008 : BCC .lessThanOneHeart
; Notice no SEC was needed since carry is assumedly set.
SBC.w #$0008 : STA $00
LDY.w #$0004
JSR .drawHeart
INX #2
BRA .nextHeart
.lessThanOneHeart
CMP.w #$0005 : BCC .halfHeartOrLess
LDY.w #$0004
BRA .drawHeart
.halfHeartOrLess
CMP.w #$0001 : BCC .emptyHeart
LDY.w #$0002
BRA .drawHeart
.emptyHeart
RTS
.drawHeart
; Compare number of hearts so far on current line to 10
CPX.w #$0014 : BCC .noLineChange
; if not, we have to move down one tile in the tilemap
LDX.w #$0000
LDA $07 : CLC : ADC #$0040 : STA $07
.noLineChange
LDA [$0A], Y : TXY : STA [$07], Y
RTS
}
@@ -762,7 +740,6 @@ FloorIndicatorNumberLow:
dw $E50C, $A50E, $007F
}
; *$57D0C-$57DA7 JUMP LOCATION (LONG)
org $0AFD0C
FloorIndicator: