← B446 Name entry: cursor index along the name-entry strip Map B585 → Step the name-entry cursor left
B447: Enter a name for the high-score table
The high-score name-entry screen, shown when the player's score qualifies. The player spells a name off the name-entry strip.
name_entry_pos B447 DEFB $0D Write position in the entry buffer: where the next confirmed letter is stored.
enter_highscore_name B448 POP HL Take the caller's three saved words back. The slot counter of the entry that qualified decides how much of the table moves.
B449 POP DE
B44A POP BC
B44B PUSH HL
B44C LD A,B
B44D CP $01
B44F JR Z,highscore_draw
B451 DEC B Every slot above the bottom needs the records under it pushed down one place, so measure how far.
B452 LD DE,$0016
B455 LD HL,$0000
highscore_scroll B458 ADD HL,DE Total that as a byte count.
B459 DJNZ highscore_scroll
B45B LD C,L Slide the block down to open the new record's slot.
B45C LD B,H
B45D LD HL,highscore_entries+$C5
B460 LD DE,highscore_entries+$DB
B463 LDDR
highscore_draw B465 LD A,$0C Start the write position at the first name cell and the cursor on the strip's first cell. Print the two captions and the strip, then copy the live score and the separator into the entry buffer.
B467 LD (name_entry_pos),A
B46A XOR A
B46B LD (name_entry_cursor),A
B46E LD HL,highscore_heading
B471 LD DE,msg_congrats
B474 LD C,$4E
B476 CALL print_string_2x
B479 LD HL,SCREEN_BASE+$A5
B47C LD DE,msg_input_name
B47F LD C,$45
B481 CALL print_string_2x
B484 LD HL,SCREEN_BASE+$801
B487 LD DE,name_entry_strip
B48A LD C,$47
B48C CALL print_string
B48F LD HL,score_display
B492 LD DE,highscore_entry_buffer
B495 LD BC,$0008
B498 LDIR
B49A EX DE,HL
B49B LD (HL),$20
B49D INC HL
B49E LD (HL),$2D
B4A0 INC HL
B4A1 LD (HL),$2D
B4A3 INC HL
B4A4 LD (HL),$20
B4A6 INC HL
B4A7 LD B,$0A
highscore_holder_loop B4A9 LD (HL),$24 Fill the name holder with the underscore placeholder.
B4AB INC HL
B4AC DJNZ highscore_holder_loop
B4AE DEC HL Bit 7 on the last cell makes the holder print as a terminated string.
B4AF SET 7,(HL)
highscore_print_name B4B1 LD HL,SCREEN_BASE+$8A5 Print the record so far, the score and the name, double-height under the strip.
B4B4 LD DE,highscore_entry_buffer
B4B7 LD C,$47
B4B9 CALL print_string_2x
highscore_cursor_pos B4BC LD A,(name_entry_cursor) Work out where the cursor sits on the strip so the highlight lands on it.
B4BF LD E,A
B4C0 LD D,$00
B4C2 LD HL,ATTR_BASE+$101
B4C5 ADD HL,DE
B4C6 DEC HL
B4C7 LD (HL),$47
B4C9 INC HL
B4CA LD (HL),$78
B4CC INC HL
B4CD LD (HL),$47
B4CF CALL read_ctrl Read the player's input each pass. Fire goes on to act on the cell under the cursor.
B4D2 LD HL,controls
B4D5 BIT 4,(HL)
B4D7 JR NZ,highscore_confirm_char
B4D9 BIT 2,(HL)
B4DB CALL NZ,name_cursor_left The game has no left/right action, so up/forward steps the cursor right along the strip and down/back steps it left.
B4DE BIT 3,(HL)
B4E0 CALL NZ,name_cursor_right
B4E3 CALL highscore_input_delay Pause so a held control repeats at a steady rate, then loop to reposition the highlight and read the controls again.
B4E6 JR highscore_cursor_pos
highscore_confirm_char B4E8 CALL read_ctrl Wait for fire to be released, then act on the strip cell under the cursor. The ENTER cell finishes the name.
B4EB LD HL,controls
B4EE BIT 4,(HL)
B4F0 JR NZ,highscore_confirm_char
B4F2 LD A,(name_entry_cursor)
B4F5 LD E,A
B4F6 LD D,$00
B4F8 LD HL,name_entry_strip
B4FB ADD HL,DE
B4FC LD A,(HL)
B4FD CP $A9
B4FF JR NZ,highscore_check_delete
B501 LD HL,highscore_new_name
B504 LD B,$0A
highscore_finalize_loop B506 LD A,(HL) Walk the name for the first placeholder cell, plain or terminated.
B507 CP $24
B509 JR Z,highscore_clear_holder
B50B CP $A4
B50D JR Z,highscore_clear_holder
B50F INC HL Cells with letters are stepped over.
B510 DJNZ highscore_finalize_loop
B512 JR highscore_store_name
highscore_clear_holder B514 LD (HL),$20 From the first such cell, blank the rest and terminate the string.
B516 INC HL
B517 DJNZ highscore_clear_holder
B519 DEC HL
B51A SET 7,(HL)
highscore_store_name B51C POP DE Copy the finished record, the score and the name, into the table slot and repaint the score screen.
B51D LD HL,highscore_entry_buffer
B520 LD BC,$0016
B523 LDIR
B525 JP draw_highscore_table
highscore_check_delete B528 CP $28 Not the ENTER cell, so test the DELETE one; it only bites while at least one letter has been entered.
B52A JR NZ,highscore_letter_check
B52C LD A,(name_entry_pos)
B52F CP $0D
B531 JP C,highscore_print_name
B534 CP $15
B536 JR NZ,highscore_delete_apply
B538 LD E,A At the far end the cell at the write position is cleared first.
B539 LD D,$00
B53B LD HL,highscore_entry_buffer
B53E ADD HL,DE
B53F LD A,(HL)
B540 CP $A4
B542 JR Z,highscore_delete_pos
B544 LD (HL),$A4
B546 JR highscore_delete_done
highscore_delete_pos B548 LD A,E With the last cell already blank, step back from the far end.
highscore_delete_apply B549 DEC A Step the write position back and blank the cell it lands on.
B54A LD (name_entry_pos),A
B54D LD E,A
B54E LD D,$00
B550 LD HL,highscore_entry_buffer
B553 ADD HL,DE
B554 LD (HL),$24
highscore_delete_done B556 CALL sfx_key_blip Blip, wait for the key to come up, and redraw for either outcome.
B559 CALL wait_no_key
B55C JP highscore_print_name
highscore_letter_check B55F LD HL,highscore_entry_buffer An ordinary letter: store it at the write position in the name, then test whether that was the last cell.
B562 EX AF,AF'
B563 LD A,(name_entry_pos)
B566 LD E,A
B567 LD D,$00
B569 ADD HL,DE
B56A EX AF,AF'
B56B LD (HL),A
B56C LD HL,name_entry_pos
B56F LD A,(HL)
B570 CP $15
B572 JR NZ,highscore_advance_pos
B574 LD HL,highscore_new_name_last A name filled to the last cell is terminated where it stands.
B577 SET 7,(HL)
B579 JR highscore_wait_release
highscore_advance_pos B57B INC (HL) Otherwise the write position moves on to the next cell.
highscore_wait_release B57C CALL wait_no_key Wait for the key to come up, blip, and redraw the entry screen.
B57F CALL sfx_key_blip
B582 JP highscore_print_name
← B446 Name entry: cursor index along the name-entry strip Map B585 → Step the name-entry cursor left
Fork me on GitHub