| ← B3FE | Map | B446 → |
B412: Check whether the just-finished score makes the high-score table
|
Decides on game over whether the score earns a place in the high-score table. A tie or better goes to name entry.
|
|||
| check_highscore | B412 | CALL clear_screen | |
| B415 | LD A,$47 | Fill the attributes with bright white on black. | |
| B417 | CALL fill_attrs | ||
| B41A | LD HL,score_units | Clear the print terminator on the live score's last digit, so every digit compares as plain ASCII against the table entries. | |
| B41D | RES 7,(HL) | ||
| B41F | LD DE,score_display | Walk the live score against the table entries, highest first. | |
| B422 | LD HL,highscore_entries | ||
| B425 | LD B,$0A | ||
|
One table entry's turn. The slot counter counts down from 10 at the top slot to 1 at the bottom. An entry that qualifies hands the name entry the matched record, the live score and the slot counter.
|
|||
| highscore_compare_entry | B427 | PUSH BC | Save the two cursors and the slot counter, then ready the digit compare. |
| B428 | PUSH DE | ||
| B429 | PUSH HL | ||
| B42A | LD B,$08 | ||
|
The score is fixed-width, zero-padded ASCII, so a plain byte compare of the eight digits ranks two of them. The first digit where the live score is greater qualifies it and branches to name entry. A smaller digit abandons the entry and steps to the next record. All eight equal is a tie, and it qualifies.
|
|||
| highscore_compare_digit | B42C | LD A,(DE) | Compare one digit: live score against table entry. |
| B42D | CP (HL) | ||
| B42E | JR Z,highscore_digit_equal | Equal digit: compare the next one. | |
| B430 | JR NC,enter_highscore_name | Live digit higher: the score beats this entry, go enter the name. | |
| B432 | JR highscore_next_entry | Live digit lower: this entry outranks the score, try the next. | |
| highscore_digit_equal | B434 | INC HL | Step to the next (less-significant) digit; all 8 matched falls through. |
| B435 | INC DE | ||
| B436 | DJNZ highscore_compare_digit | ||
| B438 | JR enter_highscore_name | All 8 digits equal: a tie qualifies too. | |
| highscore_next_entry | B43A | POP HL | Reject this entry: advance the table cursor by the 22-byte record stride, restore the live-score cursor, and loop to the next-lower entry. |
| B43B | LD DE,$0016 | ||
| B43E | ADD HL,DE | ||
| B43F | POP DE | ||
| B440 | POP BC | ||
| B441 | DJNZ highscore_compare_entry | ||
| B443 | JP draw_highscore_table | Score below all 10 entries: redisplay the table without name entry. | |
| ← B3FE | Map | B446 → |
