Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
9237 leency 1
 
2
;TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1
3
;ROUND equ 8
4
;Ext = NON
5
;MMX = 1
6
;NON = 0
7
;------- Big thanks to Majuma (www.majuma.xt.pl) for absolutely great---
8
;------- DOS 13h mode demos --------------------------------------------
9
;------- Procedure draws bump triangle with texture, I use -------------
10
;--------Catmull Z-buffer algorithm- (Z coordinate interpolation)-------
11
;--------I calc texture pixel by this way: col1*col2/256 ---------------
12
bump_tex_triangle_z:
13
;------------------in - eax - x1 shl 16 + y1 -----------
14
;---------------------- ebx - x2 shl 16 + y2 -----------
15
;---------------------- ecx - x3 shl 16 + y3 -----------
16
;---------------------- edx - pointer to bump map-------
17
;---------------------- esi - pointer to env map--------
18
;---------------------- edi - pointer to screen buffer--
19
;---------------------- stack : bump coordinates--------
20
;----------------------         environment coordinates-
21
;----------------------         Z position coordinates--
22
;----------------------         pointer to Z buffer-----
23
;----------------------         pointer to texture------
24
;----------------------         texture coordinates-----
25
;-- Z-buffer - filled with coordinates as dword --------
26
;-- (Z coor. as word) shl CATMULL_SHIFT ----------------
27
28
 
29
 
30
 
9512 IgorA 31
.t_x1   equ ebp+6   ; each coordinate as word
32
.e_y1   equ ebp+8              ; texture coords
33
.e_x1   equ ebp+10
34
.b_y1   equ ebp+12
35
.b_x1   equ ebp+14
36
9237 leency 37
 
38
 
39
 
9512 IgorA 40
.t_x2   equ ebp+18            ; b - bump map coords
41
.e_y2   equ ebp+20              ; texture coords
42
.e_x2   equ ebp+22
43
.b_y2   equ ebp+24
44
.b_x2   equ ebp+26
45
9237 leency 46
 
47
 
48
 
49
 
9512 IgorA 50
.t_x3   equ ebp+30
51
.e_y3   equ ebp+32              ; texture coords
52
.e_x3   equ ebp+34
53
.b_y3   equ ebp+36
54
.b_x3   equ ebp+38
55
9237 leency 56
 
9512 IgorA 57
.z2     equ word[ebp+42]
58
.z3     equ word[ebp+44]
59
.z_buff equ dword[ebp+46]       ; pointer to Z-buffer
60
.tex_ptr equ dword[ebp+50]      ; ptr to texture
61
62
 
63
 
64
 
65
.t_emap equ dword[ebp-8]        ; pointer to env map
66
.x1     equ word[ebp-10]
67
.y1     equ word[ebp-12]
68
.x2     equ word[ebp-14]
69
.y2     equ word[ebp-16]
70
.x3     equ word[ebp-18]
71
.y3     equ word[ebp-20]
72
73
 
74
 
75
 
76
 
77
.dz12   equ      [ebp-28]
78
.dbx12  equ dword[ebp-32]
79
.dby12  equ      [ebp-36]
80
.dex12  equ dword[ebp-40]
81
.dey12  equ      [ebp-44]
82
.dtx12  equ dword[ebp-48]
83
.dty12  equ      [ebp-52]
84
85
 
9237 leency 86
.dz13  equ      [ebp-52-4*2]
9512 IgorA 87
.dbx13 equ dword[ebp-52-4*3]
9237 leency 88
.dby13 equ      [ebp-52-4*4]
9512 IgorA 89
.dex13 equ dword[ebp-52-4*5]
9237 leency 90
.dey13 equ      [ebp-52-4*6]
9512 IgorA 91
.dtx13 equ dword[ebp-52-4*7]
9237 leency 92
.dty13 equ      [ebp-52-4*8]
9512 IgorA 93
9237 leency 94
 
95
 
96
.dz23  equ      [ebp-(52+4*10)]
9512 IgorA 97
.dbx23 equ dword[ebp-(52+4*11)]
9237 leency 98
.dby23 equ      [ebp-(52+4*12)]
9512 IgorA 99
.dex23 equ dword[ebp-(52+4*13)]
9237 leency 100
.dey23 equ      [ebp-(52+4*14)]
9512 IgorA 101
.dtx23 equ dword[ebp-(52+4*15)]
9237 leency 102
.dty23 equ      [ebp-(52+4*16)]
9512 IgorA 103
9237 leency 104
 
105
 
106
 
9512 IgorA 107
.cz1   equ      [ebp-(52+4*18)]
108
.cbx1  equ dword[ebp-(52+4*19)]
9237 leency 109
.cby1  equ      [ebp-(52+4*20)]
9512 IgorA 110
.cex1  equ dword[ebp-(52+4*21)]
9237 leency 111
.cey1  equ      [ebp-(52+4*22)]
9512 IgorA 112
.ctx1  equ dword[ebp-(52+4*23)]
9237 leency 113
.cty1  equ      [ebp-(52+4*24)]
9512 IgorA 114
9237 leency 115
 
116
.cz2   equ      [ebp-(52+4*26)]
9512 IgorA 117
.cbx2  equ dword[ebp-(52+4*27)]
9237 leency 118
.cby2  equ      [ebp-(52+4*28)]
9512 IgorA 119
.cex2  equ dword[ebp-(52+4*29)]
9237 leency 120
.cey2  equ      [ebp-(52+4*30)]
9512 IgorA 121
.ctx2  equ dword[ebp-(52+4*31)]
9237 leency 122
.cty2  equ      [ebp-(52+4*32)]
9512 IgorA 123
9237 leency 124
 
9512 IgorA 125
       emms
126
end if
9237 leency 127
9512 IgorA 128
 
9237 leency 129
       mov     ebp,esp
130
       push    edx        ; store bump map
9512 IgorA 131
       push    esi        ; store e. map
132
     ; sub     esp,120
9237 leency 133
 .sort3:                  ; sort triangle coordinates...
9512 IgorA 134
       cmp     ax,bx
9237 leency 135
       jle     .sort1
136
       xchg    eax,ebx
137
   if Ext >= MMX
9512 IgorA 138
       movq    mm0,[.t_y1]
139
       movq    mm1,[.t_y2]
140
       movq    [.t_y1],mm1
141
       movq    [.t_y2],mm0
142
    end if
143
       mov     edx,dword[.b_y1]
144
       xchg    edx,dword[.b_y2]
145
       mov     dword[.b_y1],edx
146
    if Ext = NON
147
       mov     edx,dword[.e_y1]
148
       xchg    edx,dword[.e_y2]
149
       mov     dword[.e_y1],edx
150
       mov     edx,dword[.t_y1]
151
       xchg    edx,dword[.t_y2]
152
       mov     dword[.t_y1],edx
153
    end if
154
       mov     dx,.z1
9237 leency 155
       xchg    dx,.z2
156
       mov     .z1,dx
157
 .sort1:
158
       cmp      bx,cx
9512 IgorA 159
       jle      .sort2
160
       xchg     ebx,ecx
161
     if Ext >= MMX
162
       movq    mm0,[.t_y3]
163
       movq    mm1,[.t_y2]
164
       movq    [.t_y3],mm1
165
       movq    [.t_y2],mm0
166
     end if
167
       mov      edx,dword[.b_y2]
168
       xchg     edx,dword[.b_y3]
169
       mov      dword[.b_y2],edx
170
     if Ext = NON
171
       mov      edx,dword[.e_y2]
172
       xchg     edx,dword[.e_y3]
173
       mov      dword[.e_y2],edx
174
       mov      edx,dword[.t_y2]
175
       xchg     edx,dword[.t_y3]
176
       mov      dword[.t_y2],edx
177
     end if
178
       mov     dx,.z2
9237 leency 179
       xchg    dx,.z3
180
       mov     .z2,dx
181
       jmp      .sort3
9512 IgorA 182
 .sort2:
9237 leency 183
       push     eax     ; store triangle coords in variables
9512 IgorA 184
       push     ebx
185
       push     ecx
186
         mov      edx,80008000h  ; eax,ebx,ecx are ANDd together into edx which means that
187
         and      edx,ebx        ; if *all* of them are negative a sign flag is raised
188
         and      edx,ecx
189
         and      edx,eax
190
         test     edx,80008000h  ; Check both X&Y at once
191
         jne      .loop23_done
192
    ;   mov     edx,eax         ; eax,ebx,ecx are ORd together into edx which means that
9237 leency 193
    ;   or      edx,ebx         ; if any *one* of them is negative a sign flag is raised
194
    ;   or      edx,ecx
195
    ;   test    edx,80000000h   ; Check only X
196
    ;   jne     .loop23_done
197
198
 
199
    ;   jg      .loop23_done
200
    ;   cmp     .x2,SIZE_X     ; This can be optimized with effort
201
    ;   jg      .loop23_done
202
    ;   cmp     .x3,SIZE_X
203
    ;   jg      .loop23_done    ; {
204
205
 
206
 
9512 IgorA 207
       sub      bx,.y1
208
       jnz      .bt_dx12_make
209
210
 
211
       xor      edx,edx
212
     @@:
9237 leency 213
       push     edx
9512 IgorA 214
       loop     @b
215
216
 
217
 .bt_dx12_make:
9237 leency 218
       movsx    ebx,bx
9512 IgorA 219
if Ext >= SSE2
220
       mov      eax,1 shl 15
221
       cdq
222
       idiv     ebx
223
       mov      ebx,eax
224
9237 leency 225
 
226
 
9512 IgorA 227
       sub      ax,.x1
228
       cwde
229
       imul     ebx
230
       sar      eax,15 - ROUND
231
       push     eax
232
9237 leency 233
 
9512 IgorA 234
       sub      ax,.z1
235
       cwde
9237 leency 236
       imul     ebx
9512 IgorA 237
       sar      eax,15 - ROUND
238
       push     eax
239
9237 leency 240
 
9512 IgorA 241
       movd      xmm0,ebx
242
       pshuflw   xmm0,xmm0,0
243
       movlhps   xmm0,xmm0
244
       movdqu    xmm1,[.t_y1]
245
       movdqu    xmm2,[.t_y2]
246
       psubw     xmm2,xmm1
247
       movdqa    xmm3,xmm2
248
       pmullw    xmm2,xmm0
249
       pmulhw    xmm3,xmm0
250
       movhlps   xmm4,xmm2
251
       movhlps   xmm5,xmm3
252
       punpcklwd xmm2,xmm3
253
       punpcklwd xmm4,xmm5
254
       psrad     xmm2,15 - ROUND
255
       psrad     xmm4,15 - ROUND
256
       movdqu    .dty12,xmm2
257
       movq      .dby12,xmm4
258
else
259
9237 leency 260
 
9512 IgorA 261
       sub      ax,.x1
262
       cwde
9237 leency 263
       shl      eax,ROUND
9512 IgorA 264
       cdq
9237 leency 265
       idiv     ebx
9512 IgorA 266
 ;     mov      .dx12,eax
9237 leency 267
       push      eax
9512 IgorA 268
9237 leency 269
 
270
       sub     ax,.z1
271
       cwde
272
       shl     eax,CATMULL_SHIFT
273
       cdq
274
       idiv    ebx
275
       push    eax
276
277
 
9512 IgorA 278
       sub      ax,word[.b_x1]
279
       cwde
9237 leency 280
       shl      eax,ROUND
9512 IgorA 281
       cdq
9237 leency 282
       idiv     ebx
9512 IgorA 283
 ;     mov      .dbx12,eax
9237 leency 284
       push      eax
9512 IgorA 285
9237 leency 286
 
9512 IgorA 287
       sub      ax,word[.b_y1]
288
       cwde
9237 leency 289
       shl      eax,ROUND
9512 IgorA 290
       cdq
9237 leency 291
       idiv     ebx
9512 IgorA 292
 ;     mov      .dby12,eax
9237 leency 293
       push      eax
9512 IgorA 294
9237 leency 295
 
9512 IgorA 296
       sub      ax,word[.e_x1]
297
       cwde
9237 leency 298
       shl      eax,ROUND
9512 IgorA 299
       cdq
9237 leency 300
       idiv     ebx
9512 IgorA 301
 ;     mov      .dex12,eax
9237 leency 302
       push      eax
9512 IgorA 303
9237 leency 304
 
9512 IgorA 305
       sub      ax,word[.e_y1]
306
       cwde
9237 leency 307
       shl      eax,ROUND
9512 IgorA 308
       cdq
9237 leency 309
       idiv     ebx
9512 IgorA 310
 ;     mov      .dey12,eax
9237 leency 311
       push      eax
9512 IgorA 312
9237 leency 313
 
9512 IgorA 314
       sub      ax,word[.t_x1]
315
       cwde
9237 leency 316
       shl      eax,ROUND
9512 IgorA 317
       cdq
9237 leency 318
       idiv     ebx
9512 IgorA 319
 ;     mov      .dtx12,eax
9237 leency 320
       push      eax
9512 IgorA 321
9237 leency 322
 
9512 IgorA 323
       sub      ax,word[.t_y1]
324
       cwde
9237 leency 325
       shl      eax,ROUND
9512 IgorA 326
       cdq
9237 leency 327
       idiv     ebx
9512 IgorA 328
 ;     mov      .dty12,eax
9237 leency 329
       push      eax
9512 IgorA 330
end if
9237 leency 331
   .bt_dx12_done:
332
333
 
9512 IgorA 334
       sub      bx,.y1
335
       jnz      .bt_dx13_make
336
       mov      ecx,8
337
       xor      edx,edx
338
     @@:
9237 leency 339
       push     edx   ;dword 0
9512 IgorA 340
       loop     @b
341
       jmp      .bt_dx13_done
342
 .bt_dx13_make:
9237 leency 343
       movsx    ebx,bx
9512 IgorA 344
9237 leency 345
 
9512 IgorA 346
       mov      eax,1 shl 15
347
       cdq
348
       idiv     ebx
349
       mov      ebx,eax
350
9237 leency 351
 
352
 
9512 IgorA 353
       sub      ax,.x1
354
       cwde
355
       imul     ebx
356
       sar      eax,15 - ROUND
357
       push     eax
358
    ;   mov      .dx12,eax
359
9237 leency 360
 
9512 IgorA 361
       sub      ax,.z1
362
       cwde
9237 leency 363
       imul     ebx
9512 IgorA 364
       sar      eax,15 - ROUND
365
       push     eax
366
9237 leency 367
 
9512 IgorA 368
       movd      xmm0,ebx
369
       pshuflw   xmm0,xmm0,0
370
       movlhps   xmm0,xmm0
371
       movdqu    xmm1,[.t_y1]
372
       movdqu    xmm2,[.t_y3]
373
       psubw     xmm2,xmm1
374
       movdqa    xmm3,xmm2
375
       pmullw    xmm2,xmm0
376
       pmulhw    xmm3,xmm0
377
       movhlps   xmm4,xmm2
378
       movhlps   xmm5,xmm3
379
       punpcklwd xmm2,xmm3
380
       punpcklwd xmm4,xmm5
381
       psrad     xmm2,15 - ROUND
382
       psrad     xmm4,15 - ROUND
383
       movdqu    .dty13,xmm2
384
       movq      .dby13,xmm4
385
else
9237 leency 386
387
 
9512 IgorA 388
       sub      ax,.x1
389
       cwde
9237 leency 390
       shl      eax,ROUND
9512 IgorA 391
       cdq
9237 leency 392
       idiv     ebx
9512 IgorA 393
 ;     mov      .dx13,eax
9237 leency 394
       push      eax
9512 IgorA 395
9237 leency 396
 
397
       sub     ax,.z1
398
       cwde
399
       shl     eax,CATMULL_SHIFT
400
       cdq
401
       idiv    ebx
402
  ;    mov    .dz13,eax
403
       push    eax
404
405
 
406
 
9512 IgorA 407
       sub      ax,word[.b_x1]
408
       cwde
9237 leency 409
       shl      eax,ROUND
9512 IgorA 410
       cdq
9237 leency 411
       idiv     ebx
9512 IgorA 412
 ;     mov      .dbx13,eax
9237 leency 413
       push      eax
9512 IgorA 414
9237 leency 415
 
9512 IgorA 416
       sub      ax,word[.b_y1]
417
       cwde
9237 leency 418
       shl      eax,ROUND
9512 IgorA 419
       cdq
9237 leency 420
       idiv     ebx
9512 IgorA 421
 ;     mov      .dby13,eax
9237 leency 422
       push      eax
9512 IgorA 423
9237 leency 424
 
9512 IgorA 425
       sub      ax,word[.e_x1]
426
       cwde
9237 leency 427
       shl      eax,ROUND
9512 IgorA 428
       cdq
9237 leency 429
       idiv     ebx
9512 IgorA 430
 ;     mov      .dex13,eax
9237 leency 431
       push      eax
9512 IgorA 432
9237 leency 433
 
9512 IgorA 434
       sub      ax,word[.e_y1]
435
       cwde
9237 leency 436
       shl      eax,ROUND
9512 IgorA 437
       cdq
9237 leency 438
       idiv     ebx
9512 IgorA 439
 ;     mov      .dey13,eax
9237 leency 440
       push      eax
9512 IgorA 441
9237 leency 442
 
9512 IgorA 443
       sub      ax,word[.t_x1]
444
       cwde
9237 leency 445
       shl      eax,ROUND
9512 IgorA 446
       cdq
9237 leency 447
       idiv     ebx
9512 IgorA 448
 ;     mov      .dtx13,eax
9237 leency 449
       push      eax
9512 IgorA 450
9237 leency 451
 
9512 IgorA 452
       sub      ax,word[.t_y1]
453
       cwde
9237 leency 454
       shl      eax,ROUND
9512 IgorA 455
       cdq
9237 leency 456
       idiv     ebx
9512 IgorA 457
 ;     mov      .dty13,eax
9237 leency 458
       push      eax
9512 IgorA 459
end if
9237 leency 460
   .bt_dx13_done:
461
462
 
9512 IgorA 463
       sub      bx,.y2
464
       jnz      .bt_dx23_make
465
       mov      ecx,8
466
       xor      edx,edx
467
     @@:
9237 leency 468
       push     edx   ;dword 0
9512 IgorA 469
       loop     @b
470
       jmp      .bt_dx23_done
471
 .bt_dx23_make:
9237 leency 472
       movsx    ebx,bx
9512 IgorA 473
if Ext >= SSE2
474
9237 leency 475
 
9512 IgorA 476
       cdq
477
       idiv     ebx
478
    ;   push     eax
479
       mov      ebx,eax
480
9237 leency 481
 
482
 
9512 IgorA 483
       sub      ax,.x2
484
       cwde
485
       imul     ebx
486
       sar      eax,15 - ROUND
487
       push     eax
488
    ;   mov      .dx12,eax
489
9237 leency 490
 
9512 IgorA 491
       sub      ax,.z2
492
       cwde
9237 leency 493
       imul     ebx
9512 IgorA 494
       sar      eax,15 - ROUND
495
       push     eax
496
9237 leency 497
 
9512 IgorA 498
       movd      xmm0,ebx
499
       pshuflw   xmm0,xmm0,0
500
       movlhps   xmm0,xmm0
501
       movdqu    xmm1,[.t_y2]
502
       movdqu    xmm2,[.t_y3]
503
       psubw     xmm2,xmm1
504
       movdqa    xmm3,xmm2
505
       pmullw    xmm2,xmm0
506
       pmulhw    xmm3,xmm0
507
       movhlps   xmm4,xmm2
508
       movhlps   xmm5,xmm3
509
       punpcklwd xmm2,xmm3
510
       punpcklwd xmm4,xmm5
511
       psrad     xmm2,15 - ROUND
512
       psrad     xmm4,15 - ROUND
513
       movdqu    .dty23,xmm2
514
       movq      .dby23,xmm4
515
else
9237 leency 516
       mov      ax,.x3
9512 IgorA 517
       sub      ax,.x2
518
       cwde
9237 leency 519
       shl      eax,ROUND
9512 IgorA 520
       cdq
9237 leency 521
       idiv     ebx
9512 IgorA 522
 ;     mov      .dx23,eax
9237 leency 523
       push      eax
9512 IgorA 524
9237 leency 525
 
526
       sub     ax,.z2
527
       cwde
528
       shl     eax,CATMULL_SHIFT
529
       cdq
530
       idiv    ebx
531
     ; mov     .dz23,eax
532
       push    eax
533
534
 
9512 IgorA 535
       sub      ax,word[.b_x2]
536
       cwde
9237 leency 537
       shl      eax,ROUND
9512 IgorA 538
       cdq
9237 leency 539
       idiv     ebx
9512 IgorA 540
 ;     mov      .dbx23,eax
9237 leency 541
       push      eax
9512 IgorA 542
9237 leency 543
 
9512 IgorA 544
       sub      ax,word[.b_y2]
545
       cwde
9237 leency 546
       shl      eax,ROUND
9512 IgorA 547
       cdq
9237 leency 548
       idiv     ebx
9512 IgorA 549
 ;     mov      .dby23,eax
9237 leency 550
       push      eax
9512 IgorA 551
9237 leency 552
 
9512 IgorA 553
       sub      ax,word[.e_x2]
554
       cwde
9237 leency 555
       shl      eax,ROUND
9512 IgorA 556
       cdq
9237 leency 557
       idiv     ebx
9512 IgorA 558
 ;     mov      .dex23,eax
9237 leency 559
       push      eax
9512 IgorA 560
9237 leency 561
 
9512 IgorA 562
       sub      ax,word[.e_y2]
563
       cwde
9237 leency 564
       shl      eax,ROUND
9512 IgorA 565
       cdq
9237 leency 566
       idiv     ebx
9512 IgorA 567
 ;     mov      .dey23,eax
9237 leency 568
       push      eax
9512 IgorA 569
9237 leency 570
 
571
 
9512 IgorA 572
       sub      ax,word[.t_x2]
573
       cwde
9237 leency 574
       shl      eax,ROUND
9512 IgorA 575
       cdq
9237 leency 576
       idiv     ebx
9512 IgorA 577
 ;     mov      .dtx23,eax
9237 leency 578
       push      eax
9512 IgorA 579
9237 leency 580
 
9512 IgorA 581
       sub      ax,word[.t_y2]
582
       cwde
9237 leency 583
       shl      eax,ROUND
9512 IgorA 584
       cdq
9237 leency 585
       idiv     ebx
9512 IgorA 586
 ;     mov      .dty23,eax
9237 leency 587
       push      eax
9512 IgorA 588
end if
9237 leency 589
9512 IgorA 590
 
591
 
9237 leency 592
593
 
9512 IgorA 594
595
 
596
       shl      eax,ROUND
597
       mov      .cx1,eax
598
       mov      .cx2,eax
599
  ;     push     eax
9237 leency 600
  ;     push     eax
601
602
 
9512 IgorA 603
       shl      ebx,ROUND
604
       mov      .cbx1,ebx
605
       mov      .cbx2,ebx
606
      ; push     ebx
9237 leency 607
      ; push     ebx
608
609
 
9512 IgorA 610
       shl      ecx,ROUND
611
       mov      .cby1,ecx
612
       mov      .cby2,ecx
613
      ; push     ecx
9237 leency 614
      ; push     ecx
615
616
 
9512 IgorA 617
       shl      edx,ROUND
618
       mov      .cex1,edx
619
       mov      .cex2,edx
620
    ;   push     edx
9237 leency 621
    ;   push     edx
622
623
 
9512 IgorA 624
       shl      eax,ROUND
625
       mov      .cey1,eax
626
       mov      .cey2,eax
627
    ;   push     eax
9237 leency 628
    ;   push     eax
629
630
 
9512 IgorA 631
       shl      ebx,CATMULL_SHIFT
632
       mov      .cz1,ebx
633
       mov      .cz2,ebx
634
   ;    push     ebx
9237 leency 635
   ;    push     ebx
636
637
 
638
       movsx    ecx,word[.t_x1]
9512 IgorA 639
       shl      ecx,ROUND
640
       mov      .ctx1,ecx
641
       mov      .ctx2,ecx
642
       ;push     ecx
9237 leency 643
       ;push     ecx
644
645
 
9512 IgorA 646
       shl      edx,ROUND
647
       mov      .cty1,edx
648
       mov      .cty2,edx
649
      ; push     edx
9237 leency 650
      ; push     edx
651
652
 
9512 IgorA 653
       movups  xmm0,.cby1
9237 leency 654
       movups  xmm1,.cty1
655
       movups  xmm2,.cby2
656
       movups  xmm3,.cty2
657
       movups  xmm4,.dby13
658
       movups  xmm5,.dty13
659
       movups  xmm6,.dby12
660
       movups  xmm7,.dty12
661
  ;     .scby1  equ [edi]
9512 IgorA 662
  ;     .scty1  equ [edi+16]
663
  ;     .scby2  equ [edi+32]
664
  ;     .scty2  equ [edi+48]
665
  ;     .sdby13 equ [edi+64]
666
  ;     .sdty13 equ [edi+80]
667
  ;     .sdby12 equ [edi+96]
668
  ;     .sdty12 equ [edi+128]
669
  ;     push    edi
670
       mov     edi,sse_repository
9237 leency 671
       movaps  .scby1,xmm0
672
       movaps  .scty1,xmm1
673
       movaps  .scby2,xmm2
674
       movaps  .scty2,xmm3
675
       movaps  .sdby13,xmm4
676
       movaps  .sdty13,xmm5
677
       movaps  .sdby12,xmm6
678
       movaps  .sdty12,xmm7
679
       pop     edi
680
681
 
682
9512 IgorA 683
 
684
       cmp      cx,.y2
685
       jge      .loop12_done
686
  .loop12:
9237 leency 687
       call     .call_line
9512 IgorA 688
689
 
690
691
 
9237 leency 692
       movups  xmm1,.cty1
693
       movups  xmm2,.cby2
694
       movups  xmm3,.cty2
695
       movups  xmm4,.dby13
9512 IgorA 696
       movups  xmm5,.dty13
697
       movups  xmm6,.dby12
698
       movups  xmm7,.dty12
699
       paddd   xmm0,xmm4
700
       paddd   xmm1,xmm5
701
       paddd   xmm2,xmm6
702
       paddd   xmm3,xmm7
703
       movups  .cby1,xmm0
9237 leency 704
       movups  .cty1,xmm1
705
       movups  .cby2,xmm2
706
       movups  .cty2,xmm3
707
end if
708
709
 
9740 macgub 710
       movq     mm0,.cby2
9512 IgorA 711
       movq     mm1,.cby1
712
       movq     mm2,.cey2
713
       movq     mm3,.cey1
714
       movq     mm4,.cty1
715
       movq     mm5,.cty2
716
       movq     mm6,.cz1
717
       movq     mm7,.cz2
718
       paddd    mm0,.dby12
719
       paddd    mm1,.dby13
720
       paddd    mm2,.dey12
721
       paddd    mm3,.dey13
722
       paddd    mm4,.dty13
723
       paddd    mm5,.dty12
724
       paddd    mm6,.dz13
725
       paddd    mm7,.dz12
726
       movq     .cby2,mm0
727
       movq     .cby1,mm1
728
       movq     .cey1,mm3
729
       movq     .cey2,mm2
730
       movq     .cty1,mm4
731
       movq     .cty2,mm5
732
       movq     .cz1,mm6
733
       movq     .cz2,mm7
734
end if
9237 leency 735
if Ext = NON
736
       mov      edx,.dbx13
9512 IgorA 737
       add      .cbx1,edx
738
       mov      eax,.dbx12
739
       add      .cbx2,eax
740
       mov      ebx,.dby13
741
       add      .cby1,ebx
742
       mov      edx,.dby12
743
       add      .cby2,edx
744
9237 leency 745
 
9512 IgorA 746
       add      .cex1,eax
747
       mov      ebx,.dex12
748
       add      .cex2,ebx
749
       mov      edx,.dey13
750
       add      .cey1,edx
751
       mov      eax,.dey12
752
       add      .cey2,eax
753
9237 leency 754
 
9512 IgorA 755
       add      .ctx1,eax
756
       mov      ebx,.dtx12
757
       add      .ctx2,ebx
758
       mov      edx,.dty13
759
       add      .cty1,edx
760
       mov      eax,.dty12
761
       add      .cty2,eax
762
9237 leency 763
 
9512 IgorA 764
       add      .cx1,eax
765
       mov      ebx,.dx12
766
       add      .cx2,ebx
767
       mov      ebx,.dz13
768
       add      .cz1,ebx
769
       mov      edx,.dz12
770
       add      .cz2,edx
771
end if
9237 leency 772
       inc      ecx
9512 IgorA 773
       cmp      cx,.y2
774
       jl       .loop12
775
    .loop12_done:
9237 leency 776
777
 
9512 IgorA 778
       cmp      cx,.y3
779
       jge      .loop23_done
780
9237 leency 781
 
782
 
9512 IgorA 783
       shl      eax,CATMULL_SHIFT
784
       mov      .cz2,eax
785
9237 leency 786
 
9512 IgorA 787
       shl      ebx,ROUND
788
       mov      .cx2,ebx
789
9237 leency 790
 
9512 IgorA 791
       shl      edx,ROUND
792
       mov      .cbx2,edx
793
9237 leency 794
 
9512 IgorA 795
       shl      eax,ROUND
796
       mov      .cby2,eax
797
9237 leency 798
 
9512 IgorA 799
       shl      ebx,ROUND
800
       mov      .cex2,ebx
801
9237 leency 802
 
9512 IgorA 803
       shl      edx,ROUND
804
       mov      .cey2,edx
805
9237 leency 806
 
9512 IgorA 807
       shl      eax,ROUND
808
       mov      .ctx2,eax
809
9237 leency 810
 
9512 IgorA 811
       shl      ebx,ROUND
812
       mov      .cty2,ebx
813
9237 leency 814
 
815
       call     .call_line
9512 IgorA 816
9237 leency 817
 
9512 IgorA 818
;       fxrstor [sse_repository]
819
       movups  xmm0,.cby1
9237 leency 820
       movups  xmm1,.cty1
821
       movups  xmm2,.cby2
822
       movups  xmm3,.cty2
823
       movups  xmm4,.dby13
9512 IgorA 824
       movups  xmm5,.dty13
825
       movups  xmm6,.dby23
826
       movups  xmm7,.dty23
827
       paddd   xmm0,xmm4
828
       paddd   xmm1,xmm5
829
       paddd   xmm2,xmm6
830
       paddd   xmm3,xmm7
831
    ;   push    edi
832
    ;   mov     edi,sse_repository
833
    ;   paddd   xmm0,.sdby13
834
    ;   paddd   xmm1,.sdty13
835
    ;   paddd   xmm2,.sdby12
836
    ;   paddd   xmm3,.sdty12
837
    ;   pop     edi
838
       movups  .cby1,xmm0
9237 leency 839
       movups  .cty1,xmm1
840
       movups  .cby2,xmm2
841
       movups  .cty2,xmm3
842
end if
9512 IgorA 843
9237 leency 844
 
845
 
9740 macgub 846
       movq     mm0,.cby2
9512 IgorA 847
       movq     mm1,.cby1
848
       movq     mm2,.cey2
849
       movq     mm3,.cey1
850
       movq     mm4,.cty1
851
       movq     mm5,.cty2
852
       movq     mm6,.cz1
853
       movq     mm7,.cz2
854
       paddd    mm0,.dby23
855
       paddd    mm1,.dby13
856
       paddd    mm2,.dey23
857
       paddd    mm3,.dey13
858
       paddd    mm4,.dty13
859
       paddd    mm5,.dty23
860
       paddd    mm6,.dz13
861
       paddd    mm7,.dz23
862
       movq     .cby2,mm0
863
       movq     .cby1,mm1
864
       movq     .cey2,mm2
865
       movq     .cey1,mm3
866
       movq     .cty1,mm4
867
       movq     .cty2,mm5
868
       movq     .cz1,mm6
869
       movq     .cz2,mm7
870
end if
9237 leency 871
If  Ext = NON
9512 IgorA 872
       mov      edx,.dbx13
873
       add      .cbx1,edx
874
       mov      eax,.dbx23
875
       add      .cbx2,eax
876
       mov      ebx,.dby13
877
       add      .cby1,ebx
878
       mov      edx,.dby23
879
       add      .cby2,edx
880
9237 leency 881
 
9512 IgorA 882
       add      .cex1,eax
883
       mov      ebx,.dex23
884
       add      .cex2,ebx
885
       mov      edx,.dey13
886
       add      .cey1,edx
887
       mov      eax,.dey23
888
       add      .cey2,eax
889
9237 leency 890
 
9512 IgorA 891
       add      .cx1,eax
892
       mov      ebx,.dx23
893
       add      .cx2,ebx
894
       mov      ebx,.dz13
895
       add      .cz1,ebx
896
       mov      edx,.dz23
897
       add      .cz2,edx
898
9237 leency 899
 
9512 IgorA 900
       add      .ctx1,eax
901
       mov      ebx,.dtx23
902
       add      .ctx2,ebx
903
       mov      edx,.dty13
904
       add      .cty1,edx
905
       mov      eax,.dty23
906
       add      .cty2,eax
907
end if
9237 leency 908
       inc      ecx
9512 IgorA 909
       cmp      cx,.y3
910
       jl       .loop23
911
    .loop23_done:
9237 leency 912
913
 
9512 IgorA 914
ret   50
9237 leency 915
916
 
917
918
 
919
       push     dword .cty1
9512 IgorA 920
       push     .ctx1
921
9237 leency 922
 
9512 IgorA 923
       push     dword .cty2
924
       push     .ctx2
925
9237 leency 926
 
9512 IgorA 927
9237 leency 928
 
9512 IgorA 929
       push     .cex2
930
       push     dword .cby2
931
       push     .cbx2
932
       push     dword .cey1
933
       push     .cex1
934
       push     dword .cby1
935
       push     .cbx1
936
9237 leency 937
 
938
 
9512 IgorA 939
       push     .z_buff
940
       push     .t_emap
941
       push     .t_bmap
942
9237 leency 943
 
9512 IgorA 944
945
 
946
       sar      eax,ROUND
947
       mov      ebx,.cx2
948
       sar      ebx,ROUND
949
950
 
951
952
 
9237 leency 953
9512 IgorA 954
 
9237 leency 955
bump_tex_line_z:
956
;--------------in: eax - x1
957
;--------------    ebx - x2
958
;--------------    edi - pointer to screen buffer
959
;stack - another parameters :
960
.y      equ dword [ebp+4]
9512 IgorA 961
.bmap   equ dword [ebp+8]        ; bump map pointer
962
.emap   equ dword [ebp+12]       ; env map pointer
963
.z_buff equ dword [ebp+16]       ; z buffer
964
.tex_map equ dword [ebp+20]      ; texture pointer
965
9237 leency 966
 
9512 IgorA 967
.by1    equ  [ebp+28]  ;       |
968
.ex1    equ  [ebp+32]  ;       |
969
.ey1    equ  [ebp+36]  ;       |
970
.bx2    equ  [ebp+40]  ;       |
971
.by2    equ  [ebp+44]  ;       |>   b. map and e. map coords
972
.ex2    equ  [ebp+48]  ;       |>   shifted shl ROUND
973
.ey2    equ  [ebp+52]  ;   ---
974
.z2     equ  [ebp+56]
975
.tx2    equ  [ebp+60]
976
.ty2    equ  [ebp+64]
977
.z1     equ  [ebp+68]
978
.tx1    equ  [ebp+72]
979
.ty1    equ  [ebp+76]
980
9237 leency 981
 
982
 
983
 
9512 IgorA 984
.x2     equ [ebp-8]
985
.dbx    equ [ebp-12]
986
.dby    equ [ebp-16]
987
.dex    equ [ebp-20]
988
.dey    equ [ebp-24]
989
.dz     equ [ebp-28]
990
.dtx    equ [ebp-32]
991
.dty    equ [ebp-36]
992
9237 leency 993
 
9512 IgorA 994
.cby    equ [ebp-44]
995
.cex    equ [ebp-48]
996
.cey    equ [ebp-52]
997
.cz     equ [ebp-56]
998
.czbuff equ [ebp-60]
9237 leency 999
.ctx    equ [ebp-64]
9512 IgorA 1000
.cty    equ [ebp-68]
1001
.c_scr  equ [ebp-72]
1002
9237 leency 1003
 
9512 IgorA 1004
.temp2  equ        ebp-88
1005
.temp3  equ        ebp-76
1006
.temp4  equ        ebp-84
1007
.temp5  equ        ebp-92
1008
9237 leency 1009
 
9512 IgorA 1010
9237 leency 1011
 
9512 IgorA 1012
        or      ecx,ecx
1013
        jl      .bl_end
1014
        movzx   edx,word[size_y_var]
1015
        cmp     ecx,edx  ;SIZE_Y
1016
        jge     .bl_end
1017
9237 leency 1018
 
9512 IgorA 1019
        jl      .bl_ok
1020
        je      .bl_end
1021
9237 leency 1022
 
1023
 
1024
        mov     edx,.bx1
9512 IgorA 1025
        xchg    edx,.bx2
1026
        mov     .bx1,edx
1027
        mov     edx,.by1
1028
        xchg    edx,.by2
1029
        mov     .by1,edx
1030
9237 leency 1031
 
9512 IgorA 1032
        xchg    edx,.ex2
1033
        mov     .ex1,edx
1034
        mov     edx,.ey1
1035
        xchg    edx,.ey2
1036
        mov     .ey1,edx
1037
9237 leency 1038
 
9512 IgorA 1039
        xchg    edx,.tx2
1040
        mov     .tx1,edx
1041
        mov     edx,.ty1
1042
        xchg    edx,.ty2
1043
        mov     .ty1,edx
1044
end if
9237 leency 1045
if Ext = MMX
1046
        movq    mm0,.bx1
9512 IgorA 1047
        movq    mm1,.bx2
1048
        movq    mm2,.ex1
1049
        movq    mm3,.ex2
1050
        movq    mm4,.tx1
1051
        movq    mm5,.tx2
1052
        movq    .bx2,mm0
1053
        movq    .bx1,mm1
1054
        movq    .ex1,mm3
1055
        movq    .ex2,mm2
1056
        movq    .tx1,mm5
1057
        movq    .tx2,mm4
1058
end if
9237 leency 1059
if Ext>=SSE
1060
        movups xmm0,.bx1
9512 IgorA 1061
        movups xmm1,.bx2
1062
        movups .bx1,xmm1
1063
        movups .bx2,xmm0
1064
        movq    mm0,.tx1
1065
        movq    mm1,.tx2
1066
        movq    .tx1,mm1
1067
        movq    .tx2,mm0
1068
end if
9237 leency 1069
1070
 
9512 IgorA 1071
        mov     edx,.z1
1072
        xchg    edx,.z2
1073
        mov     .z1,edx
1074
1075
 
9237 leency 1076
1077
 
9512 IgorA 1078
        push    ebx           ;store x1, x2
1079
        movzx   ebx,word[size_x_var]
1080
    ;    mov     eax,.x1
9237 leency 1081
        cmp     dword .x1,ebx  ;dword .x1,SIZE_X
9512 IgorA 1082
        jge     .bl_end
1083
        cmp     dword .x2,0
1084
        jle     .bl_end
1085
9237 leency 1086
 
9512 IgorA 1087
        sub     ebx,.x1
1088
9237 leency 1089
 
9512 IgorA 1090
       cdq
1091
       idiv     ebx
1092
       mov      ebx,eax
1093
9237 leency 1094
 
1095
 
9512 IgorA 1096
       sub      eax,.bx1
1097
       sar      eax,ROUND
1098
       imul     ebx
1099
       sar      eax,15 - ROUND
1100
       push     eax
1101
9237 leency 1102
 
1103
 
1104
 
1105
 
9512 IgorA 1106
       sub      eax,.by1
1107
       sar      eax,ROUND
1108
       imul     ebx
1109
       sar      eax,15 - ROUND
1110
       push     eax
1111
9237 leency 1112
 
1113
 
1114
 
9512 IgorA 1115
       sub      eax,.ex1
1116
       sar      eax,ROUND
1117
       imul     ebx
1118
       sar      eax,15 - ROUND
1119
       push     eax
1120
9237 leency 1121
 
1122
 
1123
 
9512 IgorA 1124
       sub      eax,.ey1
1125
       sar      eax,ROUND
1126
       imul     ebx
1127
       sar      eax,15 - ROUND
1128
       push     eax
1129
9237 leency 1130
 
1131
 
9512 IgorA 1132
       sub      eax,.z1
1133
       sar      eax,ROUND
1134
       imul     ebx
1135
       sar      eax,15 - ROUND
1136
       push     eax
1137
9237 leency 1138
 
9512 IgorA 1139
       sub      eax,.tx1
1140
       sar      eax,ROUND
1141
       imul     ebx
1142
       sar      eax,15 - ROUND
1143
       push     eax
1144
9237 leency 1145
 
1146
 
9512 IgorA 1147
       sub      eax,.ty1
1148
       sar      eax,ROUND
1149
       imul     ebx
1150
       sar      eax,15 - ROUND
1151
       push     eax
1152
9237 leency 1153
 
1154
 
9512 IgorA 1155
        jge     @f            ; CLIPPING ON FUNCTION
1156
                              ; cutting triangle exceedes screen
1157
        mov     ebx,.x1
1158
        neg     ebx
1159
9237 leency 1160
 
1161
1162
 
1163
;        shufps   xmm0,xmm0,0
1164
;        movups   xmm1,.dey
1165
;        mulps    xmm1,xmm0
1166
;        shufps   xmm1,xmm1,00011011b
1167
;        movups   xmm2,.bx1
1168
;        addps    xmm2,xmm1
1169
;        movups   .bx1,xmm2
1170
1171
 
9512 IgorA 1172
        imul    ebx           ; eax = .dz * abs(.x1)
1173
        add     .z1,eax
1174
        mov     dword .x1,0
1175
9237 leency 1176
 
9512 IgorA 1177
        imul    ebx
1178
        add    .bx1,eax
1179
9237 leency 1180
 
9512 IgorA 1181
        imul    ebx
1182
        add     .by1,eax
1183
9237 leency 1184
 
9512 IgorA 1185
        imul    ebx
1186
        add     .ex1,eax
1187
9237 leency 1188
 
9512 IgorA 1189
        imul    ebx
1190
        add     .ey1,eax
1191
9237 leency 1192
 
9512 IgorA 1193
        imul    ebx
1194
        add     .tx1,eax
1195
9237 leency 1196
 
9512 IgorA 1197
        imul    ebx
1198
        add     .ty1,eax
1199
9237 leency 1200
 
1201
   ;     mov     ebx,.x2
1202
        movzx   eax,word[size_x_var]
9512 IgorA 1203
       ; cmp     dword .x2,SIZE_X
9237 leency 1204
        cmp     dword .x2,eax  ; eax,ebx
9512 IgorA 1205
        jl      @f
1206
        mov     dword .x2,eax  ;SIZE_X
1207
      @@:
9237 leency 1208
        movzx   eax,word[size_x_var]  ;SIZE_X       ;calc memory begin in buffers
9512 IgorA 1209
        mul     .y
1210
        add     eax,.x1
1211
        lea     esi,[4*eax]
1212
        add     esi,.z_buff       ; z-buffer filled with dd variables
1213
        lea     eax,[eax*3]
1214
        add     edi,eax
1215
9237 leency 1216
 
1217
 
9512 IgorA 1218
        sub     ecx,.x1
1219
        ; init current variables
1220
        push    dword .bx1   ; current b, e and t shifted shl ROUND   .cbx
1221
        push    dword .by1                                         ;  .cby
1222
        push    dword .ex1                                         ;  .cex
1223
        push    dword .ey1                                         ;  .cey
1224
9237 leency 1225
 
9512 IgorA 1226
        push    esi                                          ; .czbuff
1227
9237 leency 1228
 
9512 IgorA 1229
        push    dword .ty1      ;         .cty
1230
        push    edi       ;         .c_scr
1231
if Ext = SSE2
9237 leency 1232
        mov    eax,TEXTURE_SIZE
9512 IgorA 1233
        movd   xmm1,eax
1234
        shufps xmm1,xmm1,0
1235
        push   dword  TEX_X
1236
        push   dword  -TEX_X
1237
        push   dword  1
1238
        push   dword  -1
1239
        movups xmm2,[esp]
1240
        movd   xmm3,.bmap
1241
        shufps xmm3,xmm3,0
1242
end if
9237 leency 1243
1244
 
1245
        movq    mm7,.cty
9512 IgorA 1246
        movq    mm6,.cby
1247
        movq    mm5,.cey
1248
;        movq    mm4,.dtyq
9237 leency 1249
;        movq    mm3,.dbyq
1250
end if
1251
1252
 
1253
    ; if TEX = SHIFTING   ;bump drawing only in shifting mode
1254
        mov     esi,.czbuff      ; .czbuff current address in buffer
9512 IgorA 1255
        mov     ebx,.cz          ; .cz - cur z position
1256
        cmp     ebx,dword[esi]
1257
        jge     .skip
1258
if Ext=NON
9237 leency 1259
        mov     eax,.cby
9512 IgorA 1260
        shr     eax,ROUND
1261
        mov     esi,.cbx
1262
        shr     esi,ROUND
1263
else
9237 leency 1264
        movq    mm1,mm6
9512 IgorA 1265
        psrld   mm1,ROUND
1266
        movd    eax,mm1
1267
        psrlq   mm1,32
1268
        movd    esi,mm1
1269
end if
9237 leency 1270
1271
 
9512 IgorA 1272
        add     esi,eax         ;-  ; esi - current bump map index
1273
9237 leency 1274
 
1275
1276
 
9512 IgorA 1277
        shufps  xmm0,xmm0,0
1278
        paddd   xmm0,xmm2
1279
        pand    xmm0,xmm1
1280
        paddd   xmm0,xmm3
1281
9237 leency 1282
 
9512 IgorA 1283
        movzx   eax,byte[ebx]
1284
;
9237 leency 1285
;        shufps  xmm0,xmm0,11100001b
1286
        psrldq  xmm0,4
9512 IgorA 1287
        movd    ebx,xmm0
1288
        movzx   ebx,byte[ebx]
1289
        sub     eax,ebx
1290
;
9237 leency 1291
;        shufps  xmm0,xmm0,11111110b
1292
        psrldq  xmm0,4
9512 IgorA 1293
        movd    ebx,xmm0
1294
        movzx   edx, byte [ebx]
1295
;
9237 leency 1296
;        shufps  xmm0,xmm0,11111111b
1297
        psrldq  xmm0,4
9512 IgorA 1298
        movd    ebx,xmm0
1299
        movzx   ebx, byte [ebx]
1300
        sub     edx,ebx
1301
;
9237 leency 1302
else
1303
;        mov     ebx,esi
1304
;        dec     ebx
1305
        lea     ebx,[esi-1]
9512 IgorA 1306
        and     ebx,TEXTURE_SIZE
1307
        add     ebx,.bmap
1308
        movzx   eax,byte [ebx]
1309
9237 leency 1310
 
1311
;        inc     ebx
1312
        lea     ebx,[esi+1]
9512 IgorA 1313
        and     ebx,TEXTURE_SIZE
1314
        add     ebx,.bmap
1315
        movzx   ebx,byte [ebx]
1316
        sub     eax,ebx
1317
9237 leency 1318
 
1319
;        sub     ebx,TEX_X
1320
        lea     ebx,[esi-TEX_X]
9512 IgorA 1321
        and     ebx,TEXTURE_SIZE
1322
        add     ebx,.bmap
1323
        movzx   edx,byte [ebx]
1324
9237 leency 1325
 
1326
;        add     ebx,TEX_X
1327
        lea     ebx,[esi+TEX_X]
9512 IgorA 1328
        and     ebx,TEXTURE_SIZE
1329
        add     ebx,.bmap
1330
        movzx   ebx,byte [ebx]
1331
        sub     edx,ebx
1332
end if
9237 leency 1333
1334
 
1335
     ;  edx - vertical   sub    modificated y coord
1336
if Ext=NON
1337
        mov     ebx,.cex       ;.cex - current env map X
9512 IgorA 1338
        shr     ebx,ROUND
1339
        add     eax,ebx
1340
9237 leency 1341
 
1342
 
9512 IgorA 1343
        shr     ebx,ROUND
1344
        add     edx,ebx
1345
9237 leency 1346
 
1347
        movq    mm1,mm5        ; mm5 - copy of cur env coords
9512 IgorA 1348
        psrld   mm1,ROUND
1349
        movd    ebx,mm1
1350
        psrlq   mm1,32
1351
        add     eax,ebx
1352
        movd    ebx,mm1
1353
        add     edx,ebx
1354
;        movq    qword[.temp1],mm3
9237 leency 1355
;        add     eax,dword [.temp1]
1356
;        add     edx,dword [.temp1+4]
1357
end if
1358
1359
 
9512 IgorA 1360
        jl      .black
1361
        cmp     eax,TEX_X
1362
        jg      .black
1363
        or      edx,edx
1364
        jl      .black
1365
        cmp     edx,TEX_Y
1366
        jg      .black
1367
9237 leency 1368
 
9512 IgorA 1369
        add     edx,eax         ; proponuje nie stawiac czarnego pixela tylko
1370
        lea     esi,[edx*3]     ; niezaburzony.
1371
        add     esi,.emap       ;
1372
        lodsd
1373
9237 leency 1374
 
1375
        mov     edx,.cty
9512 IgorA 1376
        shr     edx,ROUND  ; sar
1377
9237 leency 1378
 
9512 IgorA 1379
        shr     edi,ROUND  ; sar
1380
else
9237 leency 1381
        movq    mm1,mm7
9512 IgorA 1382
        psrld   mm1,ROUND
1383
        movd    edx,mm1
1384
        psrlq   mm1,32
1385
        movd    edi,mm1
1386
9237 leency 1387
 
1388
1389
 
9512 IgorA 1390
        add     edi,edx
1391
        and     edi,TEXTURE_SIZE
1392
        lea     esi,[edi*3]
1393
        add     esi,.tex_map
1394
9237 leency 1395
 
1396
        mov     edx,eax
9512 IgorA 1397
        lodsd
1398
        push    ax
1399
        mul     dl
1400
        mov     dl,ah
1401
        pop     ax
1402
        shr     ax,8
1403
        mul     dh
1404
        mov     al,dl
1405
        mov     edi,.c_scr
1406
        stosw
1407
        shr     edx,16
1408
        shr     eax,16
1409
        mul     dl
1410
        shr     ax,8
1411
        stosb
1412
else
9237 leency 1413
        movd       mm0,eax
9512 IgorA 1414
        pxor       mm1,mm1
1415
        punpcklbw  mm0,mm1
1416
        movd       mm2,[esi]
1417
        punpcklbw  mm2,mm1
1418
        pmullw     mm0,mm2
1419
        psrlw      mm0,8
1420
        packuswb   mm0,mm1
1421
        mov        edi,.c_scr
1422
        movd       [edi],mm0
1423
9237 leency 1424
 
1425
1426
 
9512 IgorA 1427
     @@:
9237 leency 1428
     .black:
1429
        xor     eax,eax
9512 IgorA 1430
        mov     edi,.c_scr
1431
        stosd
1432
     .actual_zbuff:
9237 leency 1433
        mov     eax,.cz
9512 IgorA 1434
        mov     edi,.czbuff
1435
        stosd
1436
9237 leency 1437
 
1438
        add     dword .czbuff,4
9512 IgorA 1439
        add     dword .c_scr,3
1440
9237 leency 1441
 
1442
        mov     eax,.dbx
9512 IgorA 1443
        add     .cbx,eax
1444
        mov     ebx,.dby
1445
        add     .cby,ebx
1446
9237 leency 1447
 
9512 IgorA 1448
        add     .cex,edx
1449
        mov     eax,.dey
1450
        add     .cey,eax
1451
9237 leency 1452
 
9512 IgorA 1453
        add     .ctx,ebx
1454
        mov     edx,.dty
1455
        add     .cty,edx
1456
9237 leency 1457
 
1458
        paddd   mm7,.dty
9512 IgorA 1459
        paddd   mm6,.dby
1460
        paddd   mm5,.dey
1461
end if
9237 leency 1462
        mov     eax,.dz
9512 IgorA 1463
        add     .cz,eax
1464
9237 leency 1465
 
9512 IgorA 1466
        jnz     .draw
1467
9237 leency 1468
 
1469
        mov     esp,ebp
9512 IgorA 1470
ret 76
9237 leency 1471