Prev: 45855 Up: Map Next: 45978
45887: Handle Moving Block
The handler for a block which moves up and down (object 31), and the code which moves the block for HandleRisingBlock. It falls with gravity until it lands, then rises at 3 until it is higher than BlockScratch, when it falls again. The first block sets BlockScratch to its own height. Bit 2 of the state remembers whether it is rising.
Input
IX The address of the object
Set BlockScratch the first time a block is handled.
HandleMovingBlock 45887 CALL SetPixelAdjustments Call SetPixelAdjustments.
45890 LD A,(23333) Fetch BlockScratch.
45893 AND A Jump to HandleMovingBlock_Move if it is not zero.
45894 JR NZ,HandleMovingBlock_Move
45896 LD A,(IX+3) Fetch the height of the block.
45899 LD (23333),A Set BlockScratch.
This entry point is used by the routine at HandleRisingBlock.
Fall with gravity until the block lands, then start rising.
HandleMovingBlock_Move 45902 CALL PlaySoundFromHeight Call PlaySoundFromHeight.
45905 XOR A Set A to 0.
45906 LD (IX+9),A Stop the speed along the x axis.
45909 LD (IX+10),A Stop the speed along the y axis.
45912 BIT 2,(IX+13) Jump to HandleMovingBlock_Rising if the block is rising.
45916 JR NZ,HandleMovingBlock_Rising
45918 LD (IX+11),A Set the speed along the z axis to 0.
45921 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
45924 BIT 2,(IX+12) Jump to HandleMovingBlock_Redraw if the block has not landed.
45928 JR Z,HandleMovingBlock_Redraw
45930 SET 2,(IX+13) Set bit 2 of the state.
HandleMovingBlock_Redraw 45934 JP SetWipeAndDrawFlags Jump to SetWipeAndDrawFlags.
The block is rising.
HandleMovingBlock_Rising 45937 LD (IX+11),3 Write 3 as the speed along the z axis.
45941 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
45944 BIT 2,(IX+12) Jump to HandleMovingBlock_TestHighestPoint if the block is not blocked.
45948 JR Z,HandleMovingBlock_TestHighestPoint
45950 LD (IX+11),4 Write 4 as the speed along the z axis.
45954 XOR A Set A to 0.
45955 LD (IX+9),A Stop the speed along the x axis.
45958 LD (IX+10),A Stop the speed along the y axis.
45961 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
HandleMovingBlock_TestHighestPoint 45964 LD A,(23333) Fetch BlockScratch.
45967 CP (IX+3) Jump to HandleMovingBlock_Redraw if the block has not gone above it.
45970 JR NC,HandleMovingBlock_Redraw
45972 RES 2,(IX+13) Reset bit 2 of the state.
45976 JR HandleMovingBlock_Redraw Jump to HandleMovingBlock_Redraw.
Prev: 45855 Up: Map Next: 45978