![]() |
Routines |
| Prev: C591 | Up: Map | Next: C603 |
|
Handles the graphic numbers 50 to 53, which are a ghost. The ghost moves in a straight line until it hits something, or does not move at all, and then it picks a new direction at random: its speed in X and in Y is 03 or 04, in either direction. The graphic of the ghost shows the way it moves, and is changed between its two frames each time. The ghost is deadly.
|
||||||||
| HandleGhost | C5C8 | CALL SetPixelAdjustments_Legs | Set the pixel adjustments of the bottom half of a guard. | |||||
| C5CB | CALL ApplyGravityAndMove | Apply gravity to the ghost and move it. | ||||||
| C5CE | LD A,(IX+$09) | Fetch the speed in X. | ||||||
| C5D1 | OR (IX+$0A) | Combine it with the speed in Y. | ||||||
| C5D4 | JR Z,HandleGhost_NewDirection | Jump to HandleGhost_NewDirection if the ghost is not moving. | ||||||
| C5D6 | LD A,(IX+$0C) | Fetch the flags that say what the ghost has hit. | ||||||
| C5D9 | AND %00000011 | Keep the bits for X and Y. | ||||||
| C5DB | JR Z,HandleGhost_Draw | Jump to HandleGhost_Draw if the ghost has not hit anything. | ||||||
|
Choose a new direction.
|
||||||||
| HandleGhost_NewDirection | C5DD | LD A,($5BA5) | Fetch the second random seed from RandomSeed2. | |||||
| C5E0 | AND %00000011 | Keep the lowest two bits. | ||||||
| C5E2 | ADD A,$04 | Add 04, to get a number from 04 to 07. | ||||||
| C5E4 | CALL LookUpGhostSpeed | Look up the speed. | ||||||
| C5E7 | LD (IX+$09),A | Set the speed in X. | ||||||
| C5EA | LD A,($5BA2) | Fetch the frame counter from FrameCounter. | ||||||
| C5ED | AND %00000011 | Keep the lowest two bits. | ||||||
| C5EF | ADD A,$04 | Add 04, to get a number from 04 to 07. | ||||||
| C5F1 | CALL LookUpGhostSpeed | Look up the speed. | ||||||
| C5F4 | LD (IX+$0A),A | Set the speed in Y. | ||||||
| C5F7 | CALL SetGhostDirectionGraphic | Choose the graphic of the ghost from its direction. | ||||||
| C5FA | CALL PlaySoundFromPosition | Play the sound of a moving object. | ||||||
| HandleGhost_Draw | C5FD | CALL ToggleGraphic | Toggle the graphic of the ghost between its two frames. | |||||
| C600 | JP SetDeadlyFlagsAndDraw | Make the ghost deadly and flag it to be drawn again. | ||||||
| Prev: C591 | Up: Map | Next: C603 |