Prev: C8E8 Up: Map Next: C998
C93D: Scroll View Right
Used by the routine at ScrollView.
Scrolls the view to the right when the player has moved towards the left of the view. The buffer is shifted with one of the routines in the table at ShiftRightTable, the view is moved with AdjustViewOrigin_Signed and the objects that have come into view are drawn using DrawLeftStrip.
Input
IX The player entity
Check whether the player is near enough to the left of the view for the view to scroll to the right. If it is not, stop scrolling.
ScrollViewRight C93D LD A,($5CF0) Fetch the scroll position along the view and keep it in C.
C940 LD C,A
C941 LD A,(IX+$0E) Fetch the column of the player on the screen and keep it in D.
C944 LD D,A
C945 CP $40 Compare it with 40.
C947 LD L,$F3 Set the bits of the view flags to keep, to clear the scroll bits.
C949 JP NC,UpdateViewFlags Jump to UpdateViewFlags if the player is not near the left of the view.
Choose the speed to scroll at, which is two pixels a frame when the player is near the edge of the view and one pixel a frame otherwise.
C94C LD E,$FE Set the speed to two pixels, negative as the view moves the other way.
C94E LD A,($5CE6) Fetch the view flags.
C951 AND %00001100 Keep the scroll right bits.
C953 CP $08 Jump to ScrollViewRight_CheckPhase if the view is not already scrolling at two pixels.
C955 JR NZ,ScrollViewRight_CheckPhase
C957 LD A,D Fetch the column of the player.
C958 CP $34 Jump to ScrollViewRight_OnePixel to slow down to one pixel if the player is further across than that.
C95A JR NC,ScrollViewRight_OnePixel
C95C JR ScrollViewRight_Scroll Keep the speed at two pixels.
ScrollViewRight_CheckPhase C95E LD A,C Fetch the scroll position.
C95F AND %00000011 Keep the low two bits.
C961 JR NZ,ScrollViewRight_OnePixel Slow down to one pixel if it is part way through a pixel step.
C963 LD A,D Fetch the column of the player.
C964 CP $29 Jump to ScrollViewRight_Scroll to keep the speed at two pixels if the player is that far across.
C966 JR C,ScrollViewRight_Scroll
ScrollViewRight_OnePixel C968 INC E Slow down to one pixel.
ScrollViewRight_Scroll C969 PUSH DE Save the speed.
When the view has scrolled by another sixteen pixels, draw the objects that have come into view along the left edge of the buffer.
C96A LD HL,$E5BB Point HL at the left of the first row of the buffer.
C96D LD ($5CBB),HL Store it as the place to draw to.
C970 LD HL,$C0F0 Point HL at the routine that draws the objects in the left strip.
C973 LD A,C Fetch the scroll position.
C974 AND %00001111 Keep the low four bits.
C976 CALL Z,DrawLevelObjects Draw the objects of the level in the strip if it is a multiple of sixteen.
C979 POP DE Restore the speed.
Move the view along by the speed and note it in the view flags.
C97A LD D,$FF Make the amount to move the origin of the view negative.
C97C CALL AdjustViewOrigin_Signed Move the origin of the view.
C97F LD A,E Fetch the speed.
C980 NEG Make it positive.
C982 SRL A Halve it.
C984 LD E,A Keep it in E.
C985 INC A Add one.
C986 ADD A,A Shift it left twice, to make the scroll right value of the flags.
C987 ADD A,A
C988 LD B,A Copy it into B.
C989 LD A,($5CE6) Fetch the view flags.
C98C AND %11110011 Clear the scroll right bits.
C98E OR B Set the new scroll right value.
C98F LD ($5CE6),A Store the view flags.
C992 LD HL,$C998 Point HL at the table of routines that shift the buffer to the right.
C995 JP JumpViaTable_Index Shift the buffer.
Prev: C8E8 Up: Map Next: C998