Prev: B09C Up: Map Next: B16F
B115: Read Controls
Used by the routine at UpdateShipSpeeds.
Reads the controls and keeps what is pressed at Controls (bit 0 is right, bit 1 is left, bit 3 is up, bit 4 is fire and bit 5 is the extra key). Up is ignored in one place near the start of the planet, and only fire and the extra key are used while the special shot is out. Moving uses fuel, which is worked out here and taken off by UseFuel: more for going up and sideways together, and half as much if part 06 is fitted or the value at Variables is not zero.
ReadControls B115 CALL ReadInputDevice Call ReadInputDevice.
B118 LD B,$00 Clear B.
B11A LD A,($F5F2) The fifth part flag.
B11D AND A Jump to ReadControls_Zone if A is not zero.
B11E JR NZ,ReadControls_Zone
B120 LD B,$05 B=05.
ReadControls_Zone B122 LD A,($CE58) The map row.
B125 CP B Jump to ReadControls_Special if A is not B.
B126 JR NZ,ReadControls_Special
B128 LD A,($CE46) The position down.
B12B CP $60 Jump to ReadControls_Special if A is 60 or more.
B12D JR NC,ReadControls_Special
B12F LD A,C A=C.
B130 AND %11110111 Keep the bits of A that are set in F7.
B132 LD C,A C=A.
ReadControls_Special B133 LD A,($B832) The special-shot flag.
B136 AND A Jump to ReadControls_Store if A is zero.
B137 JR Z,ReadControls_Store
B139 LD A,C A=C.
B13A AND %00110000 Keep the bits of A that are set in 30.
B13C LD C,A C=A.
ReadControls_Store B13D LD A,($96AB) The crystal-delivery flag.
B140 AND A Return if A is not zero.
B141 RET NZ
B142 LD A,C A=C.
B143 LD ($5C37),A Update the controls.
B146 AND %00001011 Keep the bits of A that are set in 0B.
B148 RET Z Return if the zero flag is set.
B149 LD DE,$0008 DE=08.
B14C BIT 3,A Jump to ReadControls_Part if bit 3 of A is clear.
B14E JR Z,ReadControls_Part
B150 AND %00000011 Keep the bits of A that are set in 03.
B152 JR Z,ReadControls_Part Jump to ReadControls_Part if the zero flag is set.
B154 LD DE,$0010 DE=10.
ReadControls_Part B157 LD A,($F5F3) The sixth part, which halves the fuel.
B15A AND A Jump to ReadControls_Use if A is zero.
B15B JR Z,ReadControls_Use
B15D SRA D Shift D right keeping the sign.
B15F RR E Rotate E right through the carry.
ReadControls_Use B161 LD A,($5C40) The ship was just hit.
B164 AND A Jump to UseFuel if A is zero.
B165 JP Z,UseFuel
B168 SRA D Shift D right keeping the sign.
B16A RR E Rotate E right through the carry.
B16C JP UseFuel Jump to UseFuel.
Prev: B09C Up: Map Next: B16F