Prev: 56668 Up: Map Next: 56737
56702: Set length of Maroc's energy bar based on his current energy level
Used by the routine at 56668.
energy bar
The next routine changes the screen display attributes so the energy bar reflects Maroc's current energy
When Maroc has full energy, the whole energy bar is INK 2, PAPER 6 (attribute value = 50). As Maroc loses energy, the bar is reduced from the right by setting character attributes to INK 6, PAPER 6 (54), so the pixels are invisible.
56702 LD A,(60128) Get Maroc's current energy (0-255)
56705 RRA Each of the 16 energy bar character squares represents 16 energy units, or part thereof, so divide by 16
56706 RRA
56707 RRA
56708 RRA
56709 AND 15 Keep the bottom four bits to give a value of 0-15
56711 LD C,A
56712 LD A,16 Subtract from 16 to give the number of energy bar characters to remove
56714 SUB C
56715 LD B,16 16 character squares
56717 LD HL,23239 Screen attribute display address - start of energy bar at bottom left of scroll
Count backwards (B register) from 16 to 0, comparing against Maroc's energy and obscuring squares accordingly.
56720 CP B Check current position to see if it's one that needs obscuring
56721 JR C,56731 If there's a carry, jump to 56731 to keep the character square as INK 2, PAPER 6
56723 CP 1
56725 JR Z,56731 Because Maroc's 'energy squares' value is in the range 0-15 (rather than 1-16), this check/jump ensures that the rightmost bit of flame isn't hidden when Maroc has full energy.
56727 LD (HL),54 Set the character square attribute as invisible (INK 6, PAPER 6)
56729 JR 56733
56731 LD (HL),50 Set the character square attribute as visible (INK 2, PAPER 6)
56733 INC HL Move screen attribute address right one character square along the energy bar
56734 DJNZ 56720 ...and keep checking for all 16 squares.
56736 RET
Prev: 56668 Up: Map Next: 56737