; "Ikeda's Attractor", an example of Chaos
; Ron Thomas Ron_Thom@Compuserve.com 15/5/99
;---------------------------------------------
;The Ikeda Attractor
;This is graphical demo which reproduces the clasic "Ikeda Attractor".
;Try resizing the window and you will see a completely different orbit each time !
;Enjoy
;Ron Thomas
;Ron_Thom@Compuserve.com
;www.rbthomas.freeserve.co.uk
;15/5/99
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;以上是原作者的说明,
;这是我从国外(俄国)的一个网站下载的。
;这个程序我存放半年多了,特放出来与需要的人共享。
;QQ:112426112
;Email:leguanyuan at 126 dot com
;Homepage:http://correy.webs.com
;以下是我改编的代码:
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
include gdi32.inc
includelib gdi32.lib
.code
hInstance dd 0
hWinMain dd 0
szClassName db "made by correy",0
pwndclassex dd 48,3,offset liuchunli,0,0,0,0,0,6,0,offset szClassName,0
stMsg MSG <>
cxClient DD ?
cyClient DD ?
xx DD ? ; Coordinates of point to be plotted
yy DD ?
x_offset DD ? ; Screen offsets
y_offset DD ?
scaleX DD ? ; Scaling factors
scaleY DD ?
numpoints DD 10000
temp DD ?
c1 real4 0.4
c2 real4 0.9
c3 real4 6.0
c1_3 real4 -5.6
rho real4 1.0
x real4 0.1
xt real4 ?
y real4 0.1
phi real4 ?
sin_phi real4 ?
cos_phi real4 ?
liuchunli proc uses ebx edi esi,hWnd,uMsg,wParam,lParam
LOCAL hdc:HDC, ps:PAINTSTRUCT
.if uMsg == WM_CLOSE;放置后面会反应更快点。
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,0
.elseif uMsg == WM_SIZE
mov eax,lParam
and eax,0FFFFh
mov cxClient,eax
shr eax,1
mov x_offset,eax ; Compute offset
mov ecx,4 ; Compute scaling factor
mov eax,cxClient
mov edx,0
div ecx
mov scaleX,eax
mov ebx,lParam
shr ebx,16
mov cyClient,ebx
shr ebx,1
mov y_offset,ebx
mov ecx,4 ; Compute scaling factor
mov eax,cyClient
mov edx,0
div ecx
mov scaleY,eax
.elseif uMsg == WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax
finit ;Initialise the coprocessor
mov esi,0
.WHILE esi < numpoints
fld x
fld st ;Push copy onto stack
fmul ;X**2
fld y
fld st
fmul ;Y**2, X**2
fadd ;X**2 + Y**2
fld1 ;Load 1.0
fadd ;1.0 + X**2 + Y**2
fdivr c1_3 ; (c1 - c3)/(1.0 + X**2 + Y**2)
fst phi
fld st ;phi,phi
fsin ;sin(phi),phi
fstp sin_phi ;phi
fcos ;cos(phi)
fst cos_phi
fld x ;X,cos(phi)
fmul ;X*cos(phi)
fld y ;Y,X*cos(phi)
fmul sin_phi ;Y*sin(phi),X*cos(phi)
fsub ;X*cos(phi) - Y*sin(phi)
fmul c2 ;c2*(X*cos(phi) - Y*sin(phi))
fadd rho ;rho + c2*(X*cos(phi - Y*sin(phi))
fstp xt ;Update XT
fld x ;X,XT
fmul sin_phi ;X*sin(phi)
fld y ;Y,X*sin(phi)
fmul cos_phi ;Y*cos(phi),X*sin(phi)
fadd ;Y*cos(phi) + X*sin(phi)
fmul c2 ;c2*(Y*cos(phi) + X*sin(phi))
fst y ;Update Y
fimul scaleY ;Scale to fit screen
fiadd y_offset
fistp yy
fld xt
fst x ;Update X
fimul scaleX
fiadd x_offset
fistp xx ;Convert to integer
invoke SetPixel, hdc, xx, yy, 255 ;Plot orbit in red pixels @ coords xx,yy
inc esi
.ENDW
invoke EndPaint,hWnd, ADDR ps
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret;不能去掉。
.endif
xor eax,eax;这两行可以去掉?
ret
liuchunli endp
start: invoke GetModuleHandle,0
mov hInstance,eax
mov pwndclassex+20,eax
invoke LoadCursor,0,32512;加载箭头鼠标。
mov pwndclassex+28,eax
invoke RegisterClassEx,addr pwndclassex
invoke CreateWindowEx,200h,offset szClassName,offset szClassName,0Cf0000h,80000000h,80000000h,710,530,0,0,hInstance,0;0Ca0000h
mov hWinMain,eax
invoke ShowWindow,hWinMain,1;若不想显示,此行也可以去掉。
again:invoke GetMessage,addr stMsg,0,0,0
cmp eax,0
je exit
invoke DispatchMessage,addr stMsg
jmp again
exit:invoke ExitProcess,0
end start
;made at 2011.09.24
没有评论:
发表评论