![]() |
Routines |
| Prev: B691 | Up: Map | Next: B6F8 |
|
Used by the routines at CreateMoneyBag, CreateTumbleweed, CreateHorse, CreateDirectionPointer and CreateBystander.
Puts an object in a cell which is a number of cells away from the sheriff, both across and up the screen. Which of the four diagonal directions is used depends on the bottom two bits of the frame counter.
|
||||||||||||||
|
Fetch the sheriff's cell and the frame counter.
|
||||||||||||||
| PlaceNearSheriff | B6CD | LD A,($A27F) | Fetch the horizontal cell of the sheriff and keep it in L. | |||||||||||
| B6D0 | LD L,A | |||||||||||||
| B6D1 | LD A,($A281) | Fetch the vertical cell of the sheriff and keep it in H. | ||||||||||||
| B6D4 | LD H,A | |||||||||||||
| B6D5 | LD A,($A216) | Fetch the frame counter and keep it in C. | ||||||||||||
| B6D8 | LD C,A | |||||||||||||
|
Choose a diagonal from the bottom two bits of the frame.
|
||||||||||||||
| B6D9 | LD A,B | Fetch the distance. | ||||||||||||
| B6DA | BIT 0,C | Jump to PlaceNearSheriff_AddHorizontal if bit 0 of the frame counter is clear. | ||||||||||||
| B6DC | JR Z,PlaceNearSheriff_AddHorizontal | |||||||||||||
| B6DE | NEG | Go in the other direction horizontally. | ||||||||||||
| PlaceNearSheriff_AddHorizontal | B6E0 | ADD A,L | Add the horizontal cell of the sheriff. | |||||||||||
| B6E1 | AND %00001111 | Wrap round the town. | ||||||||||||
| B6E3 | LD L,A | Keep the wrapped horizontal cell in L. | ||||||||||||
| B6E4 | LD A,B | Fetch the distance again. | ||||||||||||
| B6E5 | BIT 1,C | Jump to PlaceNearSheriff_AddVertical if bit 1 of the frame counter is clear. | ||||||||||||
| B6E7 | JR Z,PlaceNearSheriff_AddVertical | |||||||||||||
| B6E9 | NEG | Go in the other direction vertically. | ||||||||||||
| PlaceNearSheriff_AddVertical | B6EB | ADD A,H | Add the vertical cell of the sheriff. | |||||||||||
| B6EC | AND %00001111 | Wrap round the town. | ||||||||||||
| B6EE | LD H,A | Keep the wrapped vertical cell in H. | ||||||||||||
|
Store the cell and test whether it is free.
|
||||||||||||||
| B6EF | LD (IY+$02),L | Set the horizontal cell of the object. | ||||||||||||
| B6F2 | LD (IY+$04),H | Set the vertical cell of the object. | ||||||||||||
| B6F5 | JP GetMapCell | Jump to GetMapCell. | ||||||||||||
| Prev: B691 | Up: Map | Next: B6F8 |