Prev: 39453 Up: Map Next: 39528
39484: Spawn Nastie
Used by the routine at UpdateCounters.
Called once every time all of the actors have been processed. If the start-of-turn delay is over, the nastie spawn delay has run out and the player is alive, this looks for an empty record in the nastie table at NastieData and, if one is found, tries to start a new nastie in it with StartNastie.
Return if the start-of-turn delay is still running.
SpawnNastie 39484 LD A,(38581) Return if the start-of-turn delay in GameDelayTimer is not zero.
39487 AND A
39488 RET NZ
Count down the delay between nasties appearing.
39489 LD A,(38577) Jump to SpawnNastie_Ready if the nastie spawn delay in NastieSpawnDelay is zero.
39492 AND A
39493 JR Z,SpawnNastie_Ready
39495 DEC A Decrease the nastie spawn delay by one.
39496 LD (38577),A Store the nastie spawn delay in NastieSpawnDelay.
39499 RET Return.
Return unless the player is alive (the sprite ID of the player's actor is in the range 16-47).
SpawnNastie_Ready 39500 LD A,(38658) Fetch the sprite ID of the player's actor from ImmortalData.
39503 SUB 16 Subtract 16 (the first Sabreman sprite ID).
39505 CP 32 Return if the player is not alive.
39507 RET NC
Look for an empty record in the nastie table.
39508 LD IX,38802 Point IX at the first nastie record at NastieData.
39512 LD DE,12 Set the size of an actor record in DE to 12.
39515 LD B,6 Set the nastie record counter in B to 6.
SpawnNastie_Loop 39517 LD A,(IX+0) Fetch the sprite ID of the nastie.
39520 AND A Jump to StartNastie if the record is empty.
39521 JR Z,StartNastie
39523 ADD IX,DE Move onto the next nastie record.
39525 DJNZ SpawnNastie_Loop Decrease the nastie record counter by one and loop back to SpawnNastie_Loop until all six records have been checked.
39527 RET Return.
Prev: 39453 Up: Map Next: 39528