Prev: B6B9 Up: Map Next: B6DB
B6BF: Shuttling block: the common part
Used by the routine at upd_55.
One routine serves both axes by patching the displacement bytes of two IX instructions: the read of the position at shuttle_block_step and the write of the step at shuttle_block_move.
The block follows the frame counter. Folding the counter at bit 4 gives a triangle wave, 0 up to 15 and back down over 32 frames, and the block steps one unit a frame towards that position within a 16-unit span. Blocks in odd-numbered object records add 16 to the counter first, which puts them half a cycle out of step with their even-numbered neighbours: one is at the far end while the next is at the near one.
Input
H the offset of the axis to follow, 1 (X) or 2 (Y)
L the offset of the delta to set, 9 (dX) or 10 (dY)
shuttle_block B6BF LD A,H patch the two displacements
B6C0 LD ($B6E0),A
B6C3 LD A,L
B6C4 LD ($B6F1),A
B6C7 CALL upd_6_7 pixel offsets
B6CA PUSH IX C = 16 if IX is an odd-numbered record, else 0
B6CC POP BC
B6CD LD A,C
B6CE RRCA
B6CF AND $10
B6D1 LD C,A
B6D2 LD A,($5BA2) frame counter plus C, folded when bit 4 is set
B6D5 ADD A,C
B6D6 BIT 4,A
B6D8 JR Z,shuttle_block_target
B6DA CPL
Prev: B6B9 Up: Map Next: B6DB