Subversion Repositories Kolibri OS

Rev

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

Rev 8666 Rev 8719
Line 1... Line 1...
1
; application : View3ds ver. 0.072 - tiny .3ds and .asc files viewer
1
; application : View3ds ver. 0.071 - 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
7
; web         : http://macgub.j.pl, http://macgub.co.pl
7
; web         : http://macgub.co.pl, http://macgub.j.pl
8
; Fell free to use this intro in your own distribution of KolibriOS.
8
; Fell free to use this intro in your own distribution of KolibriOS.
9
; Special greetings to KolibriOS team .
9
; Special greetings to KolibriOS team .
10
; I hope because my demos Christian Belive will be near to each of You.
10
; I hope because my demos Christian Belive will be near to each of You.
Line 17... Line 17...
17
; 1) Read from a file (*.3DS standard)
17
; 1) Read from a file (*.3DS standard)
18
; 2) Written in manually (at the end of the code) ; now not exist
18
; 2) Written in manually (at the end of the code) ; now not exist
19
 
19
 
Line 20... Line 20...
20
 
20
 
21
SIZE_X equ 500
21
SIZE_X equ 512
22
SIZE_Y equ 600                               ;      /////     I want definitely
22
SIZE_Y equ 512                               ;      /////     I want definitely
23
TIMEOUT equ 10                               ;     ------     say:
23
TIMEOUT equ 10                               ;     ------     say:
24
ROUND equ 10                                 ;     \ @ @/     keep smiling every
24
ROUND equ 10                                 ;     \ @ @/     keep smiling every
25
TEX_X equ 512    ; texture width             ;      \ ./    / day.
25
TEX_X equ 512    ; texture width             ;      \ ./    / day.
26
TEX_Y equ 512    ;         height            ;       \/    /
26
TEX_Y equ 512    ;         height            ;       \/    /
Line 59... Line 59...
59
        fild   dword[esp]
59
        fild   dword[esp]
60
        fstp   [rsscale]
60
        fstp   [rsscale]
61
        pop    ebx
61
        pop    ebx
62
 
62
 
Line 63... Line -...
63
        mov    [x_start],dword 20 shl  16 + 20  ;eax
-
 
64
 
-
 
65
 
-
 
66
        call   alloc_buffer_mem
63
        call   alloc_buffer_mem
67
        call   read_param
64
        call   read_param
68
        call   read_from_disk    ; read, if all is ok eax = 0
65
        call   read_from_disk    ; read, if all is ok eax = 0
69
        cmp    eax,0
66
        cmp    eax,0
70
        jne    .gen
67
        jne    .gen
Line 84... Line 81...
84
        call   alloc_mem_for_tp
81
        call   alloc_mem_for_tp
85
        call   read_asc
82
        call   read_asc
86
        jmp    .opt
83
        jmp    .opt
87
    .malloc:
84
    .malloc:
88
     if USE_LFN
85
        call   alloc_mem_for_tp
89
        call   alloc_mem_for_tp
-
 
90
     end if
86
        call   read_from_file
91
        call   read_from_file
-
 
92
    .opt:
87
    .opt:
93
 
88
        call   optimize_object1     ;  proc in file b_procs.asm
94
 
-
 
95
 
-
 
96
        call   optimize_object1     ;  proc in file b_procs.asm
-
 
97
                                    ;  set point(0,0,0) in center and  calc all coords
89
                                    ;  set point(0,0,0) in center and  calc all coords
98
                                    ;  to be in <-1.0,1.0>
90
                                    ;  to be in <-1.0,1.0>
99
        call   normalize_all_light_vectors
91
        call   normalize_all_light_vectors
100
      if Ext >= SSE3
92
      if Ext >= SSE3
101
        call   copy_lights ; to aligned float
93
        call   copy_lights ; to aligned float
Line 109... Line 101...
109
        call   do_color_buffer   ; intit color_map
101
        call   do_color_buffer   ; intit color_map
110
        mov    edi,bumpmap
102
        mov    edi,bumpmap
111
        call   calc_bumpmap
103
        call   calc_bumpmap
112
        call   calc_bumpmap_coords   ; bump and texture mapping
104
        call   calc_bumpmap_coords   ; bump and texture mapping
113
        call   draw_window
105
        call   do_edges_list
-
 
106
        call   draw_window
114
        ;mov     [draw_win_at_first],0
107
        ;mov     [draw_win_at_first],0
115
        ;mov    eax,40         ; set events mask
108
        ;mov    eax,40         ; set events mask
116
        ;mov    ebx,1100000000000000000000000100111b
109
        ;mov    ebx,1100000000000000000000000100111b
117
        ;int    0x40
110
        ;int    0x40
118
      if Ext >= SSE3
111
 
119
        mov     eax,1
-
 
120
        cpuid
-
 
121
        bt      ecx,0  ; is sse3 on board?
-
 
122
        jc      @f
-
 
123
        mov     [max_dr_flg],12
-
 
124
       @@:
-
 
125
       end if
112
 
126
 
-
 
Line 127... Line 113...
127
still:
113
still:
128
        cmp    [edit_flag],1
114
        cmp    [edit_flag],1
129
        jne    @f
115
        jne    @f
130
        mov    eax,40         ; set events mask
116
        mov    eax,40         ; set events mask
Line 182... Line 168...
182
        mov     ebx,procinfo
168
        mov     ebx,procinfo
183
        mov     ecx,-1
169
        mov     ecx,-1
184
        int     0x40
170
        int     0x40
185
        mov     eax,[procinfo+42]    ; read params of window
171
        mov     eax,[procinfo+42]    ; read params of window
186
        sub     eax,115
172
        sub     eax,225
187
        mov     [size_x_var],ax
173
        mov     [size_x_var],ax
188
        shr     ax,1
174
        shr     ax,1
189
        mov     [vect_x],ax
175
        mov     [vect_x],ax
190
;
176
;
191
        mov     eax,[procinfo+46]
177
        mov     eax,[procinfo+46]
192
        sub     eax,30
178
        sub     eax,30
Line 257... Line 243...
257
        cmp     ah,5
243
        cmp     ah,5
258
        jne     @f
244
        jne     @f
259
     .zoom_out:
245
        .zoom_out:
260
        mov     dword[scale],0.7
246
        mov     dword[scale],0.7
261
        movss   xmm0,[rsscale]
247
        fninit
262
        mulss   xmm0,[scale]
-
 
263
        movss   [rsscale],xmm0
-
 
264
      ;  fninit
-
 
265
      ;  fld     [rsscale]
248
        fld     [rsscale]
266
      ;  fmul    [scale]
249
        fmul    [scale]
267
      ;  fstp    [rsscale]
250
        fstp    [rsscale]
268
 
251
       @@:
269
 
-
 
270
      @@:
-
 
271
        cmp     ah,6                 ; ah = 6 ->  scale+
252
        cmp     ah,6                 ; ah = 6 ->  scale+
272
        jne     @f
253
        jne     @f
273
       .zoom_in:
254
      .zoom_in:
274
        mov     dword[scale],1.3
255
        mov     dword[scale],1.3
275
        movss   xmm0,[rsscale]
256
        fninit
276
        mulss   xmm0,[scale]
-
 
277
        movss   [rsscale],xmm0
-
 
278
 
-
 
279
       ; fninit
-
 
280
       ; fld     [rsscale]
257
        fld     [rsscale]
281
       ; fmul    [scale]
258
        fmul    [scale]
282
       ; fstp    [rsscale]
259
        fstp    [rsscale]
283
 
260
       @@:
284
      @@:
-
 
285
        cmp     ah,9    ; lights random                 ;    'flat'  0
261
        cmp     ah,9    ; lights random                 ;    'flat'  0
286
        jne     .next_m5                                ;    'grd '  1
262
        jne     .next_m5                                ;    'grd '  1
287
        call    make_random_lights                      ;    'env '  2
263
        call    make_random_lights                      ;    'env '  2
288
        call    normalize_all_light_vectors             ;    'bump'  3
264
        call    normalize_all_light_vectors             ;    'bump'  3
289
      if Ext >= SSE3
265
      if Ext >= SSE3
290
        call    copy_lights
266
        call    copy_lights
291
      end if
267
      end if
292
        call    do_color_buffer   ; intit color_map     ;    'tex '  4
268
        call    do_color_buffer   ; intit color_map     ;    'tex '  4
293
      ;  cmp     [emboss_flag],1                         ;    'pos '  5
269
 
294
      ;  je      @f                                      ;    'dots'  6
-
 
295
      ;  cmp     [dr_flag],8
-
 
296
      ;  jge     @f
-
 
297
      ;  cmp     [dr_flag],2                             ;    'txgr'  7
-
 
298
      ;  jl      .next_m5                            ;    '2tex'  8
-
 
299
      ;  cmp     [dr_flag],3                             ;    'btex'  9
-
 
300
      ;  jg      .next_m5
-
 
301
    ; @@:
-
 
302
        call    init_envmap2    ; update env map if shading model = environment or bump
270
        call    init_envmap2    ; update env map if shading model = environment or bump
303
    .next_m5:
271
    .next_m5:
304
        cmp      ah,11
272
        cmp      ah,11
305
        je       @f
273
        je       @f
306
        cmp      ah,12
274
        cmp      ah,12
307
        je       @f
275
        je       @f
Line 358... Line 326...
358
        call    optimize_object1
326
        call    optimize_object1
359
        call    init_triangles_normals2
327
        call    init_triangles_normals2
360
        call    init_point_normals
328
        call    init_point_normals
361
        call    calc_bumpmap_coords   ; bump and texture mapping
329
        call    calc_bumpmap_coords   ; bump and texture mapping
362
 
330
        call    do_edges_list
363
     .next_m2:
-
 
-
 
331
        call    write_info
-
 
332
     .next_m2:
364
        cmp      ah,19
333
        cmp      ah,19
365
        je       @f
334
        je       @f
366
        cmp      ah,20
335
        cmp      ah,20
367
        jne      .next_m3
336
        jne      .next_m3
368
     @@:
337
     @@:
Line 545... Line 514...
545
        cmp     [fire_flag],0
514
        cmp     [fire_flag],0
546
        jne     @f
515
        jne     @f
547
        call    clrscr          ; clear the screen
516
        call    clrscr          ; clear the screen
548
     @@:
517
     @@:
-
 
518
    ;    cmp     [catmull_flag],1  ;non sort if Catmull = on
-
 
519
    ;    je      .no_sort
-
 
520
    ; 64 indexes    call    sort_triangles
-
 
521
      .no_sort:
549
        cmp     [dr_flag],7       ; fill if 2tex and texgrd
522
        cmp     [dr_flag],7       ; fill if 2tex and texgrd
550
        jge     @f
523
        jge     @f
551
        cmp     [catmull_flag],0  ;non fill if Catmull = off
524
        cmp     [catmull_flag],0  ;non fill if Catmull = off
552
        je      .non_f
525
        je      .non_f
553
        cmp     [dr_flag],6       ; non fill if dots
526
        cmp     [dr_flag],6       ; non fill if dots
Line 566... Line 539...
566
        call   clear_vertices_index
539
        call   clear_vertices_index
567
        call   draw_handlers
540
        call   draw_handlers
568
    ;    call   edit
541
    ;    call   edit
569
 
542
 
Line -... Line 543...
-
 
543
 
-
 
544
 
-
 
545
 
-
 
546
 
-
 
547
 
570
    .no_edit:
548
    .no_edit:
Line 571... Line 549...
571
 
549
 
572
      .blurrr:
550
      .blurrr:
573
        cmp  [sinus_flag],0
551
        cmp  [sinus_flag],0
Line 593... Line 571...
593
        call    do_emboss
571
        call    do_emboss
594
 
572
 
Line 595... Line 573...
595
      @@:
573
      @@:
Line -... Line 574...
-
 
574
 
596
 
575
 
597
    cmp     [inc_bright_flag],0           ; increase brightness
576
    cmp     [inc_bright_flag],0           ; increase brightness
598
    je      .no_inc_bright
577
    je      .no_inc_bright
599
    movzx   ebx,[inc_bright_flag]
578
    movzx   ebx,[inc_bright_flag]
600
    shl     ebx,4
579
    shl     ebx,4
Line 725... Line 704...
725
 
704
 
726
    mov     eax,7           ; put image
705
    mov     eax,7           ; put image
727
    mov     ebx,[screen_ptr]
706
    mov     ebx,[screen_ptr]
728
    mov     ecx,[size_y_var]
-
 
729
  ;  mov     ecx,SIZE_X shl 16 + SIZE_Y
707
    mov     ecx,[size_y_var]
730
    mov     edx,[offset_y]  ;5 shl 16 + 25
708
    mov    edx,[offset_y]
731
    cmp     [dr_flag],12
709
    cmp     [dr_flag],11
732
    jge     .ff
710
    jge     .ff
733
    int     0x40
711
    int     0x40
734
    jmp     .f
712
    jmp     .f
735
  .ff:
713
  .ff:
Line 1233... Line 1211...
1233
         mov      al,byte[esi+13]   ; g
1211
         mov      al,byte[esi+13]   ; g
1234
         push     ax
1212
         push     ax
1235
         mov      al,byte[esi+12]   ; r
1213
         mov      al,byte[esi+12]   ; r
1236
         push     ax
1214
         push     ax
1237
    ;     pxor       xmm1,xmm1
1215
         mov      al,byte[esi+20]   ; b     max color
1238
    ;     movd       xmm0,[esi+12]
-
 
1239
    ;     punpckhbw  xmm0,xmm1
-
 
1240
    ;     sub        esp,8
-
 
1241
    ;     movq       [esp],xmm0
-
 
1242
 
-
 
1243
 
-
 
1244
         mov      al,byte[esi+20]   ; b     max color
-
 
1245
         push     ax
1216
         push     ax
1246
         mov      al,byte[esi+19]   ; g
1217
         mov      al,byte[esi+19]   ; g
1247
         push     ax
1218
         push     ax
1248
         mov      al,byte[esi+18]   ; r
1219
         mov      al,byte[esi+18]   ; r
1249
         push     ax
1220
         push     ax
Line 1416... Line 1387...
1416
    .env_done:
1387
    .env_done:
1417
         mov     esp,ebp
1388
         mov     esp,ebp
1418
         pop     ebp
1389
         pop     ebp
1419
ret
1390
ret
1420
if   Ext >= SSE2
1391
if Ext >= SSE3
1421
init_point_normals:
1392
init_point_normals:
1422
.z equ dword [ebp-8]
1393
.z equ dword [ebp-8]
1423
.y equ dword [ebp-12]
1394
.y equ dword [ebp-12]
1424
.x equ [ebp-16]
1395
.x equ [ebp-16]
1425
.point_number equ dword [ebp-28]
1396
.point_number equ dword [ebp-28]
1426
.hit_faces    equ dword [ebp-32]
1397
.hit_faces    equ dword [ebp-32]
Line -... Line 1398...
-
 
1398
 
1427
 
1399
        fninit
1428
         push      ebp
1400
        push      ebp
1429
        mov       ebp,esp
1401
        mov       ebp,esp
1430
        sub       esp,64
1402
        sub       esp,64
1431
        and       ebp,-16
1403
        and       ebp,-16
Line 1464... Line 1436...
1464
        cmp       ecx,[triangles_count_var]
1436
        cmp       ecx,[triangles_count_var]
1465
        jne       .ipn_check_face
1437
        jne       .ipn_check_face
1466
        cvtsi2ss  xmm6,.hit_faces
1438
        cvtsi2ss  xmm6,.hit_faces
1467
        movaps    xmm7,.x
1439
        movaps    xmm7,.x
1468
 
1440
        rcpss     xmm6,xmm6
1469
        rcpss     xmm6,xmm6
-
 
1470
        shufps    xmm6,xmm6,11000000b
1441
        shufps    xmm6,xmm6,11000000b
1471
        mulps     xmm7,xmm6
1442
        mulps     xmm7,xmm6
1472
        movlps    [edi],xmm7
1443
        movaps    xmm6,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
1473
        movhlps   xmm7,xmm7
1451
        movhlps   xmm7,xmm7
1474
        movss     [edi+8],xmm7
1452
        movss     [edi+8],xmm7
1475
        call      normalize_vector
1453
        add       edi,12
1476
    ;    movaps    xmm6,xmm7
-
 
1477
    ;    mulps     xmm6,xmm6
-
 
1478
    ;    andps     xmm6,[zero_hgst_dd]
-
 
1479
    ;    haddps    xmm6,xmm6
-
 
1480
    ;    haddps    xmm6,xmm6
-
 
1481
    ;    rsqrtps    xmm6,xmm6
-
 
1482
    ;    mulps     xmm7,xmm6
-
 
1483
    ;    movlps    [edi],xmm7
-
 
1484
    ;    movhlps   xmm7,xmm7
-
 
1485
    ;    movss     [edi+8],xmm7
-
 
1486
 
-
 
1487
        add       edi,12
-
 
1488
        inc       .point_number
1454
        inc       .point_number
1489
        mov       edx,.point_number
1455
        mov       edx,.point_number
1490
        cmp       edx,[points_count_var]
1456
        cmp       edx,[points_count_var]
1491
        jne       .ipn_loop
1457
        jne       .ipn_loop
1492
 
1458
 
Line 1762... Line 1728...
1762
      .no_stencil:
1728
      .no_stencil:
1763
      end if
1729
      end if
Line -... Line 1730...
-
 
1730
 
-
 
1731
 
Line 1764... Line 1732...
1764
 
1732
        cmp     [dr_flag],11
1765
 
1733
        je      .draw_smooth_line
1766
 
1734
 
1767
        mov esi,[triangles_ptr]
1735
        mov esi,[triangles_ptr]
1768
        mov ecx,[triangles_count_var]
1736
        mov ecx,[triangles_count_var]
1769
    .again_dts:
1737
    .again_dts:
1770
        push    ecx
1738
        push    ecx
1771
        mov     ebp,[points_translated_ptr]
1739
        mov     ebp,[points_translated_ptr]
1772
      if Ext = NON
1740
      if Ext >= SSE2
1773
        mov     eax,dword[esi]
1741
        mov     eax,dword[esi]
1774
        mov     [point_index1],eax
1742
        mov     [point_index1],eax
Line 1812... Line 1780...
1812
        mov     eax,[ebp+4]
1780
        mov     eax,[ebp+4]
1813
        mov     [zz3],ax
1781
        mov     [zz3],ax
1814
      else
1782
      else
1815
        movq    mm0,[esi]           ; don't know MMX
1783
        movq    mm0,[esi]           ; don't know MMX
1816
        movq    qword[point_index1],mm0
1784
        mov     qword[point_index1],mm0
1817
       ; shr     eax,16
1785
       ; shr     eax,16
1818
       ; mov     [point_index2],ax
1786
       ; mov     [point_index2],ax
1819
        mov     eax,dword[esi+8]
1787
        mov     eax,dword[esi+8]
1820
        mov     [point_index3],eax
1788
        mov     [point_index3],eax
1821
        movdqu  xmm0,[esi]
1789
        movdqu  xmm0,[esi]
1822
        paddd   xmm0,xmm0
1790
        paddd   xmm0,xmm0
Line 1888... Line 1856...
1888
        mov     eax,dword[esi]
1856
        mov     eax,dword[esi]
1889
        lea     eax,[eax*3]
1857
        lea     eax,[eax*3]
1890
        shl     eax,2
1858
        shl     eax,2
1891
        add     eax,[points_normals_rot_ptr]
1859
        add     eax,[points_normals_rot_ptr]
1892
        bt      dword[eax+8],+31
1860
;        lea     eax,[eax+point_normals_rotated]
1893
        jc      .no_culling
-
 
1894
;        lea     eax,[eax+point_normals_rotated]
-
 
1895
     ;   fld     dword[eax+8]             ; *****************************
1861
        fld     dword[eax+8]             ; *****************************
1896
  ;      ftst                             ; CHECKING OF Z COOFICIENT OF
1862
        ftst                             ; CHECKING OF Z COOFICIENT OF
1897
  ;      fstsw   ax                       ; NORMAL VECTOR
1863
        fstsw   ax                       ; NORMAL VECTOR
1898
  ;      sahf
1864
        sahf
1899
  ;      jb      @f
1865
        jb      @f
1900
  ;      ffree   st
1866
        ffree   st
1901
        loop    @b
1867
        loop    @b
1902
        jmp     .end_draw   ; non visable
1868
        jmp     .end_draw   ; non visable
1903
  ;    @@:
1869
      @@:
1904
  ;      ffree   st  ;is visable
1870
        ffree   st  ;is visable
1905
      .no_culling:
1871
      .no_culling:
1906
        cmp     [dr_flag],0               ; draw type flag
1872
        cmp     [dr_flag],0               ; draw type flag
1907
        je      .flat_draw
1873
        je      .flat_draw
1908
        cmp     [dr_flag],2
1874
        cmp     [dr_flag],2
1909
        je      .env_mapping
1875
        je      .env_mapping
1910
        cmp     [dr_flag],3
1876
        cmp     [dr_flag],3
Line 1929... Line 1895...
1929
        cmp     [dr_flag],13
1895
        cmp     [dr_flag],13
1930
        je      .glass
1896
        je      .glass
1931
        cmp     [dr_flag],14
1897
        cmp     [dr_flag],14
1932
        je      .glass_tex
1898
        je      .glass_tex
1933
 
1899
     end if                                 ; ****************
1934
     end if                                 ; ****************
-
 
1935
        mov     esi,point_index3      ; do Gouraud shading
1900
        mov     esi,point_index3      ; do Gouraud shading
1936
        mov     ecx,3
1901
        mov     ecx,3
1937
      .again_grd_draw:
1902
      .again_grd_draw:
1938
        mov     eax,dword[esi]
1903
        mov     eax,dword[esi]
1939
        shl     eax,2
1904
        shl     eax,2
1940
        lea     eax,[eax*3]
1905
        lea     eax,[eax*3]
1941
        add     eax,[points_normals_rot_ptr]
1906
        add     eax,[points_normals_rot_ptr]
1942
    if Ext < SSE
1907
        ; texture x=(rotated point normal -> x * 255)+255
1943
        ; texture x=(rotated point normal -> x * 255)+255
-
 
1944
        fld     dword[eax]       ; x cooficient of normal vector
1908
        fld     dword[eax]       ; x cooficient of normal vector
1945
        fmul    dword[correct_texf]
1909
        fimul   [correct_tex]
1946
        fadd    dword[correct_texf]
1910
        fiadd   [correct_tex]
1947
        fistp   [temp1]
1911
        fistp   [temp1]
1948
        ; texture y=(rotated point normal -> y * 255)+255
1912
        ; texture y=(rotated point normal -> y * 255)+255
1949
        fld     dword[eax+4]      ; y cooficient
1913
        fld     dword[eax+4]      ; y cooficient
1950
        fmul    dword[correct_texf]
1914
        fimul   [correct_tex]
1951
        fadd    dword[correct_texf]
1915
        fiadd   [correct_tex]
1952
        fistp   [temp2]
1916
        fistp   [temp2]
1953
        mov      eax,[temp2]
1917
 
-
 
1918
        mov      eax,[temp2]
1954
        mov      ebx,[temp1]
1919
        mov      ebx,[temp1]
1955
     else
1920
        and      ebx,0xfffffff
1956
        movlps   xmm0,[eax]
-
 
1957
        mulps    xmm0,[correct_texf]
-
 
1958
        addps    xmm0,[correct_texf]
-
 
1959
        cvtps2dq xmm0,xmm0
-
 
1960
        movd     eax,xmm0
-
 
1961
        psrldq   xmm0,4
-
 
1962
        movd     ebx,xmm0
-
 
1963
     end if
-
 
1964
        and      ebx,0xfffffff
-
 
1965
        shl      eax,TEX_SHIFT
1921
        shl      eax,TEX_SHIFT
1966
        add      eax,ebx
1922
        add      eax,ebx
1967
        lea      eax,[eax*3+color_map]
1923
        lea      eax,[eax*3+color_map]
1968
        mov      eax,dword[eax]
1924
        mov      eax,dword[eax]
1969
     ;   cmp     [catmull_flag],1      ; put on stack z coordinate if necessary
1925
     ;   cmp     [catmull_flag],1      ; put on stack z coordinate if necessary
Line 2064... Line 2020...
2064
        fninit                             ; FLAT DRAWING
2020
        fninit                             ; FLAT DRAWING
2065
        mov     eax,[point_index1]
2021
        mov     eax,[point_index1]
2066
        mov     ebx,[point_index2]
2022
        mov     ebx,[point_index2]
2067
        mov     ecx,[point_index3]
2023
        mov     ecx,[point_index3]
2068
    ;    shl     eax,2
2024
        shl     eax,2
2069
        imul    eax,[i12]
2025
        shl     ebx,2
2070
        imul    ebx,[i12]
-
 
2071
        imul    ecx,[i12]
-
 
2072
     ;   shl     ebx,2
-
 
2073
     ;   shl     ecx,2
2026
        shl     ecx,2
2074
     ;   lea     eax,[eax*3]  ;+point_normals_rotated]
2027
        lea     eax,[eax*3]  ;+point_normals_rotated]
2075
        add     eax,[points_normals_rot_ptr]
2028
        add     eax,[points_normals_rot_ptr]
2076
     ;   lea     ebx,[ebx*3]  ;+point_normals_rotated]
2029
        lea     ebx,[ebx*3]  ;+point_normals_rotated]
2077
        add     ebx,[points_normals_rot_ptr]
2030
        add     ebx,[points_normals_rot_ptr]
2078
     ;   lea     ecx,[ecx*3]  ;+point_normals_rotated]
2031
        lea     ecx,[ecx*3]  ;+point_normals_rotated]
2079
        add     ecx,[points_normals_rot_ptr]
2032
        add     ecx,[points_normals_rot_ptr]
2080
        fld     dword[eax]      ; x cooficient of normal vector
2033
        fld     dword[eax]      ; x cooficient of normal vector
2081
        fadd    dword[ebx]
2034
        fadd    dword[ebx]
2082
        fadd    dword[ecx]
2035
        fadd    dword[ecx]
2083
        fidiv   [i3]
2036
        fidiv   [i3]
2084
        fmul   dword[correct_texf]
2037
        fimul   [correct_tex]
2085
        fadd   dword[correct_texf]
2038
        fiadd   [correct_tex]
2086
        fistp   [temp1]  ;dword[esp-4]    ; x temp variables
2039
        fistp   [temp1]  ;dword[esp-4]    ; x temp variables
2087
        fld     dword[eax+4]    ; y cooficient of normal vector
2040
        fld     dword[eax+4]    ; y cooficient of normal vector
2088
        fadd    dword[ebx+4]
2041
        fadd    dword[ebx+4]
2089
        fadd    dword[ecx+4]
2042
        fadd    dword[ecx+4]
2090
        fidiv   [i3]
2043
        fidiv   [i3]
2091
        fmul   dword[correct_texf]
2044
        fimul   [correct_tex]
2092
        fadd   dword[correct_texf]
2045
        fiadd   [correct_tex]
2093
        fistp   [temp2]  ;dword[esp-8]   ;  y
2046
        fistp   [temp2]  ;dword[esp-8]   ;  y
2094
        mov     edx,[temp2] ;dword[esp-8]
2047
        mov     edx,[temp2] ;dword[esp-8]
2095
        and     edx,0xfffffff
2048
        and     edx,0xfffffff
2096
        and     [temp1],0xfffffff
2049
        and     [temp1],0xfffffff
2097
        shl     edx,TEX_SHIFT
2050
        shl     edx,TEX_SHIFT
2098
        add     edx,[temp1]  ;dword[esp-4]
2051
        add     edx,[temp1]  ;dword[esp-4]
Line 2145... Line 2098...
2145
        mov       eax,dword[esi]
2098
        mov     eax,dword[esi]
2146
        lea       eax,[eax*3]
2099
        lea     eax,[eax*3]
2147
        shl       eax,2
2100
        shl     eax,2
2148
        add       eax,[points_normals_rot_ptr]       ;point_normals_rotated
2101
        add     eax,[points_normals_rot_ptr]       ;point_normals_rotated
2149
        movlps      xmm0,[eax]
2102
        ; texture x=(rotated point normal -> x * 255)+255
-
 
2103
        fld     dword[eax]
2150
        mulps       xmm0,[correct_texf]
2104
        fimul   [correct_tex]
2151
        addps       xmm0,[correct_texf]
2105
        fiadd   [correct_tex]
2152
        cvtps2dq    xmm0,xmm0
2106
        fistp   word[edi]
2153
        packssdw    xmm0,xmm0
2107
        ; texture y=(rotated point normal -> y * 255)+255
-
 
2108
        fld     dword[eax+4]
2154
        movd        [edi],xmm0
2109
        fimul   [correct_tex]
-
 
2110
        fiadd   [correct_tex]
-
 
2111
        fistp   word[edi+2]
2155
        add         edi,4
2112
 
-
 
2113
        add     edi,4
2156
        add         esi,4
2114
        add     esi,4
2157
        loop        @b
2115
        loop    @b
2158
 
2116
 
Line 2159... Line 2117...
2159
        mov     eax,dword[xx1]
2117
        mov     eax,dword[xx1]
Line 2190... Line 2148...
2190
        fld1
2148
        fld1
2191
        fld1
2149
        fld1
2192
        faddp
2150
        faddp
2193
        fmulp
2151
        fmulp
2194
        fmul    dword[correct_texf]
2152
        fimul   [correct_tex]
2195
        fadd    dword[correct_texf]
2153
        fiadd   [correct_tex]
2196
        fistp   word[edi]
2154
        fistp   word[edi]
2197
        mov     word[edi+2],0
2155
        mov     word[edi+2],0
2198
;        fistp   word[edi+2]
2156
;        fistp   word[edi+2]
2199
; # last change
2157
; # last change
2200
;        ; texture x=(rotated point normal -> x * 255)+255
2158
;        ; texture x=(rotated point normal -> x * 255)+255
2201
;        fld     dword[eax]
2159
;        fld     dword[eax]
Line 2242... Line 2200...
2242
      @@:
2200
      @@:
2243
        mov     eax,dword[esi]
2201
        mov     eax,dword[esi]
2244
        lea     eax,[eax*3]
2202
        lea     eax,[eax*3]
2245
        shl     eax,2
2203
        shl     eax,2
2246
    ;    imul    eax,[i12]
2204
        add     eax,[points_normals_rot_ptr]  ;point_normals_rotated
2247
        add     eax,[points_normals_rot_ptr]  ;point_normals_rotated
-
 
2248
        ; texture x=(rotated point normal -> x * 255)+255
2205
        ; texture x=(rotated point normal -> x * 255)+255
2249
 
2206
        fld     dword[eax]
-
 
2207
        fimul   [correct_tex]
-
 
2208
        fiadd   [correct_tex]
-
 
2209
        fistp   word[edi]
-
 
2210
        ; texture y=(rotated point normal -> y * 255)+255
-
 
2211
        fld     dword[eax+4]
-
 
2212
        fimul   [correct_tex]
-
 
2213
        fiadd   [correct_tex]
-
 
2214
        fistp   word[edi+2]
-
 
2215
 
Line 2250... Line -...
2250
        movlps      xmm0,[eax]
-
 
2251
        mulps       xmm0,[correct_texf]
-
 
2252
        addps       xmm0,[correct_texf]
-
 
2253
        cvtps2dq    xmm0,xmm0
-
 
2254
        packssdw    xmm0,xmm0
-
 
2255
        movd        [edi],xmm0
-
 
2256
        add         edi,4
2216
        add     edi,4
2257
        add         esi,4
2217
        add     esi,4
2258
        loop        @b
2218
        loop    @b
Line 2259... Line 2219...
2259
 
2219
 
Line 2263... Line 2223...
2263
        push   dword[esi]
2223
        push   dword[esi]
2264
        mov    esi,[point_index2]
2224
        mov    esi,[point_index2]
2265
        shl    esi,2
2225
        shl    esi,2
2266
        add    esi,tex_points
2226
        add    esi,tex_points
2267
        push   dword[esi]
2227
;       lea    esi,[esi*3]
-
 
2228
;       lea    esi,[points+2+esi*2]
-
 
2229
        push   dword[esi]
2268
        mov    esi,[point_index1]
2230
  ;     push   dword[xx2]
-
 
2231
        mov    esi,[point_index1]
2269
        shl    esi,2
2232
        shl    esi,2
2270
        add    esi,tex_points
2233
        add    esi,tex_points
2271
        push   dword[esi]
2234
;       lea     esi,[esi*3]
-
 
2235
;       lea     esi,[points+2+esi*2]
-
 
2236
        push   dword[esi]
2272
 
2237
   ;    push     dword[xx1]
-
 
2238
 
Line 2273... Line 2239...
2273
        mov     eax,dword[xx1]
2239
        mov     eax,dword[xx1]
2274
        ror     eax,16
2240
        ror     eax,16
2275
        mov     ebx,dword[xx2]
2241
        mov     ebx,dword[xx2]
2276
        ror     ebx,16
2242
        ror     ebx,16
Line 2375... Line 2341...
2375
      .aagain_grd_draw:
2341
      .aagain_grd_draw:
Line 2376... Line 2342...
2376
 
2342
 
2377
        lea      edx,[ecx*3]
2343
        lea      edx,[ecx*3]
2378
        push     word[edx*2+xx1-2]    ; zz1 ,2 ,3
2344
        push     word[edx*2+xx1-2]    ; zz1 ,2 ,3
2379
    ;    fninit
2345
        fninit
2380
        mov     eax,dword[esi]
2346
        mov     eax,dword[esi]
2381
        shl     eax,2
2347
        shl     eax,2
2382
        lea     eax,[eax*3] ;+point_normals_rotated]
2348
        lea     eax,[eax*3] ;+point_normals_rotated]
2383
        add     eax,[points_normals_rot_ptr]
-
 
2384
     if Ext < SSE
2349
        add     eax,[points_normals_rot_ptr]
2385
        ; texture x=(rotated point normal -> x * 255)+255
2350
        ; texture x=(rotated point normal -> x * 255)+255
2386
        fld     dword[eax]       ; x cooficient of normal vector
2351
        fld     dword[eax]       ; x cooficient of normal vector
2387
        fmul    dword[correct_texf]
2352
        fimul   [correct_tex]
2388
        fadd    dword[correct_texf]
2353
        fiadd   [correct_tex]
2389
        fistp   [temp1]  ;word[ebp-2]
2354
        fistp   [temp1]  ;word[ebp-2]
2390
        ; texture y=(rotated point normal -> y * 255)+255
2355
        ; texture y=(rotated point normal -> y * 255)+255
2391
        fld     dword[eax+4]      ; y cooficient
2356
        fld     dword[eax+4]      ; y cooficient
2392
        fmul    dword[correct_texf]
2357
        fimul   [correct_tex]
2393
        fadd    dword[correct_texf]
2358
        fiadd   [correct_tex]
-
 
2359
        fistp   [temp2]  ;word[ebp-4]
2394
        fistp   [temp2]  ;word[ebp-4]
2360
 
2395
        mov      eax,[temp2]
2361
        mov      eax,[temp2]   ;word[ebp-4]
2396
        mov      ebx,[temp1]
-
 
2397
       else
-
 
2398
        movlps   xmm0,[eax]
-
 
2399
        mulps    xmm0,[correct_texf]
-
 
2400
        addps    xmm0,[correct_texf]
-
 
2401
        cvtps2dq xmm0,xmm0
-
 
2402
        movd     eax,xmm0
-
 
2403
        psrldq   xmm0,4
-
 
2404
        movd     ebx,xmm0
-
 
2405
      end if
2362
        mov      ebx,[temp1]   ;word[ebp-2]
2406
        and      ebx,0xfffffff ; some onjects need thid 'and'
2363
        and      ebx,0xfffffff ; some onjects need thid 'and'
2407
        shl      eax,TEX_SHIFT
2364
        shl      eax,TEX_SHIFT
2408
        add      eax,ebx
2365
        add      eax,ebx
2409
        lea      eax,[eax*3]
2366
        lea      eax,[eax*3]
Line 2469... Line 2426...
2469
        lea     eax,[eax*3]
2426
        lea     eax,[eax*3]
2470
        shl     eax,2
2427
        shl     eax,2
2471
        add     eax,[points_normals_rot_ptr]
2428
        add     eax,[points_normals_rot_ptr]
2472
        ; texture x=(rotated point normal -> x * 255)+255
2429
        ; texture x=(rotated point normal -> x * 255)+255
2473
        movlps   xmm0,[eax]
2430
        fld     dword[eax]
2474
        mulps    xmm0,[correct_texf]
-
 
2475
        addps    xmm0,[correct_texf]
-
 
2476
        cvtps2dq xmm0,xmm0
-
 
2477
        packssdw xmm0,xmm0
-
 
2478
        movd     [edi],xmm0
-
 
2479
     ;   fld     dword[eax]
-
 
2480
     ;   fmul    dword[correct_texf]
2431
        fimul   [correct_tex]
2481
     ;   fadd    dword[correct_texf]
2432
        fiadd   [correct_tex]
2482
     ;   fistp   word[edi]
2433
        fistp   word[edi]
2483
 
2434
 
Line 2484... Line 2435...
2484
        ; texture y=(rotated point normal -> y * 255)+255
2435
        ; texture y=(rotated point normal -> y * 255)+255
2485
      ;  fld     dword[eax+4]
2436
        fld     dword[eax+4]
2486
      ;  fmul    dword[correct_texf]
2437
        fimul   [correct_tex]
2487
      ;  fadd    dword[correct_texf]
2438
        fiadd   [correct_tex]
2488
      ;  fistp   word[edi+2]
2439
        fistp   word[edi+2]
2489
        and     word[edi+2],0x7fff  ; some objects need it
2440
        and     word[edi+2],0x7fff  ; some objects need it
2490
        add     edi,4
2441
        add     edi,4
2491
        add     esi,4
2442
        add     esi,4
2492
        loop    @b
2443
        loop    @b
Line 2535... Line 2486...
2535
        mov     eax,dword[esi]
2486
        mov     eax,dword[esi]
2536
        lea     eax,[eax*3]
2487
        lea     eax,[eax*3]
2537
        shl     eax,2
2488
        shl     eax,2
2538
        add     eax,[points_normals_rot_ptr]
2489
        add     eax,[points_normals_rot_ptr]
2539
      if Ext >= SSE
2490
        ; texture x=(rotated point normal -> x * 255)+255
2540
        ; texture x=(rotated point normal -> x * 255)+255
-
 
2541
        movlps   xmm0,[eax]
2491
        fld     dword[eax]
2542
        mulps    xmm0,[correct_texf]
-
 
2543
        addps    xmm0,[correct_texf]
-
 
2544
        cvtps2dq xmm0,xmm0
-
 
2545
        packssdw xmm0,xmm0
-
 
2546
        movd     [edi],xmm0
-
 
2547
      else
-
 
2548
        fld     dword[eax]
-
 
2549
        fimul   [correct_tex]
2492
        fimul   [correct_tex]
2550
        fiadd   [correct_tex]
2493
        fiadd   [correct_tex]
2551
        fistp   word[edi]
2494
        fistp   word[edi]
2552
        ; texture y=(rotated point normal -> y * 255)+255
2495
        ; texture y=(rotated point normal -> y * 255)+255
2553
        fld     dword[eax+4]
2496
        fld     dword[eax+4]
2554
        fimul   [correct_tex]
2497
        fimul   [correct_tex]
2555
        fiadd   [correct_tex]
2498
        fiadd   [correct_tex]
2556
        fistp   word[edi+2]
2499
        fistp   word[edi+2]
2557
     end if
2500
 
2558
        add     edi,4
2501
        add     edi,4
2559
        add     esi,4
2502
        add     esi,4
2560
        loop    @b
2503
        loop    @b
2561
 
2504
 
Line 2562... Line 2505...
2562
;        push  dword 1 shl 16 + 1  ; emap coords
2505
;        push  dword 1 shl 16 + 1  ; emap coords
Line 2594... Line 2537...
2594
        call bump_tex_triangle_z
2537
        call bump_tex_triangle_z
Line 2595... Line 2538...
2595
 
2538
 
Line 2596... Line -...
2596
        jmp     .end_draw
-
 
2597
 
-
 
2598
      .draw_smooth_line:
-
 
2599
        mov     esi,point_index3
-
 
2600
        mov     ecx,3
-
 
2601
      .again_line_param:
-
 
2602
        mov     eax,dword[esi]
-
 
2603
        shl     eax,2
-
 
2604
        lea     eax,[eax*3]
-
 
2605
        add     eax,[points_normals_rot_ptr]
-
 
2606
      if Ext>=SSE2
-
 
2607
        movlps  xmm0,[eax]
-
 
2608
        mulps   xmm0,[correct_texf]
-
 
2609
        addps   xmm0,[correct_texf]
-
 
2610
        cvtps2dq xmm0,xmm0
-
 
2611
        movd    eax,xmm0
-
 
2612
        psrldq  xmm0,4
-
 
2613
        movd    ebx,xmm0
-
 
2614
       else if
-
 
2615
         ; texture ;x=(rotated point normal -> x * 255)+255
-
 
2616
        fld     dword[eax]       ; x cooficient of normal vector
-
 
2617
        fmul   dword[correct_texf]
-
 
2618
        fadd   dword[correct_texf]
-
 
2619
        fistp   [temp1]  ;word[esp-2]
-
 
2620
        ; texture y=(rotated point normal -> y * 255)+255
-
 
2621
        fld     dword[eax+4]      ; y cooficient
-
 
2622
        fmul   dword[correct_texf]
-
 
2623
        fadd   dword[correct_texf]
-
 
2624
        fistp   [temp2]  ;word[esp-4]
-
 
2625
        mov      eax,[temp2]  ;word[esp-4]
-
 
2626
        mov      ebx,[temp1]  ;word[esp-2]
-
 
2627
      end if
-
 
2628
        and      ebx,0xfffffff
-
 
2629
        shl      eax,TEX_SHIFT
-
 
2630
        add      eax,ebx
-
 
2631
        lea      eax,[eax*3+color_map]
-
 
2632
        mov      eax,dword[eax]
-
 
2633
        lea      ebx,[ecx-1]
-
 
2634
        shl      ebx,2
-
 
2635
        mov      [ebx+col1],eax
-
 
2636
 
-
 
2637
        sub      esi,4
-
 
2638
        dec      ecx
-
 
2639
        jnz      .again_line_param
-
 
2640
 
-
 
2641
        mov     edi,[screen_ptr]
-
 
2642
        mov     esi,[Zbuffer_ptr]
-
 
2643
 
-
 
2644
        mov     eax,[col1]
-
 
2645
        movzx   bx,al
-
 
2646
        push    bx                ; b
-
 
2647
        movzx   bx,ah
-
 
2648
        push    bx
-
 
2649
        rol     eax,16
-
 
2650
        xor     ah,ah
-
 
2651
        push    ax
-
 
2652
        push    [zz1]
-
 
2653
        push    [yy1]
-
 
2654
        push    [xx1]
-
 
2655
 
-
 
2656
        mov     eax,[col2]
-
 
2657
        movzx   bx,al
-
 
2658
        push    bx                ; b
-
 
2659
        movzx   bx,ah
-
 
2660
        push    bx
-
 
2661
        rol     eax,16
-
 
2662
        xor     ah,ah
-
 
2663
        push    ax
-
 
2664
        push    [zz2]
-
 
2665
        push    [yy2]
-
 
2666
        push    [xx2]
-
 
2667
 
-
 
2668
        call    smooth_line
-
 
2669
     @@:
-
 
2670
 
-
 
2671
        mov     edi,[screen_ptr]
-
 
2672
        mov     esi,[Zbuffer_ptr]
-
 
2673
 
-
 
2674
        mov     eax,[col1]
-
 
2675
        movzx   bx,al
-
 
2676
        push    bx                ; b
-
 
2677
        movzx   bx,ah
-
 
2678
        push    bx
-
 
2679
        rol     eax,16
-
 
2680
        xor     ah,ah
-
 
2681
        push    ax
-
 
2682
        push    [zz1]
-
 
2683
        push    [yy1]
-
 
2684
        push    [xx1]
-
 
2685
 
-
 
2686
        mov     eax,[col3]
-
 
2687
        movzx   bx,al
-
 
2688
        push    bx                ; b
-
 
2689
        movzx   bx,ah
-
 
2690
        push    bx
-
 
2691
        rol     eax,16
-
 
2692
        xor     ah,ah
-
 
2693
        push    ax
-
 
2694
        push    [zz3]
-
 
2695
        push    [yy3]
-
 
2696
        push    [xx3]
-
 
2697
 
-
 
2698
        call    smooth_line
-
 
2699
      @@:
-
 
2700
 
-
 
2701
 
-
 
2702
        mov     edi,[screen_ptr]
-
 
2703
        mov     esi,[Zbuffer_ptr]
-
 
2704
 
-
 
2705
        mov     eax,[col3]
-
 
2706
        movzx   bx,al
-
 
2707
        push    bx                ; b
-
 
2708
        movzx   bx,ah
-
 
2709
        push    bx
-
 
2710
        rol     eax,16
-
 
2711
        xor     ah,ah
-
 
2712
        push    ax
-
 
2713
        push    [zz3]
-
 
2714
        push    [yy3]
-
 
2715
        push    [xx3]
-
 
2716
 
-
 
2717
        mov     eax,[col2]
-
 
2718
        movzx   bx,al
-
 
2719
        push    bx                ; b
-
 
2720
        movzx   bx,ah
-
 
2721
        push    bx
-
 
2722
        rol     eax,16
-
 
2723
        xor     ah,ah
-
 
2724
        push    ax
-
 
2725
        push    [zz2]
-
 
2726
        push    [yy2]
-
 
2727
        push    [xx2]
-
 
2728
 
-
 
2729
        call    smooth_line
-
 
Line 2730... Line 2539...
2730
        jmp     .end_draw
2539
        jmp     .end_draw
2731
      @@:
2540
 
Line 2787... Line 2596...
2787
 
2596
 
Line 2788... Line 2597...
2788
        jmp     .end_draw
2597
        jmp     .end_draw
Line 2789... Line 2598...
2789
 
2598
 
2790
     .glass:
-
 
2791
 
2599
     .glass:
2792
        movd      xmm5,[size_y_var]
2600
        movd      xmm5,[size_y_var]
2793
        punpcklwd xmm5,[the_zero]
2601
        punpcklwd xmm5,[the_zero]
Line 2841... Line 2649...
2841
 
2649
 
Line 2842... Line 2650...
2842
        call    glass_tri
2650
        call    glass_tri
2843
        jmp     .end_draw
2651
        jmp     .end_draw
Line -... Line 2652...
-
 
2652
 
2844
 
2653
 
2845
   .glass_tex:
2654
   .glass_tex:
2846
        movd      xmm5,[size_y_var]
2655
        movd      xmm5,[size_y_var]
2847
        punpcklwd xmm5,[the_zero]
2656
        punpcklwd xmm5,[the_zero]
Line 2915... Line 2724...
2915
        mov     esi,[Zbuffer_ptr]
2724
        mov     esi,[Zbuffer_ptr]
2916
 
2725
 
Line 2917... Line 2726...
2917
        call    glass_tex_tri
2726
        call    glass_tex_tri
Line 2918... Line -...
2918
 
-
 
2919
        jmp     .end_draw
-
 
2920
end if
-
 
Line -... Line 2727...
-
 
2727
 
Line 2921... Line 2728...
2921
 
2728
 
2922
 
2729
 
2923
 
2730
end if
Line 2924... Line 2731...
2924
 
2731
 
2925
      .end_draw:
2732
      .end_draw:
Line 2926... Line 2733...
2926
        pop     esi
2733
        pop     esi
2927
        add     esi,12
2734
        add     esi,12
Line -... Line 2735...
-
 
2735
 
-
 
2736
        pop     ecx
-
 
2737
        dec     ecx
-
 
2738
 
-
 
2739
        jnz     .again_dts
-
 
2740
ret
Line -... Line 2741...
-
 
2741
 
-
 
2742
 
-
 
2743
   .draw_smooth_line:
-
 
2744
        mov     esi,[edges_ptr]
-
 
2745
        xor     ecx,ecx
-
 
2746
    .again_s_line:
-
 
2747
        push    ecx
-
 
2748
        push    esi
-
 
2749
 
-
 
2750
        mov     ecx,2
-
 
2751
     .aga_n:
-
 
2752
        mov     eax,[esi]
-
 
2753
        shl     eax,2
-
 
2754
        lea     eax,[eax*3]
-
 
2755
        add     eax,[points_normals_rot_ptr]
-
 
2756
        movups   xmm0,[eax]
-
 
2757
        xorps    xmm1,xmm1
-
 
2758
        mov      edx,lights_aligned
-
 
2759
    .again_cc:
-
 
2760
        movaps    xmm3,xmm0   ;.cnv
-
 
2761
        mulps     xmm3,[edx]
-
 
2762
        andps     xmm3,[zero_hgst_dd]
-
 
2763
   ;     haddps    xmm3,xmm3
-
 
2764
   ;     haddps    xmm3,xmm3   ; xmm3 - dot pr
-
 
2765
        movhlps   xmm2,xmm3
-
 
2766
        addps     xmm3,xmm2
-
 
2767
        movdqa    xmm2,xmm3
-
 
2768
        shufps    xmm2,xmm2,01010101b
-
 
2769
        addps     xmm3,xmm2
-
 
2770
        shufps    xmm3,xmm3,0
-
 
2771
        movaps    xmm6,xmm3   ;xmm7
-
 
2772
        mulps     xmm6,xmm6
-
 
2773
        mulps     xmm6,xmm6
-
 
2774
        mulps     xmm6,xmm6
-
 
2775
        mulps     xmm6,xmm6
-
 
2776
        mulps     xmm6,xmm6
-
 
2777
        mulps     xmm6,[edx+48]
-
 
2778
        movaps    xmm7,xmm3
-
 
2779
        mulps     xmm7,[edx+16]
-
 
2780
        addps     xmm7,xmm6
-
 
2781
        addps     xmm7,[edx+32]
-
 
2782
        minps     xmm7,[mask_255f]   ; global
Line -... Line 2783...
-
 
2783
 
-
 
2784
        maxps     xmm1,xmm7
-
 
2785
        add       edx,64     ; size of one light in aligned list
-
 
2786
        cmp       edx,lights_aligned_end
-
 
2787
        jl        .again_cc
-
 
2788
        sub       esp,16
-
 
2789
        movups    [esp],xmm1
-
 
2790
        add       esi,4
-
 
2791
        loop      .aga_n
-
 
2792
 
-
 
2793
        movups    xmm0,[esp]
Line -... Line 2794...
-
 
2794
        movups    xmm1,[esp+16]
-
 
2795
        add       esp,32
-
 
2796
        sub       esi,8
-
 
2797
 
-
 
2798
        mov     ecx,[esi]
-
 
2799
        mov     edx,[esi+4]
-
 
2800
        imul    ecx,[i6]
-
 
2801
        imul    edx,[i6]
-
 
2802
        add     ecx,[points_translated_ptr]
-
 
2803
        add     edx,[points_translated_ptr]
-
 
2804
 
-
 
2805
        movd    xmm7,[ecx]
-
 
2806
        movhps  xmm7,[edx]
-
 
2807
        pshufd  xmm7,xmm7,11101000b
-
 
2808
        movdqa  xmm6,xmm7
-
 
2809
        movd    xmm5,[size_y_var]
-
 
2810
        pshuflw xmm5,xmm5,00010001b
-
 
2811
        pcmpgtw xmm7,xmm5
-
 
2812
        pcmpgtw xmm6,[the_zero]
-
 
2813
        pxor    xmm7,xmm6
-
 
2814
        pmovmskb eax,xmm7
-
 
2815
        cmp     al,-1
-
 
2816
        jnz      .skp
-
 
2817
 
-
 
2818
 
-
 
2819
 
-
 
2820
 
-
 
2821
        mov     eax,[esi]
-
 
2822
        mov     ebx,[esi+4]
-
 
2823
        imul    eax,[i12]
-
 
2824
        imul    ebx,[i12]
-
 
2825
        add     eax,[points_rotated_ptr]
-
 
2826
        add     ebx,[points_rotated_ptr]
-
 
2827
        movss   xmm2,[eax+8]
-
 
2828
        movss   xmm3,[ebx+8]
-
 
2829
 
-
 
2830
 
-
 
2831
        movzx   eax,word[ecx]
-
 
2832
        movzx   ebx,word[ecx+2]
-
 
2833
        movzx   ecx,word[edx]
-
 
2834
        movzx   edx,word[edx+2]
-
 
2835
 
-
 
2836
        emms
-
 
2837
        movd    mm1,[screen_ptr]
-
 
2838
        movd    mm0,[Zbuffer_ptr]
-
 
2839
        movzx   esi,word[size_x_var]
-
 
2840
        movd    mm2,esi
-
 
2841
 
-
 
2842
        push    ebp
Line 3069... Line 2984...
3069
 
2984
 
Line 3070... Line 2985...
3070
 
2985
 
3071
fill_Z_buffer:
2986
fill_Z_buffer:
3072
        mov     eax,0x70000000
2987
        mov     eax,0x70000000
3073
        cmp     [dr_flag],12
2988
        cmp     [dr_flag],11
3074
        jne     @f
2989
        jl      @f
3075
        mov     eax,60000.1
2990
        mov     eax,60000.1
3076
    @@:
2991
    @@:
3077
        mov     edi,[Zbuffer_ptr]
2992
        mov     edi,[Zbuffer_ptr]
3078
        movzx   ecx,word[size_x_var]
2993
        movzx   ecx,word[size_x_var]
Line 3205... Line 3120...
3205
        xor     ebx,ebx
3120
        xor     ebx,ebx
3206
        xor     ebp,ebp
3121
        xor     ebp,ebp
3207
        mov     [points_count_var],0
3122
        mov     [points_count_var],0
3208
        mov     [triangles_count_var],0
3123
        mov     [triangles_count_var],0
3209
   if USE_LFN = 0
3124
        mov     esi,[fptr]
3210
        mov     esi,SourceFile
-
 
3211
   else
-
 
3212
        mov     esi,[fptr]
-
 
3213
   end if
3125
        cmp     [esi],word 4D4Dh
3214
        cmp     [esi],word 4D4Dh
-
 
3215
        jne     .exit ;Must be legal .3DS file
3126
        jne     .exit ;Must be legal .3DS file
3216
;        cmp     dword[esi+2],EndFile-SourceFile
3127
;        cmp     dword[esi+2],EndFile-SourceFile
3217
;        jne     .exit ;This must tell the length
3128
;        jne     .exit ;This must tell the length
3218
        mov     eax,dword[esi+2]
3129
        mov     eax,dword[esi+2]
3219
  ;      cmp     eax,[fsize]
3130
  ;      cmp     eax,[fsize]
Line 3296... Line 3207...
3296
        add     esi,8
3207
        add     esi,8
3297
        ;mov     edi,triangles
3208
        ;mov     edi,triangles
3298
      @@:
3209
      @@:
3299
        movzx   eax,word[esi]
3210
        movzx   eax,word[esi]
3300
        add     eax,ebp
3211
        stosd
3301
        stosd
-
 
3302
        movzx   eax,word[esi+2]
3212
        movzx   eax,word[esi+2]
3303
        add     eax,ebp
3213
        stosd
3304
        stosd
-
 
3305
        movzx   eax,word[esi+4]
3214
        movzx   eax,word[esi+4]
3306
        add     eax,ebp
3215
        stosd
3307
        stosd
-
 
3308
 ;       add     dword[edi-12],ebp
3216
        add     dword[edi-12],ebp
3309
 ;       add     dword[edi-8],ebp
3217
        add     dword[edi-8],ebp
3310
 ;       add     dword[edi-4],ebp
3218
        add     dword[edi-4],ebp
3311
        add     esi,8
3219
        add     esi,8
3312
        dec     ecx
3220
        dec     ecx
3313
        jnz     @b
3221
        jnz     @b
3314
        add     ebp,edx
3222
        add     ebp,edx
3315
        jmp     .find4k
3223
        jmp     .find4k
3316
        mov     eax,-1 ;<---mark if OK
3224
        mov     eax,-1 ;<---mark if OK
Line 3335... Line 3243...
3335
        mov     edx,[triangles_ptr]
3243
        mov     edx,[triangles_ptr]
3336
        int     0x40                   ;  -> allocate memory to triangles
3244
        int     0x40                   ;  -> allocate memory to triangles
3337
        mov     [triangles_ptr], eax   ;  -> eax = pointer to allocated mem
3245
        mov     [triangles_ptr], eax   ;  -> eax = pointer to allocated mem
3338
 
3246
 
Line -... Line 3247...
-
 
3247
        mov     eax, 68
-
 
3248
        mov     ecx,[triangles_count_var]
-
 
3249
        imul    ecx,[i36]
-
 
3250
        mov     edx,[edges_ptr]
-
 
3251
        int     0x40                   ;  -> allocate memory to triangles
-
 
3252
        mov     [edges_ptr], eax   ;  -> eax = pointer to allocated mem
-
 
3253
 
-
 
3254
 
3339
                                            ; ststic  memory
3255
                                            ; ststic  memory
Line 3340... Line 3256...
3340
 
3256
 
3341
        mov     eax, 68
3257
        mov     eax, 68
3342
        mov     ecx, [triangles_count_var]
3258
        mov     ecx, [triangles_count_var]
Line 3408... Line 3324...
3408
       xor     eax,eax
3324
       xor     eax,eax
3409
    @@:
3325
    @@:
3410
  ;  eax = 0   -> ok file loaded
3326
  ;  eax = 0   -> ok file loaded
3411
ret
3327
ret
3412
 
3328
read_param:
3413
read_param:
-
 
3414
    mov        esi,I_Param
3329
    mov        esi,I_Param
3415
    cmp        dword[esi],0
3330
    cmp        dword[esi],0
3416
    je         .end
3331
    je         .end
3417
    cmp        byte[esi],'/'
3332
    cmp        byte[esi],'/'
3418
    je         .copy
3333
    je         .copy
Line 3480... Line 3395...
3480
        add     edi,17
3395
        add     edi,17
3481
        cmp     byte[edi],-1
3396
        cmp     byte[edi],-1
3482
        jnz     .again
3397
        jnz     .again
3483
ret
3398
ret
3484
;   *********************************************
3399
write_info:
-
 
3400
        mov     eax,13
-
 
3401
        mov     bx,[size_x_var]
-
 
3402
        shl     ebx,16
-
 
3403
        add     ebx,120*65536+70   ; [x start] *65536 + [y start]
-
 
3404
        mov     ecx,30 shl 16 + 100
-
 
3405
        xor     edx,edx
-
 
3406
        int     0x40
-
 
3407
 
-
 
3408
 
-
 
3409
        xor     esi,esi
-
 
3410
        emms
-
 
3411
        movd    mm7,esi
-
 
3412
     .nxxx:
-
 
3413
        push    esi
-
 
3414
        movd    mm7,esi
-
 
3415
 
-
 
3416
        mov     eax,4           ; function 4 : write text to window
-
 
3417
        movzx   ebx,word[size_x_var]
-
 
3418
        shl     ebx,16
-
 
3419
        add     ebx,120*65536   ; [x start] *65536 + [y start]
-
 
3420
        mov     bx,si
-
 
3421
        shl     bx,3
-
 
3422
        add     ebx,30
-
 
3423
        mov     ecx,0x00ddeeff  ; font 1 & color ( 0xF0RRGGBB )
-
 
3424
        movd    edx,mm7
-
 
3425
        shl     edx,2
-
 
3426
        add     edx,lab_vert      ; pointer to text beginning
-
 
3427
        mov     esi,lab_vert_end-lab_vert     ; text length
-
 
3428
        int     0x40
-
 
3429
 
-
 
3430
        movd    esi,mm7
-
 
3431
        mov     eax,[points_count_var+esi]
-
 
3432
        mov     ecx,10
-
 
3433
   .dc:
-
 
3434
        xor     edx,edx
-
 
3435
        mov     edi,10
-
 
3436
        div     edi
-
 
3437
        add     dl,30h
-
 
3438
        mov     [STRdata+ecx-1],dl
-
 
3439
        loop    .dc
-
 
3440
 
-
 
3441
        mov  eax,4                     ; function 4 : write text to window
-
 
3442
        mov  bx,[size_x_var]
-
 
3443
        add  ebx,120
-
 
3444
        shl  ebx,16
-
 
3445
        mov  bx,si                     ; [x start] *65536 + [y start]
-
 
3446
        shl  bx,3
-
 
3447
        add  bx,45
-
 
3448
        mov  ecx,0x00ddeeff
-
 
3449
        mov  edx,STRdata               ; pointer to text beginning
-
 
3450
        mov  esi,10                    ; text length
-
 
3451
        int  40h
-
 
3452
        pop  esi
-
 
3453
        add  esi,4
-
 
3454
        cmp  esi,12
-
 
3455
        jnz  .nxxx
-
 
3456
ret
-
 
3457
;   *********************************************
3485
;   *******  WINDOW DEFINITIONS AND DRAW ********
3458
;   *******  WINDOW DEFINITIONS AND DRAW ********
3486
;   *********************************************
3459
;   *********************************************
3487
    draw_window:
3460
    draw_window:
3488
        mov     eax,12          ; function 12:tell os about windowdraw
3461
        mov     eax,12          ; function 12:tell os about windowdraw
3489
        mov     ebx,1           ; 1, start of draw
3462
        mov     ebx,1           ; 1, start of draw
Line 3497... Line 3470...
3497
        shl     ecx,16
3470
        shl     ecx,16
3498
;ebx -  [x start] *65536 + [x size]
3471
;ebx -  [x start] *65536 + [x size]
3499
;ecx -  [y start] *65536 + [y size]
3472
;ecx -  [y start] *65536 + [y size]
3500
        mov     bx,[size_x_var]
3473
        mov     bx,[size_x_var]
3501
        add     bx,115
3474
        add     bx,225
3502
        mov     cx,[size_y_var]
3475
        mov     cx,[size_y_var]
3503
        add     cx,30
3476
        add     cx,30
3504
    ; @@:
3477
    ; @@:
3505
        mov     edx,0x13000000  ; color of work area RRGGBB,8->color gl
3478
        mov     edx,0x13000000  ; color of work area RRGGBB,8->color gl
3506
        mov     edi,labelt      ; WINDOW LABEL
3479
        mov     edi,labelt      ; WINDOW LABEL
3507
        int     0x40
3480
        int     0x40
Line 3509... Line 3482...
3509
        call    buttons         ; more buttons
3482
        call    buttons         ; more buttons
Line 3510... Line 3483...
3510
 
3483
 
Line -... Line 3484...
-
 
3484
        .Y_ADD equ 2   ;-> offset of 'add vector' buttons
-
 
3485
 
-
 
3486
     ;   mov     eax,47
-
 
3487
     ;   mov     ebx,0000000000111000000000000000b
-
 
3488
     ;   mov     ecx,[points_count_var]
-
 
3489
     ;   movzx   edx,word[size_x_var]
-
 
3490
     ;   shl     edx,16
-
 
3491
     ;   add     edx,130*65536+60  ; [x start] *65536 + [y start]
-
 
3492
     ;   mov     esi,0x00ddeeff  ; font 1 & color ( 0xF0RRGGBB )
-
 
3493
     ;   int     0x40
3511
        .Y_ADD equ 2   ;-> offset of 'add vector' buttons
3494
       call  write_info
3512
 
3495
 
3513
        ; ADD VECTOR LABEL      ; add vector buttons - 30 ++
3496
        ; ADD VECTOR LABEL      ; add vector buttons - 30 ++
3514
        mov     eax,4           ; function 4 : write text to window
3497
        mov     eax,4           ; function 4 : write text to window
3515
        movzx   ebx,word[size_x_var]
3498
        movzx   ebx,word[size_x_var]