thank you emil for your example!
I haven't checked it, but I will try next hours, looks good if that's working I am very glad!
here's my result of explorations about "rand" and "rnd()" by charles and peter's example shown:
'first random() ' rand(a,b) ' peter
Long seed=0x12345678 'initial seed value
Function Rand(byval z1 as long, byval z2 as long) as long
long rnd
long sys_Seed=0x12345678
mov eax,z2
sub eax,z1
Inc eax
imul edx,sys_Seed,0x8088405
Inc edx
mov sys_Seed,edx
mul edx
add edx,z1
mov rnd,edx
Function = rnd
End Function
print Rand(64,255) /Log(10) '93.80760809
print Rand(64,255) '216
'second random() 'Rnd() ' charles
'-----------------------
Function Rnd() as single 'sys
'=======================
'
Static As Single f, d=1/0x7fffffff
mov eax,seed
rol eax,7
imul eax,eax,13
mov seed,eax
push eax
fild dWord [esp]
add esp,4
fmul dWord d
fstp dWord f
Function=f
End Function
print rnd() '0.657777..
the rand() example from peter is good, but it's not working correct for different values for my openGL cubes (or I have done something wrong), I already tried it.
I suppose that's not working as usual rnd(min,max) function because there's a fixed value with the "seed", but I am not sure about that one.
got this from Fasm and converted to Oxygen.
@emil: little question just for my curiosity, because I didn't know Fasm: is that a heavy job to convert from Fasm to oxygen? thanks!
best regards, frank