Subversion Repositories Kolibri OS

Rev

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