baardbi
Well-known member

Here's a modified DrawSpriteHud macro that draws the health bar (or whatever) vertically. This can be very useful to reduce the number of sprites on a scan line.
The Y starting position is at the bottom of the health bar, so the Y coordinate will have to be much further down than usual. In the example above I use the following values:
X: 16
Y: 72
Code:
DrawSpriteHud #16, #72, #125, myMaxHealth, #126, myHealth, #%00000001 ;;;; this draws health
Here is the macro. You can replace the default macro with this:
Code:
MACRO DrawSpriteHud arg1, arg0, 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
LDX #$00
doDrawSpriteHudElementFullLoop:
LDY spriteRamPointer
; LDA arg1
LDA temp2
STA SpriteRam,y
INY
LDA temp
STA SpriteRam,y
INY
LDA arg6
STA SpriteRam,y
INY
; LDA temp2
LDA arg1
STA SpriteRam,y
INY
LDA spriteRamPointer
CLC
ADC #$04
STA spriteRamPointer
LDA temp2
; CLC
; ADC #$08
SEC
SBC #$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
Last edited: