Prev: CC11 Up: Map Next: CC4B
CC31: Set Creature Timer
Used by the routines at RunGame and CreateCreature.
Sets the number of frames that CreateCreature waits before it makes a creature. The timer is four times two more than a count of the entries of the object store at ObjectStore that have one of the types 70 to 73. The loop does not move on from the first entry, though, so the first entry is tested 12 times and the timer is 50 if it has one of the types and 08 if it does not.
Count the matching entries of the object store.
SetCreatureTimer CC31 LD HL,$D432 Start at the first entry of the object store.
CC34 LD DE,$0010 Set the size of an entry (which is not used).
CC37 LD BC,$1202 Set the number of entries in B, which is 12, and the starting count in C, which is 02.
SetCreatureTimer_Loop CC3A LD A,(HL) Fetch the type of the object.
CC3B AND %11111100 Keep the type without its lowest two bits.
CC3D CP $70 Jump to SetCreatureTimer_Next unless it is one of the types 70 to 73.
CC3F JR NZ,SetCreatureTimer_Next
CC41 INC C Add one to the count.
SetCreatureTimer_Next CC42 DJNZ SetCreatureTimer_Loop Count down the entries and jump to SetCreatureTimer_Loop until all are tested.
Set the timer to four times the count.
CC44 LD A,C Fetch the count.
CC45 ADD A,A Multiply it by four.
CC46 ADD A,A
CC47 LD ($A73D),A Set the timer.
CC4A RET Return.
Prev: CC11 Up: Map Next: CC4B