![]() |
Routines |
| Prev: A5C8 | Up: Map | Next: A601 |
|
Used by the routines at HandlerChooseNastie and HandlerWanderingNastie.
Chooses the velocity for a wandering actor. If it is moving then it is stopped (by StopActor). If it has stopped then it is given a random X velocity and a random Y velocity from VelocityTable, and the sprite is made to face the way it is going.
|
||||||||
| ChooseVelocity | A5CD | LD A,(IX+$06) | Fetch the X velocity of the actor. | |||||
| A5D0 | OR (IX+$07) | Combine it with the Y velocity. | ||||||
| A5D3 | JR NZ,StopActor | Jump to StopActor to stop the actor if it is moving. | ||||||
|
Choose the X velocity.
|
||||||||
| A5D5 | LD A,($9695) | Fetch the random seed from RandomNumber. | ||||||
| A5D8 | AND %00000111 | Keep only bits 0-2. | ||||||
| A5DA | LD L,A | Stash the velocity index in L. | ||||||
| A5DB | LD H,$00 | Clear H. | ||||||
| A5DD | LD BC,$A601 | Point BC at the table of velocities at VelocityTable. | ||||||
| A5E0 | ADD HL,BC | Add the table address to get the address of the velocity. | ||||||
| A5E1 | LD A,(HL) | Fetch the velocity from the table. | ||||||
| A5E2 | LD (IX+$06),A | Set the X velocity of the actor. | ||||||
| A5E5 | BIT 7,A | Jump to ChooseVelocity_Right if the actor is moving right. | ||||||
| A5E7 | JR Z,ChooseVelocity_Right | |||||||
| A5E9 | RES 1,(IX+$00) | Reset bit 1 of the sprite ID so that the actor faces left. | ||||||
|
Choose the Y velocity.
|
||||||||
| ChooseVelocity_Y | A5ED | LD A,($5C78) | Fetch the low byte of FRAMES. | |||||
| A5F0 | AND %00000111 | Keep only bits 0-2. | ||||||
| A5F2 | LD L,A | Stash the velocity index in L. | ||||||
| A5F3 | LD H,$00 | Clear H. | ||||||
| A5F5 | ADD HL,BC | Add the table address to get the address of the velocity. | ||||||
| A5F6 | LD A,(HL) | Fetch the velocity from the table. | ||||||
| A5F7 | LD (IX+$07),A | Set the Y velocity of the actor. | ||||||
| A5FA | RET | Return. | ||||||
|
The actor is moving to the right.
|
||||||||
| ChooseVelocity_Right | A5FB | SET 1,(IX+$00) | Set bit 1 of the sprite ID so that the actor faces right. | |||||
| A5FF | JR ChooseVelocity_Y | Jump to ChooseVelocity_Y to choose the Y velocity. | ||||||
| Prev: A5C8 | Up: Map | Next: A601 |