Subversion Repositories Kolibri OS

Rev

Rev 8666 | Rev 9237 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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