News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

What am I doing wrong??

Started by bigrichlegend, September 28, 2006, 08:54:20 PM

Previous topic - Next topic

agathon

Hi,

Let me rephrase my previous request. What sequence of API calls would be necessary in order to print the image produced by this application?

Cordially,
RWM

six_L

#16
Hello,bigrichlegend
it isn't the maurer_rose. but it works.
.586
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\msimg32.inc

includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\msimg32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\macros\macros.asm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
ClassName db "MainWinClass",0
AppName db "Greadient",0
Rct RECT<0>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hWnd dd ?
Points dd 82 dup (?) 
ptrArr dd 2 dup (?)
   
crTRIVERTEX struct
x dword   ? 
y dword
Red word
Green word ?
Blue word ?
Alpha word    ? 
crTRIVERTEX ends

crGRADIENT_TRIANGLE struct
Vertex1 dword ?
Vertex2 dword ?
Vertex3 dword ?
crGRADIENT_TRIANGLE ends
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke GetModuleHandle, NULL
mov    hInstance,eax

invoke GetCommandLine
mov    CommandLine,eax

invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND

mov   wc.cbSize,SIZEOF WNDCLASSEX
mov   wc.style, CS_HREDRAW or CS_VREDRAW
mov   wc.lpfnWndProc, OFFSET WndProc
mov   wc.cbClsExtra,NULL
mov   wc.cbWndExtra,NULL
push  hInstance
pop   wc.hInstance
mov   wc.hbrBackground,COLOR_BTNFACE+1
mov   wc.lpszMenuName,NULL
mov   wc.lpszClassName,OFFSET ClassName

invoke LoadIcon,NULL,IDI_APPLICATION
mov   wc.hIcon,eax
mov   wc.hIconSm,eax

invoke LoadCursor,NULL,IDC_ARROW
mov   wc.hCursor,eax

invoke RegisterClassEx, addr wc
INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW,150,50,650,670,NULL,NULL,hInst,NULL
mov   hwnd,eax

invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd

.WHILE TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDW

mov     eax,msg.wParam
ret
WinMain endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WndProc proc hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL

.ELSEIF uMsg==WM_CREATE
m2m hWnd,hWin
invoke SetWindowText,hWin,SADD("Please click the left button of mouse")

.elseif uMsg==WM_LBUTTONDOWN
.data
r   dd 180.0
p   dd 3.1415926535897
pp  dd 0
     
.code
fld  dword ptr[p]
fdiv dword ptr[r]
fstp dword ptr[pp]
Call DrawGtadient
.ELSE
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
.ENDIF

xor eax,eax
ret
WndProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DrawGtadient proc uses ebx edi esi
LOCAL TV0 :crTRIVERTEX
LOCAL TV1 :crTRIVERTEX
LOCAL TV2 :crTRIVERTEX
LOCAL TV3 :crTRIVERTEX
LOCAL GradRect0 :crGRADIENT_TRIANGLE
LOCAL GradRect1 :crGRADIENT_TRIANGLE

LOCAL hDC :DWORD
LOCAL memDC :DWORD
LOCAL hBmp :DWORD

invoke GetClientRect,hWnd,ADDR Rct
invoke GetDC,hWnd
mov hDC,eax

invoke CreateCompatibleDC,hDC
mov memDC,eax

invoke CreateCompatibleBitmap,hDC,Rct.right,Rct.bottom
mov hBmp,eax

invoke SelectObject,memDC,hBmp

mov GradRect0.Vertex1,0
mov GradRect0.Vertex2,1
mov GradRect0.Vertex3,2

mov GradRect1.Vertex1,0
mov GradRect1.Vertex2,1
mov GradRect1.Vertex3,3

mov TV0.x, 0
mov TV0.y, 0
mov TV0.Red, 0f000h
mov TV0.Green, 00000h
mov TV0.Blue, 00000h

m2m TV1.x, Rct.right
m2m TV1.y, Rct.bottom
mov TV1.Red, 0f000h
mov TV1.Green, 0f000h ;D9D0C4
mov TV1.Blue, 00000h
mov TV1.Alpha, 0

mov TV2.x, 0
m2m TV2.y, Rct.bottom
mov TV2.Red, 0f000h
mov TV2.Green, 0f000h ;D9D0C4
mov TV2.Blue, 00000h
mov TV2.Alpha, 0

m2m TV3.x, Rct.right
mov TV3.y, 0
mov TV3.Red, 00000h
mov TV3.Green, 0f000h ;D9D0C4
mov TV3.Blue, 00000h
mov TV3.Alpha, 0

invoke GradientFill,memDC,ADDR TV3,4,ADDR GradRect1,2,2

call CalcPoints
mov ebx, offset Points
mov edi,0
mov esi,0
.while (esi<320)
.while (edi<320)
invoke MoveToEx, memDC,[ebx+esi],[ebx+esi+4],NULL
invoke LineTo,memDC,[ebx+edi],[ebx+edi+4]
add edi,8
.endw
add esi,8
mov edi,0
.endw

invoke BitBlt,hDC,0,0,Rct.right,Rct.bottom,memDC,0,0,SRCCOPY
invoke DeleteObject,hBmp
invoke DeleteDC,memDC
invoke ReleaseDC,hWnd,hDC

ret
DrawGtadient endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CalcPoints proc uses ebx esi edi
LOCAL radius:DWORD

.data
angel dq  0.0
pi dq  0.157079632679 ;pi/40   39744830961566084581988
.code
mov ebx, offset Points
mov edi, 41
mov eax, Rct.bottom
shr eax, 1
mov radius, eax
mov esi, eax

@Loop:
fld qword ptr [angel]
fsin
fimul dword ptr [radius]
fistp dword ptr [ebx]
neg dword ptr [ebx]
add dword ptr [ebx],esi

fld qword ptr [angel]
fcos
fimul dword ptr [radius]
fistp dword ptr [ebx+4]
add dword ptr [ebx+4],esi
fld qword ptr [angel]
fadd qword ptr [pi]
fstp qword ptr [angel]
add ebx,8
dec edi
jnz @Loop

ret

CalcPoints endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

end start

[edit for resizing]
regards

bigrichlegend

Cheers six_L. I do like this result. It does work. Now to decipher it 

stanhebben

Attached is the source code I used. (almost forgot it...)

[attachment deleted by admin]