Prev: 51432 Up: Map Next: 51608
51517: 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 51517 LD A,(23792) Fetch the scroll position along the view and keep it in C.
51520 LD C,A
51521 LD A,(IX+14) Fetch the column of the player on the screen and keep it in D.
51524 LD D,A
51525 CP 64 Compare it with 64.
51527 LD L,243 Set the bits of the view flags to keep, to clear the scroll bits.
51529 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.
51532 LD E,254 Set the speed to two pixels, negative as the view moves the other way.
51534 LD A,(23782) Fetch the view flags.
51537 AND %00001100 Keep the scroll right bits.
51539 CP 8 Jump to ScrollViewRight_CheckPhase if the view is not already scrolling at two pixels.
51541 JR NZ,ScrollViewRight_CheckPhase
51543 LD A,D Fetch the column of the player.
51544 CP 52 Jump to ScrollViewRight_OnePixel to slow down to one pixel if the player is further across than that.
51546 JR NC,ScrollViewRight_OnePixel
51548 JR ScrollViewRight_Scroll Keep the speed at two pixels.
ScrollViewRight_CheckPhase 51550 LD A,C Fetch the scroll position.
51551 AND %00000011 Keep the low two bits.
51553 JR NZ,ScrollViewRight_OnePixel Slow down to one pixel if it is part way through a pixel step.
51555 LD A,D Fetch the column of the player.
51556 CP 41 Jump to ScrollViewRight_Scroll to keep the speed at two pixels if the player is that far across.
51558 JR C,ScrollViewRight_Scroll
ScrollViewRight_OnePixel 51560 INC E Slow down to one pixel.
ScrollViewRight_Scroll 51561 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.
51562 LD HL,58811 Point HL at the left of the first row of the buffer.
51565 LD (23739),HL Store it as the place to draw to.
51568 LD HL,49392 Point HL at the routine that draws the objects in the left strip.
51571 LD A,C Fetch the scroll position.
51572 AND %00001111 Keep the low four bits.
51574 CALL Z,DrawLevelObjects Draw the objects of the level in the strip if it is a multiple of sixteen.
51577 POP DE Restore the speed.
Move the view along by the speed and note it in the view flags.
51578 LD D,255 Make the amount to move the origin of the view negative.
51580 CALL AdjustViewOrigin_Signed Move the origin of the view.
51583 LD A,E Fetch the speed.
51584 NEG Make it positive.
51586 SRL A Halve it.
51588 LD E,A Keep it in E.
51589 INC A Add one.
51590 ADD A,A Shift it left twice, to make the scroll right value of the flags.
51591 ADD A,A
51592 LD B,A Copy it into B.
51593 LD A,(23782) Fetch the view flags.
51596 AND %11110011 Clear the scroll right bits.
51598 OR B Set the new scroll right value.
51599 LD (23782),A Store the view flags.
51602 LD HL,51608 Point HL at the table of routines that shift the buffer to the right.
51605 JP JumpViaTable_Index Shift the buffer.
Prev: 51432 Up: Map Next: 51608