Prev: 26489 Up: Map Next: 26566
26490: Player bullet interception detection
Check whether the player's bullet has hit an alien bullet. There are up to 4 alien bullets in play, so loop over them and check their screen locations. If there's a hit, play the click sound and remove the bullets from screen.
If there's no such interception jump off to the routine which checks whether the player's bullet has hit the underside of a barrier.
Used by the routine at is_alien_hit.
bullet_intercept_detect 26490 LD IX,_ALIEN_BULLET_ARRAY Alien bullet array, 4 slots, x,y entries
26494 LD A,4 Loop 4 times, once for each alien bullet
26496 LD (_MOVE_BULLET_LOOP),A
26499 LD BC,(_PLAYER_BULLET_XPOS) C=xpos, B=ypos of player bullet
bullet_intercept_detect_0 26503 LD A,(IX+1) Alien bullet ypos, a zero value is used to indicate this bullet isn't in flight. Skip slot if not used.
26506 OR A
26507 JR Z,not_hit_player_bullet
26509 LD A,(IX+0) Pick up alien bullet xpos. Compare to player bullet xpos, jump forward if it's not the same since it can't be an intercept
26512 CP C
26513 JR NZ,not_hit_player_bullet
Alien bullets locations are stored upside down. i.e. the x,y pos on screen is the top of the bullet, not the leading point which is the bottom as drawn. So this ypos check is a bit fiddly.
26515 LD A,(IX+1) Pick up player bullet ypos again, subtract player bullet ypos, take 2s comp and compare with 6 (bullet length). NC means no hit.
26518 SUB B
26519 NEG
26521 CP 6
26523 JR NC,not_hit_player_bullet
Intercept!
alien_bullet_intercepted 26525 CALL clear_alien_bullet_sprite Clears alien bullet
26528 CALL sound_burbler Sound burbler
26531 DEFB 4,24,8,12,16,6,0 Hit alien bullet sound
26538 JP clear_player_bullet Jump to clear player bullet. The return exits this routine, which is fine since there's no player bullet now.
Alien bullet and player bullet haven't intecepted, so check the next alien bullet.
not_hit_player_bullet 26541 INC IX Next alien bullet
26543 INC IX
26545 LD A,(_MOVE_BULLET_LOOP) Back to check next alien bullet for interception
26548 DEC A
26549 LD (_MOVE_BULLET_LOOP),A
26552 JR NZ,bullet_intercept_detect_0
If we get here the player's bullet hasn't intercepted an alien bullet, so we need to check if the player's bullet hit a barrier
26554 LD BC,(_PLAYER_BULLET_XPOS) Player bullet y,x in BC, move player bullet up the screen a pixel
26558 DEC B
26559 CALL bullet_barrier_hit Check whether the player's bullet hit a barrier
26562 RET Z Return with Z mean no barrier collision, otherwise clear the player's bullet
26563 JP clear_player_bullet
Prev: 26489 Up: Map Next: 26566