Bah hum bug to using time as a seed.
I rewrote my code so that the user specifies a 10 character seed and then made an algorithm that does a pretty nice job at making random numbers. I dont know how random it is but within a screen of 2000 outputs I could not find a single repeat, even with a seed of all As. So its atleast good for 2000+ entries which in a 16-bit project isnt bad.
Code: Select all
rand_int:
mov si,[seed_pos]
mov al,[si] //Stage one XORs three
mov di,[seed_pos+2]
mov ah,[di]
xor al,ah
mov di,[seed_pos+4]
mov ah,[di]
xor al,ah
and al,3
inc al
push ax
mov di,[seed_pos]
mov al,[di]
rol al,3
mov [di],al
mov ah,al
mov di,[seed_pos+2]
mov al,[di]
xor al,ah
and ah,al
rol al,7
mov [di],al
mov di,[seed_pos+4]
mov al,[di]
xor al,ah
rol al,5
mov [di],al
add si,9
call fix_seed_pos
mov [seed_pos],si
mov si,[seed_pos+2]
add si,4
call fix_seed_pos
mov [seed_pos+2],si
mov si,[seed_pos+4]
add si,7
call fix_seed_pos
mov [seed_pos+4],si
pop ax
ret
fix_seed_pos:
cmp si,0x7C00
jl fix_seed_pos_end
sub si,0x7C00
add si,RN_BUFFER
fix_seed_pos_end:
ret