Subversion Repositories Kolibri OS

Rev

Rev 1979 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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