Prev: B7E0 Up: Map Next: B890
B866: Push Object On Block
Used by the routine at BlockMovementInZ.
Pushes an object that stands on a moving block. The type of the block gives the direction of the push, in the low two bits, and the object is pushed on every other frame. The pushes are in a table of pairs of speeds at ConveyorPushes.
A block is not pushed if it already has something on it, so the first thing on it does the pushing.
Input
A Type of the block
IX Object record
IY Block record
Return if the block already has something on it.
PushObjectOnBlock B866 BIT 3,(IY+$0D) Return if the block already has something on it.
B86A RET NZ
Find the push for this direction.
B86B AND %00000011 Keep the two bits that give the direction.
B86D ADD A,A Double it, to get an offset into the table of pairs.
B86E PUSH DE Stash DE and HL on the stack.
B86F PUSH HL
B870 LD D,$00 Set DE to the offset.
B872 LD E,A
Push on every other frame.
B873 LD A,($A715) Fetch the frame counter.
B876 AND %00000001 Keep only bit 0.
B878 JR Z,PushObjectOnBlock_Done Jump to PushObjectOnBlock_Done if it is an even frame.
B87A LD HL,$D30A Use the table of pushes, ConveyorPushes.
B87D ADD HL,DE Add the offset.
B87E LD A,(HL) Fetch the push along x.
B87F ADD A,(IX+$09) Add it to the speed of the object along x.
B882 LD (IX+$09),A Write it back.
B885 INC HL Move on to the push along y.
B886 LD A,(HL) Fetch it.
B887 ADD A,(IX+$0A) Add it to the speed of the object along y.
B88A LD (IX+$0A),A Write it back.
PushObjectOnBlock_Done B88D POP HL Restore HL and DE from the stack.
B88E POP DE
B88F RET Return.
Prev: B7E0 Up: Map Next: B890