1 | ------------------------------------------------------------------------
3 | ------------------------------------------------------------------------
7 | Random number generator
8 | ------------------------------------------------------------------------
10 | Seed random number generator, using a 32 bit seed stored in d0 (s0s1s2s3 high
11 | to low bytes) This needn't be a pseudoroutine, but just for symmetry with the
12 | following routine, we'll make it one
24 | Reverse of seed: it will collect the seed from registers d4-d7 to d0
36 | Calculate next random number, it will be stored in the low byte of d7
43 lsl.w #8, %d4 | Hack - shift d4 to the left, so we can use its 8 LSB for storing the intermediate value
44 move.b %d6, %d4 | - Tmp store d6
45 lsr.b #1, %d4 | - This will produce d6>>1 in the LSB
47 add.b %d4, %d7 | Yup! I remebered it!
49 lsr.w #8, %d4 | Hack - Revert d4 to what it was before
54 | Function exposed to C - 1 longword argument
58 movem %d2-%d7/%a2-%a5, -(%sp)
61 pseudo_call rng_calc_next
62 pseudo_call rng_unseed
63 movem (%sp)+, %d2-%d7/%a2-%a5