Prev: A8F1 Up: Map Next: A95A
A8F9: Handle Land Mine
The update routine for the land mine (object 82). It sits on the floor and is deadly to touch. Every so often one mine in the room leaps and falls. Bit 0 of IX+10 is set while it is leaping, bit 1 while it is falling. IX+11 is the height at the top of the leap. LandMineFlag is set while any mine is leaping.
Input
IX The address of the object
Start a leap if no other mine is leaping.
HandleLandMine A8F9 CALL SetPixelAdjustments Call SetPixelAdjustments.
A8FC CALL SetDeadlyFlags Call SetDeadlyFlags.
A8FF BIT 0,(IX+$10) Jump to HandleLandMine_MoveMine if the mine is already leaping.
A903 JR NZ,HandleLandMine_MoveMine
A905 LD A,($5B43) Return if LandMineFlag is set.
A908 AND A
A909 RET NZ
A90A LD A,($5B05) Fetch RandomSeed2.
A90D INC A Add one to it.
A90E AND %00000011 Keep bits 0 and 1.
A910 RET NZ Return if they are not zero.
A911 LD A,$01 Set A to 01.
A913 LD ($5B43),A Set LandMineFlag.
A916 LD (IX+$10),A Mark this mine as leaping.
A919 LD A,(IX+$03) Fetch the height of the mine.
A91C ADD A,$30 Add 30.
A91E LD (IX+$11),A Store the height at the top of the leap.
Move the mine for this pass.
HandleLandMine_MoveMine A921 BIT 1,(IX+$10) Jump to HandleLandMine_Rising if the mine is not falling.
A925 JR Z,HandleLandMine_Rising
A927 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
A92A BIT 2,(IX+$0C) Jump to HandleLandMine_SoundAndRedraw if the mine has not landed.
A92E JR Z,HandleLandMine_SoundAndRedraw
A930 XOR A Write 00.
A931 LD (IX+$10),A Clear the state of the mine.
A934 LD ($5B43),A Write 00 to LandMineFlag.
Play a sound and redraw the mine.
HandleLandMine_SoundAndRedraw A937 CALL PlaySoundFromHeight Call PlaySoundFromHeight.
A93A JP SetWipeAndDrawFlags Jump to SetWipeAndDrawFlags.
The mine is rising.
HandleLandMine_Rising A93D LD (IX+$0B),$03 Set the vertical speed to 03.
A941 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
A944 LD A,(IX+$03) Fetch the height of the mine.
A947 CP (IX+$11) Jump to HandleLandMine_StartFalling if it has reached the top.
A94A JR NC,HandleLandMine_StartFalling
A94C BIT 2,(IX+$0C) Jump to HandleLandMine_StartFalling if it has hit something above.
A950 JR NZ,HandleLandMine_StartFalling
A952 JR HandleLandMine_SoundAndRedraw Jump to HandleLandMine_SoundAndRedraw.
The mine starts falling.
HandleLandMine_StartFalling A954 SET 1,(IX+$10) Mark the mine as falling.
A958 JR HandleLandMine_SoundAndRedraw Jump to HandleLandMine_SoundAndRedraw.
Prev: A8F1 Up: Map Next: A95A