![]() |
Routines |
| Prev: 8E21 | Up: Map | Next: 8ECA |
|
Used by the routine at UpdateEnemies.
Works out what happens when the player's ship hits an object. The object sets the byte at 8E2C when it is updated, and each bit of that byte selects an effect:
|
||||||||||||||||||||||||||
| ApplyCollisionEffects | 8E2D | LD A,($96AB) | Fetch the flag from 96AB. | |||||||||||||||||||||||
| 8E30 | AND A | Test it. | ||||||||||||||||||||||||
| 8E31 | RET NZ | Return if it is set. | ||||||||||||||||||||||||
| 8E32 | LD A,($8F53) | Fetch the explosion counter from 8F53. | ||||||||||||||||||||||||
| 8E35 | AND A | Test it. | ||||||||||||||||||||||||
| 8E36 | RET NZ | Return if the ship is exploding. | ||||||||||||||||||||||||
| 8E37 | LD A,($8E2C) | Fetch the collision effects from 8E2C. | ||||||||||||||||||||||||
| 8E3A | AND A | Test them. | ||||||||||||||||||||||||
| 8E3B | RET Z | Return if there are none. | ||||||||||||||||||||||||
| 8E3C | LD A,($A1D8) | Fetch the collision flag from A1D8. | ||||||||||||||||||||||||
| 8E3F | AND A | Test it. | ||||||||||||||||||||||||
| 8E40 | RET Z | Return if there is no collision. | ||||||||||||||||||||||||
| 8E41 | LD IX,($AD46) | Fetch the address of the object that was hit from CurrentObject. | ||||||||||||||||||||||||
| 8E45 | BIT 3,(IX+$17) | Test bit 3 of its second set of flags. | ||||||||||||||||||||||||
| 8E49 | RET NZ | Return if it is set. | ||||||||||||||||||||||||
| 8E4A | LD L,(IX+$11) | Fetch the screen position of the object into HL. | ||||||||||||||||||||||||
| 8E4D | LD H,(IX+$12) | |||||||||||||||||||||||||
| 8E50 | LD IX,$ABA4 | Use the hit data at CollisionBox. | ||||||||||||||||||||||||
| 8E54 | LD (IX+$03),A | Store the collision effects in the hit data. | ||||||||||||||||||||||||
| 8E57 | LD A,L | Fetch the horizontal screen position. | ||||||||||||||||||||||||
| 8E58 | CP $8E | Is it 8E or more? | ||||||||||||||||||||||||
| 8E5A | RET NC | Return if so. | ||||||||||||||||||||||||
| 8E5B | CP $28 | Is it lower than 28? | ||||||||||||||||||||||||
| 8E5D | RET C | Return if so. | ||||||||||||||||||||||||
| 8E5E | LD (IX+$00),L | Store the screen position in the hit data. | ||||||||||||||||||||||||
| 8E61 | LD (IX+$01),H | |||||||||||||||||||||||||
| 8E64 | LD A,($5C29) | Fetch the value from 5C29. | ||||||||||||||||||||||||
| 8E67 | LD (IX+$02),A | Store it in the hit data. | ||||||||||||||||||||||||
| 8E6A | LD A,($5C38) | Fetch the value from ShipRow. | ||||||||||||||||||||||||
| 8E6D | ADD A,$08 | Add eight. | ||||||||||||||||||||||||
| 8E6F | LD H,A | Use it as the vertical position. | ||||||||||||||||||||||||
| 8E70 | LD L,$64 | Set the horizontal position to 64. | ||||||||||||||||||||||||
| 8E72 | LD D,$28 | Set the width to 28... | ||||||||||||||||||||||||
| 8E74 | LD E,$10 | ...and the height to 10. | ||||||||||||||||||||||||
| 8E76 | CALL TestBoxesOverlap | Check for a hit. | ||||||||||||||||||||||||
| 8E79 | LD IX,($AD46) | Bring IX back from CurrentObject. | ||||||||||||||||||||||||
| 8E7D | LD IY,$C8E5 | Use the player's object. | ||||||||||||||||||||||||
| 8E81 | LD A,($5C1C) | Fetch the value from ScratchValue. | ||||||||||||||||||||||||
| 8E84 | AND A | Test it. | ||||||||||||||||||||||||
| 8E85 | JP Z,ApplyPlayerCollision | Jump to ApplyPlayerCollision if it is zero. | ||||||||||||||||||||||||
| 8E88 | LD A,$80 | Set CollisionKind to 80. | ||||||||||||||||||||||||
| 8E8A | LD ($D0BC),A | |||||||||||||||||||||||||
| 8E8D | LD A,($8E2C) | Fetch the collision effects from 8E2C. | ||||||||||||||||||||||||
| 8E90 | LD C,A | Copy them into C. | ||||||||||||||||||||||||
| 8E91 | INC A | Increment them. | ||||||||||||||||||||||||
| 8E92 | JR NZ,ApplyCollisionEffects_Bit7 | Jump to ApplyCollisionEffects_Bit7 if they were not FF. | ||||||||||||||||||||||||
| 8E94 | DEC A | Make 896F FF. | ||||||||||||||||||||||||
| 8E95 | LD ($896F),A | |||||||||||||||||||||||||
| 8E98 | SET 4,(IX+$10) | Set bit 4 of the flags of the object. | ||||||||||||||||||||||||
| 8E9C | JP PlayHitSound | Play the explosion sound. | ||||||||||||||||||||||||
| ApplyCollisionEffects_Bit7 | 8E9F | BIT 7,C | Test bit 7. | |||||||||||||||||||||||
| 8EA1 | CALL NZ,SlowShip | Slow the ship down if it is set. | ||||||||||||||||||||||||
| 8EA4 | BIT 6,C | Test bit 6. | ||||||||||||||||||||||||
| 8EA6 | CALL NZ,DamageShip | Damage the ship if it is set. | ||||||||||||||||||||||||
| 8EA9 | BIT 5,C | Test bit 5. | ||||||||||||||||||||||||
| 8EAB | CALL NZ,DrainFuel | Drain the fuel if it is set. | ||||||||||||||||||||||||
| 8EAE | BIT 4,C | Test bit 4. | ||||||||||||||||||||||||
| 8EB0 | CALL NZ,BounceShip | Bounce the ship if it is set. | ||||||||||||||||||||||||
| 8EB3 | BIT 3,C | Test bit 3. | ||||||||||||||||||||||||
| 8EB5 | CALL NZ,DestroyObject | Mark the object as destroyed if it is set. | ||||||||||||||||||||||||
| 8EB8 | BIT 2,C | Test bit 2. | ||||||||||||||||||||||||
| 8EBA | CALL NZ,AddFuel | Add fuel if it is set. | ||||||||||||||||||||||||
| 8EBD | PUSH BC | Save the effects. | ||||||||||||||||||||||||
| 8EBE | BIT 1,C | Test bit 1. | ||||||||||||||||||||||||
| 8EC0 | CALL NZ,AddShip | Add a ship if it is set. | ||||||||||||||||||||||||
| 8EC3 | POP BC | Restore the effects. | ||||||||||||||||||||||||
| 8EC4 | BIT 0,C | Jump to MarkObjectHit if bit 0 is set. | ||||||||||||||||||||||||
| 8EC6 | JP NZ,MarkObjectHit | |||||||||||||||||||||||||
| 8EC9 | RET | Return. | ||||||||||||||||||||||||
| Prev: 8E21 | Up: Map | Next: 8ECA |