← C874 Test whether a candidate tile blocks movement Map C8C2 → Pick a new wander heading on a timer
C897: Bias a replacement heading for the wheel
Post-processes a candidate heading (E) chosen by object_avoid_walls. For every object except the wheel it returns E unchanged. The wheel homes on the bat's edge, so the routine biases its heading toward that edge.
Input
E candidate heading from object_avoid_walls
IY the object's logic record (obj2_record)
Output
E the heading: unchanged, or steered toward the bat's edge for the wheel
The wheel only. If the candidate heading is vertical, the travel counter is cleared and the wheel steers toward the bat's edge. It steers rightward when the bat is on the right, and leftward when it is on the left. If the candidate is not vertical, a vertical heading is forced instead, opposite to the saved one. It is up when the saved one is down, and otherwise down.
object_steer C897 LD A,(IY+$08) Bias only the wheel; other types keep E.
C89A CP $0D
C89C RET NZ
C89D LD A,E A vertical candidate heading? Steer toward the bat.
C89E OR A
C89F JR Z,steer_toward_bat
C8A1 CP $04
C8A3 JR Z,steer_toward_bat
C8A5 LD A,(IY+$0F) Non-vertical candidate: force a vertical heading, opposite to the saved heading, whose down value clears E.
C8A8 CP $04
C8AA JR NZ,steer_vertical_alt
C8AC LD E,$00
C8AE RET
steer_vertical_alt C8AF LD E,$04 Otherwise take the other vertical heading.
C8B1 RET
steer_toward_bat C8B2 XOR A Clear the travel counter.
C8B3 LD (IY+$09),A
C8B6 LD A,(bat_side) Bat on the right edge?
C8B9 OR A
C8BA JR NZ,steer_toward_left
C8BC LD E,$02 Yes: head rightward, toward the bat.
C8BE RET
steer_toward_left C8BF LD E,$06 Bat on the left edge: head leftward, toward it.
C8C1 RET
← C874 Test whether a candidate tile blocks movement Map C8C2 → Pick a new wander heading on a timer
Fork me on GitHub