![]() |
Routines |
| Prev: 28177 | Up: Map | Next: 28328 |
|
Used by the routine at HandleHitActor.
Moves an actor which has been hit by a flour shot (see TestFlourCollision). The actor moves by the speeds in bytes 4 and 5 which were taken from the flour shot. Byte 7 of the actor is a counter which was set to 64; each time this is called it is decreased, and when it reaches zero the actor recovers (see RecoverHitActor). The speed is changed to 4 (or 252) when the actor reaches the left (or right) edge of the play area or the top of it, and if the other speed is zero it is changed to a random one. When the actor reaches the bottom of the play area then LandHitActor deals with it.
Two bits of byte 6 of the actor are changed; bit 1 is set if the actor is less than 52 pixels from the middle of the screen (104), and bit 7 is set if the actor is moving towards the middle of the screen (which is when it is in the left half and moving right, or in the right half and moving left).
|
||||||||
| MoveHitActor | 28197 | DEC (IX+7) | Decrease the counter in byte 7 of the actor by one. | |||||
| 28200 | JR Z,RecoverHitActor | Jump to RecoverHitActor if the counter is zero. | ||||||
| 28202 | LD A,(IX+1) | Fetch the horizontal co-ordinate. | ||||||
| 28205 | ADD A,(IX+4) | Add the horizontal speed. | ||||||
| 28208 | CP 4 | Jump to MoveHitActor_LeftEdge if the actor has reached the left edge. | ||||||
| 28210 | JR C,MoveHitActor_LeftEdge | |||||||
| 28212 | CP 196 | Jump to MoveHitActor_RightEdge if the actor has reached the right edge. | ||||||
| 28214 | JR NC,MoveHitActor_RightEdge | |||||||
| 28216 | LD (IX+1),A | Update the horizontal co-ordinate. | ||||||
| MoveHitActor_Vertical | 28219 | LD A,(IX+2) | Fetch the vertical co-ordinate. | |||||
| 28222 | ADD A,(IX+5) | Add the vertical speed. | ||||||
| 28225 | CP 32 | Jump to MoveHitActor_Top if the actor has reached the top. | ||||||
| 28227 | JR C,MoveHitActor_Top | |||||||
| 28229 | CP 160 | Jump to LandHitActor if the actor has reached the bottom. | ||||||
| 28231 | JR NC,LandHitActor | |||||||
| 28233 | LD (IX+2),A | Update the vertical co-ordinate. | ||||||
|
Work out which half of the screen the actor is in, and how far it is from the middle.
|
||||||||
| 28236 | LD A,(IX+1) | Fetch the horizontal co-ordinate. | ||||||
| 28239 | SUB 104 | Subtract 104 (the middle of the screen). | ||||||
| 28241 | JP P,MoveHitActor_RightHalf | Jump to MoveHitActor_RightHalf if the actor is in the right half. | ||||||
| 28244 | SET 7,(IX+6) | Set bit 7 of byte 6 of the actor. | ||||||
| 28248 | NEG | Make the distance positive. | ||||||
| 28250 | JR MoveHitActor_Distance | Jump to MoveHitActor_Distance. | ||||||
| MoveHitActor_RightHalf | 28252 | RES 7,(IX+6) | Reset bit 7 of byte 6 of the actor. | |||||
| MoveHitActor_Distance | 28256 | CP 52 | Jump to MoveHitActor_Far if the actor is 52 pixels or more from the middle. | |||||
| 28258 | JR NC,MoveHitActor_Far | |||||||
| 28260 | SET 1,(IX+6) | Set bit 1 of byte 6 of the actor. | ||||||
| 28264 | JR MoveHitActor_Direction | Jump to MoveHitActor_Direction. | ||||||
| MoveHitActor_Far | 28266 | RES 1,(IX+6) | Reset bit 1 of byte 6 of the actor. | |||||
|
Make bit 7 of byte 6 of the actor show whether the actor is moving towards the middle, by combining it with the direction of the horizontal speed.
|
||||||||
| MoveHitActor_Direction | 28270 | LD A,(IX+4) | Fetch the horizontal speed. | |||||
| 28273 | AND %10000000 | Keep only bit 7. | ||||||
| 28275 | XOR (IX+6) | Combine with byte 6 of the actor. | ||||||
| 28278 | LD (IX+6),A | Update byte 6 of the actor with the result. | ||||||
| 28281 | RET | Return. | ||||||
|
The actor has reached the left edge, so make it move to the right.
|
||||||||
| MoveHitActor_LeftEdge | 28282 | LD (IX+4),4 | Set the horizontal speed to 4 (moving right). | |||||
| MoveHitActor_TestVerticalSpeed | 28286 | LD A,(IX+5) | Fetch the vertical speed. | |||||
| 28289 | AND A | Is the vertical speed zero? | ||||||
| 28290 | JR NZ,MoveHitActor_Vertical | Jump to MoveHitActor_Vertical if it is not. | ||||||
| 28292 | LD A,R | Fetch a random number. | ||||||
| 28294 | AND %00000100 | Keep only bit 2. | ||||||
| 28296 | SUB 2 | Subtract 2 so that the speed is 254 or 2. | ||||||
| 28298 | LD (IX+5),A | Update the vertical speed. | ||||||
| 28301 | JR MoveHitActor_Vertical | Jump to MoveHitActor_Vertical. | ||||||
|
The actor has reached the right edge, so make it move to the left.
|
||||||||
| MoveHitActor_RightEdge | 28303 | LD (IX+4),252 | Set the horizontal speed to 252 (moving left). | |||||
| 28307 | JR MoveHitActor_TestVerticalSpeed | Jump to MoveHitActor_TestVerticalSpeed. | ||||||
|
The actor has reached the top, so make it move down.
|
||||||||
| MoveHitActor_Top | 28309 | LD (IX+5),4 | Set the vertical speed to 4 (moving down). | |||||
|
This entry point is used by the routine at LandHitActor.
|
||||||||
| MoveHitActor_TestHorizontalSpeed | 28313 | LD A,(IX+4) | Fetch the horizontal speed. | |||||
| 28316 | AND A | Is the horizontal speed zero? | ||||||
| 28317 | RET NZ | Return if it is not. | ||||||
| 28318 | LD A,R | Fetch a random number. | ||||||
| 28320 | AND %00000100 | Keep only bit 2. | ||||||
| 28322 | SUB 2 | Subtract 2 so that the speed is 254 or 2. | ||||||
| 28324 | LD (IX+4),A | Update the horizontal speed. | ||||||
| 28327 | RET | Return. | ||||||
| Prev: 28177 | Up: Map | Next: 28328 |