Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
9237 leency 1
 
2
 
3
init_point_lights:
4
  ;      mov       eax,1000
5
  ;      cvtsi2ss  xmm1,eax
6
  ;      shufps    xmm1,xmm1,11000000b
7
  ;      mov       esi,lights_aligned
8
  ;      mov       edi,point_light_coords
9
  ;      mov       ecx,3
10
  ;    @@:
11
  ;      movaps    xmm0,[esi]
12
  ;      addps     xmm0,[f05xz]
13
  ;      mulps     xmm0,xmm1
14
  ;      movaps    [edi],xmm0
15
  ;      add       esi,64
16
   ;     add       edi,16
17
   ;     loop      @b
18
      mov       ecx,3
19
      mov       edi,point_light_coords
20
    @@:
21
      push      ecx
22
      xor       ecx,ecx
23
      movzx     edx,word[size_x_var]
24
      call      random
25
      cvtsi2ss  xmm0,eax
26
      movss     [edi],xmm0
27
      xor       ecx,ecx
28
      movzx     edx,word[size_x_var]
29
      call      random
30
      cvtsi2ss  xmm0,eax
31
      movss     [edi+4],xmm0
32
   ;   movzx     ebx,word[size_x_var]
33
   ;   shl       ebx,2
34
   ;   neg       ebx
35
      mov       ecx,-1900
36
   ;   sub       ecx,100
37
      mov       edx,-600
38
      call      random
39
      cvtsi2ss  xmm0,eax
40
      movss     [edi+8],xmm0
41
   ;   mov       dword[edi+8],-1700.0
42
      mov       [edi+12],dword 0
43
      add       edi,16
44
      pop       ecx
45
      loop      @b
46
47
ret
48
 
49
;------------------------------------------------------------------
50
 
51
; in:
52
;     xmm0 - ray direction  ; should be normalized
53
;     xmm1 - ray orgin
54
;     xmm2 - tri vert1
55
;     xmm3 - tri vert2
56
;     xmm4 - tri vert3
57
;     if  eax = 1 - intersction with edge
58
;        xmm6 - edge lenght
59
;     if  eax = 0 - intersect with ray (classic)
60
; out:
61
;     eax  = 1 - intersection occured
62
;     xmm0 - float lo -> hi = t, v, u, ...
63
      push    ebp
64
      mov     ebp,esp
65
      and     ebp,-16
66
      sub     esp,220
67
68
       .dir    equ [ebp-16]
69
 
70
       .ta     equ [ebp-48]
71
       .tb     equ [ebp-64]
72
       .tc     equ [ebp-80]
73
       .tvec   equ [ebp-96]
74
       .pvec   equ [ebp-112]
75
       .qvec   equ [ebp-128]
76
       .e1     equ [ebp-128-16]
77
       .ift    equ dword[ebp-152]
78
       .invdet equ [ebp-156]
79
       .det    equ [ebp-160]
80
       .ed_l   equ [ebp-164]
81
       .u      equ [ebp-168]
82
       .v      equ [ebp-172]
83
       .t      equ [ebp-176]
84
       .e2     equ [ebp-192]
85
86
      movaps   .dir,xmm0
87
 
88
      movaps   .ta,xmm2
89
      movaps   .tb,xmm3
90
      movaps   .tc,xmm4
91
      mov      .ift,eax
92
      movss    .ed_l,xmm6
93
      subps    xmm3,xmm2
94
      subps    xmm4,xmm2
95
      andps    xmm3,[zero_hgst_dd]
96
      andps    xmm4,[zero_hgst_dd]
97
      movaps   .e1,xmm3
98
      movaps   .e2,xmm4
99
100
      lea      esi,.dir
101
 
102
      lea      ebx,.pvec
103
      call     cross_aligned
104
105
      movaps   xmm0,.e1
106
 
107
 ;     andps    xmm0,[zero_hgst_dd]
108
      haddps   xmm0,xmm0
109
      haddps   xmm0,xmm0
110
      movss    .det,xmm0
111
;      cmpnless xmm0,[eps]
112
;      movd     eax,xmm0
113
;      or       eax,eax
114
;      jz       @f
115
      comiss   xmm0,[eps]
116
      jl       @f
117
118
      rcpss    xmm0,.det
119
 
120
121
      movaps   xmm0,.origin
122
 
123
      andps    xmm0,[zero_hgst_dd]
124
      movaps   .tvec,xmm0
125
126
      mulps    xmm0,.pvec
127
 
128
      haddps   xmm0,xmm0
129
      mulss    xmm0,.invdet
130
      movss    xmm1,xmm0
131
      movss    .u,xmm0
132
      cmpnless xmm1,[epsone]
133
      cmpnless xmm0,[epsminus]
134
      pxor     xmm1,xmm0
135
      movd     eax,xmm1
136
      or       eax,eax
137
      jz       @f
138
139
      lea      esi,.tvec
140
 
141
      lea      ebx,.qvec
142
      call     cross_aligned
143
144
      movaps   xmm0,.dir
145
 
146
      haddps   xmm0,xmm0
147
      haddps   xmm0,xmm0
148
      mulss    xmm0,.invdet
149
      movss    .v,xmm0
150
      movss    xmm1,xmm0
151
      addss    xmm1,.u
152
      cmpnless xmm1,[epsone]
153
      cmpnless xmm0,[epsminus]
154
      pxor     xmm1,xmm0
155
      movd     eax,xmm1
156
      or       eax,eax
157
      jz       @f
158
159
      movaps   xmm1,.e2
160
 
161
      haddps   xmm1,xmm1
162
      haddps   xmm1,xmm1
163
      mulss    xmm1,.invdet
164
      movss    .t,xmm1
165
   ;   cmpnless xmm1,[eps]
166
   ;   movmskps eax,xmm1
167
   ;   test     eax,1
168
   ;   jz       @f
169
      comiss   xmm1,[eps]
170
      jl       @f
171
172
      mov      eax,1
173
 
174
      je       .end       ; ok intersect occured, no edge cause
175
176
      movss    xmm0,.t      ; else check with edge lenght
177
 
178
      cmpnless xmm0,[eps]
179
      cmpnless xmm1,.ed_l
180
      xorps    xmm0,xmm1
181
      movd     ebx,xmm0
182
      or       ebx,ebx
183
      jz       @f
184
185
 ;     mov      eax,1
186
 
187
      jmp      .end
188
   @@:
189
      xor      eax,eax
190
    .end:
191
      movaps   xmm0,.t
192
      add      esp,220
193
      pop      ebp
194
ret
195
end if
196
;===============================================================
197
do_edges_list:
8719 leency 198
    push    ebp
199
    mov     ebp,esp
200
    sub     esp,32
201
202
    .ed_cnt   equ [ebp-4]
203
 
204
    .counter  equ [ebp-12]
205
206
207
 
208
 
209
    mov     ecx,[triangles_count_var]
210
  @@:
211
    movdqu  xmm0,[eax]
212
    movq    [ebx],xmm0
213
    pshufd  xmm0,xmm0,11001001b
214
    movq    [ebx+8],xmm0
215
    pshufd  xmm0,xmm0,11001001b
216
    movq    [ebx+16],xmm0
217
    add     ebx,24
218
    add     eax,12
219
    loop    @b
220
221
222
 
223
 
224
    lea     ecx,[ecx*3]
225
  .mxd:
226
    mov     eax,[ebx]
227
    cmp     eax,[ebx+4]
228
    jl      @f
229
    movq    xmm0,[ebx]
230
    pshufd  xmm0,xmm0,11100001b
231
    movq    [ebx],xmm0
232
  @@:
233
    add     ebx,8
234
    loop    .mxd
235
236
237
 
238
 
239
   mov    ecx,[triangles_count_var]
240
   lea    ecx,[ecx*3]
241
242
   mov    esi,ecx
243
 
244
   add    esi,ebx
245
246
 .ccc:
247
 
248
   cmp    eax,[ebx]
249
   jge    .g
250
   movq   xmm0,[ebx+8]
251
   push   ebx
252
 .c:
253
   cmp    ebx,esi
254
   jge    .done
255
   cmp    ebx,[edges_ptr]
256
   jl     .done
257
   cmp    eax,[ebx]
258
   jge    .done
259
   movq   xmm7,[ebx]
260
   movq   [ebx+8],xmm7
261
   sub    ebx,8
262
   jnz    .c
263
   add    ebx,8
264
 .done:
265
   movq   [ebx+8],xmm0
266
 .p:
267
   pop    ebx
268
 .g:
269
   add    ebx,8
270
   dec    ecx
271
   cmp    ecx,1
272
   jnz    .ccc
273
274
275
 
276
 
277
   mov    ecx,[triangles_count_var]
278
   lea    ecx,[ecx*3]
279
   mov    esi,ecx
280
   shl    esi,3
281
   add    esi,ebx
282
283
 .count:
284
 
285
   push   ebx
286
   xor    ecx,ecx
287
   mov    eax,[ebx]          ; count
288
 .aa:
289
   inc    ecx
290
   add    ebx,8
291
   cmp    ebx,esi
292
   jge    .br         ; break
293
   cmp    eax,[ebx]
294
   je     .aa
295
   mov    .counter,ecx
296
   pop    ebx
297
   mov    edi,ebx
298
   sub    edi,8
299
   mov    edx,[ebx+8]
300
 .ccc2:
301
302
   cmp    ebx,esi
303
 
304
   add    esp,4
305
   jmp    .ff
306
 @@:
307
   mov    eax,[ebx+12]
308
   mov    edx,[ebx+8]
309
   cmp    eax,[ebx+4]
310
   jge    .gg2
311
   movq   xmm0,[ebx+8]
312
   push   ebx
313
 .c2:
314
   cmp    eax,[ebx+4]
315
   jge    .done2
316
   movq   xmm7,[ebx]
317
   movq   [ebx+8],xmm7
318
319
   sub    ebx,8
320
 
321
   jz     @f
322
   cmp    [ebx+8],edx
323
   jz     .c2
324
 @@:
325
 .done2:
326
   add    ebx,8
327
   movq   [ebx],xmm0
328
329
 .p2:
330
 
331
 .gg2:
332
   add    ebx,8
333
   dec    ecx
334
   cmp    ecx,1
335
   jnz    .ccc2
336
337
   pop    ecx
338
 
339
   add    ebx,8
340
   ja     .count
341
342
   jmp    .ff
343
 
344
   add   esp,8
345
 .ff:
346
347
   ; count edges
348
 
349
   mov    edx,[triangles_count_var]
350
   lea    edx,[edx*3]
351
   mov    ebx,[edges_ptr]
352
;   mov    esi,edx
353
;   shl    esi,3
354
;   add    esi,[edges_ptr]
355
 .nx:
356
   movq    xmm0,[ebx]
357
   add     ebx,8
358
;   cmp     ebx,esi
359
;   jae     @f
360
   movq    xmm1,[ebx]
361
; @@:
362
   pcmpeqd xmm0,xmm1
363
   pmovmskb eax,xmm0
364
   and     eax,0xff
365
   cmp     eax,0xff
366
   jz      @f
367
   inc     ecx
368
  @@:
369
   dec     edx
370
   jnz     .nx
371
372
373
 
374
 
375
    shl     ecx,2
376
    add     ecx,65536
377
    mov     ebx,12
378
    mov     eax,68
379
    mov     edx,.edd_ptr
380
    int     0x40                   ;  -> allocate memory to triangles
381
    mov     .edd_ptr, eax   ;  -> eax = pointer to allocated mem
382
383
384
 
385
 
386
 
387
   lea      ecx,[ecx*3]
388
  .seek:
389
   movq     xmm0,[ebx]
390
   movq     xmm1,[ebx+8]
391
   pcmpeqd  xmm1,xmm0
392
   pmovmskb edx,xmm1
393
   and      edx,0xff
394
   cmp      edx,0xff
395
   je       @f
396
   movq     [eax],xmm0
397
   add      eax,8
398
 @@:
399
   add      ebx,8
400
   loop     .seek
401
402
   mov       eax,68
403
 
404
   mov       ecx,[edges_ptr]
405
   int       0x40          ; release old edges ptr
406
407
408
 
409
 
410
   mov      [edges_ptr],eax
411
   mov      [edges_count],ecx
412
413
   mov      esp,ebp
414
 
415
ret
416
417
;=======================
418
 
419
420
 
421
 
422
   .x      equ  [ebp-8]
9237 leency 423
   .y      equ  [ebp-12]
8719 leency 424
   .new_y  equ  [ebp-16]
425
   .temp   equ  [ebp-20]
426
   .dr_f   equ  word[ebp-22]
427
9237 leency 428
   push    ebp
429
 
8719 leency 430
   sub     esp,30
431
   mov     .dr_f,ax
9237 leency 432
433
   mov     dword .x,0
434
 
8719 leency 435
   mov     esi,[screen_ptr]
436
   mov     edi,[Zbuffer_ptr]
437
   push    edi
438
   ;  clear Zbuffer temporally used as image buffer
439
   movzx   ecx,word[size_x_var]
440
   movzx   eax,word[size_y_var]
441
   imul    ecx,eax  ;SIZE_X*SIZE_Y
442
   xor     eax,eax
443
   cld
444
   rep     stosd
445
   pop     edi
446
   fninit
447
 .again:
448
   fild    dword .x
449
   fmul    [sin_frq]
450
   fistp   dword .temp
451
   mov     eax, .temp
452
453
   and     eax, 0x000000ff
454
 
455
   fld     dword [sin_tab+eax*4]
456
 
457
   fiadd   dword .y
458
   fistp   dword .new_y
459
460
   mov     eax,.new_y
9237 leency 461
 
8719 leency 462
   jl      .skip
463
   movzx   ebx,word[size_y_var]
464
   cmp     eax,ebx  ;SIZE_Y
465
   jg      .skip
466
   movzx   edx,word[size_x_var]
467
   mul     edx
468
   add     eax,dword .x
469
470
   lea     ebx,[eax*3]
471
 
472
   jb      @f
9237 leency 473
   add     ebx,eax
474
  @@:
8719 leency 475
   mov     eax,[esi]
476
   mov     [edi+ebx],eax
477
 .skip:
478
   add     esi,3
479
   cmp     .dr_f,12
480
   jb      @f
9237 leency 481
   inc     esi
482
  @@:
8719 leency 483
   inc     dword .x
484
   movzx   edx,word[size_x_var]
485
   cmp     dword .x,edx  ;SIZE_X
486
   jl      .again
487
   mov     dword .x,0
488
   inc     dword .y
489
   movzx   edx,word[size_y_var]
490
   cmp     dword .y,edx   ;SIZE_Y
491
   jl      .again
492
493
   ; copy from temporary buffer -> Zbuffer to screen
494
 
495
   mov     edi,[screen_ptr]
496
   movzx   ecx,word[size_x_var]
497
   movzx   eax,word[size_y_var]
498
   imul    ecx,eax
499
   cmp     .dr_f,12
500
   jae     @f
9237 leency 501
   lea     ecx,[ecx*3]
502
   shr     ecx,2
8719 leency 503
 ;  mov     ecx,SIZE_X*SIZE_Y*3/4
504
  @@:
505
   cld
506
   rep     movsd
507
508
509
 
510
 
511
ret
512
513
514
 
515
 
516
   mov     ecx,[points_count_var]
517
 .drw:
518
 @@:
519
   lodsd
520
   add     esi,2           ; skip z
521
   movzx   ebx,ax
522
   shr     eax,16          ; bx = x , ax = y
523
   or      ax,ax
524
   jl      @f
525
   or      bx,bx
526
   jl      @f
527
   cmp     ax,[size_y_var]  ;SIZE_Y
528
   jge     @f
529
   cmp     bx,[size_x_var]  ;SIZE_X
530
   jge     @f
531
   movzx   edx,word[size_x_var]  ;SIZE_X      ; SIZE_X not only power of 2   -> 256,512,...
532
   mul     edx
533
   add     eax,ebx
534
   mov     edi,[screen_ptr]
535
   lea     eax,[eax*3]
536
   add     edi,eax
537
   xor     eax,eax
538
   not     eax
539
   stosd
540
 @@:
541
   loop    .drw
542
543
ret
544
 
545
do_emboss:   ; sse2 version only
546
 
547
   push  ebp
9237 leency 548
   mov   ebp,esp
549
   sub   esp,4
550
551
   .dr_mod  equ word[ebp-2]
552
 
553
   mov    .dr_mod,ax
554
 
555
if Ext >= SSE2
556
 
8719 leency 557
9237 leency 558
 
559
 
560
 
8719 leency 561
 call  blur_screen    ;blur n times
562
563
 mov   eax,[size_y_var]  ;load both x, y
564
 
565
 shr   ebx,16
566
 cwde
567
 mul   ebx
568
 mov   ecx,eax
569
 sub   ecx,ebx
570
 sub   ecx,ebx
571
 mov   esi,[screen_ptr]
572
 mov   edi,[Zbuffer_ptr]
573
 cmp   .dr_mod,11
574
 jge   @f
9237 leency 575
 lea   ebx,[ebx*3]
8719 leency 576
 jmp   .gf
577
@@:
9237 leency 578
 shl   ebx,2
8719 leency 579
.gf:
580
 mov   edx,esi
9237 leency 581
 add   esi,ebx
8719 leency 582
 lea   ebx,[ebx+esi]
583
 pxor  xmm0,xmm0
584
 push  eax
585
.emb:
586
 cmp    .dr_mod ,11
587
 jge   @f
9237 leency 588
 movlps     xmm1,[esi+3]
8719 leency 589
 movhps     xmm1,[esi+6]
590
 movlps     xmm2,[esi-3]
591
 movhps     xmm2,[esi]
592
 movlps     xmm3,[ebx]
593
 movhps     xmm3,[ebx+3]
594
 movlps     xmm4,[edx]
595
 movhps     xmm4,[edx+3]
596
 jmp        .ff
597
@@:
598
 movlps     xmm1,[esi+4]
599
 movhps     xmm1,[esi+8]
600
 movlps     xmm2,[esi-4]
601
 movhps     xmm2,[esi]
602
 movlps     xmm3,[ebx]
603
 movhps     xmm3,[ebx+4]
604
 movlps     xmm4,[edx]
605
 movhps     xmm4,[edx+4]
606
.ff:
607
 punpcklbw  xmm1,xmm0
608
 punpcklbw  xmm2,xmm0
609
 punpcklbw  xmm3,xmm0
610
 punpcklbw  xmm4,xmm0
611
 psubsw     xmm1,xmm2
612
 paddw      xmm1,[emboss_bias]
613
 psubsw     xmm3,xmm4
614
 paddw      xmm3,[emboss_bias]
615
 pmulhw     xmm1,xmm3
616
 movaps      xmm7,xmm1
617
 movaps      xmm6,xmm1
618
 psrlq       xmm7,2*8
619
 psrlq       xmm6,4*8
620
 pmaxsw      xmm1,xmm7
621
 pmaxsw      xmm1,xmm6
622
623
624
 
9237 leency 625
 
8719 leency 626
 movd        eax,xmm1
627
 
628
; cmp         [dr_flag],12
629
; je          @f
630
 lea         eax,[eax*3+envmap_cub]
631
; jmp         .fff
632
;@@:
633
634
 mov         eax,[eax]
635
 
636
 psrldq     xmm1,8
637
 movd       eax,xmm1
638
 movzx      eax,al
639
 lea        eax,[eax*3+envmap_cub]
640
 mov        eax,[eax]
641
 mov        [edi+4],eax
642
643
 cmp    .dr_mod,11
644
 
9237 leency 645
 add    esi,2
8719 leency 646
 add    ebx,2
647
 add    edx,2
648
@@:
649
650
 add    edi,8
651
 
652
 add    ebx,6
653
 add    edx,6
654
 sub    ecx,2
655
 jnc    .emb
656
657
658
 
659
 
660
 mov    esi,[Zbuffer_ptr]
661
 cmp    .dr_mod,11
662
 jge    .e
9237 leency 663
@@:
8719 leency 664
 movsd
665
 dec    edi
666
 loop   @b
667
.e:
668
 rep    movsd
669
670
end if
671
 
672
673
 
9237 leency 674
 
675
 
676
677
ret
678
 
8719 leency 679
;align 16
680
 
681
;    dw 128, 128, 128, 128, 128, 128, 128, 128
682
683
if 0  ; old emb proc
684
 
685
 ;  emboss -  after drawing all,
686
 
687
 ;  and draw two bump triangles
688
 ; *************************************
689
        mov     esi,screen
690
        mov     edi,bumpmap2
691
        mov     ecx,TEXTURE_SIZE/3
692
        cld
693
if  Ext=NON
694
        xor     eax,eax
695
        xor     bh,bh
696
        xor     dh,dh
697
      @@:
698
        lodsb
699
        movzx   bx,al
700
        lodsb
701
        movzx   dx,al
702
        lodsb
703
        add     ax,bx
704
        add     ax,dx
705
      ;  cwd
706
      ;  div     [i3]
707
 ;;       push    ax
708
 ;;       pop     bx
709
 ;;       shr     bx,3
710
 ;;       shr     ax,2
711
 ;;       add     ax,bx
712
713
        lea      eax,[eax*5]
714
 
715
716
        stosb
717
 
718
else
719
        emms
720
        pxor          mm1,mm1
721
        mov           ebx,0x0000ffff
722
      @@:
723
        movd          mm0,[esi]
724
        punpcklbw     mm0,mm1
725
        movq          mm2,mm0
726
        psrlq         mm2,16
727
        movq          mm3,mm0
728
        psrlq         mm3,32
729
        paddw         mm0,mm2
730
        paddw         mm0,mm3
731
732
733
 
734
 
735
        lea           eax,[eax*5]
736
        shr           ax,4
737
        stosb
738
        add           esi,3
739
        loop          @b
740
741
end if
742
 
743
744
        push    dword 0          ; env coords
745
 
746
        push    word SIZE_X
747
        push    word SIZE_Y
748
        push    dword 0
749
        push    dword 0          ; bump coords
750
        push    word SIZE_X
751
        push    word SIZE_Y
752
        push    word 0
753
        mov     eax,SIZE_Y
754
        mov     ebx,SIZE_X*65536+0
755
        xor     ecx,ecx
756
        mov     edx,bumpmap2
757
        mov     esi,envmap
758
        mov     edi,screen
759
        call    bump_triangle
760
761
        push    dword SIZE_X shl 16 + SIZE_Y       ; env coords
762
 
763
        push    word SIZE_X
764
        push    word SIZE_Y
765
        push    word 0
766
        push    dword SIZE_X shl 16 + SIZE_Y        ; bump coords
767
        push    word 0
768
        push    word SIZE_X
769
        push    word SIZE_Y
770
        push    word 0
771
        mov     eax,SIZE_Y
772
        mov     ebx,SIZE_X * 65536+0
773
        mov     ecx,SIZE_X shl 16 + SIZE_Y
774
        mov     edx,bumpmap2
775
        mov     esi,envmap
776
        mov     edi,screen
777
        call    bump_triangle
778
779
        pop     ebp
780
 
781
end if
782
;********************************EMBOSS DONE*******************************
783
784
785
 
786
 
787
;locals
788
;   counter dw ?
789
;   sin     dd ?
790
;   cos     dd ?
791
;endl
792
.counter equ  word[ebp-2]
793
.sin     equ  dword[ebp-6]
794
.cos     equ  dword[ebp-10]
795
.sin2    equ  dword[ebp-14]
796
.cos2    equ  dword[ebp-18]
797
.piD180m3 equ dword[ebp-22]
798
.cD2      equ word[ebp-24]
799
        push  ebp
800
        mov   ebp,esp
801
        sub   esp,24
802
803
        push  ax
804
 
805
        fninit
806
 
807
        xor     eax,eax
808
                                    ; init seed -> 4   3d points
809
        mov     dword[edi],-1.0     ; x
810
        add     edi,4
811
        stosd                       ; y
812
        stosd                       ; z
813
        mov     dword[edi],-0.9     ; x1
814
        mov     dword[edi+4],0.1    ; y1
815
        add     edi,8
816
        stosd                       ; z1
817
        mov     dword[edi],-0.8
818
        add     edi,4
819
        stosd
820
        stosd
821
        mov     dword[edi],-0.9     ; x3
822
        mov     dword[edi+4],-0.1   ; y3
823
        add     edi,8
824
        stosd                       ; z3
825
        mov     [points_count_var],4
826
827
        fld     [piD180]
828
 
829
        fstp    .piD180m3
830
        mov     .cD2,5
831
832
        pop     ax
833
 
834
        mov     edx,9
835
      .next:                      ; calc angle and rotate seed 4 points
836
        mov     .counter,cx
837
        mov     ebx,[points_ptr]
838
        fld     .piD180m3
839
        fimul   .counter
840
        fld     st
841
        fsincos
842
        fstp    .sin
843
        fstp    .cos
844
        fadd    st,st0
845
        fsincos
846
        fstp    .sin2
847
        fstp    .cos2
848
849
      .rotor:                          ; next 4
850
 
851
        fld     dword[ebx]         ; x
852
        fld     .sin
853
        fmul    dword[ebx+8]       ; z * sinbeta
854
        fchs
855
        fld     .cos
856
        fmul    dword[ebx]         ; x * cosbeta
857
        faddp
858
        fstp    dword[edi]         ; new x
859
        fmul    .sin             ; old x * sinbeta
860
        fld     .cos
861
        fmul    dword[ebx+8]       ; z * cosbeta
862
        faddp
863
        dec     dx
864
        or      dx,dx
865
        jnz     @f
866
;        mov     .counter,dx
867
        fld     st
868
        fidiv   [i3]
869
        faddp
870
    @@:
871
        fstp    dword[edi+8]       ; new z
872
        fld     dword[ebx+4]
873
        or      dx,dx
874
        jnz     @f
875
  ;      fld1
876
  ;      faddp
877
;        fld     st
878
        fadd    st,st0
879
        fadd    st,st0
880
;        fxch
881
;        fimul   [i3]
882
;        fsin
883
;        faddp
884
        mov     dx,9
885
    @@:
886
        fstp    dword[edi+4]
887
        ; rotary x
888
        cmp     al,3
889
        jl      .end_rot
890
        fld     dword[edi+4]    ;y
891
        fld     .sin2
892
        fmul    dword[edi+8]    ;z
893
        fld     .cos2
894
        fmul    dword[edi+4]    ;y
895
        faddp
896
        fstp    dword[edi+4]    ; new y
897
        fmul    .sin2       ; sinbeta * old y
898
        fchs
899
        fld     .cos2
900
        fmul    dword[edi+8]
901
        faddp
902
        fstp    dword[edi+8]
903
        ; rotary z
904
        cmp     al,4
905
        jl      .end_rot
906
        fld     dword[edi]      ;x
907
        fld     .sin
908
        fmul    dword[edi+4]    ;y
909
        fld     .cos
910
        fmul    dword[edi]      ;x
911
        faddp
912
        fstp    dword[edi]      ;new x
913
        fmul    .sin       ; sinbeta * old x
914
        fchs
915
        fld     .cos
916
        fmul    dword[edi+4]         ; cosbeta * y
917
        faddp
918
        fstp    dword[edi+4]    ; new y
919
920
921
 
922
 
923
 
924
        add     edi,12
925
 
926
        mov     esi,[points_ptr]
927
        add     esi,12*4
928
        cmp     ebx,esi
929
        jl      .rotor
930
931
        add     [points_count_var],4
932
 
933
        cmp     cx,(18*21*3)+1
934
        jle     .next
935
936
        mov     edi,[triangles_ptr]
937
 
938
        mov     ebx,4+4
939
        mov     [triangles_count_var],160*3    ;164*3   ;140
940
941
        mov     ecx,80*3  ;68
942
 
943
        stosd                 ;----
944
        mov     [edi],ebx      ;    |
945
        add     edi,4         ;    |
946
        inc     eax            ;    |
947
        stosd                 ;    |repeat 4 times
948
949
        mov     [edi],ebx      ;    |
950
 
951
        add     edi,4
952
        stosd                 ;    |
953
        mov     [edi],ebx      ;    |
954
        add     edi,4         ;----
955
        loop     @b
956
957
958
 
959
 
960
961
        mov     esp,ebp
962
 
963
964
ret
965
 
966
;locals
967
;   counter dw ?
968
;   sin     dd ?
969
;   cos     dd ?
970
;endl
971
.counter equ  word[ebp-2]
972
.sin     equ  dword[ebp-6]
973
.cos     equ  dword[ebp-10]
974
.sin2    equ  dword[ebp-14]
975
.cos2    equ  dword[ebp-18]
976
.piD180m3 equ dword[ebp-22]
977
.cD2      equ word[ebp-24]
978
        push  ebp
979
        mov   ebp,esp
980
        sub   esp,24
981
982
        fninit
983
 
984
        xor     eax,eax
985
                               ; init seed -> eight   3d points
986
        mov     dword[edi],2.0
987
        add     edi,4
988
        stosd
989
        stosd
990
991
        mov     dword[edi],2.0
992
 
993
        add     edi,8
994
        stosd
995
996
        mov     dword[edi],1.5
997
 
998
        add     edi,8
999
        stosd
1000
        mov     dword[edi],1.0
1001
        mov     dword[edi+4],-2.0
1002
        add     edi,8
1003
        stosd
1004
1005
        stosd
1006
 
1007
        add     edi,4
1008
        stosd
1009
1010
        mov     [points_count_var],5
1011
 
1012
        mov     ecx,1
1013
 
1014
        mov     .counter,cx
1015
        mov     ebx,[points_ptr]
1016
        fld     [piD180]
1017
        fimul   .counter
1018
        fsincos
1019
        fstp    .sin
1020
        fstp    .cos
1021
1022
      .rotor:                          ; next 4
1023
 
1024
        fld     dword[ebx]         ; x
1025
        fld     .sin
1026
        fmul    dword[ebx+8]       ; z * sinbeta
1027
        fchs
1028
        fld     .cos
1029
        fmul    dword[ebx]         ; x * cosbeta
1030
        faddp
1031
        fidiv   [i3]
1032
        fstp    dword[edi]         ; new x
1033
        fmul    .sin               ; old x * sinbeta
1034
        fld     .cos
1035
        fmul    dword[ebx+8]       ; z * cosbeta
1036
        faddp
1037
        fstp    dword[edi+8]       ; new z
1038
1039
        fld     dword[ebx+4]   ;y
1040
 
1041
1042
1043
 
1044
 
1045
        add     edi,12
1046
 
1047
        mov     esi,[points_ptr]
1048
        add     esi,12*5
1049
        cmp     ebx,esi  ;real_points + (12*5)
1050
        jl      .rotor
1051
1052
        add     [points_count_var],5
1053
 
1054
        cmp     cx,(18*21)+1
1055
        jle     .next
1056
;last points
1057
1058
        xor     eax,eax
1059
 
1060
        mov     dword[edi],0.22
1061
 
1062
        mov     dword[edi+8],1.25
1063
        add     edi,12
1064
1065
        mov     dword[edi],0.22
1066
 
1067
        mov     dword[edi+8],-1.25
1068
        add     edi,12
1069
        stosd
1070
1071
        add     [points_count_var],2
1072
 
1073
; init triangles list
1074
 
1075
        mov     edi,[triangles_ptr]
1076
 
1077
        mov     ebx,5+5
1078
        mov     [triangles_count_var],200  ;204
1079
1080
        mov     ecx,100
1081
 
1082
        stosd                 ;----
1083
        mov     [edi],ebx      ;    |
1084
        add     edi,4         ;    |
1085
        inc     eax            ;    |
1086
        stosd                 ;    |repeat
1087
1088
        mov     [edi],ebx      ;    |
1089
 
1090
        add     edi,4
1091
        stosd                 ;    |
1092
        mov     [edi],ebx      ;    |
1093
        add     edi,4         ;----
1094
        loop     @b
1095
1096
        mov     eax,5
1097
 
1098
        sub     ebx,2
1099
        mov     dl,2
1100
    .nx:
1101
        mov     ecx,5
1102
        add     [triangles_count_var],ecx
1103
    @@:
1104
        stosd
1105
        add     eax,5
1106
        stosd
1107
        mov     dword[edi],ebx
1108
        add     edi,4
1109
        loop    @b
1110
1111
        cmp     dl,1
1112
 
1113
1114
        inc     ebx
1115
 
1116
     @@:
1117
        dec     ebx
1118
     .lab:
1119
        mov     ecx,5
1120
        add     [triangles_count_var],ecx
1121
     @@:
1122
        stosd
1123
        add     eax,5
1124
        stosd
1125
        mov     dword[edi],ebx
1126
        add     edi,4
1127
        loop    @b
1128
1129
        dec     dl
1130
 
1131
        jnz     .nx
1132
1133
        sub     eax,25
1134
 
1135
        sub     eax,50
1136
        stosd
1137
        mov     dword[edi],ebx
1138
        add     edi,4
1139
1140
        stosd
1141
 
1142
        stosd
1143
        inc     ebx
1144
        mov     dword[edi],ebx
1145
        add     edi,4
1146
        add     [triangles_count_var],2
1147
1148
        mov     dword[edi],-1  ; < - end mark
1149
 
1150
1151
        mov     esp,ebp
1152
 
1153
1154
ret
1155