Subversion Repositories Kolibri OS

Rev

Rev 7788 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7788 Rev 8014
Line 310... Line 310...
310
	call	 alloc_mem_for_tp
310
        call     alloc_mem_for_tp
311
	mov	 [re_alloc_flag],0
311
        mov      [re_alloc_flag],0
312
     end if
312
     end if
313
	mov	 bl,[generator_flag]
313
        mov      bl,[generator_flag]
314
	or	 bl,bl
314
       ; or       bl,bl
315
	jz	 .next_m2
315
       ; jz       .next_m2
316
	cmp	 bl,1
316
        cmp      bl,1
317
	jne	 @f
317
        jne      @f
318
	call	 generate_object
318
        call     generate_object
319
	jmp	 .calc_norm
319
        jmp      .calc_norm
320
      @@:
320
      @@:
321
	cmp	 bl,4
321
        cmp      bl,4
Line 490... Line 490...
490
    push eax
490
    push eax
491
	mov	esi,[points_normals_ptr]
491
        mov     esi,[points_normals_ptr]
492
	mov	edi,[points_normals_rot_ptr]
492
        mov     edi,[points_normals_rot_ptr]
493
	mov	ebx,matrix
493
        mov     ebx,matrix
494
	movzx	ecx,[points_count_var]
494
        mov     ecx,[points_count_var]
495
	call	rotary
495
        call    rotary
496
 
496
 
Line 497... Line 497...
497
	mov	esi,matrix
497
        mov     esi,matrix
498
	call	add_scale_to_matrix
498
        call    add_scale_to_matrix
Line 499... Line 499...
499
 
499
 
500
	mov	esi,[points_ptr]
500
        mov     esi,[points_ptr]
501
	mov	edi,[points_rotated_ptr]
501
        mov     edi,[points_rotated_ptr]
502
	mov	ebx,matrix
502
        mov     ebx,matrix
503
	movzx	ecx,[points_count_var]
503
        mov     ecx,[points_count_var]
Line 504... Line 504...
504
	call	rotary
504
        call    rotary
505
 
505
 
506
;    RDTSC
506
;    RDTSC
507
;    pop    ebx
507
;    pop    ebx
508
;    sub    eax,ebx
508
;    sub    eax,ebx
Line 509... Line 509...
509
;    sub    eax,41
509
;    sub    eax,41
510
;    push   eax
510
;    push   eax
511
 
511
 
512
	mov	esi,[points_rotated_ptr]
512
        mov     esi,[points_rotated_ptr]
Line 513... Line 513...
513
	mov	edi,[points_translated_ptr]
513
        mov     edi,[points_translated_ptr]
514
	movzx	ecx,[points_count_var]
514
        mov     ecx,[points_count_var]
515
	call	translate_points
515
        call    translate_points
516
 
516
 
517
;	 cmp	 [dr_flag],5
517
;        cmp     [dr_flag],5
518
;	 jne	 @f
518
;        jne     @f
519
;	 call	 calc_attenuation_light
519
;        call    calc_attenuation_light
520
;     @@:
520
;     @@:
521
	cmp	[fire_flag],0
521
        cmp     [fire_flag],0
522
	jne	@f
522
        jne     @f
523
	call	clrscr		; clear the screen
523
        call    clrscr          ; clear the screen
524
     @@:
524
     @@:
525
	cmp	[catmull_flag],1  ;non sort if Catmull = on
525
    ;    cmp     [catmull_flag],1  ;non sort if Catmull = on
526
	je	.no_sort
526
    ;    je      .no_sort
527
	call	sort_triangles
527
    ; 64 indexes    call    sort_triangles
528
      .no_sort:
528
      .no_sort:
Line 747... Line 747...
747
 
747
 
Line 748... Line 748...
748
;--------------------------------------------------------------------------------
748
;--------------------------------------------------------------------------------
749
;-------------------------PROCEDURES---------------------------------------------
749
;-------------------------PROCEDURES---------------------------------------------
750
;--------------------------------------------------------------------------------
750
;--------------------------------------------------------------------------------
751
include "TEX3.INC"
751
;include "TEX3.INC"
752
include "FLAT_CAT.INC"
752
include "FLAT_CAT.INC"
753
include "TEX_CAT.INC"
753
include "TEX_CAT.INC"
754
include "BUMP_CAT.INC"
754
include "BUMP_CAT.INC"
755
include "3DMATH.INC"
755
include "3DMATH.INC"
756
include "GRD_LINE.INC"
756
include "GRD_LINE.INC"
757
include "GRD3.INC"
757
;include "GRD3.INC"
758
include "FLAT3.INC"
758
;include "FLAT3.INC"
759
include "BUMP3.INC"
759
;include "BUMP3.INC"
760
include "B_PROCS.INC"
760
include "B_PROCS.INC"
761
include "A_PROCS.INC"
761
include "A_PROCS.INC"
762
include "GRD_CAT.INC"
762
include "GRD_CAT.INC"
763
include "BUMP_TEX.INC"
763
include "BUMP_TEX.INC"
764
include "GRD_TEX.INC"
764
include "GRD_TEX.INC"
Line 1100... Line 1100...
1100
      fldpi
1100
      fldpi
1101
      fadd	st,st
1101
      fadd      st,st
1102
      mov	esi,[points_ptr]
1102
      mov       esi,[points_ptr]
1103
      mov	edi,tex_points
1103
      mov       edi,tex_points
1104
      movzx	ecx,[points_count_var]
1104
      mov       ecx,[points_count_var]
1105
      inc	ecx
1105
      inc       ecx
1106
;      cmp	 [map_tex_flag],1
1106
;      cmp       [map_tex_flag],1
1107
;      jne	 .cylindric
1107
;      jne       .cylindric
1108
      ; spherical mapping around y axle
1108
      ; spherical mapping around y axle
1109
 
1109
 
Line 1420... Line 1420...
1420
	mov	ebp,triangles
1420
        mov     ebp,triangles
1421
     @@:
1421
     @@:
1422
	push	ebx
1422
        push    ebx
1423
	mov	ebx,vectors
1423
        mov     ebx,vectors
1424
	movzx	esi,word[ebp]	       ; first point index
1424
        mov     esi,dword[ebp]              ; first point index
1425
	lea	esi,[esi*3]
1425
        lea     esi,[esi*3]
1426
	lea	esi,[points+esi*2]     ; esi - pointer to 1st 3d point
1426
        lea     esi,[points+esi*2]     ; esi - pointer to 1st 3d point
1427
	movzx	edi,word[ebp+2]        ; second point index
1427
        movzx   edi,dword[ebp+4]        ; second point index
1428
	lea	edi,[edi*3]
1428
        lea     edi,[edi*3]
1429
	lea	edi,[points+edi*2]     ; edi - pointer to 2nd 3d point
1429
        lea     edi,[points+edi*2]     ; edi - pointer to 2nd 3d point
1430
	call	make_vector
1430
        call    make_vector
1431
	add	ebx,12
1431
        add     ebx,12
1432
	mov	esi,edi
1432
        mov     esi,edi
1433
	movzx	edi,word[ebp+4]        ; third point index
1433
        movzx   edi,dword[ebp+8]        ; third point index
1434
	lea	edi,[edi*3]
1434
        lea     edi,[edi*3]
1435
	lea	edi,[points+edi*2]
1435
        lea     edi,[points+edi*2]
1436
	call	make_vector
1436
        call    make_vector
1437
	mov	edi,ebx 		; edi - pointer to 2nd vector
1437
        mov     edi,ebx                 ; edi - pointer to 2nd vector
1438
	mov	esi,ebx
1438
        mov     esi,ebx
1439
	sub	esi,12			; esi - pointer to 1st vector
1439
        sub     esi,12                  ; esi - pointer to 1st vector
1440
	pop	ebx
1440
        pop     ebx
1441
	call	cross_product
1441
        call    cross_product
1442
	mov	edi,ebx
1442
        mov     edi,ebx
1443
	call	normalize_vector
1443
        call    normalize_vector
1444
	add	ebp,6
1444
        add     ebp,12
1445
	add	ebx,12
1445
        add     ebx,12
1446
	cmp	dword[ebp],-1
1446
        cmp     dword[ebp],-1
1447
	jne	@b
1447
        jne     @b
1448
ret
1448
ret
1449
end if
1449
end if
1450
init_point_normals:
1450
 
-
 
1451
init_point_normals:
1451
.x equ dword [ebp-4]
1452
.x equ dword [ebp-4]
1452
.y equ dword [ebp-8]
1453
.y equ dword [ebp-8]
1453
.z equ dword [ebp-12]
1454
.z equ dword [ebp-12]
1454
.point_number equ word [ebp-26]
1455
.point_number equ dword [ebp-28]
1455
.hit_faces    equ word [ebp-28]
1456
.hit_faces    equ dword [ebp-32]
1456
 
1457
 
Line 1457... Line 1458...
1457
	fninit
1458
        fninit
1458
	mov	  ebp,esp
1459
        mov       ebp,esp
1459
	sub	  esp,28
1460
        sub       esp,32
1460
	mov	  edi,[points_normals_ptr]
1461
        mov       edi,[points_normals_ptr]
1461
	mov	  .point_number,0
1462
        mov       .point_number,0
1462
    .ipn_loop:
1463
    .ipn_loop:
1463
	mov	  .hit_faces,0
1464
        mov       .hit_faces,0
1464
	mov	  .x,0
1465
        mov       .x,0
Line 1468... Line 1469...
1468
	xor	  ecx,ecx	       ; ecx - triangle number
1469
        xor       ecx,ecx              ; ecx - triangle number
1469
    .ipn_check_face:
1470
    .ipn_check_face:
1470
	xor	  ebx,ebx	       ; ebx - 'position' in one triangle
1471
        xor       ebx,ebx              ; ebx - 'position' in one triangle
1471
    .ipn_check_vertex:
1472
    .ipn_check_vertex:
1472
	movzx	  eax,word[esi+ebx]    ;  eax - point_number
1473
        mov       eax,dword[esi+ebx]    ;  eax - point_number
1473
	cmp	  ax,.point_number
1474
        cmp       eax,.point_number
1474
	jne	  .ipn_next_vertex
1475
        jne       .ipn_next_vertex
1475
	push	  esi
1476
        push      esi
1476
	mov	  esi,ecx
1477
        mov       esi,ecx
1477
	lea	  esi,[esi*3]
1478
        lea       esi,[esi*3]
1478
       ; lea	   esi,[triangles_normals+esi*4]
1479
       ; lea       esi,[triangles_normals+esi*4]
1479
	shl	  esi,2
1480
        shl       esi,2
Line 1491... Line 1492...
1491
	pop	  esi
1492
        pop       esi
1492
	inc	  .hit_faces
1493
        inc       .hit_faces
1493
	jmp	  .ipn_next_face
1494
        jmp       .ipn_next_face
1494
    .ipn_next_vertex:
1495
    .ipn_next_vertex:
1495
	add	  ebx,2
1496
        add       ebx,4
1496
	cmp	  ebx,6
1497
        cmp       ebx,12
1497
	jne	  .ipn_check_vertex
1498
        jne       .ipn_check_vertex
1498
    .ipn_next_face:
1499
    .ipn_next_face:
1499
	add	  esi,6
1500
        add       esi,12
1500
	inc	  ecx
1501
        inc       ecx
1501
	cmp	  cx,[triangles_count_var]
1502
        cmp       ecx,[triangles_count_var]
1502
	jne	  .ipn_check_face
1503
        jne       .ipn_check_face
1503
 
1504
 
Line 1504... Line 1505...
1504
	fld	  .x
1505
        fld       .x
1505
	fidiv	  .hit_faces
1506
        fidiv     .hit_faces
1506
	fstp	  dword[edi+vec_x]
1507
        fstp      dword[edi+vec_x]
Line 1512... Line 1513...
1512
	fstp	  dword[edi+vec_z]
1513
        fstp      dword[edi+vec_z]
1513
	call	  normalize_vector
1514
        call      normalize_vector
1514
	add	  edi,12  ;type vector 3d
1515
        add       edi,12  ;type vector 3d
1515
	inc	  .point_number
1516
        inc       .point_number
1516
	mov	  dx,.point_number
1517
        mov       edx,.point_number
1517
	cmp	  dx,[points_count_var]
1518
        cmp       edx,[points_count_var]
1518
	jne	  .ipn_loop
1519
        jne       .ipn_loop
1519
 
1520
 
Line 1520... Line 1521...
1520
	mov	  esp,ebp
1521
        mov       esp,ebp
1521
ret
1522
ret
1522
;===============================================================
1523
;===============================================================
Line 1523... Line 1524...
1523
 
1524
 
1524
init_triangles_normals2:
1525
init_triangles_normals2:
1525
	mov	ebx,[triangles_normals_ptr]
1526
        mov     ebx,[triangles_normals_ptr]
-
 
1527
        mov     ebp,[triangles_ptr]
1526
	mov	ebp,[triangles_ptr]
1528
        mov     ecx,[triangles_count_var]
-
 
1529
     @@:
1527
     @@:
1530
        push    ecx
1528
	push	ebx
1531
        push    ebx
1529
	mov	ebx,vectors
1532
        mov     ebx,vectors
1530
	movzx	esi,word[ebp]	       ; first point index
1533
        mov     esi,dword[ebp]          ; first point index
1531
	lea	esi,[esi*3]
1534
        lea     esi,[esi*3]
1532
;	 lea	 esi,[points+esi*2]	; esi - pointer to 1st 3d point
1535
;        lea     esi,[points+esi*2]     ; esi - pointer to 1st 3d point
1533
	shl	esi,2
1536
        shl     esi,2
1534
	add	esi,[points_ptr]
1537
        add     esi,[points_ptr]
1535
	movzx	edi,word[ebp+2] 	 ; first point index
1538
        mov     edi,dword[ebp+4]          ; first point index
1536
	lea	edi,[edi*3]
1539
        lea     edi,[edi*3]
1537
	shl	edi,2
1540
        shl     edi,2
1538
	add	edi,[points_ptr]
1541
        add     edi,[points_ptr]
1539
;	 movzx	 edi,word[ebp+2]	; second point index
1542
;        movzx   edi,word[ebp+2]        ; second point index
1540
;	 lea	 edi,[edi*3]
1543
;        lea     edi,[edi*3]
1541
;	 lea	 edi,[points+edi*2]	; edi - pointer to 2nd 3d point
1544
;        lea     edi,[points+edi*2]     ; edi - pointer to 2nd 3d point
1542
	call	make_vector_r
1545
        call    make_vector_r
1543
	add	ebx,12
1546
        add     ebx,12
1544
	mov	esi,edi
1547
        mov     esi,edi
1545
	movzx	edi,word[ebp+4]        ; third point index
1548
        mov     edi,dword[ebp+8]        ; third point index
1546
	lea	edi,[edi*3]
1549
        lea     edi,[edi*3]
1547
	shl	edi,2
1550
        shl     edi,2
1548
	add	edi,[points_ptr]
1551
        add     edi,[points_ptr]
1549
;	 lea	 edi,[points+edi*2]
1552
;        lea     edi,[points+edi*2]
Line 1554... Line 1557...
1554
	pop	ebx
1557
        pop     ebx
1555
	call	cross_product
1558
        call    cross_product
1556
	mov	edi,ebx
1559
        mov     edi,ebx
1557
	call	normalize_vector
1560
        call    normalize_vector
1558
	add	ebp,6
1561
        add     ebp,12
1559
	add	ebx,12
1562
        add     ebx,12
1560
	cmp	dword[ebp],-1
1563
        pop     ecx
-
 
1564
        sub     ecx,1
-
 
1565
        jnz     @b
-
 
1566
       ; cmp     dword[ebp],-1
1561
	jne	@b
1567
       ; jne     @b
1562
ret
1568
ret
1563
 
1569
if 0 ; ind 64 but
1564
 
-
 
-
 
1570
 
Line 1565... Line 1571...
1565
;=================================================================
1571
;=================================================================
1566
sort_triangles:
1572
sort_triangles:
1567
	mov	esi,[triangles_ptr]
1573
        mov     esi,[triangles_ptr]
1568
	mov	edi,triangles_with_z
1574
        mov     edi,triangles_with_z
Line 1871... Line 1877...
1871
;	 emms
1877
;        emms
1872
;      end if
1878
;      end if
1873
	movsd  ; copy end mark too
1879
        movsd  ; copy end mark too
1874
ret
1880
ret
1875
 
1881
end if ; 64 ind
1876
clrscr:
1882
clrscr:
1877
	mov	edi,[screen_ptr]
1883
        mov     edi,[screen_ptr]
1878
	movzx	ecx,word[size_x_var]
1884
        movzx   ecx,word[size_x_var]
1879
	movzx	eax,word[size_y_var]
1885
        movzx   eax,word[size_y_var]
1880
	imul	ecx,eax
1886
        imul    ecx,eax
1881
	lea	ecx,[ecx*3]
1887
        lea     ecx,[ecx*3]
Line 1935... Line 1941...
1935
 
1941
 
1936
 
1942
 
-
 
1943
        mov esi,[triangles_ptr]
1937
	mov esi,[triangles_ptr]
1944
        mov [edges_counter],0
-
 
1945
        mov ecx,[triangles_count_var]
1938
	mov [edges_counter],0
1946
    .again_dts:
1939
    .again_dts:
1947
        push    ecx
1940
	mov ebp,[points_translated_ptr]
1948
        mov     ebp,[points_translated_ptr]
1941
      if Ext=NON
1949
      if Ext >= SSE2
1942
	movzx	eax,word[esi]
1950
        mov     eax,dword[esi]
1943
	mov	[point_index1],ax
1951
        mov     [point_index1],eax
1944
	lea	eax,[eax*3]
1952
        lea     eax,[eax*3]
1945
	add	eax,eax
1953
        add     eax,eax
1946
	push	ebp
1954
        push    ebp
1947
	add	ebp,eax
1955
        add     ebp,eax
1948
	mov	eax,[ebp]
1956
        mov     eax,[ebp]
1949
	cmp	[vertex_edit_no],0
1957
   ;     cmp     [vertex_edit_no],0
1950
	jne	@f
1958
   ;     jne     @f
1951
 
1959
   ;
1952
      @@:
1960
   ;   @@:
1953
	mov	dword[xx1],eax
1961
        mov     dword[xx1],eax
-
 
1962
        mov     eax,[ebp+4]
1954
	mov	eax,[ebp+4]
1963
        mov     [zz1],ax
Line 1955... Line 1964...
1955
	mov	[zz1],ax
1964
 
1956
	pop	ebp
1965
        pop     ebp
1957
 
1966
 
1958
 
1967
 
1959
	movzx	eax,word[esi+2]
1968
        mov     eax,dword[esi+4]
1960
	mov	[point_index2],ax
1969
        mov     [point_index2],eax
1961
	lea	eax,[eax*3]
1970
        lea     eax,[eax*3]
Line 1968... Line 1977...
1968
	mov	[zz2],ax
1977
        mov     [zz2],ax
1969
	pop	ebp
1978
        pop     ebp
1970
 
1979
 
Line 1971... Line 1980...
1971
 
1980
 
1972
	movzx	eax,word[esi+4]        ; xyz3 = [ebp+[esi+4]*6]
1981
        mov     eax,dword[esi+8]        ; xyz3 = [ebp+[esi+4]*6]
1973
	mov	[point_index3],ax
1982
        mov     [point_index3],eax
1974
	lea	eax,[eax*3]
1983
        lea     eax,[eax*3]
1975
	add	eax,eax
1984
        add     eax,eax
1976
    ;	 push	 ebp
1985
    ;    push    ebp
1977
	add	ebp,eax
1986
        add     ebp,eax
1978
	mov	eax,[ebp]
1987
        mov     eax,[ebp]
1979
	mov	dword[xx3],eax
1988
        mov     dword[xx3],eax
1980
	mov	eax,[ebp+4]
1989
        mov     eax,[ebp+4]
1981
	mov	[zz3],ax
1990
        mov     [zz3],ax
1982
      else
1991
      else
1983
	mov	eax,dword[esi]		 ; don't know MMX
1992
        movq    mm0,[esi]           ; don't know MMX
1984
	mov	dword[point_index1],eax
1993
        mov     qword[point_index1],mm0
1985
       ; shr	 eax,16
1994
       ; shr     eax,16
1986
       ; mov	 [point_index2],ax
1995
       ; mov     [point_index2],ax
1987
	mov	ax,word[esi+4]
1996
        mov     eax,dword[esi+8]
1988
	mov	[point_index3],ax
1997
        mov     [point_index3],eax
-
 
1998
        movdqu  xmm0,[esi]
1989
	movq	mm0,[esi]
1999
        paddd   xmm0,xmm0
-
 
2000
        movdqa  xmm1,xmm0
-
 
2001
        paddd   xmm0,xmm0
1990
	pmullw	mm0,qword[const6]
2002
        paddd   xmm0,xmm1
1991
	movd	eax,mm0
2003
        movd    eax,xmm0
1992
	psrlq	mm0,16
2004
        psrldq  xmm0,4
1993
	movd	ebx,mm0
2005
        movd    ebx,xmm0
1994
	psrlq	mm0,16
2006
        psrldq  xmm0,4
1995
	movd	ecx,mm0
2007
        movd    ecx,xmm0
1996
	and	eax,0FFFFh
2008
        and     eax,0FFFFh
1997
	and	ebx,0FFFFh
2009
        and     ebx,0FFFFh
1998
	and	ecx,0FFFFh
2010
        and     ecx,0FFFFh
1999
	movq	mm0,[ebp+eax]
2011
        movq    mm0,[ebp+eax]
Line 2048... Line 2060...
2048
	jne	.no_culling
2060
        jne     .no_culling
2049
	mov	esi,point_index1	  ; *********************************
2061
        mov     esi,point_index1          ; *********************************
2050
	mov	ecx,3			  ;
2062
        mov     ecx,3                     ;
2051
      @@:
2063
      @@:
2052
	movzx	eax,word[esi]
2064
        mov     eax,dword[esi]
2053
	lea	eax,[eax*3]
2065
        lea     eax,[eax*3]
2054
	shl	eax,2
2066
        shl     eax,2
2055
	add	eax,[points_normals_rot_ptr]
2067
        add     eax,[points_normals_rot_ptr]
2056
;	 lea	 eax,[eax+point_normals_rotated]
2068
;        lea     eax,[eax+point_normals_rotated]
2057
	fld	dword[eax+8]		 ; *****************************
2069
        fld     dword[eax+8]             ; *****************************
2058
	ftst				 ; CHECKING OF Z COOFICIENT OF
2070
        ftst                             ; CHECKING OF Z COOFICIENT OF
Line 2088... Line 2100...
2088
				      ; ****************
2100
                                      ; ****************
2089
	mov	esi,point_index3      ; do Gouraud shading
2101
        mov     esi,point_index3      ; do Gouraud shading
2090
	mov	ecx,3
2102
        mov     ecx,3
2091
      .again_grd_draw:
2103
      .again_grd_draw:
2092
	movzx	eax,word[esi]
2104
        mov     eax,dword[esi]
2093
	shl	eax,2
2105
        shl     eax,2
2094
	lea	eax,[eax*3]
2106
        lea     eax,[eax*3]
2095
	add	eax,[points_normals_rot_ptr]
2107
        add     eax,[points_normals_rot_ptr]
2096
	; texture x=(rotated point normal -> x * 255)+255
2108
        ; texture x=(rotated point normal -> x * 255)+255
2097
	fld	dword[eax]	 ; x cooficient of normal vector
2109
        fld     dword[eax]       ; x cooficient of normal vector
2098
	fimul	[correct_tex]
2110
        fimul   [correct_tex]
Line 2109... Line 2121...
2109
	shl	 eax,TEX_SHIFT
2121
        shl      eax,TEX_SHIFT
2110
	add	 eax,ebx
2122
        add      eax,ebx
2111
	lea	 eax,[eax*3+color_map]
2123
        lea      eax,[eax*3+color_map]
2112
	mov	 eax,dword[eax]
2124
        mov      eax,dword[eax]
2113
	cmp	[catmull_flag],1      ; put on stack z coordinate if necessary
2125
     ;   cmp     [catmull_flag],1      ; put on stack z coordinate if necessary
2114
	jne	 @f
2126
     ;   jne      @f
2115
	lea	 edx,[ecx*3]
2127
        lea      edx,[ecx*3]
2116
	push	 word[edx*2+xx1-2]    ; zz1 ,2 ,3
2128
        push     word[edx*2+xx1-2]    ; zz1 ,2 ,3
2117
      @@:
2129
     ; @@:
2118
	ror	 eax,16 	      ; eax -0xxxrrggbb -> 0xggbbxxrr
2130
        ror      eax,16               ; eax -0xxxrrggbb -> 0xggbbxxrr
2119
	xor	 ah,ah
2131
        xor      ah,ah
2120
	push	 ax	    ;r
2132
        push     ax         ;r
2121
	rol	 eax,8		      ; eax-0xggbb00rr -> 0xbb00rrgg
2133
        rol      eax,8                ; eax-0xggbb00rr -> 0xbb00rrgg
2122
	xor	 ah,ah
2134
        xor      ah,ah
2123
	push	 ax	    ;g
2135
        push     ax         ;g
2124
	shr	 eax,24
2136
        shr      eax,24
2125
	push	 ax	    ;b
2137
        push     ax         ;b
2126
 
2138
 
Line 2127... Line 2139...
2127
	sub	 esi,2
2139
        sub      esi,4
2128
	dec	 cx
2140
        dec      cx
2129
	jnz	 .again_grd_draw
2141
        jnz      .again_grd_draw
2130
	jmp	 .both_draw
2142
        jmp      .both_draw
Line 2131... Line 2143...
2131
 
2143
 
Line 2177... Line 2189...
2177
	and	 eax,ebx
2189
        and      eax,ebx
2178
	push	 eax
2190
        push     eax
2179
	neg	 al
2191
        neg      al
2180
	push	 ax
2192
        push     ax
2181
	cmp	[catmull_flag],1
2193
     ;   cmp     [catmull_flag],1
2182
	jne	 @f
2194
     ;   jne      @f
2183
	push	 [zz2]
2195
        push     [zz2]
2184
      @@:
2196
     ; @@:
2185
	mov	 eax,dword[yy2]
2197
        mov      eax,dword[yy2]
2186
	and	 eax,ebx
2198
        and      eax,ebx
2187
	push	 eax
2199
        push     eax
2188
	neg	 al
2200
        neg      al
2189
	push	 ax
2201
        push     ax
2190
	cmp	[catmull_flag],1
2202
      ;  cmp     [catmull_flag],1
2191
	jne	 @f
2203
      ;  jne      @f
2192
	push	 [zz1]
2204
        push     [zz1]
2193
      @@:
2205
    ;  @@:
2194
	mov	 eax,dword[yy1]
2206
        mov      eax,dword[yy1]
2195
	and	 eax,ebx
2207
        and      eax,ebx
2196
	push	 eax
2208
        push     eax
2197
	neg	 al
2209
        neg      al
2198
	push	 ax
2210
        push     ax
2199
    .both_draw:
2211
    .both_draw:
Line 2203... Line 2215...
2203
	ror	ebx,16
2215
        ror     ebx,16
2204
	mov	ecx,dword[xx3]
2216
        mov     ecx,dword[xx3]
2205
	ror	ecx,16
2217
        ror     ecx,16
2206
	mov	edi,[screen_ptr]
2218
        mov     edi,[screen_ptr]
2207
	cmp	[catmull_flag],0
2219
  ;      cmp     [catmull_flag],0
2208
	je	@f
2220
  ;      je      @f
2209
  ;	 lea	 esi,[Z_buffer]
-
 
2210
	mov	esi,[Zbuffer_ptr]
2221
        mov     esi,[Zbuffer_ptr]
2211
	call	gouraud_triangle_z
2222
        call    gouraud_triangle_z
2212
	jmp	.end_draw
2223
     ;   jmp     .end_draw
2213
       @@:
2224
     ;  @@:
2214
	call	gouraud_triangle
2225
     ;   call    gouraud_triangle
2215
	jmp	.end_draw
2226
        jmp     .end_draw
2216
 
2227
 
Line 2217... Line 2228...
2217
     .flat_draw:		     ;**************************
2228
     .flat_draw:                     ;**************************
2218
				     ; FLAT DRAWING
2229
                                     ; FLAT DRAWING
2219
	movzx	eax,[point_index1]
2230
        mov     eax,[point_index1]
2220
	movzx	ebx,[point_index2]
2231
        mov     ebx,[point_index2]
2221
	movzx	ecx,[point_index3]
2232
        mov     ecx,[point_index3]
2222
	shl	eax,2
2233
        shl     eax,2
2223
	shl	ebx,2
2234
        shl     ebx,2
2224
	shl	ecx,2
2235
        shl     ecx,2
2225
	lea	eax,[eax*3]  ;+point_normals_rotated]
2236
        lea     eax,[eax*3]  ;+point_normals_rotated]
2226
	add	eax,[points_normals_rot_ptr]
2237
        add     eax,[points_normals_rot_ptr]
Line 2244... Line 2255...
2244
	fistp	dword[esp-8]   ;  y
2255
        fistp   dword[esp-8]   ;  y
2245
	mov	edx,dword[esp-8]
2256
        mov     edx,dword[esp-8]
2246
	shl	edx,TEX_SHIFT
2257
        shl     edx,TEX_SHIFT
2247
	add	edx,dword[esp-4]
2258
        add     edx,dword[esp-4]
2248
	lea	eax,[3*edx+color_map]
2259
        lea     eax,[3*edx]
-
 
2260
        add     eax,color_map
2249
	mov	edx,dword[eax]
2261
        mov     edx,dword[eax]
2250
 
2262
 
Line 2251... Line 2263...
2251
	and	edx,0x00ffffff	  ; edx = 0x00rrggbb
2263
        and     edx,0x00ffffff    ; edx = 0x00rrggbb
Line 2269... Line 2281...
2269
	mov	ebx,dword[xx2]
2281
        mov     ebx,dword[xx2]
2270
	ror	ebx,16
2282
        ror     ebx,16
2271
	mov	ecx,dword[xx3]
2283
        mov     ecx,dword[xx3]
2272
	ror	ecx,16
2284
        ror     ecx,16
2273
       ; mov	 edi,screen
2285
        mov     edi,[screen_ptr]
2274
	mov	edi,[screen_ptr]
-
 
2275
	cmp	[catmull_flag],0
2286
  ;      cmp     [catmull_flag],0
2276
	je	@f
2287
  ;      je      @f
2277
   ;	 lea	 esi,[Z_buffer]
-
 
2278
	mov	esi,[Zbuffer_ptr]
2288
        mov     esi,[Zbuffer_ptr]
2279
	push	word[zz3]
2289
        push    word[zz3]
2280
	push	word[zz2]
2290
        push    word[zz2]
2281
	push	word[zz1]
2291
        push    word[zz1]
2282
	call	flat_triangle_z
2292
        call    flat_triangle_z
2283
	jmp	.end_draw
2293
        jmp     .end_draw
2284
      @@:
2294
  ;    @@:
2285
	call	draw_triangle
2295
  ;      call    draw_triangle
2286
	jmp	.end_draw
2296
  ;      jmp     .end_draw
2287
      .env_mapping:
2297
      .env_mapping:
2288
       ; fninit
2298
       ; fninit
2289
	cmp	[catmull_flag],0
2299
   ;     cmp     [catmull_flag],0
2290
	je	@f
2300
   ;     je      @f
2291
	push	[zz3]
2301
        push    [zz3]
2292
	push	[zz2]
2302
        push    [zz2]
2293
	push	[zz1]
2303
        push    [zz1]
2294
      @@:
2304
    ;  @@:
2295
	mov	esi,point_index1
2305
        mov     esi,point_index1
2296
	sub	esp,12
2306
        sub     esp,12
2297
	mov	edi,esp
2307
        mov     edi,esp
2298
	mov	ecx,3
2308
        mov     ecx,3
2299
      @@:
2309
      @@:
2300
	movzx	eax,word[esi]
2310
        mov     eax,dword[esi]
2301
	lea	eax,[eax*3]
2311
        lea     eax,[eax*3]
2302
	shl	eax,2
2312
        shl     eax,2
2303
	add	eax,[points_normals_rot_ptr]	   ;point_normals_rotated
2313
        add     eax,[points_normals_rot_ptr]       ;point_normals_rotated
2304
; #
2314
; #
2305
;	 fld	 dword[eax]
2315
;        fld     dword[eax]
2306
;	 fmul	 dword[eax+4]
2316
;        fmul    dword[eax+4]
Line 2325... Line 2335...
2325
	fiadd	[correct_tex]
2335
        fiadd   [correct_tex]
2326
	fistp	word[edi+2]
2336
        fistp   word[edi+2]
2327
; # end of last ch.
2337
; # end of last ch.
2328
	add	edi,4
2338
        add     edi,4
2329
	add	esi,2
2339
        add     esi,4
2330
	loop	@b
2340
        loop    @b
2331
 
2341
 
Line 2332... Line 2342...
2332
	mov	eax,dword[xx1]
2342
        mov     eax,dword[xx1]
2333
	ror	eax,16
2343
        ror     eax,16
2334
	mov	ebx,dword[xx2]
2344
        mov     ebx,dword[xx2]
2335
	ror	ebx,16
2345
        ror     ebx,16
2336
	mov	ecx,dword[xx3]
2346
        mov     ecx,dword[xx3]
2337
	ror	ecx,16
2347
        ror     ecx,16
2338
	mov	edi,[screen_ptr]
2348
        mov     edi,[screen_ptr]
2339
	mov	esi,envmap
2349
        mov     esi,envmap
2340
	cmp	[catmull_flag],0
2350
  ;      cmp     [catmull_flag],0
2341
	je	@f
-
 
2342
  ;	 mov	 edx,Z_buffer
2351
  ;      je      @f
-
 
2352
 
2343
	mov	edx,[Zbuffer_ptr]
2353
        mov     edx,[Zbuffer_ptr]
2344
	call	tex_triangle_z
2354
        call    tex_triangle_z
2345
	jmp	.end_draw
2355
   ;     jmp     .end_draw
2346
      @@:
2356
   ;   @@:
2347
	call	tex_triangle
2357
   ;     call    tex_triangle
2348
	jmp	.end_draw
2358
        jmp     .end_draw
2349
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2359
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2350
     .cubic_env_mapping:
2360
     .cubic_env_mapping:
2351
       ; fninit
2361
       ; fninit
2352
	cmp	[catmull_flag],0
2362
    ;    cmp     [catmull_flag],0
2353
	je	@f
2363
    ;    je      @f
2354
	push	[zz3]
2364
        push    [zz3]
2355
	push	[zz2]
2365
        push    [zz2]
2356
	push	[zz1]
2366
        push    [zz1]
2357
      @@:
2367
    ;  @@:
2358
	mov	esi,point_index1
2368
        mov     esi,point_index1
2359
	sub	esp,12
2369
        sub     esp,12
2360
	mov	edi,esp
2370
        mov     edi,esp
2361
	mov	ecx,3
2371
        mov     ecx,3
2362
      @@:
2372
      @@:
2363
	movzx	eax,word[esi]
2373
        mov     eax,dword[esi]
2364
	lea	eax,[eax*3]
2374
        lea     eax,[eax*3]
2365
	shl	eax,2
2375
        shl     eax,2
2366
	add	eax,[points_normals_rot_ptr]  ;point_normals_rotated
2376
        add     eax,[points_normals_rot_ptr]  ;point_normals_rotated
2367
; #
2377
; #
2368
	fld	dword[eax]
2378
        fld     dword[eax]
Line 2388... Line 2398...
2388
;	 fiadd	 [correct_tex]
2398
;        fiadd   [correct_tex]
2389
;	 fistp	 word[edi+2]
2399
;        fistp   word[edi+2]
2390
; # end of last ch.
2400
; # end of last ch.
2391
	add	edi,4
2401
        add     edi,4
2392
	add	esi,2
2402
        add     esi,4
2393
	loop	@b
2403
        loop    @b
2394
 
2404
 
Line 2395... Line 2405...
2395
	mov	eax,dword[xx1]
2405
        mov     eax,dword[xx1]
2396
	ror	eax,16
2406
        ror     eax,16
2397
	mov	ebx,dword[xx2]
2407
        mov     ebx,dword[xx2]
2398
	ror	ebx,16
2408
        ror     ebx,16
2399
	mov	ecx,dword[xx3]
2409
        mov     ecx,dword[xx3]
2400
	ror	ecx,16
2410
        ror     ecx,16
2401
	mov	edi,[screen_ptr]
2411
        mov     edi,[screen_ptr]
2402
	mov	esi,envmap_cub
2412
        mov     esi,envmap_cub
2403
	cmp	[catmull_flag],0
2413
 ;       cmp     [catmull_flag],0
2404
	je	@f
-
 
2405
  ;	 mov	 edx,Z_buffer
2414
 ;       je      @f
2406
	mov	edx,[Zbuffer_ptr]
2415
        mov     edx,[Zbuffer_ptr]
2407
	call	tex_triangle_z
2416
        call    tex_triangle_z
2408
	jmp	.end_draw
2417
 ;       jmp     .end_draw
2409
      @@:
2418
 ;     @@:
2410
	call	tex_triangle
2419
 ;       call    tex_triangle
2411
	jmp	.end_draw
2420
        jmp     .end_draw
Line 2412... Line 2421...
2412
 
2421
 
Line 2413... Line 2422...
2413
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2422
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2414
 
2423
 
2415
      .bump_mapping:
2424
      .bump_mapping:
2416
	; fninit
-
 
2417
	cmp	[catmull_flag],0
2425
        ; fninit
-
 
2426
  ;      cmp     [catmull_flag],0
2418
	je	@f
2427
  ;      je      @f
2419
;	 push	 Z_buffer
2428
 
2420
	push	[Zbuffer_ptr]
2429
        push    [Zbuffer_ptr]
2421
	push	[zz3]
2430
        push    [zz3]
2422
	push	[zz2]
2431
        push    [zz2]
2423
	push	[zz1]
2432
        push    [zz1]
2424
      @@:
2433
;      @@:
2425
	mov	esi,point_index1
2434
        mov     esi,point_index1
2426
	sub	esp,12
2435
        sub     esp,12
2427
	mov	edi,esp
2436
        mov     edi,esp
2428
	mov	ecx,3
2437
        mov     ecx,3
2429
      @@:
2438
      @@:
2430
	movzx	eax,word[esi]
2439
        mov     eax,dword[esi]
2431
	lea	eax,[eax*3]
2440
        lea     eax,[eax*3]
2432
	shl	eax,2
2441
        shl     eax,2
2433
	add	eax,[points_normals_rot_ptr]  ;point_normals_rotated
2442
        add     eax,[points_normals_rot_ptr]  ;point_normals_rotated
Line 2442... Line 2451...
2442
	fiadd	[correct_tex]
2451
        fiadd   [correct_tex]
2443
	fistp	word[edi+2]
2452
        fistp   word[edi+2]
2444
 
2453
 
Line 2445... Line 2454...
2445
	add	edi,4
2454
        add     edi,4
2446
	add	esi,2
2455
        add     esi,4
2447
	loop	@b
2456
        loop    @b
Line 2448... Line 2457...
2448
 
2457
 
2449
	movzx  esi,[point_index3]      ; bump map coords
2458
        mov    esi,[point_index3]      ; bump map coords
2450
	shl    esi,2
2459
        shl    esi,2
2451
	add    esi,tex_points
2460
        add    esi,tex_points
2452
	push   dword[esi]
2461
        push   dword[esi]
2453
	movzx  esi,[point_index2]
2462
        mov    esi,[point_index2]
2454
	shl    esi,2
2463
        shl    esi,2
2455
	add    esi,tex_points
2464
        add    esi,tex_points
2456
;	lea    esi,[esi*3]
2465
;       lea    esi,[esi*3]
2457
;	lea    esi,[points+2+esi*2]
2466
;       lea    esi,[points+2+esi*2]
2458
	push   dword[esi]
2467
        push   dword[esi]
2459
  ;	push   dword[xx2]
2468
  ;     push   dword[xx2]
2460
	movzx  esi,[point_index1]
2469
        mov    esi,[point_index1]
2461
	shl    esi,2
2470
        shl    esi,2
2462
	add    esi,tex_points
2471
        add    esi,tex_points
2463
;	lea	esi,[esi*3]
2472
;       lea     esi,[esi*3]
2464
;	lea	esi,[points+2+esi*2]
2473
;       lea     esi,[points+2+esi*2]
Line 2474... Line 2483...
2474
	mov	edi,[screen_ptr]
2483
        mov     edi,[screen_ptr]
2475
	mov	esi,envmap
2484
        mov     esi,envmap
2476
	mov	edx,bumpmap	       ;BUMP_MAPPING
2485
        mov     edx,bumpmap            ;BUMP_MAPPING
2477
 
2486
 
Line 2478... Line 2487...
2478
	cmp	[catmull_flag],0
2487
 ;       cmp     [catmull_flag],0
2479
	je	@f
2488
 ;       je      @f
2480
	call	bump_triangle_z
2489
        call    bump_triangle_z
2481
	jmp	.end_draw
2490
 ;       jmp     .end_draw
2482
      @@:
2491
 ;     @@:
2483
	call	bump_triangle
2492
 ;       call    bump_triangle
2484
	jmp	.end_draw
2493
        jmp     .end_draw
Line 2485... Line 2494...
2485
 
2494
 
Line 2486... Line 2495...
2486
      .tex_mapping:
2495
      .tex_mapping:
2487
 
2496
 
2488
	; fninit
2497
        ; fninit
2489
	cmp	[catmull_flag],0
2498
  ;      cmp     [catmull_flag],0
2490
	je	@f
2499
  ;      je      @f
2491
	push	[zz3]
2500
        push    [zz3]
2492
	push	[zz2]
2501
        push    [zz2]
2493
	push	[zz1]
2502
        push    [zz1]
2494
      @@:
2503
   ;   @@:
2495
	movzx  esi,[point_index3]      ; tex map coords
2504
        mov    esi,[point_index3]      ; tex map coords
2496
	shl    esi,2
2505
        shl    esi,2
2497
	add    esi,tex_points
2506
        add    esi,tex_points
2498
	push   dword[esi]
2507
        push   dword[esi]
2499
	movzx  esi,[point_index2]
2508
        mov    esi,[point_index2]
2500
	shl    esi,2
2509
        shl    esi,2
2501
	add    esi,tex_points
2510
        add    esi,tex_points
2502
	push   dword[esi]
2511
        push   dword[esi]
2503
	movzx  esi,[point_index1]
2512
        mov    esi,[point_index1]
2504
	shl    esi,2
2513
        shl    esi,2
Line 2505... Line 2514...
2505
	add    esi,tex_points
2514
        add    esi,tex_points
Line 2512... Line 2521...
2512
	mov	ecx,dword[xx3]
2521
        mov     ecx,dword[xx3]
2513
	ror	ecx,16
2522
        ror     ecx,16
2514
	mov	edi,[screen_ptr]
2523
        mov     edi,[screen_ptr]
2515
	mov	esi,texmap
2524
        mov     esi,texmap
2516
	cmp	[catmull_flag],0
2525
   ;     cmp     [catmull_flag],0
2517
	je	@f
2526
   ;     je      @f
2518
   ;	 mov	 edx,Z_buffer
-
 
2519
	mov	edx,[Zbuffer_ptr]
2527
         mov     edx,[Zbuffer_ptr]
2520
	call	tex_triangle_z
2528
        call    tex_triangle_z
2521
 ;	 call	 tex_plus_grd_trianlgle
2529
;        jmp     .end_draw
2522
	jmp	.end_draw
-
 
2523
      @@:
2530
;      @@:
2524
	call	tex_triangle
2531
;        call    tex_triangle
2525
	jmp	.end_draw
2532
        jmp     .end_draw
2526
;      .ray:
2533
;      .ray:
2527
;	 grd_triangle according to points index
2534
;        grd_triangle according to points index
2528
;	 cmp	 [catmull_flag],0
2535
;        cmp     [catmull_flag],0
2529
;	 je	 @f
2536
;        je      @f
2530
;	 push	 [zz3]			 ; spot light with attenuation
2537
;        push    [zz3]                   ; spot light with attenuation
Line 2562... Line 2569...
2562
	 mov	ebp,esp
2569
         mov    ebp,esp
2563
	 sub	esp,4
2570
         sub    esp,4
2564
	 push	ebp
2571
         push   ebp
2565
 
2572
 
Line 2566... Line 2573...
2566
	 movzx	esi,[point_index3]	; tex map coords
2573
         mov    esi,[point_index3]      ; tex map coords
2567
	 shl	esi,2
2574
         shl    esi,2
2568
	 add	esi,tex_points
2575
         add    esi,tex_points
2569
	 push	dword[esi]		; texture coords as first
2576
         push   dword[esi]              ; texture coords as first
2570
	 movzx	esi,[point_index2]	; group of parameters
2577
         mov    esi,[point_index2]      ; group of parameters
2571
	 shl	esi,2
2578
         shl    esi,2
2572
	 add	esi,tex_points
2579
         add    esi,tex_points
2573
	 push	dword[esi]
2580
         push   dword[esi]
2574
	 movzx	esi,[point_index1]
2581
         mov    esi,[point_index1]
2575
	 shl	esi,2
2582
         shl    esi,2
2576
	 add	esi,tex_points
2583
         add    esi,tex_points
2577
	 push	dword[esi]
2584
         push   dword[esi]
Line 2578... Line 2585...
2578
 
2585
 
Line 2583... Line 2590...
2583
 
2590
 
Line 2584... Line 2591...
2584
	lea	 edx,[ecx*3]
2591
        lea      edx,[ecx*3]
2585
	push	 word[edx*2+xx1-2]    ; zz1 ,2 ,3
2592
        push     word[edx*2+xx1-2]    ; zz1 ,2 ,3
Line 2586... Line 2593...
2586
 
2593
 
2587
	movzx	eax,word[esi]
2594
        mov     eax,dword[esi]
2588
	shl	eax,2
2595
        shl     eax,2
2589
	lea	eax,[eax*3] ;+point_normals_rotated]
2596
        lea     eax,[eax*3] ;+point_normals_rotated]
2590
	add	eax,[points_normals_rot_ptr]
2597
        add     eax,[points_normals_rot_ptr]
2591
	; texture x=(rotated point normal -> x * 255)+255
2598
        ; texture x=(rotated point normal -> x * 255)+255
Line 2614... Line 2621...
2614
	push	 ax	    ;g
2621
        push     ax         ;g
2615
	shr	 eax,24
2622
        shr      eax,24
2616
	push	 ax	    ;b
2623
        push     ax         ;b
2617
 
2624
 
Line 2618... Line 2625...
2618
	sub	 esi,2
2625
        sub      esi,4
2619
	dec	 cx
2626
        dec      cx
2620
	jnz	 .aagain_grd_draw
2627
        jnz      .aagain_grd_draw
Line 2621... Line 2628...
2621
 
2628
 
2622
	mov	eax,dword[xx1]
2629
        mov     eax,dword[xx1]
Line 2642... Line 2649...
2642
	push	word[zz3]
2649
        push    word[zz3]
2643
	push	word[zz2]
2650
        push    word[zz2]
2644
	push	word[zz1]
2651
        push    word[zz1]
Line 2645... Line 2652...
2645
 
2652
 
2646
	movzx  esi,[point_index3]      ; tex map coords
2653
        mov    esi,[point_index3]      ; tex map coords
2647
	shl    esi,2
2654
        shl    esi,2
2648
	add    esi,tex_points
2655
        add    esi,tex_points
2649
	push   dword[esi]
2656
        push   dword[esi]
2650
	movzx  esi,[point_index2]
2657
        mov    esi,[point_index2]
2651
	shl    esi,2
2658
        shl    esi,2
2652
	add    esi,tex_points
2659
        add    esi,tex_points
2653
	push   dword[esi]
2660
        push   dword[esi]
2654
	movzx  esi,[point_index1]
2661
        mov    esi,[point_index1]
2655
	shl    esi,2
2662
        shl    esi,2
2656
	add    esi,tex_points
2663
        add    esi,tex_points
Line 2657... Line 2664...
2657
	push   dword[esi]
2664
        push   dword[esi]
2658
 
2665
 
2659
	mov	esi,point_index1     ; env coords
2666
        mov     esi,point_index1     ; env coords
2660
	sub	esp,12
2667
        sub     esp,12
2661
	mov	edi,esp
2668
        mov     edi,esp
2662
	mov	ecx,3
2669
        mov     ecx,3
2663
      @@:
2670
      @@:
2664
	movzx	eax,word[esi]
2671
        mov     eax,dword[esi]
2665
	lea	eax,[eax*3]
2672
        lea     eax,[eax*3]
2666
	shl	eax,2
2673
        shl     eax,2
2667
	add	eax,[points_normals_rot_ptr]
2674
        add     eax,[points_normals_rot_ptr]
Line 2676... Line 2683...
2676
	fiadd	[correct_tex]
2683
        fiadd   [correct_tex]
2677
	fistp	word[edi+2]
2684
        fistp   word[edi+2]
2678
 
2685
 
Line 2679... Line 2686...
2679
	add	edi,4
2686
        add     edi,4
2680
	add	esi,2
2687
        add     esi,4
2681
	loop	@b
2688
        loop    @b
Line 2682... Line 2689...
2682
 
2689
 
2683
	mov	eax,dword[xx1]
2690
        mov     eax,dword[xx1]
2684
	ror	eax,16
2691
        ror     eax,16
Line 2693... Line 2700...
2693
	call	two_tex_triangle_z
2700
        call    two_tex_triangle_z
2694
	jmp	.end_draw
2701
        jmp     .end_draw
Line 2695... Line 2702...
2695
 
2702
 
2696
   .bump_tex:
2703
   .bump_tex:
2697
	movzx  esi,[point_index3]      ; tex map coords
2704
        mov    esi,[point_index3]      ; tex map coords
2698
	shl    esi,2
2705
        shl    esi,2
2699
	add    esi,tex_points
2706
        add    esi,tex_points
2700
	push   dword[esi]
2707
        push   dword[esi]
2701
	movzx  esi,[point_index2]
2708
        mov    esi,[point_index2]
2702
	shl    esi,2
2709
        shl    esi,2
2703
	add    esi,tex_points
2710
        add    esi,tex_points
2704
	push   dword[esi]
2711
        push   dword[esi]
2705
	movzx  esi,[point_index1]
2712
        mov    esi,[point_index1]
2706
	shl    esi,2
2713
        shl    esi,2
2707
	add    esi,tex_points
2714
        add    esi,tex_points
Line 2708... Line 2715...
2708
	push   dword[esi]
2715
        push   dword[esi]
Line 2720... Line 2727...
2720
	sub	esp,12
2727
        sub     esp,12
2721
	mov	edi,esp
2728
        mov     edi,esp
2722
	mov	ecx,3
2729
        mov     ecx,3
2723
      @@:
2730
      @@:
2724
	movzx	eax,word[esi]
2731
        mov     eax,dword[esi]
2725
	lea	eax,[eax*3]
2732
        lea     eax,[eax*3]
2726
	shl	eax,2
2733
        shl     eax,2
2727
	add	eax,[points_normals_rot_ptr]
2734
        add     eax,[points_normals_rot_ptr]
2728
	; texture x=(rotated point normal -> x * 255)+255
2735
        ; texture x=(rotated point normal -> x * 255)+255
2729
	fld	dword[eax]
2736
        fld     dword[eax]
2730
	fimul	[correct_tex]
2737
        fimul   [correct_tex]
Line 2736... Line 2743...
2736
	fiadd	[correct_tex]
2743
        fiadd   [correct_tex]
2737
	fistp	word[edi+2]
2744
        fistp   word[edi+2]
2738
 
2745
 
Line 2739... Line 2746...
2739
	add	edi,4
2746
        add     edi,4
2740
	add	esi,2
2747
        add     esi,4
2741
	loop	@b
2748
        loop    @b
Line 2742... Line 2749...
2742
 
2749
 
2743
;	 push  dword 1 shl 16 + 1  ; emap coords
2750
;        push  dword 1 shl 16 + 1  ; emap coords
2744
;	 push  dword 127 shl 16 + 1
2751
;        push  dword 127 shl 16 + 1
Line 2745... Line 2752...
2745
;	 push  dword 127 shl 16 + 127
2752
;        push  dword 127 shl 16 + 127
2746
 
2753
 
2747
	movzx  esi,[point_index3]      ; bump map coords
2754
        mov    esi,[point_index3]      ; bump map coords
2748
	shl    esi,2
2755
        shl    esi,2
2749
	add    esi,tex_points
2756
        add    esi,tex_points
2750
	push   dword[esi]
2757
        push   dword[esi]
2751
	movzx  esi,[point_index2]
2758
        mov    esi,[point_index2]
2752
	shl    esi,2
2759
        shl    esi,2
Line 2753... Line 2760...
2753
	add    esi,tex_points
2760
        add    esi,tex_points
2754
	push   dword[esi]
2761
        push   dword[esi]
2755
 
2762
 
2756
	movzx  esi,[point_index1]
2763
        mov    esi,[point_index1]
Line 2757... Line 2764...
2757
	shl    esi,2
2764
        shl    esi,2
Line 2779... Line 2786...
2779
      .draw_smooth_line:
2786
      .draw_smooth_line:
2780
	mov	esi,point_index3
2787
        mov     esi,point_index3
2781
	mov	ecx,3
2788
        mov     ecx,3
2782
      .again_line_param:
2789
      .again_line_param:
2783
	movzx	eax,word[esi]
2790
        mov     eax,dword[esi]
2784
	shl	eax,2
2791
        shl     eax,2
2785
	lea	eax,[eax*3]
2792
        lea     eax,[eax*3]
2786
	add	eax,[points_normals_rot_ptr]
2793
        add     eax,[points_normals_rot_ptr]
2787
	; texture ;x=(rotated point normal -> x * 255)+255
2794
        ; texture ;x=(rotated point normal -> x * 255)+255
2788
	fld	dword[eax]	 ; x cooficient of normal vector
2795
        fld     dword[eax]       ; x cooficient of normal vector
Line 2804... Line 2811...
2804
	lea	 ebx,[ecx-1]
2811
        lea      ebx,[ecx-1]
2805
	shl	 ebx,2
2812
        shl      ebx,2
2806
	mov	 [ebx+col1],eax
2813
        mov      [ebx+col1],eax
2807
 
2814
 
Line 2808... Line 2815...
2808
	sub	 esi,2
2815
        sub      esi,4
2809
	dec	 ecx
2816
        dec      ecx
2810
	jnz	 .again_line_param
2817
        jnz      .again_line_param
Line 2811... Line 2818...
2811
 
2818
 
2812
;	 mov	 eax,[edges_ptr]	 ;   this not works correctly
2819
;        mov     eax,[edges_ptr]         ;   this not works correctly
Line 2916... Line 2923...
2916
      @@:
2923
      @@:
2917
 
2924
 
Line 2918... Line 2925...
2918
      .end_draw:
2925
      .end_draw:
2919
	pop	esi
2926
        pop     esi
2920
	add	esi,6
2927
        add     esi,12
2921
	inc	[edges_counter]
2928
        inc     [edges_counter]
-
 
2929
        pop     ecx
-
 
2930
        sub     ecx,1
2922
	cmp	dword[esi],-1
2931
     ;   cmp     dword[esi],-1
2923
	jne	.again_dts
2932
        jnz     .again_dts
2924
ret
2933
ret
Line -... Line 2934...
-
 
2934
 
-
 
2935
 
-
 
2936
 
-
 
2937
 
2925
 
2938
 
Line 2926... Line 2939...
2926
 
2939
 
2927
 
2940
 
Line 3019... Line 3032...
3019
       pop   esi
3032
       pop   esi
3020
       add   esi,6
3033
       add   esi,6
3021
       inc   dword[.counter]
3034
       inc   dword[.counter]
3022
       mov   ecx,[.counter]
3035
       mov   ecx,[.counter]
3023
       cmp   cx,[points_count_var]
3036
       cmp   ecx,[points_count_var]
3024
       jng   .loop
3037
       jng   .loop
3025
 
3038
 
Line 3026... Line 3039...
3026
       mov   esp,ebp
3039
       mov   esp,ebp
3027
       pop   ebp
3040
       pop   ebp
Line 3062... Line 3075...
3062
read_tp_variables:	      ; read [triangles_count_var] and	[points_count_var]
3075
read_tp_variables:            ; read [triangles_count_var] and  [points_count_var]
3063
			      ; and  allocate memory
3076
                              ; and  allocate memory
3064
	xor	ebx,ebx
3077
        xor     ebx,ebx
3065
	xor	ebp,ebp
3078
        xor     ebp,ebp
3066
	mov	[points_count_var],bx
3079
        mov     [points_count_var],ebx
3067
	mov	[triangles_count_var],bx
3080
        mov     [triangles_count_var],ebx
3068
   if USE_LFN = 0
3081
   if USE_LFN = 0
3069
	mov	esi,SourceFile
3082
        mov     esi,SourceFile
3070
   else
3083
   else
3071
	mov	esi,[fptr]
3084
        mov     esi,[fptr]
3072
   end if
3085
   end if
Line 3122... Line 3135...
3122
	add	esi,[esi+2]
3135
        add     esi,[esi+2]
3123
	jmp	@b
3136
        jmp     @b
3124
      @@:
3137
      @@:
3125
	movzx	ecx,word[esi+6]
3138
        movzx   ecx,word[esi+6]
3126
	add	[points_count_var],cx
3139
        add     [points_count_var],ecx
3127
 
3140
 
Line 3128... Line 3141...
3128
	mov	edx,ecx
3141
        mov     edx,ecx
3129
	add	esi,8
3142
        add     esi,8
3130
     @@:
3143
     @@:
Line 3141... Line 3154...
3141
	add	esi,[esi+2]
3154
        add     esi,[esi+2]
3142
	jmp	@b
3155
        jmp     @b
3143
      @@:
3156
      @@:
3144
	movzx	ecx,word[esi+6]
3157
        movzx   ecx,word[esi+6]
3145
	add	[triangles_count_var],cx
3158
        add     [triangles_count_var],ecx
3146
	add	esi,8
3159
        add     esi,8
3147
 
3160
 
Line 3148... Line 3161...
3148
      @@:
3161
      @@:
3149
	add	esi,8
3162
        add     esi,8
3150
	dec	ecx
3163
        dec     ecx
Line 3216... Line 3229...
3216
	add	esi,[esi+2]
3229
        add     esi,[esi+2]
3217
	jmp	@b
3230
        jmp     @b
3218
      @@:
3231
      @@:
3219
	movzx	ecx,word[esi+6]
3232
        movzx   ecx,word[esi+6]
3220
	add	[points_count_var],cx
3233
        add     [points_count_var],ecx
3221
 
3234
 
Line 3222... Line 3235...
3222
	mov	edx,ecx
3235
        mov     edx,ecx
3223
	add	esi,8
3236
        add     esi,8
3224
     @@:
3237
     @@:
3225
	push	edi
3238
        push    edi
Line 3230... Line 3243...
3230
	pop	dword[edi+ebx*2+4]
3243
        pop     dword[edi+ebx*2+4]
3231
	push	dword[esi+8]
3244
        push    dword[esi+8]
3232
	pop	dword[edi+ebx*2+8]
3245
        pop     dword[edi+ebx*2+8]
3233
	pop	edi
3246
        pop     edi
3234
;	 fld	 dword[esi+4]
3247
 
3235
;	 fstp	 dword[real_points+ebx*2+0]  ; x
-
 
3236
;	 fld	 dword[esi+8]
-
 
3237
;	 fstp	dword[real_points+ebx*2+4]  ; y
-
 
3238
;	 fld	 dword[esi+0]
-
 
3239
;	 fstp	dword[real_points+ebx*2+8]  ; z
-
 
3240
 
-
 
Line 3241... Line 3248...
3241
	add	ebx,6
3248
        add     ebx,6
3242
	add	esi,12
3249
        add     esi,12
3243
	dec	ecx
3250
        dec     ecx
3244
	jnz	@b
3251
        jnz     @b
Line 3254... Line 3261...
3254
	add	esi,[esi+2]
3261
        add     esi,[esi+2]
3255
	jmp	@b
3262
        jmp     @b
3256
      @@:
3263
      @@:
3257
	movzx	ecx,word[esi+6]
3264
        movzx   ecx,word[esi+6]
3258
	add	[triangles_count_var],cx
3265
        add     [triangles_count_var],ecx
3259
	add	esi,8
3266
        add     esi,8
3260
	;mov	 edi,triangles
3267
        ;mov     edi,triangles
3261
      @@:
3268
      @@:
3262
	movsd
3269
        movzx   eax,word[esi]
-
 
3270
        stosd
3263
	movsw
3271
        movzx   eax,word[esi+2]
-
 
3272
        stosd
3264
	add	word[edi-6],bp
3273
        movzx   eax,word[esi+4]
-
 
3274
        stosd
-
 
3275
        add     dword[edi-12],ebp
3265
	add	word[edi-4],bp
3276
        add     dword[edi-8],ebp
3266
	add	word[edi-2],bp
3277
        add     dword[edi-4],ebp
3267
	add	esi,2
3278
        add     esi,8
3268
	dec	ecx
3279
        dec     ecx
3269
	jnz	@b
3280
        jnz     @b
3270
	add	ebp,edx
3281
        add     ebp,edx
3271
	jmp	.find4k
3282
        jmp     .find4k
3272
	mov	eax,-1 ;<---mark if OK
3283
        mov     eax,-1 ;<---mark if OK
3273
      .exit:
3284
      .exit:
Line 3284... Line 3295...
3284
    @@:
3295
    @@:
3285
	mov	ebx,20
3296
        mov     ebx,20
3286
    .alloc:
3297
    .alloc:
3287
 
3298
 
Line 3288... Line 3299...
3288
	movzx	ecx, [triangles_count_var]
3299
        mov     ecx,[triangles_count_var]
3289
	inc	ecx
3300
        add     ecx,20
3290
	lea	ecx, [ecx*3]
3301
        lea     ecx, [ecx*3]
3291
	add	ecx, ecx
3302
        shl     ecx,2
3292
	mov	edx,[triangles_ptr]
3303
        mov     edx,[triangles_ptr]
3293
	int	0x40		       ;  -> allocate memory to triangles
3304
        int     0x40                   ;  -> allocate memory to triangles
3294
	mov	[triangles_ptr], eax   ;  -> eax = pointer to allocated mem
3305
        mov     [triangles_ptr], eax   ;  -> eax = pointer to allocated mem
Line 3295... Line 3306...
3295
 
3306
 
Line 3317... Line 3328...
3317
;	 mov	 [triangles_w_z_ptr], eax   ; for trainagles_with_z list
3328
;        mov     [triangles_w_z_ptr], eax   ; for trainagles_with_z list
3318
					    ; ststic  memory
3329
                                            ; ststic  memory
3319
 
3330
 
Line 3320... Line 3331...
3320
	mov	eax, 68
3331
        mov     eax, 68
3321
	movzx	ecx, [triangles_count_var]
3332
        mov     ecx, [triangles_count_var]
3322
	lea	ecx, [3+ecx*3]
3333
        lea     ecx, [3+ecx*3]
3323
	shl	ecx, 2
3334
        shl     ecx, 2
3324
	mov	edx,[triangles_normals_ptr]
3335
        mov     edx,[triangles_normals_ptr]
3325
	int	0x40			       ;  -> allocate memory for triangles normals
3336
        int     0x40                           ;  -> allocate memory for triangles normals
3326
	mov	[triangles_normals_ptr], eax   ;  -> eax = pointer to allocated mem
3337
        mov     [triangles_normals_ptr], eax   ;  -> eax = pointer to allocated mem
Line 3332... Line 3343...
3332
   ;	 int	 0x40
3343
   ;     int     0x40
3333
   ;	 mov	 dword[vertices_index_ptr], eax
3344
   ;     mov     dword[vertices_index_ptr], eax
3334
 
3345
 
Line 3335... Line 3346...
3335
	mov	eax, 68
3346
        mov     eax, 68
3336
	movzx	ecx, [points_count_var]
3347
        mov     ecx, [points_count_var]
3337
	lea	ecx,[3+ecx*3]
3348
        lea     ecx,[3+ecx*3]
3338
	shl	ecx, 2
3349
        shl     ecx, 2
3339
	mov	edx,[points_normals_ptr]
3350
        mov     edx,[points_normals_ptr]
3340
	int	0x40
3351
        int     0x40
3341
	mov	[points_normals_ptr], eax
3352
        mov     [points_normals_ptr], eax
Line 3346... Line 3357...
3346
 
3357
 
Line 3347... Line 3358...
3347
 
3358
 
3348
	mov	eax, 68
3359
        mov     eax, 68
3349
    ;	 mov	 ebx, 12
3360
    ;    mov     ebx, 12
3350
	movzx	ecx, [points_count_var]
3361
        mov     ecx, [points_count_var]
3351
	lea	ecx,[3+ecx*3]
3362
        lea     ecx,[3+ecx*3]
3352
	shl	ecx, 2
3363
        shl     ecx, 2
3353
	mov	edx,[points_normals_rot_ptr]
3364
        mov     edx,[points_normals_rot_ptr]
3354
	int	0x40
3365
        int     0x40
Line 3364... Line 3375...
3364
	int	0x40
3375
        int     0x40
3365
	mov	[points_rotated_ptr], eax
3376
        mov     [points_rotated_ptr], eax
3366
 
3377
 
Line 3367... Line 3378...
3367
	mov	eax, 68
3378
        mov     eax, 68
3368
	movzx	ecx, [points_count_var]
3379
        mov     ecx, [points_count_var]
3369
	inc	ecx
3380
        inc     ecx
3370
	shl	ecx, 3
3381
        shl     ecx, 3
3371
	mov	edx,[points_translated_ptr]
3382
        mov     edx,[points_translated_ptr]
3372
	int	0x40
3383
        int     0x40
3373
	mov	[points_translated_ptr], eax
3384
        mov     [points_translated_ptr], eax
Line 3379... Line 3390...
3379
if USE_LFN
3390
if USE_LFN
3380
;-
3391
;-
3381
    mov     eax, 68
3392
    mov     eax, 68
3382
    mov     ebx, 11
3393
    mov     ebx, 11
3383
    int     0x40		   ;  -> init heap
3394
    int     0x40                   ;  -> create heap
3384
 
3395
 
Line 3385... Line 3396...
3385
    ;mov     eax, 70
3396
 ;    mov     eax, 70
3386
    ;mov     ebx, file_info
3397
 ;    mov     ebx, file_info
3387
    ;mov     dword[ebx], 5	   ;  -> subfunction number
3398
 ;    mov     dword[ebx], 5          ;  -> subfunction number
3388
    ;int     0x40		   ;  -> read file size
3399
 ;    int     0x40                   ;  -> read file size
3389
    ;mov     ebx, [fptr]
3400
 ;    mov     ebx, [fptr]
3390
    ;mov     ebx, dword[ebx+32]
3401
 ;    mov     ebx, dword[ebx+32]
3391
    ;inc     ebx
3402
 ;    inc     ebx
3392
    ;mov     [fsize], ebx
3403
 ;    mov     [fsize], ebx
Line -... Line 3404...
-
 
3404
 
-
 
3405
 
3393
 
3406
 
3394
    ;mov     eax, 68
3407
    ;   mov     eax, 68
3395
    ;mov     ebx, 12
3408
    ;   mov     ebx, 12
3396
    ;mov     ecx, [fsize]
3409
    ;   mov     ecx, [fsize]
3397
    ;int     0x40		   ;  -> allocate memory for file
3410
    ;   int     0x40                   ;  -> allocate memory for file
Line 3398... Line 3411...
3398
    ;mov     [fptr], eax 	   ;  -> eax = pointer to allocated mem
3411
    ;   mov     [fptr], eax            ;  -> eax = pointer to allocated mem
3399
 
3412
 
3400
    ;mov     eax, 70
3413
 ;    mov     eax, 70
3401
    ;mov     ebx, file_info
3414
 ;    mov     ebx, file_info
3402
    ;mov     dword[ebx],0
-
 
3403
    ;int     0x40		   ; -> read file
-
 
3404
	
-
 
3405
    ;mov     [fsize],ebx
-
 
3406
    ;cmp     eax,6
-
 
3407
    ;jnz     @f
-
 
3408
    ;xor     eax,eax	;;;;---
-
 
3409
	
-
 
3410
    ;cmp     eax,6
-
 
3411
    ;jnz     @f
-
 
3412
    ;xor     eax,eax	;;;;---
3415
 ;    mov     dword[ebx],0
3413
 
-
 
3414
    ;load kpacked files by Leency
3416
 ;    int     0x40                   ; -> read file
3415
 
3417
   ;load kpacked files by Leency
3416
	mov     eax,68
3418
       mov     eax,68
3417
	mov     ebx,27
3419
       mov     ebx,27
Line 3418... Line 3420...
3418
	mov     ecx,I_Param
3420
       mov     ecx,file_name
3419
	int     0x40
3421
       int     0x40
Line 3452... Line 3454...
3452
    int      0x40
3454
    int      0x40
3453
end if
3455
end if
3454
  ;  eax = 0   -> ok file loaded
3456
  ;  eax = 0   -> ok file loaded
3455
ret
3457
ret
3456
read_param:
3458
  ;  eax = 0   -> ok file loaded
-
 
3459
ret
-
 
3460
read_param:
3457
    mov        esi,I_Param
3461
    mov        esi,I_Param
3458
    cmp        dword[esi],0
3462
    cmp        dword[esi],0
3459
    je	       .end
3463
    je         .end
3460
    cmp        byte[esi],'/'
3464
    cmp        byte[esi],'/'
3461
    je	       .copy
3465
    je         .copy