Prev: BE52 Up: Map Next: BEB2
BE94: Generate a random number from 0 to 9
get_random BE94 PUSH HL preserve HL and DE
BE95 PUSH DE
get_random_0 BE96 LD A,R copy value of R register into E
BE98 LD E,A
BE99 LD HL,$E0B5 set HL to address of map_object_table+$96
BE9C LD D,$00 add byte in E
BE9E ADD HL,DE load byte from resulting address into E
BE9F LD A,(HL)
BEA0 LD E,A
BEA1 LD A,R add value of R register
BEA3 ADD A,E
BEA4 LD HL,$5C76 add value of SEED system variable
BEA7 ADD A,(HL)
BEA8 AND $0F select lower four bits
BEAA CP $0A jump back to get_random_0 if A is greater than 9
BEAC JP P,get_random_0
BEAF POP DE restore DE and HL
BEB0 POP HL
BEB1 RET
Prev: BE52 Up: Map Next: BEB2