![]() |
Routines |
| Prev: 53303 | Up: Map | Next: 54153 |
|
Used by the routine at MoveEntity.
Moves an entity that is following a path from the level data, which is the case when fields 36 and 37 are not both zero. Bits 0-2 of field 37 choose a three-byte step from a table. Bits 6-7 of field 36 can replace that step: 64 lowers the entity and can play the long buzz, 128 moves it back along y, and 192 moves it on along x. The three bytes of a looked-up step are added to x, y and z. A step above 8 finishes the path. The player can be scored and shown the filled cup, and a path position is then copied into the entity before the falling sweep plays.
|
||||||||
| FollowPath | 53762 | RES 7,(IX+17) | Clear the moving flag. | |||||
| 53766 | RES 7,(IX+30) | Clear the fast flag. | ||||||
| 53770 | CALL FindPathEntry | Find the path entry. | ||||||
| 53773 | PUSH HL | Remember the entry. | ||||||
| 53774 | LD A,(IX+37) | Read the low byte of the path. | ||||||
| 53777 | AND %00000111 | Keep the step number in bits 0-2. | ||||||
| 53779 | JR NZ,FollowPath_Lookup | Look the step up when a number is set. | ||||||
| 53781 | DEC HL | Use the two bytes just before the entry. | ||||||
| 53782 | DEC HL | |||||||
| 53783 | JR FollowPath_Step | Join the stored step. | ||||||
| FollowPath_Lookup | 53785 | DEC A | Turn the step number into a table offset. | |||||
| 53786 | ADD A,A | |||||||
| 53787 | ADD A,A | |||||||
| 53788 | CALL AddToAddress | Look the offset up. | ||||||
| 53791 | LD C,(HL) | Read the x step, the y step and the z step. | ||||||
| 53792 | INC HL | |||||||
| 53793 | LD B,(HL) | |||||||
| 53794 | INC HL | |||||||
| 53795 | LD E,(HL) | |||||||
| FollowPath_Step | 53796 | LD (54134),HL | Remember where the path continues. | |||||
| 53799 | LD A,(IX+36) | Read the high byte of the path. | ||||||
| 53802 | AND %11000000 | Keep the nudge in bits 6-7. | ||||||
| 53804 | JR Z,FollowPath_Z | Use the looked-up step when there is no nudge. | ||||||
| 53806 | CP 64 | Lower the entity when the nudge is 64. | ||||||
| 53808 | JR NZ,FollowPath_Nudge | |||||||
| 53810 | LD A,(IX+37) | Read the low byte of the path again. | ||||||
| 53813 | CP 64 | Play the long buzz when that byte is 64 as well. | ||||||
| 53815 | CALL Z,PlayLongBuzz | |||||||
| 53818 | LD BC,0 | Clear the x step and the y step. | ||||||
| 53821 | LD E,254 | Lower the entity by two. | ||||||
| 53823 | JR FollowPath_Z | Add the step. | ||||||
| FollowPath_Nudge | 53825 | LD B,254 | Move the entity back along y, and clear the other steps. | |||||
| 53827 | LD C,0 | |||||||
| 53829 | LD E,C | |||||||
| 53830 | CP 128 | Keep that nudge when the bits are 128. | ||||||
| 53832 | JR Z,FollowPath_Z | |||||||
| 53834 | LD C,2 | Move the entity on along x instead. | ||||||
| 53836 | LD B,E | |||||||
| FollowPath_Z | 53837 | LD H,(IX+8) | Fetch the z coordinate. | |||||
| 53840 | LD L,(IX+9) | |||||||
| 53843 | LD D,0 | Sign-extend the z step. | ||||||
| 53845 | BIT 7,E | |||||||
| 53847 | JR Z,FollowPath_AddZ | |||||||
| 53849 | DEC D | |||||||
| FollowPath_AddZ | 53850 | ADD HL,DE | Add the z step to the z coordinate. | |||||
| 53851 | LD (IX+8),H | |||||||
| 53854 | LD (IX+9),L | |||||||
| 53857 | LD E,C | Sign-extend the x step. | ||||||
| 53858 | BIT 7,E | |||||||
| 53860 | LD D,0 | |||||||
| 53862 | JR Z,FollowPath_X | |||||||
| 53864 | DEC D | |||||||
| FollowPath_X | 53865 | LD H,(IX+2) | Fetch the x coordinate. | |||||
| 53868 | LD L,(IX+3) | |||||||
| 53871 | ADD HL,DE | Add the x step to the x coordinate. | ||||||
| 53872 | LD (IX+2),H | |||||||
| 53875 | LD (IX+3),L | |||||||
| 53878 | LD E,B | Sign-extend the y step. | ||||||
| 53879 | BIT 7,E | |||||||
| 53881 | LD D,0 | |||||||
| 53883 | JR Z,FollowPath_Y | |||||||
| 53885 | DEC D | |||||||
| FollowPath_Y | 53886 | LD H,(IX+5) | Fetch the y coordinate. | |||||
| 53889 | LD L,(IX+6) | |||||||
| 53892 | ADD HL,DE | Add the y step to the y coordinate. | ||||||
| 53893 | LD (IX+5),H | |||||||
| 53896 | LD (IX+6),L | |||||||
|
A step above 8 finishes the path. A step of exactly 8 or a step number that no longer matches the entry, reads the next path byte.
|
||||||||
| 53899 | POP HL | Restore the path entry. | ||||||
| 53900 | LD A,(IX+37) | A step of 8 reads the next path byte. | ||||||
| 53903 | SUB 8 | |||||||
| 53905 | JP Z,FollowPath_Next | |||||||
| 53908 | JR NC,FollowPath_Finish | A larger step finishes the path. | ||||||
| 53910 | LD A,(IX+37) | Read field 37 again. | ||||||
| 53913 | AND %00000111 | Use the step number. | ||||||
| 53915 | DEC HL | Compare it with the byte before the entry. | ||||||
| 53916 | CP (HL) | |||||||
| 53917 | JP NZ,FollowPath_Next | Read the next path byte when they differ. | ||||||
| 53920 | LD A,(IX+36) | Read field 36. | ||||||
| 53923 | AND %11000000 | Use bits 6-7 of the path. | ||||||
| 53925 | JR Z,FollowPath_Reward | Copy the path position when those bits are clear. | ||||||
| 53927 | LD A,(IX+0) | Only the player finishes the path here. | ||||||
| 53930 | DEC A | |||||||
| 53931 | JR NZ,FollowPath_Clear | |||||||
| 53933 | LD HL,0 | Set the player's vertical speed to 8704. | ||||||
| 53936 | LD (46418),HL | |||||||
| 53939 | LD (23808),A | Clear the jump counter. | ||||||
| 53942 | LD A,(IX+16) | Read the width byte. | ||||||
| 53945 | AND %11110000 | Use the countdown nibble. | ||||||
| 53947 | LD (IX+16),A | Clear the sprite width. | ||||||
| 53950 | LD (IX+26),0 | Clear the fraction of the speed. | ||||||
| FollowPath_Clear | 53954 | XOR A | Clear field 36. | |||||
| 53955 | LD (IX+36),A | |||||||
| FollowPath_Finish | 53958 | LD (IX+37),A | Clear field 37 and return. | |||||
| 53961 | RET | |||||||
|
The byte stored by FindPathEntry chooses the player's reward. Zero scores 1280. Any other byte, the first time, scores 96 and draws the cup.
|
||||||||
| FollowPath_Reward | 53962 | LD A,(IX+0) | Only the player is rewarded. | |||||
| 53965 | DEC A | |||||||
| 53966 | JR NZ,FollowPath_1 | |||||||
| 53968 | EXX | Switch to the reward byte. | ||||||
| 53969 | LD A,0 | Score 1280 when the path byte is zero. | ||||||
| 53971 | AND A | |||||||
| 53972 | JR NZ,FollowPath_Cup | |||||||
| 53974 | LD BC,1280 | Add a score of 1280. | ||||||
| 53977 | CALL AddScore | |||||||
| 53980 | JR FollowPath_0 | Skip the cup. | ||||||
| FollowPath_Cup | 53982 | LD A,(57084) | The cup is shown only once. | |||||
| 53985 | AND A | |||||||
| 53986 | JR NZ,FollowPath_0 | |||||||
| 53988 | LD A,(46428) | Read the player's animation counter. | ||||||
| 53991 | AND %11110000 | Use the high nibble of the animation. | ||||||
| 53993 | OR %00000101 | Set the low nibble to 5. | ||||||
| 53995 | LD (46428),A | Keep that animation. | ||||||
| 53998 | LD A,5 | Set the control byte to 5. | ||||||
| 54000 | LD (43901),A | |||||||
| 54003 | LD BC,96 | Add a score of 96. | ||||||
| 54006 | CALL AddScore | |||||||
| 54009 | LD HL,26632 | Draw the filled cup. | ||||||
| 54012 | LD DE,25752 | |||||||
| 54015 | CALL DrawPicture | |||||||
| 54018 | LD A,1 | Remember that the cup has been shown. | ||||||
| 54020 | LD (57084),A | |||||||
| FollowPath_0 | 54023 | EXX | Switch back. | |||||
| FollowPath_1 | 54024 | DEC HL | Step back to the path's position. | |||||
| 54025 | LD A,(IX+36) | Read field 36. | ||||||
| 54028 | AND %00111111 | Use bits 0-5 of the path. | ||||||
| 54030 | OR (HL) | Combine them with the path byte and keep them. | ||||||
| 54031 | LD B,A | |||||||
| 54032 | LD (IX+36),A | |||||||
| 54035 | LD A,(IX+37) | Read field 37. | ||||||
| 54038 | AND %00000111 | Use the step number. | ||||||
| 54040 | OR %00100000 | Mark the step with bit 5. | ||||||
| 54042 | LD (IX+37),A | Keep the marked step. | ||||||
| 54045 | DEC HL | Copy the path's coordinates into the entity. | ||||||
| 54046 | LD A,(HL) | |||||||
| 54047 | LD (IX+9),A | |||||||
| 54050 | DEC HL | |||||||
| 54051 | LD A,(HL) | |||||||
| 54052 | LD (IX+8),A | |||||||
| 54055 | DEC HL | |||||||
| 54056 | LD A,(HL) | |||||||
| 54057 | LD (IX+6),A | |||||||
| 54060 | DEC HL | |||||||
| 54061 | LD A,(HL) | |||||||
| 54062 | LD (IX+5),A | |||||||
| 54065 | DEC HL | |||||||
| 54066 | LD A,(HL) | |||||||
| 54067 | LD (IX+3),A | |||||||
| 54070 | DEC HL | |||||||
| 54071 | LD A,(HL) | |||||||
| 54072 | LD (IX+2),A | |||||||
| 54075 | LD A,B | Bring the new path flags back. | ||||||
| 54076 | AND %11000000 | Use bits 6-7 of those flags. | ||||||
| 54078 | CP 144 | Place the entity on y unless the flags are 192. | ||||||
| 54080 | JR NC,FollowPath_PlaceX | |||||||
| 54082 | LD A,(IX+6) | Read the low byte of y. | ||||||
| 54085 | AND %11110000 | Use the high nibble of y. | ||||||
| 54087 | OR %00001000 | Force the low nibble to 8. | ||||||
| 54089 | LD (IX+6),A | Keep that y position. | ||||||
| 54092 | LD A,16 | Shift x by half of 16 less the x extent. | ||||||
| 54094 | SUB (IX+11) | |||||||
| 54097 | SRL A | |||||||
| 54099 | ADD A,(IX+3) | |||||||
| 54102 | LD (IX+3),A | |||||||
| 54105 | JR FollowPath_2 | Join the falling sweep. | ||||||
| FollowPath_PlaceX | 54107 | LD A,(IX+3) | Read the low byte of x. | |||||
| 54110 | AND %11110000 | Use the high nibble of x. | ||||||
| 54112 | OR %00001000 | Force the low nibble to 8. | ||||||
| 54114 | LD (IX+3),A | Keep that x position. | ||||||
| 54117 | LD A,16 | Shift y by half of 16 less the y extent. | ||||||
| 54119 | SUB (IX+12) | |||||||
| 54122 | SRL A | |||||||
| 54124 | ADD A,(IX+6) | |||||||
| 54127 | LD (IX+6),A | |||||||
| FollowPath_2 | 54130 | JP PlayFallingSweep | Play the falling sweep. | |||||
| FollowPath_Next | 54133 | LD HL,0 | Read the next byte of the path table. | |||||
| 54136 | LD DE,5 | |||||||
| 54139 | ADD HL,DE | |||||||
| 54140 | LD A,(HL) | Use it as field 37. | ||||||
| 54141 | LD (IX+37),A | |||||||
| 54144 | LD A,(IX+36) | Read field 36. | ||||||
| 54147 | AND %00111111 | Use bits 0-5 of the path. | ||||||
| 54149 | LD (IX+36),A | Clear bits 6-7 of the path. | ||||||
| 54152 | RET | Return. | ||||||
| Prev: 53303 | Up: Map | Next: 54153 |