Masmblend

Description

MasmBlend permet d'utiliser les objets 3D crées par BLENDER dans
les programmes Masm utilisant la bibliothèque OpenGL.
Une fois l'objet crée sous blender,exporter le au format wavefront (.obj)
Dans MasmBlend,sélectionnez fichier/ouvrir fichier blend format .obj,le contenu du fichier apparait dans la fenetre de gauche,appuyez sur le bouton CONVERSION,le resultat apparait dans l'autre fenetre.Sauvegardez le au format .txt par exemples.
Vous n'avez plus qu'à l'incorporer dans votre prog Masm par copier/coller.
Pour l'affichage,utilisez glInterleavedArrays et glDrawElements. (cf lisez moi.txt)

Source / Exemple :


.586
.model	flat,stdcall
option	casemap:none  

include MasmBlend.inc
include comdlg32.inc
INCLUDELIB user32.lib
INCLUDELIB kernel32.lib
INCLUDELIB gdi32.lib
includelib comdlg32.lib

traduction proto

.data
ofn   OPENFILENAME <>
MAXSIZE equ 260
buffer db MAXSIZE dup(0)

.data?
ID_BUFFER_ASM	dword ?
ID_BUFFER_BLEND	dword ?
HANDLE_PROCESS_PRIMAIRE	dword ?
hFile_blend	dword ?
hwndedit	dword ?
hwndedit1	dword ?
szero	sdword ?
hFile_asm	dword ?
taille_fichier_obj	dword ?

.code

debut:		
	invoke	GetModuleHandle,NULL
	mov HANDLE_PROCESS_PRIMAIRE,eax
	invoke	Maitre,HANDLE_PROCESS_PRIMAIRE 
	invoke	ExitProcess,eax
	
Maitre 		PROC	hInst:DWORD 	
	LOCAL 	IDclass[4]:BYTE	
	LOCAL	Menu1[4]:byte
	LOCAL	largeur,hauteur,xSupGauche,ySupGauche,hWnd:DWORD
	LOCAL   wc:WNDCLASSEX
	
		mov DWORD PTR[ebp-4],004D5341h 
		mov DWORD PTR[ebp-8],006E656Dh
						
		mov wc.cbSize,SIZEOF WNDCLASSEX
		mov wc.style,CS_HREDRAW or CS_VREDRAW
		mov wc.lpfnWndProc,poste
		mov wc.cbClsExtra,NULL
		mov wc.cbWndExtra,NULL
		mov wc.hInstance,NULL
		mov wc.hIcon,NULL
		mov wc.hCursor,NULL
		mov wc.hbrBackground,1 
		lea eax,Menu1
		mov wc.lpszMenuName,eax
		lea eax,IDclass
		mov wc.lpszClassName,eax
		mov wc.hIconSm,NULL
.data

MainHDC			DWORD   0

.code	
			
	mov	largeur,750
	mov	hauteur,650
	mov xSupGauche,10
	mov ySupGauche,10
	
    mov eax,hInst
    mov wc.hInstance,eax
	invoke	LoadIcon,hInst,2
	mov	wc.hIcon,eax
	invoke	LoadCursor,NULL,IDC_ARROW
	mov	wc.hCursor,eax
	invoke	RegisterClassEx, ADDR wc
	invoke ShowCursor,TRUE
	invoke CreateWindowEx, WS_EX_CLIENTEDGE,ADDR IDclass,NULL,WS_OVERLAPPEDWINDOW,
          xSupGauche,ySupGauche,largeur,hauteur,NULL,NULL,hInst,NULL
	mov	hWnd,eax
	invoke	ShowWindow,hWnd,SW_SHOWNORMAL
	invoke	UpdateWindow,hWnd
						
	invoke	chercheMsg,hInst
	ret
Maitre 		ENDP
;-------------------------
poste		PROC	hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

	LOCAL	ButtonClassName[8]:BYTE
	LOCAL	ButtonText[12]:BYTE
	LOCAL	labelClassName[8]:BYTE
	LOCAL	labelText[12]:BYTE
	LOCAL	labelText2[12]:BYTE
	LOCAL	editClassName[8]:BYTE
	LOCAL	buffer_asm[12]:BYTE
	LOCAL	WINRect:RECT
	LOCAL 	hMemory_blend:DWORD
	LOCAL	hMemory_asm:DWORD
	LOCAL   hwndButton:DWORD
	LOCAL	hwndLabel,hwndLabel2:dword 
	LOCAL 	BCN,BTT,LBN,LBT,LBT2,ECN,BUF,SRW,SZE:DWORD
	LOCAL	hFile:DWORD
	LOCAL	SizeReadWrite:DWORD
	
	mov hMemory_blend,0
	mov hMemory_asm,0
	
	;initialisation des variables locales
			
	mov DWORD PTR[ebp-4],00006E6Fh	
	mov DWORD PTR[ebp-8],74747562h	
	mov DWORD PTR[ebp-12],00006E6Fh	
	mov DWORD PTR[ebp-16],69737265h	
	mov DWORD PTR[ebp-20],766E6F63h	
	mov DWORD PTR[ebp-24],00006369h	
	mov DWORD PTR[ebp-28],74617473h	
	mov DWORD PTR[ebp-32],004A424Fh	
	mov DWORD PTR[ebp-36],5F726569h	
	mov DWORD PTR[ebp-40],68636966h	
	mov DWORD PTR[ebp-44],004D5341h	
	mov DWORD PTR[ebp-48],5F726569h	
	mov DWORD PTR[ebp-52],68636966h	
	mov DWORD PTR[ebp-56],00000000h	
	mov DWORD PTR[ebp-60],74696465h	
			
	.if	uMsg == WM_CREATE
			
	;creation interface graphique
	;-----------------------------
	;bouton -----------
	;		"conversion"
	lea eax,ButtonClassName
	mov BCN,eax
	lea eax,ButtonText
	mov BTT,eax
	
	invoke CreateWindowEx,NULL,BCN,BTT,\
                WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\
                255,5,140,25,hWin,1,HANDLE_PROCESS_PRIMAIRE,NULL
	 mov  hwndButton,eax
	 
	 ;label ----------
	 ;		"fichier blend"
	 lea eax,labelClassName
	 mov LBN,eax
	 lea eax,labelText
	 mov LBT,eax
	 invoke CreateWindowEx,NULL, LBN,LBT,\
                WS_CHILD or WS_VISIBLE or SS_CENTER,\
                55,20,100,15,hWin,1,HANDLE_PROCESS_PRIMAIRE,NULL
     mov hwndLabel,eax
     
	 ;		"fichier ASM"
	 
	 lea eax,labelText2
	 mov LBT2,eax
	invoke CreateWindowEx,NULL,LBN,LBT2,\
                WS_CHILD or WS_VISIBLE or SS_CENTER,\
                450,20,100,15,hWin,2,HANDLE_PROCESS_PRIMAIRE,NULL   
    mov hwndLabel2,eax
    
    ;editeur de texte ----------
    ;		"fichier blend"
    
    lea eax,editClassName
    mov ECN,eax
    invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,ECN,NULL,\
            WS_VISIBLE or WS_CHILD or ES_LEFT or ES_MULTILINE or\
           ES_AUTOHSCROLL or ES_AUTOVSCROLL or WS_VSCROLL or WS_HSCROLL,\
                5,40,320,500,hWin,1,HANDLE_PROCESS_PRIMAIRE,NULL 
    mov hwndedit,eax
    
    ;		"fichier ASM"
    invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,ECN,NULL,\
            WS_VISIBLE or WS_CHILD or ES_LEFT or ES_MULTILINE or\
           ES_AUTOHSCROLL or ES_AUTOVSCROLL or WS_VSCROLL or WS_HSCROLL,\
                350,40,360,500,hWin,2,HANDLE_PROCESS_PRIMAIRE,NULL 
    mov hwndedit1,eax
    
    ;------ remplissage structure Open File Name 
            
	invoke SetFocus,hwndedit
	mov ofn.lStructSize,SIZEOF ofn
	push hWin
	pop  ofn.hwndOwner
	push HANDLE_PROCESS_PRIMAIRE
	pop  ofn.hInstance
	mov  ofn.lpstrFilter,NULL
	mov  ofn.lpstrFile, OFFSET buffer	;stockage nom du fichier ouvert
	mov  ofn.nMaxFile,MAXSIZE
	ret
			
    .ELSEIF uMsg==WM_COMMAND
		mov eax,wParam
			.if lParam==0
			nop
			nop
			
				.if ax==1 ;IDM_OPEN
					;ouvre la boite de dialogue openfilename
					;et selectionne le fichier .obj 
					
					mov  ofn.Flags, OFN_FILEMUSTEXIST or \
                    OFN_PATHMUSTEXIST or OFN_LONGNAMES or\
                    OFN_EXPLORER or OFN_HIDEREADONLY
					invoke GetOpenFileName, ADDR ofn
						.if eax==TRUE
						invoke CreateFile,ADDR buffer,\
                        GENERIC_READ or GENERIC_WRITE ,\
                        FILE_SHARE_READ or FILE_SHARE_WRITE,\
                         NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,\
                         NULL
						mov hFile_blend,eax
						
					;determination de la taille du fichier .obj choisi
					invoke GetFileSize,hFile_blend,0
					mov taille_fichier_obj,eax	
					;creation des buffers de travail
					;qui recoit le fichier .obj à traiter
					invoke GlobalAlloc,GMEM_FIXED,eax
					mov ID_BUFFER_BLEND,eax	;buffer pour fichier.obj
					invoke GlobalLock,eax
					;qui recoit le resultat du traitement
					mov eax,taille_fichier_obj
					shl eax,1	;on double la taille par precaution
					invoke GlobalAlloc,GMEM_FIXED,eax
					mov ID_BUFFER_ASM,eax	;buffer pour traduction asm
					invoke GlobalLock,eax
					
					;initialisation des buffers avec 20h 
					
					mov ecx,taille_fichier_obj
					mov eax,ID_BUFFER_BLEND
					mov edx,ID_BUFFER_ASM
initiBuff:			mov BYTE ptr[eax],20h
					mov BYTE PTR[edx],20h
					inc eax
					inc edx
					dec ecx
					cmp ecx,0
					jne initiBuff
					;
					mov ecx,taille_fichier_obj
					mov edx,ID_BUFFER_ASM
					add edx,taille_fichier_obj
initBis:			mov byte ptr[edx],20h
					inc edx
					dec ecx
					cmp ecx,0
					jne initBis
					;
					;lit le fichier .obj et le stocke dans le buffer
					invoke ReadFile,hFile_blend,ID_BUFFER_BLEND,taille_fichier_obj,ADDR SizeReadWrite,NULL
					;
					invoke SendMessage,hwndedit,WM_SETTEXT,NULL,ID_BUFFER_BLEND										
						.endif
					invoke SetFocus,hwndedit
					;
					ret
            	.elseif ax==2 ;IDM_SAVE
            		;sauvegarde le contenu de l'edit text "masm"
            		;dans le fichier choisi 
					mov ofn.Flags,OFN_LONGNAMES or\
                    OFN_EXPLORER or OFN_HIDEREADONLY
					invoke GetSaveFileName, ADDR ofn
						.if eax==TRUE
						invoke CreateFile,ADDR buffer,\
                        GENERIC_READ or GENERIC_WRITE ,\
                        FILE_SHARE_READ or FILE_SHARE_WRITE,\
                        NULL,CREATE_NEW,FILE_ATTRIBUTE_ARCHIVE,\
                        NULL
						mov hFile,eax
						;
						mov eax,taille_fichier_obj
						shl eax,1
						invoke SendMessage,hwndedit1,WM_GETTEXT,eax,ID_BUFFER_ASM
						lea ecx,SizeReadWrite
						mov SRW,ecx
						invoke WriteFile,hFile,ID_BUFFER_ASM,eax,SRW,NULL
						invoke CloseHandle,hFile
						.endif
					invoke SetFocus,hwndedit1
					ret
				.elseif ax==3 ;IDM_EXIT
					invoke	DestroyWindow,hWin
					ret
            	.endif
            .else
            	.IF ax==1	;ButtonID	;conversion demandée
    ;-------------------------------------------------------
					shr eax,16
						.IF ax==0	;BN_CLICKED	
				
	
	;extraction des donnees de buffer_blend vers bufferAsm
							
	invoke traduction
									
	;on charge bufferAsm dans edit masm (ecrase le texte present si il y en a un)
	invoke SendMessage,hwndedit1,WM_SETTEXT,NULL,ID_BUFFER_ASM
	
						.ENDIF
				.ENDIF
            .endif
            
	.ELSEIF uMsg == WM_KEYDOWN    
		mov eax,wParam
		cmp eax,VK_ESCAPE
		jne suite
		invoke	DestroyWindow,hWin
suite:	ret

	.elseif	uMsg == WM_CLOSE	
		invoke	DestroyWindow,hWin
		ret
		
	.elseif uMsg == WM_DESTROY	
		;ferme le fichier .obj 
		lea ecx,hFile_blend
		invoke CloseHandle,dword ptr[ecx]
		;deverouille les zones memoires
		push [ID_BUFFER_BLEND]
		pop eax
		invoke GlobalUnlock,eax
		push [ID_BUFFER_ASM]
		pop eax
		invoke GlobalUnlock,eax
		
		;libere la memoire
		push [ID_BUFFER_BLEND]
		pop eax
		invoke 	GlobalFree,eax	
		push [ID_BUFFER_ASM]
		pop eax
		invoke 	GlobalFree,eax	
		;	
		invoke	PostQuitMessage,NULL
		ret		
		
	.endif
		invoke	DefWindowProc,hWin,uMsg,wParam,lParam
		ret
	
poste		ENDP
;-----------------------
chercheMsg		PROC	hInst1:DWORD
			LOCAL	msg:MSG
			
boucleMsg:	
			invoke	PeekMessage,ADDR msg,0,0,0,PM_NOREMOVE
			or	eax,eax
			jz	pasMsg
			invoke	GetMessage,ADDR msg,NULL,0,0
			or	eax,eax
			jz	fin
			invoke	TranslateMessage,ADDR msg
			invoke	DispatchMessage,ADDR msg	
			jmp boucleMsg
pasMsg:		
			jmp	boucleMsg
fin:
			mov	eax,msg.wParam
			
			ret
chercheMsg		ENDP
traduction proc uses eax ecx edx ebx

	LOCAL	valeur_texture,compteur_octets:DWORD
	LOCAL	curseur_blend,curseur_asm,nombre_de_signe_moins,curseur_blend_intermediaire:DWORD
	LOCAL	longueur_ligne_vertex:BYTE
	LOCAL	compteur_boucle,nbre_sommets,compteur_chiffre,compteur_sommet:dword
	
	mov compteur_octets,0
	mov valeur_texture,0
	mov curseur_blend,30h
	mov curseur_asm,0
	mov nombre_de_signe_moins,0
	mov curseur_blend_intermediaire,0
	mov longueur_ligne_vertex,26	
	mov compteur_boucle,0
;------------------------------------------------------------------------------------	
;premier scanne du fichier blend en entier pour retrouver et afficher tous les vertex
;------------------------------------------------------------------------------------
extraction:

	mov longueur_ligne_vertex,26	;longueur mini d'une ligne de vertex (sans -)
		;extraction de 4 caractères
		mov eax,ID_BUFFER_BLEND
		add eax,curseur_blend
		cmp BYTE PTR [eax],0Dh
		jne NOvertex
		cmp BYTE PTR [eax+1],0Ah
		jne NOvertex
		;on est au debut d'une ligne de code
		;est ce une ligne de vertex ?
		cmp BYTE PTR [eax+2],'v'
		jne NOvertex
		cmp BYTE PTR [eax+3],' '
		jne NOvertex
		;oui c'est une ligne de vertex
		;traitement de la ligne de vertex
		mov eax,curseur_blend
		mov curseur_blend_intermediaire,eax	;sauvegarde de la position du curseur_blend
		add curseur_blend_intermediaire,4	
A1:		
		mov eax,ID_BUFFER_ASM
		add eax,curseur_asm
		mov BYTE PTR [eax],'D'
		mov BYTE PTR [eax+1],'W'
		mov BYTE PTR [eax+2],'O'
		mov BYTE PTR [eax+3],'R'
		mov BYTE PTR [eax+4],'D'
		mov BYTE PTR [eax+5],' '
		;coordonnees de texture type carré
			inc valeur_texture
			cmp valeur_texture,5
			jne V1
			mov valeur_texture,1
V1:				
				cmp valeur_texture,1
				jne V2
					mov BYTE PTR [eax+6],'0'
					mov BYTE PTR [eax+7],'.'
					mov BYTE PTR [eax+8],'0'
					mov BYTE PTR [eax+9],','
					mov BYTE PTR [eax+10],'0'
					mov BYTE PTR [eax+11],'.'
					mov BYTE PTR [eax+12],'0'
					mov BYTE PTR [eax+13],','
V2:
				cmp valeur_texture,2
				jne V3				
					mov BYTE PTR [eax+6],'1'
					mov BYTE PTR [eax+7],'.'
					mov BYTE PTR [eax+8],'0'
					mov BYTE PTR [eax+9],','
					mov BYTE PTR [eax+10],'0'
					mov BYTE PTR [eax+11],'.'
					mov BYTE PTR [eax+12],'0'
					mov BYTE PTR [eax+13],','
V3:				cmp valeur_texture,3
				jne V4
					mov BYTE PTR [eax+6],'1'
					mov BYTE PTR [eax+7],'.'
					mov BYTE PTR [eax+8],'0'
					mov BYTE PTR [eax+9],','
					mov BYTE PTR [eax+10],'1'
					mov BYTE PTR [eax+11],'.'
					mov BYTE PTR [eax+12],'0'
					mov BYTE PTR [eax+13],','
V4:				cmp valeur_texture,4
				jne V5
					mov BYTE PTR [eax+6],'0'
					mov BYTE PTR [eax+7],'.'
					mov BYTE PTR [eax+8],'0'
					mov BYTE PTR [eax+9],','
					mov BYTE PTR [eax+10],'1'
					mov BYTE PTR [eax+11],'.'
					mov BYTE PTR [eax+12],'0'
					mov BYTE PTR [eax+13],','
V5:				
			;mise à jour du curseur_asm pour pointer sur le caractere suivant
			add curseur_asm,14	
			add compteur_octets,14
A2:			
			mov eax,ID_BUFFER_BLEND
			add eax,curseur_blend_intermediaire
			cmp BYTE PTR [eax],02Dh  ;'-'
			jne A3
			inc nombre_de_signe_moins
A3:
			inc curseur_blend_intermediaire	;pointe sur caractere suivant
			mov eax,curseur_blend
			add eax,33	
			cmp curseur_blend_intermediaire,eax	
			jne A2	
			
			mov ah,byte ptr longueur_ligne_vertex
			add ah,byte ptr nombre_de_signe_moins
			mov longueur_ligne_vertex,ah
			
			;stockage de cette ligne de vertex dans bufferAsm
			mov eax,curseur_blend
			mov curseur_blend_intermediaire,eax	
			add curseur_blend_intermediaire,4	
A4:
			mov eax,ID_BUFFER_ASM
			add eax,curseur_asm
			inc curseur_asm	;[buffer_asm+curseur_asm] pointe sur caractere suivant '0DWORD '
			inc compteur_octets
			mov ecx,ID_BUFFER_BLEND
			add ecx,curseur_blend_intermediaire
			mov dh,BYTE PTR [ecx]
				;mise en place des virgules
				cmp dh,20h
				jne A5
				mov BYTE PTR[eax],','
				jmp A6
A5:			mov BYTE PTR [eax],dh
A6:			inc curseur_blend_intermediaire
			mov ah,longueur_ligne_vertex
			dec ah
			mov longueur_ligne_vertex,ah
			cmp ah,0
			jne A4
				;ajout des caracteres de fin de lignes
			mov eax,ID_BUFFER_ASM
			add eax,curseur_asm
			mov BYTE PTR[eax],0Dh
			inc eax
			mov BYTE PTR[eax],0Ah
					
			;ici curseur_asm pointe sur sur le dernier caractere lu/ecrit
			inc curseur_asm	;pointe sur derniere position libre
			inc curseur_asm
			add compteur_octets,2
			mov eax,curseur_blend
			add eax,29
			add eax,nombre_de_signe_moins
			mov curseur_blend,eax
			
			;remise à zero
			mov curseur_blend_intermediaire,0
			mov nombre_de_signe_moins,0
			jmp Z1
			
NOvertex:			
			inc curseur_blend
			jmp Z1
Z1:
		inc compteur_boucle
		mov ebx,taille_fichier_obj
		cmp compteur_boucle,ebx	;à determiner en fonction de la taille du fichier(100 000)
		jne extraction

;---------------------------------------------------------------------
;deuxieme scanne du fichier blend en entier pour retrouver les faces
;----------------------------------------------------------------------

	mov curseur_blend,30h	
	mov curseur_blend_intermediaire,0
	mov compteur_boucle,0
	mov compteur_chiffre,0
	mov compteur_sommet,0
face:

	mov eax,ID_BUFFER_BLEND
	add eax,curseur_blend
	cmp BYTE PTR [eax],0Dh
	jne blabla
	cmp BYTE PTR [eax+1],0Ah
	jne blabla
	cmp BYTE PTR [eax+2],'f'
	jne blabla
	cmp BYTE PTR [eax+3],' '
	jne blabla
	;c'est une ligne de face,ecriture de "BYTE "
	mov ecx,ID_BUFFER_ASM
	add ecx,curseur_asm
	mov BYTE PTR [ecx],'W'
	mov BYTE PTR [ecx+1],'O'
	mov BYTE PTR [ecx+2],'R'
	mov BYTE PTR [ecx+3],'D'
	mov BYTE PTR [ecx+4],' '
	;curseur_asm pointe sur le caractere suivant ' '
	add curseur_asm,5
	add compteur_octets,5
	
	xor edx,edx
	xor esi,esi
	xor edi,edi
	mov esi,4
	mov edi,5
C0:
	mov dh,BYTE PTR[eax+esi]
	cmp dh,0Dh
	je stop
	cmp dh,20h
	je fin_chiffre
	;
	mov byte ptr[ecx+edi],dh
		inc compteur_chiffre
	inc esi
	inc edi
	jmp C0
	;
fin_chiffre:
	mov byte ptr[ecx+edi],','

	.if compteur_chiffre==1
		mov dl,49
F1:
	mov dh,byte ptr[ecx+edi-1]
	cmp dh,dl
	jne F2
	dec dl
	mov byte ptr[ecx+edi-1],dl
	jmp F4
F2:
	inc dl
	cmp dl,58
	je F4
	jmp F1
F4:
	.endif

	.if compteur_chiffre==2
		;xx='10' ?
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,49
		jne H1
		mov dh,byte ptr[ecx+edi-1]	
		cmp dh,48
		jne H1
		mov byte ptr[ecx+edi-2],20h ;on met un blanc
		mov byte ptr[ecx+edi-1],57	;9  10-1=blanc+'9'	
		jmp fin2
H1:	
		;xx=x0 ?
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48	;=0 ?
		jne H2
		mov byte ptr[ecx+edi-1],57 ;'9'
		mov dh,byte ptr[ecx+edi-2]
		dec dh	;dizaine-1
		mov byte ptr[ecx+edi-2],dh	; si xx=x0 alors xx=(x-1)9
		jmp fin2
H2:		
		;sinon xx=x(x-1)
		mov dh,byte ptr[ecx+edi-1]
		dec dh
		mov byte ptr[ecx+edi-1],dh
fin2:	
	.endif
	
	.if compteur_chiffre==3 ;x1=ecx+edi-3  x2=ecx+edi-2 x3=ecx+edi-1
		;xxx=100 ?	
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48	;x1=0 ?
		jne M1
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,48	;x2=0 ?
		jne M1
		mov dh,byte ptr[ecx+edi-3]
		cmp dh,48	;x1=1?
		jne M1
		;oui c'est 100 d'ou 100= 99
		mov byte ptr[ecx+edi-3],20h	;blanc
		mov byte ptr[ecx+edi-2],57	;9
		mov byte ptr[ecx+edi-1],57	;9
		jmp fin3suite
M1:		;xxx=x00 ?
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48
		jne M2
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,48
		jne M2
		;oui c'est x00 d'ou xxx=(x-1)99
		mov byte ptr[ecx+edi-1],57	;9
		mov byte ptr[ecx+edi-2],57	;9
		mov dh,byte ptr[ecx+edi-3]
		dec dh
		mov byte ptr[ecx+edi-3],dh
		jmp fin3suite
M2:		
		;xxx=xx0 ?
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48	;=0 ?
		jne M3
		;oui d'ou xx0=x(x-1)9
		mov byte ptr[ecx+edi-1],57	;9
		mov dh,byte ptr[ecx+edi-2]
		dec dh
		mov byte ptr[ecx+edi-2],dh	;x2=x2-1
		;x3 ne change pas,on s'en occupe pas
		jmp fin3suite	
M3:		;sinon xxx=xx(x-1)
		mov dh,byte ptr[ecx+edi-1]
		dec dh
		mov byte ptr[ecx+edi-1],dh

fin3suite:
	.endif
	
	.if compteur_chiffre==4
		;xxxx=1000 d'ou = 999
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48	;=0 ?
		jne O1		
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,48	;=0 ?
		jne O1
		mov dh,byte ptr[ecx+edi-3]
		cmp dh,48	;=0 ?
		jne O1
		mov dh,byte ptr[ecx+edi-4]
		cmp dh,49	;=1 ?
		;ok c'est 1000
		mov byte ptr[ecx+edi-4],20h	;espace
		mov byte ptr[ecx+edi-3],57	;9
		mov byte ptr[ecx+edi-2],57	;9
		mov byte ptr[ecx+edi-1],57	;9
		jmp fin4
O1:		;xxxx=x000 d'ou =(x-1)999
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48
		jne O2
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,48
		jne O2
		mov dh,byte ptr[ecx+edi-3]
		cmp dh,48
		jne O2
		;ok c'est x000
		mov dh,byte ptr[ecx+edi-4]
		dec dh
		mov byte ptr[ecx+edi-4],dh
		mov byte ptr[ecx+edi-3],57	;9
		mov byte ptr[ecx+edi-2],57	;9
		mov byte ptr[ecx+edi-1],57	;9
		jmp fin4		
O2:		;xxxx=xx00 d'ou =x(x-1)99
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48
		jne O3
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,48
		jne O3
		;ok c'est xx00
		mov dh,byte ptr[ecx+edi-3]
		dec dh
		mov byte ptr[ecx+edi-3],dh
		mov byte ptr[ecx+edi-2],57	;9
		mov byte ptr[ecx+edi-1],57	;9
		jmp fin4		
		
O3:		;xxxx=xxx0 d'ou =xx(x-1)9
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48
		jne O4
		;ok c'est xxx0
		mov dh,byte ptr[ecx+edi-2]
		dec dh
		mov byte ptr[ecx+edi-2],dh	
		mov byte ptr[ecx+edi-1],57 ;9
		jmp fin4
O4:		;sinon xxxx=xxx(x-1)
		mov dh,byte ptr[ecx+edi-1]
		dec dh
		mov byte ptr[ecx+edi-1],dh
fin4:		
	.endif
	
		mov compteur_chiffre,0
		inc compteur_sommet
		
	inc esi
	inc edi
	jmp C0
stop:
	;ici on teste le dernier paquet de chiffres (qui n'est pas suivi de virgules)

	.if compteur_chiffre==1
		mov dl,49
G1:
	mov dh,byte ptr[ecx+edi-1]
	cmp dh,dl
	jne G2
	dec dl
	mov byte ptr[ecx+edi-1],dl
	jmp G4
G2:
	inc dl
	cmp dl,58
	je G4
	jmp G1
G4:
	.endif

	
	.if compteur_chiffre==2
		
		;xx='10' ?
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,49
		jne J1
		mov dh,byte ptr[ecx+edi-1]	
		cmp dh,48
		jne J1
		mov byte ptr[ecx+edi-2],20h ;on met un blanc
		mov byte ptr[ecx+edi-1],57	;9  10-1=blanc+'9'
		jmp fin2bis	
J1:	
		;xx=x0 ?
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48	;=0 ?
		jne J2
		mov byte ptr[ecx+edi-1],57 ;'9'
		mov dh,byte ptr[ecx+edi-2]
		dec dh	;dizaine-1
		mov byte ptr[ecx+edi-2],dh	; si xx=x0 alors xx=(x-1)9
		jmp fin2bis
J2:	
		;sinon xx=x(x-1)
		mov dh,byte ptr[ecx+edi-1]
		dec dh
		mov byte ptr[ecx+edi-1],dh
fin2bis:	
	.endif
	
	.if compteur_chiffre==3 
		;xxx=100 ?	
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48	;x1=0 ?
		jne K1
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,48	;x2=0 ?
		jne K1
		mov dh,byte ptr[ecx+edi-3]
		cmp dh,48	;x1=1?
		jne K1
		;oui c'est 100 d'ou 100= 99
		mov byte ptr[ecx+edi-3],20h	;blanc
		mov byte ptr[ecx+edi-2],57	;9
		mov byte ptr[ecx+edi-1],57	;9
		jmp fin3
K1:		;xxx=x00 ?
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48
		jne K2
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,48
		jne K2
		;oui c'est x00 d'ou xxx=(x-1)99
		mov byte ptr[ecx+edi-1],57	;9
		mov byte ptr[ecx+edi-2],57	;9
		mov dh,byte ptr[ecx+edi-3]
		dec dh
		mov byte ptr[ecx+edi-3],dh
		jmp fin3
K2:		
		;xxx=xx0 ?
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48	;=0 ?
		jne K3
		;oui d'ou xx0=x(x-1)9
		mov byte ptr[ecx+edi-1],57	;9
		mov dh,byte ptr[ecx+edi-2]
		dec dh
		mov byte ptr[ecx+edi-2],dh	;x2=x2-1
		;x3 ne change pas,on s'en occupe pas
		jmp fin3	
K3:		;sinon xxx=xx(x-1)
		mov dh,byte ptr[ecx+edi-1]
		dec dh
		mov byte ptr[ecx+edi-1],dh

fin3:
	.endif
	
	.if compteur_chiffre==4
		;xxxx=1000 d'ou = 999
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48	;=0 ?
		jne P1		
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,48	;=0 ?
		jne P1
		mov dh,byte ptr[ecx+edi-3]
		cmp dh,48	;=0 ?
		jne P1
		mov dh,byte ptr[ecx+edi-4]
		cmp dh,49	;=1 ?
		;ok c'est 1000
		mov byte ptr[ecx+edi-4],20h	;espace
		mov byte ptr[ecx+edi-3],57	;9
		mov byte ptr[ecx+edi-2],57	;9
		mov byte ptr[ecx+edi-1],57	;9
		jmp fin4suite
P1:		;xxxx=x000 d'ou =(x-1)999
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48
		jne P2
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,48
		jne P2
		mov dh,byte ptr[ecx+edi-3]
		cmp dh,48
		jne P2
		;ok c'est x000
		mov dh,byte ptr[ecx+edi-4]
		dec dh
		mov byte ptr[ecx+edi-4],dh
		mov byte ptr[ecx+edi-3],57	;9
		mov byte ptr[ecx+edi-2],57	;9
		mov byte ptr[ecx+edi-1],57	;9
		jmp fin4suite		
P2:		;xxxx=xx00 d'ou =x(x-1)99
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48
		jne P3
		mov dh,byte ptr[ecx+edi-2]
		cmp dh,48
		jne P3
		;ok c'est xx00
		mov dh,byte ptr[ecx+edi-3]
		dec dh
		mov byte ptr[ecx+edi-3],dh
		mov byte ptr[ecx+edi-2],57	;9
		mov byte ptr[ecx+edi-1],57	;9
		jmp fin4suite		
		
P3:		;xxxx=xxx0 d'ou =xx(x-1)9
		mov dh,byte ptr[ecx+edi-1]
		cmp dh,48
		jne P4
		;ok c'est xxx0
		mov dh,byte ptr[ecx+edi-2]
		dec dh
		mov byte ptr[ecx+edi-2],dh	
		mov byte ptr[ecx+edi-1],57 ;9
		jmp fin4suite
P4:		;sinon xxxx=xxx(x-1)
		mov dh,byte ptr[ecx+edi-1]
		dec dh
		mov byte ptr[ecx+edi-1],dh
fin4suite:		
	.endif
	
	mov compteur_chiffre,0
	inc compteur_sommet
	mov byte ptr[ecx+edi],0Dh
	mov byte ptr[ecx+edi+1],0Ah
	add curseur_blend,esi
	add curseur_asm,edi
	add compteur_octets,edi
	jmp Y1
	
blabla:
	
	inc curseur_blend
	jmp Y1
		
Y1:

	inc compteur_boucle
	;cmp compteur_boucle,390	;à determiner en fonction de la taille du fichier
	mov ebx,taille_fichier_obj
	dec ebx
	dec ebx	;taille_fichier-2
	cmp compteur_boucle,ebx	;à determiner en fonction de la taille du fichier(100 000)
	jne face

;-------------------------------------
;fin du traitement du fichier blend
;-------------------------------------
	;affichage du nombre de sommets total
	
	mov byte ptr[ecx+edi+2],0Dh
	mov byte ptr[ecx+edi+3],0Ah
	mov byte ptr[ecx+edi+4],';'
	
	;
	add edi,18
	add compteur_octets,18

.data
	stocke qword 0
.code
	fild compteur_sommet
	fistp dword ptr[stocke]	
	;
	cmp compteur_sommet,10
	jae cont	;>=10 ? saut si gauche>=droit
	xor edx,edx
	mov dl,byte ptr compteur_sommet
	add dl,030h
	mov byte ptr[ecx+edi],dl
	jmp bye
cont:	
	
divise:
	mov edx,dword ptr stocke+4
	mov eax,dword ptr stocke
	mov ebx,10
	div ebx
	mov dword ptr stocke,eax	;eax=resultat
	add edx,030h				;edx=reste
	mov byte ptr[ecx+edi],dl
	;resultat=10 ?
	cmp dword ptr stocke,10
	jne cont1
	;oui
	mov byte ptr[ecx+edi],'0'
	mov byte ptr[ecx+edi-1],'1'
	jmp bye
cont1:	;resultat<10 ?
	cmp dword ptr stocke,10
	ja cont2	;saut si gauche>droit
	;oui
	xor edx,edx
	mov dl,byte ptr stocke
	add dl,30h
	mov byte ptr[ecx+edi-1],dl
	jmp bye
cont2:	;resultat>10 on peut encore diviser
		dec edi
		jmp divise

bye:	
	add edi,10
	add compteur_octets,10

	mov byte ptr[ecx+edi+2],' '
	mov byte ptr[ecx+edi+2],'S'
	mov byte ptr[ecx+edi+3],'O'
	mov byte ptr[ecx+edi+4],'M'
	mov byte ptr[ecx+edi+5],'M'
	mov byte ptr[ecx+edi+6],'E'
	mov byte ptr[ecx+edi+7],'T'
	mov byte ptr[ecx+edi+8],'S'
	
	mov byte ptr[ecx+edi+9],0Dh
	mov byte ptr[ecx+edi+10],0Ah
	
;nettoyage position inoccupée du bufferAsm

	add compteur_octets,30	
	add curseur_asm,38	
	;mov eax,NbreOctetFichierBlend
	mov eax,taille_fichier_obj
	shl eax,1	;eax=eax*2
	sub eax,dword ptr compteur_octets
	
.data
	x	dword ?
.code
	mov x,eax
	mov eax,ID_BUFFER_ASM
	add eax,curseur_asm	
nettoie:
	mov byte ptr[eax],0h
	inc eax
	dec x
	cmp x,0
	jne nettoie
	ret

traduction endp

end debut

Conclusion :


MasmBlend rend moins pénible l'inclusion d'objets 3d dans un prog masm Open GL.

Codes Sources

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.