Prev: A54A Up: Map Next: A5A9
A54F: Handler: Wandering Nastie
Handles the nastie types which wander about: the spider (sprite IDs 60 to 63), scorpion (64 to 67), parrot (6C to 6F), monkey (70 to 73) and all of the nastie types which are only possible later in the game (98 to 9F and B0 to C3).
The nastie moves with a velocity chosen by ChooseVelocity, which also makes it pause for a while. It chooses a new velocity when the timer in IX+02 runs out or when it is blocked. It bounces off the edges of the screen, is stopped by objects in the room, and is blown up (by BlowUpActor) if it touches the player or if the player is not alive.
Input
IX Nastie record
Count off the nastie if it is not in the same room as the player.
HandlerWanderingNastie A54F LD A,($9703) Fetch the room of the player from 9703.
A552 CP (IX+$01) Jump to ExpireActor if the nastie is in a different room to the player.
A555 JP NZ,ExpireActor
A558 LD A,$17 Set the width of the nastie in Actor_Width to 17.
A55A LD ($96AD),A
A55D CALL StoreEntity Remember the previous position of the nastie.
Blow up the nastie if the player is not alive.
A560 LD A,($9702) Fetch the sprite ID of the player from ImmortalData.
A563 SUB $10 Subtract 10 (the first Sabreman sprite ID).
A565 CP $20 Jump to BlowUpActor to blow up the nastie if the player is not alive.
A567 JP NC,BlowUpActor
Choose a new velocity when the timer has run out.
A56A DEC (IX+$02) Decrease the velocity timer by one and choose a new velocity if it has run out.
A56D CALL Z,ChooseVelocity
Skip the move if the nastie is not moving.
A570 LD A,(IX+$06) Fetch the X velocity of the nastie.
A573 OR (IX+$07) Combine it with the Y velocity.
A576 JR Z,HandlerWanderingNastie_Touch Jump to HandlerWanderingNastie_Touch if the nastie is not moving.
Move the nastie, bouncing it off the edges of the screen.
A578 CALL CalculateNewPosition Work out the new position of the nastie.
A57B BIT 0,B Jump to BounceWanderingNastieHorizontally if the nastie has hit the left or right edge of the screen.
A57D JR NZ,BounceWanderingNastieHorizontally
A57F BIT 1,B Jump to BounceWanderingNastieVertically if the nastie has hit the top or bottom edge of the screen.
A581 JR NZ,BounceWanderingNastieVertically
This entry point is used by the routines at BounceWanderingNastieHorizontally and BounceWanderingNastieVertically.
Stop the nastie moving through objects in the room. If it did not manage to move then choose a new velocity.
HandlerWanderingNastie_Move A583 LD BC,$1717 Set the height and width of the nastie in B and C to 17.
A586 CALL SlideActorPastObjects Stop the nastie passing through objects in the room.
A589 CALL TestPositionUnchanged Test whether the nastie has stayed where it was.
A58C CALL Z,ChooseVelocity Choose a new velocity if the nastie has stayed where it was.
Flip the animation frame and store the new position.
A58F LD A,(IX+$00) Fetch the sprite ID of the nastie.
A592 XOR %00000001 Flip bit 0.
A594 LD (IX+$00),A Set the new sprite ID of the nastie.
A597 LD (IX+$03),E Set the X position of the nastie.
A59A LD (IX+$04),D Set the Y position of the nastie.
Blow up the nastie if it touches the player, otherwise draw it.
HandlerWanderingNastie_Touch A59D LD BC,$1313 Set the reach used to test whether the nastie is touching the player in BC to 1313.
A5A0 CALL TestActorHurtingPlayer Test whether the nastie is touching the player.
A5A3 JP NC,DisplayActor Jump to DisplayActor to display the nastie if it is not touching the player.
A5A6 JP BlowUpActor Jump to BlowUpActor to blow up the nastie.
Prev: A54A Up: Map Next: A5A9