![]() |
Routines |
| Prev: 9A2F | Up: Map | Next: 9BBB |
|
Fire a shot when the Shooter is on screen, then chase Jetman's Y position.
|
||||||||
| Handler_Shooter | 9AE2 | LD H,(IX+$03) | Fetch the high byte of the world X. | |||||
| 9AE5 | LD L,(IX+$02) | Fetch the low byte of the world X. | ||||||
| 9AE8 | PUSH HL | Stash the world X on the stack. | ||||||
| 9AE9 | LD DE,($607A) | Fetch Jetman_Position. | ||||||
| 9AED | AND A | Subtract the scroll position. | ||||||
| 9AEE | SBC HL,DE | |||||||
| 9AF0 | BIT 7,(IX+$05) | Jump to Handler_Shooter_ChaseStillOnScreen if the horizontal speed is negative. | ||||||
| 9AF4 | JP NZ,Handler_Shooter_ChaseStillOnScreen | |||||||
| 9AF7 | LD A,H | Fetch the high byte of the gap. | ||||||
| 9AF8 | AND %00011111 | Keep only bits 0-4. | ||||||
| 9AFA | CP $01 | Jump to Handler_Shooter_ChaseClearType if the alien has left the screen. | ||||||
| 9AFC | JP Z,Handler_Shooter_ChaseClearType | |||||||
|
Skip firing and chase Jetman if the shooter is not on this screen.
|
||||||||
| Handler_Shooter_ShotTolerance | 9AFF | LD DE,$0078 | Add a 78 tolerance. | |||||
| 9B02 | ADD HL,DE | |||||||
| 9B03 | LD A,H | Fetch the high byte. | ||||||
| 9B04 | POP DE | Restore the world X into DE from the stack. | ||||||
| 9B05 | AND A | Jump to Handler_Shooter_ChaseJetmanY if the alien is not on this screen. | ||||||
| 9B06 | JR NZ,Handler_Shooter_ChaseJetmanY | |||||||
| 9B08 | PUSH DE | Stash the world X on the stack again. | ||||||
|
Set the speed to 50 or B0 if bit 7 of *IX+01 differs from the direction of travel.
|
||||||||
| 9B09 | LD A,(IX+$01) | Fetch the screen column. | ||||||
| 9B0C | XOR (IX+$05) | XOR it with the horizontal speed. | ||||||
| 9B0F | AND %10000000 | Keep only bit 7. | ||||||
| 9B11 | JR Z,Handler_Shooter_SpawnShot | Jump to Handler_Shooter_SpawnShot if they already match. | ||||||
| 9B13 | LD A,(IX+$05) | Jump to Handler_Shooter_ShotSpeedLeft if the horizontal speed is negative. | ||||||
| 9B16 | AND A | |||||||
| 9B17 | JP M,Handler_Shooter_ShotSpeedLeft | |||||||
| 9B1A | LD (IX+$05),$50 | Write 50 to the horizontal speed. | ||||||
| 9B1E | JR Handler_Shooter_SpawnShot | Jump to Handler_Shooter_SpawnShot. | ||||||
| Handler_Shooter_ShotSpeedLeft | 9B20 | LD (IX+$05),$B0 | Write B0 to the horizontal speed. | |||||
|
Spawn a shot in a free alien slot.
|
||||||||
| Handler_Shooter_SpawnShot | 9B24 | CALL FindSlotAlien | Call FindSlotAlien. | |||||
| 9B27 | POP DE | Restore the world X into DE from the stack. | ||||||
| 9B28 | JR NZ,Handler_Shooter_ChaseJetmanY | Jump to Handler_Shooter_ChaseJetmanY if no alien slot is free. | ||||||
| 9B2A | LD (HL),$B6 | Write type B6 to the new slot. | ||||||
| 9B2C | BIT 7,(IX+$05) | Jump to Handler_Shooter_CopyShotX if the shot is moving left. | ||||||
| 9B30 | JR NZ,Handler_Shooter_CopyShotX | |||||||
| 9B32 | LD (HL),$B7 | Write type B7. | ||||||
|
Fill in the new shot: its position, speed, thrust and colour.
|
||||||||
| Handler_Shooter_CopyShotX | 9B34 | INC HL | Move onto the world X. | |||||
| 9B35 | INC HL | |||||||
| 9B36 | LD (HL),E | Write the shooter's world X into the slot. | ||||||
| 9B37 | INC HL | |||||||
| 9B38 | LD (HL),D | |||||||
| 9B39 | INC HL | Move onto the Y position. | ||||||
| 9B3A | LD A,(IX+$04) | Copy the shooter's Y position. | ||||||
| 9B3D | LD (HL),A | |||||||
|
Give the shot a speed in the direction the shooter is moving.
|
||||||||
| 9B3E | INC HL | Move onto the horizontal speed. | ||||||
| 9B3F | LD A,(IX+$05) | Jump to Handler_Shooter_ShotSpeedRight if the shooter is moving left. | ||||||
| 9B42 | AND A | |||||||
| 9B43 | JP M,Handler_Shooter_ShotSpeedRight | |||||||
| 9B46 | LD (HL),$70 | Write 70 to the shot speed. | ||||||
| 9B48 | JR Handler_Shooter_InitialiseShotSlot | Jump to Handler_Shooter_InitialiseShotSlot. | ||||||
| Handler_Shooter_ShotSpeedRight | 9B4A | LD (HL),$90 | Write 90 to the shot speed. | |||||
|
Zero the thrust, set the colour and clear the rest of the slot.
|
||||||||
| Handler_Shooter_InitialiseShotSlot | 9B4C | INC HL | Write 00 to the thrust. | |||||
| 9B4D | LD (HL),$00 | |||||||
| 9B4F | INC HL | |||||||
| 9B50 | LD (HL),$47 | Write INK:WHITE, PAPER:BLACK (BRIGHT) to the colour. | ||||||
| 9B52 | LD B,$0F | Set a byte counter in B for 0F loops. | ||||||
| Handler_Shooter_ClearShotTail | 9B54 | INC HL | Clear the next slot byte. | |||||
| 9B55 | LD (HL),$00 | |||||||
| 9B57 | DJNZ Handler_Shooter_ClearShotTail | Decrease the byte counter by one and loop back to Handler_Shooter_ClearShotTail until the slot is cleared. | ||||||
|
Chase Jetman's Y position.
|
||||||||
| Handler_Shooter_ChaseJetmanY | 9B59 | LD A,($607C) | Fetch Jetman_Y. | |||||
| 9B5C | SUB (IX+$04) | Subtract the alien's Y position. | ||||||
| 9B5F | JP P,Handler_Shooter_ChaseAddThrustTest | Jump to Handler_Shooter_ChaseAddThrustTest if Jetman is below the alien. | ||||||
| 9B62 | LD A,(IX+$06) | Jump to Handler_Shooter_ChaseSubtractThrust if the vertical thrust is positive. | ||||||
| 9B65 | AND A | |||||||
| 9B66 | JP P,Handler_Shooter_ChaseSubtractThrust | |||||||
| 9B69 | CP $EF | Jump to Handler_Shooter_ChaseApplyThrust if the thrust is already below EF. | ||||||
| 9B6B | JR C,Handler_Shooter_ChaseApplyThrust | |||||||
| Handler_Shooter_ChaseSubtractThrust | 9B6D | SUB $02 | Subtract 02 from the thrust. | |||||
|
Apply the thrust to the Y position unless it would leave the play area.
|
||||||||
| Handler_Shooter_ChaseApplyThrust | 9B6F | LD (IX+$06),A | Write the thrust back. | |||||
| 9B72 | SRA A | Divide it by 10. | ||||||
| 9B74 | SRA A | |||||||
| 9B76 | SRA A | |||||||
| 9B78 | SRA A | |||||||
| 9B7A | ADD A,(IX+$04) | Add it to the alien's Y position. | ||||||
| 9B7D | CP $38 | Jump to Handler_Shooter_ChaseTickAnimation if the alien is above the play area. | ||||||
| 9B7F | JR C,Handler_Shooter_ChaseTickAnimation | |||||||
| 9B81 | CP $B0 | Jump to Handler_Shooter_ChaseTickAnimation if the alien has hit the ground line. | ||||||
| 9B83 | JR NC,Handler_Shooter_ChaseTickAnimation | |||||||
| 9B85 | LD (IX+$04),A | Write the Y position back. | ||||||
|
Step the animation timer and pick the animation frame.
|
||||||||
| Handler_Shooter_ChaseTickAnimation | 9B88 | INC (IX+$11) | Increase the animation timer. | |||||
| 9B8B | LD A,(IX+$11) | Fetch the animation timer. | ||||||
| 9B8E | CP $07 | Jump to Handler_Shooter_ChaseWriteFrame if it is still below 07. | ||||||
| 9B90 | JR C,Handler_Shooter_ChaseWriteFrame | |||||||
| 9B92 | XOR A | Write 00 to the animation timer. | ||||||
| 9B93 | LD (IX+$11),A | |||||||
|
Sprite IDs begin at B8 ("Shooter: Frame 1").
|
||||||||
| Handler_Shooter_ChaseWriteFrame | 9B96 | ADD A,$B8 | Add B8 for these frames. | |||||
| 9B98 | LD (IX+$00),A | Write it to the actor type. | ||||||
| 9B9B | JP PlaceSpawnedAlien_Age | Jump to PlaceSpawnedAlien_Age. | ||||||
|
Test whether a left-moving shooter has gone off the left edge.
|
||||||||
| Handler_Shooter_ChaseStillOnScreen | 9B9E | LD A,H | Fetch the high byte of the gap. | |||||
| 9B9F | OR %11100000 | Set bits 5-7. | ||||||
| 9BA1 | CP $FE | Jump to Handler_Shooter_ShotTolerance if the alien has not left the left edge. | ||||||
| 9BA3 | JP NZ,Handler_Shooter_ShotTolerance | |||||||
| Handler_Shooter_ChaseClearType | 9BA6 | LD (IX+$00),$00 | Write 00 to the actor type. | |||||
| 9BAA | POP HL | Restore the world X from the stack. | ||||||
| 9BAB | RET | Return. | ||||||
|
When Jetman is below the shooter, thrust downward.
|
||||||||
| Handler_Shooter_ChaseAddThrustTest | 9BAC | LD A,(IX+$06) | Jump to Handler_Shooter_ChaseAddThrust if the vertical thrust is negative. | |||||
| 9BAF | AND A | |||||||
| 9BB0 | JP M,Handler_Shooter_ChaseAddThrust | |||||||
| 9BB3 | CP $20 | Jump to Handler_Shooter_ChaseApplyThrust if the thrust is already at least 20. | ||||||
| 9BB5 | JR NC,Handler_Shooter_ChaseApplyThrust | |||||||
| Handler_Shooter_ChaseAddThrust | 9BB7 | ADD A,$02 | Add 02 to the thrust. | |||||
| 9BB9 | JR Handler_Shooter_ChaseApplyThrust | Jump to Handler_Shooter_ChaseApplyThrust. | ||||||
| Prev: 9A2F | Up: Map | Next: 9BBB |