Prev: 46481 Up: Map Next: 46559
46495: Graphic layout routine: (249) Jump to time-weighted, randomly selected graphic layout data address in list
Used by the routine at 46218.
Input
IX Address of first parameter in current graphic layout data instruction
Output
B Do-not-recalculate-display-buffer-address flag (0)
IX Address of next graphic layout data instruction to process
46495 PUSH IX Store IX (pointer to first parameter in graphic layout data)
46497 LD A,(IX+1) Advance IX to start of data for current state
46500 ADD A,A
46501 ADD A,A
46502 ADD A,2
46504 LD C,A
46505 LD B,0
46507 ADD IX,BC
46509 DEC (IX+0) Decrease the remaining time for this state and if not zero, skip ahead to 46544
46512 JR NZ,46544
Remaining time for current state is zero
46514 POP IX Restore IX (pointer to first parameter in graphic layout data)
46516 LD A,(IX+0) Set current state to be a random selection from all possible states
46519 CALL 54222
46522 LD (IX+1),A
46525 ADD A,A Advance IX to start of data for new state
46526 ADD A,A
46527 ADD A,2
46529 LD C,A
46530 ADD IX,BC
46532 LD A,(IX+1) Set remaining time for current state to be a random number between 1 and the state's maximum (inclusive)
46535 CALL 54222
46538 INC A
46539 LD (IX+0),A
46542 JR 46545 Skip ahead to 46545
Remaining time for current state is not zero
46544 POP BC Restore BC (graphic layout data position, was previously in IX)
46545 LD C,(IX+2) Load IX with graphic layout data address for current state
46548 LD B,(IX+3)
46551 PUSH BC
46552 POP IX
46554 LD B,0 Prepare to recalculate display buffer address
46556 JP 46003 Read / process data at address in IX
Prev: 46481 Up: Map Next: 46559