Prev: 47363 Up: Map Next: 47468
47431: Select a remaining timer figure at random and update its eyes to a random (open-eyed) frame
Used by the routine at 47363.
47431 LD A,(34210) Load remaining time / lives into A...
47434 OR A ...and if none remain...
47435 RET Z ...then return
47436 LD E,A Load remaining time / lives into E
47437 LD A,18 Load A with 18 minus remaining time / lives (i.e. number in range 2 to 18)...
47439 SUB E ...
As the value of x (remaining time / lives) decreases, the probability that a randomly generated number between 0 and (18-x) is 2 or more increases. This probability is used to ensure that the rate at which each timer figure is updated remains roughly constant.
47440 CALL 54222 Load A with a random number, 0-(17 minus remaining time / lives)
47443 CP 2 If generated number is 2 or more...
47445 RET NC ...then return
47446 LD IX,23232 Point IX to start of second-last row of attribute file
47450 LD A,E Load remaining time / lives into A
If remaining time / lives is one, then there is only one timer figure to update
47451 CP 1 If this is 1...
47453 JP Z,47315 ...then jump to 47315 (if show-score flag reset then draw pair of timer figure eyes and return)
Otherwise, randomly select one of the remaining timer figures to update
47456 CALL 54222 Load A with random number between 0 and (x-1) where x is remaining time / lives
47459 ADD A,A Double A...
47460 LD C,A ...and load into BC...
47461 LD B,0 ...
47463 ADD IX,BC Add BC as offset to IX (i.e. advance IX to point to left eye of randomly chosen timer figure)
47465 JP 47315 If show-score flag reset then draw pair of timer figure eyes (open, random frame) at attribute file address IX, advance IX by two bytes then return
Prev: 47363 Up: Map Next: 47468