![]() |
Routines |
| Prev: BF48 | Up: Map | Next: BFF1 |
|
Used by the routine at StartGame.
Creates a ghost at the player's position every 0100 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 | BF95 | LD A,($BBB2) | Return unless the frame counter has wrapped round to a multiple of 0100, so that a ghost appears every 0100 frames. | |
| BF98 | AND A | |||
| BF99 | RET NZ | |||
| BF9A | LD IX,$BD9E | Start with the first of the six short-lived objects. | ||
| BF9E | LD DE,$0010 | Set the distance between one object and the next (10 bytes). | ||
| BFA1 | LD B,$06 | Set a counter for the six short-lived objects. | ||
| SpawnGhost_FindSlot | BFA3 | LD C,$02 | Look for an object that is at least two cells away from the player. | |
| BFA5 | CALL CheckPlayerClose | Check whether the object is close to the player. | ||
| BFA8 | JR NC,SpawnGhost_Create | Jump to SpawnGhost_Create to use this object if it is not close to the player. | ||
| BFAA | ADD IX,DE | Move on to the next short-lived object. | ||
| BFAC | DJNZ SpawnGhost_FindSlot | Loop back until all six objects have been tried. | ||
| BFAE | LD A,$88 | Every object is close to the player, so use the first one anyway. | ||
| BFB0 | LD ($BD9E),A | |||
| BFB3 | RET | Return. | ||
|
Place the ghost in the player's cell at a random position.
|
||||
| SpawnGhost_Create | BFB4 | LD A,($BBAA) | Choose a random place between 40 and BF along the X axis of the player's cell... | |
| BFB7 | AND $7F | |||
| BFB9 | ADD A,$40 | |||
| BFBB | LD (IX+$01),A | ... and set it as the fractional part of the ghost's X position. | ||
| BFBE | LD A,($BC90) | Fetch the player's column. | ||
| BFC1 | LD (IX+$02),A | Put the ghost in the same column. | ||
| BFC4 | LD A,($BBAB) | Choose a random place between 40 and BF along the Y axis of the player's cell... | ||
| BFC7 | AND $7F | |||
| BFC9 | ADD A,$40 | |||
| BFCB | LD (IX+$03),A | ... and set it as the fractional part of the ghost's Y position. | ||
| BFCE | LD A,($BC92) | Fetch the player's row. | ||
| BFD1 | LD (IX+$04),A | Put the ghost in the same row. | ||
| BFD4 | LD (IX+$08),$10 | Set the width of the ghost to 10. | ||
| BFD8 | LD (IX+$09),$10 | Set the depth of the ghost to 10. | ||
| BFDC | LD (IX+$0C),$F4 | Set the drawing offsets of the ghost to F4 and 04. | ||
| BFE0 | LD (IX+$0D),$04 | |||
| BFE4 | CALL CheckPlayerCollision | Check whether the ghost has appeared on top of the player. | ||
| BFE7 | LD A,$0C | Choose the type for a burst (0C), in case it has. | ||
| BFE9 | JR C,SpawnGhost_SetType | Jump to SpawnGhost_SetType if the ghost is on top of the player. | ||
| BFEB | ADD A,$7C | Otherwise choose the type for a ghost (88). | ||
| SpawnGhost_SetType | BFED | LD (IX+$00),A | Turn the object into a ghost, or a burst. | |
| BFF0 | RET | Return. | ||
| Prev: BF48 | Up: Map | Next: BFF1 |