The MASM Forum

Miscellaneous => Miscellaneous Projects => Topic started by: caballero on September 11, 2015, 04:39:05 AM

Title: AOW32
Post by: caballero on September 11, 2015, 04:39:05 AM
Hello. I've finally decided to release AOW32 (http://abreojosensamblador.net/Productos/AOW32/) now. It is far from finished and there're several things that I have to change. But maybe it could be useful for anyone.

It would be great to receive any feedback (constructive comments). Not just, view, take, run and forget.

I have market several things as wrong that I belive that I can fix (when I have time).

Regards,
alfonso
Title: Re: AOW32
Post by: HSE on September 11, 2015, 09:14:01 AM
Hola Alfonso!

El menú va cambiando entre uno en el que el capítulo 02 es Estructuras y uno en el capítulo 02 es Demos Gráficas. Parece que algunas cosas son de AOWG y otras AOW32.

Lo que quise descargar parece que no está ahí. Muy buena pinta los demos (te digo más cuando pueda descargar alguno, ja, ja). Justo uno que está en su lugar me lo bloqueo el antivirus porque lo quise ejecutar directamente.

Saludos. HSE 
Title: Re: AOW32
Post by: Mikl__ on September 11, 2015, 03:56:33 PM
Hola Alfonso!
No puedo llegar a su sitio web desde una computadora en mi trabajo desde que obtuvo el mensaje
Quote
Abreojosensamblador.net Sitio puede representar una amenaza
¿Qué pasó
Yandex encontrar en este código malicioso sitio que puede infectar su computadora con un virus o el acceso a su información personal.
En la configuración de tu red prohibido páginas de demostración de este tipo de recursos.

Más información sobre el código malicioso
Qué hacer a continuación
Ver copia guardada segura
Quote
Сайт abreojosensamblador.net может представлять угрозу
Что произошло
Яндекс обнаружил на этом сайте вредоносный программный код, который может заразить ваш компьютер вирусом или получить доступ к вашей личной информации.
В настройках вашей сети запрещён показ страниц с подобных ресурсов.

Подробнее про вредоносный код
Что делать дальше
Просмотреть безопасную сохранённую копию
link (https://yandex.ru/infected?url=abreojosensamblador.net&fmode=inject&infectedalert=yes&mime=html)
Title: Re: AOW32
Post by: caballero on September 11, 2015, 05:21:51 PM
A ver si la WiFi me permite contestaros. Gracias. He reutilizado el proyecto html de aowg. Las paginas en inglés siguen con el mismo texto. Lo voy traduciendo poco a poco. Mikl__, dime si no puedes acceder de otra manera porque son sobre 9 mb
Title: Re: AOW32
Post by: caballero on September 11, 2015, 05:30:06 PM
Desde que publique aowg en mi sitio, yandex lo consideró sospechoso. Parece que muchos av consideran sospechoso muchos programas que no llevan info ni iconos. Además parece que tinyc suele ser muy proclive a ello.
Title: Re: AOW32
Post by: Mikl__ on September 11, 2015, 05:56:16 PM
Alfonso, voy a tratar en mi ordenador personal. La verdad es que hay acceso a la red bastante lento
Title: Re: AOW32
Post by: anta40 on September 12, 2015, 03:45:55 AM
Hi Alfonso

The download link:
Quote
http://abreojosensamblador.net/Productos/AOW32/html/Libro/AOWG.025.7z

Doesn't seem to work properly
Title: Re: AOW32
Post by: caballero on September 12, 2015, 05:12:48 AM
Yes, I'm sorry. I did it un a hurry, reusing the aowg project, and many things of this remains here. The English versión isn't available either for now. But I'm working on it to be ready as son as I can.

Regards
Title: Re: AOW32
Post by: caballero on September 17, 2015, 01:30:30 AM
Hello.

1. I did my best translating it to English (http://abreojosensamblador.net/Productos/AOW32/Index_en.html).
2. Added some things like join text and images on a button creating a compatible bitmap on the fly.
3. Added 7zipped project to download. It is needed for some programs to compile and run properly.

Regards
Title: Re: AOW32
Post by: caballero on October 05, 2015, 04:44:49 AM
Knock, knock. HHHmmmm, anybody there?

Never mind, I have uploaded it with several fixings and some new things, though in the Spanish side, no time for translating...

See you
Title: Re: AOW32
Post by: Mikl__ on October 27, 2015, 04:33:06 PM
Hola Alfonso!
¿Cómo está tu salud? ¿Cómo está tu hijo?
Hoja del helecho del fractal en 64 bits -- esto es simple, aún más simple y muy sencillamente (http://www.cyberforum.ru/images/smilies/ap.gif)
asm-file
Code: [Select]
include win64a.inc
include gdi32.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;macro for transfer a real value to a local variable
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 r: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
; ---------------------------------------------------------------------------
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--------------------------------------------------------
mov XCC,rbx
mov YCC,rbx
mov i,ebx
loc_4015A0:mov eax, i
cmp eax, 150000
jae wmBYE
call rand
mov ecx,10000
cdq
idiv ecx
mov r,edx
cmp edx, 100
ja @f
mov a,ebx;a = 0
mov b,ebx; b = 0
        mov c,ebx; c = 0
movr d, 0.16
mov f,ebx; f = 0
jmp loc_4016FE
@@: mov eax, r
cmp eax, 800
ja @f
movr a, -0.15
movr b, 0.28
movr c, 0.26
movr d, 0.24
movr f, 0.44
jmp loc_4016FE
@@: cmp eax,1500
ja @f
movr a, 0.20
movr b, -0.26
movr c, 0.23
movr d, 0.22
jmp loc_4016FF
@@: movr a,0.85
movr b, 0.04
movr c, -0.04
movr d, 0.85
loc_4016FF:movr f, 1.60 ; f = 1.60
loc_4016FE:fld a     
fmul XCC
fld b
fmul YCC
faddp
fstp NewX    ;NewX = a * XCC + b * YCC
fld c
fmul XCC
fld d
fmul YCC
faddp
fadd f
fstp NewY    ;NewY = c * XCC + d * YCC + f
fld const40
fmul NewX
fadd const320
fistp x       ;x = (int) (NewX*40+cdXSize/2)
fld1
fsub NewY
fmul const40
fadd const365
fistp y       ; y = (int) ((1-NewY)*40+cdYSize-35)
cmp x,cdXSize
jae @f
cmp y,cdYSize
jae @f
mov eax,2560
mul y
add rax,pMainDIB
mov ecx, x
mov dword ptr [rax+rcx*4],0FF00h ;*(pMainDIB + (y<<9)+(y<<7)+x) = 0xFF00;
@@: fld NewX  ;XCC = NewX
fstp XCC
fld NewY  ;YCC = NewY
fstp YCC
inc i
jmp loc_4015A0
; ---------------------------------------------------------------------------
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
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 'Fern Leaf Fractal - (c) abreojosensamblador.net',0
bi BITMAPINFO <<28h,640,-430,1,32,0,0,0,0,0,0>>
bufDIBDC dq ?
pMainDIB dq ?
const40 dq 4.0e1
const320 dq 3.2e2
const365 dq 3.65e2
end
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
Title: Re: AOW32
Post by: Mikl__ on November 02, 2015, 08:17:12 PM
Hola Alfonso!
Fractal Tree
asm-file
Code: [Select]
; masm windows gui #
.686
.model flat
includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib
includelib msvcrt.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__rand:dword
extern _imp__RegisterClassA@4:dword
extern _imp__ReleaseDC@8:dword
extern _imp__SelectObject@8:dword

cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 400
cdXSize         equ 640 ;cdYSize*1.6
c1              equ 27
c2              equ 6
c3              equ 3
stPaleta struct
  Azul db ?
  Verde db ?
  Rojo db ?
  Alfa db ?
stPaleta ends
.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
call _imp__RegisterClassA@4
        push ebx    
push esi
push ebx
push ebx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
push WS_OVERLAPPEDWINDOW + WS_VISIBLE
push edi; szWinTitle
push edi; lpszClassName
push ebx
call _imp__CreateWindowExA@48
mov ebp,esp
message_loop: push ebx 
push ebx
push ebx
push ebp
call _imp__GetMessageA@16
        cmp [ebp+MSG.wParam],1Bh;press "Esc"?
jz wmDESTROY
push ebp
call _imp__DispatchMessageA@4     ;return control to Windows       
jmp short message_loop
WndProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
local ps:PAINTSTRUCT
local hdc:dword
local hOldBmp:dword
local hGDITmp:dword
local hOldDIB:dword
local hBackDC:dword
local hMainDIB:dword
local bufBMP:dword

mov eax,uMsg
        dec eax;cmp eax,WM_CREATE
jz wmCREATE
        dec eax;cmp eax,WM_DESTROY
jz wmDESTROY
        sub eax,WM_PAINT-WM_DESTROY
jz wmPAINT
leave
jmp _imp__DefWindowProcA@16

wmDESTROY::push hOldBmp
push hBackDC
call _imp__SelectObject@8
mov hGDITmp, eax
push bufBMP
call _imp__DeleteObject@4
push hBackDC
call _imp__DeleteDC@4
push hOldDIB
push bufDIBDC
call _imp__SelectObject@8
mov hGDITmp,eax
push bufDIBDC
call _imp__DeleteDC@4
push hMainDIB
call _imp__DeleteObject@4
push hWnd
call _imp__DestroyWindow@4
push ebx ; nExitCode
call _imp__ExitProcess@4

wmCREATE:push hWnd
call _imp__GetDC@4
mov hdc, eax
        push eax ; HDC
call _imp__CreateCompatibleDC@4
mov bufDIBDC,eax

push ebx
push ebx
push offset pMainDIB
push ebx;DIB_RGB_COLORS
push offset bi
push hdc
        call _imp__CreateDIBSection@24
mov hMainDIB,eax
push eax; hMainDIB
push bufDIBDC
call _imp__SelectObject@8
        mov eax,hOldDIB
push hdc
push hWnd         
        call _imp__ReleaseDC@8;   // Libera device context         
;Initialization
;Create Paleta---------------------------------
  ; Verde normal
mov miPaleta[2*4].Azul,23h
mov miPaleta[2*4].Verde,0ADh
mov miPaleta[2*4].Rojo,30h
  ; Marrуn
mov miPaleta[6*4].Azul,0Bh
mov miPaleta[6*4].Verde,1Dh
mov miPaleta[6*4].Rojo,3Fh
  ; Verde oscuro
mov miPaleta[8*4].Azul,2Dh
mov miPaleta[8*4].Verde,77h
mov miPaleta[8*4].Rojo,11h
  ; Verde claro
mov miPaleta[10*4].Azul,88h
mov miPaleta[10*4].Verde,0FFh
mov miPaleta[10*4].Rojo,9Ch
;------------------------------------------------
push 150
push 270
push cdYSize-1
push (cdXSize/2)
call Fractal_Tree
jmp wmBYE

wmPAINT:lea eax,ps
push eax
push hWnd
call _imp__BeginPaint@8
push SRCCOPY
push ebx;0
push ebx;0
push bufDIBDC
push cdYSize
push cdXSize
push ebx;0
push ebx;0
push eax;hdc
call _imp__BitBlt@36
lea eax,ps
push eax
push hWnd
        call _imp__EndPaint@8
wmBYE:  ret
WndProc endp
Fractal_Tree proc x:dword,y:dword,angle:dword,len:dword

local color:dword
local u1:dword
local a1:dword
local p:dword
local i:dword
local y1:dword
local x1:dword

cmp len, 5
jl locret_402029
fild angle
fmul deg2rad
fsincos
fimul len
fiadd x
fistp x1             ; x1 = x + len * cos(angle*deg2rad)
fimul len
fiadd y
fistp y1 ; y1 = y + len * sin(angle*deg2rad)
cmp len,95         ; if (len > 95)
jle @f
mov p, 95          ;p = 95
jmp loc_4019C1
@@: mov eax, len       ;else p = len;
mov p, eax
loc_4019C1: mov eax, p
mov ecx, 5
cdq
idiv ecx
mov ecx, offset mColores[0]
add ecx, eax
movzx eax, byte ptr [ecx]
mov i, eax         ;i = mColores[p/5]
call _imp__rand
and eax,1          ;if ((rand() % 2) == 0) {
jnz setcolor
mov eax, i
cmp al,mColores[0] ;if (i == mColores[0])
jnz @f
movzx eax, byte ptr mColores[1]
mov i, eax         ;i = mColores[1]
jmp setcolor
@@: mov eax,i          ;else
cmp al,mColores[1] ;if (i == mColores[1])
jnz setcolor
movzx eax,mColores[0];i = mColores[0]
mov i, eax
setcolor: mov eax,i
lea edx,miPaleta[eax*4].Rojo
movzx ecx,byte ptr [edx]
shl ecx,16
                lea edx,miPaleta[eax*4].Verde
mov ch,[edx]
                lea edx,miPaleta[eax*4].Azul
mov cl,[edx]
                mov color,ecx;color = miPaleta[i].Azul + (miPaleta[i].Verde<<8) + (miPaleta[i].Rojo<<16)
;mov eax, i
cmp al,mColores[0]
jz @f
cmp al,mColores[1]
jnz loc_401B65;if ( (i == mColores[0]) || (i == mColores[1]) ) {
@@: mov i,ebx
loc_401AA0: cmp i,c3         ;for (i = 0; i <= c3; i++) {
ja loc_401C47
mov eax, x
add eax,i
sub eax,1
mov u1,eax      ;u1 = x+i-c3/2
cmp eax,cdXSize
jae @f
cmp y,cdYSize
jae @f
cmp x1,cdXSize
jae @f
cmp y1,cdYSize
jae @f          ;if (u1 < cdXSize && u1 > 0 && y < cdYSize && y > 0 && x1 < cdXSize && x1 > 0 && y1 < cdYSize && y1 > 0)
push color
push y1
push x1
push y
push u1
call DIBLine     ;DIBLine (u1,y,x1,y1, color, pMainDIB)
@@: inc i
jmp short loc_401AA0
;} else {
loc_401B65: mov i,ebx   ;for (i = 0; i <= p/c2; i++) {
loc_401B6D: mov eax, p
mov ecx, c2
cdq
idiv ecx
cmp i, eax
ja loc_401C47
mov eax, x
add eax, i
push eax
mov eax, p
mov ecx,c2*2; 12
cdq
idiv ecx
pop ecx
sub ecx, eax
mov u1, ecx   ;u1 = x+i-p/(c2*2)
cmp u1,cdXSize
jae @f
cmp y,cdYSize
jae @f
cmp x1,cdXSize
jae @f
cmp y1,cdYSize
jae @f       ;if (u1 < cdXSize && u1 > 0 && y < cdYSize && y > 0 && x1 < cdXSize && x1 > 0 && y1 < cdYSize && y1 > 0)
push color
push y1
push x1
push y
push u1
call DIBLine  ;DIBLine (u1,y,x1,y1, color, pMainDIB)
@@: inc i
jmp loc_401B6D
loc_401C47: mov i,ebx     ;for (i = 0; i <= 3 - (rand()%3); i++) {
loc_401C4F: call _imp__rand
mov ecx, c3
cdq
idiv ecx
mov eax, c3
sub eax, edx
cmp i, eax
jg locret_402029
call _imp__rand
push eax
mov eax, len
mov ecx, c2
cdq
idiv ecx
mov ecx, len
sub ecx, eax
pop eax
cdq
idiv ecx
mov eax, len
mov ecx, c2
push edx
cdq
idiv ecx
pop ecx
add ecx, eax
mov p, ecx ;p = rand() % (len - len / 6) + len / 6
call _imp__rand
mov ecx,55
cdq
idiv ecx
mov eax, angle
sub eax, edx
mov a1, eax;a1 = angle - (rand() % 55)
fild angle
fmul deg2rad
fsincos
fimul p
fiadd x
fistp x1 ; x1 = x + p * cos(angle*deg2rad)
fimul p
fiadd y
fistp y1 ; y1 = y + p * sin(angle*deg2rad)
mov eax, len
cmp eax,100
jle @f;loc_401DFB   ;if (len > 100)
call _imp__rand
mov ecx,15
cdq
idiv ecx
mov eax,100
jmp a2
@@: call _imp__rand
mov ecx,15
cdq
idiv ecx
mov eax, len
a2: sub eax, edx
sub eax,c1
push eax
call _imp__rand
mov ecx,c1
cdq
idiv ecx
pop eax
add eax, edx
push eax
push a1
push y1
push x1
call Fractal_Tree ;Fractal_Tree(x1,y1,a1,100-(rand()%15)-c1+(rand()%c1))
loc_401E40: call _imp__rand
push eax
mov eax, len
mov ecx, c2
cdq
idiv ecx
mov ecx, len
sub ecx, eax
pop eax
cdq
idiv ecx
mov eax, len
mov ecx, c2
push edx
cdq
idiv ecx
pop ecx
add ecx, eax
mov p, ecx
call _imp__rand
mov ecx,55
cdq
idiv ecx
mov eax, angle
add eax, edx
mov a1, eax
;----------------------------------------------------------------
fild angle
fmul deg2rad
fsincos
fimul p
fiadd x
fistp x1 ; x1 = x + p * cos(angle*deg2rad)
fimul p
fiadd y
fistp y1         ; y1 = y + p * sin(angle*deg2rad)
;-----------------------------------------------------------------
call _imp__rand
cmp len, 100 ; if (len > 100)
jle @f
mov ecx,15
cdq
idiv ecx
mov eax, 100; Fractal_Tree(x1,y1,a1,100-(rand()%15)-c1+(rand()%c1));
jmp a0
@@: mov ecx, 15
cdq
idiv ecx
mov eax, len
a0: sub eax, edx
sub eax,c1
push eax
call _imp__rand
mov ecx,c1
cdq
idiv ecx
pop eax
add eax, edx
push eax
push a1
push y1
push x1
call Fractal_Tree ; Fractal_Tree(x1,y1,a1,len-(rand()%15)-c1+(rand()%c1));
inc i
jmp loc_401C4F
locret_402029: leave
retn 10h
Fractal_Tree endp
;----------------------------------------------
DIBLine proc u1:dword,y:dword,x1:dword,y1:dword,color:dword

local var_1C:dword
local var_18:dword
local var_14:dword
local var_10:dword
local var_C:dword
local var_8:dword
local var_4:dword


mov eax,y
cmp eax,y1
jnz @f

push color
push x1
push y
push u1
call sub_401121
jmp exit
@@: mov eax, u1
cmp eax, x1
jnz @f
push color
push y1
push y
push u1
call sub_4011A8
jmp exit
@@: mov eax, x1
sub eax, u1
mov var_4, eax
cmp eax, ebx
jge @f
neg var_4
@@: mov eax, y1
sub eax, y
mov var_8, eax
cmp eax, ebx
jge @f
neg var_8
@@: mov eax, u1
cmp x1,eax
sbb ecx,ecx
or ecx,1
mov var_C,ecx
mov eax, y
cmp y1,eax
sbb ecx,ecx
or ecx,1
mov var_10,ecx
mov eax, var_4
sub eax, var_8
mov var_14, eax
loc_401334:     mov ecx, y
shl ecx, 7
mov eax, ecx
shl eax, 2
add eax, ecx
add eax, u1
mov var_1C, eax
shl eax, 2
mov ecx, pMainDIB
add ecx, eax
mov eax, color
mov [ecx], eax
mov eax, u1
cmp eax, x1
jnz @f
mov eax, y
cmp eax, y1
jz exit
@@: mov eax, var_14
shl eax, 1
mov var_18, eax
xor eax,eax
sub eax, var_8
cmp var_18, eax
jle @f
mov eax, var_14
sub eax, var_8
mov var_14, eax
mov eax, u1
add eax, var_C
mov u1, eax
@@: mov eax, u1
cmp eax, x1
jnz @f
mov eax, y
cmp eax, y1
jnz @f
mov ecx, y
shl ecx, 7
mov eax, ecx
shl eax, 2
add eax, ecx
add eax, u1
mov var_1C, eax
shl eax, 2
mov ecx, pMainDIB
add ecx, eax
mov eax, color
mov [ecx], eax
jmp exit
@@: mov eax, var_18
cmp eax, var_4
jge loc_401334
mov eax, var_4
add var_14,eax
mov eax,var_10
add y,eax
jmp loc_401334

exit: ret
DIBLine endp
;----------------------------------------------------------------------
sub_401121 proc u1:dword,y:dword,x1:dword,color:dword

local var_8:dword
local var_4:dword

mov eax, u1
cmp eax, x1
jle @f
lea eax, x1
push eax
lea eax, u1
push eax
call sub_401000
@@: mov ecx, y
shl ecx, 7
                mov eax, ecx
shl eax, 2
add eax, ecx
add eax, u1
mov var_8,eax
mov var_4,ebx
@@: mov eax, x1
sub eax, u1
cmp var_4, eax
jg @f
mov eax, var_8
add eax,var_4
mov ecx, pMainDIB
lea ecx,[ecx+eax*4]
mov eax, color
mov [ecx], eax
inc var_4
jmp @b
@@: leave
retn 10h
sub_401121 endp
;----------------------------------------------------------------------
sub_4011A8 proc u1:dword,y:dword,y1:dword,color:dword
local var_8:dword
local var_4:dword

mov eax,y
cmp eax,y1
jle @f
lea eax,y1
push eax
lea eax,y
push eax
call sub_401000
@@: mov ecx,y
shl ecx,7
mov eax,ecx
shl eax,2
add eax,ecx
mov ecx,u1
add eax,ecx
mov var_8,eax
mov var_4,ebx
@@: mov eax,y1
sub eax,y
cmp var_4,eax
jg @f
mov eax,var_8
mov ecx,pMainDIB
lea ecx,[ecx+eax*4]
mov eax,color
mov [ecx],eax
add var_8,cdXSize
inc var_4
jmp @b
@@: leave
retn 10h
sub_4011A8 endp
;---------------------------------------------------------------------
sub_401000 proc arg_0:dword,arg_4:dword
local var_4:dword

mov eax, arg_0
mov ecx, [eax]
mov var_4, ecx
mov eax, arg_0
mov ecx, arg_4
mov edx, [ecx]
mov [eax], edx
mov eax, arg_4
mov ecx, var_4
mov [eax], ecx
leave
retn 8
sub_401000 endp
;----------------------------------------------------------------------
.data
miPaleta stPaleta <0>,<0>,<0>,<0>,<0>,<0>,<0>,<0>,<0>,<0>,<0>
wTitle db "Fractal Tree - (c) abreojosensamblador.net",0
bi BITMAPINFOHEADER <sizeof BITMAPINFOHEADER,cdXSize,-cdYSize,1,32,0>
bufDIBDC dd ?
pMainDIB dd 0
mColores db 2,10,10,8,8,8,8,6,6,6,6,6,6,6,6,6,6,6,6,6
deg2rad dq 0.01745329251994329576923690768
end start
bat-file
Code: [Select]
cls
set filename=FTreeWM01
if exist %filename%.exe del %filename%.exe
if exist %filename%.com del %filename%.com
if exist %filename%.dll del %filename%.dll
set masm_path=c:\masm32
if exist %filename%.rc (
%masm_path%\bin\rc /v %1.rc
%masm_path%\bin\cvtres /machine:ix86 %1.res
%masm_path%\bin\ml /c /Cp /Gz /I%masm_path%\include /coff /nologo %filename%.asm  || exit
%masm_path%\bin\link /SUBSYSTEM:WINDOWS  ^
/LIBPATH:%masm_path%\lib /NOLOGO  %1.obj %filename%.res || exit
del %filename%.res
) else (
%masm_path%\bin\ml /c /Cp /Gz /I%masm_path%\include /coff /nologo %filename%.asm  || exit
%masm_path%\bin\PoLink /SUBSYSTEM:WINDOWS  ^
/LIBPATH:%masm_path%\lib /NOLOGO %filename%.obj
)
if exist %filename%.map del %filename%.map
if exist %filename%.obj del %filename%.obj
if exist %filename%.ilc del %filename%.ilc
if exist %filename%.ild del %filename%.ild
if exist %filename%.ilf del %filename%.ilf
if exist %filename%.ils del %filename%.ils
if exist %filename%.tds del %filename%.tds
exit
Title: Re: AOW32
Post by: caballero on November 02, 2015, 09:19:56 PM
Qué tal, Mikl__. Da la sensación de que tu forma de trabajo es desensamblar el fichero exe y trabajar sobre el código resultante, el resultado es un código ilegible. No es necesario, tienes las bibliotecas accesibles.

Ahora, tu método de desensamblaje es encomiable, algún día me podrías enseñar cómo lo haces, estoy muy interesado  :t.
Title: Re: AOW32
Post by: Mikl__ on November 03, 2015, 11:12:25 AM
Hola Alonso!
En AOW32 no son los original asm-files ("Fern Leaf Fractal" y "Fractal Tree") o la biblioteca "CDIBLines.h." Por lo tanto es necesario desensamblar el fichero exe, comparar con el  texto del C-file, escribir los comentarios, elimina el exceso (KilTimer hay, pero SetTimer no hay) etcétera (http://www.cyberforum.ru/images/smilies/smile3.gif)
Title: Re: AOW32
Post by: Mikl__ on November 09, 2015, 11:28:58 AM
Fractal de Julia
asm-file
Code: [Select]
; masm windows gui #
.686
.model flat
includelib user32.lib
includelib kernel32.lib
includelib gdi32.lib
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__RegisterClassA@4:dword
extern _imp__ReleaseDC@8:dword
extern _imp__SelectObject@8:dword

cdXPos          equ 131
cdYPos          equ 217
cdYSize         equ 440
cdXSize         equ 640 ;cdYSize*1.6
DIB_RGB_COLORS  equ 0
cdNumColores    equ 256
cdMaxIterac     equ 256

VK_ESCAPE                            equ 1Bh
WM_CREATE                            equ 1h
WM_DESTROY                           equ 2h
WM_PAINT                             equ 0Fh
SRCCOPY                              equ 0CC0020h
BITMAPINFOHEADER STRUCT
  biSize            DWORD      ?
  biWidth           DWORD      ?
  biHeight          DWORD      ?
  biPlanes          WORD       ?
  biBitCount        WORD       ?
  biCompression     DWORD      ?
  biSizeImage       DWORD      ?
  biXPelsPerMeter   DWORD      ?
  biYPelsPerMeter   DWORD      ?
  biClrUsed         DWORD      ?
  biClrImportant    DWORD      ?
BITMAPINFOHEADER ENDS
stPaleta struct
  Azul db ?
  Verde db ?
  Rojo db ?
  Alfa db ?
stPaleta ends
RECT STRUCT
  left    dd      ?
  top     dd      ?
  right   dd      ?
  bottom  dd      ?
RECT ENDS
POINT STRUCT
  x  DWORD ?
  y  DWORD ?
POINT ENDS
PAINTSTRUCT STRUCT
  hdc           DWORD      ?
  fErase        DWORD      ?
  rcPaint       RECT       <>
  fRestore      DWORD      ?
  fIncUpdate    DWORD      ?
  rgbReserved   BYTE 32 dup(?)
PAINTSTRUCT ENDS
MSG STRUCT
  hwnd      DWORD      ?
  message   DWORD      ?
  wParam    DWORD      ?
  lParam    DWORD      ?
  time      DWORD      ?
  pt        POINT      <>
MSG ENDS
BLACK_PEN                            equ 7
WS_VISIBLE                           equ 10000000h
.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
call _imp__RegisterClassA@4
        push ebx    
push esi
push ebx
push ebx
push cdYSize
push cdXSize
push cdYPos
push cdXPos
push WS_VISIBLE;+ WS_OVERLAPPEDWINDOW
push edi; szWinTitle
push edi; lpszClassName
push ebx
call _imp__CreateWindowExA@48
mov ebp,esp
message_loop: push ebx  ;цикл обработки сообщений
push ebx
push ebx
push ebp
call _imp__GetMessageA@16
        cmp [ebp+MSG.wParam],VK_ESCAPE;press "Esc"?
jz wmDESTROY
push ebp
call _imp__DispatchMessageA@4     ;вернуть управление Windows       
jmp short message_loop
;------------------------------------------------------------
WndProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
local ps:PAINTSTRUCT
local hdc:dword
local hOldDIB:dword
local hMainDIB:dword
local bufBMP:dword
local n:dword
local m:dword
local x:qword
local y:qword
local u:qword
local v:qword

mov eax,uMsg
        dec eax;cmp eax,WM_CREATE
jz wmCREATE
        dec eax;cmp eax,WM_DESTROY
jz wmDESTROY
        sub eax,WM_PAINT-WM_DESTROY
jz wmPAINT
leave
jmp _imp__DefWindowProcA@16

wmDESTROY::push bufBMP
call _imp__DeleteObject@4
push hOldDIB
push bufDIBDC
call _imp__SelectObject@8
push bufDIBDC
call _imp__DeleteDC@4
push hMainDIB
call _imp__DeleteObject@4
push hWnd
call _imp__DestroyWindow@4
push ebx ; nExitCode
call _imp__ExitProcess@4
wmPAINT:lea eax,ps
push eax
push hWnd
call _imp__BeginPaint@8
push SRCCOPY
push ebx;0
push ebx;0
push bufDIBDC
push cdYSize
push cdXSize
push ebx;0
push ebx;0
push eax;hdc
call _imp__BitBlt@36
lea eax,ps
push eax
push hWnd
        call _imp__EndPaint@8
        jmp wmBYE
wmCREATE:push hWnd
call _imp__GetDC@4
mov hdc, eax
        push eax ; HDC
call _imp__CreateCompatibleDC@4
mov bufDIBDC,eax

push ebx
push ebx
push offset pMainDIB
push ebx;DIB_RGB_COLORS
push offset bi
push hdc
        call _imp__CreateDIBSection@24
mov hMainDIB,eax
push eax; hMainDIB
push bufDIBDC
call _imp__SelectObject@8
        mov eax,hOldDIB
push hdc
push hWnd         
        call _imp__ReleaseDC@8;   // Libera device context         
;Initialization
;Creat Paleta---------------------------------
mov eax,cdNumColores - 31
mov ecx,16
mov dl,240
@@: mov miPaleta[eax*4].Verde,dl
sub dl,16
mov miPaleta[eax*4].Rojo,0FCh
        inc eax
loop @b
mov ecx,16
mov dl,240
@@: mov miPaleta[eax*4].Rojo,dl
sub dl,16
inc eax
loop @b
;Creat Fractal------------------------------------------------
mov n,cdYSize
        fld const4
a0: mov m,cdXSize
a1: fild m
fdiv const160
fsub const2
fstp x ; x = m /(cdXSize/4.0) - 2.0
fld1
fild n
fdiv const200
fsubrp st(1),st
fstp y ; y = n /(cdYSize/2.0) - 1.0
mov ecx,cdMaxIterac
@@: fld x
fmul st,st
fld y
fmul st,st
fsubp st(1),st
fadd cfReal
fstp u ; u = x*x - y*y + cfReal
fld x
fmul y
fadd st,st
fadd cfImaginario ; v = 2*x*y + cfImaginario
fstp v
fld u
fst x ; x = u
fmul st,st
fld v
fst y ; y = v
        fmul st,st
faddp st(1),st
fucomp                  ; if (u*u+v*v > 4.0) break;
fnstsw ax
test ah,01000101y ;45h
loopnz @b ; for (i = cdMaxIterac; i >= 1; i--) {
movzx eax,miPaleta[ecx*4].Rojo
shl eax,16
mov ah,miPaleta[ecx*4].Verde
mov al,miPaleta[ecx*4].Azul; eax = miPaleta[Color].Azul + (miPaleta[Color].Verde << 8 ) + (miPaleta[Color].Rojo<<16);
mov edx,n
dec edx
imul edx,cdXSize
add edx,m
dec edx
shl edx,2
add edx,pMainDIB
mov [edx],eax ; *(pMainDIB + (n-1)*cdXSize+m-1) = c; //0xFFBBCC
dec m
jnz a1  ; for (m = cdXSize; m >= 1; m--) {
dec n   ; for (n = cdYSize; n >= 1; n--) {
jnz a0
wmBYE:  ret
WndProc endp
;----------------------------------------------------------------------
.data
miPaleta stPaleta 256 dup (<0>)
wTitle db "Fractal de Julia - (c) abreojosensamblador.net",0
bi BITMAPINFOHEADER <sizeof BITMAPINFOHEADER,cdXSize,-cdYSize,1,32,0>
bufDIBDC dd ?
pMainDIB dd ?
const2 dd 2.0
const160 dd 160.0
const200 dd 200.0
const4 dd 4.0
cfReal          dd 0.3
cfImaginario dd -0.5
end start
bat-file
Code: [Select]
cls
set filename=JuliaWM01
if exist %filename%.exe del %filename%.exe
set masm_path=c:\masm32
%masm_path%\bin\ml /c /Cp /Gz /I%masm_path%\include /coff /nologo %filename%.asm  || exit
%masm_path%\bin\link /SUBSYSTEM:WINDOWS  /LIBPATH:%masm_path%\lib /NOLOGO %filename%.obj
del %filename%.obj
exit
Title: Re: AOW32
Post by: Mikl__ on November 17, 2015, 05:29:19 PM
The revised text of the program FernCM1.asm. The size of executable file is reduced from 856 bytes to 473 bytes.
Code: [Select]
; masm dos com #
.286
.model tiny
.code
  ClipX2    EQU  640
  ClipY2    EQU  480
org 100h
start:
;Semilla---------------------------------------------------------
mov ah, 0           ; CLOCK - GET TIME OF DAY
int 1Ah ; Return: CX:DX = clock count
; AL = 00h if clock was read or written (via AH=0,1) since the previous
; midnight
; Otherwise, AL > 0
mov word_101CA, dx
mov cx,37h
push cs
pop es
mov si,offset word_101CA
lea di,[si+1]
                mov bx,3DCDh
@@: lodsw
mul bx
inc ax
stosw
loop @b
mov word ptr [si],2Ah
mov ax,12h
int 10h ; - VIDEO - SET VIDEO MODE
finit
DrawFern:
    ; Propуsito : Dibuja una hoja de helecho
    ; Entrada   : Ninguna
    ; Salida    : Ninguna
    ; Destruye  : Ninguna
;Randomization--------------------------------------------
mov bx,word_10238
inc bx
cmp bx,37h
jnz @f
xor bx,bx
@@: mov word_10238,bx
lea ax,[bx+17h]
mov dl,37h
div dl
shr ax,8
mov si,ax
mov cx,word_101CA[si]
lea ax,[bx+36h]
div dl
shr ax,8
mov si,ax
add cx,word_101CA[si]
mov word_101CA[bx], cx
mov ax,10000    ; Rango
mul cx
;--------------------------------------------------------------------
mov bx,7*2*3             ; Suponemos AX < 100
cmp dx,9300
jb Siguiente1
mov bx,7*2*0
jmp Final
Siguiente1: cmp dx,8600
jb Siguiente2
mov bx,7*2*1
jmp Final
Siguiente2: cmp dx,100
jb Final
mov bx,7*2*2
Final: mov si,offset ParamFern+2
add si,bx
mov di,offset x0
mov cx,6
rep movsw
                ; Xn = x0 + ((xu - x0)*x + (xv - x0)*y)/400
fild xu         ; ST(0)=xu
fisub x0         ; ST(0)=xu-x0
fmul X          ; ST(0)=(xu-x0)*x
fild xv         ; ST(0)=xv
fisub x0         ; ST(0)=xv-x0
fmul Y          ; ST(0)=(xv-x)*y
faddp st(1),st   ; ST(0)=((xu - x0)*x + (xv - x0)*y) y Liberamos ST(1)
fidiv const400
fiadd x0
                ; Yn = y0 + ((yu - y0)*x + (yv - y0)*y)/400
fild yu
fisub y0
fmul X
fild Yv
fisub y0
fmul Y
faddp st(1), st
fidiv const400
fiadd y0
                ; x = Xn: y = Yn
fst Y
fchs    ;st(0)=-Y
fistp R2Tmp
mov dx,R2Tmp
                fst X
add dx,440 ; dx = 440 - Y
fistp R2Tmp
mov cx,R2Tmp
add cx,10  ; cx = x + 10
ClipPixel: ; PSET (x + 10, 440 - y)
    ;  Propуsito: Dibujamos un punto con recorte en (BX,DX)
    ;  Entrada  : BX, eje X; DX, eje Y; AL, color
    ;  Salida   : Ninguna
    ;  Destruye : Ninguna
;IF (BX>0) && (BX<ClipX2) && (DX>0) && (DX<ClipY2)
cmp cx, ClipX2    ; CX = column
jnb @f
cmp dx, ClipY2    ; DX = row
jnb @f            ; BH = 0 display page
mov ax, 0C0Ah     ; AH = 0Ch WRITE DOT ON SCREEN
int 10h ; AL = color of dot
@@: dec i
jnz DrawFern
xor ah,ah ; їQueremos salir?
int 16h                 ; Si no pulsamos ninguna tecla
mov ax,3
int 10h ; - VIDEO - SET VIDEO MODE
ret
;--------------------------------------------------------------
i dw ClipX2*ClipY2
word_101CA dw 37h dup(?)
word_10238 dw ?
x0 dw ?
y0 dw ?
xu dw ?
yu dw ?
xv dw ?
Yv dw ?
const400 dw 400
X dd 200.0
Y dd 200.0
R2Tmp dw ?
ParamFern dw 2, 184, 0,  124, 64,  333, 82    ; Primer valor es el color
                DW 2, 128, 34, 208, 103, 0,   122   ; Primer valor es el color
                DW 2, 24,  57, 364, 45,  45,  397   ; Primer valor es el color
                DW 2, 160, 0,  160, 0,   160, 64    ; Primer valor es el color
end start
Title: Re: AOW32
Post by: caballero on November 17, 2015, 09:59:37 PM
Let's see, Mikl__. What you are doing is ripping my codes and posting the resulting codes here. What is the effort? I asked you to help me on continue working with the Desktop Window Manager, because I don't have enough time, but you omised it and working on what you want (nothig to say, you can do whatever you want). But, tell me where is the effort? doing what I have already done?
Title: Re: AOW32
Post by: Mikl__ on November 18, 2015, 12:08:28 PM
Hola, Alonso! En cuanto a la Desktop Window Manager escucho por primera vez, me tienes con alguien confundido. Conmigo usted habló de la AOW32 traducción al ruso
Title: Re: AOW32
Post by: caballero on November 18, 2015, 07:54:40 PM
I did, it was in our mails. Are you translating it to russian? Where you are working on is in AOWG, not in AOW32. AOWG has all the libraries available to download for all the examples, it is just that I had no time to make everything also in asm, that is what is missed, everything was coded in c, you can compile everything. This last fern is from AOE in MS-DOS. Nevertheless, you can keep doing what you want.
Title: Re: AOW32
Post by: Mikl__ on November 23, 2015, 10:44:41 PM
asm-file part #1
Code: [Select]
; masm windows gui #
.686
.model flat, stdcall
option casemap :none
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\gdi32.lib
includelib c:\masm32\lib\msvcrt.lib
include c:\masm32\include\windows.inc
extern _imp__RegisterClassA@4:dword
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__DeleteObject@4:dword
extern _imp__DeleteDC@4:dword
extern _imp__DestroyWindow@4:dword
extern _imp__DefWindowProcA@16:dword
extern _imp__DispatchMessageA@4:dword
extern _imp__EndPaint@8:dword
extern _imp__ExitProcess@4:dword
extern _imp__GetMessageA@16:dword
extern _imp__GetDC@4:dword
extern _imp__InvalidateRect@12:dword
extern _imp__KillTimer@8:dword
extern _imp__rand:dword
extern _imp__ReleaseDC@8:dword
extern _imp__SetTimer@16:dword
extern _imp__SelectObject@8:dword
.code
cdXPos          equ 131
cdYPos          equ 217
ScreenHeight equ 400
ScreenWidth     equ 640 ;ScreenHeight*1.6
cdIdTimer       equ 1
DIB_RGB_COLORS  equ 0
stPaleta struct
  Azul db ?
  Verde db ?
  Rojo db ?
  Alfa db ?
stPaleta ends
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 WinProc
push ebx
push esp ; lpWndClass
call _imp__RegisterClassA@4
push ebx    
push esi
push ebx
push ebx
push ScreenHeight+25
push ScreenWidth
push cdYPos
push cdXPos
push WS_VISIBLE
push edi; szWinTitle
push edi; lpszClassName
push ebx ; dwExStyle
call _imp__CreateWindowExA@48
mov ebp,esp

message_loop: push ebx  ;                       
push ebx
push ebx
push ebp
call _imp__GetMessageA@16
        cmp [ebp+MSG.wParam],1Bh ;press "Esc"?
jz wmDESTROY
push ebp
call _imp__DispatchMessageA@4       
jmp message_loop

sub_4010DD proc arg_0:dword,arg_4:dword

mov eax, arg_0
mov edx, [eax]
mov eax, arg_0
mov ecx, arg_4
mov ecx, [ecx]
mov [eax], ecx
mov eax, arg_4
mov [eax], edx
ret
sub_4010DD endp

sub_401421 proc X1:dword,Y1:dword,X2:dword

mov eax, X1
cmp eax, X2
jbe @f
lea eax, X2
push eax
lea eax, X1
push eax
call sub_4010DD
@@: imul eax, Y1,ScreenWidth
add eax, X1
mov edx, eax ; edx = Y1 * ScreenWidth + X1
xor ecx, ecx
@@: mov eax, X2
sub eax, X1
cmp ecx, eax
ja @f
mov buffer1[ecx+edx], 5 ; color = 5
inc ecx
jmp @b
@@: ret
sub_401421 endp


sub_4014A3 proc X1:dword,Y1:dword,Y2:dword

mov eax, Y1
cmp eax, Y2
jbe @f
lea eax, Y2
push eax
lea eax, Y1
push eax
call sub_4010DD
@@: imul    eax, Y1,ScreenWidth
add eax, X1
mov edx, eax ;edx = Y1 * ScreenWidth + X1
xor ecx, ecx
@@: mov eax, Y2
sub eax, Y1
cmp ecx, eax
ja @f
mov buffer1[edx], 5;color
add edx, ScreenWidth
inc ecx
jmp @b
@@: ret
sub_4014A3 endp





BresLine proc X1:dword,Y1:dword,X2:dword,Y2:dword
local var_4:dword
local var_8:dword
local var_C:dword
local var_10:dword
local var_14:dword
local var_18:dword


mov eax, Y1
cmp eax, Y2
jnz @f
push X2
push Y1
push X1
call sub_401421
jmp fin

@@: mov eax, X1
cmp eax, X2
jnz @f
push Y2
push Y1
push X1
call sub_4014A3
jmp fin

@@: mov eax, X2
sub eax, X1
mov var_4, eax
cmp eax, 0
jge @f
neg var_4

@@: mov eax, Y2
sub eax, Y1
mov var_8, eax
cmp eax, 0
jge @f
neg var_8

@@: mov eax, X1
cmp eax, X2
jge @f
mov var_C, 1
jmp loc_401601


@@: or var_C, -1

loc_401601: mov eax, Y1
cmp eax, Y2
jge @f
mov var_10, 1
jmp loc_401624


@@: or var_10, -1

loc_401624: mov eax, var_4
sub eax, var_8
mov var_14, eax

loc_40162F: imul eax, Y1,ScreenWidth
add eax, X1      ; eax = Y1 * ScreenWidth + X1
mov buffer1[eax], 5;color
mov eax, X1
cmp eax, X2
jnz @f
mov eax, Y1
cmp eax, Y2
jz fin


@@: mov eax, var_14
shl eax, 1
mov var_18, eax
mov eax, 0
sub eax, var_8
cmp var_18, eax
jle @f
mov eax, var_14
sub eax, var_8
mov var_14, eax
mov eax, X1
add eax, var_C
mov X1, eax

@@: mov eax, X1
cmp eax, X2
jnz @f
mov eax, Y1
cmp eax, Y2
jnz @f
imul eax, Y1,ScreenWidth
add eax, X1 ; eax = Y1 * ScreenWidth + X1
mov buffer1[eax], 5;color=5
jmp fin


@@: mov eax, var_18
cmp eax, var_4
jge loc_40162F
mov eax, var_14
add eax, var_4
mov var_14, eax
mov eax, Y1
add eax, var_10
mov Y1, eax
jmp loc_40162F
fin: ret
BresLine endp


WinProc proc hWnd:dword,Msg:dword,wParam:dword,lParam:dword
local hdc:dword
local ps:PAINTSTRUCT

mov eax, Msg
dec eax;cmp eax,WM_CREATE
jz wmCREATE
        dec eax;cmp eax,WM_DESTROY
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 cdIdTimer ; uIDEvent
push hWnd
call _imp__KillTimer@8
push hOldBmp
push hBackDC
call _imp__SelectObject@8
mov hGDITmp, eax
push bufBMP ; HGDIOBJ
call _imp__DeleteObject@4
push hBackDC ; HDC
call _imp__DeleteDC@4
push hOldDIB ; HGDIOBJ
push bufDIBDC ; HDC
call _imp__SelectObject@8
mov hGDITmp, eax
push bufDIBDC ; HDC
call _imp__DeleteDC@4
push hMainDIB ; HGDIOBJ
call _imp__DeleteObject@4
push hWnd
call _imp__DestroyWindow@4
push ebx ; nExitCode
call _imp__ExitProcess@4


wmCREATE: push hWnd
call _imp__GetDC@4
mov hdc, eax
push eax ; HDC
call _imp__CreateCompatibleDC@4
mov bufDIBDC, eax
push ebx ; DWORD
push ebx ; HANDLE
push offset pMainDIB
push ebx ; UINT
push offset bi       ; BITMAPINFO *
push hdc ; HDC
call _imp__CreateDIBSection@24
mov hMainDIB, eax
push eax ; HGDIOBJ
push bufDIBDC ; HDC
call _imp__SelectObject@8
mov hOldDIB, eax
push hdc
push hWnd
call _imp__ReleaseDC@8
call Init
push ebx ; lpTimerFunc
push 40 ; uElapse
push cdIdTimer ; nIDEvent
push hWnd
call _imp__SetTimer@16
jmp wmBYE

wmTIMER: push ebx ; bErase
push ebx ; lpRect
push hWnd
call _imp__InvalidateRect@12
jmp wmBYE


wmPAINT: lea eax,ps
push eax ; lpPaint
push hWnd
call _imp__BeginPaint@8
mov hdc, eax
call PintaObjeto
push SRCCOPY
push ebx ; int
push ebx ; int
push bufDIBDC ; HDC
push 190h ; int
push ScreenWidth ; int
push ebx ; int
push ebx ; int
push hdc ; HDC
call _imp__BitBlt@36
lea eax,ps
push eax ; lpPaint
push hWnd
call _imp__EndPaint@8
wmBYE: ret
WinProc endp


sub_401BC7 proc arg_0:dword
local i:dword

mov i,ScreenWidth*ScreenHeight-1
@@: mov eax, arg_0
add eax, i
mov cl, byte ptr [eax]
test cl, cl
jz loc_401C6D
mov edx, i
shl edx, 2
add edx, pMainDIB

movzx eax, cl
shl eax, 2
add eax, offset miPaleta
assume eax: ptr stPaleta
                movzx ecx, byte ptr [eax].Rojo
shl ecx, 10h
                mov ch, byte ptr [eax].Verde
                mov cl, byte ptr [eax].Azul
assume eax: nothing
mov [edx], ecx

loc_401C6D: dec i
jns @b

ret
sub_401BC7 endp


KochTree proc X1:qword,Y1:qword,X2:qword,Y2:qword,Nivel:qword

local XX1:qword
local YY1:qword
local XX2:qword
local YY2:qword
local XX3:qword
local YY3:qword
local XX4:qword
local YY4:qword
local XVector:qword
local YVector:qword
local var_54:dword
local var_58:dword
local XVector2:qword
local YVector2:qword
local Temp:qword

fld Nivel
fldz            ;Nivel > 0 ?
fucompp
fnstsw ax
test ah, 5
jnz @@KOCH_ELSE
fld X1
push eax
fistp dword ptr [esp]
pop var_54
fld Y1
push ecx
fistp dword ptr [esp]
pop var_58
fld X2
push edx
fistp dword ptr [esp]
pop edx
fld Y2
push eax
fistp dword ptr [esp]
pop eax
push offset buffer1
push 5
push eax    ;=Y2
push edx    ;=X2
push var_58 ;=Y1
push var_54 ;=X1
call BresLine
jmp @@KOCH_FIN


@@KOCH_ELSE: fld X2     ;st(0)=X2
fsub X1     ;st(0)=X2-X1
fst XVector;XVector=X2-X1
                fadd st,st 
fstp XVector2;st(0)=2*XVector

fld Y2     ;st(0)=Y2
fsub Y1     ;st(0)=Y2-Y1
fst YVector;YVector=Y2-Y1
                fadd st,st
fstp YVector2 ;st(0)=2*YVector

fld const3
fdivr XVector;st(0)=XVector/3
fadd X1     ;st(0)=X1+XVector/3
fstp XX1    ;XX1=X1+XVector/3
fld const3
fdivr YVector;st(0)=YVector/3
fadd Y1     ;st(0)=Y1+YVector/3
fstp YY1    ;YY1=Y1+YVector/3
fld const2
fdivr XVector;st(0)=XVector/2
fadd X1     ;st(0)=X1+XVector/2
fstp XX2    ;XX2=X1+XVector/2
fld const2
fdivr YVector;st(0)=YVector/2
fadd Y1     ;st(0)=Y1+YVector/2
fstp YY2    ;YY2=Y1+YVector/2

fld const3
fdivr XVector2 ;st(0)=2*XVector/3
fadd X1     ;st(0)=X1+2*XVector/3
fstp XX3    ;XX3=X1+2*XVector/3

fld const3
fdivr YVector2;st(0)=2*YVector/3
fadd Y1    ;st(0)=Y1+2*YVector/3
fstp YY3   ;YY3=Y1+2*YVector/3
fld constSQRT3x2
fdivr YVector;st(0)=YVector/(2*SQRT(3))
fsubr XX2    ;st(0)=XX2-YVector/(2*SQRT(3))
fstp XX4    ;XX4=XX2-YVector/(2*SQRT(3))
fld constSQRT3x2
fdivr XVector;st(0)=XVector/(2*SQRT(3))
fsubr YY2    ;st(0)=YY2-XVector/(2*SQRT(3))
fstp YY4    ;YY4=YY2-XVector/(2*SQRT(3))
fld1
fsubr Nivel
fstp    Temp
push dword ptr Temp+4
                push dword ptr Temp
push dword ptr YY1+4
push dword ptr YY1
push dword ptr XX1+4
push dword ptr XX1
push dword ptr Y1+4
push dword ptr Y1
push dword ptr X1+4
push dword ptr X1
call KochTree
push dword ptr Temp+4
                push dword ptr Temp
push dword ptr YY4+4
push dword ptr YY4
push dword ptr XX4+4
push dword ptr XX4
push dword ptr YY1+4
push dword ptr YY1
push dword ptr XX1+4
push dword ptr XX1
call KochTree
push dword ptr Temp+4
                push dword ptr Temp
push dword ptr YY3+4
push dword ptr YY3
push dword ptr XX3+4
push dword ptr XX3
push dword ptr YY4+4
push dword ptr YY4
push dword ptr XX4+4
push dword ptr XX4
call KochTree
push dword ptr Temp+4
                push dword ptr Temp
push dword ptr Y2+4
push dword ptr Y2
push dword ptr X2+4
push dword ptr X2
push dword ptr YY3+4
push dword ptr YY3
push dword ptr XX3+4
push dword ptr XX3
call KochTree

@@KOCH_FIN: ret
KochTree endp


sub_401FE0 proc arg_0:dword 
local var_4:dword
local var_8:dword
local var_C:dword

mov var_4, 0
mov eax, arg_0
imul eax, 10
add eax, offset buffer3+2
movsx eax, word ptr [eax]
add eax, 1
shl eax, 9
mov ecx, arg_0
imul ecx, 10
add ecx, offset buffer3+2
movsx ecx, word ptr [ecx]
add ecx, 1
shl ecx, 7
add eax, ecx
mov ecx, arg_0
imul ecx, 10
add ecx, offset buffer3
movsx ecx, word ptr [ecx]
add eax, ecx
mov var_C, eax
mov eax, arg_0
imul eax, 10
add eax, offset buffer3+2
movsx eax, word ptr [eax]
add eax, 1
mov var_8, eax

loc_402068: mov eax, offset buffer1
add eax, var_C
movzx ecx, byte ptr [eax]
cmp ecx, 5
jz loc_4020B7
mov eax, offset buffer1
add eax, var_C
movzx ecx, byte ptr [eax]
cmp ecx, 5
jnz loc_4020C2


loc_4020B7: mov eax, var_8
mov var_4, eax
jmp loc_4020D0


loc_4020C2: sub var_C, ScreenWidth
dec var_8
jnz   loc_402068


loc_4020D0: mov eax, var_4

leave
retn 4
sub_401FE0 endp
Title: Re: AOW32
Post by: Mikl__ on November 23, 2015, 10:46:15 PM
asm-file part #2
Code: [Select]
sub_4020DA proc arg_0:dword 
local var_4:dword
local var_8:dword

mov eax, arg_0
imul eax, 10
add eax, offset buffer3+6
mov var_4, eax
call _imp__rand
and eax,0Fh
shl eax, 1
add eax, offset word_404004
movsx ecx, word ptr [eax]
mov eax, var_4
mov [eax], cx
mov eax, arg_0
imul eax, 10
add eax, offset buffer3+8
mov var_8, eax
call _imp__rand
and eax,0Fh
shl eax, 1
add eax, offset word_404024
movsx ecx, word ptr [eax]
mov eax, var_8
mov [eax], cx
leave
retn 4
sub_4020DA endp


sub_402156 proc arg_0:dword,arg_4:dword
local var_4:dword
local var_8:dword
local var_C:dword

mov eax, arg_0
imul eax, 10
add eax, offset buffer3
mov var_4, eax
call _imp__rand
mov ecx, 27Fh
cdq
idiv ecx
mov eax, var_4
mov [eax], dx
mov eax, arg_0
imul eax, 10
add eax, offset buffer3+2
mov var_8, eax
mov eax, arg_4
cmp eax, 0
mov eax, 0
setz al
test eax, eax
jnz loc_4021CE


loc_4021BB: call _imp__rand
mov ecx, arg_4
sub ecx, 1
cdq
idiv ecx
jmp loc_4021D5


loc_4021CE: xor eax, eax
cdq ;edx=0

loc_4021D5: mov eax, var_8
mov [eax], dx
mov eax, arg_0
imul eax, 10
add eax, offset buffer3+4
mov var_C, eax
call _imp__rand
and eax, 3
inc eax
mov ecx, var_C
mov [ecx], ax
push arg_0
call sub_4020DA
ret
sub_402156 endp

sub_402217 proc arg_0:dword 
local var_4:dword
local var_8:dword
local var_C:dword
local var_10:dword

mov eax, arg_0
imul eax, 10
add eax, offset buffer3+2
movsx eax, word ptr [eax]
shl eax, 9
mov ecx, arg_0
imul ecx, 10
add ecx, offset buffer3+2
movsx ecx, word ptr [ecx]
shl ecx, 7
add eax, ecx
mov ecx, arg_0
imul ecx, 10
add ecx, offset buffer3
movsx ecx, word ptr [ecx]
add eax, ecx
mov var_4, eax
mov eax, offset buffer2
add eax, var_4
mov ecx, var_4
add ecx, 1
mov edx, offset buffer2
add edx, ecx
mov ecx, var_4
add ecx, ScreenWidth
mov var_8, eax
mov eax, offset buffer2
add eax, ecx
mov ecx, var_4
add ecx, 281h
mov var_C, edx
mov edx, offset buffer2
add edx, ecx
mov ecx, arg_0
mov var_10, eax
imul ecx, 10;eax
add ecx, offset buffer3+4
movsx ecx, word ptr [ecx]
mov [edx], cl
mov eax, var_10
mov [eax], cl
mov eax, var_C
mov [eax], cl
mov eax, var_8
mov [eax], cl
leave
retn 4
sub_402217 endp

sub_4022ED proc
local var_4:dword
local var_8:dword
local var_10:dword

mov var_4, 0
loc_4022FF: push 390
push var_4
call sub_402156
push var_4
call sub_401FE0
mov var_8, eax
cmp eax, 0
jle loc_402379
mov eax, var_4
imul eax, 10
add eax, offset buffer3+2
mov var_10, eax
call _imp__rand
mov ecx, var_8
sar ecx, 2
cdq
idiv ecx
mov eax, var_10
mov [eax], dx

loc_402379: push var_4
call sub_402217
inc var_4
                cmp var_4,1000
jl loc_4022FF

locret_402387: leave
retn
sub_4022ED endp

Init proc
push dword ptr CNivel+4
push dword ptr CNivel
push dword ptr CY2+4
push dword ptr CY2
push dword ptr CX2+4
push dword ptr CX2
push dword ptr CY1+4
push dword ptr CY1
push dword ptr CX1+4
push dword ptr CX1
call KochTree
call sub_4022ED
retn
Init endp






sub_4023F7 proc arg_0:dword
local var_4:dword
local var_8:dword

mov var_4, 0
mov var_8, 0
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 6
movsx eax, word ptr [ecx]
cmp eax, 0
jle loc_4024AF
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
movsx eax, word ptr [ecx]
add eax, 1
cmp eax, ScreenWidth
jge loc_402498
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
movsx eax, word ptr [ecx]
mov edx, eax
add eax, 1
mov [ecx], ax
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 6
movsx eax, word ptr [ecx]
mov edx, eax
dec eax
mov [ecx], ax
jmp loc_4024AA


loc_402498: mov eax, 0
push eax
mov eax, arg_0
push eax
call sub_402156
loc_4024AA: jmp loc_40254F


loc_4024AF: mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 6
movsx eax, word ptr [ecx]
cmp eax, 0
jge loc_402547
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
movsx eax, word ptr [ecx]
cmp eax, 0
jle loc_402530
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
movsx eax, word ptr [ecx]
mov edx, eax
dec eax
mov [ecx], ax
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 6
movsx eax, word ptr [ecx]
mov edx, eax
add eax, 1
mov [ecx], ax
jmp loc_402542


loc_402530: mov eax, 0
push eax
mov eax, arg_0
push eax
call sub_402156
loc_402542: jmp loc_40254F


loc_402547: mov eax, 1
mov var_4, eax

loc_40254F: mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 8
movsx eax, word ptr [ecx]
cmp eax, 0
jle loc_4025F3
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 2
movsx eax, word ptr [ecx]
add eax, 1
cmp eax, 186h
jge loc_4025DC
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 2
movsx eax, word ptr [ecx]
mov edx, eax
add eax, 1
mov [ecx], ax
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 8
movsx eax, word ptr [ecx]
mov edx, eax
dec eax
mov [ecx], ax
jmp loc_4025EE


loc_4025DC: mov eax, 0
push eax
mov eax, arg_0
push eax
call sub_402156
loc_4025EE: jmp loc_402699


loc_4025F3: mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 8
movsx eax, word ptr [ecx]
cmp eax, 0
jge loc_402691
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 2
movsx eax, word ptr [ecx]
cmp eax, 0
jle loc_40267A
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 2
movsx eax, word ptr [ecx]
mov edx, eax
dec eax
mov [ecx], ax
mov eax, arg_0
mov ecx, 0Ah
imul eax, ecx
mov ecx, offset buffer3
add ecx, eax
add ecx, 8
movsx eax, word ptr [ecx]
mov edx, eax
inc eax
mov [ecx], ax
jmp loc_40268C


loc_40267A: push ebx
push arg_0
call sub_402156
loc_40268C: jmp loc_402699


loc_402691: mov var_8, 1

loc_402699: cmp var_4, 1
jnz locret_4026BD
cmp var_8, 1
jnz locret_4026BD
push arg_0
call sub_4020DA

locret_4026BD: leave
retn 4
sub_4023F7 endp


sub_4026BF proc

local var_4:dword

mov ecx,ScreenHeight*ScreenWidth/4
xor eax,eax
mov edi,offset buffer2
rep stosd
mov var_4, 0
loc_4026EB: push var_4
call sub_4023F7
push var_4
call sub_401FE0
cmp eax, 0
jle loc_40273F
push ebx
push var_4
call sub_402156
loc_40273F: push var_4
call sub_402217
inc var_4
cmp var_4,3E8h
jl loc_4026EB

locret_40274D: leave
retn
sub_4026BF endp

PintaObjeto proc
mov ecx,ScreenHeight*ScreenWidth*4/4
xor eax,eax
mov edi,pMainDIB
rep stosd
call sub_4026BF
push offset buffer2
call sub_401BC7
push offset buffer1
call sub_401BC7
retn
PintaObjeto endp

sub_402E27 proc arg_0:dword,arg_4:dword,arg_8:dword
local var_4:dword
local var_8:dword
local var_C:dword

mov eax, arg_0
mov ecx, arg_4
mov var_8, eax
mov var_4, ecx
cmp arg_8, 20h
jl loc_402E6C
mov eax, arg_8
sub eax, 20h
mov ecx, var_8
mov var_C, ecx
mov ecx, eax
mov eax, var_C
shl eax, cl
mov var_4, eax
mov var_8, 0
jmp loc_402E9F


loc_402E6C: cmp arg_8, 0
jz loc_402E9F
mov eax, var_4
mov ecx, arg_8
shl eax, cl
mov ecx, 20h
sub ecx, arg_8
mov edx, var_8
shr edx, cl
or eax, edx
mov var_4, eax
mov eax, var_8
mov ecx, arg_8
shl eax, cl
mov var_8, eax

loc_402E9F: mov eax, var_8
mov edx, var_4

leave
retn
sub_402E27 endp
;-----------------------------------------------------------------
.data
word_404004 dw 7, 0FFF9h, 6, 0FFFAh, 5, 0FFFBh, 4, 0FFFCh, 3, 0FFFDh
dw 2, 0FFFEh, 1, 0FFFFh, 0, 1
word_404024 dw 4, 2, 3, 1, 2, 0, 1, 2, 2 dup(3), 2, 4, 1, 0FFFFh, 2 dup(0)
wTitle db 'Nevada - (c) abreojosensamblador.net',0
const3 dq 3.0
const2 dq 2.0
constSQRT3x2 dq 3.464101615137754;sqrt(3)=1,7320508075688772935274463415059*2
CNivel dq 5.0
CY2 dq 390.0
CX2 dq 639.0
CY1 dq 390.0
CX1 dq 0.0
db 8 dup(0)
db 1Ah dup(0)
byte_404180 db 10h dup(0), 98h, 42h, 0Eh dup(0), 0F4h, 41h, 2 dup(0)
db 0F4h, 42h, 0Eh dup(0), 50h, 42h, 2 dup(0), 4, 43h, 0Eh dup(0)
db 60h, 42h, 2 dup(0), 20h, 43h, 0Eh dup(0), 7Ch, 42h
db 16h dup(0)

dd 4347h, 435Ah, 4369h, 4375h, 4383h, 4394h, 43A2h, 43B4h
dd 43C1h, 43D0h, 43DEh, 43F1h, 4404h, 4410h, 4422h, 442Ah
dd 4436h, 4441h, 4452h, 445Fh, 446Ah, 447Ah, 0, 4498h
dd 44ABh, 44BDh, 0, 44D9h, 44E8h, 44F7h, 4502h, 4517h
dd 452Ah, 0, 453Eh, 4547h, 454Eh, 455Fh, 456Ch, 4573h
dd 92h dup(0)
bi BITMAPINFOHEADER <sizeof BITMAPINFOHEADER,ScreenWidth,-ScreenHeight,1,32,0>
miPaleta stPaleta <0>,<43,43,43>,<85,85,85>,<128,128,128>,<171,171,171>,<255,255,255>
.data?
buffer3 db 10000 dup(?)
buffer1 db ScreenHeight*ScreenWidth dup(?)
buffer2 db ScreenHeight*ScreenWidth dup(?)
bufDIBDC dd ?
hBackDC dd ?
hMainDIB dd ?
bufBMP dd ?
hOldBmp dd ?
hGDITmp dd ?
hOldDIB dd ?
pMainDIB dd ?
end start
bat-file
Code: [Select]
cls
set filename=%1
set masm_path=c:\masm32
if exist %filename%.exe del %filename%.exe
%masm_path%\bin\ml /c /Cp /Gz /I%masm_path%\include /coff /nologo %filename%.asm  || exit
%masm_path%\bin\link /SUBSYSTEM:WINDOWS /LIBPATH:%masm_path%\lib /NOLOGO %filename%.obj
del %filename%.obj
Title: Re: AOW32
Post by: Mikl__ on November 25, 2015, 02:48:28 PM
Program was made slightly smaller and were added meaningful names for procedures and for labels. There is original program in attachment NevadaWC01.zip
asm-file
Code: [Select]
; masm windows gui #
.686
.model flat, stdcall
option casemap :none
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\gdi32.lib
includelib c:\masm32\lib\msvcrt.lib
include c:\masm32\include\windows.inc
extern _imp__RegisterClassA@4:dword
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__DeleteObject@4:dword
extern _imp__DeleteDC@4:dword
extern _imp__DestroyWindow@4:dword
extern _imp__DefWindowProcA@16:dword
extern _imp__DispatchMessageA@4:dword
extern _imp__EndPaint@8:dword
extern _imp__ExitProcess@4:dword
extern _imp__GetMessageA@16:dword
extern _imp__GetDC@4:dword
extern _imp__InvalidateRect@12:dword
extern _imp__KillTimer@8:dword
extern _imp__rand:dword
extern _imp__ReleaseDC@8:dword
extern _imp__SetTimer@16:dword
extern _imp__SelectObject@8:dword
.code
cdXPos          equ 131
cdYPos          equ 217
ScreenHeight equ 400;+50
ScreenWidth     equ 640 ;ScreenHeight*1.6
cdIdTimer       equ 1
DIB_RGB_COLORS  equ 0
SnowLevel       equ ScreenHeight-10
stPaleta struct
  Azul db ?
  Verde db ?
  Rojo db ?
  Alfa db ?
stPaleta ends
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 WinProc
push ebx
push esp ; lpWndClass
call _imp__RegisterClassA@4
push ebx    
push esi
push ebx
push ebx
push ScreenHeight+25
push ScreenWidth
push cdYPos
push cdXPos
push WS_VISIBLE
push edi; szWinTitle
push edi; lpszClassName
push ebx ; dwExStyle
call _imp__CreateWindowExA@48
mov ebp,esp

message_loop: push ebx  ;                       
push ebx
push ebx
push ebp
call _imp__GetMessageA@16
        cmp [ebp+MSG.wParam],VK_ESCAPE ;press "Esc"? without TranslateMessage
jz wmDESTROY
push ebp
call _imp__DispatchMessageA@4       
jmp message_loop

CopyPoint proc arg_0:dword,arg_4:dword

mov esi, arg_0
                mov edi, arg_4
movsd
ret
CopyPoint endp

sub_401421 proc X1:dword,Y1:dword,X2:dword

mov eax, X1
cmp eax, X2
jbe @f
lea eax, X2
push eax
lea eax, X1
push eax
call CopyPoint
@@: imul eax, Y1,ScreenWidth
add eax, X1
mov edx, eax ; edx = Y1 * ScreenWidth + X1
xor ecx, ecx
@@: mov eax, X2
sub eax, X1
cmp ecx, eax
ja fin
mov buffer1[ecx+edx], 5 ; color = 5
inc ecx
jmp @b
fin: ret
sub_401421 endp


sub_4014A3 proc X1:dword,Y1:dword,Y2:dword

mov eax, Y1
cmp eax, Y2
jbe @f
lea eax, Y2
push eax
lea eax, Y1
push eax
call CopyPoint
@@: imul    eax, Y1,ScreenWidth
add eax, X1
mov edx, eax ;edx = Y1 * ScreenWidth + X1
xor ecx, ecx
@@: mov eax, Y2
sub eax, Y1
cmp ecx, eax
ja fin
mov buffer1[edx], 5;color
add edx, ScreenWidth
inc ecx
jmp @b
fin: ret
sub_4014A3 endp





BresLine proc X1:dword,Y1:dword,X2:dword,Y2:dword
local DeltaX:dword
local DeltaY:dword
local Xinc:dword
local Yinc:dword
local Error:dword


mov eax, Y1
cmp eax, Y2
jnz @f
push X2
push Y1
push X1
call sub_401421
jmp fin

@@: mov eax, X1
cmp eax, X2
jnz @f
push Y2
push Y1
push X1
call sub_4014A3
jmp fin

@@: mov eax, X2
sub eax, X1
cdq
xor eax,edx
sub eax,edx
mov DeltaX, eax  ; DeltaX = |X2 - X1|
or edx,1
mov Xinc, edx    ; if X2 - X1 >= 0  Xinc=1 else Xinc= -1

mov eax, Y2
sub eax, Y1
cdq
xor eax,edx      ; if edx = -1 not(eax)
sub eax,edx      ; if edx = -1 neg(eax) = not(eax)-(-1)
mov DeltaY, eax  ; DeltaY = |Y2 - Y1|
or edx,1
                mov Yinc, edx    ; if Y2 - Y1 >= 0  Yinc=1 else Yinc= -1

mov eax, DeltaX
sub eax, DeltaY
mov Error, eax

bucle: imul eax, Y1,ScreenWidth
add eax, X1      ; eax = Y1 * ScreenWidth + X1
mov buffer1[eax], 5;color
mov eax, X1
cmp eax, X2
jnz @f
mov eax, Y1
cmp eax, Y2
jz fin

@@: mov eax, Error
shl eax, 1
add eax,DeltaY
jle @f
mov eax, Error
sub eax, DeltaY
mov Error, eax
mov eax, X1
add eax, Xinc
mov X1, eax

@@: mov eax, X1
cmp eax, X2
jnz @f
mov eax, Y1
cmp eax, Y2
jnz @f
imul eax, Y1,ScreenWidth
add eax, X1 ; eax = Y1 * ScreenWidth + X1
mov buffer1[eax], 5;color=5
jmp fin


@@: mov eax, Error
shl eax,1
cmp eax, DeltaX
jge bucle
mov eax, Error
add eax, DeltaX
mov Error, eax
mov eax, Y1
add eax, Yinc
mov Y1, eax
jmp bucle
fin: ret
BresLine endp


WinProc proc hWnd:dword,Msg:dword,wParam:dword,lParam:dword
local hdc:dword
local ps:PAINTSTRUCT

mov eax, Msg
dec eax;cmp eax,WM_CREATE
jz wmCREATE
        dec eax;cmp eax,WM_DESTROY
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 cdIdTimer ; uIDEvent
push hWnd
call _imp__KillTimer@8
push hOldBmp
push hBackDC
call _imp__SelectObject@8
mov hGDITmp, eax
push bufBMP ; HGDIOBJ
call _imp__DeleteObject@4
push hBackDC ; HDC
call _imp__DeleteDC@4
push hOldDIB ; HGDIOBJ
push bufDIBDC ; HDC
call _imp__SelectObject@8
mov hGDITmp, eax
push bufDIBDC ; HDC
call _imp__DeleteDC@4
push hMainDIB ; HGDIOBJ
call _imp__DeleteObject@4
push hWnd
call _imp__DestroyWindow@4
push ebx ; nExitCode
call _imp__ExitProcess@4


wmCREATE: push hWnd
call _imp__GetDC@4
mov hdc, eax
push eax ; HDC
call _imp__CreateCompatibleDC@4
mov bufDIBDC, eax
push ebx ; DWORD
push ebx ; HANDLE
push offset pMainDIB
push ebx ; UINT
push offset bi       ; BITMAPINFO *
push hdc ; HDC
call _imp__CreateDIBSection@24
mov hMainDIB, eax
push eax ; HGDIOBJ
push bufDIBDC ; HDC
call _imp__SelectObject@8
mov hOldDIB, eax
push hdc
push hWnd
call _imp__ReleaseDC@8
call Init
push ebx ; lpTimerFunc
push 40 ; uElapse
push cdIdTimer ; nIDEvent
push hWnd
call _imp__SetTimer@16
jmp wmBYE

wmTIMER: push ebx ; bErase
push ebx ; lpRect
push hWnd
call _imp__InvalidateRect@12
jmp wmBYE


wmPAINT: lea eax,ps
push eax ; lpPaint
push hWnd
call _imp__BeginPaint@8
mov hdc, eax
call PintaObjeto
push SRCCOPY
push ebx ; int
push ebx ; int
push bufDIBDC ; HDC
push ScreenHeight ; int
push ScreenWidth ; int
push ebx ; int
push ebx ; int
push hdc ; HDC
call _imp__BitBlt@36
lea eax,ps
push eax ; lpPaint
push hWnd
call _imp__EndPaint@8
wmBYE: ret
WinProc endp


sub_401BC7 proc arg_0:dword

mov edx,ScreenWidth*ScreenHeight-1
bucle: mov eax, arg_0
movzx ecx, byte ptr [eax+edx]
test ecx, ecx
jz @f
lea eax, miPaleta[ecx*4]
assume eax: ptr stPaleta
                movzx ecx, byte ptr [eax].Rojo
shl ecx, 10h
                mov ch, byte ptr [eax].Verde
                mov cl, byte ptr [eax].Azul
assume eax: nothing
mov eax, pMainDIB
mov [eax+edx*4], ecx

@@: dec edx
jns bucle

ret
sub_401BC7 endp


KochTree proc X1:qword,Y1:qword,X2:qword,Y2:qword,Nivel:dword

local XX1:qword
local YY1:qword
local XX2:qword
local YY2:qword
local XX3:qword
local YY3:qword
local XX4:qword
local YY4:qword
local XVector:qword
local YVector:qword
local XVector2:qword
local YVector2:qword
local Temp:dword

cmp Nivel,0
jnz @@KOCH_ELSE
fld Y2
push eax
fistp dword ptr [esp]
fld X2
push eax
fistp dword ptr [esp]
fld Y1
push eax
fistp dword ptr [esp]
fld X1
push eax
fistp dword ptr [esp]
call BresLine
jmp @@KOCH_FIN


@@KOCH_ELSE: fld X2     ;st(0)=X2
fsub X1     ;st(0)=X2-X1
fst XVector;XVector=X2-X1
                fadd st,st 
fstp XVector2;st(0)=2*XVector

fld Y2     ;st(0)=Y2
fsub Y1     ;st(0)=Y2-Y1
fst YVector;YVector=Y2-Y1
                fadd st,st
fstp YVector2 ;st(0)=2*YVector

fld const3
fdivr XVector;st(0)=XVector/3
fadd X1     ;st(0)=X1+XVector/3
fstp XX1    ;XX1=X1+XVector/3
fld const3
fdivr YVector;st(0)=YVector/3
fadd Y1     ;st(0)=Y1+YVector/3
fstp YY1    ;YY1=Y1+YVector/3
fld1
fadd st,st  ;st(0)=2
fdivr XVector;st(0)=XVector/2
fadd X1     ;st(0)=X1+XVector/2
fstp XX2    ;XX2=X1+XVector/2
fld1
fadd st,st  ;st(0)=2
fdivr YVector;st(0)=YVector/2
fadd Y1     ;st(0)=Y1+YVector/2
fstp YY2    ;YY2=Y1+YVector/2

fld const3
fdivr XVector2 ;st(0)=2*XVector/3
fadd X1     ;st(0)=X1+2*XVector/3
fstp XX3    ;XX3=X1+2*XVector/3

fld const3
fdivr YVector2;st(0)=2*YVector/3
fadd Y1     ;st(0)=Y1+2*YVector/3
fstp YY3    ;YY3=Y1+2*YVector/3
fld constSQRT3x2
fdivr YVector;st(0)=YVector/(2*SQRT(3))
fsubr XX2    ;st(0)=XX2-YVector/(2*SQRT(3))
fstp XX4    ;XX4=XX2-YVector/(2*SQRT(3))
fld constSQRT3x2
fdivr XVector;st(0)=XVector/(2*SQRT(3))
fsubr YY2    ;st(0)=YY2-XVector/(2*SQRT(3))
fstp YY4    ;YY4=YY2-XVector/(2*SQRT(3))
mov eax,Nivel
            dec eax
            mov Temp,eax
            push eax
push dword ptr YY1+4
push dword ptr YY1
push dword ptr XX1+4
push dword ptr XX1
push dword ptr Y1+4
push dword ptr Y1
push dword ptr X1+4
push dword ptr X1
call KochTree
push Temp
push dword ptr YY4+4
push dword ptr YY4
push dword ptr XX4+4
push dword ptr XX4
push dword ptr YY1+4
push dword ptr YY1
push dword ptr XX1+4
push dword ptr XX1
call KochTree
push Temp
push dword ptr YY3+4
push dword ptr YY3
push dword ptr XX3+4
push dword ptr XX3
push dword ptr YY4+4
push dword ptr YY4
push dword ptr XX4+4
push dword ptr XX4
call KochTree
push Temp
push dword ptr Y2+4
push dword ptr Y2
push dword ptr X2+4
push dword ptr X2
push dword ptr YY3+4
push dword ptr YY3
push dword ptr XX3+4
push dword ptr XX3
call KochTree

@@KOCH_FIN: ret
KochTree endp


sub_401FE0 proc arg_0:dword 

mov eax, arg_0
imul eax, 10
movsx ecx, word ptr buffer3[eax]
movsx eax, word ptr buffer3[eax+2]
inc eax
                mov edx, eax
imul eax, ScreenWidth
add eax, ecx

bucle: cmp byte ptr buffer1[eax],5
jz @f
sub eax, ScreenWidth
dec edx
jnz    bucle
@@: mov eax,edx
ret
sub_401FE0 endp

sub_4020DA proc arg_0:dword 
local var_4:dword

mov eax, arg_0
imul eax, 10
add eax, offset buffer3+6
mov var_4, eax
call _imp__rand
and eax,0Fh
mov cx, word_404004[eax*2]
mov eax, var_4
mov [eax], cx
call _imp__rand
and eax,0Fh
mov cx, word_404024[eax*2]
mov eax, var_4
mov [eax+2], cx
ret
sub_4020DA endp


sub_402156 proc arg_0:dword,arg_4:dword
local var_4:dword

mov eax, arg_0
imul eax, 10
add eax, offset buffer3
mov var_4, eax
call _imp__rand
mov ecx, ScreenWidth-1
cdq
idiv ecx
mov eax, var_4
mov [eax], dx
or eax,eax ;eax = 0 ?
mov eax, 0
setz al
test eax, eax
jnz @f
call _imp__rand
mov ecx, arg_4
dec ecx
cdq
idiv ecx
jmp loc_4021D5


@@: xor eax, eax
cdq ;edx=0

loc_4021D5: mov eax, var_4
mov [eax+2], dx
call _imp__rand
and eax, 3
inc eax
mov ecx, var_4
mov [ecx+4], ax
push arg_0
call sub_4020DA
ret
sub_402156 endp

sub_402217 proc arg_0:dword 

mov eax, arg_0
imul eax, 10
                mov dl, buffer3[eax+4]
                movsx ecx, word ptr buffer3[eax]
movsx eax, word ptr buffer3[eax+2]
inc eax
imul eax,ScreenWidth    ;eax=(y+1)*ScreenWidth
add eax, ecx           ;eax=(y+1)*ScreenWidth+x
add eax, offset buffer2
mov [eax+1], dl
mov [eax], dl
mov [eax-ScreenWidth+1], dl
mov [eax-ScreenWidth], dl
ret
sub_402217 endp

sub_4022ED proc
local var_4:dword
local var_8:dword
local var_10:dword

mov var_4,999
bucle: push SnowLevel
push var_4
call sub_402156
push var_4
call sub_401FE0
mov var_8, eax
or eax, eax
jz @f
mov eax, var_4
imul eax, 10
add eax, offset buffer3+2
mov var_10, eax
call _imp__rand
mov ecx, var_8
sar ecx, 2
cdq
idiv ecx
mov eax, var_10
mov [eax], dx

@@: push var_4
call sub_402217
dec var_4
jns bucle

ret
sub_4022ED endp

Init proc
push 5; nesting level = 5
push dword ptr CY2+4
push dword ptr CY2
push dword ptr CX2+4
push dword ptr CX2
push dword ptr CY1+4
push dword ptr CY1
push dword ptr CX1+4
push dword ptr CX1
call KochTree
call sub_4022ED
retn
Init endp


sub_4023F7 proc arg_0:dword
local var_4:dword
local var_8:dword
local var_C:dword

mov var_4, 0
mov var_8, 0
mov eax, arg_0
imul eax, 10
add eax, offset buffer3
mov var_C,eax
movsx ecx, word ptr [eax+6]
cmp ecx, 0
jle loc_4024AF
movsx ecx, word ptr [eax]
inc ecx
cmp ecx, ScreenWidth
jge loc_402498
mov [eax], cx
movsx ecx, word ptr [eax+6]
dec ecx
mov [eax+6], cx
jmp @f

loc_402498: push ebx
push arg_0
call sub_402156
jmp @f

loc_4024AF: mov ecx, var_C
movsx eax, word ptr [ecx+6]
cmp eax, 0
jge loc_402547
movsx eax, word ptr [ecx]
cmp eax, 0
jle loc_402530
dec eax
mov [ecx], ax
movsx eax, word ptr [ecx+6]
mov edx, eax
inc eax
mov [ecx+6], ax
jmp @f

loc_402530: push ebx
push arg_0
call sub_402156
jmp @f

loc_402547: mov eax, 1
mov var_4, eax

@@: mov ecx, var_C
movsx eax, word ptr [ecx+8]
cmp eax, 0
jle loc_4025F3
movsx eax, word ptr [ecx+2]
inc eax
cmp eax, SnowLevel
jge loc_4025DC
movsx eax, word ptr [ecx+2]
inc eax
mov [ecx+2], ax
movsx eax, word ptr [ecx+8]
dec eax
mov [ecx+8], ax
jmp @f

loc_4025DC: push ebx
push arg_0
call sub_402156
jmp @f

loc_4025F3: mov ecx, var_C
movsx eax, word ptr [ecx+8]
cmp eax, 0
jge loc_402691
movsx eax, word ptr [ecx+2]
cmp eax, 0
jle loc_40267A
movsx eax, word ptr [ecx+2]
dec eax
mov [ecx+2], ax
movsx eax, word ptr [ecx+8]
inc eax
mov [ecx+8], ax
jmp @f

loc_40267A: push ebx
push arg_0
call sub_402156
jmp @f

loc_402691: mov var_8, 1

@@: cmp var_4, 1
jnz fin
cmp var_8, 1
jnz fin
push arg_0
call sub_4020DA
fin: ret
sub_4023F7 endp


sub_4026BF proc

local var_4:dword

mov ecx,ScreenHeight*ScreenWidth/4
xor eax,eax
mov edi,offset buffer2
rep stosd
mov var_4, 999
bucle: push var_4
call sub_4023F7
push var_4
call sub_401FE0
or eax, eax
jz @f
push ebx
push var_4
call sub_402156
@@:       push var_4
call sub_402217
dec var_4
jns bucle
            ret
sub_4026BF endp

PintaObjeto proc
mov ecx,ScreenHeight*ScreenWidth*4/4
xor eax,eax
mov edi,pMainDIB
rep stosd
call sub_4026BF
push offset buffer2
call sub_401BC7
push offset buffer1
call sub_401BC7
retn
PintaObjeto endp
;-----------------------------------------------------------------
.data
word_404004 dw 7, 0FFF9h, 6, 0FFFAh, 5, 0FFFBh, 4, 0FFFCh, 3, 0FFFDh
dw 2, 0FFFEh, 1, 0FFFFh, 0, 1
word_404024 dw 4, 2, 3, 1, 2, 0, 1, 2, 2 dup(3), 2, 4, 1, 0FFFFh, 2 dup(0)
wTitle db 'Nevada - (c) abreojosensamblador.net',0
const3 dq 3.0
constSQRT3x2 dq 3.464101615137754;sqrt(3)=1,7320508075688772935274463415059*2
CY2 dq 390.0 ;SnowLevel
CX2 dq 639.0 ;ScreenWidth-1
CY1 dq 390.0 ;SnowLevel
CX1 dq 0.0
db 8 dup(0)
db 1Ah dup(0)
byte_404180 db 10h dup(0), 98h, 42h, 0Eh dup(0), 0F4h, 41h, 2 dup(0)
db 0F4h, 42h, 0Eh dup(0), 50h, 42h, 2 dup(0), 4, 43h, 0Eh dup(0)
db 60h, 42h, 2 dup(0), 20h, 43h, 0Eh dup(0), 7Ch, 42h
db 16h dup(0)

dd 4347h, 435Ah, 4369h, 4375h, 4383h, 4394h, 43A2h, 43B4h
dd 43C1h, 43D0h, 43DEh, 43F1h, 4404h, 4410h, 4422h, 442Ah
dd 4436h, 4441h, 4452h, 445Fh, 446Ah, 447Ah, 0, 4498h
dd 44ABh, 44BDh, 0, 44D9h, 44E8h, 44F7h, 4502h, 4517h
dd 452Ah, 0, 453Eh, 4547h, 454Eh, 455Fh, 456Ch, 4573h
dd 92h dup(0)
bi BITMAPINFOHEADER <sizeof BITMAPINFOHEADER,ScreenWidth,-ScreenHeight,1,32,0>
miPaleta stPaleta <0>,<43,43,43>,<85,85,85>,<128,128,128>,<171,171,171>,<255,255,255>
.data?
buffer3 db 10000 dup(?)
buffer1 db ScreenHeight*ScreenWidth dup(?)
buffer2 db ScreenHeight*ScreenWidth dup(?)
bufDIBDC dd ?
hBackDC dd ?
hMainDIB dd ?
bufBMP dd ?
hOldBmp dd ?
hGDITmp dd ?
hOldDIB dd ?
pMainDIB dd ?
end start
Title: Re: AOW32
Post by: Mikl__ on November 27, 2015, 06:25:30 PM
Code: [Select]
; masm windows gui #
.686
.model flat, stdcall
option casemap :none
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\msvcrt.lib
extern _imp__RegisterClassA@4:dword
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__DeleteObject@4:dword
extern _imp__DeleteDC@4:dword
extern _imp__DestroyWindow@4:dword
extern _imp__DefWindowProcA@16:dword
extern _imp__DispatchMessageA@4:dword
extern _imp__EndPaint@8:dword
extern _imp__ExitProcess@4:dword
extern _imp__GetMessageA@16:dword
extern _imp__GetDC@4:dword
extern _imp__InvalidateRect@12:dword
extern _imp__KillTimer@8:dword
extern _imp__rand:dword
extern _imp__ReleaseDC@8:dword
extern _imp__SetTimer@16:dword
extern _imp__SelectObject@8:dword
.code
cdXPos          equ 131
cdYPos          equ 217
ScreenHeight equ 400;+50
ScreenWidth     equ 640 ;ScreenHeight*1.6
cdIdTimer       equ 1
DIB_RGB_COLORS  equ 0
SnowLevel       equ ScreenHeight-10
stPaleta struct
  Azul db ?
  Verde db ?
  Rojo db ?
  Alfa db ?
stPaleta ends
RECT STRUCT
  left    dd      ?
  top     dd      ?
  right   dd      ?
  bottom  dd      ?
RECT ENDS
POINT STRUCT
  x  DWORD ?
  y  DWORD ?
POINT ENDS
PAINTSTRUCT STRUCT
  hdc           DWORD      ?
  fErase        DWORD      ?
  rcPaint       RECT       <>
  fRestore      DWORD      ?
  fIncUpdate    DWORD      ?
  rgbReserved   BYTE 32 dup(?)
PAINTSTRUCT ENDS
MSG STRUCT
  hwnd      DWORD      ?
  message   DWORD      ?
  wParam    DWORD      ?
  lParam    DWORD      ?
  time      DWORD      ?
  pt        POINT      <>
MSG ENDS
BITMAPINFOHEADER STRUCT
  biSize            DWORD      ?
  biWidth           DWORD      ?
  biHeight          DWORD      ?
  biPlanes          WORD       ?
  biBitCount        WORD       ?
  biCompression     DWORD      ?
  biSizeImage       DWORD      ?
  biXPelsPerMeter   DWORD      ?
  biYPelsPerMeter   DWORD      ?
  biClrUsed         DWORD      ?
  biClrImportant    DWORD      ?
BITMAPINFOHEADER ENDS
BLACK_PEN                            equ 7
WS_VISIBLE                           equ 10000000h
WM_DESTROY                           equ 2
WM_PAINT                             equ 0Fh
WM_TIMER                             equ 113h
SRCCOPY                              equ 0CC0020h
VK_ESCAPE                            equ 1Bh

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 WinProc
push ebx
push esp ; lpWndClass
call _imp__RegisterClassA@4
push ebx    
push esi
push ebx
push ebx
push ScreenHeight+30
push ScreenWidth
push cdYPos
push cdXPos
push WS_VISIBLE
push edi; szWinTitle
push edi; lpszClassName
push ebx ; dwExStyle
call _imp__CreateWindowExA@48
mov ebp,esp

message_loop: push ebx  ;                       
push ebx
push ebx
push ebp
call _imp__GetMessageA@16
        cmp [ebp+MSG.wParam],VK_ESCAPE ;press "Esc"?
jz wmDESTROY
push ebp
call _imp__DispatchMessageA@4       
jmp message_loop


; We construct a line on Bresenham algorithm
BresLine proc X1:dword,Y1:dword,X2:dword,Y2:dword
local DeltaX:dword
local DeltaY:dword
local Xinc:dword
local Yinc:dword
local Error:dword


mov eax, X1
cmp eax, X2   ; X1 = X2 ?
jnz a1
;VertLine---------------------------------------------------
mov ecx, Y2               
cmp ecx, Y1   ; Y2 > Y1 ?
jnbe @f
lea esi, Y1
                lea edi, Y2
movsd
@@: imul    edi, Y1,ScreenWidth
add edi, X1
add edi, offset fir_trees_buffer;edi = Y1 * ScreenWidth + X1 + &fir_trees_buffer
mov al, 5  ;color of fir-tres
                mov ecx, Y2
sub ecx, Y1
inc ecx
@@: stosb          ; Draw a vertical line in fir_tres_buffer
add edi, ScreenWidth-1
loop @b
;-----------------------------------------------------
jmp fin

a1: mov eax, X2
sub eax, X1
cdq
xor eax,edx
sub eax,edx
mov DeltaX, eax  ; DeltaX = |X2 - X1|
or edx,1
mov Xinc, edx    ; if X2 - X1 >= 0  Xinc=1 else Xinc= -1

mov eax, Y2
sub eax, Y1
cdq
xor eax,edx      ; if edx = -1 not(eax)
sub eax,edx      ; if edx = -1 neg(eax) = not(eax)-(-1)
mov DeltaY, eax  ; DeltaY = |Y2 - Y1|
or edx,1
                mov Yinc, edx    ; if Y2 - Y1 >= 0  Yinc=1 else Yinc= -1

mov eax, DeltaX
sub eax, DeltaY
mov Error, eax   ; Error = DeltaX - DeltaY

bucle: imul eax, Y1,ScreenWidth
add eax, X1      ; eax = Y1 * ScreenWidth + X1
mov fir_trees_buffer[eax], 5;color
mov eax, X1
cmp eax, X2      ; X1 = X2 ?
jnz @f
mov eax, Y1
cmp eax, Y2      ; Y1 = Y2 ?
jz fin

@@: mov eax, Error
shl eax, 1
add eax,DeltaY   ;2*Error >= -DeltaY ?
jle @f
mov eax, Error
sub eax, DeltaY
mov Error, eax   ;Error = Error + DeltaY
mov eax, X1
add eax, Xinc
mov X1, eax      ;X1 = X1 + Xinc

@@: mov eax, X1      ;X1 = X2 ?
cmp eax, X2
jnz @f
mov eax, Y1      ;Y1 = Y2 ?
cmp eax, Y2
jnz @f
imul eax, Y1,ScreenWidth
add eax, X1      ;eax = Y1 * ScreenWidth + X1
mov fir_trees_buffer[eax],5 ;fir-tres color=5
jmp fin

@@: mov eax, Error
shl eax,1
cmp eax, DeltaX  ;2*Error >= DeltaX ?
jge bucle
mov eax, Error
add eax, DeltaX
mov Error, eax   ;Error = Error + DeltaX
mov eax, Y1
add eax, Yinc
mov Y1, eax      ;Y1 = Y1 + Yinc
jmp bucle
fin: ret
BresLine endp


WinProc proc hWnd:dword,Msg:dword,wParam:dword,lParam:dword
local ps:PAINTSTRUCT
local i:dword

mov eax, Msg
dec eax;cmp eax,WM_CREATE
jz wmCREATE
        dec eax;cmp eax,WM_DESTROY
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 cdIdTimer ; uIDEvent
push hWnd
call _imp__KillTimer@8
push hOldBmp
push hBackDC
call _imp__SelectObject@8
mov hGDITmp, eax
push bufBMP ; HGDIOBJ
call _imp__DeleteObject@4
push hBackDC ; HDC
call _imp__DeleteDC@4
push hOldDIB ; HGDIOBJ
push bufDIBDC ; HDC
call _imp__SelectObject@8
mov hGDITmp, eax
push bufDIBDC ; HDC
call _imp__DeleteDC@4
push hMainDIB ; HGDIOBJ
call _imp__DeleteObject@4
push hWnd
call _imp__DestroyWindow@4
push ebx ; nExitCode
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
push ebx ; UINT
push offset bi       ; BITMAPINFO *
push ps.hdc ; HDC
call _imp__CreateDIBSection@24
mov hMainDIB, eax
push eax ; HGDIOBJ
push bufDIBDC ; HDC
call _imp__SelectObject@8
mov hOldDIB, eax
push ps.hdc
push hWnd
call _imp__ReleaseDC@8
;Init-----------------------------------------------------
push 5; nesting level = 5
push CY2
push CX2
push CY1
push CX1
call KochTree
call sub_4022ED
;---------------------------------------------------------
push ebx ; lpTimerFunc
push 40 ; uElapse
push cdIdTimer ; nIDEvent
push hWnd
call _imp__SetTimer@16
jmp wmBYE

wmTIMER: push ebx ; bErase
push ebx ; lpRect
push hWnd
call _imp__InvalidateRect@12
jmp wmBYE

wmPAINT: lea eax,ps
push eax ; lpPaint
push hWnd
call _imp__BeginPaint@8
;PintaObjeto--------------------------------------------
mov ecx,ScreenHeight*ScreenWidth
xor eax,eax
mov edi,pMainDIB
rep stosd         ;Clear buffer pMainDIB
;--------------------------------------------------------
mov ecx,ScreenHeight*ScreenWidth/4
xor eax,eax
mov edi,offset snow_buffer
rep stosd      ; Clear snow_buffer
;--------------------------------------------------------
mov i, 999
bucle0: push i
call sub_4023F7
push i
call sub_401FE0
or eax, eax
jz @f
push ebx
push i
call sub_402156
@@:       push i
call sub_402217
dec i
jns bucle0
;draw snowfall--------------------------------------------
mov ecx,ScreenWidth*ScreenHeight
bucle1: movzx edx, snow_buffer[ecx-1]
test edx, edx
jz @f
lea eax, miPaleta[edx*4]
assume eax: ptr stPaleta
                movzx edx, byte ptr [eax].Rojo
shl edx, 10h
                mov dh, byte ptr [eax].Verde
                mov dl, byte ptr [eax].Azul
;color = miPaleta[i].Azul + (miPaleta[i].Verde<<8) + (miPaleta[i].Rojo<<16)
assume eax: nothing
mov eax, pMainDIB
mov [eax+ecx*4-4], edx
@@: loop bucle1
;draw fir-trees-------------------------------------------
mov ecx,ScreenWidth*ScreenHeight
mov eax, pMainDIB
bucle2: cmp fir_trees_buffer[ecx-1],0
jz @f
mov dword ptr [eax+ecx*4-4],0FFFFFFh
@@: loop bucle2
;--------------------------------------------------
push SRCCOPY
push ebx ; int
push ebx ; int
push bufDIBDC ; HDC
push ScreenHeight ; int
push ScreenWidth ; int
push ebx ; int
push ebx ; int
push ps.hdc ; HDC
call _imp__BitBlt@36
lea eax,ps
push eax ; lpPaint
push hWnd
call _imp__EndPaint@8
wmBYE: ret
WinProc endp


KochTree proc X1:dword,Y1:dword,X2:dword,Y2:dword,Nivel:dword

local XX1:dword
local YY1:dword
local XX2:dword
local YY2:dword
local XX3:dword
local YY3:dword
local XX4:dword
local YY4:dword
local XVector:dword
local YVector:dword
local XVector2:dword
local YVector2:dword
local Temp:dword

cmp Nivel,0
jnz @@KOCH_ELSE
push Y2
push X2
push Y1
push X1
call BresLine
jmp @@KOCH_FIN


@@KOCH_ELSE: fild X2     ;st(0)=X2
fisub X1     ;st(0)=X2-X1
fst XVector;XVector=X2-X1
                fadd st,st 
fstp XVector2;st(0)=2*XVector

fild Y2     ;st(0)=Y2
fisub Y1     ;st(0)=Y2-Y1
fst YVector;YVector=Y2-Y1
                fadd st,st
fstp YVector2 ;st(0)=2*YVector

fld const3
fld st     ;st(0)=st(1)=3
fld st     ;st(0)=st(1)=st(2)=3
fld st     ;st(0)=st(1)=st(2)=st(3)=3
fdivr XVector;st(0)=XVector/3
fiadd X1     ;st(0)=X1+XVector/3
fistp XX1    ;XX1=X1+XVector/3
               ;st(0)=3
fdivr YVector;st(0)=YVector/3
fiadd Y1     ;st(0)=Y1+YVector/3
fistp YY1    ;YY1=Y1+YVector/3
fld1
fadd st,st  ;st(0)=2
fdivr XVector;st(0)=XVector/2
fiadd X1     ;st(0)=X1+XVector/2
fstp XX2    ;XX2=X1+XVector/2
fld1
fadd st,st  ;st(0)=2
fdivr YVector;st(0)=YVector/2
fiadd Y1     ;st(0)=Y1+YVector/2
fstp YY2    ;YY2=Y1+YVector/2
               ;st(0)=3
fdivr XVector2 ;st(0)=2*XVector/3
fiadd X1     ;st(0)=X1+2*XVector/3
fistp XX3    ;XX3=X1+2*XVector/3
               ;st(0)=3
fdivr YVector2;st(0)=2*YVector/3
fiadd Y1     ;st(0)=Y1+2*YVector/3
fistp YY3    ;YY3=Y1+2*YVector/3
fld constSQRT3x2
fld st     ;st(0)=st(1)=2*SQRT(3)
fdivr YVector;st(0)=YVector/(2*SQRT(3))
fsubr XX2    ;st(0)=XX2-YVector/(2*SQRT(3))
fistp XX4    ;XX4=XX2-YVector/(2*SQRT(3))
               ;st(0)=2*SQRT(3)
fdivr XVector;st(0)=XVector/(2*SQRT(3))
fsubr YY2    ;st(0)=YY2-XVector/(2*SQRT(3))
fistp YY4    ;YY4=YY2-XVector/(2*SQRT(3))
mov eax,Nivel
            dec eax
            mov Temp,eax
            push eax
push YY1
push XX1
push Y1
push X1
call KochTree
push Temp
push YY4
push XX4
push YY1
push XX1
call KochTree
push Temp
push YY3
push XX3
push YY4
push XX4
call KochTree
push Temp
push Y2
push X2
push YY3
push XX3
call KochTree

@@KOCH_FIN: ret
KochTree endp


sub_401FE0 proc arg_0:dword 

mov eax, arg_0
imul eax, 10
movsx edx, word ptr buffer3[eax]
movsx eax, word ptr buffer3[eax+2]
inc eax
                mov ecx, eax
imul eax, ScreenWidth
add eax, edx
bucle: cmp byte ptr fir_trees_buffer[eax],5
jz @f
sub eax, ScreenWidth
loop bucle
@@: mov eax,ecx
ret
sub_401FE0 endp

sub_4020DA proc arg_0:dword 
local var_4:dword

mov eax, arg_0
imul eax, 10
add eax, offset buffer3+6
mov var_4, eax
call _imp__rand
and eax,0Fh
mov cx, word_404004[eax*2]
mov eax, var_4
mov [eax], cx
call _imp__rand
and eax,0Fh
mov cx, word_404024[eax*2]
mov eax, var_4
mov [eax+2], cx
ret
sub_4020DA endp


sub_402156 proc arg_0:dword,arg_4:dword
local var_4:dword

mov eax, arg_0
imul eax, 10
add eax, offset buffer3
mov var_4, eax
call _imp__rand
mov ecx, ScreenWidth-1
cdq
idiv ecx
mov eax, var_4
mov [eax], dx
or eax,eax ;eax = 0 ?
jz @f
call _imp__rand
mov ecx, arg_4
dec ecx
cdq
idiv ecx
jmp loc_4021D5

@@: xor eax, eax
cdq ;edx=0

loc_4021D5: mov eax, var_4
mov [eax+2], dx
call _imp__rand
and eax, 3
inc eax
mov ecx, var_4
mov [ecx+4], ax
push arg_0
call sub_4020DA
ret
sub_402156 endp

sub_402217 proc arg_0:dword 

mov eax, arg_0
imul eax, 10
                mov dl, buffer3[eax+4]
                movsx ecx, word ptr buffer3[eax]
movsx eax, word ptr buffer3[eax+2]
inc eax
imul eax,ScreenWidth    ;eax=(y+1)*ScreenWidth
add eax, ecx           ;eax=(y+1)*ScreenWidth+x
add eax, offset snow_buffer
mov [eax+1], dl
mov [eax], dl
mov [eax-ScreenWidth+1], dl
mov [eax-ScreenWidth], dl
ret
sub_402217 endp

sub_4022ED proc
local var_4:dword
local var_8:dword
local var_10:dword

mov var_4,999
bucle: push SnowLevel
push var_4
call sub_402156
push var_4
call sub_401FE0
mov var_8, eax
or eax, eax
jz @f
mov eax, var_4
imul eax, 10
add eax, offset buffer3+2
mov var_10, eax
call _imp__rand
mov ecx, var_8
sar ecx, 2
cdq
idiv ecx
mov eax, var_10
mov [eax], dx

@@: push var_4
call sub_402217
dec var_4
jns bucle

ret
sub_4022ED endp


sub_4023F7 proc arg_0:dword
local var_4:dword
local var_8:dword
local var_C:dword

mov var_4, 0
mov var_8, 0
mov eax, arg_0
imul eax, 10
add eax, offset buffer3
mov var_C,eax
cmp word ptr [eax+6], 0
jle loc_4024AF
movsx ecx, word ptr [eax]
inc ecx
cmp ecx, ScreenWidth
jge loc_402498
mov [eax], cx
movsx ecx, word ptr [eax+6]
dec ecx
mov [eax+6], cx
jmp @f

loc_402498: push ebx
push arg_0
call sub_402156
jmp @f

loc_4024AF: mov ecx, var_C
cmp word ptr [ecx+6], 0
jge loc_402547
movsx eax, word ptr [ecx]
cmp eax, 0
jle loc_402530
dec eax
mov [ecx], ax
movsx eax, word ptr [ecx+6]
mov edx, eax
inc eax
mov [ecx+6], ax
jmp @f

loc_402530: push ebx
push arg_0
call sub_402156
jmp @f

loc_402547: mov var_4, 1

@@: mov ecx, var_C
cmp word ptr [ecx+8], 0
jle loc_4025F3
movsx eax, word ptr [ecx+2]
inc eax
cmp eax, SnowLevel
jge loc_4025DC
movsx eax, word ptr [ecx+2]
inc eax
mov [ecx+2], ax
movsx eax, word ptr [ecx+8]
dec eax
mov [ecx+8], ax
jmp @f

loc_4025DC: push ebx
push arg_0
call sub_402156
jmp @f

loc_4025F3: mov ecx, var_C
cmp word ptr [ecx+8], 0
jge loc_402691
cmp word ptr [ecx+2], 0
jle loc_40267A
movsx eax, word ptr [ecx+2]
dec eax
mov [ecx+2], ax
movsx eax, word ptr [ecx+8]
inc eax
mov [ecx+8], ax
jmp @f

loc_40267A: push ebx
push arg_0
call sub_402156
jmp @f

loc_402691: mov var_8, 1

@@: cmp var_4, 1
jnz fin
cmp var_8, 1
jnz fin
push arg_0
call sub_4020DA
fin: ret
sub_4023F7 endp
;-----------------------------------------------------------------
.data
word_404004 dw 7,-7, 6,-6, 5,-5, 4,-4, 3,-3, 2,-2, 1,-1, 0, 1
word_404024 dw 4, 2, 3, 1, 2, 0, 1, 2, 3, 3, 2, 4, 1,-1, 0, 0
wTitle db 'Nevada - (c) abreojosensamblador.net',0
const3 dq 3.0
constSQRT3x2 dq 3.464101615137754;sqrt(3)=1,7320508075688772935274463415059*2
CY2 dd SnowLevel
CX2 dd ScreenWidth-1
CY1 dd SnowLevel
CX1 dd 0
bi BITMAPINFOHEADER <sizeof BITMAPINFOHEADER,ScreenWidth,-ScreenHeight,1,32,0>
miPaleta stPaleta <0>,<43,43,43>,<85,85,85>,<128,128,128>,<171,171,171>,<255,255,255>
.data?
buffer3 db 10000 dup(?)
fir_trees_buffer db ScreenHeight*ScreenWidth dup(?)
snow_buffer db ScreenHeight*ScreenWidth dup(?)
bufDIBDC dd ?
hBackDC dd ?
hMainDIB dd ?
bufBMP dd ?
hOldBmp dd ?
hGDITmp dd ?
hOldDIB dd ?
pMainDIB dd ?
end start
Title: Re: AOW32
Post by: Mikl__ on December 01, 2015, 06:26:21 PM
asm-file
Code: [Select]
; masm windows gui #
.686
.model flat, stdcall
option casemap :none
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\gdi32.lib
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__InvalidateRect@12:dword
extern _imp__RegisterClassA@4:dword
extern _imp__ReleaseDC@8:dword
extern _imp__SelectObject@8:dword

cdXPos          equ 128
cdYPos          equ 128
cdYSize         equ 400
cdXSize         equ 640
cdNumColores    equ 256
cdNMax          equ 100
stPaleta struct
  Azul db ?
  Verde db ?
  Rojo db ?
  Alfa db ?
stPaleta ends
RECT STRUCT
  left    dd      ?
  top     dd      ?
  right   dd      ?
  bottom  dd      ?
RECT ENDS
POINT STRUCT
  x  DWORD ?
  y  DWORD ?
POINT ENDS
PAINTSTRUCT STRUCT
  hdc           DWORD      ?
  fErase        DWORD      ?
  rcPaint       RECT       <>
  fRestore      DWORD      ?
  fIncUpdate    DWORD      ?
  rgbReserved   BYTE 32 dup(?)
PAINTSTRUCT ENDS
MSG STRUCT
  hwnd      DWORD      ?
  message   DWORD      ?
  wParam    DWORD      ?
  lParam    DWORD      ?
  time      DWORD      ?
  pt        POINT      <>
MSG ENDS
BITMAPINFOHEADER STRUCT
  biSize            DWORD      ?
  biWidth           DWORD      ?
  biHeight          DWORD      ?
  biPlanes          WORD       ?
  biBitCount        WORD       ?
  biCompression     DWORD      ?
  biSizeImage       DWORD      ?
  biXPelsPerMeter   DWORD      ?
  biYPelsPerMeter   DWORD      ?
  biClrUsed         DWORD      ?
  biClrImportant    DWORD      ?
BITMAPINFOHEADER ENDS
BLACK_PEN                            equ 7
WS_VISIBLE                           equ 10000000h
WM_DESTROY                           equ 2
WM_PAINT                             equ 0Fh
WM_TIMER                             equ 113h
SRCCOPY                              equ 0CC0020h
VK_ESCAPE                            equ 1Bh
.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+35
push cdXSize+5
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 ps:PAINTSTRUCT

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

wmDESTROY:: 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
push ps.hdc
push hWnd
call _imp__ReleaseDC@8
mov edi, offset miPaleta
mov ecx, cdNumColores
xor eax, eax
rep stosd
mov cl,16
sub edi,16*4
Bucle: assume edi: ptr stPaleta
mov [edi+ecx*4-68].Verde,al
mov [edi+ecx*4-68].Rojo, 0FCh
mov [edi+ecx*4-4].Rojo, al
assume edi: nothing
add al,16
loop Bucle
call CreaFractal
jmp wmBYE


wmPAINT: push esp ; 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
push esp ; lpPaint
push hWnd
call _imp__EndPaint@8

wmBYE: ret
WndProc endp


CreaFractal proc
local y:dword 
local x:dword 
local v:dword 
local u:dword 
local CurrY:dword 
local CurrX:dword 
local Color:dword 


mov ecx,cdYSize     ;y-Contador
                fld const4          ;st(0)=4
Bucle_Y: push ecx
fild dword ptr [esp] ;st(0) = yCont
push cdYSize
fidiv dword ptr [esp] ;st(0) = yCont/cdYSize
add esp, 8
fadd st,st ;st(0) = YRDif*yCont/cdYSize
fadd cfYRMin         ;st(0) = YRDif*yCont/cdYSize +cfYRMin
fstp CurrY ;CurrY = YRDif*yCont/cdYSize +cfYRMin
mov edx,cdXSize     ; x-Contador

Bucle_X: push edx
fild dword ptr [esp] ;st(0) = xCont
push cdXSize
fidiv dword ptr [esp] ;st(0) = xCont/cdXSize
add esp, 8
fmul XRDif ;st(0) = XRDif*xCont/cdXSize
fadd cfXRMin         ;st(0) = XRDif*xCont/cdXSize +cfXRMin
fstp CurrX           ;CurrX = XRDif*xCont/cdXSize +cfXRMin
mov x, 0
mov y, 0            ; x = y = 0
mov Color, cdNumColores
mov esi, cdNMax               
Bucle_I: fld y               ;st(0)=y
fmul st, st          ;st(0)=y*y
fld x               ;st(0)=x
fmul st, st          ;st(0)=x*x
fsubrp st(1), st       ;st(0)=x*x - y*y
fadd CurrX           ;st(0)=x*x - y*y + CurrX
fst u               ;u=x*x - y*y + CurrX
fmul st, st          ;st(0)=u*u
fld y               ;st(0)=y
fmul x               ;st(0)=y*x
fadd st, st          ;st(0)=2*y*x
fadd CurrY           ;st(0)=2*y*x+CurrY
fst v               ;v=2*y*x+CurrY
fst y               ;y=v
fmul st, st          ;st(0)=v*v
faddp st(1), st       ;st(0)=u*u + v*v
fucomp ;u*u + v*v > 4 ?
fnstsw ax
test ah,45h
jz Exit_BI
mov eax, u
mov x, eax          ;x=u
dec Color
dec esi
jnz Bucle_I

Exit_BI:        mov eax, Color
mov eax, miPaleta[eax*4]
imul esi,ecx,cdXSize
lea esi,[esi+edx-cdXSize-1]               
mov edi, pMainDIB
mov [edi+esi*4], eax
dec edx
jnz Bucle_X
dec ecx
jnz Bucle_Y
leave
retn
CreaFractal endp
;-------------------------------------------------------------------------
.data
wTitle db 'Fractal de Mandelbrot - (c) abreojosensamblador.net',0
bi BITMAPINFOHEADER <sizeof BITMAPINFOHEADER,cdXSize,-cdYSize,1,32,0>   
cfYRMin dd -1.0
cfXRMin dd -2.0
const4 dd 4.0
XRDif dd 2.6
.data?
bufDIBDC dd ?
pMainDIB dd ?
hMainDIB dd ?
hOldBmp dd ?
hOldDIB dd ?
miPaleta stPaleta cdNumColores dup(<?>)
end start
Title: Re: AOW32
Post by: hutch-- on December 22, 2015, 11:15:05 AM
This one does look really slick.  :t
Title: Re: AOW32
Post by: dedndave on December 23, 2015, 12:04:31 AM
man del brat

(https://cdn3.vox-cdn.com/thumbor/tZ_q1Hpo-UN9_okNdOAW8xECo8w=/198x0:1278x720/2400x1600/cdn0.vox-cdn.com/uploads/chorus_image/image/47229656/CHHEEESEEE.0.0.0.jpg)
Title: Re: AOW32
Post by: guga on December 25, 2015, 08:09:30 AM
 :icon_mrgreen: :greensml: :greensml:
Title: Re: AOW32
Post by: dedndave on December 28, 2015, 12:21:06 AM
only in america - lol

the mandelbrot does look nice   :t

one of my little christmas presents was a 64-bit laptop
so, when i get some time to play, i can work with 64-bit code   :biggrin:
Title: Re: AOW32
Post by: Siekmanski on December 28, 2015, 08:06:11 AM
Dave, that's a nice little christmas present.  :t
Title: Re: AOW32
Post by: caballero on September 12, 2016, 06:06:23 PM
Hello, I have reopened AOW32 (http://abreojosensamblador.net/Productos/AOW32_/). There are a lot of new things, but it is heavily in progress, so many things still missing. Almost everything is in Spanish, the English part is quite outdated. Though it is in asm and c, TinyC is the central and many asm versions are still missing, until I have time to complete it.
Title: Re: AOW32
Post by: caballero on September 19, 2016, 06:11:08 PM
Added tab controls (http://abreojosensamblador.net/Productos/AOW32_/html/Pags/Cap03.html#TabControls) examples with resources and with CreateWindowEx. Updated also the navigation menu. The English version keeps on beeing outdated.

 :eusa_boohoo:Viva la fiesta (https://www.youtube.com/watch?v=1c1vNEb3k-8)
Title: Re: AOW32
Post by: jj2007 on September 19, 2016, 06:48:59 PM
Added tab controls (http://abreojosensamblador.net/Productos/AOW32_/html/Pags/Cap03.html#TabControls) examples

When I click on "codigo Masm", http://abreojosensamblador.net/Productos/AOW32_/html/Codigos/Cap03/Masm/TabbedWM01.asm shows just publicity.
Title: Re: AOW32
Post by: caballero on September 19, 2016, 06:52:26 PM
I'm sorry. It's not publicity, it's just that there's no masm version yet, so appears the 1&1 page telling you that there's no such page. There are many of the code in asm already but specially the latest one is just only in TinyC, when I have time I will make the English version and the asm versions.
Title: Re: AOW32
Post by: jj2007 on September 19, 2016, 07:34:15 PM
I see. Peter Redei's example (3.1.6. Más botones en la barra del título) is also very nice :t

Re 3.1.7.7. Tab Controls, perhaps you should add the rc file, too.
Title: Re: AOW32
Post by: caballero on September 19, 2016, 07:48:28 PM
another example (http://abreojosensamblador.net/Productos/AOW32_/html/Pags/Cap06.html#GetWindowDC) drawing bitmaps on title bar
(http://abreojosensamblador.net/Productos/AOW32_/html/Imags/Cap06/Fig_06_03.png)
I have to see how to attach the work to be downloable
Title: Re: AOW32
Post by: jj2007 on September 19, 2016, 08:55:00 PM
another example (http://abreojosensamblador.net/Productos/AOW32_/html/Pags/Cap06.html#GetWindowDC) drawing bitmaps on title bar

Try moving the window. GetWindowDC is a great function, but I needed some extra acrobatics to make the RichMasm menus (http://masm32.com/board/index.php?topic=5314.0) work on Win7. Especially with Aero themes there is no chance to use GetWindowDC :(
Title: Re: AOW32
Post by: caballero on September 19, 2016, 09:29:38 PM
Yes. It's not easy to make them work. It seems that it is not recommeded to put such a things on title bar, so I have not worked much on them, I put them just as a curiosity. More over when at last you have achieved them working, and int the next Windows version they don't work at all.

To do such things, it is best to create your own title bar (http://www.abreojosensamblador.net/Productos/AOW32_/html/Pags/Cap03.html#VentanasAMedida)
(http://www.abreojosensamblador.net/Productos/AOW32_/html/Imags/Cap03/Fig_03_14.png)
and then do whatever you want on it. As for Aero (http://www.abreojosensamblador.net/Productos/AOW32_/html/Pags/Cap03.html#DWM), it is very exciting, but is still in my tasks to be done.
(http://www.abreojosensamblador.net/Productos/AOW32_/html/Imags/Cap03/Fig_03_44.png)
Title: Re: AOW32
Post by: caballero on October 03, 2016, 06:59:39 PM
Hello, I have updated my win32 tuto/notes (http://www.abreojosensamblador.net/Productos/AOW32_/).
* Completed the navigation bar
* Added an example of multiple type mdi (http://www.abreojosensamblador.net/Productos/AOW32_/html/Pags/Cap03.html#MDIMultiple)
* Included source code of tiny raycast (http://www.abreojosensamblador.net/Productos/AOW32_/html/Pags/Cap06.html#RayCast)
* Included source code for Newton Raphson method (http://www.abreojosensamblador.net/Productos/AOW32_/html/Pags/Cap06.html#NewtonRaphson)
Title: Re: AOW32
Post by: caballero on January 04, 2017, 05:43:29 AM
If anyone interested, I have upgraded it to v0.1.4.
  + Chapter 6. Adding a GDI+ section.
  + Chapter 4. Adding text editors (only Edit, not Rich Edit)
  + Chapter 3. Adding a MDI text editor.
  + Chapter 5. Adding auxiliary modal/no modal windows.
  + Chapter 11. Adding to the dropdown menu the sections of this chapter.
  + Downloable (http://www.abreojosensamblador.net/Productos/AOW32_/html/Libro/AOW32.014.7z) the entire book.

AOW32 is far from finished, but I think that there are already many things. English version is yet obsolete, I will do it when I have time.
Title: Re: AOW32
Post by: caballero on March 07, 2017, 09:08:00 PM
Hello, I'm remodelling my web page (http://www.abreojosensamblador.net/Productos/AOE/Index_en.html) only with html and css, no javascript, and minimal image pics as possible. There's now a fixed header to have grouped and more accesible everything, anchors works fine even with the fixed header.

It's a work in progress, so many things are missed yet.

Web programming is also in my interest, hence I will dedicate some time to it as I have it  ;)

 :eusa_boohoo:zono moja (https://www.youtube.com/watch?v=J8t9d4TIVHQ)
Title: Re: AOW32
Post by: LordAdef on March 20, 2017, 09:34:48 PM
hi Caballero, nice! I will have a deeper look later.