![]() |
Routines |
| Prev: BBCA | Up: Map | Next: BC37 |
|
Used by the routine at HandleWaitingOutlaw.
Checks whether the next move would take the outlaw past an edge of the area he moves in, and if so changes his speed so that he does not go past it, and sets a bit in IX+05 for the edge: bit 0 for the left edge, bit 1 for the right edge, bit 2 for the lower edge and bit 3 for the upper edge.
|
||||||||
|
Test the left edge.
|
||||||||
| KeepOutlawOnScreen | BBDD | LD (IX+$05),$00 | Clear the flags for the edges. | |||||
| BBE1 | LD A,(IX+$02) | Fetch the horizontal position. | ||||||
| BBE4 | ADD A,(IX+$01) | Add the horizontal speed. | ||||||
| BBE7 | SUB $28 | Subtract the left edge. | ||||||
| BBE9 | JR NC,KeepOutlawOnScreen_Right | Jump if the outlaw is not past it. | ||||||
| BBEB | NEG | Make the distance past the edge positive. | ||||||
| BBED | LD (IX+$01),A | Set it as the horizontal speed, which bounces him back to the right. | ||||||
| BBF0 | SET 0,(IX+$05) | Set the flag for the left edge. | ||||||
|
Test the right edge.
|
||||||||
| KeepOutlawOnScreen_Right | BBF4 | LD A,(IX+$02) | Fetch the horizontal position. | |||||
| BBF7 | ADD A,(IX+$08) | Add the width of the outlaw. | ||||||
| BBFA | ADD A,(IX+$01) | Add the horizontal speed. | ||||||
| BBFD | SUB $D1 | Subtract the right edge. | ||||||
| BBFF | JR C,KeepOutlawOnScreen_Lower | Jump if the outlaw is not past it. | ||||||
| BC01 | NEG | Subtract it from zero, to give the distance still to go to the edge. | ||||||
| BC03 | ADD A,(IX+$01) | Add the horizontal speed. | ||||||
| BC06 | LD (IX+$01),A | Set it as the horizontal speed, which stops him at the edge. | ||||||
| BC09 | SET 1,(IX+$05) | Set the flag for the right edge. | ||||||
|
Test the lower edge.
|
||||||||
| KeepOutlawOnScreen_Lower | BC0D | LD A,(IX+$04) | Fetch the vertical position. | |||||
| BC10 | ADD A,(IX+$03) | Add the vertical speed. | ||||||
| BC13 | SUB $48 | Subtract the lower edge. | ||||||
| BC15 | JR NC,KeepOutlawOnScreen_Upper | Jump if the outlaw is not past it. | ||||||
| BC17 | NEG | Make the distance past the edge positive. | ||||||
| BC19 | LD (IX+$03),A | Set it as the vertical speed, which bounces him back up. | ||||||
| BC1C | SET 2,(IX+$05) | Set the flag for the lower edge. | ||||||
|
Test the upper edge.
|
||||||||
| KeepOutlawOnScreen_Upper | BC20 | LD A,(IX+$04) | Fetch the vertical position. | |||||
| BC23 | ADD A,(IX+$09) | Add the height of the outlaw. | ||||||
| BC26 | ADD A,(IX+$03) | Add the vertical speed. | ||||||
| BC29 | SUB $B9 | Subtract the upper edge. | ||||||
| BC2B | JR C,KeepOutlawOnScreen_Finish | Return if the outlaw is not past it. | ||||||
| BC2D | NEG | Subtract it from zero, to give a speed which takes him back down. | ||||||
| BC2F | LD (IX+$03),A | Set it as the vertical speed. | ||||||
| BC32 | SET 3,(IX+$05) | Set the flag for the upper edge. | ||||||
| KeepOutlawOnScreen_Finish | BC36 | RET | Return. | |||||
| Prev: BBCA | Up: Map | Next: BC37 |