Prev: EC69 Up: Map Next: ECD0
EC7B: Move Sam from the midstride or mid-action position and scroll the screen if necessary
Called from the main loop at F02B, and also used by the routines at 75C2 and F308.
EC7B CALL $EC69 Make a sound effect
EC7E LD H,$E6 0xE6=Sam
EC80 CALL $EC5A Move Sam from the midstride or mid-action position and update the SRB
This entry point is used by the routines at 64BD, 7AF4 and FB52.
EC83 LD DE,$7FFE 7FFE holds X, the x-coordinate of the leftmost column of the play area on screen
EC86 LD L,$01 Point HL at byte 0x01 of Sam's buffer
EC88 LD A,(DE) A=X
EC89 SUB (HL) Subtract Sam's x-coordinate
EC8A JR Z,$EC90 Jump if they are equal
EC8C CP $F7 Is Sam's x-coordinate >= X+10?
EC8E JR C,$EC9C Jump if so (no need to scroll right)
EC90 LD A,(DE) A=X
EC91 AND A Is X=0?
EC92 JR Z,$ECAB Jump if so (no need to scroll right)
EC94 CALL $EA80 Update the display
EC97 CALL $F18E Cycle a character buffer group forwards and scroll the screen right
EC9A JR $ECAB
EC9C CP $EB Is Sam's x-coordinate <= X+21?
EC9E JR NC,$ECAB Jump if so (no need to scroll left)
ECA0 LD A,(DE) A=X
ECA1 CP $E0 Is X=224?
ECA3 JR Z,$ECAB Jump if so (no need to scroll left)
ECA5 CALL $EA80 Update the display
ECA8 CALL $F1BA Cycle a character buffer group backwards and scroll the screen left
Now that any required horizontal scrolling has been done, it's time to check whether any vertical scrolling is required.
ECAB LD DE,$7FFF 7FFF holds Y, the y-coordinate of the topmost row of the play area on screen
ECAE LD HL,$E602 Point HL at byte 0x02 of Sam's buffer
ECB1 LD A,(DE) A=Y-3
ECB2 SUB $03
ECB4 SUB (HL) Subtract Sam's y-coordinate
ECB5 CP $FC Is Sam's y-coordinate >= Y+2?
ECB7 JR C,$ECC3 Jump if so (no need to scroll down)
ECB9 LD A,(DE) A=Y
ECBA CP $02 Is Y=2?
ECBC RET Z Return if so (no need to scroll down)
ECBD CALL $EA80 Update the display
ECC0 JP $E8B7 Scroll the screen down
ECC3 CP $F0 Is Sam's y-coordinate <= Y+13?
ECC5 RET NC Return if so (no need to scroll up)
ECC6 LD A,(DE) A=Y
ECC7 CP $14 Is Y=20?
ECC9 RET Z Return if so (no need to scroll up)
ECCA CALL $EA80 Update the display
ECCD JP $E87C Scroll the screen up
Prev: EC69 Up: Map Next: ECD0