Prev: C8B2 Up: Map Next: C949
C8CA: The menu
Used by the routine at NEW_GAME.
Called by NEW_GAME before every game, after the screen has been cleared. It clears MENU_SHOWN, so that the first time the text is printed the border is drawn round it, stops every line's flash, clears the play area's buffers (the second half of SHOW_PLAY_AREA), draws the menu (DISPLAY_MENU) and flashes the lines chosen (FLASH_MENU). Then round a loop: print the text again (which rewrites the attributes, and so the flashing), play the menu's tune the first time round (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; if several are held the highest wins, since each is applied in turn. Key 5 toggles bit 3, directional control, once a press (KEY_LATCH). A change to CONTROL plays a short tune (TUNE_CONTROL_CHOSEN). Key 0 starts the game. Every pass counts the turn counter on and stirs the random number with R (NEXT_TURN), so the time spent on the menu decides where the knight starts (RANDOM_START_CELL).
Alien 8's MENU, key 5 and all, but for the tune where Alien 8 beeps, the random number where Alien 8 counts a seed, and the clearing of the buffers.
MENU C8CA XOR A no text printed yet: the first printing draws the border
C8CB LD (MENU_SHOWN),A
C8CE LD HL,MENU_COLOURS no line flashing: all eight colours in MENU_COLOURS
C8D1 LD B,$08
MENU_0 C8D3 RES 7,(HL)
C8D5 INC HL
C8D6 DJNZ MENU_0
C8D8 CALL CLEAR_BUFFER a clear buffer; the menu and its border; the lines chosen
C8DB CALL DISPLAY_MENU
C8DE CALL FLASH_MENU
MENU_LOOP C8E1 CALL DISPLAY_MENU the text again; the tune, once
C8E4 LD DE,TUNE_MENU
C8E7 CALL PLAY_TUNE_ONCE
C8EA LD A,$F7 E = keys 1-5, key 1 in bit 0
C8EC CALL READ_KEYS
C8EF LD E,A A = CONTROL, and as it was into LAST_CONTROL
C8F0 LD A,(CONTROL)
C8F3 LD (LAST_CONTROL),A
C8F6 BIT 0,E 1: keyboard
C8F8 JR Z,MENU_1
C8FA AND $F9
MENU_1 C8FC BIT 1,E 2: Kempston
C8FE JR Z,MENU_2
C900 AND $F9
C902 OR $02
MENU_2 C904 BIT 2,E 3: cursor keys
C906 JR Z,MENU_3
C908 AND $F9
C90A OR $04
MENU_3 C90C BIT 3,E 4: Interface II
C90E JR Z,MENU_4
C910 OR $06
MENU_4 C912 LD (CONTROL),A the new method
C915 LD HL,KEY_LATCH key 5 not held: clear its latch (at the end)
C918 BIT 4,E
C91A JR Z,MENU_KEY5_RELEASED
C91C BIT 0,(HL) still held since the last pass: nothing
C91E JR NZ,MENU_TUNE_IF_CHANGED
C920 SET 0,(HL) a new press: latch it, and toggle directional control
C922 LD A,(CONTROL)
C925 XOR $08
C927 LD (CONTROL),A
MENU_TUNE_IF_CHANGED C92A LD HL,LAST_CONTROL A is the new CONTROL whichever way this is reached: the tune if it has changed
C92D CP (HL)
C92E LD DE,TUNE_CONTROL_CHOSEN
C931 CALL NZ,PLAY_TUNE
C934 LD A,$EF key 0 (bit 0 of the 6-0 half-row): start the game
C936 CALL READ_KEYS
C939 BIT 0,A
C93B RET NZ
C93C CALL NEXT_TURN the turn counter on, and the random number stirred
C93F CALL FLASH_MENU flash the choice; round again
C942 JP MENU_LOOP
MENU_KEY5_RELEASED C945 RES 0,(HL) key 5 is up: clear the latch
C947 JR MENU_TUNE_IF_CHANGED
Prev: C8B2 Up: Map Next: C949