![]() |
Routines |
| Prev: 59736 | Up: Map | Next: 59869 |
|
|
||||
|
This routine calculates the vertical direction and speed of the servant/spell cursor icon, and adds/subtracts it from the sprite's vertical pixel position.
|
||||
| 59783 | LD A,(60162) | Get sprite vertical movement speed | ||
| 59786 | LD C,A | |||
| 59787 | LD A,(60158) | Get up/down sprite control value (determine whether the sprite is moving and in which direction) | ||
| 59790 | CALL 57276 | Calculate the new sprite speed/position offset based on direction/speed (returned in H register) | ||
| 59793 | LD A,H | Retrieve calculated offset from H register... | ||
| 59794 | LD (60162),A | ...and store | ||
| 59797 | LD A,(60159) | Get the sprite's current vertical screen position | ||
| 59800 | LD C,A | Temp store in C register | ||
| 59801 | ADD A,H | Add (or subtract) the offset calculated earlier | ||
|
Check top of playing area boundary
|
||||
| 59802 | CP 224 | If new position is < 8 or a negative value, upwards movement will have taken the graphic past the top border of the playing area | ||
| 59804 | JR NC,59810 | |||
| 59806 | CP 8 | |||
| 59808 | JR NC,59817 | |||
| 59810 | LD A,0 | ...If so, reset movement speed to zero... | ||
| 59812 | LD (60162),A | |||
| 59815 | LD A,8 | ...And vertical pixel position to 8, two pixels below the top of the playing area (top of playing area is zero, but the servant and cursor icon both have a -6 vertical pixel offset). | ||
| 59817 | LD (60159),A | Store the new (or reset) vertical pixel position | ||
|
Check bottom of playing area boundary
|
||||
| 59820 | CP 120 | Check if vertical sprite position is greater than 120 pixels from top of playing area | ||
| 59822 | JR C,59829 | |||
| 59824 | LD A,0 | If so, set vertical movement speed to zero. HTML[<br/>]No further action is required at this point because the spell will be cancelled in the following routine. | ||
| 59826 | LD (60162),A | |||
| 59829 | LD A,0 | |||
| 59831 | LD (60116),A | High byte of screen position (0 = current viewport, no offset) | ||
|
Erase the graphic at the old position and draw it at its new one
|
||||
| 59834 | LD (60111),A | ...Set draw/erase flag to ERASE | ||
| 59837 | LD HL,(60564) | Get the graphic address pointer ready to ERASE the graphic | ||
| 59840 | CALL 56216 | Run screen boundary checks and erase the servant/icon graphic | ||
| 59843 | LD A,(60160) | Copy the (new) horizontal pixel position into store | ||
| 59846 | LD (60115),A | |||
| 59849 | LD A,(60159) | ...and also the vertical pixel position | ||
| 59852 | LD (60114),A | |||
| 59855 | LD A,1 | Set draw/erase flag to DRAW | ||
| 59857 | LD (60111),A | |||
| 59860 | LD HL,(60241) | Copy graphic address pointer to (table at 38851) into store | ||
| 59863 | LD (60564),HL | |||
| 59866 | CALL 56216 | Run screen boundary checks and draw the servant/icon graphic in its new position | ||
| Prev: 59736 | Up: Map | Next: 59869 |