![]() |
Routines |
Prev: 26097 | Up: Map | Next: 26225 |
Check whether the bullet's X axis position matches an alien's location. We already know that the Y axis matches one, so if this does too we have a hit.
This function is also used to see if a suggested new alien bullet lines up with an alien. If it doesn't then that alien bullet isn't generated.
Used by the routines at generate_alien_bullets and bullet_alien_coll_yaxis.
|
||||||||||||||
bullet_alien_coll_xaxis | 26154 | LD (_TEMP_A_STORE),A | Save bullet xpos | |||||||||||
26157 | CALL prep_alien_row_data | Work out this row's left side space, the width of the horde, and the right side space. | ||||||||||||
26160 | LD IX,_ALIEN_ROW_PTR | IX points to the alien data structure | ||||||||||||
26164 | LD A,(_TEMP_A_STORE) | Pick up bullet xpos again | ||||||||||||
26167 | LD B,A | B holds the player bullet xpos in chars | ||||||||||||
26168 | SRL A | x2 | ||||||||||||
26170 | SRL A | x4 | ||||||||||||
26172 | SRL A | x8, now A holds the player bullet xpos in px | ||||||||||||
26174 | LD (_EXPLOSION_CX_CY),A | That's the explosion cx value (we've not yet determined it's needed, but there it is) | ||||||||||||
26177 | SUB (IX+4) | Alien row left margin | ||||||||||||
26180 | JR C,no_xpos_hit | Left of leftmost alien, no hit | ||||||||||||
26182 | BIT 0,A | A is cx, if it's an even value the bullet is on the left half of the 2 char alien which means the bullet is hitting | ||||||||||||
26184 | JR Z,bullet_alien_coll_xaxis_0 | |||||||||||||
26186 | BIT 2,B | B is x in px, check bit 2 | ||||||||||||
26188 | JR NZ,no_xpos_hit | If that one is set the bullet is going through the 2 pixel gap to the right of the alien graphic | ||||||||||||
bullet_alien_coll_xaxis_0 | 26190 | CP (IX+5) | Compare with width of alien row | |||||||||||
26193 | JR NC,no_xpos_hit | If the bullet has gone up the right side, no hit | ||||||||||||
If we arrive here the alien is hit in the x axis. A contains row xchar location of hit (so if the leftmost alien is hit A contains 0 or 1, regardless of where the row is on screen)
|
||||||||||||||
26195 | AND 254 | Reset cx lowest bit, so left half of alien | ||||||||||||
26197 | ADD A,(IX+4) | Add to row's left margin | ||||||||||||
26200 | LD (_EXPLOSION_CX_CY),A | That's where the explosion needs to go | ||||||||||||
26203 | SUB (IX+2) | Next draw is from this cx | ||||||||||||
26206 | LD (_CX_OFFSET_HIT_ALIEN),A | |||||||||||||
26209 | LD C,A | Pick up leftmost cx,cy of alien row and add hit alien's offset | ||||||||||||
26210 | LD B,0 | |||||||||||||
26212 | LD IX,(_ALIEN_ROW_PTR) | |||||||||||||
26216 | ADD IX,BC | |||||||||||||
26218 | LD A,(IX+2) | A goes back with cx | ||||||||||||
Collision exit point
|
||||||||||||||
26221 | OR A | Flag collision | ||||||||||||
26222 | RET | |||||||||||||
No collision exit point
|
||||||||||||||
no_xpos_hit | 26223 | XOR A | Flag no collision | |||||||||||
26224 | RET |
Prev: 26097 | Up: Map | Next: 26225 |