Prev: 991C Up: Map Next: 9962
9924: Grow the food back, one slot every 512 passes
Used by the routine at MAIN_LOOP_MONSTERS.
On a pass when TICKS' low byte is zero and bit 0 of its high byte clear -- once in 512 -- REGROW_CURSOR ($5E55) steps to the next of the eighty food records, wrapping from the mushrooms back to the first. If that slot is empty and not in the player's room, it is refilled with a random kind of food, $50 + FRAMES AND 7, in its old place (measured in the simulator). A whole round of the eighty takes 512 times 80 passes, about half an hour.
REGROW_FOOD 9924 LD A,($5E12)
9927 LD C,A
9928 LD A,($5E13)
992B AND $01
992D OR C
992E RET NZ
992F LD HL,($5E55)
9932 LD DE,$0008
9935 ADD HL,DE
9936 LD ($5E55),HL
9939 PUSH HL
993A POP IX
993C LD DE,$EDD8
993F AND A
9940 SBC HL,DE
9942 JR NC,REGROW_FOOD_0
9944 LD A,($EA91)
9947 CP (IX+$01)
994A RET Z
994B LD A,(IX+$00)
994E AND A
994F RET NZ
9950 LD A,($5C78)
9953 AND $07
9955 ADD A,$50
9957 LD (IX+$00),A
995A RET
REGROW_FOOD_0 995B LD HL,$EB58
995E LD ($5E55),HL
9961 RET
Prev: 991C Up: Map Next: 9962