Prev: C06E Up: Map Next: C25D
C16A: Name-entry cursor flash and letter-selection input
Handles one frame of the high-score name-entry screen: flashes the underline cursor beneath the current letter/name-length position, reads input via $800E, and on confirm (bit 4) either advances to cycle_and_draw_letter (scroll/select the next letter) or, if the entry is finished, stores the chosen character into the row (cursor position at $C59C, see insert_high_score_entry) and patches $C2F2 to RET (see scroll_score_rows / redraw_score_name) to end the entry loop.
Used by the routine at insert_high_score_entry.
name_entry_input C16A LD HL,$C595 HL -> flash-timer counter
C16D DEC (HL)
C16E JR NZ,name_entry_input_1 Skip the cursor toggle until the timer hits zero
C170 LD (HL),$0C Reload the timer (12 frames)
Advances the blinking selector by writing attribute $46 into cell $5967+offset ($C596 holds the 0-19 offset within this row). While the advanced offset is still < 20 ($14), that is the whole effect for this call: save offset+1 back to $C596 and return via $C19B. Once the offset would wrap past 20, the selector has completed a full pass along this row: additionally nudge the row pointer held at $C597 -- clear its old highlighted cell (attribute $42), move it on by one screen line (+$20) then step it back by 31 (net +1 down and +1 right, i.e. onto the next row's first cell, attribute $02) -- and if that pointer's low byte has itself reached $17 (23), the whole multi-row cycle is complete and control passes to nei_finalise (name entry finished/row exhausted) instead of resetting the offset to 0 and continuing. $C596 and $C597 start at 0 and $590A respectively (from the 13-byte template at $C580, copied by check_high_score). $C597's low byte must climb from $0A to $17, i.e. 13 row-wraps of 20 cells at 12 frames/cell = 3120 frames (~62s at 50Hz) of elapsed time with no player input before this idle path alone forces nei_finalise, independent of RIGHT/LEFT/FIRE.
C172 LD HL,$5967
C175 LD A,($C596)
C178 LD C,A
C179 ADD A,L
C17A LD L,A
C17B LD (HL),$46
C17D LD A,C
C17E INC A
C17F CP $14
C181 JR C,name_entry_input_0
C183 EX DE,HL
C184 LD HL,($C597)
C187 LD (HL),$42
C189 LD A,L
C18A ADD A,$20
C18C LD L,A
C18D LD (HL),$02
C18F SUB $1F
C191 CP $17
C193 JR Z,nei_finalise
C195 LD L,A
C196 LD ($C597),HL
C199 EX DE,HL
C19A XOR A
name_entry_input_0 C19B LD ($C596),A
name_entry_input_1 C19E LD HL,$5967 Clear the old cursor cell
C1A1 LD A,($C596)
C1A4 ADD A,L
C1A5 LD L,A
C1A6 LD (HL),$00
C1A8 LD HL,$C59A Toggle two flash-phase flag bytes ($C59A, $C59B)
C1AB RLC (HL)
C1AD LD DE,($C58E)
C1B1 LD C,$00
C1B3 JR NC,name_entry_input_2
C1B5 LD C,$42
name_entry_input_2 C1B7 EX AF,AF'
C1B8 LD HL,($C597)
C1BB LD (HL),C
C1BC LD A,L
C1BD ADD A,$20
C1BF LD L,A
C1C0 RES 6,C
C1C2 LD (HL),C
C1C3 LD HL,$C579
C1C6 EX AF,AF'
C1C7 JP C,cad_draw_glyph
C1CA LD HL,$C59B
C1CD RLC (HL)
C1CF LD HL,($C593) HL -> current position in the letter/name table
C1D2 JP C,cad_draw_entry
C1D5 PUSH HL Preserve HL/DE across the input read
C1D6 PUSH DE
C1D7 CALL $800E Read input (common routine outside this bank)
C1DA POP DE
C1DB POP HL
C1DC AND $13 Mask to the relevant input bits
C1DE JP Z,cad_clear_locked Nothing relevant pressed
C1E1 BIT 4,A Test the confirm/fire bit
C1E3 JR Z,cycle_and_draw_letter Not confirming -> scroll/select the next letter
C1E5 LD A,($C599) Skip if a "locked" flag is set
C1E8 AND A
C1E9 JP NZ,cad_draw_entry
C1EC INC E E += 2
C1ED INC E
C1EE LD A,E
C1EF CP $94 At the maximum name length
C1F1 JR Z,nei_finalise Yes -> finalise without storing another character
C1F3 LD ($C58E),DE
C1F7 PUSH DE
C1F8 LD DE,($C59C) DE -> row write cursor (see insert_high_score_entry)
C1FC LD A,(HL) A = selected character code
C1FD CP $40 $40 is the "blank" marker -> display as a full stop
C1FF JR NZ,name_entry_input_3
C201 LD A,$2E
name_entry_input_3 C203 LD (DE),A Store the confirmed character into the row
C204 INC DE
C205 LD ($C59C),DE Advance the row write cursor
C209 POP DE
C20A INC HL
C20B LD ($C593),HL Save the updated letter-table position
C20E LD A,$01
C210 JR cycle_and_draw_letter_2
nei_finalise C212 POP HL
C213 LD HL,($C593)
C216 LD A,(HL)
C217 CP $40 $40 is the "blank" marker -> store as a full stop
C219 JR NZ,name_entry_input_4
C21B LD A,$2E
name_entry_input_4 C21D LD C,A
C21E LD A,($C58E)
C221 CP $92
C223 JR NZ,name_entry_input_5
C225 SET 7,C
name_entry_input_5 C227 LD HL,($C59C)
C22A LD (HL),C Store the final character into the row
C22B XOR A
C22C LD ($C58D),A
C22F LD A,$C9 $C9 = RET opcode
C231 LD ($C2F2),A Patch $C2F2 to RET, ending the entry loop in insert_high_score_entry
C234 CALL stop_music_and_silence Wait for the keyboard to clear (stop_music_and_silence)
C237 LD A,($C13D)
C23A AND A
C23B CALL Z,name_entry_frame Run one more entry frame (see name_entry_frame)
Redraw the cursor cells one final time ($C23E-$C251), mirroring $C172-$C18D above.
C23E LD HL,$5967
C241 LD A,($C596)
C244 ADD A,L
C245 LD L,A
C246 LD (HL),$46
C248 LD HL,($C597)
C24B LD (HL),$42
C24D LD A,L
C24E ADD A,$20
C250 LD L,A
C251 LD (HL),$02
C253 LD A,$02
C255 CALL titlescr_start_tune See titlescr_start_tune, called with A=2
name_entry_input_6 C258 CALL titlescr_music See titlescr_music
C25B JR name_entry_input_6 Loop -- exits via a side effect inside a callee
Prev: C06E Up: Map Next: C25D