Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1245 hidnplayr 1
 
2736 leency 2
; compiler    : FASM
1819 yogev_ezra 3
; system      : KolibriOS
4
; author      : Macgub aka Maciej Guba
1245 hidnplayr 5
; email       : macgub3@wp.pl
6
; web         : www.macgub.hekko.pl
1819 yogev_ezra 7
; Fell free to use this intro in your own distribution of KolibriOS/MenuetOS.
1245 hidnplayr 8
; Special greetings to all MenuetOS maniax in the world.
9
; I hope because my intros Christian Belive will be near to each of You.
10
11
 
12
 
13
; madis.kalme@mail.ee
14
; I tried optimizing it a bit, but don't know if it was successful. The objects
15
; can be:
16
; 1) Read from a file (*.3DS standard)
17
; 2) Written in manually (at the end of the code)
18
;include 'proc32.inc'
19
20
 
21
SIZE_Y equ 512				     ;      /////     I want definitely
2736 leency 22
TIMEOUT equ 10				     ;     ------     say:
23
ROUND equ 10				     ;     \ @ @/     keep smiling every
24
TEX_X equ 512	 ; texture width             ;      \ ./    / day.
25
TEX_Y equ 512	 ;         height            ;       \/    /
26
TEX_SHIFT equ 9  ; texture width shifting    ;     __||__ /
27
TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1	     ;   /|      |
28
TEX equ SHIFTING ; TEX={SHIFTING | FLUENTLY} ;  / \      /
29
FLUENTLY = 0				     ; /   |    |
30
SHIFTING = 1				     ;     ------
31
CATMULL_SHIFT equ 8			     ;      |  |
32
LIGHT_SIZE equ 22			     ;      |  |
33
NON   =   0				     ;     -/  \-
34
MMX   =   1
1245 hidnplayr 35
SSE   =   2
36
SSE2  =   3
1979 yogev_ezra 37
Ext   =   SSE2		    ;Ext={ NON | MMX | SSE | SSE2 }
2736 leency 38
1245 hidnplayr 39
 
40
USE_LFN = 1
41
42
 
43
	org    0x0
44
	db     'MENUET01'	; 8 byte id
45
	dd     0x01		; header version
46
	dd     START		; start of code
47
	dd     I_END		; size of image
48
	dd     MEM_END		; memory for app
49
	dd     MEM_END		; esp
50
	dd     I_Param		; I_Param
51
	dd     0x0		; I_Icon
52
53
 
54
	cld
55
	call   alloc_buffer_mem
56
	call   read_param
57
	call   read_from_disk	 ; read, if all is ok eax = 0
58
	cmp    eax,0
59
	jne    .gen
60
	call   read_tp_variables ; init points and triangles count variables
61
	cmp    eax,0
62
	je     .gen
63
	jmp    .malloc
64
    .gen:
65
     if USE_LFN
66
	mov    [triangles_count_var],1000
67
	mov    [points_count_var],1000
68
	call   alloc_mem_for_tp
69
     end if
70
	call   generate_object
71
	jmp    .opt
72
    .malloc:
73
     if USE_LFN
74
	call   alloc_mem_for_tp
75
     end if
76
	call   read_from_file
77
    .opt:
78
	call   optimize_object1     ;  proc in file b_procs.asm
79
				    ;  set point(0,0,0) in center and  calc all coords
80
				    ;  to be in <-1.0,1.0>
81
	call   normalize_all_light_vectors
82
	call   init_triangles_normals2
83
	call   init_point_normals
84
	call   init_envmap2
1931 yogev_ezra 85
	call   init_envmap_cub
1245 hidnplayr 86
	call   generate_texture2
87
	call   init_sincos_tab
88
89
 
90
	mov    edi,bumpmap
91
	call   calc_bumpmap
92
	call   calc_bumpmap_coords   ; bump and texture mapping
93
	call   draw_window
94
95
 
96
97
 
98
	mov	ebx,TIMEOUT
99
	cmp	[speed_flag],1
100
	jne	.skip
101
	mov	eax,11
102
    .skip:
103
	int	0x40
104
105
 
106
	je	red
107
	cmp	eax,2		; key in buffer ?
108
	je	key
109
	cmp	eax,3		; button in buffer ?
110
	je	button
111
112
 
113
114
 
115
	call	draw_window
116
117
 
118
119
 
120
	mov	eax,2		; just read it and ignore
121
	int	0x40
122
	jmp	noclose
123
124
 
125
	mov	eax,17		; get id
126
	int	0x40
127
128
 
129
	jne	@f
130
131
 
132
	int	0x40
133
    @@:
134
	cmp	ah,30
135
	jge	add_vec_buttons
136
	call	update_flags	      ; update flags and write labels of flags
137
138
 
139
	cmp	ah,3		      ; ah = 3 -> shading model
140
	jne	.next_m6
141
	cmp	[dr_flag],2
142
	jne	@f
143
   ;     call    init_envmap2    ;   <----! this don't works in env mode
1931 yogev_ezra 144
				 ;          and more than ~18 kb objects
145
 ;       call    init_envmap_cub2
1245 hidnplayr 146
     @@:
147
	cmp	[dr_flag],4
148
	jne	@f
149
	call	generate_texture2
150
151
 
152
     .next_m6:
153
				      ; ah = 5 -> scale-
154
	cmp	ah,5
155
	jne	@f
156
	mov	[scale],0.7
157
	fninit
158
	fld	[rsscale]
159
	fmul	[scale]
160
	fstp	[rsscale]
161
162
 
163
	cmp	ah,6		     ; ah = 6 ->  scale+
164
	jne	@f
165
	mov	[scale],1.3
166
	fninit
167
	fld	[rsscale]
168
	fmul	[scale]
169
	fstp	[rsscale]
170
171
 
172
	cmp	ah,9	; lights random                 ;    'flat'  0
173
	jne	.next_m5				;    'grd '  1
174
	call	make_random_lights			;    'env '  2
175
	call	normalize_all_light_vectors		;    'bump'  3
176
	call	do_color_buffer   ; intit color_map     ;    'tex '  4
177
      ;  cmp     [emboss_flag],1                         ;    'pos '  5
1931 yogev_ezra 178
      ;  je      @f                                      ;    'dots'  6
179
      ;  cmp     [dr_flag],8
180
      ;  jge     @f
181
      ;  cmp     [dr_flag],2                             ;    'txgr'  7
182
      ;  jl      .next_m5                            ;    '2tex'  8
183
      ;  cmp     [dr_flag],3                             ;    'btex'  9
184
      ;  jg      .next_m5
185
    ; @@:
186
	call	init_envmap2	; update env map if shading model = environment or bump
1245 hidnplayr 187
    .next_m5:
188
	cmp	 ah,11
189
	je	 @f
190
	cmp	 ah,12
191
	je	 @f
192
	cmp	 ah,13
193
	jne	 .next_m4
194
      @@:
195
	call	 mirror
196
     .next_m4:
197
	cmp	 ah,14
198
	jne	 @f
199
	call	 exchange
200
     @@:
201
	cmp	 ah,15
202
	jne	 @f
203
	cmp	 [emboss_flag],1
204
	call	 init_envmap2
205
     @@:
206
;        cmp      ah,17
207
;        jne      .next_m
208
;        cmp      [move_flag],2
209
;        jne      @f
210
;        call     draw_window             ; redraw other labels to navigation buttons
211
;      @@:
212
;        cmp      [move_flag],0
213
;        jne      .next_m
214
;        call     draw_window             ; redraw other labels to navigation buttons
215
     .next_m:
216
	cmp	 ah,18
217
	jne	 .next_m2
218
     if USE_LFN
1776 yogev_ezra 219
	mov	 [re_alloc_flag],1	 ; reallocate memory
220
	mov	 [triangles_count_var],1000
221
	mov	 [points_count_var],1000
222
	call	 alloc_mem_for_tp
223
	mov	 [re_alloc_flag],0
224
     end if
225
	mov	 bl,[generator_flag]
1245 hidnplayr 226
	or	 bl,bl
227
	jz	 .next_m2
228
	cmp	 bl,1
229
	jne	 @f
230
	call	 generate_object
231
	jmp	 .calc_norm
232
      @@:
233
	cmp	 bl,4
234
	jg	 @f
235
	movzx	 ax,bl		      ; ax < - object number
236
	call	 generate_object2
237
	jmp	.calc_norm
238
      @@:
239
	call	generate_object3
240
      .calc_norm:
241
	call	optimize_object1
242
	call	init_triangles_normals2
243
	call	init_point_normals
244
	call	calc_bumpmap_coords   ; bump and texture mapping
245
246
 
247
	cmp	 ah,19
248
	je	 @f
249
	cmp	 ah,20
250
	jne	 .next_m3
251
     @@:
252
	mov	 edi,bumpmap
253
	call	 calc_bumpmap
254
     .next_m3:
1776 yogev_ezra 255
	cmp	ah,21		 ; re map bumps, texture coordinates
256
	jne	@f
257
	call	calc_bumpmap_coords
258
      @@:
259
	jmp	noclose
1245 hidnplayr 260
261
 
262
 
263
   add_vec_buttons:	       ; can move: object, camera,.. list is open
264
			       ;
265
	cmp	ah,30
266
	jne	.next
267
	cmp	[move_flag],1
268
	je	@f
269
;        cmp     [move_flag],2
270
;        je      .set_light1
271
	sub	[vect_y],10
272
	jmp	.next
273
      @@:
274
	sub	[yobs],10   ;  observator = camera position
275
	jmp	.next
276
277
 
278
;      .set_light1:          ;  r -
279
;        movzx   ebx,[light_no_flag]  ; * 22
280
;        mov     ecx,ebx
281
;        shl     ebx,4
282
;        shl     ecx,1
283
;        add     ebx,ecx
284
;        shl     ecx,1
285
;        add     ebx,ecx
286
;        add     ebx,lights+6    ; 6 -> light vector size
287
;
288
;        movzx   ecx,[light_comp_flag]
289
;        lea     ecx,[ecx*3}
290
;        add     ebx,ecx         ; ebx ->  color to set
291
292
 
293
      .next:
294
	cmp	ah,31
295
	jne	.next1
296
	cmp	[move_flag],1
297
	je	@f
298
299
 
300
	jmp	.next1
301
      @@:
302
	add	[zobs],10	  ;  observator = camera position
303
     .next1:
304
	cmp	ah,33
305
	jne	.next2
306
	cmp	[move_flag],1
307
	je	@f
308
309
 
310
	jmp	.next2
311
      @@:
312
	sub	[xobs],10	  ;  observator = camera position
313
      .next2:
314
	cmp	ah,32
315
	jne	.next3
316
	cmp	[move_flag],1
317
	je	@f
318
319
 
320
	jmp	.next3
321
      @@:
322
	add	[xobs],10	  ;  observator = camera position
323
      .next3:
324
	cmp	ah,34
325
	jne	.next4
326
	cmp	[move_flag],1
327
	je	@f
328
329
 
330
	jmp	.next4
331
      @@:
332
	sub	[zobs],10	  ;  observator = camera position
333
      .next4:
334
	cmp	ah,35
335
	jne	.next5
336
	cmp	[move_flag],1
337
	je	@f
338
339
 
340
	add	[vect_y],10
341
	jmp	.next5
342
      @@:
343
	add	[yobs],10	  ;  observator = camera position
344
      .next5:
345
346
 
347
 
348
 
349
350
 
351
	jne	.no_x
352
	inc	[angle_x]
353
	and	[angle_x],0xff
354
	mov	[angle_z],0
355
	jmp	.end_rot
356
357
 
358
	cmp	[r_flag],0
359
	jne	.no_y
360
	inc	[angle_y]
361
	and	[angle_y],0xff
362
	mov	[angle_z],0
363
	jmp	.end_rot
364
365
 
366
	cmp	[r_flag],1
367
	jne	.end_rot
368
	mov	cx,[angle_x]
369
	inc	cx
370
	and	cx,0xff
371
	mov	[angle_z],0
372
	mov	[angle_y],cx
373
	mov	[angle_x],cx
374
     .end_rot:
375
376
 
377
	mov	edi,matrix
378
	call	make_rotation_matrix
379
    RDTSC
1931 yogev_ezra 380
    push eax
381
	mov	esi,[points_normals_ptr]
1245 hidnplayr 382
	mov	edi,[points_normals_rot_ptr]
383
	mov	ebx,matrix
384
	movzx	ecx,[points_count_var]
385
	call	rotary
386
387
 
388
	call	add_scale_to_matrix
389
390
 
391
	mov	edi,[points_rotated_ptr]
392
	mov	ebx,matrix
393
	movzx	ecx,[points_count_var]
394
	call	rotary
395
396
 
397
;    pop    ebx
398
;    sub    eax,ebx
399
;    sub    eax,41
400
;    push   eax
401
402
 
403
	mov	edi,[points_translated_ptr]
404
	movzx	ecx,[points_count_var]
405
	call	translate_points
406
407
 
408
;        jne     @f
409
;        call    calc_attenuation_light
410
;     @@:
411
	cmp	[fire_flag],0
412
	jne	@f
413
	call	clrscr		; clear the screen
414
     @@:
415
	cmp	[catmull_flag],1  ;non sort if Catmull = on
416
	je	.no_sort
417
	call	sort_triangles
418
      .no_sort:
419
	cmp	[dr_flag],7	  ; fill if 2tex and texgrd
420
	jge	@f
421
	cmp	[catmull_flag],0  ;non fill if Catmull = off
422
	je	.non_f
423
	cmp	[dr_flag],6	  ; non fill if dots
424
	je	.non_f
425
      @@:
426
	call	fill_Z_buffer	  ; make background
427
     .non_f:
428
;    RDTSC
1931 yogev_ezra 429
;    push eax
430
	cmp	[dr_flag],6
1245 hidnplayr 431
	jne	@f
432
	call	 draw_dots
433
	jmp	 .blurrr
434
      @@:
435
	call	draw_triangles	; draw all triangles from the list
436
      .blurrr:
437
	cmp	[fire_flag],0
438
	jne	@f
439
	cmp	[blur_flag],0
440
	je	.no_blur  ; no blur, no fire
441
	movzx	ecx,[blur_flag]
442
	call	blur_screen    ; blur and fire
443
	jmp	.no_blur
444
    @@:
445
	cmp	[emboss_flag],0
446
	jne	.emb	       ; if emboss=true -> no fire
447
	movzx	ecx,[fire_flag]
448
	call	blur_screen    ; blur and fire
449
    .no_blur:		       ; no blur, no fire
450
	cmp	[emboss_flag],0
451
	je	@f
452
     .emb:
453
	call	do_emboss
454
455
 
456
457
 
458
 
2736 leency 459
    je	    .no_inc_bright
460
    movzx   ebx,[inc_bright_flag]
461
    shl     ebx,4
462
    mov     esi,screen
463
    mov     ecx,SIZE_X*SIZE_Y*3
464
if (Ext = MMX)|(Ext = SSE)
465
    mov      bh,bl
466
    push     bx
467
    shl      ebx,16
468
    pop      bx
469
    push     ebx
470
    push     ebx
471
    movq     mm0,[esp]
472
    add      esp,8
473
else if Ext >= SSE2
474
    mov      bh,bl
475
    push     bx
476
    shl      ebx,16
477
    pop      bx
478
    movd     xmm0,ebx
479
    shufps   xmm0,xmm0,0
480
end if
481
  .oop:
482
if Ext=NON
483
    lodsb
484
    add     al,bl
485
    jnc     @f
486
    mov     byte[esi-1],255
487
    loop    .oop
488
   @@:
489
    mov     [esi-1],al
490
    loop    .oop
491
else if (Ext=MMX)|(Ext=SSE)
492
    movq    mm1,[esi]
493
    movq    mm2,[esi+8]
494
    paddusb mm1,mm0
495
    paddusb mm2,mm0
496
    movq    [esi],mm1
497
    movq    [esi+8],mm2
498
    add     esi,16
499
    sub     ecx,16
500
    jnz     .oop
501
else
502
    movaps  xmm1,[esi]
503
    paddusb xmm1,xmm0
504
    movaps  [esi],xmm1
505
    add     esi,16
506
    sub     ecx,16
507
    jnz     .oop
508
end if
509
510
 
511
512
 
513
 
514
    je	    .no_dec_bright
515
    movzx   ebx,[dec_bright_flag]
516
    shl     ebx,4
517
    mov     esi,screen
518
    mov     ecx,SIZE_X*SIZE_Y*3
519
if (Ext = MMX)|(Ext = SSE)
520
    mov      bh,bl
521
    push     bx
522
    shl      ebx,16
523
    pop      bx
524
    push     ebx
525
    push     ebx
526
    movq     mm0,[esp]
527
    add      esp,8
528
else if Ext >=SSE2
529
    mov      bh,bl
530
    push     bx
531
    shl      ebx,16
532
    pop      bx
533
    movd     xmm0,ebx
534
    shufps   xmm0,xmm0,0
535
end if
536
 .oop1:
537
if Ext=NON
538
    lodsb
539
    sub     al,bl
540
    jb	    @f
541
    mov     [esi-1],al
542
    loop    .oop1
543
   @@:
544
    mov     byte[esi-1],0
545
    loop    .oop1
546
else if (Ext = MMX)|(Ext=SSE)
547
    movq    mm1,[esi]
548
    psubusb mm1,mm0
549
    movq    [esi],mm1
550
    add     esi,8
551
    sub     ecx,8
552
    jnz     .oop1
553
else
554
    movaps  xmm1,[esi]
555
    psubusb xmm1,xmm0
556
    movaps  [esi],xmm1
557
    add     esi,16
558
    sub     ecx,16
559
    jnz     .oop1
560
end if
561
  .no_dec_bright:
562
;======================================commmented====================
563
if 0
564
if Ext >= SSE
565
    cmp     [max_flag],0
566
    je	    .no_max
567
    ;movzx   ebx,[max_flag]
568
 .again_max:
569
;    push       ecx
570
    mov        edi,screen
571
    mov        ecx,SIZE_X*3/4
572
  ;   ;    pxor       mm5,mm5
573
    xor        eax,eax
574
    rep        stosd
575
576
 
577
  .calc_max:
578
  @@:
579
    movq       mm0,[edi+SIZE_X*3]
580
    movq       mm1,[edi-SIZE_X*3]
581
    movq       mm2,[edi-3]
582
    movq       mm3,[edi+3]
583
584
 
585
    pmaxub	mm2,mm3
586
    pmaxub	mm0,mm2
587
588
 
589
    add 	edi,8
590
    loop	@b
591
592
 
593
    mov        ecx,SIZE_X*3/4
594
    rep        stosd
595
end if
596
597
 
598
599
 
600
    cmp     [min_flag],0
601
    je	    .no_min
602
;    push       ecx
603
    mov        edi,screen
604
    mov        ecx,SIZE_X*3/4
605
  ;   ;    pxor       mm5,mm5
606
    xor        eax,eax
607
    rep        stosd
608
609
 
610
  @@:
611
    movq       mm0,[edi+SIZE_X*3]
612
    movq       mm1,[edi-SIZE_X*3]
613
    movq       mm2,[edi-3]
614
    movq       mm3,[edi+3]
615
616
 
617
    pminub	mm2,mm3
618
    pminub	mm0,mm2
619
620
 
621
    add 	edi,8
622
    loop	@b
623
624
 
625
626
 
627
    rep        stosd
628
end if
629
.no_min:
630
end if
631
;========================commented=====================================
632
    RDTSC
1245 hidnplayr 633
    sub eax,[esp]
634
    sub eax,41
635
;    pop     eax
636
637
 
638
  .dc:
639
    xor     edx,edx
640
    mov     edi,10
641
    div     edi
642
    add     dl,30h
643
    mov     [STRdata+ecx-1],dl
644
    loop    .dc
645
    pop eax
646
647
 
648
    mov     ebx,screen
649
    mov     ecx,SIZE_X shl 16 + SIZE_Y
650
    mov     edx,5 shl 16 + 23
2206 leency 651
    int     0x40
1245 hidnplayr 652
653
 
2736 leency 654
    mov  ebx,530*65536+60
655
    mov  ecx,510*65536+9
656
    xor  edx,edx
657
    int  40h
658
659
 
1245 hidnplayr 660
    mov  ebx,530*65536+510 	   ; [x start] *65536 + [y start]
2736 leency 661
    mov  ecx,0x00888888
662
    mov  edx,STRdata		   ; pointer to text beginning
1245 hidnplayr 663
    mov  esi,10 		   ; text length
664
    int  40h
665
666
 
667
 
668
 
669
670
 
671
;-------------------------PROCEDURES---------------------------------------------
672
;--------------------------------------------------------------------------------
673
include "TEX3.INC"
1728 clevermous 674
include "FLAT_CAT.INC"
675
include "TEX_CAT.INC"
676
include "BUMP_CAT.INC"
677
include "3DMATH.INC"
678
include "GRD3.INC"
679
include "FLAT3.INC"
680
include "BUMP3.INC"
681
include "B_PROCS.INC"
682
include "A_PROCS.INC"
683
include "GRD_CAT.INC"
684
include "BUMP_TEX.INC"
685
include "GRD_TEX.INC"
686
include "TWO_TEX.INC"
687
1245 hidnplayr 688
 
2736 leency 689
 
1245 hidnplayr 690
    movzx    ecx,[size_x]
691
    movzx    eax,[size_y]
692
    mul      ecx
693
    lea      ecx,[eax*3]
694
    push     ecx
695
    shl      eax,2
696
    add      ecx,eax
697
    add      ecx,MEM_END
698
    mov      ebx,1
699
    mov      eax,64	; allocate mem  - resize app mem
700
    int      0x40
701
    mov      [screen_ptr],MEM_END
702
    mov      [Zbuffer_ptr],MEM_END
703
    pop      ecx
704
    add      [Zbuffer_ptr],ecx
705
ret
706
707
 
708
; updates flags and writing flag description
709
; in    ah - button number
710
	push	ax
711
	mov	edi,menu
712
      .ch_another:
713
	cmp	ah,byte[edi]	 ; ah = button id
714
	jne	@f
715
	mov	bl,byte[edi+11]  ; max_flag + 1
716
	cmp	bl,255
717
	je	.no_write
718
	inc	byte[edi+12]	 ; flag
719
	cmp	byte[edi+12],bl
720
	jne	.write
721
	mov	byte[edi+12],0
722
	jmp	.write
723
      @@:
724
	add	edi,17
725
	cmp	byte[edi],-1
726
	jne	.ch_another
727
     .write:
728
;     clreol   {pascal never dies}
729
;          * eax = 13 - function number
730
;  * ebx = [coordinate on axis x]*65536 + [size on axis x]
731
;  * ecx = [coordinate on axis y]*65536 + [size on axis y]
732
;  * edx = color 0xRRGGBB or 0x80RRGGBB for gradient fill
733
734
 
735
	movzx	ecx,byte[edi]
736
	sub	cl,2
737
	lea	ecx,[ecx*3]
738
	lea	ecx,[ecx*5]
739
	add	ecx,28
740
	shl	ecx,16
741
	add	ecx,14				;  ecx = [coord y]*65536 + [size y]
742
	mov	ebx,(SIZE_X+12+70)*65536+25	; [x start] *65536 + [size x]
743
	mov	edx,0x00000000			;  color  0x00RRGGBB
744
	int	0x40
745
746
 
747
	movzx	ebx,byte[edi]
748
	sub	bl,2
749
	lea	ebx,[ebx*3]
750
	lea	ebx,[ebx*5]
751
	add	ebx,(SIZE_X+12+70)*65536+28	; [x start] *65536 + [y start]
752
	mov	ecx,0x20ddeeff			; font 1 & color ( 0xF0RRGGBB )
753
	movzx	edx,byte[edi+12]		; current flag
754
	shl	edx,2				; * 4 = text length
755
	add	edx,dword[edi+13]		; pointer to text beginning
756
	mov	esi,4				; text length -
757
						; flag description 4 characters
758
	int	0x40
759
760
 
761
	pop	ax
762
ret
763
normalize_all_light_vectors:
764
	mov	edi,lights
765
     @@:
766
	call	normalize_vector	   ;       3dmath.inc
767
	add	edi,LIGHT_SIZE
768
	cmp	edi,lightsend	;ecx
769
	jl	@b
770
ret
771
772
 
773
;macro .comment222
774
;                                ; planar mapping
775
;        mov     esi,points
776
;        mov     edi,tex_points
777
;      @@:
778
;         add     esi,2
779
;         movsd
780
;         cmp     dword[esi],dword -1
781
;         jne     @b
782
783
 
784
785
 
786
;      sub   esp,4
787
788
 
1776 yogev_ezra 789
      fldpi
1245 hidnplayr 790
      fadd	st,st
791
      mov	esi,[points_ptr]
792
      mov	edi,tex_points
793
      movzx	ecx,[points_count_var]
794
      inc	ecx
795
;      cmp       [map_tex_flag],1
1776 yogev_ezra 796
;      jne       .cylindric
797
      ; spherical mapping around y axle
798
1245 hidnplayr 799
 
800
      fld	dword[esi]     ; x coord
801
      fld	dword[esi+8]   ; z coord
802
      fpatan		       ; arctg(st1/st)
803
;      fdiv      .Pi2
804
      fdiv	st0,st1
805
      fimul	[tex_x_div2]
806
      fiadd	[tex_x_div2]
807
      fistp	word[edi]      ; x
808
809
 
810
      fld	dword[esi]     ; x
811
      fmul	st,st0
812
      fld	dword[esi+4]   ; y
813
      fmul	st,st0
814
      fld	dword[esi+8]   ; z
815
      fmul	st,st0
816
      faddp
817
      faddp
818
      fsqrt
819
      fpatan
820
      fldpi
821
      fdivp
822
      fimul    [tex_y_div2]
823
      fiadd    [tex_y_div2]
824
      fistp    word[edi+2]     ; y
825
826
 
827
      add      edi,4
828
      loop     @b
829
      ffree    st0
830
;      jmp      .end_map
1776 yogev_ezra 831
;  .cylindric:
832
;       fld     dword[esi]     ; around y axle
833
;       fld     dword[esi+8]
834
;       fpatan
835
;       fdiv    st0,st1
836
;       fimul   [tex_x_div2]
837
;       fiadd   [tex_x_div2]
838
;       fistp   word[edi]
839
1245 hidnplayr 840
 
1776 yogev_ezra 841
;       fimul   [tex_y_div2]
842
;       fiadd   [tex_y_div2]
843
;       fistp   word[edi+2]
844
845
 
846
;       add     edi,4
847
;       loop    .cylindric
848
;       ffree    st0
849
;;      mov      esp,ebp
850
;   .end_map:
851
ret
1245 hidnplayr 852
853
 
854
 
855
;env_map 512 x 512 x 3 bytes
856
.temp  equ word   [ebp-2]
857
.nEy   equ word  [ebp-4]
858
.nEx   equ word  [ebp-6]
859
.col_r equ    [ebp-8]
860
.col_g equ    [ebp-9]
861
.col_b equ    [ebp-10]
862
863
 
864
	 mov	  ebp,esp
865
	 sub	  esp,20
866
	 mov	  edi,envmap
867
	 fninit
868
869
 
870
    .ie_ver:
871
	 mov	  cx,- TEX_X / 2 ;256   ; cx - horizontal coord = x
872
    .ie_hor:
873
	 xor	  ebx,ebx
874
	 mov	  dword .col_b, 0
875
     .light:
876
	 lea	  esi,[lights+ebx]
877
	 fld	  dword[esi]	 ; light vector x cooficient
878
	 fimul	  [tex_x_div2] ;[i256]
879
	 mov	  .temp,cx
880
	 fisubr   .temp
881
	 fistp	  .nEx
882
	 fld	  dword[esi+4]	 ; light vector y cooficient
883
	 fimul	  [tex_y_div2] ;[i256]
884
	 mov	  .temp,dx
885
	 fisubr   .temp
886
	 fistp	  .nEy
887
888
 
889
	 jl	  .update_counters
890
	 cmp	  .nEy,- TEX_Y / 2 ;256
891
	 jl	  .update_counters
892
	 cmp	  .nEx,TEX_X / 2 ;256
893
	 jg	  .update_counters
894
	 cmp	  .nEy,TEX_Y / 2 ;256
895
	 jg	  .update_counters
896
897
 
898
	 fmul	  st,st0
899
	 fild	  .nEy
900
	 fmul	  st,st0
901
	 faddp
902
	 fsqrt
903
	 fisubr   [i256]
904
	 fmul	  [env_const]
905
	 fidiv	  [i256]   ; st - 'virtual' dot product
906
907
 
908
	 fstsw	  ax
909
	 sahf
910
	 jb	  @f
911
	 ffree	  st
912
	 fld1	  ;[dot_max]
913
      @@:
914
	 fcom	  [dot_min]
915
	 fstsw	  ax
916
	 sahf
917
	 ja	  @f
918
	 ffree	  st
919
	 fldz	  ;[dot_min]
920
      @@:
921
	 push	  ebp
922
	 movzx	  ax,byte[esi+21]
923
	 push	  ax  ;- shines
924
	 mov	  al,byte[esi+14]   ; b    orginal color
925
	 push	  ax
926
	 mov	  al,byte[esi+13]   ; g
927
	 push	  ax
928
	 mov	  al,byte[esi+12]   ; r
929
	 push	  ax
930
	 mov	  al,byte[esi+20]   ; b     max color
931
	 push	  ax
932
	 mov	  al,byte[esi+19]   ; g
933
	 push	  ax
934
	 mov	  al,byte[esi+18]   ; r
935
	 push	  ax
936
	 mov	  al,byte[esi+17]   ; b    min col
937
	 push	  ax
938
	 mov	  al,byte[esi+16]   ; g
939
	 push	  ax
940
	 mov	  al,byte[esi+15]   ; r
941
	 push	  ax
942
	 push	  eax	      ; earlier - dot pr
943
      ;  fstp     .dot_product
944
      ;  push     .dot_product
945
	 call	  calc_one_col
946
	 pop	  ebp
947
	 ; eax-0x00rrggbb
948
	 cmp	  al,.col_b
949
	 jbe	  @f
950
	 mov	  .col_b,al
951
   @@:			      ;  eax - ggbb00rr
952
	 shr	  ax,8
953
	 cmp	  al,.col_g
954
	 jbe	  @f
955
	 mov	  .col_g,al
956
   @@:			      ;  eax - bb0000gg
957
	 shr	  eax,16
958
	 cmp	  al,.col_r
959
	 jbe	  @f
960
	 mov	  .col_r,al
961
   @@:
962
   .update_counters:			 ; update and jump when neccesery
963
	 add	  ebx,LIGHT_SIZE
964
	 cmp	  bx,[all_lights_size]
965
	 jl	  .light    ; next_light
966
	 mov	  eax,dword .col_b
967
	 stosd
968
	 dec	  edi
969
970
 
971
	 cmp	  cx,TEX_X / 2 ;256
972
	 jne	  .ie_hor
973
974
 
975
	 cmp	  dx,TEX_Y / 2 ;256
976
	 jne	 .ie_ver
977
978
 
979
	 pop	 ebp
980
ret
981
982
 
1931 yogev_ezra 983
 
984
 
1245 hidnplayr 985
;env_map 512 x 512 x 3 bytes    ; many lights using
986
.temp  equ word   [ebp-2]
987
.nz    equ dword  [ebp-6]  ; dword
988
.ny    equ dword  [ebp-10]
989
.nx    equ dword  [ebp-14]
990
.col_r equ    [ebp-16]
991
.col_g equ    [ebp-17]
992
.col_b equ    [ebp-18]
993
994
 
995
	 mov	  ebp,esp
996
	 sub	  esp,20
997
	 mov	  edi,color_map
998
	 fninit
999
1000
 
1001
    .ie_ver:
1002
	 mov	  cx,- TEX_X / 2 ;256   ; cx - horizontal coord = x
1003
    .ie_hor:
1004
	 mov	  .temp,cx
1005
	 fild	  .temp
1006
	 fidiv	  [i256]   ;st = Nx - vector normal x cooficient
1007
	 fst	  .nx
1008
	 fmul	  st,st0
1009
	 mov	  .temp,dx
1010
	 fild	  .temp
1011
	 fidiv	  [i256]   ; st = Ny - vector normal y coeficient
1012
	 fst	  .ny
1013
	 fmul	  st,st0
1014
	 faddp
1015
	 fld1
1016
	 fchs
1017
	 faddp
1018
	 fabs
1019
	 fsqrt
1020
	 fchs
1021
	 fstp	  .nz		   ; st - Nz - vect normal z coeficient
1022
	 xor	  ebx,ebx
1023
	 mov	  dword .col_b, 0
1024
     .light:
1025
	 push	  edi	;env_map
1026
	 lea	  esi,[lights+ebx]
1027
	 lea	  edi,.nx
1028
	 call	  dot_product
1029
	 pop	  edi
1030
	 fcom	  [dot_min]
1031
	 fstsw	  ax
1032
	 sahf
1033
	 ja	  .env_ok1  ;compare with dot_max
1034
	 ffree	  st
1035
1036
 
1037
      .env_ok1:
1038
	 fcom	 [dot_max]
1039
	 fstsw	 ax
1040
	 sahf
1041
	 jb	 .env_ok2     ; calc col
1042
	 ffree	 st
1043
	 jmp	 .update_counters
1044
      .env_ok2: 	   ;calc col
1045
	 push	  ebp
1046
	 movzx	  ax,byte[esi+21]
1047
	 push	  ax  ;- shines
1048
	 mov	  al,byte[esi+14]   ; b    orginal color
1049
	 push	  ax
1050
	 mov	  al,byte[esi+13]   ; g
1051
	 push	  ax
1052
	 mov	  al,byte[esi+12]   ; r
1053
	 push	  ax
1054
	 mov	  al,byte[esi+20]   ; b     max color
1055
	 push	  ax
1056
	 mov	  al,byte[esi+19]   ; g
1057
	 push	  ax
1058
	 mov	  al,byte[esi+18]   ; r
1059
	 push	  ax
1060
	 mov	  al,byte[esi+17]   ; b    min col
1061
	 push	  ax
1062
	 mov	  al,byte[esi+16]   ; g
1063
	 push	  ax
1064
	 mov	  al,byte[esi+15]   ; r
1065
	 push	  ax
1066
	 push	  eax	      ; earlier - dot pr
1067
      ;  fstp     .dot_product
1068
      ;  push     .dot_product
1069
	 call	  calc_one_col
1070
	 pop	  ebp
1071
	 ; eax-0x00rrggbb
1072
	 cmp	  al,.col_b
1073
	 jbe	  @f
1074
	 mov	  .col_b,al
1075
   @@:
1076
	 shr	  ax,8
1077
	 cmp	  al,.col_g
1078
	 jbe	  @f
1079
	 mov	  .col_g,al
1080
   @@:
1081
	 shr	  eax,16
1082
	 cmp	  al,.col_r
1083
	 jbe	  @f
1084
	 mov	  .col_r,al
1085
  @@:
1086
 .update_counters:				    ; update and jump when neccesery
1087
	add	ebx,LIGHT_SIZE
1088
	cmp	bx,[all_lights_size]
1089
	jl	.light	  ; next_light
1090
	mov	eax,dword .col_b
1091
	stosd
1092
	dec	edi
1093
1094
 
1095
	cmp	cx,TEX_X / 2 ;256
1096
	jne	.ie_hor
1097
1098
 
1099
	cmp	dx,TEX_X / 2 ;256
1100
	jne	.ie_ver
1101
1102
 
1103
	 mov	 esp,ebp
1104
	 pop	 ebp
1105
ret
1106
if 0
1107
init_triangles_normals:
1108
	mov	ebx,triangles_normals
1109
	mov	ebp,triangles
1110
     @@:
1111
	push	ebx
1112
	mov	ebx,vectors
1113
	movzx	esi,word[ebp]	       ; first point index
1114
	lea	esi,[esi*3]
1115
	lea	esi,[points+esi*2]     ; esi - pointer to 1st 3d point
1116
	movzx	edi,word[ebp+2]        ; second point index
1117
	lea	edi,[edi*3]
1118
	lea	edi,[points+edi*2]     ; edi - pointer to 2nd 3d point
1119
	call	make_vector
1120
	add	ebx,12
1121
	mov	esi,edi
1122
	movzx	edi,word[ebp+4]        ; third point index
1123
	lea	edi,[edi*3]
1124
	lea	edi,[points+edi*2]
1125
	call	make_vector
1126
	mov	edi,ebx 		; edi - pointer to 2nd vector
1127
	mov	esi,ebx
1128
	sub	esi,12			; esi - pointer to 1st vector
1129
	pop	ebx
1130
	call	cross_product
1131
	mov	edi,ebx
1132
	call	normalize_vector
1133
	add	ebp,6
1134
	add	ebx,12
1135
	cmp	dword[ebp],-1
1136
	jne	@b
1137
ret
1138
end if
1139
init_point_normals:
1140
.x equ dword [ebp-4]
1141
.y equ dword [ebp-8]
1142
.z equ dword [ebp-12]
1143
.point_number equ word [ebp-26]
1144
.hit_faces    equ word [ebp-28]
1145
1146
 
1147
	mov	  ebp,esp
1148
	sub	  esp,28
1149
	mov	  edi,[points_normals_ptr]
1150
	mov	  .point_number,0
1151
    .ipn_loop:
1152
	mov	  .hit_faces,0
1153
	mov	  .x,0
1154
	mov	  .y,0
1155
	mov	  .z,0
1156
	mov	  esi,[triangles_ptr]
1157
	xor	  ecx,ecx	       ; ecx - triangle number
1158
    .ipn_check_face:
1159
	xor	  ebx,ebx	       ; ebx - 'position' in one triangle
1160
    .ipn_check_vertex:
1161
	movzx	  eax,word[esi+ebx]    ;  eax - point_number
1162
	cmp	  ax,.point_number
1163
	jne	  .ipn_next_vertex
1164
	push	  esi
1165
	mov	  esi,ecx
1166
	lea	  esi,[esi*3]
1167
       ; lea       esi,[triangles_normals+esi*4]
1168
	shl	  esi,2
1169
	add	  esi,[triangles_normals_ptr]
1170
1171
 
1172
	fadd	  dword[esi+vec_x]	 ; vec_x this defined in 3dmath.asm - x cooficient
1173
	fstp	  .x			 ; of normal vactor
1174
	fld	  .y
1175
	fadd	  dword[esi+vec_y]
1176
	fstp	  .y
1177
	fld	  .z
1178
	fadd	  dword[esi+vec_z]
1179
	fstp	  .z
1180
	pop	  esi
1181
	inc	  .hit_faces
1182
	jmp	  .ipn_next_face
1183
    .ipn_next_vertex:
1184
	add	  ebx,2
1185
	cmp	  ebx,6
1186
	jne	  .ipn_check_vertex
1187
    .ipn_next_face:
1188
	add	  esi,6
1189
	inc	  ecx
1190
	cmp	  cx,[triangles_count_var]
1191
	jne	  .ipn_check_face
1192
1193
 
1194
	fidiv	  .hit_faces
1195
	fstp	  dword[edi+vec_x]
1196
	fld	  .y
1197
	fidiv	  .hit_faces
1198
	fstp	  dword[edi+vec_y]
1199
	fld	  .z
1200
	fidiv	  .hit_faces
1201
	fstp	  dword[edi+vec_z]
1202
	call	  normalize_vector
1203
	add	  edi,12  ;type vector 3d
1204
	inc	  .point_number
1205
	mov	  dx,.point_number
1206
	cmp	  dx,[points_count_var]
1207
	jne	  .ipn_loop
1208
1209
 
1210
ret
1211
;===============================================================
1212
1213
 
1214
	mov	ebx,[triangles_normals_ptr]
1215
	mov	ebp,[triangles_ptr]
1216
     @@:
1217
	push	ebx
1218
	mov	ebx,vectors
1219
	movzx	esi,word[ebp]	       ; first point index
1220
	lea	esi,[esi*3]
1221
;        lea     esi,[points+esi*2]     ; esi - pointer to 1st 3d point
1222
	shl	esi,2
1223
	add	esi,[points_ptr]
1224
	movzx	edi,word[ebp+2] 	 ; first point index
1225
	lea	edi,[edi*3]
1226
	shl	edi,2
1227
	add	edi,[points_ptr]
1228
;        movzx   edi,word[ebp+2]        ; second point index
1229
;        lea     edi,[edi*3]
1230
;        lea     edi,[points+edi*2]     ; edi - pointer to 2nd 3d point
1231
	call	make_vector_r
1232
	add	ebx,12
1233
	mov	esi,edi
1234
	movzx	edi,word[ebp+4]        ; third point index
1235
	lea	edi,[edi*3]
1236
	shl	edi,2
1237
	add	edi,[points_ptr]
1238
;        lea     edi,[points+edi*2]
1239
	call	make_vector_r
1240
	mov	edi,ebx 		; edi - pointer to 2nd vector
1241
	mov	esi,ebx
1242
	sub	esi,12			; esi - pointer to 1st vector
1243
	pop	ebx
1244
	call	cross_product
1245
	mov	edi,ebx
1246
	call	normalize_vector
1247
	add	ebp,6
1248
	add	ebx,12
1249
	cmp	dword[ebp],-1
1250
	jne	@b
1251
ret
1252
1253
 
1254
 
1255
sort_triangles:
1256
	mov	esi,[triangles_ptr]
1257
	mov	edi,triangles_with_z
1258
	mov	ebp,[points_translated_ptr]
1259
1260
 
1261
	movzx	eax,word[esi]
1262
	lea	eax,[eax*3]
1263
	movzx	ecx,word[ebp+eax*2+4]
1264
1265
 
1266
	lea	eax,[eax*3]
1267
	add	cx,word[ebp+eax*2+4]
1268
1269
 
1270
	lea	eax,[eax*3]
1271
	add	cx,word[ebp+eax*2+4]
1272
1273
 
1274
       ; cwd
1275
       ; idiv    word[i3]
1276
	movsd			; store vertex coordinates
1277
	movsw
1278
	stosw			; middle vertex coordinate  'z' in triangles_with_z list
1279
	cmp	dword[esi],-1
1280
	jne	make_triangle_with_z
1281
	movsd			; copy end mark
1282
	mov	eax,4
1283
	lea	edx,[edi-8-trizdd]
1284
     ;   lea     edx, [edi-8]
1285
     ;   sub     edx,[triangles_w_z_ptr]
1286
	mov	[high],edx
1287
	call	quicksort
1288
	mov	eax,4
1289
	mov	edx,[high]
1290
	call	insertsort
1291
	jmp	end_sort
1292
1293
 
1294
	mov	ecx,edx
1295
	sub	ecx,eax
1296
	cmp	ecx,32
1297
	jc	.exit
1298
	lea	ecx,[eax+edx]
1299
	shr	ecx,4
1300
	lea	ecx,[ecx*8-4];
1301
;        mov     edi,[triangles_w_z_ptr]
1302
;        mov     ebx,[edi+eax]
1303
;        mov     esi,[edi+ecx]
1304
;        mov     edi,[edi+edx]
1305
	mov	ebx,[trizdd+eax]; trizdd[l]
1306
	mov	esi,[trizdd+ecx]; trizdd[i]
1307
	mov	edi,[trizdd+edx]; trizdd[h]
1308
	cmp	ebx,esi
1309
	jg	@f		; direction NB! you need to negate these to invert the order
1310
      if Ext=NON
1311
	mov	[trizdd+eax],esi
1312
	mov	[trizdd+ecx],ebx
1313
	mov	ebx,[trizdd+eax-4]
1314
	mov	esi,[trizdd+ecx-4]
1315
	mov	[trizdd+eax-4],esi
1316
	mov	[trizdd+ecx-4],ebx
1317
	mov	ebx,[trizdd+eax]
1318
	mov	esi,[trizdd+ecx]
1319
      else
1320
;        push    ebx
1321
;        mov     ebx,[triangles_w_z_ptr]
1322
;        movq    mm0,[ebx+eax-4]
1323
;        movq    mm1,[ebx+ecx-4]
1324
;        movq    [ebx+ecx-4],mm0
1325
;        movq    [ebx+eax-4],mm1
1326
;        pop     ebx
1327
	movq	mm0,[trizdq+eax-4]
1328
	movq	mm1,[trizdq+ecx-4]
1329
	movq	[trizdq+ecx-4],mm0
1330
	movq	[trizdq+eax-4],mm1
1331
	xchg	ebx,esi
1332
      end if
1333
      @@:
1334
	cmp	ebx,edi
1335
	jg	@f		; direction
1336
      if Ext=NON
1337
	mov	[trizdd+eax],edi
1338
	mov	[trizdd+edx],ebx
1339
	mov	ebx,[trizdd+eax-4]
1340
	mov	edi,[trizdd+edx-4]
1341
	mov	[trizdd+eax-4],edi
1342
	mov	[trizdd+edx-4],ebx
1343
	mov	ebx,[trizdd+eax]
1344
	mov	edi,[trizdd+edx]
1345
      else
1346
;        push    ebx
1347
;        mov     ebx,[triangles_w_z_ptr]
1348
;        movq    mm0,[ebx+eax-4]
1349
;        movq    mm1,[ebx+edx-4]
1350
;        movq    [ebx+edx-4],mm0
1351
;        movq    [ebx+eax-4],mm1
1352
	movq	mm0,[trizdq+eax-4]
1353
	movq	mm1,[trizdq+edx-4]
1354
	movq	[trizdq+edx-4],mm0
1355
	movq	[trizdq+eax-4],mm1
1356
;        pop     ebx
1357
	xchg	ebx,edi
1358
      end if
1359
      @@:
1360
	cmp	esi,edi
1361
	jg	@f		; direction
1362
      if Ext=NON
1363
	mov	[trizdd+ecx],edi
1364
	mov	[trizdd+edx],esi
1365
	mov	esi,[trizdd+ecx-4]
1366
	mov	edi,[trizdd+edx-4]
1367
	mov	[trizdd+ecx-4],edi
1368
	mov	[trizdd+edx-4],esi
1369
      else
1370
;        push    ebx
1371
;        mov     ebx,[triangles_w_z_ptr]
1372
;        movq    mm0,[ebx+ecx-4]
1373
;        movq    mm1,[ebx+edx-4]
1374
;        movq    [ebx+edx-4],mm0
1375
;        movq    [ebx+ecx-4],mm1
1376
;        pop     ebx
1377
1378
 
1379
	movq	mm1,[trizdq+edx-4]
1380
	movq	[trizdq+edx-4],mm0
1381
	movq	[trizdq+ecx-4],mm1
1382
	xchg	ebx,esi
1383
      end if
1384
      @@:
1385
	mov	ebp,eax 	; direction
1386
	add	ebp,8	   ;   j
1387
      if Ext=NON
1388
	mov	esi,[trizdd+ebp]
1389
	mov	edi,[trizdd+ecx]
1390
	mov	[trizdd+ebp],edi
1391
	mov	[trizdd+ecx],esi
1392
	mov	esi,[trizdd+ebp-4]
1393
	mov	edi,[trizdd+ecx-4]
1394
	mov	[trizdd+ecx-4],esi
1395
	mov	[trizdd+ebp-4],edi
1396
      else
1397
;        push    ebx
1398
;        mov     ebx,[triangles_w_z_ptr]
1399
;        movq    mm0,[ebx+ebp-4]
1400
;        movq    mm1,[ebx+ecx-4]
1401
;        movq    [ebx+ecx-4],mm0
1402
;        movq    [ebx+ebp-4],mm1
1403
;        pop     ebx
1404
1405
 
1406
	movq	mm1,[trizdq+ecx-4]
1407
	movq	[trizdq+ecx-4],mm0
1408
	movq	[trizdq+ebp-4],mm1
1409
      end if
1410
	mov	ecx,edx    ;   i; direction
1411
	mov	ebx,[trizdd+ebp]; trizdd[j]
1412
;        mov     ebx, [triangles_w_z_ptr]
1413
;        add     ebx, ebp
1414
1415
 
1416
 ;       mov     eax, [triangles_w_z_ptr]
1417
      .loop:
1418
	sub	ecx,8		; direction
1419
	cmp	[trizdd+ecx],ebx
1420
;        cmp     [eax+ecx],ebx
1421
	jl	.loop		; direction
1422
      @@:
1423
	add	ebp,8		; direction
1424
	cmp	[trizdd+ebp],ebx
1425
;        cmp     [eax+ebp],ebx
1426
	jg	@b		; direction
1427
	cmp	ebp,ecx
1428
	jge	@f		; direction
1429
      if Ext=NON
1430
	mov	esi,[trizdd+ecx]
1431
	mov	edi,[trizdd+ebp]
1432
	mov	[trizdd+ebp],esi
1433
	mov	[trizdd+ecx],edi
1434
	mov	edi,[trizdd+ecx-4]
1435
	mov	esi,[trizdd+ebp-4]
1436
	mov	[trizdd+ebp-4],edi
1437
	mov	[trizdd+ecx-4],esi
1438
      else
1439
;        movq    mm0,[eax+ecx-4]
1440
;        movq    mm1,[eax+ebp-4]
1441
;        movq    [eax+ebp-4],mm0
1442
;        movq    [eax+ecx-4],mm1
1443
	movq	mm0,[trizdq+ecx-4]
1444
	movq	mm1,[trizdq+ebp-4]
1445
	movq	[trizdq+ebp-4],mm0
1446
	movq	[trizdq+ecx-4],mm1
1447
      end if
1448
	jmp	.loop
1449
;        pop     eax
1450
      @@:
1451
      if Ext=NON
1452
	mov	esi,[trizdd+ecx]
1453
	mov	edi,[trizdd+eax+8]
1454
	mov	[trizdd+eax+8],esi
1455
	mov	[trizdd+ecx],edi
1456
	mov	edi,[trizdd+ecx-4]
1457
	mov	esi,[trizdd+eax+4]
1458
	mov	[trizdd+eax+4],edi
1459
	mov	[trizdd+ecx-4],esi
1460
      else
1461
;        push    edx
1462
;        mov     edx,[triangles_w_z_ptr]
1463
;        movq    mm0,[edx+ecx-4]
1464
;        movq    mm1,[edx+eax+4]; dir
1465
;        movq    [edx+eax+4],mm0; dir
1466
;        movq    [edx+ecx-4],mm1
1467
;        pop     edx
1468
1469
 
1470
	movq	mm1,[trizdq+eax+4]; dir
1471
	movq	[trizdq+eax+4],mm0; dir
1472
	movq	[trizdq+ecx-4],mm1
1473
      end if
1474
	add	ecx,8
1475
	push	ecx edx
1476
	mov	edx,ebp
1477
	call	quicksort
1478
	pop	edx eax
1479
	call	quicksort
1480
      .exit:
1481
    ret
1482
    insertsort:
1483
	mov	esi,eax
1484
      .start:
1485
	add	esi,8
1486
	cmp	esi,edx
1487
	ja	.exit
1488
	mov	ebx,[trizdd+esi]
1489
;        mov     ebx,[triangles_w_z_ptr]
1490
;        add     ebx,esi
1491
      if Ext=NON
1492
	mov	ecx,[trizdd+esi-4]
1493
      else
1494
;        push    ebx
1495
;        mov     ebx,[triangles_w_z_ptr]
1496
;        movq    mm1,[ebx+esi-4]
1497
	movq	mm1,[trizdq+esi-4]
1498
;        pop     ebx
1499
      end if
1500
	mov	edi,esi
1501
      @@:
1502
	cmp	edi,eax
1503
	jna	@f
1504
;        push    eax
1505
;        mov     eax,[triangles_w_z_ptr]
1506
;        cmp     [eax+edi-8],ebx
1507
;        pop     eax
1508
       cmp     [trizdd+edi-8],ebx
1509
	jg	@f		   ; direction
1510
      if Ext=NON
1511
	mov	ebp,[trizdd+edi-8]
1512
	mov	[trizdd+edi],ebp
1513
	mov	ebp,[trizdd+edi-12]
1514
	mov	[trizdd+edi-4],ebp
1515
      else
1516
;        push    eax
1517
;        mov     eax,[triangles_w_z_ptr]
1518
;        movq    mm0,[eax+edi-12]
1519
;        movq    [eax+edi-4],mm0
1520
	movq	mm0,[trizdq+edi-12]
1521
	movq	[trizdq+edi-4],mm0
1522
;        pop     eax
1523
      end if
1524
	sub	edi,8
1525
	jmp	@b
1526
      @@:
1527
      if Ext=NON
1528
	mov	[trizdd+edi],ebx
1529
	mov	[trizdd+edi-4],ecx
1530
      else
1531
;        push    eax
1532
;        mov     eax,[triangles_w_z_ptr]
1533
;        movq    [eax+edi-4],mm1
1534
	movq	[trizdq+edi-4],mm1
1535
;        pop     eax
1536
      end if
1537
	jmp	.start
1538
      .exit:
1539
    ret
1540
   end_sort:
1541
    ; translate triangles_with_z to sorted_triangles
1542
	mov	esi,triangles_with_z
1543
;        mov      esi,[triangles_w_z_ptr]
1544
      ;  mov     edi,sorted_triangles
1545
	mov	 edi,[triangles_ptr]
1546
    again_copy:
1547
      if Ext=NON
1548
	movsd
1549
	movsw
1550
	add	esi,2
1551
      else
1552
	movq	mm0,[esi]
1553
	movq	[edi],mm0
1554
	add	esi,8
1555
	add	edi,6
1556
      end if
1557
	cmp	dword[esi],-1
1558
	jne	again_copy
1559
;      if Ext=MMX
1560
;        emms
1561
;      end if
1562
	movsd  ; copy end mark too
1563
ret
1564
1565
 
1566
	mov	edi,screen
1567
	mov	ecx,SIZE_X*SIZE_Y*3/4
1568
	xor	eax,eax
1569
      if Ext=NON
1570
	rep	stosd
1571
      else
1572
	pxor	mm0,mm0
1573
      @@:
1574
	movq	[edi+00],mm0
1575
	movq	[edi+08],mm0
1576
	movq	[edi+16],mm0
1577
	movq	[edi+24],mm0
1578
	add	edi,32
1579
	sub	ecx,8
1580
	jnc	@b
1581
      end if
1582
ret
1583
1584
 
1585
 
1586
	mov esi,[triangles_ptr]
1587
    .again_dts:
1588
	mov ebp,[points_translated_ptr]
1589
      if Ext=NON
1590
	movzx	eax,word[esi]
1591
	mov	[point_index1],ax
1592
	lea	eax,[eax*3]
1593
	add	eax,eax
1594
	push	ebp
1595
	add	ebp,eax
1596
	mov	eax,[ebp]
1597
	mov	dword[xx1],eax
1598
	mov	eax,[ebp+4]
1599
	mov	[zz1],ax
1600
	pop	ebp
1601
1602
 
1603
 
1604
	mov	[point_index2],ax
1605
	lea	eax,[eax*3]
1606
	add	eax,eax
1607
	push	ebp
1608
	add	ebp,eax
1609
	mov	eax,[ebp]
1610
	mov	dword[xx2],eax
1611
	mov	eax,[ebp+4]
1612
	mov	[zz2],ax
1613
	pop	ebp
1614
1615
 
1616
 
1617
	mov	[point_index3],ax
1618
	lea	eax,[eax*3]
1619
	add	eax,eax
1620
    ;    push    ebp
1621
	add	ebp,eax
1622
	mov	eax,[ebp]
1623
	mov	dword[xx3],eax
1624
	mov	eax,[ebp+4]
1625
	mov	[zz3],ax
1626
      else
1627
	mov	eax,dword[esi]		 ; don't know MMX
1628
	mov	dword[point_index1],eax
1629
       ; shr     eax,16
1630
       ; mov     [point_index2],ax
1631
	mov	ax,word[esi+4]
1632
	mov	[point_index3],ax
1633
	movq	mm0,[esi]
1634
	pmullw	mm0,qword[const6]
1635
	movd	eax,mm0
1636
	psrlq	mm0,16
1637
	movd	ebx,mm0
1638
	psrlq	mm0,16
1639
	movd	ecx,mm0
1640
	and	eax,0FFFFh
1641
	and	ebx,0FFFFh
1642
	and	ecx,0FFFFh
1643
	movq	mm0,[ebp+eax]
1644
	movq	mm1,[ebp+ebx]
1645
	movq	mm2,[ebp+ecx]
1646
	movq	qword[xx1],mm0
1647
	movq	qword[xx2],mm1
1648
	movq	qword[xx3],mm2
1649
;        emms
1650
      end if				  ; *********************************
1651
	push esi			  ;
1652
	fninit				  ; DO culling AT FIRST
1653
	cmp	[culling_flag],1	  ; (if culling_flag = 1)
1654
	jne	.no_culling
1655
	mov	esi,point_index1	  ; *********************************
1656
	mov	ecx,3			  ;
1657
      @@:
1658
	movzx	eax,word[esi]
1659
	lea	eax,[eax*3]
1660
	shl	eax,2
1661
	add	eax,[points_normals_rot_ptr]
1662
;        lea     eax,[eax+point_normals_rotated]
1663
	fld	dword[eax+8]		 ; *****************************
1664
	ftst				 ; CHECKING OF Z COOFICIENT OF
1665
	fstsw	ax			 ; NORMAL VECTOR
1666
	sahf
1667
	jb	@f
1668
	ffree	st
1669
	loop	@b
1670
	jmp	.end_draw   ; non visable
1671
      @@:
1672
	ffree	st  ;is visable
1673
      .no_culling:
1674
	cmp	[dr_flag],0		  ; draw type flag
1675
	je	.flat_draw
1676
	cmp	[dr_flag],2
1677
	je	.env_mapping
1678
	cmp	[dr_flag],3
1679
	je	.bump_mapping
1680
	cmp	[dr_flag],4
1681
	je	.tex_mapping
1682
	cmp	[dr_flag],5
1683
	je	.rainbow
1684
	cmp	[dr_flag],7
1685
	je	.grd_tex
1686
	cmp	[dr_flag],8
1687
	je	.two_tex
1688
	cmp	[dr_flag],9
1689
	je	.bump_tex
1690
	cmp	[dr_flag],10
1691
	je	.cubic_env_mapping
1692
				      ; ****************
1693
	mov	esi,point_index3      ; do Gouraud shading
1694
	mov	ecx,3
1695
      .again_grd_draw:
1696
	movzx	eax,word[esi]
1697
	shl	eax,2
1698
	lea	eax,[eax*3]
1699
	add	eax,[points_normals_rot_ptr]
1700
	; texture x=(rotated point normal -> x * 255)+255
1701
	fld	dword[eax]	 ; x cooficient of normal vector
1702
	fimul	[correct_tex]
1703
	fiadd	[correct_tex]
1704
	fistp	word[esp-2]
1705
	; texture y=(rotated point normal -> y * 255)+255
1706
	fld	dword[eax+4]	  ; y cooficient
1707
	fimul	[correct_tex]
1708
	fiadd	[correct_tex]
1709
	fistp	word[esp-4]
1710
1711
 
1712
	movzx	 ebx,word[esp-2]
1713
	shl	 eax,TEX_SHIFT
1714
	add	 eax,ebx
1715
	lea	 eax,[eax*3+color_map]
1716
	mov	 eax,dword[eax]
1717
	cmp	[catmull_flag],1      ; put on stack z coordinate if necessary
1718
	jne	 @f
1719
	lea	 edx,[ecx*3]
1720
	push	 word[edx*2+xx1-2]    ; zz1 ,2 ,3
1721
      @@:
1722
	ror	 eax,16 	      ; eax -0xxxrrggbb -> 0xggbbxxrr
1723
	xor	 ah,ah
1724
	push	 ax	    ;r
1725
	rol	 eax,8		      ; eax-0xggbb00rr -> 0xbb00rrgg
1726
	xor	 ah,ah
1727
	push	 ax	    ;g
1728
	shr	 eax,24
1729
	push	 ax	    ;b
1730
1731
 
1732
	dec	 cx
1733
	jnz	 .again_grd_draw
1734
	jmp	 .both_draw
1735
1736
 
1737
   ;     lea     edi,[edi*3]
1738
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
1739
   ;     mov     esi,light_vector
1740
   ;     call    dot_product
1741
   ;     fabs
1742
   ;     fimul   [orginal_color_r]
1743
   ;     fistp   [temp_col]
1744
   ;     and     [temp_col],0x00ff
1745
   ;     push    [temp_col]
1746
   ;     push    [temp_col]
1747
   ;     push    [temp_col]
1748
1749
 
1750
   ;     lea     edi,[edi*3]
1751
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
1752
   ;     mov     esi,light_vector
1753
   ;     call    dot_product
1754
   ;     fabs
1755
   ;     fimul   [orginal_color_r]
1756
   ;     fistp    [temp_col]
1757
   ;     and     [temp_col],0x00ff
1758
   ;     push    [temp_col]
1759
   ;     push    [temp_col]
1760
   ;     push    [temp_col]
1761
1762
 
1763
   ;     lea     edi,[edi*3]
1764
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
1765
   ;     mov     esi,light_vector
1766
   ;     call    dot_product
1767
   ;     fabs
1768
   ;     fimul   [orginal_color_r]
1769
   ;     fistp   [temp_col]
1770
   ;     and     [temp_col],0x00ff
1771
   ;     push    [temp_col]
1772
   ;     push    [temp_col]
1773
   ;     push    [temp_col]
1774
   .rainbow:
1775
	cmp	[catmull_flag],1      ; put on stack z coordinate if necessary
1776
	jne	 @f
1777
	push	 [zz3]
1778
      @@:
1779
	mov	 eax,dword[yy3]
1780
	mov	 ebx,0x00ff00ff
1781
	and	 eax,ebx
1782
	push	 eax
1783
	neg	 al
1784
	push	 ax
1785
	cmp	[catmull_flag],1
1786
	jne	 @f
1787
	push	 [zz2]
1788
      @@:
1789
	mov	 eax,dword[yy2]
1790
	and	 eax,ebx
1791
	push	 eax
1792
	neg	 al
1793
	push	 ax
1794
	cmp	[catmull_flag],1
1795
	jne	 @f
1796
	push	 [zz1]
1797
      @@:
1798
	mov	 eax,dword[yy1]
1799
	and	 eax,ebx
1800
	push	 eax
1801
	neg	 al
1802
	push	 ax
1803
    .both_draw:
1804
	mov	eax,dword[xx1]
1805
	ror	eax,16
1806
	mov	ebx,dword[xx2]
1807
	ror	ebx,16
1808
	mov	ecx,dword[xx3]
1809
	ror	ecx,16
1810
	lea	edi,[screen]
1811
	cmp	[catmull_flag],0
1812
	je	@f
1813
  ;      lea     esi,[Z_buffer]
1814
	mov	esi,[Zbuffer_ptr]
1815
	call	gouraud_triangle_z
1816
	jmp	.end_draw
1817
       @@:
1818
	call	gouraud_triangle
1819
	jmp	.end_draw
1820
1821
 
1822
				     ; FLAT DRAWING
1823
	movzx	eax,[point_index1]
1824
	movzx	ebx,[point_index2]
1825
	movzx	ecx,[point_index3]
1826
	shl	eax,2
1827
	shl	ebx,2
1828
	shl	ecx,2
1829
	lea	eax,[eax*3]  ;+point_normals_rotated]
1830
	add	eax,[points_normals_rot_ptr]
1831
	lea	ebx,[ebx*3]  ;+point_normals_rotated]
1832
	add	ebx,[points_normals_rot_ptr]
1833
	lea	ecx,[ecx*3]  ;+point_normals_rotated]
1834
	add	ecx,[points_normals_rot_ptr]
1835
	fld	dword[eax]	; x cooficient of normal vector
1836
	fadd	dword[ebx]
1837
	fadd	dword[ecx]
1838
	fidiv	[i3]
1839
	fimul	[correct_tex]
1840
	fiadd	[correct_tex]
1841
	fistp	dword[esp-4]	; x temp variables
1842
	fld	dword[eax+4]	; y cooficient of normal vector
1843
	fadd	dword[ebx+4]
1844
	fadd	dword[ecx+4]
1845
	fidiv	[i3]
1846
	fimul	[correct_tex]
1847
	fiadd	[correct_tex]
1848
	fistp	dword[esp-8]   ;  y
1849
	mov	edx,dword[esp-8]
1850
	shl	edx,TEX_SHIFT
1851
	add	edx,dword[esp-4]
1852
	lea	eax,[3*edx+color_map]
1853
	mov	edx,dword[eax]
1854
1855
 
1856
1857
 
1858
 
1859
 
1860
     ;   add     ax,[zz2]
1861
     ;   add     ax,[zz3]
1862
     ;   cwd
1863
     ;   idiv    [i3] ;    = -((a+b+c)/3+130)
1864
     ;   add     ax,130
1865
     ;   neg     al
1866
     ;   xor     edx,edx
1867
     ;   mov     ah,al           ;set color according to z position
1868
     ;   shl     eax,8
1869
     ;   mov     edx,eax
1870
1871
 
1872
	ror	eax,16
1873
	mov	ebx,dword[xx2]
1874
	ror	ebx,16
1875
	mov	ecx,dword[xx3]
1876
	ror	ecx,16
1877
       ; mov     edi,screen
1878
	lea	edi,[screen]
1879
	cmp	[catmull_flag],0
1880
	je	@f
1881
   ;     lea     esi,[Z_buffer]
1882
	mov	esi,[Zbuffer_ptr]
1883
	push	word[zz3]
1884
	push	word[zz2]
1885
	push	word[zz1]
1886
	call	flat_triangle_z
1887
	jmp	.end_draw
1888
      @@:
1889
	call	draw_triangle
1890
	jmp	.end_draw
1891
      .env_mapping:
1892
       ; fninit
1893
	cmp	[catmull_flag],0
1894
	je	@f
1895
	push	[zz3]
1896
	push	[zz2]
1897
	push	[zz1]
1898
      @@:
1899
	mov	esi,point_index1
1900
	sub	esp,12
1901
	mov	edi,esp
1902
	mov	ecx,3
1903
      @@:
1904
	movzx	eax,word[esi]
1905
	lea	eax,[eax*3]
1906
	shl	eax,2
1907
	add	eax,[points_normals_rot_ptr]	   ;point_normals_rotated
1908
; #
1909
;        fld     dword[eax]
1910
;        fmul    dword[eax+4]
1911
;        fld1
1912
;        fld1
1913
;        faddp
1914
;        fmulp
1915
;        fimul   [correct_tex]
1916
;        fiadd   [correct_tex]
1917
;        fistp   word[edi]
1918
;        mov     word[edi+2],0
1919
;;        fistp   word[edi+2]
1920
; # last change
1921
	; texture x=(rotated point normal -> x * 255)+255
1922
	fld	dword[eax]
1923
	fimul	[correct_tex]
1924
	fiadd	[correct_tex]
1925
	fistp	word[edi]
1926
	; texture y=(rotated point normal -> y * 255)+255
1927
	fld	dword[eax+4]
1928
	fimul	[correct_tex]
1929
	fiadd	[correct_tex]
1930
	fistp	word[edi+2]
1931
; # end of last ch.
1932
	add	edi,4
1933
	add	esi,2
1934
	loop	@b
1935
1936
 
1937
	ror	eax,16
1938
	mov	ebx,dword[xx2]
1939
	ror	ebx,16
1940
	mov	ecx,dword[xx3]
1941
	ror	ecx,16
1942
	mov	edi,screen
1943
	mov	esi,envmap
1944
	cmp	[catmull_flag],0
1945
	je	@f
1946
  ;      mov     edx,Z_buffer
1947
	mov	edx,[Zbuffer_ptr]
1948
	call	tex_triangle_z
1949
	jmp	.end_draw
1950
      @@:
1951
	call	tex_triangle
1952
	jmp	.end_draw
1953
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1954
     .cubic_env_mapping:
1955
       ; fninit
1956
	cmp	[catmull_flag],0
1957
	je	@f
1958
	push	[zz3]
1959
	push	[zz2]
1960
	push	[zz1]
1961
      @@:
1962
	mov	esi,point_index1
1963
	sub	esp,12
1964
	mov	edi,esp
1965
	mov	ecx,3
1966
      @@:
1967
	movzx	eax,word[esi]
1968
	lea	eax,[eax*3]
1969
	shl	eax,2
1970
	add	eax,[points_normals_rot_ptr]  ;point_normals_rotated
1971
; #
1972
	fld	dword[eax]
1973
	fmul	dword[eax+4]
1974
	fld1
1975
	fld1
1976
	faddp
1977
	fmulp
1978
	fimul	[correct_tex]
1979
	fiadd	[correct_tex]
1980
	fistp	word[edi]
1981
	mov	word[edi+2],0
1982
;        fistp   word[edi+2]
1983
; # last change
1984
;        ; texture x=(rotated point normal -> x * 255)+255
1985
;        fld     dword[eax]
1986
;        fimul   [correct_tex]
1987
;        fiadd   [correct_tex]
1988
;        fistp   word[edi]
1989
;        ; texture y=(rotated point normal -> y * 255)+255
1990
;        fld     dword[eax+4]
1991
;        fimul   [correct_tex]
1992
;        fiadd   [correct_tex]
1993
;        fistp   word[edi+2]
1994
; # end of last ch.
1995
	add	edi,4
1996
	add	esi,2
1997
	loop	@b
1998
1999
 
2000
	ror	eax,16
2001
	mov	ebx,dword[xx2]
2002
	ror	ebx,16
2003
	mov	ecx,dword[xx3]
2004
	ror	ecx,16
2005
	mov	edi,screen
2006
	mov	esi,envmap_cub
2007
	cmp	[catmull_flag],0
2008
	je	@f
2009
  ;      mov     edx,Z_buffer
2010
	mov	edx,[Zbuffer_ptr]
2011
	call	tex_triangle_z
2012
	jmp	.end_draw
2013
      @@:
2014
	call	tex_triangle
2015
	jmp	.end_draw
2016
2017
 
2018
2019
 
2020
	; fninit
2021
	cmp	[catmull_flag],0
2022
	je	@f
2023
;        push    Z_buffer
2024
	push	[Zbuffer_ptr]
2025
	push	[zz3]
2026
	push	[zz2]
2027
	push	[zz1]
2028
      @@:
2029
	mov	esi,point_index1
2030
	sub	esp,12
2031
	mov	edi,esp
2032
	mov	ecx,3
2033
      @@:
2034
	movzx	eax,word[esi]
2035
	lea	eax,[eax*3]
2036
	shl	eax,2
2037
	add	eax,[points_normals_rot_ptr]  ;point_normals_rotated
2038
	; texture x=(rotated point normal -> x * 255)+255
2039
	fld	dword[eax]
2040
	fimul	[correct_tex]
2041
	fiadd	[correct_tex]
2042
	fistp	word[edi]
2043
	; texture y=(rotated point normal -> y * 255)+255
2044
	fld	dword[eax+4]
2045
	fimul	[correct_tex]
2046
	fiadd	[correct_tex]
2047
	fistp	word[edi+2]
2048
2049
 
2050
	add	esi,2
2051
	loop	@b
2052
2053
 
2054
	shl    esi,2
2055
	add    esi,tex_points
2056
	push   dword[esi]
2057
	movzx  esi,[point_index2]
2058
	shl    esi,2
2059
	add    esi,tex_points
2060
;       lea    esi,[esi*3]
2061
;       lea    esi,[points+2+esi*2]
2062
	push   dword[esi]
2063
  ;     push   dword[xx2]
2064
	movzx  esi,[point_index1]
2065
	shl    esi,2
2066
	add    esi,tex_points
2067
;       lea     esi,[esi*3]
2068
;       lea     esi,[points+2+esi*2]
2069
	push   dword[esi]
2070
   ;    push     dword[xx1]
2071
2072
 
2073
	ror	eax,16
2074
	mov	ebx,dword[xx2]
2075
	ror	ebx,16
2076
	mov	ecx,dword[xx3]
2077
	ror	ecx,16
2078
	mov	edi,screen
2079
	mov	esi,envmap
2080
	mov	edx,bumpmap	       ;BUMP_MAPPING
2081
2082
 
2083
	je	@f
2084
	call	bump_triangle_z
2085
	jmp	.end_draw
2086
      @@:
2087
	call	bump_triangle
2088
	jmp	.end_draw
2089
2090
 
2091
2092
 
2093
	cmp	[catmull_flag],0
2094
	je	@f
2095
	push	[zz3]
2096
	push	[zz2]
2097
	push	[zz1]
2098
      @@:
2099
	movzx  esi,[point_index3]      ; tex map coords
2100
	shl    esi,2
2101
	add    esi,tex_points
2102
	push   dword[esi]
2103
	movzx  esi,[point_index2]
2104
	shl    esi,2
2105
	add    esi,tex_points
2106
	push   dword[esi]
2107
	movzx  esi,[point_index1]
2108
	shl    esi,2
2109
	add    esi,tex_points
2110
	push   dword[esi]
2111
2112
 
2113
	ror	eax,16
2114
	mov	ebx,dword[xx2]
2115
	ror	ebx,16
2116
	mov	ecx,dword[xx3]
2117
	ror	ecx,16
2118
	mov	edi,screen
2119
	mov	esi,texmap
2120
	cmp	[catmull_flag],0
2121
	je	@f
2122
   ;     mov     edx,Z_buffer
2123
	mov	edx,[Zbuffer_ptr]
2124
	call	tex_triangle_z
2125
 ;       call    tex_plus_grd_trianlgle
2126
	jmp	.end_draw
2127
      @@:
2128
	call	tex_triangle
2129
	jmp	.end_draw
2130
;      .ray:
2131
;        grd_triangle according to points index
2132
;        cmp     [catmull_flag],0
2133
;        je      @f
2134
;        push    [zz3]                   ; spot light with attenuation
2135
;     @@:
2136
;        movzx   eax,[point_index3]      ; env_map - points color list
2137
;        shl     eax,1                   ; each color as word, 0x00rr00gg00bb..
2138
;        lea     eax,[3*eax+bumpmap]
2139
;        push    word[eax]
2140
;        push    word[eax+2]
2141
;        push    word[eax+4]
2142
;        cmp     [catmull_flag],0
2143
;        je      @f
2144
;        push    [zz2]
2145
;    @@:
2146
;        movzx   eax,[point_index2]      ; env_map - points color list
2147
;        shl     eax,1                   ; each color as word, 0x00rr00gg00bb..
2148
;        lea     eax,[eax*3+bumpmap]
2149
;        push    word[eax]
2150
;        push    word[eax+2]
2151
;        push    word[eax+4]
2152
;        cmp     [catmull_flag],0
2153
;        je      @f
2154
;        push    [zz1]
2155
;     @@:
2156
;        movzx   eax,[point_index1]      ; env_map - points color list
2157
;        shl     eax,1                   ; each color as word, 0xrr00gg00bb00..
2158
;        lea     eax,[eax*3+bumpmap]
2159
;        push    word[eax]
2160
;        push    word[eax+2]
2161
;        push    word[eax+4]
2162
;        jmp     .both_draw
2163
2164
 
2165
	 push	ebp
2166
	 mov	ebp,esp
2167
	 sub	esp,4
2168
	 push	ebp
2169
2170
 
2171
	 shl	esi,2
2172
	 add	esi,tex_points
2173
	 push	dword[esi]		; texture coords as first
2174
	 movzx	esi,[point_index2]	; group of parameters
2175
	 shl	esi,2
2176
	 add	esi,tex_points
2177
	 push	dword[esi]
2178
	 movzx	esi,[point_index1]
2179
	 shl	esi,2
2180
	 add	esi,tex_points
2181
	 push	dword[esi]
2182
2183
 
2184
	 mov	 ecx,3
2185
2186
 
2187
2188
 
2189
	push	 word[edx*2+xx1-2]    ; zz1 ,2 ,3
2190
2191
 
2192
	shl	eax,2
2193
	lea	eax,[eax*3] ;+point_normals_rotated]
2194
	add	eax,[points_normals_rot_ptr]
2195
	; texture x=(rotated point normal -> x * 255)+255
2196
	fld	dword[eax]	 ; x cooficient of normal vector
2197
	fimul	[correct_tex]
2198
	fiadd	[correct_tex]
2199
	fistp	word[ebp-2]
2200
	; texture y=(rotated point normal -> y * 255)+255
2201
	fld	dword[eax+4]	  ; y cooficient
2202
	fimul	[correct_tex]
2203
	fiadd	[correct_tex]
2204
	fistp	word[ebp-4]
2205
2206
 
2207
	movzx	 ebx,word[ebp-2]
2208
	shl	 eax,TEX_SHIFT
2209
	add	 eax,ebx
2210
	lea	 eax,[eax*3+color_map]
2211
	mov	 eax,dword[eax]
2212
2213
 
2214
	xor	 ah,ah
2215
	push	 ax	    ;r
2216
	rol	 eax,8		      ; eax-0xggbb00rr -> 0xbb00rrgg
2217
	xor	 ah,ah
2218
	push	 ax	    ;g
2219
	shr	 eax,24
2220
	push	 ax	    ;b
2221
2222
 
2223
	dec	 cx
2224
	jnz	 .aagain_grd_draw
2225
2226
 
2227
	ror	eax,16
2228
	mov	ebx,dword[xx2]
2229
	ror	ebx,16
2230
	mov	ecx,dword[xx3]
2231
	ror	ecx,16
2232
	mov	edi,screen
2233
	mov	edx,texmap
2234
	mov	esi,[Zbuffer_ptr]
2235
2236
 
2237
2238
 
2239
	mov	esp,ebp
2240
	pop	ebp
2241
	jmp	.end_draw
2242
2243
 
2244
	push	[Zbuffer_ptr]
2245
2246
 
2247
	push	word[zz2]
2248
	push	word[zz1]
2249
2250
 
2251
	shl    esi,2
2252
	add    esi,tex_points
2253
	push   dword[esi]
2254
	movzx  esi,[point_index2]
2255
	shl    esi,2
2256
	add    esi,tex_points
2257
	push   dword[esi]
2258
	movzx  esi,[point_index1]
2259
	shl    esi,2
2260
	add    esi,tex_points
2261
	push   dword[esi]
2262
2263
 
2264
	sub	esp,12
2265
	mov	edi,esp
2266
	mov	ecx,3
2267
      @@:
2268
	movzx	eax,word[esi]
2269
	lea	eax,[eax*3]
2270
	shl	eax,2
2271
	add	eax,[points_normals_rot_ptr]
2272
	; texture x=(rotated point normal -> x * 255)+255
2273
	fld	dword[eax]
2274
	fimul	[correct_tex]
2275
	fiadd	[correct_tex]
2276
	fistp	word[edi]
2277
	; texture y=(rotated point normal -> y * 255)+255
2278
	fld	dword[eax+4]
2279
	fimul	[correct_tex]
2280
	fiadd	[correct_tex]
2281
	fistp	word[edi+2]
2282
2283
 
2284
	add	esi,2
2285
	loop	@b
2286
2287
 
2288
	ror	eax,16
2289
	mov	ebx,dword[xx2]
2290
	ror	ebx,16
2291
	mov	ecx,dword[xx3]
2292
	ror	ecx,16
2293
	mov	edi,screen
2294
	mov	esi,texmap
2295
	mov	edx,envmap
2296
2297
 
2298
	jmp	.end_draw
2299
2300
 
2301
	movzx  esi,[point_index3]      ; tex map coords
2302
	shl    esi,2
2303
	add    esi,tex_points
2304
	push   dword[esi]
2305
	movzx  esi,[point_index2]
2306
	shl    esi,2
2307
	add    esi,tex_points
2308
	push   dword[esi]
2309
	movzx  esi,[point_index1]
2310
	shl    esi,2
2311
	add    esi,tex_points
2312
	push   dword[esi]
2313
2314
 
2315
2316
 
2317
	xor   edi,edi
2318
2319
 
2320
	push	word[zz2]
2321
	push	word[zz1]
2322
2323
 
2324
	sub	esp,12
2325
	mov	edi,esp
2326
	mov	ecx,3
2327
      @@:
2328
	movzx	eax,word[esi]
2329
	lea	eax,[eax*3]
2330
	shl	eax,2
2331
	add	eax,[points_normals_rot_ptr]
2332
	; texture x=(rotated point normal -> x * 255)+255
2333
	fld	dword[eax]
2334
	fimul	[correct_tex]
2335
	fiadd	[correct_tex]
2336
	fistp	word[edi]
2337
	; texture y=(rotated point normal -> y * 255)+255
2338
	fld	dword[eax+4]
2339
	fimul	[correct_tex]
2340
	fiadd	[correct_tex]
2341
	fistp	word[edi+2]
2342
2343
 
2344
	add	esi,2
2345
	loop	@b
2346
2347
 
2348
;        push  dword 127 shl 16 + 1
2349
;        push  dword 127 shl 16 + 127
2350
2351
 
2352
	shl    esi,2
2353
	add    esi,tex_points
2354
	push   dword[esi]
2355
	movzx  esi,[point_index2]
2356
	shl    esi,2
2357
	add    esi,tex_points
2358
	push   dword[esi]
2359
2360
 
2361
	shl    esi,2
2362
	add    esi,tex_points
2363
	push   dword[esi]
2364
2365
 
2366
;        push  dword 127 shl 16 + 127
2367
;        push  dword 1 shl 16 + 1  ; bump coords
2368
2369
 
2370
	ror	eax,16
2371
	mov	ebx,dword[xx2]
2372
	ror	ebx,16
2373
	mov	ecx,dword[xx3]
2374
	ror	ecx,16
2375
	mov	edi,screen
2376
	mov	esi,envmap
2377
	mov	edx,bumpmap
2378
2379
 
2380
2381
 
2382
	pop	esi
2383
	add	esi,6
2384
	cmp	dword[esi],-1
2385
	jne	.again_dts
2386
ret
2387
2388
 
2389
 
2390
	mov	eax,0x70000000
2391
      ;  mov     edi,Z_buffer
2392
	mov	edi,[Zbuffer_ptr]
2393
	mov	ecx,SIZE_X*SIZE_Y
2394
	rep	stosd
2395
ret
2396
2397
 
2398
	fninit
2399
	mov	edi,[triangles_ptr]
2400
	xor	ebx,ebx
2401
	xor	ebp,ebp
2402
	mov	[points_count_var],0
2403
	mov	[triangles_count_var],0
2404
   if USE_LFN = 0
2405
	mov	esi,SourceFile
2406
   else
2407
	mov	esi,[fptr]
2408
   end if
2409
	cmp	[esi],word 4D4Dh
2410
	jne	.exit ;Must be legal .3DS file
2411
;        cmp     dword[esi+2],EndFile-SourceFile
2412
;        jne     .exit ;This must tell the length
2413
	mov	eax,dword[esi+2]
2414
  ;      cmp     eax,[fsize]
2415
  ;      jne     .exit
2416
2417
 
2418
	mov	[EndFile],eax	 ;
2419
2420
 
2421
      @@:
2422
	cmp	[esi],word 3D3Dh
2423
	je	@f
2424
	add	esi,[esi+2]
2425
	jmp	@b
2426
      @@:
2427
	add	esi,6
2428
      .find4k:
2429
	cmp	[esi],word 4000h
2430
	je	@f
2431
	add	esi,[esi+2]
2432
	cmp	esi,[EndFile]
2433
	jc	.find4k
2434
	jmp	.exit
2435
      @@:
2436
	add	esi,6
2437
      @@:
2438
	cmp	[esi],byte 0
2439
	je	@f
2440
	inc	esi
2441
	jmp	@b
2442
      @@:
2443
	inc	esi
2444
      @@:
2445
	cmp	[esi],word 4100h
2446
	je	@f
2447
	add	esi,[esi+2]
2448
	jmp	@b
2449
      @@:
2450
	add	esi,6
2451
      @@:
2452
	cmp	[esi],word 4110h
2453
	je	@f
2454
	add	esi,[esi+2]
2455
	jmp	@b
2456
      @@:
2457
	movzx	ecx,word[esi+6]
2458
	add	[points_count_var],cx
2459
2460
 
2461
	add	esi,8
2462
     @@:
2463
	push	edi
2464
	mov	edi,[points_ptr]
2465
	push	dword[esi+4]
2466
	pop	dword[edi+ebx*2+0]
2467
	push	dword[esi+8]
2468
	pop	dword[edi+ebx*2+4]
2469
	push	dword[esi+0]
2470
	pop	dword[edi+ebx*2+8]
2471
	pop	edi
2472
;        fld     dword[esi+4]
2473
;        fstp    dword[real_points+ebx*2+0]  ; x
2474
;        fld     dword[esi+8]
2475
;        fstp   dword[real_points+ebx*2+4]  ; y
2476
;        fld     dword[esi+0]
2477
;        fstp   dword[real_points+ebx*2+8]  ; z
2478
2479
 
2480
	add	esi,12
2481
	dec	ecx
2482
	jnz	@b
2483
      @@:
2484
  ;      mov     dword[points+ebx],-1
2485
	push	edi
2486
	mov	edi,[points_ptr]
2487
	mov	dword[edi+ebx*2],-1	   ; end mark (not always in use)
2488
	pop	edi
2489
      @@:
2490
	cmp	[esi],word 4120h
2491
	je	@f
2492
	add	esi,[esi+2]
2493
	jmp	@b
2494
      @@:
2495
	movzx	ecx,word[esi+6]
2496
	add	[triangles_count_var],cx
2497
	add	esi,8
2498
	;mov     edi,triangles
2499
      @@:
2500
	movsd
2501
	movsw
2502
	add	word[edi-6],bp
2503
	add	word[edi-4],bp
2504
	add	word[edi-2],bp
2505
	add	esi,2
2506
	dec	ecx
2507
	jnz	@b
2508
	add	ebp,edx
2509
	jmp	.find4k
2510
	mov	eax,-1 ;<---mark if OK
2511
      .exit:
2512
	mov	dword[edi],-1
2513
ret
2514
2515
 
2516
			      ; and  allocate memory
2517
	xor	ebx,ebx
2518
	xor	ebp,ebp
2519
	mov	[points_count_var],bx
2520
	mov	[triangles_count_var],bx
2521
   if USE_LFN = 0
2522
	mov	esi,SourceFile
2523
   else
2524
	mov	esi,[fptr]
2525
   end if
2526
2527
 
2528
	je	@f ;Must be legal .3DS file
2529
	xor	eax,eax
2530
	ret
2531
    @@:
2532
	mov	eax,dword[esi+2]
2533
	cmp	eax,[fsize] ;This must tell the length
2534
	je	@f
2535
	xor	eax,eax
2536
	ret
2537
     @@:
2538
	add	eax,esi
2539
	mov	[EndFile],eax	 ;
2540
2541
 
2542
      @@:
2543
	cmp	[esi],word 3D3Dh
2544
	je	@f
2545
	add	esi,[esi+2]
2546
	jmp	@b
2547
      @@:
2548
	add	esi,6
2549
      .find4k:
2550
	cmp	[esi],word 4000h
2551
	je	@f
2552
	add	esi,[esi+2]
2553
	cmp	esi,[EndFile]
2554
	jc	.find4k
2555
	jmp	.exit
2556
      @@:
2557
	add	esi,6
2558
      @@:
2559
	cmp	[esi],byte 0
2560
	je	@f
2561
	inc	esi
2562
	jmp	@b
2563
      @@:
2564
	inc	esi
2565
      @@:
2566
	cmp	[esi],word 4100h
2567
	je	@f
2568
	add	esi,[esi+2]
2569
	jmp	@b
2570
      @@:
2571
	add	esi,6
2572
      @@:
2573
	cmp	[esi],word 4110h
2574
	je	@f
2575
	add	esi,[esi+2]
2576
	jmp	@b
2577
      @@:
2578
	movzx	ecx,word[esi+6]
2579
	add	[points_count_var],cx
2580
2581
 
2582
	add	esi,8
2583
     @@:
2584
2585
 
2586
	add	esi,12
2587
     ;   dec     ecx
2588
	loop	 @b
2589
      @@:
2590
2591
 
2592
	cmp	[esi],word 4120h
2593
	je	@f
2594
	add	esi,[esi+2]
2595
	jmp	@b
2596
      @@:
2597
	movzx	ecx,word[esi+6]
2598
	add	[triangles_count_var],cx
2599
	add	esi,8
2600
2601
 
2602
	add	esi,8
2603
	dec	ecx
2604
	jnz	@b
2605
;        xor     ecx,ecx
2606
	add	ebp,edx
2607
	jmp	.find4k
2608
	mov	eax,-1 ;<---mark if OK
2609
      .exit:
2610
ret
2611
2612
 
2613
alloc_mem_for_tp:
2614
	mov	eax, 68
2615
	cmp	[re_alloc_flag],1
1776 yogev_ezra 2616
	jz	@f
2617
	mov	ebx, 12
1245 hidnplayr 2618
	jmp	.alloc
1776 yogev_ezra 2619
    @@:
2620
	mov	ebx,20
2621
    .alloc:
2622
	movzx	ecx, [triangles_count_var]
1245 hidnplayr 2623
	inc	ecx
2624
	lea	ecx, [ecx*3]
2625
	add	ecx, ecx
2626
	mov	edx,[triangles_ptr]
1776 yogev_ezra 2627
	int	0x40		       ;  -> allocate memory to triangles
1245 hidnplayr 2628
	mov	[triangles_ptr], eax   ;  -> eax = pointer to allocated mem
2629
2630
 
2631
;        mov     ebx, 12
2632
;        movzx   ecx, [triangles_count_var]
2633
;        shl     ecx, 4
2634
;        int     0x40
2635
;        mov     [triangles_w_z_ptr], eax   ; for trainagles_with_z list
2636
					    ; ststic  memory
2637
2638
 
2639
	movzx	ecx, [triangles_count_var]
2640
	lea	ecx, [3+ecx*3]
2641
	shl	ecx, 2
2642
	mov	edx,[triangles_normals_ptr]
1776 yogev_ezra 2643
	int	0x40			       ;  -> allocate memory for triangles normals
1245 hidnplayr 2644
	mov	[triangles_normals_ptr], eax   ;  -> eax = pointer to allocated mem
2645
2646
 
2647
	movzx	ecx, [points_count_var]
2648
	lea	ecx,[3+ecx*3]
2649
	shl	ecx, 2
2650
	mov	edx,[points_normals_ptr]
1776 yogev_ezra 2651
	int	0x40
1245 hidnplayr 2652
	mov	[points_normals_ptr], eax
2653
2654
 
2655
    ;    mov     ebx, 12
1776 yogev_ezra 2656
	movzx	ecx, [points_count_var]
1245 hidnplayr 2657
	lea	ecx,[3+ecx*3]
2658
	shl	ecx, 2
2659
	mov	edx,[points_normals_rot_ptr]
1776 yogev_ezra 2660
	int	0x40
1245 hidnplayr 2661
	mov	[points_normals_rot_ptr], eax
2662
2663
 
2664
	mov	edx,[points_ptr]
1776 yogev_ezra 2665
	int	0x40
1245 hidnplayr 2666
	mov	[points_ptr], eax
2667
2668
 
2669
	mov	edx,[points_rotated_ptr]
1776 yogev_ezra 2670
	int	0x40
1245 hidnplayr 2671
	mov	[points_rotated_ptr], eax
2672
2673
 
2674
	movzx	ecx, [points_count_var]
2675
	inc	ecx
2676
	shl	ecx, 3
2677
	mov	edx,[points_translated_ptr]
1776 yogev_ezra 2678
	int	0x40
1245 hidnplayr 2679
	mov	[points_translated_ptr], eax
2680
ret
2681
end if
2682
2683
 
2684
 
2685
if USE_LFN
2686
;-
2687
    mov     eax, 70
2688
    mov     ebx, file_info
2689
    mov     dword[ebx], 5	   ;  -> subfunction number
2690
    int     0x40		   ;  -> read file size
2691
    mov     ebx, [fptr]
2692
    mov     ebx, dword[ebx+32]
2693
    inc     ebx
2694
    mov     [fsize], ebx
2695
2696
 
2697
    mov     ebx, 11
2698
    int     0x40		   ;  -> create heap
2699
2700
 
2701
    mov     ebx, 12
2702
    mov     ecx, [fsize]
2703
    int     0x40		   ;  -> allocate memory for file
2704
    mov     [fptr], eax 	   ;  -> eax = pointer to allocated mem
2705
2706
 
2707
    mov     ebx, file_info
2708
    mov     dword[ebx],0
2709
    int     0x40		   ; -> read file
2710
2711
 
2712
2713
 
2714
    jnz     @f
2715
    xor     eax,eax	;;;;---
2716
  @@:
2717
else
2718
    mov      eax,58
2719
    mov      ebx,file_info
2720
    int      0x40
2721
2722
 
2723
    shr      eax,9
2724
    inc      eax
2725
    mov      [fsize],eax
2726
;    mov      ecx,ebx
2727
;    add      ecx,MEM_END
2728
;    mov      ebx,1
2729
;    mov      eax,64     ; allocate mem  - resize app mem
2730
			; for points and  triangles
2731
    int      0x40
2732
2733
 
2734
    mov      ebx,file_info
2735
    int      0x40
2736
end if
2737
  ;  eax = 0   -> ok file loaded
2738
ret
2739
read_param:
2740
    mov        esi,I_Param
2741
    cmp        dword[esi],0
2742
    je	       .end
2743
    cmp        byte[esi],'/'
2744
    je	       .copy
2745
    mov        edi,esi
2746
    mov        ecx,25	; 25 - would be enought
2747
    repe       scasb
2748
    jne        .end
2749
    dec        edi
2750
    mov        esi,edi
2751
 .copy:
2752
    mov 	edi,file_name
2753
    mov 	ecx,50
2754
    rep 	movsd
2755
 .end:
2756
ret
2757
buttons:				      ; draw some buttons (all but navigation and close )
2758
	mov	edi,menu
2759
      .again:
2760
	mov	eax,8			      ; function 8 : define and draw button
2761
	mov	ebx,(SIZE_X+10)*65536+62      ; [x start] *65536 + [x size]
2762
	movzx	ecx,byte[edi]		      ; button id = position+2
2763
	sub	cl,2
2764
	lea	ecx,[ecx*5]
2765
	lea	ecx,[ecx*3]
2766
	add	ecx,25
2767
	shl	ecx,16
2768
	add	ecx,12
2769
	movzx	edx,byte[edi]			; button id
2770
	mov	esi,0x6688dd			; button color RRGGBB
2771
	int	0x40
2772
	 ; BUTTON  LABEL
2773
	mov	eax,4				; function 4 : write text to window
2774
	movzx	ebx,byte[edi]
2775
	sub	bl,2				; button id, according to position
2776
	lea	ebx,[ebx*3]
2777
	lea	ebx,[ebx*5]
2778
	add	ebx,(SIZE_X+12)*65536+28	; [x start] *65536 + [y start]
2779
	mov	ecx,0x20ddeeff			; font 1 & color ( 0xF0RRGGBB )
2780
	lea	edx,[edi+1]			; pointer to text beginning
2781
	mov	esi,10				; text length
2782
	int	0x40
2783
	cmp	byte[edi+11],255		; if max_flag=255
2784
	je	@f				; skip
2785
	; flag description
2786
;       mov     eax,4                           ; function 4 : write text to window
2787
;       movzx   ebx,byte[edi]
2788
;       sub     bl,2
2789
;       lea     ebx,[ebx*3]
2790
;       lea     ebx,[ebx*5]
2791
;       add     ebx,(SIZE_X+12+70)*65536+28     ; [x start] *65536 + [y start]
2792
	add	ebx,70*65536
2793
;       mov     ecx,0x20ddeeff                  ; font 1 & color ( 0xF0RRGGBB )
2794
	movzx	edx,byte[edi+12]		; current flag
2795
	shl	edx,2				; * 4 = text length
2796
	add	edx,dword[edi+13]		; pointer to text beginning
2797
	mov	esi,4				; text length
2798
	int	0x40
2799
2800
 
2801
	add	edi,17
2802
	cmp	byte[edi],-1
2803
	jnz	.again
2804
ret
2805
;   *********************************************
2806
;   *******  WINDOW DEFINITIONS AND DRAW ********
2807
;   *********************************************
2808
    draw_window:
2809
	mov	eax,12		; function 12:tell os about windowdraw
2810
	mov	ebx,1		; 1, start of draw
2811
	int	0x40
2812
2813
 
2814
	mov	eax,0		; function 0 : define and draw window
2815
	mov	ebx,100*65536;+SIZE_X;+80+30 ; [x start] *65536 + [x size]
2816
	mov	ecx,100*65536;+SIZE_Y;+30    ; [y start] *65536 + [y size]
2817
	mov	bx,[size_x]
2818
	add	bx,114
2280 leency 2819
	mov	cx,[size_y]
1245 hidnplayr 2820
	add	cx,30
2821
	mov	edx,0x14000000	; color of work area RRGGBB,8->color gl
1776 yogev_ezra 2822
	mov	edi,labelt	; WINDOW LABEL
2024 leency 2823
	int	0x40
1245 hidnplayr 2824
2825
 
2826
2827
 
2828
2829
 
2830
	mov	eax,4		; function 4 : write text to window
2831
	mov	ebx,(SIZE_X+12)*65536+(168+15*(13+.Y_ADD))   ; [x start] *65536 + [y start]
2832
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
2833
	mov	edx,labelvector      ; pointer to text beginning
2834
	mov	esi,labelvectorend-labelvector	   ; text length
2835
    ;    cmp     [move_flag],2
2836
    ;    jne     @f
2837
    ;    add     edx,navigation_size
2838
    ;  @@:
2839
	int	0x40
2840
	 ; VECTOR Y- BUTTON
2841
	mov	eax,8		; function 8 : define and draw button
2842
	mov	ebx,(SIZE_X+30)*65536+20     ; [x start] *65536 + [x size]
2843
	mov	ecx,(165+15*(14+.Y_ADD))*65536+12  ; [y start] *65536 + [y size]
2844
	mov	edx,30		 ; button id
2845
	mov	esi,0x6688dd	; button color RRGGBB
2846
	int	0x40
2847
	;VECTOR Y- LABEL
2848
	mov	eax,4		; function 4 : write text to window
2849
	mov	ebx,(SIZE_X+32)*65536+(168+15*(14+.Y_ADD))   ; [x start] *65536 + [y start]
2850
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
2851
	mov	edx,labelyminus      ; pointer to text beginning
2852
	mov	esi,labelyminusend-labelyminus	   ; text length
2853
	cmp	[move_flag],2
2854
   ;     jne     @f
2855
   ;     add     edx,navigation_size
2856
   ;   @@:
2857
	int	0x40
2858
	; VECTOR Z+ BUTTON
2859
	mov	eax,8		; function 8 : define and draw button
2860
	mov	ebx,(SIZE_X+51)*65536+21     ; [x start] *65536 + [x size]
2861
	mov	ecx,(165+15*(14+.Y_ADD))*65536+12  ; [y start] *65536 + [y size]
2862
	mov	edx,31		 ; button id
2863
	mov	esi,0x6688dd	; button color RRGGBB
2864
	int	0x40
2865
	;VECTOR Z+ LABEL
2866
	mov	eax,4		; function 4 : write text to window
2867
	mov	ebx,(SIZE_X+53)*65536+(168+15*(14+.Y_ADD))   ; [x start] *65536 + [y start]
2868
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
2869
	mov	edx,labelzplus	    ; pointer to text beginning
2870
	mov	esi,labelzplusend-labelzplus	 ; text length
2871
   ;     cmp     [move_flag],2
2872
   ;     jne     @f
2873
   ;     add     edx,navigation_size
2874
   ;   @@:
2875
2876
 
2877
	; VECTOR x- BUTTON
2878
	mov	eax,8		; function 8 : define and draw button
2879
	mov	ebx,(SIZE_X+10)*65536+21     ; [x start] *65536 + [x size]
2880
	mov	ecx,(165+15*(15+.Y_ADD))*65536+12  ; [y start] *65536 + [y size]
2881
	mov	edx,32		 ; button id
2882
	mov	esi,0x6688dd	; button color RRGGBB
2883
	int	0x40
2884
	;VECTOR x- LABEL
2885
	mov	eax,4		; function 4 : write text to window
2886
	mov	ebx,(SIZE_X+12)*65536+(168+15*(15+.Y_ADD))   ; [x start] *65536 + [y start]
2887
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
2888
	mov	edx,labelxminus      ; pointer to text beginning
2889
	mov	esi,labelxminusend-labelxminus	   ; text length
2890
   ;     cmp     [move_flag],2
2891
   ;     jne     @f
2892
   ;     add     edx,navigation_size
2893
   ;   @@:
2894
	int	0x40
2895
	; VECTOR x+ BUTTON
2896
	mov	eax,8		; function 8 : define and draw button
2897
	mov	ebx,(SIZE_X+51)*65536+21     ; [x start] *65536 + [x size]
2898
	mov	ecx,(165+15*(15+.Y_ADD))*65536+12  ; [y start] *65536 + [y size]
2899
	mov	edx,33		 ; button id
2900
	mov	esi,0x6688dd	; button color RRGGBB
2901
	int	0x40
2902
	;VECTOR x+ LABEL
2903
	mov	eax,4		; function 4 : write text to window
2904
	mov	ebx,(SIZE_X+53)*65536+(168+15*(15+.Y_ADD))   ; [x start] *65536 + [y start]
2905
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
2906
	mov	edx,labelxplus	    ; pointer to text beginning
2907
	mov	esi,labelxplusend-labelxplus	 ; text length
2908
   ;     cmp     [move_flag],2
2909
   ;     jne     @f
2910
   ;     add     edx,navigation_size
2911
   ;   @@:
2912
	int	0x40
2913
	; VECTOR z- BUTTON
2914
	mov	eax,8		; function 8 : define and draw button
2915
	mov	ebx,(SIZE_X+10)*65536+62-41	; [x start] *65536 + [x size]
2916
	mov	ecx,(25+140+15*(16+.Y_ADD))*65536+12  ; [y start] *65536 + [y size]
2917
	mov	edx,34		 ; button id
2918
	mov	esi,0x6688dd	; button color RRGGBB
2919
	int	0x40
2920
	;VECTOR z- LABEL
2921
	mov	eax,4		; function 4 : write text to window
2922
	mov	ebx,(SIZE_X+12)*65536+(168+15*(16+.Y_ADD))   ; [x start] *65536 + [y start]
2923
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
2924
	mov	edx,labelzminus      ; pointer to text beginning
2925
	mov	esi,labelzminusend-labelzminus	   ; text length
2926
   ;     cmp     [move_flag],2
2927
   ;     jne     @f
2928
   ;     add     edx,navigation_size
2929
   ;   @@:
2930
	int	0x40
2931
       ;VECTOR Y+ BUTTON
2932
	mov	eax,8		; function 8 : define and draw button
2933
	mov	ebx,(SIZE_X+10+20)*65536+20	; [x start] *65536 + [x size]
2934
	mov	ecx,(165+15*(16+.Y_ADD))*65536+12  ; [y start] *65536 + [y size]
2935
	mov	edx,35		 ; button id
2936
	mov	esi,0x6688dd	; button color RRGGBB
2937
	int	0x40
2938
	;VECTOR Y+ LABEL
2939
	mov	eax,4		; function 4 : write text to window
2940
	mov	ebx,(SIZE_X+32)*65536+(168+15*(16+.Y_ADD))   ; [x start] *65536 + [y start]
2941
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
2942
	mov	edx,labelyplus	    ; pointer to text beginning
2943
	mov	esi,labelyplusend-labelyplus	 ; text length
2944
   ;     cmp     [move_flag],2
2945
   ;     jne     @f
2946
   ;     add     edx,navigation_size
2947
   ;   @@:
2948
	int	0x40
2949
2950
 
2951
	mov	ebx,2		; 2, end of draw
2952
	int	0x40
2953
	ret
2954
2955
 
2956
 
2957
2958
 
1979 yogev_ezra 2959
1245 hidnplayr 2960
 
2961