Prev: B234 Up: Map Next: B312
B2D5: 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 B2D5 LD DE,($B320) Fetch the word at VerticalScrollFraction into DE.
B2D9 ADD HL,DE HL gains DE.
B2DA LD ($B320),HL Update the vertical scroll fraction.
B2DD LD A,H A=H.
B2DE SUB D Subtract D from A.
B2DF ADD A,A Double A.
B2E0 LD H,A H=A.
B2E1 BIT 7,A Jump to UpdateVerticalScrollSpeed_Up if bit 7 of A is set.
B2E3 JR NZ,UpdateVerticalScrollSpeed_Up
B2E5 LD A,($5C3F) The vertical scroll limit.
B2E8 ADD A,$02 Add 02 to A.
B2EA CP H Compare A with H.
B2EB LD A,H A=H.
B2EC JR NZ,UpdateVerticalScrollSpeed_Store Jump to UpdateVerticalScrollSpeed_Store if the zero flag is clear.
B2EE LD A,($5C3F) The vertical scroll limit.
B2F1 JR UpdateVerticalScrollSpeed_Store Jump to UpdateVerticalScrollSpeed_Store.
UpdateVerticalScrollSpeed_Up B2F3 CP $FA Jump to UpdateVerticalScrollSpeed_Store if A is not FA.
B2F5 JR NZ,UpdateVerticalScrollSpeed_Store
B2F7 LD A,$FC A=FC.
UpdateVerticalScrollSpeed_Store B2F9 LD ($CCBA),A Update the vertical scroll speed.
B2FC CP $04 Jump to UpdateVerticalScrollSpeed_Halve if A is 04.
B2FE JR Z,UpdateVerticalScrollSpeed_Halve
B300 CP $FC Return if A is not FC.
B302 RET NZ
UpdateVerticalScrollSpeed_Halve B303 LD A,($CE42) The vertical offset.
B306 AND %00000010 Keep the bits of A that are set in 02.
B308 RET Z Return if the zero flag is set.
B309 LD A,($CCBA) The vertical scroll speed.
B30C SRA A Shift A right keeping the sign.
B30E LD ($CCBA),A Update the vertical scroll speed.
B311 RET Return.
Prev: B234 Up: Map Next: B312