View 3DS 0.69 by macgub:

1. 32bit vertices indexes and ability to load whole RAM limited objects. (Above 65535 vertices and triangles).
2. I switch off painters algotithm mode (depth sorting). In app impelementetion it has limited vertices count and produce less quality image than Z buffer Catmull algo. In addition this switch off reduces app size.

git-svn-id: svn://kolibrios.org@8014 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-06-01 15:44:39 +00:00
parent f6ab28ae5b
commit 4b8e0542e3
12 changed files with 4183 additions and 6247 deletions

View File

@ -160,6 +160,7 @@ reverse_mx_3x3:
ret ret
make_vector_r: make_vector_r:
if Ext < SSE2
fninit fninit
fld dword[edi] ;edi+x3d fld dword[edi] ;edi+x3d
fsub dword[esi] ;esi+x3d fsub dword[esi] ;esi+x3d
@ -172,6 +173,14 @@ make_vector_r:
fld dword[edi+8] fld dword[edi+8]
fsub dword[esi+8] fsub dword[esi+8]
fstp dword[ebx+vec_z] fstp dword[ebx+vec_z]
else
movups xmm0,[esi]
movups xmm1,[edi]
subps xmm1,xmm0
movlps [ebx],xmm1
movhlps xmm1,xmm1
movss [ebx+8],xmm1
end if
ret ret
;---------------------- in: ------------------------------- ;---------------------- in: -------------------------------

View File

@ -31,7 +31,7 @@ read_asc:
mov ebx,eax mov ebx,eax
push eax push eax
call ascii_to_integer call ascii_to_integer
mov [points_count_var],dx mov [points_count_var],edx
pop eax pop eax
@@: @@:
@ -59,7 +59,7 @@ read_asc:
mov ebx,eax mov ebx,eax
push eax push eax
call ascii_to_integer call ascii_to_integer
mov [triangles_count_var],dx mov [triangles_count_var],edx
pop eax pop eax
@@: @@:
@ -114,7 +114,7 @@ read_asc:
jne .decode_coord jne .decode_coord
pop ebx pop ebx
inc ebx inc ebx
cmp bx,[points_count_var] cmp ebx,[points_count_var]
jne .decode_vertices jne .decode_vertices
mov dword[edi],-1 mov dword[edi],-1
@ -175,9 +175,9 @@ read_asc:
call ascii_to_integer call ascii_to_integer
mov eax,edx mov eax,edx
stosw stosd
pop esi pop esi
add esi,2 add esi,4
pop ecx pop ecx
inc ecx inc ecx
@ -185,7 +185,7 @@ read_asc:
jne .next_vertex_number jne .next_vertex_number
pop edx pop edx
inc edx inc edx
cmp dx,[triangles_count_var] cmp edx,[triangles_count_var]
jne .decode_face jne .decode_face
mov dword[edi],-1 ;dword[triangles+ebx+2],-1 ; end mark mov dword[edi],-1 ;dword[triangles+ebx+2],-1 ; end mark
mov eax,1 ;-> mark if ok mov eax,1 ;-> mark if ok

View File

@ -111,7 +111,7 @@ ret
draw_dots: draw_dots:
mov esi,[points_translated_ptr] mov esi,[points_translated_ptr]
movzx ecx,[points_count_var] mov ecx,[points_count_var]
.drw: .drw:
@@: @@:
lodsd lodsd
@ -486,24 +486,24 @@ generate_object2: ; torus
jle .next jle .next
mov edi,[triangles_ptr] mov edi,[triangles_ptr]
mov ax,4 mov eax,4
mov bx,4+4 mov ebx,4+4
mov [triangles_count_var],164*3 ;140 mov [triangles_count_var],160*3 ;164*3 ;140
mov cx,80*3 ;68 mov ecx,80*3 ;68
@@: @@:
stosw ;---- stosd ;----
mov [edi],bx ; | mov [edi],ebx ; |
add edi,2 ; | add edi,4 ; |
inc ax ; | inc eax ; |
stosw ; |repeat 4 times stosd ; |repeat 4 times
mov [edi],bx ; | mov [edi],ebx ; |
inc bx inc ebx
add edi,2 add edi,4
stosw ; | stosd ; |
mov [edi],bx ; | mov [edi],ebx ; |
add edi,2 ;---- add edi,4 ;----
loop @b loop @b
@ -627,76 +627,76 @@ generate_object3: ; heart
; init triangles list ; init triangles list
mov edi,[triangles_ptr] mov edi,[triangles_ptr]
mov ax,5 mov eax,5
mov bx,5+5 mov ebx,5+5
mov [triangles_count_var],204 mov [triangles_count_var],200 ;204
mov cx,100 mov ecx,100
@@: @@:
stosw ;---- stosd ;----
mov [edi],bx ; | mov [edi],ebx ; |
add edi,2 ; | add edi,4 ; |
inc ax ; | inc eax ; |
stosw ; |repeat stosd ; |repeat
mov [edi],bx ; | mov [edi],ebx ; |
inc bx inc ebx
add edi,2 add edi,4
stosw ; | stosd ; |
mov [edi],bx ; | mov [edi],ebx ; |
add edi,2 ;---- add edi,4 ;----
loop @b loop @b
mov ax,5 mov eax,5
mov bx,[points_count_var] mov ebx,[points_count_var]
sub bx,2 sub ebx,2
mov dl,2 mov dl,2
.nx: .nx:
mov cx,5 mov ecx,5
add [triangles_count_var],cx add [triangles_count_var],ecx
@@: @@:
stosw stosd
add ax,5 add eax,5
stosw stosd
mov word[edi],bx mov dword[edi],ebx
add edi,2 add edi,4
loop @b loop @b
cmp dl,1 cmp dl,1
je @f je @f
inc bx inc ebx
jmp .lab jmp .lab
@@: @@:
dec bx dec ebx
.lab: .lab:
mov cx,5 mov ecx,5
add [triangles_count_var],cx add [triangles_count_var],ecx
@@: @@:
stosw stosd
add ax,5 add eax,5
stosw stosd
mov word[edi],bx mov dword[edi],ebx
add edi,2 add edi,4
loop @b loop @b
dec dl dec dl
or dl,dl or dl,dl
jnz .nx jnz .nx
sub ax,25 sub eax,25
stosw stosd
sub ax,50 sub eax,50
stosw stosd
mov word[edi],bx mov dword[edi],ebx
add edi,2 add edi,4
stosw stosd
add ax,50 add eax,50
stosw stosd
inc bx inc ebx
mov word[edi],bx mov dword[edi],ebx
add edi,2 add edi,4
add [triangles_count_var],2 add [triangles_count_var],2
mov dword[edi],-1 ; < - end mark mov dword[edi],-1 ; < - end mark
@ -706,3 +706,4 @@ generate_object3: ; heart
pop ebp pop ebp
ret ret

View File

@ -1,630 +0,0 @@
;------- Big thanks to majuma (www.majuma.xt.pl) for absolutelly great--
;------- 13h mode demos ------------------------------------------------
bump_triangle:
;------------------in - eax - x1 shl 16 + y1 -----------
;---------------------- ebx - x2 shl 16 + y2 -----------
;---------------------- ecx - x3 shl 16 + y3 -----------
;---------------------- edx - pointer to bump map ------
;---------------------- esi - pointer to environment map
;---------------------- edi - pointer to screen buffer--
;---------------------- stack : bump coordinates--------
;---------------------- environment coordinates-
.b_x1 equ ebp+4 ; procedure don't save registers !!!
.b_y1 equ ebp+6 ; each coordinate as word
.b_x2 equ ebp+8
.b_y2 equ ebp+10
.b_x3 equ ebp+12
.b_y3 equ ebp+14
.e_x1 equ ebp+16
.e_y1 equ ebp+18
.e_x2 equ ebp+20
.e_y2 equ ebp+22
.e_x3 equ ebp+24
.e_y3 equ ebp+26
.t_bmap equ dword[ebp-4]
.t_emap equ dword[ebp-8]
.x1 equ word[ebp-10]
.y1 equ word[ebp-12]
.x2 equ word[ebp-14]
.y2 equ word[ebp-16]
.x3 equ word[ebp-18]
.y3 equ word[ebp-20]
.dx12 equ dword[ebp-24]
.dbx12 equ dword[ebp-28]
.dby12 equ dword[ebp-32]
.dex12 equ dword[ebp-36]
.dey12 equ dword[ebp-40]
.dx13 equ dword[ebp-44]
.dbx13 equ dword[ebp-48]
.dby13 equ dword[ebp-52]
.dex13 equ dword[ebp-56]
.dey13 equ dword[ebp-60]
.dx23 equ dword[ebp-64]
.dbx23 equ dword[ebp-68]
.dby23 equ dword[ebp-72]
.dex23 equ dword[ebp-76]
.dey23 equ dword[ebp-80]
.cx1 equ dword[ebp-84] ; current variables
.cx2 equ dword[ebp-88]
.cbx1 equ dword[ebp-92]
.cbx2 equ dword[ebp-96]
.cby1 equ dword[ebp-100]
.cby2 equ dword[ebp-104]
.cex1 equ dword[ebp-108]
.cex2 equ dword[ebp-112]
.cey1 equ dword[ebp-116]
.cey2 equ dword[ebp-120]
mov ebp,esp
push edx ; store bump map
push esi ; store e. map
; sub esp,120
.sort3: ; sort triangle coordinates...
cmp ax,bx
jle .sort1
xchg eax,ebx
mov edx,dword[.b_x1]
xchg edx,dword[.b_x2]
mov dword[.b_x1],edx
mov edx,dword[.e_x1]
xchg edx,dword[.e_x2]
mov dword[.e_x1],edx
.sort1:
cmp bx,cx
jle .sort2
xchg ebx,ecx
mov edx,dword[.b_x2]
xchg edx,dword[.b_x3]
mov dword[.b_x2],edx
mov edx,dword[.e_x2]
xchg edx,dword[.e_x3]
mov dword[.e_x2],edx
jmp .sort3
.sort2:
push eax ; store triangle coords in variables
push ebx
push ecx
mov edx,eax ; eax,ebx,ecx are ORd together into edx which means that
or edx,ebx ; if any *one* of them is negative a sign flag is raised
or edx,ecx
test edx,80000000h ; Check only X
jne .loop23_done
mov dx,[size_x_var]
cmp .x1,dx ;SIZE_X ; {
jg .loop23_done
cmp .x2,dx ;SIZE_X ; This can be optimized with effort
jg .loop23_done
cmp .x3,dx ;SIZE_X
jg .loop23_done ; {
mov bx,.y2 ; calc delta 12
sub bx,.y1
jnz .bt_dx12_make
mov ecx,5
xor edx,edx
@@:
push edx ;dword 0
loop @b
jmp .bt_dx12_done
.bt_dx12_make:
mov ax,.x2
sub ax,.x1
cwde
movsx ebx,bx
shl eax,ROUND
cdq
idiv ebx
; mov .dx12,eax
push eax
mov ax,word[.b_x2]
sub ax,word[.b_x1]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dbx12,eax
push eax
mov ax,word[.b_y2]
sub ax,word[.b_y1]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dby12,eax
push eax
mov ax,word[.e_x2]
sub ax,word[.e_x1]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dex12,eax
push eax
mov ax,word[.e_y2]
sub ax,word[.e_y1]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dey12,eax
push eax
.bt_dx12_done:
mov bx,.y3 ; calc delta13
sub bx,.y1
jnz .bt_dx13_make
mov ecx,5
xor edx,edx
@@:
push edx ;dword 0
loop @b
jmp .bt_dx13_done
.bt_dx13_make:
mov ax,.x3
sub ax,.x1
cwde
movsx ebx,bx
shl eax,ROUND
cdq
idiv ebx
; mov .dx13,eax
push eax
mov ax,word[.b_x3]
sub ax,word[.b_x1]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dbx13,eax
push eax
mov ax,word[.b_y3]
sub ax,word[.b_y1]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dby13,eax
push eax
mov ax,word[.e_x3]
sub ax,word[.e_x1]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dex13,eax
push eax
mov ax,word[.e_y3]
sub ax,word[.e_y1]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dey13,eax
push eax
.bt_dx13_done:
mov bx,.y3 ; calc delta23
sub bx,.y2
jnz .bt_dx23_make
mov ecx,5
xor edx,edx
@@:
push edx ;dword 0
loop @b
jmp .bt_dx23_done
.bt_dx23_make:
mov ax,.x3
sub ax,.x2
cwde
movsx ebx,bx
shl eax,ROUND
cdq
idiv ebx
; mov .dx23,eax
push eax
mov ax,word[.b_x3]
sub ax,word[.b_x2]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dbx23,eax
push eax
mov ax,word[.b_y3]
sub ax,word[.b_y2]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dby23,eax
push eax
mov ax,word[.e_x3]
sub ax,word[.e_x2]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dex23,eax
push eax
mov ax,word[.e_y3]
sub ax,word[.e_y2]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dey23,eax
push eax
; sub esp,40
.bt_dx23_done:
movsx eax,.x1
shl eax,ROUND
; mov .cx1,eax
; mov .cx2,eax
push eax
push eax
movsx eax,word[.b_x1]
shl eax,ROUND
; mov .cbx1,eax
; mov .cbx2,eax
push eax
push eax
movsx eax,word[.b_y1]
shl eax,ROUND
; mov .cby1,eax
; mov .cby2,eax
push eax
push eax
movsx eax,word[.e_x1]
shl eax,ROUND
;mov .cex1,eax
;mov .cex2,eax
push eax
push eax
movsx eax,word[.e_y1]
shl eax,ROUND
;mov .cey1,eax
;mov .cey2,eax
push eax
push eax
movzx ecx,.y1
cmp cx,.y2
jge .loop12_done
.loop12:
call .call_bump_line
mov eax,.dx13
add .cx1,eax
mov eax,.dx12
add .cx2,eax
mov eax,.dbx13
add .cbx1,eax
mov eax,.dbx12
add .cbx2,eax
mov eax,.dby13
add .cby1,eax
mov eax,.dby12
add .cby2,eax
mov eax,.dex13
add .cex1,eax
mov eax,.dex12
add .cex2,eax
mov eax,.dey13
add .cey1,eax
mov eax,.dey12
add .cey2,eax
inc ecx
cmp cx,.y2
jl .loop12
.loop12_done:
movzx ecx,.y2
cmp cx,.y3
jge .loop23_done
movzx eax,.x2
shl eax,ROUND
mov .cx2,eax
movzx eax,word[.b_x2]
shl eax,ROUND
mov .cbx2,eax
movzx eax,word[.b_y2]
shl eax,ROUND
mov .cby2,eax
movzx eax,word[.e_x2]
shl eax,ROUND
mov .cex2,eax
movzx eax,word[.e_y2]
shl eax,ROUND
mov .cey2,eax
.loop23:
call .call_bump_line
mov eax,.dx13
add .cx1,eax
mov eax,.dx23
add .cx2,eax
mov eax,.dbx13
add .cbx1,eax
mov eax,.dbx23
add .cbx2,eax
mov eax,.dby13
add .cby1,eax
mov eax,.dby23
add .cby2,eax
mov eax,.dex13
add .cex1,eax
mov eax,.dex23
add .cex2,eax
mov eax,.dey13
add .cey1,eax
mov eax,.dey23
add .cey2,eax
inc ecx
cmp cx,.y3
jl .loop23
.loop23_done:
mov esp,ebp
ret 24
.call_bump_line:
; push ebp
; push ecx
pushad
push .t_emap
push .t_bmap
push .cey2
push .cex2
push .cey1
push .cex1
push .cby2
push .cbx2
push .cby1
push .cbx1
push ecx
mov eax,.cx1
sar eax,ROUND
mov ebx,.cx2
sar ebx,ROUND
call bump_line
popad
ret
bump_line:
;--------------in: eax - x1
;-------------- ebx - x2
;-------------- edi - pointer to screen buffer
;stack - another parameters :
.y equ dword [ebp+4]
.bx1 equ [ebp+8] ; ---
.by1 equ dword [ebp+12] ; |
.bx2 equ [ebp+16] ; |
.by2 equ dword [ebp+20] ; |> bump and env coords
.ex1 equ [ebp+24] ; |> shifted shl ROUND
.ey1 equ dword [ebp+28] ; |
.ex2 equ [ebp+32] ; |
.ey2 equ dword [ebp+36] ; ---
.bmap equ dword [ebp+40]
.emap equ dword [ebp+44]
.x1 equ dword [ebp-4]
.x2 equ dword [ebp-8]
.dbx equ dword [ebp-12]
.dby equ [ebp-16]
.dex equ dword [ebp-20]
.dey equ [ebp-24]
.cbx equ dword [ebp-28]
.cby equ [ebp-32]
.cex equ dword [ebp-36]
.cey equ [ebp-40]
mov ebp,esp
mov ecx,.y
or ecx,ecx
jl .bl_end
movzx edx,word[size_y_var]
cmp ecx,edx ;SIZE_Y
jge .bl_end
cmp eax,ebx
jl .bl_ok
je .bl_end
xchg eax,ebx
if Ext = NON
mov edx,.bx1
xchg edx,.bx2
mov .bx1,edx
mov edx,.by1
xchg edx,.by2
mov .by1,edx
mov edx,.ex1
xchg edx,.ex2
mov .ex1,edx
mov edx,.ey1
xchg edx,.ey2
mov .ey1,edx
else
movq mm0,.bx1
movq mm1,.bx2
movq mm2,.ex1
movq mm3,.ex2
movq .bx2,mm0
movq .bx1,mm1
movq .ex1,mm3
movq .ex2,mm2
end if
.bl_ok:
push eax
push ebx ;store x1, x2
movzx eax,word[size_x_var]
lea eax,[eax*3]
; mov eax,SIZE_X*3
mov ebx,.y
mul ebx
mov ecx,.x1
lea ecx,[ecx*3]
add eax,ecx
add edi,eax
mov ecx,.x2
sub ecx,.x1
mov eax,.bx2 ; calc .dbx
sub eax,.bx1
cdq
idiv ecx
push eax
mov eax,.by2 ; calc .dby
sub eax,.by1
cdq
idiv ecx
push eax
mov eax,.ex2 ; calc .dex
sub eax,.ex1
cdq
idiv ecx
push eax
mov eax,.ey2 ; calc .dey
sub eax,.ey1
cdq
idiv ecx
push eax
push dword .bx1
push .by1
push dword .ex1
push .ey1
.draw:
; if TEX = SHIFTING ;bump drawing only in shifting mode
mov eax,.cby
sar eax,ROUND
shl eax,TEX_SHIFT
mov esi,.cbx
sar esi,ROUND
add esi,eax
mov ebx,esi
dec ebx
and ebx,TEXTURE_SIZE
add ebx,.bmap
movzx eax,byte [ebx]
mov ebx,esi
inc ebx
and ebx,TEXTURE_SIZE
add ebx,.bmap
movzx ebx,byte [ebx]
sub eax,ebx
mov ebx,esi
sub ebx,TEX_X
and ebx,TEXTURE_SIZE
add ebx,.bmap
movzx edx,byte [ebx]
mov ebx,esi
add ebx,TEX_X
and ebx,TEXTURE_SIZE
add ebx,.bmap
movzx ebx,byte [ebx]
sub edx,ebx
mov ebx,.cex ;.cex - current env map X
sar ebx,ROUND
add eax,ebx ; eax - modified x coord
mov ebx,.cey ;.cey - current env map y
sar ebx,ROUND
add edx,ebx ; edx - modified y coord
or eax,eax
jl .black
cmp eax,TEX_X
jg .black
or edx,edx
jl .black
cmp edx,TEX_Y
jg .black
shl edx,TEX_SHIFT
add edx,eax
lea edx,[edx*3]
add edx,.emap
mov eax,dword[edx]
jmp .put_pixel
.black:
xor eax,eax
.put_pixel:
stosd
dec edi
;if Ext >= MMX
; movq mm0,.cby
; movq mm1,.cey
; paddd mm0,.dby
; paddd mm1,.dey
; movq .cby,mm0
; movq .cey,mm1
;else
mov eax,.dbx
add .cbx,eax
mov eax,.dby
add .cby,eax
mov eax,.dex
add .cex,eax
mov eax,.dey
add .cey,eax
;end if
dec ecx
jnz .draw
; end if
.bl_end:
mov esp,ebp
ret 44

View File

@ -280,12 +280,12 @@ optimize_object1: ; setting point (0,0,0) in center of object
xor ebx,ebx ; ebx - x,y,z coord in real_points list xor ebx,ebx ; ebx - x,y,z coord in real_points list
.next_c: ; max/min/center x,y,z .next_c: ; max/min/center x,y,z
mov edi,[points_ptr] ; in real_point list minimum two points mov edi,[points_ptr] ; in real_point list minimum two points
mov dx,[points_count_var] mov edx,[points_count_var]
fld dword[edi+ebx] fld dword[edi+ebx]
fst .max fst .max
fstp .min fstp .min
add edi,12 add edi,12
dec dx dec edx
.next_coord: ; next coord from real_points list .next_coord: ; next coord from real_points list
fld dword [edi+ebx] ; real_points -> x,y,z fld dword [edi+ebx] ; real_points -> x,y,z
fcom .max ; max_x,y,z fcom .max ; max_x,y,z
@ -305,7 +305,7 @@ optimize_object1: ; setting point (0,0,0) in center of object
.end_coords: .end_coords:
add edi,12 add edi,12
; cmp dword[edi],-1 ; cmp with end mark ; cmp dword[edi],-1 ; cmp with end mark
dec dx dec edx
jnz .next_coord jnz .next_coord
; ok after this we found max_coord and min_coord ; ok after this we found max_coord and min_coord
fld .max ; find center point fld .max ; find center point
@ -326,7 +326,7 @@ optimize_object1: ; setting point (0,0,0) in center of object
@@: @@:
ffree st ffree st
mov edi,[points_ptr] mov edi,[points_ptr]
mov dx,[points_count_var] ; substraction all coords - center point mov edx,[points_count_var] ; substraction all coords - center point
@@: @@:
fld dword[edi+ebx] fld dword[edi+ebx]
fsub .center fsub .center
@ -334,7 +334,7 @@ optimize_object1: ; setting point (0,0,0) in center of object
add edi,12 add edi,12
; cmp dword[edi],-1 ; cmp dword[edi],-1
; jne @b ; jne @b
dec dx dec edx
jnz @b jnz @b
add ebx,4 ; ebx - x,y,z cooficientes in list real_points add ebx,4 ; ebx - x,y,z cooficientes in list real_points
@ -343,7 +343,7 @@ optimize_object1: ; setting point (0,0,0) in center of object
fld .maxxx fld .maxxx
mov edi,[points_ptr] ; create all coords in <-1.0,1.0> mov edi,[points_ptr] ; create all coords in <-1.0,1.0>
movzx ecx,[points_count_var] mov ecx,[points_count_var]
@@: @@:
fld dword[edi] fld dword[edi]
fdiv .maxxx fdiv .maxxx
@ -405,78 +405,78 @@ generate_object: ; generate node
;init triangles list ;init triangles list
mov edi,[triangles_ptr] mov edi,[triangles_ptr]
xor si,si xor esi,esi
xor ax,ax xor eax,eax
mov bx,.N+1 mov ebx,.N+1
mov cx,(.N*2)+2 ;-- mov ecx,(.N*2)+2 ;--
mov dx,(.N*3)+3 ;--- mov edx,(.N*3)+3 ;---
mov [triangles_count_var],0 mov [triangles_count_var],0
.again_tri: .again_tri:
stosw ; main wave stosd ; main wave
mov word[edi],bx mov dword[edi],ebx
inc ax inc eax
add edi,2 add edi,4
stosw stosd
stosw stosd
mov word[edi],bx mov dword[edi],ebx
inc bx inc ebx
mov word[edi+2],bx mov dword[edi+4],ebx
add edi,8
mov dword[edi],ecx ;---- ; n2+2 ; xor ax,ax
inc ecx ; n2+3 ; mov bx,.N+1
mov dword[edi+4],edx ; ; mov cx,(.N*2)+2 ;--
mov dword[edi+8],ecx ; n3+3 ; mov dx,(.N*3)+3 ;---
mov dword[edi+12],edx ; n3+3 ;
inc edx ; ;
mov dword[edi+16],edx ; n2+3 ;
mov dword[edi+20],ecx ; n3+4
add edi,24 ;----
dec eax ; border of wave
dec ebx
dec ecx
dec edx
stosd ; first border
inc eax
stosd
mov dword[edi],edx
add edi,4 add edi,4
mov word[edi],cx ;---- ; n2+2 ; xor ax,ax mov dword[edi],edx
inc cx ; n2+3 ; mov bx,.N+1 add edi,4
mov word[edi+2],dx ; ; mov cx,(.N*2)+2 ;-- stosd
mov word[edi+4],cx ; n3+3 ; mov dx,(.N*3)+3 ;--- inc edx
mov word[edi+6],dx ; n3+3 ; mov dword[edi],edx
inc dx ; ;
mov word[edi+8],dx ; n2+3 ;
mov word[edi+10],cx ; n3+4
add edi,12 ;----
dec ax ; border of wave mov dword[edi+4],ebx ; second border
dec bx mov dword[edi+8],ecx
dec cx inc ebx
dec dx mov dword[edi+12],ebx
stosw ; first border mov dword[edi+16],ebx
inc ax mov dword[edi+20],ecx
stosw inc ecx
mov word[edi],dx mov dword[edi+24],ecx
add edi,2 add edi,28
mov word[edi],dx
add edi,2
stosw
inc dx
mov word[edi],dx
mov word[edi+2],bx ; second border
mov word[edi+4],cx
inc bx
mov word[edi+6],bx
mov word[edi+8],bx
mov word[edi+10],cx
inc cx
mov word[edi+12],cx
add edi,14
add [triangles_count_var],8 ;10 add [triangles_count_var],8 ;10
inc si inc esi
cmp si,.N cmp esi,.N
jne .again_tri jne .again_tri
add ax,((.N+1)*3)+1 add eax,((.N+1)*3)+1
add bx,((.N+1)*3)+1 add ebx,((.N+1)*3)+1
add cx,((.N+1)*3)+1 add ecx,((.N+1)*3)+1
add dx,((.N+1)*3)+1 add edx,((.N+1)*3)+1
xor si,si xor esi,esi
cmp ax,(.N*13)+13 ;;;(.N*23)+23 ; ax,(.N*13)+13 cmp eax,(.N*13)+13 ;;;(.N*23)+23 ; ax,(.N*13)+13
jl .again_tri jl .again_tri
mov dword[edi],-1 ; <--- end mark not always in use ; mov dword[edi],-1 ; <--- end mark not always in use
; init real points list ; init real points list
mov .x,-(.N/2) mov .x,-(.N/2)
@ -824,11 +824,8 @@ if Ext=SSE
; mov ecx,(SIZE_X*(SIZE_Y-3))*3/8 ; mov ecx,(SIZE_X*(SIZE_Y-3))*3/8
.blr: .blr:
@@: @@:
push ecx
mov ecx,edi
sub ecx,ebx
movq mm0,[edi+ebx] movq mm0,[edi+ebx]
movq mm1,[ecx] movq mm1,[edi-ebx]
movq mm2,[edi-3] movq mm2,[edi-3]
movq mm3,[edi+3] movq mm3,[edi+3]
@ -841,7 +838,7 @@ if Ext=SSE
movq [edi],mm0 movq [edi],mm0
add edi,8 add edi,8
add esi,8 add esi,8
pop ecx
loop .blr loop .blr
xor eax,eax xor eax,eax
@ -995,7 +992,7 @@ mirror: ; mirror effect - loseless operation
mov edi,[points_ptr] ; one real point - triple float mov edi,[points_ptr] ; one real point - triple float
mov esi,[points_normals_ptr] ; one 3dvector - triple float dword x,y,z mov esi,[points_normals_ptr] ; one 3dvector - triple float dword x,y,z
fninit fninit
movzx ecx,[points_count_var] mov ecx,[points_count_var]
cmp ah,11 cmp ah,11
je @f je @f
@ -1044,7 +1041,7 @@ exchange: ; exchange some coords - loseless operation
mov edi,[points_ptr] ; one real point - triple float mov edi,[points_ptr] ; one real point - triple float
mov esi,[points_normals_ptr] ; one 3dvector - triple float dword x,y,z mov esi,[points_normals_ptr] ; one 3dvector - triple float dword x,y,z
fninit ; exchange both points and normal vactors coords/coofics fninit ; exchange both points and normal vactors coords/coofics
movzx ecx,[points_count_var] mov ecx,[points_count_var]
cmp [xchg_flag],1 cmp [xchg_flag],1
je @f je @f

View File

@ -74,7 +74,7 @@
db 3 db 3
db 'shd. model' db 'shd. model'
db 12 db 12
dr_flag db 0 dr_flag db 0 ; 6 - dots
dd shd_f dd shd_f
db 4 db 4
@ -457,8 +457,8 @@ align 8
scale dd ? ; help scale variable scale dd ? ; help scale variable
edges_counter dd ? edges_counter dd ?
;== ;==
triangles_count_var dw ? triangles_count_var dd ?
points_count_var dw ? points_count_var dd ?
; triangles_ptr dd ? ; triangles_ptr dd ?
; triangles_w_z_ptr dd ? ; triangles_w_z_ptr dd ?
; triangles_normals_ptr dd ? ; triangles_normals_ptr dd ?
@ -485,9 +485,9 @@ align 8
;=== ;===
point_index1 dw ? ;-\ point_index1 dd ? ;-\
point_index2 dw ? ; } don't change order point_index2 dd ? ; } don't change order
point_index3 dw ? ;-/ point_index3 dd ? ;-/
temp_col dw ? temp_col dw ?
high dd ? high dd ?
rand_seed dw ? rand_seed dw ?

View File

@ -1,209 +0,0 @@
draw_triangle:
;----------in - eax - x1 shl 16 + y1
;------------- -ebx - x2 shl 16 + y2
;---------------ecx - x3 shl 16 + y3
;---------------edx - color 0x00rrggbb
;---------------edi - pointer to screen buffer
.col equ ebp-4 ;dd ?
.x1 equ ebp-6 ;dw ?
.y1 equ ebp-8 ;dw ?;+8
.x2 equ ebp-10 ;dw ?
.y2 equ ebp-12 ;dw ?
.x3 equ ebp-14 ;dw ?
.y3 equ ebp-16 ;dw ?;+16
.dx12 equ ebp-20 ; dd ?
.dx13 equ ebp-24 ; dd ?;+24
.dx23 equ ebp-28 ; dd ?
mov ebp,esp
; sub esp,28
push edx
.ch3:
cmp ax,bx
jg .ch1
.ch4: ; sort parameters
cmp bx,cx
jg .ch2
jle .chEnd
.ch1:
xchg eax,ebx
jmp .ch4
.ch2:
xchg ebx,ecx
jmp .ch3
.chEnd:
; mov dword[.y1],eax ; ..and store to user friendly variables
; mov dword[.y2],ebx
; mov dword[.y3],ecx
; mov [.col],edx
push eax
push ebx
push ecx
sub esp,12
mov edx,eax ; eax,ebx,ecx are ORd together into edx which means that
or edx,ebx ; if any *one* of them is negative a sign flag is raised
or edx,ecx
test edx,80008000h ; Check both X&Y at once
jne .end_triangle
mov dx,[size_x_var]
cmp word[.x1],dx ;SIZE_X ; {
jg .end_triangle
cmp word[.x2],dx ;SIZE_X ; This can be optimized with effort
jg .end_triangle
cmp word[.x3],dx ;SIZE_X
jg .end_triangle ; }
shr eax,16
shr ebx,16
shr ecx,16
neg ax ; calculate delta 12
add ax,bx
cwde
shl eax,ROUND
cdq
mov bx,[.y2]
mov cx,[.y1]
sub bx,cx
;cmp ebx,0
jne .noZero1
mov dword[.dx12],0
jmp .yesZero1
.noZero1:
idiv ebx
mov [.dx12],eax
.yesZero1:
mov ax,[.x3] ; calculate delta 13
sub ax,[.x1]
cwde
shl eax,ROUND
cdq
mov bx,[.y3]
mov cx,[.y1]
sub bx,cx
;cmp ebx,0
jne .noZero2
mov dword[.dx13],0
jmp .yesZero2
.noZero2:
idiv ebx
mov [.dx13],eax
.yesZero2:
mov ax,[.x3] ; calculate delta 23 [dx23]
sub ax,[.x2]
cwde
shl eax,ROUND
cdq
mov bx,[.y3]
mov cx,[.y2]
sub bx,cx
;cmp ebx,0
jne .noZero3
mov dword[.dx23],0
jmp .yesZero3
.noZero3:
idiv ebx
mov [.dx23],eax
.yesZero3:
movsx eax,word[.x1] ; eax - xk1 ;;;
shl eax,ROUND
mov ebx,eax ; ebx - xk2 ;;;
movsx esi,word[.y1] ; esi - y
.next_line1:
mov ecx,eax ; ecx - x11
sar ecx,ROUND
mov edx,ebx ; edx - x12
sar edx,ROUND
cmp ecx,edx
jle .nochg
xchg ecx,edx
.nochg:
pusha
mov ebx,ecx
sub edx,ecx
mov ecx,edx
mov edx,esi
mov eax,[.col]
call .horizontal_line
popa
add eax,[.dx13]
add ebx,[.dx12]
inc esi
cmp si,[.y2]
jl .next_line1
movzx esi,word[.y2]
movzx ebx,word[.x2]
shl ebx,ROUND
.next_line2:
mov ecx,eax
sar ecx,ROUND
mov edx,ebx
sar edx,ROUND
cmp ecx,edx
jle .nochg1
xchg ecx,edx
.nochg1:
pusha
mov ebx,ecx
sub edx,ecx
mov ecx,edx
mov edx,esi
mov eax,[.col]
call .horizontal_line
popa
add eax,[.dx13]
add ebx,[.dx23]
inc esi
cmp si,[.y3]
jl .next_line2
.end_triangle:
mov esp,ebp
ret
.horizontal_line:
;---------in
;---------eax - color of line, 0x00RRGGBB
;---------ebx - x1 - x position of line begin
;---------ecx - lenght of line
;---------edx - y position of line
;---------edi - pointer to buffer
jcxz .end_hor_l
; or edx,edx
; jl .end_hor_l
movzx esi,word[size_y_var]
cmp edx,esi ;SIZE_Y
jg .end_hor_l
push eax
movzx eax,word[size_x_var]
lea eax,[eax*3]
; mov eax,SIZE_X*3
mul edx
add edi,eax ; calculate line begin adress
;add edi,ebx
;shl ebx,1
lea edi,[edi+ebx*2]
add edi,ebx
pop eax
cld
;mov dword[edi-3],0000FF00h
dec ecx
jecxz .last_pix
.ddraw: ; Drawing horizontally:
;push eax
stosd ; 4 bytes at a time
dec edi ; point to the 4th
loop .ddraw
.last_pix:
stosw
shr eax,16
stosb
; mov byte[edi],0 ; The last 4th will be reset
.end_hor_l:
ret

View File

@ -1,697 +0,0 @@
gouraud_triangle:
;------------------in - eax - x1 shl 16 + y1 ---------
;---------------------- ebx - x2 shl 16 + y2 ---------
;---------------------- ecx - x3 shl 16 + y3 ---------
;---------------------- edi - pointer to screen buffer
;---------------------- stack : colors----------------
;----------------- procedure don't save registers !!--
.col1r equ ebp+4 ; each color as word
.col1g equ ebp+6
.col1b equ ebp+8
.col2r equ ebp+10
.col2g equ ebp+12
.col2b equ ebp+14
.col3r equ ebp+16
.col3g equ ebp+18
.col3b equ ebp+20
.x1 equ word[ebp-2]
.y1 equ word[ebp-4]
.x2 equ word[ebp-6]
.y2 equ word[ebp-8]
.x3 equ word[ebp-10]
.y3 equ word[ebp-12]
.dx12 equ dword[ebp-16]
.dc12r equ dword[ebp-20]
.dc12g equ [ebp-24]
.dc12b equ dword[ebp-28]
.dx13 equ dword[ebp-32]
.dc13r equ dword[ebp-36]
.dc13g equ [ebp-40]
.dc13b equ dword[ebp-44]
.dx23 equ dword[ebp-48]
.dc23r equ dword[ebp-52]
.dc23g equ [ebp-56]
.dc23b equ dword[ebp-60]
.c1r equ dword[ebp-64]
.c1g equ [ebp-68]
.c1b equ dword[ebp-72]
.c2r equ dword[ebp-76]
.c2g equ [ebp-80]
.c2b equ dword[ebp-84]
mov ebp,esp
; sub esp,72
.sort3: ; sort triangle coordinates...
cmp ax,bx
jle .sort1
xchg eax,ebx
mov edx,dword[.col1r]
xchg edx,dword[.col2r]
mov dword[.col1r],edx
mov dx,word[.col1b]
xchg dx,word[.col2b]
mov word[.col1b],dx
.sort1:
cmp bx,cx
jle .sort2
xchg ebx,ecx
mov edx,dword[.col2r]
xchg edx,dword[.col3r]
mov dword[.col2r],edx
mov dx,word[.col2b]
xchg dx,word[.col3b]
mov word[.col2b],dx
jmp .sort3
.sort2:
push eax ;store triangle coordinates in user friendly variables
push ebx
push ecx
; sub esp,72 ; set correctly value of esp
mov edx,eax ; check only X triangle coordinate
or edx,ebx
or edx,ecx
test edx,80000000h
jne .gt_loop2_end
mov dx,[size_x_var]
dec dx
shr eax,16
cmp ax,dx ;SIZE_X-1
jg .gt_loop2_end
shr ebx,16
cmp bx,dx ;SIZE_X-1
jg .gt_loop2_end
shr ecx,16
cmp cx,dx ;SIZE_X-1
jg .gt_loop2_end
mov bx,.y2 ; calc deltas
sub bx,.y1
jnz .gt_dx12_make
xor edx,edx
mov ecx,4
@@:
push edx
loop @b
; mov .dx12,0
; mov .dc12r,0
; mov .dc12g,0
; mov .dc12b,0
jmp .gt_dx12_done
.gt_dx12_make:
mov ax,.x2
sub ax,.x1
cwde
movsx ebx,bx
shl eax,ROUND
cdq
idiv ebx
; mov .dx12,eax
push eax
mov ax,word[.col2r]
sub ax,word[.col1r]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dc12r,eax
push eax
mov ax,word[.col2g]
sub ax,word[.col1g]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dc12g,eax
push eax
mov ax,word[.col2b]
sub ax,word[.col1b]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dc12b,eax
push eax
.gt_dx12_done:
mov bx,.y3
sub bx,.y1
jnz .gt_dx13_make
xor edx,edx
mov ecx,4
@@:
push edx
loop @b
; mov .dx13,0
; mov .dc13r,0
; mov .dc13g,0
; mov .dc13b,0
jmp .gt_dx13_done
.gt_dx13_make:
mov ax,.x3
sub ax,.x1
cwde
movsx ebx,bx
shl eax,ROUND
cdq
idiv ebx
; mov .dx13,eax
push eax
mov ax,word[.col3r]
sub ax,word[.col1r]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dc13r,eax
push eax
mov ax,word[.col3g]
sub ax,word[.col1g]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dc13g,eax
push eax
mov ax,word[.col3b]
sub ax,word[.col1b]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dc13b,eax
push eax
.gt_dx13_done:
mov bx,.y3
sub bx,.y2
jnz .gt_dx23_make
xor edx,edx
mov ecx,4
@@:
push edx
loop @b
; mov .dx23,0
; mov .dc23r,0
; mov .dc23g,0
; mov .dc23b,0
jmp .gt_dx23_done
.gt_dx23_make:
mov ax,.x3
sub ax,.x2
cwde
movsx ebx,bx
shl eax,ROUND
cdq
idiv ebx
; mov .dx23,eax
push eax
mov ax,word[.col3r]
sub ax,word[.col2r]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dc23r,eax
push eax
mov ax,word[.col3g]
sub ax,word[.col2g]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dc23g,eax
push eax
mov ax,word[.col3b]
sub ax,word[.col2b]
cwde
shl eax,ROUND
cdq
idiv ebx
; mov .dc23b,eax
push eax
.gt_dx23_done:
sub esp,24
movsx eax,.x1
shl eax,ROUND
mov ebx,eax
movsx edx,word[.col1r]
shl edx,ROUND
mov .c1r,edx
mov .c2r,edx
movsx edx,word[.col1g]
shl edx,ROUND
mov .c1g,edx
mov .c2g,edx
movsx edx,word[.col1b]
shl edx,ROUND
mov .c1b,edx
mov .c2b,edx
mov cx,.y1
cmp cx,.y2
jge .gt_loop1_end
.gt_loop1:
push eax ; eax - cur x1
push ebx ; ebx - cur x2
push cx ; cx - cur y
push edi
push ebp
sar ebx,ROUND
push bx
mov edx,.c2r ; c2r,c2g,c2b,c1r,c1g,c1b - current colors
sar edx,ROUND
push dx
mov edx,.c2g
sar edx,ROUND
push dx
mov edx,.c2b
sar edx,ROUND
push dx
sar eax,ROUND
push ax
mov edx,.c1r
sar edx,ROUND
push dx
mov edx,.c1g
sar edx,ROUND
push dx
mov edx,.c1b
sar edx,ROUND
push dx
push cx
call gouraud_line
pop ebp
pop edi
pop cx
pop ebx
pop eax
if Ext >= MMX
movq mm0,.c1g
paddd mm0,.dc13g
movq .c1g,mm0
else
mov edx,.dc13r
add .c1r,edx
mov edx,.dc13g
add .c1g,edx
end if
mov edx,.dc13b
add .c1b,edx
if Ext >= MMX
movq mm0,.c2g
paddd mm0,.dc12g
movq .c2g,mm0
else
mov edx,.dc12r
add .c2r,edx
mov edx,.dc12g
add .c2g,edx
end if
mov edx,.dc12b
add .c2b,edx
add eax,.dx13
add ebx,.dx12
inc cx
cmp cx,.y2
jl .gt_loop1
.gt_loop1_end:
mov cx,.y2
cmp cx,.y3
jge .gt_loop2_end
movsx ebx,.x2
shl ebx,ROUND
movsx edx,word[.col2r]
shl edx,ROUND
mov .c2r,edx
movsx edx,word[.col2g]
shl edx,ROUND
mov .c2g,edx
movsx edx,word[.col2b]
shl edx,ROUND
mov .c2b,edx
.gt_loop2:
push eax ; eax - cur x1
push ebx ; ebx - cur x2
push cx
push edi
push ebp
sar ebx,ROUND
push bx
mov edx,.c2r
sar edx,ROUND
push dx
mov edx,.c2g
sar edx,ROUND
push dx
mov edx,.c2b
sar edx,ROUND
push dx
sar eax,ROUND
push ax
mov edx,.c1r
sar edx,ROUND
push dx
mov edx,.c1g
sar edx,ROUND
push dx
mov edx,.c1b
sar edx,ROUND
push dx
push cx
call gouraud_line
pop ebp
pop edi
pop cx
pop ebx
pop eax
if Ext >= MMX
movq mm0,.c1g
paddd mm0,.dc13g
movq .c1g,mm0
else
mov edx,.dc13r
add .c1r,edx
mov edx,.dc13g
add .c1g,edx
end if
mov edx,.dc13b
add .c1b,edx
if Ext >= MMX
movq mm0,.c2g
paddd mm0,.dc23g
movq .c2g,mm0
else
mov edx,.dc23r
add .c2r,edx
mov edx,.dc23g
add .c2g,edx
end if
mov edx,.dc23b
add .c2b,edx
add eax,.dx13
add ebx,.dx23
inc cx
cmp cx,.y3
jl .gt_loop2
.gt_loop2_end:
; add esp,84
mov esp,ebp
ret 18
gouraud_line:
;-------------in - edi - pointer to screen buffer
;----------------- stack - another parameters
.y equ word [ebp+4]
.col1b equ ebp+6
.col1g equ ebp+8
.col1r equ ebp+10
.x1 equ [ebp+12]
.col2b equ ebp+14
.col2g equ ebp+16
.col2r equ ebp+18
.x2 equ [ebp+20]
.dc_r equ dword[ebp-4]
.dc_g equ dword[ebp-8]
.dc_b equ dword[ebp-12]
mov ebp,esp
mov ax,.y
or ax,ax
jl .gl_quit
mov dx,[size_y_var]
dec dx
cmp ax,dx ;SIZE_Y-1
jg .gl_quit
mov ax,.x1
cmp ax,.x2
je .gl_quit
jl .gl_ok
if Ext >= MMX
movq mm0,[.col1b]
movq mm1,[.col2b]
movq [.col1b],mm1
movq [.col2b],mm0
else
mov eax,[.col1b]
xchg eax,[.col2b]
mov [.col1b],eax
mov eax,[.col1r]
xchg eax,[.col2r]
mov [.col1r],eax
end if
.gl_ok:
; cmp .x1,SIZE_X-1 ;check
; jg .gl_quit
; cmp .x2,SIZE_X-1
; jl @f
; mov .x2,SIZE_X-1
; @@:
; cmp .x1,0
; jg @f
; mov .x1,0
; @@:
; cmp .x2,0
; jl .gl_quit
movsx ecx,.y
movzx eax,word[size_x_var]
lea eax,[eax*3]
; mov eax,SIZE_X*3
mul ecx
movsx ebx,word .x1
lea ecx,[ebx*2+eax]
add edi,ecx
add edi,ebx
mov ax,word[.col2r]
sub ax,word[.col1r]
cwde
shl eax,ROUND
cdq
mov cx,.x2
sub cx,.x1
movsx ecx,cx
idiv ecx
;mov .dc_r,eax ;first delta
push eax
mov ax,word[.col2g]
sub ax,word[.col1g]
cwde
shl eax,ROUND
cdq
idiv ecx
;mov .dc_g,eax
push eax
mov ax,word[.col2b]
sub ax,word[.col1b]
cwde
shl eax,ROUND
cdq
idiv ecx
; mov .dc_b,eax
push eax
movsx ebx,word[.col1r]
shl ebx,ROUND
movsx edx,word[.col1g]
shl edx,ROUND
movsx esi,word[.col1b]
shl esi,ROUND
.gl_draw:
mov eax,ebx
sar eax,ROUND
stosb
mov eax,edx
sar eax,ROUND
stosb
mov eax,esi
sar eax,ROUND
stosb
add ebx,.dc_r
add edx,.dc_g
add esi,.dc_b
loop .gl_draw
.gl_quit:
; add esp,12
mov esp,ebp
ret 18
if 0
gouraud_line_SSE: ; new
;-------------in - edi - pointer to screen buffer
;----------------- stack - another parameters
.y equ word [ebp+4]
.col1b equ ebp+6
.col1g equ ebp+8
.col1r equ ebp+10
.x1 equ [ebp+12]
.col2b equ ebp+14
.col2g equ ebp+16
.col2r equ ebp+18
.x2 equ [ebp+20]
.dc_r equ dword[ebp-4]
.dc_g equ dword[ebp-8]
.dc_b equ dword[ebp-12]
.lenght equ [ebp-16]
.factor equ [ebp-24] ;new
mov ebp,esp
mov ax,.y
or ax,ax
jl .gl_quit
cmp ax,SIZE_Y-1
jg .gl_quit
mov ax,.x1
cmp ax,.x2
je .gl_quit
jl .gl_ok
if Ext >= MMX
movq mm0,[.col1b]
movq mm1,[.col2b]
movq [.col1b],mm1
movq [.col2b],mm0
else
mov eax,[.col1b]
xchg eax,[.col2b]
mov [.col1b],eax
mov eax,[.col1r]
xchg eax,[.col2r]
mov [.col1r],eax
end if
.gl_ok:
; cmp .x1,SIZE_X-1 ;check
; jg .gl_quit
; cmp .x2,SIZE_X-1
; jl @f
; mov .x2,SIZE_X-1
; @@:
; cmp .x1,0
; jg @f
; mov .x1,0
; @@:
; cmp .x2,0
; jl .gl_quit
movsx ecx,.y
mov eax,SIZE_X*3
mul ecx
movsx ebx,word .x1
lea ecx,[ebx*2+eax]
add edi,ecx
add edi,ebx
mov ax,word[.col2r]
sub ax,word[.col1r]
cwde
shl eax,ROUND
cdq
mov cx,.x2
sub cx,.x1
movsx ecx,cx
idiv ecx
;mov .dc_r,eax ;first delta
push eax
mov ax,word[.col2g]
sub ax,word[.col1g]
cwde
shl eax,ROUND
cdq
idiv ecx
;mov .dc_g,eax
push eax
mov ax,word[.col2b]
sub ax,word[.col1b]
cwde
shl eax,ROUND
cdq
idiv ecx
; mov .dc_b,eax
push eax
movsx ebx,word[.col1r]
shl ebx,ROUND
movsx edx,word[.col1g]
shl edx,ROUND
movsx esi,word[.col1b]
shl esi,ROUND
push ecx ; store line lenght
movd mm3,.dc_r
psrlq mm3,16 ; load dr to lowest word of mm3
pxor mm2,mm2 ; clear mm2
movd mm4,.dc_g
punpcklwd mm3,mm3 ; unpack dr to lower 2 words in in mm3
psrlq mm4,16 ; load dg to lowest word of mm4
movd mm5,.dc_b
psrlq mm5,16 ; load db to lowest word of mm5
punpcklwd mm4,mm4 ; unpack dg to lower 2 words in in mm3
lea ecx,[factor]
punpckldq mm3,mm3
punpcklwd mm5,mm5 ; unpack db to lower 2 words in in mm5
movq mm6,[.col1b]
xor eax,eax
pinsrw mm6,eax,3 ; clear the highest word in mm6
mov eax,010000h
punpckldq mm4,mm4 ; unpack dg to 4 words in mm4
mov [ecx],eax
mov eax,030002h
punpckldq mm5,mm5 ; unpack db to 4 words in mm5
movq mm7,mm6 ; load r1r1,g1g1,b1b1 to the first three
; words of mm7
pxor mm1,mm1 ; clear mm1
.gl_draw:
mov eax,ebx
sar eax,ROUND
stosb
mov eax,edx
sar eax,ROUND
stosb
mov eax,esi
sar eax,ROUND
stosb
add ebx,.dc_r
add edx,.dc_g
add esi,.dc_b
loop .gl_draw
.gl_quit:
; add esp,12
mov esp,ebp
ret 18
end if

View File

@ -1,9 +1,8 @@
View3ds 0.068b - V 2018
1. Fixed SSE build.
-----------------------------------------------------------------------------------
View3ds 0.068 - XI 2016 View3ds 0.068 - XI 2016
1. Editing option - new 'editor' button. 1. Editing option - new 'editor' button.
2. For now I disable perspective correction, to make implemtation of editing option easier. 2. For now I disable perspective correction, to make implemtation
of editing option easier.
----------------------------------------------------------------------------------- -----------------------------------------------------------------------------------
View3ds 0.067 - XI 2016 View3ds 0.067 - XI 2016

View File

@ -1,6 +1,15 @@
View3ds 0.068b - tiny viewer to .3ds and .asc files with several graphics View3ds 0.069 - tiny viewer to .3ds and .asc files with several graphics
effects implementation. effects implementation.
What's new?
1. KPacked files support by Leency.
1. 32bit vertices indexes and ability to load whole RAM limited objects.
(Above 65535 vertices and triangles), (by me).
2. I switch off painters algotithm mode (depth sorting). In app impelementetion it has
limited vertices count and produce less quality image than Z buffer Catmull algo.
In addition this switch off reduces app size, (by me).
Buttons description: Buttons description:
1. rotary: choosing rotary axle: x, y, x+y. 1. rotary: choosing rotary axle: x, y, x+y.
2. shd. model: choosing shading model: flat, grd (smooth), env (spherical 2. shd. model: choosing shading model: flat, grd (smooth), env (spherical
@ -11,8 +20,7 @@ Buttons description:
mapping), grdl (Gouraud lines - edges only). mapping), grdl (Gouraud lines - edges only).
3. speed: idle, full. 3. speed: idle, full.
4,5. zoom in, out: no comment. 4,5. zoom in, out: no comment.
6. catmull: on -> use z buffer ( z coordinate interpolation), off -> depth sorting, painters 6. catmull: disabled
alghoritm).Txgrd, 2tex and bumptex models only with catmull = on.
7. culling: backface culling on/ off. 7. culling: backface culling on/ off.
8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination). 8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination).
9. Blur: blur N times; N=0,1,2,3,4,5 9. Blur: blur N times; N=0,1,2,3,4,5
@ -34,4 +42,4 @@ Buttons description:
is released apply current position. You may also decrease whole handlers count by enable culling (using is released apply current position. You may also decrease whole handlers count by enable culling (using
appropriate button) - some back handlers become hidden. appropriate button) - some back handlers become hidden.
Maciej Guba XI 2016 Maciej Guba V 2020

View File

@ -1,546 +0,0 @@
;---------------------------------------------------------------------
;--------------------textured triangle procedure----------------------
;---------------------------------------------------------------------
tex_triangle:
;----------in - eax - x1 shl 16 + y1
;-------------- ebx - x2 shl 16 + y2
;---------------ecx - x3 shl 16 + y3
;---------------edx - nothing
;---------------esi - pointer to texture buffer
;---------------edi - pointer to screen buffer
;-------------stack - texture coordinates
.tex_x1 equ ebp+4
.tex_y1 equ ebp+6
.tex_x2 equ ebp+8
.tex_y2 equ ebp+10
.tex_x3 equ ebp+12
.tex_y3 equ ebp+14
.x1 equ ebp-2 ;dw ?
.y1 equ ebp-4 ;dw ?
.x2 equ ebp-6 ;dw ?
.y2 equ ebp-8 ;dw ?
.x3 equ ebp-10 ;dw ?
.y3 equ ebp-12 ;dw ?
.dx12 equ ebp-16 ;dd ?
.dx13 equ ebp-20 ;dd ?
.dx23 equ ebp-24 ;dd ?
.tex_dx12 equ ebp-28 ;dd ?
.tex_dy12 equ ebp-32 ;dd ?
.tex_dx13 equ ebp-36 ;dd ?
.tex_dy13 equ ebp-40 ;dd ?
.tex_dx23 equ ebp-44 ;dd ?
.tex_dy23 equ ebp-48 ;dd ?
.tex_ptr equ ebp-52 ;dd ?
.scan_x2 equ ebp-56 ;dd ?
.scan_y2 equ ebp-60 ;dd ?
.scan_x1 equ ebp-64 ;dd ?
.scan_y1 equ ebp-68 ;dd ?
mov ebp,esp
sub esp,68
;if Ext = MMX
; emms
;end if
mov edx,dword[.tex_x1] ; check all parameters
or dx,dx
jl .tt_end
cmp dx,TEX_X-1
jg .tt_end
shr edx,16
or dx,dx
jl .tt_end
cmp dx,TEX_Y-1
jg .tt_end
mov edx,dword[.tex_x2]
or dx,dx
jl .tt_end
cmp dx,TEX_X-1
jg .tt_end
shr edx,16
or dx,dx
jl .tt_end
cmp dx,TEX_Y-1
jg .tt_end
mov edx,dword[.tex_x3]
or dx,dx
jl .tt_end
cmp dx,TEX_X-1
jg .tt_end
shr edx,16
cmp dx,TEX_Y-1
jg .tt_end
or dx,dx
jl .tt_end
mov edx,eax ; check X&Y triangle coordinate
or edx,ebx
or edx,ecx
test edx,80008000h
jne .tt_end
mov dx,[size_x_var]
; or ax,ax
; jl .tt_end
; cmp ax,SIZE_Y
; jg .tt_end
ror eax,16
; or ax,ax
; jl .tt_end
cmp ax,dx ;SIZE_X
jg .tt_end
rol eax,16
; or bx,bx
; jl .tt_end
; cmp bx,SIZE_Y
; jg .tt_end
ror ebx,16
; or bx,bx
; jl .tt_end
cmp bx,dx ;SIZE_X
jg .tt_end
rol ebx,16
; or cx,cx
; jl .tt_end
; cmp cx,SIZE_Y
; jg .tt_end
ror ecx,16
; or cx,cx
; jl .tt_end
cmp cx,dx ;SIZE_X
jg .tt_end
rol ecx,16 ; uff.. parameters was checked
cmp ax,bx ;sort all parameters
jle .tt_sort1
xchg eax,ebx
mov edx,dword [.tex_x1]
xchg edx,dword [.tex_x2]
mov dword[.tex_x1],edx
.tt_sort1:
cmp ax,cx
jle .tt_sort2
xchg eax,ecx
mov edx,dword [.tex_x1]
xchg edx,dword [.tex_x3]
mov dword [.tex_x1],edx
.tt_sort2:
cmp bx,cx
jle .tt_sort3
xchg ebx,ecx
mov edx,dword [.tex_x2]
xchg edx,dword [.tex_x3]
mov dword [.tex_x2],edx
.tt_sort3:
mov [.y1],ax ; and store to user friendly variables
shr eax,16
mov [.x1],ax
mov [.y2],bx
shr ebx,16
mov [.x2],bx
mov [.y3],cx
shr ecx,16
mov [.x3],cx
mov [.tex_ptr],esi
movsx ebx,word[.y2]
sub bx,[.y1]
jnz .tt_dx12_make
mov dword[.dx12],0
mov dword[.tex_dx12],0
mov dword[.tex_dy12],0
jmp .tt_dx12_done
.tt_dx12_make:
mov ax,[.x2]
sub ax,[.x1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.dx12],eax ; dx12 = (x2-x1)/(y2-y1)
mov ax,word[.tex_x2]
sub ax,word[.tex_x1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.tex_dx12],eax ; tex_dx12 = (tex_x2-tex_x1)/(y2-y1)
mov ax,word[.tex_y2]
sub ax,word[.tex_y1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.tex_dy12],eax ; tex_dy12 = (tex_y2-tex_y1)/(y2-y1)
.tt_dx12_done:
movsx ebx,word[.y3]
sub bx,word[.y1]
jnz .tt_dx13_make
mov dword [.dx13],0
mov dword [.tex_dx13],0
mov dword [.tex_dy13],0
jmp .tt_dx13_done
.tt_dx13_make:
mov ax,[.x3]
sub ax,[.x1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.dx13],eax ; dx13 = (x3-x1)/(y3-y1)
mov ax,word[.tex_x3]
sub ax,word[.tex_x1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.tex_dx13],eax ; tex_dx13 = (tex_x3-tex_x1)/(y3-y1)
mov ax,word[.tex_y3]
sub ax,word[.tex_y1]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.tex_dy13],eax ; tex_dy13 = (tex_y3-tex_y1)/(y3-y1)
.tt_dx13_done:
movsx ebx,word[.y3]
sub bx,word[.y2]
jnz .tt_dx23_make
mov dword [.dx23],0
mov dword [.tex_dx23],0
mov dword [.tex_dy23],0
jmp .tt_dx23_done
.tt_dx23_make:
mov ax,[.x3]
sub ax,[.x2]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.dx23],eax ; dx23 = (x3-x2)/(y3-y2)
mov ax,word[.tex_x3]
sub ax,word[.tex_x2]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.tex_dx23],eax ; tex_dx23 = (tex_x3-tex_x2)/(y3-y2)
mov ax,word[.tex_y3]
sub ax,word[.tex_y2]
cwde
shl eax,ROUND
cdq
idiv ebx
mov [.tex_dy23],eax ; tex_dy23 = (tex_y3-tex_y2)/(y3-y2)
.tt_dx23_done:
movsx eax,word[.x1]
shl eax,ROUND
mov ebx,eax
movsx edx, word[.tex_x1]
shl edx,ROUND
mov [.scan_x1],edx
mov [.scan_x2],edx
movsx edx, word[.tex_y1]
shl edx,ROUND
mov [.scan_y1],edx
mov [.scan_y2],edx
mov cx,[.y1]
cmp cx, [.y2]
jge .tt_loop1_end
.tt_loop1:
push edi
push eax
push ebx
push cx
push ebp
;; Madis
;if Ext=MMX ; With MMX enabled it reverse light vectors ????
; mov dword[esp-8],ROUND
; mov dword[esp-4],0 ; Is this a bug? Explanation down 3 lines
; movq mm0,qword[.scan_y1]
; movq mm1,qword[.scan_y2]
; psrad mm0,[esp-8] ;This instr. won't allow modifiers BYTE, WORD, etc.
; psrad mm1,[esp-8] ;It always defaults to QWORD
; packssdw mm0,mm1
; movq [esp-8],mm0
; sub esp,8
;else
push dword[.scan_y2] ; now I push variables on stack without shifting
push dword[.scan_x2]
push dword[.scan_y1]
push dword[.scan_x1]
;end if
push dword[.tex_ptr]
push cx
mov edx,ebx
sar edx,ROUND
push dx
mov edx,eax
sar edx,ROUND
push dx
call textured_line
pop ebp
pop cx
pop ebx
pop eax
pop edi
mov edx, [.tex_dx13]
add [.scan_x1], edx
mov edx, [.tex_dx12]
add [.scan_x2], edx
mov edx, [.tex_dy13]
add [.scan_y1], edx
mov edx, [.tex_dy12]
add [.scan_y2], edx
add eax, [.dx13]
add ebx, [.dx12]
inc cx
cmp cx,[.y2]
jl .tt_loop1
.tt_loop1_end:
mov cx, [.y2]
cmp cx, [.y3]
jge .tt_loop2_end
movsx ebx,word[.x2]
shl ebx,ROUND
movsx edx, word[.tex_x2]
shl edx,ROUND
mov [.scan_x2],edx
movsx edx, word[.tex_y2]
shl edx,ROUND
mov [.scan_y2],edx
.tt_loop2:
push edi
push eax
push ebx
push cx
push ebp
;; Madis
;if Ext=MMX
; mov dword[esp-8],ROUND
; mov dword[esp-4],0 ; Is this a bug? Explanation down 3 lines
; movq mm0,qword[.scan_y1]
; movq mm1,qword[.scan_y2]
; psrad mm0,[esp-8] ;This instr. won't allow modifiers BYTE, WORD, etc.
; psrad mm1,[esp-8] ;It always defaults to QWORD
; packssdw mm0,mm1
; movq [esp-8],mm0
; sub esp,8
;else
;end if
push dword[.scan_y2]
push dword[.scan_x2]
push dword[.scan_y1]
push dword[.scan_x1]
push dword[.tex_ptr]
push cx
mov edx,ebx
sar edx,ROUND
push dx
mov edx,eax
sar edx,ROUND
push dx
call textured_line
pop ebp
pop cx
pop ebx
pop eax
pop edi
mov edx, [.tex_dx13]
add [.scan_x1], edx
mov edx, [.tex_dx23]
add [.scan_x2], edx
mov edx, [.tex_dy13]
add [.scan_y1], edx
mov edx, [.tex_dy23]
add [.scan_y2], edx
add eax, [.dx13]
add ebx, [.dx23]
inc cx
cmp cx,[.y3]
jl .tt_loop2
.tt_loop2_end:
.tt_end:
mov esp,ebp
ret 12
textured_line:
;-----in -edi screen buffer pointer
;------------ stack:
.x1 equ word [ebp+4]
.x2 equ word [ebp+6]
.y equ word [ebp+8]
.tex_ptr equ dword [ebp+10]
.tex_x1 equ [ebp+14]
.tex_y1 equ [ebp+18]
.tex_x2 equ [ebp+22]
.tex_y2 equ [ebp+26]
.tex_dx equ ebp-4 ;dd ?
.tex_dy equ ebp-8 ;dd ?
mov ebp,esp
sub esp,8
mov ax,.y
or ax,ax
jl .tl_quit
mov dx,[size_y_var]
cmp ax,dx ;SIZE_Y
jg .tl_quit
mov ax,.x1
cmp ax,.x2
je .tl_quit
jl .tl_ok
xchg ax,.x2
mov .x1,ax
if Ext >= MMX
movq mm0,.tex_x1
movq mm1,.tex_x2
movq .tex_x2,mm0
movq .tex_x1,mm1
else
mov eax,.tex_x1
xchg eax,.tex_x2
mov .tex_x1,eax
mov eax,.tex_y1
xchg eax,.tex_y2
mov .tex_y1,eax
end if
.tl_ok:
mov ebx,edi
movsx edi,.y
movzx eax,word[size_x_var]
lea eax,[eax*3]
; mov eax,SIZE_X*3
mul edi
mov edi,eax
movsx eax,.x1
add edi,eax
shl eax,1
add edi,eax
add edi,ebx
mov cx,.x2
sub cx,.x1
movsx ecx,cx
mov eax,.tex_x2
sub eax,.tex_x1
cdq
idiv ecx
mov [.tex_dx],eax ; tex_dx=(tex_x2-tex_x1)/(x2-x1)
mov eax,.tex_y2
sub eax,.tex_y1
cdq
idiv ecx
mov [.tex_dy],eax ; tex_dy = (tex_y2-tex_y1)/(x2-x1)
mov eax,.tex_x1
mov ebx,.tex_y1
cld
.tl_loop:
mov edx,eax ; eax - cur x
mov esi,ebx ; ebx - cur y
shr edx,ROUND
shr esi,ROUND
macro .fluent
{
push eax
push edx
mov eax,TEX_X*3
mul esi
mov esi,eax
pop edx
pop eax
}
macro .shift
{
shl esi,TEX_SHIFT
lea esi,[esi*3]
;push edx
;mov edx,esi
;shl esi,1
;add esi,edx
;pop edx
}
if TEX = FLUENTLY
.fluent
end if
if TEX = SHIFTING
.shift
end if
lea edx,[edx*3]
add esi,edx
; shl edx,1
; add esi,edx
add esi,.tex_ptr
movsd
dec edi
add eax,[.tex_dx]
add ebx,[.tex_dy]
loop .tl_loop
.tl_quit:
mov esp,ebp
ret 18+8
; .tex_dx dd ?
; .tex_dy dd ?

View File

@ -312,8 +312,8 @@ still:
mov [re_alloc_flag],0 mov [re_alloc_flag],0
end if end if
mov bl,[generator_flag] mov bl,[generator_flag]
or bl,bl ; or bl,bl
jz .next_m2 ; jz .next_m2
cmp bl,1 cmp bl,1
jne @f jne @f
call generate_object call generate_object
@ -492,7 +492,7 @@ still:
mov esi,[points_normals_ptr] mov esi,[points_normals_ptr]
mov edi,[points_normals_rot_ptr] mov edi,[points_normals_rot_ptr]
mov ebx,matrix mov ebx,matrix
movzx ecx,[points_count_var] mov ecx,[points_count_var]
call rotary call rotary
mov esi,matrix mov esi,matrix
@ -501,7 +501,7 @@ still:
mov esi,[points_ptr] mov esi,[points_ptr]
mov edi,[points_rotated_ptr] mov edi,[points_rotated_ptr]
mov ebx,matrix mov ebx,matrix
movzx ecx,[points_count_var] mov ecx,[points_count_var]
call rotary call rotary
; RDTSC ; RDTSC
@ -512,7 +512,7 @@ still:
mov esi,[points_rotated_ptr] mov esi,[points_rotated_ptr]
mov edi,[points_translated_ptr] mov edi,[points_translated_ptr]
movzx ecx,[points_count_var] mov ecx,[points_count_var]
call translate_points call translate_points
; cmp [dr_flag],5 ; cmp [dr_flag],5
@ -523,9 +523,9 @@ still:
jne @f jne @f
call clrscr ; clear the screen call clrscr ; clear the screen
@@: @@:
cmp [catmull_flag],1 ;non sort if Catmull = on ; cmp [catmull_flag],1 ;non sort if Catmull = on
je .no_sort ; je .no_sort
call sort_triangles ; 64 indexes call sort_triangles
.no_sort: .no_sort:
cmp [dr_flag],7 ; fill if 2tex and texgrd cmp [dr_flag],7 ; fill if 2tex and texgrd
jge @f jge @f
@ -749,15 +749,15 @@ end if
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
;-------------------------PROCEDURES--------------------------------------------- ;-------------------------PROCEDURES---------------------------------------------
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
include "TEX3.INC" ;include "TEX3.INC"
include "FLAT_CAT.INC" include "FLAT_CAT.INC"
include "TEX_CAT.INC" include "TEX_CAT.INC"
include "BUMP_CAT.INC" include "BUMP_CAT.INC"
include "3DMATH.INC" include "3DMATH.INC"
include "GRD_LINE.INC" include "GRD_LINE.INC"
include "GRD3.INC" ;include "GRD3.INC"
include "FLAT3.INC" ;include "FLAT3.INC"
include "BUMP3.INC" ;include "BUMP3.INC"
include "B_PROCS.INC" include "B_PROCS.INC"
include "A_PROCS.INC" include "A_PROCS.INC"
include "GRD_CAT.INC" include "GRD_CAT.INC"
@ -1102,7 +1102,7 @@ calc_bumpmap_coords: ; map texture, bump
fadd st,st fadd st,st
mov esi,[points_ptr] mov esi,[points_ptr]
mov edi,tex_points mov edi,tex_points
movzx ecx,[points_count_var] mov ecx,[points_count_var]
inc ecx inc ecx
; cmp [map_tex_flag],1 ; cmp [map_tex_flag],1
; jne .cylindric ; jne .cylindric
@ -1422,16 +1422,16 @@ init_triangles_normals:
@@: @@:
push ebx push ebx
mov ebx,vectors mov ebx,vectors
movzx esi,word[ebp] ; first point index mov esi,dword[ebp] ; first point index
lea esi,[esi*3] lea esi,[esi*3]
lea esi,[points+esi*2] ; esi - pointer to 1st 3d point lea esi,[points+esi*2] ; esi - pointer to 1st 3d point
movzx edi,word[ebp+2] ; second point index movzx edi,dword[ebp+4] ; second point index
lea edi,[edi*3] lea edi,[edi*3]
lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point
call make_vector call make_vector
add ebx,12 add ebx,12
mov esi,edi mov esi,edi
movzx edi,word[ebp+4] ; third point index movzx edi,dword[ebp+8] ; third point index
lea edi,[edi*3] lea edi,[edi*3]
lea edi,[points+edi*2] lea edi,[points+edi*2]
call make_vector call make_vector
@ -1442,22 +1442,23 @@ init_triangles_normals:
call cross_product call cross_product
mov edi,ebx mov edi,ebx
call normalize_vector call normalize_vector
add ebp,6 add ebp,12
add ebx,12 add ebx,12
cmp dword[ebp],-1 cmp dword[ebp],-1
jne @b jne @b
ret ret
end if end if
init_point_normals: init_point_normals:
.x equ dword [ebp-4] .x equ dword [ebp-4]
.y equ dword [ebp-8] .y equ dword [ebp-8]
.z equ dword [ebp-12] .z equ dword [ebp-12]
.point_number equ word [ebp-26] .point_number equ dword [ebp-28]
.hit_faces equ word [ebp-28] .hit_faces equ dword [ebp-32]
fninit fninit
mov ebp,esp mov ebp,esp
sub esp,28 sub esp,32
mov edi,[points_normals_ptr] mov edi,[points_normals_ptr]
mov .point_number,0 mov .point_number,0
.ipn_loop: .ipn_loop:
@ -1470,8 +1471,8 @@ init_point_normals:
.ipn_check_face: .ipn_check_face:
xor ebx,ebx ; ebx - 'position' in one triangle xor ebx,ebx ; ebx - 'position' in one triangle
.ipn_check_vertex: .ipn_check_vertex:
movzx eax,word[esi+ebx] ; eax - point_number mov eax,dword[esi+ebx] ; eax - point_number
cmp ax,.point_number cmp eax,.point_number
jne .ipn_next_vertex jne .ipn_next_vertex
push esi push esi
mov esi,ecx mov esi,ecx
@ -1493,13 +1494,13 @@ init_point_normals:
inc .hit_faces inc .hit_faces
jmp .ipn_next_face jmp .ipn_next_face
.ipn_next_vertex: .ipn_next_vertex:
add ebx,2 add ebx,4
cmp ebx,6 cmp ebx,12
jne .ipn_check_vertex jne .ipn_check_vertex
.ipn_next_face: .ipn_next_face:
add esi,6 add esi,12
inc ecx inc ecx
cmp cx,[triangles_count_var] cmp ecx,[triangles_count_var]
jne .ipn_check_face jne .ipn_check_face
fld .x fld .x
@ -1514,8 +1515,8 @@ init_point_normals:
call normalize_vector call normalize_vector
add edi,12 ;type vector 3d add edi,12 ;type vector 3d
inc .point_number inc .point_number
mov dx,.point_number mov edx,.point_number
cmp dx,[points_count_var] cmp edx,[points_count_var]
jne .ipn_loop jne .ipn_loop
mov esp,ebp mov esp,ebp
@ -1525,15 +1526,17 @@ ret
init_triangles_normals2: init_triangles_normals2:
mov ebx,[triangles_normals_ptr] mov ebx,[triangles_normals_ptr]
mov ebp,[triangles_ptr] mov ebp,[triangles_ptr]
mov ecx,[triangles_count_var]
@@: @@:
push ecx
push ebx push ebx
mov ebx,vectors mov ebx,vectors
movzx esi,word[ebp] ; first point index mov esi,dword[ebp] ; first point index
lea esi,[esi*3] lea esi,[esi*3]
; lea esi,[points+esi*2] ; esi - pointer to 1st 3d point ; lea esi,[points+esi*2] ; esi - pointer to 1st 3d point
shl esi,2 shl esi,2
add esi,[points_ptr] add esi,[points_ptr]
movzx edi,word[ebp+2] ; first point index mov edi,dword[ebp+4] ; first point index
lea edi,[edi*3] lea edi,[edi*3]
shl edi,2 shl edi,2
add edi,[points_ptr] add edi,[points_ptr]
@ -1543,7 +1546,7 @@ init_triangles_normals2:
call make_vector_r call make_vector_r
add ebx,12 add ebx,12
mov esi,edi mov esi,edi
movzx edi,word[ebp+4] ; third point index mov edi,dword[ebp+8] ; third point index
lea edi,[edi*3] lea edi,[edi*3]
shl edi,2 shl edi,2
add edi,[points_ptr] add edi,[points_ptr]
@ -1556,12 +1559,15 @@ init_triangles_normals2:
call cross_product call cross_product
mov edi,ebx mov edi,ebx
call normalize_vector call normalize_vector
add ebp,6 add ebp,12
add ebx,12 add ebx,12
cmp dword[ebp],-1 pop ecx
jne @b sub ecx,1
jnz @b
; cmp dword[ebp],-1
; jne @b
ret ret
if 0 ; ind 64 but
;================================================================= ;=================================================================
sort_triangles: sort_triangles:
@ -1873,7 +1879,7 @@ sort_triangles:
; end if ; end if
movsd ; copy end mark too movsd ; copy end mark too
ret ret
end if ; 64 ind
clrscr: clrscr:
mov edi,[screen_ptr] mov edi,[screen_ptr]
movzx ecx,word[size_x_var] movzx ecx,word[size_x_var]
@ -1937,28 +1943,31 @@ draw_triangles:
mov esi,[triangles_ptr] mov esi,[triangles_ptr]
mov [edges_counter],0 mov [edges_counter],0
mov ecx,[triangles_count_var]
.again_dts: .again_dts:
push ecx
mov ebp,[points_translated_ptr] mov ebp,[points_translated_ptr]
if Ext=NON if Ext >= SSE2
movzx eax,word[esi] mov eax,dword[esi]
mov [point_index1],ax mov [point_index1],eax
lea eax,[eax*3] lea eax,[eax*3]
add eax,eax add eax,eax
push ebp push ebp
add ebp,eax add ebp,eax
mov eax,[ebp] mov eax,[ebp]
cmp [vertex_edit_no],0 ; cmp [vertex_edit_no],0
jne @f ; jne @f
;
@@: ; @@:
mov dword[xx1],eax mov dword[xx1],eax
mov eax,[ebp+4] mov eax,[ebp+4]
mov [zz1],ax mov [zz1],ax
pop ebp pop ebp
movzx eax,word[esi+2] mov eax,dword[esi+4]
mov [point_index2],ax mov [point_index2],eax
lea eax,[eax*3] lea eax,[eax*3]
add eax,eax add eax,eax
push ebp push ebp
@ -1970,8 +1979,8 @@ draw_triangles:
pop ebp pop ebp
movzx eax,word[esi+4] ; xyz3 = [ebp+[esi+4]*6] mov eax,dword[esi+8] ; xyz3 = [ebp+[esi+4]*6]
mov [point_index3],ax mov [point_index3],eax
lea eax,[eax*3] lea eax,[eax*3]
add eax,eax add eax,eax
; push ebp ; push ebp
@ -1981,19 +1990,22 @@ draw_triangles:
mov eax,[ebp+4] mov eax,[ebp+4]
mov [zz3],ax mov [zz3],ax
else else
mov eax,dword[esi] ; don't know MMX movq mm0,[esi] ; don't know MMX
mov dword[point_index1],eax mov qword[point_index1],mm0
; shr eax,16 ; shr eax,16
; mov [point_index2],ax ; mov [point_index2],ax
mov ax,word[esi+4] mov eax,dword[esi+8]
mov [point_index3],ax mov [point_index3],eax
movq mm0,[esi] movdqu xmm0,[esi]
pmullw mm0,qword[const6] paddd xmm0,xmm0
movd eax,mm0 movdqa xmm1,xmm0
psrlq mm0,16 paddd xmm0,xmm0
movd ebx,mm0 paddd xmm0,xmm1
psrlq mm0,16 movd eax,xmm0
movd ecx,mm0 psrldq xmm0,4
movd ebx,xmm0
psrldq xmm0,4
movd ecx,xmm0
and eax,0FFFFh and eax,0FFFFh
and ebx,0FFFFh and ebx,0FFFFh
and ecx,0FFFFh and ecx,0FFFFh
@ -2050,7 +2062,7 @@ end if
mov esi,point_index1 ; ********************************* mov esi,point_index1 ; *********************************
mov ecx,3 ; mov ecx,3 ;
@@: @@:
movzx eax,word[esi] mov eax,dword[esi]
lea eax,[eax*3] lea eax,[eax*3]
shl eax,2 shl eax,2
add eax,[points_normals_rot_ptr] add eax,[points_normals_rot_ptr]
@ -2090,7 +2102,7 @@ end if
mov esi,point_index3 ; do Gouraud shading mov esi,point_index3 ; do Gouraud shading
mov ecx,3 mov ecx,3
.again_grd_draw: .again_grd_draw:
movzx eax,word[esi] mov eax,dword[esi]
shl eax,2 shl eax,2
lea eax,[eax*3] lea eax,[eax*3]
add eax,[points_normals_rot_ptr] add eax,[points_normals_rot_ptr]
@ -2111,11 +2123,11 @@ end if
add eax,ebx add eax,ebx
lea eax,[eax*3+color_map] lea eax,[eax*3+color_map]
mov eax,dword[eax] mov eax,dword[eax]
cmp [catmull_flag],1 ; put on stack z coordinate if necessary ; cmp [catmull_flag],1 ; put on stack z coordinate if necessary
jne @f ; jne @f
lea edx,[ecx*3] lea edx,[ecx*3]
push word[edx*2+xx1-2] ; zz1 ,2 ,3 push word[edx*2+xx1-2] ; zz1 ,2 ,3
@@: ; @@:
ror eax,16 ; eax -0xxxrrggbb -> 0xggbbxxrr ror eax,16 ; eax -0xxxrrggbb -> 0xggbbxxrr
xor ah,ah xor ah,ah
push ax ;r push ax ;r
@ -2125,7 +2137,7 @@ end if
shr eax,24 shr eax,24
push ax ;b push ax ;b
sub esi,2 sub esi,4
dec cx dec cx
jnz .again_grd_draw jnz .again_grd_draw
jmp .both_draw jmp .both_draw
@ -2179,19 +2191,19 @@ end if
push eax push eax
neg al neg al
push ax push ax
cmp [catmull_flag],1 ; cmp [catmull_flag],1
jne @f ; jne @f
push [zz2] push [zz2]
@@: ; @@:
mov eax,dword[yy2] mov eax,dword[yy2]
and eax,ebx and eax,ebx
push eax push eax
neg al neg al
push ax push ax
cmp [catmull_flag],1 ; cmp [catmull_flag],1
jne @f ; jne @f
push [zz1] push [zz1]
@@: ; @@:
mov eax,dword[yy1] mov eax,dword[yy1]
and eax,ebx and eax,ebx
push eax push eax
@ -2205,21 +2217,20 @@ end if
mov ecx,dword[xx3] mov ecx,dword[xx3]
ror ecx,16 ror ecx,16
mov edi,[screen_ptr] mov edi,[screen_ptr]
cmp [catmull_flag],0 ; cmp [catmull_flag],0
je @f ; je @f
; lea esi,[Z_buffer]
mov esi,[Zbuffer_ptr] mov esi,[Zbuffer_ptr]
call gouraud_triangle_z call gouraud_triangle_z
jmp .end_draw ; jmp .end_draw
@@: ; @@:
call gouraud_triangle ; call gouraud_triangle
jmp .end_draw jmp .end_draw
.flat_draw: ;************************** .flat_draw: ;**************************
; FLAT DRAWING ; FLAT DRAWING
movzx eax,[point_index1] mov eax,[point_index1]
movzx ebx,[point_index2] mov ebx,[point_index2]
movzx ecx,[point_index3] mov ecx,[point_index3]
shl eax,2 shl eax,2
shl ebx,2 shl ebx,2
shl ecx,2 shl ecx,2
@ -2246,7 +2257,8 @@ end if
mov edx,dword[esp-8] mov edx,dword[esp-8]
shl edx,TEX_SHIFT shl edx,TEX_SHIFT
add edx,dword[esp-4] add edx,dword[esp-4]
lea eax,[3*edx+color_map] lea eax,[3*edx]
add eax,color_map
mov edx,dword[eax] mov edx,dword[eax]
and edx,0x00ffffff ; edx = 0x00rrggbb and edx,0x00ffffff ; edx = 0x00rrggbb
@ -2271,34 +2283,32 @@ end if
ror ebx,16 ror ebx,16
mov ecx,dword[xx3] mov ecx,dword[xx3]
ror ecx,16 ror ecx,16
; mov edi,screen
mov edi,[screen_ptr] mov edi,[screen_ptr]
cmp [catmull_flag],0 ; cmp [catmull_flag],0
je @f ; je @f
; lea esi,[Z_buffer]
mov esi,[Zbuffer_ptr] mov esi,[Zbuffer_ptr]
push word[zz3] push word[zz3]
push word[zz2] push word[zz2]
push word[zz1] push word[zz1]
call flat_triangle_z call flat_triangle_z
jmp .end_draw jmp .end_draw
@@: ; @@:
call draw_triangle ; call draw_triangle
jmp .end_draw ; jmp .end_draw
.env_mapping: .env_mapping:
; fninit ; fninit
cmp [catmull_flag],0 ; cmp [catmull_flag],0
je @f ; je @f
push [zz3] push [zz3]
push [zz2] push [zz2]
push [zz1] push [zz1]
@@: ; @@:
mov esi,point_index1 mov esi,point_index1
sub esp,12 sub esp,12
mov edi,esp mov edi,esp
mov ecx,3 mov ecx,3
@@: @@:
movzx eax,word[esi] mov eax,dword[esi]
lea eax,[eax*3] lea eax,[eax*3]
shl eax,2 shl eax,2
add eax,[points_normals_rot_ptr] ;point_normals_rotated add eax,[points_normals_rot_ptr] ;point_normals_rotated
@ -2327,7 +2337,7 @@ end if
fistp word[edi+2] fistp word[edi+2]
; # end of last ch. ; # end of last ch.
add edi,4 add edi,4
add esi,2 add esi,4
loop @b loop @b
mov eax,dword[xx1] mov eax,dword[xx1]
@ -2338,30 +2348,30 @@ end if
ror ecx,16 ror ecx,16
mov edi,[screen_ptr] mov edi,[screen_ptr]
mov esi,envmap mov esi,envmap
cmp [catmull_flag],0 ; cmp [catmull_flag],0
je @f ; je @f
; mov edx,Z_buffer
mov edx,[Zbuffer_ptr] mov edx,[Zbuffer_ptr]
call tex_triangle_z call tex_triangle_z
jmp .end_draw ; jmp .end_draw
@@: ; @@:
call tex_triangle ; call tex_triangle
jmp .end_draw jmp .end_draw
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.cubic_env_mapping: .cubic_env_mapping:
; fninit ; fninit
cmp [catmull_flag],0 ; cmp [catmull_flag],0
je @f ; je @f
push [zz3] push [zz3]
push [zz2] push [zz2]
push [zz1] push [zz1]
@@: ; @@:
mov esi,point_index1 mov esi,point_index1
sub esp,12 sub esp,12
mov edi,esp mov edi,esp
mov ecx,3 mov ecx,3
@@: @@:
movzx eax,word[esi] mov eax,dword[esi]
lea eax,[eax*3] lea eax,[eax*3]
shl eax,2 shl eax,2
add eax,[points_normals_rot_ptr] ;point_normals_rotated add eax,[points_normals_rot_ptr] ;point_normals_rotated
@ -2390,7 +2400,7 @@ end if
; fistp word[edi+2] ; fistp word[edi+2]
; # end of last ch. ; # end of last ch.
add edi,4 add edi,4
add esi,2 add esi,4
loop @b loop @b
mov eax,dword[xx1] mov eax,dword[xx1]
@ -2401,34 +2411,33 @@ end if
ror ecx,16 ror ecx,16
mov edi,[screen_ptr] mov edi,[screen_ptr]
mov esi,envmap_cub mov esi,envmap_cub
cmp [catmull_flag],0 ; cmp [catmull_flag],0
je @f ; je @f
; mov edx,Z_buffer
mov edx,[Zbuffer_ptr] mov edx,[Zbuffer_ptr]
call tex_triangle_z call tex_triangle_z
jmp .end_draw ; jmp .end_draw
@@: ; @@:
call tex_triangle ; call tex_triangle
jmp .end_draw jmp .end_draw
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.bump_mapping: .bump_mapping:
; fninit ; fninit
cmp [catmull_flag],0 ; cmp [catmull_flag],0
je @f ; je @f
; push Z_buffer
push [Zbuffer_ptr] push [Zbuffer_ptr]
push [zz3] push [zz3]
push [zz2] push [zz2]
push [zz1] push [zz1]
@@: ; @@:
mov esi,point_index1 mov esi,point_index1
sub esp,12 sub esp,12
mov edi,esp mov edi,esp
mov ecx,3 mov ecx,3
@@: @@:
movzx eax,word[esi] mov eax,dword[esi]
lea eax,[eax*3] lea eax,[eax*3]
shl eax,2 shl eax,2
add eax,[points_normals_rot_ptr] ;point_normals_rotated add eax,[points_normals_rot_ptr] ;point_normals_rotated
@ -2444,21 +2453,21 @@ end if
fistp word[edi+2] fistp word[edi+2]
add edi,4 add edi,4
add esi,2 add esi,4
loop @b loop @b
movzx esi,[point_index3] ; bump map coords mov esi,[point_index3] ; bump map coords
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
movzx esi,[point_index2] mov esi,[point_index2]
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
; lea esi,[esi*3] ; lea esi,[esi*3]
; lea esi,[points+2+esi*2] ; lea esi,[points+2+esi*2]
push dword[esi] push dword[esi]
; push dword[xx2] ; push dword[xx2]
movzx esi,[point_index1] mov esi,[point_index1]
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
; lea esi,[esi*3] ; lea esi,[esi*3]
@ -2476,32 +2485,32 @@ end if
mov esi,envmap mov esi,envmap
mov edx,bumpmap ;BUMP_MAPPING mov edx,bumpmap ;BUMP_MAPPING
cmp [catmull_flag],0 ; cmp [catmull_flag],0
je @f ; je @f
call bump_triangle_z call bump_triangle_z
jmp .end_draw ; jmp .end_draw
@@: ; @@:
call bump_triangle ; call bump_triangle
jmp .end_draw jmp .end_draw
.tex_mapping: .tex_mapping:
; fninit ; fninit
cmp [catmull_flag],0 ; cmp [catmull_flag],0
je @f ; je @f
push [zz3] push [zz3]
push [zz2] push [zz2]
push [zz1] push [zz1]
@@: ; @@:
movzx esi,[point_index3] ; tex map coords mov esi,[point_index3] ; tex map coords
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
movzx esi,[point_index2] mov esi,[point_index2]
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
movzx esi,[point_index1] mov esi,[point_index1]
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
@ -2514,15 +2523,13 @@ end if
ror ecx,16 ror ecx,16
mov edi,[screen_ptr] mov edi,[screen_ptr]
mov esi,texmap mov esi,texmap
cmp [catmull_flag],0 ; cmp [catmull_flag],0
je @f ; je @f
; mov edx,Z_buffer
mov edx,[Zbuffer_ptr] mov edx,[Zbuffer_ptr]
call tex_triangle_z call tex_triangle_z
; call tex_plus_grd_trianlgle ; jmp .end_draw
jmp .end_draw ; @@:
@@: ; call tex_triangle
call tex_triangle
jmp .end_draw jmp .end_draw
; .ray: ; .ray:
; grd_triangle according to points index ; grd_triangle according to points index
@ -2564,15 +2571,15 @@ end if
sub esp,4 sub esp,4
push ebp push ebp
movzx esi,[point_index3] ; tex map coords mov esi,[point_index3] ; tex map coords
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] ; texture coords as first push dword[esi] ; texture coords as first
movzx esi,[point_index2] ; group of parameters mov esi,[point_index2] ; group of parameters
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
movzx esi,[point_index1] mov esi,[point_index1]
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
@ -2585,7 +2592,7 @@ end if
lea edx,[ecx*3] lea edx,[ecx*3]
push word[edx*2+xx1-2] ; zz1 ,2 ,3 push word[edx*2+xx1-2] ; zz1 ,2 ,3
movzx eax,word[esi] mov eax,dword[esi]
shl eax,2 shl eax,2
lea eax,[eax*3] ;+point_normals_rotated] lea eax,[eax*3] ;+point_normals_rotated]
add eax,[points_normals_rot_ptr] add eax,[points_normals_rot_ptr]
@ -2616,7 +2623,7 @@ end if
shr eax,24 shr eax,24
push ax ;b push ax ;b
sub esi,2 sub esi,4
dec cx dec cx
jnz .aagain_grd_draw jnz .aagain_grd_draw
@ -2644,15 +2651,15 @@ end if
push word[zz2] push word[zz2]
push word[zz1] push word[zz1]
movzx esi,[point_index3] ; tex map coords mov esi,[point_index3] ; tex map coords
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
movzx esi,[point_index2] mov esi,[point_index2]
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
movzx esi,[point_index1] mov esi,[point_index1]
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
@ -2662,7 +2669,7 @@ end if
mov edi,esp mov edi,esp
mov ecx,3 mov ecx,3
@@: @@:
movzx eax,word[esi] mov eax,dword[esi]
lea eax,[eax*3] lea eax,[eax*3]
shl eax,2 shl eax,2
add eax,[points_normals_rot_ptr] add eax,[points_normals_rot_ptr]
@ -2678,7 +2685,7 @@ end if
fistp word[edi+2] fistp word[edi+2]
add edi,4 add edi,4
add esi,2 add esi,4
loop @b loop @b
mov eax,dword[xx1] mov eax,dword[xx1]
@ -2695,15 +2702,15 @@ end if
jmp .end_draw jmp .end_draw
.bump_tex: .bump_tex:
movzx esi,[point_index3] ; tex map coords mov esi,[point_index3] ; tex map coords
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
movzx esi,[point_index2] mov esi,[point_index2]
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
movzx esi,[point_index1] mov esi,[point_index1]
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
@ -2722,7 +2729,7 @@ end if
mov edi,esp mov edi,esp
mov ecx,3 mov ecx,3
@@: @@:
movzx eax,word[esi] mov eax,dword[esi]
lea eax,[eax*3] lea eax,[eax*3]
shl eax,2 shl eax,2
add eax,[points_normals_rot_ptr] add eax,[points_normals_rot_ptr]
@ -2738,23 +2745,23 @@ end if
fistp word[edi+2] fistp word[edi+2]
add edi,4 add edi,4
add esi,2 add esi,4
loop @b loop @b
; push dword 1 shl 16 + 1 ; emap coords ; push dword 1 shl 16 + 1 ; emap coords
; push dword 127 shl 16 + 1 ; push dword 127 shl 16 + 1
; push dword 127 shl 16 + 127 ; push dword 127 shl 16 + 127
movzx esi,[point_index3] ; bump map coords mov esi,[point_index3] ; bump map coords
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
movzx esi,[point_index2] mov esi,[point_index2]
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
movzx esi,[point_index1] mov esi,[point_index1]
shl esi,2 shl esi,2
add esi,tex_points add esi,tex_points
push dword[esi] push dword[esi]
@ -2781,7 +2788,7 @@ end if
mov esi,point_index3 mov esi,point_index3
mov ecx,3 mov ecx,3
.again_line_param: .again_line_param:
movzx eax,word[esi] mov eax,dword[esi]
shl eax,2 shl eax,2
lea eax,[eax*3] lea eax,[eax*3]
add eax,[points_normals_rot_ptr] add eax,[points_normals_rot_ptr]
@ -2806,7 +2813,7 @@ end if
shl ebx,2 shl ebx,2
mov [ebx+col1],eax mov [ebx+col1],eax
sub esi,2 sub esi,4
dec ecx dec ecx
jnz .again_line_param jnz .again_line_param
@ -2918,10 +2925,12 @@ end if
.end_draw: .end_draw:
pop esi pop esi
add esi,6 add esi,12
inc [edges_counter] inc [edges_counter]
cmp dword[esi],-1 pop ecx
jne .again_dts sub ecx,1
; cmp dword[esi],-1
jnz .again_dts
ret ret
@ -2930,6 +2939,10 @@ ret
draw_handlers: draw_handlers:
push ebp push ebp
@ -3021,7 +3034,7 @@ draw_handlers:
add esi,6 add esi,6
inc dword[.counter] inc dword[.counter]
mov ecx,[.counter] mov ecx,[.counter]
cmp cx,[points_count_var] cmp ecx,[points_count_var]
jng .loop jng .loop
mov esp,ebp mov esp,ebp
@ -3064,8 +3077,8 @@ read_tp_variables: ; read [triangles_count_var] and [points_count_var]
; and allocate memory ; and allocate memory
xor ebx,ebx xor ebx,ebx
xor ebp,ebp xor ebp,ebp
mov [points_count_var],bx mov [points_count_var],ebx
mov [triangles_count_var],bx mov [triangles_count_var],ebx
if USE_LFN = 0 if USE_LFN = 0
mov esi,SourceFile mov esi,SourceFile
else else
@ -3124,7 +3137,7 @@ read_tp_variables: ; read [triangles_count_var] and [points_count_var]
jmp @b jmp @b
@@: @@:
movzx ecx,word[esi+6] movzx ecx,word[esi+6]
add [points_count_var],cx add [points_count_var],ecx
mov edx,ecx mov edx,ecx
add esi,8 add esi,8
@ -3143,7 +3156,7 @@ read_tp_variables: ; read [triangles_count_var] and [points_count_var]
jmp @b jmp @b
@@: @@:
movzx ecx,word[esi+6] movzx ecx,word[esi+6]
add [triangles_count_var],cx add [triangles_count_var],ecx
add esi,8 add esi,8
@@: @@:
@ -3218,7 +3231,7 @@ read_from_file:
jmp @b jmp @b
@@: @@:
movzx ecx,word[esi+6] movzx ecx,word[esi+6]
add [points_count_var],cx add [points_count_var],ecx
mov edx,ecx mov edx,ecx
add esi,8 add esi,8
@ -3232,12 +3245,6 @@ read_from_file:
push dword[esi+8] push dword[esi+8]
pop dword[edi+ebx*2+8] pop dword[edi+ebx*2+8]
pop edi pop edi
; fld dword[esi+4]
; fstp dword[real_points+ebx*2+0] ; x
; fld dword[esi+8]
; fstp dword[real_points+ebx*2+4] ; y
; fld dword[esi+0]
; fstp dword[real_points+ebx*2+8] ; z
add ebx,6 add ebx,6
add esi,12 add esi,12
@ -3256,16 +3263,20 @@ read_from_file:
jmp @b jmp @b
@@: @@:
movzx ecx,word[esi+6] movzx ecx,word[esi+6]
add [triangles_count_var],cx add [triangles_count_var],ecx
add esi,8 add esi,8
;mov edi,triangles ;mov edi,triangles
@@: @@:
movsd movzx eax,word[esi]
movsw stosd
add word[edi-6],bp movzx eax,word[esi+2]
add word[edi-4],bp stosd
add word[edi-2],bp movzx eax,word[esi+4]
add esi,2 stosd
add dword[edi-12],ebp
add dword[edi-8],ebp
add dword[edi-4],ebp
add esi,8
dec ecx dec ecx
jnz @b jnz @b
add ebp,edx add ebp,edx
@ -3286,10 +3297,10 @@ alloc_mem_for_tp:
mov ebx,20 mov ebx,20
.alloc: .alloc:
movzx ecx, [triangles_count_var] mov ecx,[triangles_count_var]
inc ecx add ecx,20
lea ecx, [ecx*3] lea ecx, [ecx*3]
add ecx, ecx shl ecx,2
mov edx,[triangles_ptr] mov edx,[triangles_ptr]
int 0x40 ; -> allocate memory to triangles int 0x40 ; -> allocate memory to triangles
mov [triangles_ptr], eax ; -> eax = pointer to allocated mem mov [triangles_ptr], eax ; -> eax = pointer to allocated mem
@ -3319,7 +3330,7 @@ alloc_mem_for_tp:
; ststic memory ; ststic memory
mov eax, 68 mov eax, 68
movzx ecx, [triangles_count_var] mov ecx, [triangles_count_var]
lea ecx, [3+ecx*3] lea ecx, [3+ecx*3]
shl ecx, 2 shl ecx, 2
mov edx,[triangles_normals_ptr] mov edx,[triangles_normals_ptr]
@ -3334,7 +3345,7 @@ alloc_mem_for_tp:
; mov dword[vertices_index_ptr], eax ; mov dword[vertices_index_ptr], eax
mov eax, 68 mov eax, 68
movzx ecx, [points_count_var] mov ecx, [points_count_var]
lea ecx,[3+ecx*3] lea ecx,[3+ecx*3]
shl ecx, 2 shl ecx, 2
mov edx,[points_normals_ptr] mov edx,[points_normals_ptr]
@ -3348,7 +3359,7 @@ alloc_mem_for_tp:
mov eax, 68 mov eax, 68
; mov ebx, 12 ; mov ebx, 12
movzx ecx, [points_count_var] mov ecx, [points_count_var]
lea ecx,[3+ecx*3] lea ecx,[3+ecx*3]
shl ecx, 2 shl ecx, 2
mov edx,[points_normals_rot_ptr] mov edx,[points_normals_rot_ptr]
@ -3366,7 +3377,7 @@ alloc_mem_for_tp:
mov [points_rotated_ptr], eax mov [points_rotated_ptr], eax
mov eax, 68 mov eax, 68
movzx ecx, [points_count_var] mov ecx, [points_count_var]
inc ecx inc ecx
shl ecx, 3 shl ecx, 3
mov edx,[points_translated_ptr] mov edx,[points_translated_ptr]
@ -3381,42 +3392,33 @@ if USE_LFN
;- ;-
mov eax, 68 mov eax, 68
mov ebx, 11 mov ebx, 11
int 0x40 ; -> init heap int 0x40 ; -> create heap
;mov eax, 70 ; mov eax, 70
;mov ebx, file_info ; mov ebx, file_info
;mov dword[ebx], 5 ; -> subfunction number ; mov dword[ebx], 5 ; -> subfunction number
;int 0x40 ; -> read file size ; int 0x40 ; -> read file size
;mov ebx, [fptr] ; mov ebx, [fptr]
;mov ebx, dword[ebx+32] ; mov ebx, dword[ebx+32]
;inc ebx ; inc ebx
;mov [fsize], ebx ; mov [fsize], ebx
;mov eax, 68
;mov ebx, 12
;mov ecx, [fsize]
;int 0x40 ; -> allocate memory for file
;mov [fptr], eax ; -> eax = pointer to allocated mem
;mov eax, 70
;mov ebx, file_info
;mov dword[ebx],0
;int 0x40 ; -> read file
;mov [fsize],ebx ; mov eax, 68
;cmp eax,6 ; mov ebx, 12
;jnz @f ; mov ecx, [fsize]
;xor eax,eax ;;;;--- ; int 0x40 ; -> allocate memory for file
; mov [fptr], eax ; -> eax = pointer to allocated mem
;cmp eax,6
;jnz @f
;xor eax,eax ;;;;---
; mov eax, 70
; mov ebx, file_info
; mov dword[ebx],0
; int 0x40 ; -> read file
;load kpacked files by Leency ;load kpacked files by Leency
mov eax,68 mov eax,68
mov ebx,27 mov ebx,27
mov ecx,I_Param mov ecx,file_name
int 0x40 int 0x40
mov [fsize],edx mov [fsize],edx
@ -3453,6 +3455,8 @@ else
int 0x40 int 0x40
end if end if
; eax = 0 -> ok file loaded ; eax = 0 -> ok file loaded
ret
; eax = 0 -> ok file loaded
ret ret
read_param: read_param:
mov esi,I_Param mov esi,I_Param