dos33fsprogs/games/peasant/random8.s
Vince Weaver 73b38a02e5 peasant: update the random code
old random generator not very random.  The new one is, makes
the cliff climb impossibly hard
2024-10-10 13:22:45 -04:00

25 lines
427 B
ArmAsm

; https://wimcouwenberg.wordpress.com/2020/11/15/a-fast-24-bit-prng-algorithm-for-the-6502-processor/
random8:
lda rand_a ; Operation 7 (with carry clear).
asl
eor rand_b
sta rand_b
rol ; Operation 9.
eor rand_c
sta rand_c
eor rand_a ; Operation 5.
sta rand_a
lda rand_b ; Operation 15.
ror
eor rand_c
sta rand_c
eor rand_b ; Operation 6.
sta rand_b
rts
rand_a: .byte 0
rand_b: .byte 0
rand_c: .byte 1