Subversion Repositories Kolibri OS

Rev

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

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