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?
So I'm on vacation and didn't bring my laptop with me. i have also was switching stuff over to my desktop because my laptop has been acting up and was planning to use remote destop to see if i could squeeze in some work while i am away, but I forgot to transfer over some files. What i'm saying is that it will be a bit dificult to help til i get back on Sunday. That said, i dont remember having issues remiplenting this in 4.1.5, but this was during the byte off, and i was in a rush, so i don't remember everything i did. I'll attach my most recent code for the macro. It's a little cumbersome to check to see if it is different at the moment, sorry. I think you should be able to call the macro in the pre-draw script (which can easily be accessed in the script settings in 4.1) and you should be pretty much good to go.
Code: Select all
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
iirc the main difference is that the tranpoline for the macro to work has to be set in bank14.asm instead of HandleUpdateObjects.asm
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
Hm, that's weird. The health bar should update automatically depending on whatever value your health currently is. If I understand you correctly, the health bar is working correctly when the player gets damaged and health goes down? Can I see your health pick up code? Can you confirm if your health variable is actually getting updated?
Thanks for the reply i got it working it was my mistake.