Prev: 9883 Up: Map Next: 98C4
988B: Handle Mushroom
The handler for the mushroom (sprite ID A1). While the player is touching it (see CheckPlayerTouching), the energy in PlayerEnergy is decreased by one every frame, the chicken is drawn again with DrawChicken and a sound is made with SoundsTouching. When the energy reaches zero the mushroom is removed by RemoveMushroom. The attribute of the mushroom cycles round the colours in MushroomAttributes, changing every fourth frame (using offset 06), and the attributes are set by SetItemAttributes.
Input
IX The mushroom entity
HandlerMushroom 988B CALL StoreEntity Call StoreEntity to save the position of the mushroom.
988E CALL CheckPlayerTouching Call CheckPlayerTouching to see whether the player is touching the mushroom.
9891 JR C,HandlerMushroom_Touching Jump to HandlerMushroom_Touching if it is.
HandlerMushroom_Colour 9893 LD A,($5E12) Fetch the counter from CounterLow.
9896 CPL Flip the bits.
9897 AND %00000011 Keep only bits 0-1.
9899 JR NZ,HandlerMushroom_Attribute Jump to HandlerMushroom_Attribute unless this is every fourth frame.
989B INC (IX+$06) Increment offset 06 of the mushroom.
HandlerMushroom_Attribute 989E LD A,(IX+$06) A=offset 06 of the mushroom.
98A1 AND %00000011 Keep only bits 0-1.
98A3 LD C,A Keep the index in C.
98A4 LD B,$00 B=00.
98A6 LD HL,$98C4 Point HL at the mushroom attributes at MushroomAttributes.
98A9 ADD HL,BC Add BC to HL.
98AA LD A,(HL) Fetch the attribute.
98AB LD (IX+$05),A Update the attribute of the mushroom.
98AE JP SetItemAttributes Jump to SetItemAttributes to set the attributes of the item.
The player is touching the mushroom, so decrease the energy.
HandlerMushroom_Touching 98B1 LD A,($5E28) Fetch the energy of the player from PlayerEnergy.
98B4 DEC A Decrease it by one.
98B5 LD ($5E28),A Update the energy of the player in PlayerEnergy.
98B8 JP Z,RemoveMushroom Jump to RemoveMushroom if the energy is zero.
98BB CALL DrawChicken Call DrawChicken to draw the chicken.
98BE CALL SoundsTouching Call SoundsTouching to make the sound of touching.
98C1 JP HandlerMushroom_Colour Jump to HandlerMushroom_Colour to colour the mushroom.
Prev: 9883 Up: Map Next: 98C4