Rev 1245 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1245 | hidnplayr | 1 | gouraud_triangle: |
2 | ;------------------in - eax - x1 shl 16 + y1 --------- |
||
3 | ;---------------------- ebx - x2 shl 16 + y2 --------- |
||
4 | ;---------------------- ecx - x3 shl 16 + y3 --------- |
||
5 | ;---------------------- edi - pointer to screen buffer |
||
6 | ;---------------------- stack : colors---------------- |
||
7 | ;----------------- procedure don't save registers !!-- |
||
8 | .col1r equ ebp+4 ; each color as word |
||
9 | .col1g equ ebp+6 |
||
10 | .col1b equ ebp+8 |
||
11 | .col2r equ ebp+10 |
||
12 | .col2g equ ebp+12 |
||
13 | .col2b equ ebp+14 |
||
14 | .col3r equ ebp+16 |
||
15 | .col3g equ ebp+18 |
||
16 | .col3b equ ebp+20 |
||
17 | |||
18 | .x1 equ word[ebp-2] |
||
19 | .y1 equ word[ebp-4] |
||
20 | .x2 equ word[ebp-6] |
||
21 | .y2 equ word[ebp-8] |
||
22 | .x3 equ word[ebp-10] |
||
23 | .y3 equ word[ebp-12] |
||
24 | |||
1776 | yogev_ezra | 25 | .dx12 equ dword[ebp-16] |
26 | .dc12r equ dword[ebp-20] |
||
27 | .dc12g equ [ebp-24] |
||
28 | .dc12b equ dword[ebp-28] |
||
29 | .dx13 equ dword[ebp-32] |
||
30 | .dc13r equ dword[ebp-36] |
||
31 | .dc13g equ [ebp-40] |
||
32 | .dc13b equ dword[ebp-44] |
||
33 | .dx23 equ dword[ebp-48] |
||
34 | .dc23r equ dword[ebp-52] |
||
35 | .dc23g equ [ebp-56] |
||
36 | .dc23b equ dword[ebp-60] |
||
1245 | hidnplayr | 37 | |
1776 | yogev_ezra | 38 | .c1r equ dword[ebp-64] |
39 | .c1g equ [ebp-68] |
||
40 | .c1b equ dword[ebp-72] |
||
41 | .c2r equ dword[ebp-76] |
||
42 | .c2g equ [ebp-80] |
||
43 | .c2b equ dword[ebp-84] |
||
1245 | hidnplayr | 44 | |
45 | |||
46 | mov ebp,esp |
||
47 | ; sub esp,72 |
||
48 | |||
49 | .sort3: ; sort triangle coordinates... |
||
50 | cmp ax,bx |
||
51 | jle .sort1 |
||
52 | xchg eax,ebx |
||
53 | mov edx,dword[.col1r] |
||
54 | xchg edx,dword[.col2r] |
||
55 | mov dword[.col1r],edx |
||
56 | mov dx,word[.col1b] |
||
57 | xchg dx,word[.col2b] |
||
58 | mov word[.col1b],dx |
||
59 | .sort1: |
||
60 | cmp bx,cx |
||
61 | jle .sort2 |
||
62 | xchg ebx,ecx |
||
63 | mov edx,dword[.col2r] |
||
64 | xchg edx,dword[.col3r] |
||
65 | mov dword[.col2r],edx |
||
66 | mov dx,word[.col2b] |
||
67 | xchg dx,word[.col3b] |
||
68 | mov word[.col2b],dx |
||
69 | jmp .sort3 |
||
70 | .sort2: |
||
71 | push eax ;store triangle coordinates in user friendly variables |
||
72 | push ebx |
||
73 | push ecx |
||
1776 | yogev_ezra | 74 | ; sub esp,72 ; set correctly value of esp |
1245 | hidnplayr | 75 | |
76 | mov edx,eax ; check only X triangle coordinate |
||
77 | or edx,ebx |
||
78 | or edx,ecx |
||
79 | test edx,80000000h |
||
80 | jne .gt_loop2_end |
||
81 | shr eax,16 |
||
82 | cmp ax,SIZE_X-1 |
||
83 | jg .gt_loop2_end |
||
84 | shr ebx,16 |
||
85 | cmp bx,SIZE_X-1 |
||
86 | jg .gt_loop2_end |
||
87 | shr ecx,16 |
||
88 | cmp cx,SIZE_X-1 |
||
89 | jg .gt_loop2_end |
||
90 | |||
91 | |||
92 | mov bx,.y2 ; calc deltas |
||
93 | sub bx,.y1 |
||
94 | jnz .gt_dx12_make |
||
1776 | yogev_ezra | 95 | xor edx,edx |
96 | mov ecx,4 |
||
97 | @@: |
||
98 | push edx |
||
99 | loop @b |
||
100 | ; mov .dx12,0 |
||
101 | ; mov .dc12r,0 |
||
102 | ; mov .dc12g,0 |
||
103 | ; mov .dc12b,0 |
||
1245 | hidnplayr | 104 | jmp .gt_dx12_done |
105 | .gt_dx12_make: |
||
106 | |||
107 | mov ax,.x2 |
||
108 | sub ax,.x1 |
||
109 | cwde |
||
110 | movsx ebx,bx |
||
111 | shl eax,ROUND |
||
112 | cdq |
||
113 | idiv ebx |
||
1776 | yogev_ezra | 114 | ; mov .dx12,eax |
115 | push eax |
||
1245 | hidnplayr | 116 | |
117 | mov ax,word[.col2r] |
||
118 | sub ax,word[.col1r] |
||
119 | cwde |
||
120 | shl eax,ROUND |
||
121 | cdq |
||
122 | idiv ebx |
||
1776 | yogev_ezra | 123 | ; mov .dc12r,eax |
124 | push eax |
||
125 | |||
1245 | hidnplayr | 126 | mov ax,word[.col2g] |
127 | sub ax,word[.col1g] |
||
128 | cwde |
||
129 | shl eax,ROUND |
||
130 | cdq |
||
131 | idiv ebx |
||
1776 | yogev_ezra | 132 | ; mov .dc12g,eax |
133 | push eax |
||
134 | |||
1245 | hidnplayr | 135 | mov ax,word[.col2b] |
136 | sub ax,word[.col1b] |
||
137 | cwde |
||
138 | shl eax,ROUND |
||
139 | cdq |
||
140 | idiv ebx |
||
1776 | yogev_ezra | 141 | ; mov .dc12b,eax |
142 | push eax |
||
1245 | hidnplayr | 143 | .gt_dx12_done: |
144 | mov bx,.y3 |
||
145 | sub bx,.y1 |
||
146 | jnz .gt_dx13_make |
||
1776 | yogev_ezra | 147 | xor edx,edx |
148 | mov ecx,4 |
||
149 | @@: |
||
150 | push edx |
||
151 | loop @b |
||
152 | ; mov .dx13,0 |
||
153 | ; mov .dc13r,0 |
||
154 | ; mov .dc13g,0 |
||
155 | ; mov .dc13b,0 |
||
1245 | hidnplayr | 156 | jmp .gt_dx13_done |
157 | .gt_dx13_make: |
||
158 | mov ax,.x3 |
||
159 | sub ax,.x1 |
||
160 | cwde |
||
161 | movsx ebx,bx |
||
162 | shl eax,ROUND |
||
163 | cdq |
||
164 | idiv ebx |
||
1776 | yogev_ezra | 165 | ; mov .dx13,eax |
166 | push eax |
||
1245 | hidnplayr | 167 | |
168 | mov ax,word[.col3r] |
||
169 | sub ax,word[.col1r] |
||
170 | cwde |
||
171 | shl eax,ROUND |
||
172 | cdq |
||
173 | idiv ebx |
||
1776 | yogev_ezra | 174 | ; mov .dc13r,eax |
175 | push eax |
||
176 | |||
1245 | hidnplayr | 177 | mov ax,word[.col3g] |
178 | sub ax,word[.col1g] |
||
179 | cwde |
||
180 | shl eax,ROUND |
||
181 | cdq |
||
182 | idiv ebx |
||
1776 | yogev_ezra | 183 | ; mov .dc13g,eax |
184 | push eax |
||
1245 | hidnplayr | 185 | mov ax,word[.col3b] |
186 | sub ax,word[.col1b] |
||
187 | cwde |
||
188 | shl eax,ROUND |
||
189 | cdq |
||
190 | idiv ebx |
||
1776 | yogev_ezra | 191 | ; mov .dc13b,eax |
192 | push eax |
||
1245 | hidnplayr | 193 | .gt_dx13_done: |
194 | mov bx,.y3 |
||
195 | sub bx,.y2 |
||
196 | jnz .gt_dx23_make |
||
1776 | yogev_ezra | 197 | xor edx,edx |
198 | mov ecx,4 |
||
199 | @@: |
||
200 | push edx |
||
201 | loop @b |
||
202 | ; mov .dx23,0 |
||
203 | ; mov .dc23r,0 |
||
204 | ; mov .dc23g,0 |
||
205 | ; mov .dc23b,0 |
||
1245 | hidnplayr | 206 | jmp .gt_dx23_done |
207 | .gt_dx23_make: |
||
208 | mov ax,.x3 |
||
209 | sub ax,.x2 |
||
210 | cwde |
||
211 | movsx ebx,bx |
||
212 | shl eax,ROUND |
||
213 | cdq |
||
214 | idiv ebx |
||
1776 | yogev_ezra | 215 | ; mov .dx23,eax |
216 | push eax |
||
1245 | hidnplayr | 217 | |
218 | mov ax,word[.col3r] |
||
219 | sub ax,word[.col2r] |
||
220 | cwde |
||
221 | shl eax,ROUND |
||
222 | cdq |
||
223 | idiv ebx |
||
1776 | yogev_ezra | 224 | ; mov .dc23r,eax |
225 | push eax |
||
226 | |||
227 | |||
1245 | hidnplayr | 228 | mov ax,word[.col3g] |
229 | sub ax,word[.col2g] |
||
230 | cwde |
||
231 | shl eax,ROUND |
||
232 | cdq |
||
233 | idiv ebx |
||
1776 | yogev_ezra | 234 | ; mov .dc23g,eax |
235 | push eax |
||
236 | |||
1245 | hidnplayr | 237 | mov ax,word[.col3b] |
238 | sub ax,word[.col2b] |
||
239 | cwde |
||
240 | shl eax,ROUND |
||
241 | cdq |
||
242 | idiv ebx |
||
1776 | yogev_ezra | 243 | ; mov .dc23b,eax |
244 | push eax |
||
245 | |||
1245 | hidnplayr | 246 | .gt_dx23_done: |
1776 | yogev_ezra | 247 | sub esp,24 |
1245 | hidnplayr | 248 | movsx eax,.x1 |
249 | shl eax,ROUND |
||
250 |