![]() |
Routines |
| Prev: 27194 | Up: Map | Next: 27251 |
|
Checks whether a bug is touching either of the two weapon objects (the weapon has to be within 15 pixels horizontally and 12 pixels vertically). If it is, the "hit" flag of the weapon (IX+5 of the weapon) is set so that the weapon removes itself. This does not check whether the weapon is active, so the caller does that using the state which is returned in C.
|
||||||||||||||||
| CheckWeaponHit | 27202 | LD HL,24188 | HL=State_Weapon_1 (the first weapon object). | |||||||||||||
| 27205 | LD B,2 | Set the weapon counter to 2. | ||||||||||||||
| CheckWeaponHit_Loop | 27207 | LD A,(IX+1) | A=the X position of the bug. | |||||||||||||
| 27210 | LD C,(HL) | C=the state of the weapon. | ||||||||||||||
| 27211 | INC HL | Move onto the X position of the weapon. | ||||||||||||||
| 27212 | SUB (HL) | Subtract the X position of the weapon. | ||||||||||||||
| 27213 | JP P,CheckWeaponHit_Test_X | Make sure we have a positive byte. | ||||||||||||||
| 27216 | NEG | |||||||||||||||
| CheckWeaponHit_Test_X | 27218 | CP 16 | Jump to CheckWeaponHit_Next if the weapon is 16 pixels or more away. | |||||||||||||
| 27220 | JR NC,CheckWeaponHit_Next | |||||||||||||||
| 27222 | LD A,(IX+2) | A=the Y position of the bug. | ||||||||||||||
| 27225 | INC HL | Move onto the Y position of the weapon. | ||||||||||||||
| 27226 | SUB (HL) | Subtract the Y position of the weapon. | ||||||||||||||
| 27227 | JP P,CheckWeaponHit_Test_Y | Make sure we have a positive byte. | ||||||||||||||
| 27230 | NEG | |||||||||||||||
| CheckWeaponHit_Test_Y | 27232 | CP 13 | Jump to CheckWeaponHit_Next if the weapon is 13 pixels or more away. | |||||||||||||
| 27234 | JR NC,CheckWeaponHit_Next | |||||||||||||||
| 27236 | INC HL | Move onto the "hit" flag of the weapon. | ||||||||||||||
| 27237 | INC HL | |||||||||||||||
| 27238 | INC HL | |||||||||||||||
| 27239 | LD E,1 | E=1 (a weapon has hit the bug). | ||||||||||||||
| 27241 | LD (HL),E | Set the "hit" flag of the weapon. | ||||||||||||||
| 27242 | RET | Return. | ||||||||||||||
| CheckWeaponHit_Next | 27243 | LD HL,24196 | HL=State_Weapon_2 (the second weapon object). | |||||||||||||
| 27246 | DJNZ CheckWeaponHit_Loop | Decrease the weapon counter by one and loop back to CheckWeaponHit_Loop until both weapons have been checked. | ||||||||||||||
| 27248 | LD E,0 | E=0 (no hit). | ||||||||||||||
| 27250 | RET | Return. | ||||||||||||||
| Prev: 27194 | Up: Map | Next: 27251 |