Prev: 52241 Up: Map Next: 52299
52273: 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 112 to 115. The loop does not move on from the first entry, though, so the first entry is tested 18 times and the timer is 80 if it has one of the types and 8 if it does not.
Count the matching entries of the object store.
SetCreatureTimer 52273 LD HL,54322 Start at the first entry of the object store.
52276 LD DE,16 Set the size of an entry (which is not used).
52279 LD BC,4610 Set the number of entries in B, which is 18, and the starting count in C, which is 2.
SetCreatureTimer_Loop 52282 LD A,(HL) Fetch the type of the object.
52283 AND %11111100 Keep the type without its lowest two bits.
52285 CP 112 Jump to SetCreatureTimer_Next unless it is one of the types 112 to 115.
52287 JR NZ,SetCreatureTimer_Next
52289 INC C Add one to the count.
SetCreatureTimer_Next 52290 DJNZ SetCreatureTimer_Loop Count down the entries and jump to SetCreatureTimer_Loop until all are tested.
Set the timer to four times the count.
52292 LD A,C Fetch the count.
52293 ADD A,A Multiply it by four.
52294 ADD A,A
52295 LD (42813),A Set the timer.
52298 RET Return.
Prev: 52241 Up: Map Next: 52299