xWhyohwhyx
New member
Hey, I'm trying to do this on version 4.1.5, but for some reaon the scripts seem to be a little different? Like, I can't find any of the reffered code at all. What's up with that?
MACRO DrawStatusBar arg0, arg1, arg2, arg3, arg4, arg5, arg6
;; arg0 x position of bottom bar segment
;; arg1 y position of bottom bar segment
;; arg2 value bar is displaying
;; arg3 location of empty graphic
;; arg4 attribute data (bits 0 and 1 determine which palette is used)
;; arg5 maxValue
;; arg6 location of top graphic
LDA #$00
STA temp2 ;Number of full sprites
STA temp1 ;if there is a partial sprite and what is it
LDA #$08
STA temp ;Number of empty sprites
STA tempz
LDA arg5
CMP #$FF
BEQ MaxBar
CLC
ADC #$01
ROL
ROL
ROL
ROL
STA tempz
MaxBar:
LDA arg2
BEQ readyToDrawHealthBar
AND #%11111000
CMP #%11111000
BNE checkForHalf
;; Full
LDA #$08
STA temp2
JMP drawHealthBar
checkForHalf:
LDA arg2
AND #%10000000
BEQ checkForQuarter
;;; Half Full
LDA #$04
STA temp2
checkForQuarter:
LDA arg2
AND #%01000000
BEQ checkForEighth
;;; Quarter full
INC temp2
INC temp2
checkForEighth:
LDA arg2
AND #%00100000
BEQ checkForOneMore
;;; Eighth full
INC temp2
checkForOneMore:
LDA arg2
AND #%00011000
CMP #%00011000
BNE checkForPartialThreeQuarters
INC temp2
JMP drawHealthBar
checkForPartialThreeQuarters:
LDA arg2
AND #%00010000
BEQ checkForPartialHalf
;; Partial is 3/4 full
LDA arg3+48
STA temp1
JMP drawHealthBar
checkForPartialHalf:
LDA arg2
AND #%00001000
BEQ checkForPartialQuarter
;; Partial is half full
LDA arg3+32
STA temp1
JMP drawHealthBar
checkForPartialQuarter:
LDA arg2
AND #%00000111
BEQ drawHealthBar
;; Partial is quarter full
LDA arg3+16
STA temp1
drawHealthBar:
LDX temp2
LDA temp
SEC
SBC temp2 ;Number of full sprites
STA temp2 ;Number of empty sprites
BEQ readyToDrawHealthBar ;If we only have full sprites, then we can go ahead and draw
LDA temp1
BEQ readyToDrawHealthBar ;Does an empty sprite need to be replaced with a partial sprite?
DEC temp2
readyToDrawHealthBar:
LDA arg1
STA temp ;Now temp is the y position of drawing from bottom up
LDA #$00
STA tempy
fullSpritesLoop:
TXA ;8
BEQ partialSpriteDraw
DrawSprite arg0, temp, arg3+64, arg4, spriteOffset
inc spriteOffset
inc spriteOffset
inc spriteOffset
inc spriteOffset
LDA temp
SEC
SBC #$08
STA temp
DEX
INC tempy
LDA tempy
CMP tempz
BNE fullSpritesLoop
JMP doneWithHealthBar
partialSpriteDraw:
LDA temp1
BEQ readyToDrawEmptyBars
DrawSprite arg0, temp, temp1, arg4, spriteOffset
inc spriteOffset
inc spriteOffset
inc spriteOffset
inc spriteOffset
LDA temp
SEC
SBC #$08
STA temp
INC tempy
LDA tempy
CMP tempz
BNE readyToDrawEmptyBars
JMP doneWithHealthBar
readyToDrawEmptyBars:
LDX temp2 ;Loaded into X for iteration
emptySpritesLoop:
TXA
BEQ doneWithHealthBar
DrawSprite arg0, temp, arg3, arg4, spriteOffset
inc spriteOffset
inc spriteOffset
inc spriteOffset
inc spriteOffset
LDA temp
SEC
SBC #$08
STA temp
DEX
INC tempy
LDA tempy
CMP tempz
BNE emptySpritesLoop
JMP doneWithHealthBar
doneWithHealthBar:
DrawSprite arg0, temp, arg6, arg4, spriteOffset
inc spriteOffset
inc spriteOffset
inc spriteOffset
inc spriteOffset
ENDM
Efoerg said:i got this to work but i have a problem where after i die or get a health power up i cant get it to refill. any help would be appreciated. thanks
Efoerg said:Thanks for the reply i got it working it was my mistake.