Prev: CDBB Up: Map Next: CE9A
CE31: Run Bobbing Block
Used by the routine at RunHarmfulBobbingBlock.
The handler of the object type 55, which no room uses. The block falls until it lands, and then it rises until it is at a height of B0, and falls again. It rises faster while something is standing on it. Flag bit 2 of the hit flags is used for the state: it is set while the block is rising.
Input
IX Object record
RunBobbingBlock CE31 CALL SetSpriteOffset_Minus16_Minus8 Call SetSpriteOffset_Minus16_Minus8 to set the offsets of the sprite.
CE34 XOR A Set the speeds along x and y to zero.
CE35 LD (IX+$09),A
CE38 LD (IX+$0A),A
Fall until the block lands, then start rising.
CE3B BIT 2,(IX+$0D) Jump to RunBobbingBlock_Rising if the block is rising.
CE3F JR NZ,RunBobbingBlock_Rising
CE41 LD (IX+$0B),A Set the speed along z to zero.
CE44 CALL ApplyGravityAndMove Call ApplyGravityAndMove to apply gravity to the block and move it.
CE47 BIT 2,(IX+$0C) Jump to RunBobbingBlock_Finish if the block has not landed.
CE4B JR Z,RunBobbingBlock_Finish
CE4D SET 2,(IX+$0D) Flag the block as rising.
CE51 LD (IX+$0B),$02 Set the speed along z to 02.
RunBobbingBlock_Finish CE55 XOR A Set the speeds along x and y to zero.
CE56 LD (IX+$09),A
CE59 LD (IX+$0A),A
CE5C JP SetWipeAndDrawFlags Jump to SetWipeAndDrawFlags to flag the block as moved.
Rise towards B0, faster if something is standing on the block.
RunBobbingBlock_Rising CE5F LD A,($A77B) Fetch the collision flags of the player.
CE62 AND %00001000 Keep the flag for the player jumping.
CE64 JR Z,RunBobbingBlock_Speed Jump to RunBobbingBlock_Speed if the player is not jumping.
CE66 RES 7,(IX+$17) Clear the flag for something having landed on the block.
RunBobbingBlock_Speed CE6A LD A,(IX+$0B) Fetch the speed along z.
CE6D AND A Test it.
CE6E BIT 7,(IX+$17) Jump to RunBobbingBlock_Rise if something has landed on the block.
CE72 JR NZ,RunBobbingBlock_Rise
CE74 AND A Jump to RunBobbingBlock_Fall if the block has no speed along z.
CE75 JR Z,RunBobbingBlock_Fall
RunBobbingBlock_Rise CE77 LD A,$01 Set the speed along z to one.
CE79 JP P,RunBobbingBlock_Move Keep it at one if the block is rising and nothing has landed on it.
CE7C ADD A,$02 Otherwise make it three.
RunBobbingBlock_Move CE7E LD (IX+$0B),A Set the speed along z of the block.
CE81 CALL ApplyGravityAndMove_Move Call ApplyGravityAndMove_Move to move the block, without gravity.
CE84 LD A,(IX+$03) Jump to RunBobbingBlock_Finish if the block is lower than B0.
CE87 CP $B0
CE89 JR C,RunBobbingBlock_Finish
CE8B RES 2,(IX+$0D) Flag the block as not rising.
CE8F JR RunBobbingBlock_Finish Jump to RunBobbingBlock_Finish to finish.
RunBobbingBlock_Fall CE91 CALL ApplyGravityAndMove Call ApplyGravityAndMove to apply gravity to the block and move it.
CE94 RES 2,(IX+$0D) Flag the block as not rising.
CE98 JR RunBobbingBlock_Finish Jump to RunBobbingBlock_Finish to finish.
Prev: CDBB Up: Map Next: CE9A