Prev: 45620 Up: Map Next: 45842
45781: Update Vertical Scroll Speed
Used by the routines at BounceVertically and CheckTerrainCollision.
Adds the vertical speed of the ship to the fraction in VerticalScrollFraction and works out how many whole pixels of vertical scroll that makes, limited to the value at VerticalLimit and stores it in VerticalSpeed. Halved if the speed is at its limit and bit 1 of VerticalOffset is set.
UpdateVerticalScrollSpeed 45781 LD DE,(45856) Fetch the word at VerticalScrollFraction into DE.
45785 ADD HL,DE HL gains DE.
45786 LD (45856),HL Update the vertical scroll fraction.
45789 LD A,H A=H.
45790 SUB D Subtract D from A.
45791 ADD A,A Double A.
45792 LD H,A H=A.
45793 BIT 7,A Jump to UpdateVerticalScrollSpeed_Up if bit 7 of A is set.
45795 JR NZ,UpdateVerticalScrollSpeed_Up
45797 LD A,(23615) The vertical scroll limit.
45800 ADD A,2 Add 2 to A.
45802 CP H Compare A with H.
45803 LD A,H A=H.
45804 JR NZ,UpdateVerticalScrollSpeed_Store Jump to UpdateVerticalScrollSpeed_Store if the zero flag is clear.
45806 LD A,(23615) The vertical scroll limit.
45809 JR UpdateVerticalScrollSpeed_Store Jump to UpdateVerticalScrollSpeed_Store.
UpdateVerticalScrollSpeed_Up 45811 CP 250 Jump to UpdateVerticalScrollSpeed_Store if A is not 250.
45813 JR NZ,UpdateVerticalScrollSpeed_Store
45815 LD A,252 A=252.
UpdateVerticalScrollSpeed_Store 45817 LD (52410),A Update the vertical scroll speed.
45820 CP 4 Jump to UpdateVerticalScrollSpeed_Halve if A is 4.
45822 JR Z,UpdateVerticalScrollSpeed_Halve
45824 CP 252 Return if A is not 252.
45826 RET NZ
UpdateVerticalScrollSpeed_Halve 45827 LD A,(52802) The vertical offset.
45830 AND %00000010 Keep the bits of A that are set in 2.
45832 RET Z Return if the zero flag is set.
45833 LD A,(52410) The vertical scroll speed.
45836 SRA A Shift A right keeping the sign.
45838 LD (52410),A Update the vertical scroll speed.
45841 RET Return.
Prev: 45620 Up: Map Next: 45842