Prev: 39366 Up: Map Next: 39557
39513: Turn: Pick A Script Entry
Used by the routine at Turn_GateTheMessage.
Takes the smaller of the script limit and the special-object limit, rolls below that, and stores the script pointer from the chosen entry.
Turn_PickAScriptEntry 39513 LD A,(IX+1) Read the limit from this script byte.
39516 CP (IY+1) Jump to Turn_PickAScriptEntry_RollBelowTheLimit if that limit is below the special-object limit.
39519 JR C,Turn_PickAScriptEntry_RollBelowTheLimit
39521 LD A,(IY+1) Use the special-object limit instead.
Roll a random number.
Turn_PickAScriptEntry_RollBelowTheLimit 39524 CALL GetRandomNumber Call GetRandomNumber to roll a number from the limit in A.
39527 LD E,A Keep the roll in E.
This entry point is used by the routine at Turn_GateTheMessage.
Turn_PickAScriptEntry_0 39528 LD A,(IY+1) Read the special-object limit.
39531 CP E Jump to Turn_PickAScriptEntry_Store if the special-object limit is not below the roll.
39532 JR NC,Turn_PickAScriptEntry_Store
39534 LD E,A Keep the special-object limit in E.
Turn_PickAScriptEntry_Store 39535 LD L,(IY+4) Read the low byte of the table pointer.
39538 LD H,(IY+5) Read the high byte of the table pointer.
39541 LD D,0 The record offset's high byte is zero.
39543 ADD HL,DE Add the roll in DE.
39544 ADD HL,DE Add the roll in DE again.
39545 ADD HL,DE Add the roll in DE a third time. Each entry is three bytes.
39546 INC HL Step to the next byte.
39547 LD E,(HL) Read the low byte of the chosen script pointer.
39548 INC HL Step to the next byte.
39549 LD D,(HL) Read the high byte of the chosen script pointer.
39550 LD (IY+2),E Store the chosen script pointer in bytes 2 and 3 of the special-object record.
39553 LD (IY+3),D
39556 RET Return.
Prev: 39366 Up: Map Next: 39557