← B2C9 Lives-indicator icon glyph codes Map B306 → Draw the lives indicator
B2CB: Draw the "LEVEL nnn" status caption
Draws the LEVEL caption once per level. It counts the digit cells up, so the caption shows the displayed level.
draw_level_number B2CB LD A,$30 Reset the tens digit of the level caption to ASCII '0'. The hundreds cell beside it keeps the value the previous laps left there. The new-game setup clears all three at the start of a game.
B2CD LD (level_caption_tens),A
B2D0 LD A,$B1 Seed the units digit to game-font '1'; the count starts at 1, so the caption shows the level index plus one within the current lap. The game font's digits carry bit 7, so this last digit also terminates the print string.
B2D2 LD (level_caption_units),A
B2D5 LD A,(level) On the first level of a lap the seeded "01" prints after the hundreds digit, which stays as it is.
B2D8 OR A
B2D9 JR Z,draw_level_number_1
B2DB LD B,A Otherwise step the counter up by the level index.
Each pass adds one to the displayed level and carries into the tens and the hundreds. The displayed level is the level index plus one, plus a hundred for each completed lap of the level tables. The index wraps to 0 at the end of a lap while the hundreds digit stands, so the caption counts on past 100. The carry into the hundreds lands on the pass that takes the count from 99 to 100. The lap digit therefore advances while the last level of a lap is drawn.
draw_level_number_0 B2DC LD HL,level_caption_units Step the units digit; it wraps at the game font's ':' back to '0' and carries left.
B2DF INC (HL)
B2E0 LD A,(HL)
B2E1 CP $BA
B2E3 JR NZ,level_caption_next
B2E5 LD (HL),$B0 Wrapped units carry into the tens, which wrap at ASCII ':' the same way.
B2E7 DEC HL
B2E8 INC (HL)
B2E9 LD A,(HL)
B2EA CP $3A
B2EC JR NZ,level_caption_next
B2EE LD (HL),$30 That carry reaches the hundreds, the lap digit.
B2F0 DEC HL
B2F1 INC (HL)
B2F2 LD A,(HL)
B2F3 CP $3A
B2F5 JR NZ,level_caption_next
B2F7 LD (HL),$30 The hundreds wrap too, so the caption counts modulo 1000.
level_caption_next B2F9 DJNZ draw_level_number_0 One pass per level of the index
draw_level_number_1 B2FB LD HL,SCREEN_BASE+$A Print the caption double-height at character row 0, column 10.
B2FE LD DE,level_caption_text
B301 LD C,$47
B303 JP print_string_2x
← B2C9 Lives-indicator icon glyph codes Map B306 → Draw the lives indicator
Fork me on GitHub