![]() |
Routines |
| Prev: 8800 | Up: Map | Next: 89A6 |
|
Compares the current score to the high score digit by digit, most significant first. RET C immediately if the score is lower. Jumps to score_hiscore_check_0 if higher. If equal, falls through to RET with no update.
At score_hiscore_check_0: draws the "* NOVO RECORDE *" / "Introduza o seu nome ." frame (frame_new_record). Reads up to 32 chars into var_record_name. Asks "Esta correcto o seu nome ?" (frame_name_correct): 's' saves, 'n' re-enters.
|
||||
|
Compare digit 1
|
||||
| score_hiscore_check | 8900 | LD HL,($C346) | Load score digits 1–2 (var_score_digits12) into HL (H=digit 1, L=digit 2) | |
| 8903 | LD DE,($C342) | Load hiscore digits 1–2 (var_hiscore_digits12) into DE (D=digit 1, E=digit 2) | ||
| 8907 | LD A,H | If score digit 1 < hiscore digit 1 → RET C | ||
| 8908 | SUB D | |||
| 8909 | RET C | |||
| 890A | LD A,H | If score digit 1 > hiscore digit 1 → new record (score_hiscore_check_0) | ||
| 890B | CP D | |||
| 890C | JP NZ,score_hiscore_check_0 | |||
|
Compare digit 2
|
||||
| 890F | LD A,L | If score digit 2 < hiscore digit 2 → RET C | ||
| 8910 | SUB E | |||
| 8911 | RET C | |||
| 8912 | LD A,L | If score digit 2 > hiscore digit 2 → new record (score_hiscore_check_0) | ||
| 8913 | CP E | |||
| 8914 | JP NZ,score_hiscore_check_0 | |||
|
Compare digit 3
|
||||
| 8917 | LD HL,($C348) | Load score digits 3–4 (var_score_digits34) into HL (H=digit 3, L=digit 4) | ||
| 891A | LD DE,($C344) | Load hiscore digits 3–4 (var_hiscore_digits34) into DE (D=digit 3, E=digit 4) | ||
| 891E | LD A,H | If score digit 3 < hiscore digit 3 → RET C | ||
| 891F | SUB D | |||
| 8920 | RET C | |||
| 8921 | LD A,H | If score digit 3 > hiscore digit 3 → new record (score_hiscore_check_0) | ||
| 8922 | CP D | |||
| 8923 | JP NZ,score_hiscore_check_0 | |||
|
Compare digit 4
|
||||
| 8926 | LD A,L | If score digit 4 < hiscore digit 4 → RET C | ||
| 8927 | SUB E | |||
| 8928 | RET C | |||
| 8929 | LD A,L | If score digit 4 > hiscore digit 4 → new record (score_hiscore_check_0) | ||
| 892A | CP E | |||
| 892B | JP NZ,score_hiscore_check_0 | |||
| 892E | RET | Score equals hiscore — RET (no update) | ||
|
New record — prompt for name
|
||||
| score_hiscore_check_0 | 892F | LD DE,$3C00 | Set CHARS=$3C00 (ROM font), draw "* NOVO RECORDE *" frame (frame_new_record) | |
| 8932 | CALL set_chars | |||
| 8935 | LD HL,$89D2 | Draw "Introduza o seu nome ." frame (frame_new_record) | ||
| 8938 | CALL draw_frame | |||
| score_hiscore_check_1 | 893B | LD HL,$89A6 | HL = name buffer (var_record_name) | |
| 893E | LD A,$16 | Emit PRINT AT row 12, col 0 | ||
| 8940 | RST $10 | |||
| 8941 | LD A,$0C | |||
| 8943 | RST $10 | |||
| 8944 | LD A,$00 | |||
| 8946 | RST $10 | |||
| 8947 | LD A,$10 | Set INK=6 (yellow) | ||
| 8949 | RST $10 | |||
| 894A | LD A,$06 | |||
| 894C | RST $10 | |||
| 894D | LD B,$20 | B = 32 (max chars) | ||
|
Name input loop
|
||||
| score_hiscore_check_2 | 894F | PUSH BC | Save BC and HL; wait for keypress (wait_keypress) | |
| 8950 | PUSH HL | |||
| 8951 | CALL wait_keypress | |||
| 8954 | POP HL | Restore BC and HL; load key from var_last_key | ||
| 8955 | POP BC | |||
| 8956 | LD A,($C34C) | |||
| 8959 | CP $0D | If ENTER → confirm name (score_hiscore_check_3) | ||
| 895B | JP Z,score_hiscore_check_3 | |||
| 895E | PUSH BC | Store char in buffer, print it, advance HL | ||
| 895F | LD (HL),A | |||
| 8960 | RST $10 | |||
| 8961 | NOP | |||
| 8962 | NOP | |||
| 8963 | INC HL | |||
| 8964 | POP BC | |||
| 8965 | DJNZ score_hiscore_check_2 | DJNZ name input loop | ||
|
Confirm name
|
||||
| score_hiscore_check_3 | 8967 | PUSH BC | Draw "Esta correcto o seu nome ?" frame (frame_name_correct) | |
| 8968 | PUSH HL | |||
| 8969 | LD HL,$8A09 | |||
| 896C | CALL draw_frame | |||
| score_hiscore_check_4 | 896F | CALL wait_keypress | Wait for keypress (wait_keypress) | |
| 8972 | LD A,($C34C) | Load key from var_last_key; CP 'n' | ||
| 8975 | CP $6E | |||
| 8977 | POP HL | POP HL and POP BC | ||
| 8978 | POP BC | |||
| 8979 | JP Z,score_hiscore_check_6 | If 'n' → re-enter name (score_hiscore_check_6) | ||
| 897C | CP $73 | CP 's' | ||
| 897E | JP Z,score_hiscore_check_5 | If 's' → save hiscore (score_hiscore_check_5) | ||
| 8981 | PUSH BC | Neither key — loop back to wait (score_hiscore_check_4) | ||
| 8982 | PUSH HL | |||
| 8983 | JR score_hiscore_check_4 | |||
|
Save hiscore
|
||||
| score_hiscore_check_5 | 8985 | LD A,$20 | Pad name buffer with spaces to 32 chars | |
| 8987 | LD (HL),A | |||
| 8988 | INC HL | |||
| 8989 | DJNZ score_hiscore_check_5 | |||
| 898B | LD HL,($C346) | Copy score digits 1–2 to hiscore (var_hiscore_digits12) | ||
| 898E | LD ($C342),HL | |||
| 8991 | LD HL,($C348) | Copy score digits 3–4 to hiscore (var_hiscore_digits34) | ||
| 8994 | LD ($C344),HL | |||
| 8997 | LD A,$05 | Delay 5 ticks | ||
| 8999 | CALL delay_a | |||
| 899C | RET | |||
|
Re-enter name
|
||||
| score_hiscore_check_6 | 899D | LD HL,$8A29 | Draw blank-lines frame (frame_clear_name) | |
| 89A0 | CALL draw_frame | |||
| 89A3 | JP score_hiscore_check_1 | Jump back to name entry (score_hiscore_check_1) | ||
| Prev: 8800 | Up: Map | Next: 89A6 |