Subversion Repositories Kolibri OS

Rev

Rev 9512 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9512 Rev 9740
Line 60... Line 60...
60
;========================================================
60
;========================================================
Line 61... Line 61...
61
 
61
 
62
if Ext > SSE2
62
if Ext > SSE2
63
 ;--------------------------------------------------------------------
63
 ;--------------------------------------------------------------------
64
init_point_lights:
-
 
65
  ;      mov       eax,1000
-
 
66
  ;      cvtsi2ss  xmm1,eax
-
 
67
  ;      shufps    xmm1,xmm1,11000000b
-
 
68
  ;      mov       esi,lights_aligned
-
 
69
  ;      mov       edi,point_light_coords
-
 
70
  ;      mov       ecx,3
-
 
71
  ;    @@:
-
 
72
  ;      movaps    xmm0,[esi]
-
 
73
  ;      addps     xmm0,[f05xz]
-
 
74
  ;      mulps     xmm0,xmm1
-
 
75
  ;      movaps    [edi],xmm0
-
 
76
  ;      add       esi,64
-
 
77
   ;     add       edi,16
-
 
78
   ;     loop      @b
64
init_point_lights:
79
      mov       ecx,3
65
      mov       ecx,3
80
      mov       edi,point_light_coords
66
      mov       edi,point_light_coords
81
    @@:
67
    @@:
82
      push      ecx
68
      push      ecx
Line 88... Line 74...
88
      xor       ecx,ecx
74
      xor       ecx,ecx
89
      movzx     edx,word[size_x_var]
75
      movzx     edx,word[size_x_var]
90
      call      random
76
      call      random
91
      cvtsi2ss  xmm0,eax
77
      cvtsi2ss  xmm0,eax
92
      movss     [edi+4],xmm0
78
      movss     [edi+4],xmm0
93
   ;   movzx     ebx,word[size_x_var]
-
 
94
   ;   shl       ebx,2
-
 
95
   ;   neg       ebx
-
 
96
      mov       ecx,-1900
79
      mov       ecx,-1900
97
   ;   sub       ecx,100
-
 
98
      mov       edx,-600
80
      mov       edx,-600
99
      call      random
81
      call      random
100
      cvtsi2ss  xmm0,eax
82
      cvtsi2ss  xmm0,eax
101
      movss     [edi+8],xmm0
83
      movss     [edi+8],xmm0
102
   ;   mov       dword[edi+8],-1700.0
-
 
103
      mov       [edi+12],dword 0
84
      mov       [edi+12],dword 0
104
      add       edi,16
85
      add       edi,16
105
      pop       ecx
86
      pop       ecx
106
      loop      @b
87
      loop      @b
Line 172... Line 153...
172
;      cmpnless xmm0,[eps]
153
;      cmpnless xmm0,[eps]
173
;      movd     eax,xmm0
154
;      movd     eax,xmm0
174
;      or       eax,eax
155
;      or       eax,eax
175
;      jz       @f
156
;      jz       @f
176
      comiss   xmm0,[eps]
157
      comiss   xmm0,[eps]
177
      jl       @f
158
      jb       @f
Line 178... Line 159...
178
 
159
 
179
      rcpss    xmm0,.det
160
      rcpss    xmm0,.det
Line 180... Line 161...
180
      movss    .invdet,xmm0
161
      movss    .invdet,xmm0
Line 226... Line 207...
226
   ;   cmpnless xmm1,[eps]
207
   ;   cmpnless xmm1,[eps]
227
   ;   movmskps eax,xmm1
208
   ;   movmskps eax,xmm1
228
   ;   test     eax,1
209
   ;   test     eax,1
229
   ;   jz       @f
210
   ;   jz       @f
230
      comiss   xmm1,[eps]
211
      comiss   xmm1,[eps]
231
      jl       @f
212
      jb       @f
Line 232... Line 213...
232
 
213
 
233
      mov      eax,1
214
      mov      eax,1
234
      cmp      .ift,0
215
      cmp      .ift,0
Line 262... Line 243...
262
 
243
 
263
    .ed_cnt   equ [ebp-4]
244
    .ed_cnt   equ [ebp-4]
264
    .edd_ptr  equ [ebp-8]
245
    .edd_ptr  equ [ebp-8]
Line -... Line 246...
-
 
246
    .counter  equ [ebp-12]
-
 
247
 
-
 
248
       mov     ebx, 12
-
 
249
       mov     eax, 68
-
 
250
       mov     ecx,[triangles_count_var]
-
 
251
       lea     ecx,[ecx*3]
-
 
252
       shl     ecx,4
-
 
253
       add     ecx,1024
-
 
254
       mov     edx,[edges_ptr]
-
 
255
       int     0x40                   ;  -> allocate memory to edges
Line 265... Line 256...
265
    .counter  equ [ebp-12]
256
       mov     [edges_ptr], eax   ;  -> eax = pointer to allocated mem
266
 
257
 
267
 
258
 
268
    mov     ebx,[edges_ptr]
259
    mov     ebx,[edges_ptr]
Line 278... Line 269...
278
    add     ebx,24
269
    add     ebx,24
279
    add     eax,12
270
    add     eax,12
280
    loop    @b
271
    loop    @b
Line -... Line 272...
-
 
272
 
281
 
273
 
282
 
274
 
283
    mov     ebx,[edges_ptr]
275
    mov     ebx,[edges_ptr]
284
    mov     ecx,[triangles_count_var]
276
    mov     ecx,[triangles_count_var]
285
    lea     ecx,[ecx*3]
277
    lea     ecx,[ecx*3]
-
 
278
  .mxd:
286
  .mxd:
279
    mov     eax,[ebx]
287
    mov     eax,[ebx]
280
    mov     edx,[ebx+4]
288
    cmp     eax,[ebx+4]
281
    cmp     eax,[ebx+4]
289
    jl      @f
282
    cmovg   eax,edx
290
    movq    xmm0,[ebx]
283
    cmovg   edx,[ebx]
291
    pshufd  xmm0,xmm0,11100001b
-
 
292
    movq    [ebx],xmm0
284
    mov     [ebx],eax
293
  @@:
285
    mov     [ebx+4],edx
Line 294... Line 286...
294
    add     ebx,8
286
    add     ebx,8
Line 301... Line 293...
301
   lea    ecx,[ecx*3]
293
   lea    ecx,[ecx*3]
Line 302... Line 294...
302
 
294
 
303
   mov    esi,ecx
295
   mov    esi,ecx
304
   shl    esi,3
296
   shl    esi,3
305
   add    esi,ebx
297
   add    esi,ebx
306
 
298
   dec    ecx
307
 .ccc:
299
 .ccc:
308
   mov    eax,[ebx+8]
300
   mov    eax,[ebx+8]
309
   cmp    eax,[ebx]
301
   cmp    eax,[ebx]
310
   jge    .g
302
   jae    .g
311
   movq   xmm0,[ebx+8]
303
   movq   xmm0,[ebx+8]
312
   push   ebx
304
   push   ebx
313
 .c:
305
 .c:
314
   cmp    ebx,esi
306
   cmp    ebx,esi
315
   jge    .done
307
   jae    .done
316
   cmp    ebx,[edges_ptr]
308
   cmp    ebx,[edges_ptr]
317
   jl     .done
309
   jb     .done
318
   cmp    eax,[ebx]
310
   cmp    eax,[ebx]
319
   jge    .done
311
   jae    .done
320
   movq   xmm7,[ebx]
312
   movq   xmm7,[ebx]
321
   movq   [ebx+8],xmm7
313
   movq   [ebx+8],xmm7
322
   sub    ebx,8
314
   sub    ebx,8
323
   jnz    .c
315
   jnz    .c
Line 326... Line 318...
326
   movq   [ebx+8],xmm0
318
   movq   [ebx+8],xmm0
327
 .p:
319
 .p:
328
   pop    ebx
320
   pop    ebx
329
 .g:
321
 .g:
330
   add    ebx,8
322
   add    ebx,8
331
   dec    ecx
-
 
332
   cmp    ecx,1
-
 
333
   jnz    .ccc
323
   loop    .ccc
334
 
-
 
Line 335... Line 324...
335
 
324
 
336
  ; insert sort again
325
  ; insert sort again
337
   mov    ebx,[edges_ptr]
326
   mov    ebx,[edges_ptr]
338
   mov    ecx,[triangles_count_var]
327
   mov    ecx,[triangles_count_var]
Line 348... Line 337...
348
   mov    eax,[ebx]          ; count
337
   mov    eax,[ebx]          ; count
349
 .aa:
338
 .aa:
350
   inc    ecx
339
   inc    ecx
351
   add    ebx,8
340
   add    ebx,8
352
   cmp    ebx,esi
341
   cmp    ebx,esi
353
   jge    .br         ; break
342
   jae    .br         ; break
354
   cmp    eax,[ebx]
343
   cmp    eax,[ebx]
355
   je     .aa
344
   je     .aa
356
   mov    .counter,ecx
345
   mov    .counter,ecx
357
   pop    ebx
346
   pop    ebx
358
   mov    edi,ebx
347
   mov    edi,ebx
Line 366... Line 355...
366
   jmp    .ff
355
   jmp    .ff
367
 @@:
356
 @@:
368
   mov    eax,[ebx+12]
357
   mov    eax,[ebx+12]
369
   mov    edx,[ebx+8]
358
   mov    edx,[ebx+8]
370
   cmp    eax,[ebx+4]
359
   cmp    eax,[ebx+4]
371
   jge    .gg2
360
   jae    .gg2
372
   movq   xmm0,[ebx+8]
361
   movq   xmm0,[ebx+8]
373
   push   ebx
362
   push   ebx
374
 .c2:
363
 .c2:
375
   cmp    eax,[ebx+4]
364
   cmp    eax,[ebx+4]
376
   jge    .done2
365
   jae    .done2
377
   movq   xmm7,[ebx]
366
   movq   xmm7,[ebx]
378
   movq   [ebx+8],xmm7
367
   movq   [ebx+8],xmm7
Line 379... Line 368...
379
 
368
 
380
   sub    ebx,8
369
   sub    ebx,8
Line 403... Line 392...
403
   jmp    .ff
392
   jmp    .ff
404
 .br: ;break
393
 .br: ;break
405
   add   esp,8
394
   add   esp,8
406
 .ff:
395
 .ff:
Line -... Line 396...
-
 
396
 
407
 
397
 
408
   ; count edges
398
   ; count edges
409
   mov    ecx,0
399
 
410
   mov    edx,[triangles_count_var]
400
   mov    ecx,[triangles_count_var]
411
   lea    edx,[edx*3]
401
   lea    ecx,[ecx*3+3]
412
   mov    ebx,[edges_ptr]
402
   mov    esi,[edges_ptr]
413
;   mov    esi,edx
403
   xor    edx,edx
414
;   shl    esi,3
-
 
415
;   add    esi,[edges_ptr]
404
   cld
-
 
405
 .nx:
416
 .nx:
406
   lodsd
417
   movq    xmm0,[ebx]
407
   mov    ebx,eax
418
   add     ebx,8
408
   lodsd
419
;   cmp     ebx,esi
409
   cmp    ebx,[esi]
420
;   jae     @f
410
   jnz    .ic
421
   movq    xmm1,[ebx]
-
 
422
; @@:
411
   cmp    eax,[esi+4]
423
   pcmpeqd xmm0,xmm1
412
   jnz    .ic
424
   pmovmskb eax,xmm0
413
   loop   .nx
425
   and     eax,0xff
414
   jmp    .endc
-
 
415
 .ic:
426
   cmp     eax,0xff
416
 
427
   jz      @f
417
   inc    edx
428
   inc     ecx
418
   loop   .nx
429
  @@:
419
  .endc:
430
   dec     edx
420
    mov     .ed_cnt,edx
Line 431... Line -...
431
   jnz     .nx
-
 
432
 
-
 
433
 
421
    mov     ecx,edx
434
    mov     .ed_cnt,ecx
422
 
435
    lea     ecx,[ecx*3]
423
 
436
    shl     ecx,2
424
    shl     ecx,3
437
    add     ecx,65536
425
    add     ecx,65536
438
    mov     ebx,12
426
    mov     ebx,12
439
    mov     eax,68
427
    mov     eax,68
Line 440... Line -...
440
    mov     edx,.edd_ptr
-
 
441
    int     0x40                   ;  -> allocate memory to triangles
428
    mov     edx,.edd_ptr
442
    mov     .edd_ptr, eax   ;  -> eax = pointer to allocated mem
429
    int     0x40            ;  -> allocate memory to new edges
443
 
430
    mov     .edd_ptr, eax   ;  -> eax = pointer to allocated mem
444
 
431
 
445
 
432
 
446
   mov      ebx,[edges_ptr]
433
 
-
 
434
   mov    ecx,[triangles_count_var]
-
 
435
   lea    ecx,[ecx*3]
-
 
436
   add    ecx,ecx
447
   mov      ecx,[triangles_count_var]
437
   mov    esi,[edges_ptr]
-
 
438
   mov    edi,eax
448
   lea      ecx,[ecx*3]
439
   xor    edx,edx
-
 
440
   cld
449
  .seek:
441
 .nx1:
450
   movq     xmm0,[ebx]
442
   lodsd
451
   movq     xmm1,[ebx+8]
443
   mov    ebx,eax
452
   pcmpeqd  xmm1,xmm0
444
   lodsd
453
   pmovmskb edx,xmm1
445
   cmp    ebx,[esi]
-
 
446
   jnz    .ic1
-
 
447
   cmp    eax,[esi+4]
-
 
448
   jnz    .ic1
-
 
449
   loop   .nx1
454
   and      edx,0xff
450
   jmp    .endc1
455
   cmp      edx,0xff
451
 .ic1:
-
 
452
   xchg   eax,ebx
Line 456... Line 453...
456
   je       @f
453
   stosd
457
   movq     [eax],xmm0
454
   mov    eax,ebx
458
   add      eax,8
455
   stosd
459
 @@:
456
   inc    edx
Line 593... Line 590...
593
   mul     edx
590
   mul     edx
594
   add     eax,ebx
591
   add     eax,ebx
595
   mov     edi,[screen_ptr]
592
   mov     edi,[screen_ptr]
596
   lea     eax,[eax*3]
593
   lea     eax,[eax*3]
597
   add     edi,eax
594
   add     edi,eax
598
   xor     eax,eax
595
   or      eax,-1
599
   not     eax
596
;   not     eax
600
   stosd
597
   stosd
601
 @@:
598
 @@:
602
   loop    .drw
599
   loop    .drw
Line 603... Line 600...
603
 
600