| jetpac | Routines | 
| Prev: 6cb0 | Up: Map | Next: 6d43 | 
  | 
||||||||
| 6cbe | call $6cb0 | Update actor direction | ||||||
| 6cc1 | ld hl,$5dcb | Increment alien number | ||||||
| 6cc4 | inc (hl) | |||||||
| 6cc5 | call $6e1b | Fire laser beam (returns C) | ||||||
| 6cc8 | dec c | |||||||
| 6cc9 | jp z,$6d59 | Add points and kill alien (type #3) if dead | ||||||
| 6ccc | call $6de9 | Alien collision (returns E) | ||||||
| 6ccf | dec e | |||||||
| 6cd0 | jp z,$6456 | Alien killed by collision | ||||||
| 6cd3 | xor a | |||||||
| 6cd4 | ld ($5dc9),a | Reset alien new direction | ||||||
| 
 
Crossed ship direction change on platform collision.
 
 | 
||||||||
| 6cd7 | call $75e8 | Platform collision (returns E) | ||||||
| 6cda | bit 2,e | Update alien X position if bit-2 is reset | ||||||
| 6cdc | jr z,$6cf7 | |||||||
| 6cde | bit 7,e | Set alien direction to up if bit-7 set | ||||||
| 6ce0 | jp nz,$6d67 | |||||||
| 6ce3 | bit 4,e | Set alien direction to down if bit-4 set | ||||||
| 6ce5 | jp nz,$6d76 | |||||||
| 
 
Alien has hit the end of a platform: change direction in a slightly more erratic way than other aliens (note the XOR).
 
 | 
||||||||
| 6ce8 | ld a,e | Update alien "moving" value | ||||||
| 6ce9 | and $40 | |||||||
| 6ceb | xor $40 | |||||||
| 6ced | ld e,a | |||||||
| 6cee | ld a,(ix+$04) | |||||||
| 6cf1 | and $bf | |||||||
| 6cf3 | or e | |||||||
| 6cf4 | ld (ix+$04),a | |||||||
| 
 
Move crossed ship horizontally.
 
 | 
||||||||
| 6cf7 | bit 6,(ix+$04) | Check moving left/right bit | ||||||
| 6cfb | ld a,(ix+$01) | A=X position (fetch before the jump) | ||||||
| 6cfe | jp nz,$6d7d | If moving left, subtract 2 from direction (via jump) | ||||||
| 6d01 | add a,$02 | otherwise, we add 2 to move right | ||||||
| 
 
Update the alien YX position.
 
 | 
||||||||
| 6d03 | ld (ix+$01),a | Set new X position +/- 2 | ||||||
| 6d06 | ld h,$00 | HL=Y speed x 2 | ||||||
| 6d08 | ld l,(ix+$06) | |||||||
| 6d0b | add hl,hl | |||||||
| 6d0c | ld d,(ix+$02) | D=alien X position | ||||||
| 6d0f | ld e,(ix+$05) | E=alien X speed | ||||||
| 6d12 | bit 7,(ix+$04) | If alien moving is "up" subtract hl/de | ||||||
| 6d16 | jr z,$6d8d | |||||||
| 6d18 | add hl,de | else add them | ||||||
| 
 
Update vertical position, direction, and speed.
 
 | 
||||||||
| 6d19 | ld (ix+$05),l | Set alien X speed | ||||||
| 6d1c | ld (ix+$02),h | Alien Y position = H | ||||||
| 6d1f | ld a,h | If alien is at top of screen, set to moving down | ||||||
| 6d20 | cp $28 | |||||||
| 6d22 | jr nc,$6d28 | |||||||
| 6d24 | set 7,(ix+$04) | |||||||
| 6d28 | bit 7,(ix+$04) | Check if moving up | ||||||
| 6d2c | jr z,$6d82 | Change alien direction to down if it is | ||||||
| 6d2e | inc (ix+$06) | else increment Y speed | ||||||
| 6d31 | jr nz,$6d37 | Jump if it wasn't $FF before the increment | ||||||
| 6d33 | ld (ix+$06),$ff | else set Y speed to $FF | ||||||
| 
 
Draw the alien if a new direction is set, otherwise repeat platform collision check again.
 
 | 
||||||||
| 6d37 | ld a,($5dc9) | Draw the alien if the new direction flag is set, otherwise, increment the value | ||||||
| 6d3a | and a | |||||||
| 6d3b | jr nz,$6d43 | |||||||
| 6d3d | inc a | |||||||
| 6d3e | ld ($5dc9),a | |||||||
| 6d41 | jr $6cd7 | Jump back and repeat collision check | ||||||
| Prev: 6cb0 | Up: Map | Next: 6d43 |