Prev: C861 Up: Map Next: C8D9
C873: Scroll View Up
Used by the routine at ScrollView.
Scrolls the view up by eight rows when the player has moved towards the bottom of the view. The rows of the screen buffer are moved up with MoveRowsUp, the new rows at the bottom are cleared with ClearRows, the view is moved with MoveView and the objects that have come into view are drawn using DrawBottomStrip.
Input
IX The player entity
Check whether the player is near enough to the bottom of the view for the view to scroll up. If it is not, and the view is not part way through a scroll, stop scrolling.
ScrollViewUp C873 LD A,($5CE9) Fetch the scroll position, which is 10 when the view is at rest and keep it in C.
C876 LD C,A
C877 LD A,(IX+$0F) Fetch the row of the player on the screen and keep it in D.
C87A LD D,A
C87B CP $61 Jump to ScrollViewUp_Speed if the player is near the bottom of the view.
C87D JR NC,ScrollViewUp_Speed
C87F LD A,C Fetch the scroll position.
C880 LD L,$3F Set the bits of the view flags to keep, to clear the scroll bits.
C882 CP $10 Jump to UpdateViewFlags to clear the scroll bits of the view flags if the view is at rest.
C884 JP Z,UpdateViewFlags
Work out how fast to scroll from the change in the row of the player on the screen. If the player is moving down then the view scrolls up faster.
ScrollViewUp_Speed C887 LD A,($5CE6) Fetch the view flags.
C88A AND %00111111 Clear bits 6-7.
C88C LD L,A Keep them in L.
C88D LD A,($5CED) Fetch the change in the row of the player.
C890 ADD A,A Double it.
C891 JR Z,ScrollViewUp_Slowest Jump to ScrollViewUp_Slowest if the player is not moving.
C893 JR C,ScrollViewUp_Slowest Jump to ScrollViewUp_Slowest if the player is moving up.
C895 LD E,A Use the doubled change as the amount to scroll.
C896 LD A,L Set bits 6-7 of the flags.
C897 OR $C0
C899 LD L,A
C89A JR ScrollViewUp_SetFlags Jump to ScrollViewUp_SetFlags.
ScrollViewUp_Slowest C89C LD E,$02 Scroll by the slowest amount, 02.
C89E LD A,L Set bit 6 of the flags.
C89F OR $40
C8A1 LD L,A
ScrollViewUp_SetFlags C8A2 LD A,L Store the view flags.
C8A3 LD ($5CE6),A
C8A6 LD A,E Add the amount to scroll to the scroll position.
C8A7 ADD A,C
C8A8 LD ($5CE9),A Store the scroll position.
C8AB BIT 5,A Test bit 5 of the scroll position.
C8AD RET Z Return if it has not gone past 20 as the view is not ready to move by a whole row of the buffer.
C8AE SUB $10 Take away 10 from the scroll position.
C8B0 LD ($5CE9),A Store it.
Move the view up by eight rows. The player moves up the screen by eight rows, the buffer is moved up, and the eight rows at the bottom are cleared and drawn again.
C8B3 LD A,(IX+$0F) Fetch the row of the player on the screen.
C8B6 SUB $08 Take away 08.
C8B8 LD (IX+$0F),A Store it.
C8BB LD ($5CEC),A Store it as the last row of the player.
C8BE LD DE,$FFF8 Set the distance to move the view origin, FFF8.
C8C1 CALL MoveView Move the view origin.
C8C4 CALL MoveRowsUp Move the rows of the buffer up.
C8C7 LD HL,$F1BB Point HL at the last rows of the buffer.
C8CA CALL ClearRows Clear the eight rows.
C8CD LD HL,$F1A1 Point HL at the last rows of the buffer.
C8D0 LD ($5CBB),HL Store it as the place to draw to.
C8D3 LD HL,$C119 Point HL at the routine that draws the objects in the bottom strip.
C8D6 JP DrawLevelObjects_Second Draw the objects of the level in the strip.
Prev: C861 Up: Map Next: C8D9