Subversion Repositories Kolibri OS

Rev

Rev 1245 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1245 Rev 1776
1
gouraud_triangle:
1
gouraud_triangle:
2
;------------------in - eax - x1 shl 16 + y1 ---------
2
;------------------in - eax - x1 shl 16 + y1 ---------
3
;---------------------- ebx - x2 shl 16 + y2 ---------
3
;---------------------- ebx - x2 shl 16 + y2 ---------
4
;---------------------- ecx - x3 shl 16 + y3 ---------
4
;---------------------- ecx - x3 shl 16 + y3 ---------
5
;---------------------- edi - pointer to screen buffer
5
;---------------------- edi - pointer to screen buffer
6
;---------------------- stack : colors----------------
6
;---------------------- stack : colors----------------
7
;----------------- procedure don't save registers !!--
7
;----------------- procedure don't save registers !!--
8
.col1r equ ebp+4	     ; each color as word
8
.col1r equ ebp+4	     ; each color as word
9
.col1g equ ebp+6
9
.col1g equ ebp+6
10
.col1b equ ebp+8
10
.col1b equ ebp+8
11
.col2r equ ebp+10
11
.col2r equ ebp+10
12
.col2g equ ebp+12
12
.col2g equ ebp+12
13
.col2b equ ebp+14
13
.col2b equ ebp+14
14
.col3r equ ebp+16
14
.col3r equ ebp+16
15
.col3g equ ebp+18
15
.col3g equ ebp+18
16
.col3b equ ebp+20
16
.col3b equ ebp+20
17
 
17
 
18
.x1    equ word[ebp-2]
18
.x1    equ word[ebp-2]
19
.y1    equ word[ebp-4]
19
.y1    equ word[ebp-4]
20
.x2    equ word[ebp-6]
20
.x2    equ word[ebp-6]
21
.y2    equ word[ebp-8]
21
.y2    equ word[ebp-8]
22
.x3    equ word[ebp-10]
22
.x3    equ word[ebp-10]
23
.y3    equ word[ebp-12]
23
.y3    equ word[ebp-12]
24
 
24
 
25
.dc12r equ dword[ebp-16]
25
.dx12  equ dword[ebp-16]
26
.dc12g equ dword[ebp-20]
26
.dc12r equ dword[ebp-20]
27
.dc12b equ dword[ebp-24]
27
.dc12g equ [ebp-24]
28
.dc13r equ dword[ebp-28]
28
.dc12b equ dword[ebp-28]
29
.dc13g equ dword[ebp-32]
29
.dx13  equ dword[ebp-32]
30
.dc13b equ dword[ebp-36]
30
.dc13r equ dword[ebp-36]
31
.dc23r equ dword[ebp-40]
31
.dc13g equ [ebp-40]
32
.dc23g equ dword[ebp-44]
32
.dc13b equ dword[ebp-44]
33
.dc23b equ dword[ebp-48]
-
 
34
 
33
.dx23  equ dword[ebp-48]
35
.c1r   equ dword[ebp-52]
34
.dc23r equ dword[ebp-52]
36
.c1g   equ dword[ebp-56]
35
.dc23g equ [ebp-56]
-
 
36
.dc23b equ dword[ebp-60]
37
.c1b   equ dword[ebp-60]
37
 
38
.c2r   equ dword[ebp-64]
38
.c1r   equ dword[ebp-64]
39
.c2g   equ dword[ebp-68]
39
.c1g   equ [ebp-68]
40
.c2b   equ dword[ebp-72]
-
 
41
 
40
.c1b   equ dword[ebp-72]
42
.dx12  equ dword[ebp-76]
41
.c2r   equ dword[ebp-76]
43
.dx13  equ dword[ebp-80]
42
.c2g   equ [ebp-80]
44
.dx23  equ dword[ebp-84]
-
 
45
 
43
.c2b   equ dword[ebp-84]
46
 
44
 
47
 
45
 
48
       mov ebp,esp
46
       mov ebp,esp
49
;       sub esp,72
47
;       sub esp,72
50
 
48
 
51
 .sort3:		  ; sort triangle coordinates...
49
 .sort3:		  ; sort triangle coordinates...
52
       cmp ax,bx
50
       cmp ax,bx
53
       jle .sort1
51
       jle .sort1
54
       xchg eax,ebx
52
       xchg eax,ebx
55
       mov edx,dword[.col1r]
53
       mov edx,dword[.col1r]
56
       xchg edx,dword[.col2r]
54
       xchg edx,dword[.col2r]
57
       mov dword[.col1r],edx
55
       mov dword[.col1r],edx
58
       mov dx,word[.col1b]
56
       mov dx,word[.col1b]
59
       xchg dx,word[.col2b]
57
       xchg dx,word[.col2b]
60
       mov word[.col1b],dx
58
       mov word[.col1b],dx
61
 .sort1:
59
 .sort1:
62
       cmp bx,cx
60
       cmp bx,cx
63
       jle .sort2
61
       jle .sort2
64
       xchg ebx,ecx
62
       xchg ebx,ecx
65
       mov edx,dword[.col2r]
63
       mov edx,dword[.col2r]
66
       xchg edx,dword[.col3r]
64
       xchg edx,dword[.col3r]
67
       mov dword[.col2r],edx
65
       mov dword[.col2r],edx
68
       mov dx,word[.col2b]
66
       mov dx,word[.col2b]
69
       xchg dx,word[.col3b]
67
       xchg dx,word[.col3b]
70
       mov word[.col2b],dx
68
       mov word[.col2b],dx
71
       jmp .sort3
69
       jmp .sort3
72
 .sort2:
70
 .sort2:
73
       push eax   ;store triangle coordinates in user friendly variables
71
       push eax   ;store triangle coordinates in user friendly variables
74
       push ebx
72
       push ebx
75
       push ecx
73
       push ecx
76
       sub esp,72 ; set correctly value of esp
74
    ;   sub esp,72 ; set correctly value of esp
77
 
75
 
78
       mov edx,eax    ; check only X triangle coordinate
76
       mov edx,eax    ; check only X triangle coordinate
79
       or edx,ebx
77
       or edx,ebx
80
       or edx,ecx
78
       or edx,ecx
81
       test edx,80000000h
79
       test edx,80000000h
82
       jne .gt_loop2_end
80
       jne .gt_loop2_end
83
       shr eax,16
81
       shr eax,16
84
       cmp ax,SIZE_X-1
82
       cmp ax,SIZE_X-1
85
       jg .gt_loop2_end
83
       jg .gt_loop2_end
86
       shr ebx,16
84
       shr ebx,16
87
       cmp bx,SIZE_X-1
85
       cmp bx,SIZE_X-1
88
       jg .gt_loop2_end
86
       jg .gt_loop2_end
89
       shr ecx,16
87
       shr ecx,16
90
       cmp cx,SIZE_X-1
88
       cmp cx,SIZE_X-1
91
       jg .gt_loop2_end
89
       jg .gt_loop2_end
92
 
90
 
93
 
91
 
94
       mov bx,.y2	; calc deltas
92
       mov bx,.y2	; calc deltas
95
       sub bx,.y1
93
       sub bx,.y1
96
       jnz .gt_dx12_make
94
       jnz .gt_dx12_make
-
 
95
       xor edx,edx
-
 
96
       mov ecx,4
-
 
97
     @@:
-
 
98
       push edx
-
 
99
       loop @b
97
       mov .dx12,0
100
     ;  mov .dx12,0
98
       mov .dc12r,0
101
     ;  mov .dc12r,0
99
       mov .dc12g,0
102
     ;  mov .dc12g,0
100
       mov .dc12b,0
103
     ;  mov .dc12b,0
101
       jmp .gt_dx12_done
104
       jmp .gt_dx12_done
102
  .gt_dx12_make:
105
  .gt_dx12_make:
103
 
106
 
104
       mov ax,.x2
107
       mov ax,.x2
105
       sub ax,.x1
108
       sub ax,.x1
106
       cwde
109
       cwde
107
       movsx ebx,bx
110
       movsx ebx,bx
108
       shl eax,ROUND
111
       shl eax,ROUND
109
       cdq
112
       cdq
110
       idiv ebx
113
       idiv ebx
111
       mov .dx12,eax
114
     ;  mov .dx12,eax
-
 
115
       push eax
112
 
116
 
113
       mov ax,word[.col2r]
117
       mov ax,word[.col2r]
114
       sub ax,word[.col1r]
118
       sub ax,word[.col1r]
115
       cwde
119
       cwde
116
       shl eax,ROUND
120
       shl eax,ROUND
117
       cdq
121
       cdq
118
       idiv ebx
122
       idiv ebx
119
       mov .dc12r,eax
123
      ; mov .dc12r,eax
-
 
124
       push eax
-
 
125
 
120
       mov ax,word[.col2g]
126
       mov ax,word[.col2g]
121
       sub ax,word[.col1g]
127
       sub ax,word[.col1g]
122
       cwde
128
       cwde
123
       shl eax,ROUND
129
       shl eax,ROUND
124
       cdq
130
       cdq
125
       idiv ebx
131
       idiv ebx
126
       mov .dc12g,eax
132
     ;  mov .dc12g,eax
-
 
133
       push eax
-
 
134
 
127
       mov ax,word[.col2b]
135
       mov ax,word[.col2b]
128
       sub ax,word[.col1b]
136
       sub ax,word[.col1b]
129
       cwde
137
       cwde
130
       shl eax,ROUND
138
       shl eax,ROUND
131
       cdq
139
       cdq
132
       idiv ebx
140
       idiv ebx
133
       mov .dc12b,eax
141
     ;  mov .dc12b,eax
-
 
142
       push eax
134
.gt_dx12_done:
143
.gt_dx12_done:
135
 
-
 
136
       mov bx,.y3
144
       mov bx,.y3
137
       sub bx,.y1
145
       sub bx,.y1
138
       jnz .gt_dx13_make
146
       jnz .gt_dx13_make
-
 
147
       xor edx,edx
-
 
148
       mov ecx,4
-
 
149
     @@:
-
 
150
       push edx
-
 
151
       loop @b
139
       mov .dx13,0
152
   ;    mov .dx13,0
140
       mov .dc13r,0
153
   ;    mov .dc13r,0
141
       mov .dc13g,0
154
   ;    mov .dc13g,0
142
       mov .dc13b,0
155
   ;    mov .dc13b,0
143
       jmp .gt_dx13_done
156
       jmp .gt_dx13_done
144
.gt_dx13_make:
157
.gt_dx13_make:
145
       mov ax,.x3
158
       mov ax,.x3
146
       sub ax,.x1
159
       sub ax,.x1
147
       cwde
160
       cwde
148
       movsx ebx,bx
161
       movsx ebx,bx
149
       shl eax,ROUND
162
       shl eax,ROUND
150
       cdq
163
       cdq
151
       idiv ebx
164
       idiv ebx
152
       mov .dx13,eax
165
   ;    mov .dx13,eax
-
 
166
       push eax
153
 
167
 
154
       mov ax,word[.col3r]
168
       mov ax,word[.col3r]
155
       sub ax,word[.col1r]
169
       sub ax,word[.col1r]
156
       cwde
170
       cwde
157
       shl eax,ROUND
171
       shl eax,ROUND
158
       cdq
172
       cdq
159
       idiv ebx
173
       idiv ebx
160
       mov .dc13r,eax
174
    ;   mov .dc13r,eax
-
 
175
       push eax
-
 
176
 
161
       mov ax,word[.col3g]
177
       mov ax,word[.col3g]
162
       sub ax,word[.col1g]
178
       sub ax,word[.col1g]
163
       cwde
179
       cwde
164
       shl eax,ROUND
180
       shl eax,ROUND
165
       cdq
181
       cdq
166
       idiv ebx
182
       idiv ebx
167
       mov .dc13g,eax
183
     ;  mov .dc13g,eax
-
 
184
       push eax
168
       mov ax,word[.col3b]
185
       mov ax,word[.col3b]
169
       sub ax,word[.col1b]
186
       sub ax,word[.col1b]
170
       cwde
187
       cwde
171
       shl eax,ROUND
188
       shl eax,ROUND
172
       cdq
189
       cdq
173
       idiv ebx
190
       idiv ebx
174
       mov .dc13b,eax
191
    ;   mov .dc13b,eax
-
 
192
       push eax
175
.gt_dx13_done:
193
.gt_dx13_done:
176
 
-
 
177
       mov bx,.y3
194
       mov bx,.y3
178
       sub bx,.y2
195
       sub bx,.y2
179
       jnz .gt_dx23_make
196
       jnz .gt_dx23_make
-
 
197
       xor edx,edx
-
 
198
       mov ecx,4
-
 
199
     @@:
-
 
200
       push edx
-
 
201
       loop @b
180
       mov .dx23,0
202
   ;    mov .dx23,0
181
       mov .dc23r,0
203
   ;    mov .dc23r,0
182
       mov .dc23g,0
204
   ;    mov .dc23g,0
183
       mov .dc23b,0
205
   ;    mov .dc23b,0
184
       jmp .gt_dx23_done
206
       jmp .gt_dx23_done
185
.gt_dx23_make:
207
.gt_dx23_make:
186
       mov ax,.x3
208
       mov ax,.x3
187
       sub ax,.x2
209
       sub ax,.x2
188
       cwde
210
       cwde
189
       movsx ebx,bx
211
       movsx ebx,bx
190
       shl eax,ROUND
212
       shl eax,ROUND
191
       cdq
213
       cdq
192
       idiv ebx
214
       idiv ebx
193
       mov .dx23,eax
215
     ; mov .dx23,eax
-
 
216
       push eax
194
 
217
 
195
       mov ax,word[.col3r]
218
       mov ax,word[.col3r]
196
       sub ax,word[.col2r]
219
       sub ax,word[.col2r]
197
       cwde
220
       cwde
198
       shl eax,ROUND
221
       shl eax,ROUND
199
       cdq
222
       cdq
200
       idiv ebx
223
       idiv ebx
201
       mov .dc23r,eax
224
      ; mov .dc23r,eax
-
 
225
       push eax
-
 
226
 
-
 
227
 
202
       mov ax,word[.col3g]
228
       mov ax,word[.col3g]
203
       sub ax,word[.col2g]
229
       sub ax,word[.col2g]
204
       cwde
230
       cwde
205
       shl eax,ROUND
231
       shl eax,ROUND
206
       cdq
232
       cdq
207
       idiv ebx
233
       idiv ebx
208
       mov .dc23g,eax
234
     ;  mov .dc23g,eax
-
 
235
       push eax
-
 
236
 
209
       mov ax,word[.col3b]
237
       mov ax,word[.col3b]
210
       sub ax,word[.col2b]
238
       sub ax,word[.col2b]
211
       cwde
239
       cwde
212
       shl eax,ROUND
240
       shl eax,ROUND
213
       cdq
241
       cdq
214
       idiv ebx
242
       idiv ebx
215
       mov .dc23b,eax
243
    ;   mov .dc23b,eax
216
.gt_dx23_done:
244
       push eax
-
 
245
 
-
 
246
.gt_dx23_done:
217
 
247
       sub esp,24
218
       movsx eax,.x1
248
       movsx eax,.x1
219
       shl eax,ROUND
249
       shl eax,ROUND
220
       mov ebx,eax
250
       mov ebx,eax
221
       movsx edx,word[.col1r]
251
       movsx edx,word[.col1r]
222
       shl edx,ROUND
252
       shl edx,ROUND
223
       mov .c1r,edx
253
       mov .c1r,edx
224
       mov .c2r,edx
254
       mov .c2r,edx
225
       movsx edx,word[.col1g]
255
       movsx edx,word[.col1g]
226
       shl edx,ROUND
256
       shl edx,ROUND
227
       mov .c1g,edx
257
       mov .c1g,edx
228
       mov .c2g,edx
258
       mov .c2g,edx
229
       movsx edx,word[.col1b]
259
       movsx edx,word[.col1b]
230
       shl edx,ROUND
260
       shl edx,ROUND
231
       mov .c1b,edx
261
       mov .c1b,edx
232
       mov .c2b,edx
262
       mov .c2b,edx
233
       mov cx,.y1
263
       mov cx,.y1
234
       cmp cx,.y2
264
       cmp cx,.y2
235
       jge .gt_loop1_end
265
       jge .gt_loop1_end
236
.gt_loop1:
266
.gt_loop1:
237
       push eax 		      ; eax - cur x1
267
       push eax 		      ; eax - cur x1
238
       push ebx 		      ; ebx - cur x2
268
       push ebx 		      ; ebx - cur x2
239
       push cx			      ; cx  - cur y
269
       push cx			      ; cx  - cur y
240
       push edi
270
       push edi
241
       push ebp
271
       push ebp
-
 
272
 
-
 
273
       sar ebx,ROUND
242
 
274
       push bx
243
       mov edx,.c2r		 ; c2r,c2g,c2b,c1r,c1g,c1b - current colors
275
       mov edx,.c2r		 ; c2r,c2g,c2b,c1r,c1g,c1b - current colors
244
       sar edx,ROUND
276
       sar edx,ROUND
245
       push dx
277
       push dx
246
       mov edx,.c2g
278
       mov edx,.c2g
247
       sar edx,ROUND
279
       sar edx,ROUND
248
       push dx
280
       push dx
249
       mov edx,.c2b
281
       mov edx,.c2b
250
       sar edx,ROUND
282
       sar edx,ROUND
251
       push dx
283
       push dx
-
 
284
 
-
 
285
       sar eax,ROUND
-
 
286
       push ax
252
       mov edx,.c1r
287
       mov edx,.c1r
253
       sar edx,ROUND
288
       sar edx,ROUND
254
       push dx
289
       push dx
255
       mov edx,.c1g
290
       mov edx,.c1g
256
       sar edx,ROUND
291
       sar edx,ROUND
257
       push dx
292
       push dx
258
       mov edx,.c1b
293
       mov edx,.c1b
259
       sar edx,ROUND
294
       sar edx,ROUND
260
       push dx
295
       push dx
261
       push cx
296
       push cx
262
       sar ebx,ROUND
-
 
263
       push bx
-
 
264
       sar eax,ROUND
-
 
265
       push ax
-
 
266
       call gouraud_line
297
       call gouraud_line
267
 
298
 
268
       pop ebp
299
       pop ebp
269
       pop edi
300
       pop edi
270
       pop cx
301
       pop cx
271
       pop ebx
302
       pop ebx
272
       pop eax
303
       pop eax
-
 
304
 
-
 
305
if Ext >= MMX
-
 
306
       movq mm0,.c1g
-
 
307
       paddd mm0,.dc13g
-
 
308
       movq .c1g,mm0
273
 
309
else
274
       mov edx,.dc13r
310
       mov edx,.dc13r
275
       add .c1r,edx
311
       add .c1r,edx
276
       mov edx,.dc13g
312
       mov edx,.dc13g
277
       add .c1g,edx
313
       add .c1g,edx
-
 
314
end if
278
       mov edx,.dc13b
315
       mov edx,.dc13b
279
       add .c1b,edx
316
       add .c1b,edx
-
 
317
if Ext >= MMX
-
 
318
       movq mm0,.c2g
-
 
319
       paddd mm0,.dc12g
-
 
320
       movq .c2g,mm0
-
 
321
else
280
       mov edx,.dc12r
322
       mov edx,.dc12r
281
       add .c2r,edx
323
       add .c2r,edx
282
       mov edx,.dc12g
324
       mov edx,.dc12g
283
       add .c2g,edx
325
       add .c2g,edx
-
 
326
end if
284
       mov edx,.dc12b
327
       mov edx,.dc12b
285
       add .c2b,edx
328
       add .c2b,edx
286
 
329
 
287
       add eax,.dx13
330
       add eax,.dx13
288
       add ebx,.dx12
331
       add ebx,.dx12
289
       inc cx
332
       inc cx
290
       cmp cx,.y2
333
       cmp cx,.y2
291
       jl .gt_loop1
334
       jl .gt_loop1
292
.gt_loop1_end:
335
.gt_loop1_end:
293
 
336
 
294
       mov cx,.y2
337
       mov cx,.y2
295
       cmp cx,.y3
338
       cmp cx,.y3
296
       jge .gt_loop2_end
339
       jge .gt_loop2_end
297
       movsx ebx,.x2
340
       movsx ebx,.x2
298
       shl ebx,ROUND
341
       shl ebx,ROUND
299
 
342
 
300
       movsx edx,word[.col2r]
343
       movsx edx,word[.col2r]
301
       shl edx,ROUND
344
       shl edx,ROUND
302
       mov .c2r,edx
345
       mov .c2r,edx
303
       movsx edx,word[.col2g]
346
       movsx edx,word[.col2g]
304
       shl edx,ROUND
347
       shl edx,ROUND
305
       mov .c2g,edx
348
       mov .c2g,edx
306
       movsx edx,word[.col2b]
349
       movsx edx,word[.col2b]
307
       shl edx,ROUND
350
       shl edx,ROUND
308
       mov .c2b,edx
351
       mov .c2b,edx
309
.gt_loop2:
352
.gt_loop2:
310
       push eax 		      ; eax - cur x1
353
       push eax 		      ; eax - cur x1
311
       push ebx 		      ; ebx - cur x2
354
       push ebx 		      ; ebx - cur x2
312
       push cx
355
       push cx
313
       push edi
356
       push edi
314
       push ebp
357
       push ebp
-
 
358
 
-
 
359
       sar ebx,ROUND
315
 
360
       push bx
316
       mov edx,.c2r
361
       mov edx,.c2r
317
       sar edx,ROUND
362
       sar edx,ROUND
318
       push dx
363
       push dx
319
       mov edx,.c2g
364
       mov edx,.c2g
320
       sar edx,ROUND
365
       sar edx,ROUND
321
       push dx
366
       push dx
322
       mov edx,.c2b
367
       mov edx,.c2b
323
       sar edx,ROUND
368
       sar edx,ROUND
324
       push dx
369
       push dx
-
 
370
 
-
 
371
       sar eax,ROUND
-
 
372
       push ax
325
       mov edx,.c1r
373
       mov edx,.c1r
326
       sar edx,ROUND
374
       sar edx,ROUND
327
       push dx
375
       push dx
328
       mov edx,.c1g
376
       mov edx,.c1g
329
       sar edx,ROUND
377
       sar edx,ROUND
330
       push dx
378
       push dx
331
       mov edx,.c1b
379
       mov edx,.c1b
332
       sar edx,ROUND
380
       sar edx,ROUND
333
       push dx
381
       push dx
334
       push cx
382
       push cx
335
       sar ebx,ROUND
-
 
336
       push bx
-
 
337
       sar eax,ROUND
-
 
338
       push ax
-
 
339
       call gouraud_line
383
       call gouraud_line
340
 
384
 
341
       pop ebp
385
       pop ebp
342
       pop edi
386
       pop edi
343
       pop cx
387
       pop cx
344
       pop ebx
388
       pop ebx
345
       pop eax
389
       pop eax
-
 
390
 
-
 
391
if Ext >= MMX
-
 
392
       movq mm0,.c1g
-
 
393
       paddd mm0,.dc13g
-
 
394
       movq .c1g,mm0
346
 
395
else
347
       mov edx,.dc13r
396
       mov edx,.dc13r
348
       add .c1r,edx
397
       add .c1r,edx
349
       mov edx,.dc13g
398
       mov edx,.dc13g
350
       add .c1g,edx
399
       add .c1g,edx
-
 
400
end if
351
       mov edx,.dc13b
401
       mov edx,.dc13b
352
       add .c1b,edx
402
       add .c1b,edx
-
 
403
if Ext >= MMX
-
 
404
       movq mm0,.c2g
-
 
405
       paddd mm0,.dc23g
-
 
406
       movq .c2g,mm0
-
 
407
else
353
       mov edx,.dc23r
408
       mov edx,.dc23r
354
       add .c2r,edx
409
       add .c2r,edx
355
       mov edx,.dc23g
410
       mov edx,.dc23g
356
       add .c2g,edx
411
       add .c2g,edx
-
 
412
end if
357
       mov edx,.dc23b
413
       mov edx,.dc23b
358
       add .c2b,edx
414
       add .c2b,edx
359
 
415
 
360
       add eax,.dx13
416
       add eax,.dx13
361
       add ebx,.dx23
417
       add ebx,.dx23
362
       inc cx
418
       inc cx
363
       cmp cx,.y3
419
       cmp cx,.y3
364
       jl .gt_loop2
420
       jl .gt_loop2
365
.gt_loop2_end:
421
.gt_loop2_end:
366
 
422
 
367
      ; add esp,84
423
      ; add esp,84
368
      mov esp,ebp
424
      mov esp,ebp
369
ret 18
425
ret 18
370
gouraud_line:
426
gouraud_line:
371
;-------------in - edi - pointer to screen buffer
427
;-------------in - edi - pointer to screen buffer
372
;----------------- stack - another parameters
428
;----------------- stack - another parameters
373
.x1 equ word [ebp+4]
429
.y equ word [ebp+4]
374
.x2 equ word [ebp+6]
430
.col1b equ ebp+6
375
.y equ word [ebp+8]
431
.col1g equ ebp+8
376
.col1b equ ebp+10
432
.col1r equ ebp+10
377
.col1g equ ebp+12
433
.x1    equ [ebp+12]
378
.col1r equ ebp+14
434
.col2b equ ebp+14
379
.col2b equ ebp+16
435
.col2g equ ebp+16
380
.col2g equ ebp+18
436
.col2r equ ebp+18
381
.col2r equ ebp+20
437
.x2    equ [ebp+20]
382
.dc_r equ dword[ebp-4]
438
.dc_r equ dword[ebp-4]
383
.dc_g equ dword[ebp-8]
439
.dc_g equ dword[ebp-8]
384
.dc_b equ dword[ebp-12]
440
.dc_b equ dword[ebp-12]
385
       mov ebp,esp
441
       mov ebp,esp
386
 
442
 
387
       mov ax,.y
443
       mov ax,.y
388
       or ax,ax
444
       or ax,ax
389
       jl .gl_quit
445
       jl .gl_quit
390
       cmp ax,SIZE_Y-1
446
       cmp ax,SIZE_Y-1
391
       jg .gl_quit
447
       jg .gl_quit
392
 
448
 
393
       mov ax,.x1
449
       mov ax,.x1
394
       cmp ax,.x2
450
       cmp ax,.x2
395
       je .gl_quit
451
       je .gl_quit
396
       jl .gl_ok
452
       jl .gl_ok
-
 
453
 
-
 
454
if Ext >= MMX
397
 
455
       movq mm0,[.col1b]
398
       xchg ax,.x2
456
       movq mm1,[.col2b]
-
 
457
       movq [.col1b],mm1
-
 
458
       movq [.col2b],mm0
399
       mov .x1,ax
459
else
400
       mov eax,dword[.col1b]
460
       mov eax,[.col1b]
401
       xchg eax,dword[.col2b]
461
       xchg eax,[.col2b]
402
       mov  dword[.col1b],eax
462
       mov  [.col1b],eax
403
       mov ax,word[.col1r]
463
       mov eax,[.col1r]
404
       xchg ax,word[.col2r]
464
       xchg eax,[.col2r]
-
 
465
       mov [.col1r],eax
405
       mov word[.col1r],ax
466
end if
406
.gl_ok:
467
.gl_ok:
407
  ;     cmp .x1,SIZE_X-1  ;check
468
  ;     cmp .x1,SIZE_X-1  ;check
408
  ;     jg .gl_quit
469
  ;     jg .gl_quit
409
  ;     cmp .x2,SIZE_X-1
470
  ;     cmp .x2,SIZE_X-1
410
  ;     jl @f
471
  ;     jl @f
411
  ;     mov .x2,SIZE_X-1
472
  ;     mov .x2,SIZE_X-1
412
  ;  @@:
473
  ;  @@:
413
  ;     cmp .x1,0
474
  ;     cmp .x1,0
414
  ;     jg @f
475
  ;     jg @f
415
  ;     mov .x1,0
476
  ;     mov .x1,0
416
  ;  @@:
477
  ;  @@:
417
  ;     cmp .x2,0
478
  ;     cmp .x2,0
418
  ;     jl .gl_quit
479
  ;     jl .gl_quit
419
 
480
 
420
       movsx ecx,.y
481
       movsx ecx,.y
421
       mov eax,SIZE_X*3
482
       mov eax,SIZE_X*3
422
       mul ecx
483
       mul ecx
423
       movsx ebx,.x1
484
       movsx ebx,word .x1
424
       lea ecx,[ebx*2+eax]
485
       lea ecx,[ebx*2+eax]
425
       add edi,ecx
486
       add edi,ecx
426
       add edi,ebx
487
       add edi,ebx
427
 
488
 
428
       mov ax,word[.col2r]
489
       mov ax,word[.col2r]
429
       sub ax,word[.col1r]
490
       sub ax,word[.col1r]
430
       cwde
491
       cwde
431
       shl eax,ROUND
492
       shl eax,ROUND
432
       cdq
493
       cdq
433
       mov cx,.x2
494
       mov cx,.x2
434
       sub cx,.x1
495
       sub cx,.x1
435
       movsx ecx,cx
496
       movsx ecx,cx
436
       idiv ecx
497
       idiv ecx
437
       ;mov .dc_r,eax           ;first delta
498
       ;mov .dc_r,eax           ;first delta
438
       push eax
499
       push eax
439
 
500
 
440
       mov ax,word[.col2g]
501
       mov ax,word[.col2g]
441
       sub ax,word[.col1g]
502
       sub ax,word[.col1g]
442
       cwde
503
       cwde
443
       shl eax,ROUND
504
       shl eax,ROUND
444
       cdq
505
       cdq
445
       idiv ecx
506
       idiv ecx
446
       ;mov .dc_g,eax
507
       ;mov .dc_g,eax
447
       push eax
508
       push eax
448
 
509
 
449
       mov ax,word[.col2b]
510
       mov ax,word[.col2b]
450
       sub ax,word[.col1b]
511
       sub ax,word[.col1b]
451
       cwde
512
       cwde
452
       shl eax,ROUND
513
       shl eax,ROUND
453
       cdq
514
       cdq
454
       idiv ecx
515
       idiv ecx
455
      ; mov .dc_b,eax
516
      ; mov .dc_b,eax
456
       push eax
517
       push eax
457
 
518
 
458
       movsx ebx,word[.col1r]
519
       movsx ebx,word[.col1r]
459
       shl ebx,ROUND
520
       shl ebx,ROUND
460
       movsx edx,word[.col1g]
521
       movsx edx,word[.col1g]
461
       shl edx,ROUND
522
       shl edx,ROUND
462
       movsx esi,word[.col1b]
523
       movsx esi,word[.col1b]
463
       shl esi,ROUND
524
       shl esi,ROUND
464
.gl_draw:
525
.gl_draw:
465
       mov eax,ebx
526
       mov eax,ebx
466
       sar eax,ROUND
527
       sar eax,ROUND
467
       stosb
528
       stosb
468
       mov eax,edx
529
       mov eax,edx
469
       sar eax,ROUND
530
       sar eax,ROUND
470
       stosb
531
       stosb
471
       mov eax,esi
532
       mov eax,esi
472
       sar eax,ROUND
533
       sar eax,ROUND
473
       stosb
534
       stosb
474
       add ebx,.dc_r
535
       add ebx,.dc_r
475
       add edx,.dc_g
536
       add edx,.dc_g
476
       add esi,.dc_b
537
       add esi,.dc_b
477
       loop .gl_draw
538
       loop .gl_draw
478
.gl_quit:
539
.gl_quit:
479
      ; add esp,12
540
      ; add esp,12
480
       mov esp,ebp
541
       mov esp,ebp
481
ret 18
542
ret 18
482
543
if 0
-
 
544
gouraud_line_SSE:	 ; new
-
 
545
;-------------in - edi - pointer to screen buffer
-
 
546
;----------------- stack - another parameters
-
 
547
.y equ word [ebp+4]
-
 
548
.col1b equ ebp+6
-
 
549
.col1g equ ebp+8
-
 
550
.col1r equ ebp+10
-
 
551
.x1    equ [ebp+12]
-
 
552
.col2b equ ebp+14
-
 
553
.col2g equ ebp+16
-
 
554
.col2r equ ebp+18
-
 
555
.x2    equ [ebp+20]
-
 
556
.dc_r equ dword[ebp-4]
-
 
557
.dc_g equ dword[ebp-8]
-
 
558
.dc_b equ dword[ebp-12]
-
 
559
.lenght equ [ebp-16]
-
 
560
.factor equ [ebp-24]   ;new
-
 
561
       mov ebp,esp
-
 
562
 
-
 
563
       mov ax,.y
-
 
564
       or ax,ax
-
 
565
       jl .gl_quit
-
 
566
       cmp ax,SIZE_Y-1
-
 
567
       jg .gl_quit
-
 
568
 
-
 
569
       mov ax,.x1
-
 
570
       cmp ax,.x2
-
 
571
       je .gl_quit
-
 
572
       jl .gl_ok
-
 
573
 
-
 
574
if Ext >= MMX
-
 
575
       movq mm0,[.col1b]
-
 
576
       movq mm1,[.col2b]
-
 
577
       movq [.col1b],mm1
-
 
578
       movq [.col2b],mm0
-
 
579
else
-
 
580
       mov eax,[.col1b]
-
 
581
       xchg eax,[.col2b]
-
 
582
       mov  [.col1b],eax
-
 
583
       mov eax,[.col1r]
-
 
584
       xchg eax,[.col2r]
-
 
585
       mov [.col1r],eax
-
 
586
end if
-
 
587
.gl_ok:
-
 
588
  ;     cmp .x1,SIZE_X-1  ;check
-
 
589
  ;     jg .gl_quit
-
 
590
  ;     cmp .x2,SIZE_X-1
-
 
591
  ;     jl @f
-
 
592
  ;     mov .x2,SIZE_X-1
-
 
593
  ;  @@:
-
 
594
  ;     cmp .x1,0
-
 
595
  ;     jg @f
-
 
596
  ;     mov .x1,0
-
 
597
  ;  @@:
-
 
598
  ;     cmp .x2,0
-
 
599
  ;     jl .gl_quit
-
 
600
 
-
 
601
       movsx ecx,.y
-
 
602
       mov eax,SIZE_X*3
-
 
603
       mul ecx
-
 
604
       movsx ebx,word .x1
-
 
605
       lea ecx,[ebx*2+eax]
-
 
606
       add edi,ecx
-
 
607
       add edi,ebx
-
 
608
 
-
 
609
       mov ax,word[.col2r]
-
 
610
       sub ax,word[.col1r]
-
 
611
       cwde
-
 
612
       shl eax,ROUND
-
 
613
       cdq
-
 
614
       mov cx,.x2
-
 
615
       sub cx,.x1
-
 
616
       movsx ecx,cx
-
 
617
       idiv ecx
-
 
618
       ;mov .dc_r,eax           ;first delta
-
 
619
       push eax
-
 
620
 
-
 
621
       mov ax,word[.col2g]
-
 
622
       sub ax,word[.col1g]
-
 
623
       cwde
-
 
624
       shl eax,ROUND
-
 
625
       cdq
-
 
626
       idiv ecx
-
 
627
       ;mov .dc_g,eax
-
 
628
       push eax
-
 
629
 
-
 
630
       mov ax,word[.col2b]
-
 
631
       sub ax,word[.col1b]
-
 
632
       cwde
-
 
633
       shl eax,ROUND
-
 
634
       cdq
-
 
635
       idiv ecx
-
 
636
      ; mov .dc_b,eax
-
 
637
       push eax
-
 
638
 
-
 
639
       movsx ebx,word[.col1r]
-
 
640
       shl ebx,ROUND
-
 
641
       movsx edx,word[.col1g]
-
 
642
       shl edx,ROUND
-
 
643
       movsx esi,word[.col1b]
-
 
644
       shl esi,ROUND
-
 
645
 
-
 
646
       push	 ecx	     ; store line lenght
-
 
647
       movd	 mm3,.dc_r
-
 
648
       psrlq	 mm3,16      ; load dr to lowest word of mm3
-
 
649
       pxor	 mm2,mm2     ; clear mm2
-
 
650
       movd	 mm4,.dc_g
-
 
651
       punpcklwd mm3,mm3     ; unpack dr to lower 2 words in in mm3
-
 
652
       psrlq	 mm4,16      ; load dg to lowest word of mm4
-
 
653
       movd	 mm5,.dc_b
-
 
654
       psrlq	 mm5,16      ; load db to lowest word of mm5
-
 
655
       punpcklwd mm4,mm4     ; unpack dg to lower 2 words in in mm3
-
 
656
       lea	 ecx,[factor]
-
 
657
       punpckldq mm3,mm3
-
 
658
       punpcklwd mm5,mm5     ; unpack db to lower 2 words in in mm5
-
 
659
       movq	 mm6,[.col1b]
-
 
660
       xor	 eax,eax
-
 
661
       pinsrw	 mm6,eax,3     ; clear the highest word in mm6
-
 
662
       mov	 eax,010000h
-
 
663
       punpckldq mm4,mm4     ; unpack dg to 4 words in mm4
-
 
664
       mov	 [ecx],eax
-
 
665
       mov	 eax,030002h
-
 
666
       punpckldq mm5,mm5    ; unpack db to 4 words in mm5
-
 
667
       movq	 mm7,mm6    ; load r1r1,g1g1,b1b1 to the first three
-
 
668
			    ; words of mm7
-
 
669
       pxor	 mm1,mm1    ; clear mm1
-
 
670
 
-
 
671
 
-
 
672
.gl_draw:
-
 
673
       mov eax,ebx
-
 
674
       sar eax,ROUND
-
 
675
       stosb
-
 
676
       mov eax,edx
-
 
677
       sar eax,ROUND
-
 
678
       stosb
-
 
679
       mov eax,esi
-
 
680
       sar eax,ROUND
-
 
681
       stosb
-
 
682
       add ebx,.dc_r
-
 
683
       add edx,.dc_g
-
 
684
       add esi,.dc_b
-
 
685
       loop .gl_draw
-
 
686
.gl_quit:
-
 
687
      ; add esp,12
-
 
688
       mov esp,ebp
-
 
689
ret 18
-
 
690
end if
-
 
691