Prev: 51297 Up: Map Next: 51417
51315: 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 51315 LD A,(23785) Fetch the scroll position, which is 16 when the view is at rest and keep it in C.
51318 LD C,A
51319 LD A,(IX+15) Fetch the row of the player on the screen and keep it in D.
51322 LD D,A
51323 CP 97 Jump to ScrollViewUp_Speed if the player is near the bottom of the view.
51325 JR NC,ScrollViewUp_Speed
51327 LD A,C Fetch the scroll position.
51328 LD L,63 Set the bits of the view flags to keep, to clear the scroll bits.
51330 CP 16 Jump to UpdateViewFlags to clear the scroll bits of the view flags if the view is at rest.
51332 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 51335 LD A,(23782) Fetch the view flags.
51338 AND %00111111 Clear bits 6-7.
51340 LD L,A Keep them in L.
51341 LD A,(23789) Fetch the change in the row of the player.
51344 ADD A,A Double it.
51345 JR Z,ScrollViewUp_Slowest Jump to ScrollViewUp_Slowest if the player is not moving.
51347 JR C,ScrollViewUp_Slowest Jump to ScrollViewUp_Slowest if the player is moving up.
51349 LD E,A Use the doubled change as the amount to scroll.
51350 LD A,L Set bits 6-7 of the flags.
51351 OR 192
51353 LD L,A
51354 JR ScrollViewUp_SetFlags Jump to ScrollViewUp_SetFlags.
ScrollViewUp_Slowest 51356 LD E,2 Scroll by the slowest amount, 2.
51358 LD A,L Set bit 6 of the flags.
51359 OR 64
51361 LD L,A
ScrollViewUp_SetFlags 51362 LD A,L Store the view flags.
51363 LD (23782),A
51366 LD A,E Add the amount to scroll to the scroll position.
51367 ADD A,C
51368 LD (23785),A Store the scroll position.
51371 BIT 5,A Test bit 5 of the scroll position.
51373 RET Z Return if it has not gone past 32 as the view is not ready to move by a whole row of the buffer.
51374 SUB 16 Take away 16 from the scroll position.
51376 LD (23785),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.
51379 LD A,(IX+15) Fetch the row of the player on the screen.
51382 SUB 8 Take away 8.
51384 LD (IX+15),A Store it.
51387 LD (23788),A Store it as the last row of the player.
51390 LD DE,65528 Set the distance to move the view origin, 65528.
51393 CALL MoveView Move the view origin.
51396 CALL MoveRowsUp Move the rows of the buffer up.
51399 LD HL,61883 Point HL at the last rows of the buffer.
51402 CALL ClearRows Clear the eight rows.
51405 LD HL,61857 Point HL at the last rows of the buffer.
51408 LD (23739),HL Store it as the place to draw to.
51411 LD HL,49433 Point HL at the routine that draws the objects in the bottom strip.
51414 JP DrawLevelObjects_Second Draw the objects of the level in the strip.
Prev: 51297 Up: Map Next: 51417