Prev: C8D9 Up: Map Next: C93D
C8E8: Scroll View Left
Used by the routine at ScrollView.
Scrolls the view to the left when the player has moved towards the right of the view. The buffer is shifted with one of the routines in the table at ShiftLeftTable, the view is moved with AdjustViewOrigin and the objects that have come into view are drawn using DrawRightStrip.
Input
IX The player entity
Check whether the player is near enough to the right of the view for the view to scroll to the left. If it is not, stop scrolling.
ScrollViewLeft C8E8 LD A,($5CF0) Fetch the scroll position along the view and keep it in C.
C8EB LD C,A
C8EC LD A,(IX+$0E) Fetch the column of the player on the screen and keep it in D.
C8EF LD D,A
C8F0 CP $68 Compare it with 68.
C8F2 LD L,$FC Set the bits of the view flags to keep, to clear the scroll bits.
C8F4 JP C,UpdateViewFlags Jump to UpdateViewFlags if the player is not near the right 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.
C8F7 LD E,$02 Set the speed to two pixels.
C8F9 LD A,($5CE6) Fetch the view flags.
C8FC AND %00000011 Keep the scroll left bits.
C8FE CP $02 Jump to ScrollViewLeft_CheckPhase if the view is not already scrolling at two pixels.
C900 JR NZ,ScrollViewLeft_CheckPhase
C902 LD A,D Fetch the column of the player.
C903 CP $74 Jump to ScrollViewLeft_OnePixel to slow down to one pixel if the player is not as far across as that.
C905 JR C,ScrollViewLeft_OnePixel
C907 JR ScrollViewLeft_Scroll Keep the speed at two pixels.
ScrollViewLeft_CheckPhase C909 LD A,C Fetch the scroll position.
C90A AND %00000011 Keep the low two bits.
C90C JR NZ,ScrollViewLeft_OnePixel Slow down to one pixel if it is part way through a pixel step.
C90E LD A,D Fetch the column of the player.
C90F CP $80 Jump to ScrollViewLeft_Scroll to keep the speed at two pixels if the player is that far across.
C911 JR NC,ScrollViewLeft_Scroll
ScrollViewLeft_OnePixel C913 DEC E Slow down to one pixel.
ScrollViewLeft_Scroll C914 PUSH DE Save the speed.
When the view has scrolled by another sixteen pixels, draw the objects that have come into view along the right edge of the buffer.
C915 LD HL,$E5D1 Point HL at the right of the first row of the buffer.
C918 LD ($5CBB),HL Store it as the place to draw to.
C91B LD HL,$C0E1 Point HL at the routine that draws the objects in the right strip.
C91E LD A,C Fetch the scroll position.
C91F AND %00001111 Keep the low four bits.
C921 CALL Z,DrawLevelObjects Draw the objects of the level in the strip if it is a multiple of sixteen.
C924 POP DE Restore the speed.
Move the view along by the speed and note it in the view flags.
C925 CALL AdjustViewOrigin Move the origin of the view.
C928 LD A,E Fetch the speed.
C929 SRL A Halve it.
C92B LD E,A Keep it in E.
C92C INC A Add one, to make the scroll left value of the flags.
C92D LD B,A Copy it into B.
C92E LD A,($5CE6) Fetch the view flags.
C931 AND %11111100 Clear the scroll left bits.
C933 OR B Set the new scroll left value.
C934 LD ($5CE6),A Store the view flags.
C937 LD HL,$C9C3 Point HL at the table of routines that shift the buffer to the left.
C93A JP JumpViaTable_Index Shift the buffer.
Prev: C8D9 Up: Map Next: C93D