Prev: B115 Up: Map Next: B234
B16F: Read the current player's control method
Used by the routine at read_controls.
By the method in the current player's record (control_method): 0 keyboard, 1 Kempston, 2 cursor keys, 3 Interface II. Every method gives C in the Kempston layout -- bit 0 right, 1 left, 2 down, 3 up (thrust), 4 fire -- plus bit 5, the special key, which fires the special beam (special_beam_key). On the keyboard the special key is the number row; with a joystick it is any letter key but CAPS SHIFT and SPACE (read_keyboard masks the five keys of each half-row).
The keyboard: right is X, V, N or SYMBOL SHIFT, left Z, C, B or M -- alternate keys along the bottom row -- thrust any key on the middle letter row, fire any on the top letter row. Down is never set from the keyboard. Every read goes through OUT ($FD),A first (read_keyboard).
Output
C the controls
read_control_method B16F LD A,(control_method) by the method
B172 AND A
B173 JP Z,read_control_method_3
B176 CP $01
B178 JR Z,read_control_method_0
B17A CP $02
B17C JR Z,read_control_method_2
B17E JR read_control_method_1
read_control_method_0 B180 IN A,($1F) Kempston: the port is already in this layout
B182 AND $1F
B184 LD C,A
B185 JP read_control_method_9
read_control_method_1 B188 LD A,$EF Interface II, keys 6-0 on half-row $EF: 0 fire, 9 up, 8 down, 7 right, 6 left, rotated into place a bit at a time and inverted
B18A OUT ($FD),A
B18C IN A,($FE)
B18E LD B,$FF
B190 RRA
B191 RL B
B193 RRA
B194 RL B
B196 RRA
B197 RL B
B199 RRA
B19A RRA
B19B RL B
B19D RLA
B19E RL B
B1A0 LD A,B
B1A1 CPL
B1A2 LD C,A
B1A3 JP read_control_method_9
read_control_method_2 B1A6 LD A,$EF cursor keys: 7 up, 8 right, 6 down and 0 fire from half-row $EF, 5 left from half-row $F7; bits 6 and 7 come out set
B1A8 OUT ($FD),A
B1AA IN A,($FE)
B1AC OR $E0
B1AE LD B,A
B1AF AND $08
B1B1 LD C,A
B1B2 LD A,B
B1B3 RRCA
B1B4 RRCA
B1B5 LD B,A
B1B6 AND $05
B1B8 OR C
B1B9 LD C,A
B1BA LD A,B
B1BB RRA
B1BC RRA
B1BD AND $10
B1BF OR C
B1C0 LD C,A
B1C1 LD A,$F7
B1C3 OUT ($FD),A
B1C5 IN A,($FE)
B1C7 RRA
B1C8 RRA
B1C9 RRA
B1CA AND $02
B1CC OR C
B1CD CPL
B1CE LD C,A
B1CF JP read_control_method_9
read_control_method_3 B1D2 XOR A keyboard: X or V (half-row $FE), N or SYMBOL SHIFT ($7F): right
B1D3 LD C,A
B1D4 LD A,$FE
B1D6 OUT ($FD),A
B1D8 IN A,($FE)
B1DA AND $14
B1DC LD B,A
B1DD LD A,$7F
B1DF OUT ($FD),A
B1E1 IN A,($FE)
B1E3 AND $0A
B1E5 OR B
B1E6 XOR $1E
B1E8 JR Z,read_control_method_4
B1EA LD A,C
B1EB OR $01
B1ED LD C,A
B1EE JR read_control_method_5
read_control_method_4 B1F0 LD A,$FE Z or C, B or M: left
B1F2 OUT ($FD),A
B1F4 IN A,($FE)
B1F6 AND $0A
B1F8 LD B,A
B1F9 LD A,$7F
B1FB OUT ($FD),A
B1FD IN A,($FE)
B1FF AND $14
B201 OR B
B202 XOR $1E
B204 JR Z,read_control_method_5
B206 SET 1,C
read_control_method_5 B208 LD A,$BD any key of A-G or H-ENTER: thrust
B20A CALL read_keyboard
B20D JR Z,read_control_method_6
B20F SET 3,C
read_control_method_6 B211 LD A,$DB any of Q-T or Y-P: fire
B213 CALL read_keyboard
B216 JR Z,read_control_method_7
B218 SET 4,C
read_control_method_7 B21A LD A,$E7 any of 1-5 or 6-0: the special key
B21C LD B,$00
read_control_method_8 B21E CALL read_keyboard
B221 OR B
B222 RET Z
B223 SET 5,C
B225 RET
read_control_method_9 B226 RES 5,C joysticks: Z-V or B-SYMBOL SHIFT (not CAPS SHIFT or SPACE), or any of the other letter rows: the special key
B228 LD A,$7E
B22A CALL read_keyboard
B22D AND $1E
B22F LD B,A
B230 LD A,$99
B232 JR read_control_method_8
Prev: B115 Up: Map Next: B234