Prev: 6FC7 Up: Map Next: 6FDB
6FC8: Randomly select a message number
Used by the routine at 6EC5. Returns with a randomly chosen message number (different from the last one used) in A. On entry, A holds 0xC5 or 0xC6 depending on the type of message required: 0xC5 for a person or group of people, 0xC6 for a verb.
Input
A 0xC5 or 0xC6
6FC8 LD C,A Point BC at the relevant last used message number (see 6FC5)
6FC9 LD B,$6F
6FCB LD A,(BC) E=last used message number (0x08-0x0F, 0x10-0x17)
6FCC LD E,A
6FCD AND $F8 Discard bits 0-2
6FCF LD D,A D=0x08 or 0x10
6FD0 CALL $F17F Get a random number in A
6FD3 AND $07 A=message number (0x08-0x0F, 0x10-0x17)
6FD5 ADD A,D
6FD6 CP E Is this the same message number as last time?
6FD7 JR Z,$6FD0 Jump back to try again if so
6FD9 LD (BC),A Store the randomly chosen message number for comparison next time
6FDA RET
Prev: 6FC7 Up: Map Next: 6FDB