Subversion Repositories Kolibri OS

Rev

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

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