![]() |
Routines |
| Prev: 48968 | Up: Map | Next: 49137 |
|
Used by the routine at StartGame.
Creates a ghost at the player's position every 256 frames. The ghost is placed in the first of the six short-lived objects at ObjectTable_Transient that is not close to the player, at a random position within the player's cell. The ghost becomes a burst if it appears on top of the player.
|
||||
| SpawnGhost | 49045 | LD A,(48050) | Return unless the frame counter has wrapped round to a multiple of 256, so that a ghost appears every 256 frames. | |
| 49048 | AND A | |||
| 49049 | RET NZ | |||
| 49050 | LD IX,48542 | Start with the first of the six short-lived objects. | ||
| 49054 | LD DE,16 | Set the distance between one object and the next (16 bytes). | ||
| 49057 | LD B,6 | Set a counter for the six short-lived objects. | ||
| SpawnGhost_FindSlot | 49059 | LD C,2 | Look for an object that is at least two cells away from the player. | |
| 49061 | CALL CheckPlayerClose | Check whether the object is close to the player. | ||
| 49064 | JR NC,SpawnGhost_Create | Jump to SpawnGhost_Create to use this object if it is not close to the player. | ||
| 49066 | ADD IX,DE | Move on to the next short-lived object. | ||
| 49068 | DJNZ SpawnGhost_FindSlot | Loop back until all six objects have been tried. | ||
| 49070 | LD A,136 | Every object is close to the player, so use the first one anyway. | ||
| 49072 | LD (48542),A | |||
| 49075 | RET | Return. | ||
|
Place the ghost in the player's cell at a random position.
|
||||
| SpawnGhost_Create | 49076 | LD A,(48042) | Choose a random place between 64 and 191 along the X axis of the player's cell... | |
| 49079 | AND 127 | |||
| 49081 | ADD A,64 | |||
| 49083 | LD (IX+1),A | ... and set it as the fractional part of the ghost's X position. | ||
| 49086 | LD A,(48272) | Fetch the player's column. | ||
| 49089 | LD (IX+2),A | Put the ghost in the same column. | ||
| 49092 | LD A,(48043) | Choose a random place between 64 and 191 along the Y axis of the player's cell... | ||
| 49095 | AND 127 | |||
| 49097 | ADD A,64 | |||
| 49099 | LD (IX+3),A | ... and set it as the fractional part of the ghost's Y position. | ||
| 49102 | LD A,(48274) | Fetch the player's row. | ||
| 49105 | LD (IX+4),A | Put the ghost in the same row. | ||
| 49108 | LD (IX+8),16 | Set the width of the ghost to 16. | ||
| 49112 | LD (IX+9),16 | Set the depth of the ghost to 16. | ||
| 49116 | LD (IX+12),244 | Set the drawing offsets of the ghost to 244 and 4. | ||
| 49120 | LD (IX+13),4 | |||
| 49124 | CALL CheckPlayerCollision | Check whether the ghost has appeared on top of the player. | ||
| 49127 | LD A,12 | Choose the type for a burst (12), in case it has. | ||
| 49129 | JR C,SpawnGhost_SetType | Jump to SpawnGhost_SetType if the ghost is on top of the player. | ||
| 49131 | ADD A,124 | Otherwise choose the type for a ghost (136). | ||
| SpawnGhost_SetType | 49133 | LD (IX+0),A | Turn the object into a ghost, or a burst. | |
| 49136 | RET | Return. | ||
| Prev: 48968 | Up: Map | Next: 49137 |