Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
9237 leency 1
 
2
 
3
;NON=0
4
;MMX=1
5
;SSE=2
6
;SSE2=3
9512 IgorA 7
8
;Ext=SSE2
9
 
10
11
 
12
 
9237 leency 13
;SIZE_Y equ 512
14
;ROUND = 8
15
 ; TEX_SHIFT equ 6
16
 ; TEXTURE_SIZE = 0xFFFFF
9512 IgorA 17
18
; procedure drawing textured triangle with Gouraud shading
9237 leency 19
 
20
; I set the color by this way -- (col1 * col2)/256 ------
21
;------------------in - eax - x1 shl 16 + y1 ------------
22
;---------------------- ebx - x2 shl 16 + y2 ------------
23
;---------------------- ecx - x3 shl 16 + y3 ------------
24
;---------------------- esi - pointer to Z-buffer--------
25
;---------------------- edx - pointer to texture---------
26
;---------------------- Z-buffer filled with dd variables
27
;---------------------- shifted CATMULL_SHIFT------------
28
;---------------------- edi - pointer to screen buffer---
29
;---------------------- stack : colors-------------------
30
31
32
 
33
 
34
 
35
   .tex_y3  equ [ebp+38]   ; 36 bytes through stack
36
   .tex_x3  equ [ebp+36]
37
   .tex_y2  equ [ebp+34]
38
   .tex_x2  equ [ebp+32]
39
   .tex_y1  equ [ebp+30]
40
   .tex_x1  equ [ebp+28]
41
42
   .z3      equ [ebp+26]
43
 
9512 IgorA 44
   .col3g   equ [ebp+22]
9237 leency 45
   .col3r   equ [ebp+20]
46
47
   .z2      equ [ebp+18]
48
 
9512 IgorA 49
   .col2g   equ [ebp+14]
9237 leency 50
   .col2r   equ [ebp+12]
51
52
   .z1      equ [ebp+10]
53
 
9512 IgorA 54
   .col1g   equ [ebp+6]
9237 leency 55
   .col1r   equ [ebp+4]
56
57
; local variables:
58
 
59
   .tex_ptr   equ dword[ebp-4]
60
 
61
   .scr_buff  equ dword[ebp-12]
62
63
   .x1        equ  word[ebp-14] ;dw ? ;equ word[ebp-10]
64
 
9512 IgorA 65
   .x2        equ  word[ebp-18] ;dw ? ;equ word[ebp-14]
66
   .y2        equ  word[ebp-20] ;dw ? ;equ word[ebp-16]
67
   .x3        equ  word[ebp-22] ;dw ? ;equ word[ebp-18]
68
   .y3        equ  word[ebp-24] ;dw ? ;equ word[ebp-20]
69
70
   .dx12      equ  dword[ebp-28] ;dd ?
9237 leency 71
 
72
   .tex_dx12  equ       [ebp-36] ;dd ?
9512 IgorA 73
   .dz12      equ  dword[ebp-40] ;dd ?
74
   .dc12r     equ       [ebp-44] ;dd ?
9237 leency 75
   .dc12g     equ  dword[ebp-48] ;dd ?
9512 IgorA 76
   .dc12b     equ       [ebp-52] ;dd ?
9237 leency 77
9512 IgorA 78
   .dx23      equ  dword[ebp-56] ;dd ?
9237 leency 79
 
80
   .tex_dx23  equ       [ebp-64] ;dd ?
9512 IgorA 81
   .dz23      equ  dword[ebp-68] ;dd ?
82
   .dc23r     equ       [ebp-72] ;dd ?
9237 leency 83
   .dc23g     equ  dword[ebp-76] ;dd ?
9512 IgorA 84
   .dc23b     equ       [ebp-80] ;dword[ebp-8]dd ?
9237 leency 85
9512 IgorA 86
   .dx13      equ  dword[ebp-84] ;dd ?
9237 leency 87
 
88
   .tex_dx13  equ       [ebp-92] ;dd ?
9512 IgorA 89
   .dz13      equ  dword[ebp-96] ;dd ?
90
   .dc13r     equ       [ebp-100] ;dd ?
9237 leency 91
   .dc13g     equ  dword[ebp-104] ;dd ?
9512 IgorA 92
   .dc13b     equ       [ebp-108] ;dd ?
9237 leency 93
9512 IgorA 94
   .scan_y1   equ       [ebp-112] ;dd ?
9237 leency 95
 
9512 IgorA 96
   .zz1       equ  dword[ebp-120] ;dw ?
97
   .cur1r     equ       [ebp-124] ;dw ?
9237 leency 98
   .cur1g     equ       [ebp-128] ;dw ?
9512 IgorA 99
   .cur1b     equ       [ebp-132] ;dw ?
100
101
   .scan_y2   equ       [ebp-136] ;dd ?
9237 leency 102
 
9512 IgorA 103
   .zz2       equ       [ebp-144] ;dw ?
104
   .cur2r     equ       [ebp-148] ;dw ?
105
   .cur2g     equ       [ebp-152] ;dw ?
106
   .cur2b     equ       [ebp-156] ;dw ?
107
108
9237 leency 109
 
110
 
111
         push    edx esi edi
112
 
9512 IgorA 113
         mov      edx,80008000h  ; eax,ebx,ecx are ANDd together into edx which means that
9237 leency 114
 
9512 IgorA 115
         and      edx,ecx
116
         and      edx,eax
117
         test     edx,80008000h  ; Check both X&Y at once
118
         jne      .loop2_end
119
120
   .sort3:
121
 
9237 leency 122
       jle     .sort1
123
       xchg    eax,ebx
124
if Ext>=MMX
125
       movq    mm0, .col1r       ; exchange r, g, b, z
126
       movq    mm1, .col2r
9512 IgorA 127
       movq    .col1r ,mm1
9237 leency 128
       movq    .col2r ,mm0
129
else
130
       mov     edx,dword .col1r   ; exchange both r and g
131
       xchg    edx,dword .col2r
132
       mov     dword .col1r ,edx
133
134
       mov     edx,dword .col1b   ; b and z
135
 
136
       mov     dword .col1b ,edx
137
end if
138
139
       mov     edx,dword .tex_x1
140
 
141
       mov     dword .tex_x1 ,edx
142
143
 .sort1:
144
 
145
       jle      .sort2
9512 IgorA 146
       xchg    ebx,ecx
147
9237 leency 148
if Ext>=MMX
149
 
150
       movq    mm1, .col3r
9512 IgorA 151
       movq    .col3r ,mm0
9237 leency 152
       movq    .col2r ,mm1
153
else
154
155
       mov     edx,dword .col2r  ; r, g
156
 
157
       mov     dword .col2r,edx
158
159
       mov     edx,dword .col2b  ; b, z
160
 
161
       mov     dword .col2b,edx
162
end if
163
164
       mov     edx,dword .tex_x2
165
 
166
       mov     dword .tex_x2,edx
167
168
       jmp .sort3
169
 
170
 .sort2:
171
 
172
       push     eax ebx ecx         ; store in variables
173
 
9512 IgorA 174
  ;     push     ecx
9237 leency 175
176
;****************** delta computng zone **************
177
 
178
       mov      bx,.y2       ; calc delta12
179
       sub      bx,.y1
9512 IgorA 180
       jnz      .dx12_make
181
       mov      ecx,7
182
     @@:
183
       push     dword 0
9237 leency 184
       loop     @b
9512 IgorA 185
       jmp      .dx12_done
186
  .dx12_make:
187
     ;  sub      esp,7*4
9237 leency 188
9512 IgorA 189
       movsx    ebx,bx
9237 leency 190
 
9512 IgorA 191
       cdq
192
       idiv     ebx
9237 leency 193
    ;   push     eax
9512 IgorA 194
       mov      ebx,eax
195
196
9237 leency 197
 
198
 
9512 IgorA 199
       cwde
200
       imul     ebx
9237 leency 201
       sar      eax,15 - ROUND
9512 IgorA 202
       push     eax
203
    ;   mov      .dx12,eax
204
205
       sub       esp,6*4
9237 leency 206
 
9512 IgorA 207
       pshuflw   xmm0,xmm0,0
208
    ;   pshufd    xmm0,xmm0,0
209
       movlhps   xmm0,xmm0
210
       movq      xmm1,.col1r
211
       movq      xmm2,.col2r
212
       movhps    xmm1,.tex_x1
213
       movhps    xmm2,.tex_x2
214
       psubw     xmm2,xmm1
215
       movdqa    xmm3,xmm2
216
       pmullw    xmm2,xmm0
217
       pmulhw    xmm3,xmm0
218
       movhlps   xmm4,xmm2
219
       movhlps   xmm5,xmm3
220
       punpcklwd xmm2,xmm3
221
       punpcklwd xmm4,xmm5
222
       psrad     xmm2,15 - ROUND
223
       psrad     xmm4,15 - ROUND
224
       pshufd    xmm2,xmm2,11000110b
225
       movdqu    .dc12b,xmm2
226
   ;    punpcklwd xmm4,xmm5
227
    ;   psrad     xmm4,15 - ROUND
228
       movq      .tex_dx12,xmm4
229
230
9237 leency 231
 
232
 
233
234
       mov      bx,.y3       ; calc delta23
235
 
9512 IgorA 236
       jnz      .dx23_make
237
       mov      ecx,7
238
    @@:
239
       push     dword 0
9237 leency 240
       loop     @b
9512 IgorA 241
       jmp      .dx23_done
242
243
  .dx23_make:
9237 leency 244
 
245
       mov      eax,1 shl 15
9512 IgorA 246
       cdq
247
       idiv     ebx
9237 leency 248
       mov      ebx,eax
9512 IgorA 249
250
9237 leency 251
 
252
 
9512 IgorA 253
       cwde
254
       imul     ebx
9237 leency 255
       sar      eax,15 - ROUND
9512 IgorA 256
       push     eax
257
258
       sub       esp,6*4
9237 leency 259
 
9512 IgorA 260
       pshuflw   xmm0,xmm0,0
261
       movlhps   xmm0,xmm0
262
       movq      xmm1,.col2r
263
       movq      xmm2,.col3r
264
       movhps    xmm1,.tex_x2
265
       movhps    xmm2,.tex_x3
266
       psubw     xmm2,xmm1
267
       movdqa    xmm3,xmm2
268
       pmullw    xmm2,xmm0
269
       pmulhw    xmm3,xmm0
270
       movhlps   xmm4,xmm2
271
       movhlps   xmm5,xmm3
272
       punpcklwd xmm2,xmm3
273
       punpcklwd xmm4,xmm5
274
       psrad     xmm2,15 - ROUND
275
       psrad     xmm4,15 - ROUND
276
       pshufd    xmm2,xmm2,11000110b
277
       movdqu    .dc23b,xmm2
278
       movq      .tex_dx23,xmm4
279
280
9237 leency 281
 
282
 
283
       mov      bx,.y3       ; calc delta13
284
       sub      bx,.y1
9512 IgorA 285
       jnz      .dx13_make
286
       mov      ecx,7
287
     @@:
288
       push     dword 0
9237 leency 289
       loop     @b
9512 IgorA 290
       jmp      .dx13_done
291
  .dx13_make:
292
       movsx    ebx,bx
9237 leency 293
       mov      eax,1 shl 15
9512 IgorA 294
       cdq
295
       idiv     ebx
9237 leency 296
       mov      ebx,eax
9512 IgorA 297
298
9237 leency 299
 
300
 
9512 IgorA 301
       cwde
302
       imul     ebx
9237 leency 303
       sar      eax,15 - ROUND
9512 IgorA 304
       push     eax
305
306
       sub       esp,6*4
9237 leency 307
 
9512 IgorA 308
       pshuflw   xmm0,xmm0,0
309
       movlhps   xmm0,xmm0
310
       movq      xmm1,.col1r
311
       movq      xmm2,.col3r
312
       movhps    xmm1,.tex_x1
313
       movhps    xmm2,.tex_x3
314
       psubw     xmm2,xmm1
315
       movdqa    xmm3,xmm2
316
       pmullw    xmm2,xmm0
317
       pmulhw    xmm3,xmm0
318
       movhlps   xmm4,xmm2
319
       movhlps   xmm5,xmm3
320
       punpcklwd xmm2,xmm3
321
       punpcklwd xmm4,xmm5
322
       psrad     xmm2,15 - ROUND
323
       psrad     xmm4,15 - ROUND
324
       pshufd    xmm2,xmm2,11000110b
325
       movdqu    .dc13b,xmm2
326
       movq      .tex_dx13,xmm4
327
   .dx13_done:
328
329
; <<<<<<<  ::delta zone end+++++++++++++++++++++ >>>>>>>>
9237 leency 330
 
9512 IgorA 331
       sub      esp,(12*4)
9237 leency 332
 
9512 IgorA 333
       movsx    eax,.x1                    ; eax - cur x1
9237 leency 334
 
9512 IgorA 335
       mov      ebx,eax
336
337
9237 leency 338
 
339
 
9512 IgorA 340
       mov      .scan_x1,edi
341
       mov      .scan_x2,edi
342
    ;   push     edi
343
    ;   push     edi
344
       movzx    edx,word .tex_y1
345
       shl      edx,ROUND
346
  ;     push     edx
347
  ;     push     edx
348
       mov      .scan_y1,edx
349
       mov      .scan_y2,edx
350
351
       movsx    edx,word .z1
9237 leency 352
 
9512 IgorA 353
   ;    push     edx
354
   ;    push     edx
355
       mov      .zz1,edx
356
       mov      .zz2,edx
357
358
       movzx    edi,word .col1r
9237 leency 359
 
9512 IgorA 360
       mov      .cur1r,edi
361
       mov      .cur2r,edi
362
       movzx    esi,word .col1g
363
       shl      esi,ROUND
364
       mov      .cur1g,esi
365
       mov      .cur2g,esi
366
       movzx    edx,word .col1b
367
       shl      edx,ROUND
368
       mov      .cur1b,edx
369
       mov      .cur2b,edx
370
371
9237 leency 372
 
9512 IgorA 373
 
374
       jge      .loop1_end
375
    .loop_1:
376
9237 leency 377
       pushad
9512 IgorA 378
 
9237 leency 379
       push     .tex_ptr
380
 
9512 IgorA 381
       push     .z_ptr
382
       push     cx
383
384
       push     dword .zz2
9237 leency 385
 
9512 IgorA 386
       push     dword .cur2b
9237 leency 387
 
9512 IgorA 388
       push     dword .cur2r
389
       push     dword .scan_x2
390
       push     dword .scan_y2
391
392
       push      .zz1
9237 leency 393
 
9512 IgorA 394
       push     dword .cur1b
9237 leency 395
 
9512 IgorA 396
       push     dword .cur1r
397
       push     dword .scan_x1
398
       push     dword .scan_y1
399
400
       sar      eax,ROUND
9237 leency 401
 
9512 IgorA 402
       call     horizontal_tex_grd_line
403
404
9237 leency 405
 
9512 IgorA 406
 
9237 leency 407
408
 
409
 
9512 IgorA 410
       movups   xmm2,.cur2b
411
       movups   xmm3,.dc12b
412
       movq     mm2,.scan_x1
413
       movq     mm5,.scan_x2
414
       paddd    xmm0,xmm1
415
       paddd    xmm2,xmm3
416
       paddd    mm2,.tex_dx13
417
       paddd    mm5,.tex_dx12
418
       movq     .scan_x1,mm2
419
       movq     .scan_x2,mm5
420
       movups   .cur1b,xmm0
421
       movups   .cur2b,xmm2
422
423
9237 leency 424
 
9512 IgorA 425
 
426
       inc      cx
427
       cmp      cx,.y2
428
       jl      .loop_1
429
 .loop1_end:
9237 leency 430
       movzx    ecx,.y2
431
       cmp      cx,.y3
9512 IgorA 432
       jge      .loop2_end
433
434
       movsx    ebx,.x2                    ; eax - cur x1
9237 leency 435
 
9512 IgorA 436
437
       movsx    edx,word .z2
9237 leency 438
 
9512 IgorA 439
;       mov      .zz1,edx
440
       mov      .zz2,edx
9237 leency 441
9512 IgorA 442
       movzx    edi,word .col2r
9237 leency 443
 
9512 IgorA 444
   ;    mov      .cur1r,edi
445
       mov      .cur2r,edi
9237 leency 446
       movzx    esi,word .col2g
9512 IgorA 447
       shl      esi,ROUND
448
   ;    mov      .cur1g,esi
449
       mov      .cur2g,esi
9237 leency 450
       movzx    edx,word .col2b
9512 IgorA 451
       shl      edx,ROUND
452
   ;    mov      .cur1b,edx
453
       mov      .cur2b,edx
9237 leency 454
9512 IgorA 455
       movzx    edi,word .tex_x2
9237 leency 456
 
9512 IgorA 457
 ;      mov      .scan_x1,edi
458
       mov      .scan_x2,edi
9237 leency 459
       movzx    edx,word .tex_y2
9512 IgorA 460
       shl      edx,ROUND
461
 ;      mov      .scan_y1,edx
462
       mov      .scan_y2,edx
9237 leency 463
9512 IgorA 464
  .loop_2:
9237 leency 465
 
466
467
       push     .tex_ptr
468
 
9512 IgorA 469
       push     .z_ptr
470
       push     cx
471
472
       push     dword .zz2
9237 leency 473
 
9512 IgorA 474
       push     dword .cur2b
9237 leency 475
 
9512 IgorA 476
       push     dword .cur2r
477
       push     dword .scan_x2
478
       push     dword .scan_y2
479
480
       push      .zz1
9237 leency 481
 
9512 IgorA 482
       push     dword .cur1b
9237 leency 483
 
9512 IgorA 484
       push     dword .cur1r
485
       push     dword .scan_x1
486
       push     dword .scan_y1
487
488
       sar      eax,ROUND
9237 leency 489
 
9512 IgorA 490
       call     horizontal_tex_grd_line
491
492
       popad
9237 leency 493
 
494
495
 
496
 
9512 IgorA 497
       movups   xmm2,.cur2b
498
       movups   xmm3,.dc23b
499
       movq     mm2,.scan_x1
500
       movq     mm5,.scan_x2
501
       paddd    xmm0,xmm1
502
       paddd    xmm2,xmm3
503
       paddd    mm2,.tex_dx13
504
       paddd    mm5,.tex_dx23
505
       movq     .scan_x1,mm2
506
       movq     .scan_x2,mm5
507
       movups   .cur1b,xmm0
508
       movups   .cur2b,xmm2
509
510
       add      eax,.dx13
9237 leency 511
 
9512 IgorA 512
       inc      cx
513
       cmp      cx,.y3
514
       jl       .loop_2
515
516
.loop2_end:
517
 
9237 leency 518
ret 36
9512 IgorA 519
horizontal_tex_grd_line:
9237 leency 520
;in:
521
; eax : x1, ebx : x2
522
523
.tex_ptr  equ [ebp+62]
524
 
525
.z_buffer equ [ebp+54]
526
.y        equ [ebp+52]
527
9512 IgorA 528
.z2     equ [ebp+48]
9237 leency 529
 
9512 IgorA 530
.g2     equ [ebp+40]
531
.r2     equ [ebp+36]
532
.tex_x2 equ [ebp+32]
533
.tex_y2 equ [ebp+28]
534
535
9237 leency 536
 
537
 
9512 IgorA 538
.g1     equ [ebp+16]
539
.r1     equ [ebp+12]
540
.tex_x1 equ [ebp+8]
541
.tex_y1 equ [ebp+4]
542
543
544
 
545
 
9237 leency 546
.dz equ dword[ebp-8]
547
.db equ [ebp-12]
548
.dg equ dword[ebp-16]
9512 IgorA 549
.dr equ [ebp-20]
9237 leency 550
.dtex_x equ dword[ebp-24]
9512 IgorA 551
.dtex_y equ [ebp-28]
9237 leency 552
9512 IgorA 553
        mov     ebp,esp
9237 leency 554
 
9512 IgorA 555
9237 leency 556
 
557
 
9512 IgorA 558
        jl      .quit_l
559
560
        cmp     cx,word[size_y_var]  ;SIZE_Y
9237 leency 561
 
9512 IgorA 562
563
        cmp     ax,bx
9237 leency 564
 
9512 IgorA 565
        jl      @f
566
567
        xchg    eax,ebx
9237 leency 568
 
9512 IgorA 569
9237 leency 570
 
571
 
9512 IgorA 572
       movdqu  .tex_y1,xmm1
573
       movdqu  .tex_y2,xmm0
574
       movq    xmm4,.b1    ; x, z
575
       movq    xmm5,.b2
576
       movq    .b1,xmm5
577
       movq    .b2,xmm4
578
579
9237 leency 580
 
581
 
9512 IgorA 582
        jle     .quit_l
583
        cmp     ax,word[size_x_var]  ;SIZE_X
584
        jge     .quit_l
585
586
        push    ax
9237 leency 587
 
9512 IgorA 588
if 1
589
        mov     bx,.x2
590
        sub     bx,.x1
591
592
        movsx    ebx,bx
9237 leency 593
 
9512 IgorA 594
        cdq
595
        idiv     ebx
596
        mov      ebx,eax
597
598
9237 leency 599
 
600
 
9512 IgorA 601
        imul    ebx
602
        sar     eax,15
603
        push    eax  ; .dz
604
605
        mov     eax,.b2
9237 leency 606
 
9512 IgorA 607
        imul    ebx
608
        sar     eax,15
609
        push    eax
610
611
        mov     eax,.g2
9237 leency 612
 
9512 IgorA 613
        imul    ebx
614
        sar     eax,15
615
        push    eax  ; .dz
616
617
        mov     eax,.r2
9237 leency 618
 
9512 IgorA 619
        imul    ebx
620
        sar     eax,15
621
        push    eax
622
623
        mov     eax,.tex_x2
9237 leency 624
 
9512 IgorA 625
        imul    ebx
626
        sar     eax,15
627
        push    eax
628
629
        mov     eax,.tex_y2
9237 leency 630
 
9512 IgorA 631
        imul    ebx
632
        sar     eax,15
633
        push    eax
634
635
9237 leency 636
 
637
 
9512 IgorA 638
       sub       esp,6*4
639
       movd      xmm0,ebx
640
       pshuflw   xmm0,xmm0,0
641
       movlhps   xmm0,xmm0
642
       movdqu    xmm1,.tex_y1
643
       movdqu    xmm2,.tex_y2
644
       movq      xmm3,.b1
645
       movq      xmm4,.b2
646
       psubd     xmm4,xmm3
647
       psubd     xmm2,xmm1
648
       packssdw  xmm2,xmm4
649
  ;     packlssdw  xmm2,xmm2
650
   ;    movlhps   xmm2,xmm4
651
652
9237 leency 653
 
654
 
9512 IgorA 655
       pmullw    xmm2,xmm0
656
       pmulhw    xmm3,xmm0
657
       movhlps   xmm4,xmm2
658
       movhlps   xmm5,xmm3
659
       punpcklwd xmm2,xmm3
660
       punpcklwd xmm4,xmm5
661
       psrad     xmm2,15 - ROUND
662
       psrad     xmm4,15 - ROUND
663
   ;    pshufd    xmm2,xmm2,11000110b
664
       movdqu    .dtex_y,xmm2
665
       movq      .db,xmm4
666
667
9237 leency 668
 
669
 
9512 IgorA 670
        cmp     .x1,0
671
 
672
673
        mov     eax,.dz     ; clipping
674
 
675
        neg     ebx
676
        imul    ebx
677
        add     .z1,eax
678
        mov     .x1,0
679
680
        mov    eax,.dr
681
 
682
        add    .r1,eax
683
;if  Ext=NON
684
        mov    eax,.dg
9237 leency 685
        imul   ebx
9512 IgorA 686
        add    .g1,eax
687
688
        mov    eax,.db
9237 leency 689
 
9512 IgorA 690
        add    .b1,eax
691
692
        mov    eax,.dtex_x
9237 leency 693
 
9512 IgorA 694
        add    .tex_x1,eax
695
696
        mov    eax,.dtex_y
9237 leency 697
 
9512 IgorA 698
        add    .tex_y1,eax
699
   @@:
700
        movsx     edx,word[size_x_var]  ;SIZE_X
9237 leency 701
        cmp       .x2,dx
9512 IgorA 702
        jl        @f
703
        mov       .x2,dx
704
    @@:
705
; calc line addres begin in screen and Z buffer
9237 leency 706
        movsx     eax,word .y
707
        mul       edx
9512 IgorA 708
        movsx     edx,.x1
709
        add       eax,edx
710
711
        mov       esi,eax
9237 leency 712
 
9512 IgorA 713
        add       esi,.z_buffer
714
715
        lea       eax,[eax*3]
9237 leency 716
 
9512 IgorA 717
        add       edi,eax
718
719
        mov       cx,.x2
9237 leency 720
 
9512 IgorA 721
        movzx     ecx,cx
722
723
; init current variables
9237 leency 724
 
725
        movdqu    xmm1,.dr
9512 IgorA 726
        pxor      xmm2,xmm2
727
        movq      xmm4,.dtex_y
728
        movq      xmm5,.tex_y1
729
730
        mov       ebx,.z1
9237 leency 731
 
9512 IgorA 732
        cmp       ebx,dword[esi]
9237 leency 733
        jge       @f
9512 IgorA 734
        movdqa    xmm6,xmm5
735
        psrld     xmm6,ROUND
736
        movd      eax,xmm6
737
        psrldq    xmm6,4
738
        movd      edx,xmm6
739
        shl       eax,TEX_SHIFT
740
741
   ; calc texture pixel mem addres
9237 leency 742
 
9512 IgorA 743
       add       eax,edx
9237 leency 744
 
9512 IgorA 745
       lea       eax,[3*eax]
746
       add       eax,.tex_ptr
747
       mov       dword[esi],ebx
748
749
       movd      xmm7,[eax]
9237 leency 750
 
9512 IgorA 751
       movdqa    xmm3,xmm0   ; calc col
752
       psrld     xmm3,ROUND  ;
753
       packssdw  xmm3,xmm3
754
       pmullw    xmm7,xmm3
755
       psrlw     xmm7,8
756
       packuswb  xmm7,xmm7
757
       movd      [edi],xmm7
758
759
       mov        dword[esi],ebx
9237 leency 760
 
9512 IgorA 761
       add        edi,3
762
       add        esi,4
763
       add        ebx,.dz
764
       paddd      xmm5,xmm4
765
       paddd      xmm0,xmm1
766
767
       loop     .ddraw
768
 
769
  .quit_l:
770
 
9237 leency 771
        mov     esp,ebp
772
 
9512 IgorA 773
;the_zero:
9237 leency 774
;size_y_var:
9512 IgorA 775
;size_x_var:
776