Prev: BB6B Up: Map Next: BBD8
BB74: The menu
Used by the routine at START.
Called by START before every game. It stops every line's flash, clears the buffer, draws the menu's text and frame (DISPLAY_MENU, which draws the frame and shows the buffer only the first time, as the flag cleared here tells it) and flashes the chosen control method (FLASH_MENU). Then round a loop: print the text again (its attributes, with the flashing, go straight to the screen), play the tune if it has not been heard (PLAY_TUNE_ONCE, which a key cuts short), and read the keys.
Keys 1 to 4 set bits 1 and 2 of CONTROL to 0 keyboard, 1 Kempston, 2 cursor, 3 Interface II, and key 0 starts the game. If several are held the highest wins, since each is applied in turn. Key 5 is not read, and nothing here sets bit 3 of CONTROL, though FLASH_MENU flashes a sixth line of the menu when it is set.
Two leftovers do nothing: HL is loaded with one variable's address and at once with another's, and the CP after them sets flags nothing reads -- perhaps a test, once, for whether the choice had changed.
MENU BB74 XOR A the menu's frame is still to be drawn
BB75 LD (FRAME_DRAWN),A
BB78 LD HL,MENU_COLOURS no line flashing; the loop takes in the byte after the seven attributes as well, whose bit 7 is clear anyway
BB7B LD B,$08
MENU_0 BB7D RES 7,(HL)
BB7F INC HL
BB80 DJNZ MENU_0
BB82 CALL CLEAR_BUFFER a clear buffer; the text, the frame and the choice
BB85 CALL DISPLAY_MENU
BB88 CALL FLASH_MENU
MENU_1 BB8B CALL DISPLAY_MENU the text again; the tune, once
BB8E LD DE,TUNE_MENU
BB91 CALL PLAY_TUNE_ONCE
BB94 LD A,$F7 the keys 1 to 5; CONTROL as it was, into CONTROL_BEFORE
BB96 CALL READ_KEYS
BB99 LD E,A
BB9A LD A,(CONTROL)
BB9D LD (CONTROL_BEFORE),A
BBA0 BIT 0,E 1: keyboard
BBA2 JR Z,MENU_2
BBA4 AND $F9
MENU_2 BBA6 BIT 1,E 2: Kempston
BBA8 JR Z,MENU_3
BBAA AND $F9
BBAC OR $02
MENU_3 BBAE BIT 2,E 3: cursor keys
BBB0 JR Z,MENU_4
BBB2 AND $F9
BBB4 OR $04
MENU_4 BBB6 BIT 3,E 4: Interface II
BBB8 JR Z,MENU_5
BBBA OR $06
MENU_5 BBBC LD (CONTROL),A the new choice
BBBF LD HL,MENU_SPARE leftovers: a load at once overwritten, and a compare nothing reads
BBC2 LD HL,CONTROL_BEFORE
BBC5 CP (HL)
BBC6 LD A,$EF key 0: start
BBC8 CALL READ_KEYS
BBCB BIT 0,A
BBCD RET NZ
BBCE LD HL,MENU_PASSES count the passes
BBD1 INC (HL)
BBD2 CALL FLASH_MENU flash the choice; round again
BBD5 JP MENU_1
Prev: BB6B Up: Map Next: BBD8