![]() |
Routines |
| Prev: 39471 | Up: Map | Next: 39867 |
|
Fire a shot when the Shooter is on screen, then chase Jetman's Y position.
|
||||||||
| Handler_Shooter | 39650 | LD H,(IX+3) | Fetch the high byte of the world X. | |||||
| 39653 | LD L,(IX+2) | Fetch the low byte of the world X. | ||||||
| 39656 | PUSH HL | Stash the world X on the stack. | ||||||
| 39657 | LD DE,(24698) | Fetch Jetman_Position. | ||||||
| 39661 | AND A | Subtract the scroll position. | ||||||
| 39662 | SBC HL,DE | |||||||
| 39664 | BIT 7,(IX+5) | Jump to Handler_Shooter_ChaseStillOnScreen if the horizontal speed is negative. | ||||||
| 39668 | JP NZ,Handler_Shooter_ChaseStillOnScreen | |||||||
| 39671 | LD A,H | Fetch the high byte of the gap. | ||||||
| 39672 | AND %00011111 | Keep only bits 0-4. | ||||||
| 39674 | CP 1 | Jump to Handler_Shooter_ChaseClearType if the alien has left the screen. | ||||||
| 39676 | JP Z,Handler_Shooter_ChaseClearType | |||||||
|
Skip firing and chase Jetman if the shooter is not on this screen.
|
||||||||
| Handler_Shooter_ShotTolerance | 39679 | LD DE,120 | Add a 120 tolerance. | |||||
| 39682 | ADD HL,DE | |||||||
| 39683 | LD A,H | Fetch the high byte. | ||||||
| 39684 | POP DE | Restore the world X into DE from the stack. | ||||||
| 39685 | AND A | Jump to Handler_Shooter_ChaseJetmanY if the alien is not on this screen. | ||||||
| 39686 | JR NZ,Handler_Shooter_ChaseJetmanY | |||||||
| 39688 | PUSH DE | Stash the world X on the stack again. | ||||||
|
Set the speed to 80 or 176 if bit 7 of *IX+1 differs from the direction of travel.
|
||||||||
| 39689 | LD A,(IX+1) | Fetch the screen column. | ||||||
| 39692 | XOR (IX+5) | XOR it with the horizontal speed. | ||||||
| 39695 | AND %10000000 | Keep only bit 7. | ||||||
| 39697 | JR Z,Handler_Shooter_SpawnShot | Jump to Handler_Shooter_SpawnShot if they already match. | ||||||
| 39699 | LD A,(IX+5) | Jump to Handler_Shooter_ShotSpeedLeft if the horizontal speed is negative. | ||||||
| 39702 | AND A | |||||||
| 39703 | JP M,Handler_Shooter_ShotSpeedLeft | |||||||
| 39706 | LD (IX+5),80 | Write 80 to the horizontal speed. | ||||||
| 39710 | JR Handler_Shooter_SpawnShot | Jump to Handler_Shooter_SpawnShot. | ||||||
| Handler_Shooter_ShotSpeedLeft | 39712 | LD (IX+5),176 | Write 176 to the horizontal speed. | |||||
|
Spawn a shot in a free alien slot.
|
||||||||
| Handler_Shooter_SpawnShot | 39716 | CALL FindSlotAlien | Call FindSlotAlien. | |||||
| 39719 | POP DE | Restore the world X into DE from the stack. | ||||||
| 39720 | JR NZ,Handler_Shooter_ChaseJetmanY | Jump to Handler_Shooter_ChaseJetmanY if no alien slot is free. | ||||||
| 39722 | LD (HL),182 | Write type 182 to the new slot. | ||||||
| 39724 | BIT 7,(IX+5) | Jump to Handler_Shooter_CopyShotX if the shot is moving left. | ||||||
| 39728 | JR NZ,Handler_Shooter_CopyShotX | |||||||
| 39730 | LD (HL),183 | Write type 183. | ||||||
|
Fill in the new shot: its position, speed, thrust and colour.
|
||||||||
| Handler_Shooter_CopyShotX | 39732 | INC HL | Move onto the world X. | |||||
| 39733 | INC HL | |||||||
| 39734 | LD (HL),E | Write the shooter's world X into the slot. | ||||||
| 39735 | INC HL | |||||||
| 39736 | LD (HL),D | |||||||
| 39737 | INC HL | Move onto the Y position. | ||||||
| 39738 | LD A,(IX+4) | Copy the shooter's Y position. | ||||||
| 39741 | LD (HL),A | |||||||
|
Give the shot a speed in the direction the shooter is moving.
|
||||||||
| 39742 | INC HL | Move onto the horizontal speed. | ||||||
| 39743 | LD A,(IX+5) | Jump to Handler_Shooter_ShotSpeedRight if the shooter is moving left. | ||||||
| 39746 | AND A | |||||||
| 39747 | JP M,Handler_Shooter_ShotSpeedRight | |||||||
| 39750 | LD (HL),112 | Write 112 to the shot speed. | ||||||
| 39752 | JR Handler_Shooter_InitialiseShotSlot | Jump to Handler_Shooter_InitialiseShotSlot. | ||||||
| Handler_Shooter_ShotSpeedRight | 39754 | LD (HL),144 | Write 144 to the shot speed. | |||||
|
Zero the thrust, set the colour and clear the rest of the slot.
|
||||||||
| Handler_Shooter_InitialiseShotSlot | 39756 | INC HL | Write 0 to the thrust. | |||||
| 39757 | LD (HL),0 | |||||||
| 39759 | INC HL | |||||||
| 39760 | LD (HL),71 | Write INK:WHITE, PAPER:BLACK (BRIGHT) to the colour. | ||||||
| 39762 | LD B,15 | Set a byte counter in B for 15 loops. | ||||||
| Handler_Shooter_ClearShotTail | 39764 | INC HL | Clear the next slot byte. | |||||
| 39765 | LD (HL),0 | |||||||
| 39767 | 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 | 39769 | LD A,(24700) | Fetch Jetman_Y. | |||||
| 39772 | SUB (IX+4) | Subtract the alien's Y position. | ||||||
| 39775 | JP P,Handler_Shooter_ChaseAddThrustTest | Jump to Handler_Shooter_ChaseAddThrustTest if Jetman is below the alien. | ||||||
| 39778 | LD A,(IX+6) | Jump to Handler_Shooter_ChaseSubtractThrust if the vertical thrust is positive. | ||||||
| 39781 | AND A | |||||||
| 39782 | JP P,Handler_Shooter_ChaseSubtractThrust | |||||||
| 39785 | CP 239 | Jump to Handler_Shooter_ChaseApplyThrust if the thrust is already below 239. | ||||||
| 39787 | JR C,Handler_Shooter_ChaseApplyThrust | |||||||
| Handler_Shooter_ChaseSubtractThrust | 39789 | SUB 2 | Subtract 2 from the thrust. | |||||
|
Apply the thrust to the Y position unless it would leave the play area.
|
||||||||
| Handler_Shooter_ChaseApplyThrust | 39791 | LD (IX+6),A | Write the thrust back. | |||||
| 39794 | SRA A | Divide it by 16. | ||||||
| 39796 | SRA A | |||||||
| 39798 | SRA A | |||||||
| 39800 | SRA A | |||||||
| 39802 | ADD A,(IX+4) | Add it to the alien's Y position. | ||||||
| 39805 | CP 56 | Jump to Handler_Shooter_ChaseTickAnimation if the alien is above the play area. | ||||||
| 39807 | JR C,Handler_Shooter_ChaseTickAnimation | |||||||
| 39809 | CP 176 | Jump to Handler_Shooter_ChaseTickAnimation if the alien has hit the ground line. | ||||||
| 39811 | JR NC,Handler_Shooter_ChaseTickAnimation | |||||||
| 39813 | LD (IX+4),A | Write the Y position back. | ||||||
|
Step the animation timer and pick the animation frame.
|
||||||||
| Handler_Shooter_ChaseTickAnimation | 39816 | INC (IX+17) | Increase the animation timer. | |||||
| 39819 | LD A,(IX+17) | Fetch the animation timer. | ||||||
| 39822 | CP 7 | Jump to Handler_Shooter_ChaseWriteFrame if it is still below 7. | ||||||
| 39824 | JR C,Handler_Shooter_ChaseWriteFrame | |||||||
| 39826 | XOR A | Write 0 to the animation timer. | ||||||
| 39827 | LD (IX+17),A | |||||||
|
Sprite IDs begin at 184 ("Shooter: Frame 1").
|
||||||||
| Handler_Shooter_ChaseWriteFrame | 39830 | ADD A,184 | Add 184 for these frames. | |||||
| 39832 | LD (IX+0),A | Write it to the actor type. | ||||||
| 39835 | JP PlaceSpawnedAlien_Age | Jump to PlaceSpawnedAlien_Age. | ||||||
|
Test whether a left-moving shooter has gone off the left edge.
|
||||||||
| Handler_Shooter_ChaseStillOnScreen | 39838 | LD A,H | Fetch the high byte of the gap. | |||||
| 39839 | OR %11100000 | Set bits 5-7. | ||||||
| 39841 | CP 254 | Jump to Handler_Shooter_ShotTolerance if the alien has not left the left edge. | ||||||
| 39843 | JP NZ,Handler_Shooter_ShotTolerance | |||||||
| Handler_Shooter_ChaseClearType | 39846 | LD (IX+0),0 | Write 0 to the actor type. | |||||
| 39850 | POP HL | Restore the world X from the stack. | ||||||
| 39851 | RET | Return. | ||||||
|
When Jetman is below the shooter, thrust downward.
|
||||||||
| Handler_Shooter_ChaseAddThrustTest | 39852 | LD A,(IX+6) | Jump to Handler_Shooter_ChaseAddThrust if the vertical thrust is negative. | |||||
| 39855 | AND A | |||||||
| 39856 | JP M,Handler_Shooter_ChaseAddThrust | |||||||
| 39859 | CP 32 | Jump to Handler_Shooter_ChaseApplyThrust if the thrust is already at least 32. | ||||||
| 39861 | JR NC,Handler_Shooter_ChaseApplyThrust | |||||||
| Handler_Shooter_ChaseAddThrust | 39863 | ADD A,2 | Add 2 to the thrust. | |||||
| 39865 | JR Handler_Shooter_ChaseApplyThrust | Jump to Handler_Shooter_ChaseApplyThrust. | ||||||
| Prev: 39471 | Up: Map | Next: 39867 |