← 8BA8 Program entry and the main per-frame loop Map 8DF9 → Poll the quit key (Q)
8D9C: Quit-confirmation handler (per-frame)
Offers the ARE YOU SURE Y-N? prompt when Q is pressed, and abandons the game on Y. The prompt blocks the frame until the player answers.
Q held: blip to acknowledge, then draw the two-line prompt beside the bat. Its column comes from the bat side, so the text lands on the wall the bat occupies.
Wait for Q to be released, then poll the Y and N keys until one answers. Y discards the call stack and jumps to the restart entry. N erases the prompt and returns.
The prompt is two single-height font lines one character row apart. The N-key path erases both at once with a single double-height blank string.
handle_quit_confirm 8D9C CALL poll_quit_key Return unless the Q key is held this frame.
8D9F OR A
8DA0 RET Z
8DA1 CALL sfx_key_blip Blip to acknowledge the Q press.
8DA4 LD A,(bat_side) Pick the prompt's line-1 cell so it sits on the bat's side: the bat on the left takes column 2.
8DA7 OR A
8DA8 JR Z,handle_quit_confirm_0
8DAA LD HL,SCREEN_BASE+$882
8DAD JR handle_quit_confirm_1
handle_quit_confirm_0 8DAF LD HL,SCREEN_BASE+$894 A zero side takes column 20 instead.
handle_quit_confirm_1 8DB2 PUSH HL Keep the line-1 cell for line 2 and the later erase.
8DB3 LD DE,msg_are_you_sure Print line 1 in bright white on black.
8DB6 LD C,$47
8DB8 CALL print_string
8DBB POP HL Reload the line-1 cell and keep it saved.
8DBC PUSH HL
8DBD LD DE,$0020 Step down one character row (32 cells) to line 2.
8DC0 ADD HL,DE
8DC1 LD DE,msg_sure_yn Print line 2.
8DC4 LD C,$47
8DC6 CALL print_string
wait_q_release 8DC9 CALL poll_quit_key Wait for the Q key to be released before it reads the answer.
8DCC OR A
8DCD JR NZ,wait_q_release
poll_quit_answer 8DCF LD BC,KBD_ROW_Y_P Read the P-Y keyboard half-row and keep the 5 key bits.
8DD2 IN A,(C)
8DD4 AND $1F
8DD6 BIT 4,A Bit 4 is the Y key (0 when pressed).
8DD8 JR NZ,poll_quit_no_key Y up: go test the N key.
8DDA CALL sfx_key_blip Y pressed: blip to confirm the quit.
8DDD POP HL Discard the saved cell and the caller's return address – the call chain is abandoned.
8DDE POP HL
8DDF JP new_game Restart a fresh game from the restart entry.
poll_quit_no_key 8DE2 LD B,$7F Switch BC to the B-Space half-row and keep the 5 key bits.
8DE4 IN A,(C)
8DE6 AND $1F
8DE8 BIT 3,A Bit 3 is the N key (0 when pressed).
8DEA JR NZ,poll_quit_answer Neither Y nor N pressed: poll again for an answer.
8DEC CALL sfx_key_blip N pressed: blip and resume play.
8DEF POP HL Recover the line-1 cell, then erase both lines with one double-height blank.
8DF0 LD DE,msg_sure_pad
8DF3 LD C,$47
8DF5 CALL print_string_2x
8DF8 RET
← 8BA8 Program entry and the main per-frame loop Map 8DF9 → Poll the quit key (Q)
Fork me on GitHub