Routines |
Prev: 59689 | Up: Map | Next: 59783 |
|
||||
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.
|
||||
59736 | LD A,(60161) | Get sprite horizontal movement speed | ||
59739 | LD C,A | |||
59740 | LD A,(60157) | Get left/right sprite control value (determine whether the sprite is moving and in which direction) | ||
59743 | CALL 57276 | Calculate the new sprite speed/position offset based on direction/speed (returned in H register) | ||
59746 | LD A,H | Retrieve calculated offset from H register... | ||
59747 | LD (60161),A | ...and store | ||
59750 | LD A,(60160) | Get the sprite's current horizontal screen position | ||
59753 | ADD A,H | Add (or subtract) the offset calculated earlier | ||
59754 | LD C,A | Temporary store in C register | ||
59755 | SUB 12 | 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). | ||
59757 | CP 216 | |||
59759 | JR C,59779 | 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.
|
||||
59761 | LD A,0 | Set movement speed to zero to stop dead | ||
59763 | LD (60161),A | |||
59766 | LD A,(60160) | Get horizontal pixel position | ||
59769 | CP 128 | Check which half of the screen it is | ||
59771 | JR C,59777 | |||
59773 | LD C,228 | If right hand side, set horizontal pixel position to 228 | ||
59775 | JR 59779 | |||
59777 | LD C,12 | If left hand side, set horizontal pixel position to 12 | ||
Store adjusted horizontal pixel position:
|
||||
59779 | LD A,C | Get calculated horizontal pixel position | ||
59780 | LD (60160),A | ...and store |
Prev: 59689 | Up: Map | Next: 59783 |