Prev: E89E Up: Map Next: E8E8
E8AA: Graphic Layout Routine: (F9) Jump To Time-Weighted Random Address
Jump to one of several graphic-layout addresses using a time-weighted random pick.
GraphicLayoutRoutine_JumpTimeWeightedRandom E8AA PUSH IX Stash IX on the stack.
E8AC LD A,(IX+$01) Load A with the current entity's flags byte 1.
E8AF ADD A,A Multiply A by 04 to index the four-byte table entries.
E8B0 ADD A,A
E8B1 ADD A,$02 A+=02.
E8B3 LD E,A Copy A into E as a saved coordinate / value.
E8B4 LD D,$00 Clear D (high byte of a pointer/offset).
E8B6 ADD IX,DE IX+=DE.
E8B8 DEC (IX+$00) Decrease the current entity's entity type.
E8BB JR NZ,Layout_LoopEnd Jump to Layout_LoopEnd to continue if the comparison did not match.
E8BD POP IX Restore IX from the stack.
E8BF LD A,(IX+$00) Fetch the current entity's type into A.
E8C2 CALL PseudoRandom Call PseudoRandom to pick a pseudo-random value.
E8C5 LD (IX+$01),A Set the current entity's flags byte 1.
E8C8 ADD A,A Multiply A by 04 to index the four-byte table entries.
E8C9 ADD A,A
E8CA ADD A,$02 A+=02.
E8CC LD E,A Copy A into E as a saved coordinate / value.
E8CD ADD IX,DE IX+=DE.
E8CF LD A,(IX+$01) Load A with the current entity's flags byte 1.
E8D2 CALL PseudoRandom Call PseudoRandom to pick a pseudo-random value.
E8D5 INC A Step the graphic-set / attribute index on by one.
E8D6 LD (IX+$00),A Set the current entity's entity type.
E8D9 JR GraphicLayoutRoutine_F9Continue Jump to GraphicLayoutRoutine_F9Continue to continue this routine.
Timer still counting: restore IX and jump to the current time-weighted layout address.
Layout_LoopEnd E8DB POP DE Restore DE from the stack.
Load the chosen F9 table entry's layout address into IX and process it at Process_GraphicLayoutData.
GraphicLayoutRoutine_F9Continue E8DC LD E,(IX+$02) Fetch this table entry's graphic-layout address into DE.
E8DF LD D,(IX+$03)
E8E2 PUSH DE Copy DE into IX (using the stack).
E8E3 POP IX
E8E5 JP Process_GraphicLayoutData Jump to Process_GraphicLayoutData to process graphic layout data.
View the equivalent code in;
Prev: E89E Up: Map Next: E8E8