aboutsummaryrefslogtreecommitdiff
path: root/game/random.asm
blob: 0cb74db8683169db1c720e2702b861b845d6f67e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
;
; Random number generator
;
; x[i + 1] = (5 * x[i] + 1) mod 256
;
; out: y random value
rnd:
    ld x, <seed
    ld a, >seed

    ld y, [a : x]
    ld b, y

    add y, y
    add y, y
    add y, b
    add y, 7

    ld [a : x], y

    ret

seed:
    .db 0