Prev: B647 Up: Map Next: B6CD
B691: Create Bystander
Used by the routine at CreateTownObjects.
Called every frame in the town. Looks for a free slot among the tenth to thirteenth object slots, and if there is one puts a bystander (an object of type 06) in it, one cell away from the sheriff.
CreateBystander B691 LD IY,$A30D Point IY at the tenth object slot.
B695 LD DE,$0010 Set the size of an object slot.
B698 LD B,$04 Set the number of slots to four.
CreateBystander_Loop B69A LD A,(IY+$00) Fetch the type of the object in the slot.
B69D AND A Jump to CreateBystander_Found if the slot is free.
B69E JR Z,CreateBystander_Found
B6A0 ADD IY,DE Move on to the next slot.
B6A2 DJNZ CreateBystander_Loop Loop back until all four slots have been checked.
B6A4 RET Return.
Place a bystander in the free slot.
CreateBystander_Found B6A5 LD B,$01 Set the distance from the sheriff to one cell.
B6A7 CALL PlaceNearSheriff Place the bystander one cell away from the sheriff.
B6AA RET NZ Return if that cell is blocked.
B6AB CALL SetPositionInCell Set the position of the bystander within its cell.
B6AE LD A,($A21A) Fetch a random number.
B6B1 AND %00000110 Keep bits 1 and 2.
B6B3 ADD A,$04 Add four to give a speed of four, six, eight or ten.
B6B5 LD (IY+$05),A Set the speed of the bystander.
B6B8 LD (IY+$00),$06 Turn the slot into a bystander.
B6BC LD (IY+$06),$01 Set the direction of the bystander.
B6C0 LD (IY+$08),$10 Set the horizontal size of the bystander.
B6C4 LD (IY+$09),$10 Set the vertical size of the bystander.
B6C8 LD (IY+$0D),$00 Clear the counter used for slowing down changes of sprite.
B6CC RET Return.
Prev: B647 Up: Map Next: B6CD