Prev: 35893 Up: Map Next: 35980
35939: Handle Food Item
The handler for the food and drink items (sprite IDs 80 to 87). If the player is not touching the item then the colour of its cells is set by SetItemAttributes. When the player touches it the item is removed, the eating sound is queued (see SoundsEating), and 64 is added to the energy of the player in PlayerEnergy, up to a maximum of 240. The chicken is then redrawn by DrawChicken.
Input
IX The food item entity
HandlerFoodItem 35939 CALL StoreEntity Call StoreEntity to save the position of the item.
35942 CALL CheckPlayerTouching Call CheckPlayerTouching to check whether the player is touching the item.
35945 JR C,HandlerFoodItem_Eat Jump to HandlerFoodItem_Eat if the player is touching it.
35947 JP SetItemAttributes Jump to SetItemAttributes to set the colour of the item.
The player has touched the item, so remove it and give the player some energy.
HandlerFoodItem_Eat 35950 CALL RemoveEntity Call RemoveEntity to remove the item from the screen.
35953 LD (IX+0),0 Write 0 to the sprite ID of the item.
35957 CALL SoundsEating Call SoundsEating to queue the eating sound.
35960 LD C,64 C=64 (the energy that is gained).
35962 LD A,(24104) Fetch the energy of the player from PlayerEnergy.
35965 ADD A,C Add the energy that is gained to the energy of the player.
35966 JR C,HandlerFoodItem_MaximumEnergy Jump to HandlerFoodItem_MaximumEnergy if the energy has overflowed.
35968 CP 240 Jump to HandlerFoodItem_SetEnergy if the energy of the player is lower than 240 which is the maximum.
35970 JR C,HandlerFoodItem_SetEnergy
HandlerFoodItem_MaximumEnergy 35972 LD A,240 A=240 (the maximum energy).
HandlerFoodItem_SetEnergy 35974 LD (24104),A Update the energy of the player in PlayerEnergy.
35977 JP DrawChicken Jump to DrawChicken to redraw the chicken.
Prev: 35893 Up: Map Next: 35980