Subversion Repositories Kolibri OS

Rev

Rev 8666 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8719 leency 1
; Line drawing procedure by Pablo Reda.
2
; Gouraud extension by Maciej Guba.
3
;****************************************************
4
line_grd:  ; eax=x1 ebx=y1 ecx=x2 edx=y2
5
                 ; xmm0 - color1 argb as 4 dword float
6
                 ; xmm1 - color2 argb as 4 dword float
7
                 ; xmm2 - z1 as dword  float
8
                 ; xmm3 - z2 as dword  float
9
                 ; mm0  - Z buffer
10
                 ; mm1  - screen buffer
11
                 ; mm2  - screen width
12
 
13
 
14
        cmp    ebx,edx
15
      ;  je     horizontal_grd
16
        jg     .noswap
17
        xchg   eax,ecx
18
        xchg   ebx,edx
19
        movaps xmm7,xmm0
20
        movaps xmm0,xmm1
21
        movaps xmm1,xmm7
22
        movaps xmm7,xmm2
23
        movaps xmm2,xmm3
24
        movaps xmm3,xmm7
25
.noswap:
26
 
27
        cvtsi2ss xmm7,eax
28
        cvtsi2ss xmm6,ebx
29
        cvtsi2ss xmm5,ecx
30
        cvtsi2ss xmm4,edx
31
        subss    xmm7,xmm5
32
        subss    xmm6,xmm4
33
        andps    xmm7,[abs_mask]  ; 0x7fff
34
        andps    xmm6,[abs_mask]  ; 0x7fff
35
        maxss    xmm7,xmm6   ; xmm7 - delta
36
        shufps   xmm7,xmm7,0
37
        movaps   xmm6,xmm3
38
        rcpps    xmm7,xmm7
39
        subss    xmm6,xmm2
40
        mulss    xmm6,xmm7   ; xmm6 - delta z
41
        movaps   xmm5,xmm1
42
        subps    xmm5,xmm0
43
        mulps    xmm5,xmm7   ; xmm5 - delta col argb
44
 
45
 
46
        shl eax,16
47
        shl ecx,16
48
        sub eax,ecx
49
        push ebx
50
        push edx
51
        sub ebx,edx
52
        add ebx,1
53
        cdq
54
        idiv ebx
55
        mov esi,eax
56
        add ecx,$7fff
57
        pop ebx
58
        pop edx
59
.lineas:
60
        mov eax,ecx
61
        add eax,esi
62
        push ebx
63
        push eax
64
        push edx
65
        shr ecx,16
66
        shr eax,16
67
        call horizontal_grd
68
        pop edx
69
        pop ecx
70
        pop ebx
71
        add ebx,1
72
        cmp ebx,edx
73
        jle .lineas
74
        ret
75
 
76
horizontal_grd:  ; eax=x1 ebx=y1 ecx=x2
77
        cmp ecx,eax
78
        jg .m
79
        xchg ecx,eax
80
.m:
81
        sub ecx,eax
82
        jnz .nn
83
        add ecx,1
84
.nn:
85
        movd  edx,mm2
86
        imul  ebx,edx
87
        add   eax,ebx
88
        movd  edi,mm1
89
        lea   edi,[edi+eax*4]
90
        push  eax
91
        push  ebx
92
        movd  ebx,mm0
93
        lea   ebx,[ebx+eax*4]
94
.l:
95
      ;  movss    xmm4,xmm2     ; xmm2 - cur z
96
      ;  cmpnltss xmm4,[ebx]
97
      ;  movd     eax,xmm4
98
      ;  or       eax,eax
99
      ;  jnz      @f
100
        comiss   xmm2,[ebx]
101
        jng      @f
102
        movaps   xmm4,xmm0    ; xmm0 - cur col
103
        cvtps2dq xmm4,xmm4
104
        packssdw xmm4,xmm4
105
        packuswb xmm4,xmm4
106
        movd     [edi],xmm4
107
      @@:
108
        addss xmm2,xmm6
109
        addps xmm0,xmm5
110
        add   edi,4
111
        sub   ecx,1
112
        jnz   .l
113
        pop   ebx
114
        pop   eax
115
        ret