| jetpac | Routines | 
| Prev: 6fb6 | Up: Map | Next: 706d | 
| 
 
Note the copious amounts of register swapping! These annotations need checking.
 
  | 
||||||||
| 6fc5 | ld d,(ix+$01) | Laser Y position | ||||||
| 6fc8 | ld a,(ix+$02) | Laser X position: pulse #1 | ||||||
| 6fcb | bit 2,a | Jump if bit-2 is reset | ||||||
| 6fcd | jr z,$7007 | |||||||
| 6fcf | ld l,a | L=X position: pules #1 | ||||||
| 6fd0 | ld a,$08 | |||||||
| 6fd2 | bit 0,l | Negate (A=$F8) if bit-0 of pulse #1 is reset | ||||||
| 6fd4 | jr z,$6fd8 | |||||||
| 6fd6 | neg | |||||||
| 6fd8 | add a,l | H=laser Y position, L=updated X position | ||||||
| 6fd9 | ld e,a | |||||||
| 6fda | ld h,d | |||||||
| 6fdb | push hl | Preserve HL - pulse Y,X position | ||||||
| 6fdc | call $72d0 | HL=coord to screen address (using HL) | ||||||
| 6fdf | ld a,(ix+$01) | Laser Y position | ||||||
| 6fe2 | cp $80 | Jump if Y position >= 128 | ||||||
| 6fe4 | jr nc,$6fea | |||||||
| 6fe6 | ld a,(hl) | A=byte at Y,X position of laser pulse #1 | ||||||
| 6fe7 | and a | |||||||
| 6fe8 | jr nz,$702c | Jump if byte is empty | ||||||
| 
 
Update the on screen colour for the pulse.
 
 | 
||||||||
| 6fea | ld (ix+$02),e | Update X position: pulse #1 | ||||||
| 6fed | ld (hl),$ff | Add a "full length" pulse to Y,X position | ||||||
| 6fef | pop hl | Restores the pulse Y,X positions | ||||||
| 6ff0 | call $71d6 | HL=coord to attribute file address (using HL) | ||||||
| 6ff3 | ld a,(ix+$07) | Set screen colour attribute to the laser pulse colour | ||||||
| 6ff6 | ld (hl),a | |||||||
| 6ff7 | ld a,(ix+$06) | Subtract 8 from laser pulse "length" | ||||||
| 6ffa | sub $08 | |||||||
| 6ffc | ld (ix+$06),a | |||||||
| 6fff | and $f8 | |||||||
| 7001 | jr nz,$7007 | Jump if pulse length has bit 3-7 set | ||||||
| 
 
Update the X position of all the laser beam pulses.
 
 | 
||||||||
| 7003 | res 2,(ix+$02) | Reset bit-2 of X position: pulse #1 | ||||||
| 7007 | exx | |||||||
| 7008 | ld bc,$031c | |||||||
| 700b | ld e,$e0 | Loop counter (14) | ||||||
| 700d | exx | |||||||
| 700e | ld e,$03 | Loop counter (to process pulses #2, #3, #4) | ||||||
| 7010 | push ix | BC is now the laser beam object | ||||||
| 7012 | pop bc | |||||||
| 7013 | inc bc | Laser beam Y position | ||||||
| 7014 | inc bc | Laser beam X position: pulse #1 | ||||||
| 7015 | inc bc | Laser beam X position: pulse #2 | ||||||
| 
 
A loop (to the end of routine) which draws the pixel byte to the screen.
 
 | 
||||||||
| 7016 | ld a,(bc) | A=X position (loops on pulse #2, #3, #4) | ||||||
| 7017 | xor (ix+$02) | XOR with X position: pulse #1 | ||||||
| 701a | and $f8 | |||||||
| 701c | jr nz,$702f | Jump if A has any of these bits set | ||||||
| 701e | exx | |||||||
| 701f | ld a,b | |||||||
| 7020 | ld b,c | |||||||
| 7021 | ld c,e | |||||||
| 7022 | exx | |||||||
| 7023 | inc bc | Repeat for next X position pulse | ||||||
| 7024 | dec e | |||||||
| 7025 | jr nz,$7016 | |||||||
| 7027 | ld (ix+$00),$00 | Set laser beam to "unused" | ||||||
| 702b | ret | |||||||
| 
 
No pixel to draw, loop back and process next pulse.
 
 | 
||||||||
| 702c | pop hl | |||||||
| 702d | jr $7003 | |||||||
| 
 
Update the length of the laser beam pulse.
 
 | 
||||||||
| 702f | ld a,(bc) | Laser beam X position | ||||||
| 7030 | bit 2,a | Jump if bit-2 is set | ||||||
| 7032 | jr nz,$704f | |||||||
| 7034 | dec (ix+$06) | Decrement pulse length | ||||||
| 7037 | ld a,(ix+$06) | |||||||
| 703a | and $07 | Return if pulse has any pixels set? | ||||||
| 703c | ret nz | |||||||
| 703d | ld a,($5dce) | Random number | ||||||
| 7040 | and $03 | Calculate the length of the laser pulse | ||||||
| 7042 | or $04 | |||||||
| 7044 | or (ix+$06) | |||||||
| 7047 | ld (ix+$06),a | |||||||
| 704a | ld a,(bc) | Current X position += 4 | ||||||
| 704b | or $04 | |||||||
| 704d | ld (bc),a | |||||||
| 704e | ret | |||||||
| 704f | ld a,(bc) | |||||||
| 7050 | ld l,a | L=current X position pulse | ||||||
| 7051 | ld a,$08 | |||||||
| 7053 | bit 0,l | Negate (A=$F8) if bit-0 of pulse is reset | ||||||
| 7055 | jr z,$7059 | |||||||
| 7057 | neg | |||||||
| 7059 | add a,l | |||||||
| 705a | ld (bc),a | Update current X position | ||||||
| 705b | ld h,d | H=laser Y position, L=updated X position | ||||||
| 705c | call $72d0 | HL=coord to screen address (using HL) | ||||||
| 705f | exx | |||||||
| 7060 | ld a,b | |||||||
| 7061 | ld b,c | |||||||
| 7062 | ld c,e | |||||||
| 7063 | exx | |||||||
| 
 
Create a new laser beam pixel and merge with current screen pixel.
 
 | 
||||||||
| 7064 | cpl | Create the pixel byte. E.g. $FC=11111100 | ||||||
| 7065 | and (hl) | Merge with current screen pixel | ||||||
| 7066 | ld (hl),a | Update display file | ||||||
| 7067 | inc bc | Next X position byte | ||||||
| 7068 | dec e | |||||||
| 7069 | jp nz,$7016 | Repeat if counter > 0 | ||||||
| 706c | ret | |||||||
| Prev: 6fb6 | Up: Map | Next: 706d |