Prev: 43339 Up: Map Next: 43432
43393: 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 20) 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 43393 LD A,(41597) Fetch the type of the object in the first slot.
43396 CP 1 Compare it with the type of a sheriff on foot.
43398 RET NZ Return if the sheriff is not on foot.
43399 LD DE,41709 Point DE at ObjectSlot_08.
43402 LD A,(DE) Fetch the type of the object in the slot.
43403 AND A Return if the slot is in use.
43404 RET NZ
Copy the template and place the horse near the sheriff.
43405 PUSH DE Copy DE to IY (using the stack).
43406 POP IY
43408 LD HL,43432 Point HL at HorseTemplate.
43411 LD BC,16 Set the size of an object slot in BC.
43414 LDIR Copy the template into the slot.
43416 LD B,2 Set the distance from the sheriff to two cells.
43418 CALL PlaceNearSheriff Place the horse two cells away from the sheriff.
43421 RET NZ Return if that cell is blocked.
43422 LD (IY+0),20 Turn the slot into a horse.
43426 LD A,64 Set the riding time of the horse to 64.
43428 LD (41481),A
43431 RET Return.
Prev: 43339 Up: Map Next: 43432