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 -... Line 1...
-
 
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
 
1
do_sinus:
225
do_sinus:
2
   .x      equ  [ebp-8]
226
   .x      equ  [ebp-8]
3
   .y      equ  [ebp-12]
227
   .y      equ  [ebp-12]
4
   .new_y  equ  [ebp-16]
228
   .new_y  equ  [ebp-16]
5
   .temp   equ  [ebp-20]
229
   .temp   equ  [ebp-20]
Line 17... Line 241...
17
   imul    ecx,eax  ;SIZE_X*SIZE_Y
241
   imul    ecx,eax  ;SIZE_X*SIZE_Y
18
   xor     eax,eax
242
   xor     eax,eax
19
   cld
243
   cld
20
   rep     stosd
244
   rep     stosd
21
   pop     edi
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
22
   fninit
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
23
 .again:
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
24
   fild    dword .x
269
   fild    dword .x
25
   fmul    [sin_frq]
270
   fmul    [sin_frq]
26
   fistp   dword .temp
271
   fistp   dword .temp
27
   mov     eax, .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
 
Line 28... Line 279...
28
 
279
 
Line -... Line 280...
-
 
280
   and     eax, 0x000000ff
-
 
281
 
-
 
282
;   cdq
-
 
283
 ;  mul     [sin_frq]
-
 
284
;   and      eax,0x000000ff
Line 29... Line 285...
29
   and     eax, 0x000000ff
285
;   and     ax,0x00ff
30
 
286
;   cwde
31
 
287
 
32
   fld     dword [sin_tab+eax*4]
288
   fld     dword [sin_tab+eax*4]
33
   fimul   dword [sin_amplitude]
289
   fimul   dword [sin_amplitude]
34
   fiadd   dword .y
290
   fiadd   dword .y
35
   fistp   dword .new_y
291
   fistp   dword .new_y
36
 
292
end if
37
   mov     eax,.new_y
293
   mov     eax,.new_y
38
   or      eax,eax
294
   or      eax,eax
Line 242... Line 498...
242
 
498
 
Line 243... Line 499...
243
end if
499
end if
Line -... Line 500...
-
 
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
Line -... Line 564...
-
 
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
244
 
602
 
Line 245... Line 603...
245
ret
603
        pop     ebp
246
 
604
ret