Prev: B31F Up: Map Next: B39A
B33F: Handle Moving Block
The handler for a block which moves up and down (object 1F), and the code which moves the block for HandleRisingBlock. It falls with gravity until it lands, then rises at 03 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 B33F CALL SetPixelAdjustments Call SetPixelAdjustments.
B342 LD A,($5B25) Fetch BlockScratch.
B345 AND A Jump to HandleMovingBlock_Move if it is not zero.
B346 JR NZ,HandleMovingBlock_Move
B348 LD A,(IX+$03) Fetch the height of the block.
B34B LD ($5B25),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 B34E CALL PlaySoundFromHeight Call PlaySoundFromHeight.
B351 XOR A Set A to 00.
B352 LD (IX+$09),A Stop the speed along the x axis.
B355 LD (IX+$0A),A Stop the speed along the y axis.
B358 BIT 2,(IX+$0D) Jump to HandleMovingBlock_Rising if the block is rising.
B35C JR NZ,HandleMovingBlock_Rising
B35E LD (IX+$0B),A Set the speed along the z axis to 00.
B361 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
B364 BIT 2,(IX+$0C) Jump to HandleMovingBlock_Redraw if the block has not landed.
B368 JR Z,HandleMovingBlock_Redraw
B36A SET 2,(IX+$0D) Set bit 2 of the state.
HandleMovingBlock_Redraw B36E JP SetWipeAndDrawFlags Jump to SetWipeAndDrawFlags.
The block is rising.
HandleMovingBlock_Rising B371 LD (IX+$0B),$03 Write 03 as the speed along the z axis.
B375 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
B378 BIT 2,(IX+$0C) Jump to HandleMovingBlock_TestHighestPoint if the block is not blocked.
B37C JR Z,HandleMovingBlock_TestHighestPoint
B37E LD (IX+$0B),$04 Write 04 as the speed along the z axis.
B382 XOR A Set A to 00.
B383 LD (IX+$09),A Stop the speed along the x axis.
B386 LD (IX+$0A),A Stop the speed along the y axis.
B389 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
HandleMovingBlock_TestHighestPoint B38C LD A,($5B25) Fetch BlockScratch.
B38F CP (IX+$03) Jump to HandleMovingBlock_Redraw if the block has not gone above it.
B392 JR NC,HandleMovingBlock_Redraw
B394 RES 2,(IX+$0D) Reset bit 2 of the state.
B398 JR HandleMovingBlock_Redraw Jump to HandleMovingBlock_Redraw.
Prev: B31F Up: Map Next: B39A