Pris le même travail de tom 'circ_rotation.asm'

Contenu du snippet

Pris le même travail de TOM 'circ_rotation.asm'
Il se peut contrôler la posicion et je tourne avec le Mouse ou Touches de Cursor
Mouse droit il meut le centre relatif aux circulos
Boton Roue meut sur axe Z
Aqui s'a 2 circulos 'À' et 'B'
Q et E zoom de je circule 'À'
À et D zoom de je circule 'B'
Z et C distance entre les deux
Chaque je circule il a 63 points
ils se peuvent unir les points depuis un je circule à l'autre
en prenant points chaque vrai intervalle aléatoire

0 (Zéro) il centre des figures à inclinacion 0 degrés
C il centre en des valeurs initiales de TOM
W voir des données en fenêtre 'debug'
L il sélectionne deux intervalles aléatoires en 'À' et 'B' et il unit des points
...zoom De valeurs (voir des sources)

Commandos switch
G,H il n'efface pas écran par chaque tracé
P axes rouges bleu vert
S lineas visibles ou invisibles
T timer on,off
R rotacion aléatoire
...Voir le programme source

http://traductor.interbusca.com/espanol-frances/

Source / Exemple :


comment %
 +------------------------------ CODED BY ---------------------------------
 |       _______________       ____________       ________________
 |      /_____    _____/\     /  ______   /\     /  ____  ____   /\
 |      \___ /   / ____\/    /  /\____/  / /    /  / __/ / __/  / /
 |          /   / /         /  / /   /  / /    /  / / / / / /  / /
 |         /   / /         /  / /   /  / /    /  / / /_/ / /  / /
 |        /   / /         /  /_/___/  / /    /  / /  \_\/ /  / /
 |       /___/ /         /___________/ /    /__/ /       /__/ /
 |       \___\/          \___________\/     \__\/   !TOM¡\__\/
 |
 | # ## ### INFO ### ## #
 |
 | # Nom : FPU SAMPLE
 |
 | # Source : ASM 32bits
 |
 | # Date : Mai 2006
 |
 | # Site : WWW.TOM-ART.FR.ST
 |
 | # Mail : TOM-ART@FR.ST
 |
 | # Notes : Quelques exemples de divers utilisations du FPU en assembleur
 | dans le domaine des démos. Cube, cercle, rotation, calculs,...
 |
 |
 |
 +-------------------------------------------------------------------------
 %

 .486
 .model flat, stdcall
 option casemap :none

 ;Includes + Libs ; <***************************************************

 include \masm32\include\windows.inc
 include \masm32\include\masm32.inc
 include \masm32\include\gdi32.inc
 include \masm32\include\user32.inc
 include \masm32\include\kernel32.inc
 include \masm32\include\advapi32.inc
 include \masm32\include\Comctl32.inc
 include \masm32\include\comdlg32.inc
 include \masm32\include\shell32.inc
 include \masm32\include\oleaut32.inc
 include \masm32\include\ole32.inc
 include \masm32\include\dialogs.inc
 include \masm32\include\winmm.inc
 include \masm32\include\msimg32.inc

 includelib \masm32\lib\masm32.lib
 includelib \masm32\lib\gdi32.lib
 includelib \masm32\lib\user32.lib
 includelib \masm32\lib\kernel32.lib
 includelib \masm32\lib\advapi32.lib
 includelib \masm32\lib\Comctl32.lib
 includelib \masm32\lib\comdlg32.lib
 includelib \masm32\lib\shell32.lib
 includelib \masm32\lib\oleaut32.lib
 includelib \masm32\lib\ole32.lib
 includelib \masm32\lib\winmm.lib
 includelib \masm32\lib\msimg32.lib

 include \masm32\MACROS\MACROS.asm

include \masm32\include\debug.inc
includelib \masm32\lib\debug.lib

DBGWIN_DEBUG_ON = 1 ;turn it off if you don't want to include debug info into the program
DBGWIN_EXT_INFO = 0 ;turns off file name and line num

;Protos ; <************************************************************

 WinMain PROTO :DWORD, :DWORD, :DWORD, :DWORD
 WndProc PROTO :DWORD, :DWORD, :DWORD, :DWORD
 ver     PROTO :DWORD
 .CONST ; <*************************************************************

 PictureW equ 700
 PictureH equ 654

 TIMER1 equ 1
 
 .DATA ; <**************************************************************

 ClassName db "Win32asm_class",0
 DisplayName db " FPU SAMPLE by TOM .:. Press any key for rotation .:.",0

 MyRect RECT <0,0,PictureW,PictureH>
 MyRectTxt RECT <0, 0, 40, 16>			;box for number

 noir dd 0000000h

 camX REAL4 0.2
 camY REAL4 0.2
 camZ REAL4 1.0

 tempX REAL4 0.0
 tempY REAL4 0.0
 tempZ REAL4 0.0

 Xt REAL4 0.0
 Yt REAL4 0.0
 Zt REAL4 0.0

 ptX dd 0
 ptY dd 0

scale REAL4 0.08727 ;  5 degrees for rotations
scale_sum  REAL4 0.08727
scale_men  REAL4 -0.08727
scale_zero REAL4 0.00
grds  REAL4 57.29578

sw_move  dw 0
SW_Y dd 0
sw_axis dw 0
sw_timer dw 0
sw_Cerc dw 1
sw_Line dw 0
sw_Hole dw 0
x1      dw 0
y1      dw 0
x2      dw 0
y2      dw 0
x3      dw 0
y3      dw 0
z0      dw 0
xopc    dw 0

PictureW2 dd PictureW / 2
PictureH2 dd PictureH / 2

hPenW  dd  0
hPenX  dd  0

 rayon dd 120		; half of initial radius
 rayon1 dd  240
 rayon2 dd  240
 theta REAL4 0.0
 newtheta REAL4 0.0997 ; 1/63 of circunference
 num180 REAL4 180.00
 num360 REAL4 360.00

a63    dd  63+1
c12    dd  12
c1500  dd  12
rot1   dd  0
rot2   dd  0
rol1   dd  0
rol2   dd  0

axis   dd  100, 0, 0
	   dd  0, 100, 0
	   dd  0, 0, 100
	   
 ;pt dd 1000 dup (0,0,0)

 .DATA? ; <*************************************************************

 pt dd 1000 dup (?,?,?) 
  
 hInstance dd ?
 hmainDC   dd ?
 hmainbmp  dd ?
 temp1 dd ?
 temp2 dd ?
 temp3 dd ?
 buff  db  20 dup (?)
 
 .CODE ; <**************************************************************

 start:

	mov dword ptr buff, '    '
	mov dword ptr buff[4], '    '

 invoke GetModuleHandle, NULL
 mov hInstance, eax

 xor edx,edx
 invoke WinMain,hInstance,edx,edx,SW_SHOWDEFAULT

 invoke ExitProcess,eax

 ; -------------------------------------------------------------------------
 WinMain PROC hInst :DWORD,hPrevInst :DWORD,CmdLine :DWORD,CmdShow :DWORD
 ; -------------------------------------------------------------------------

 LOCAL wc :WNDCLASSEX
 LOCAL msg :MSG
 LOCAL hwnd :HWND

 mov wc.cbSize,sizeof WNDCLASSEX
 mov wc.style,CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
 mov wc.lpfnWndProc,offset WndProc
 mov wc.cbClsExtra,NULL
 mov wc.cbWndExtra,NULL
 push hInst
 pop wc.hInstance

 mov wc.hbrBackground,COLOR_BTNFACE+4

 mov wc.lpszMenuName,NULL
 mov wc.lpszClassName,offset ClassName
 mov wc.hIcon,NULL
 invoke LoadCursor,NULL,IDC_ARROW
 mov wc.hCursor,eax
 mov wc.hIconSm,NULL

 invoke RegisterClassEx, ADDR wc

 invoke GetSystemMetrics,SM_CXSCREEN
 shr eax,1
 sub eax,PictureW/2
 push eax

 invoke GetSystemMetrics,SM_CYSCREEN
 shr eax,1
 sub eax,PictureH/2
 pop ebx

 invoke CreateWindowEx,WS_EX_LEFT,ADDR ClassName,ADDR DisplayName,
 WS_OVERLAPPEDWINDOW,ebx,eax,PictureW,PictureH+26,NULL,NULL,hInst,NULL
 mov hwnd,eax
 push eax

 invoke CreatePen, PS_SOLID, 1, 0FFFFFFh
 mov hPenW, eAX

 invoke SelectObject, hmainDC, hPenW
 
 invoke GetTickCount
 invoke nseed, eAX

 invoke MemCopy, Addr axis, addr pt[2999-36], 36
  
 mov z0, 7
 mov edi, hwnd
 invoke ShowWindow,edi,SW_SHOWNORMAL
 invoke UpdateWindow,edi
 
 _Start:
 invoke GetMessage,ADDR msg,NULL,0,0
 test eax, eax
 jz _Exit
 invoke TranslateMessage,ADDR msg
 invoke DispatchMessage,ADDR msg
 jmp _Start
 _Exit:
 
 mov eax,msg.wParam
 ret
 ; -------------------------------------------------------------------------
 WinMain ENDP
 ; -------------------------------------------------------------------------

 ; -------------------------------------------------------------------------
 WndProc PROC uses edx ecx ebx esi edi hWnd :HWND,uMsg :DWORD,wParam :DWORD,lParam :DWORD
 ; -------------------------------------------------------------------------

 LOCAL hdc:HDC
 LOCAL ps:PAINTSTRUCT

 mov eax, uMsg

 ; -------------------------------------------------------------------------
 .IF eax == WM_PAINT

 invoke BeginPaint,hWnd, ADDR ps
 mov hdc,eax

 		;troiciUme cercle
		 xor ebx,ebx
		 mov esi,1800

		 @SetPixel3:

		 call rotation3D
		.if ebx == 0
			invoke SetPixel, hmainDC, ptX, ptY, 000ff00h
			inc ptX
			invoke SetPixel, hmainDC, ptX, ptY, 000ff00h
			inc ptY
			invoke SetPixel, hmainDC, ptX, ptY, 000ff00h
			dec ptX
			invoke SetPixel, hmainDC, ptX, ptY, 000ff00h
		.else
			invoke SetPixel, hmainDC, ptX, ptY, 0ffffffh
		.endif
		 
		 add esi, c12
		 inc ebx 
		 cmp ebx, 63
		 jne @SetPixel3

 .if sw_Line
	 JMP @Line_Pixel
 .endif
 ; ------------------------------------------------------------- PIXEL

 xor ebx,ebx
 xor esi,esi 

 @SetPixel:

 call rotation3D
.if ebx == 0
	invoke SetPixel, hmainDC, ptX, ptY, 000ff00h
	inc ptX
	invoke SetPixel, hmainDC, ptX, ptY, 000ff00h
	inc ptY
	invoke SetPixel, hmainDC, ptX, ptY, 000ff00h
	dec ptX
	invoke SetPixel, hmainDC, ptX, ptY, 000ff00h
	invoke MoveToEx, hmainDC, ptX, ptY, 0
	invoke LineTo, hmainDC, PictureW / 2, PictureH / 2
.else
	invoke SetPixel, hmainDC, ptX, ptY, 0ffffffh
.endif
 push eSI
 add esi, 840
 call rotation3D
 invoke SetPixel, hmainDC, ptX, ptY, 0ffffffh
 
 pop eSI
 add esi, c12
 inc ebx 
 cmp ebx, 63; 1000
 jne @SetPixel

 invoke MoveToEx, hmainDC, ptX, ptY, 0
 invoke LineTo, hmainDC, PictureW / 2, PictureH / 2

 JMP  Hacer
					;-----------------------------------
@Line_Pixel:

 xor esi, esi
 xor EBX, EBX  

@RepPixel:

 PUSH eBX
 mov eAX, rol1
 add eAX, rot1
 mov eDX, 0
 mov eBX, a63
 div eBX
.if eDX
	 mov eAX, eDX
	 mov rol1, eDX
.else
	 mov rol1, eAX
.endif
.IF SW_Y
	PrintDec rol1
.ENDIF
 mov eDX, 12
 mul eDX
 mov eSI, eAX 
 call rotation3D
 POP eBX
 PUSH eBX
.if eBX == 0
	invoke MoveToEx, hmainDC, ptX, ptY, 0
.else
	invoke LineTo, hmainDC, ptX, ptY
.endif 
 
 mov eAX, rol2
 add eAX, rot2
 mov eDX, 0
 mov eBX, a63
 div eBX
.if eDX
	 mov eAX, eDX
	 mov rol2, eDX
.else
	 mov rol2, eAX
.endif
.IF SW_Y
	PrintDec rol2
.ENDIF
 mov eDX, 12
 mul eDX
 mov eSI, eAX
 add eSI, 840 
 
 call rotation3D
 invoke LineTo, hmainDC, ptX, ptY
  
 POP EBX
 inc ebx 
 cmp ebx,  700
 jne @RepPixel
 ; ------------------------------------------------------------- PIXEL

Hacer: 

.If sw_axis
	  mov eSI, 2999 - 36
	  call rotation3D
		invoke CreatePen, PS_SOLID, 1, 00000FFh
		mov hPenX, eAX
		invoke SelectObject, hmainDC, hPenX
		invoke MoveToEx, hmainDC, PictureW2, PictureH2, 0
		invoke LineTo, hmainDC, ptX, ptY
		invoke DeleteObject, hPenX

      mov eSI, 2999 - 24
	  call rotation3D
		invoke CreatePen, PS_SOLID, 1, 0FF0000h
		mov hPenX, eAX
		invoke SelectObject, hmainDC, hPenX
		invoke MoveToEx, hmainDC, PictureW2, PictureH2, 0
		invoke LineTo, hmainDC, ptX, ptY
		invoke DeleteObject, hPenX

	  mov eSI, 2999 - 12
	  call rotation3D
		invoke CreatePen, PS_SOLID, 1, 000FF00h
		mov hPenX, eAX
		invoke SelectObject, hmainDC, hPenX
		invoke MoveToEx, hmainDC, PictureW2, PictureH2, 0
		invoke LineTo, hmainDC, ptX, ptY
		invoke DeleteObject, hPenX
	   
	   Invoke SelectObject, hmainDC, hPenW
	   
.Endif

 invoke BitBlt, hdc, 0,0, PictureW, PictureH, hmainDC, 0, 0, SRCCOPY

 invoke EndPaint,hWnd, ADDR ps

;-----------------------------------------------------------
.ELSEIF eax == WM_TIMER

.if sw_timer != 0
        invoke GetTickCount
             
        mov z0, -1
		.if ! sw_move
			mov z0, 0
		.endif
        and ax, 8015
        .if ax & 8000
               mov ax, bx
               imul ax,cx
               xor ax,si
               and ax, 1010 
               .if ax & 10
                    push scale_men
                    pop scale
               .endif
               .if ax & 1000
                    push scale_sum
                    pop scale
               .endif

               ;jmp Avec_Mouse
        .endif
   
               mov ax, bx
               imul ax,cx
               xor ax,-1
               ;and ax, 3023 
               .if ax & 6
                    ;inc rol2
                    ;jmp Avec_Mouse
					invoke nrandom, 63
					mov rol2, eAX
               .endif
               ;!;.if ax & 20
               ;!;     mov eAx, 5
               jmp Avec_Mouse
               ;!;.endif
        
   
.endif

 ; -------------------------------------------------------------------------ppp
 .ELSEIF eax == WM_MOUSEMOVE
				mov eBX, wParam
				and eBX, MK_RBUTTON
				mov eAX, wParam
				and eAX, MK_LBUTTON
				;or  eAX, MK_MBUTTON                
				;mov eAX, eBX
				;mov z0 , 0
								;RIGHT MOUSE
				.if eBX != 0  &&  eAX == 0; & MK_RBUTTON  ; MOVES CENTER OF PICTURE
					  mov sw_Hole, 0
					  mov sw_timer, 0
					  mov ecx, lParam
					  mov eax, ecx
					  ror ecx, 16
					  mov ebx, eax
					  sub bx, x1
					 .if bx
						  mov eax, PictureW2
						  add ax, bx
						  mov PictureW2, eax
						  add x1, bx
					 .endif
					  sub cx, y1
					 .if cx
						  mov ebx, PictureH2
						  add bx, cx
						  mov PictureH2, ebx
						  add y1, cx
					 .endif
                     mov z0, 0   ; do not rotation
                     jmp Avec_Mouse

                .endif
							;LEFT MOUSE
				mov eCX, wParam
				and eCX, MK_MBUTTON
				.if eAX != 0  ||   eCX != 0; & MK_LBUTTON    or   MBUTTON
					.if eCX
						mov eAX, 4
					.endif
					mov ebx, lParam          
					mov ecx, lParam
					ror ecx, 16
Wheels:
					mov z0, 0
					;and z0, 0fffffff0h  ; bitclear  0  1  2

					.if bx < x2
						push scale_men
						pop scale
						or z0, 2
					.elseif bx > x3
						push scale_sum
						pop scale
						or z0, 2
					.else
						.if cx > y3
							push scale_sum
							pop scale
							or z0, 1
                        .elseif cx < y2
							push scale_men
							pop scale
							or z0, 1
						.endif
                                
					.endif

					;only  Z  axe
					.if eAX == 4 && z0 & 3						
						mov z0, 4
					.endif

					.if z0 & 7
						mov x1, bx
						mov y1, cx
						  sub bx, 3
						  mov x2, bx
						  add bx, 6
						  mov x3, bx
						  sub cx, 3
						  mov y2, cx
						  add cx, 6
						  mov y3, cx
					.endif
			jmp Avec_Mouse
		.endif

 ; -------------------------------------------------------------------------ppp
 .ELSEIF eax == WM_LBUTTONUP    ||  eax == WM_RBUTTONUP
        mov xopc, 0
 ; -------------------------------------------------------------------------ppp
 .ELSEIF eax == WM_RBUTTONDOWN
        mov sw_Hole, 0
        ;mov xopc, 3     ; RIGHT BUTTON ONLY ROTATE Z
		JMP LMouse
 ; -------------------------------------------------------------------------ppp
 .ELSEIF eax == WM_LBUTTONDOWN
 LMouse:
         mov eBX, lParam		 
         mov x1, BX		 
		 shr eBX, 16
		 mov y1, BX
		 mov CX, BX

			  sub bx, 3
			  mov x2, bx
			  add bx, 6
			  mov x3, bx
			  sub cx, 3
			  mov y2, cx
			  add cx, 6
			  mov y3, cx
jmp Avec_Mouse

 ; -------------------------------------------------------------------------
 .ELSEIF eax == WM_KEYDOWN

Avec_Mouse:

;!;.if sw_Hole == 0
;!;	invoke FillRect, hmainDC, addr MyRect,noir
;!;.endif
;!; invoke FillRect, hmainDC, addr MyRectTxt, noir
;!; invoke TextOut, hmainDC, 2, 2, addr buff, 6
;!; invoke RedrawWindow, hWnd, addr MyRect, 0, RDW_INVALIDATE

.if wParam == VK_LEFT
        push scale_men
        pop scale
		mov z0, 2
.elseif wParam == VK_RIGHT
        push scale_sum
        pop scale
		mov z0, 2
.elseif wParam == VK_UP  ||  wParam == VK_DOWN     
     .if wParam == VK_UP
		  push scale_sum
     .else
		  push scale_men
     .endif
	 pop scale
     mov z0, 1
.elseif wParam == VK_X
		XOR sw_Cerc, 1
		Call Circulito

.elseif wParam == VK_Z  ||  wParam == VK_C ; Z  AXIS
		.if wParam == VK_Z
			mov eAX, 4
		.else
			mov eAX, -4
		.endif
		xor eCX, eCX
		xor eSI, eSI
		.repeat
			add [pt+esi+8], eAX
			sub [pt+esi+848], eAX
			inc eCX
			add esi, 12
		.until eCX == 70		
		mov z0, 0
		invoke ver, pt[848]

.elseif wParam == VK_A  ||  wParam == VK_D ; Rayon Circle 1
		mov z0, 1
		.if wParam == VK_A
			dec rayon1
			.if rayon1 > 1000
				mov rayon1, 260
			.endif
		.else
			inc rayon1
		.endif
		push rayon1
		pop rayon
		INVOKE ver, rayon
		call Circulito
		mov z0, 0

.elseif wParam == VK_P
		XOR sw_axis, 1

.elseif wParam == VK_Q  ||  wParam == VK_E ; Rayon Circle 2
		mov z0, 2
		.if wParam == VK_Q
			dec rayon2
			.if rayon2 > 1000
				mov rayon2, 260
			.endif
		.else
			inc rayon2
		.endif
		push rayon2
		pop rayon
		INVOKE ver, rayon
		call Circulito
		mov z0, 0
		
.elseif wParam == VK_W
		PrintDec rot1
		PrintDec rot2
		PrintDec rol1
		PrintDec rol2
		PrintDec rayon1
		PrintDec rayon2
		mov eAX, pt[20]
		PrintDec eAX, "Dist Z"
		PrintLine
		
.elseif wParam == VK_S  ||  wParam == 192 ;'Ñ'
		
		XOR sw_Line, 1

.elseif wParam == VK_Y  ; view vars  rol%
		
		XOR SW_Y, 1

.elseif wParam == 70 ;'F'
		dec rot1
		.if rot1 > 64
			mov rot1, 64
		.endif
		INVOKE ver, rot1
.elseif wParam == 71 ;'G'   ; ops!
		dec rot2
		.if rot2 > 64
			mov rot2, 64
		.endif
		INVOKE ver, rot2
.elseif wParam == 86  ||  wParam == VK_N ;'V';'N'
		inc rot1
		INVOKE ver, rot1
		
.elseif wParam == 66  ||  wParam == VK_M ;'B';'B' 
		inc rot2
		INVOKE ver, rot2
		
.elseif wParam == VK_K
		dec rol2
		.if rol2 > 64
			mov rol2, 64
		.endif
		INVOKE ver, rol2
.elseif wParam == VK_J
		dec rol1
		.if rol1 > 64
			mov rol1, 64
		.endif
		INVOKE ver, rol1
.elseif wParam == 0BEh ;'.'
		inc rol2
		INVOKE ver, rol2
.elseif wParam == 0BCh ;','
		inc rol1
		INVOKE ver, rol1

.elseif wParam == VK_L  ||  wParam == 0BDh  ; '-'
		.if sw_Line == 0  ||  wParam == 0BDh
			invoke nrandom, 100
			mov rot1, eAX
			invoke nrandom, 100
			mov rot2, eAX
			mov sw_Line, 1
		.else
			mov sw_Line, 0
		.endif
		
.elseif wParam == VK_G  ||  wParam == VK_H  ; DO NOT FILL BACKGROUND
        
        XOR sw_Hole, 1
		
.elseif wParam == VK_SPACE  ||  wParam == VK_RETURN  ||  wParam == VK_BACK
        mov sw_Hole, 0
		mov z0, 0

.elseif wParam == VK_0  ||  wParam == VK_NUMPAD0  ||  wParam == VK_O	 
		mov eAX, scale_zero
		mov camX, eAX
		mov camY, eAX
		mov camZ, eAX
		mov scale, eAX

.elseif wParam == VK_T
avec_time:
     XOR sw_timer, 1
	 
.elseif wParam == VK_R
 
	 XOR sw_move, 1
	 JMP avec_time
	 
.endif

		.if rot1 > 63
			mov rot1, 1
		.endif
		.if rot2 > 63
			mov rot2, 1
		.endif

 cmp wParam, VK_ESCAPE
 je destroy

.if z0
.if z0 & 1
 fld scale        
 fld camX
 faddp st(1),st
 fstp camX
.endif

.if z0 & 2
 fld scale
 fld camY
 faddp st(1),st
 fstp camY
.endif

.if z0 & 4
 fld scale
 fld camZ
 faddp st(1),st
 fstp camZ
 
 fld camZ
 fld grds
 fmul
 fistp xopc
 PrintDec xopc, "---- Z"
.endif
.endif

.if sw_Hole == 0
	invoke FillRect, hmainDC, addr MyRect,noir
.endif
 invoke FillRect, hmainDC, addr MyRectTxt, noir
 invoke TextOut, hmainDC, 2, 2, addr buff, 6
 invoke RedrawWindow, hWnd, addr MyRect, 0, RDW_INVALIDATE

 ; -------------------------------------------------------------------------
.ELSEIF eax == WM_CREATE

 invoke CreateSolidBrush,noir
 mov noir,eax

 ; ««««««««««« CIRCLE

 ;cos(theta)*r = x
 ;sin(theta)*r = y

 xor ecx,ecx

 cercle:

 finit

 fld newtheta
 fild rayon

 fld theta ; X
 fcos
 fmul st,st(1)
 fistp dword ptr [pt+ecx]

 mov eAX, [pt+ecx] 
 mov [pt+ecx+840], eAX 
 add [pt+ecx+840], eAX 
 add [pt+ecx], eAX ; same radius
 
 mov [pt+ecx+8], -200
 mov [pt+ecx+848], 200
 
 fld theta ; Y
 fsin
 fmul st,st(1)
 fistp dword ptr [pt+ecx+4]

 mov eAX, [pt+ecx+4]
 mov [pt+ecx+844], eAX
 add [pt+ecx+844], eAX 
 add [pt+ecx+4], eAX ; same radius
 
 fld theta ;incremente
 fadd st, st(2)
 fstp theta

 add ecx, 12 ; next points

 fldpi
 fld num180
 fld theta
 fmul st,st(1)
 fdiv st,st(2) ;Radians*180/PI = Degrees
 fistp temp1
 cmp temp1, 360
 jnge cercle

 mov eAX, pt[0]
 mov eBX, pt[4]
 mov pt[ecx], eAX
 mov pt[ecx+4], eBX
 mov eAX, pt[8]
 mov pt[ecx+8], eAX

 mov eAX, pt[840]
 mov eBX, pt[844]
 mov pt[ecx+840], eAX
 mov pt[ecx+844], eBX
 mov eAX, pt[848]
 mov pt[ecx+848], eAX
;PrintDec eCX

 ; ««««««««««« CIRCLE

 ; ««««««««««« main

 invoke GetDC, hWnd
 mov hdc, eax

 mov esi,PictureW
 mov edi,PictureH

 invoke CreateCompatibleDC, hdc
 mov dword ptr [hmainDC],eax

 invoke SetBkMode, hmainDC, TRANSPARENT
 invoke SetTextColor, hmainDC, 000C0C0C0h ; for text color

 invoke CreateCompatibleBitmap, hdc, esi, edi
 mov dword ptr [hmainbmp],eax

 invoke SelectObject, [hmainDC], eax

 invoke ReleaseDC,hWnd, hdc
 ; ««««««««««« main
 
 invoke SetTimer, hWnd, TIMER1, 50, NULL

 .ELSEIF eax == WM_CLOSE
 destroy:
 invoke PostQuitMessage,NULL
 invoke DeleteDC, [hmainDC]
 invoke DeleteObject, [hmainbmp]
 invoke DeleteObject, noir
 invoke DeleteObject, hPenW
 invoke KillTimer, hWnd, TIMER1

 .ENDIF

 xor eax,eax
 invoke DefWindowProc,hWnd,uMsg,wParam,lParam
 ret

; ««««««««««« CIRCLEITO

Circulito:
xor ecx,ecx
mov theta, 0 

cercleito:
 finit

 fld newtheta
 fild rayon

 fld theta ; X
 fcos
 fmul st,st(1)
 fistp temp3
 mov eAX, temp3
	.if z0 & 1
		mov dword ptr [pt+ecx], eAX
	.endif
	.if z0 & 2
		mov [pt+ecx+840], eAX
	.endif
	mov [pt+ecx+1800], eAX

.if !sw_Cerc
	shr eAX, 1
	sub [pt+ecx], eAX ; half radius
.endif

.if z0 & 4
 mov [pt+ecx+8], -200
 mov [pt+ecx+848], 200
.endif
 mov [pt+ecx+1808], 250

 fld theta ; Y
 fsin
 fmul st,st(1)
 fistp temp3
 mov eAX, temp3
	.if z0 & 1
		mov dword ptr [pt+ecx+4], eAX
	.endif
	.if z0 & 2		
		mov [pt+ecx+844], eAX
	.endif
	mov [pt+ecx+1804], eAX

.if !sw_Cerc
	shr eAX, 1
	sub [pt+ecx+4], eAX ; half radius
.endif
 
 fld theta ;incremente
 fadd st, st(2)
 fstp theta

 add ecx, 12 ; next points

 fldpi
 fld num180
 fld theta
 fmul st,st(1)
 fdiv st,st(2) ;Radians*180/PI = Degrees
 fistp temp1
 
 cmp temp1, 360
 jnge cercleito
 
 .if z0 & 1
 mov eAX, pt[0]
 mov eBX, pt[4]
 mov pt[ecx], eAX
 mov pt[ecx+4], eBX
 mov eAX, pt[8]
 mov pt[ecx+8], eAX
 .endif
 .if z0 & 2
 mov eAX, pt[840]
 mov eBX, pt[844]
 mov pt[ecx+840], eAX
 mov pt[ecx+844], eBX
 mov eAX, pt[848]
 mov pt[ecx+848], eAX
 .endif
 mov eAX, pt[0]
 mov pt[ecx+1800], eAX
 mov eAX, pt[4]
 mov pt[ecx+1804], eAX
 mov pt[ecx+1808], 250
 
 RETN
 ; ««««««««««« CIRCLEITO

 rotation3D:

 fild dword ptr [pt+esi]
 fstp dword ptr [tempX]
 fild dword ptr [pt+esi+4]
 fstp dword ptr [tempY]
 fild dword ptr [pt+esi+8]
 fstp dword ptr [tempZ]

 finit

 ;rotate on the X axis
 fld dword ptr [camX]
 fsin
 fmul dword ptr [tempZ]
 fld dword ptr [camX]
 fcos
 fmul dword ptr [tempY]
 fsub st,st(1)
 fstp dword ptr [Yt]

 fld dword ptr [camX]
 fcos
 fmul dword ptr [tempZ]
 fld dword ptr [camX]
 fsin
 fmul dword ptr [tempY]
 fadd st,st(1)
 fstp dword ptr [Zt]

 fld dword ptr [Yt]
 fstp dword ptr [tempY]
 fld dword ptr [Zt]
 fstp dword ptr [tempZ]

 ;rotate on the Y axis
 fld dword ptr [camY]
 fsin
 fmul dword ptr [tempZ]
 fld dword ptr [camY]
 fcos
 fmul dword ptr [tempX]
 fsub st,st(1)
 fstp dword ptr [Xt]

 fld dword ptr [camY]
 fcos
 fmul dword ptr [tempZ]
 fld dword ptr [camY]
 fsin
 fmul dword ptr [tempX]
 fadd st,st(1)
 fstp dword ptr [Zt]

 fld dword ptr [Xt]
 fstp dword ptr [tempX]
 fld dword ptr [Zt]
 fstp dword ptr [tempZ]

 ;rotate on the Z axis
 fld dword ptr [camZ]
 fsin
 fmul dword ptr [tempY]
 fld dword ptr [camZ]
 fcos
 fmul dword ptr [tempX]
 fsub st,st(1)
 fstp dword ptr [Xt]

 fld dword ptr [camZ]
 fcos
 fmul dword ptr [tempY]
 fld dword ptr [camZ]
 fsin
 fmul dword ptr [tempX]
 fadd st,st(1)
 fstp dword ptr [Yt]

 ;on sauve
 fld dword ptr [Xt]
 fistp dword ptr [ptX]
 fld dword ptr [Yt]
 fistp dword ptr [ptY]

mov eAX, PictureW2
 add dword ptr [ptX], eAX
mov eAX, PictureH2
 add dword ptr [ptY], eAX

 retn
 ; -------------------------------------------------------------------------
 WndProc ENDP
 ; -------------------------------------------------------------------------

ver PROC qver:dword
	invoke udw2str, qver, addr buff
	;invoke TextOut, hmainDC, 2, 2, addr buff, 4
	ret
ver ENDP

; #########################################################################

; se debe encerar el buffer destino antes de proceder
  ; ---------------------------------------------------
  ; The original algorithm was written by comrade
  ; <comrade2k@hotmail.com>; http://www.comrade64.com/
  ;
  ;  It has been optimised by Alexander Yackubtchik
  ; ---------------------------------------------------

  ; udw2str

  ; Parameters
  ;     dwNumber - 32-bit double-word to be converted
  ;     pszString - not(pp) null-terminated string (output)
  ; Result
  ;     None
  ; precaucion con 80000000h y 80000001h

;   .code

; ############################################################

udw2str proc dwNumber:DWORD, pszString:DWORD
local signus:byte

    push ebx
    push esi
    push edi

    mov     eax, [dwNumber]
    mov     esi, [pszString]
    mov     edi, [pszString]
    mov ecx, 429496730  ;   
	mov signus, ' '

.if eAX == 0
    mov dword ptr [esi], 20202030h ; "   0"
	jmp Done
.endif
.if eAX > 8000h
	neg eAX
	mov signus, '-'
.endif

  @@redo:
    mov ebx,eax
    mul ecx
    mov eax,edx
    lea edx,[edx*4+edx]
    add edx,edx
    sub ebx,edx
    add bl,'0'
    mov [esi],bl
    inc esi
    test    eax, eax
    jnz     @@redo
    jmp     @@chks

  @@invs:
    dec     esi
    mov     al, [edi]
    xchg    [esi], al
    mov     [edi], al
    inc     edi
  @@chks:
    cmp     edi, esi
    jb      @@invs

Done:

   .if dwNumber == 80000000h ;2147483648
        add eDI, 3
        mov dword ptr [eDI], "  84" ; 48
   .elseif dwNumber == 80000001h  ;2147483649
        add eDI, 3
        mov dword ptr [eDI], "  94" ; 49
   .else
		.if dwNumber >= 0  &&  dwNumber < 10
			mov dword ptr [eDI], "    "
		.endif
		mov al, signus
        mov byte ptr [eDI+1], al
		mov dword ptr [eDI+2], "    " 
   .endif

    pop edi
    pop esi
    pop ebx

    ret

udw2str endp

 ; -------------------------------------------------------------------------
 END start
 ; -------------------------------------------------------------------------

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.