| ← B2CB | Map | B351 → |
B306: Draw the lives indicator
|
Draws the lives indicator: a two-glyph icon and the spare-life count, one less than the life count.
|
|||
| draw_lives | B306 | LD HL,lives_digits | Reset the count buffer to "00": tens ASCII '0', units game-font '0' (bit 7 set, the print terminator). |
| B309 | LD (HL),$30 | ||
| B30B | INC HL | ||
| B30C | LD (HL),$B0 | ||
| B30E | LD HL,SCREEN_BASE+$14 | Draw the icon's first glyph at the status line in bright white on black. | |
| B311 | LD DE,lives_icon_glyph_top | ||
| B314 | LD C,$47 | ||
| B316 | CALL print_string | ||
| B319 | LD HL,SCREEN_BASE+$34 | Draw the icon's second glyph below it. | |
| B31C | LD DE,lives_icon_glyphs | ||
| B31F | LD C,$47 | ||
| B321 | CALL print_string | ||
| B324 | LD A,(lives) | Spare lives are one less than the life count. Draw nothing more when the life count is 0. | |
| B327 | DEC A | ||
| B328 | CP $FF | ||
| B32A | RET Z | ||
| B32B | CP $0A | A single-digit count skips the tens split, so the tens digit stays '0'. | |
| B32D | JR C,draw_lives_units | ||
| B32F | LD C,$00 | Count the tens of the spare-life number. | |
| draw_lives_tens_loop | B331 | SUB $0A | Subtract ten again and again, until the units remainder is left in A. |
| B333 | INC C | ||
| B334 | CP $0A | ||
| B336 | JR NC,draw_lives_tens_loop | ||
| B338 | LD B,A | Store the tens as an ASCII digit in the high cell; keep the units in B. | |
| B339 | LD A,C | ||
| B33A | ADD A,$30 | ||
| B33C | LD HL,lives_digits | ||
| B33F | LD (HL),A | ||
| B340 | LD A,B | ||
| draw_lives_units | B341 | ADD A,$B0 | Store the units in the game font, bit 7 set in the low cell. |
| B343 | LD HL,lives_digits_units | ||
| B346 | LD (HL),A | ||
| B347 | DEC HL | Print the 2-digit count double-height beside the icon. | |
| B348 | EX DE,HL | ||
| B349 | LD HL,SCREEN_BASE+$15 | ||
| B34C | LD C,$47 | ||
| B34E | JP print_string_2x | ||
| ← B2CB | Map | B351 → |
