Фракталы на x64

Тема в разделе "WASM.X64", создана пользователем Mikl___, 19 дек 2016.

  1. Mikl___

    Mikl___ Супермодератор Команда форума

    Публикаций:
    7
    Регистрация:
    25 июн 2008
    Сообщения:
    2.697
    Ниже приведены системы итерируемых функций, которые записаны в формате FRACTINT:
    [math]Fractal \begin{Bmatrix} a_{1} b_{1} c_{1} d_{1} e_{1} f_{1} p_{1} \\ a_{2} b_{2} c_{2} d_{2} e_{2} f_{2} p_{2} \\ \cdots \\ a_{n} b_{n} c_{n} d_{n} e_{n} f_{n} p_{n} \end{Bmatrix}[/math]
    Такой записи соответствует следующая система итерируемых функций в пространстве [math]R^{2}[/math]
    [math]\begin{array}{l} T_1 \left( \begin{array}{r} x \\ y \end{array} \right) = \left( \begin{array}{rr} a_1 & b_1 \\ c_1 & d_1 \\ \end{array} \right) \left( \begin{array}{r} x \\ y \end{array} \right) + \left( \begin{array}{r} e_1 \\ f_1 \end{array} \right), \\ T_2 \left( \begin{array}{r} x \\ y \end{array} \right) = \left( \begin{array}{rr} a_2 & b_2 \\ c_2 & d_2 \\ \end{array} \right) \left( \begin{array}{r} x \\ y \end{array} \right) + \left( \begin{array}{r} e_2 \\ f_2 \end{array} \right), \\ \ldots \\ T_n \left( \begin{array}{r} x \\ y \end{array} \right) = \left( \begin{array}{rr} a_n & b_n \\ c_n & d_n \\ \end{array} \right) \left( \begin{array}{r} x \\ y \end{array} \right) + \left( \begin{array}{r} e_n \\ f_n \end{array} \right). \end{array} [/math]
    Выход из программ по Esc или Alt+F4

    Ель


    исходный текст и ехе-файл здесь

    Коэффициенты


    abcdefp
    0.10000.00000.00000.16000.00.00.01*10000= 100
    0.85000.00000.00000.85000.01.60.85*10000=8500
    -0.1667-0.28870.2887-0.16670.01.60.07*10000= 700
    -0.16670.2887-0.2887-0.16670.01.60.07*10000= 700
    Код (ASM):
    1. include win64a.inc
    2. include msvcrt.inc
    3. includelib gdi32.lib
    4. includelib msvcrt.lib
    5. IMAGE_BASE equ 400000h
    6. cdXPos          equ 131
    7. cdYPos          equ 217
    8. cdYSize         equ 430
    9. cdXSize         equ 640
    10. movr macro x,y
    11. mov x,0
    12. org $-4
    13. dd y
    14. endm
    15. .code
    16. WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD
    17. local ps:PAINTSTRUCT
    18. local hdc:qword
    19. local hOldBmp:qword
    20. local hGDITmp:qword
    21. local hOldDIB:qword
    22. local hBackDC:qword
    23. local hMainDIB:qword
    24. local bufBMP:qword
    25. local i:dword
    26. local x:dword
    27. local y:dword
    28. local a:dword
    29. local b:dword
    30. local c:dword
    31. local d:dword
    32. local f:dword
    33. local NewX:qword
    34. local NewY:qword
    35. local XCC:qword
    36. local YCC:qword
    37. push rbp
    38. mov ebp, esp
    39. sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)
    40. mov hWnd,rcx
    41. cmp edx, WM_DESTROY
    42. jz wmDESTROY
    43.         cmp edx, WM_PAINT
    44. jz wmPAINT
    45.         cmp edx, WM_CREATE
    46. jz wmCREATE
    47. leave
    48.         jmp DefWindowProc
    49. ; ---------------------------------------------------------------------------
    50. wmDESTROY::mov rdx,hOldBmp
    51. mov rcx,hBackDC
    52. call SelectObject
    53. mov hGDITmp,rax
    54. mov rcx,bufBMP
    55. call DeleteObject
    56. mov rcx,hBackDC
    57. call DeleteDC
    58. mov rdx,hOldDIB
    59. mov rcx,bufDIBDC
    60. call SelectObject
    61. mov hGDITmp,rax
    62. mov rcx,bufDIBDC
    63. call DeleteDC
    64. mov rcx,hMainDIB
    65. call DeleteObject
    66. mov rcx,hWnd
    67. call DestroyWindow
    68. xor ecx,ecx ; nExitCode
    69. call ExitProcess
    70. ; ---------------------------------------------------------------------------
    71. wmPAINT:lea edx,ps
    72. call BeginPaint
    73. mov hdc,rax
    74. mov qword ptr [rsp+40h],SRCCOPY; rop
    75.         xor edx,edx ; x
    76. mov [rsp+38h],rdx ; y1
    77. mov [rsp+30h],rdx ; x1
    78. mov rax,bufDIBDC ; hdcSrc
    79.         mov [rsp+28h],rax
    80. mov rax,cdYSize
    81. mov [rsp+20h],rax
    82. mov r9,cdXSize ; cx
    83. xor r8d,r8d ; cy
    84. mov rcx,hdc ; hdc
    85. call BitBlt
    86. lea edx,ps
    87. mov rcx,hWnd
    88. call EndPaint
    89. jmp wmBYE
    90. ; ---------------------------------------------------------------------------
    91. wmCREATE:mov rcx,hWnd
    92. call GetDC
    93. mov hdc,rax
    94.         mov rcx,rax ; HDC
    95. call CreateCompatibleDC
    96. mov bufDIBDC,rax
    97. mov [rsp+28h],rbx
    98. mov [rsp+20h],rbx
    99. mov r9d,offset pMainDIB
    100. mov r8d,DIB_RGB_COLORS
    101. mov edx,offset bi
    102. mov rcx,hdc
    103.         call CreateDIBSection
    104. mov hMainDIB,rax
    105. mov rdx,rax; hMainDIB
    106. mov rcx,bufDIBDC
    107. call SelectObject
    108.         mov rax,hOldDIB
    109. mov rdx,hdc
    110. mov rcx,hWnd
    111.         call ReleaseDC;   // Libera device context
    112. ;Init--------------------------------------------------------
    113. ; a       b       c       d      e   f   p
    114. ; 0.1000  0.0000  0.0000  0.1600 0.0 0.0 0.01*10000= 100
    115. ; 0.8500  0.0000  0.0000  0.8500 0.0 1.6 0.85*10000=8500
    116. ;-0.1667 -0.2887  0.2887 -0.1667 0.0 1.6 0.07*10000= 700
    117. ;-0.1667  0.2887 -0.2887 -0.1667 0.0 1.6 0.07*10000= 700
    118. mov XCC,rbx
    119. mov YCC,rbx
    120. mov i,60000
    121. bucle:  call rand
    122. mov ecx,10000
    123. xor edx,edx;cdq
    124. div ecx
    125. cmp edx, 100  ;p1
    126. ja @f
    127. movr a,0.1;a = 0.1
    128. mov b,ebx; b = 0
    129.         mov c,ebx; c = 0
    130. movr d,0.16
    131. mov f,ebx; f = 0
    132. jmp fin
    133. @@: cmp edx, 800  ;p1+p4=100+700=800
    134. ja @f
    135. movr a,-0.1667
    136. movr b, 0.2887
    137. movr c,-0.2887
    138. movr d,-0.1667
    139. movr f, 1.6
    140. jmp fin
    141. @@: cmp edx,1500  ;p1+p4+p3=800+700=1500
    142. ja @f
    143. movr a,-0.1667
    144. movr b,-0.2887
    145. movr c,0.2887
    146. movr d,-0.1667
    147. movr f,1.6
    148. jmp fin
    149. @@: movr a,0.8500
    150. mov b,ebx
    151. mov c,ebx
    152. movr d, 0.85
    153. movr f, 1.60 ; f = 1.60
    154. fin: fld a       ;st(0) = a
    155. fmul XCC     ;st(0) = a * XCC
    156. fld b       ;st(0) = b
    157. fmul YCC     ;st(0) = b * YCC
    158. faddp        ;st(0) = a * XCC + b * YCC
    159. fst NewX    ;NewX = a * XCC + b * YCC
    160. fmul const40 ;st(0) = NewX * 40
    161. fld c           ;st(0) = c
    162. fmul XCC     ;st(0) = c * XCC
    163. fld d       ;st(0) = d
    164. fmul YCC     ;st(0) = d * YCC
    165. faddp        ;st(0) = c * XCC + d * YCC
    166. fadd f       ;st(0) = c * XCC + d * YCC + f
    167. fst NewY    ;NewY = c * XCC + d * YCC + f
    168. fstp YCC     ;YCC = NewY
    169. fadd const320;st(0) = NewX * 40 + cdXSize/2
    170. fistp x       ;x = (int) (NewX*40+cdXSize/2)
    171. mov ecx, x
    172. cmp ecx,cdXSize
    173. jae @f
    174. fld1        ;st(0) = 1
    175. fsub NewY    ;st(0) = 1 - NewY
    176. fmul const40 ;st(0) = (1 - NewY)*40
    177. fadd const365;st(0) = (1 - NewY)*40 + cdYSize - 35
    178. fistp y       ; y = (int) ((1-NewY)*40+cdYSize-35)
    179. cmp y,cdYSize
    180. jae @f
    181. imul eax,y,2560
    182. add rax,pMainDIB
    183. mov dword ptr [rax+rcx*4],0FF00h ;*(pMainDIB + (y<<9)+(y<<7)+x) = 0xFF00;
    184. @@: fld NewX  ;XCC = NewX
    185. fstp XCC
    186. dec i
    187. jnz  bucle
    188. wmBYE: leave
    189. retn
    190. WndProc endp
    191. WinMain proc
    192. local msg:MSG
    193. push rbp
    194. mov ebp,esp
    195. sub esp,sizeof MSG
    196. xor ebx,ebx
    197. mov esi,IMAGE_BASE
    198. mov edi,offset ClassName
    199. push rbx ;hIconSm
    200. push rdi ;lpszClassName
    201. push rbx ;lpszMenuName
    202. push COLOR_WINDOWTEXT; hbrBackground
    203. push rbx ;hCursor
    204. push rbx         ;hIcon
    205. push rsi ;hInstance
    206. push rbx         ;cbClsExtra & cbWndExtra
    207. db 68h
    208. dd WndProc       ;lpfnWndProc
    209. push sizeof WNDCLASSEX ;cbSize & style
    210. mov ecx,esp ;addr WNDCLASSEX
    211. call RegisterClassEx
    212. push rbx
    213. push rsi ;rsi=400000h
    214. push rbx
    215. push rbx
    216. push cdYSize
    217. push cdXSize
    218. push cdYPos
    219. push cdXPos
    220. mov r9d,WS_VISIBLE
    221. mov r8,rdi ;offset ClassName
    222. mov edx,edi ;offset ClassName
    223. xor ecx,ecx
    224. sub esp,20h ; dwExStyle
    225. call CreateWindowEx
    226. @@:     lea ecx,msg
    227. xor edx,edx
    228. xor r8d,r8d
    229. xor r9d,r9d
    230. call GetMessage
    231. cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
    232. je wmDESTROY
    233. lea ecx,msg
    234. call DispatchMessage
    235. jmp @b
    236. WinMain endp
    237. .data
    238. ClassName db 'Fir Tree Fractal',0
    239. bi BITMAPINFO <<28h,640,-430,1,32,0,0,0,0,0,0>>
    240. bufDIBDC dq ?
    241. pMainDIB dq ?
    242. const40 dq 40.0
    243. const320 dq 320.0
    244. const365 dq 365.0
    245. end
    bat-файл
    Код (Text):
    1. cls
    2. set masm64_path=\masm64\
    3. set filename=%1
    4. del %filename%.exe
    5. %masm64_path%bin\ml64 /Cp /c /I"%masm64_path%Include" %filename%.asm || exit
    6. if exist %1.rc (
    7. %masm64_path%bin\RC /r  %filename%.rc || exit
    8. %masm64_path%bin\link /SUBSYSTEM:WINDOWS /LIBPATH:"%masm64_path%Lib" ^
    9. /entry:WinMain %filename%.obj %filename%.res /LARGEADDRESSAWARE:NO ^
    10. /ALIGN:16 /SECTION:.text,W ^
    11. /BASE:0x400000 /STUB:%masm64_path%\bin\stubby.exe || exit
    12. del %filename%.res
    13. ) else (
    14. %masm64_path%bin\link /SUBSYSTEM:WINDOWS /LIBPATH:"%masm64_path%Lib" ^
    15. /entry:WinMain %filename%.obj /LARGEADDRESSAWARE:NO ^
    16. /ALIGN:16 /SECTION:.text,W ^
    17. /BASE:0x400000 /STUB:%masm64_path%\bin\stubby.exe || exit
    18. )
    19. del %filename%.obj
    20.  

    Результат


    [​IMG]
     

    Вложения:

    • FireTree.png
      FireTree.png
      Размер файла:
      33,2 КБ
      Просмотров:
      562
    • FirTreex64.zip
      Размер файла:
      3,9 КБ
      Просмотров:
      192
    Последнее редактирование: 27 дек 2016
    gazlan и Thetrik нравится это.
  2. Mikl___

    Mikl___ Супермодератор Команда форума

    Публикаций:
    7
    Регистрация:
    25 июн 2008
    Сообщения:
    2.697

    Галактика


    исходный текст и ехе-файл здесь

    Коэффициенты


    abcdefp
    -0.92-0.090.09-0.920.000.000.1*10000=1000
    0.790.26-0.260.790.210.260.9*10000=9000
    Код (ASM):
    1. include win64a.inc
    2. include msvcrt.inc
    3. includelib gdi32.lib
    4. includelib msvcrt.lib
    5. IMAGE_BASE equ 400000h
    6. cdXPos          equ 131
    7. cdYPos          equ 217
    8. cdYSize         equ 430
    9. cdXSize         equ 640
    10. movr macro x,y
    11. mov x,0
    12. org $-4
    13. dd y
    14. endm
    15. .code
    16. WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD
    17. local ps:PAINTSTRUCT
    18. local hdc:qword
    19. local hOldBmp:qword
    20. local hGDITmp:qword
    21. local hOldDIB:qword
    22. local hBackDC:qword
    23. local hMainDIB:qword
    24. local bufBMP:qword
    25. local i:dword
    26. local x:dword
    27. local y:dword
    28. local a:dword
    29. local b:dword
    30. local c:dword
    31. local d:dword
    32. local e:dword
    33. local f:dword
    34. local NewX:qword
    35. local NewY:qword
    36. local XCC:qword
    37. local YCC:qword
    38. push rbp
    39. mov ebp, esp
    40. sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)
    41. mov hWnd,rcx
    42. cmp edx, WM_DESTROY
    43. jz wmDESTROY
    44.         cmp edx, WM_PAINT
    45. jz wmPAINT
    46.         cmp edx, WM_CREATE
    47. jz wmCREATE
    48. leave
    49.         jmp DefWindowProc
    50. ; ---------------------------------------------------------------------------
    51. wmDESTROY::mov rdx,hOldBmp
    52. mov rcx,hBackDC
    53. call SelectObject
    54. mov hGDITmp,rax
    55. mov rcx,bufBMP
    56. call DeleteObject
    57. mov rcx,hBackDC
    58. call DeleteDC
    59. mov rdx,hOldDIB
    60. mov rcx,bufDIBDC
    61. call SelectObject
    62. mov hGDITmp,rax
    63. mov rcx,bufDIBDC
    64. call DeleteDC
    65. mov rcx,hMainDIB
    66. call DeleteObject
    67. mov rcx,hWnd
    68. call DestroyWindow
    69. xor ecx,ecx ; nExitCode
    70. call ExitProcess
    71. ; ---------------------------------------------------------------------------
    72. wmPAINT:lea edx,ps
    73. call BeginPaint
    74. mov hdc,rax
    75. mov qword ptr [rsp+40h],SRCCOPY; rop
    76.         xor edx,edx ; x
    77. mov [rsp+38h],rdx ; y1
    78. mov [rsp+30h],rdx ; x1
    79. mov rax,bufDIBDC ; hdcSrc
    80.         mov [rsp+28h],rax
    81. mov rax,cdYSize
    82. mov [rsp+20h],rax
    83. mov r9,cdXSize ; cx
    84. xor r8d,r8d ; cy
    85. mov rcx,hdc ; hdc
    86. call BitBlt
    87. lea edx,ps
    88. mov rcx,hWnd
    89. call EndPaint
    90. jmp wmBYE
    91. ; ---------------------------------------------------------------------------
    92. wmCREATE:mov rcx,hWnd
    93. call GetDC
    94. mov hdc,rax
    95.         mov rcx,rax ; HDC
    96. call CreateCompatibleDC
    97. mov bufDIBDC,rax
    98. mov [rsp+28h],rbx
    99. mov [rsp+20h],rbx
    100. mov r9d,offset pMainDIB
    101. mov r8d,DIB_RGB_COLORS
    102. mov edx,offset bi
    103. mov rcx,hdc
    104.         call CreateDIBSection
    105. mov hMainDIB,rax
    106. mov rdx,rax; hMainDIB
    107. mov rcx,bufDIBDC
    108. call SelectObject
    109.         mov rax,hOldDIB
    110. mov rdx,hdc
    111. mov rcx,hWnd        
    112.         call ReleaseDC;   // Libera device context        
    113. ;Init--------------------------------------------------------
    114. ; a      b     c     d    e     f    p
    115. ; -0.92 -0.09  0.09 -0.92 0.00 0.00 0.1*10000=1000
    116. ;  0.79  0.26 -0.26  0.79 0.21 0.26 0.9*10000=9000
    117. mov XCC,rbx
    118. mov YCC,rbx
    119. mov i,45000
    120. bucle:  call rand
    121. mov ecx,10000
    122. xor edx,edx
    123. div ecx
    124. cmp edx,9000
    125. jg @f
    126. movr a,-0.92
    127. movr b,-0.09
    128. movr c,0.09
    129. movr d,-0.92
    130. mov e,ebx
    131. mov f,ebx
    132. jmp fin
    133. @@: movr a,0.79
    134. movr b,0.26
    135. movr c,-0.26
    136. movr d,0.79
    137. movr e,0.21
    138. movr f,0.26
    139. fin: fld a       ;st(0) = a
    140. fmul XCC     ;st(0) = a * XCC
    141. fld b       ;st(0) = b
    142. fmul YCC     ;st(0) = b * YCC
    143. faddp        ;st(0) = a * XCC + b * YCC
    144.         fadd e       ;st(0) = a * XCC + b * YCC + e
    145. fst NewX    ;NewX  = a * XCC + b * YCC + e
    146. fmul const300;st(0) = NewX * 300
    147.         fadd const320 ;st(0) = NewX * 300 + 320
    148. fistp x       ;x = (int) (NewX * 300 + 320)
    149.         mov eax,x
    150. cmp eax,cdXSize
    151. jae @f
    152. fld c       ;st(0) = c
    153. fmul XCC     ;st(0) = c * XCC
    154. fld d       ;st(0) = d
    155. fmul YCC     ;st(0) = d * YCC
    156. faddp        ;st(0) = c * XCC + d * YCC
    157. fadd f       ;st(0) = c * XCC + d * YCC + f
    158. fst NewY    ;NewY  = c * XCC + d * YCC + f
    159. fst YCC     ;YCC = NewY
    160. fmul const300;st(0) = NewY * 300
    161. fsubr const240;st(0)  = -NewY * 300 + 240
    162. fistp y       ; y = (int) (-NewY * 300 + 240)
    163. mov ecx, y
    164. cmp ecx,cdYSize
    165. jae @f
    166. imul ecx,cdXSize*4
    167. add rcx,pMainDIB
    168. mov dword ptr [rcx+rax*4],0FFFFFFh ;*(pMainDIB + y*cdXSize*4 + x*4) = white color
    169. @@: fld NewX  ;XCC = NewX
    170. fstp XCC
    171. dec i
    172. jnz  bucle
    173. wmBYE: leave
    174. retn
    175. WndProc endp
    176. WinMain proc
    177. local msg:MSG
    178. push rbp
    179. mov ebp,esp
    180. sub esp,sizeof MSG
    181. xor ebx,ebx
    182. mov esi,IMAGE_BASE
    183. mov edi,offset ClassName
    184. push rbx ;hIconSm
    185. push rdi ;lpszClassName
    186. push rbx ;lpszMenuName
    187. push COLOR_WINDOWTEXT; hbrBackground
    188. push rbx ;hCursor
    189. push rbx         ;hIcon
    190. push rsi ;hInstance
    191. push rbx         ;cbClsExtra & cbWndExtra
    192. db 68h
    193. dd WndProc       ;lpfnWndProc
    194. push sizeof WNDCLASSEX ;cbSize & style
    195. mov ecx,esp ;addr WNDCLASSEX
    196. call RegisterClassEx
    197. push rbx
    198. push rsi ;rsi=400000h
    199. push rbx
    200. push rbx
    201. push cdYSize
    202. push cdXSize
    203. push cdYPos
    204. push cdXPos
    205. mov r9d,WS_VISIBLE
    206. mov r8,rdi ;offset ClassName
    207. mov edx,edi ;offset ClassName
    208. xor ecx,ecx
    209. sub esp,20h ; dwExStyle
    210. call CreateWindowEx
    211. @@:     lea ecx,msg
    212. xor edx,edx
    213. xor r8d,r8d
    214. xor r9d,r9d
    215. call GetMessage
    216. cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
    217. je wmDESTROY
    218. lea ecx,msg
    219. call DispatchMessage
    220. jmp @b
    221. WinMain endp
    222. .data
    223. ClassName db 'Galaxy Fractal',0
    224. bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
    225. bufDIBDC dq ?
    226. pMainDIB dq ?
    227. const300 dd 300.0
    228. const320 dd 320.0
    229. const240 dd 240.0
    230. end

    Результат


    [​IMG]
     

    Вложения:

    • Galaxyx64.zip
      Размер файла:
      3,8 КБ
      Просмотров:
      183
    • galaxy.png
      galaxy.png
      Размер файла:
      46,4 КБ
      Просмотров:
      557
  3. Mikl___

    Mikl___ Супермодератор Команда форума

    Публикаций:
    7
    Регистрация:
    25 июн 2008
    Сообщения:
    2.697

    Раковина

    исходный текст и ехе-файл здесь

    Коэффициенты


    abcdefp
    -0.92-0.090.09-0.920.000.000.1*10000=1000
    0.790.26-0.260.790.210.260.9*10000=9000
    Код (ASM):
    1. include win64a.inc
    2. include msvcrt.inc
    3. includelib gdi32.lib
    4. includelib msvcrt.lib
    5. IMAGE_BASE equ 400000h
    6. cdXPos          equ 131
    7. cdYPos          equ 217
    8. cdYSize         equ 430
    9. cdXSize         equ 640
    10. movr macro x,y
    11. mov x,0
    12. org $-4
    13. dd y
    14. endm
    15. .code
    16. WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD
    17. local ps:PAINTSTRUCT
    18. local hdc:qword
    19. local hOldBmp:qword
    20. local hGDITmp:qword
    21. local hOldDIB:qword
    22. local hBackDC:qword
    23. local hMainDIB:qword
    24. local bufBMP:qword
    25. local i:dword
    26. local x:dword
    27. local y:dword
    28. local a:dword
    29. local b:dword
    30. local c:dword
    31. local d:dword
    32. local e:dword
    33. local f:dword
    34. local NewX:qword
    35. local NewY:qword
    36. local XCC:qword
    37. local YCC:qword
    38. push rbp
    39. mov ebp, esp
    40. sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)
    41. mov hWnd,rcx
    42. cmp edx, WM_DESTROY
    43. jz wmDESTROY
    44.         cmp edx, WM_PAINT
    45. jz wmPAINT
    46.         cmp edx, WM_CREATE
    47. jz wmCREATE
    48. leave
    49.         jmp DefWindowProc
    50. ; ---------------------------------------------------------------------------
    51. wmDESTROY::mov rdx,hOldBmp
    52. mov rcx,hBackDC
    53. call SelectObject
    54. mov hGDITmp,rax
    55. mov rcx,bufBMP
    56. call DeleteObject
    57. mov rcx,hBackDC
    58. call DeleteDC
    59. mov rdx,hOldDIB
    60. mov rcx,bufDIBDC
    61. call SelectObject
    62. mov hGDITmp,rax
    63. mov rcx,bufDIBDC
    64. call DeleteDC
    65. mov rcx,hMainDIB
    66. call DeleteObject
    67. mov rcx,hWnd
    68. call DestroyWindow
    69. xor ecx,ecx ; nExitCode
    70. call ExitProcess
    71. ; ---------------------------------------------------------------------------
    72. wmPAINT:lea edx,ps
    73. call BeginPaint
    74. mov hdc,rax
    75. mov qword ptr [rsp+40h],SRCCOPY; rop
    76.         xor edx,edx ; x
    77. mov [rsp+38h],rdx ; y1
    78. mov [rsp+30h],rdx ; x1
    79. mov rax,bufDIBDC ; hdcSrc
    80.         mov [rsp+28h],rax
    81. mov rax,cdYSize
    82. mov [rsp+20h],rax
    83. mov r9,cdXSize ; cx
    84. xor r8d,r8d ; cy
    85. mov rcx,hdc ; hdc
    86. call BitBlt
    87. lea edx,ps
    88. mov rcx,hWnd
    89. call EndPaint
    90. jmp wmBYE
    91. ; ---------------------------------------------------------------------------
    92. wmCREATE:mov rcx,hWnd
    93. call GetDC
    94. mov hdc,rax
    95.         mov rcx,rax ; HDC
    96. call CreateCompatibleDC
    97. mov bufDIBDC,rax
    98. mov [rsp+28h],rbx
    99. mov [rsp+20h],rbx
    100. mov r9d,offset pMainDIB
    101. mov r8d,DIB_RGB_COLORS
    102. mov edx,offset bi
    103. mov rcx,hdc
    104.         call CreateDIBSection
    105. mov hMainDIB,rax
    106. mov rdx,rax; hMainDIB
    107. mov rcx,bufDIBDC
    108. call SelectObject
    109.         mov rax,hOldDIB
    110. mov rdx,hdc
    111. mov rcx,hWnd        
    112.         call ReleaseDC;   // Libera device context        
    113. ;Init--------------------------------------------------------
    114. ; a      b     c     d    e     f    p
    115. ; -0.92 -0.09  0.09 -0.92 0.00 0.00 0.1*10000=1000
    116. ;  0.79  0.26 -0.26  0.79 0.21 0.26 0.9*10000=9000
    117. mov XCC,rbx
    118. mov YCC,rbx
    119. mov i,45000
    120. bucle:  call rand
    121. mov ecx,10000
    122. xor edx,edx
    123. div ecx
    124. cmp edx,1000
    125. jg @f
    126. movr a,-0.92
    127. movr b,-0.09
    128. movr c,0.09
    129. movr d,-0.92
    130. mov e,ebx
    131. mov f,ebx
    132. jmp fin
    133. @@: movr a,0.79
    134. movr b,0.26
    135. movr c,-0.26
    136. movr d,0.79
    137. movr e,0.21
    138. movr f,0.26
    139. fin: fld a       ;st(0) = a
    140. fmul XCC     ;st(0) = a * XCC
    141. fld b       ;st(0) = b
    142. fmul YCC     ;st(0) = b * YCC
    143. faddp        ;st(0) = a * XCC + b * YCC
    144.         fadd e       ;st(0) = a * XCC + b * YCC + e
    145. fst NewX    ;NewX  = a * XCC + b * YCC + e
    146. fmul const150;st(0) = NewX * 150
    147.         fadd const320 ;st(0) = NewX * 150 + 320
    148. fistp x       ;x = (int) (NewX * 150 + 320)
    149.         mov eax,x
    150. cmp eax,cdXSize
    151. jae @f
    152. fld c       ;st(0) = c
    153. fmul XCC     ;st(0) = c * XCC
    154. fld d       ;st(0) = d
    155. fmul YCC     ;st(0) = d * YCC
    156. faddp        ;st(0) = c * XCC + d * YCC
    157. fadd f       ;st(0) = c * XCC + d * YCC + f
    158. fst NewY    ;NewY  = c * XCC + d * YCC + f
    159. fst YCC     ;YCC = NewY
    160. fmul const150;st(0) = NewY * 150
    161. fsubr const240;st(0)  = -NewY * 150 + 240
    162. fistp y       ; y = (int) (-NewY * 150 + 240)
    163. mov ecx, y
    164. cmp ecx,cdYSize
    165. jae @f
    166. imul ecx,cdXSize*4
    167. add rcx,pMainDIB
    168. mov dword ptr [rcx+rax*4],0FFFFFFh ;*(pMainDIB + y*cdXSize*4 + x*4) = white color
    169. @@: fld NewX  ;XCC = NewX
    170. fstp XCC
    171. dec i
    172. jnz  bucle
    173. wmBYE: leave
    174. retn
    175. WndProc endp
    176. WinMain proc
    177. local msg:MSG
    178. push rbp
    179. mov ebp,esp
    180. sub esp,sizeof MSG
    181. xor ebx,ebx
    182. mov esi,IMAGE_BASE
    183. mov edi,offset ClassName
    184. push rbx ;hIconSm
    185. push rdi ;lpszClassName
    186. push rbx ;lpszMenuName
    187. push COLOR_WINDOWTEXT; hbrBackground
    188. push rbx ;hCursor
    189. push rbx         ;hIcon
    190. push rsi ;hInstance
    191. push rbx         ;cbClsExtra & cbWndExtra
    192. db 68h
    193. dd WndProc       ;lpfnWndProc
    194. push sizeof WNDCLASSEX ;cbSize & style
    195. mov ecx,esp ;addr WNDCLASSEX
    196. call RegisterClassEx
    197. push rbx
    198. push rsi ;rsi=400000h
    199. push rbx
    200. push rbx
    201. push cdYSize
    202. push cdXSize
    203. push cdYPos
    204. push cdXPos
    205. mov r9d,WS_VISIBLE
    206. mov r8,rdi ;offset ClassName
    207. mov edx,edi ;offset ClassName
    208. xor ecx,ecx
    209. sub esp,20h ; dwExStyle
    210. call CreateWindowEx
    211. @@:     lea ecx,msg
    212. xor edx,edx
    213. xor r8d,r8d
    214. xor r9d,r9d
    215. call GetMessage
    216. cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
    217. je wmDESTROY
    218. lea ecx,msg
    219. call DispatchMessage
    220. jmp @b
    221. WinMain endp
    222. .data
    223. ClassName db 'Seashell Fractal',0
    224. bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
    225. bufDIBDC dq ?
    226. pMainDIB dq ?
    227. const150 dd 150.0
    228. const320 dd 320.0
    229. const240 dd 240.0
    230. end
    231.  

    Результат


    [​IMG]
     

    Вложения:

    • Seashellx64.zip
      Размер файла:
      3,8 КБ
      Просмотров:
      198
    • Seashell.png
      Seashell.png
      Размер файла:
      74,2 КБ
      Просмотров:
      546
  4. Mikl___

    Mikl___ Супермодератор Команда форума

    Публикаций:
    7
    Регистрация:
    25 июн 2008
    Сообщения:
    2.697

    Ветрено

    исходный текст и ехе-файл здесь

    Коэффициенты


    abcdefp
    0.3585910.329160-0.3340070.580720-5.8890501.9242780.361396*10000=3614
    0.7962180.1369420.0751870.7190741.0869980.4084520.638604*10000=6386
    Код (ASM):
    1. include win64a.inc
    2. include msvcrt.inc
    3. includelib gdi32.lib
    4. includelib msvcrt.lib
    5. IMAGE_BASE equ 400000h
    6. cdXPos          equ 131
    7. cdYPos          equ 217
    8. cdYSize         equ 430
    9. cdXSize         equ 640
    10. movr macro x,y
    11. mov x,0
    12. org $-4
    13. dd y
    14. endm
    15. .code
    16. WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD
    17. local ps:PAINTSTRUCT
    18. local hdc:qword
    19. local hOldBmp:qword
    20. local hGDITmp:qword
    21. local hOldDIB:qword
    22. local hBackDC:qword
    23. local hMainDIB:qword
    24. local bufBMP:qword
    25. local i:dword
    26. local x:dword
    27. local y:dword
    28. local a:dword
    29. local b:dword
    30. local c:dword
    31. local d:dword
    32. local e:dword
    33. local f:dword
    34. local NewX:qword
    35. local NewY:qword
    36. local XCC:qword
    37. local YCC:qword
    38. push rbp
    39. mov ebp, esp
    40. sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)
    41. mov hWnd,rcx
    42. cmp edx, WM_DESTROY
    43. jz wmDESTROY
    44.         cmp edx, WM_PAINT
    45. jz wmPAINT
    46.         cmp edx, WM_CREATE
    47. jz wmCREATE
    48. leave
    49.         jmp DefWindowProc
    50. ; ---------------------------------------------------------------------------
    51. wmDESTROY::mov rdx,hOldBmp
    52. mov rcx,hBackDC
    53. call SelectObject
    54. mov hGDITmp,rax
    55. mov rcx,bufBMP
    56. call DeleteObject
    57. mov rcx,hBackDC
    58. call DeleteDC
    59. mov rdx,hOldDIB
    60. mov rcx,bufDIBDC
    61. call SelectObject
    62. mov hGDITmp,rax
    63. mov rcx,bufDIBDC
    64. call DeleteDC
    65. mov rcx,hMainDIB
    66. call DeleteObject
    67. mov rcx,hWnd
    68. call DestroyWindow
    69. xor ecx,ecx ; nExitCode
    70. call ExitProcess
    71. ; ---------------------------------------------------------------------------
    72. wmPAINT:lea edx,ps
    73. call BeginPaint
    74. mov hdc,rax
    75. mov qword ptr [rsp+40h],SRCCOPY; rop
    76.         xor edx,edx ; x
    77. mov [rsp+38h],rdx ; y1
    78. mov [rsp+30h],rdx ; x1
    79. mov rax,bufDIBDC ; hdcSrc
    80.         mov [rsp+28h],rax
    81. mov rax,cdYSize
    82. mov [rsp+20h],rax
    83. mov r9,cdXSize ; cx
    84. xor r8d,r8d ; cy
    85. mov rcx,hdc ; hdc
    86. call BitBlt
    87. lea edx,ps
    88. mov rcx,hWnd
    89. call EndPaint
    90. jmp wmBYE
    91. ; ---------------------------------------------------------------------------
    92. wmCREATE:mov rcx,hWnd
    93. call GetDC
    94. mov hdc,rax
    95.         mov rcx,rax ; HDC
    96. call CreateCompatibleDC
    97. mov bufDIBDC,rax
    98. mov [rsp+28h],rbx
    99. mov [rsp+20h],rbx
    100. mov r9d,offset pMainDIB
    101. mov r8d,DIB_RGB_COLORS
    102. mov edx,offset bi
    103. mov rcx,hdc
    104.         call CreateDIBSection
    105. mov hMainDIB,rax
    106. mov rdx,rax; hMainDIB
    107. mov rcx,bufDIBDC
    108. call SelectObject
    109.         mov rax,hOldDIB
    110. mov rdx,hdc
    111. mov rcx,hWnd          
    112.         call ReleaseDC;   // Libera device context          
    113. ;Init--------------------------------------------------------
    114. ; a     b     c   d    e     f    p
    115. ; 0.358591 0.329160 -0.334007 0.580720 -5.889050 1.924278 0.361396*10000=3614
    116. ; 0.796218 0.136942  0.075187 0.719074  1.086998 0.408452 0.638604*10000=6386
    117. mov rdi,pMainDIB
    118. mov ecx,cdYSize*cdXSize
    119. mov eax,0FFFFFFh
    120. rep stosd
    121. mov XCC,rbx
    122. mov YCC,rbx
    123. mov i,35000
    124. bucle:  call rand
    125. mov ecx,10000
    126. xor edx,edx
    127. div ecx
    128. cmp edx,3160
    129. jg @f
    130. cmp edx,3614
    131. jg @f
    132. movr a,0.358591
    133. movr b,0.329160
    134. movr c,-0.334007
    135. movr d,0.580720
    136. movr e,-5.889050
    137. movr f,1.924278
    138. jmp fin
    139. @@: movr a,0.796218
    140. movr b,0.136942  
    141. movr c,0.075187
    142. movr d,0.719074  
    143. movr e,1.086998
    144. movr f,0.408452
    145. fin: fld a       ;st(0) = a
    146. fmul XCC     ;st(0) = a * XCC
    147. fld b       ;st(0) = b
    148. fmul YCC     ;st(0) = b * YCC
    149. faddp        ;st(0) = a * XCC + b * YCC  pop
    150.         fadd e       ;st(0) = a * XCC + b * YCC + e
    151. fst NewX    ;NewX  = a * XCC + b * YCC + e
    152. fmul const45;st(0) = NewX * 45
    153.         fadd const312;st(0) = NewX * 45 + 312
    154. fistp x       ;x = (int) (NewX * 470 + 312)
    155.         mov eax,x
    156. cmp eax,cdXSize
    157. jae @f
    158. fld c       ;st(0) = c
    159. fmul XCC     ;st(0) = c * XCC
    160. fld d       ;st(0) = d
    161. fmul YCC     ;st(0) = d * YCC
    162. faddp        ;st(0) = c * XCC + d * YCC
    163. fadd f       ;st(0) = c * XCC + d * YCC + f
    164. fst NewY    ;NewY  = c * XCC + d * YCC + f
    165. fst YCC     ;YCC = NewY
    166. fmul const45 ;st(0) = NewY * 45
    167. fsubr const410;st(0)  = -NewY * 45 + 410
    168. fistp y       ; y = (int) (-NewY * 45 + 410)
    169. mov ecx, y
    170. cmp ecx,cdYSize
    171. jae @f
    172. imul ecx,cdXSize*4
    173. add rcx,pMainDIB
    174. mov dword ptr [rcx+rax*4],ebx ;*(pMainDIB + y*cdXSize*4 + x*4) = black color
    175. @@: fld NewX  ;XCC = NewX
    176. fstp XCC
    177. dec i
    178. jnz  bucle
    179. wmBYE: leave
    180. retn
    181. WndProc endp
    182. WinMain proc
    183. local msg:MSG
    184. push rbp
    185. mov ebp,esp
    186. sub esp,sizeof MSG
    187. xor ebx,ebx
    188. mov esi,IMAGE_BASE
    189. mov edi,offset ClassName
    190. push rbx ;hIconSm
    191. push rdi ;lpszClassName
    192. push rbx ;lpszMenuName
    193. push COLOR_WINDOWTEXT; hbrBackground
    194. push rbx ;hCursor
    195. push rbx         ;hIcon
    196. push rsi ;hInstance
    197. push rbx         ;cbClsExtra & cbWndExtra
    198. db 68h
    199. dd WndProc       ;lpfnWndProc
    200. push sizeof WNDCLASSEX ;cbSize & style
    201. mov ecx,esp ;addr WNDCLASSEX
    202. call RegisterClassEx
    203. push rbx
    204. push rsi ;rsi=400000h
    205. push rbx
    206. push rbx
    207. push cdYSize
    208. push cdXSize
    209. push cdYPos
    210. push cdXPos
    211. mov r9d,WS_VISIBLE
    212. mov r8,rdi ;offset ClassName
    213. mov edx,edi ;offset ClassName
    214. xor ecx,ecx
    215. sub esp,20h ; dwExStyle
    216. call CreateWindowEx
    217. @@:     lea ecx,msg
    218. xor edx,edx
    219. xor r8d,r8d
    220. xor r9d,r9d
    221. call GetMessage
    222. cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
    223. je wmDESTROY
    224. lea ecx,msg
    225. call DispatchMessage
    226. jmp @b
    227. WinMain endp
    228. .data
    229. ClassName db 'Windy Fractal',0
    230. bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
    231. bufDIBDC dq ?
    232. pMainDIB dq ?
    233. const45 dd 45.0
    234. const312 dd 312.0
    235. const410 dd 410.0
    236. end

    Результат

    [​IMG]
     

    Вложения:

    • Windyx64.zip
      Размер файла:
      3,9 КБ
      Просмотров:
      171
    • Windy.png
      Windy.png
      Размер файла:
      59 КБ
      Просмотров:
      550
  5. Mikl___

    Mikl___ Супермодератор Команда форума

    Публикаций:
    7
    Регистрация:
    25 июн 2008
    Сообщения:
    2.697

    Спираль

    исходный текст и ехе-файл здесь

    Коэффициенты



    abcdefp
    0.935567-0.1649660.1649660.935567000.958*10000=9580
    0.1000.10.75-0.750.011*10000= 110
    0.1000.1-0.750.750.011*10000= 110
    0.1000.10.750.750.011*10000= 110
    0.1000.1-0.75-0.750.009*10000= 90
    Код (ASM):
    1. include win64a.inc
    2. include msvcrt.inc
    3. includelib gdi32.lib
    4. includelib msvcrt.lib
    5. IMAGE_BASE equ 400000h
    6. cdXPos          equ 131
    7. cdYPos          equ 217
    8. cdYSize         equ 430
    9. cdXSize         equ 640
    10. movr macro x,y
    11. mov x,0
    12. org $-4
    13. dd y
    14. endm
    15. .code
    16. WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD
    17. local ps:PAINTSTRUCT
    18. local hdc:qword
    19. local hOldBmp:qword
    20. local hGDITmp:qword
    21. local hOldDIB:qword
    22. local hBackDC:qword
    23. local hMainDIB:qword
    24. local bufBMP:qword
    25. local i:dword
    26. local x:dword
    27. local y:dword
    28. local a:dword
    29. local b:dword
    30. local c:dword
    31. local d:dword
    32. local e:dword
    33. local f:dword
    34. local NewX:qword
    35. local NewY:qword
    36. local XCC:qword
    37. local YCC:qword
    38. push rbp
    39. mov ebp, esp
    40. sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)
    41. mov hWnd,rcx
    42. cmp edx, WM_DESTROY
    43. jz wmDESTROY
    44.         cmp edx, WM_PAINT
    45. jz wmPAINT
    46.         cmp edx, WM_CREATE
    47. jz wmCREATE
    48. leave
    49.         jmp DefWindowProc
    50. ; ---------------------------------------------------------------------------
    51. wmDESTROY::mov rdx,hOldBmp
    52. mov rcx,hBackDC
    53. call SelectObject
    54. mov hGDITmp,rax
    55. mov rcx,bufBMP
    56. call DeleteObject
    57. mov rcx,hBackDC
    58. call DeleteDC
    59. mov rdx,hOldDIB
    60. mov rcx,bufDIBDC
    61. call SelectObject
    62. mov hGDITmp,rax
    63. mov rcx,bufDIBDC
    64. call DeleteDC
    65. mov rcx,hMainDIB
    66. call DeleteObject
    67. mov rcx,hWnd
    68. call DestroyWindow
    69. xor ecx,ecx ; nExitCode
    70. call ExitProcess
    71. ; ---------------------------------------------------------------------------
    72. wmPAINT:lea edx,ps
    73. call BeginPaint
    74. mov hdc,rax
    75. mov qword ptr [rsp+40h],SRCCOPY; rop
    76.         xor edx,edx ; x
    77. mov [rsp+38h],rdx ; y1
    78. mov [rsp+30h],rdx ; x1
    79. mov rax,bufDIBDC ; hdcSrc
    80.         mov [rsp+28h],rax
    81. mov rax,cdYSize
    82. mov [rsp+20h],rax
    83. mov r9,cdXSize ; cx
    84. xor r8d,r8d ; cy
    85. mov rcx,hdc ; hdc
    86. call BitBlt
    87. lea edx,ps
    88. mov rcx,hWnd
    89. call EndPaint
    90. jmp wmBYE
    91. ; ---------------------------------------------------------------------------
    92. wmCREATE:mov rcx,hWnd
    93. call GetDC
    94. mov hdc,rax
    95.         mov rcx,rax ; HDC
    96. call CreateCompatibleDC
    97. mov bufDIBDC,rax
    98. mov [rsp+28h],rbx
    99. mov [rsp+20h],rbx
    100. mov r9d,offset pMainDIB
    101. mov r8d,DIB_RGB_COLORS
    102. mov edx,offset bi
    103. mov rcx,hdc
    104.         call CreateDIBSection
    105. mov hMainDIB,rax
    106. mov rdx,rax; hMainDIB
    107. mov rcx,bufDIBDC
    108. call SelectObject
    109.         mov rax,hOldDIB
    110. mov rdx,hdc
    111. mov rcx,hWnd        
    112.         call ReleaseDC;   // Libera device context        
    113. ;Init--------------------------------------------------------
    114. ;0.935567 -0.164966 0.164966 0.935567  0     0    0.958*10000=9580
    115. ;0.1       0        0        0.1       0.75 -0.75 0.011*10000= 110
    116. ;0.1       0        0        0.1      -0.75  0.75 0.011*10000= 110
    117. ;0.1       0        0        0.1       0.75  0.75 0.011*10000= 110
    118. ;0.1       0        0        0.1      -0.75 -0.75 0.009*10000=  90
    119. mov XCC,rbx
    120. mov YCC,rbx
    121. mov i,390000
    122. bucle:  call rand
    123. mov ecx,10000
    124. xor edx,edx
    125. div ecx
    126. cmp edx,90
    127. jg @f
    128. movr a,0.1                    
    129. mov b,ebx
    130. mov c,ebx
    131. movr d,0.1    
    132. movr e,-0.75
    133. movr f,-0.75
    134. jmp fin
    135. @@: cmp edx,200
    136. jg @f
    137. movr a,0.1                    
    138. mov b,ebx
    139. mov c,ebx
    140. movr d,0.1    
    141. movr e,0.75
    142. movr f,0.75
    143. jmp fin
    144. @@: cmp edx,310
    145. jg @f
    146. movr a,0.1                    
    147. mov b,ebx
    148. mov c,ebx
    149. movr d,0.1    
    150. movr e,-0.75
    151. movr f,0.75
    152. jmp fin
    153. @@: cmp edx,420
    154. jg @f
    155. movr a,0.1                    
    156. mov b,ebx
    157. mov c,ebx
    158. movr d,0.1    
    159. movr e,0.75
    160. movr f,-0.75
    161. jmp fin
    162. @@: movr a,0.935567
    163. movr b,-0.164966
    164. movr c,0.164966
    165. movr d,0.935567    
    166. mov e,ebx
    167. mov f,ebx
    168. fin: fld a       ;st(0) = a
    169. fmul XCC     ;st(0) = a * XCC
    170. fld b       ;st(0) = b
    171. fmul YCC     ;st(0) = b * YCC
    172. faddp        ;st(0) = a * XCC + b * YCC
    173.         fadd e       ;st(0) = a * XCC + b * YCC + e
    174. fst NewX    ;NewX  = a * XCC + b * YCC + e
    175. fmul Scale ;st(0) = NewX * 190
    176.         fadd ShiftX ;st(0) = NewX * 190 + 320
    177. fistp x       ;x = (int) (NewX * 190 + 320)
    178.         mov eax,x
    179. cmp eax,cdXSize
    180. jae @f
    181. fld c       ;st(0) = c
    182. fmul XCC     ;st(0) = c * XCC
    183. fld d       ;st(0) = d
    184. fmul YCC     ;st(0) = d * YCC
    185. faddp        ;st(0) = c * XCC + d * YCC
    186. fadd f       ;st(0) = c * XCC + d * YCC + f
    187. fst NewY    ;NewY  = c * XCC + d * YCC + f
    188. fst YCC     ;YCC = NewY
    189. fmul Scale;st(0) = NewY * 190
    190. fsubr ShiftY;st(0)  = -NewY * 190 + 405
    191. fistp y       ; y = (int) (-NewY * 190 + 405)
    192. mov ecx, y
    193. cmp ecx,cdYSize
    194. jae @f
    195. imul ecx,cdXSize*4
    196. add rcx,pMainDIB
    197. mov dword ptr [rcx+rax*4],0FFFFFFh
    198. @@: fld NewX  ;XCC = NewX
    199. fstp XCC
    200. dec i
    201. jnz  bucle
    202. wmBYE: leave
    203. retn
    204. WndProc endp
    205. WinMain proc
    206. local msg:MSG
    207. push rbp
    208. mov ebp,esp
    209. sub esp,sizeof MSG
    210. xor ebx,ebx
    211. mov esi,IMAGE_BASE
    212. mov edi,offset ClassName
    213. push rbx ;hIconSm
    214. push rdi ;lpszClassName
    215. push rbx ;lpszMenuName
    216. push COLOR_WINDOWTEXT; hbrBackground
    217. push rbx ;hCursor
    218. push rbx         ;hIcon
    219. push rsi ;hInstance
    220. push rbx         ;cbClsExtra & cbWndExtra
    221. db 68h
    222. dd WndProc       ;lpfnWndProc
    223. push sizeof WNDCLASSEX ;cbSize & style
    224. mov ecx,esp ;addr WNDCLASSEX
    225. call RegisterClassEx
    226. push rbx
    227. push rsi ;rsi=400000h
    228. push rbx
    229. push rbx
    230. push cdYSize
    231. push cdXSize
    232. push cdYPos
    233. push cdXPos
    234. mov r9d,WS_VISIBLE
    235. mov r8,rdi ;offset ClassName
    236. mov edx,edi ;offset ClassName
    237. xor ecx,ecx
    238. sub esp,20h ; dwExStyle
    239. call CreateWindowEx
    240. @@:     lea ecx,msg
    241. xor edx,edx
    242. xor r8d,r8d
    243. xor r9d,r9d
    244. call GetMessage
    245. cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
    246. je wmDESTROY
    247. lea ecx,msg
    248. call DispatchMessage
    249. jmp @b
    250. WinMain endp
    251. .data
    252. ClassName db 'Spiral Fractal',0
    253. bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
    254. bufDIBDC dq ?
    255. pMainDIB dq ?
    256. Scale dd 190.0
    257. ShiftX dd 320.0
    258. ShiftY dd 185.0
    259. end
    Результат
    [​IMG]
     

    Вложения:

    • Spiral.png
      Spiral.png
      Размер файла:
      48,2 КБ
      Просмотров:
      563
    • Spiralx64.zip
      Размер файла:
      3,8 КБ
      Просмотров:
      146
  6. Mikl___

    Mikl___ Супермодератор Команда форума

    Публикаций:
    7
    Регистрация:
    25 июн 2008
    Сообщения:
    2.697

    Когти

    исходный текст и ехе-файл здесь

    Коэффициенты


    abcdefp
    0.70.2-0.20.70.00.00.5
    0.0-0.60.60.01.0-0.60.5
    Код (ASM):
    1. include win64a.inc
    2. include msvcrt.inc
    3. includelib gdi32.lib
    4. includelib msvcrt.lib
    5. IMAGE_BASE equ 400000h
    6. cdXPos          equ 131
    7. cdYPos          equ 217
    8. cdYSize         equ 430
    9. cdXSize         equ 640
    10. movr macro x,y
    11. mov x,0
    12. org $-4
    13. dd y
    14. endm
    15. .code
    16. WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD
    17. local ps:PAINTSTRUCT
    18. local hdc:qword
    19. local hOldBmp:qword
    20. local hGDITmp:qword
    21. local hOldDIB:qword
    22. local hBackDC:qword
    23. local hMainDIB:qword
    24. local bufBMP:qword
    25. local i:dword
    26. local x:dword
    27. local y:dword
    28. local a:dword
    29. local b:dword
    30. local c:dword
    31. local d:dword
    32. local e:dword
    33. local f:dword
    34. local NewX:qword
    35. local NewY:qword
    36. local XCC:qword
    37. local YCC:qword
    38. push rbp
    39. mov ebp, esp
    40. sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)
    41. mov hWnd,rcx
    42. cmp edx, WM_DESTROY
    43. jz wmDESTROY
    44.         cmp edx, WM_PAINT
    45. jz wmPAINT
    46.         cmp edx, WM_CREATE
    47. jz wmCREATE
    48. leave
    49.         jmp DefWindowProc
    50. ; ---------------------------------------------------------------------------
    51. wmDESTROY::mov rdx,hOldBmp
    52. mov rcx,hBackDC
    53. call SelectObject
    54. mov hGDITmp,rax
    55. mov rcx,bufBMP
    56. call DeleteObject
    57. mov rcx,hBackDC
    58. call DeleteDC
    59. mov rdx,hOldDIB
    60. mov rcx,bufDIBDC
    61. call SelectObject
    62. mov hGDITmp,rax
    63. mov rcx,bufDIBDC
    64. call DeleteDC
    65. mov rcx,hMainDIB
    66. call DeleteObject
    67. mov rcx,hWnd
    68. call DestroyWindow
    69. xor ecx,ecx ; nExitCode
    70. call ExitProcess
    71. ; ---------------------------------------------------------------------------
    72. wmPAINT:lea edx,ps
    73. call BeginPaint
    74. mov hdc,rax
    75. mov qword ptr [rsp+40h],SRCCOPY; rop
    76.         xor edx,edx ; x
    77. mov [rsp+38h],rdx ; y1
    78. mov [rsp+30h],rdx ; x1
    79. mov rax,bufDIBDC ; hdcSrc
    80.         mov [rsp+28h],rax
    81. mov rax,cdYSize
    82. mov [rsp+20h],rax
    83. mov r9,cdXSize ; cx
    84. xor r8d,r8d ; cy
    85. mov rcx,hdc ; hdc
    86. call BitBlt
    87. lea edx,ps
    88. mov rcx,hWnd
    89. call EndPaint
    90. jmp wmBYE
    91. ; ---------------------------------------------------------------------------
    92. wmCREATE:mov rcx,hWnd
    93. call GetDC
    94. mov hdc,rax
    95.         mov rcx,rax ; HDC
    96. call CreateCompatibleDC
    97. mov bufDIBDC,rax
    98. mov [rsp+28h],rbx
    99. mov [rsp+20h],rbx
    100. mov r9d,offset pMainDIB
    101. mov r8d,DIB_RGB_COLORS
    102. mov edx,offset bi
    103. mov rcx,hdc
    104.         call CreateDIBSection
    105. mov hMainDIB,rax
    106. mov rdx,rax; hMainDIB
    107. mov rcx,bufDIBDC
    108. call SelectObject
    109.         mov rax,hOldDIB
    110. mov rdx,hdc
    111. mov rcx,hWnd        
    112.         call ReleaseDC;   // Libera device context        
    113. ;Init--------------------------------------------------------
    114. ; a     b     c   d    e     f    p
    115. ;0.7  0.2 -0.2 0.7 0.0  0.0 0.5
    116. ;0.0 -0.6  0.6 0.0 1.0 -0.6 0.5
    117. mov XCC,rbx
    118. mov YCC,rbx
    119. mov i,60000
    120. bucle:  call rand
    121. mov ecx,1000
    122. xor edx,edx
    123. div ecx
    124. cmp edx,400
    125. jg @f
    126. movr a,0.7
    127. movr b,0.2
    128. movr c,-0.2
    129. movr d,0.7
    130. mov e,ebx
    131. mov f,ebx
    132. jmp fin
    133. @@: mov a,ebx
    134. movr b,-0.6
    135. movr c,0.6
    136. mov d,ebx
    137. movr e,1.0
    138. movr f,-0.6
    139. fin: fld a       ;st(0) = a
    140. fmul XCC     ;st(0) = a * XCC
    141. fld b       ;st(0) = b
    142. fmul YCC     ;st(0) = b * YCC
    143. faddp        ;st(0) = a * XCC + b * YCC
    144.         fadd e       ;st(0) = a * XCC + b * YCC + e
    145. fst NewX    ;NewX  = a * XCC + b * YCC + e
    146. fmul const340;st(0) = NewX * 340
    147.         fadd const120;st(0) = NewX * 340 + 120
    148. fistp x       ;x = (int) (NewX * 470 + 120)
    149.         mov eax,x
    150. cmp eax,cdXSize
    151. jae @f
    152. fld c       ;st(0) = c
    153. fmul XCC     ;st(0) = c * XCC
    154. fld d       ;st(0) = d
    155. fmul YCC     ;st(0) = d * YCC
    156. faddp        ;st(0) = c * XCC + d * YCC
    157. fadd f       ;st(0) = c * XCC + d * YCC + f
    158. fst NewY    ;NewY  = c * XCC + d * YCC + f
    159. fst YCC     ;YCC = NewY
    160. fchs            ;st(0)  = -NewY
    161. fmul const340;st(0) = -NewY * 340
    162. fadd const160;st(0)  = -NewY * 340 + 160
    163. fistp y       ; y = (int) (-NewY * 340 + 160)
    164. mov ecx, y
    165. cmp ecx,cdYSize
    166. jae @f
    167. imul ecx,cdXSize*4
    168. add rcx,pMainDIB
    169. mov dword ptr [rcx+rax*4],0FFFFFFh ;*(pMainDIB + y*cdXSize*4 + x*4) = white color
    170. @@: fld NewX  ;XCC = NewX
    171. fstp XCC
    172. dec i
    173. jnz  bucle
    174. wmBYE: leave
    175. retn
    176. WndProc endp
    177. WinMain proc
    178. local msg:MSG
    179. push rbp
    180. mov ebp,esp
    181. sub esp,sizeof MSG
    182. xor ebx,ebx
    183. mov esi,IMAGE_BASE
    184. mov edi,offset ClassName
    185. push rbx ;hIconSm
    186. push rdi ;lpszClassName
    187. push rbx ;lpszMenuName
    188. push COLOR_APPWORKSPACE ;hbrBackground
    189. push rbx ;hCursor
    190. push rbx         ;hIcon
    191. push rsi ;hInstance
    192. push rbx         ;cbClsExtra & cbWndExtra
    193. db 68h
    194. dd WndProc       ;lpfnWndProc
    195. push sizeof WNDCLASSEX ;cbSize & style
    196. mov ecx,esp ;addr WNDCLASSEX
    197. call RegisterClassEx
    198. push rbx
    199. push rsi ;rsi=400000h
    200. push rbx
    201. push rbx
    202. push cdYSize
    203. push cdXSize
    204. push cdYPos
    205. push cdXPos
    206. mov r9d,WS_VISIBLE
    207. mov r8,rdi ;offset ClassName
    208. mov edx,edi ;offset ClassName
    209. xor ecx,ecx
    210. sub esp,20h ; dwExStyle
    211. call CreateWindowEx
    212. @@:     lea ecx,msg
    213. xor edx,edx
    214. xor r8d,r8d
    215. xor r9d,r9d
    216. call GetMessage
    217. cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
    218. je wmDESTROY
    219. lea ecx,msg
    220. call DispatchMessage
    221. jmp @b
    222. WinMain endp
    223. .data
    224. ClassName db 'Talon Fractal',0
    225. bi BITMAPINFO <<28h,640,-430,1,32,0,0,0,0,0,0>>
    226. bufDIBDC dq ?
    227. pMainDIB dq ?
    228. const340 dd 340.0
    229. const120 dd 120.0
    230. const160 dd 160.0
    231. end
    Результат
    [​IMG]
     

    Вложения:

    • Talonx64.zip
      Размер файла:
      3,7 КБ
      Просмотров:
      181
    • talon.png
      talon.png
      Размер файла:
      49,8 КБ
      Просмотров:
      542
    Последнее редактирование: 19 дек 2016
  7. Mikl___

    Mikl___ Супермодератор Команда форума

    Публикаций:
    7
    Регистрация:
    25 июн 2008
    Сообщения:
    2.697

    Клен

    исходный текст и ехе-файл здесь

    Коэффициенты


    abcdefp
    0.49-0.0100.620.250.020.316*10000=3160
    0.27-0.520.40.360-0.560.316*10000=3160
    0.180.73-0.50.260.88-0.080.316*10000=3160
    0.040.01-0.500.52-0.320.052*10000= 520
    Код (ASM):
    1. include win64a.inc
    2. include msvcrt.inc
    3. includelib gdi32.lib
    4. includelib msvcrt.lib
    5. IMAGE_BASE equ 400000h
    6. cdXPos          equ 131
    7. cdYPos          equ 217
    8. cdYSize         equ 430
    9. cdXSize         equ 640
    10. movr macro x,y
    11. mov x,0
    12. org $-4
    13. dd y
    14. endm
    15. .code
    16. WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD
    17. local ps:PAINTSTRUCT
    18. local hdc:qword
    19. local hOldBmp:qword
    20. local hGDITmp:qword
    21. local hOldDIB:qword
    22. local hBackDC:qword
    23. local hMainDIB:qword
    24. local bufBMP:qword
    25. local i:dword
    26. local x:dword
    27. local y:dword
    28. local a:dword
    29. local b:dword
    30. local c:dword
    31. local d:dword
    32. local e:dword
    33. local f:dword
    34. local NewX:qword
    35. local NewY:qword
    36. local XCC:qword
    37. local YCC:qword
    38. push rbp
    39. mov ebp, esp
    40. sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)
    41. mov hWnd,rcx
    42. cmp edx, WM_DESTROY
    43. jz wmDESTROY
    44.         cmp edx, WM_PAINT
    45. jz wmPAINT
    46.         cmp edx, WM_CREATE
    47. jz wmCREATE
    48. leave
    49.         jmp DefWindowProc
    50. ; ---------------------------------------------------------------------------
    51. wmDESTROY::mov rdx,hOldBmp
    52. mov rcx,hBackDC
    53. call SelectObject
    54. mov hGDITmp,rax
    55. mov rcx,bufBMP
    56. call DeleteObject
    57. mov rcx,hBackDC
    58. call DeleteDC
    59. mov rdx,hOldDIB
    60. mov rcx,bufDIBDC
    61. call SelectObject
    62. mov hGDITmp,rax
    63. mov rcx,bufDIBDC
    64. call DeleteDC
    65. mov rcx,hMainDIB
    66. call DeleteObject
    67. mov rcx,hWnd
    68. call DestroyWindow
    69. xor ecx,ecx ; nExitCode
    70. call ExitProcess
    71. ; ---------------------------------------------------------------------------
    72. wmPAINT:lea edx,ps
    73. call BeginPaint
    74. mov hdc,rax
    75. mov qword ptr [rsp+40h],SRCCOPY; rop
    76.         xor edx,edx ; x
    77. mov [rsp+38h],rdx ; y1
    78. mov [rsp+30h],rdx ; x1
    79. mov rax,bufDIBDC ; hdcSrc
    80.         mov [rsp+28h],rax
    81. mov rax,cdYSize
    82. mov [rsp+20h],rax
    83. mov r9,cdXSize ; cx
    84. xor r8d,r8d ; cy
    85. mov rcx,hdc ; hdc
    86. call BitBlt
    87. lea edx,ps
    88. mov rcx,hWnd
    89. call EndPaint
    90. jmp wmBYE
    91. ; ---------------------------------------------------------------------------
    92. wmCREATE:mov rcx,hWnd
    93. call GetDC
    94. mov hdc,rax
    95.         mov rcx,rax ; HDC
    96. call CreateCompatibleDC
    97. mov bufDIBDC,rax
    98. mov [rsp+28h],rbx
    99. mov [rsp+20h],rbx
    100. mov r9d,offset pMainDIB
    101. mov r8d,DIB_RGB_COLORS
    102. mov edx,offset bi
    103. mov rcx,hdc
    104.         call CreateDIBSection
    105. mov hMainDIB,rax
    106. mov rdx,rax; hMainDIB
    107. mov rcx,bufDIBDC
    108. call SelectObject
    109.         mov rax,hOldDIB
    110. mov rdx,hdc
    111. mov rcx,hWnd          
    112.         call ReleaseDC;   // Libera device context          
    113. ;Init--------------------------------------------------------
    114. ; a     b     c   d    e     f    p
    115. ; 0.49 -0.01  0   0.62 0.25  0.02 0.316*10000=3160;
    116. ; 0.27 -0.52  0.4 0.36 0    -0.56 0.316*10000=3160;6320
    117. ; 0.18  0.73 -0.5 0.26 0.88 -0.08 0.316*10000=3160;9480
    118. ; 0.04  0.01 -0.5 0    0.52 -0.32 0.052*10000= 520
    119. mov XCC,rbx
    120. mov YCC,rbx
    121. mov i,48000
    122. bucle:  call rand
    123. mov ecx,10000
    124. xor edx,edx
    125. div ecx
    126. cmp edx,3160
    127. jg @f
    128. movr a,0.49
    129. movr b,-0.01    
    130. mov c,ebx
    131. movr d,0.62
    132. movr e,0.25  
    133. movr f,0.02
    134. jmp fin
    135. @@: cmp edx,6320
    136. jg @f
    137. movr a,0.27
    138. movr b,-0.52  
    139. movr c,0.4
    140. movr d,0.36    
    141. mov e,ebx
    142. movr f,-0.56
    143. jmp fin
    144. @@: cmp edx,9480
    145. jg @f
    146. movr a,0.18  
    147. movr b,0.73
    148. movr c,-0.5
    149. movr d,0.26
    150. movr e,0.88
    151. movr f,-0.08
    152. jmp fin
    153. @@: movr a,0.04  
    154. movr b,0.01
    155. movr c,-0.5    
    156. mov d,ebx
    157. movr e,0.52
    158. movr f,-0.32
    159. fin: fld a       ;st(0) = a
    160. fmul XCC     ;st(0) = a * XCC
    161. fld b       ;st(0) = b
    162. fmul YCC     ;st(0) = b * YCC
    163. faddp        ;st(0) = a * XCC + b * YCC
    164.         fadd e       ;st(0) = a * XCC + b * YCC + e
    165. fst NewX    ;NewX  = a * XCC + b * YCC + e
    166. fmul const470;st(0) = NewX * 470
    167.         fadd const82 ;st(0) = NewX * 470 + 82
    168. fistp x       ;x = (int) (NewX * 470 + 82)
    169.         mov eax,x
    170. cmp eax,cdXSize
    171. jae @f
    172. fld c       ;st(0) = c
    173. fmul XCC     ;st(0) = c * XCC
    174. fld d       ;st(0) = d
    175. fmul YCC     ;st(0) = d * YCC
    176. faddp        ;st(0) = c * XCC + d * YCC
    177. fadd f       ;st(0) = c * XCC + d * YCC + f
    178. fst NewY    ;NewY  = c * XCC + d * YCC + f
    179. fst YCC     ;YCC = NewY
    180. fchs            ;st(0)  = -NewY
    181. fmul const470;st(0) = -NewY * 470
    182. fadd const42;st(0)  = -NewY * 470 + 42
    183. fistp y       ; y = (int) (-NewY * 470 + 42)
    184. mov ecx, y
    185. cmp ecx,cdYSize
    186. jae @f
    187. imul ecx,y,cdXSize*4
    188. add rcx,pMainDIB
    189. mov dword ptr [rcx+rax*4],0FF8000h ;*(pMainDIB + y*cdXSize*4 + x*4) = orange color
    190. @@: fld NewX  ;XCC = NewX
    191. fstp XCC
    192. dec i
    193. jnz  bucle
    194. wmBYE: leave
    195. retn
    196. WndProc endp
    197. WinMain proc
    198. local msg:MSG
    199. push rbp
    200. mov ebp,esp
    201. sub esp,sizeof MSG
    202. xor ebx,ebx
    203. mov esi,IMAGE_BASE
    204. mov edi,offset ClassName
    205. push rbx ;hIconSm
    206. push rdi ;lpszClassName
    207. push rbx ;lpszMenuName
    208. push COLOR_WINDOWTEXT; hbrBackground
    209. push rbx ;hCursor
    210. push rbx         ;hIcon
    211. push rsi ;hInstance
    212. push rbx         ;cbClsExtra & cbWndExtra
    213. db 68h
    214. dd WndProc       ;lpfnWndProc
    215. push sizeof WNDCLASSEX ;cbSize & style
    216. mov ecx,esp ;addr WNDCLASSEX
    217. call RegisterClassEx
    218. push rbx
    219. push rsi ;rsi=400000h
    220. push rbx
    221. push rbx
    222. push cdYSize
    223. push cdXSize
    224. push cdYPos
    225. push cdXPos
    226. mov r9d,WS_VISIBLE
    227. mov r8,rdi ;offset ClassName
    228. mov edx,edi ;offset ClassName
    229. xor ecx,ecx
    230. sub esp,20h ; dwExStyle
    231. call CreateWindowEx
    232. @@:     lea ecx,msg
    233. xor edx,edx
    234. xor r8d,r8d
    235. xor r9d,r9d
    236. call GetMessage
    237. cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
    238. je wmDESTROY
    239. lea ecx,msg
    240. call DispatchMessage
    241. jmp @b
    242. WinMain endp
    243. .data
    244. ClassName db 'Maple Fractal',0
    245. bi BITMAPINFO <<28h,640,-430,1,32,0,0,0,0,0,0>>
    246. bufDIBDC dq ?
    247. pMainDIB dq ?
    248. const470 dd 470.0
    249. const82 dd 82.0
    250. const42 dd 42.0
    251. end

    Результат



    [​IMG]
     

    Вложения:

    • Maplex64.zip
      Размер файла:
      4 КБ
      Просмотров:
      182
    • maple.png
      maple.png
      Размер файла:
      49,6 КБ
      Просмотров:
      547
    Последнее редактирование: 19 дек 2016
    gazlan нравится это.
  8. Mikl___

    Mikl___ Супермодератор Команда форума

    Публикаций:
    7
    Регистрация:
    25 июн 2008
    Сообщения:
    2.697

    Лестницы

    исходный текст и ехе-файл здесь

    Коэффициенты


    abcdefp
    0.50.50000.50.08*10000=800
    0.50.5000-0.50.08*10000=800
    0 0 0.5 0.5 0.5 0 0.08*10000=800
    000.50.5-0.500.08*10000=800
    0.85-0.15 0.150.85000.68*10000=6800
    Код (ASM):
    1. include win64a.inc
    2. include msvcrt.inc
    3. includelib gdi32.lib
    4. includelib msvcrt.lib
    5. IMAGE_BASE equ 400000h
    6. cdXPos          equ 131
    7. cdYPos          equ 217
    8. cdYSize         equ 430
    9. cdXSize         equ 640
    10. movr macro x,y
    11. mov x,0
    12. org $-4
    13. dd y
    14. endm
    15. .code
    16. WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD
    17. local ps:PAINTSTRUCT
    18. local hdc:qword
    19. local hOldBmp:qword
    20. local hGDITmp:qword
    21. local hOldDIB:qword
    22. local hBackDC:qword
    23. local hMainDIB:qword
    24. local bufBMP:qword
    25. local i:dword
    26. local x:dword
    27. local y:dword
    28. local a:dword
    29. local b:dword
    30. local c:dword
    31. local d:dword
    32. local e:dword
    33. local f:dword
    34. local NewX:qword
    35. local NewY:qword
    36. local XCC:qword
    37. local YCC:qword
    38. push rbp
    39. mov ebp, esp
    40. sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)
    41. mov hWnd,rcx
    42. cmp edx, WM_DESTROY
    43. jz wmDESTROY
    44.         cmp edx, WM_PAINT
    45. jz wmPAINT
    46.         cmp edx, WM_CREATE
    47. jz wmCREATE
    48. leave
    49.         jmp DefWindowProc
    50. ; ---------------------------------------------------------------------------
    51. wmDESTROY::mov rdx,hOldBmp
    52. mov rcx,hBackDC
    53. call SelectObject
    54. mov hGDITmp,rax
    55. mov rcx,bufBMP
    56. call DeleteObject
    57. mov rcx,hBackDC
    58. call DeleteDC
    59. mov rdx,hOldDIB
    60. mov rcx,bufDIBDC
    61. call SelectObject
    62. mov hGDITmp,rax
    63. mov rcx,bufDIBDC
    64. call DeleteDC
    65. mov rcx,hMainDIB
    66. call DeleteObject
    67. mov rcx,hWnd
    68. call DestroyWindow
    69. xor ecx,ecx ; nExitCode
    70. call ExitProcess
    71. ; ---------------------------------------------------------------------------
    72. wmPAINT:lea edx,ps
    73. call BeginPaint
    74. mov hdc,rax
    75. mov qword ptr [rsp+40h],SRCCOPY; rop
    76.         xor edx,edx ; x
    77. mov [rsp+38h],rdx ; y1
    78. mov [rsp+30h],rdx ; x1
    79. mov rax,bufDIBDC ; hdcSrc
    80.         mov [rsp+28h],rax
    81. mov rax,cdYSize
    82. mov [rsp+20h],rax
    83. mov r9,cdXSize ; cx
    84. xor r8d,r8d ; cy
    85. mov rcx,hdc ; hdc
    86. call BitBlt
    87. lea edx,ps
    88. mov rcx,hWnd
    89. call EndPaint
    90. jmp wmBYE
    91. ; ---------------------------------------------------------------------------
    92. wmCREATE:mov rcx,hWnd
    93. call GetDC
    94. mov hdc,rax
    95.         mov rcx,rax ; HDC
    96. call CreateCompatibleDC
    97. mov bufDIBDC,rax
    98. mov [rsp+28h],rbx
    99. mov [rsp+20h],rbx
    100. mov r9d,offset pMainDIB
    101. mov r8d,DIB_RGB_COLORS
    102. mov edx,offset bi
    103. mov rcx,hdc
    104.         call CreateDIBSection
    105. mov hMainDIB,rax
    106. mov rdx,rax; hMainDIB
    107. mov rcx,bufDIBDC
    108. call SelectObject
    109.         mov rax,hOldDIB
    110. mov rdx,hdc
    111. mov rcx,hWnd      
    112.         call ReleaseDC;   // Libera device context      
    113. ;Init--------------------------------------------------------
    114. ;  a     b   c    d     e    f   p
    115. ; 0.5   0.5  0    0     0   0.5 0.08*10000=800
    116. ; 0.5   0.5  0    0     0  -0.5 0.08*10000=800
    117. ; 0     0    0.5  0.5   0.5 0   0.08*10000=800
    118. ; 0     0    0.5  0.5  -0.5 0   0.08*10000=800
    119. ; 0.85 -0.15 0.15 0.85  0   0   0.68*10000=6800
    120. mov XCC,rbx
    121. mov YCC,rbx
    122. mov i,390000
    123. bucle:  call rand
    124. mov ecx,10000
    125. xor edx,edx
    126. div ecx
    127. cmp edx,800
    128. jg @f
    129. movr a,0.5
    130. movr b,0.5
    131. mov c,ebx
    132. mov d,ebx
    133. mov e,ebx
    134. movr f,0.5
    135. jmp fin
    136. @@: cmp edx,1600
    137. jg @f
    138. movr a,0.5
    139. movr b,0.5
    140. mov c,ebx
    141. mov d,ebx
    142. mov e,ebx
    143. movr f,-0.5
    144. jmp fin
    145. @@: cmp edx,2400
    146. jg @f
    147. mov a,ebx
    148. mov b,ebx
    149. movr c,0.5
    150. movr d,0.5
    151. movr e,0.5
    152. mov f,ebx
    153. jmp fin
    154. @@: cmp edx,3200
    155. jg @f
    156. mov a,ebx
    157. mov b,ebx
    158. movr c,0.5
    159. movr d,0.5
    160. movr e,-0.5
    161. mov f,ebx
    162. jmp fin
    163. @@: movr a,0.85
    164. movr b,-0.15
    165. movr c,0.15
    166. movr d,0.85
    167. mov e,ebx
    168. mov f,ebx
    169. fin: fld a       ;st(0) = a
    170. fmul XCC     ;st(0) = a * XCC
    171. fld b       ;st(0) = b
    172. fmul YCC     ;st(0) = b * YCC
    173. faddp        ;st(0) = a * XCC + b * YCC
    174.         fadd e       ;st(0) = a * XCC + b * YCC + e
    175. fst NewX    ;NewX  = a * XCC + b * YCC + e
    176. fimul Scale;st(0) = NewX * 360
    177.         fiadd ShiftX ;st(0) = NewX * 360 + 320
    178. fistp x       ;x = (int) (NewX * 360 + 320)
    179.         mov eax,x
    180. cmp eax,cdXSize
    181. jae @f
    182. fld c       ;st(0) = c
    183. fmul XCC     ;st(0) = c * XCC
    184. fld d       ;st(0) = d
    185. fmul YCC     ;st(0) = d * YCC
    186. faddp        ;st(0) = c * XCC + d * YCC
    187. fadd f       ;st(0) = c * XCC + d * YCC + f
    188. fst NewY    ;NewY  = c * XCC + d * YCC + f
    189. fst YCC     ;YCC = NewY
    190. fimul Scale;st(0) = NewY * 300
    191. fisubr ShiftY;st(0)  = -NewY * 360 + 185
    192. fistp y       ; y = (int) (-NewY * 360 + 185)
    193. mov ecx, y
    194. cmp ecx,cdYSize
    195. jae @f
    196. imul ecx,cdXSize*4
    197. add rcx,pMainDIB
    198. mov dword ptr [rcx+rax*4],0FFFFFFh ;*(pMainDIB + y*cdXSize*4 + x*4) = white color
    199. @@: fld NewX  ;XCC = NewX
    200. fstp XCC
    201. dec i
    202. jnz  bucle
    203. wmBYE: leave
    204. retn
    205. WndProc endp
    206. WinMain proc
    207. local msg:MSG
    208. push rbp
    209. mov ebp,esp
    210. sub esp,sizeof MSG
    211. xor ebx,ebx
    212. mov esi,IMAGE_BASE
    213. mov edi,offset ClassName
    214. push rbx ;hIconSm
    215. push rdi ;lpszClassName
    216. push rbx ;lpszMenuName
    217. push COLOR_WINDOWTEXT; hbrBackground
    218. push rbx ;hCursor
    219. push rbx         ;hIcon
    220. push rsi ;hInstance
    221. push rbx         ;cbClsExtra & cbWndExtra
    222. db 68h
    223. dd WndProc       ;lpfnWndProc
    224. push sizeof WNDCLASSEX ;cbSize & style
    225. mov ecx,esp ;addr WNDCLASSEX
    226. call RegisterClassEx
    227. push rbx
    228. push rsi ;rsi=400000h
    229. push rbx
    230. push rbx
    231. push cdYSize
    232. push cdXSize
    233. push cdYPos
    234. push cdXPos
    235. mov r9d,WS_VISIBLE
    236. mov r8,rdi ;offset ClassName
    237. mov edx,edi ;offset ClassName
    238. xor ecx,ecx
    239. sub esp,20h ; dwExStyle
    240. call CreateWindowEx
    241. @@:     lea ecx,msg
    242. xor edx,edx
    243. xor r8d,r8d
    244. xor r9d,r9d
    245. call GetMessage
    246. cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
    247. je wmDESTROY
    248. lea ecx,msg
    249. call DispatchMessage
    250. jmp @b
    251. WinMain endp
    252. .data
    253. ClassName db 'Stairway Fractal',0
    254. bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
    255. bufDIBDC dq ?
    256. pMainDIB dq ?
    257. Scale dd 360
    258. ShiftX dd 320
    259. ShiftY dd 185
    260. end
    261.  
    Результат
    [​IMG]
     

    Вложения:

    • stairway.png
      stairway.png
      Размер файла:
      31,6 КБ
      Просмотров:
      530
    • Stairwayx64.zip
      Размер файла:
      3,9 КБ
      Просмотров:
      179
  9. Mikl___

    Mikl___ Супермодератор Команда форума

    Публикаций:
    7
    Регистрация:
    25 июн 2008
    Сообщения:
    2.697

    Дерево #1


    исходный текст и ехе-файл здесь

    Коэффициенты


    abcdefp
    0000.50000.05*100000=500
    0.42-0.420.420.4200.2 0.4*100000=4000
    0.420.42-0.420.4200.20.4*100000=4000
    0.1000.100.20.15*10000=1500

    Код (ASM):
    1. include win64a.inc
    2. include msvcrt.inc
    3. includelib gdi32.lib
    4. includelib msvcrt.lib
    5. IMAGE_BASE equ 400000h
    6. cdXPos          equ 131
    7. cdYPos          equ 217
    8. cdYSize         equ 430
    9. cdXSize         equ 640
    10. movr macro x,y
    11. mov x,0
    12. org $-4
    13. dd y
    14. endm
    15. .code
    16. WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD
    17. local ps:PAINTSTRUCT
    18. local hdc:qword
    19. local hOldBmp:qword
    20. local hGDITmp:qword
    21. local hOldDIB:qword
    22. local hBackDC:qword
    23. local hMainDIB:qword
    24. local bufBMP:qword
    25. local i:dword
    26. local x:dword
    27. local y:dword
    28. local a:dword
    29. local b:dword
    30. local c:dword
    31. local d:dword
    32. local e:dword
    33. local f:dword
    34. local NewX:qword
    35. local NewY:qword
    36. local XCC:qword
    37. local YCC:qword
    38. push rbp
    39. mov ebp, esp
    40. sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)
    41. mov hWnd,rcx
    42. cmp edx, WM_DESTROY
    43. jz wmDESTROY
    44.         cmp edx, WM_PAINT
    45. jz wmPAINT
    46.         cmp edx, WM_CREATE
    47. jz wmCREATE
    48. leave
    49.         jmp DefWindowProc
    50. ; ---------------------------------------------------------------------------
    51. wmDESTROY::mov rdx,hOldBmp
    52. mov rcx,hBackDC
    53. call SelectObject
    54. mov hGDITmp,rax
    55. mov rcx,bufBMP
    56. call DeleteObject
    57. mov rcx,hBackDC
    58. call DeleteDC
    59. mov rdx,hOldDIB
    60. mov rcx,bufDIBDC
    61. call SelectObject
    62. mov hGDITmp,rax
    63. mov rcx,bufDIBDC
    64. call DeleteDC
    65. mov rcx,hMainDIB
    66. call DeleteObject
    67. mov rcx,hWnd
    68. call DestroyWindow
    69. xor ecx,ecx ; nExitCode
    70. call ExitProcess
    71. ; ---------------------------------------------------------------------------
    72. wmPAINT:lea edx,ps
    73. call BeginPaint
    74. mov hdc,rax
    75. mov qword ptr [rsp+40h],SRCCOPY; rop
    76.         xor edx,edx ; x
    77. mov [rsp+38h],rdx ; y1
    78. mov [rsp+30h],rdx ; x1
    79. mov rax,bufDIBDC ; hdcSrc
    80.         mov [rsp+28h],rax
    81. mov rax,cdYSize
    82. mov [rsp+20h],rax
    83. mov r9,cdXSize ; cx
    84. xor r8d,r8d ; cy
    85. mov rcx,hdc ; hdc
    86. call BitBlt
    87. lea edx,ps
    88. mov rcx,hWnd
    89. call EndPaint
    90. jmp wmBYE
    91. ; ---------------------------------------------------------------------------
    92. wmCREATE:mov rcx,hWnd
    93. call GetDC
    94. mov hdc,rax
    95.         mov rcx,rax ; HDC
    96. call CreateCompatibleDC
    97. mov bufDIBDC,rax
    98. mov [rsp+28h],rbx
    99. mov [rsp+20h],rbx
    100. mov r9d,offset pMainDIB
    101. mov r8d,DIB_RGB_COLORS
    102. mov edx,offset bi
    103. mov rcx,hdc
    104.         call CreateDIBSection
    105. mov hMainDIB,rax
    106. mov rdx,rax; hMainDIB
    107. mov rcx,bufDIBDC
    108. call SelectObject
    109.         mov rax,hOldDIB
    110. mov rdx,hdc
    111. mov rcx,hWnd      
    112.         call ReleaseDC;   // Libera device context      
    113. ;Init--------------------------------------------------------
    114. ;a     b     c    d    e f   p
    115. ;0     0     0    0.50 0 0   0.05         500
    116. ;0.42 -0.42  0.42 0.42 0 0.2 0.4         4000
    117. ;0.42  0.42 -0.42 0.42 0 0.2 0.4         4000
    118. ;0.1   0     0    0.1  0 0.2 0.15*10000= 1500
    119. mov XCC,rbx
    120. mov YCC,rbx
    121. mov i,150000
    122. bucle:  call rand
    123. mov ecx,10000
    124. xor edx,edx
    125. div ecx
    126. cmp edx,500
    127. jg @f
    128. mov a,ebx
    129. mov b,ebx
    130. mov c,ebx; c = 0
    131. movr d,0.5
    132. mov f,ebx
    133. jmp fin
    134. @@: cmp edx,4500
    135. jg @f
    136. movr a,0.42
    137. movr b,-0.42
    138. movr c,0.42
    139. movr d,0.42
    140. movr f,0.2  
    141. jmp fin
    142. @@: cmp edx,8500
    143. jg @f
    144. movr a,0.42
    145. movr b,0.42
    146. movr c,-0.42
    147. movr d,0.42
    148. movr f,0.2
    149. jmp fin
    150. @@: movr a,0.1
    151. mov b,ebx
    152. mov c,ebx
    153. movr d,0.1
    154. movr f,0.2
    155. fin: fld a       ;st(0) = a
    156. fmul XCC     ;st(0) = a * XCC
    157. fld b       ;st(0) = b
    158. fmul YCC     ;st(0) = b * YCC
    159. faddp        ;st(0) = a * XCC + b * YCC
    160. fst NewX    ;NewX  = a * XCC + b * YCC
    161. fmul Scale ;st(0) = NewX * 900
    162.         fadd ShiftX ;st(0) = NewX * 900 + 320
    163. fistp x       ;x = (int) (NewX * 900 + 320)
    164.         mov eax,x
    165. cmp eax,cdXSize
    166. jae @f
    167. fld c       ;st(0) = c
    168. fmul XCC     ;st(0) = c * XCC
    169. fld d       ;st(0) = d
    170. fmul YCC     ;st(0) = d * YCC
    171. faddp        ;st(0) = c * XCC + d * YCC
    172. fadd f       ;st(0) = c * XCC + d * YCC + f
    173. fst NewY    ;NewY  = c * XCC + d * YCC + f
    174. fst YCC     ;YCC = NewY
    175. fmul Scale;st(0) = NewY * 900
    176. fsubr ShiftY;st(0)  = -NewY * 900 + 405
    177. fistp y       ; y = (int) (-NewY * 900 + 405)
    178. mov ecx, y
    179. cmp ecx,cdYSize
    180. jae @f
    181. imul ecx,cdXSize*4
    182. add rcx,pMainDIB
    183. mov dword ptr [rcx+rax*4],0FF00h ;*(pMainDIB + y*cdXSize*4 + x*4) = black color
    184. @@: fld NewX  ;XCC = NewX
    185. fstp XCC
    186. dec i
    187. jnz  bucle
    188. wmBYE: leave
    189. retn
    190. WndProc endp
    191. WinMain proc
    192. local msg:MSG
    193. push rbp
    194. mov ebp,esp
    195. sub esp,sizeof MSG
    196. xor ebx,ebx
    197. mov esi,IMAGE_BASE
    198. mov edi,offset ClassName
    199. push rbx ;hIconSm
    200. push rdi ;lpszClassName
    201. push rbx ;lpszMenuName
    202. push COLOR_WINDOWTEXT; hbrBackground
    203. push rbx ;hCursor
    204. push rbx         ;hIcon
    205. push rsi ;hInstance
    206. push rbx         ;cbClsExtra & cbWndExtra
    207. db 68h
    208. dd WndProc       ;lpfnWndProc
    209. push sizeof WNDCLASSEX ;cbSize & style
    210. mov ecx,esp ;addr WNDCLASSEX
    211. call RegisterClassEx
    212. push rbx
    213. push rsi ;rsi=400000h
    214. push rbx
    215. push rbx
    216. push cdYSize
    217. push cdXSize
    218. push cdYPos
    219. push cdXPos
    220. mov r9d,WS_VISIBLE
    221. mov r8,rdi ;offset ClassName
    222. mov edx,edi ;offset ClassName
    223. xor ecx,ecx
    224. sub esp,20h ; dwExStyle
    225. call CreateWindowEx
    226. @@:     lea ecx,msg
    227. xor edx,edx
    228. xor r8d,r8d
    229. xor r9d,r9d
    230. call GetMessage
    231. cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
    232. je wmDESTROY
    233. lea ecx,msg
    234. call DispatchMessage
    235. jmp @b
    236. WinMain endp
    237. .data
    238. ClassName db 'Tree #1 Fractal',0
    239. bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
    240. bufDIBDC dq ?
    241. pMainDIB dq ?
    242. Scale dd 900.0
    243. ShiftX dd 320.0
    244. ShiftY dd 405.0
    245. end
    246.  
    Результат
    [​IMG]

    [​IMG]
     

    Вложения:

    • Dancing Julia.png
      Dancing Julia.png
      Размер файла:
      137,7 КБ
      Просмотров:
      323
    • Tree1.png
      Tree1.png
      Размер файла:
      26 КБ
      Просмотров:
      535
    • Tree1x64.zip
      Размер файла:
      3,8 КБ
      Просмотров:
      198
  10. ml64

    ml64 New Member

    Публикаций:
    0
    Регистрация:
    29 окт 2017
    Сообщения:
    9
    Добавлю пару простых примеров.
    Строятся методом хаоса, без IFC-матрицы. Регистрами общего назначения. Целочисленными инструкциями.
    Случайные числа генерируются функцией CryptGenRandom

    Треугольник Серпинского


    Код (ASM):
    1.     ;x = (x + x_A)/2
    2.         mov rax,x
    3.         add rax,x_A    ;x = x + x_A
    4.         shr rax,1    ;x = x/2
    5.         mov x,rax    ;Store x
    6.     ;y = (y + y_A)/2
    7.         mov rax,y
    8.         add rax,y_A    ;y = y + y_A
    9.         shr rax,1    ;y = y/2
    10.         mov y,rax    ;Store y
    [​IMG]

    Ковёр Серпинского


    Код (ASM):
    1.     ;x = (x + 2*x_A) / 3
    2.         xor rdx,rdx    ;Dividend
    3.         mov rcx,3    ;Divisor
    4.         mov rax,x
    5.         add rax,x_A    ;x = x + x_A
    6.         add rax,x_A    ;x = x + x_A
    7.         div ecx        ;x = x/3
    8.         mov x,rax    ;Store x
    9.     ;y = (y + 2*y_A) / 3
    10.         xor rdx,rdx    ;Dividend
    11.         mov rcx,3    ;Divisor
    12.         mov rax,y
    13.         add rax,y_A    ;y = y + y_A
    14.         add rax,y_A    ;y = y + y_A
    15.         div ecx        ;y = y/3
    16.         mov y,rax    ;Store y
    [​IMG]
     

    Вложения:

    • Sieve.jpg
      Sieve.jpg
      Размер файла:
      141,2 КБ
      Просмотров:
      278
    • SierpinskiSieve.zip
      Размер файла:
      7,5 КБ
      Просмотров:
      37
    • Gasket.jpg
      Gasket.jpg
      Размер файла:
      375 КБ
      Просмотров:
      275
    • SierpinskiGasket.zip
      Размер файла:
      6,8 КБ
      Просмотров:
      37
    Mikl___ и TermoSINteZ нравится это.