Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
2984 leency 1
do_sinus:
8014 leency 2
   .x      equ  [ebp-8]
3
   .y      equ  [ebp-12]
4
   .new_y  equ  [ebp-16]
5
   .temp   equ  [ebp-20]
2984 leency 6
   push    ebp
8014 leency 7
   mov     ebp,esp
8
   sub     esp,64
9
   mov     dword .x,0
10
   mov     dword .y,0
11
   mov     esi,[screen_ptr]
12
   mov     edi,[Zbuffer_ptr]
2984 leency 13
   push    edi
14
   ;  clear Zbuffer temporally used as image buffer
6619 leency 15
   movzx   ecx,word[size_x_var]
16
   movzx   eax,word[size_y_var]
17
   imul    ecx,eax  ;SIZE_X*SIZE_Y
8014 leency 18
   xor     eax,eax
2984 leency 19
   cld
8014 leency 20
   rep     stosd
21
   pop     edi
2984 leency 22
   fninit
23
 .again:
24
   fild    dword .x
25
   fmul    [sin_frq]
26
   fistp   dword .temp
8014 leency 27
   mov     eax, .temp
2984 leency 28
 
8014 leency 29
   and     eax, 0x000000ff
2984 leency 30
 
31
 
8014 leency 32
   fld     dword [sin_tab+eax*4]
2984 leency 33
   fimul   dword [sin_amplitude]
34
   fiadd   dword .y
35
   fistp   dword .new_y
8666 dunkaist 36
 
8014 leency 37
   mov     eax,.new_y
38
   or      eax,eax
39
   jl      .skip
6619 leency 40
   movzx   ebx,word[size_y_var]
8014 leency 41
   cmp     eax,ebx  ;SIZE_Y
42
   jg      .skip
6619 leency 43
   movzx   edx,word[size_x_var]
8014 leency 44
   mul     edx
6619 leency 45
;   shl     eax,9
8014 leency 46
   add     eax,dword .x
8047 leency 47
 
8014 leency 48
   lea     ebx,[eax*3]
8047 leency 49
   cmp     [dr_flag],12 ; 32 bit col cause
8232 leency 50
   jl      @f
8047 leency 51
   add     ebx,eax
52
  @@:
8014 leency 53
   mov     eax,[esi]
54
   mov     [edi+ebx],eax
2984 leency 55
 .skip:
8014 leency 56
   add     esi,3
8047 leency 57
   cmp     [dr_flag],12
8232 leency 58
   jl      @f
8047 leency 59
   inc     esi
60
  @@:
8014 leency 61
   inc     dword .x
6619 leency 62
   movzx   edx,word[size_x_var]
8014 leency 63
   cmp     dword .x,edx  ;SIZE_X
64
   jl      .again
65
   mov     dword .x,0
66
   inc     dword .y
6619 leency 67
   movzx   edx,word[size_y_var]
8014 leency 68
   cmp     dword .y,edx   ;SIZE_Y
69
   jl      .again
2984 leency 70
 
71
   ; copy from temporary buffer -> Zbuffer to screen
8014 leency 72
   mov     esi,[Zbuffer_ptr]
73
   mov     edi,[screen_ptr]
6619 leency 74
   movzx   ecx,word[size_x_var]
75
   movzx   eax,word[size_y_var]
76
   imul    ecx,eax
8232 leency 77
   cmp     [dr_flag],12
78
   jge     @f
8014 leency 79
   lea     ecx,[ecx*3]
80
   shr     ecx,2
6619 leency 81
 ;  mov     ecx,SIZE_X*SIZE_Y*3/4
8047 leency 82
  @@:
2984 leency 83
   cld
8014 leency 84
   rep     movsd
2984 leency 85
 
86
 
8014 leency 87
   mov     esp,ebp
88
   pop     ebp
2984 leency 89
ret
90
 
91
 
1245 hidnplayr 92
draw_dots:
8014 leency 93
   mov     esi,[points_translated_ptr]
94
   mov     ecx,[points_count_var]
1245 hidnplayr 95
 .drw:
96
 @@:
97
   lodsd
8014 leency 98
   add     esi,2           ; skip z
1245 hidnplayr 99
   movzx   ebx,ax
8014 leency 100
   shr     eax,16          ; bx = x , ax = y
101
   or      ax,ax
102
   jl      @f
103
   or      bx,bx
104
   jl      @f
105
   cmp     ax,[size_y_var]  ;SIZE_Y
106
   jge     @f
107
   cmp     bx,[size_x_var]  ;SIZE_X
108
   jge     @f
6619 leency 109
   movzx   edx,word[size_x_var]  ;SIZE_X      ; SIZE_X not only power of 2   -> 256,512,...
8014 leency 110
   mul     edx
111
   add     eax,ebx
112
   mov     edi,[screen_ptr]
113
   lea     eax,[eax*3]
114
   add     edi,eax
115
   xor     eax,eax
116
   not     eax
1245 hidnplayr 117
   stosd
118
 @@:
119
   loop    .drw
120
 
121
ret
122
 
6619 leency 123
do_emboss:   ; sse2 version only
124
if Ext >= SSE2
125
 movzx ecx,[bumps_deep_flag]
126
 inc   ecx
127
 call  blur_screen    ;blur n times
128
 
129
 mov   eax,[size_y_var]  ;load both x, y
130
 mov   ebx,eax
131
 shr   ebx,16
132
 cwde
133
 mul   ebx
134
 mov   ecx,eax
135
 sub   ecx,ebx
136
 sub   ecx,ebx
137
 mov   esi,[screen_ptr]
138
 mov   edi,[Zbuffer_ptr]
8047 leency 139
 cmp   [dr_flag],12
8232 leency 140
 jge   @f
6619 leency 141
 lea   ebx,[ebx*3]
8047 leency 142
 jmp   .f
143
@@:
144
 shl   ebx,2
145
.f:
6619 leency 146
 mov   edx,esi
147
 add   esi,ebx
148
 lea   ebx,[ebx+esi]
149
 pxor  xmm0,xmm0
150
 push  eax
8047 leency 151
.emb:
152
 cmp   [dr_flag],12
8232 leency 153
 jge   @f
6619 leency 154
 movlps     xmm1,[esi+3]
155
 movhps     xmm1,[esi+6]
156
 movlps     xmm2,[esi-3]
157
 movhps     xmm2,[esi]
158
 movlps     xmm3,[ebx]
159
 movhps     xmm3,[ebx+3]
160
 movlps     xmm4,[edx]
161
 movhps     xmm4,[edx+3]
8047 leency 162
 jmp        .ff
163
@@:
164
 movlps     xmm1,[esi+4]
165
 movhps     xmm1,[esi+8]
166
 movlps     xmm2,[esi-4]
167
 movhps     xmm2,[esi]
168
 movlps     xmm3,[ebx]
169
 movhps     xmm3,[ebx+4]
170
 movlps     xmm4,[edx]
171
 movhps     xmm4,[edx+4]
172
.ff:
173
 punpcklbw  xmm1,xmm0
174
 punpcklbw  xmm2,xmm0
6619 leency 175
 punpcklbw  xmm3,xmm0
176
 punpcklbw  xmm4,xmm0
177
 psubsw     xmm1,xmm2
8014 leency 178
 paddw      xmm1,[emboss_bias]
6619 leency 179
 psubsw     xmm3,xmm4
8014 leency 180
 paddw      xmm3,[emboss_bias]
6619 leency 181
 pmulhw     xmm1,xmm3
182
 movaps      xmm7,xmm1
183
 movaps      xmm6,xmm1
8014 leency 184
 psrlq       xmm7,2*8
185
 psrlq       xmm6,4*8
6619 leency 186
 pmaxsw      xmm1,xmm7
187
 pmaxsw      xmm1,xmm6
188
 
189
if 0
190
 movaps      xmm7,xmm3
191
 movaps      xmm6,xmm3
8014 leency 192
 psrlq       xmm7,2*8
193
 psrlq       xmm6,4*8
6619 leency 194
 pmaxsw      xmm3,xmm7
195
 pmaxsw      xmm3,xmm6
196
end if
197
 pmaxsw      xmm1,xmm3
198
 
8014 leency 199
 movd        eax,xmm1
200
 movzx       eax,al
8047 leency 201
; cmp         [dr_flag],12
202
; je          @f
8014 leency 203
 lea         eax,[eax*3+envmap_cub]
8047 leency 204
; jmp         .fff
205
;@@:
206
 
8014 leency 207
 mov         eax,[eax]
208
 mov        [edi],eax  ;xmm1
6619 leency 209
 psrldq     xmm1,8
8014 leency 210
 movd       eax,xmm1
211
 movzx      eax,al
212
 lea        eax,[eax*3+envmap_cub]
213
 mov        eax,[eax]
214
 mov        [edi+4],eax
6619 leency 215
 
8047 leency 216
 cmp    [dr_flag],12
8232 leency 217
 jl     @f
8047 leency 218
 add    esi,2
219
 add    ebx,2
220
 add    edx,2
221
@@:
6619 leency 222
 
8014 leency 223
 add    edi,8
224
 add    esi,6
225
 add    ebx,6
226
 add    edx,6
227
 sub    ecx,2
8047 leency 228
 jnc    .emb
6619 leency 229
 
230
 
8014 leency 231
 pop    ecx  ;,eax
232
 mov    edi,[screen_ptr]
233
 mov    esi,[Zbuffer_ptr]
8047 leency 234
 cmp    [dr_flag],12
8232 leency 235
 jge    .e
6619 leency 236
@@:
237
 movsd
8014 leency 238
 dec    edi
239
 loop   @b
8047 leency 240
.e:
241
 rep    movsd
242
 
6619 leency 243
end if
8047 leency 244
 
6619 leency 245
ret
246
 
247
 
1245 hidnplayr 248
;********************************EMBOSS DONE*******************************
249
 
250
 
251
generate_object2:  ; torus
252
;in  ax - figure number       2=torus, 3=loop, 4=loop
253
;locals
254
;   counter dw ?
255
;   sin     dd ?
256
;   cos     dd ?
257
;endl
258
.counter equ  word[ebp-2]
8014 leency 259
.sin     equ  dword[ebp-6]
260
.cos     equ  dword[ebp-10]
261
.sin2    equ  dword[ebp-14]
262
.cos2    equ  dword[ebp-18]
1245 hidnplayr 263
.piD180m3 equ dword[ebp-22]
8014 leency 264
.cD2      equ word[ebp-24]
265
        push  ebp
266
        mov   ebp,esp
267
        sub   esp,24
1245 hidnplayr 268
 
8014 leency 269
        push  ax
1245 hidnplayr 270
 
8014 leency 271
        fninit
272
        mov     edi,[points_ptr]
273
        xor     eax,eax
274
                                    ; init seed -> 4   3d points
275
        mov     dword[edi],-1.0     ; x
276
        add     edi,4
277
        stosd                       ; y
278
        stosd                       ; z
279
        mov     dword[edi],-0.9     ; x1
280
        mov     dword[edi+4],0.1    ; y1
281
        add     edi,8
282
        stosd                       ; z1
283
        mov     dword[edi],-0.8
284
        add     edi,4
285
        stosd
286
        stosd
287
        mov     dword[edi],-0.9     ; x3
288
        mov     dword[edi+4],-0.1   ; y3
289
        add     edi,8
290
        stosd                       ; z3
291
        mov     [points_count_var],4
1245 hidnplayr 292
 
8014 leency 293
        fld     [piD180]
294
        fidiv   [i3]
295
        fstp    .piD180m3
296
        mov     .cD2,5
1245 hidnplayr 297
 
8014 leency 298
        pop     ax
299
        mov     ecx,1
300
        mov     edx,9
301
      .next:                      ; calc angle and rotate seed 4 points
302
        mov     .counter,cx
303
        mov     ebx,[points_ptr]
304
        fld     .piD180m3
305
        fimul   .counter
306
        fld     st
307
        fsincos
308
        fstp    .sin
309
        fstp    .cos
310
        fadd    st,st0
311
        fsincos
312
        fstp    .sin2
313
        fstp    .cos2
1245 hidnplayr 314
 
8014 leency 315
      .rotor:                          ; next 4
316
        ; rotary y
317
        fld     dword[ebx]         ; x
318
        fld     .sin
319
        fmul    dword[ebx+8]       ; z * sinbeta
320
        fchs
321
        fld     .cos
322
        fmul    dword[ebx]         ; x * cosbeta
323
        faddp
324
        fstp    dword[edi]         ; new x
325
        fmul    .sin             ; old x * sinbeta
326
        fld     .cos
327
        fmul    dword[ebx+8]       ; z * cosbeta
328
        faddp
329
        dec     dx
330
        or      dx,dx
331
        jnz     @f
1245 hidnplayr 332
;        mov     .counter,dx
8014 leency 333
        fld     st
334
        fidiv   [i3]
335
        faddp
1245 hidnplayr 336
    @@:
8014 leency 337
        fstp    dword[edi+8]       ; new z
338
        fld     dword[ebx+4]
339
        or      dx,dx
340
        jnz     @f
1245 hidnplayr 341
  ;      fld1
342
  ;      faddp
343
;        fld     st
8014 leency 344
        fadd    st,st0
345
        fadd    st,st0
1245 hidnplayr 346
;        fxch
347
;        fimul   [i3]
348
;        fsin
349
;        faddp
8014 leency 350
        mov     dx,9
1245 hidnplayr 351
    @@:
8014 leency 352
        fstp    dword[edi+4]
353
        ; rotary x
354
        cmp     al,3
355
        jl      .end_rot
356
        fld     dword[edi+4]    ;y
357
        fld     .sin2
358
        fmul    dword[edi+8]    ;z
359
        fld     .cos2
360
        fmul    dword[edi+4]    ;y
361
        faddp
362
        fstp    dword[edi+4]    ; new y
363
        fmul    .sin2       ; sinbeta * old y
364
        fchs
365
        fld     .cos2
366
        fmul    dword[edi+8]
367
        faddp
368
        fstp    dword[edi+8]
369
        ; rotary z
370
        cmp     al,4
371
        jl      .end_rot
372
        fld     dword[edi]      ;x
373
        fld     .sin
374
        fmul    dword[edi+4]    ;y
375
        fld     .cos
376
        fmul    dword[edi]      ;x
377
        faddp
378
        fstp    dword[edi]      ;new x
379
        fmul    .sin       ; sinbeta * old x
380
        fchs
381
        fld     .cos
382
        fmul    dword[edi+4]         ; cosbeta * y
383
        faddp
384
        fstp    dword[edi+4]    ; new y
1245 hidnplayr 385
 
386
 
387
 
388
      .end_rot:
389
 
8014 leency 390
        add     edi,12
391
        add     ebx,12
392
        mov     esi,[points_ptr]
393
        add     esi,12*4
394
        cmp     ebx,esi
395
        jl      .rotor
1245 hidnplayr 396
 
8014 leency 397
        add     [points_count_var],4
398
        add     cx,18
399
        cmp     cx,(18*21*3)+1
400
        jle     .next
1245 hidnplayr 401
 
8014 leency 402
        mov     edi,[triangles_ptr]
403
        mov     eax,4
404
        mov     ebx,4+4
405
        mov     [triangles_count_var],160*3    ;164*3   ;140
1245 hidnplayr 406
 
8014 leency 407
        mov     ecx,80*3  ;68
1245 hidnplayr 408
      @@:
8014 leency 409
        stosd                 ;----
410
        mov     [edi],ebx      ;    |
411
        add     edi,4         ;    |
412
        inc     eax            ;    |
413
        stosd                 ;    |repeat 4 times
1245 hidnplayr 414
 
8014 leency 415
        mov     [edi],ebx      ;    |
416
        inc     ebx
417
        add     edi,4
418
        stosd                 ;    |
419
        mov     [edi],ebx      ;    |
420
        add     edi,4         ;----
421
        loop     @b
1245 hidnplayr 422
 
423
 
8014 leency 424
        mov     dword[edi],-1  ; < - end mark
425
        mov       [culling_flag],0
1245 hidnplayr 426
 
8014 leency 427
        mov     esp,ebp
428
        pop     ebp
1245 hidnplayr 429
 
430
ret
431
generate_object3:  ; heart
432
;locals
433
;   counter dw ?
434
;   sin     dd ?
435
;   cos     dd ?
436
;endl
437
.counter equ  word[ebp-2]
8014 leency 438
.sin     equ  dword[ebp-6]
439
.cos     equ  dword[ebp-10]
440
.sin2    equ  dword[ebp-14]
441
.cos2    equ  dword[ebp-18]
1245 hidnplayr 442
.piD180m3 equ dword[ebp-22]
8014 leency 443
.cD2      equ word[ebp-24]
444
        push  ebp
445
        mov   ebp,esp
446
        sub   esp,24
1245 hidnplayr 447
 
8014 leency 448
        fninit
449
        mov     edi,[points_ptr]
450
        xor     eax,eax
451
                               ; init seed -> eight   3d points
452
        mov     dword[edi],2.0
453
        add     edi,4
454
        stosd
455
        stosd
1245 hidnplayr 456
 
8014 leency 457
        mov     dword[edi],2.0
458
        mov     dword[edi+4],-0.5
459
        add     edi,8
460
        stosd
1245 hidnplayr 461
 
8014 leency 462
        mov     dword[edi],1.5
463
        mov     dword[edi+4],-1.5
464
        add     edi,8
465
        stosd
466
        mov     dword[edi],1.0
467
        mov     dword[edi+4],-2.0
468
        add     edi,8
469
        stosd
1245 hidnplayr 470
 
8014 leency 471
        stosd
472
        mov     dword[edi],-2.5
473
        add     edi,4
474
        stosd
1245 hidnplayr 475
 
8014 leency 476
        mov     [points_count_var],5
1245 hidnplayr 477
 
8014 leency 478
        mov     ecx,1
479
      .next:                      ; calc angle and rotate seed 4 points
480
        mov     .counter,cx
481
        mov     ebx,[points_ptr]
482
        fld     [piD180]
483
        fimul   .counter
484
        fsincos
485
        fstp    .sin
486
        fstp    .cos
1245 hidnplayr 487
 
8014 leency 488
      .rotor:                          ; next 4
489
        ; rotary y
490
        fld     dword[ebx]         ; x
491
        fld     .sin
492
        fmul    dword[ebx+8]       ; z * sinbeta
493
        fchs
494
        fld     .cos
495
        fmul    dword[ebx]         ; x * cosbeta
496
        faddp
497
        fidiv   [i3]
498
        fstp    dword[edi]         ; new x
499
        fmul    .sin               ; old x * sinbeta
500
        fld     .cos
501
        fmul    dword[ebx+8]       ; z * cosbeta
502
        faddp
503
        fstp    dword[edi+8]       ; new z
1245 hidnplayr 504
 
8014 leency 505
        fld     dword[ebx+4]   ;y
506
        fstp    dword[edi+4]
1245 hidnplayr 507
 
508
 
509
      .end_rot:
510
 
8014 leency 511
        add     edi,12
512
        add     ebx,12
513
        mov     esi,[points_ptr]
514
        add     esi,12*5
515
        cmp     ebx,esi  ;real_points + (12*5)
516
        jl      .rotor
1245 hidnplayr 517
 
8014 leency 518
        add     [points_count_var],5
519
        add     cx,18
520
        cmp     cx,(18*21)+1
521
        jle     .next
1245 hidnplayr 522
;last points
523
 
8014 leency 524
        xor     eax,eax
1245 hidnplayr 525
 
8014 leency 526
        mov     dword[edi],0.22
527
        mov     dword[edi+4],0.77
528
        mov     dword[edi+8],1.25
529
        add     edi,12
1245 hidnplayr 530
 
8014 leency 531
        mov     dword[edi],0.22
532
        mov     dword[edi+4],0.77
533
        mov     dword[edi+8],-1.25
534
        add     edi,12
535
        stosd
1245 hidnplayr 536
 
8014 leency 537
        add     [points_count_var],2
1245 hidnplayr 538
 
539
; init triangles list
540
 
8014 leency 541
        mov     edi,[triangles_ptr]
542
        mov     eax,5
543
        mov     ebx,5+5
544
        mov     [triangles_count_var],200  ;204
1245 hidnplayr 545
 
8014 leency 546
        mov     ecx,100
1245 hidnplayr 547
      @@:
8014 leency 548
        stosd                 ;----
549
        mov     [edi],ebx      ;    |
550
        add     edi,4         ;    |
551
        inc     eax            ;    |
552
        stosd                 ;    |repeat
1245 hidnplayr 553
 
8014 leency 554
        mov     [edi],ebx      ;    |
555
        inc     ebx
556
        add     edi,4
557
        stosd                 ;    |
558
        mov     [edi],ebx      ;    |
559
        add     edi,4         ;----
560
        loop     @b
1245 hidnplayr 561
 
8014 leency 562
        mov     eax,5
563
        mov     ebx,[points_count_var]
564
        sub     ebx,2
565
        mov     dl,2
1245 hidnplayr 566
    .nx:
8014 leency 567
        mov     ecx,5
568
        add     [triangles_count_var],ecx
1245 hidnplayr 569
    @@:
8014 leency 570
        stosd
571
        add     eax,5
572
        stosd
573
        mov     dword[edi],ebx
574
        add     edi,4
575
        loop    @b
1245 hidnplayr 576
 
8014 leency 577
        cmp     dl,1
578
        je      @f
1245 hidnplayr 579
 
8014 leency 580
        inc     ebx
581
        jmp     .lab
1245 hidnplayr 582
     @@:
8014 leency 583
        dec     ebx
1245 hidnplayr 584
     .lab:
8014 leency 585
        mov     ecx,5
586
        add     [triangles_count_var],ecx
1245 hidnplayr 587
     @@:
8014 leency 588
        stosd
589
        add     eax,5
590
        stosd
591
        mov     dword[edi],ebx
592
        add     edi,4
593
        loop    @b
1245 hidnplayr 594
 
8014 leency 595
        dec     dl
596
        or      dl,dl
597
        jnz     .nx
1245 hidnplayr 598
 
8014 leency 599
        sub     eax,25
600
        stosd
601
        sub     eax,50
602
        stosd
603
        mov     dword[edi],ebx
604
        add     edi,4
1245 hidnplayr 605
 
8014 leency 606
        stosd
607
        add     eax,50
608
        stosd
609
        inc     ebx
610
        mov     dword[edi],ebx
611
        add     edi,4
612
        add     [triangles_count_var],2
1245 hidnplayr 613
 
8014 leency 614
        mov     dword[edi],-1  ; < - end mark
615
        mov     [culling_flag],0
1245 hidnplayr 616
 
8014 leency 617
        mov     esp,ebp
618
        pop     ebp
1245 hidnplayr 619
 
620
ret
8014 leency 621