Prev: A94B Up: Map Next: A9A8
A981: Create Horse
Used by the routine at CreateTownObjects.
Called every frame in town. While the sheriff is on foot it puts a horse (an object of type 14) in the eighth object slot, two cells from the sheriff, if the slot is free.
While the sheriff is on foot, use the eighth slot if it is free.
CreateHorse A981 LD A,($A27D) Fetch the type of the object in the first slot.
A984 CP $01 Compare it with the type of a sheriff on foot.
A986 RET NZ Return if the sheriff is not on foot.
A987 LD DE,$A2ED Point DE at ObjectSlot_08.
A98A LD A,(DE) Fetch the type of the object in the slot.
A98B AND A Return if the slot is in use.
A98C RET NZ
Copy the template and place the horse near the sheriff.
A98D PUSH DE Copy DE to IY (using the stack).
A98E POP IY
A990 LD HL,$A9A8 Point HL at HorseTemplate.
A993 LD BC,$0010 Set the size of an object slot in BC.
A996 LDIR Copy the template into the slot.
A998 LD B,$02 Set the distance from the sheriff to two cells.
A99A CALL PlaceNearSheriff Place the horse two cells away from the sheriff.
A99D RET NZ Return if that cell is blocked.
A99E LD (IY+$00),$14 Turn the slot into a horse.
A9A2 LD A,$40 Set the riding time of the horse to 40.
A9A4 LD ($A209),A
A9A7 RET Return.
Prev: A94B Up: Map Next: A9A8