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

@ -13,18 +13,18 @@ vec_z equ 8
;---------------------- out : none ------------------------
if 0
make_vector:
fninit
fild word[edi+x3d] ;edi+x3d
fisub word[esi+x3d] ;esi+x3d
fstp dword[ebx+vec_x]
fninit
fild word[edi+x3d] ;edi+x3d
fisub word[esi+x3d] ;esi+x3d
fstp dword[ebx+vec_x]
fild word[edi+y3d]
fisub word[esi+y3d]
fstp dword[ebx+vec_y]
fild word[edi+y3d]
fisub word[esi+y3d]
fstp dword[ebx+vec_y]
fild word[edi+z3d]
fisub word[esi+z3d]
fstp dword[ebx+vec_z]
fild word[edi+z3d]
fisub word[esi+z3d]
fstp dword[ebx+vec_z]
ret
end if
@ -32,10 +32,10 @@ reverse_mx_3x3:
; esi - source matrix
; edi - desired reversed matrix
push ebp
mov ebp,esp
sub esp,4
.det equ ebp-4
push ebp
mov ebp,esp
sub esp,4
.det equ ebp-4
fninit
fld dword[esi]
@ -160,18 +160,27 @@ reverse_mx_3x3:
ret
make_vector_r:
fninit
fld dword[edi] ;edi+x3d
fsub dword[esi] ;esi+x3d
fstp dword[ebx+vec_x]
if Ext < SSE2
fninit
fld dword[edi] ;edi+x3d
fsub dword[esi] ;esi+x3d
fstp dword[ebx+vec_x]
fld dword[edi+4]
fsub dword[esi+4]
fstp dword[ebx+vec_y]
fld dword[edi+4]
fsub dword[esi+4]
fstp dword[ebx+vec_y]
fld dword[edi+8]
fsub dword[esi+8]
fstp dword[ebx+vec_z]
fld dword[edi+8]
fsub dword[esi+8]
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
;---------------------- in: -------------------------------
@ -180,61 +189,61 @@ ret
;--------------------------- ebx - pointer to result vector
;---------------------- out : none
cross_product:
fninit
fld dword [esi+vec_y]
fmul dword [edi+vec_z]
fld dword [esi+vec_z]
fmul dword [edi+vec_y]
fsubp ;st1 ,st
fstp dword [ebx+vec_x]
fninit
fld dword [esi+vec_y]
fmul dword [edi+vec_z]
fld dword [esi+vec_z]
fmul dword [edi+vec_y]
fsubp ;st1 ,st
fstp dword [ebx+vec_x]
fld dword [esi+vec_z]
fmul dword [edi+vec_x]
fld dword [esi+vec_x]
fmul dword [edi+vec_z]
fsubp ;st1 ,st
fstp dword [ebx+vec_y]
fld dword [esi+vec_z]
fmul dword [edi+vec_x]
fld dword [esi+vec_x]
fmul dword [edi+vec_z]
fsubp ;st1 ,st
fstp dword [ebx+vec_y]
fld dword [esi+vec_x]
fmul dword [edi+vec_y]
fld dword [esi+vec_y]
fmul dword [edi+vec_x]
fsubp ;st1 ,st
fstp dword [ebx+vec_z]
fld dword [esi+vec_x]
fmul dword [edi+vec_y]
fld dword [esi+vec_y]
fmul dword [edi+vec_x]
fsubp ;st1 ,st
fstp dword [ebx+vec_z]
ret
;----------------------- in: ------------------------------
;---------------------------- edi - pointer to vector -----
;----------------------- out : none
normalize_vector:
fninit
fld dword [edi+vec_x]
fmul st, st
fld dword [edi+vec_y]
fmul st, st
fld dword [edi+vec_z]
fmul st, st
faddp st1, st
faddp st1, st
fsqrt
fninit
fld dword [edi+vec_x]
fmul st, st
fld dword [edi+vec_y]
fmul st, st
fld dword [edi+vec_z]
fmul st, st
faddp st1, st
faddp st1, st
fsqrt
ftst
fstsw ax
sahf
jnz @f
ftst
fstsw ax
sahf
jnz @f
fst dword [edi+vec_x]
fst dword [edi+vec_y]
fstp dword [edi+vec_z]
ret
fst dword [edi+vec_x]
fst dword [edi+vec_y]
fstp dword [edi+vec_z]
ret
@@:
fld st
fld st
fdivr dword [edi+vec_x]
fstp dword [edi+vec_x]
fdivr dword [edi+vec_y]
fstp dword [edi+vec_y]
fdivr dword [edi+vec_z]
fstp dword [edi+vec_z]
fld st
fld st
fdivr dword [edi+vec_x]
fstp dword [edi+vec_x]
fdivr dword [edi+vec_y]
fstp dword [edi+vec_y]
fdivr dword [edi+vec_z]
fstp dword [edi+vec_z]
ret
;------------------in: -------------------------
;------------------ esi - pointer to 1st vector
@ -242,15 +251,15 @@ ret
;------------------out: ------------------------
;------------------ st0 - dot-product
dot_product:
fninit
fld dword [esi+vec_x]
fmul dword [edi+vec_x]
fld dword [esi+vec_y]
fmul dword [edi+vec_y]
fld dword [esi+vec_z]
fmul dword [edi+vec_z]
faddp
faddp
fninit
fld dword [esi+vec_x]
fmul dword [edi+vec_x]
fld dword [esi+vec_y]
fmul dword [edi+vec_y]
fld dword [esi+vec_z]
fmul dword [edi+vec_z]
faddp
faddp
ret
; DOS version Coded by Mikolaj Felix aka Majuma
@ -258,33 +267,33 @@ ret
; www.majuma.xt.pl
; into FASM translation by Macgub
init_sincos_tab:
.counter equ dword [ebp-4] ; cur angle
.counter equ dword [ebp-4] ; cur angle
push ebp
mov ebp,esp
push ebp
mov ebp,esp
xor eax,eax
push eax ; init .counter
mov edi,cos_tab
mov esi,sin_tab
mov ecx,256
xor eax,eax
push eax ; init .counter
mov edi,cos_tab
mov esi,sin_tab
mov ecx,256
fninit
fld .counter
fld .counter
@@:
fld st
fld st
fsincos
fstp dword [edi]
fstp dword [esi]
fstp dword [edi]
fstp dword [esi]
; fadd [piD180]
fadd [piD128]
add esi,4
add edi,4
loop @b
ffree st
fadd [piD128]
add esi,4
add edi,4
loop @b
ffree st
mov esp,ebp
pop ebp
mov esp,ebp
pop ebp
ret
;------
; esi - offset (pointer) to angles, edi offset to 3x3 matrix
@ -469,36 +478,36 @@ ret
add_scale_to_matrix:
fninit
fld [rsscale]
fld dword[esi] ;-----
fld dword[esi] ;-----
fmul st,st1
fstp dword[esi]
fld dword[esi+12] ; x scale
fld dword[esi+12] ; x scale
fmul st,st1
fstp dword[esi+12]
fld dword[esi+24]
fmul st,st1
fstp dword[esi+24] ;------
fstp dword[esi+24] ;------
fld dword[esi+4] ;-----
fld dword[esi+4] ;-----
fmul st,st1
fstp dword[esi+4]
fld dword[esi+16] ; y scale
fld dword[esi+16] ; y scale
fmul st,st1
fstp dword[esi+16]
fld dword[esi+28]
fmul st,st1
fstp dword[esi+28] ;------
fstp dword[esi+28] ;------
fld dword[esi+8] ;-----
fld dword[esi+8] ;-----
fmul st,st1
fstp dword[esi+8]
fld dword[esi+20] ; z scale
fld dword[esi+20] ; z scale
fmul st,st1
fstp dword[esi+20]
fld dword[esi+32]
fmulp st1,st
fstp dword[esi+32] ;------
fstp dword[esi+32] ;------
ret

View File

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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,5 +1,14 @@
View3ds 0.068b - tiny viewer to .3ds and .asc files with several graphics
effects implementation.
View3ds 0.069 - tiny viewer to .3ds and .asc files with several graphics
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:
1. rotary: choosing rotary axle: x, y, x+y.
@ -11,8 +20,7 @@ Buttons description:
mapping), grdl (Gouraud lines - edges only).
3. speed: idle, full.
4,5. zoom in, out: no comment.
6. catmull: on -> use z buffer ( z coordinate interpolation), off -> depth sorting, painters
alghoritm).Txgrd, 2tex and bumptex models only with catmull = on.
6. catmull: disabled
7. culling: backface culling on/ off.
8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination).
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
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 ?

File diff suppressed because it is too large Load Diff