Prev: AC6B Up: Map Next: AD54
AD13: Handle Egg Top
The handler for the top half of a broken egg (object 49), which is deadly to touch. Only one is active at a time (EggTopFlag is set), and none are while EggTopDisabledFlag is set. An inactive egg top becomes active with a chance of one in sixteen on each frame. While it is active it is moved with gravity and makes a sound when it lands. Until then it hangs in the air.
Input
IX The address of the object
Hang in the air until this egg is chosen to drop.
HandleEggTop AD13 CALL SetDeadlyFlags Call SetDeadlyFlags.
AD16 CALL SetPixelAdjustments_Appearing Call SetPixelAdjustments_Appearing.
AD19 LD A,($5B3B) Return if EggTopDisabledFlag is set.
AD1C AND A
AD1D RET NZ
AD1E BIT 2,(IX+$0D) Jump to HandleEggTop_MoveActive if this egg top is already active.
AD22 JR NZ,HandleEggTop_MoveActive
AD24 LD HL,$5B3A Point HL at EggTopFlag.
AD27 LD A,(HL) Return if EggTopFlag is set.
AD28 AND A
AD29 RET NZ
AD2A LD A,($5B05) Fetch RandomSeed2.
AD2D CP $10 Return unless it is less than 10.
AD2F RET NC
AD30 SET 2,(IX+$0D) Set bit 2 of the state.
AD34 LD (HL),$01 Write 01 to EggTopFlag.
AD36 RET Return.
The egg top is active, so let it fall.
HandleEggTop_MoveActive AD37 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
AD3A CALL PlayLandingSoundOnce Call PlayLandingSoundOnce.
AD3D BIT 2,(IX+$0C) Jump to HandleEggTop_Landed if it has landed.
AD41 JR NZ,HandleEggTop_Landed
AD43 CALL PlaySoundFromHeight Call PlaySoundFromHeight.
HandleEggTop_Redraw AD46 JP SetWipeAndDrawFlags Jump to SetWipeAndDrawFlags.
The egg top has landed, so another one may drop.
HandleEggTop_Landed AD49 RES 2,(IX+$0D) Reset bit 2 of the state.
AD4D LD HL,$5B3A Point HL at EggTopFlag.
AD50 LD (HL),$00 Write 00 to EggTopFlag.
AD52 JR HandleEggTop_Redraw Jump to HandleEggTop_Redraw.
View the equivalent code in;
Prev: AC6B Up: Map Next: AD54