Prev: 45423 Up: Map Next: 45781
45620: Update Ship Speeds
Used by the routine at RunFrame.
Reads the controls, then changes the horizontal and vertical speeds of the ship by the amounts in the table at ShipAccelerationTable, depending on what is pressed and on the speed it already has, limits them, and works out the vertical scroll speed in VerticalSpeed with UpdateVerticalScrollSpeed.
Input
IX Address of the ship at ShipObject
UpdateShipSpeeds 45620 CALL ReadControls Call ReadControls.
45623 XOR A Clear A.
45624 LD (23606),A Update the steering direction.
45627 LD DE,(45850) Fetch the word at 45850 into DE.
45631 LD A,(38571) The crystal-delivery flag.
45634 AND A Jump to UpdateShipSpeeds_Drag if A is zero.
45635 JR Z,UpdateShipSpeeds_Drag
45637 LD A,8 A=8.
45639 LD (23607),A Update the controls.
45642 LD A,4 A=4.
45644 LD (23615),A Update the vertical scroll limit.
45647 LD A,(52824) The map row.
45650 AND A Jump to UpdateShipSpeeds_Sideways if A is not zero.
45651 JR NZ,UpdateShipSpeeds_Sideways
45653 LD (52410),A Update the vertical scroll speed.
45656 RET Return.
UpdateShipSpeeds_Drag 45657 LD A,(IX+7) Read offset 7 of IX.
45660 NEG Negate A.
45662 AND A Jump to UpdateShipSpeeds_Sideways if A is zero.
45663 JR Z,UpdateShipSpeeds_Sideways
45665 LD DE,(45854) Fetch the word at 45854 into DE.
45669 BIT 7,A Jump to UpdateShipSpeeds_Sideways if bit 7 of A is set.
45671 JR NZ,UpdateShipSpeeds_Sideways
45673 LD DE,(45852) Fetch the word at 45852 into DE.
UpdateShipSpeeds_Sideways 45677 LD A,(23607) The controls.
45680 BIT 1,A Jump to UpdateShipSpeeds_Right if bit 1 of A is clear.
45682 JR Z,UpdateShipSpeeds_Right
45684 EX DE,HL Swap DE and HL.
45685 LD DE,(45848) Fetch the word at 45848 into DE.
45689 LD A,128 A=128.
45691 LD (23606),A Update the steering direction.
45694 LD A,H A=H.
45695 CP 255 Jump to UpdateShipSpeeds_Vertical if A is 255.
45697 JR Z,UpdateShipSpeeds_Vertical
45699 ADD HL,DE HL gains DE.
45700 EX DE,HL Swap DE and HL.
45701 JR UpdateShipSpeeds_Vertical Jump to UpdateShipSpeeds_Vertical.
UpdateShipSpeeds_Right 45703 BIT 0,A Jump to UpdateShipSpeeds_Vertical if bit 0 of A is clear.
45705 JR Z,UpdateShipSpeeds_Vertical
45707 EX DE,HL Swap DE and HL.
45708 LD DE,(45846) Fetch the word at 45846 into DE.
45712 LD A,3 A=3.
45714 LD (23606),A Update the steering direction.
45717 LD A,H A=H.
45718 AND A Jump to UpdateShipSpeeds_Vertical if A is zero.
45719 JR Z,UpdateShipSpeeds_Vertical
45721 ADD HL,DE HL gains DE.
45722 EX DE,HL Swap DE and HL.
UpdateShipSpeeds_Vertical 45723 LD A,(23616) The ship was just hit.
45726 AND A Jump to UpdateShipSpeeds_Thrust if A is zero.
45727 JR Z,UpdateShipSpeeds_Thrust
45729 LD DE,0 DE=0.
UpdateShipSpeeds_Thrust 45732 CALL UpdateHorizontalSpeed Call UpdateHorizontalSpeed.
45735 LD DE,(45842) Fetch the word at ShipAccelerationTable into DE.
45739 LD A,(23607) The controls.
45742 AND %00001000 Keep the bits of A that are set in 8.
45744 JR Z,UpdateShipSpeeds_Gravity Jump to UpdateShipSpeeds_Gravity if the zero flag is set.
45746 LD DE,(45844) Fetch the word at 45844 into DE.
UpdateShipSpeeds_Gravity 45750 LD H,(IX+27) Read offset 27 of IX into H.
45753 LD L,(IX+28) Read offset 28 of IX into L.
45756 LD A,(47154) The special-shot flag.
45759 AND A Jump to UpdateShipSpeeds_Limit if A is zero.
45760 JR Z,UpdateShipSpeeds_Limit
45762 LD HL,0 HL=0.
45765 LD DE,0 DE=0.
45768 LD (45856),HL Update the vertical scroll fraction.
UpdateShipSpeeds_Limit 45771 ADD HL,DE HL gains DE.
45772 CALL LimitVerticalSpeed Call LimitVerticalSpeed.
45775 LD (IX+27),H Write H to offset 27 of IX.
45778 LD (IX+28),L Write L to offset 28 of IX.
Continue on to UpdateVerticalScrollSpeed.
Prev: 45423 Up: Map Next: 45781