The MASM Forum

64 bit assembler => Mikl__'s ml64 examples => Topic started by: Mikl__ on December 02, 2015, 08:27:27 PM

Title: Fractals
Post by: Mikl__ on December 02, 2015, 08:27:27 PM
asm-file
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
; a       b       c       d      e   f   p
; 0.1000  0.0000  0.0000  0.1600 0.0 0.0 0.01*10000= 100
; 0.8500  0.0000  0.0000  0.8500 0.0 1.6 0.85*10000=8500
;-0.1667 -0.2887  0.2887 -0.1667 0.0 1.6 0.07*10000= 700
;-0.1667  0.2887 -0.2887 -0.1667 0.0 1.6 0.07*10000= 700
mov XCC,rbx
mov YCC,rbx
mov i,60000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx, 100  ;p1
ja @f
movr a,0.1;a = 0.1
mov b,ebx; b = 0
        mov c,ebx; c = 0
movr d,0.16
mov f,ebx; f = 0
jmp fin
@@: cmp edx, 800  ;p1+p4=100+700=800
ja @f
movr a,-0.1667 
movr b, 0.2887
movr c,-0.2887
movr d,-0.1667
movr f, 1.6
jmp fin
@@: cmp edx,1500  ;p1+p4+p3=800+700=1500
ja @f
movr a,-0.1667
movr b,-0.2887 
movr c,0.2887
movr d,-0.1667
movr f,1.6
jmp fin
@@: movr a,0.8500 
mov b,ebx
mov c,ebx
movr d, 0.85
movr f, 1.60 ; f = 1.60
fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
fst NewX    ;NewX = a * XCC + b * YCC
fmul const40 ;st(0) = NewX * 40
fld c           ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY = c * XCC + d * YCC + f
fstp YCC     ;YCC = NewY
fadd const320;st(0) = NewX * 40 + cdXSize/2
fistp x       ;x = (int) (NewX*40+cdXSize/2)
mov ecx, x
cmp ecx,cdXSize
jae @f
fld1         ;st(0) = 1
fsub NewY    ;st(0) = 1 - NewY
fmul const40 ;st(0) = (1 - NewY)*40
fadd const365;st(0) = (1 - NewY)*40 + cdYSize - 35
fistp y       ; y = (int) ((1-NewY)*40+cdYSize-35)
cmp y,cdYSize
jae @f
imul eax,y,2560
add rax,pMainDIB
mov dword ptr [rax+rcx*4],0FF00h ;*(pMainDIB + (y<<9)+(y<<7)+x) = 0xFF00;
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Fir Tree Fractal',0
bi BITMAPINFO <<28h,640,-430,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
const40 dq 40.0
const320 dq 320.0
const365 dq 365.0
end
Title: Re: Fractals
Post by: Mikl__ on December 04, 2015, 02:19:47 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
; a     b     c   d    e     f    p
; 0.49 -0.01  0   0.62 0.25  0.02 0.316*10000=3160;
; 0.27 -0.52  0.4 0.36 0    -0.56 0.316*10000=3160;6320
; 0.18  0.73 -0.5 0.26 0.88 -0.08 0.316*10000=3160;9480
; 0.04  0.01 -0.5 0    0.52 -0.32 0.052*10000= 520
mov XCC,rbx
mov YCC,rbx
mov i,48000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,3160
jg @f
movr a,0.49
movr b,-0.01     
mov c,ebx
movr d,0.62
movr e,0.25 
movr f,0.02
jmp fin
@@: cmp edx,6320
jg @f
movr a,0.27
movr b,-0.52 
movr c,0.4
movr d,0.36     
mov e,ebx
movr f,-0.56
jmp fin
@@: cmp edx,9480
jg @f
movr a,0.18 
movr b,0.73
movr c,-0.5
movr d,0.26
movr e,0.88
movr f,-0.08
jmp fin
@@: movr a,0.04 
movr b,0.01
movr c,-0.5     
mov d,ebx
movr e,0.52
movr f,-0.32

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul const470;st(0) = NewX * 470
        fadd const82 ;st(0) = NewX * 470 + 82
fistp x       ;x = (int) (NewX * 470 + 82)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fchs            ;st(0)  = -NewY
fmul const470;st(0) = -NewY * 470
fadd const42;st(0)  = -NewY * 470 + 42
fistp y       ; y = (int) (-NewY * 470 + 42)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,y,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],0FF8000h ;*(pMainDIB + y*cdXSize*4 + x*4) = orange color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Maple Fractal',0
bi BITMAPINFO <<28h,640,-430,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
const470 dd 470.0
const82 dd 82.0
const42 dd 42.0
end
Title: Re: Fractals
Post by: jj2007 on December 04, 2015, 03:19:12 PM
Fantastic, thanks for sharing this :t
Title: Re: Fractals
Post by: Mikl__ on December 04, 2015, 05:22:07 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
; a     b      c     d    e       f    p
; 0.7  0.2 -0.2 0.7 0.0  0.0 0.5
; 0.0 -0.6  0.6 0.0 1.0 -0.6 0.5
mov XCC,rbx
mov YCC,rbx
mov i,60000
bucle:  call rand
mov ecx,1000
xor edx,edx
div ecx
cmp edx,499
jg @f
movr a,0.7 
movr b,0.2
movr c,-0.2
movr d,0.7
mov e,ebx
mov f,ebx
jmp fin
@@: mov a,ebx
movr b,-0.6 
movr c,0.6
mov d,ebx
movr e,1.0
movr f,-0.6
fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul const340;st(0) = NewX * 340
        fadd const120;st(0) = NewX * 340 + 120
fistp x       ;x = (int) (NewX * 470 + 120)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fchs            ;st(0)  = -NewY
fmul const340;st(0) = -NewY * 340
fadd const160;st(0)  = -NewY * 340 + 160
fistp y       ; y = (int) (-NewY * 340 + 160)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],0FFFFFFh ;*(pMainDIB + y*cdXSize*4 + x*4) = white color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_APPWORKSPACE ;hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp
.data
ClassName db 'Talon Fractal',0
bi BITMAPINFO <<28h,640,-430,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
const340 dd 340.0
const120 dd 120.0
const160 dd 160.0
end
Title: Re: Fractals
Post by: Mikl__ on December 04, 2015, 05:59:22 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
; a     b     c   d    e     f    p
; 0.45881 -0.22565  0.07268 0.60187 -0.00177  0.31948 0.31*10000=3100
; 0.34268  0.37561 -0.20337 0.54642 -0.02210  0.32976 0.20*10000=2000;5100
; 0.13582  0.50273 -0.31347 0.13846 -0.02004  0.21706 0.16*10000=1600;6700
; 0.25326 -0.48975  0.30798 0.34989 -0.00740  0.19810 0.23*10000=2300;9000
; 0.06641  0        0       0.47942 -0.01492 -0.02422 0.10*10000=1000;
mov XCC,rbx
mov YCC,rbx
mov i,45000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,3160
jg @f
cmp edx,3100
jg @f
movr a,0.45881
movr b,-0.22565 
movr c,0.07268
movr d,0.60187     
movr e,-0.00177   
movr f,0.31948
jmp fin
@@: cmp edx,5100
jg @f
movr a,0.34268 
movr b,0.37561
movr c,-0.20337
movr d,0.54642
movr e,-0.02210 
movr f,0.32976
jmp fin
@@: cmp edx,6700
jg @f
movr a,0.13582 
movr b,0.50273
movr c,-0.31347
movr d,0.13846
movr e,-0.02004 
movr f,0.21706
jmp fin
@@: cmp edx,9000
jg @f
movr a,0.25326
movr b,-0.48975 
movr c,0.30798
movr d,0.34989
movr e,-0.00740 
movr f,0.19810
jmp fin
@@: movr a,0.06641                 
mov b,ebx
mov c,ebx
movr d,0.47942
movr e,-0.01492
movr f,-0.02422

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul const470;st(0) = NewX * 470
        fadd const320 ;st(0) = NewX * 470 + 320
fistp x       ;x = (int) (NewX * 470 + 320)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fmul const470;st(0) = NewY * 470
fsubr const420;st(0)  = -NewY * 470 + 420
fistp y       ; y = (int) (-NewY * 470 + 420)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],0FF00h ;*(pMainDIB + y*cdXSize*4 + x*4) = orange color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Tree #5 Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
const470 dd 470.0
const320 dd 320.0
const420 dd 420.0
end
Title: Re: Fractals
Post by: Magnum on December 05, 2015, 09:12:52 AM
I got empty zips for for all the attachments. ??
Title: Re: Fractals
Post by: Mikl__ on December 05, 2015, 11:49:10 AM
Quote
I got empty zips for for all the attachments. ??
Hi, Magnum!
I checked again, attached files are in perfect order. There are attached files in Tree5x64.zip. The picture "Tree5.png" renamed in "Tree5.zip". Pay attention to the end of the file name is "x64" or is not (http://www.cyberforum.ru/images/smilies/smile3.gif)
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
;      a               b                c                d                e              f             p
; 0.358591 0.329160 -0.334007 0.580720 -5.889050 1.924278 0.361396*10000=3614
; 0.796218 0.136942  0.075187 0.719074  1.086998 0.408452 0.638604*10000=6386
mov rdi,pMainDIB
mov ecx,cdYSize*cdXSize
mov eax,0FFFFFFh
rep stosd

mov XCC,rbx
mov YCC,rbx
mov i,35000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,3160
jg @f
cmp edx,3614
jg @f
movr a,0.358591
movr b,0.329160
movr c,-0.334007
movr d,0.580720
movr e,-5.889050
movr f,1.924278
jmp fin
@@: movr a,0.796218
movr b,0.136942 
movr c,0.075187
movr d,0.719074 
movr e,1.086998
movr f,0.408452

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC  pop
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul const45;st(0) = NewX * 45
        fadd const312;st(0) = NewX * 45 + 312
fistp x       ;x = (int) (NewX * 45 + 312)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fmul const45 ;st(0) = NewY * 45
fsubr const410;st(0)  = -NewY * 45 + 410
fistp y       ; y = (int) (-NewY * 45 + 410)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],ebx ;*(pMainDIB + y*cdXSize*4 + x*4) = black color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Windy Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
const45 dd 45.0
const312 dd 312.0
const410 dd 410.0
end
Title: Re: Fractals
Post by: Magnum on December 05, 2015, 12:17:04 PM
Thanks
I though the xxx64 files were for 64 bit systems - I have a 32 bit system.

Just saw that the code is 64 bit. bummer :-)
Title: Re: Fractals
Post by: Mikl__ on December 05, 2015, 12:42:56 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
; a      b     c     d    e     f    p
; -0.92 -0.09  0.09 -0.92 0.00 0.00 0.1*10000=1000
;  0.79  0.26 -0.26  0.79 0.21 0.26 0.9*10000=9000
mov XCC,rbx
mov YCC,rbx
mov i,45000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,9000
jg @f
movr a,-0.92
movr b,-0.09 
movr c,0.09
movr d,-0.92
mov e,ebx
mov f,ebx
jmp fin
@@: movr a,0.79 
movr b,0.26
movr c,-0.26 
movr d,0.79
movr e,0.21
movr f,0.26

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul const300;st(0) = NewX * 300
        fadd const320 ;st(0) = NewX * 300 + 320
fistp x       ;x = (int) (NewX * 300 + 320)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fmul const300;st(0) = NewY * 300
fsubr const240;st(0)  = -NewY * 300 + 240
fistp y       ; y = (int) (-NewY * 300 + 240)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],0FFFFFFh ;*(pMainDIB + y*cdXSize*4 + x*4) = white color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Galaxy Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
const300 dd 300.0
const320 dd 320.0
const240 dd 240.0
end
Title: Re: Fractals
Post by: Mikl__ on December 05, 2015, 12:52:05 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
; a      b     c     d    e     f    p
; -0.92 -0.09  0.09 -0.92 0.00 0.00 0.1*10000=1000
;  0.79  0.26 -0.26  0.79 0.21 0.26 0.9*10000=9000
mov XCC,rbx
mov YCC,rbx
mov i,45000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,1000
jg @f
movr a,-0.92
movr b,-0.09 
movr c,0.09
movr d,-0.92
mov e,ebx
mov f,ebx
jmp fin
@@: movr a,0.79 
movr b,0.26
movr c,-0.26 
movr d,0.79
movr e,0.21
movr f,0.26

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul const150;st(0) = NewX * 150
        fadd const320 ;st(0) = NewX * 150 + 320
fistp x       ;x = (int) (NewX * 150 + 320)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fmul const150;st(0) = NewY * 150
fsubr const240;st(0)  = -NewY * 150 + 240
fistp y       ; y = (int) (-NewY * 150 + 240)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],0FFFFFFh ;*(pMainDIB + y*cdXSize*4 + x*4) = white color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Seashell Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
const150 dd 150.0
const320 dd 320.0
const240 dd 240.0
end
Title: Re: Fractals
Post by: Mikl__ on December 05, 2015, 01:14:54 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
;     a         b         c        d        e          f        p
; 0.860671  0.401487 -0.402177 0.860992  0.108537  0.075138 0.956972*10000=9570
; 0.094957 -0.000995  0.237023 0.002036 -0.746911  0.047343 0.009813*10000=  98
; 0.150288  0.000000  0.000000 0.146854 -0.563199  0.032007 0.023402*10000= 234
; 0.324279 -0.002163  0.005846 0.001348 -0.557936 -0.139735 0.009813*10000=  98

mov rdi,pMainDIB
mov ecx,cdYSize*cdXSize
mov eax,0FFFFFFh
rep stosd

mov XCC,rbx
mov YCC,rbx
mov i,200000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,9570
jg @f
movr a,0.860671 
movr b,0.401487
movr c,-0.402177
movr d,0.860992 
movr e,0.108537 
movr f,0.075138
jmp fin
@@: cmp edx,9570+98
jg @f
movr a,0.094957
movr b,-0.000995 
movr c,0.237023
movr d,0.002036
movr e,-0.746911 
movr f,0.047343
jmp fin
@@: cmp edx,9570+98+234
jg @f
movr a,0.150288 
mov b,ebx 
mov c,ebx
movr d,0.146854
movr e,-0.563199 
movr f,0.032007
jmp fin
@@: movr a,0.324279
movr b,-0.002163 
movr c,0.005846
movr d,0.001348
movr e,-0.557936
movr f,-0.139735

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul const250;st(0) = NewX * 250
        fadd const300 ;st(0) = NewX * 250 + 300
fistp x       ;x = (int) (NewX * 250 + 300)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fmul const250;st(0) = NewY * 250
fsubr const180;st(0)  = -NewY * 250 + 180
fistp y       ; y = (int) (-NewY * 250 + 180)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],ebx ;*(pMainDIB + y*cdXSize*4 + x*4) = black color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Nautilus Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
const250 dd 250.0
const300 dd 300.0
const180 dd 180.0
end
Title: Re: Fractals
Post by: Mikl__ on December 05, 2015, 07:47:17 PM
I wonder whether it is possible by fractal to paint  of a deck of cards, where on each card is King of spades with a deck of cards in his hand  on each card is King of spades with a deck of cards in his hand etc.?
Title: Re: Fractals
Post by: dedndave on December 05, 2015, 11:35:50 PM
fractal image compression looks like it might be kind of fun to play with  :P

https://karczmarczuk.users.greyc.fr/matrs/Dess/RADI/Refs/monroWake.pdf (https://karczmarczuk.users.greyc.fr/matrs/Dess/RADI/Refs/monroWake.pdf)

i haven't done anything with it, myself - but i find the idea interesting
Title: Re: Fractals
Post by: Siekmanski on December 06, 2015, 05:49:44 PM
Nice set of fractals.  8)

Why not copy the picture with a smaller resolution into the hands of kings of spades etc...
You could make an animated infinite zoomer that way.

Audio Fractals maybe fun too.
http://sessionville.com/articles/exploring-audio-fractals

Title: Re: Fractals
Post by: Mikl__ on December 07, 2015, 07:38:02 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
;  a         b         c         d        e        f        p
; -0.312500 -0.831731  0.812500 -0.283654 2.194113 6.130637 0.845745*10000=8457
;  0.125     0.317308 -0.187500  0.177885 1.075775 5.177031 0.090426*10000= 904
; -0.25      0.134615  0.187500  0.129808 3.498840 2.560557 0.063830*10000= 638

mov XCC,rbx
mov YCC,rbx
mov i,45000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,8457
jg @f
movr a,-0.312500
movr b,-0.831731 
movr c,0.812500
movr d,-0.283654
movr e,2.194113
movr f,6.130637
jmp fin
@@: cmp edx,8457+904
jg @f
movr a,0.125     
movr b,0.317308
movr c,-0.187500 
movr d,0.177885
movr e,1.075775
movr f,5.177031
jmp fin
@@: movr a,-0.25     
movr b,0.134615 
movr c,0.187500 
movr d,0.129808
movr e,3.498840
movr f,2.560557

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fimul Scale;st(0) = NewX * 34
        fiadd ShiftX ;st(0) = NewX * 34 + 320
fistp x       ;x = (int) (NewX * 34 + 320)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fimul Scale;st(0) = NewY * 300
fisubr ShiftY;st(0)  = -NewY * 34 + 350
fistp y       ; y = (int) (-NewY * 34 + 350)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],0FFFFFFh ;*(pMainDIB + y*cdXSize*4 + x*4) = white color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Sparkle Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
Scale dd 34
ShiftX dd 320
ShiftY dd 350
end
Title: Re: Fractals
Post by: Mikl__ on December 07, 2015, 07:47:23 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
;  a     b   c    d     e    f   p
; 0.5   0.5  0    0     0   0.5 0.08*10000=800
; 0.5   0.5  0    0     0  -0.5 0.08*10000=800
; 0     0    0.5  0.5   0.5 0   0.08*10000=800
; 0     0    0.5  0.5  -0.5 0   0.08*10000=800
; 0.85 -0.15 0.15 0.85  0   0   0.68*10000=6800

mov XCC,rbx
mov YCC,rbx
mov i,390000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,800
jg @f
movr a,0.5   
movr b,0.5 
mov c,ebx
mov d,ebx
mov e,ebx
movr f,0.5
jmp fin
@@: cmp edx,1600
jg @f
movr a,0.5   
movr b,0.5 
mov c,ebx
mov d,ebx
mov e,ebx
movr f,-0.5
jmp fin
@@: cmp edx,2400
jg @f
mov a,ebx   
mov b,ebx 
movr c,0.5
movr d,0.5
movr e,0.5
mov f,ebx
jmp fin
@@: cmp edx,3200
jg @f
mov a,ebx   
mov b,ebx 
movr c,0.5
movr d,0.5
movr e,-0.5
mov f,ebx
jmp fin
@@: movr a,0.85
movr b,-0.15
movr c,0.15
movr d,0.85 
mov e,ebx
mov f,ebx

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fimul Scale;st(0) = NewX * 360
        fiadd ShiftX ;st(0) = NewX * 360 + 320
fistp x       ;x = (int) (NewX * 360 + 320)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fimul Scale;st(0) = NewY * 300
fisubr ShiftY;st(0)  = -NewY * 360 + 185
fistp y       ; y = (int) (-NewY * 360 + 185)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],0FFFFFFh ;*(pMainDIB + y*cdXSize*4 + x*4) = white color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Stairway Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
Scale dd 360
ShiftX dd 320
ShiftY dd 185
end
Title: Re: Fractals
Post by: Mikl__ on December 07, 2015, 08:02:49 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
;    a         b         c        d         e        f       p
; 0.424242 -0.651515 -0.484848 -0.344697  3.442830 2.889184 0.622449*10000=6225
; 0.030303 -0.439394 -0.636364 -0.022727 -1.425239 6.437284 0.377551*10000=3775

mov XCC,rbx
mov YCC,rbx
mov rdi,pMainDIB
mov ecx,cdYSize*cdXSize
mov eax,0FFFFFFh
rep stosd

mov i,45000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,6225
jg @f
movr a,0.424242
movr b,-0.651515
movr c,-0.484848
movr d,-0.344697 
movr e,3.442830
movr f,2.889184
jmp fin
@@: movr a,0.030303
movr b,-0.439394
movr c,-0.636364
movr d,-0.022727
movr e,-1.425239
movr f,6.437284

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul Scale ;st(0) = NewX * 40
        fadd ShiftX ;st(0) = NewX * 40 + 320
fistp x       ;x = (int) (NewX * 40 + 320)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fmul Scale;st(0) = NewY * 300
fsubr ShiftY;st(0)  = -NewY * 40 + 400
fistp y       ; y = (int) (-NewY * 40 + 400)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],ebx ;*(pMainDIB + y*cdXSize*4 + x*4) = black color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Twigs Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
Scale dd 40.0
ShiftX dd 320.0
ShiftY dd 400.0
end
Title: Re: Fractals
Post by: Mikl__ on December 07, 2015, 08:13:13 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
;a     b     c    d    e f   p
;0     0     0    0.50 0 0   0.05         500
;0.42 -0.42  0.42 0.42 0 0.2 0.4         4000
;0.42  0.42 -0.42 0.42 0 0.2 0.4         4000
;0.1   0     0    0.1  0 0.2 0.15*10000= 1500

mov XCC,rbx
mov YCC,rbx

mov i,150000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,500
jg @f
mov a,ebx
mov b,ebx 
mov c,ebx; c = 0
movr d,0.5
mov f,ebx
jmp fin
@@: cmp edx,4500
jg @f
movr a,0.42
movr b,-0.42 
movr c,0.42
movr d,0.42 
movr f,0.2     
jmp fin
@@: cmp edx,8500
jg @f
movr a,0.42 
movr b,0.42
movr c,-0.42
movr d,0.42
movr f,0.2
jmp fin
@@: movr a,0.1   
mov b,ebx
mov c,ebx     
movr d,0.1 
movr f,0.2

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
fst NewX    ;NewX  = a * XCC + b * YCC
fmul Scale ;st(0) = NewX * 900
        fadd ShiftX ;st(0) = NewX * 900 + 320
fistp x       ;x = (int) (NewX * 900 + 320)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fmul Scale;st(0) = NewY * 900
fsubr ShiftY;st(0)  = -NewY * 900 + 405
fistp y       ; y = (int) (-NewY * 900 + 405)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],0FF00h ;*(pMainDIB + y*cdXSize*4 + x*4) = black color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Tree #1 Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
Scale dd 900.0
ShiftX dd 320.0
ShiftY dd 405.0
end
Title: Re: Fractals
Post by: Mikl__ on December 07, 2015, 08:32:33 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
; a      b      c      d     e      f      p
; 0.195 -0.488  0.344  0.443 0.4431 0.2452 0.25*10000=2500
; 0.462  0.414 -0.252  0.361 0.2511 0.5692 0.25*10000=2500;5000
;-0.058 -0.07   0.423 -0.111 0.5976 0.0969 0.15*10000=1500;6500
;-0.035  0.07  -0.469  0.022 0.4884 0.5069 0.15*10000=1500;8000
;-0.637  0      0      0.501 0.8562 0.2513 0.2 *10000=2000

mov XCC,rbx
mov YCC,rbx

mov i,150000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,2500
jg @f
movr a,0.195
movr b,-0.488 
movr c,0.344 
movr d,0.443
movr e,0.4431
movr f,0.2452
mov edx,0FF00h
jmp fin
@@: cmp edx,5000
jg @f
movr a,0.462 
movr b,0.414
movr c,-0.252 
movr d,0.361
movr e,0.2511
movr f,0.5692
mov edx,0C900h
jmp fin
@@: cmp edx,6500
jg @f
movr a,-0.058
movr b,-0.07   
movr c,0.423
movr d,-0.111
movr e,0.5976
movr f,0.0969
mov edx,804000h
jmp fin
@@: cmp edx,8000
jg @f
movr a,-0.035 
movr b,0.07 
movr c,-0.469 
movr d,0.022
movr e,0.4884
movr f,0.5069
mov edx,804000h
jmp fin
@@: movr a,-0.637       
mov b,ebx
mov c,ebx     
movr d,0.501
movr e,0.8562
movr f,0.2513
mov edx,0A600h
fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul Scale ;st(0) = NewX * 450
        fadd ShiftX ;st(0) = NewX * 450 + 100
fistp x       ;x = (int) (NewX * 450 + 100)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fmul Scale;st(0) = NewY * 300
fsubr ShiftY;st(0)  = -NewY * 450 + 405
fistp y       ; y = (int) (-NewY * 450 + 405)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],edx ;*(pMainDIB + y*cdXSize*4 + x*4) = black color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Tree #2 Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
Scale dd 450.0
ShiftX dd 100.0
ShiftY dd 405.0
end
Title: Re: Fractals
Post by: Mikl__ on December 07, 2015, 09:30:24 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
; a        b        c        d        e       f       p
; 0.28421 -0.35644  0.32632  0.44555  0.00625 0.56275 0.166*10000=1660
; 0.37895  0.38614 -0.27368  0.34653 -0.08171 0.54063 0.166*10000=1660;3320
; 0.41053  0        0        0.55446 -0.02832 0.53347 0.166*10000=1660;4980
;-0.62105  0        0        0.43564 -0.09537 0.35772 0.166*10000=1660;6640
;-0.03158 -0.07921  0.55790 -0.08911 -0.00755 0.51196 0.166*10000=1660;8300
;-0.08421  0.08911 -0.55790 -0.05941 -0.17617 0.40587 0.166*10000=1660

mov XCC,rbx
mov YCC,rbx

mov i,150000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,1660
jg @f
movr a,0.28421
movr b,-0.35644 
movr c,0.32632 
movr d,0.44555 
movr e,0.00625
movr f,0.56275
mov edx,0C900h
jmp fin
@@: cmp edx,3320
jg @f
movr a,0.37895 
movr b,0.38614
movr c,-0.27368 
movr d,0.34653
movr e,-0.08171
movr f,0.54063
mov edx,0FF00h
jmp fin
@@: cmp edx,4980
jg @f
movr a,0.41053                 
mov b,ebx   
mov c,ebx
movr d,0.55446
movr e,-0.02832
movr f,0.53347
mov edx,80FF80h
jmp fin
@@: cmp edx,6640
jg @f
movr a,-0.62105                 
mov b,ebx
mov c,ebx
movr d,0.43564
movr e,-0.09537
movr f,0.35772
mov edx,0A7FF00h
jmp fin
@@: cmp edx,8300
jg @f
movr a,-0.03158
movr b,-0.07921 
movr c,0.55790
movr d,-0.08911
movr e,-0.00755
movr f,0.51196
mov edx,808000h
jmp fin
@@: movr a,-0.08421 
movr b,0.08911
movr c,-0.55790
movr d,-0.05941
movr e,-0.17617
movr f,0.40587
mov edx,804000h
fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul Scale ;st(0) = NewX * 340
        fadd ShiftX ;st(0) = NewX * 340 + 320
fistp x       ;x = (int) (NewX * 340 + 320)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fmul Scale;st(0) = NewY * 340
fsubr ShiftY;st(0)  = -NewY * 340 + 405
fistp y       ; y = (int) (-NewY * 340 + 405)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],edx ;*(pMainDIB + y*cdXSize*4 + x*4) = black color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Tree #3 Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
Scale dd 340.0
ShiftX dd 320.0
ShiftY dd 405.0
end
Title: Re: Fractals
Post by: Mikl__ on December 08, 2015, 12:27:50 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
; a     b     c     d     e     f    p
; 0.05  0     0     0.4  -0.06 -0.47 0.0260*10000= 260
;-0.05  0     0    -0.4  -0.06 -0.47 0.0264*10000= 264; 524
; 0.03 -0.14  0     0.26 -0.16 -0.01 0.0103*10000= 103; 627
;-0.03  0.14  0    -0.26 -0.16 -0.01 0.0103*10000= 103; 730
; 0.56  0.44 -0.37  0.51  0.3   0.15 0.5919*10000=5919;6649
; 0.19  0.07 -0.01  0.15 -0.2   0.28 0.0385*10000= 385;7034
;-0.33 -0.34 -0.33  0.34 -0.54  0.39 0.2962*10000=2962

mov XCC,rbx
mov YCC,rbx

mov i,150000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,260
jg @f
movr a,0.05           
mov b,ebx 
mov c,ebx
movr d,0.4 
movr e,-0.06
movr f,-0.47
mov edx,0FF8000h
jmp fin
@@: cmp edx,524
jg @f
movr a,-0.05           
mov b,ebx
mov c,ebx
movr d,-0.4 
movr e,-0.06
movr f,-0.47
mov edx,804000h
jmp fin
@@: cmp edx,627
jg @f
movr a,0.03
movr b,-0.14       
mov c,ebx
movr d,0.26
movr e,-0.16
movr f,-0.01
mov edx,0FF00h
jmp fin
@@: cmp edx,730
jg @f
movr a,-0.03 
movr b,0.14     
mov c,ebx
movr d,-0.26
movr e,-0.16
movr f,-0.01
mov edx,0FF8000h
jmp fin
@@: cmp edx,6649
jg @f
movr a,0.56 
movr b,0.44
movr c,-0.37 
movr d,0.51 
movr e,0.3   
movr f,0.15
mov edx,0A7FF00h
jmp fin
@@: cmp edx,7034
jg @f
movr a,0.19 
movr b,0.07
movr c,-0.01 
movr d,0.15
movr e,-0.2   
movr f,0.28
mov edx,0FF0000h
jmp fin
@@: movr a,-0.33
movr b,-0.34
movr c,-0.33 
movr d,0.34
movr e,-0.54 
movr f,0.39
mov edx,0A600h
fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul Scale ;st(0) = NewX * 226
        fadd ShiftX ;st(0) = NewX * 226 + 320
fistp x       ;x = (int) (NewX * 340 + 320)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fmul Scale;st(0) = NewY * 226
fsubr ShiftY;st(0)  = -NewY * 226 + 205
fistp y       ; y = (int) (-NewY * 226 + 205)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],edx ;*(pMainDIB + y*cdXSize*4 + x*4) = black color
@@: fld NewX  ;XCC = NewX
fstp XCC
        fld NewY  ;YCC = NewY
fstp YCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Tree #4 Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
Scale dd 226.0
ShiftX dd 320.0
ShiftY dd 205.0
end
Title: Re: Fractals
Post by: Mikl__ on December 08, 2015, 12:34:20 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
;0.935567 -0.164966 0.164966 0.935567  0     0    0.958*10000=9580
;0.1       0        0        0.1       0.75 -0.75 0.011*10000= 110
;0.1       0        0        0.1      -0.75  0.75 0.011*10000= 110
;0.1       0        0        0.1       0.75  0.75 0.011*10000= 110
;0.1       0        0        0.1      -0.75 -0.75 0.009*10000=  90

mov XCC,rbx
mov YCC,rbx

mov i,390000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,90
jg @f
movr a,0.1                       
mov b,ebx 
mov c,ebx
movr d,0.1     
movr e,-0.75
movr f,-0.75
jmp fin
@@: cmp edx,200
jg @f
movr a,0.1                       
mov b,ebx 
mov c,ebx
movr d,0.1       
movr e,0.75 
movr f,0.75
jmp fin
@@: cmp edx,310
jg @f
movr a,0.1                       
mov b,ebx 
mov c,ebx
movr d,0.1     
movr e,-0.75 
movr f,0.75
jmp fin
@@: cmp edx,420
jg @f
movr a,0.1                       
mov b,ebx 
mov c,ebx
movr d,0.1       
movr e,0.75
movr f,-0.75
jmp fin
@@: movr a,0.935567
movr b,-0.164966
movr c,0.164966
movr d,0.935567       
mov e,ebx
mov f,ebx

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul Scale ;st(0) = NewX * 190
        fadd ShiftX ;st(0) = NewX * 190 + 320
fistp x       ;x = (int) (NewX * 190 + 320)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fmul Scale;st(0) = NewY * 190
fsubr ShiftY;st(0)  = -NewY * 190 + 185
fistp y       ; y = (int) (-NewY * 190 + 185)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],0FFFFFFh; white color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Spiral Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
Scale dd 190.0
ShiftX dd 320.0
ShiftY dd 185.0
end
Title: Re: Fractals
Post by: caballero on December 09, 2015, 09:41:24 PM
How many fractals  :P. My swirls look like this
Title: Re: Fractals
Post by: Magnum on December 10, 2015, 04:03:06 PM
I have some 16 bit code for fractals.

Could you post some 32 bit fractal code ?

Linux folks said it could not be done. :-)

Just kidding.

Title: Re: Fractals
Post by: Mikl__ on December 10, 2015, 04:59:37 PM
Quote from: Magnum
I have some 16 bit code for fractals.
Hi, Magnum!
let's show the text of the 16-bit programs, I think that it will not be very difficult to translate into a 32/64-bit programs (http://www.cyberforum.ru/images/smilies/smile3.gif)
Title: Re: Fractals
Post by: Magnum on December 10, 2015, 05:23:43 PM
Quote from: Magnum
I have some 16 bit code for fractals.
Hi, Magnum!
let's show the text of the 16-bit programs, I think that it will not be very difficult to translate into a 32/64-bit programs (http://www.cyberforum.ru/images/smilies/smile3.gif)

Thanks Mikl.

I am a little old at 60 years old.

;*****************************************************************************
;*
;*  ASMANDEL by (c) Taslehof / Null Pointer Assignment 1995   v1.0
;*
;*   This code is freeware. Only one thing: if you use it please remember me.
;*   ASMANDEL is the Mandelbrot's fractal in assembler, I use the iterated
;*   mode,the default number is 150 iterations
;*   The metod I used: we have the left upper corner point, and the size of
;*   the side. This is the zone will be zoom up to the screen's resolution.

.MODEL TINY
.DATA

;Datos    LABEL    BYTE

         MandelX  DD   -2.50           ;left y point of mandel
         Mandely  DD   -1.50           ;left x point of mandel
         Resx     =     320            ;resolution X
         Resy     =     200            ;resolution y
         Lado     DW    5              ;size of
         Iteration DW   200            ;number of iterations
         A        DD    0.0            ;general var
         B        DD    0.0
         X        DD    0.0
         Y        DD    0.0
         Xaux     DD    0.0
         Yaux     DD    0.0
         VGA      =     0A000h         ;my VGA and you
         ESCALA   DD    0.015625       ;scale= lado /resx
         KK       DD    ?              ;kk???
         Color    DB    ?
         Estado   DW    ?
         DOS      DD    2
         Caracter DB    0,0,0,0,0,255,255,255,255,255,255,0,0,0,0,0
         TEXTO    DB    ' (c) TASLEHOF / Null Pointer Assignment 1995',10,13
                  DB    '        Saludos a la gente de la U.G.R Informatica',10,13
                  DB    '        If you have some request or some comment my email address:',10,13
                  DB    '                       jagarcia@verne.ugr.es                    ',10,13
                  DB    '$'

;-----------------------------------------------------------------------------
;Fichero creado  en MK_PAN .
;(c) Taslehof.
Paleta LABEL BYTE
   DB 0,0,0, 0,0,6, 0,0,6, 0,0,7, 0,0,8, 0,0,8, 0,0,9, 0,0,10, 2,0,10
   DB 4,0,9, 6,0,9, 8,0,8, 10,0,7, 12,0,7, 14,0,6, 16,0,5, 18,0,5
   DB 20,0,4, 22,0,4, 24,0,3, 26,0,2, 28,0,2, 30,0,1, 32,0,0, 32,0,0
   DB 33,0,0, 34,0,0, 35,0,0, 36,0,0, 36,0,0, 37,0,0, 38,0,0, 39,0,0
   DB 40,0,0, 40,0,0, 41,0,0, 42,0,0, 43,0,0, 44,0,0, 45,0,0, 46,1,0
   DB 47,1,0, 48,2,0, 49,2,0, 50,3,0, 51,3,0, 52,4,0, 53,4,0, 54,5,0
   DB 55,5,0, 56,6,0, 57,6,0, 58,7,0, 59,7,0, 60,8,0, 61,8,0, 63,9,0
   DB 63,9,0, 63,10,0, 63,10,0, 63,11,0, 63,11,0, 63,12,0, 63,12,0, 63,13,0
   DB 63,13,0, 63,14,0, 63,14,0, 63,15,0, 63,15,0, 63,16,0, 63,16,0, 63,17,0
   DB 63,17,0, 63,18,0, 63,18,0, 63,19,0, 63,19,0, 63,20,0, 63,20,0, 63,21,0
   DB 63,21,0, 63,22,0, 63,22,0, 63,23,0, 63,24,0, 63,24,0, 63,25,0, 63,25,0
   DB 63,26,0, 63,26,0, 63,27,0, 63,27,0, 63,28,0, 63,28,0, 63,29,0, 63,29,0
   DB 63,30,0, 63,30,0, 63,31,0, 63,31,0, 63,32,0, 63,32,0, 63,33,0, 63,33,0
   DB 63,34,0, 63,34,0, 63,35,0, 63,35,0, 63,36,0, 63,36,0, 63,37,0, 63,38,0
   DB 63,38,0, 63,39,0, 63,39,0, 63,40,0, 63,40,0, 63,41,0, 63,41,0, 63,42,0
   DB 63,42,0, 63,43,0, 63,43,0, 63,44,0, 63,44,0, 63,45,0, 63,45,0, 63,46,0
   DB 63,46,0, 63,47,0, 63,47,0, 63,48,0, 63,48,0, 63,49,0, 63,49,0, 63,50,0
   DB 63,50,0, 63,51,0, 63,52,0, 63,52,0, 63,52,0, 63,52,0, 63,52,0, 63,53,0
   DB 63,53,0, 63,53,0, 63,53,0, 63,54,0, 63,54,0, 63,54,0, 63,54,0, 63,54,0
   DB 63,55,0, 63,55,0, 63,55,0, 63,55,0, 63,56,0, 63,56,0, 63,56,0, 63,56,0
   DB 63,57,0, 63,57,0, 63,57,0, 63,57,0, 63,57,0, 63,58,0, 63,58,0, 63,58,0
   DB 63,58,0, 63,59,0, 63,59,0, 63,59,0, 63,59,0, 63,60,0, 63,60,0, 63,60,0
   DB 63,60,0, 63,60,0, 63,61,0, 63,61,0, 63,61,0, 63,61,0, 63,62,0, 63,62,0
   DB 63,62,0, 63,62,0, 63,63,0, 63,63,1, 63,63,2, 63,63,3, 63,63,4, 63,63,5
   DB 63,63,6, 63,63,7, 63,63,8, 63,63,9, 63,63,10, 63,63,10, 63,63,11, 63,63,12
   DB 63,63,13, 63,63,14, 63,63,15, 63,63,16, 63,63,17, 63,63,18, 63,63,19, 63,63,20
   DB 63,63,21, 63,63,21, 63,63,22, 63,63,23, 63,63,24, 63,63,25, 63,63,26, 63,63,27
   DB 63,63,28, 63,63,29, 63,63,30, 63,63,31, 63,63,31, 63,63,32, 63,63,33, 63,63,34
   DB 63,63,35, 63,63,36, 63,63,37, 63,63,38, 63,63,39, 63,63,40, 63,63,41, 63,63,42
   DB 63,63,42, 63,63,43, 63,63,44, 63,63,45, 63,63,46, 63,63,47, 63,63,48, 63,63,49
   DB 63,63,50, 63,63,51, 63,63,52, 63,63,52, 63,63,53, 63,63,54, 63,63,55, 63,63,56
   DB 63,63,57, 63,63,58, 63,63,59, 63,63,60, 63,63,61, 63,63,62, 0,0,0

.CODE
ORG 100H

Main:
         MOV     AX,VGA                ;es = vga
         MOV     ES,AX                 ;lets go to 13h
         MOV     AX,13h
         INT     10h
         CALL    PAL

         MOV     CX,319                ;For x=0 to 320 do begin
Loopx:   MOV     SI,CX                 ;si=cx to acces it easier.
         MOV     WORD PTR KK,CX
         MOV     WORD PTR KK+2,0
         FINIT                         ;
         FILD    KK                    ;A=x*escala+mandelx, this is necesari for calculate
         FMUL    Escala                ;the color of point (si,di)
         FADD    Mandelx               ;
         FSTP    A                     ;is necesari for whatcolor
                                       ;the parameters is pases by memori

         PUSH    CX                    ;
                                       ;loop whith the y
         MOV     CX,199
Loopy:   MOV     DI,CX                 ;
         MOV     WORD PTR KK,CX        ;B=y*escala+mandely
         MOV     WORD PTR KK+2,0
         FINIT
         FILD    KK
         FMUL    Escala
         FADD    MandelY
         FSTP    B                     ;

         CALL    WHATCOLOR             ;this calculate the color whith A ,B
         WAIT

         MOV     AX,DI                 ;Draw the color  the pos (si,di):=color
         MOV     BX,AX
         SHL     AX,8
         SHL     BX,6
         ADD     BX,AX
         ADD     BX,SI
         MOV     Al,BYTE PTR Color
         MOV     ES:[BX],Al            ;

         LOOP    Loopy
         POP     CX
         LOOP    Loopx                 ;end of a line

 ReadK:  MOV     AH,1
         INT     16h
         JZ      ReadK
         MOV     AX,03h                ;go to test mode
         INT     10h
         CALL    THEEND
         MOV     AX,4C00h
         INT     21h

WHATCOLOR        PROC
                  PUSH    CX           ;keep register in use
                  PUSH    DI
                  PUSH    SI
                  FINIT
                  FLD     X            ;PUSH ,ST=X
                  FSUB    X            ;ST=X-X
                  FSTP    X            ;X=X-X=0 , POP
                  FLD     Y            ;PUSH , ST=Y
                  FSUB    Y            ;ST = ST-Y
                  FSTP    Y            ;Y=ST=0  , POP
                  MOV     CX,iteration ;iterations

                                       ;keep the registers
          @bucle: PUSH    ES
                  PUSH    CX
                  MOV     AX,DS        ;ES=DS
                  MOV     ES,AX
                                       ;lets to copy xaux=x
                  MOV     CX,4
                  MOV     SI,OFFSET X
                  MOV     DI,OFFSET Xaux
                  REP     MOVSB
                                       ;same yaux=y
                  MOV     CX,4
                  MOV     SI,OFFSET Y
                  MOV     DI,OFFSET Yaux
                  REP     MOVSB

                  POP     CX           ;well
                  POP     ES           ;

                  FINIT
                  FLD     Xaux         ;st = xaux
                  FMUL    Xaux         ;st = st* Xaux
                  FLD     Yaux         ;push st ,st(1)=xaux^2 , st=yaux
                  FMUL    Yaux         ;st = yaux^2
                  FSUBR   ST,ST(1)     ;st = st-st(1) +- st =xaux^2-yaux^2
                  FADD    A            ;st = st+ a
                  FSTP    X            ;X  = xaux^2 + yaux^2 + a ,pop
                  FFREE   ST(0)        ;set st=0

                  FLD     Xaux         ;st = xaux
                  FMUL    Yaux         ;st = xaux * yaux
                  FIMUL   DOS          ;st = xaux * yaux *2
                  FADD    B            ;st = xaux * yaux *2 +b
                  FSTP    Y            ;y  = st

                  FLD     X            ;st = x
                  FMUL    X            ;st = st* x
                  FSTP    KK           ;KK = x^2
                  FLD     Y            ;st = y ,st(1)= x^2
                  FMUL    Y            ;st = st * y = y^2
                  FADD    kk           ;st = x^2+y^2
                  FSQRT                ;st = st^1/2

                  FICOM   DOS          ;st = st-2
                  FSTSW   ESTADO       ;estado = word of state of the copro
                  FWAIT                ; no comment
                  MOV     AH,BYTE PTR ESTADO+1
                  SAHF                 ;set flag

                  JA      @FIN         ;

                  DEC     CX
                  CMP     CX,0
                  JE      @FIN         ;this jump is so far
                  JMP     @BUCLE       ;lets use JMP
            @FIN:
                  CMP     CX,0         ;and calc the color with the number of iterations
                  JNE     NOFINITO
                  MOV     BYTE PTR COLOR,254
                  JMP     EXIT
        NOFINITO:
                  ADD     CX,40
                  MOV     BYTE PTR COLOR,CL    ;!!!!! CH !!!!!!! ja

        EXIT:     POP     SI
                  POP     DI
                  POP     CX
                  RET

                ENDP

PAL       PROC
           mov  cx,255
           mov  bx,offset paleta
      @@1: mov  dx,3C8h
           mov  al,cl
           out  dx,al
           inc  dx
           mov  al,[bx]
           out  dx,al
           mov  al,[bx+1]
           out  dx,al
           mov  al,[bx+2]
           out  dx,al
           add  bx,3
           loop @@1
           ret
          endp

THEEND     PROC
            MOV     AX,CS
            MOV     ES,AX
            MOV     BP,OFFSET (caracter)    ;lets change the 219 for my flag char
            MOV     AX,1100h
            MOV     BH,16
            MOV     BL,0
            MOV     CX,1
            MOV     DX,219
            INT     10h
            MOV     AH,09h                  ;Write 3 char #219
            MOV     AL,219
            MOV     BH,0
            MOV     BL,78
            MOV     CX,3
            INT     10h
                                            ;¨what is the cursor position?
            MOV     AH,03h
            MOV     BX,0                    ;RETURN DH=column ,DL=row
            INT     10h

            ADD     DL,3                    ;
            MOV     AH,02h
            MOV     BH,0                    ; set the cursor in 3 pos right
            INT     10h

            MOV     DX,OFFSET Texto         ; set credits
            MOV     AH,9
            INT     21h
            RET
           ENDP

         END     Main


Title: Re: Fractals
Post by: caballero on December 10, 2015, 10:42:49 PM
This is basically the same as the program that Mikl__ has kindly ripped it out for you here (http://masm32.com/board/index.php?topic=4585.msg52343#msg52343)

Do you have any other new interesting fractal example?  :bgrin:

By the way, the code is from a guy from UGR (University of Granada, Spain, where original Sierra Nevada is :P), saludos por ahí. Some years ago I read a tuto from "legión", also from UGR, and he talked about an interesting subject: core wars (https://en.wikipedia.org/wiki/Core_War)  (Saludos, legión  ;)). It consists in a tournament on making a program that prevaleced over any other. Just came to my mind this subject when reading UGR.
Title: Re: Fractals
Post by: Mikl__ on December 17, 2015, 04:56:15 PM
Code: [Select]
include win64a.inc
include msvcrt.inc
includelib gdi32.lib
includelib msvcrt.lib
IMAGE_BASE equ 400000h
cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 430
cdXSize         equ 640

movr macro x,y
mov x,0
org $-4
dd y
endm

.code


WndProc proc hWnd:QWORD,Msg:QWORD,wParam:QWORD,lParam:QWORD

local ps:PAINTSTRUCT
local hdc:qword
local hOldBmp:qword
local hGDITmp:qword
local hOldDIB:qword
local hBackDC:qword
local hMainDIB:qword
local bufBMP:qword
local i:dword
local x:dword
local y:dword
local a:dword
local b:dword
local c:dword
local d:dword
local e:dword
local f:dword
local NewX:qword
local NewY:qword
local XCC:qword
local YCC:qword

push rbp
mov ebp, esp
sub esp,(50h+sizeof PAINTSTRUCT+11*8+9*4+15)and(-16)

mov hWnd,rcx
cmp edx, WM_DESTROY
jz wmDESTROY
        cmp edx, WM_PAINT
jz wmPAINT
        cmp edx, WM_CREATE
jz wmCREATE
leave
        jmp DefWindowProc
; ---------------------------------------------------------------------------
wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov hGDITmp,rax
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess
; ---------------------------------------------------------------------------
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint
jmp wmBYE
; ---------------------------------------------------------------------------
wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
        mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax

mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context         
;Init--------------------------------------------------------
;  a     b     c     d     e     f    p
;-0.04  0.0   0.23 -0.65 -0.08  0.26 0.25*10000=2500
; 0.61  0.0   0.0   0.31  0.07  2.5  0.25*10000=2500; 5000
; 0.65  0.29 -0.3   0.48  0.54  0.39 0.25*10000=2500; 7500
; 0.64 -0.3   0.16  0.56 -0.56  0.40 0.25*10000=2500;10000
mov XCC,rbx
mov YCC,rbx
mov i,45000
bucle:  call rand
mov ecx,10000
xor edx,edx
div ecx
cmp edx,2500
jg @f
movr a,-0.04     
mov b,ebx
movr c,0.23
movr d,-0.65
movr e,-0.08 
movr f,0.26
jmp fin
@@: cmp edx,5000
jg @f
movr a,0.61 
mov b,ebx
mov c,ebx
movr d,0.31 
movr e,0.07 
movr f,2.5
jmp fin
@@: cmp edx,7500
ja @f
movr a,0.65 
movr b,0.29
movr c,-0.3   
movr d,0.48 
movr e,0.54 
movr f,0.39
jmp fin
@@: movr a,0.64
movr b,-0.3   
movr c,0.16 
movr d,0.56
movr e,-0.56 
movr f,0.40

fin: fld a       ;st(0) = a
fmul XCC     ;st(0) = a * XCC
fld b       ;st(0) = b
fmul YCC     ;st(0) = b * YCC
faddp         ;st(0) = a * XCC + b * YCC
        fadd e       ;st(0) = a * XCC + b * YCC + e
fst NewX    ;NewX  = a * XCC + b * YCC + e
fmul Scale;st(0) = NewX * 57
        fadd ShiftX ;st(0) = NewX * 470 + 320
fistp x       ;x = (int) (NewX * 470 + 320)
        mov eax,x
cmp eax,cdXSize
jae @f
fld c       ;st(0) = c
fmul XCC     ;st(0) = c * XCC
fld d       ;st(0) = d
fmul YCC     ;st(0) = d * YCC
faddp         ;st(0) = c * XCC + d * YCC
fadd f       ;st(0) = c * XCC + d * YCC + f
fst NewY    ;NewY  = c * XCC + d * YCC + f
fst YCC     ;YCC = NewY
fmul Scale;st(0) = NewY * 57
fsubr ShiftY;st(0)  = -NewY * 57 + 220
fistp y       ; y = (int) (-NewY * 57 + 220)
mov ecx, y
cmp ecx,cdYSize
jae @f
imul ecx,cdXSize*4
add rcx,pMainDIB
mov dword ptr [rcx+rax*4],0FFFFFFh ;*(pMainDIB + y*cdXSize*4 + x*4) = white color
@@: fld NewX  ;XCC = NewX
fstp XCC
dec i
jnz  bucle
wmBYE: leave
retn
WndProc endp

WinMain proc
local msg:MSG

push rbp
mov ebp,esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp

.data
ClassName db 'Tree #6 Fractal',0
bi BITMAPINFO <<28h,cdXSize,-cdXSize,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
Scale dd 57.0
ShiftX dd 320.0
ShiftY dd 220.0
end
Title: Re: Fractals
Post by: caballero on December 17, 2015, 09:32:40 PM
How can I attach an image in a zip file to achieve a preview of it?
Title: Re: Fractals
Post by: Mikl__ on December 17, 2015, 11:37:24 PM
¡Hola, Alfonso!
Tu debe cambiar el nombre del file por ejemplo image.bmp o image.gif en image.zip
Title: Re: Fractals
Post by: caballero on December 18, 2015, 12:04:10 AM
Vamos a ver... Pues no, me parece que no funciona. Gracias de todas formas Mikl__
Title: Re: Fractals
Post by: dedndave on December 18, 2015, 01:24:14 AM
do not ZIP the image
just rename it with .ZIP extension   :P
Title: Re: Fractals
Post by: caballero on December 18, 2015, 01:34:30 AM
Ah That's the manager's contribution :P. Thanks, Dave.
Title: Re: Fractals
Post by: caballero on December 18, 2015, 01:36:30 AM
And a Sierpinski 64 bit resizable
Title: Re: Fractals
Post by: Mikl__ on December 18, 2015, 04:48:20 PM
dedndave, avcaballero,
There is a lot of beautiful pictures in the Internet. But is it possible to see the source code, or even exe-files that create the Cave of Neptune, Galaxians or Swirls...? I showed both
Title: Re: Fractals
Post by: mabdelouahab on December 18, 2015, 06:07:36 PM
dedndave, avcaballero,
There is a lot of beautiful pictures in the Internet. But is it possible to see the source code, or even exe-files that create the Cave of Neptune, Galaxians or Swirls...? I showed both
There are a lot of them : http://www.fractalforums.com/programming (http://www.fractalforums.com/programming); At least we get the equation
Title: Re: Fractals
Post by: Mikl__ on December 18, 2015, 06:43:30 PM
Hi, mabdelouahab!
Thank you!
Title: Re: Fractals
Post by: caballero on January 14, 2016, 01:57:34 AM
Though 32 bits
Title: Re: Fractals
Post by: Grincheux on January 14, 2016, 02:56:07 AM
W O N D E R F U L L

Could you make a screen saver of that wonderfull program? I would install it on my computer.

Félicitations, Bravo
Title: Re: Fractals
Post by: caballero on January 14, 2016, 03:04:26 AM
Thank you. I think so,... when I have time
Title: Re: Fractals
Post by: Siekmanski on January 14, 2016, 06:59:05 AM
avcaballero,

That's a very nice looking julia fractal.  :t
Would you show us the formula?
Title: Re: Fractals
Post by: caballero on January 14, 2016, 07:07:01 AM
Yeah, quid pro quo Marinus :biggrin:, could you show us the mod player formula? I have some of them and I never have time to code it...
Title: Re: Fractals
Post by: guga on January 14, 2016, 08:32:41 AM
I know here is not the proper forum but.... are there 32 bit versions too ? I would like to see too. Seems  amazing.
Title: Re: Fractals
Post by: Siekmanski on January 14, 2016, 11:28:31 AM
avcaballero,

The mod player isn't finished yet. ( some effects are not implemented )
I'll have to rewrite it because it is 15 year old ( buggy ) code. But if I have the time to finish it I'll post it.
Title: Re: Fractals
Post by: caballero on January 14, 2016, 07:58:11 PM
Here it is.
Title: Re: Fractals
Post by: Siekmanski on January 14, 2016, 09:24:18 PM
 :t

Here the unfinished old Protracker mod player routine....
Some effects are not correct or full implemented ( never finished it )
But some time it will  :bgrin:
Title: Re: Fractals
Post by: caballero on January 14, 2016, 09:43:54 PM
( never finished it )
But some time it will  :bgrin:
Believe me, I understand you. every time I have less free time. Thank you!
Title: Re: Fractals
Post by: guga on January 15, 2016, 01:06:38 AM
Thanks Alfonso

It´s wonderfull !! :t :t
Title: Re: Fractals
Post by: Mikl__ on January 18, 2016, 09:08:10 PM
Julia01.asm
Code: [Select]
; masm windows gui #
.686
.model flat
includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib
include windows.inc
extern _imp__BeginPaint@8:dword
extern _imp__BitBlt@36:dword
extern _imp__CreateWindowExA@48:dword
extern _imp__CreateCompatibleDC@4:dword
extern _imp__CreateDIBSection@24:dword
extern _imp__DefWindowProcA@16:dword
extern _imp__DispatchMessageA@4:dword
extern _imp__DeleteObject@4:dword
extern _imp__DeleteDC@4:dword
extern _imp__DestroyWindow@4:dword
extern _imp__EndPaint@8:dword
extern _imp__ExitProcess@4:dword
extern _imp__GetDC@4:dword
extern _imp__GetMessageA@16:dword
extern _imp__GetTickCount@0:dword
extern _imp__InvalidateRect@12:dword
extern _imp__RegisterClassA@4:dword
extern _imp__ReleaseDC@8:dword
extern _imp__SelectObject@8:dword
extern _imp__SetTimer@16:dword
extern _imp__SetWindowTextA@8:dword
extern _imp__wsprintfA:dword

cdXPos          equ 128
cdYPos          equ 6
cdYSize         equ 600
cdXSize         equ 800
cdYMSize equ cdYSize/2
cdIdTimer equ 1
cdScrSize equ cdXSize*cdYSize
MAXITER         equ 20
.code
start: xor ebx, ebx
mov edi, offset wTitle
mov esi, 400000h
push edi
push ebx
push BLACK_PEN
push 10011h
push ebx
push esi
push ebx
push ebx
push offset WndProc
push ebx
push esp ; lpWndClass
call _imp__RegisterClassA@4
push ebx ; lpParam
push esi ; hInstance
push ebx ; hMenu
push ebx ; hWndParent
push cdYSize
push cdXSize
push cdYPos
push cdXPos ; X
push WS_VISIBLE ; dwStyle
push edi ; lpWindowName
push edi ; lpClassName
push ebx ; dwExStyle
call _imp__CreateWindowExA@48
mov ebp, esp

message_loop: push ebx ; wMsgFilterMax
push ebx ; wMsgFilterMin
push ebx ; hWnd
push ebp ; lpMsg
call _imp__GetMessageA@16
cmp [ebp+MSG.wParam], VK_ESCAPE
jz wmDESTROY
push ebp ; lpMsg
call _imp__DispatchMessageA@4
jmp message_loop


WndProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
local szBuffer[100]:byte
local ps:PAINTSTRUCT

mov eax, uMsg
dec eax
jz wmCREATE
dec eax
jz wmDESTROY
sub eax,WM_PAINT-WM_DESTROY
jz wmPAINT
                sub eax,WM_TIMER-WM_PAINT
jz wmTIMER
leave
jmp _imp__DefWindowProcA@16

wmDESTROY:: push hOldBmp ; HGDIOBJ
push hBackDC ; HDC
call _imp__SelectObject@8
push bufBMP ; HGDIOBJ
call _imp__DeleteObject@4
push hBackDC ; HDC
call _imp__DeleteDC@4
push hOldDIB ; HGDIOBJ
push bufDIBDC ; HDC
call _imp__SelectObject@8
push bufDIBDC ; HDC
call _imp__DeleteDC@4
push hMainDIB ; HGDIOBJ
call _imp__DeleteObject@4
push hWnd
call _imp__DestroyWindow@4
push ebx ; uExitCode
call _imp__ExitProcess@4

wmCREATE: push hWnd
call _imp__GetDC@4
mov ps.hdc, eax
push eax ; HDC
call _imp__CreateCompatibleDC@4
mov bufDIBDC, eax
push ebx ; DWORD
push ebx ; HANDLE
push offset pMainDIB ; void **
push ebx ; UINT
push offset bi ; BITMAPINFO *
push ps.hdc
call _imp__CreateDIBSection@24
mov hMainDIB, eax
push eax ; HGDIOBJ
push bufDIBDC ; HDC
call _imp__SelectObject@8
mov hOldDIB, eax
;Indicia-------------------------------------------------
mov eax,cdXSize-1
fld xmax
@@: fst Lx[eax*8]
                fsub deltax
dec eax
jns @b
fstp st

mov eax,cdYSize-1
fld ymax
@@: fst Ly[eax*8]
                fsub deltay
dec eax
jns @b
;-----------------------------------------------------
                call _imp__GetTickCount@0
mov s_time, eax
push ebx
push 20
push    cdIdTimer
push hWnd
call _imp__SetTimer@16
jmp wmBYE
wmTIMER:        call doJulia
                inc fps; fps = fps + 1
call _imp__GetTickCount@0
sub eax, s_time
mov ecx, 1000
xor edx, edx
div ecx
cmp eax,1 ;if ((GetTickCount() - s_time)/1000 > 1.0) {
jbe @f
call _imp__GetTickCount@0
mov s_time, eax ;s_time = GetTickCount()
push fps
push offset szTitleFPS
lea eax,szBuffer
push eax
call _imp__wsprintfA ;wsprintf (szBuffer, szTitleFPS, fps)
add esp,12
lea eax,szBuffer
push eax ; lpString
push hWnd
call _imp__SetWindowTextA@8;SetWindowText (hWnd, szBuffer)
mov fps,ebx         ;fps = 0
@@:             push ebx ;FALSE
push ebx ;NULL
push hWnd
          call _imp__InvalidateRect@12
                jmp wmBYE
wmPAINT: lea eax, ps
push eax ; lpPaint
push hWnd
call _imp__BeginPaint@8
push SRCCOPY ; DWORD
push ebx ; int
push ebx ; int
push bufDIBDC ; HDC
push cdYSize ; int
push cdXSize ; int
push ebx ; int
push ebx ; int
push eax ; HDC
call _imp__BitBlt@36
lea eax, ps
push eax ; lpPaint
push hWnd
call _imp__EndPaint@8

wmBYE: ret
WndProc endp

doJulia proc
local i:dword
local red:dword
local green:dword
local blu:dword
local tmp:dword
local px:dword
local py:dword
local i_last:dword
local ztoti:dword
local p:dword
local q:dword
local theta:dword
local x:dword
local y:dword
local xsquare:dword
local ysquare:dword
local ytemp:dword
local ty:dword
local cmagsq:dword
local zmag:dword
local drad_L:dword
local drad_H:dword
local ztot:dword

inc frame
and frame, 7FFFFFFFh
fild frame ;frame = (frame + 1) & 0x7fffffff
fmul Pi180
fst theta           ;theta = frame * Pi180
fcos                    ;st(0)=cos(theta)
fld const0_7       
fmul theta           ;st(0)=theta*0.7 st(1)=cos(theta)
fsin                    ;st(0)=sin(theta*0.7) st(1)=cos(theta)
fmulp st(1),st ;st(0)=sin(theta*0.7) * cos(theta)
fmul const0_6
fst p               ;p=sin(theta*0.7) * cos(theta)*0.6
fmul st,st           ;st(0)=p*p
fld theta
fsin
fmul const1_2 ;q = (sin(theta) + sin(theta)) * .6
fst q
fmul st,st           ;st(0)=q*q
faddp st(1),st
fst cmagsq ;cmagsq = (p *p + q* q)
fsqrt                   ;cmag = sqrt(cmagsq)
fld st
fsub drad
fmul st,st
                fstp drad_L          ;drad_L = (cmag - drad)*(cmag - drad)
fadd drad
fmul st,st
fstp drad_H          ;drad_H = (cmag + drad)*(cmag + drad)
mov pIniDib,ebx ;pIniDib = 0
mov pFinDib, cdScrSize-1
mov py,ebx ;py = 0

@@: mov eax, py
fld Ly[eax*8]
fstp ty              ;ty = Ly[py]
mov px,ebx ;px = 0
a0: mov eax, px
cmp eax, cdXSize
jb @f
inc py
jmp @b
@@: mov eax, px
fld Lx[eax*8]
fstp x               ;x = Lx[px]
fld ty             
fstp y
fldz
fst ysquare         ;xsquare = ysquare = ztot = 0
fst xsquare
fstp ztot
mov i,ebx ;i = 0

a1: mov eax, i

fld xsquare
fadd ysquare
fld const4          ;(xsquare + ysquare) < MAXSIZE
fucomip st,st(1)
fstp st
jb a2

fld x
fmul st,st
fstp xsquare         ;xsquare = x * x
fld y
fmul st,st
fstp ysquare         ;ysquare = y * y
fld x
fmul y
fadd st,st
fstp ytemp ;ytemp = x * y * 2
fld xsquare
fsub ysquare
fadd p
fst x               ;x = xsquare - ysquare + p
fmul st,st ;st(0)=x*x
fld ytemp
fadd q
fst y               ;y = ytemp + q
fmul st,st ;st(0)=y*y st(1)=x*x
faddp st(1),st ;zmag = (x * x + y * y)
fst zmag            ;if ( (zmag < drad_H) && (zmag > drad_L) && (i > 0) ) {
fld drad_H
fucomip st,st(1)
fstp st       
jb @f
fld drad_L
fld zmag
fucomip st,st(1)
fstp st       
jb @f
cmp i, 0
jle @f
fld zmag
fsub cmagsq
fabs
fdiv drad
fld1
fsubrp st(1),st
fadd ztot
fstp ztot          ;ztot = ztot + ( 1 - (miAbs(zmag - cmagsq) / drad))
mov eax, i
mov i_last, eax
@@: fld const4
fld zmag
fucomip st,st(1)
fstp st
jnb a2
inc i
cmp i,20
jb a1

a2: mov i, 0
fld ztot
ftst
fnstsw ax
test ah, 45h
jnz @f
fsqrt
fmul const500
fist i            ;i = (int)(sqrt(ztot) * 500)

@@: fstp st
mov red, 255
mov eax, i
cmp eax, 256
jae @f
mov red, eax

@@: cmp eax, 512
jae @f
cmp eax, 255
jbe @f
sub eax, 256
mov green, eax
jmp a3

@@: mov green, ebx ;green=0
cmp eax, 512
jb a3
mov green, 255

a3: mov eax, i
cmp eax, 768
ja @f
cmp eax, 511
jbe @f
sub eax, 512
mov blu, eax
jmp a4
@@: mov blu,ebx ; blu=0
cmp i, 768
jl a4
mov blu, 255
a4: mov eax, red
add eax, green
add eax, blu
mov ecx, 3
cdq
idiv ecx
mov tmp, eax
mov eax, red
add eax, green
add eax, tmp
cdq
idiv ecx
mov red, eax
mov eax, green
add eax, blu
add eax, tmp
cdq
idiv ecx
mov green, eax
mov eax, blu
add eax, red
add eax, tmp
cdq
idiv ecx
mov blu, eax
mov eax, i_last    ;switch (i_last & 3)
and eax, 3
jp break          ;i_last=0 or i_last=3 ?
cmp eax, 1
jnz @f

mov eax, red       ;case 1:
mov tmp, eax       ;tmp = red
mov eax, green     
mov red, eax       ;red = grn
mov eax, blu
mov green, eax     ;grn = blu
mov eax, tmp
mov blu, eax       ;blu = tmp
jmp break


@@: mov eax, red       ;case 2:
mov tmp, eax       ;tmp = red
mov eax, green
mov blu, eax       ;blu = green
mov eax, blu
mov red, eax       ;red = blu
mov eax, tmp
mov green, eax     ;green = tmp

break: mov ecx, pIniDib
mov edx, pMainDIB
mov eax, red
shl eax, 8
or eax, green
                shl eax, 8
                or eax, blu
                mov [edx+ecx*4], eax
                mov ecx, pFinDib
mov [edx+ecx*4], eax;*(pMainDIB + pIniDib) = *(pMainDIB + pFinDib) = (red << 16) | (grn << 8) | blu
inc pIniDib         ;pIniDib++
dec pFinDib         ;pFinDib--
inc px
cmp py,cdYMSize
jl a0
ret
doJulia endp
;-------------------------------------------------------------------------
.data
wTitle db 'Dancing Julia [Greetings: Lopesoft] - (c) abreojosensamblador.net',0
bi BITMAPINFOHEADER <sizeof BITMAPINFOHEADER,cdXSize,-cdYSize,1,32,0>
szTitleFPS db 'Dancing Julia [Greetings: Lopesoft] [fps:%i] - (c) abreojosensamblador.net',0
xmin dq -2.0
xmax dq 2.0
ymin dq -1.5
ymax dq 1.5
deltax dq 0.0050062578222778473091364205256571
deltay dq 0.0050083472454090150250417362270451
Pi180 dq 0.01745329251994329576923690768489
const0_7 dd 0.7
const0_6 dd 0.6
const1_2 dd 1.2
const799 dq 799.0
const599 dq 599.0
const4 dq 4.0
const500 dq 500.0
drad dd 0.04
.data?
bufDIBDC dd ?
pMainDIB dd ?
hBackDC dd ?
hMainDIB dd ?
bufBMP dd ?
hOldBmp dd ?
hOldDIB dd ?
s_time dd ?
pIniDib dd ?
pFinDib dd ?
Lx dq cdXSize dup (?)
Ly dq cdYSize dup (?)
frame dd ?
fps dd ?
end start
Source- and exe-files in attachment
Title: Re: Fractals
Post by: jj2007 on January 18, 2016, 11:54:43 PM
wow  :eusa_dance:
Title: Re: Fractals
Post by: caballero on January 19, 2016, 03:02:21 AM
One more. It makes a bleep from time to time that I haven't fixed yet.
Title: Re: Fractals
Post by: Mikl__ on January 20, 2016, 01:24:07 PM
64-bits version of Dancing Julia
bat-file
Code: [Select]
cls
set masm64_path=\masm64\
set filename=%1
del %filename%.exe
if exist %1.rc (
%masm64_path%bin\RC /r  %filename%.rc || exit
%masm64_path%bin\ml64 /Cp /c /I"%masm64_path%Include" %filename%.asm || exit
%masm64_path%bin\link /SUBSYSTEM:WINDOWS /LIBPATH:"%masm64_path%Lib" ^
/entry:WinMain %filename%.obj %filename%.res /LARGEADDRESSAWARE:NO ^
/ALIGN:16 /SECTION:.text,W ^
/BASE:0x400000 /STUB:%masm64_path%\bin\stubby.exe || exit
del %filename%.res
) else (
%masm64_path%bin\ml64 /Cp /c /I"%masm64_path%Include" %filename%.asm || exit
%masm64_path%bin\link /SUBSYSTEM:WINDOWS /LIBPATH:"%masm64_path%Lib" ^
/entry:WinMain %filename%.obj /LARGEADDRESSAWARE:NO ^
/ALIGN:16 /SECTION:.text,W ^
/BASE:0x400000 /STUB:%masm64_path%\bin\stubby.exe || exit
)
del %filename%.obj
asm-file
Code: [Select]
include win64a.inc
include gdi32.inc
IMAGE_BASE equ 400000h
cdXPos          equ 128
cdYPos          equ 6
cdYSize         equ 600
cdXSize         equ 800
cdYMSize equ cdYSize/2
cdIdTimer equ 1
cdScrSize equ cdXSize*cdYSize
MAXITER         equ 20
.code


WndProc proc hWnd:QWORD, uMsg:QWORD, wParam:QWORD, lParam:QWORD
local hdc:qword
local hOldBmp:qword
local szBuffer[100]:byte
local ps:PAINTSTRUCT
local hOldDIB:qword
local hBackDC:qword
local bufBMP:qword

push rbp
mov ebp,esp
sub esp,(50h+sizeof PAINTSTRUCT+8*6+100+15)and(-16)

mov hWnd,rcx
cmp edx,WM_CREATE
jz wmCREATE
cmp edx,WM_DESTROY
jz wmDESTROY
cmp edx,WM_PAINT
jz wmPAINT
        cmp edx,WM_TIMER
jz wmTIMER
leave
jmp DefWindowProc

wmDESTROY::mov rdx,hOldBmp
mov rcx,hBackDC
call SelectObject
mov rcx,bufBMP
call DeleteObject
mov rcx,hBackDC
call DeleteDC
mov rdx,hOldDIB
mov rcx,bufDIBDC
call SelectObject
mov rcx,bufDIBDC
call DeleteDC
mov rcx,hMainDIB
call DeleteObject
mov rcx,hWnd
call DestroyWindow
xor ecx,ecx ; nExitCode
call ExitProcess

wmCREATE:mov rcx,hWnd
call GetDC
mov hdc,rax
mov rcx,rax ; HDC
call CreateCompatibleDC
mov bufDIBDC,rax
mov [rsp+28h],rbx
mov [rsp+20h],rbx
mov r9d,offset pMainDIB
mov r8d,DIB_RGB_COLORS
mov edx,offset bi
mov rcx,hdc
        call CreateDIBSection
mov hMainDIB,rax
mov rdx,rax; hMainDIB
mov rcx,bufDIBDC
call SelectObject
        mov rax,hOldDIB
mov rdx,hdc
mov rcx,hWnd         
        call ReleaseDC;   // Libera device context     
;Indicia-------------------------------------------------
mov eax,cdXSize-1
fld xmax
@@: fst Lx[rax*8]
        fsub deltax
dec eax
jns @b
fstp st

mov eax,cdYSize-1
fld ymax
@@: fst Ly[rax*8]
        fsub deltay
dec eax
jns @b
;-----------------------------------------------------
        call GetTickCount
mov s_time,rax
xor r9,r9
mov r8d,20
mov     rdx,cdIdTimer
mov rcx,hWnd
call SetTimer
jmp wmBYE
wmTIMER:call doJulia
        inc fps; fps = fps + 1
call GetTickCount
sub rax, s_time
mov ecx, 1000
xor edx, edx
div ecx
cmp eax,1 ;if ((GetTickCount() - s_time)/1000 > 1.0) {
jbe @f
call GetTickCount
mov s_time, rax ;s_time = GetTickCount()
mov r8d,fps
mov edx,offset szTitleFPS
lea ecx,szBuffer
call wsprintf ;wsprintf (szBuffer, szTitleFPS, fps)
lea edx,szBuffer
mov rcx,hWnd
call SetWindowText
mov fps,0
@@:     xor r8d,r8d ;FALSE
xor edx,edx ;NULL
mov rcx, hWnd
        call InvalidateRect
        jmp wmBYE
wmPAINT:lea edx,ps
call BeginPaint
mov hdc,rax
mov qword ptr [rsp+40h],SRCCOPY; rop
        xor edx,edx ; x
mov [rsp+38h],rdx ; y1
mov [rsp+30h],rdx ; x1
mov rax,bufDIBDC ; hdcSrc
        mov [rsp+28h],rax
mov rax,cdYSize
mov [rsp+20h],rax
mov r9,cdXSize ; cx
xor r8d,r8d ; cy
mov rcx,hdc ; hdc
call BitBlt
lea edx,ps
mov rcx,hWnd
call EndPaint

wmBYE:  leave
ret
WndProc endp
WinMain proc
local msg:MSG

push rbp
mov ebp, esp
sub esp,sizeof MSG

xor ebx,ebx
mov esi,IMAGE_BASE
mov edi,offset ClassName
push rbx ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOWTEXT; hbrBackground
push rbx ;hCursor
push rbx        ;hIcon
push rsi ;hInstance
push rbx        ;cbClsExtra & cbWndExtra
db 68h
dd WndProc      ;lpfnWndProc
push sizeof WNDCLASSEX ;cbSize & style
mov ecx,esp ;addr WNDCLASSEX
call RegisterClassEx
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
mov r9d,WS_VISIBLE
mov r8,rdi ;offset ClassName
mov edx,edi ;offset ClassName
xor ecx,ecx
sub esp,20h ; dwExStyle
call CreateWindowEx
@@:     lea ecx,msg
xor edx,edx
xor r8d,r8d
xor r9d,r9d
call GetMessage
cmp msg.wParam,VK_ESCAPE;user press 'Esc'?
je wmDESTROY
lea ecx,msg
call DispatchMessage
jmp @b
WinMain endp




doJulia proc
local i:dword
local red:dword
local green:dword
local blu:dword
local tmp:dword
local px:dword
local py:dword
local i_last:dword
local ztoti:dword
local p:dword
local q:dword
local theta:dword
local x:dword
local y:dword
local xsquare:dword
local ysquare:dword
local ytemp:dword
local ty:dword
local cmagsq:dword
local zmag:dword
local drad_L:dword
local drad_H:dword
local ztot:dword
        push rbp
mov ebp, esp
sub esp,(4*23+15)and(-16)

        finit
inc frames
and frames, 7FFFFFFFh
fild frames ;frames = (frames + 1) & 0x7fffffff
fmul Pi180
fst theta           ;theta = frames * Pi180
fcos                    ;st(0)=cos(theta)
fld const0_7       
fmul theta           ;st(0)=theta*0.7 st(1)=cos(theta)
fsin                    ;st(0)=sin(theta*0.7) st(1)=cos(theta)
fmulp st(1),st ;st(0)=sin(theta*0.7) * cos(theta)
fmul const0_6
fst p               ;p=sin(theta*0.7) * cos(theta)*0.6
fmul st,st           ;st(0)=p*p
fld theta
fsin
fmul const1_2 ;q = (sin(theta) + sin(theta)) * .6
fst q
fmul st,st           ;st(0)=q*q
faddp st(1),st
fst cmagsq ;cmagsq = (p *p + q* q)
fsqrt                   ;cmag = sqrt(cmagsq)
fld st
fsub drad
fmul st,st
                fstp drad_L          ;drad_L = (cmag - drad)*(cmag - drad)
fadd drad
fmul st,st
fstp drad_H          ;drad_H = (cmag + drad)*(cmag + drad)
mov pIniDib,0 ;pIniDib = 0
mov pFinDib,cdScrSize-1
mov py, 0
 
@@: mov eax, py
fld Ly[rax*8]
fstp ty              ;ty = Ly[py]
mov px, 0
a0: mov eax, px
cmp eax, cdXSize
jb @f
inc py
jmp @b
@@: mov eax, px
fld Lx[rax*8]
fstp x               ;x = Lx[px]
fld ty             
fstp y
fldz
fst ysquare         ;xsquare = ysquare = ztot = 0
fst xsquare
fstp ztot
mov i,ebx ;i = 0
 
a1: mov eax, i

fld xsquare
fadd ysquare
fld const4          ;(xsquare + ysquare) < MAXSIZE
fucomip st,st(1)
fstp st
jb a2
 
fld x
fmul st,st
fstp xsquare         ;xsquare = x * x
fld y
fmul st,st
fstp ysquare         ;ysquare = y * y
fld x
fmul y
fadd st,st
fstp ytemp ;ytemp = x * y * 2
fld xsquare
fsub ysquare
fadd p
fst x               ;x = xsquare - ysquare + p
fmul st,st ;st(0)=x*x
fld ytemp
fadd q
fst y               ;y = ytemp + q
fmul st,st ;st(0)=y*y st(1)=x*x
faddp st(1),st ;zmag = (x * x + y * y)
fst zmag            ;if ( (zmag < drad_H) && (zmag > drad_L) && (i > 0) ) {
fld drad_H
fucomip st,st(1)
fstp st       
jb @f
fld drad_L
fld zmag
fucomip st,st(1)
fstp st       
jb @f
cmp i, 0
jle @f
fld zmag
fsub cmagsq
fabs
fdiv drad
fld1
fsubrp st(1),st
fadd ztot
fstp ztot          ;ztot = ztot + ( 1 - (miAbs(zmag - cmagsq) / drad))
mov eax, i
mov i_last, eax
@@: fld const4
fld zmag
fucomip st,st(1)
fstp st
jnb a2
inc i
cmp i,20
jb a1
 
a2: mov i, 0
fld ztot
ftst
fnstsw ax
test ah, 45h
jnz @f
fsqrt
fmul const500
fist i            ;i = (int)(sqrt(ztot) * 500)

@@: fstp st
mov red, 255
mov eax, i
cmp eax, 256
jae @f
mov red, eax

@@: cmp eax, 512
jae @f
cmp eax, 255
jbe @f
sub eax, 256
mov green, eax
jmp a3

@@: mov green, ebx ;green=0
cmp eax, 512
jb a3
mov green, 255
 
a3: mov eax, i
cmp eax, 768
ja @f
cmp eax, 511
jbe @f
sub eax, 512
mov blu, eax
jmp a4
@@: mov blu,ebx ; blu=0
cmp i, 768
jl a4
mov blu, 255
a4: mov eax, red
add eax, green
add eax, blu
mov ecx, 3
cdq
idiv ecx
mov tmp, eax
mov eax, red
add eax, green
add eax, tmp
cdq
idiv ecx
mov red, eax
mov eax, green
add eax, blu
add eax, tmp
cdq
idiv ecx
mov green, eax
mov eax, blu
add eax, red
add eax, tmp
cdq
idiv ecx
mov blu, eax
mov eax, i_last    ;switch (i_last & 3)
and eax, 3
jp break          ;i_last=0 or i_last=3 ?
cmp eax, 1
jnz @f
 
mov eax, red       ;case 1:
mov tmp, eax       ;tmp = red
mov eax, green     
mov red, eax       ;red = grn
mov eax, blu
mov green, eax     ;grn = blu
mov eax, tmp
mov blu, eax       ;blu = tmp
jmp break
 

@@: mov eax, red       ;case 2:
mov tmp, eax       ;tmp = red
mov eax, green
mov blu, eax       ;blu = green
mov eax, blu
mov red, eax       ;red = blu
mov eax, tmp
mov green, eax     ;green = tmp

break: mov rcx, pIniDib
mov rdx, pMainDIB
mov eax, red
shl eax, 8
or eax, green
                shl eax, 8
                or eax, blu
                mov [rdx+rcx*4], eax
                mov rcx, pFinDib
mov [rdx+rcx*4], eax;*(pMainDIB + pIniDib) = *(pMainDIB + pFinDib) = (red << 16) | (grn << 8) | blu
inc pIniDib         ;pIniDib++
dec pFinDib         ;pFinDib--
inc px
cmp py,cdYMSize
jl a0
leave
retn
doJulia endp
;-------------------------------------------------------------------------
.data
ClassName db 'Dancing Julia [Greetings: Lopesoft] - (c) abreojosensamblador.net',0
bi BITMAPINFOHEADER <sizeof BITMAPINFOHEADER,cdXSize,-cdYSize,1,32,>
szTitleFPS db 'Dancing Julia [Greetings: Lopesoft] [fps:%i] - (c) abreojosensamblador.net',0
xmin dq -2.0
xmax dq 2.0
ymin dq -1.5
ymax dq 1.5
deltax dq 0.00500625782227784730913642052;56571
deltay dq 0.00500834724540901502504173622;70451
Pi180 dq 0.01745329251994329576923690768;489
const0_7 dd 0.7
const0_6 dd 0.6
const1_2 dd 1.2
const799 dq 799.0
const599 dq 599.0
const4 dq 4.0
const500 dq 500.0
drad dd 0.04
.data?
bufDIBDC dq ?
pMainDIB dq ?
hMainDIB dq ?
s_time dq ?
pIniDib dq ?
pFinDib dq ?
Lx dq cdXSize dup (?)
Ly dq cdYSize dup (?)
frames dd ?
fps dd ?
end
Source- and exe-files in attachment
Title: Re: Fractals
Post by: TWell on January 20, 2016, 07:24:17 PM
From where can i download those inc-files?
win64a.inc?
Title: Re: Fractals
Post by: Mikl__ on January 20, 2016, 08:39:25 PM
Hi, TWell!
from topic Examples for Win64 Iczelion tutorial (http://masm32.com/board/index.php?topic=4190.0) better to copy the inc-files from the last lessons
Title: Re: Fractals
Post by: Mikl__ on January 21, 2016, 01:01:28 PM
Especially for TWell inc-files that were used
Title: Re: Fractals
Post by: TWell on January 21, 2016, 06:08:36 PM
Thanks, спасибо
A pity those don't work with poasm :(
Title: Re: Fractals
Post by: Mikl__ on January 21, 2016, 06:22:52 PM
I didn't work with poasm, but I think that it is not really big problem to transfer from one dialect of the assembler (masm) on another (fasm, nasm, poasm) (http://www.cyberforum.ru/images/smilies/good3.gif)
Title: Re: Fractals
Post by: felipe on May 27, 2018, 01:49:52 PM
 :greenclp: Mikl__ you are really a genius of fractals, thanks for share this with us!   :t