Prev: E929 Up: Map Next: E987
E958: Calculate change to servant/cursor icon horizontal screen position
eye cursor icon servant graphic
This routine calculates the horizontal direction and speed of the servant/spell cursor icon, and adds/subtracts it from the sprite's horizontal pixel position.
E958 LD A,($EB01) Get sprite horizontal movement speed
E95B LD C,A
E95C LD A,($EAFD) Get left/right sprite control value (determine whether the sprite is moving and in which direction)
E95F CALL $DFBC Calculate the new sprite speed/position offset based on direction/speed (returned in H register)
E962 LD A,H Retrieve calculated offset from H register...
E963 LD ($EB01),A ...and store
E966 LD A,($EB00) Get the sprite's current horizontal screen position
E969 ADD A,H Add (or subtract) the offset calculated earlier
E96A LD C,A Temporary store in C register
E96B SUB $0C The left and right play area limits are 12 and 228 respectively. This check forces a NC continue to the following routine (after the JR C) if the movement takes the servant/cursor position beyond the left hand side of the play area (< 12) or past the right hand side (> 228).
E96D CP $D8
E96F JR C,$E983 If the servant/cursor is still within screen limits, skip the next few instructions.
Servant/cursor position is at the left or right border or the screen.
E971 LD A,$00 Set movement speed to zero to stop dead
E973 LD ($EB01),A
E976 LD A,($EB00) Get horizontal pixel position
E979 CP $80 Check which half of the screen it is
E97B JR C,$E981
E97D LD C,$E4 If right hand side, set horizontal pixel position to 228
E97F JR $E983
E981 LD C,$0C If left hand side, set horizontal pixel position to 12
Store adjusted horizontal pixel position:
E983 LD A,C Get calculated horizontal pixel position
E984 LD ($EB00),A ...and store
Prev: E929 Up: Map Next: E987