![]() |
Routines |
| Prev: 37187 | Up: Map | Next: 37428 |
|
Used by the routine at UpdateEnemies.
Checks whether any of the four objects at ShotSlots has hit the object described by the hit data at CollisionBox. If one has, bit 7 of its flags is set and effects are applied to the object that was hit.
|
||||||||||
| CheckShotCollisions | 37244 | LD A,D | Fetch the collision flag. | |||||||
| 37245 | DEC A | Subtract one. | ||||||||
| 37246 | RET M | Return if it was zero. | ||||||||
| 37247 | PUSH IX | Save the address of the object. | ||||||||
| 37249 | LD IX,43940 | Use the hit data at CollisionBox. | ||||||||
| 37253 | LD A,4 | Set the counter for four objects. | ||||||||
| 37255 | LD IY,45946 | Use the first object. | ||||||||
|
This entry point is used by the routine at CheckObjectAgainstShots.
|
||||||||||
| CheckShotCollisions_Loop | 37259 | EX AF,AF' | Save the counter. | |||||||
| 37260 | BIT 7,(IY+22) | Jump to CheckShotCollisions_Position if bit 7 of the second set of flags of the object is set. | ||||||||
| 37264 | JR NZ,CheckShotCollisions_Position | |||||||||
| 37266 | LD L,(IY+11) | Fetch the first value of the object. | ||||||||
| 37269 | LD A,L | Test it. | ||||||||
| 37270 | AND A | Jump to CheckShotCollisions_Next if it is zero. | ||||||||
| 37271 | JR Z,CheckShotCollisions_Next | |||||||||
| 37273 | JR CheckShotCollisions_Offset | Jump to CheckShotCollisions_Offset. | ||||||||
| CheckShotCollisions_Position | 37275 | BIT 7,(IY+16) | Jump to CheckShotCollisions_Next if bit 7 of the flags of the object is clear. | |||||||
| 37279 | JR Z,CheckShotCollisions_Next | |||||||||
| 37281 | LD L,(IY+17) | Fetch the screen position of the object. | ||||||||
| 37284 | LD H,(IY+18) | |||||||||
| 37287 | JR CheckShotCollisions_Range | Jump to CheckShotCollisions_Range. | ||||||||
| CheckShotCollisions_Offset | 37289 | LD H,(IY+12) | Fetch the value from the object. | |||||||
| 37292 | INC H | Add one. | ||||||||
| 37293 | BIT 7,(IY+21) | Jump to CheckShotCollisions_Wide if bit 7 of the third set of flags of the object is set. | ||||||||
| 37297 | JR NZ,CheckShotCollisions_Wide | |||||||||
| CheckShotCollisions_Range | 37299 | LD A,(23582) | Fetch the value from ScratchPair. | |||||||
| 37302 | INC H | Add one to the vertical position. | ||||||||
| 37303 | CP H | Compare it with the vertical position. | ||||||||
| 37304 | JR NC,CheckShotCollisions_Next | Jump to CheckShotCollisions_Next if it is lower. | ||||||||
| 37306 | DEC H | Subtract one again. | ||||||||
| 37307 | LD A,(IX+1) | Fetch the vertical position of the hit data. | ||||||||
| 37310 | ADD A,3 | Add three. | ||||||||
| 37312 | CP H | Compare it with the vertical position. | ||||||||
| 37313 | JR C,CheckShotCollisions_Next | Jump to CheckShotCollisions_Next if it is lower. | ||||||||
| 37315 | LD E,5 | Set the width to five. | ||||||||
| 37317 | JR CheckShotCollisions_Height | Jump to CheckShotCollisions_Height. | ||||||||
| CheckShotCollisions_Wide | 37319 | LD E,8 | Set the width to eight. | |||||||
| CheckShotCollisions_Height | 37321 | LD D,8 | Set the height to eight. | |||||||
| 37323 | BIT 7,(IY+22) | Jump to CheckShotCollisions_Check if bit 7 of the third set of flags of the object is set. | ||||||||
| 37327 | JR NZ,CheckShotCollisions_Check | |||||||||
| 37329 | LD A,(IY+14) | Fetch the value from the object. | ||||||||
| 37332 | ADD A,A | Multiply it by eight. | ||||||||
| 37333 | ADD A,A | |||||||||
| 37334 | ADD A,A | |||||||||
| 37335 | JR Z,CheckShotCollisions_Next | Jump to CheckShotCollisions_Next if it is zero. | ||||||||
| 37337 | LD D,A | Use it as the height. | ||||||||
| CheckShotCollisions_Check | 37338 | CALL TestBoxesOverlap | Check for a collision. | |||||||
| 37341 | LD A,(23580) | Fetch the value from ScratchValue. | ||||||||
| 37344 | AND A | Test it. | ||||||||
| 37345 | JR NZ,CheckShotCollisions_Hit | Jump to CheckShotCollisions_Hit if there has been a collision. | ||||||||
| CheckShotCollisions_Next | 37347 | LD BC,24 | Set the length of an object. | |||||||
| 37350 | ADD IY,BC | Move on to the next object. | ||||||||
| 37352 | EX AF,AF' | Restore the counter. | ||||||||
| 37353 | DEC A | Decrease the counter by one... | ||||||||
| 37354 | JR NZ,CheckShotCollisions_Loop | ...and loop back to CheckShotCollisions_Loop until none remain. | ||||||||
| 37356 | POP IX | Restore the address of the object. | ||||||||
| 37358 | RET | Return. | ||||||||
| CheckShotCollisions_Hit | 37359 | POP IX | Restore the address of the object. | |||||||
| 37361 | BIT 7,(IY+22) | Jump to CheckShotCollisions_Mark if bit 7 of the third set of flags of the shot is clear. | ||||||||
| 37365 | JR Z,CheckShotCollisions_Mark | |||||||||
| 37367 | SET 4,(IY+16) | Set bit 4 of the flags of the shot. | ||||||||
| 37371 | LD A,(IX+0) | Fetch the type of the object that was hit. | ||||||||
| 37374 | CP 25 | Jump to CheckShotCollisions_Mark if it is not 25. | ||||||||
| 37376 | JR NZ,CheckShotCollisions_Mark | |||||||||
| 37378 | INC (IX+22) | Add one to the third state byte of the object. | ||||||||
| 37381 | CALL PlayHitSound | Play the explosion sound. | ||||||||
| 37384 | CALL ScoreDestroyedObject | Score the points for the object. | ||||||||
| CheckShotCollisions_Mark | 37387 | SET 7,(IY+16) | Set bit 7 of the flags of the shot. | |||||||
| 37391 | SET 5,(IX+16) | Set bit 5 of the flags of the object that was hit. | ||||||||
| 37395 | BIT 7,(IY+21) | Test bit 7 of the second value of the shot. | ||||||||
| 37399 | RET Z | Return if it is clear. | ||||||||
| 37400 | SET 3,(IX+23) | Set bit 3 of the second set of flags of the object. | ||||||||
| 37404 | RES 5,(IX+16) | Clear bit 5 of its flags. | ||||||||
| 37408 | LD A,(IX+0) | Fetch the type of the object. | ||||||||
| 37411 | CP 25 | Jump to ScoreDestroyedObject if it is not 25. | ||||||||
| 37413 | JR NZ,ScoreDestroyedObject | |||||||||
| 37415 | LD A,(IX+13) | Fetch the attribute of the object. | ||||||||
| 37418 | INC A | Increment it. | ||||||||
| 37419 | RET NZ | Return if it was not 255. | ||||||||
| 37420 | CALL ScoreDestroyedObject | Score the points for the object. | ||||||||
| 37423 | LD A,R | Fetch a pseudo-random value from the refresh register. | ||||||||
| 37425 | JP AddToStack_Units | Jump to AddToStack_Units. | ||||||||
| Prev: 37187 | Up: Map | Next: 37428 |