Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change
Quote from: sinsi on October 20, 2024, 02:35:02 AMWhy omit the test eax, 80000000h part? Admittedly, I don't understand why it's in the original. Overflow?I have been scouring through some papers regarding the original Park-Miller algorithm. Apparently the seed value should be an integer less than or equal to 2147483647 (2^31)-1.
GenerateAlgoCurve proc uses rbx @@pGraphics:QWORD
LOCAL Fmin:REAL10
LOCAL Fmax:REAL10
local aa:REAL10
local bb:REAL10
local theta:REAL10
local x00:REAL4
local y00:REAL4
local x11:REAL4
local y11:REAL4
local @Pen:QWORD
local xPhase:REAL10
local nn:REAL10
;Lissajous Curve
;x(@)=a.sin(@)
;y(@)=b.sin(n.@+0) n >= 1 ,(3.14/2) >= 0 >= O
;n: Multiple of frequency
finit
fld FP10(1.0)
fstp Fmin
fld FP10(2.0)
fstp Fmax
invoke randf,addr Fmax,addr Fmin
fstp nn
fldz
fstp Fmin
fldpi ; 3.14
fld FP10(2.0)
fdiv ; 3.14/2
fstp Fmax
invoke randf,addr Fmax,addr Fmin ;st0=[@Fmin,@Fmax)
fstp xPhase
fldz
fstp theta
fld FP10(295.11) ;a=width
fstp aa
fld FP10(240.07) ;b=height
fstp bb
invoke GdipCreatePen1,0FF00FF00H,FP4(0.5),0,addr @Pen ;FP4(0.5) pen width,
xor rbx,rbx
.repeat
fld theta
fldpi ; 3.14
fmul ; theta*3.14
fld FP10(180.0)
fdiv
fsin ; sin(theta*3.14/180)
fld aa
fmul ; a*sin(theta*3.14/180)
fstp x11
fld theta
fldpi ; 3.14
fmul ; theta*3.14/180
fld FP10(180.0)
fdiv
fld nn
fmul ; n*(theta*3.14/180)
fld xPhase
fadd ; n*(theta*3.14/180)+xPhase
fsin ; sin(n*(theta*3.14/180)+xPhase)
fld bb
fmul ; b*sin(n*(theta*3.14/180)+xPhase)
fstp y11
;move to the center
fld FP10(420.5)
fld x11
fadd
fstp x00
fld FP10(310.5)
fld y11
fadd
fstp y00
invoke GdipDrawEllipse,@@pGraphics,@Pen,x00,y00,FP4(2.1),FP4(2.1)
fld FP10(0.908) ;step of theta
fld theta
fadd
fstp theta
inc rbx
.until rbx == 6000
invoke GdipDeletePen,@Pen
ret
GenerateAlgoCurve endp
Quote from: sinsi on October 20, 2024, 02:35:02 AMJust curious about a few thingsRegisters now restored to (almost) original design. Version rand64a.zip in first post.
Why change from using ECX to using RSI?
Quote from: zedd151 on October 21, 2024, 03:19:55 AM@C3, nope. Reading that stuff makes my eyes bleed.
I prefer explanations in plain language, from others with experience with such things.