![]() |
Routines |
| Prev: A8C1 | Up: Map | Next: A94B |
|
Type 17: a tumbleweed rolling about next to the sheriff. It follows one of two routes, stepping through the route one byte at a time; the high nibble of each byte is the vertical speed and the low nibble the horizontal speed, both signed. Bits 6 and 7 of byte 05 mirror the route, and they change every time a route ends, so the tumbleweed wanders in a different way each time. It spins by flipping its sprite every frame, and it hurts the sheriff if they touch. It goes away when the sheriff is two cells away.
|
||||
|
Disappear if the sheriff is more than two cells away.
|
||||
| HandleTumbleweed | A8D5 | LD C,$02 | Set the distance to two cells. | |
| A8D7 | CALL CheckDistance | Check how close the sheriff is. | ||
| A8DA | JP NC,HandleBody_Remove | Remove the tumbleweed if the sheriff has moved away. | ||
|
Fetch the next step of the route.
|
||||
| A8DD | LD A,(IX+$0A) | Fetch the number of the route, zero or one. | ||
| A8E0 | LD BC,$A94B | Point BC at TumbleweedRoutes. | ||
| A8E3 | CALL GetTableEntry | Point HL at the start of the route. | ||
| A8E6 | LD A,(IX+$0B) | Fetch the position in the route. | ||
| A8E9 | INC (IX+$0B) | Move on to the next step. | ||
| A8EC | CALL AddAToHL | Point HL at the step. | ||
| A8EF | LD A,(HL) | Fetch the step. | ||
| A8F0 | CP $80 | Jump to HandleTumbleweed_RouteEnd if this is the end of the route. | ||
| A8F2 | JR Z,HandleTumbleweed_RouteEnd | |||
|
Work out the vertical speed from the high nibble.
|
||||
| A8F4 | SRA A | Shift the high nibble into the bottom of the byte, keeping the sign. | ||
| A8F6 | SRA A | |||
| A8F8 | SRA A | |||
| A8FA | SRA A | |||
| A8FC | BIT 6,(IX+$05) | Jump to HandleTumbleweed_DoubleVertical unless the route is mirrored vertically. | ||
| A900 | JR Z,HandleTumbleweed_DoubleVertical | |||
| A902 | NEG | Negate the speed to mirror the route. | ||
| HandleTumbleweed_DoubleVertical | A904 | SLA A | Double the speed. | |
| A906 | LD ($A215),A | Store it as the vertical speed. | ||
|
Work out the horizontal speed from the low nibble.
|
||||
| A909 | LD A,(HL) | Fetch the step again. | ||
| A90A | LD C,A | Keep the tumbleweed step in C. | ||
| A90B | AND %00001111 | Keep the low nibble. | ||
| A90D | BIT 3,C | Jump to HandleTumbleweed_TestHorizontal unless the nibble is negative. | ||
| A90F | JR Z,HandleTumbleweed_TestHorizontal | |||
| A911 | OR %11110000 | Extend the sign of the nibble into the top half. | ||
| HandleTumbleweed_TestHorizontal | A913 | BIT 7,(IX+$05) | Jump to HandleTumbleweed_DoubleHorizontal unless the route is mirrored horizontally. | |
| A917 | JR Z,HandleTumbleweed_DoubleHorizontal | |||
| A919 | NEG | Negate the speed to mirror the route. | ||
| HandleTumbleweed_DoubleHorizontal | A91B | SLA A | Double the speed. | |
| A91D | LD ($A214),A | Store it as the horizontal speed. | ||
|
Move the tumbleweed.
|
||||
| A920 | CALL CheckWallsEachWay | Set the direction the tumbleweed is facing from its speed. | ||
| A923 | CALL MoveObject | Move the tumbleweed. | ||
| A926 | LD A,(IX+$07) | Fetch the flags of the object. | ||
| A929 | XOR %01000000 | Flip the sprite horizontally. | ||
| A92B | LD (IX+$07),A | Store the flags. | ||
| A92E | CALL CheckSheriffTouch | Check whether the tumbleweed is touching the sheriff. | ||
| A931 | JP C,KillSheriff | Hurt the sheriff if it is. | ||
| A934 | RET | Return. | ||
|
The route has ended, so choose the next one.
|
||||
| HandleTumbleweed_RouteEnd | A935 | LD A,($A218) | Fetch a random number. | |
| A938 | AND %00000001 | Keep bit 0. | ||
| A93A | LD (IX+$0A),A | Choose the route with it. | ||
| A93D | LD (IX+$0B),$00 | Write 00 to byte 0B to go back to the first step. | ||
| A941 | LD A,(IX+$05) | Fetch the mirror flags. | ||
| A944 | ADD A,$40 | Add 40 to change how the route is mirrored. | ||
| A946 | LD (IX+$05),A | Store the flags. | ||
| A949 | JR HandleTumbleweed | Start again with the new route. | ||
| Prev: A8C1 | Up: Map | Next: A94B |