Prev: 48074 Up: Map Next: 48183
48093: Keep Outlaw On Screen
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+5 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.
Input
IX The address of the outlaw
Test the left edge.
KeepOutlawOnScreen 48093 LD (IX+5),0 Clear the flags for the edges.
48097 LD A,(IX+2) Fetch the horizontal position.
48100 ADD A,(IX+1) Add the horizontal speed.
48103 SUB 40 Subtract the left edge.
48105 JR NC,KeepOutlawOnScreen_Right Jump if the outlaw is not past it.
48107 NEG Make the distance past the edge positive.
48109 LD (IX+1),A Set it as the horizontal speed, which bounces him back to the right.
48112 SET 0,(IX+5) Set the flag for the left edge.
Test the right edge.
KeepOutlawOnScreen_Right 48116 LD A,(IX+2) Fetch the horizontal position.
48119 ADD A,(IX+8) Add the width of the outlaw.
48122 ADD A,(IX+1) Add the horizontal speed.
48125 SUB 209 Subtract the right edge.
48127 JR C,KeepOutlawOnScreen_Lower Jump if the outlaw is not past it.
48129 NEG Subtract it from zero, to give the distance still to go to the edge.
48131 ADD A,(IX+1) Add the horizontal speed.
48134 LD (IX+1),A Set it as the horizontal speed, which stops him at the edge.
48137 SET 1,(IX+5) Set the flag for the right edge.
Test the lower edge.
KeepOutlawOnScreen_Lower 48141 LD A,(IX+4) Fetch the vertical position.
48144 ADD A,(IX+3) Add the vertical speed.
48147 SUB 72 Subtract the lower edge.
48149 JR NC,KeepOutlawOnScreen_Upper Jump if the outlaw is not past it.
48151 NEG Make the distance past the edge positive.
48153 LD (IX+3),A Set it as the vertical speed, which bounces him back up.
48156 SET 2,(IX+5) Set the flag for the lower edge.
Test the upper edge.
KeepOutlawOnScreen_Upper 48160 LD A,(IX+4) Fetch the vertical position.
48163 ADD A,(IX+9) Add the height of the outlaw.
48166 ADD A,(IX+3) Add the vertical speed.
48169 SUB 185 Subtract the upper edge.
48171 JR C,KeepOutlawOnScreen_Finish Return if the outlaw is not past it.
48173 NEG Subtract it from zero, to give a speed which takes him back down.
48175 LD (IX+3),A Set it as the vertical speed.
48178 SET 3,(IX+5) Set the flag for the upper edge.
KeepOutlawOnScreen_Finish 48182 RET Return.
Prev: 48074 Up: Map Next: 48183