Subversion Repositories Kolibri OS

Rev

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

Rev 8719 Rev 9237
Line 1... Line 1...
1
; application : View3ds ver. 0.071 - tiny .3ds and .asc files viewer
1
; application : View3ds ver. 0.074 - tiny .3ds and .asc files viewer
2
;               with a few graphics effects demonstration.
2
;               with a few graphics effects demonstration.
3
; compiler    : FASM
3
; compiler    : FASM
4
; system      : KolibriOS
4
; system      : KolibriOS
5
; author      : Macgub aka Maciej Guba
5
; author      : Macgub aka Maciej Guba
6
; email       : macgub3@wp.pl
6
; email       : macgub3@wp.pl
Line 36... Line 36...
36
SSE   =   2
36
SSE   =   2
37
SSE2  =   3
37
SSE2  =   3
38
SSE3  =   4
38
SSE3  =   4
39
Ext   =   SSE3           ;Ext={ NON | MMX | SSE | SSE2 | SSE3 }
39
Ext   =   SSE3           ;Ext={ NON | MMX | SSE | SSE2 | SSE3 }
40
 
40
; For now correct only SSE2 and SSE3 versions. if you have older CPU
-
 
41
; use older versions of app. Probably ver 005 will be OK but it need
-
 
42
; re-edit to support new Kolibri features.
-
 
43
 
Line 41... Line 44...
41
; 0 for short names (Menuet-compatible), 1 for long names (Kolibri features)
44
; 0 for short names (Menuet-compatible), 1 for long names (Kolibri features)
42
USE_LFN = 1  ; App is Kolibri only now.
45
USE_LFN = 1  ; App is Kolibri only now.
Line 43... Line 46...
43
 
46
 
Line 52... Line 55...
52
        dd     I_Param          ; I_Param
55
        dd     I_Param          ; I_Param
53
        dd     0x0              ; I_Icon
56
        dd     0x0              ; I_Icon
54
 
57
 
Line 55... Line 58...
55
START:    ; start of execution
58
START:    ; start of execution
-
 
59
        rdtsc
-
 
60
        mov    [rand_seed],ax
56
        cld
61
        cld
57
        push   dword (SIZE_Y shr 3) * 3
62
        push   dword (SIZE_Y shr 3) * 3
58
        fninit
63
        fninit
59
        fild   dword[esp]
64
        fild   dword[esp]
60
        fstp   [rsscale]
65
        fstp   [rsscale]
Line 88... Line 93...
88
        call   optimize_object1     ;  proc in file b_procs.asm
93
        call   optimize_object1     ;  proc in file b_procs.asm
89
                                    ;  set point(0,0,0) in center and  calc all coords
94
                                    ;  set point(0,0,0) in center and  calc all coords
90
                                    ;  to be in <-1.0,1.0>
95
                                    ;  to be in <-1.0,1.0>
91
        call   normalize_all_light_vectors
96
        call   normalize_all_light_vectors
92
      if Ext >= SSE3
97
        call   copy_lights ; to aligned float
93
        call   copy_lights ; to aligned float
-
 
94
      end if
98
        call   init_triangles_normals2
95
        call   init_triangles_normals2
-
 
96
        call   init_point_normals
99
        call   init_point_normals
97
        call   init_envmap2
100
        call   init_envmap2
98
        call   init_envmap_cub
101
        call   init_envmap_cub
99
        call   generate_texture2
102
        call   generate_texture2
100
        call   init_sincos_tab
103
        call   init_sincos_tab
101
        call   do_color_buffer   ; intit color_map
104
        call   do_color_buffer   ; intit color_map
102
        mov    edi,bumpmap
105
     if Ext >= SSE3
-
 
106
        call   init_point_lights
-
 
107
        mov    [fire_flag],0     ; proteza
-
 
108
       end if
-
 
109
        mov    edi,bumpmap
103
        call   calc_bumpmap
110
        call   calc_bumpmap
104
        call   calc_bumpmap_coords   ; bump and texture mapping
111
        call   calc_bumpmap_coords   ; bump and texture mapping
105
        call   do_edges_list
112
        call   do_edges_list
106
        call   draw_window
113
        call   draw_window
107
        ;mov     [draw_win_at_first],0
114
     if Ext > SSE2
-
 
115
        mov     eax,1
108
        ;mov    eax,40         ; set events mask
116
        cpuid
-
 
117
        bt      ecx,0  ; is sse3 on board?
109
        ;mov    ebx,1100000000000000000000000100111b
118
        jc      @f
-
 
119
        mov     [max_dr_flg],12
110
        ;int    0x40
120
        mov     [isSSE3],0
111
 
121
       @@:
112
 
122
     end if
-
 
123
 
Line 113... Line 124...
113
still:
124
still:
114
        cmp    [edit_flag],1
125
        cmp    [edit_flag],1
115
        jne    @f
126
        jne    @f
116
        mov    eax,40         ; set events mask
127
        mov    eax,40         ; set events mask
Line 120... Line 131...
120
        mov    eax,40         ; set events mask
131
        mov    eax,40         ; set events mask
121
        mov    ebx,111b
132
        mov    ebx,111b
122
      .int:
133
      .int:
123
        int    0x40
134
        int    0x40
124
 
135
      if Ext > SSE2
-
 
136
        cmp    [ray_shd_flag],1
-
 
137
        jne    @f
-
 
138
        cmp    [isSSE3],1
-
 
139
        jne    @f
-
 
140
        mov    eax,10
-
 
141
        jmp    .intt
-
 
142
      end if
-
 
143
 
Line -... Line 144...
-
 
144
       @@:
125
        mov     eax,23
145
        mov     eax,23
126
        mov     ebx,TIMEOUT
146
        mov     ebx,TIMEOUT
127
        cmp     [speed_flag],0
147
        cmp     [speed_flag],0
128
        je      .skip
148
        je      .skip
129
        mov     eax,11
149
        mov     eax,11
Line 132... Line 152...
132
        jne     @f
152
        jne     @f
133
        mov     eax,10
153
        mov     eax,10
134
 
154
 
Line 135... Line 155...
135
      @@:
155
      @@:
-
 
156
      .intt:
136
        int     0x40
157
        int     0x40
Line 137... Line 158...
137
 
158
 
138
        cmp     eax,1           ; redraw event ?
159
        cmp     eax,1           ; redraw event ?
139
        je      red
160
        je      red
Line 261... Line 282...
261
        cmp     ah,9    ; lights random                 ;    'flat'  0
282
        cmp     ah,9    ; lights random                 ;    'flat'  0
262
        jne     .next_m5                                ;    'grd '  1
283
        jne     .next_m5                                ;    'grd '  1
263
        call    make_random_lights                      ;    'env '  2
284
        call    make_random_lights                      ;    'env '  2
264
        call    normalize_all_light_vectors             ;    'bump'  3
285
        call    normalize_all_light_vectors             ;    'bump'  3
265
      if Ext >= SSE3
286
        call    copy_lights
266
        call    copy_lights
-
 
267
      end if
287
      if Ext >= SSE3
-
 
288
        call   init_point_lights  ; for ex. ray casting
-
 
289
      end if
268
        call    do_color_buffer   ; intit color_map     ;    'tex '  4
290
        call    do_color_buffer   ; intit color_map     ;    'tex '  4
269
 
291
 
Line 270... Line 292...
270
        call    init_envmap2    ; update env map if shading model = environment or bump
292
        call    init_envmap2    ; update env map if shading model = environment or bump
271
    .next_m5:
293
    .next_m5:
Line 394... Line 416...
394
        jne     .next2
416
        jne     .next2
395
        cmp     [move_flag],0
417
        cmp     [move_flag],0
396
        jne     @f
418
        jne     @f
397
        .x_minus:
419
        .x_minus:
398
        sub     [vect_x],10
420
        sub     word[vect_x],10
399
        jmp     .next2
421
        jmp     .next2
400
      @@:
422
      @@:
401
        cmp     [move_flag],1
423
        cmp     [move_flag],1
402
        jne     @f
424
        jne     @f
403
        sub     [xobs],10         ;  observator = camera position
425
        sub     [xobs],10         ;  observator = camera position
404
        jmp     .next2
426
        jmp     .next2
Line 412... Line 434...
412
        jne     .next3
434
        jne     .next3
413
        cmp     [move_flag],0
435
        cmp     [move_flag],0
414
        jne     @f
436
        jne     @f
415
        .x_plus:
437
        .x_plus:
416
        add     [vect_x],10
438
        add     word[vect_x],10
417
        jmp     .next3
439
        jmp     .next3
418
      @@:
440
      @@:
419
        cmp     [move_flag],1
441
        cmp     [move_flag],1
420
        jne     @f
442
        jne     @f
421
        add     [xobs],10         ;  observator = camera position
443
        add     [xobs],10         ;  observator = camera position
422
        jmp     .next3
444
        jmp     .next3
Line 520... Line 542...
520
    ; 64 indexes    call    sort_triangles
542
    ; 64 indexes    call    sort_triangles
521
      .no_sort:
543
      .no_sort:
522
        cmp     [dr_flag],7       ; fill if 2tex and texgrd
544
        cmp     [dr_flag],7       ; fill if 2tex and texgrd
523
        jge     @f
545
        jge     @f
524
        cmp     [catmull_flag],0  ;non fill if Catmull = off
546
        cmp     [dr_flag],6       ; non fill if dots
525
        je      .non_f
-
 
526
        cmp     [dr_flag],6       ; non fill if dots
-
 
527
        je      .non_f
547
        je      .non_f
528
      @@:
548
      @@:
529
        call    fill_Z_buffer     ; make background
549
        call    fill_Z_buffer     ; make background
530
     .non_f:
550
     .non_f:
531
        cmp     [dr_flag],6
551
        cmp     [dr_flag],6
532
        jne     @f
552
        jne     @f
533
        call     draw_dots
553
        call     draw_dots
534
        jmp      .blurrr
554
        jmp      .blurrr
535
      @@:
555
      @@:
536
        call    draw_triangles  ; draw all triangles from the list
556
      if Ext > SSE2
-
 
557
        cmp     [ray_shd_flag],1  ;non fill if Catmull = off
-
 
558
        jne     @f
-
 
559
        cmp     [isSSE3],1
-
 
560
        jne     @f
-
 
561
        mov     ax,100
-
 
562
        jmp     .dr
-
 
563
       @@:
-
 
564
      end if
-
 
565
 
-
 
566
        movzx   ax,[dr_flag]
-
 
567
      .dr:
-
 
568
        call    draw_triangles  ; draw all triangles from the list
537
        cmp    [edit_flag],0
569
        cmp    [edit_flag],0
538
        jz     .no_edit
570
        jz     .no_edit
539
        call   clear_vertices_index
571
        call   clear_vertices_index
540
        call   draw_handlers
572
        movzx eax,[dr_flag]
-
 
573
        movzx ebx,[ray_shd_flag]
-
 
574
        shl   ebx,10
-
 
575
        or    eax,ebx
-
 
576
         call   draw_handlers
541
    ;    call   edit
577
    ;    call   edit
542
 
578
 
Line 543... Line -...
543
 
-
 
544
 
-
 
545
 
-
 
546
 
579
 
Line 547... Line 580...
547
 
580
 
-
 
581
    .no_edit:
-
 
582
 
-
 
583
      .blurrr:
-
 
584
        movzx eax,[dr_flag]
548
    .no_edit:
585
        movzx ebx,[ray_shd_flag]
549
 
586
        shl   ebx,10
-
 
587
        or    eax,ebx
-
 
588
        cmp   [sinus_flag],0
-
 
589
        je    .no_sin
-
 
590
        movzx eax,[dr_flag]
550
      .blurrr:
591
        movzx ebx,[ray_shd_flag]
-
 
592
        shl   ebx,10
-
 
593
        or    eax,ebx
551
        cmp  [sinus_flag],0
594
        call  do_sinus
-
 
595
      ;  jmp   .finito
552
        je   @f
596
      .no_sin:
553
        call do_sinus
597
      @@:
554
      @@:
598
        movzx   ecx,[fire_flag]
555
        cmp     [fire_flag],0
599
        cmp     [fire_flag],1
556
        jne     @f
600
        je      @f
557
        cmp     [blur_flag],0
-
 
558
        je      .no_blur  ; no blur, no fire
-
 
559
        movzx   ecx,[blur_flag]
601
        cmp     [blur_flag],0
560
        call    blur_screen    ; blur and fire
602
        je      .no_blur  ; no blur, no fire
561
        jmp     .no_blur
603
        movzx   ecx,[blur_flag]
-
 
604
      @@:
562
    @@:
605
        movzx   eax,[dr_flag]
563
        cmp     [emboss_flag],0
606
        movzx   ebx,[ray_shd_flag]
-
 
607
        shl     ebx,10
-
 
608
        or      eax,ebx
564
        jne     .emb           ; if emboss=true -> no fire
609
        call    blur_screen    ; blur and fire
565
        movzx   ecx,[fire_flag]
610
     ;   jmp     .finito
566
        call    blur_screen    ; blur and fire
611
 
-
 
612
    .no_blur:                  ; no blur, no fire
-
 
613
        cmp     [emboss_flag],0
-
 
614
        je      @f
567
    .no_blur:                  ; no blur, no fire
615
        movzx eax,[dr_flag]
568
        cmp     [emboss_flag],0
616
        movzx ebx,[ray_shd_flag]
569
        je      @f
617
        shl   ebx,10
570
     .emb:
618
        or    eax,ebx
Line 571... Line 619...
571
        call    do_emboss
619
        call    do_emboss
572
 
620
    .finito:
Line 705... Line 753...
705
    mov     eax,7           ; put image
753
    mov     eax,7           ; put image
706
    mov     ebx,[screen_ptr]
754
    mov     ebx,[screen_ptr]
707
    mov     ecx,[size_y_var]
755
    mov     ecx,[size_y_var]
708
    mov    edx,[offset_y]
756
    mov     edx,[offset_y]
-
 
757
    cmp     [ray_shd_flag],1
-
 
758
    jge     .ff
709
    cmp     [dr_flag],11
759
    cmp     [dr_flag],11
710
    jge     .ff
760
    jge     .ff
711
    int     0x40
761
    int     0x40
712
    jmp     .f
762
    jmp     .f
713
  .ff:
763
  .ff:
Line 762... Line 812...
762
include "3r_phg.inc"
812
include "3r_phg.inc"
763
include '3stencil.inc'
813
include '3stencil.inc'
764
include '3glass.inc'
814
include '3glass.inc'
765
include '3glass_tex.inc'
815
include '3glass_tex.inc'
766
end if
816
include '3ray_shd.inc'
-
 
817
end if
767
clear_vertices_index:
818
clear_vertices_index:
768
    mov   edi,[vertices_index_ptr]
819
    mov   edi,[vertices_index_ptr]
769
    movzx eax,word[size_x_var]
820
    movzx eax,word[size_x_var]
770
    movzx ecx,word[size_y_var]
821
    movzx ecx,word[size_y_var]
771
    imul  ecx,eax
822
    imul  ecx,eax
Line 1073... Line 1124...
1073
      fninit
1124
      fninit
1074
      fldpi
1125
      fldpi
1075
      fadd      st,st
1126
      fadd      st,st
1076
      mov       esi,[points_ptr]
1127
      mov       esi,[points_ptr]
1077
      mov       edi,tex_points
1128
      mov       edi,[tex_points_ptr]
1078
      mov       ecx,[points_count_var]
1129
      mov       ecx,[points_count_var]
1079
      inc       ecx
1130
      inc       ecx
1080
;      cmp       [map_tex_flag],1
1131
;      cmp       [map_tex_flag],1
1081
;      jne       .cylindric
1132
;      jne       .cylindric
1082
      ; spherical mapping around y axle
1133
      ; spherical mapping around y axle
Line 1387... Line 1438...
1387
    .env_done:
1438
    .env_done:
1388
         mov     esp,ebp
1439
         mov     esp,ebp
1389
         pop     ebp
1440
         pop     ebp
1390
ret
1441
ret
-
 
1442
 
1391
if Ext >= SSE3
1443
if   Ext >= SSE2
1392
init_point_normals:
1444
init_point_normals:
1393
.z equ dword [ebp-8]
1445
.z equ dword [ebp-8]
1394
.y equ dword [ebp-12]
1446
.y equ dword [ebp-12]
1395
.x equ [ebp-16]
1447
.x equ [ebp-16]
1396
.point_number equ dword [ebp-28]
1448
.point_number equ dword [ebp-28]
1397
.hit_faces    equ dword [ebp-32]
1449
.hit_faces    equ dword [ebp-32]
Line 1398... Line -...
1398
 
-
 
1399
        fninit
1450
 
1400
        push      ebp
1451
        push      ebp
1401
        mov       ebp,esp
1452
        mov       ebp,esp
1402
        sub       esp,64
1453
        sub       esp,64
1403
        and       ebp,-16
1454
        and       ebp,-16
Line 1436... Line 1487...
1436
        cmp       ecx,[triangles_count_var]
1487
        cmp       ecx,[triangles_count_var]
1437
        jne       .ipn_check_face
1488
        jne       .ipn_check_face
1438
        cvtsi2ss  xmm6,.hit_faces
1489
        cvtsi2ss  xmm6,.hit_faces
1439
        movaps    xmm7,.x
1490
        movaps    xmm7,.x
1440
        rcpss     xmm6,xmm6
1491
 
-
 
1492
        rcpss     xmm6,xmm6
1441
        shufps    xmm6,xmm6,11000000b
1493
        shufps    xmm6,xmm6,11000000b
1442
        mulps     xmm7,xmm6
1494
        mulps     xmm7,xmm6
1443
        movaps    xmm6,xmm7
1495
        movlps    [edi],xmm7
1444
        mulps     xmm6,xmm6
-
 
1445
        andps     xmm6,[zero_hgst_dd]
-
 
1446
        haddps    xmm6,xmm6
-
 
1447
        haddps    xmm6,xmm6
-
 
1448
        rsqrtps    xmm6,xmm6
-
 
1449
        mulps     xmm7,xmm6
-
 
1450
        movlps    [edi],xmm7
-
 
1451
        movhlps   xmm7,xmm7
1496
        movhlps   xmm7,xmm7
1452
        movss     [edi+8],xmm7
1497
        movss     [edi+8],xmm7
1453
        add       edi,12
1498
        call      normalize_vector
-
 
1499
    ;    movaps    xmm6,xmm7
-
 
1500
    ;    mulps     xmm6,xmm6
-
 
1501
    ;    andps     xmm6,[zero_hgst_dd]
-
 
1502
    ;    haddps    xmm6,xmm6
-
 
1503
    ;    haddps    xmm6,xmm6
-
 
1504
    ;    rsqrtps    xmm6,xmm6
-
 
1505
    ;    mulps     xmm7,xmm6
-
 
1506
    ;    movlps    [edi],xmm7
-
 
1507
    ;    movhlps   xmm7,xmm7
-
 
1508
    ;    movss     [edi+8],xmm7
-
 
1509
 
-
 
1510
        add       edi,12
1454
        inc       .point_number
1511
        inc       .point_number
1455
        mov       edx,.point_number
1512
        mov       edx,.point_number
1456
        cmp       edx,[points_count_var]
1513
        cmp       edx,[points_count_var]
1457
        jne       .ipn_loop
1514
        jne       .ipn_loop
1458
 
1515
 
Line 1574... Line 1631...
1574
        add     ebx,12
1631
        add     ebx,12
1575
        pop     ecx
1632
        pop     ecx
1576
        sub     ecx,1
1633
        sub     ecx,1
1577
        jnz     @b
1634
        jnz     @b
1578
       ; cmp     dword[ebp],-1
1635
ret
1579
       ; jne     @b
-
 
1580
ret
-
 
1581
 
1636
 
Line 1582... Line 1637...
1582
if Ext >= SSE3
1637
 
1583
copy_lights: ; after normalising !
1638
copy_lights: ; after normalising !
1584
        mov      esi,lights
1639
        mov      esi,lights
1585
        mov      edi,lights_aligned
1640
        mov      edi,lights_aligned
1586
        mov      ecx,3
1641
        mov      ecx,3
1587
       .again:
1642
       .again:
Line 1608... Line 1663...
1608
        inc      esi  ; skip  shiness
1663
        inc      esi  ; skip  shiness
1609
        pop      ecx
1664
        pop      ecx
1610
        loop     .again
1665
        loop     .again
1611
ret
1666
ret
1612
end if
1667
 
1613
 
1668
 
Line 1614... Line 1669...
1614
clrscr:
1669
clrscr:
1615
        mov     edi,[screen_ptr]
1670
        mov     edi,[screen_ptr]
1616
        movzx   ecx,word[size_x_var]
1671
        movzx   ecx,word[size_x_var]
1617
        movzx   eax,word[size_y_var]
1672
        movzx   eax,word[size_y_var]
Line 1652... Line 1707...
1652
ret
1707
ret
Line 1653... Line 1708...
1653
 
1708
 
-
 
1709
 
-
 
1710
draw_triangles:
-
 
1711
;  in:  eax - render draw model
-
 
1712
        .tri_no          equ dword[ebp-60]
-
 
1713
        .point_index3    equ [ebp-8]
-
 
1714
        .point_index2    equ [ebp-12]
-
 
1715
        .point_index1    equ [ebp-16]
-
 
1716
        .yy3             equ [ebp-18]
-
 
1717
        .xx3             equ [ebp-20]
-
 
1718
        .yy2             equ [ebp-22]
-
 
1719
        .xx2             equ [ebp-24]
-
 
1720
        .yy1             equ [ebp-26]
-
 
1721
        .xx1             equ [ebp-28]
-
 
1722
 
-
 
1723
        .zz3             equ [ebp-30]
-
 
1724
        .zz2             equ [ebp-32]
-
 
1725
        .zz1             equ [ebp-34]
-
 
1726
        .index3x12       equ [ebp-38]
-
 
1727
        .index2x12       equ [ebp-42]
-
 
1728
        .index1x12       equ [ebp-46]
-
 
1729
        .temp1           equ dword[ebp-50]
-
 
1730
        .temp2           equ dword[ebp-54]
-
 
1731
        .dr_flag         equ word[ebp-56]
-
 
1732
 
-
 
1733
 
-
 
1734
        push    ebp
-
 
1735
        mov     ebp,esp
-
 
1736
        sub     esp,60
-
 
1737
 
-
 
1738
 ;       movzx   ax,[dr_flag]
Line 1654... Line 1739...
1654
 
1739
        mov     .dr_flag,ax
1655
draw_triangles:
1740
 
1656
 
1741
 
1657
        emms
1742
        emms
Line 1669... Line 1754...
1669
        paddw   mm1,mm0
1754
        paddw   mm1,mm0
1670
        movd    dword[eax],mm1
1755
        movd    dword[eax],mm1
1671
     @@:
1756
     @@:
1672
     if Ext >= SSE3
1757
     if Ext >= SSE3
1673
        cmp     [dr_flag],13
1758
 
-
 
1759
        cmp     .dr_flag,13
1674
        jnge    .no_stencil
1760
        jnge    .no_stencil
1675
        mov     esi,[triangles_ptr]
1761
        mov     esi,[triangles_ptr]
1676
        mov     ecx,[triangles_count_var]
1762
        mov     ecx,[triangles_count_var]
1677
     @@:
1763
     @@:
1678
        push    esi
1764
        push    esi
1679
        push    ecx
1765
        push    ecx
Line 1732... Line 1818...
1732
        cmp     [dr_flag],11
1818
        cmp     [dr_flag],11
1733
        je      .draw_smooth_line
1819
        je      .draw_smooth_line
Line 1734... Line 1820...
1734
 
1820
 
1735
        mov esi,[triangles_ptr]
1821
        mov esi,[triangles_ptr]
1736
        mov ecx,[triangles_count_var]
1822
        xor ecx,ecx  ;mov ecx,[triangles_count_var]
-
 
1823
    .again_dts:
-
 
1824
       ; push    ebp
1737
    .again_dts:
1825
        push    esi
1738
        push    ecx
-
 
1739
        mov     ebp,[points_translated_ptr]
-
 
1740
      if Ext >= SSE2
-
 
1741
        mov     eax,dword[esi]
-
 
1742
        mov     [point_index1],eax
-
 
1743
        lea     eax,[eax*3]
-
 
1744
        add     eax,eax
-
 
1745
        push    ebp
-
 
1746
        add     ebp,eax
-
 
1747
        mov     eax,[ebp]
-
 
1748
   ;     cmp     [vertex_edit_no],0
-
 
1749
   ;     jne     @f
-
 
1750
   ;
-
 
1751
   ;   @@:
-
 
1752
        mov     dword[xx1],eax
-
 
1753
        mov     eax,[ebp+4]
1826
        push    ecx
1754
        mov     [zz1],ax
-
 
1755
 
-
 
1756
        pop     ebp
-
 
1757
 
-
 
1758
 
-
 
1759
        mov     eax,dword[esi+4]
-
 
1760
        mov     [point_index2],eax
-
 
1761
        lea     eax,[eax*3]
-
 
1762
        add     eax,eax
-
 
1763
        push    ebp
-
 
1764
        add     ebp,eax
-
 
1765
        mov     eax,[ebp]
-
 
1766
        mov     dword[xx2],eax
-
 
1767
        mov     eax,[ebp+4]
-
 
1768
        mov     [zz2],ax
-
 
Line -... Line 1827...
-
 
1827
        mov     .tri_no,ecx
-
 
1828
 
-
 
1829
        mov     eax,[esi]
Line 1769... Line -...
1769
        pop     ebp
-
 
1770
 
1830
        mov     ebx,[esi+4]
1771
 
-
 
1772
        mov     eax,dword[esi+8]        ; xyz3 = [ebp+[esi+4]*6]
-
 
1773
        mov     [point_index3],eax
-
 
1774
        lea     eax,[eax*3]
-
 
1775
        add     eax,eax
-
 
1776
    ;    push    ebp
-
 
1777
        add     ebp,eax
-
 
1778
        mov     eax,[ebp]
-
 
1779
        mov     dword[xx3],eax
-
 
1780
        mov     eax,[ebp+4]
-
 
1781
        mov     [zz3],ax
-
 
1782
      else
-
 
1783
        movq    mm0,[esi]           ; don't know MMX
1831
        mov     ecx,[esi+8]
1784
        mov     qword[point_index1],mm0
-
 
1785
       ; shr     eax,16
1832
 
1786
       ; mov     [point_index2],ax
-
 
1787
        mov     eax,dword[esi+8]
-
 
1788
        mov     [point_index3],eax
-
 
1789
        movdqu  xmm0,[esi]
-
 
1790
        paddd   xmm0,xmm0
-
 
1791
        movdqa  xmm1,xmm0
1833
        mov     .point_index1,eax
1792
        paddd   xmm0,xmm0
-
 
1793
        paddd   xmm0,xmm1
1834
        mov     .point_index2,ebx
1794
        movd    eax,xmm0
-
 
1795
        psrldq  xmm0,4
1835
        mov     .point_index3,ecx
1796
        movd    ebx,xmm0
-
 
1797
        psrldq  xmm0,4
-
 
1798
        movd    ecx,xmm0
-
 
1799
        and     eax,0FFFFh
-
 
1800
        and     ebx,0FFFFh
-
 
1801
        and     ecx,0FFFFh
-
 
1802
        movq    mm0,[ebp+eax]
1836
        imul    eax,[i12]
1803
        movq    mm1,[ebp+ebx]
-
 
1804
        movq    mm2,[ebp+ecx]
1837
        imul    ebx,[i12]
1805
        movq    qword[xx1],mm0
-
 
1806
        movq    qword[xx2],mm1
-
 
1807
        movq    qword[xx3],mm2
-
 
1808
;        emms
-
 
1809
      end if  ; *********************************
-
 
1810
 if 0
-
 
1811
        cmp     [vertex_edit_no],0
-
 
1812
        jne     .no_edit
-
 
1813
        mov     ax,[vertex_edit_no]
-
 
1814
        dec     ax
-
 
1815
        cmp     ax,[point_index1]
-
 
1816
        jne     @f
-
 
1817
        movd    mm0,[edit_start_x]
-
 
1818
        psubw   mm0,[edit_end_x]
1838
        imul    ecx,[i12]
1819
        movd    mm1,dword[xx1]
-
 
1820
        paddw   mm1,mm0
-
 
Line 1821... Line 1839...
1821
        movd    dword[xx1],mm1
1839
        mov     .index1x12,eax
1822
        jmp     .no_edit
1840
        mov     .index2x12,ebx
-
 
1841
        mov     .index3x12,ecx
-
 
1842
 
-
 
1843
        shr     eax,1
1823
       @@:
1844
        shr     ebx,1
1824
 
1845
        shr     ecx,1
1825
        cmp     ax,[point_index2]
1846
        add     eax,[points_translated_ptr]
1826
        jne     @f
1847
        add     ebx,[points_translated_ptr]
1827
        movd    mm0,[edit_start_x]
1848
        add     ecx,[points_translated_ptr]
1828
        psubw   mm0,[edit_end_x]
1849
        push    word[eax+4]
1829
        movd    mm1,dword[xx2]
1850
        push    word[ebx+4]
Line 1830... Line 1851...
1830
        paddw   mm1,mm0
1851
        push    word[ecx+4]
1831
        movd    dword[xx2],mm1
1852
        pop     word .zz3
1832
        jmp     .no_edit
1853
        pop     word .zz2
1833
       @@:
1854
        pop     word .zz1
1834
 
1855
 
1835
        cmp     ax,[point_index3]
1856
        mov     eax,[eax]
1836
        jne     @f
1857
        mov     ebx,[ebx]
1837
        movd    mm0,[edit_start_x]
1858
        mov     ecx,[ecx]
1838
        psubw   mm0,[edit_end_x]
1859
        ror     eax,16
Line 1839... Line -...
1839
        movd    mm1,dword[xx3]
-
 
1840
        paddw   mm1,mm0
-
 
Line 1841... Line 1860...
1841
        movd    dword[xx3],mm1
1860
        ror     ebx,16
1842
        jmp     .no_edit
1861
        ror     ecx,16
1843
       @@:
1862
        mov     .xx1,eax
1844
 
1863
        mov     .xx2,ebx
1845
 
1864
        mov     .xx3,ecx
1846
    .no_edit:
1865
 
1847
end if
1866
 
1848
 
1867
 
1849
        push esi                          ;
1868
      ;  push    esi
1850
        fninit                            ; DO culling AT FIRST
1869
        fninit                            ; DO culling AT FIRST
1851
        cmp     [culling_flag],1          ; (if culling_flag = 1)
1870
        cmp     [culling_flag],1          ; (if culling_flag = 1)
1852
        jne     .no_culling
1871
        jne     .no_culling
-
 
1872
        lea     esi,.point_index1          ; *********************************
-
 
1873
        mov     ecx,3                     ;
1853
        mov     esi,point_index1          ; *********************************
1874
      @@:
1854
        mov     ecx,3                     ;
1875
        mov     eax,dword[esi]
1855
      @@:
1876
        lea     eax,[eax*3]
1856
        mov     eax,dword[esi]
-
 
1857
        lea     eax,[eax*3]
1877
        shl     eax,2
1858
        shl     eax,2
-
 
1859
        add     eax,[points_normals_rot_ptr]
1878
        add     eax,[points_normals_rot_ptr]
1860
;        lea     eax,[eax+point_normals_rotated]
1879
        mov     eax,[eax+8]
1861
        fld     dword[eax+8]             ; *****************************
1880
        bt      eax,31
1862
        ftst                             ; CHECKING OF Z COOFICIENT OF
-
 
-
 
1881
        jc      @f
1863
        fstsw   ax                       ; NORMAL VECTOR
1882
                       ; *****************************
1864
        sahf
1883
                       ; CHECKING OF Z COOFICIENT OF
1865
        jb      @f
1884
                       ; NORMAL VECTOR
1866
        ffree   st
1885
        add     esi,4
1867
        loop    @b
1886
        loop    @b
1868
        jmp     .end_draw   ; non visable
1887
        jmp     .end_draw   ; non visable
1869
      @@:
1888
      @@:
1870
        ffree   st  ;is visable
1889
 
1871
      .no_culling:
1890
      .no_culling:
1872
        cmp     [dr_flag],0               ; draw type flag
1891
        cmp     .dr_flag,0               ; draw type flag
1873
        je      .flat_draw
1892
        je      .flat_draw
1874
        cmp     [dr_flag],2
1893
        cmp     .dr_flag,2
1875
        je      .env_mapping
1894
        je      .env_mapping
1876
        cmp     [dr_flag],3
1895
        cmp     .dr_flag,3
1877
        je      .bump_mapping
1896
        je      .bump_mapping
1878
        cmp     [dr_flag],4
1897
        cmp     .dr_flag,4
1879
        je      .tex_mapping
1898
        je      .tex_mapping
1880
        cmp     [dr_flag],5
1899
        cmp     .dr_flag,5
1881
        je      .rainbow
1900
        je      .rainbow
1882
        cmp     [dr_flag],7
1901
        cmp     .dr_flag,7
1883
        je      .grd_tex
1902
        je      .grd_tex
1884
        cmp     [dr_flag],8
1903
        cmp     .dr_flag,8
1885
        je      .two_tex
1904
        je      .two_tex
1886
        cmp     [dr_flag],9
1905
        cmp     .dr_flag,9
1887
        je      .bump_tex
1906
        je      .bump_tex
1888
        cmp     [dr_flag],10
1907
        cmp     .dr_flag,10
1889
        je      .cubic_env_mapping
1908
        je      .cubic_env_mapping
1890
        cmp     [dr_flag],11
1909
        cmp     .dr_flag,11
-
 
1910
        je      .draw_smooth_line
-
 
1911
      if Ext >= SSE3
-
 
1912
        cmp     .dr_flag,12
-
 
1913
        je      .r_phg
-
 
1914
        cmp     .dr_flag,13
1891
        je      .draw_smooth_line
1915
        je      .glass
1892
      if Ext >= SSE3
1916
        cmp     .dr_flag,14
-
 
1917
        je      .glass_tex
1893
        cmp     [dr_flag],12
1918
        cmp     .dr_flag,100
1894
        je      .r_phg
1919
        je      .ray_shd
1895
        cmp     [dr_flag],13
1920
 
1896
        je      .glass
-
 
1897
        cmp     [dr_flag],14
-
 
1898
        je      .glass_tex
1921
     end if
1899
     end if                                 ; ****************
1922
 
1900
        mov     esi,point_index3      ; do Gouraud shading
1923
        push    ebp                    ; ****************
1901
        mov     ecx,3
1924
        lea     esi,.index3x12      ; do Gouraud shading
1902
      .again_grd_draw:
1925
        lea     edi,.zz3
1903
        mov     eax,dword[esi]
1926
        mov     ecx,3
1904
        shl     eax,2
1927
      .again_grd_draw:
1905
        lea     eax,[eax*3]
1928
        mov     eax,dword[esi]
1906
        add     eax,[points_normals_rot_ptr]
1929
        add     eax,[points_normals_rot_ptr]
1907
        ; texture x=(rotated point normal -> x * 255)+255
1930
        ; texture x=(rotated point normal -> x * 255)+255
1908
        fld     dword[eax]       ; x cooficient of normal vector
1931
        fld     dword[eax]       ; x cooficient of normal vector
Line 1909... Line 1932...
1909
        fimul   [correct_tex]
1932
        fimul   [correct_tex]
1910
        fiadd   [correct_tex]
1933
        fiadd   [correct_tex]
1911
        fistp   [temp1]
1934
        fistp   .temp1
1912
        ; texture y=(rotated point normal -> y * 255)+255
1935
        ; texture y=(rotated point normal -> y * 255)+255
1913
        fld     dword[eax+4]      ; y cooficient
1936
        fld     dword[eax+4]      ; y cooficient
1914
        fimul   [correct_tex]
1937
        fimul   [correct_tex]
1915
        fiadd   [correct_tex]
1938
        fiadd   [correct_tex]
1916
        fistp   [temp2]
-
 
1917
 
-
 
1918
        mov      eax,[temp2]
-
 
1919
        mov      ebx,[temp1]
1939
        fistp   .temp2
1920
        and      ebx,0xfffffff
1940
 
1921
        shl      eax,TEX_SHIFT
1941
        mov      eax,.temp2
1922
        add      eax,ebx
1942
        mov      ebx,.temp1
1923
        lea      eax,[eax*3+color_map]
1943
        and      ebx,0xfffffff
1924
        mov      eax,dword[eax]
1944
        shl      eax,TEX_SHIFT
1925
     ;   cmp     [catmull_flag],1      ; put on stack z coordinate if necessary
1945
        add      eax,ebx
1926
     ;   jne      @f
1946
        lea      eax,[eax*3+color_map]
1927
        lea      edx,[ecx*3]
1947
        mov      eax,dword[eax]
1928
        push     word[edx*2+xx1-2]    ; zz1 ,2 ,3
1948
        push     word[edi]    ; zz1 ,2 ,3
Line 1929... Line 1949...
1929
     ; @@:
1949
 
-
 
1950
        ror      eax,16               ; eax -0xxxrrggbb -> 0xggbbxxrr
1930
        ror      eax,16               ; eax -0xxxrrggbb -> 0xggbbxxrr
1951
        xor      ah,ah
1931
        xor      ah,ah
1952
        push     ax         ;r
1932
        push     ax         ;r
1953
        rol      eax,8                ; eax-0xggbb00rr -> 0xbb00rrgg
Line 1933... Line -...
1933
        rol      eax,8                ; eax-0xggbb00rr -> 0xbb00rrgg
-
 
1934
        xor      ah,ah
-
 
1935
        push     ax         ;g
-
 
1936
        shr      eax,24
-
 
1937
        push     ax         ;b
-
 
1938
 
-
 
1939
        sub      esi,4
-
 
1940
        dec      cx
-
 
1941
        jnz      .again_grd_draw
-
 
1942
        jmp      .both_draw
-
 
1943
 
-
 
1944
   ;     movzx   edi,[point_index3]   ;gouraud shading according to light vector
-
 
1945
   ;     lea     edi,[edi*3]
-
 
1946
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
-
 
1947
   ;     mov     esi,light_vector
-
 
1948
   ;     call    dot_product
-
 
1949
   ;     fabs
-
 
1950
   ;     fimul   [orginal_color_r]
-
 
1951
   ;     fistp   [temp_col]
-
 
1952
   ;     and     [temp_col],0x00ff
-
 
1953
   ;     push    [temp_col]
-
 
1954
   ;     push    [temp_col]
-
 
1955
   ;     push    [temp_col]
-
 
1956
 
-
 
1957
   ;     movzx   edi,[point_index2]
-
 
1958
   ;     lea     edi,[edi*3]
-
 
1959
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
-
 
1960
   ;     mov     esi,light_vector
-
 
1961
   ;     call    dot_product
-
 
1962
   ;     fabs
-
 
1963
   ;     fimul   [orginal_color_r]
-
 
1964
   ;     fistp    [temp_col]
-
 
1965
   ;     and     [temp_col],0x00ff
-
 
1966
   ;     push    [temp_col]
-
 
1967
   ;     push    [temp_col]
-
 
1968
   ;     push    [temp_col]
-
 
1969
 
-
 
1970
   ;     movzx   edi,[point_index1]
-
 
1971
   ;     lea     edi,[edi*3]
1954
        xor      ah,ah
1972
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
-
 
1973
   ;     mov     esi,light_vector
1955
        push     ax         ;g
1974
   ;     call    dot_product
1956
        shr      eax,24
-
 
1957
        push     ax         ;b
1975
   ;     fabs
1958
 
1976
   ;     fimul   [orginal_color_r]
1959
        sub      esi,4
1977
   ;     fistp   [temp_col]
1960
        sub      edi,2
1978
   ;     and     [temp_col],0x00ff
1961
        dec      cx
1979
   ;     push    [temp_col]
1962
        jnz      .again_grd_draw
1980
   ;     push    [temp_col]
1963
        jmp      .both_draw
1981
   ;     push    [temp_col]
1964
 
1982
   .rainbow:
1965
   .rainbow:
Line 1983... Line 1966...
1983
       ; cmp     [catmull_flag],1      ; put on stack z coordinate if necessary
1966
        push     ebp
-
 
1967
        push     word .zz3
1984
       ; jne      @f
1968
 
1985
        push     [zz3]
1969
        mov      eax, .xx3
1986
      @@:
1970
        ror      eax,16
1987
        mov      eax,dword[yy3]
1971
        mov      ebx,0x00ff00ff
1988
        mov      ebx,0x00ff00ff
1972
        and      eax,ebx
Line 1989... Line 1973...
1989
        and      eax,ebx
1973
        push     eax
-
 
1974
        neg      al
1990
        push     eax
1975
        push     ax
1991
        neg      al
1976
        push     word .zz2
1992
        push     ax
1977
 
1993
        push     [zz2]
1978
        mov      eax, .xx2
1994
 
1979
        ror      eax,16
1995
        mov      eax,dword[yy2]
1980
        and      eax,ebx
1996
        and      eax,ebx
-
 
1997
        push     eax
1981
        push     eax
1998
        neg      al
-
 
1999
        push     ax
1982
        neg      al
2000
        push     [zz1]
-
 
2001
 
1983
        push     ax
2002
        mov      eax,dword[yy1]
1984
        push     word .zz1
2003
        and      eax,ebx
1985
 
-
 
1986
        mov      eax, .xx1
2004
        push     eax
1987
        ror      eax,16
Line 2005... Line 1988...
2005
        neg      al
1988
        and      eax,ebx
2006
        push     ax
1989
        push     eax
2007
    .both_draw:
1990
        neg      al
2008
        mov     eax,dword[xx1]
1991
        push     ax
2009
        ror     eax,16
1992
    .both_draw:
2010
        mov     ebx,dword[xx2]
-
 
2011
        ror     ebx,16
-
 
2012
        mov     ecx,dword[xx3]
-
 
2013
        ror     ecx,16
-
 
2014
        mov     edi,[screen_ptr]
1993
        mov     eax, .xx1
2015
        mov     esi,[Zbuffer_ptr]
-
 
2016
        call    gouraud_triangle_z
1994
        mov     ebx, .xx2
2017
        jmp     .end_draw
-
 
2018
 
1995
        mov     ecx, .xx3
2019
     .flat_draw:                     ;**************************
1996
        mov     edi,[screen_ptr]
2020
        fninit                             ; FLAT DRAWING
1997
        mov     esi,[Zbuffer_ptr]
2021
        mov     eax,[point_index1]
1998
        call    gouraud_triangle_z
2022
        mov     ebx,[point_index2]
1999
        pop     ebp
2023
        mov     ecx,[point_index3]
2000
        jmp     .end_draw
2024
        shl     eax,2
2001
 
2025
        shl     ebx,2
2002
     .flat_draw:                     ;**************************
2026
        shl     ecx,2
2003
        fninit                             ; FLAT DRAWING
2027
        lea     eax,[eax*3]  ;+point_normals_rotated]
2004
        mov     eax,.index1x12
2028
        add     eax,[points_normals_rot_ptr]
2005
        mov     ebx,.index2x12
2029
        lea     ebx,[ebx*3]  ;+point_normals_rotated]
2006
        mov     ecx,.index3x12
2030
        add     ebx,[points_normals_rot_ptr]
2007
        add     eax,[points_normals_rot_ptr]
2031
        lea     ecx,[ecx*3]  ;+point_normals_rotated]
2008
        add     ebx,[points_normals_rot_ptr]
2032
        add     ecx,[points_normals_rot_ptr]
2009
        add     ecx,[points_normals_rot_ptr]
2033
        fld     dword[eax]      ; x cooficient of normal vector
2010
        fld     dword[eax]      ; x cooficient of normal vector
2034
        fadd    dword[ebx]
2011
        fadd    dword[ebx]
2035
        fadd    dword[ecx]
2012
        fadd    dword[ecx]
2036
        fidiv   [i3]
2013
        fidiv   [i3]
2037
        fimul   [correct_tex]
2014
        fimul   [correct_tex]
Line 2038... Line 2015...
2038
        fiadd   [correct_tex]
2015
        fiadd   [correct_tex]
2039
        fistp   [temp1]  ;dword[esp-4]    ; x temp variables
2016
        fistp   .temp1  ;dword[esp-4]    ; x temp variables
2040
        fld     dword[eax+4]    ; y cooficient of normal vector
2017
        fld     dword[eax+4]    ; y cooficient of normal vector
Line 2069... Line 2046...
2069
     ;   mov     ah,al           ;set color according to z position
2046
     ;   mov     ah,al           ;set color according to z position
2070
     ;   shl     eax,8
2047
     ;   shl     eax,8
2071
     ;   mov     edx,eax
2048
     ;   mov     edx,eax
2072
 
2049
 
Line 2073... Line 2050...
2073
        mov     eax,dword[xx1]
2050
        mov     eax,dword .xx1
2074
        ror     eax,16
-
 
2075
        mov     ebx,dword[xx2]
2051
        mov     ebx,dword .xx2
2076
        ror     ebx,16
-
 
2077
        mov     ecx,dword[xx3]
2052
        mov     ecx,dword .xx3
2078
        ror     ecx,16
-
 
2079
        mov     edi,[screen_ptr]
2053
        mov     edi,[screen_ptr]
Line 2080... Line 2054...
2080
 
2054
 
-
 
2055
        mov     esi,[Zbuffer_ptr]
2081
        mov     esi,[Zbuffer_ptr]
2056
        push    ebp
2082
        push    word[zz3]
2057
        push    word .zz3
2083
        push    word[zz2]
2058
        push    word .zz2
2084
        push    word[zz1]
2059
        push    word .zz1
-
 
2060
        call    flat_triangle_z
2085
        call    flat_triangle_z
2061
        pop     ebp
Line 2086... Line 2062...
2086
        jmp     .end_draw
2062
        jmp     .end_draw
2087
 
2063
 
-
 
2064
      .env_mapping:
2088
      .env_mapping:
2065
        push    ebp
2089
        push    [zz3]
2066
        push    word .zz3
Line 2090... Line 2067...
2090
        push    [zz2]
2067
        push    word .zz2
2091
        push    [zz1]
2068
        push    word .zz1
2092
 
2069
 
2093
        mov     esi,point_index1
2070
        lea     esi, .index1x12
2094
        sub     esp,12
2071
        sub     esp,12
2095
        mov     edi,esp
2072
        mov     edi,esp
2096
        mov     ecx,3
-
 
2097
      @@:
-
 
2098
        mov     eax,dword[esi]
2073
        mov     ecx,3
2099
        lea     eax,[eax*3]
2074
      @@:
2100
        shl     eax,2
2075
        mov     eax,dword[esi]
2101
        add     eax,[points_normals_rot_ptr]       ;point_normals_rotated
2076
        add     eax,[points_normals_rot_ptr]       ;point_normals_rotated
2102
        ; texture x=(rotated point normal -> x * 255)+255
2077
        ; texture x=(rotated point normal -> x * 255)+255
Line 2113... Line 2088...
2113
        add     edi,4
2088
        add     edi,4
2114
        add     esi,4
2089
        add     esi,4
2115
        loop    @b
2090
        loop    @b
Line 2116... Line 2091...
2116
 
2091
 
2117
        mov     eax,dword[xx1]
-
 
2118
        ror     eax,16
2092
        mov     eax, .xx1
2119
        mov     ebx,dword[xx2]
-
 
2120
        ror     ebx,16
2093
        mov     ebx,dword .xx2
2121
        mov     ecx,dword[xx3]
-
 
2122
        ror     ecx,16
2094
        mov     ecx,dword .xx3
2123
        mov     edi,[screen_ptr]
2095
        mov     edi,[screen_ptr]
Line 2124... Line 2096...
2124
        mov     esi,envmap
2096
        mov     esi,envmap
2125
 
2097
 
2126
        mov     edx,[Zbuffer_ptr]
-
 
-
 
2098
        mov     edx,[Zbuffer_ptr]
2127
        call    tex_triangle_z
2099
        call    tex_triangle_z
2128
 
2100
        pop     ebp
2129
        jmp     .end_draw
2101
        jmp     .end_draw
2130
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2102
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
2103
     .cubic_env_mapping:
2131
     .cubic_env_mapping:
2104
        push    ebp
2132
        push    [zz3]
2105
        push    word .zz3
Line 2133... Line 2106...
2133
        push    [zz2]
2106
        push    word .zz2
2134
        push    [zz1]
2107
        push    word .zz1
2135
 
2108
 
2136
        mov     esi,point_index1
2109
        lea     esi,.index1x12
2137
        sub     esp,12
2110
        sub     esp,12
2138
        mov     edi,esp
2111
        mov     edi,esp
2139
        mov     ecx,3
-
 
2140
      @@:
-
 
2141
        mov     eax,dword[esi]
2112
        mov     ecx,3
Line 2142... Line 2113...
2142
        lea     eax,[eax*3]
2113
      @@:
2143
        shl     eax,2
2114
        mov     eax,dword[esi]
2144
        add     eax,[points_normals_rot_ptr]
2115
        add     eax,[points_normals_rot_ptr]
Line 2169... Line 2140...
2169
        add     edi,4
2140
        add     edi,4
2170
        add     esi,4
2141
        add     esi,4
2171
        loop    @b
2142
        loop    @b
2172
 
2143
 
Line 2173... Line 2144...
2173
        mov     eax,dword[xx1]
2144
        mov     eax, .xx1
2174
        ror     eax,16
-
 
2175
        mov     ebx,dword[xx2]
2145
        mov     ebx, .xx2
2176
        ror     ebx,16
-
 
2177
        mov     ecx,dword[xx3]
2146
        mov     ecx, .xx3
2178
        ror     ecx,16
-
 
2179
        mov     edi,[screen_ptr]
2147
        mov     edi,[screen_ptr]
2180
        mov     esi,envmap_cub
2148
        mov     esi,envmap_cub
2181
        mov     edx,[Zbuffer_ptr]
2149
        mov     edx,[Zbuffer_ptr]
Line 2182... Line 2150...
2182
 
2150
 
2183
        call    tex_triangle_z
-
 
-
 
2151
        call    tex_triangle_z
2184
 
2152
        pop     ebp
Line 2185... Line 2153...
2185
        jmp     .end_draw
2153
        jmp     .end_draw
Line 2186... Line 2154...
2186
 
2154
 
2187
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
 
-
 
2155
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2188
 
2156
 
2189
      .bump_mapping:
2157
      .bump_mapping:
2190
 
2158
        push    ebp
2191
        push    [Zbuffer_ptr]
2159
        push    [Zbuffer_ptr]
Line 2192... Line 2160...
2192
        push    [zz3]
2160
        push    word .zz3
2193
        push    [zz2]
2161
        push    word .zz2
2194
        push    [zz1]
2162
        push    word .zz1
2195
 
2163
 
2196
        mov     esi,point_index1
2164
        lea     esi,.index1x12
2197
        sub     esp,12
2165
        sub     esp,12
2198
        mov     edi,esp
-
 
2199
        mov     ecx,3
-
 
2200
      @@:
2166
        mov     edi,esp
2201
        mov     eax,dword[esi]
2167
        mov     ecx,3
2202
        lea     eax,[eax*3]
2168
      @@:
2203
        shl     eax,2
2169
        mov     eax,dword[esi]
2204
        add     eax,[points_normals_rot_ptr]  ;point_normals_rotated
2170
        add     eax,[points_normals_rot_ptr]  ;point_normals_rotated
Line 2216... Line 2182...
2216
        add     edi,4
2182
        add     edi,4
2217
        add     esi,4
2183
        add     esi,4
2218
        loop    @b
2184
        loop    @b
Line 2219... Line 2185...
2219
 
2185
 
2220
        mov    esi,[point_index3]      ; bump map coords
2186
        mov    esi, .point_index3      ; bump map coords
2221
        shl    esi,2
2187
        shl    esi,2
2222
        add    esi,tex_points
2188
        add    esi,[tex_points_ptr]
2223
        push   dword[esi]
2189
        push   dword[esi]
2224
        mov    esi,[point_index2]
2190
        mov    esi, .point_index2
2225
        shl    esi,2
2191
        shl    esi,2
2226
        add    esi,tex_points
-
 
2227
;       lea    esi,[esi*3]
-
 
2228
;       lea    esi,[points+2+esi*2]
2192
        add    esi,[tex_points_ptr]
2229
        push   dword[esi]
-
 
2230
  ;     push   dword[xx2]
2193
        push   dword[esi]
2231
        mov    esi,[point_index1]
2194
        mov    esi, .point_index1
2232
        shl    esi,2
2195
        shl    esi,2
2233
        add    esi,tex_points
-
 
2234
;       lea     esi,[esi*3]
-
 
2235
;       lea     esi,[points+2+esi*2]
2196
        add    esi,[tex_points_ptr]
2236
        push   dword[esi]
-
 
Line 2237... Line 2197...
2237
   ;    push     dword[xx1]
2197
        push   dword[esi]
2238
 
-
 
2239
        mov     eax,dword[xx1]
2198
 
2240
        ror     eax,16
-
 
2241
        mov     ebx,dword[xx2]
2199
        mov     eax,dword .xx1
2242
        ror     ebx,16
-
 
2243
        mov     ecx,dword[xx3]
2200
        mov     ebx,dword .xx2
2244
        ror     ecx,16
2201
        mov     ecx,dword .xx3
2245
        mov     edi,[screen_ptr]
2202
        mov     edi,[screen_ptr]
Line 2246... Line 2203...
2246
        mov     esi,envmap
2203
        mov     esi,envmap
2247
        mov     edx,bumpmap            ;BUMP_MAPPING
-
 
-
 
2204
        mov     edx,bumpmap            ;BUMP_MAPPING
2248
 
2205
 
Line 2249... Line 2206...
2249
        call    bump_triangle_z
2206
        call    bump_triangle_z
2250
 
-
 
-
 
2207
        pop     ebp
2251
        jmp     .end_draw
2208
        jmp     .end_draw
2252
 
2209
 
2253
      .tex_mapping:
2210
      .tex_mapping:
2254
 
2211
        push   ebp
2255
        push    [zz3]
2212
        push   word .zz3
2256
        push    [zz2]
2213
        push   word .zz2
2257
        push    [zz1]
2214
        push   word .zz1
2258
   ;   @@:
2215
   ;   @@:
2259
        mov    esi,[point_index3]      ; tex map coords
2216
        mov    esi, .point_index3      ; tex map coords
2260
        shl    esi,2
2217
        shl    esi,2
2261
        add    esi,tex_points
2218
        add    esi,[tex_points_ptr]
2262
        push   dword[esi]
2219
        push   dword[esi]
2263
        mov    esi,[point_index2]
2220
        mov    esi, .point_index2
2264
        shl    esi,2
2221
        shl    esi,2
2265
        add    esi,tex_points
2222
        add    esi,[tex_points_ptr]
2266
        push   dword[esi]
2223
        push   dword[esi]
Line 2267... Line 2224...
2267
        mov    esi,[point_index1]
2224
        mov    esi, .point_index1
2268
        shl    esi,2
-
 
2269
        add    esi,tex_points
2225
        shl    esi,2
2270
        push   dword[esi]
-
 
2271
 
2226
        add    esi,[tex_points_ptr]
2272
        mov     eax,dword[xx1]
-
 
2273
        ror     eax,16
2227
        push   dword[esi]
2274
        mov     ebx,dword[xx2]
2228
 
2275
        ror     ebx,16
2229
        mov     eax,dword .xx1
Line 2276... Line 2230...
2276
        mov     ecx,dword[xx3]
2230
        mov     ebx,dword .xx2
2277
        ror     ecx,16
-
 
-
 
2231
        mov     ecx,dword .xx3
2278
        mov     edi,[screen_ptr]
2232
        mov     edi,[screen_ptr]
2279
        mov     esi,texmap
2233
        mov     esi,texmap
2280
         mov     edx,[Zbuffer_ptr]
2234
        mov     edx,[Zbuffer_ptr]
2281
 
2235
 
2282
        call    tex_triangle_z
2236
        call    tex_triangle_z
Line 2317... Line 2271...
2317
;        jmp     .both_draw
2271
;        jmp     .both_draw
2318
 
2272
 
Line 2319... Line 2273...
2319
     .grd_tex:            ; smooth shading + texture
2273
     .grd_tex:            ; smooth shading + texture
2320
         push   ebp
2274
         push   ebp
2321
         mov    ebp,esp
-
 
2322
         sub    esp,4
-
 
2323
         push   ebp
-
 
Line 2324... Line 2275...
2324
 
2275
 
2325
         mov    esi,[point_index3]      ; tex map coords
2276
         mov    esi, .point_index3      ; tex map coords
2326
         shl    esi,2
2277
         shl    esi,2
2327
         add    esi,tex_points
2278
         add    esi,[tex_points_ptr]
2328
         push   dword[esi]              ; texture coords as first
2279
         push   dword[esi]              ; texture coords as first
2329
         mov    esi,[point_index2]      ; group of parameters
2280
         mov    esi, .point_index2      ; group of parameters
2330
         shl    esi,2
2281
         shl    esi,2
2331
         add    esi,tex_points
2282
         add    esi,[tex_points_ptr]
2332
         push   dword[esi]
2283
         push   dword[esi]
2333
         mov    esi,[point_index1]
2284
         mov    esi, .point_index1
2334
         shl    esi,2
2285
         shl    esi,2
2335
         add    esi,tex_points
2286
         add    esi,[tex_points_ptr]
Line 2336... Line 2287...
2336
         push   dword[esi]
2287
         push   dword[esi]
-
 
2288
 
2337
 
2289
         lea     esi, .index3x12
2338
         mov     esi,point_index3
-
 
2339
         mov     ecx,3
2290
         lea     edi, .zz3
Line 2340... Line -...
2340
 
-
 
2341
      .aagain_grd_draw:
2291
         mov     ecx,3
2342
 
2292
       .aagain_grd_draw:
2343
        lea      edx,[ecx*3]
2293
 
2344
        push     word[edx*2+xx1-2]    ; zz1 ,2 ,3
-
 
2345
        fninit
-
 
2346
        mov     eax,dword[esi]
2294
        push     word[edi]    ; zz1 ,2 ,3
2347
        shl     eax,2
2295
        fninit
2348
        lea     eax,[eax*3] ;+point_normals_rotated]
2296
        mov     eax,dword[esi]
2349
        add     eax,[points_normals_rot_ptr]
2297
        add     eax,[points_normals_rot_ptr]
2350
        ; texture x=(rotated point normal -> x * 255)+255
2298
        ; texture x=(rotated point normal -> x * 255)+255
2351
        fld     dword[eax]       ; x cooficient of normal vector
2299
        fld     dword[eax]       ; x cooficient of normal vector
2352
        fimul   [correct_tex]
2300
        fimul   [correct_tex]
2353
        fiadd   [correct_tex]
2301
        fiadd   [correct_tex]
2354
        fistp   [temp1]  ;word[ebp-2]
2302
        fistp   .temp1  ;word[ebp-2]
2355
        ; texture y=(rotated point normal -> y * 255)+255
2303
        ; texture y=(rotated point normal -> y * 255)+255
2356
        fld     dword[eax+4]      ; y cooficient
2304
        fld     dword[eax+4]      ; y cooficient
Line 2357... Line 2305...
2357
        fimul   [correct_tex]
2305
        fimul   [correct_tex]
2358
        fiadd   [correct_tex]
2306
        fiadd   [correct_tex]
2359
        fistp   [temp2]  ;word[ebp-4]
2307
        fistp   .temp2  ;word[ebp-4]
2360
 
2308
 
2361
        mov      eax,[temp2]   ;word[ebp-4]
2309
        mov      eax,.temp2
2362
        mov      ebx,[temp1]   ;word[ebp-2]
2310
        mov      ebx,.temp1
2363
        and      ebx,0xfffffff ; some onjects need thid 'and'
2311
        and      ebx,0xfffffff ; some onjects need this 'and'
2364
        shl      eax,TEX_SHIFT
2312
        shl      eax,TEX_SHIFT
Line 2374... Line 2322...
2374
        xor      ah,ah
2322
        xor      ah,ah
2375
        push     ax         ;g
2323
        push     ax         ;g
2376
        shr      eax,24
2324
        shr      eax,24
2377
        push     ax         ;b
2325
        push     ax         ;b
2378
 
2326
        sub      edi,2
2379
        sub      esi,4
-
 
-
 
2327
        sub      esi,4
2380
        dec      cx
2328
        dec      cx
2381
        jnz      .aagain_grd_draw
2329
        jnz      .aagain_grd_draw
2382
 
2330
 
Line 2383... Line 2331...
2383
        mov     eax,dword[xx1]
2331
        mov     eax, .xx1
2384
        ror     eax,16
-
 
2385
        mov     ebx,dword[xx2]
2332
        mov     ebx, .xx2
2386
        ror     ebx,16
-
 
2387
        mov     ecx,dword[xx3]
2333
        mov     ecx, .xx3
2388
        ror     ecx,16
-
 
2389
        mov     edi,[screen_ptr]
2334
        mov     edi,[screen_ptr]
2390
        mov     edx,texmap
2335
        mov     edx,texmap
2391
        mov     esi,[Zbuffer_ptr]
2336
        mov     esi,[Zbuffer_ptr]
Line 2392... Line 2337...
2392
 
2337
 
Line 2393... Line 2338...
2393
        call    tex_plus_grd_triangle
2338
        call    tex_plus_grd_triangle
2394
 
-
 
2395
        pop     ebp
-
 
2396
        mov     esp,ebp
2339
 
Line 2397... Line 2340...
2397
        pop     ebp
2340
        pop     ebp
-
 
2341
        jmp     .end_draw
2398
        jmp     .end_draw
2342
 
Line 2399... Line 2343...
2399
 
2343
      .two_tex:
2400
      .two_tex:
2344
        push     ebp
2401
        push    [Zbuffer_ptr]
2345
        push    [Zbuffer_ptr]
Line 2402... Line 2346...
2402
 
2346
 
2403
        push    word[zz3]
2347
        push    word .zz3
2404
        push    word[zz2]
2348
        push    word .zz2
2405
        push    word[zz1]
2349
        push    word .zz1
2406
 
2350
 
2407
        mov    esi,[point_index3]      ; tex map coords
2351
        mov    esi, .point_index3      ; tex map coords
2408
        shl    esi,2
2352
        shl    esi,2
2409
        add    esi,tex_points
2353
        add    esi,[tex_points_ptr]
2410
        push   dword[esi]
2354
        push   dword[esi]
2411
        mov    esi,[point_index2]
2355
        mov    esi, .point_index2
2412
        shl    esi,2
2356
        shl    esi,2
2413
        add    esi,tex_points
2357
        add    esi,[tex_points_ptr]
Line 2414... Line 2358...
2414
        push   dword[esi]
2358
        push   dword[esi]
2415
        mov    esi,[point_index1]
2359
        mov    esi, .point_index1
2416
        shl    esi,2
2360
        shl    esi,2
2417
        add    esi,tex_points
2361
        add    esi,[tex_points_ptr]
2418
        push   dword[esi]
2362
        push   dword[esi]
2419
 
2363
 
Line 2441... Line 2385...
2441
        add     edi,4
2385
        add     edi,4
2442
        add     esi,4
2386
        add     esi,4
2443
        loop    @b
2387
        loop    @b
2444
 
2388
 
Line 2445... Line 2389...
2445
        mov     eax,dword[xx1]
2389
        mov     eax, .xx1
2446
        ror     eax,16
-
 
2447
        mov     ebx,dword[xx2]
2390
        mov     ebx, .xx2
2448
        ror     ebx,16
-
 
2449
        mov     ecx,dword[xx3]
2391
        mov     ecx, .xx3
2450
        ror     ecx,16
-
 
2451
        mov     edi,[screen_ptr]
2392
        mov     edi,[screen_ptr]
2452
        mov     esi,texmap
2393
        mov     esi,texmap
2453
        mov     edx,envmap
2394
        mov     edx,envmap
Line 2454... Line 2395...
2454
 
2395
 
-
 
2396
        call    two_tex_triangle_z
2455
        call    two_tex_triangle_z
2397
        pop     ebp
Line 2456... Line 2398...
2456
        jmp     .end_draw
2398
        jmp     .end_draw
-
 
2399
 
2457
 
2400
   .bump_tex:
2458
   .bump_tex:
2401
        push   ebp
2459
        mov    esi,[point_index3]      ; tex map coords
2402
        mov    esi, .point_index3      ; tex map coords
2460
        shl    esi,2
2403
        shl    esi,2
2461
        add    esi,tex_points
2404
        add    esi,[tex_points_ptr]
2462
        push   dword[esi]
2405
        push   dword[esi]
2463
        mov    esi,[point_index2]
2406
        mov    esi, .point_index2
2464
        shl    esi,2
2407
        shl    esi,2
2465
        add    esi,tex_points
2408
        add    esi,[tex_points_ptr]
2466
        push   dword[esi]
2409
        push   dword[esi]
2467
        mov    esi,[point_index1]
2410
        mov    esi, .point_index1
2468
        shl    esi,2
2411
        shl    esi,2
Line 2469... Line 2412...
2469
        add    esi,tex_points
2412
        add    esi,[tex_points_ptr]
Line 2470... Line 2413...
2470
        push   dword[esi]
2413
        push   dword[esi]
2471
 
-
 
Line 2472... Line 2414...
2472
        push  dword texmap
2414
 
2473
 
2415
        push  dword texmap
2474
        push  [Zbuffer_ptr]
2416
 
Line 2475... Line 2417...
2475
        xor   edi,edi
2417
        push  [Zbuffer_ptr]
2476
 
2418
 
2477
        push    word[zz3]
2419
        push    word .zz3
2478
        push    word[zz2]
2420
        push    word .zz2
2479
        push    word[zz1]
2421
        push    word .zz1
2480
 
2422
 
2481
        mov     esi,point_index1     ; env coords
-
 
2482
        sub     esp,12
-
 
2483
        mov     edi,esp
2423
        lea     esi, .index1x12     ; env coords
2484
        mov     ecx,3
2424
        sub     esp,12
2485
      @@:
2425
        mov     edi,esp
2486
        mov     eax,dword[esi]
2426
        mov     ecx,3
2487
        lea     eax,[eax*3]
2427
      @@:
Line 2501... Line 2441...
2501
        add     edi,4
2441
        add     edi,4
2502
        add     esi,4
2442
        add     esi,4
2503
        loop    @b
2443
        loop    @b
Line 2504... Line -...
2504
 
-
 
2505
;        push  dword 1 shl 16 + 1  ; emap coords
-
 
2506
;        push  dword 127 shl 16 + 1
-
 
2507
;        push  dword 127 shl 16 + 127
-
 
2508
 
2444
 
2509
        mov    esi,[point_index3]      ; bump map coords
2445
        mov    esi, .point_index3      ; bump map coords
2510
        shl    esi,2
2446
        shl    esi,2
2511
        add    esi,tex_points
2447
        add    esi,[tex_points_ptr]
2512
        push   dword[esi]
2448
        push   dword[esi]
2513
        mov    esi,[point_index2]
2449
        mov    esi, .point_index2
2514
        shl    esi,2
2450
        shl    esi,2
2515
        add    esi,tex_points
2451
        add    esi,[tex_points_ptr]
2516
        push   dword[esi]
-
 
2517
 
2452
        push   dword[esi]
2518
        mov    esi,[point_index1]
2453
        mov    esi, .point_index1
2519
        shl    esi,2
2454
        shl    esi,2
2520
        add    esi,tex_points
2455
        add    esi,[tex_points_ptr]
Line 2521... Line -...
2521
        push   dword[esi]
-
 
2522
 
-
 
2523
;        push  dword 1 shl 16 + 127
-
 
2524
;        push  dword 127 shl 16 + 127
-
 
2525
;        push  dword 1 shl 16 + 1  ; bump coords
2456
        push   dword[esi]
2526
 
-
 
2527
        mov     eax,dword[xx1]
2457
 
2528
        ror     eax,16
-
 
2529
        mov     ebx,dword[xx2]
2458
        mov     eax,dword .xx1
2530
        ror     ebx,16
-
 
2531
        mov     ecx,dword[xx3]
2459
        mov     ebx,dword .xx2
2532
        ror     ecx,16
2460
        mov     ecx,dword .xx3
2533
        mov     edi,[screen_ptr]
2461
        mov     edi,[screen_ptr]
Line 2534... Line 2462...
2534
        mov     esi,envmap
2462
        mov     esi,envmap
2535
        mov     edx,bumpmap
-
 
-
 
2463
        mov     edx,bumpmap
2536
 
2464
 
Line 2537... Line 2465...
2537
        call bump_tex_triangle_z
2465
        call bump_tex_triangle_z
2538
 
2466
        pop     ebp
Line 2547... Line 2475...
2547
        punpcklwd xmm5,[the_zero]
2475
        punpcklwd xmm5,[the_zero]
2548
        pshufd    xmm5,xmm5,01110011b
2476
        pshufd    xmm5,xmm5,01110011b
2549
 
2477
 
Line 2550... Line 2478...
2550
 
2478
 
2551
        mov     eax,[point_index1]
2479
        mov     eax, .index1x12
2552
        mov     ebx,[point_index2]
2480
        mov     ebx, .index2x12
2553
        mov     ecx,[point_index3]
-
 
2554
        imul    eax,[i12]
-
 
2555
        imul    ebx,[i12]
-
 
2556
        imul    ecx,[i12]
2481
        mov     ecx, .index3x12
2557
        add     eax,[points_normals_rot_ptr]
2482
        add     eax,[points_normals_rot_ptr]
2558
        add     ebx,[points_normals_rot_ptr]
2483
        add     ebx,[points_normals_rot_ptr]
2559
        add     ecx,[points_normals_rot_ptr]
2484
        add     ecx,[points_normals_rot_ptr]
2560
        movups  xmm0,[eax]
2485
        movups  xmm0,[eax]
Line 2564... Line 2489...
2564
        andps   xmm1,[zero_hgst_dd]
2489
        andps   xmm1,[zero_hgst_dd]
2565
        andps   xmm2,[zero_hgst_dd]
2490
        andps   xmm2,[zero_hgst_dd]
2566
        xorps   xmm3,xmm3
2491
        xorps   xmm3,xmm3
2567
 
2492
 
Line 2568... Line 2493...
2568
        mov     eax,[point_index1]
2493
        mov     eax, .index1x12
2569
        mov     ebx,[point_index2]
2494
        mov     ebx, .index2x12
2570
        mov     ecx,[point_index3]
2495
        mov     ecx, .index3x12
2571
        imul    eax,[i12]
-
 
2572
        imul    ebx,[i12]
-
 
2573
        imul    ecx,[i12]
-
 
2574
        add     eax,[points_rotated_ptr]
2496
        add     eax,[points_rotated_ptr]
2575
        add     ebx,[points_rotated_ptr]
2497
        add     ebx,[points_rotated_ptr]
2576
        add     ecx,[points_rotated_ptr]
2498
        add     ecx,[points_rotated_ptr]
2577
        push    dword[ecx+8]
2499
        push    dword[ecx+8]
2578
        push    dword[ebx+8]
2500
        push    dword[ebx+8]
Line 2582... Line 2504...
2582
        andps   xmm4,[zero_hgst_dd]
2504
        andps   xmm4,[zero_hgst_dd]
2583
 
2505
 
Line 2584... Line 2506...
2584
 
2506
 
2585
 
-
 
2586
        mov     eax,dword[xx1]
2507
 
2587
        ror     eax,16
-
 
2588
        mov     ebx,dword[xx2]
2508
        mov     eax,dword .xx1
2589
        ror     ebx,16
-
 
2590
        mov     ecx,dword[xx3]
2509
        mov     ebx,dword .xx2
2591
        ror     ecx,16
2510
        mov     ecx,dword .xx3
Line 2592... Line 2511...
2592
        mov     edi,[screen_ptr]
2511
        mov     edi,[screen_ptr]
Line 2601... Line 2520...
2601
        punpcklwd xmm5,[the_zero]
2520
        punpcklwd xmm5,[the_zero]
2602
        pshufd    xmm5,xmm5,01110011b
2521
        pshufd    xmm5,xmm5,01110011b
2603
 
2522
 
Line 2604... Line 2523...
2604
 
2523
 
2605
        mov     eax,[point_index1]
2524
        mov     eax, .index1x12
2606
        mov     ebx ,[point_index2]
2525
        mov     ebx, .index2x12
2607
        mov     ecx,[point_index3]
-
 
2608
        imul    eax,[i12]
-
 
2609
        imul    ebx,[i12]
-
 
2610
        imul    ecx,[i12]
2526
        mov     ecx, .index3x12
2611
        add     eax,[points_normals_rot_ptr]
2527
        add     eax,[points_normals_rot_ptr]
2612
        add     ebx,[points_normals_rot_ptr]
2528
        add     ebx,[points_normals_rot_ptr]
2613
        add     ecx,[points_normals_rot_ptr]
2529
        add     ecx,[points_normals_rot_ptr]
2614
        movups  xmm0,[eax]
2530
        movups  xmm0,[eax]
Line 2618... Line 2534...
2618
        andps   xmm1,[zero_hgst_dd]
2534
        andps   xmm1,[zero_hgst_dd]
2619
        andps   xmm2,[zero_hgst_dd]
2535
        andps   xmm2,[zero_hgst_dd]
2620
        xorps   xmm3,xmm3
2536
        xorps   xmm3,xmm3
2621
 
2537
 
Line 2622... Line 2538...
2622
        mov     eax,[point_index1]
2538
        mov     eax, .index1x12
2623
        mov     ebx,[point_index2]
2539
        mov     ebx, .index2x12
2624
        mov     ecx,[point_index3]
2540
        mov     ecx, .index3x12
2625
        imul    eax,[i12]
-
 
2626
        imul    ebx,[i12]
-
 
2627
        imul    ecx,[i12]
-
 
2628
        add     eax,[points_rotated_ptr]
2541
        add     eax,[points_rotated_ptr]
2629
        add     ebx,[points_rotated_ptr]
2542
        add     ebx,[points_rotated_ptr]
2630
        add     ecx,[points_rotated_ptr]
2543
        add     ecx,[points_rotated_ptr]
2631
        push    dword[ecx+8]
2544
        push    dword[ecx+8]
2632
        push    dword[ebx+8]
2545
        push    dword[ebx+8]
Line 2636... Line 2549...
2636
        andps   xmm4,[zero_hgst_dd]
2549
        andps   xmm4,[zero_hgst_dd]
2637
 
2550
 
Line 2638... Line 2551...
2638
 
2551
 
2639
 
-
 
2640
        mov     eax,dword[xx1]
2552
 
2641
        ror     eax,16
-
 
2642
        mov     ebx,dword[xx2]
2553
        mov     eax, .xx1
2643
        ror     ebx,16
-
 
2644
        mov     ecx,dword[xx3]
2554
        mov     ebx, .xx2
2645
        ror     ecx,16
2555
        mov     ecx, .xx3
2646
        mov     edi,[screen_ptr]
2556
        mov     edi,[screen_ptr]
Line 2647... Line 2557...
2647
        mov     edx,[Zbuffer_ptr]
2557
        mov     edx,[Zbuffer_ptr]
Line 2655... Line 2565...
2655
        movd      xmm5,[size_y_var]
2565
        movd      xmm5,[size_y_var]
2656
        punpcklwd xmm5,[the_zero]
2566
        punpcklwd xmm5,[the_zero]
2657
        pshufd    xmm5,xmm5,01110011b
2567
        pshufd    xmm5,xmm5,01110011b
2658
 
2568
 
Line 2659... Line 2569...
2659
        mov     eax,[point_index1]
2569
        mov     eax, .index1x12
2660
        mov     ebx,[point_index2]
2570
        mov     ebx, .index2x12
2661
        mov     ecx,[point_index3]
2571
        mov     ecx, .index3x12
2662
        imul    eax,[i12]
-
 
2663
        imul    ebx,[i12]
-
 
2664
        imul    ecx,[i12]
-
 
2665
        add     eax,[points_normals_rot_ptr]
2572
        add     eax,[points_normals_rot_ptr]
2666
        add     ebx,[points_normals_rot_ptr]
2573
        add     ebx,[points_normals_rot_ptr]
2667
        add     ecx,[points_normals_rot_ptr]
2574
        add     ecx,[points_normals_rot_ptr]
2668
        movups  xmm0,[eax]
2575
        movups  xmm0,[eax]
2669
        movups  xmm1,[ebx]
2576
        movups  xmm1,[ebx]
Line 2672... Line 2579...
2672
        andps   xmm1,[zero_hgst_dd]
2579
        andps   xmm1,[zero_hgst_dd]
2673
        andps   xmm2,[zero_hgst_dd]
2580
        andps   xmm2,[zero_hgst_dd]
2674
        xorps   xmm3,xmm3
2581
        xorps   xmm3,xmm3
2675
 
2582
 
Line 2676... Line 2583...
2676
        mov     eax,[point_index1]
2583
        mov     eax, .index1x12
2677
        mov     ebx,[point_index2]
2584
        mov     ebx, .index2x12
2678
        mov     ecx,[point_index3]
2585
        mov     ecx, .index3x12
2679
        imul    eax,[i12]
-
 
2680
        imul    ebx,[i12]
-
 
2681
        imul    ecx,[i12]
-
 
2682
        add     eax,[points_rotated_ptr]
2586
        add     eax,[points_rotated_ptr]
2683
        add     ebx,[points_rotated_ptr]
2587
        add     ebx,[points_rotated_ptr]
2684
        add     ecx,[points_rotated_ptr]
2588
        add     ecx,[points_rotated_ptr]
2685
        push    dword[ecx+8]
2589
        push    dword[ecx+8]
2686
        push    dword[ebx+8]
2590
        push    dword[ebx+8]
2687
        push    dword[eax+8]
2591
        push    dword[eax+8]
2688
        movups  xmm4,[esp]
2592
        movups  xmm4,[esp]
2689
        add     esp,12
2593
        add     esp,12
2690
        andps   xmm4,[zero_hgst_dd]
2594
        andps   xmm4,[zero_hgst_dd]
Line 2691... Line 2595...
2691
 
2595
 
2692
        mov    esi,[point_index3]      ; tex map coords
2596
        mov    esi,.point_index3      ; tex map coords
2693
        shl    esi,2
2597
        shl    esi,2
2694
        add    esi,tex_points
2598
        add    esi,[tex_points_ptr]
2695
        push   dword[esi]
2599
        push   dword[esi]
2696
        mov    esi,[point_index2]
2600
        mov    esi,.point_index2
2697
        shl    esi,2
2601
        shl    esi,2
2698
        add    esi,tex_points
2602
        add    esi,[tex_points_ptr]
2699
        push   dword[esi]
2603
        push   dword[esi]
2700
        mov    esi,[point_index1]
2604
        mov    esi,.point_index1
2701
        shl    esi,2
2605
        shl    esi,2
2702
        add    esi,tex_points
2606
        add    esi,[tex_points_ptr]
2703
        push   dword[esi]
2607
        push   dword[esi]
2704
        movups xmm6,[esp]
2608
        movups xmm6,[esp]
2705
        add    esp,12
2609
        add    esp,12
2706
     ;   pshuflw xmm6,xmm6,10110001b
2610
     ;   pshuflw xmm6,xmm6,10110001b
Line 2712... Line 2616...
2712
        pslldq xmm7,12
2616
        pslldq xmm7,12
2713
        por    xmm6,xmm7
2617
        por    xmm6,xmm7
2714
 
2618
 
Line 2715... Line 2619...
2715
 
2619
 
2716
        mov     eax,dword[xx1]
-
 
2717
        ror     eax,16
2620
        mov     eax,dword .xx1
2718
        mov     ebx,dword[xx2]
-
 
2719
        ror     ebx,16
2621
        mov     ebx,dword .xx2
2720
        mov     ecx,dword[xx3]
-
 
2721
        ror     ecx,16
2622
        mov     ecx,dword .xx3
2722
        mov     edx,texmap
2623
        mov     edx,texmap
2723
        mov     edi,[screen_ptr]
2624
        mov     edi,[screen_ptr]
Line 2724... Line 2625...
2724
        mov     esi,[Zbuffer_ptr]
2625
        mov     esi,[Zbuffer_ptr]
-
 
2626
 
-
 
2627
        call    glass_tex_tri
-
 
2628
        jmp     .end_draw
-
 
2629
 
-
 
2630
   .ray_shd:
-
 
2631
        emms
-
 
2632
        movd      xmm5,[size_y_var]
-
 
2633
        punpcklwd xmm5,[the_zero]
-
 
2634
        pshufd    xmm5,xmm5,01110011b
-
 
2635
 
-
 
2636
        mov     eax, .index1x12
-
 
2637
        mov     ebx, .index2x12
-
 
2638
        mov     ecx, .index3x12
-
 
2639
        add     eax,[points_normals_rot_ptr]
-
 
2640
        add     ebx,[points_normals_rot_ptr]
-
 
2641
        add     ecx,[points_normals_rot_ptr]
-
 
2642
        movups  xmm0,[eax]
-
 
2643
        movups  xmm1,[ebx]
-
 
2644
        movups  xmm2,[ecx]
-
 
2645
        andps   xmm0,[zero_hgst_dd]
-
 
2646
        andps   xmm1,[zero_hgst_dd]
-
 
2647
        andps   xmm2,[zero_hgst_dd]
-
 
2648
        xorps   xmm3,xmm3
-
 
2649
 
-
 
2650
   ;     mov     ebx,.tri_no
-
 
2651
   ;     cmp     ebx,0
-
 
2652
   ;     je      @f
-
 
2653
   ;     int3
-
 
2654
   ;   @@:
-
 
2655
        mov     eax, .index1x12
-
 
2656
        mov     ebx, .index2x12
-
 
2657
        mov     ecx, .index3x12
-
 
2658
        add     eax,[points_rotated_ptr]
-
 
2659
        add     ebx,[points_rotated_ptr]
-
 
2660
        add     ecx,[points_rotated_ptr]
-
 
2661
        push    dword[ecx+8]
-
 
2662
        push    dword[ebx+8]
-
 
2663
        push    dword[eax+8]
-
 
2664
        movups  xmm4,[esp]
-
 
2665
        add     esp,12
-
 
2666
        andps   xmm4,[zero_hgst_dd]
-
 
2667
 
-
 
2668
        movd    mm7,.tri_no
-
 
2669
 
-
 
2670
   ;     mm7 - intialised
-
 
2671
 
-
 
2672
 
-
 
2673
        mov     eax,dword .xx1
-
 
2674
        mov     ebx,dword .xx2
-
 
2675
        mov     ecx,dword .xx3
-
 
2676
        mov     edx,texmap
-
 
2677
        mov     edi,[screen_ptr]
-
 
2678
        mov     esi,[Zbuffer_ptr]
Line 2725... Line 2679...
2725
 
2679
 
Line 2726... Line 2680...
2726
        call    glass_tex_tri
2680
        call    ray_shad
-
 
2681
 
-
 
2682
 
2727
 
2683
 
-
 
2684
end if
2728
 
2685
 
-
 
2686
      .end_draw:
-
 
2687
    ;    pop     ebp
-
 
2688
        pop     ecx
Line 2729... Line 2689...
2729
 
2689
        pop     esi
2730
end if
-
 
Line 2731... Line -...
2731
 
-
 
2732
      .end_draw:
-
 
Line 2733... Line 2690...
2733
        pop     esi
2690
 
2734
        add     esi,12
2691
        add     esi,12
2735
 
2692
        inc     ecx
Line 2787... Line 2744...
2787
        jl        .again_cc
2744
        jl        .again_cc
2788
        sub       esp,16
2745
        sub       esp,16
2789
        movups    [esp],xmm1
2746
        movups    [esp],xmm1
2790
        add       esi,4
2747
        add       esi,4
2791
        loop      .aga_n
2748
        dec       ecx
-
 
2749
        jnz      .aga_n
2792
 
2750
 
Line 2793... Line 2751...
2793
        movups    xmm0,[esp]
2751
        movups    xmm0,[esp]
2794
        movups    xmm1,[esp+16]
2752
        movups    xmm1,[esp+16]
2795
        add       esp,32
2753
        add       esp,32
2796
        sub       esi,8
2754
        sub       esi,8
Line 2805... Line 2763...
2805
        movd    xmm7,[ecx]
2763
        movd    xmm7,[ecx]
2806
        movhps  xmm7,[edx]
2764
        movhps  xmm7,[edx]
2807
        pshufd  xmm7,xmm7,11101000b
2765
        pshufd  xmm7,xmm7,11101000b
2808
        movdqa  xmm6,xmm7
2766
        movdqa  xmm6,xmm7
-
 
2767
        movdqa  xmm3,xmm7
-
 
2768
        movdqa  xmm4,xmm7
2809
        movd    xmm5,[size_y_var]
2769
        movd    xmm5,[size_y_var]
2810
        pshuflw xmm5,xmm5,00010001b
2770
        pshuflw xmm5,xmm5,00010001b
-
 
2771
        pcmpeqw xmm3,xmm5
-
 
2772
        pcmpeqw xmm4,[the_zero]
2811
        pcmpgtw xmm7,xmm5
2773
        pcmpgtw xmm7,xmm5
2812
        pcmpgtw xmm6,[the_zero]
2774
        pcmpgtw xmm6,[the_zero]
2813
        pxor    xmm7,xmm6
2775
        pxor    xmm7,xmm6
-
 
2776
        pxor    xmm3,xmm4
-
 
2777
        pxor    xmm7,xmm3
2814
        pmovmskb eax,xmm7
2778
        pmovmskb eax,xmm7
2815
        cmp     al,-1
2779
        cmp     al,-1
2816
        jnz      .skp
2780
        jnz      .skp
Line 2849... Line 2813...
2849
        inc     ecx
2813
        inc     ecx
2850
        cmp     ecx,[edges_count]
2814
        cmp     ecx,[edges_count]
2851
        jnz     .again_s_line
2815
        jnz     .again_s_line
2852
 
2816
 
Line -... Line 2817...
-
 
2817
 
-
 
2818
 
-
 
2819
 
-
 
2820
 
-
 
2821
 
-
 
2822
   .eend:
-
 
2823
        add      esp,60
-
 
2824
        pop      ebp
-
 
2825
 
2853
 ret
2826
ret
Line 2854... Line -...
2854
 
-
 
Line -... Line 2827...
-
 
2827
 
-
 
2828
 
2855
 
2829
 
2856
 
2830
 
Line 2857... Line 2831...
2857
 
2831
 
2858
 
2832
 
2859
 
2833
 
-
 
2834
draw_handlers:
Line 2860... Line 2835...
2860
draw_handlers:
2835
       ;  in eax - render model
2861
 
2836
       push  ebp
2862
       push  ebp
2837
       mov   ebp,esp
2863
       mov   ebp,esp
-
 
-
 
2838
 
2864
 
2839
       .counter  equ ebp-16
2865
       .counter  equ ebp-16
2840
       .xres3m18 equ ebp-8
2866
       .xres3m18 equ ebp-8
2841
       .xres2m12 equ ebp-12
2867
       .xres2m12 equ ebp-12
2842
       .dr_model equ dword[ebp-4]
2868
 
2843
 
2869
 
2844
 
2870
     ; init counter
2845
     ; init counter
Line 2929... Line 2904...
2929
       imul  eax,edx
2904
       imul  eax,edx
2930
       add   eax,ebx
2905
       add   eax,ebx
2931
       push   eax
2906
       push   eax
2932
       lea   edi,[eax*3]
2907
       lea   edi,[eax*3]
2933
       cmp    [dr_flag],12
2908
       cmp    .dr_model,12
2934
       jl    @f
2909
       jl    @f
2935
       add    edi,[esp]
2910
       add    edi,[esp]
2936
      @@:
2911
      @@:
2937
       add    esp,4
2912
       add    esp,4
2938
       lea   eax,[eax*2]
2913
       lea   eax,[eax*2]
2939
       ; draw bar 6x6
2914
       ; draw bar 6x6
Line 2954... Line 2929...
2954
       mov   word[edi],0x0000 ;ax
2929
       mov   word[edi],0x0000 ;ax
2955
       mov   byte[edi+2],0xff   ;al
2930
       mov   byte[edi+2],0xff   ;al
2956
       mov   word[eax],dx
2931
       mov   word[eax],dx
2957
       add   eax,2
2932
       add   eax,2
2958
       cmp    [dr_flag],12
2933
       cmp   .dr_model,12
2959
       jl    @f
2934
       jl    @f
2960
       add   edi,4
2935
       add   edi,4
2961
       loop  .do
2936
       loop  .do
2962
       jmp   .ad
2937
       jmp   .ad
2963
      @@:
2938
      @@:
2964
       add   edi,3
2939
       add   edi,3
Line 3224... Line 3199...
3224
        mov     eax,-1 ;<---mark if OK
3199
        mov     eax,-1 ;<---mark if OK
3225
      .exit:
3200
      .exit:
3226
        mov     dword[edi],-1
3201
        mov     dword[edi],-1
3227
ret
3202
ret
3228
 
3203
alloc_mem_for_tp:
3229
alloc_mem_for_tp:
-
 
3230
        mov     eax, 68
3204
        mov     eax, 68
3231
        cmp     [re_alloc_flag],1
3205
        cmp     [re_alloc_flag],1
3232
        jz      @f
3206
        jz      @f
3233
        mov     ebx, 12
3207
        mov     ebx, 12
3234
        jmp     .alloc
3208
        jmp     .alloc
Line 3291... Line 3265...
3291
        int     0x40
3265
        int     0x40
3292
        mov     [points_rotated_ptr], eax
3266
        mov     [points_rotated_ptr], eax
3293
 
3267
 
Line 3294... Line 3268...
3294
        mov     eax, 68
3268
        mov     eax, 68
-
 
3269
        mov     ebx, 12
-
 
3270
        mov     ecx, [points_count_var]
-
 
3271
        shl     ecx,2
-
 
3272
        mov     edx,[tex_points_ptr]
-
 
3273
        int     0x40
-
 
3274
        mov     [tex_points_ptr], eax
-
 
3275
 
-
 
3276
        mov     eax, 68
3295
        mov     ecx, [points_count_var]
3277
        mov     ecx, [points_count_var]
3296
        inc     ecx
3278
        inc     ecx
3297
        shl     ecx, 3
3279
        shl     ecx, 3
3298
        mov     edx,[points_translated_ptr]
3280
        mov     edx,[points_translated_ptr]
3299
        int     0x40
3281
        int     0x40
3300
        mov     [points_translated_ptr], eax
3282
        mov     [points_translated_ptr], eax
3301
ret
3283
ret
Line 3302... Line -...
3302
 
-
 
3303
 
3284
 
3304
 
3285
 
3305
read_from_disk:
3286
read_from_disk:
3306
    mov     eax, 68
3287
    mov     eax, 68
Line 3346... Line 3327...
3346
buttons:                                      ; draw some buttons (all but navigation and close )
3327
buttons:                                      ; draw some buttons (all but navigation and close )
3347
        mov     edi,menu
3328
        mov     edi,menu
3348
      .again:
3329
      .again:
3349
        mov     eax,8             ; function 8 : define and draw button
3330
        mov     eax,8             ; function 8 : define and draw button
3350
        mov     bx,[size_x_var]
3331
        movzx   ebx,word[size_x_var]
3351
        shl     ebx,16
3332
        shl     ebx,16
3352
        add     ebx,(10)*65536+62      ; [x start] *65536 + [x size]
3333
        add     ebx,(10)*65536+62      ; [x start] *65536 + [x size]
3353
        movzx   ecx,byte[edi]                 ; button id = position+2
3334
        movzx   ecx,byte[edi]                 ; button id = position+2
3354
        sub     cl,2
3335
        sub     ecx,2
3355
        lea     ecx,[ecx*5]
3336
        lea     ecx,[ecx*5]
3356
        lea     ecx,[ecx*3]
3337
        lea     ecx,[ecx*3]
3357
        add     ecx,25
3338
        add     ecx,25
3358
        shl     ecx,16
3339
        shl     ecx,16
3359
        add     ecx,12
3340
        add     ecx,12
3360
        movzx   edx,byte[edi]                   ; button id
3341
        movzx   edx,byte[edi]                   ; button id
Line 3362... Line 3343...
3362
        int     0x40
3343
        int     0x40
3363
         ; BUTTON  LABEL
3344
         ; BUTTON  LABEL
3364
        mov     eax,4                           ; function 4 : write text to window
3345
        mov     eax,4                           ; function 4 : write text to window
3365
        movzx   ebx,byte[edi]
3346
        movzx   ebx,byte[edi]
3366
        sub     bl,2                            ; button id, according to position
3347
        sub     ebx,2                            ; button id, according to position
3367
        lea     ebx,[ebx*3]
3348
        lea     ebx,[ebx*3]
3368
        lea     ebx,[ebx*5]
3349
        lea     ebx,[ebx*5]
3369
        mov     cx,[size_x_var]
3350
        movzx   ecx,word[size_x_var]
3370
        shl     ecx,16
3351
        shl     ecx,16
3371
        add     ebx,ecx
3352
        add     ebx,ecx
3372
        add     ebx,(12)*65536+28        ; [x start] *65536 + [y start]
3353
        add     ebx,(12)*65536+28        ; [x start] *65536 + [y start]
3373
        mov     ecx,0x00ddeeff                  ; font 1 & color ( 0xF0RRGGBB )
3354
        mov     ecx,0x00ddeeff                  ; font 1 & color ( 0xF0RRGGBB )
3374
        lea     edx,[edi+1]                     ; pointer to text beginning
3355
        lea     edx,[edi+1]                     ; pointer to text beginning
3375
        mov     esi,10                          ; text length
3356
        mov     esi,10                          ; text length
Line 3457... Line 3438...
3457
;   *********************************************
3438
;   *********************************************
3458
;   *******  WINDOW DEFINITIONS AND DRAW ********
3439
;   *******  WINDOW DEFINITIONS AND DRAW ********
3459
;   *********************************************
3440
;   *********************************************
3460
    draw_window:
3441
    draw_window:
3461
        mov     eax,12          ; function 12:tell os about windowdraw
3442
        movzx   eax,[fire_flag]
-
 
3443
        push    eax
-
 
3444
    ;    int3
-
 
3445
        mov     eax,12          ; function 12:tell os about windowdraw
3462
        mov     ebx,1           ; 1, start of draw
3446
        mov     ebx,1           ; 1, start of draw
3463
        int     0x40
3447
        int     0x40
3464
 
3448
 
Line 3465... Line 3449...
3465
        ; DRAW WINDOW
3449
        ; DRAW WINDOW
Line 3490... Line 3474...
3490
     ;   shl     edx,16
3474
     ;   shl     edx,16
3491
     ;   add     edx,130*65536+60  ; [x start] *65536 + [y start]
3475
     ;   add     edx,130*65536+60  ; [x start] *65536 + [y start]
3492
     ;   mov     esi,0x00ddeeff  ; font 1 & color ( 0xF0RRGGBB )
3476
     ;   mov     esi,0x00ddeeff  ; font 1 & color ( 0xF0RRGGBB )
3493
     ;   int     0x40
3477
     ;   int     0x40
3494
       call  write_info
3478
 
-
 
3479
       call  write_info
3495
 
3480
 
Line 3496... Line 3481...
3496
        ; ADD VECTOR LABEL      ; add vector buttons - 30 ++
3481
        ; ADD VECTOR LABEL      ; add vector buttons - 30 ++
3497
        mov     eax,4           ; function 4 : write text to window
3482
        mov     eax,4           ; function 4 : write text to window
3498
        movzx   ebx,word[size_x_var]
3483
        movzx   ebx,word[size_x_var]
Line 3642... Line 3627...
3642
 
3627
 
Line 3643... Line 3628...
3643
        mov     eax,12          ; function 12:tell os about windowdraw
3628
        mov     eax,12          ; function 12:tell os about windowdraw
3644
        mov     ebx,2           ; 2, end of draw
3629
        mov     ebx,2           ; 2, end of draw
3645
        int     0x40
3630
        int     0x40
-
 
3631
        pop     eax
-
 
3632
        mov     [fire_flag],al
3646
        ret
3633
        ret
Line 3647... Line 3634...
3647
 
3634