[4.5.9] solution for Sprite HUD disappearing when value is 0

SciNEStist

Well-known member
If you are using the sprite hud, you might notice that when the user variable your hud is tracking gets down to zero, the whole hud dissappears instead of showing all empty containers.

For some people this is fine, but for others, you will want it to still show the empty parts.

Dale_Coop shared a fix on the discord, and here it is:

Replace the contents your drawspritehud.asm with this:

Code:
MACRO DrawSpriteHud arg0, arg1, arg2, arg3, arg4, arg5, arg6
    ; arg0 = starting position in pixels, x
    ; arg1 = starting position in pixels, y
    ; arg2 = sprite to draw, CONTAINER
    ; arg3 = MAX
    ; arg4 = sprite to draw, FILLED
    ; arg5 = variable.
    ; arg6 = attribute
 
    tya
    PHA
    TXA
    PHA
 
    ;LDA arg5
    ;BEQ doneWithSpriteDrawElement ;; if the variable was zero, don't draw anything.
 
    LDA arg4
    STA temp ;; full
    LDA arg0
    STA temp2
 
    LDA arg5
    BNE +skipEmpties
        LDA arg2
        STA temp ;; empty
    +skipEmpties:
 
    LDX #$00
    doDrawSpriteHudElementFullLoop:
        LDY spriteRamPointer
        LDA arg1
        STA SpriteRam,y
        INY
        LDA temp
        STA SpriteRam,y
        INY
        LDA arg6
        STA SpriteRam,y
        INY
        LDA temp2
        STA SpriteRam,y
        INY
 
        LDA spriteRamPointer
        CLC
        ADC #$04
        STA spriteRamPointer
        LDA temp2
        CLC
        ADC #$08
        STA temp2
     
        INX
        CPX arg3 ;; is it to the max?
        BEQ doneWithSpriteDrawElement
        CPX arg5 ;; has it reached the fill point?
        BEQ changeToContainerSprite
            JMP doDrawSpriteHudElementFullLoop
            changeToContainerSprite:
                    ;; not done with sprite draw element, but now need to change to container
                    LDA arg2
                    STA temp
                    JMP doDrawSpriteHudElementFullLoop
            doneWithSpriteDrawElement:
     
     
     
     
    PLA
    TAX
    PLA
    TAY
    ENDM

This comments out that part that cancels drawing when arg5, AKA your user value (MyAmmo, MyLives, etc) is zero.

but that would only show a full bar when its supposed to show all empties, so the next part is further down at line 22, which changes them all to empty container sprites.

If your empty container sprites are just blank anyways, this will not effect anything. But if you like to show players they are out of something, this is a useful fix.
 
Top Bottom