![]() |
Routines |
| Prev: 38484 | Up: Map | Next: 39044 |
|
Count the alien and steer it toward the scroll position at Jetman_Position. When it is close to the object at World_Slot_1_Position, it picks that object up and carries it.
|
||||||||
| Handler_MrMagneticBrella | 38670 | LD HL,24158 | HL=AlienCount. | |||||
| 38673 | INC (HL) | Increase AlienCount by one. | ||||||
| 38674 | BIT 0,(IX+8) | Jump to Handler_MrMagneticBrella_AttachedFly if the alien is already attached. | ||||||
| 38678 | JP NZ,Handler_MrMagneticBrella_AttachedFly | |||||||
|
Attach when the alien is close to World_Slot_1_Position.
|
||||||||
| 38681 | LD A,(24752) | Jump to Handler_MrMagneticBrella_CopyBeside if World_Slot_1_Flags is already set. | ||||||
| 38684 | AND A | |||||||
| 38685 | JR NZ,Handler_MrMagneticBrella_CopyBeside | |||||||
|
Test whether the alien is horizontally close to the object.
|
||||||||
| 38687 | LD H,(IX+3) | Fetch the high byte of the world X. | ||||||
| 38690 | LD L,(IX+2) | Fetch the low byte of the world X. | ||||||
| 38693 | LD DE,(24746) | Fetch World_Slot_1_Position. | ||||||
| 38697 | LD BC,8 | Add an 8 tolerance. | ||||||
| 38700 | ADD HL,BC | |||||||
| 38701 | SBC HL,DE | Subtract the target position. | ||||||
| 38703 | LD A,H | Fetch the high byte of the gap. | ||||||
| 38704 | AND %00011111 | Keep only bits 0-4. | ||||||
| 38706 | JR NZ,Handler_MrMagneticBrella_CopyBeside | Jump to Handler_MrMagneticBrella_CopyBeside if they are not on the same screen. | ||||||
| 38708 | LD A,L | Fetch the low byte of the gap. | ||||||
| 38709 | CP 16 | Jump to Handler_MrMagneticBrella_CopyBeside if it is at least 16. | ||||||
| 38711 | JR NC,Handler_MrMagneticBrella_CopyBeside | |||||||
|
Test whether the alien is vertically close to the object.
|
||||||||
| 38713 | LD A,(24748) | Fetch World_Slot_1_Y. | ||||||
| 38716 | SUB (IX+4) | Subtract the alien's Y position. | ||||||
| 38719 | CP 16 | Jump to Handler_MrMagneticBrella_CopyBeside if the Y gap is at least 16. | ||||||
| 38721 | JR NC,Handler_MrMagneticBrella_CopyBeside | |||||||
|
Flag both the alien and the object as attached.
|
||||||||
| 38723 | SET 0,(IX+8) | Set bit 0 of the actor flags. | ||||||
| 38727 | LD HL,24752 | HL=World_Slot_1_Flags. | ||||||
| 38730 | SET 0,(HL) | Set bit 0 of the target flags. | ||||||
|
Copy the position at World_Slot_1_Position to the alien if it is beside World_Slot_2_Position.
|
||||||||
| Handler_MrMagneticBrella_CopyBeside | 38732 | CALL TestAlienBesideSlot | Jump to Handler_MrMagneticBrella_ApplyDownThrust if the alien is not beside World_Slot_2_Position. | |||||
| 38735 | JR NZ,Handler_MrMagneticBrella_ApplyDownThrust | |||||||
| 38737 | LD DE,(24746) | Fetch World_Slot_1_Position. | ||||||
| 38741 | LD (IX+3),D | Copy that position into the alien's world X. | ||||||
| 38744 | LD (IX+2),E | |||||||
| 38747 | LD A,(24748) | Fetch World_Slot_1_Y. | ||||||
| 38750 | LD (IX+4),A | Copy it to the alien's Y position. | ||||||
|
Apply downward thrust and update the Y position.
|
||||||||
| Handler_MrMagneticBrella_ApplyDownThrust | 38753 | LD A,(IX+6) | Jump to Handler_MrMagneticBrella_AddThrust if the vertical thrust is negative. | |||||
| 38756 | AND A | |||||||
| 38757 | JP M,Handler_MrMagneticBrella_AddThrust | |||||||
| 38760 | CP 48 | Jump to Handler_MrMagneticBrella_AddThrustToY if the thrust is already at least 48. | ||||||
| 38762 | JR NC,Handler_MrMagneticBrella_AddThrustToY | |||||||
| Handler_MrMagneticBrella_AddThrust | 38764 | ADD A,2 | Add 2 to the thrust. | |||||
| 38766 | LD (IX+6),A | Write the thrust back. | ||||||
| Handler_MrMagneticBrella_AddThrustToY | 38769 | SRA A | Divide the thrust by 16. | |||||
| 38771 | SRA A | |||||||
| 38773 | SRA A | |||||||
| 38775 | SRA A | |||||||
| 38777 | ADD A,(IX+4) | Add it to the alien's Y position. | ||||||
| 38780 | CP 176 | Jump to Handler_MrMagneticBrella_BounceGround if the alien has hit the ground line. | ||||||
| 38782 | JR NC,Handler_MrMagneticBrella_BounceGround | |||||||
| Handler_MrMagneticBrella_WriteY | 38784 | LD (IX+4),A | Write the Y position back. | |||||
|
Steer toward the scroll, then animate.
|
||||||||
| Handler_MrMagneticBrella_Loop | 38787 | LD H,(IX+3) | Fetch the high byte of the world X. | |||||
| 38790 | LD L,(IX+2) | Fetch the low byte of the world X. | ||||||
| 38793 | PUSH HL | Stash the world X on the stack. | ||||||
| 38794 | LD DE,(24698) | Fetch Jetman_Position. | ||||||
| 38798 | SBC HL,DE | Subtract the scroll position. | ||||||
| 38800 | LD C,0 | C=0. | ||||||
|
Leave the speed unchanged if the alien is on this screen or just off its left edge.
|
||||||||
| 38802 | LD A,H | Fetch the high byte of the gap. | ||||||
| 38803 | AND %00011111 | Keep only bits 0-4. | ||||||
| 38805 | JR Z,Handler_MrMagneticBrella_RestoreX | Jump to Handler_MrMagneticBrella_RestoreX if the alien is on this screen. | ||||||
| 38807 | OR %11100000 | Set bits 5-7. | ||||||
| 38809 | CPL | Flip the bits. | ||||||
| 38810 | AND A | Jump to Handler_MrMagneticBrella_RestoreX if the result is zero. | ||||||
| 38811 | JR Z,Handler_MrMagneticBrella_RestoreX | |||||||
| 38813 | BIT 4,H | Test bit 4 of the gap. | ||||||
|
48 is a signed +48 rightward speed; 208 is signed -48 leftward.
|
||||||||
| 38815 | LD A,48 | A=48. | ||||||
| 38817 | JR NZ,Handler_MrMagneticBrella_WriteSpeed | Jump to Handler_MrMagneticBrella_WriteSpeed if the alien is left of the scroll. | ||||||
| 38819 | LD A,208 | A=208. | ||||||
| Handler_MrMagneticBrella_WriteSpeed | 38821 | LD (IX+5),A | Write the speed to *IX+5. | |||||
|
Move the carried object with the alien if it is attached.
|
||||||||
| Handler_MrMagneticBrella_RestoreX | 38824 | POP HL | Restore the world X from the stack. | |||||
| 38825 | BIT 0,(IX+8) | Jump to Handler_MrMagneticBrella_TickAnimation if the alien is not attached. | ||||||
| 38829 | JP Z,Handler_MrMagneticBrella_TickAnimation | |||||||
| 38832 | LD (24746),HL | Write the world X back to World_Slot_1_Position. | ||||||
| 38835 | LD A,(IX+4) | Fetch the alien's Y position. | ||||||
| 38838 | ADD A,26 | Add 26. | ||||||
| 38840 | CP 176 | Jump to Handler_MrMagneticBrella_WriteLinkedY if it is still above the ground line. | ||||||
| 38842 | JR C,Handler_MrMagneticBrella_WriteLinkedY | |||||||
|
175 is the ground line.
|
||||||||
| 38844 | LD A,175 | A=175. | ||||||
| Handler_MrMagneticBrella_WriteLinkedY | 38846 | LD (24748),A | Write it to World_Slot_1_Y. | |||||
|
Animate the alien and set its colour.
|
||||||||
| Handler_MrMagneticBrella_TickAnimation | 38849 | INC (IX+17) | Increase the animation timer. | |||||
| 38852 | LD A,(IX+17) | Fetch the animation timer. | ||||||
| 38855 | AND %00000111 | Keep only bits 0-2. | ||||||
|
Sprite IDs begin at 64 ("Mr Magnetic Brella: Frame 1").
|
||||||||
| 38857 | ADD A,64 | Add 64 for the seeking frames. | ||||||
| 38859 | LD (IX+0),A | Write it to the actor type. | ||||||
| 38862 | BIT 0,(IX+16) | Jump to Handler_MrMagneticBrella_SetColour if bit 0 of *IX+16 is reset. | ||||||
| 38866 | JR Z,Handler_MrMagneticBrella_SetColour | |||||||
| 38868 | BIT 0,(IX+8) | Jump to Handler_MrMagneticBrella_SetColour if the alien is not attached. | ||||||
| 38872 | JR Z,Handler_MrMagneticBrella_SetColour | |||||||
| 38874 | LD A,128 | Write 128 to World_Slot_1_Flags. | ||||||
| 38876 | LD (24752),A | |||||||
| Handler_MrMagneticBrella_SetColour | 38879 | LD (IX+7),69 | Write INK:CYAN, PAPER:BLACK (BRIGHT) to the actor colour. | |||||
| 38883 | JP PlaceSpawnedAlien_Age | Jump to PlaceSpawnedAlien_Age. | ||||||
|
Bounce off the ground line.
|
||||||||
| Handler_MrMagneticBrella_BounceGround | 38886 | LD A,(IX+6) | Jump to Handler_MrMagneticBrella_WriteY if the vertical thrust is negative. | |||||
| 38889 | AND A | |||||||
| 38890 | JP M,Handler_MrMagneticBrella_WriteY | |||||||
| 38893 | NEG | Negate the thrust. | ||||||
| 38895 | LD (IX+6),A | Write it back. | ||||||
| 38898 | JR Handler_MrMagneticBrella_Loop | Jump to Handler_MrMagneticBrella_Loop. | ||||||
|
When attached, keep flying and copy the new position back to World_Slot_1_Position.
|
||||||||
| Handler_MrMagneticBrella_AttachedFly | 38900 | INC (IX+17) | Increase the animation timer. | |||||
| 38903 | LD A,(IX+4) | Fetch the alien's Y position. | ||||||
| 38906 | CP 112 | Compare it with 112. | ||||||
| 38908 | LD A,(IX+6) | Fetch the vertical thrust. | ||||||
| 38911 | JR NC,Handler_MrMagneticBrella_ThrustUp | Jump to Handler_MrMagneticBrella_ThrustUp if the alien is at or below mid-screen. | ||||||
|
When above mid-screen, increase the downward thrust, up to a limit.
|
||||||||
| 38913 | AND A | Jump to Handler_MrMagneticBrella_AttachedAddThrust if the thrust is negative. | ||||||
| 38914 | JP M,Handler_MrMagneticBrella_AttachedAddThrust | |||||||
| 38917 | CP 48 | Jump to Handler_MrMagneticBrella_AttachedApplyThrust if the thrust is already at least 48. | ||||||
| 38919 | JR NC,Handler_MrMagneticBrella_AttachedApplyThrust | |||||||
| Handler_MrMagneticBrella_AttachedAddThrust | 38921 | ADD A,2 | Add 2 to the thrust. | |||||
|
Apply the thrust to the alien's Y position, stopping at the ground line.
|
||||||||
| Handler_MrMagneticBrella_AttachedApplyThrust | 38923 | LD (IX+6),A | Write the thrust back. | |||||
| 38926 | SRA A | Divide it by 16. | ||||||
| 38928 | SRA A | |||||||
| 38930 | SRA A | |||||||
| 38932 | SRA A | |||||||
| 38934 | ADD A,(IX+4) | Add it to the alien's Y position. | ||||||
| 38937 | CP 176 | Jump to Handler_MrMagneticBrella_AttachedWriteY if it is still above the ground line. | ||||||
| 38939 | JR C,Handler_MrMagneticBrella_AttachedWriteY | |||||||
|
175 is the ground line.
|
||||||||
| 38941 | LD A,175 | A=175. | ||||||
| Handler_MrMagneticBrella_AttachedWriteY | 38943 | LD (IX+4),A | Write the Y position back. | |||||
|
Occasionally pick a new horizontal direction using RandomNumber.
|
||||||||
| 38946 | LD A,(24128) | Jump to Handler_MrMagneticBrella_DetachIfTerrain if RandomNumber is zero. | ||||||
| 38949 | LD C,A | |||||||
| 38950 | AND A | |||||||
| 38951 | JR Z,Handler_MrMagneticBrella_DetachIfTerrain | |||||||
| 38953 | AND %01111111 | Keep only bits 0-6. | ||||||
| 38955 | JR NZ,Handler_MrMagneticBrella_AccelerateFromFlag | Jump to Handler_MrMagneticBrella_AccelerateFromFlag if the result is not zero. | ||||||
| 38957 | LD A,C | Fetch the stored random byte. | ||||||
| 38958 | AND %10000000 | Keep only bit 7. | ||||||
| 38960 | LD C,A | Stash that sign bit. | ||||||
| 38961 | LD A,(IX+8) | Fetch the actor flags. | ||||||
| 38964 | AND %01111111 | Keep only bits 0-6. | ||||||
| 38966 | OR C | Merge in the sign bit and write the flags back. | ||||||
| 38967 | LD (IX+8),A | |||||||
|
Accelerate left or right from bit 7 of the flags.
|
||||||||
| Handler_MrMagneticBrella_AccelerateFromFlag | 38970 | BIT 7,(IX+8) | Test bit 7 of the actor flags. | |||||
| 38974 | LD A,(IX+5) | Fetch the horizontal speed. | ||||||
| 38977 | JR NZ,Handler_MrMagneticBrella_CapSpeed | Jump to Handler_MrMagneticBrella_CapSpeed if bit 7 is set. | ||||||
|
When bit 7 is reset, speed up towards the right, up to a limit.
|
||||||||
| 38979 | AND A | Jump to Handler_MrMagneticBrella_AddSpeed if the speed is negative. | ||||||
| 38980 | JP M,Handler_MrMagneticBrella_AddSpeed | |||||||
| 38983 | CP 48 | Jump to Handler_MrMagneticBrella_WriteSpeedBack if the speed is already at least 48. | ||||||
| 38985 | JR NC,Handler_MrMagneticBrella_WriteSpeedBack | |||||||
| Handler_MrMagneticBrella_AddSpeed | 38987 | ADD A,2 | Add 2 to the speed. | |||||
| Handler_MrMagneticBrella_WriteSpeedBack | 38989 | LD (IX+5),A | Write the speed back. | |||||
|
Stash the world X and rejoin the shared code at Handler_MrMagneticBrella_RestoreX.
|
||||||||
| Handler_MrMagneticBrella_StashWorldX | 38992 | LD H,(IX+3) | Fetch the high byte of the world X. | |||||
| 38995 | LD L,(IX+2) | Fetch the low byte of the world X. | ||||||
| 38998 | PUSH HL | Stash the world X on the stack. | ||||||
| 38999 | JP Handler_MrMagneticBrella_RestoreX | Jump to Handler_MrMagneticBrella_RestoreX. | ||||||
|
When below mid-screen, apply upward thrust.
|
||||||||
| Handler_MrMagneticBrella_ThrustUp | 39002 | AND A | Jump to Handler_MrMagneticBrella_SubtractThrust if the thrust is positive. | |||||
| 39003 | JP P,Handler_MrMagneticBrella_SubtractThrust | |||||||
| 39006 | CP 209 | Jump to Handler_MrMagneticBrella_AttachedApplyThrust if the thrust is already below 209. | ||||||
| 39008 | JR C,Handler_MrMagneticBrella_AttachedApplyThrust | |||||||
| Handler_MrMagneticBrella_SubtractThrust | 39010 | SUB 2 | Subtract 2 from the thrust. | |||||
| 39012 | JR Handler_MrMagneticBrella_AttachedApplyThrust | Jump to Handler_MrMagneticBrella_AttachedApplyThrust. | ||||||
| Handler_MrMagneticBrella_CapSpeed | 39014 | AND A | Jump to Handler_MrMagneticBrella_SubtractSpeed if the speed is positive. | |||||
| 39015 | JP P,Handler_MrMagneticBrella_SubtractSpeed | |||||||
| 39018 | CP 209 | Jump to Handler_MrMagneticBrella_WriteSpeedBack if the speed is already below 209. | ||||||
| 39020 | JR C,Handler_MrMagneticBrella_WriteSpeedBack | |||||||
| Handler_MrMagneticBrella_SubtractSpeed | 39022 | SUB 2 | Subtract 2 from the speed. | |||||
| 39024 | JR Handler_MrMagneticBrella_WriteSpeedBack | Jump to Handler_MrMagneticBrella_WriteSpeedBack. | ||||||
|
When RandomNumber is zero, check for terrain under the alien. If there is some, detach the alien; otherwise carry on accelerating.
|
||||||||
| Handler_MrMagneticBrella_DetachIfTerrain | 39026 | CALL ReadTerrainCell | Call ReadTerrainCell. | |||||
| 39029 | LD A,D | Jump to Handler_MrMagneticBrella_AccelerateFromFlag if the first terrain cell is empty. | ||||||
| 39030 | AND A | |||||||
| 39031 | JR Z,Handler_MrMagneticBrella_AccelerateFromFlag | |||||||
| 39033 | LD A,128 | Write 128 to World_Slot_1_Flags. | ||||||
| 39035 | LD (24752),A | |||||||
| 39038 | LD (IX+8),0 | Write 0 to the actor flags. | ||||||
| 39042 | JR Handler_MrMagneticBrella_StashWorldX | Jump to Handler_MrMagneticBrella_StashWorldX. | ||||||
| Prev: 38484 | Up: Map | Next: 39044 |