![]() |
Routines |
| Prev: 36385 | Up: Map | Next: 36554 |
|
Used by the routine at UpdateEnemies.
Works out what happens when the player's ship hits an object. The object sets the byte at 36396 when it is updated, and each bit of that byte selects an effect:
|
||||||||||||||||||||||||||
| ApplyCollisionEffects | 36397 | LD A,(38571) | Fetch the flag from 38571. | |||||||||||||||||||||||
| 36400 | AND A | Test it. | ||||||||||||||||||||||||
| 36401 | RET NZ | Return if it is set. | ||||||||||||||||||||||||
| 36402 | LD A,(36691) | Fetch the explosion counter from 36691. | ||||||||||||||||||||||||
| 36405 | AND A | Test it. | ||||||||||||||||||||||||
| 36406 | RET NZ | Return if the ship is exploding. | ||||||||||||||||||||||||
| 36407 | LD A,(36396) | Fetch the collision effects from 36396. | ||||||||||||||||||||||||
| 36410 | AND A | Test them. | ||||||||||||||||||||||||
| 36411 | RET Z | Return if there are none. | ||||||||||||||||||||||||
| 36412 | LD A,(41432) | Fetch the collision flag from 41432. | ||||||||||||||||||||||||
| 36415 | AND A | Test it. | ||||||||||||||||||||||||
| 36416 | RET Z | Return if there is no collision. | ||||||||||||||||||||||||
| 36417 | LD IX,(44358) | Fetch the address of the object that was hit from CurrentObject. | ||||||||||||||||||||||||
| 36421 | BIT 3,(IX+23) | Test bit 3 of its second set of flags. | ||||||||||||||||||||||||
| 36425 | RET NZ | Return if it is set. | ||||||||||||||||||||||||
| 36426 | LD L,(IX+17) | Fetch the screen position of the object into HL. | ||||||||||||||||||||||||
| 36429 | LD H,(IX+18) | |||||||||||||||||||||||||
| 36432 | LD IX,43940 | Use the hit data at CollisionBox. | ||||||||||||||||||||||||
| 36436 | LD (IX+3),A | Store the collision effects in the hit data. | ||||||||||||||||||||||||
| 36439 | LD A,L | Fetch the horizontal screen position. | ||||||||||||||||||||||||
| 36440 | CP 142 | Is it 142 or more? | ||||||||||||||||||||||||
| 36442 | RET NC | Return if so. | ||||||||||||||||||||||||
| 36443 | CP 40 | Is it lower than 40? | ||||||||||||||||||||||||
| 36445 | RET C | Return if so. | ||||||||||||||||||||||||
| 36446 | LD (IX+0),L | Store the screen position in the hit data. | ||||||||||||||||||||||||
| 36449 | LD (IX+1),H | |||||||||||||||||||||||||
| 36452 | LD A,(23593) | Fetch the value from 23593. | ||||||||||||||||||||||||
| 36455 | LD (IX+2),A | Store it in the hit data. | ||||||||||||||||||||||||
| 36458 | LD A,(23608) | Fetch the value from ShipRow. | ||||||||||||||||||||||||
| 36461 | ADD A,8 | Add eight. | ||||||||||||||||||||||||
| 36463 | LD H,A | Use it as the vertical position. | ||||||||||||||||||||||||
| 36464 | LD L,100 | Set the horizontal position to 100. | ||||||||||||||||||||||||
| 36466 | LD D,40 | Set the width to 40... | ||||||||||||||||||||||||
| 36468 | LD E,16 | ...and the height to 16. | ||||||||||||||||||||||||
| 36470 | CALL TestBoxesOverlap | Check for a hit. | ||||||||||||||||||||||||
| 36473 | LD IX,(44358) | Bring IX back from CurrentObject. | ||||||||||||||||||||||||
| 36477 | LD IY,51429 | Use the player's object. | ||||||||||||||||||||||||
| 36481 | LD A,(23580) | Fetch the value from ScratchValue. | ||||||||||||||||||||||||
| 36484 | AND A | Test it. | ||||||||||||||||||||||||
| 36485 | JP Z,ApplyPlayerCollision | Jump to ApplyPlayerCollision if it is zero. | ||||||||||||||||||||||||
| 36488 | LD A,128 | Set CollisionKind to 128. | ||||||||||||||||||||||||
| 36490 | LD (53436),A | |||||||||||||||||||||||||
| 36493 | LD A,(36396) | Fetch the collision effects from 36396. | ||||||||||||||||||||||||
| 36496 | LD C,A | Copy them into C. | ||||||||||||||||||||||||
| 36497 | INC A | Increment them. | ||||||||||||||||||||||||
| 36498 | JR NZ,ApplyCollisionEffects_Bit7 | Jump to ApplyCollisionEffects_Bit7 if they were not 255. | ||||||||||||||||||||||||
| 36500 | DEC A | Make 35183 255. | ||||||||||||||||||||||||
| 36501 | LD (35183),A | |||||||||||||||||||||||||
| 36504 | SET 4,(IX+16) | Set bit 4 of the flags of the object. | ||||||||||||||||||||||||
| 36508 | JP PlayHitSound | Play the explosion sound. | ||||||||||||||||||||||||
| ApplyCollisionEffects_Bit7 | 36511 | BIT 7,C | Test bit 7. | |||||||||||||||||||||||
| 36513 | CALL NZ,SlowShip | Slow the ship down if it is set. | ||||||||||||||||||||||||
| 36516 | BIT 6,C | Test bit 6. | ||||||||||||||||||||||||
| 36518 | CALL NZ,DamageShip | Damage the ship if it is set. | ||||||||||||||||||||||||
| 36521 | BIT 5,C | Test bit 5. | ||||||||||||||||||||||||
| 36523 | CALL NZ,DrainFuel | Drain the fuel if it is set. | ||||||||||||||||||||||||
| 36526 | BIT 4,C | Test bit 4. | ||||||||||||||||||||||||
| 36528 | CALL NZ,BounceShip | Bounce the ship if it is set. | ||||||||||||||||||||||||
| 36531 | BIT 3,C | Test bit 3. | ||||||||||||||||||||||||
| 36533 | CALL NZ,DestroyObject | Mark the object as destroyed if it is set. | ||||||||||||||||||||||||
| 36536 | BIT 2,C | Test bit 2. | ||||||||||||||||||||||||
| 36538 | CALL NZ,AddFuel | Add fuel if it is set. | ||||||||||||||||||||||||
| 36541 | PUSH BC | Save the effects. | ||||||||||||||||||||||||
| 36542 | BIT 1,C | Test bit 1. | ||||||||||||||||||||||||
| 36544 | CALL NZ,AddShip | Add a ship if it is set. | ||||||||||||||||||||||||
| 36547 | POP BC | Restore the effects. | ||||||||||||||||||||||||
| 36548 | BIT 0,C | Jump to MarkObjectHit if bit 0 is set. | ||||||||||||||||||||||||
| 36550 | JP NZ,MarkObjectHit | |||||||||||||||||||||||||
| 36553 | RET | Return. | ||||||||||||||||||||||||
| Prev: 36385 | Up: Map | Next: 36554 |