Prev: 42706 Up: Map Next: 42754
42707: Print A Random Alternative
Reads how many alternatives follow, picks one at random with GetRandomNumber, prints that one through ProcessTextCommand and skips the rest.
Control code 10 in the table at JumpTable_ControlCharacters.
Used by the routine at DispatchTextControlHandler.
Input
IX Pointer to text token data
PrintRandomAlternative 42707 INC IX Read how many alternatives follow and keep that count.
42709 LD A,(IX+0)
42712 LD (42705),A
42715 DEC A Pick one of them at random with GetRandomNumber.
42716 CALL GetRandomNumber
42719 INC A Put that choice back in the range and remember it.
42720 LD (42706),A
42723 INC IX Step on to the first alternative.
PrintRandomAlternative_0 42725 LD A,(42706) Read the choice and point HL at the count still left.
42728 LD HL,42705
42731 CP (HL) Jump ahead to PrintRandomAlternative_Next if the choice differs from the alternatives left.
42732 JR NZ,PrintRandomAlternative_Next
42734 PUSH IX Call ProcessTextCommand to print this alternative.
42736 CALL ProcessTextCommand
42739 POP IX
Skip this alternative.
PrintRandomAlternative_Next 42741 CALL SkipTextTokenBasedOnType Call SkipTextTokenBasedOnType to skip this alternative.
42744 LD HL,42705 Count one fewer alternative.
42747 DEC (HL)
42748 JR NZ,PrintRandomAlternative_0 Jump back to PrintRandomAlternative_0 until none remain.
42750 DEC IX Step the record back one byte.
42752 XOR A Clear A.
42753 RET Return.
Prev: 42706 Up: Map Next: 42754