Prev: 49356 Up: Map Next: 49400
49363: Update Random Numbers
Used by the routine at InitialiseGame.
Stirs the two random numbers in FirstRandomNumber and SecondRandomNumber. The first uses FrameCounter and the refresh register, and the second uses the frame counter and the return address, so it is different for every routine which calls this.
Stir the first random number with the frame counter and the refresh register.
UpdateRandomNumbers 49363 LD DE,(41494) Fetch FrameCounter into DE.
49367 LD HL,(41496) Fetch FirstRandomNumber.
49370 LD A,R Fetch the refresh register.
49372 ADD A,E Add the low byte of the frame counter.
49373 ADD A,L Add the low byte of the random number.
49374 LD L,A Set the low byte of the new number.
49375 LD A,R Fetch the refresh register again.
49377 ADD A,D Add the high byte of the frame counter.
49378 ADD A,H Add the high byte of the random number.
49379 LD H,A Set the high byte of the new number.
Store the first random number.
49380 LD (41496),HL Set FirstRandomNumber.
Stir the second random number with the frame counter and the return address.
49383 POP BC Fetch the return address into BC, leaving it on the stack.
49384 PUSH BC
49385 LD HL,(41498) Fetch SecondRandomNumber.
49388 LD A,C Fetch the low byte of the return address.
49389 SUB E Subtract the low byte of the frame counter.
49390 ADD A,L Add the low byte of the random number.
49391 LD L,A Set the low byte of the new number.
49392 LD A,B Fetch the high byte of the return address.
49393 SUB D Subtract the high byte of the frame counter.
49394 ADD A,H Add the high byte of the random number.
49395 LD H,A Set the high byte of the new number.
Store the second random number.
49396 LD (41498),HL Set SecondRandomNumber.
49399 RET Return.
Prev: 49356 Up: Map Next: 49400