← D186 H-rotor behavior handler Map D20F → Visor behavior handler
D1B9: Wheel behavior handler
Runs the wheel each frame. It animates an 8-frame loop and follows its spawned heading.
It bounces off solid tiles. It remembers its last vertical heading (up or down) in its logic record. While its heading is horizontal (right or left) the travel counter in its record ticks once per pass. At the eighth count it toggles the saved vertical heading between up and down and steers that way.
Every horizontal run starts from zero. The spawn clears the counter, and so does the wall-avoid bias each time a blocked probe sends the wheel horizontally toward the bat. A wheel blocked before its eighth count never flips. The counter does not tick while the wheel heads vertically. The result is a vertical zig-zag whose horizontal legs last at most eight passes.
It advances, and the far edge takes it. It runs no sweep, so only a ball kill can destroy it.
update_wheel D1B9 CALL inhabitant_react_state Run the shared reaction machine; skip the update while a spawn or death animation plays.
D1BC RET C
D1BD LD HL,anim_wheel Advance its 8-frame animation.
D1C0 CALL advance_anim
D1C3 LD A,(IY+$0B) Loop the animation, and wrap the frame at the end of its table.
D1C6 CP $08
D1C8 JR C,update_wheel_0
D1CA LD (IY+$0B),$00
update_wheel_0 D1CE LD A,(IY+$00) Is the heading vertical – straight up or straight down?
D1D1 OR A
D1D2 JR Z,update_wheel_1
D1D4 CP $04
D1D6 JR NZ,update_wheel_2
update_wheel_1 D1D8 LD (IY+$0F),A If so, save it as the last vertical direction.
update_wheel_2 D1DB LD A,(IY+$00) Zig-zag only while the move is horizontal.
D1DE CP $02
D1E0 JR Z,update_wheel_3
D1E2 CP $06
D1E4 JR NZ,update_wheel_6
update_wheel_3 D1E6 INC (IY+$09) Is this the frame that flips the heading?
D1E9 LD A,(IY+$09)
D1EC CP $08
D1EE JR NZ,update_wheel_6
D1F0 LD A,(IY+$0F) A saved downward heading flips to up.
D1F3 CP $04
D1F5 JR NZ,update_wheel_4
D1F7 XOR A
D1F8 JR update_wheel_5
update_wheel_4 D1FA LD A,$04 Anything else flips to down.
update_wheel_5 D1FC LD (IY+$00),A Steer that way.
update_wheel_6 D1FF CALL object_avoid_walls Bounce off walls, advance, and despawn off the far edge.
D202 CALL move_object
D205 CALL inhabitant_offscreen
D208 RET C
D209 LD B,$0A A ball kill destroys it for 100 points; the result is ignored.
D20B CALL ball_kill
D20E RET
← D186 H-rotor behavior handler Map D20F → Visor behavior handler
Fork me on GitHub