Routines |
Prev: DD5C | Up: Map | Next: DDA1 |
Used by the routine at DD5C.
|
||||
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.
|
||||
DD7E | LD A,($EAE0) | Get Maroc's current energy (0-255) | ||
DD81 | RRA | Each of the 16 energy bar character squares represents 16 energy units, or part thereof, so divide by 16 | ||
DD82 | RRA | |||
DD83 | RRA | |||
DD84 | RRA | |||
DD85 | AND $0F | Keep the bottom four bits to give a value of 0-15 | ||
DD87 | LD C,A | |||
DD88 | LD A,$10 | Subtract from 16 to give the number of energy bar characters to remove | ||
DD8A | SUB C | |||
DD8B | LD B,$10 | 16 character squares | ||
DD8D | LD HL,$5AC7 | 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.
|
||||
DD90 | CP B | Check current position to see if it's one that needs obscuring | ||
DD91 | JR C,$DD9B | If there's a carry, jump to DD9B to keep the character square as INK 2, PAPER 6 | ||
DD93 | CP $01 | |||
DD95 | JR Z,$DD9B | 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. | ||
DD97 | LD (HL),$36 | Set the character square attribute as invisible (INK 6, PAPER 6) | ||
DD99 | JR $DD9D | |||
DD9B | LD (HL),$32 | Set the character square attribute as visible (INK 2, PAPER 6) | ||
DD9D | INC HL | Move screen attribute address right one character square along the energy bar | ||
DD9E | DJNZ $DD90 | ...and keep checking for all 16 squares. | ||
DDA0 | RET |
Prev: DD5C | Up: Map | Next: DDA1 |