Subversion Repositories Kolibri OS

Rev

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

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