Prev: 45212 Up: Map Next: 45423
45333: 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 6 is fitted or the value at Variables is not zero.
ReadControls 45333 CALL ReadInputDevice Call ReadInputDevice.
45336 LD B,0 Clear B.
45338 LD A,(62962) The fifth part flag.
45341 AND A Jump to ReadControls_Zone if A is not zero.
45342 JR NZ,ReadControls_Zone
45344 LD B,5 B=5.
ReadControls_Zone 45346 LD A,(52824) The map row.
45349 CP B Jump to ReadControls_Special if A is not B.
45350 JR NZ,ReadControls_Special
45352 LD A,(52806) The position down.
45355 CP 96 Jump to ReadControls_Special if A is 96 or more.
45357 JR NC,ReadControls_Special
45359 LD A,C A=C.
45360 AND %11110111 Keep the bits of A that are set in 247.
45362 LD C,A C=A.
ReadControls_Special 45363 LD A,(47154) The special-shot flag.
45366 AND A Jump to ReadControls_Store if A is zero.
45367 JR Z,ReadControls_Store
45369 LD A,C A=C.
45370 AND %00110000 Keep the bits of A that are set in 48.
45372 LD C,A C=A.
ReadControls_Store 45373 LD A,(38571) The crystal-delivery flag.
45376 AND A Return if A is not zero.
45377 RET NZ
45378 LD A,C A=C.
45379 LD (23607),A Update the controls.
45382 AND %00001011 Keep the bits of A that are set in 11.
45384 RET Z Return if the zero flag is set.
45385 LD DE,8 DE=8.
45388 BIT 3,A Jump to ReadControls_Part if bit 3 of A is clear.
45390 JR Z,ReadControls_Part
45392 AND %00000011 Keep the bits of A that are set in 3.
45394 JR Z,ReadControls_Part Jump to ReadControls_Part if the zero flag is set.
45396 LD DE,16 DE=16.
ReadControls_Part 45399 LD A,(62963) The sixth part, which halves the fuel.
45402 AND A Jump to ReadControls_Use if A is zero.
45403 JR Z,ReadControls_Use
45405 SRA D Shift D right keeping the sign.
45407 RR E Rotate E right through the carry.
ReadControls_Use 45409 LD A,(23616) The ship was just hit.
45412 AND A Jump to UseFuel if A is zero.
45413 JP Z,UseFuel
45416 SRA D Shift D right keeping the sign.
45418 RR E Rotate E right through the carry.
45420 JP UseFuel Jump to UseFuel.
Prev: 45212 Up: Map Next: 45423