Prev: 8C35 Up: Map Next: 8C8C
8C63: Handle Food Item
The handler for the food and drink items (sprite IDs 50 to 57). 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 40 is added to the energy of the player in PlayerEnergy, up to a maximum of F0. The chicken is then redrawn by DrawChicken.
Input
IX The food item entity
HandlerFoodItem 8C63 CALL StoreEntity Call StoreEntity to save the position of the item.
8C66 CALL CheckPlayerTouching Call CheckPlayerTouching to check whether the player is touching the item.
8C69 JR C,HandlerFoodItem_Eat Jump to HandlerFoodItem_Eat if the player is touching it.
8C6B 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 8C6E CALL RemoveEntity Call RemoveEntity to remove the item from the screen.
8C71 LD (IX+$00),$00 Write 00 to the sprite ID of the item.
8C75 CALL SoundsEating Call SoundsEating to queue the eating sound.
8C78 LD C,$40 C=40 (the energy that is gained).
8C7A LD A,($5E28) Fetch the energy of the player from PlayerEnergy.
8C7D ADD A,C Add the energy that is gained to the energy of the player.
8C7E JR C,HandlerFoodItem_MaximumEnergy Jump to HandlerFoodItem_MaximumEnergy if the energy has overflowed.
8C80 CP $F0 Jump to HandlerFoodItem_SetEnergy if the energy of the player is lower than F0 which is the maximum.
8C82 JR C,HandlerFoodItem_SetEnergy
HandlerFoodItem_MaximumEnergy 8C84 LD A,$F0 A=F0 (the maximum energy).
HandlerFoodItem_SetEnergy 8C86 LD ($5E28),A Update the energy of the player in PlayerEnergy.
8C89 JP DrawChicken Jump to DrawChicken to redraw the chicken.
Prev: 8C35 Up: Map Next: 8C8C