Prev: 34512 Up: Map Next: 34627
34567: Draw strength bar at top of screen
Used by the routine at 27703.
34567 LD A,35 If Magic Knight is not carrying the Mirror (35)...
34569 CALL 33645 ...
34572 RET NZ ...then return
34573 LD HL,16482 Point HL at display file address for top pixel row of cell at (2, 3) (characters)
34576 LD A,(25020) Load A with Magic Knight's strength
34579 CALL 28625 Divide A by eight, rounding down to nearest integer
34582 AND 15 If lowest four bits are reset (i.e. don't need to draw part of a character block)...
34584 JR Z,34603 ...then skip ahead to 34603
34586 LD B,A Load number of full character blocks to draw into B
34587 LD A,255 Load A with 255 (draw row of eight pixels)
34589 PUSH HL Store HL (current display file position in health bar block)
34590 PUSH BC Store BC (B = remaining number of full character blocks to draw)
34591 LD B,4 Load B with 4 (health bar has 4 stripes)
34593 LD (HL),A Draw a byte (i.e. a "block" of 8 health units) to health bar
34594 INC H Advance HL two rows down (as bar is made of alternating horizontal stripes)...
34595 INC H ...
34596 DJNZ 34593 Decrease B (number of stripes to draw) and loop back to 34593 if not zero
34598 POP BC Restore BC (B = remaining number of full character blocks to draw)
34599 POP HL Restore HL (current display file position in health bar block)
34600 INC HL Advance HL (horizontally) one character to draw next full block
34601 DJNZ 34589 Decrease B (remaining number of full character blocks to draw) and loop back to 34589 if not zero
34603 LD A,(25020) Load A with Magic Knight's strength
34606 AND 7 Get fractional part (i.e. amount by which strength is more than a multiple of eight)
34608 JR NZ,34613 If this is not zero, then skip ahead to 34613
34610 XOR A Set A to zero
34611 JR 34619 Skip ahead to draw the blank rows (see trivia)
34613 LD B,A Load fractional part of strength into B
34614 XOR A Set A to zero
34615 SCF Set the carry flag
34616 RRA Move carry flag bit into MSB of A
34617 DJNZ 34615 Decrease B and loop back if not zero (i.e. place a bit at the LHS of A for each unit of strength that is left!)
34619 LD B,4 Load B with 4 (health bar has 4 stripes)
34621 LD (HL),A Draw a byte (i.e. a "block" of 8 health units) to health bar
34622 INC H Advance HL two rows down (as bar is made of alternating horizontal stripes)...
34623 INC H ...
34624 DJNZ 34621 Loop back to 34621 to draw next row
34626 RET Return
Prev: 34512 Up: Map Next: 34627