Prev: 9A3C Up: Map Next: 9AB8
9A68: Start Nastie
Used by the routine at SpawnNastie.
Turns an empty nastie record into a nastie which is just appearing, unless the player's room already holds the maximum number of nasties (ActivePlayer_NastieLimit) or the position chosen by ChoosePosition is unsuitable. The nastie starts as the first of the five "appearing" sprites (sprite ID 01), in one of four colours chosen from the table at NastieColours using the low bits of the counter at GameTimer.
Input
IX Empty nastie record
Count the nasties which are already in the player's room.
StartNastie 9A68 LD HL,$9792 Point HL at the first nastie record at NastieData.
9A6B LD B,$06 Set the nastie record counter in B to 06.
9A6D LD D,$00 Set the number of nasties in the player's room in D to 00.
9A6F LD A,($9703) Fetch the player's room from 9703 into E.
9A72 LD E,A
StartNastie_CountLoop 9A73 LD A,(HL) Fetch the sprite ID of the nastie.
9A74 AND A Jump to StartNastie_NextRecord if the record is empty.
9A75 JR Z,StartNastie_NextRecord
9A77 INC HL Move onto the room of the nastie.
9A78 LD A,E Compare the room of the nastie with the player's room.
9A79 CP (HL)
9A7A DEC HL Move back to the sprite ID.
9A7B JR NZ,StartNastie_NextRecord Jump to StartNastie_NextRecord if the nastie is in a different room.
9A7D INC D Count the nastie.
StartNastie_NextRecord 9A7E LD A,$0C Set the size of an actor record in A to 0C.
9A80 CALL AddAToHL Move HL onto the next nastie record.
9A83 DJNZ StartNastie_CountLoop Decrease the nastie record counter by one and loop back to StartNastie_CountLoop until all six records have been checked.
Return if the room already holds the maximum number of nasties.
9A85 LD A,($96BE) Fetch the maximum number of nasties allowed in a room from ActivePlayer_NastieLimit.
9A88 CP D Return if the room already holds the maximum number of nasties.
9A89 RET Z
Choose where the nastie will appear and return if the position is not suitable (the carry flag is set).
9A8A CALL ChoosePosition Choose a position for the nastie.
9A8D RET C Return if the position is unsuitable.
Choose a colour for the nastie from the four in the table.
9A8E LD A,($9693) Fetch the low byte of the game timer from GameTimer.
9A91 AND %00000011 Keep only bits 0-1.
9A93 LD L,A Use it as the offset into the colour table.
9A94 LD H,$00
9A96 LD BC,$9AB8 Add the address of the colour table to get the address of the colour.
9A99 ADD HL,BC
9A9A LD A,(HL) Fetch the colour of the nastie from the table.
9A9B LD (IX+$05),A Set the colour of the nastie.
Start the nastie as the first "appearing" sprite.
9A9E LD (IX+$00),$01 Set the sprite ID of the nastie to 01 (appearing).
This entry point is used by the routine at SpawnFlame.
Clear the movement and state bytes of the new actor and draw it.
StartActor_Reset 9AA2 XOR A Clear the velocities and counters of the actor.
9AA3 LD (IX+$06),A
9AA6 LD (IX+$07),A
9AA9 LD (IX+$08),A
9AAC LD (IX+$09),A
9AAF LD (IX+$0A),A
9AB2 LD (IX+$0B),A
9AB5 JP DrawEntity Draw the actor.
Prev: 9A3C Up: Map Next: 9AB8