Prev: 39043 Up: Map Next: 39108
39051: Handle Mushroom
The handler for the mushroom (sprite ID 161). 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 6), and the attributes are set by SetItemAttributes.
Input
IX The mushroom entity
HandlerMushroom 39051 CALL StoreEntity Call StoreEntity to save the position of the mushroom.
39054 CALL CheckPlayerTouching Call CheckPlayerTouching to see whether the player is touching the mushroom.
39057 JR C,HandlerMushroom_Touching Jump to HandlerMushroom_Touching if it is.
HandlerMushroom_Colour 39059 LD A,(24082) Fetch the counter from CounterLow.
39062 CPL Flip the bits.
39063 AND %00000011 Keep only bits 0-1.
39065 JR NZ,HandlerMushroom_Attribute Jump to HandlerMushroom_Attribute unless this is every fourth frame.
39067 INC (IX+6) Increment offset 6 of the mushroom.
HandlerMushroom_Attribute 39070 LD A,(IX+6) A=offset 6 of the mushroom.
39073 AND %00000011 Keep only bits 0-1.
39075 LD C,A Keep the index in C.
39076 LD B,0 B=0.
39078 LD HL,39108 Point HL at the mushroom attributes at MushroomAttributes.
39081 ADD HL,BC Add BC to HL.
39082 LD A,(HL) Fetch the attribute.
39083 LD (IX+5),A Update the attribute of the mushroom.
39086 JP SetItemAttributes Jump to SetItemAttributes to set the attributes of the item.
The player is touching the mushroom, so decrease the energy.
HandlerMushroom_Touching 39089 LD A,(24104) Fetch the energy of the player from PlayerEnergy.
39092 DEC A Decrease it by one.
39093 LD (24104),A Update the energy of the player in PlayerEnergy.
39096 JP Z,RemoveMushroom Jump to RemoveMushroom if the energy is zero.
39099 CALL DrawChicken Call DrawChicken to draw the chicken.
39102 CALL SoundsTouching Call SoundsTouching to make the sound of touching.
39105 JP HandlerMushroom_Colour Jump to HandlerMushroom_Colour to colour the mushroom.
Prev: 39043 Up: Map Next: 39108