; Seed random number generator ; ; Entry: ; nothing ; Exit: ; nothing randseed: %ifndef disable_randseed_func ; save pusha ; get system time for seeding mov ah,2Ch ; INT21h AH=2Ch get system time int 21h ; stores hour/min in cx and sec/csec in dx ; store seed %ifdef randseed_loc mov [randseed_loc],dx %else mov [.seed],dx %endif ; restore popa ret %endif %ifndef randseed_loc .seed: dw 0 %define randseed_loc randseed.seed %endif ; Get random bits ; ; Entry: ; nothing ; Exit: ; ax contains random bits rand: ; save push cx push dx ; load seed and multiplier mov ax,[randseed_loc] mov cx,16807 ; multiply mul cx ; add add ax,1 ; store new seed mov [randseed_loc],ax ; restore pop dx pop cx ret