Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1775 → Rev 1776

/programs/demos/3DS/GRD3.INC
22,29 → 22,27
.x3 equ word[ebp-10]
.y3 equ word[ebp-12]
 
.dc12r equ dword[ebp-16]
.dc12g equ dword[ebp-20]
.dc12b equ dword[ebp-24]
.dc13r equ dword[ebp-28]
.dc13g equ dword[ebp-32]
.dc13b equ dword[ebp-36]
.dc23r equ dword[ebp-40]
.dc23g equ dword[ebp-44]
.dc23b equ dword[ebp-48]
.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-52]
.c1g equ dword[ebp-56]
.c1b equ dword[ebp-60]
.c2r equ dword[ebp-64]
.c2g equ dword[ebp-68]
.c2b equ dword[ebp-72]
.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]
 
.dx12 equ dword[ebp-76]
.dx13 equ dword[ebp-80]
.dx23 equ dword[ebp-84]
 
 
 
mov ebp,esp
; sub esp,72
 
73,7 → 71,7
push eax ;store triangle coordinates in user friendly variables
push ebx
push ecx
sub esp,72 ; set correctly value of esp
; sub esp,72 ; set correctly value of esp
 
mov edx,eax ; check only X triangle coordinate
or edx,ebx
94,10 → 92,15
mov bx,.y2 ; calc deltas
sub bx,.y1
jnz .gt_dx12_make
mov .dx12,0
mov .dc12r,0
mov .dc12g,0
mov .dc12b,0
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:
 
108,7 → 111,8
shl eax,ROUND
cdq
idiv ebx
mov .dx12,eax
; mov .dx12,eax
push eax
 
mov ax,word[.col2r]
sub ax,word[.col1r]
116,7 → 120,9
shl eax,ROUND
cdq
idiv ebx
mov .dc12r,eax
; mov .dc12r,eax
push eax
 
mov ax,word[.col2g]
sub ax,word[.col1g]
cwde
123,7 → 129,9
shl eax,ROUND
cdq
idiv ebx
mov .dc12g,eax
; mov .dc12g,eax
push eax
 
mov ax,word[.col2b]
sub ax,word[.col1b]
cwde
130,16 → 138,21
shl eax,ROUND
cdq
idiv ebx
mov .dc12b,eax
; mov .dc12b,eax
push eax
.gt_dx12_done:
 
mov bx,.y3
sub bx,.y1
jnz .gt_dx13_make
mov .dx13,0
mov .dc13r,0
mov .dc13g,0
mov .dc13b,0
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
149,7 → 162,8
shl eax,ROUND
cdq
idiv ebx
mov .dx13,eax
; mov .dx13,eax
push eax
 
mov ax,word[.col3r]
sub ax,word[.col1r]
157,7 → 171,9
shl eax,ROUND
cdq
idiv ebx
mov .dc13r,eax
; mov .dc13r,eax
push eax
 
mov ax,word[.col3g]
sub ax,word[.col1g]
cwde
164,7 → 180,8
shl eax,ROUND
cdq
idiv ebx
mov .dc13g,eax
; mov .dc13g,eax
push eax
mov ax,word[.col3b]
sub ax,word[.col1b]
cwde
171,16 → 188,21
shl eax,ROUND
cdq
idiv ebx
mov .dc13b,eax
; mov .dc13b,eax
push eax
.gt_dx13_done:
 
mov bx,.y3
sub bx,.y2
jnz .gt_dx23_make
mov .dx23,0
mov .dc23r,0
mov .dc23g,0
mov .dc23b,0
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
190,7 → 212,8
shl eax,ROUND
cdq
idiv ebx
mov .dx23,eax
; mov .dx23,eax
push eax
 
mov ax,word[.col3r]
sub ax,word[.col2r]
198,7 → 221,10
shl eax,ROUND
cdq
idiv ebx
mov .dc23r,eax
; mov .dc23r,eax
push eax
 
 
mov ax,word[.col3g]
sub ax,word[.col2g]
cwde
205,7 → 231,9
shl eax,ROUND
cdq
idiv ebx
mov .dc23g,eax
; mov .dc23g,eax
push eax
 
mov ax,word[.col3b]
sub ax,word[.col2b]
cwde
212,9 → 240,11
shl eax,ROUND
cdq
idiv ebx
mov .dc23b,eax
; mov .dc23b,eax
push eax
 
.gt_dx23_done:
 
sub esp,24
movsx eax,.x1
shl eax,ROUND
mov ebx,eax
240,6 → 270,8
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
249,6 → 281,9
mov edx,.c2b
sar edx,ROUND
push dx
 
sar eax,ROUND
push ax
mov edx,.c1r
sar edx,ROUND
push dx
259,10 → 294,6
sar edx,ROUND
push dx
push cx
sar ebx,ROUND
push bx
sar eax,ROUND
push ax
call gouraud_line
 
pop ebp
271,16 → 302,28
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
 
313,6 → 356,8
push edi
push ebp
 
sar ebx,ROUND
push bx
mov edx,.c2r
sar edx,ROUND
push dx
322,6 → 367,9
mov edx,.c2b
sar edx,ROUND
push dx
 
sar eax,ROUND
push ax
mov edx,.c1r
sar edx,ROUND
push dx
332,10 → 380,6
sar edx,ROUND
push dx
push cx
sar ebx,ROUND
push bx
sar eax,ROUND
push ax
call gouraud_line
 
pop ebp
344,16 → 388,28
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
 
370,15 → 426,15
gouraud_line:
;-------------in - edi - pointer to screen buffer
;----------------- stack - another parameters
.x1 equ word [ebp+4]
.x2 equ word [ebp+6]
.y equ word [ebp+8]
.col1b equ ebp+10
.col1g equ ebp+12
.col1r equ ebp+14
.col2b equ ebp+16
.col2g equ ebp+18
.col2r equ ebp+20
.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]
395,14 → 451,19
je .gl_quit
jl .gl_ok
 
xchg ax,.x2
mov .x1,ax
mov eax,dword[.col1b]
xchg eax,dword[.col2b]
mov dword[.col1b],eax
mov ax,word[.col1r]
xchg ax,word[.col2r]
mov word[.col1r],ax
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
420,7 → 481,7
movsx ecx,.y
mov eax,SIZE_X*3
mul ecx
movsx ebx,.x1
movsx ebx,word .x1
lea ecx,[ebx*2+eax]
add edi,ecx
add edi,ebx
478,4 → 539,152
.gl_quit:
; add esp,12
mov esp,ebp
ret 18
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