Prev: 80A1 Up: Map Next: 80FD
80C1: Menu 1: Highlight/store selected control option (1-4)
Used by the routine at 80A1.
Input
HL Address pointer for the relevant port address at 8BB2 relating to the key that's been pressed.
The player has picked a valid controls option on menu 1 (8039). Store the choice number (1-4), play a high pitched sound and highlight their choice on screen.
80C1 INC HL Advance to the second byte of the pair (to give the number)
80C2 LD A,(HL) Identify key pressed (1-4)
80C3 LD ($8BAA),A ...and store it
Play a high pitched sound (and also set the border to black)
80C6 LD C,$FF C register contains the outer loop counter for the sound duration
80C8 LD HL,$3333 H = 51, L = 51 - but also used as a token address pointer somewhere in ROM
Outer loop start - toggle speaker on and pause briefly
80CB LD B,$10 Pause duration
80CD LD A,$10 Set bit 4 - speaker bit
80CF OUT ($FE),A Output it (speaker toggle = on)
80D1 DJNZ $80D1 Short pause
The following instructions make a few changes to the value held in the A register, which is then used in the next short pause loop at 80E0.
80D3 LD H,(HL)
80D4 ADD A,H
80D5 ADD A,L
80D6 AND $0F
80D8 ADD A,$60
80DA ADD A,B
Toggle speaker off and pause briefly
80DB LD B,A Transfer to the B register to be used as a pause timer
80DC LD A,$00 Reset the A register (reset speaker bit)
80DE OUT ($FE),A Output it (speaker toggle = off)
80E0 DJNZ $80E0 Another short pause
80E2 DEC C Decrement the outer loop counter
80E3 JR NZ,$80CB ...and repeat until zero.
Highlight/flash the menu option selected
80E5 LD A,($8BAA) Get the menu option selected (1-4)
80E8 LD HL,$58A1 Screen attribute display position for first option (Kempston)
80EB LD DE,$0040 64 characters = 2 lines to jump down to next option
80EE LD B,$04 Four menu options to check (1-4)
80F0 LD C,$01 Start with 1
80F2 LD (HL),$0F Reset colour/attribute for this option (INK 7, PAPER 1)
80F4 CP C Is it this option that's selected?
80F5 JR NZ,$80F9
80F7 LD (HL),$CF ...If so, set attribute to FLASH 1, BRIGHT 1
80F9 ADD HL,DE Move attribute screen address down two lines to next option
80FA INC C Increment...
80FB DJNZ $80F2 ...and check for 2, 3 and then 4 in the same way
Prev: 80A1 Up: Map Next: 80FD