Prev: 40414 Up: Map Next: 40471
40440: Increase Entity Counter
Increases the counter in the high nibble of field 22 of an entity by one, if it is not zero, and wraps it to zero after 8. Then plays a click of a random length.
Input
IX The entity
IncreaseEntityCounter 40440 LD A,(IX+22) Read field 22 of the entity.
40443 LD B,A Keep it in B.
40444 AND %11110000 Keep the counter.
40446 RET Z Return if it is zero.
40447 ADD A,16 Add one to the counter.
40449 CP 144 Jump to IncreaseEntityCounter_Store if it is below 144.
40451 JR C,IncreaseEntityCounter_Store
40453 XOR A Set the counter to zero.
IncreaseEntityCounter_Store 40454 LD C,A Keep the new counter in C.
40455 LD A,B Fetch the old value of field 22.
40456 AND %00001111 Keep the low nibble.
40458 OR C Combine it with the new counter.
40459 LD (IX+22),A Store it in field 22 of the entity.
40462 LD A,(24474) Fetch the low byte of the seed from RandomNumber_Seed.
40465 AND %00111111 Use bits 0-5.
40467 INC A Add one.
40468 JP PlayClick Jump to PlayClick to play a click.
Prev: 40414 Up: Map Next: 40471