Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
180 heavyiron 1
use32
2
        db      'MENUET01'
3
        dd      1
4
        dd      start
5
        dd      i_end
6
memsize dd      mem
7
        dd      stacktop
474 diamond 8
        dd      0, app_path
180 heavyiron 9
 
10
include 'lang.inc'
11
include 'font.inc'
12
include 'sort.inc'
13
include 'kglobals.inc'
14
include 'dialogs.inc'
15
include 'viewer.inc'
314 diamond 16
include 'tools.inc'
474 diamond 17
include 'filetool.inc'
180 heavyiron 18
 
19
start:
474 diamond 20
        mov     edi, tolower_table
21
        push    'A'
22
        pop     ecx
23
        xor     eax, eax
24
@@:
25
        stosb
26
        inc     eax
27
        loop    @b
28
        add     al, 0x20
29
        mov     cl, 'Z'-'A'+1
30
@@:
31
        stosb
32
        inc     eax
33
        loop    @b
34
        sub     al, 0x20
35
        mov     cl, 'А'-'Z'-1
36
@@:
37
        stosb
38
        inc     eax
39
        loop    @b
40
        add     al, 0x20
41
        mov     cl, 'Р'-'А'
42
@@:
43
        stosb
44
        inc     eax
45
        loop    @b
46
        add     al, 0x30
47
        mov     cl, 'Я'-'Р'+1
48
@@:
49
        stosb
50
        inc     eax
51
        loop    @b
52
        sub     al, 0x50
53
        mov     cl, 256-'Я'-1
54
@@:
55
        stosb
56
        inc     eax
57
        loop    @b
58
        mov     byte [edi-256+'Ё'], 'ё'
59
        push    68
60
        pop     eax
61
        push    11
62
        pop     ebx
63
        int     0x40
283 diamond 64
        call    init_console
180 heavyiron 65
        call    draw_window
66
        push    66
67
        pop     eax
68
        push    1
69
        pop     ebx
70
        mov     ecx, ebx
71
        int     40h     ; set keyboard mode to scancodes
283 diamond 72
        mov     eax, 200
180 heavyiron 73
        mov     [panel1_nfa], eax
74
        mov     [panel2_nfa], eax
474 diamond 75
        mov     ecx, 200*4 + 32 + 200*304
76
        call    pgalloc
283 diamond 77
        mov     [panel1_files], eax
474 diamond 78
        call    pgalloc
283 diamond 79
        mov     [panel2_files], eax
80
        test    eax, eax
81
        jz      exit
82
        cmp     [panel1_files], eax
83
        jz      exit
180 heavyiron 84
        mov     [panel1_sortmode], 0    ; sort by name
85
        mov     [panel2_sortmode], 0
474 diamond 86
        push    2                       ; "средний" формат
87
        pop     eax
88
        mov     [panel1_colmode], eax
89
        mov     [panel2_colmode], eax
180 heavyiron 90
        mov     [num_screens], 1
474 diamond 91
        mov     ecx, 0x1000
92
        call    pgalloc
180 heavyiron 93
        mov     [screens], eax
314 diamond 94
        test    eax, eax
95
        jz      exit
180 heavyiron 96
        mov     ecx, panels_vtable
97
        mov     [eax], ecx
98
        mov     [active_screen_vtable], ecx
474 diamond 99
; load libini.obj and kfar.ini
100
        mov     eax, libini_name
101
        mov     esi, ini_import
102
        push    2
103
        pop     ebp     ; we use version 2 of libini
104
        call    load_dll_and_import
105
        test    eax, eax
106
        jnz     .noini
107
        mov     edi, app_path
108
        or      ecx, -1
109
        repnz   scasb
110
        mov     dword [edi-1], '.ini'
111
        mov     byte [edi+3], 0
112
        push    1
113
        push    dword aConfirmDelete
114
        push    dword aConfirmations
115
        push    dword app_path
116
        call    [ini.get_int]
117
        mov     [bConfirmDelete], al
118
        push    0
119
        push    dword aConfirmDeleteIncomplete
120
        push    dword aConfirmations
121
        push    dword app_path
122
        call    [ini.get_int]
123
        mov     [bConfirmDeleteIncomplete], al
124
        mov     ecx, 0x1000
125
        call    xpgalloc
126
        test    eax, eax
127
        jz      .skip_assoc
128
@@:
129
        mov     edx, eax
130
        push    edx ecx
131
        push    ecx
132
        push    edx
133
        push    dword aAssociations
134
        push    dword app_path
135
        call    [ini.query_sec]
136
        pop     ecx edx
137
        cmp     eax, ecx
138
        jbe     @f
139
        add     ecx, ecx
140
        call    xpgrealloc
141
        test    eax, eax
142
        jz      .skip_assoc
143
        jmp     @b
144
@@:
145
        cmp     ecx, 0x1000
146
        jbe     @f
147
        mov     ecx, eax
148
        call    xpgrealloc      ; must succeed, because we decrease size
149
        mov     edx, eax
150
@@:
151
        mov     [associations], edx
152
        xor     ebp, ebp
153
        xor     esi, esi
154
.skip_assoc:
155
        mov     edi, saved_file_name
156
        push    dword nullstr
157
        push    512
158
        push    edi
159
        push    dword aShortcut
160
        push    dword aFolderShortcuts
161
        push    dword app_path
162
        call    [ini.get_str]
163
        cmp     byte [edi], 0
164
        jz      .shortcut_cont
165
        or      ecx, -1
166
        xor     eax, eax
167
        repnz   scasb
168
        not     ecx
169
        cmp     ecx, 2
170
        jz      @f
171
        cmp     byte [edi-2], '/'
172
        jnz     @f
173
        mov     byte [edi-2], 0
174
        dec     ecx
175
@@:
176
        mov     al, [aShortcut.d]
177
        push    esi
178
        inc     esi
179
        mov     [FolderShortcuts+(eax-'0')*4], esi
180
        lea     esi, [esi+ecx-1]
181
        push    esi
182
        and     esi, 0xFFF
183
        cmp     esi, ecx
184
        pop     esi
185
        ja      .norealloc
186
        mov     edx, ebp
187
        mov     ecx, esi
188
        call    xpgrealloc
189
        test    eax, eax
190
        jnz     @f
191
        mov     edi, FolderShortcuts
192
        mov     ecx, 10
193
        rep     stosd
194
        jmp     .skip_shortcuts
195
@@:
196
        mov     ebp, eax
197
.norealloc:
198
        pop     edi
199
        add     edi, ebp
200
        mov     ecx, saved_file_name
201
@@:
202
        mov     al, [ecx]
203
        inc     ecx
204
        stosb
205
        test    al, al
206
        jnz     @b
207
.shortcut_cont:
208
        inc     [aShortcut.d]
209
        cmp     [aShortcut.d], '9'
210
        jbe     .skip_assoc
211
        mov     esi, FolderShortcuts
212
        mov     ecx, 10
213
        dec     ebp
214
.l3:
215
        lodsd
216
        test    eax, eax
217
        jz      @f
218
        add     [esi-4], ebp
219
@@:
220
        loop    .l3
221
.skip_shortcuts:
222
.noini:
223
        mov     esi, def_left_dir
224
        mov     edi, panel1_dir
225
@@:
226
        lodsb
227
        stosb
228
        test    al, al
229
        jnz     @b
230
        mov     esi, def_right_dir
231
        mov     edi, panel2_dir
232
@@:
233
        lodsb
234
        stosb
235
        test    al, al
236
        jnz     @b
180 heavyiron 237
        call    draw_keybar
238
        call    draw_cmdbar
314 diamond 239
        mov     [prev_dir], 0
180 heavyiron 240
        mov     ebp, panel1_data
474 diamond 241
        call    calc_colwidths
180 heavyiron 242
        call    read_folder
243
        call    draw_panel
314 diamond 244
        mov     [bSilentFolderMode], 1
180 heavyiron 245
        mov     ebp, panel2_data
474 diamond 246
        call    calc_colwidths
180 heavyiron 247
        call    read_folder
248
        call    draw_panel
249
event:
250
        push    10
251
        pop     eax
252
        int     40h
253
        dec     eax
254
        jz      redraw
255
        dec     eax
256
        jz      key
257
; button - we have only one button, close
258
exit:
259
        or      eax, -1
260
        int     40h
261
redraw:
283 diamond 262
; query kbd state from OS
263
        mov     al, 66
264
        push    3
265
        pop     ebx
266
        int     0x40
267
        and     eax, 0x3F
268
        cmp     al, [ctrlstate]
269
        mov     [ctrlstate], al
270
        jz      @f
271
        call    draw_keybar
272
@@:
180 heavyiron 273
        mov     al, 9
274
        mov     ebx, procinfo
275
        or      ecx, -1
276
        int     40h
277
; test if rolled up
278
; height of rolled up window is [skinh]+3
279
        mov     eax, [ebx+46]
280
        sub     eax, [skinh]
281
        cmp     eax, 5
282
        ja      @f
283
        mov     al, 12
284
        push    1
285
        pop     ebx
286
        int     0x40
287
        xor     eax, eax
288
; ebx, ecx, edi are ignored by function 0 after first redraw
314 diamond 289
        mov     edx, 0x53000000
180 heavyiron 290
        int     0x40
291
        mov     al, 12
292
        inc     ebx
293
        int     0x40
294
        jmp     event
295
@@:
296
        xor     ecx, ecx
297
        mov     eax, [ebx+42]
314 diamond 298
        mov     [wnd_width], eax
283 diamond 299
        sub     eax, 5*2-1
180 heavyiron 300
        jae     @f
301
        xor     eax, eax
302
@@:
303
        cdq
304
        mov     esi, font_width
305
        div     esi
306
        cmp     eax, 54
307
        jae     @f
308
        mov     al, 54
309
        mov     ch, 1
310
@@:
311
        cmp     eax, 255
312
        jbe     @f
313
        mov     eax, 255
314
        mov     ch, 1
315
@@:
316
        cmp     eax, [cur_width]
317
        mov     [cur_width], eax
318
        setnz   cl
319
        or      cl, ch
320
        test    edx, edx
314 diamond 321
        mov     [fill_width], edx
180 heavyiron 322
        setnz   ch
323
        mov     eax, [ebx+46]
314 diamond 324
        mov     [wnd_height], eax
180 heavyiron 325
        sub     eax, [skinh]
283 diamond 326
        sub     eax, 5-1
180 heavyiron 327
        jns     @f
328
        xor     eax, eax
329
@@:
330
        cdq
331
        mov     esi, font_height
332
        div     esi
333
        cmp     eax, 8
334
        jae     @f
335
        mov     al, 8
336
        mov     cl, 1
337
@@:
338
        cmp     eax, 255
339
        jbe     @f
340
        mov     eax, 255
341
        mov     cl, 1
342
@@:
314 diamond 343
        mov     [fill_height], edx
180 heavyiron 344
        cmp     eax, [cur_height]
345
        mov     [cur_height], eax
283 diamond 346
        jnz     .resize
347
        test    cl, cl
348
        jnz     .resize
349
        test    edx, edx
350
        setnz   cl
180 heavyiron 351
        or      cl, ch
352
        jz      @f
283 diamond 353
        test    byte [ebx+70], 1
354
        jnz     @f
355
.resize:
180 heavyiron 356
        push    67
357
        pop     eax
358
        or      ebx, -1
359
        or      ecx, -1
360
        mov     edx, [cur_width]
361
        imul    edx, font_width
283 diamond 362
        add     edx, 5*2-1
180 heavyiron 363
        mov     esi, [cur_height]
364
        imul    esi, font_height
365
        add     esi, [skinh]
283 diamond 366
        add     esi, 5-1
180 heavyiron 367
        int     40h
283 diamond 368
.resize_draw:
474 diamond 369
        mov     ecx, [MemForImage]
370
        call    pgfree
371
        and     [MemForImage], 0
283 diamond 372
        call    init_console
373
;        call    draw_window
180 heavyiron 374
        call    draw_keybar
375
        mov     ebp, [active_screen_data]
376
        mov     eax, [active_screen_vtable]
377
        call    dword [eax+screen_vtable.OnRedraw]
378
        jmp     event
379
@@:
380
        call    draw_window
381
        jmp     event
283 diamond 382
alt_f9:
383
        cmp     [saved_width], -1
384
        jz      @f
385
        mov     eax, [saved_width]
386
        mov     [cur_width], eax
387
        or      [saved_width], -1
388
        mov     eax, [saved_height]
389
        mov     [cur_height], eax
390
        or      [saved_height], -1
391
        jmp     redraw.resize
392
@@:
393
        push    48
394
        pop     eax
395
        push    5
396
        pop     ebx
397
        int     0x40
398
        push    eax
399
        sub     eax, [esp+2]
400
        inc     eax
401
        movzx   eax, ax
402
        sub     eax, 10
403
        xor     edx, edx
404
        mov     ecx, font_width
405
        div     ecx
406
        xchg    [cur_width], eax
407
        mov     [saved_width], eax
408
        mov     eax, ebx
409
        shr     ebx, 16
410
        sub     eax, ebx
411
        sub     eax, 5-1
412
        sub     eax, [skinh]
413
        xor     edx, edx
414
        mov     ecx, font_height
415
        div     ecx
416
        xchg    [cur_height], eax
417
        mov     [saved_height], eax
418
        mov     ecx, ebx
419
        pop     ebx
420
        shr     ebx, 16
421
        mov     edx, [cur_width]
422
        imul    edx, font_width
423
        add     edx, 5*2-1
424
        mov     esi, [cur_height]
425
        imul    esi, font_height
426
        add     esi, [skinh]
427
        add     esi, 4
428
        push    67
429
        pop     eax
430
        int     0x40
431
        jmp     redraw.resize_draw
180 heavyiron 432
key:
433
        mov     al, 2
434
        int     40h
435
        test    al, al
436
        jnz     event
437
        xchg    al, ah
438
        cmp     al, 0xE0
439
        jnz     @f
440
        mov     [bWasE0], 1
441
        jmp     event
442
@@:
443
        xchg    ah, [bWasE0]
444
        mov     ebp, [active_screen_data]
445
        mov     edx, [active_screen_vtable]
446
        cmp     al, 0x1D
447
        jz      .ctrl_down
448
        cmp     al, 0x9D
449
        jz      .ctrl_up
450
        cmp     al, 0x2A
451
        jz      .lshift_down
452
        cmp     al, 0xAA
453
        jz      .lshift_up
454
        cmp     al, 0x36
455
        jz      .rshift_down
456
        cmp     al, 0xB6
457
        jz      .rshift_up
458
        cmp     al, 0x38
459
        jz      .alt_down
460
        cmp     al, 0xB8
461
        jz      .alt_up
462
        call    [edx+screen_vtable.OnKey]
463
        jmp     event
464
.ctrl_down:
465
        test    ah, ah
466
        jnz     .rctrl_down
467
        or      [ctrlstate], 4
468
        jmp     .keybar
469
.rctrl_down:
470
        or      [ctrlstate], 8
471
        jmp     .keybar
472
.ctrl_up:
473
        test    ah, ah
474
        jnz     .rctrl_up
475
        and     [ctrlstate], not 4
476
        jmp     .keybar
477
.rctrl_up:
478
        and     [ctrlstate], not 8
479
.keybar:
480
        call    draw_keybar
481
        call    draw_image
482
@@:     jmp     event
483
.lshift_down:
484
; ignore E0 2A sequence
485
; e.g. arrow keys with NumLock on generate sequence E0 2A E0 xx / E0 xx+80 E0 AA
486
; where xx is scancode, so we can safely ignore E0 2A
487
        test    ah, ah
488
        jnz     @b
489
        or      [ctrlstate], 1
490
        jmp     .keybar
491
.lshift_up:
492
; ignore E0 AA sequence
493
        test    ah, ah
494
        jnz     @b
495
        and     [ctrlstate], not 1
496
        jmp     .keybar
497
.rshift_down:
498
        or      [ctrlstate], 2
499
        jmp     .keybar
500
.rshift_up:
501
        and     [ctrlstate], not 2
502
        jmp     .keybar
503
.alt_down:
504
        test    ah, ah
505
        jnz     .ralt_down
506
        or      [ctrlstate], 0x10
507
        jmp     .keybar
508
.ralt_down:
509
        or      [ctrlstate], 0x20
510
        jmp     .keybar
511
.alt_up:
512
        test    ah, ah
513
        jnz     .ralt_up
514
        and     [ctrlstate], not 0x10
515
        jmp     .keybar
516
.ralt_up:
517
        and     [ctrlstate], not 0x20
518
        jmp     .keybar
519
 
520
process_ctrl_keys:
521
        cmp     byte [esi], 0
522
        jz      .done
523
        push    ecx
524
        cmp     al, [esi]
525
        jz      .check
526
.cont:
527
        pop     ecx
528
        add     esi, 8
529
        jmp     process_ctrl_keys
530
.done:
531
        stc
532
        ret
533
.check:
534
        mov     cl, 0
535
        call    .check_ctrlkey
536
        jc      .cont
537
        mov     cl, 2
538
        call    .check_ctrlkey
539
        jc      .cont
540
        mov     cl, 4
541
        call    .check_ctrlkey
542
        jc      .cont
543
        pop     ecx
544
        call    dword [esi+4]
545
        clc
546
        ret
547
.check_ctrlkey:
548
        push    eax edx
549
        movzx   edx, [ctrlstate]
550
        shr     edx, cl
551
        add     cl, cl
552
        movzx   eax, word [esi+2]
553
        shr     eax, cl
554
        and     eax, 15
555
        cmp     al, ctrlkey_tests_num
556
        jae     .fail
557
        xchg    eax, edx
558
        and     al, 3
559
        call    [ctrlkey_tests + edx*4]
560
        cmp     al, 1
561
        pop     edx eax
562
        ret
563
.fail:
564
        stc
565
        pop     edx eax
566
        ret
567
 
568
ctrlkey_test0:
569
        test    al, al
570
        setz    al
571
        ret
572
ctrlkey_test1:
573
        test    al, al
574
        setnp   al
575
        ret
576
ctrlkey_test2:
577
        cmp     al, 3
578
        setz    al
579
        ret
580
ctrlkey_test3:
581
        cmp     al, 1
582
        setz    al
583
        ret
584
ctrlkey_test4:
585
        cmp     al, 2
586
        setz    al
587
        ret
588
 
589
new_screen:
474 diamond 590
; in: ecx=sizeof(screen data), edx->vtable
591
; out: ebp=pointer or NULL, eax!=0 if successful
592
; destroys ebx,ecx
593
        call    xpgalloc
180 heavyiron 594
        test    eax, eax
595
        jnz     @f
596
        ret
597
@@:
598
        mov     ebp, eax
599
        mov     eax, [screens]
474 diamond 600
        mov     ecx, [num_screens]
601
        inc     ecx
602
        shl     ecx, 3
603
        test    ecx, 0xFFF
604
        jnz     .norealloc
605
        push    edx
606
        mov     edx, eax
607
        call    xpgrealloc
608
        pop     edx
180 heavyiron 609
        test    eax, eax
610
        jnz     @f
474 diamond 611
        mov     ecx, ebp
612
        call    pgfree
180 heavyiron 613
        xor     eax, eax
614
        ret
615
@@:
616
        mov     [screens], eax
474 diamond 617
.norealloc:
180 heavyiron 618
        inc     [num_screens]
474 diamond 619
        mov     [eax+ecx-8], edx
620
        mov     [eax+ecx-4], ebp
180 heavyiron 621
        mov     eax, [num_screens]
622
        dec     eax
623
        mov     [active_screen], eax
624
        mov     [active_screen_vtable], edx
625
        mov     [active_screen_data], ebp
626
        jmp     draw_keybar
627
 
628
next_screen:
629
        mov     eax, [active_screen]
630
        inc     eax
631
        cmp     eax, [num_screens]
632
        jnz     @f
633
        xor     eax, eax
634
@@:     mov     [active_screen], eax
635
        jmp     change_screen
636
 
637
delete_active_screen:
638
        mov     edi, [screens]
639
        mov     eax, [active_screen]
640
        shl     eax, 3
641
        add     edi, eax
642
        push    dword [edi+4]
643
        lea     esi, [edi+8]
644
        mov     ecx, [num_screens]
645
        sub     ecx, [active_screen]
646
        dec     ecx
647
        add     ecx, ecx
648
        rep     movsd
649
        dec     [num_screens]
474 diamond 650
        mov     ecx, [num_screens]
651
        shl     ecx, 3
652
        test    ecx, 0xFFF
653
        jnz     .norealloc
654
        mov     edx, [screens]
655
        call    pgrealloc               ; must succeed, because we decrease size
656
        mov     [screens], eax
657
.norealloc:
658
        pop     ecx
659
        call    pgfree
180 heavyiron 660
        and     [active_screen], 0
661
 
662
change_screen:
663
        pusha
664
        mov     eax, [active_screen]
665
        mov     esi, [screens]
666
        mov     ebp, [esi+eax*8+4]
667
        mov     eax, [esi+eax*8]
668
        mov     [active_screen_vtable], eax
669
        mov     [active_screen_data], ebp
670
        call    draw_keybar
671
        call    [eax+screen_vtable.OnRedraw]
672
        popa
673
        ret
674
 
675
F12:
676
        mov     eax, [cur_width]
677
        add     eax, 8
678
        mov     esi, eax
679
        mul     [num_screens]
474 diamond 680
        mov     ecx, eax
681
        call    xpgalloc
180 heavyiron 682
        test    eax, eax
683
        jnz     @f
684
        ret
685
@@:
686
        mov     ebx, eax
687
        mov     edi, eax
688
        xor     ecx, ecx
689
.next:
690
        xor     eax, eax
691
        stosd
692
        inc     ecx
693
        cmp     ecx, [num_screens]
694
        jz      @f
695
        lea     eax, [edi+esi-4]
696
        mov     dword [edi-4], eax
697
@@:
698
        xor     eax, eax
699
        stosd
700
        dec     ecx
701
        jz      @f
702
        lea     eax, [edi-8]
703
        sub     eax, esi
704
        mov     dword [edi-4], eax
705
@@:
706
        mov     al, '&'
707
        stosb
708
        cmp     ecx, 36
709
        jae     .noletter
710
        lea     eax, [ecx+'0']
711
        cmp     al, '9'
712
        jbe     @f
713
        add     al, 7
714
@@:
715
        stosb
716
        mov     al, '.'
717
        stosb
718
        jmp     .letter_done
719
.noletter:
720
        mov     al, ' '
721
        stosb
722
        stosb
723
.letter_done:
724
        mov     al, ' '
725
        stosb
726
        pushad
727
        mov     eax, [screens]
728
        mov     ebp, [eax+ecx*8+4]
729
        mov     eax, [eax+ecx*8]
730
        mov     ecx, [cur_width]
731
        sub     ecx, 12
732
        call    [eax + screen_vtable.getname]
733
        popad
734
        sub     edi, 4
735
        add     edi, [cur_width]
736
        inc     ecx
737
        cmp     ecx, [num_screens]
738
        jb      .next
739
        mov     eax, [active_screen]
740
        mul     esi
741
        add     eax, ebx
742
        push    1
474 diamond 743
        push    dword aScreens
180 heavyiron 744
        push    eax
745
        call    menu
746
        cmp     eax, -1
747
        jz      @f
748
        sub     eax, ebx
749
        div     esi
750
        mov     [active_screen], eax
751
@@:
474 diamond 752
        mov     ecx, ebx
753
        call    pgfree
180 heavyiron 754
        jmp     change_screen
755
 
756
panels_OnKey:
757
        mov     ebp, [active_panel]
758
        mov     ecx, [ebp + panel1_index - panel1_data]
759
        mov     edx, [ebp + panel1_start - panel1_data]
760
        mov     ebx, [ebp + panel1_colst - panel1_data]
761
        add     ebx, edx
762
        mov     esi, panels_ctrlkeys
763
        jmp     process_ctrl_keys
764
.ret:
765
        ret
766
.up:
767
        jecxz   .ret
768
        dec     ecx
769
        mov     [ebp + panel1_index - panel1_data], ecx
770
        cmp     ecx, edx
771
        jae     .done_redraw
772
        mov     [ebp + panel1_start - panel1_data], ecx
773
.done_redraw:
774
;        call    draw_panel
775
;        ret
776
        jmp     draw_panel
474 diamond 777
.insert:
778
        lea     eax, [ecx*4]
779
        add     eax, [ebp + panel1_files - panel1_data]
780
        mov     eax, [eax]
781
        cmp     word [eax+40], '..'
782
        jnz     @f
783
        cmp     byte [eax+42], 0
784
        jz      .insert.down
785
@@:
786
        xor     byte [eax+303], 1
787
        mov     edx, [eax+32]
788
        test    byte [eax+303], 1
789
        mov     eax, [eax+36]
790
        jnz     .insert.increase
791
        sub     dword [ebp + panel1_selected_size - panel1_data], edx
792
        sbb     dword [ebp + panel1_selected_size+4 - panel1_data], eax
793
        dec     [ebp + panel1_selected_num - panel1_data]
794
        jmp     .insert.down
795
.insert.increase:
796
        add     dword [ebp + panel1_selected_size - panel1_data], edx
797
        adc     dword [ebp + panel1_selected_size+4 - panel1_data], eax
798
        inc     [ebp + panel1_selected_num - panel1_data]
799
.insert.down:
800
        inc     ecx
801
        cmp     ecx, [ebp + panel1_numfiles - panel1_data]
802
        jae     .done_redraw
803
        jmp     @f
180 heavyiron 804
.down:
805
        inc     ecx
806
        cmp     ecx, [ebp + panel1_numfiles - panel1_data]
807
        jae     .ret
474 diamond 808
@@:
180 heavyiron 809
        mov     [ebp + panel1_index - panel1_data], ecx
810
        cmp     ecx, ebx
811
        jb      .done_redraw
812
        sub     ecx, [ebp + panel1_colst - panel1_data]
813
        inc     ecx
814
        mov     [ebp + panel1_start - panel1_data], ecx
815
        jmp     .done_redraw
816
.left:
474 diamond 817
        test    ecx, ecx
818
        jnz     @f
819
        ret
820
@@:
821
        mov     eax, [ebp + panel1_colsz - panel1_data]
822
        sub     ecx, eax
180 heavyiron 823
        jae     @f
824
        xor     ecx, ecx
825
@@:
826
        mov     [ebp + panel1_index - panel1_data], ecx
474 diamond 827
.finalize_left:
180 heavyiron 828
        cmp     ecx, edx
829
        jae     .done_redraw
474 diamond 830
        sub     edx, eax
180 heavyiron 831
        jae     @f
832
        xor     edx, edx
833
@@:
834
        mov     [ebp + panel1_start - panel1_data], edx
835
        jmp     .done_redraw
474 diamond 836
.pgup:
837
        mov     eax, [ebp + panel1_colst - panel1_data]
838
        dec     eax
839
        jnz     @f
840
        inc     eax
841
@@:
842
        test    ecx, ecx
843
        jnz     @f
844
        ret
845
@@:
846
        sub     ecx, eax
847
        jae     @f
848
        xor     ecx, ecx
849
@@:
850
        mov     [ebp + panel1_index - panel1_data], ecx
851
        dec     ecx
852
        jmp     .finalize_left
180 heavyiron 853
.right:
474 diamond 854
        mov     eax, [ebp + panel1_colsz - panel1_data]
855
        add     ecx, eax
180 heavyiron 856
        cmp     ecx, [ebp + panel1_numfiles - panel1_data]
857
        jb      @f
858
        mov     ecx, [ebp + panel1_numfiles - panel1_data]
859
        dec     ecx
860
@@:
861
        mov     [ebp + panel1_index - panel1_data], ecx
474 diamond 862
.finalize_right:
180 heavyiron 863
        cmp     ecx, ebx
864
        jb      .done_redraw
474 diamond 865
        add     ebx, eax
180 heavyiron 866
        cmp     ebx, [ebp + panel1_numfiles - panel1_data]
867
        jbe     @f
868
        mov     ebx, [ebp + panel1_numfiles - panel1_data]
869
@@:
870
        sub     ebx, [ebp + panel1_colst - panel1_data]
871
        jae     @f
872
        xor     ebx, ebx
873
@@:
874
        mov     [ebp + panel1_start - panel1_data], ebx
875
        jmp     .done_redraw
474 diamond 876
.pgdn:
877
        mov     eax, [ebp + panel1_colst - panel1_data]
878
        dec     eax
879
        jnz     @f
880
        inc     eax
881
@@:
882
        add     ecx, eax
883
        cmp     ecx, [ebp + panel1_numfiles - panel1_data]
884
        jb      @f
885
        mov     ecx, [ebp + panel1_numfiles - panel1_data]
886
        dec     ecx
887
@@:
888
        mov     [ebp + panel1_index - panel1_data], ecx
889
        inc     ecx
890
        jmp     .finalize_right
180 heavyiron 891
.tab:
892
        xor     [active_panel], panel1_data xor panel2_data
893
        call    draw_cmdbar
894
        call    draw_panel
895
        mov     ebp, [active_panel]
896
        jmp     .done_redraw
897
.home:
898
        and     [ebp + panel1_start - panel1_data], 0
899
        and     [ebp + panel1_index - panel1_data], 0
900
        jmp     .done_redraw
901
.end:
902
        mov     eax, [ebp + panel1_numfiles - panel1_data]
903
        dec     eax
904
        mov     [ebp + panel1_index - panel1_data], eax
905
        inc     eax
906
        sub     eax, [ebp + panel1_colst - panel1_data]
907
        jae     @f
908
        xor     eax, eax
909
@@:
910
        mov     [ebp + panel1_start - panel1_data], eax
911
        jmp     .done_redraw
912
.enter:
183 diamond 913
        call    get_curfile_folder_entry
180 heavyiron 914
        test    byte [ecx], 10h
915
        jnz     .enter_folder
283 diamond 916
        call    find_extension
917
        jc      .run_app
180 heavyiron 918
.run_association:
474 diamond 919
        cmp     byte [edi], 0
920
        jz      .l1
921
        cmp     byte [edi], ';'
922
        jnz     @f
923
.l1:
924
        ret
925
@@:
926
        mov     esi, edi
927
@@:
928
        lodsb
929
        test    al, al
930
        jz      @f
931
        cmp     al, ';'
932
        jnz     @b
933
        dec     esi
934
        mov     byte [esi], 0
935
        mov     [restore_semicolon], esi
936
@@:
283 diamond 937
.run_association2:
180 heavyiron 938
        mov     [execparams], execdata
474 diamond 939
        mov     [execptr], edi
180 heavyiron 940
        jmp     .dorun
941
.run_app:
942
        mov     [execptr], execdata
943
        and     [execparams], 0
944
.dorun:
945
        lea     esi, [ebp + panel1_dir - panel1_data]
946
        mov     edi, execdata
947
@@:
948
        lodsb
949
        test    al, al
950
        jz      @f
951
        stosb
321 diamond 952
        cmp     edi, execdataend-1
953
        jae     .bigfilename
180 heavyiron 954
        jmp     @b
955
@@:
956
        lea     esi, [ecx+40]
957
        mov     al, '/'
958
        stosb
959
@@:
960
        lodsb
961
        stosb
321 diamond 962
        cmp     edi, execdataend
963
        ja      .bigfilename
180 heavyiron 964
        test    al, al
965
        jnz     @b
283 diamond 966
; for fasm call - special handling, because
967
; 1) fasm command line convention is different : fasm infile,outfile[,path] rather than tinypad infile
968
; 2) fasm will probably create new file in directory, so we want to reload panel data
969
        xor     edx, edx
970
        cmp     [execparams], edx
971
        jz      .nofasm
474 diamond 972
        mov     esi, [execptr]
973
@@:
974
        lodsb
975
        test    al, al
976
        jnz     @b
977
        mov     eax, [esi-5]
978
        or      eax, 0x20202020
979
        cmp     eax, 'fasm'
283 diamond 980
        jnz     .nofasm
321 diamond 981
        cmp     edi, execdata+(execdataend-execdata)/2
982
        ja      .bigfilename
283 diamond 983
        mov     esi, execdata
984
@@:
985
        lodsb
986
        stosb
987
        test    al, al
988
        jnz     @b
989
        mov     byte [esi-1], ','
990
        inc     edx
991
; output file: no extension if input file has extension, '.bin' otherwise
992
        push    edi
993
@@:
994
        dec     edi
995
        cmp     byte [edi], '.'
996
        jz      .ptfound
997
        cmp     byte [edi], '/'
998
        jnz     @b
999
        pop     edi
321 diamond 1000
        cmp     edi, execdataend-4
1001
        ja      .bigfilename
283 diamond 1002
        mov     dword [edi-1], '.bin'
1003
        mov     byte [edi+3], 0
1004
        jmp     .nofasm
1005
.ptfound:
1006
        mov     byte [edi], 0
1007
        pop     edi
1008
.nofasm:
321 diamond 1009
        mov     ebx, execinfo
1010
; if command line is more than 256 symbols, the kernel will truncate it
1011
; we does not want this!
1012
; N.B. We know that command line is either NULL or execdata, which is always ASCIIZ string,
1013
;      but can be up to 1023 symbols
1014
        mov     esi, [ebx+8]
1015
        test    esi, esi
1016
        jz      .cmdlinelenok
1017
@@:
1018
        lodsb
1019
        test    al, al
1020
        jnz     @b
1021
        sub     esi, [ebx+8]
1022
        dec     esi
1023
        cmp     esi, 256
1024
        ja      .bigcmdline
1025
.cmdlinelenok:
180 heavyiron 1026
        push    70
1027
        pop     eax
1028
        int     40h
474 diamond 1029
        xor     esi, esi
1030
        xchg    esi, [restore_semicolon]
1031
        test    esi, esi
1032
        jz      @f
1033
        mov     byte [esi], ';'
1034
@@:
321 diamond 1035
        neg     eax
1036
        js      @f
474 diamond 1037
        push    dword aContinue
321 diamond 1038
        mov     esi, esp
1039
        call    get_error_msg
1040
        push    eax
474 diamond 1041
        push    dword aRunError
321 diamond 1042
        mov     eax, esp
1043
        push    esi
1044
        push    1
1045
        push    eax
1046
        push    2
1047
        push    -1
1048
        push    -1
474 diamond 1049
        push    dword aError
321 diamond 1050
        call    SayErr
1051
        add     esp, 3*4
1052
        ret
1053
@@:
283 diamond 1054
        test    edx, edx
1055
        jz      @f
1056
        push    5
1057
        pop     eax
1058
        push    20
1059
        pop     ebx
1060
        int     0x40
1061
        jmp     .ctrl_r
1062
@@:
180 heavyiron 1063
        ret
321 diamond 1064
.bigfilename3:
1065
        pop     esi
1066
.bigfilename2:
1067
        pop     esi
1068
.bigfilename:
1069
        mov     eax, aFileNameTooBig
474 diamond 1070
.l2:
1071
        xor     esi, esi
1072
        xchg    esi, [restore_semicolon]
1073
        test    esi, esi
1074
        jz      @f
1075
        mov     byte [esi], ';'
321 diamond 1076
@@:
474 diamond 1077
        push    dword aContinue
321 diamond 1078
        mov     esi, esp
1079
        push    eax
1080
        mov     eax, esp
1081
        push    esi
1082
        push    1
1083
        push    eax
1084
        push    1
1085
        push    -1
1086
        push    -1
474 diamond 1087
        push    dword aError
321 diamond 1088
        call    SayErr
1089
        add     esp, 2*4
1090
        ret
1091
.bigcmdline:
1092
        mov     eax, aCmdLineTooBig
474 diamond 1093
        jmp     .l2
321 diamond 1094
.bigfoldername2:
1095
        mov     byte [ecx], 0
1096
.bigfoldername:
1097
        mov     eax, aFolderNameTooBig
474 diamond 1098
        jmp     .l2
321 diamond 1099
.copytoself:
1100
        mov     eax, aCannotCopyToSelf
474 diamond 1101
        jmp     .l2
180 heavyiron 1102
.enter_folder:
1103
        lea     esi, [ecx+40]
1104
        cmp     word [esi], '..'
1105
        jnz     @f
1106
        cmp     byte [esi+2], 0
1107
        jz      .dotdot
1108
@@:
314 diamond 1109
        push    esi
1110
        lea     esi, [ebp + panel1_dir - panel1_data]
1111
        mov     edi, prev_dir
1112
@@:
1113
        lodsb
1114
        stosb
1115
        test    al, al
1116
        jnz     @b
1117
        lea     edi, [esi-1]
321 diamond 1118
        lea     edx, [ebp + panel1_dir - panel1_data + 1024]
1119
        cmp     esi, edx
314 diamond 1120
        pop     esi
321 diamond 1121
        jae     .bigfoldername
1122
        mov     ecx, edi
180 heavyiron 1123
        mov     al, '/'
1124
        cmp     [edi-1], al
1125
        jz      @f
1126
        stosb
1127
@@:
1128
        lodsb
321 diamond 1129
        cmp     edi, edx
1130
        jae     .bigfoldername2
180 heavyiron 1131
        stosb
1132
        test    al, al
1133
        jnz     @b
1134
.reread:
1135
        call    read_folder
1136
.done_cmdbar:
1137
        call    draw_cmdbar
1138
        jmp     .done_redraw
1139
.dotdot:
1140
        lea     edi, [ebp + panel1_dir - panel1_data]
1141
        mov     al, 0
1142
        or      ecx, -1
1143
        repnz   scasb
1144
        dec     edi
1145
        mov     al, '/'
1146
        std
1147
        repnz   scasb
1148
        cld
1149
        inc     edi
1150
        mov     byte [edi], 0
1151
        inc     edi
1152
        push    edi
1153
        call    read_folder
1154
        pop     edi
1155
        mov     edx, [ebp + panel1_files - panel1_data]
1156
        mov     ecx, [ebp + panel1_numfiles - panel1_data]
1157
.scanloop:
1158
        mov     esi, [edx]
321 diamond 1159
        add     esi, 40
180 heavyiron 1160
        push    esi edi
1161
@@:
1162
        lodsb
1163
        call    match_symbol
1164
        jnz     @f
1165
        inc     edi
1166
        test    al, al
1167
        jnz     @b
1168
@@:
1169
        pop     edi esi
1170
        jz      .scanfound
1171
        add     edx, 4
1172
        loop    .scanloop
1173
        jmp     .scandone
1174
.scanfound:
1175
        sub     edx, [ebp + panel1_files - panel1_data]
1176
        shr     edx, 2
1177
        mov     [ebp + panel1_index - panel1_data], edx
1178
        sub     edx, [ebp + panel1_colst - panel1_data]
1179
        jb      .scandone
1180
        inc     edx
1181
        mov     [ebp + panel1_start - panel1_data], edx
1182
.scandone:
1183
        jmp     .done_cmdbar
1184
.ctrl_f39:
1185
        sub     al, 0x3D
1186
        add     al, al
1187
        mov     ah, [ebp + panel1_sortmode - panel1_data]
1188
        and     ah, 0xFE
1189
        cmp     al, ah
1190
        jnz     @f
1191
        and     [ebp + panel1_sortmode - panel1_data], 1
1192
        or      al, [ebp + panel1_sortmode - panel1_data]
1193
        xor     al, 1
1194
@@:
1195
        mov     [ebp + panel1_sortmode - panel1_data], al
1196
        mov     eax, [ebp + panel1_index - panel1_data]
1197
        mov     ecx, [ebp + panel1_files - panel1_data]
1198
        push    dword [ecx+eax*4]
1199
        push    ecx
1200
        call    sort_files
1201
        pop     edi
1202
        pop     eax
1203
        or      ecx, -1
1204
        repnz   scasd
1205
        not     ecx
1206
        dec     ecx
1207
        mov     [ebp + panel1_index - panel1_data], ecx
1208
        sub     ecx, [ebp + panel1_start - panel1_data]
1209
        jb      .less_start
1210
        sub     ecx, [ebp + panel1_colst - panel1_data]
1211
        jae     .gr_end
1212
@@:     jmp     .done_redraw
1213
.less_start:
1214
        add     [ebp + panel1_start - panel1_data], ecx
1215
        jmp     @b
1216
.gr_end:
1217
        inc     ecx
1218
        add     [ebp + panel1_start - panel1_data], ecx
1219
        jmp     @b
1220
.alt_f12:
1221
        mov     ebp, panel1_data
1222
        cmp     al, 0x3B
1223
        jz      @f
1224
        mov     ebp, panel2_data
1225
@@:
1226
; get drives list
1227
        mov     ebx, dirinfo
1228
        mov     [ebx+dirinfo.size-dirinfo], 1
1229
        mov     [ebx+dirinfo.dirdata-dirinfo], driveinfo
1230
        mov     [ebx+dirinfo.name-dirinfo], tmpname
1231
        mov     byte [tmpname], '/'
474 diamond 1232
        xor     edx, edx
180 heavyiron 1233
        xor     ecx, ecx
1234
.drive_loop_e:
1235
        mov     byte [tmpname+1], 0
1236
        push    70
1237
        pop     eax
1238
        int     40h
1239
        mov     ebx, dirinfo
1240
        test    eax, eax
1241
        jnz     .drive_loop_e_done
1242
        mov     esi, driveinfo+32+40
1243
        mov     edi, tmpname+1
1244
@@:
1245
        lodsb
1246
        stosb
1247
        test    al, al
1248
        jnz     @b
1249
        push    [ebx+dirinfo.first-dirinfo]
1250
        and     [ebx+dirinfo.first-dirinfo], 0
1251
.drive_loop_i:
1252
        push    70
1253
        pop     eax
1254
        int     40h
1255
        mov     ebx, dirinfo
1256
        test    eax, eax
1257
        jnz     .drive_loop_i_done
474 diamond 1258
        add     ecx, 32+8
1259
        push    ecx
1260
        and     ecx, 0xFFF
1261
        cmp     ecx, 32+8
1262
        pop     ecx
1263
        ja      @f
1264
        call    xpgrealloc
1265
        mov     edx, eax
180 heavyiron 1266
        test    eax, eax
474 diamond 1267
        jnz     @f
1268
        pop     eax
1269
        ret
180 heavyiron 1270
@@:
474 diamond 1271
        lea     edi, [edx+ecx-32]
180 heavyiron 1272
        mov     esi, tmpname
1273
@@:
1274
        lodsb
1275
        test    al, al
1276
        jz      @f
1277
        stosb
1278
        jmp     @b
1279
@@:
1280
        mov     esi, driveinfo+32+40
1281
        mov     al, '/'
1282
        stosb
1283
@@:
1284
        lodsb
1285
        stosb
1286
        test    al, al
1287
        jnz     @b
1288
        inc     [ebx+dirinfo.first-dirinfo]
1289
        jmp     .drive_loop_i
1290
.drive_loop_i_done:
1291
        pop     [ebx+dirinfo.first-dirinfo]
1292
        inc     [ebx+dirinfo.first-dirinfo]
1293
        jmp     .drive_loop_e
1294
.drive_loop_e_done:
1295
        and     [ebx+dirinfo.first-dirinfo], 0
474 diamond 1296
        mov     edi, edx
1297
        xor     esi, esi
1298
        add     ecx, edx
1299
@@:
1300
        and     dword [edi], 0
1301
        mov     dword [edi+4], esi
1302
        mov     esi, edi
1303
        add     edi, 32+8
1304
        cmp     edi, ecx
1305
        jae     @f
1306
        mov     [esi], edi
1307
        jmp     @b
1308
@@:
1309
        mov     ecx, edx
180 heavyiron 1310
        lea     edi, [ebp + panel1_dir - panel1_data]
1311
.find_cur_drive_loop:
1312
        push    edi
1313
        lea     esi, [ecx+8]
1314
@@:
1315
        lodsb
1316
        test    al, al
1317
        jz      .cur_drive_found
1318
        call    match_symbol
1319
        jnz     @f
1320
        inc     edi
1321
        jmp     @b
1322
@@:
474 diamond 1323
        cmp     dword [ecx], 0
180 heavyiron 1324
        jz      @f
1325
        pop     edi
474 diamond 1326
        mov     ecx, [ecx]
180 heavyiron 1327
        jmp     .find_cur_drive_loop
1328
@@:
474 diamond 1329
        mov     ecx, edx
180 heavyiron 1330
.cur_drive_found:
1331
        pop     edi
1332
        push    1
1333
        push    aDrive
1334
        push    ecx
1335
        mov     eax, [ebp + panel1_height - panel1_data]
1336
        sub     eax, 2
1337
        jae     @f
1338
        add     eax, 2
1339
@@:
1340
        push    eax
1341
        push    [ebp + panel1_width - panel1_data]
1342
        push    [ebp + panel1_top - panel1_data]
1343
        push    [ebp + panel1_left - panel1_data]
1344
        call    menu_centered_in
1345
        cmp     eax, -1
1346
        jz      .ret2
1347
        lea     esi, [eax+8]
1348
        lea     edi, [ebp + panel1_dir - panel1_data]
314 diamond 1349
        push    ecx esi edi
1350
        mov     esi, edi
1351
        mov     edi, prev_dir
1352
        mov     ecx, 1024/4
1353
        rep     movsd
1354
        pop     edi esi ecx
180 heavyiron 1355
@@:
1356
        lodsb
1357
        stosb
1358
        test    al, al
1359
        jnz     @b
474 diamond 1360
        mov     ecx, edx
1361
        call    pgfree
180 heavyiron 1362
        call    read_folder
1363
        jmp     .done_redraw
283 diamond 1364
.shift_f5:
1365
        call    get_curfile_folder_entry
1366
        lea     esi, [ecx+40]
1367
        mov     edi, CopyDestEditBuf
1368
        mov     eax, CopyDestEditBuf.length
1369
        stosd
1370
        scasd
1371
        xor     eax, eax
1372
        stosd
1373
        mov     edx, edi
1374
@@:
1375
        lodsb
1376
        test    al, al
1377
        jz      .f5_common
1378
        stosb
1379
        jmp     @b
1380
.f5:
1381
        mov     edi, CopyDestEditBuf
1382
        mov     eax, CopyDestEditBuf.length
1383
        stosd
1384
        scasd
1385
        xor     eax, eax
1386
        stosd
1387
        mov     edx, edi
1388
        mov     esi, ebp
1389
        xor     esi, panel1_data xor panel2_data
1390
        add     esi, panel1_dir - panel1_data
1391
@@:
1392
        lodsb
1393
        test    al, al
1394
        jz      @f
321 diamond 1395
        cmp     edi, CopyDestEditBuf+12+511
1396
        jae     .bigfoldername
283 diamond 1397
        stosb
1398
        jmp     @b
1399
@@:
1400
        mov     al, '/'
1401
        stosb
1402
.f5_common:
1403
        mov     byte [edi], 0
1404
        sub     edi, edx
1405
        mov     [edx-8], edi
1406
        mov     edi, CopySourceTextBuf
1407
        mov     esi, aCopy1
1408
@@:
1409
        lodsb
1410
        test    al, al
1411
        jz      @f
1412
        stosb
1413
        jmp     @b
1414
@@:
1415
        call    get_curfile_folder_entry
1416
        lea     esi, [ecx+40]
1417
        lea     eax, [esi+1]
1418
@@:
1419
        inc     esi
1420
        cmp     byte [esi-1], 0
1421
        jnz     @b
1422
        sub     esi, eax
1423
        xchg    eax, esi
1424
        dec     esi
1425
        mov     edx, [cur_width]
1426
        sub     edx, 50
1427
        sub     eax, edx
1428
        jbe     @f
1429
        add     esi, eax
1430
        mov     al, '.'
1431
        stosb
1432
        stosb
1433
        stosb
1434
@@:
1435
        lodsb
1436
        test    al, al
1437
        jz      @f
1438
        stosb
1439
        jmp     @b
1440
@@:
1441
        mov     esi, aCopy2
1442
@@:
1443
        lodsb
1444
        stosb
1445
        test    al, al
1446
        jnz     @b
1447
        mov     ebx, copy_dlgdata
1448
        mov     eax, [cur_width]
1449
        sub     eax, 12
1450
        mov     [ebx + dlgtemplate.width], eax
1451
        dec     eax
1452
        dec     eax
1453
        mov     [ebx - copy_dlgdata + copy_dlgdata.width2], eax
1454
        mov     [ebx - copy_dlgdata + copy_dlgdata.width3], eax
1455
        shr     eax, 1
1456
        dec     eax
1457
        dec     eax
1458
        mov     [ebx - copy_dlgdata + copy_dlgdata.copy_x2], eax
1459
        sub     eax, aCopyLength-1
1460
        mov     [ebx - copy_dlgdata + copy_dlgdata.copy_x1], eax
1461
        add     eax, aCopyLength+3
1462
        mov     [ebx - copy_dlgdata + copy_dlgdata.cnl_x1], eax
1463
        add     eax, aCancelBLength - 1
1464
        mov     [ebx - copy_dlgdata + copy_dlgdata.cnl_x2], eax
1465
        mov     byte [ebx - copy_dlgdata + copy_dlgdata.flags0], 0xC
1466
        and     byte [ebx - copy_dlgdata + copy_dlgdata.flags1], not 4
1467
        and     byte [ebx - copy_dlgdata + copy_dlgdata.flags2], not 4
1468
        push    ebx
1469
        call    DialogBox
1470
        cmp     eax, copy_dlgdata.copy_btn
1471
        jnz     .ret2
1472
; Копируем
1473
        mov     esi, CopyDestEditBuf+12
1474
        mov     edi, esi
1475
        xor     eax, eax
1476
        or      ecx, -1
1477
        repnz   scasb
1478
        dec     edi
1479
        dec     edi
1480
        cmp     edi, esi
1481
        jb      .ret2
1482
        cmp     byte [edi], '/'
1483
        jnz     @f
1484
; Наличие/отсутствие заканчивающего слэша важно только для копирования папок
1485
        cmp     edi, esi
1486
        jz      @f
1487
        mov     byte [edi], 0
1488
        dec     edi
1489
@@:
1490
; Если путь не начинается со слэша, считаем его относительно текущей папки
1491
        cmp     byte [esi], '/'
1492
        jz      .copy_absolute_path
1493
        push    esi
1494
        push    edi
1495
        lea     edi, [ebp + panel1_dir - panel1_data]
1496
        or      ecx, -1
1497
        xor     eax, eax
1498
        repnz   scasb
1499
        not     ecx
1500
        pop     edi
321 diamond 1501
        push    edi
1502
        add     edi, ecx
1503
        cmp     edi, CopyDestEditBuf+12+513
1504
        pop     edi
1505
        jb      @f
1506
        pop     esi
1507
        jmp     .bigfilename
1508
@@:
283 diamond 1509
        lea     edx, [edi+2]
1510
        sub     edx, esi
1511
        lea     edi, [edi+ecx+1]
1512
        xchg    ecx, edx
1513
        std
1514
        lea     esi, [esi+ecx-1]
1515
        rep     movsb
1516
        cld
1517
        pop     edi
1518
        lea     esi, [ebp + panel1_dir - panel1_data]
1519
        push    edi
1520
        mov     ecx, edx
1521
        rep     movsb
1522
        mov     byte [edi-1], '/'
1523
        pop     esi
1524
.copy_absolute_path:
1525
; Получаем атрибуты назначения
1526
        mov     cl, 0x10
1527
        xor     eax, eax
1528
        mov     edi, esi
1529
.countslashloop:
1530
        cmp     byte [edi], '/'
1531
        jnz     @f
1532
        inc     eax
1533
@@:
1534
        inc     edi
1535
        cmp     byte [edi], 0
1536
        jnz     .countslashloop
1537
        cmp     eax, 2
1538
        jbe     @f
1539
        mov     ebx, attrinfo
1540
        mov     [attrinfo.attr], 0
1541
        mov     [ebx + attrinfo.name - attrinfo], esi
1542
        push    70
1543
        pop     eax
1544
        int     0x40
1545
        mov     cl, byte [attrinfo.attr]
1546
@@:
1547
        test    cl, 0x10
1548
        jz      .copyfile
1549
; Нам подсунули каталог назначения, дописываем имя файла
321 diamond 1550
        cmp     edi, CopyDestEditBuf+12+513
1551
        jae     .bigfilename
283 diamond 1552
        mov     al, '/'
1553
        stosb
1554
        push    esi
1555
        call    get_curfile_folder_entry
1556
        lea     esi, [ecx+40]
1557
@@:
1558
        lodsb
321 diamond 1559
        cmp     edi, CopyDestEditBuf+12+513
1560
        jae     .bigfilename2
283 diamond 1561
        stosb
1562
        test    al, al
1563
        jnz     @b
1564
        pop     esi
1565
.copyfile:
1566
; Имя исходного файла
1567
        push    esi
1568
        lea     esi, [ebp+panel1_dir-panel1_data]
1569
        mov     edi, saved_file_name
1570
        push    edi
1571
@@:
1572
        lodsb
1573
        test    al, al
1574
        jz      @f
1575
        stosb
1576
        jmp     @b
1577
@@:
1578
        mov     al, '/'
1579
        stosb
1580
        call    get_curfile_folder_entry
1581
        lea     esi, [ecx+40]
1582
@@:
1583
        lodsb
321 diamond 1584
        cmp     edi, saved_file_name+1024
1585
        jae     .bigfilename3
283 diamond 1586
        stosb
1587
        test    al, al
1588
        jnz     @b
1589
        pop     esi
1590
        pop     edi
1591
; Нельзя скопировать файл поверх самого себя!
1592
        push    esi edi
1593
        call    strcmpi
1594
        pop     edi esi
321 diamond 1595
        jz      .copytoself
283 diamond 1596
; Собственно, копируем
1597
; esi->source name, edi->destination name
1598
        mov     [writeinfo.code], 2
1599
        mov     [writeinfo.name], edi
1600
        and     dword [writeinfo.first], 0
1601
        and     dword [writeinfo.first+4], 0
1602
        mov     [writeinfo.data], copy_buffer
1603
        mov     ebx, readinfo
1604
        and     dword [ebx+readinfo.first-readinfo], 0
1605
        and     dword [ebx+readinfo.first+4-readinfo], 0
1606
        mov     [ebx+readinfo.size-readinfo], copy_buffer_size
1607
        mov     [ebx+readinfo.data-readinfo], copy_buffer
1608
        mov     [ebx+readinfo.name-readinfo], esi
1609
.copyloop:
1610
        mov     ebx, readinfo
1611
        push    70
1612
        pop     eax
1613
        int     0x40
321 diamond 1614
        test    eax, eax
1615
        jz      .copyreadok
1616
        cmp     eax, 6
1617
        jz      .copyreadok
1618
        push    esi
474 diamond 1619
        push    dword aCannotReadFile
321 diamond 1620
        call    get_error_msg
1621
        push    eax
1622
        mov     eax, esp
474 diamond 1623
        push    dword RetryOrCancelBtn
321 diamond 1624
        push    2
1625
        push    eax
1626
        push    3
1627
        push    -1
1628
        push    -1
474 diamond 1629
        push    dword aError
321 diamond 1630
        call    SayErr
1631
        add     esp, 3*4
1632
        test    eax, eax
1633
        jz      .copyloop
1634
        jmp     .copyfailed
1635
.copyreadok:
283 diamond 1636
        test    ebx, ebx
1637
        jz      .copydone
1638
        add     dword [readinfo.first], ebx
1639
        adc     dword [readinfo.first+4], 0
1640
        mov     [writeinfo.size], ebx
321 diamond 1641
.copywrite:
283 diamond 1642
        mov     ebx, writeinfo
1643
        push    70
1644
        pop     eax
1645
        int     0x40
321 diamond 1646
        test    eax, eax
1647
        jz      .copywriteok
1648
        push    edi
474 diamond 1649
        push    dword aCannotWriteFile
321 diamond 1650
        call    get_error_msg
1651
        push    eax
1652
        mov     eax, esp
474 diamond 1653
        push    dword RetryOrCancelBtn
321 diamond 1654
        push    2
1655
        push    eax
1656
        push    3
1657
        push    -1
1658
        push    -1
474 diamond 1659
        push    dword aError
321 diamond 1660
        call    SayErr
1661
        add     esp, 3*4
1662
        test    eax, eax
1663
        jz      .copywrite
1664
        jmp     .copyfailed
1665
.copywriteok:
283 diamond 1666
        mov     ecx, [writeinfo.size]
1667
        add     dword [writeinfo.first], ecx
1668
        adc     dword [writeinfo.first+4], 0
1669
        mov     [writeinfo.code], 3
1670
        cmp     ecx, copy_buffer_size
1671
        jz      .copyloop
1672
.copydone:
1673
        push    ebp
1674
        call    .ctrl_r
1675
        pop     ebp
1676
        xor     ebp, panel1_data xor panel2_data
1677
        jmp     .ctrl_r
321 diamond 1678
.copyfailed:
1679
        cmp     [bConfirmDeleteIncomplete], 0
1680
        jz      @f
1681
        cmp     [writeinfo.code], 2
1682
        jz      .copydone
474 diamond 1683
        push    dword aIncompleteFile
321 diamond 1684
        mov     eax, esp
474 diamond 1685
        push    dword DeleteOrKeepBtn
321 diamond 1686
        push    2
1687
        push    eax
1688
        push    1
1689
        push    -1
1690
        push    -1
474 diamond 1691
        push    dword aCopyCaption
321 diamond 1692
        call    SayErr
1693
        add     esp, 4
1694
        test    eax, eax
1695
        jnz     .copydone
1696
@@:
1697
        mov     ebx, delinfo
1698
        push    dword [ebx+21]
1699
        mov     dword [ebx+21], edi
1700
        push    70
1701
        pop     eax
1702
        int     0x40
1703
; ignore errors
1704
        pop     dword [delinfo+21]
1705
        jmp     .copydone
283 diamond 1706
 
180 heavyiron 1707
.f3:
1708
        call    view_file
1709
.ret2:
1710
        ret
474 diamond 1711
.f8_has_selected:
1712
        mov     edi, saved_file_name+511
1713
        mov     byte [edi], 0
1714
        mov     eax, [ebp + panel1_selected_num - panel1_data]
1715
if lang eq ru
1716
        cmp     eax, 1
1717
        jz      @f
1718
        dec     edi
1719
        mov     byte [edi], 'а'
1720
        cmp     eax, 4
1721
        jbe     @f
1722
        dec     edi
1723
        mov     word [edi], 'ов'
1724
@@:
1725
        mov     dword [edi-4], 'мент'
1726
        mov     dword [edi-8], ' эле'
1727
        sub     edi, 8
1728
else
1729
        cmp     eax, 1
1730
        jz      @f
1731
        dec     edi
1732
        mov     byte [edi], 's'
1733
@@:
1734
        mov     dword [edi-4], 'item'
1735
        mov     byte [edi-5], ' '
1736
        sub     edi, 5
1737
end if
1738
        xor     edx, edx
1739
        push    10
1740
        pop     ecx
1741
@@:
1742
        div     ecx
1743
        add     dl, '0'
1744
        dec     edi
1745
        mov     [edi], dl
1746
        xor     edx, edx
1747
        test    eax, eax
1748
        jnz     @b
1749
        push    edi
1750
        push    aConfirmDeleteText
1751
        mov     eax, esp
1752
        push    DeleteOrCancelBtn
1753
        push    2
1754
        push    eax
1755
        push    2
1756
        push    -1
1757
        push    -1
1758
        push    aDeleteCaption
1759
        call    Message
1760
        add     esp, 8
1761
        test    eax, eax
1762
        jnz     .ret2
1763
        mov     [del_bSkipAll], 0
1764
        mov     ecx, [ebp + panel1_numfiles - panel1_data]
1765
        jecxz   .ret2
1766
        mov     esi, [ebp + panel1_files - panel1_data]
1767
.f8_loop:
1768
        lodsd
1769
        test    byte [eax+303], 1
1770
        jz      @f
1771
        call    delete_file
1772
        ja      .f8_multiple_cancel
1773
@@:
1774
        loop    .f8_loop
1775
.f8_multiple_cancel:
1776
        jmp     .ctrl_r
180 heavyiron 1777
.f8:
474 diamond 1778
        cmp     [ebp + panel1_selected_num - panel1_data], 0
1779
        jnz     .f8_has_selected
183 diamond 1780
        call    get_curfile_folder_entry
1781
        cmp     [bConfirmDelete], 0
1782
        jz      .f8_allowed
474 diamond 1783
        lea     eax, [ecx+40]
1784
        push    eax
183 diamond 1785
        mov     esi, aConfirmDeleteText
1786
        mov     edi, aConfirmDeleteTextBuf
474 diamond 1787
        push    edi
183 diamond 1788
@@:
1789
        lodsb
1790
        stosb
1791
        test    al, al
1792
        jnz     @b
1793
        dec     edi
1794
        mov     esi, aDeleteFolder
1795
        test    byte [ecx], 10h
1796
        jnz     @f
1797
        mov     esi, aDeleteFile
1798
@@:
1799
        lodsb
1800
        stosb
1801
        test    al, al
1802
        jnz     @b
321 diamond 1803
        mov     eax, esp
474 diamond 1804
        push    DeleteOrCancelBtn
321 diamond 1805
        push    2
1806
        push    eax
474 diamond 1807
        push    2
321 diamond 1808
        push    -1
1809
        push    -1
474 diamond 1810
        push    aDeleteCaption
1811
        call    Message
1812
        add     esp, 8
321 diamond 1813
        test    eax, eax
474 diamond 1814
        jz      .f8_allowed
1815
        ret
1816
.f8_allowed:
1817
        mov     [del_bSkipAll], 0
1818
        mov     eax, ecx
1819
        call    delete_file
180 heavyiron 1820
.ctrl_r:
1821
; Rescan panel
1822
;       call    read_folder
1823
;       jmp     .done_redraw
1824
        mov     eax, [ebp + panel1_index - panel1_data]
1825
        push    eax
183 diamond 1826
        call    get_curfile_name
283 diamond 1827
        mov     esi, ecx
180 heavyiron 1828
        mov     edi, saved_file_name
1829
@@:
1830
        lodsb
1831
        stosb
1832
        test    al, al
1833
        jnz     @b
1834
        push    [ebp + panel1_start - panel1_data]
1835
        call    read_folder
1836
        pop     [ebp + panel1_start - panel1_data]
1837
        pop     [ebp + panel1_index - panel1_data]
1838
        or      eax, -1
1839
@@:
1840
        inc     eax
1841
        cmp     eax, [ebp + panel1_numfiles - panel1_data]
1842
        jae     .ctrl_r.notfound
1843
        mov     ecx, [ebp + panel1_files - panel1_data]
321 diamond 1844
        mov     esi, [ecx+eax*4]
1845
        add     esi, 40
180 heavyiron 1846
        mov     edi, saved_file_name
1847
        call    strcmpi
1848
        jnz     @b
1849
.ctrl_r.found:
1850
        mov     [ebp + panel1_index - panel1_data], eax
1851
.ctrl_r.notfound:
1852
        mov     eax, [ebp + panel1_numfiles - panel1_data]
1853
        dec     eax
1854
        cmp     [ebp + panel1_index - panel1_data], eax
1855
        jbe     @f
1856
        mov     [ebp + panel1_index - panel1_data], eax
1857
@@:
1858
        mov     eax, [ebp + panel1_index - panel1_data]
1859
        cmp     [ebp + panel1_start - panel1_data], eax
1860
        jbe     @f
1861
        mov     [ebp + panel1_start - panel1_data], eax
1862
@@:
1863
        inc     eax
1864
        sub     eax, [ebp + panel1_colst - panel1_data]
1865
        jae     @f
1866
        xor     eax, eax
1867
@@:
1868
        cmp     [ebp + panel1_start - panel1_data], eax
1869
        jae     @f
1870
        mov     [ebp + panel1_start - panel1_data], eax
1871
@@:
1872
        mov     eax, [ebp + panel1_numfiles - panel1_data]
1873
        sub     eax, [ebp + panel1_colst - panel1_data]
1874
        jbe     @f
1875
        cmp     [ebp + panel1_start - panel1_data], eax
1876
        jbe     @f
1877
        mov     [ebp + panel1_start - panel1_data], eax
1878
@@:
1879
        jmp     .done_redraw
283 diamond 1880
.menu:
1881
; display context menu
1882
; ignore folders
1883
        call    get_curfile_folder_entry
1884
        test    byte [ecx], 10h
1885
        jz      @f
1886
.menuret:
1887
        ret
1888
@@:
1889
        call    find_extension
1890
        jc      .menuret
1891
; known extension
474 diamond 1892
@@:
1893
        cmp     byte [edi], 0
283 diamond 1894
        jz      .menuret
474 diamond 1895
        cmp     byte [edi], ';'
1896
        jz      @f
1897
        inc     edi
1898
        jmp     @b
1899
@@:
1900
        inc     edi
1901
@@:
1902
        inc     edi
1903
        cmp     byte [edi-1], ' '
1904
        jz      @b
1905
        cmp     byte [edi-1], 9
1906
        jz      @b
1907
        dec     edi
1908
        cmp     byte [edi], 0
1909
        jz      .menuret
283 diamond 1910
        mov     ecx, esi
1911
@@:
1912
        inc     ecx
1913
        cmp     byte [ecx-1], 0
1914
        jnz     @b
1915
        sub     ecx, esi        ; ecx = длина имени файла+1 = длина заголовка+1
1916
        cmp     ecx, 15
1917
        jb      @f
1918
        mov     cl, 15
1919
@@:
1920
        xor     edx, edx
474 diamond 1921
        xor     ebp, ebp
1922
        push    edx
283 diamond 1923
.menucreateloop:
474 diamond 1924
        mov     eax, edi
1925
        xor     ebx, ebx
283 diamond 1926
@@:
474 diamond 1927
        cmp     byte [edi], ','
1928
        jz      @f
1929
        cmp     byte [edi], bl
1930
        jz      @f
1931
        inc     edi
1932
        jmp     @b
1933
@@:
1934
        xchg    bl, [edi]
1935
        pushad
1936
        push    nullstr
1937
        push    1024
1938
        push    saved_file_name
1939
        push    eax
1940
        push    aMenu
1941
        push    app_path
1942
        call    [ini.get_str]
1943
        popad
1944
        mov     [edi], bl
1945
        mov     eax, saved_file_name
1946
@@:
1947
        cmp     byte [eax], 0
1948
        jz      .menucreatecont
1949
        cmp     byte [eax], ','
1950
        jz      @f
283 diamond 1951
        inc     eax
474 diamond 1952
        jmp     @b
1953
@@:
1954
        mov     byte [eax], 0
1955
        push    eax
1956
        sub     eax, saved_file_name-1
283 diamond 1957
        cmp     eax, ecx
1958
        ja      @f
1959
        mov     eax, ecx
1960
@@:
474 diamond 1961
        xchg    eax, [esp]
1962
        inc     eax
1963
        push    eax
1964
@@:
1965
        inc     eax
1966
        cmp     byte [eax-1], 0
1967
        jnz     @b
1968
        sub     eax, [esp]
1969
        add     [esp+4], eax
1970
        pop     eax eax
1971
        add     eax, 8
1972
        add     ebp, eax
1973
        push    ebp
1974
        and     ebp, 0xFFF
1975
        cmp     ebp, eax
1976
        pop     ebp
1977
        ja      @f
1978
        push    eax
1979
        xchg    edx, [esp+4]
1980
        push    ecx
1981
        mov     ecx, ebp
1982
        call    xpgrealloc
1983
        pop     ecx
1984
        pop     edx
1985
        xchg    edx, [esp]
283 diamond 1986
        test    eax, eax
474 diamond 1987
        xchg    eax, [esp]
283 diamond 1988
        jz      .menucreated
474 diamond 1989
@@:
1990
        neg     eax
1991
        add     eax, ebp
1992
        add     eax, [esp]
1993
        and     dword [eax], 0
1994
        and     dword [eax+4], 0
283 diamond 1995
        test    edx, edx
1996
        jz      @f
474 diamond 1997
        sub     eax, [esp]
283 diamond 1998
        mov     [edx], eax
474 diamond 1999
        add     eax, [esp]
2000
        sub     edx, [esp]
2001
        mov     [eax+4], edx
283 diamond 2002
@@:
2003
        mov     edx, eax
474 diamond 2004
        push    esi edi
2005
        mov     esi, saved_file_name
283 diamond 2006
        lea     edi, [eax+8]
2007
@@:
2008
        lodsb
2009
        stosb
2010
        test    al, al
2011
        jnz     @b
474 diamond 2012
        push    esi
2013
        sub     esi, saved_file_name
283 diamond 2014
        sub     esi, ecx
2015
        jae     .menunoadd
2016
        neg     esi
2017
@@:
2018
        mov     byte [edi-1], ' '
2019
        stosb
2020
        dec     esi
2021
        jnz     @b
2022
.menunoadd:
2023
        pop     esi
474 diamond 2024
@@:
2025
        lodsb
2026
        stosb
2027
        test    al, al
2028
        jnz     @b
2029
        pop     edi esi
2030
.menucreatecont:
2031
        inc     edi
2032
        cmp     byte [edi-1], ','
2033
        jz      .menucreateloop
283 diamond 2034
.menucreated:
2035
        test    edx, edx
474 diamond 2036
        jz      .menuret_free
283 diamond 2037
        and     dword [edx], 0
474 diamond 2038
        pop     edx
2039
        mov     ecx, edx
2040
        add     [ecx], edx
283 diamond 2041
@@:
474 diamond 2042
        mov     ecx, [ecx]
2043
        cmp     dword [ecx], 0
283 diamond 2044
        jz      @f
474 diamond 2045
        add     [ecx], edx
2046
        add     [ecx+4], edx
283 diamond 2047
        jmp     @b
2048
@@:
474 diamond 2049
        add     [ecx+4], edx
2050
        push    edx
283 diamond 2051
        push    1
2052
        push    esi
2053
        push    edx
2054
        call    menu
2055
        cmp     eax, -1
474 diamond 2056
        jz      .menuret_free
2057
        lea     edi, [eax+8]
283 diamond 2058
@@:
474 diamond 2059
        inc     edi
2060
        cmp     byte [edi-1], 0
2061
        jnz     @b
2062
        mov     ebp, [active_panel]
283 diamond 2063
        call    get_curfile_folder_entry
474 diamond 2064
        call    .run_association2
2065
.menuret_free:
2066
        pop     ecx
2067
        jmp     pgfree
321 diamond 2068
.f7:
2069
        mov     dword [CopyDestEditBuf], CopyDestEditBuf.length
2070
        and     dword [CopyDestEditBuf+4], 0
2071
        and     dword [CopyDestEditBuf+8], 0
2072
        mov     byte [CopyDestEditBuf+12], 0
2073
        mov     ebx, mkdir_dlgdata
2074
        mov     eax, [cur_width]
2075
        sub     eax, 12
2076
        mov     [ebx + dlgtemplate.width], eax
2077
        dec     eax
2078
        dec     eax
2079
        mov     [ebx - mkdir_dlgdata + mkdir_dlgdata.width2], eax
2080
        shr     eax, 1
2081
        dec     eax
2082
        dec     eax
2083
        mov     [ebx - mkdir_dlgdata + mkdir_dlgdata.cont_x2], eax
2084
        sub     eax, a_ContinueLength-1
2085
        mov     [ebx - mkdir_dlgdata + mkdir_dlgdata.cont_x1], eax
2086
        add     eax, a_ContinueLength+3
2087
        mov     [ebx - mkdir_dlgdata + mkdir_dlgdata.cnl_x1], eax
2088
        add     eax, aCancelBLength - 1
2089
        mov     [ebx - mkdir_dlgdata + mkdir_dlgdata.cnl_x2], eax
2090
        mov     byte [ebx - mkdir_dlgdata + mkdir_dlgdata.flags0], 0xC
2091
        and     byte [ebx - mkdir_dlgdata + mkdir_dlgdata.flags1], not 4
2092
        and     byte [ebx - mkdir_dlgdata + mkdir_dlgdata.flags2], not 4
2093
        push    ebx
2094
        call    DialogBox
2095
        cmp     eax, mkdir_dlgdata.cont_btn
2096
        jnz     .ret2
2097
        mov     esi, CopyDestEditBuf+12
2098
        cmp     byte [esi], 0
2099
        jz      .ret2
2100
        cmp     byte [esi], '/'
2101
        jz      .mkdir_absolute_path
2102
        push    esi
2103
        lea     edi, [ebp + panel1_dir - panel1_data]
2104
        or      ecx, -1
2105
        xor     eax, eax
2106
        repnz   scasb
2107
        not     ecx
2108
        mov     edi, esi
2109
@@:
2110
        cmp     byte [edi+1], 0
2111
        jz      @f
2112
        inc     edi
2113
        jmp     @b
2114
@@:
2115
        push    edi
2116
        add     edi, ecx
2117
        cmp     edi, CopyDestEditBuf+12+513
2118
        pop     edi
2119
        jb      @f
2120
        pop     esi
2121
        jmp     .bigfilename
2122
@@:
2123
        lea     edx, [edi+2]
2124
        sub     edx, esi
2125
        lea     edi, [edi+ecx+1]
2126
        xchg    ecx, edx
2127
        std
2128
        lea     esi, [esi+ecx-1]
2129
        rep     movsb
2130
        cld
2131
        pop     edi
2132
        lea     esi, [ebp + panel1_dir - panel1_data]
2133
        push    edi
2134
        mov     ecx, edx
2135
        rep     movsb
2136
        mov     byte [edi-1], '/'
2137
        pop     esi
2138
.mkdir_absolute_path:
2139
.mkdir_retry:
2140
        push    70
2141
        pop     eax
2142
        mov     ebx, mkdirinfo
2143
        int     0x40
2144
        test    eax, eax
2145
        jz      @f
474 diamond 2146
        push    dword CopyDestEditBuf+12
2147
        push    dword aCannotMakeFolder
321 diamond 2148
        call    get_error_msg
2149
        push    eax
2150
        mov     eax, esp
474 diamond 2151
        push    dword RetryOrCancelBtn
321 diamond 2152
        push    2
2153
        push    eax
2154
        push    3
2155
        push    -1
2156
        push    -1
474 diamond 2157
        push    dword aError
321 diamond 2158
        call    SayErr
2159
        add     esp, 3*4
2160
        test    eax, eax
2161
        jz      .mkdir_retry
2162
@@:
2163
        jmp     .copydone
474 diamond 2164
.change_mode:
2165
        dec     eax
2166
        mov     [ebp + panel1_colmode - panel1_data], eax
2167
        call    calc_colwidths
2168
        jmp     draw_panel
2169
.quick_jump:
2170
        dec     eax
2171
        cmp     al, 10
2172
        jnz     @f
2173
        xor     eax, eax
2174
@@:
2175
        mov     eax, [FolderShortcuts+eax*4]
2176
        test    eax, eax
2177
        jnz     @f
2178
        ret
2179
@@:
2180
        lea     esi, [ebp + panel1_dir - panel1_data]
2181
        push    eax esi
2182
        mov     edi, prev_dir
2183
@@:
2184
        lodsb
2185
        stosb
2186
        test    al, al
2187
        jnz     @b
2188
        pop     edi esi
2189
@@:
2190
        lodsb
2191
        stosb
2192
        test    al, al
2193
        jnz     @b
2194
        jmp     .reread
2195
.greyplus:
2196
        push    0
2197
        mov     ecx, aSelect
2198
        jmp     @f
2199
.greyminus:
2200
        push    1
2201
        mov     ecx, aDeselect
2202
@@:
2203
        mov     eax, mark_dlgdata
2204
        mov     [eax+mark_dlgdata.title-mark_dlgdata], ecx
2205
        mov     [eax+mark_dlgdata.flags-mark_dlgdata], 0xC
2206
        mov     edi, enter_string_buf+12
2207
        mov     dword [edi-12], 512
2208
        mov     dword [edi-8], 1
2209
        and     dword [edi-4], 0
2210
        mov     word [edi], '*'
2211
        push    eax
2212
        call    DialogBox
2213
        inc     eax
2214
        jnz     @f
2215
.noselect:
2216
        pop     eax
2217
        ret
2218
@@:
2219
        xor     eax, eax
2220
        mov     esi, edi
2221
@@:
2222
        lodsb
2223
        mov     al, [tolower_table+eax]
2224
        mov     [esi-1], al
2225
        test    al, al
2226
        jnz     @b
2227
@@:
2228
        mov     ecx, [ebp + panel1_numfiles - panel1_data]
2229
        mov     ebx, [ebp + panel1_files - panel1_data]
2230
        jecxz   .noselect
2231
        mov     eax, [ebx]
2232
        cmp     word [eax+40], '..'
2233
        jnz     .selectloop
2234
        cmp     byte [eax+42], 0
2235
        jnz     .selectloop
2236
        dec     ecx
2237
        jz      .noselect
2238
        add     ebx, 4
2239
.selectloop:
2240
        xor     eax, eax
2241
        mov     esi, [ebx]
2242
        add     esi, 40
2243
        mov     edx, lower_file_name-1
2244
@@:
2245
        lodsb
2246
        inc     edx
2247
        mov     al, [tolower_table+eax]
2248
        mov     [edx], al
2249
        test    al, al
2250
        jnz     @b
2251
        mov     esi, lower_file_name
2252
        call    match_mask_rev_lowercase
2253
        jc      @f
2254
        mov     esi, [ebx]
2255
        mov     eax, [esi+32]
2256
        cmp     byte [esp], 0
2257
        jz      .doselect
2258
        test    byte [esi+303], 1
2259
        jz      @f
2260
        and     byte [esi+303], not 1
2261
        sub     dword [ebp + panel1_selected_size - panel1_data], eax
2262
        mov     eax, [esi+36]
2263
        sbb     dword [ebp + panel1_selected_size+4 - panel1_data], eax
2264
        dec     dword [ebp + panel1_selected_num - panel1_data]
2265
        jmp     @f
2266
.doselect:
2267
        test    byte [esi+303], 1
2268
        jnz     @f
2269
        or      byte [esi+303], 1
2270
        add     dword [ebp + panel1_selected_size - panel1_data], eax
2271
        mov     eax, [esi+36]
2272
        adc     dword [ebp + panel1_selected_size+4 - panel1_data], eax
2273
        inc     dword [ebp + panel1_selected_num - panel1_data]
2274
@@:
2275
        add     ebx, 4
2276
        dec     ecx
2277
        jnz     .selectloop
2278
        pop     eax
2279
        jmp     .done_redraw
180 heavyiron 2280
 
2281
panels_OnRedraw:
2282
        call    draw_cmdbar
2283
        mov     ebp, panel1_data
474 diamond 2284
        call    calc_colwidths
180 heavyiron 2285
        call    draw_panel
2286
        mov     ebp, panel2_data
474 diamond 2287
        call    calc_colwidths
180 heavyiron 2288
        call    draw_panel
2289
        ret
2290
 
2291
init_console:
474 diamond 2292
        mov     ecx, [console_data_ptr]
2293
        call    pgfree
283 diamond 2294
        mov     eax, [cur_width]
2295
        mul     [cur_height]
2296
        mov     ecx, eax
474 diamond 2297
        push    ecx
2298
        shl     ecx, 2
2299
        call    pgalloc
2300
        pop     ecx
283 diamond 2301
        test    eax, eax
2302
        jz      exit
2303
        mov     [console_data_ptr], eax
2304
        mov     edi, eax
180 heavyiron 2305
        mov     ax, 0720h
2306
        rep     stosw
283 diamond 2307
        mov     [panel1_left], ecx
2308
        mov     [panel1_top], ecx
2309
        mov     [panel2_top], ecx
180 heavyiron 2310
        mov     eax, [cur_width]
2311
        inc     eax
2312
        shr     eax, 1
2313
        mov     [panel1_width], eax
2314
        mov     [panel2_left], eax
2315
        sub     eax, [cur_width]
2316
        neg     eax
2317
        mov     [panel2_width], eax
2318
        mov     eax, [cur_height]
2319
        dec     eax
2320
        dec     eax
2321
        mov     [panel1_height], eax
2322
        mov     [panel2_height], eax
2323
        ret
2324
 
183 diamond 2325
get_curfile_folder_entry:
2326
        mov     ecx, [ebp + panel1_index - panel1_data]
321 diamond 2327
        shl     ecx, 2
183 diamond 2328
        add     ecx, [ebp + panel1_files - panel1_data]
321 diamond 2329
        mov     ecx, [ecx]
183 diamond 2330
        ret
2331
get_curfile_name:
2332
        call    get_curfile_folder_entry
2333
        add     ecx, 40
2334
        ret
2335
 
180 heavyiron 2336
panels_getname:
2337
if lang eq ru
2338
        mov     eax, 'Пане'
2339
        stosd
2340
        mov     eax, 'ли  '
2341
        stosd
2342
        mov     eax, '    '
2343
        stosd
2344
        stosb
2345
else
2346
        mov     eax, 'Pane'
2347
        stosd
2348
        mov     eax, 'ls  '
2349
        stosd
2350
        mov     eax, '    '
2351
        stosd
2352
        stosb
2353
end if
2354
        sub     ecx, 13
2355
        mov     ebp, [active_panel]
2356
        lea     esi, [ebp + panel1_dir - panel1_data]
2357
        push    3
2358
        pop     edx
2359
@@:
2360
        lodsb
2361
        stosb
2362
        dec     ecx
2363
        test    al, al
2364
        jz      @f
2365
        cmp     al, '/'
2366
        jnz     @b
2367
        dec     edx
2368
        jnz     @b
2369
@@:
2370
        test    al, al
2371
        jnz     @f
2372
        dec     esi
2373
        dec     edi
2374
@@:
2375
        push    esi
2376
@@:
2377
        lodsb
2378
        test    al, al
2379
        jnz     @b
2380
        dec     esi
2381
        mov     ebx, esi
2382
        sub     ebx, [esp]
2383
        dec     esi
2384
        push    esi
2385
        mov     esi, [ebp + panel1_index - panel1_data]
321 diamond 2386
        shl     esi, 2
2387
        add     esi, [ebp + panel1_files - panel1_data]
2388
        mov     esi, [esi]
2389
        add     esi, 40
180 heavyiron 2390
        push    esi
2391
@@:
2392
        lodsb
2393
        test    al, al
2394
        jnz     @b
2395
        add     ebx, esi
2396
        sub     ebx, [esp]
2397
        dec     esi
2398
        cmp     ebx, ecx
2399
        jbe     @f
2400
        mov     al, '.'
2401
        stosb
2402
        stosb
2403
        stosb
2404
        sub     ecx, 3
2405
        mov     ebx, ecx
2406
@@:
2407
        add     edi, ebx
2408
        inc     ecx
2409
        std
2410
@@:
2411
        movsb
2412
        dec     ecx
2413
        jz      .nodir
2414
        cmp     esi, [esp]
2415
        jae     @b
2416
        mov     al, '/'
2417
        stosb
2418
        dec     ecx
2419
        jz      .nodir
2420
        mov     esi, [esp+4]
2421
@@:
2422
        cmp     esi, [esp+8]
2423
        jb      .nodir
2424
        movsb
2425
        loop    @b
2426
.nodir:
2427
        cld
2428
        pop     eax
2429
        pop     eax
2430
        pop     eax
2431
        ret
2432
 
2433
draw_window:
2434
        push    12
2435
        pop     eax
2436
        push    1
2437
        pop     ebx
2438
        int     40h
2439
        mov     al, 48
2440
        mov     bl, 4
2441
        int     40h
2442
        mov     [skinh], eax
2443
        mov     ebx, [cur_width]
2444
        imul    ebx, font_width
283 diamond 2445
        add     ebx, 100*65536 + 5*2-1
180 heavyiron 2446
        mov     ecx, [cur_height]
2447
        imul    ecx, font_height
283 diamond 2448
        lea     ecx, [eax+ecx+5-1+100*65536]
180 heavyiron 2449
        xor     eax, eax
314 diamond 2450
        mov     edx, 0x53000000
180 heavyiron 2451
        mov     edi, header
2452
        int     40h
314 diamond 2453
        mov     al, 13
2454
        xor     edx, edx
2455
        cmp     [fill_width], 0
2456
        jz      @f
2457
        mov     ebx, [wnd_width]
2458
        sub     ebx, [fill_width]
2459
        sub     ebx, 5-1
2460
        shl     ebx, 16
2461
        mov     bx, word [fill_width]
2462
        mov     ecx, [skinh-2]
2463
        mov     cx, word [wnd_height]
2464
        sub     cx, word [skinh]
2465
        sub     cx, 5-1
2466
        int     0x40
2467
@@:
2468
        cmp     [fill_height], 0
2469
        jz      @f
2470
        xor     edx, edx
2471
        mov     ebx, 50000h
2472
        mov     bx, word [wnd_width]
2473
        sub     ebx, 9
2474
        mov     ecx, [wnd_height]
2475
        sub     ecx, [fill_height]
2476
        sub     ecx, 5-1
2477
        shl     ecx, 16
2478
        mov     cx, word [fill_height]
2479
        int     0x40
2480
@@:
283 diamond 2481
;        xor     ecx, ecx
2482
;        call    draw_image
474 diamond 2483
        mov     al, 65
2484
        mov     ebx, [MemForImage]
2485
        test    ebx, ebx
2486
        jz      @f
2487
        mov     ecx, [cur_width]
2488
        imul    ecx, font_width*10000h
2489
        mov     cx, word [cur_height]
2490
        imul    cx, font_height
2491
        mov     edx, [skinh]
2492
        add     edx, 5*10000h
2493
        mov     esi, 8
2494
        mov     edi, console_colors
2495
        xor     ebp, ebp
2496
        int     0x40
2497
@@:
283 diamond 2498
        mov     al, 12
180 heavyiron 2499
        push    2
2500
        pop     ebx
2501
        int     40h
2502
        ret
2503
 
2504
draw_image.nomem:
2505
        mov     al, 13
2506
        xor     edx, edx
2507
        mov     ebx, [cur_width]
2508
        imul    ebx, font_width
2509
        add     ebx, 5*65536
2510
        mov     ecx, [skinh-2]
2511
        mov     cx, word [cur_height]
2512
        imul    cx, font_height
2513
        int     40h
2514
        mov     al, 4
2515
        mov     ebx, 32*65536+32
2516
        mov     ecx, 0xFFFFFF
2517
        mov     edx, nomem_draw
2518
        push    nomem_draw.size
2519
        pop     esi
2520
        int     40h
2521
        ret
2522
 
2523
draw_image:
474 diamond 2524
        mov     [bMemForImageValidData], byte 1
2525
        cmp     [MemForImage], 0
2526
        jnz     .allocated
2527
; allocate memory for image
2528
        mov     ecx, [cur_width]
2529
        imul    ecx, [cur_height]
2530
        imul    ecx, font_width*font_height
2531
        call    pgalloc
2532
        test    eax, eax
2533
        jz      draw_image.nomem
2534
        mov     [MemForImage], eax
2535
        mov     [bMemForImageValidData], byte 0
2536
.allocated:
283 diamond 2537
        and     [max_x], 0
2538
        or      [min_x], -1
474 diamond 2539
        and     [max_y], 0
283 diamond 2540
        or      [min_y], -1
474 diamond 2541
        mov     eax, [cursor_y]
2542
        mul     [cur_width]
2543
        add     eax, [cursor_x]
2544
        add     eax, eax
2545
        add     eax, [console_data_ptr]
2546
        xchg    [cur_cursor_pos], eax
2547
        mov     [old_cursor_pos], eax
2548
        mov     edi, [MemForImage]
283 diamond 2549
        mov     esi, [console_data_ptr]
474 diamond 2550
        mov     ecx, [cur_height]
2551
.lh:
2552
        push    ecx
283 diamond 2553
        mov     ecx, [cur_width]
474 diamond 2554
.lw:
2555
        push    ecx
2556
        mov     eax, [cur_width]
2557
        imul    eax, [cur_height]
2558
        mov     ebx, [esi]
2559
        cmp     [bMemForImageValidData], 0
2560
        jz      @f
2561
        cmp     esi, [cur_cursor_pos]
2562
        jz      @f
2563
        cmp     esi, [old_cursor_pos]
2564
        jz      @f
2565
        cmp     bx, [eax*2+esi]
2566
        jnz     @f
2567
        inc     esi
2568
        inc     esi
2569
        jmp     .skip_symbol
283 diamond 2570
@@:
474 diamond 2571
        mov     [eax*2+esi], bx
2572
        cmp     ecx, [min_x]
283 diamond 2573
        ja      @f
474 diamond 2574
        mov     [min_x], ecx
283 diamond 2575
@@:
474 diamond 2576
        cmp     ecx, [max_x]
283 diamond 2577
        jb      @f
474 diamond 2578
        mov     [max_x], ecx
283 diamond 2579
@@:
474 diamond 2580
        mov     eax, [esp+4]
2581
        mov     [min_y], eax
2582
        cmp     eax, [max_y]
283 diamond 2583
        jb      @f
474 diamond 2584
        mov     [max_y], eax
283 diamond 2585
@@:
2586
        push    edi
474 diamond 2587
        xor     eax, eax
2588
        mov     al, [esi+1]
2589
        and     al, 0xF
2590
        mov     ebx, eax
2591
        mov     al, [esi+1]
2592
        shr     al, 4
2593
        mov     ebp, eax
283 diamond 2594
        sub     ebx, ebp
474 diamond 2595
        lodsb
2596
        inc     esi
180 heavyiron 2597
if font_width > 8
2598
        lea     edx, [eax+eax+font]
2599
else
2600
        lea     edx, [eax+font]
2601
end if
2602
.sh:
474 diamond 2603
        mov     ecx, [edx]
2604
repeat font_width
2605
        shr     ecx, 1
283 diamond 2606
        sbb     eax, eax
2607
        and     eax, ebx
2608
        add     eax, ebp
474 diamond 2609
        mov     [edi+%-1], al
2610
end repeat
2611
        mov     eax, [cur_width]
2612
;        imul    eax, font_width
2613
;        add     edi, eax
2614
if font_width = 6
2615
        lea     eax, [eax*2+eax]
2616
        lea     edi, [edi+eax*2]
2617
else if font_width = 7
2618
        lea     edi, [edi+eax*8]
2619
        sub     edi, eax
2620
else if font_width = 8
2621
        lea     edi, [edi+eax*8]
2622
else if font_width = 9
2623
        lea     edi, [edi+eax*8]
180 heavyiron 2624
        add     edi, eax
474 diamond 2625
else if font_width = 10
2626
        lea     eax, [eax*4+eax]
2627
        lea     edi, [edi+eax*2]
2628
else
2629
Unknown font_width value!
2630
end if
180 heavyiron 2631
if font_width > 8
2632
        add     edx, 256*2
474 diamond 2633
        cmp     edx, font+256*2*font_height
180 heavyiron 2634
else
2635
        add     edx, 256
474 diamond 2636
        cmp     edx, font+256*font_height
180 heavyiron 2637
end if
474 diamond 2638
        jb      .sh
283 diamond 2639
        pop     edi
2640
.skip_symbol:
2641
        pop     ecx
2642
        add     edi, font_width
2643
        dec     ecx
2644
        jnz     .lw
474 diamond 2645
        mov     eax, [cur_width]
283 diamond 2646
        imul    eax, (font_height-1)*font_width
180 heavyiron 2647
        add     edi, eax
474 diamond 2648
        pop     ecx
283 diamond 2649
        dec     ecx
2650
        jnz     .lh
2651
; cursor
2652
        mov     eax, [cursor_y]
2653
        inc     eax
2654
        jz      .nocursor
474 diamond 2655
        mul     [cur_width]
283 diamond 2656
        imul    eax, font_height*font_width
2657
        mov     edx, [cursor_x]
2658
        inc     edx
2659
        imul    edx, font_width
2660
        add     eax, edx
474 diamond 2661
        add     eax, [MemForImage]
2662
        mov     edx, [cur_width]
283 diamond 2663
        imul    edx, font_width
2664
        neg     edx
2665
        mov     ecx, (font_height*15+50)/100
2666
.cursor_loop:
2667
        push    ecx
2668
        mov     ecx, font_width
2669
        add     eax, edx
2670
        push    eax
2671
@@:
2672
;        add     byte [eax-1], 0x10
2673
        xor     byte [eax-1], 7
2674
        sub     eax, 1
2675
        loop    @b
2676
        pop     eax
180 heavyiron 2677
        pop     ecx
283 diamond 2678
        loop    .cursor_loop
2679
.nocursor:
474 diamond 2680
        cmp     [min_y], -1
2681
        jz      .nodraw
2682
        mov     ecx, [cur_width]
2683
        mov     ebx, [cur_height]
2684
        mov     eax, ebx
2685
        sub     ebx, [max_y]
2686
        sub     eax, [min_y]
2687
        sub     eax, ebx
2688
        inc     eax
2689
        imul    ebp, eax, font_height
2690
        mov     edx, ecx
2691
        sub     edx, [max_x]
283 diamond 2692
        imul    edx, font_width
474 diamond 2693
        mov     eax, edx
283 diamond 2694
        shl     edx, 16
474 diamond 2695
        imul    dx, bx, font_height
2696
        imul    ebx, [cur_width]
2697
        mov     ecx, [max_x]
2698
        sub     ecx, [min_x]
2699
        inc     ecx
2700
        imul    ecx, font_width*10000h
2701
        add     ecx, ebp
2702
        imul    ebx, font_width*font_height
2703
        add     ebx, [MemForImage]
2704
        add     ebx, eax
283 diamond 2705
        add     edx, [skinh]
474 diamond 2706
        add     edx, 5*10000h
2707
        imul    esi, [cur_width], font_width
2708
        mov     ebp, ecx
2709
        shr     ebp, 16
2710
        sub     esi, ebp
2711
        mov     ebp, esi
283 diamond 2712
        push    65
180 heavyiron 2713
        pop     eax
474 diamond 2714
        mov     edi, console_colors
283 diamond 2715
        push    8
2716
        pop     esi
474 diamond 2717
        int     40h
283 diamond 2718
.nodraw:
180 heavyiron 2719
        ret
2720
 
2721
get_console_ptr:
2722
; in: eax=x, edx=y
2723
; out: edi->console data
2724
        push    edx
2725
        imul    edx, [cur_width]
2726
        add     edx, eax
283 diamond 2727
        mov     edi, [console_data_ptr]
2728
        lea     edi, [edi + edx*2]
180 heavyiron 2729
        pop     edx
2730
        ret
2731
 
2732
draw_keybar:
2733
        pushad
2734
        xor     eax, eax
2735
        test    [ctrlstate], 3
2736
        jz      @f
2737
        inc     eax
2738
@@:
2739
        test    [ctrlstate], 0xC
2740
        jz      @f
2741
        or      al, 2
2742
@@:
2743
        test    [ctrlstate], 0x30
2744
        jz      @f
2745
        or      al, 4
2746
@@:
2747
        imul    eax, 6*12
2748
        mov     esi, [active_screen_vtable]
2749
        mov     esi, [esi+screen_vtable.keybar]
2750
        add     esi, eax
2751
        xor     ecx, ecx
2752
        inc     ecx
2753
        xor     eax, eax
2754
        mov     edx, [cur_height]
2755
        dec     edx
2756
        call    get_console_ptr
2757
        push    6
2758
        pop     ebx
2759
        mov     eax, [cur_width]
2760
        sub     eax, 11+9+3*2+6
2761
        cmp     eax, 7*11
2762
        jl      @f
2763
        cdq
2764
        mov     bl, 11
2765
        div     ebx
2766
        mov     ebx, eax
2767
@@:
2768
        xor     edx, edx
2769
.l:
2770
        add     edx, 7
2771
        cmp     cl, 10
2772
        jb      @f
2773
        inc     edx
2774
@@:
2775
        cmp     edx, [cur_width]
2776
        ja      .ret
2777
        cmp     cl, 10
2778
        jae     .twodig
2779
        lea     eax, [ecx+'0']
2780
        stosb
2781
        mov     al, [keybar_number_color]
2782
        stosb
2783
        jmp     .cmn
2784
.twodig:
2785
        mov     al, cl
2786
        cbw
2787
        div     [_10]
2788
        add     al, '0'
2789
        stosb
2790
        mov     al, [keybar_number_color]
2791
        stosb
2792
        xchg    al, ah
2793
        add     al, '0'
2794
        stosw
2795
.cmn:
2796
        mov     ah, [keybar_name_color]
2797
        push    ecx
2798
        mov     cl, 6
2799
@@:
2800
        lodsb
2801
        stosw
2802
        loop    @b
2803
        mov     al, ' '
2804
        lea     ecx, [ebx-6]
2805
        cmp     byte [esp], 12
2806
        jz      .ret_pop
2807
        add     edx, ecx
2808
        rep     stosw
2809
        pop     ecx
2810
        inc     edx
2811
        cmp     edx, [cur_width]
2812
        ja      .ret
2813
        mov     ah, [keybar_bgr_color]
2814
        stosw
2815
        inc     ecx
2816
        jmp     .l
2817
.ret_pop:
2818
        pop     ecx
2819
.ret:
2820
        cmp     byte [edi-2], ' '
2821
        jnz     @f
2822
        dec     edi
2823
        dec     edi
2824
@@:
2825
        push    edi
283 diamond 2826
        xor     eax, eax
180 heavyiron 2827
        mov     edx, [cur_height]
2828
        call    get_console_ptr
2829
        mov     ecx, edi
2830
        pop     edi
2831
        sub     ecx, edi
2832
        shr     ecx, 1
2833
        mov     al, ' '
2834
        mov     ah, [keybar_name_color]
2835
        rep     stosw
2836
.done:
2837
        popad
2838
        ret
2839
 
2840
draw_cmdbar:
2841
        mov     esi, [active_panel]
2842
        add     esi, panel1_dir - panel1_data
2843
        xor     eax, eax
2844
        mov     edx, [cur_height]
2845
        dec     edx
2846
        dec     edx
2847
        call    get_console_ptr
2848
        mov     ah, [cmdbar_prefix_color]
2849
        mov     ecx, [cur_width]
2850
        dec     ecx
2851
@@:
2852
        lodsb
2853
        test    al, al
2854
        jz      @f
2855
        stosw
2856
        loop    @b
2857
@@:
2858
        mov     al, '>'
2859
        stosw
2860
        mov     al, ' '
2861
        mov     ah, [cmdbar_normal_color]
2862
        rep     stosw
2863
        ret
2864
 
2865
draw_border:
2866
        push    edi
2867
        mov     al, 0xC9
2868
        stosw
2869
        mov     al, 0xCD
2870
        lea     ecx, [ebx-2]
2871
        rep     stosw
2872
        mov     al, 0xBB
2873
        stosw
2874
        pop     edi
2875
        add     edi, [cur_width]
2876
        add     edi, [cur_width]
2877
        lea     ecx, [edx-2]
2878
.l:
2879
        push    edi
2880
        mov     al, 0xBA
2881
        stosw
2882
        mov     al, 0x20
2883
        push    ecx
2884
        lea     ecx, [ebx-2]
2885
        rep     stosw
2886
        pop     ecx
2887
        mov     al, 0xBA
2888
        stosw
2889
        pop     edi
2890
        add     edi, [cur_width]
2891
        add     edi, [cur_width]
2892
        loop    .l
2893
        mov     al, 0xC8
2894
        stosw
2895
        mov     al, 0xCD
2896
        lea     ecx, [ebx-2]
2897
        rep     stosw
2898
        mov     al, 0xBC
2899
        stosw
2900
        ret
2901
 
474 diamond 2902
calc_colwidths:
2903
; in: ebp->panel data
2904
        imul    esi, [ebp + panel1_colmode - panel1_data], PanelMode.size
2905
        add     esi, colmodes
2906
        lodsd
2907
        mov     ecx, eax
2908
        lea     edx, [ecx-1]
2909
        xor     ebx, ebx
2910
        add     esi, PanelMode.ColumnWidths-4
2911
        push    ecx esi
2912
        xor     eax, eax
2913
.loop:
2914
        lodsb
2915
        add     edx, eax
2916
        cmp     al, 1
2917
        adc     ebx, 0
2918
        loop    .loop
2919
        pop     esi ecx
2920
        lea     edi, [ebp + panel1_colwidths - panel1_data]
2921
        test    ebx, ebx
2922
        jz      .loop2
2923
        mov     eax, [ebp + panel1_width - panel1_data]
2924
        dec     eax
2925
        dec     eax
2926
        sub     eax, edx
2927
        jae     @f
2928
        xor     eax, eax
2929
@@:
2930
        xor     edx, edx
2931
        div     ebx
2932
        test    eax, eax
2933
        jnz     @f
2934
        xor     edx, edx
2935
        inc     eax
2936
@@:
2937
        push    eax
2938
.loop2:
2939
        movzx   eax, byte [esi]
2940
        inc     esi
2941
        test    eax, eax
2942
        jnz     @f
2943
        pop     eax
2944
        push    eax
2945
        dec     ebx
2946
        cmp     ebx, edx
2947
        jae     @f
2948
        inc     eax
2949
@@:
2950
        stosd
2951
        loop    .loop2
2952
        pop     eax
2953
        and     dword [edi], 0
2954
        ret
2955
 
180 heavyiron 2956
draw_panel:
2957
        mov     eax, [ebp + panel1_left - panel1_data]
2958
        mov     edx, [ebp + panel1_top - panel1_data]
2959
        call    get_console_ptr
2960
; draw border
2961
        mov     ah, [panel_border_color]
2962
        mov     ebx, [ebp + panel1_width - panel1_data]
2963
        mov     edx, [ebp + panel1_height - panel1_data]
2964
        call    draw_border
2965
        push    eax
2966
        mov     eax, [ebp + panel1_left - panel1_data]
2967
        mov     edx, [ebp + panel1_top - panel1_data]
2968
        add     edx, [ebp + panel1_height - panel1_data]
2969
        sub     edx, 3
2970
        call    get_console_ptr
2971
        pop     eax
2972
        mov     al, 0xC7
2973
        stosw
2974
        mov     al, 0xC4
2975
        lea     ecx, [ebx-2]
2976
        rep     stosw
2977
        mov     al, 0xB6
2978
        stosw
474 diamond 2979
 
2980
        imul    esi, [ebp + panel1_colmode - panel1_data], PanelMode.size
2981
        add     esi, colmodes
2982
        lodsd
2983
        mov     ecx, eax        ; number of columns
2984
        lea     ebx, [ebp + panel1_colwidths - panel1_data]
180 heavyiron 2985
        mov     eax, [ebp + panel1_left - panel1_data]
2986
        inc     eax
2987
        mov     [column_left], eax
474 diamond 2988
        mov     eax, [ebp + panel1_top - panel1_data]
2989
        inc     eax
2990
        mov     [column_top], eax
2991
        mov     eax, [ebp + panel1_height - panel1_data]
2992
        sub     eax, 4
2993
        mov     [column_height], eax
2994
        dec     eax
2995
        mov     [ebp + panel1_colsz - panel1_data], eax
2996
        and     [ebp + panel1_colst - panel1_data], 0
2997
        mov     eax, [ebp + panel1_start - panel1_data]
2998
        mov     [column_index], eax
2999
        mov     [last_column_index], eax
3000
.columns_loop:
3001
        push    ecx
3002
        mov     eax, [ebx]
3003
        add     ebx, 4
3004
        mov     [column_width], eax
3005
        cmp     ecx, 1
3006
        jz      .skip_right_border
3007
        add     eax, [column_left]
180 heavyiron 3008
        mov     edx, [ebp + panel1_top - panel1_data]
3009
        call    get_console_ptr
474 diamond 3010
        mov     ah, [panel_header_color]
180 heavyiron 3011
        mov     al, 0xD1
3012
        mov     [edi], ax
3013
        add     edi, [cur_width]
3014
        add     edi, [cur_width]
474 diamond 3015
        mov     ecx, [column_height]
180 heavyiron 3016
        mov     al, 0xB3
3017
@@:
3018
        mov     [edi], ax
3019
        add     edi, [cur_width]
3020
        add     edi, [cur_width]
3021
        loop    @b
3022
        mov     al, 0xC1
3023
        stosw
474 diamond 3024
.skip_right_border:
3025
        mov     eax, [column_left]
3026
        mov     edx, [column_top]
3027
        call    get_console_ptr
3028
; заголовок столбца
3029
        push    edi
3030
        mov     edx, [esi]
3031
        and     edx, 0xF
3032
        mov     edx, [column_headers+edx*4]
3033
        movzx   ecx, byte [edx]
3034
        inc     edx
3035
        cmp     ecx, [column_width]
3036
        jb      @f
180 heavyiron 3037
        mov     ecx, [column_width]
474 diamond 3038
@@:
3039
        push    ecx
3040
        sub     ecx, [column_width]
3041
        neg     ecx
3042
        shr     ecx, 1
3043
        mov     al, ' '
3044
        mov     ah, [column_header_color]
3045
        rep     stosw
3046
        pop     ecx
3047
        jecxz   .skipcopyhdr
3048
        push    ecx
3049
@@:
3050
        mov     al, [edx]
3051
        inc     edx
3052
        stosw
3053
        loop    @b
3054
        pop     ecx
3055
.skipcopyhdr:
3056
        sub     ecx, [column_width]
3057
        neg     ecx
180 heavyiron 3058
        inc     ecx
474 diamond 3059
        shr     ecx, 1
3060
        mov     al, ' '
3061
        rep     stosw
3062
        pop     edi
3063
        add     edi, [cur_width]
3064
        add     edi, [cur_width]
3065
; сам столбец
3066
        mov     eax, [esi]
3067
        and     eax, 0xF
3068
        push    ebx esi
3069
        call    dword [draw_column_proc+eax*4]
3070
        pop     esi ebx
3071
        inc     esi
3072
        mov     eax, [column_width]
3073
        inc     eax
3074
        add     [column_left], eax
3075
        pop     ecx
3076
        dec     ecx
3077
        jnz     .columns_loop
180 heavyiron 3078
; Заголовок панели (текущая папка)
3079
        lea     esi, [ebp + panel1_dir - panel1_data]
3080
        mov     edi, cur_header
3081
        mov     ecx, [ebp + panel1_width - panel1_data]
3082
        sub     ecx, 7
3083
        movsb
3084
@@:
3085
        lodsb
3086
        stosb
3087
        dec     ecx
3088
        test    al, al
3089
        jz      .header_created
3090
        cmp     al, '/'
3091
        jnz     @b
3092
        mov     edx, esi
3093
@@:
3094
        lodsb
3095
        test    al, al
3096
        jnz     @b
3097
        sub     esi, edx
3098
        dec     esi
3099
        cmp     esi, ecx
3100
        jbe     @f
3101
        mov     word [edi], '..'
3102
        mov     byte [edi+2], '.'
3103
        add     edi, 3
3104
        sub     ecx, 3
3105
        add     edx, esi
3106
        sub     edx, ecx
3107
@@:
3108
        mov     esi, edx
3109
@@:
3110
        lodsb
3111
        stosb
3112
        dec     ecx
3113
        test    al, al
3114
        jnz     @b
3115
.header_created:
3116
        mov     edx, [ebp + panel1_top - panel1_data]
3117
        mov     eax, [ebp + panel1_left - panel1_data]
3118
        shr     ecx, 1
3119
        lea     eax, [eax+ecx+3]
3120
        call    get_console_ptr
3121
        mov     ah, [panel_active_header_color]
3122
        cmp     ebp, [active_panel]
3123
        jz      @f
3124
        mov     ah, [panel_header_color]
3125
@@:
3126
        mov     al, ' '
3127
        stosw
3128
        mov     esi, cur_header
3129
@@:
3130
        lodsb
3131
        test    al, al
3132
        jz      @f
3133
        stosw
3134
        jmp     @b
3135
@@:
3136
        mov     al, ' '
3137
        stosw
3138
        mov     edx, [ebp + panel1_top - panel1_data]
3139
        inc     edx
3140
        mov     eax, [ebp + panel1_left - panel1_data]
3141
        inc     eax
3142
        call    get_console_ptr
3143
        movzx   eax, [ebp + panel1_sortmode - panel1_data]
3144
        mov     al, [compare_names+eax]
3145
        stosb
474 diamond 3146
        mov     eax, [ebp + panel1_selected_num - panel1_data]
3147
        test    eax, eax
3148
        jz      .skip_selected_info
3149
; Информация о выделенных файлах
3150
        push    dword [ebp + panel1_selected_size+4 - panel1_data]
3151
        push    dword [ebp + panel1_selected_size - panel1_data]
3152
        call    fill_total_info
3153
        mov     eax, [ebp + panel1_width - panel1_data]
3154
        sub     eax, 2
3155
        cmp     ecx, eax
3156
        jbe     @f
3157
        mov     ecx, eax
3158
        mov     edi, saved_file_name+512
3159
        sub     edi, eax
3160
        mov     byte [edi], '.'
3161
        mov     word [edi+1], '..'
3162
@@:
3163
        mov     esi, edi
3164
        sub     eax, ecx
3165
        shr     eax, 1
3166
        inc     eax
3167
        add     eax, [ebp + panel1_left - panel1_data]
3168
        mov     edx, [ebp + panel1_top - panel1_data]
3169
        add     edx, [ebp + panel1_height - panel1_data]
3170
        sub     edx, 3
3171
        call    get_console_ptr
3172
        mov     ah, [panel_numselected_color]
3173
@@:
3174
        lodsb
3175
        stosw
3176
        loop    @b
3177
.skip_selected_info:
3178
; Информация об общем числе и размере файлов панели
3179
        mov     eax, [ebp + panel1_total_num - panel1_data]
3180
        push    dword [ebp + panel1_total_size+4 - panel1_data]
3181
        push    dword [ebp + panel1_total_size - panel1_data]
3182
        call    fill_total_info
3183
        mov     eax, [ebp + panel1_width - panel1_data]
3184
        sub     eax, 2
3185
        cmp     ecx, eax
3186
        jbe     @f
3187
        mov     ecx, eax
3188
        mov     byte [edi+ecx-3], '.'
3189
        mov     word [edi+ecx-2], '..'
3190
@@:
3191
        sub     eax, ecx
3192
        shr     eax, 1
3193
        inc     eax
3194
        add     eax, [ebp + panel1_left - panel1_data]
3195
        add     edx, [ebp + panel1_top - panel1_data]
3196
        add     edx, [ebp + panel1_height - panel1_data]
3197
        dec     edx
3198
        mov     esi, edi
3199
        call    get_console_ptr
3200
        mov     ah, [panel_number_color]
3201
@@:
3202
        lodsb
3203
        stosw
3204
        loop    @b
180 heavyiron 3205
        cmp     [ebp + panel1_numfiles - panel1_data], 0
3206
        jz      .skip_curinfo
474 diamond 3207
; Информация о текущем файле
180 heavyiron 3208
        mov     ebx, [ebp + panel1_index - panel1_data]
3209
        mov     eax, [ebp + panel1_files - panel1_data]
3210
        mov     ebx, [eax+ebx*4]
3211
        mov     eax, [ebp + panel1_left - panel1_data]
3212
        add     eax, [ebp + panel1_width - panel1_data]
3213
        dec     eax
3214
        mov     edx, [ebp + panel1_top - panel1_data]
3215
        add     edx, [ebp + panel1_height - panel1_data]
3216
        dec     edx
3217
        dec     edx
3218
        call    get_console_ptr
3219
        mov     ecx, [ebp + panel1_width - panel1_data]
3220
        dec     ecx
3221
        dec     ecx
474 diamond 3222
        cmp     [ebp + panel1_colmode - panel1_data], 3
3223
        jz      .show_curname
180 heavyiron 3224
; Время модификации
3225
        sub     edi, 5*2
3226
        sub     ecx, 6
3227
        mov     al, [ebx+24+2]
3228
        aam
3229
        or      ax, 0x3030
3230
        mov     [edi], ah
3231
        mov     [edi+2], al
3232
        mov     [edi+4], byte ':'
3233
        mov     al, [ebx+24+1]
3234
        aam
3235
        or      ax, 0x3030
3236
        mov     [edi+6], ah
3237
        mov     [edi+8], al
3238
        mov     al, [panel_normal_color]
3239
        mov     [edi+1], al
3240
        mov     [edi+3], al
3241
        mov     [edi+5], al
3242
        mov     [edi+7], al
3243
        mov     [edi+9], al
3244
        dec     edi
3245
        mov     [edi], al
3246
        dec     edi
3247
        mov     byte [edi], ' '
3248
; Дата модификации
3249
        sub     edi, 8*2
3250
        sub     ecx, 9
3251
        mov     al, [ebx+28+0]
3252
        aam
3253
        or      ax, 0x3030
3254
        mov     [edi], ah
3255
        mov     [edi+2], al
3256
        mov     [edi+4], byte '.'
3257
        mov     al, [ebx+28+1]
3258
        aam
3259
        or      ax, 0x3030
3260
        mov     [edi+6], ah
3261
        mov     [edi+8], al
3262
        mov     [edi+10], byte '.'
3263
        mov     ax, [ebx+28+2]
3264
        div     [_100]
3265
        mov     al, ah
3266
        aam
3267
        or      ax, 0x3030
3268
        mov     [edi+12], ah
3269
        mov     [edi+14], al
3270
        mov     al, [panel_normal_color]
3271
        mov     [edi+1], al
3272
        mov     [edi+3], al
3273
        mov     [edi+5], al
3274
        mov     [edi+7], al
3275
        mov     [edi+9], al
3276
        mov     [edi+11], al
3277
        mov     [edi+13], al
3278
        mov     [edi+15], al
3279
        dec     edi
3280
        mov     [edi], al
3281
        dec     edi
3282
        mov     [edi], byte ' '
3283
; Размер
3284
        std
3285
        mov     ah, [panel_normal_color]
3286
        dec     edi
3287
        dec     edi
3288
        dec     ecx
3289
        test    byte [ebx], 0x10
3290
        jz      .size_file
3291
        push    ecx
3292
        mov     esi, aFolder+aFolder.size-1
3293
        mov     ecx, aFolder.size
3294
        cmp     word [ebx+40], '..'
3295
        jnz     @f
3296
        cmp     byte [ebx+42], 0
3297
        jnz     @f
3298
        mov     esi, aUp+aUp.size-1
3299
        mov     cl, aUp.size
3300
@@:
3301
        sub     [esp], ecx
3302
@@:
3303
        lodsb
3304
        stosw
3305
        loop    @b
3306
        pop     ecx
3307
        jmp     .size_done
3308
.size_file:
3309
        mov     edx, [ebx+36]
3310
        test    edx, edx
3311
        jz      .size_less_4g
3312
        cmp     edx, 10*256
3313
        jae     .size_tera
3314
; в гигабайтах
3315
        mov     al, 'G'
283 diamond 3316
        shl     edx, 2
180 heavyiron 3317
        jmp     .size_letter
3318
.size_tera:
3319
; в терабайтах
3320
        shr     edx, 8
3321
        mov     al, 'T'
3322
        jmp     .size_letter
3323
.size_less_4g:
3324
        mov     edx, [ebx+32]
3325
        cmp     edx, 10*(1 shl 20)
3326
        jae     .size_mega
3327
        cmp     edx, 1 shl 20
3328
        jb      .size_num
3329
        shr     edx, 10
3330
        mov     al, 'K'
3331
        jmp     .size_letter
3332
.size_mega:
3333
        mov     al, 'M'
3334
        shr     edx, 20
3335
.size_letter:
3336
        stosw
3337
        dec     ecx
3338
        mov     al, ' '
3339
        stosw
3340
        dec     ecx
3341
.size_num:
3342
        xchg    eax, edx
3343
        xor     edx, edx
3344
        div     [_10d]
3345
        xchg    eax, edx
3346
        add     al, '0'
3347
        mov     ah, [panel_normal_color]
3348
        stosw
3349
        dec     ecx
3350
        test    edx, edx
3351
        jnz     .size_num
3352
.size_done:
3353
        cld
474 diamond 3354
.show_curname:
180 heavyiron 3355
; Имя
3356
        sub     edi, ecx
3357
        sub     edi, ecx
3358
        lea     esi, [ebx+40]
3359
@@:
3360
        lodsb
3361
        test    al, al
3362
        jnz     @b
3363
        sub     esi, ebx
3364
        sub     esi, 41
3365
        mov     ah, [panel_normal_color]
3366
        cmp     esi, ecx
3367
        lea     edx, [ebx+40]
3368
        jbe     @f
3369
        mov     al, '{'
3370
        mov     [edi-2], ax
3371
        add     edx, esi
3372
        sub     edx, ecx
3373
@@:
3374
        mov     esi, edx
3375
@@:
3376
        lodsb
3377
        test    al, al
3378
        jz      @f
3379
        stosw
3380
        loop    @b
3381
@@:
3382
        mov     al, ' '
3383
        rep     stosw
3384
.skip_curinfo:
3385
        call    draw_image
3386
        ret
3387
 
474 diamond 3388
fill_total_info:
3389
        mov     edi, saved_file_name+511
3390
        mov     byte [edi], ' '
180 heavyiron 3391
if lang eq ru
474 diamond 3392
        mov     byte [edi-1], 'е'
3393
        dec     edi
3394
        cmp     eax, 1
3395
        jz      @f
3396
        mov     word [edi-1], 'ах'
3397
        dec     edi
3398
@@:
3399
        mov     dword [edi-4], 'файл'
3400
        mov     byte [edi-5], ' '
3401
        sub     edi, 5
180 heavyiron 3402
else
474 diamond 3403
        cmp     eax, 1
3404
        jz      @f
3405
        dec     edi
3406
        mov     byte [edi], 's'
3407
@@:
3408
        mov     dword [edi-4], 'file'
3409
        mov     byte [edi-5], ' '
3410
        sub     edi, 5
180 heavyiron 3411
end if
474 diamond 3412
        xor     edx, edx
3413
        push    10
3414
        pop     ecx
3415
@@:
3416
        div     ecx
3417
        dec     edi
3418
        add     dl, '0'
3419
        mov     [edi], dl
3420
        xor     edx, edx
3421
        test    eax, eax
3422
        jnz     @b
180 heavyiron 3423
if lang eq ru
474 diamond 3424
        mov     dword [edi-4], 'т в '
3425
        mov     dword [edi-8], ' бай'
3426
        sub     edi, 8
180 heavyiron 3427
else
474 diamond 3428
        mov     dword [edi-4], ' in '
3429
        mov     dword [edi-8], 'ytes'
3430
        mov     word [edi-10], ' b'
3431
        sub     edi, 10
180 heavyiron 3432
end if
474 diamond 3433
        lea     esi, [edi-3]
3434
        mov     edx, [esp+8]
3435
        mov     eax, [esp+4]
3436
.selsizel:
3437
        push    edx
3438
        mov     ebx, edx
3439
        xor     edx, edx
3440
        add     ebx, ebx
3441
        adc     edx, edx
3442
        push    ebx
3443
        push    edx
3444
        add     ebx, ebx
3445
        adc     edx, edx
3446
        add     ebx, [esp+4]
3447
        adc     edx, [esp]
3448
        add     esp, 8
3449
        add     eax, ebx
3450
        adc     edx, 0
3451
        div     ecx
3452
        dec     edi
3453
        cmp     edi, esi
3454
        jae     @f
3455
        mov     byte [edi], ','
3456
        dec     edi
3457
        sub     esi, 4
3458
@@:
3459
        pop     ebx
3460
        add     dl, '0'
3461
        mov     byte [edi], dl
3462
        xchg    eax, ebx
3463
        mul     [muldiv10]
3464
        add     eax, ebx
3465
        adc     edx, 0
3466
        mov     ebx, eax
3467
        or      ebx, edx
3468
        jnz     .selsizel
3469
        dec     edi
3470
        mov     byte [edi], ' '
3471
        mov     ecx, saved_file_name+512
3472
        sub     ecx, edi
3473
        ret     8
3474
 
3475
get_file_color:
3476
        mov     ah, [esi + 6]
3477
        cmp     ebp, [active_panel]
3478
        jnz     @f
3479
        cmp     ecx, [ebp + panel1_index - panel1_data]
3480
        jnz     @f
3481
        mov     ah, [esi + 7]
3482
@@:
3483
        test    byte [esi + 303], 1
3484
        jnz     @f
3485
        mov     ah, [esi + 4]
3486
        cmp     ebp, [active_panel]
3487
        jnz     @f
3488
        cmp     ecx, [ebp + panel1_index - panel1_data]
3489
        jnz     @f
3490
        mov     ah, [esi + 5]
3491
@@:
3492
        ret
3493
 
3494
draw_name_column:
3495
        mov     eax, [column_index]
3496
        mov     [last_column_index], eax
180 heavyiron 3497
        mov     edx, [ebp + panel1_numfiles - panel1_data]
3498
        mov     ecx, [column_height]
3499
        dec     ecx
3500
.l:
3501
        cmp     [column_index], edx
3502
        jae     .ret
3503
        push    ecx
474 diamond 3504
        mov     ecx, [column_index]
3505
        mov     esi, [ebp + panel1_files - panel1_data]
3506
        mov     esi, [esi+ecx*4]
3507
        mov     ebx, [esi]
3508
        call    get_file_color
321 diamond 3509
        add     esi, 40
180 heavyiron 3510
        mov     ecx, [column_width]
3511
        push    edi
3512
@@:
3513
        lodsb
3514
        test    al, al
3515
        jz      @f
3516
        stosw
3517
        loop    @b
474 diamond 3518
        lodsb
3519
        test    al, al
180 heavyiron 3520
        jz      @f
3521
        mov     byte [edi], '}'
474 diamond 3522
        jmp     .continue
180 heavyiron 3523
@@:
474 diamond 3524
        test    bl, 10h
3525
        jnz     .noalignext
3526
        mov     ebx, [ebp + panel1_colmode - panel1_data]
3527
; sizeof(PanelMode) = 40
3528
        lea     ebx, [ebx+ebx*4]
3529
        cmp     [colmodes+ebx*8+PanelMode.bAlignExtensions], 0
3530
        jz      .noalignext
3531
        push    ecx
3532
        sub     ecx, [column_width]
3533
        neg     ecx
3534
        jz      .noalignext2
3535
        dec     esi
3536
@@:
3537
        dec     esi
3538
        cmp     byte [esi], '.'
3539
        loopnz  @b
3540
        jnz     .noalignext2
3541
        inc     esi
3542
        sub     ecx, [column_width]
3543
        neg     ecx
3544
        sub     ecx, [esp]
3545
        sub     edi, ecx
3546
        sub     edi, ecx
3547
        dec     ecx
3548
        mov     ebx, [esp+4]
3549
        cmp     ecx, 3
3550
        ja      @f
3551
        mov     cl, 3
3552
@@:
3553
        sub     ecx, [column_width]
3554
        sub     ebx, edi
3555
        sar     ebx, 1
3556
        sub     ebx, ecx
3557
        pop     ecx
3558
        inc     ecx
3559
        push    0
3560
        cmp     ecx, ebx
3561
        jbe     @f
3562
        sub     ecx, ebx
3563
        mov     [esp], ecx
3564
        mov     ecx, ebx
3565
@@:
180 heavyiron 3566
        mov     al, ' '
3567
        rep     stosw
474 diamond 3568
@@:
3569
        lodsb
3570
        test    al, al
3571
        jz      .noalignext2
3572
        stosw
3573
        jmp     @b
3574
.noalignext2:
3575
        pop     ecx
3576
.noalignext:
3577
        mov     al, ' '
3578
        rep     stosw
3579
.continue:
180 heavyiron 3580
        pop     edi
3581
        add     edi, [cur_width]
3582
        add     edi, [cur_width]
3583
        inc     [column_index]
3584
        pop     ecx
3585
        dec     ecx
3586
        jnz     .l
3587
.ret:
474 diamond 3588
        mov     eax, [ebp + panel1_colsz - panel1_data]
3589
        add     [ebp + panel1_colst - panel1_data], eax
180 heavyiron 3590
        cmp     ebp, panel1_data
3591
        jnz     .ret2
3592
; Число экранов
3593
        mov     eax, [num_screens]
3594
        dec     eax
3595
        jz      .ret2
3596
        push    eax
3597
        xor     eax, eax
3598
        xor     edx, edx
3599
        call    get_console_ptr
3600
        mov     ah, [panel_nscreens_color]
3601
        mov     al, '['
3602
        stosw
3603
        pop     eax
3604
        push    -'0'
3605
@@:
3606
        xor     edx, edx
3607
        div     [_10d]
3608
        push    edx
3609
        test    eax, eax
3610
        jnz     @b
3611
@@:
3612
        pop     eax
3613
        add     eax, '0'
3614
        jz      @f
3615
        mov     ah, [panel_nscreens_color]
3616
        stosw
3617
        jmp     @b
3618
@@:
3619
        mov     al, ']'
3620
        mov     ah, [panel_nscreens_color]
3621
        stosw
3622
.ret2:
474 diamond 3623
draw_empty_column:
180 heavyiron 3624
        ret
3625
 
474 diamond 3626
draw_size_column:
3627
        add     edi, [column_width]
3628
        add     edi, [column_width]
3629
        dec     edi
3630
        dec     edi
3631
        std
3632
        mov     ecx, [column_height]
3633
        dec     ecx
3634
        push    [last_column_index]
3635
.l:
3636
        mov     edx, [ebp + panel1_numfiles - panel1_data]
3637
        cmp     [last_column_index], edx
3638
        jae     .ret
3639
        push    ecx
3640
        push    edi
3641
        mov     ecx, [last_column_index]
3642
        mov     esi, [ebp + panel1_files - panel1_data]
3643
        mov     esi, [esi+ecx*4]
3644
        call    get_file_color
3645
        mov     ecx, [column_width]
3646
@@:
3647
        mov     ebx, eax
3648
        cmp     word [esi+40], '..'
3649
        jnz     .nodotdot
3650
        cmp     byte [esi+42], 0
3651
        jnz     .nodotdot
3652
if lang eq ru
3653
        mov     al, 'х'
3654
        stosw
3655
        mov     al, 'р'
3656
        stosw
3657
        mov     al, 'е'
3658
        stosw
3659
        mov     al, 'в'
3660
        stosw
3661
        mov     al, 'В'
3662
        stosw
3663
        sub     ecx, 5
3664
else
3665
        mov     al, ' '
3666
        stosw
3667
        stosw
3668
        mov     al, 'p'
3669
        stosw
3670
        mov     al, 'U'
3671
        stosw
3672
        sub     ecx, 4
3673
end if
3674
        jmp     .size_written
3675
.nodotdot:
3676
        test    byte [esi], 10h
3677
        jz      .nofolder
3678
if lang eq ru
3679
        mov     al, 'а'
3680
        stosw
3681
        mov     al, 'к'
3682
        stosw
3683
        mov     al, 'п'
3684
        stosw
3685
        mov     al, 'а'
3686
        stosw
3687
        mov     al, 'П'
3688
        stosw
3689
        sub     ecx, 5
3690
else
3691
        mov     al, 'r'
3692
        stosw
3693
        mov     al, 'e'
3694
        stosw
3695
        mov     al, 'd'
3696
        stosw
3697
        mov     al, 'l'
3698
        stosw
3699
        mov     al, 'o'
3700
        stosw
3701
        mov     al, 'F'
3702
        stosw
3703
        sub     ecx, 6
3704
end if
3705
        jmp     .size_written
3706
.nofolder:
3707
        mov     eax, [esi+32]
3708
        mov     edx, [esi+36]
3709
        test    edx, edx
3710
        jz      .less_4G
3711
        cmp     edx, 10000/4*1024
3712
        jb      .giga
3713
        mov     al, 'T'
3714
        shr     edx, 10
3715
        jmp     .write_letter
3716
.giga:
3717
        mov     al, 'G'
3718
        shl     edx, 2
3719
        jmp     .write_letter
3720
.less_4G:
3721
        mov     edx, eax
3722
        cmp     eax, 1000000
3723
        jb      .byte
3724
        cmp     eax, 10000*1024
3725
        jb      .kilo
3726
        mov     al, 'M'
3727
        shr     edx, 20
3728
        jmp     .write_letter
3729
.kilo:
3730
        mov     al, 'K'
3731
        shr     edx, 10
3732
.write_letter:
3733
        mov     ah, bh
3734
        stosw
3735
        mov     al, ' '
3736
        stosw
3737
        dec     ecx
3738
        dec     ecx
3739
.byte:
3740
        xchg    eax, edx
3741
        xor     edx, edx
3742
        div     [_10d]
3743
        xchg    eax, edx
3744
        add     al, '0'
3745
        mov     ah, bh
3746
        stosw
3747
        dec     ecx
3748
        test    edx, edx
3749
        jnz     .byte
3750
.size_written:
3751
        mov     eax, ebx
3752
        test    ecx, ecx
3753
        jle     @f
3754
        mov     al, ' '
3755
        rep     stosw
3756
@@:
3757
        mov     byte [edi+1], ah
3758
        pop     edi
3759
        add     edi, [cur_width]
3760
        add     edi, [cur_width]
3761
        inc     [last_column_index]
3762
        pop     ecx
3763
        dec     ecx
3764
        jnz     .l
3765
.ret:
3766
        pop     [last_column_index]
3767
        cld
3768
        ret
3769
 
3770
draw_date_column:
3771
        mov     ecx, [column_height]
3772
        dec     ecx
3773
        push    [last_column_index]
3774
.l:
3775
        mov     edx, [ebp + panel1_numfiles - panel1_data]
3776
        cmp     [last_column_index], edx
3777
        jae     .ret
3778
        push    ecx
3779
        push    edi
3780
        mov     ecx, [last_column_index]
3781
        mov     esi, [ebp + panel1_files - panel1_data]
3782
        mov     esi, [esi+ecx*4]
3783
        call    get_file_color
3784
        mov     bh, ah
3785
        mov     byte [edi-1], bh
3786
        mov     al, [esi+28]
3787
        aam
3788
        add     eax, '00'
3789
        push    eax
3790
        mov     al, ah
3791
        mov     ah, bh
3792
        stosw
3793
        pop     eax
3794
        mov     ah, bh
3795
        stosw
3796
        mov     al, '.'
3797
        stosw
3798
        mov     al, [esi+29]
3799
        aam
3800
        add     eax, '00'
3801
        push    eax
3802
        mov     al, ah
3803
        mov     ah, bh
3804
        stosw
3805
        pop     eax
3806
        mov     ah, bh
3807
        stosw
3808
        mov     al, '.'
3809
        stosw
3810
        movzx   eax, word [esi+30]
3811
        xor     edx, edx
3812
        div     [_10d]
3813
        xchg    eax, edx
3814
        add     al, '0'
3815
        mov     ah, bh
3816
        mov     [edi+2], ax
3817
        xchg    eax, edx
3818
        xor     edx, edx
3819
        div     [_10d]
3820
        xchg    eax, edx
3821
        add     al, '0'
3822
        mov     ah, bh
3823
        stosw
3824
        pop     edi
3825
        add     edi, [cur_width]
3826
        add     edi, [cur_width]
3827
        inc     [last_column_index]
3828
        pop     ecx
3829
        dec     ecx
3830
        jnz     .l
3831
.ret:
3832
        pop     [last_column_index]
3833
        cld
3834
        ret
3835
 
3836
draw_time_column:
3837
        mov     ecx, [column_height]
3838
        dec     ecx
3839
        push    [last_column_index]
3840
.l:
3841
        mov     edx, [ebp + panel1_numfiles - panel1_data]
3842
        cmp     [last_column_index], edx
3843
        jae     .ret
3844
        push    ecx
3845
        push    edi
3846
        mov     ecx, [last_column_index]
3847
        mov     esi, [ebp + panel1_files - panel1_data]
3848
        mov     esi, [esi+ecx*4]
3849
        call    get_file_color
3850
        mov     bh, ah
3851
        mov     byte [edi-1], bh
3852
        mov     al, [esi+26]
3853
        aam
3854
        add     eax, '00'
3855
        push    eax
3856
        mov     al, ah
3857
        mov     ah, bh
3858
        stosw
3859
        pop     eax
3860
        mov     ah, bh
3861
        stosw
3862
        mov     al, ':'
3863
        stosw
3864
        mov     al, [esi+25]
3865
        aam
3866
        add     eax, '00'
3867
        push    eax
3868
        mov     al, ah
3869
        mov     ah, bh
3870
        stosw
3871
        pop     eax
3872
        mov     ah, bh
3873
        stosw
3874
        pop     edi
3875
        add     edi, [cur_width]
3876
        add     edi, [cur_width]
3877
        inc     [last_column_index]
3878
        pop     ecx
3879
        dec     ecx
3880
        jnz     .l
3881
.ret:
3882
        pop     [last_column_index]
3883
        cld
3884
        ret
3885
 
180 heavyiron 3886
;insert_last_dot:
3887
;        push    eax esi
3888
;        mov     ah, 0
3889
;.loop:
3890
;        lodsb
3891
;        test    al, al
3892
;        jz      .done
3893
;        cmp     al, '.'
3894
;        jnz     .loop
3895
;        mov     ah, 1
3896
;        jmp     .loop
3897
;.done:
3898
;        test    ah, ah
3899
;        jnz     @f
3900
;        mov     byte [esi-1], '.'
3901
;        mov     byte [esi], 0
3902
;@@:
3903
;        pop     esi eax
3904
;        ret
3905
 
3906
;delete_last_dot:
3907
;        push    esi
3908
;@@:
3909
;        cmp     byte [esi], 0
3910
;        jz      @f
3911
;        inc     esi
3912
;        jmp     @b
3913
;@@:
3914
;        cmp     byte [esi-1], '.'
3915
;        jnz     @f
3916
;        mov     byte [esi-1], 0
3917
;@@:     pop     esi
3918
;        ret
3919
 
3920
read_folder:
3921
        mov     eax, [ebp + panel1_nfa - panel1_data]
3922
        mov     [dirinfo.size], eax
3923
        shl     eax, 2
3924
        add     eax, [ebp + panel1_files - panel1_data]
3925
        mov     [dirinfo.dirdata], eax
3926
        lea     eax, [ebp + panel1_dir - panel1_data]
3927
        mov     [dirinfo.name], eax
474 diamond 3928
        xor     eax, eax
3929
        mov     [ebp + panel1_total_num - panel1_data], eax
3930
        mov     dword [ebp + panel1_total_size - panel1_data], eax
3931
        mov     dword [ebp + panel1_total_size+4 - panel1_data], eax
3932
        mov     [ebp + panel1_selected_num - panel1_data], eax
3933
        mov     dword [ebp + panel1_selected_size - panel1_data], eax
3934
        mov     dword [ebp + panel1_selected_size+4 - panel1_data], eax
314 diamond 3935
.retry:
180 heavyiron 3936
        push    70
3937
        pop     eax
3938
        mov     ebx, dirinfo
3939
        int     40h
3940
        test    eax, eax
3941
        jz      .ok
3942
        cmp     eax, 6
3943
        jz      .ok
314 diamond 3944
; Failed to read folder, notify user
3945
        cmp     [bSilentFolderMode], 0
3946
        jnz     .dont_notify
474 diamond 3947
        push    dword aContinue
3948
        push    dword aRetry
314 diamond 3949
        mov     edx, esp
3950
        call    get_error_msg
3951
        push    [dirinfo.name]
474 diamond 3952
        push    dword aCannotReadFolder
314 diamond 3953
        push    eax
3954
        mov     eax, esp
3955
        push    edx
3956
        push    2
3957
        push    eax
3958
        push    3
3959
        push    -1
3960
        push    -1
474 diamond 3961
        push    dword aError
314 diamond 3962
        call    SayErr
3963
        add     esp, 5*4
3964
        test    eax, eax
3965
        jz      .retry
3966
.dont_notify:
3967
        mov     esi, prev_dir
3968
        cmp     byte [esi], 0
3969
        jz      @f
3970
        lea     edi, [ebp + panel1_dir - panel1_data]
3971
        mov     ecx, 1024/4
3972
        rep     movsd
3973
        mov     byte [prev_dir], 0
3974
        ret
3975
@@:
3976
        mov     [bSilentFolderMode], 1  ; enter silent mode
3977
        mov     esi, [dirinfo.name]
3978
        xor     edx, edx
3979
.up1:
3980
        lodsb
3981
        test    al, al
3982
        jz      .up1done
3983
        cmp     al, '/'
3984
        jnz     .up1
3985
        inc     edx
3986
        lea     edi, [esi-1]
3987
        jmp     .up1
3988
.up1done:
3989
        cmp     edx, 2
3990
        jbe     .noup
3991
        stosb
3992
        jmp     read_folder
3993
.noup:
3994
        mov     esi, [dirinfo.name]
3995
        mov     edi, esi
3996
        lodsd
3997
        or      eax, 0x00202000
3998
        cmp     eax, '/rd/'
3999
        jnz     @f
4000
        lodsw
4001
        cmp     ax, '1'
4002
        jz      .nosetrd
4003
@@:
4004
        mov     eax, '/rd/'
4005
        stosd
4006
        mov     ax, '1'
4007
        stosw
4008
        jmp     read_folder
4009
.nosetrd:
4010
; Даже рамдиск не прочитался. Значит, не судьба...
4011
        and     dword [ebp + panel1_numfiles - panel1_data], 0
180 heavyiron 4012
        and     dword [ebp + panel1_index - panel1_data], 0
4013
        and     dword [ebp + panel1_start - panel1_data], 0
314 diamond 4014
        mov     [bSilentFolderMode], 0  ; leave silent mode
180 heavyiron 4015
        ret
4016
.ok:
4017
        mov     eax, [dirinfo.dirdata]
4018
        cmp     [eax+8], ebx
4019
        jz      .readdone
474 diamond 4020
        push    dword [eax+8]
4021
        mov     ecx, [ebp + panel1_files - panel1_data]
4022
        call    pgfree
4023
        pop     ecx
4024
        add     ecx, 0xF
4025
        and     ecx, not 0xF
4026
        push    ecx
4027
        imul    ecx, 4+304
4028
        add     ecx, 32
4029
        call    xpgalloc
180 heavyiron 4030
        test    eax, eax
4031
        jnz     .succ1
4032
        pop     eax
4033
        jmp     .readdone
4034
.succ1:
4035
        mov     [ebp + panel1_files - panel1_data], eax
4036
        pop     [ebp + panel1_nfa - panel1_data]
321 diamond 4037
        mov     [prev_dir], 0
180 heavyiron 4038
        jmp     read_folder
4039
.readdone:
4040
        and     [ebp + panel1_start - panel1_data], 0
4041
        and     [ebp + panel1_index - panel1_data], 0
4042
        and     [ebp + panel1_start - panel1_data], 0
4043
        mov     edi, [ebp + panel1_files - panel1_data]
4044
        mov     eax, [ebp + panel1_nfa - panel1_data]
321 diamond 4045
        lea     eax, [edi + eax*4 + 32]
4046
        mov     ecx, [eax-32+4]
283 diamond 4047
        test    ecx, ecx
4048
        jz      .loopdone
321 diamond 4049
        xor     edx, edx
180 heavyiron 4050
; Игнорируем специальные входы, соответствующие папке '.' и метке тома
4051
.ptrinit:
321 diamond 4052
        cmp     word [eax+40], '.'
180 heavyiron 4053
        jz      .loopcont
321 diamond 4054
        test    byte [eax], 8
180 heavyiron 4055
        jnz     .loopcont
474 diamond 4056
        mov     byte [eax+303], 0
321 diamond 4057
        test    edx, edx
4058
        jnz     .nodotdot
4059
        cmp     word [eax+40], '..'
4060
        jnz     .nodotdot
4061
        cmp     byte [eax+42], 0
4062
        jnz     .nodotdot
4063
        mov     edx, eax
4064
        push    edi
4065
@@:
4066
        cmp     edi, [ebp + panel1_files - panel1_data]
4067
        jbe     @f
4068
        push    dword [edi-4]
4069
        pop     dword [edi]
4070
        sub     edi, 4
4071
        jmp     @b
4072
@@:
180 heavyiron 4073
        stosd
321 diamond 4074
        pop     edi
4075
        scasd
4076
        jmp     .dotdot
4077
.nodotdot:
4078
        stosd
474 diamond 4079
        xor     ebx, ebx
4080
        test    byte [eax], 10h
4081
        setz    bl
4082
        add     [ebp + panel1_total_num - panel1_data], ebx
4083
        mov     ebx, dword [eax+32]
4084
        add     dword [ebp + panel1_total_size - panel1_data], ebx
4085
        mov     ebx, dword [eax+36]
4086
        adc     dword [ebp + panel1_total_size+4 - panel1_data], ebx
321 diamond 4087
.dotdot:
283 diamond 4088
; подсветка
4089
;        call    insert_last_dot
4090
        pushad
321 diamond 4091
        mov     ebp, eax
283 diamond 4092
        lea     esi, [ebp+40]
4093
        mov     edi, lower_file_name
4094
        mov     edx, edi
474 diamond 4095
        xor     eax, eax
283 diamond 4096
@@:
4097
        lodsb
474 diamond 4098
        mov     al, [tolower_table+eax]
283 diamond 4099
        stosb
4100
        test    al, al
4101
        jnz     @b
4102
        mov     esi, edx
4103
        lea     edx, [edi-1]
4104
        xor     ecx, ecx
4105
.highlight_test_loop:
4106
        mov     ebx, [highlight_groups+ecx*4]
4107
        mov     al, [ebx + highlight.IncludeAttributes]
4108
        mov     ah, [ebp]
4109
        and     ah, al
4110
        cmp     ah, al
4111
        jnz     .highlight_test_failed
4112
        lea     edi, [ebx + highlight.Mask]
4113
        call    match_mask_rev_lowercase
4114
        jc      .highlight_test_failed
4115
        mov     ah, [ebx + highlight.NormalColor]
4116
        test    ah, ah
4117
        jnz     @f
4118
        mov     ah, [panel_normal_color]
4119
@@:
474 diamond 4120
        mov     [ebp+4], ah
283 diamond 4121
        mov     ah, [ebx + highlight.CursorColor]
4122
        test    ah, ah
4123
        jnz     @f
4124
        mov     ah, [panel_cursor_color]
4125
@@:
474 diamond 4126
        mov     [ebp+5], ah
4127
        mov     ah, [ebx + highlight.SelectedColor]
4128
        test    ah, ah
4129
        jnz     @f
4130
        mov     ah, [panel_selected_color]
4131
@@:
283 diamond 4132
        mov     [ebp+6], ah
474 diamond 4133
        mov     ah, [ebx + highlight.SelectedCursorColor]
4134
        test    ah, ah
4135
        jnz     @f
4136
        mov     ah, [panel_selected_cursor_color]
4137
@@:
4138
        mov     [ebp+7], ah
283 diamond 4139
        jmp     .doname
4140
.highlight_test_failed:
4141
        inc     ecx
4142
        cmp     ecx, [highlight_num_groups]
4143
        jb      .highlight_test_loop
4144
.nohighlight:
4145
        mov     ah, [panel_normal_color]
474 diamond 4146
        mov     [ebp+4], ah
4147
        mov     ah, [panel_cursor_color]
283 diamond 4148
        mov     [ebp+5], ah
474 diamond 4149
        mov     ah, [panel_selected_color]
283 diamond 4150
        mov     [ebp+6], ah
474 diamond 4151
        mov     ah, [panel_selected_cursor_color]
4152
        mov     [ebp+7], ah
283 diamond 4153
.doname:
4154
;        call    delete_last_dot
4155
        popad
180 heavyiron 4156
.loopcont:
4157
        add     eax, 304
283 diamond 4158
        dec     ecx
4159
        jnz     .ptrinit
180 heavyiron 4160
.loopdone:
4161
        sub     edi, [ebp + panel1_files - panel1_data]
4162
        shr     edi, 2
4163
        mov     [ebp + panel1_numfiles - panel1_data], edi
4164
.done:
4165
; Сортировка
4166
sort_files:
4167
        movzx   eax, [ebp + panel1_sortmode - panel1_data]
4168
        mov     ebx, [compare_fns + eax*4]
4169
        mov     edx, [ebp + panel1_files - panel1_data]
4170
        mov     ecx, [ebp + panel1_numfiles - panel1_data]
321 diamond 4171
        jecxz   .skip
4172
        mov     eax, [edx]
474 diamond 4173
        cmp     word [eax+40], '..'
321 diamond 4174
        jnz     .nodotdot
474 diamond 4175
        cmp     byte [eax+42], 0
321 diamond 4176
        jnz     .nodotdot
4177
        dec     ecx
4178
        add     edx, 4
4179
.nodotdot:
180 heavyiron 4180
        call    sort
321 diamond 4181
.skip:
314 diamond 4182
        mov     [bSilentFolderMode], 0  ; leave silent mode
180 heavyiron 4183
        ret
4184
 
4185
compare_name:
4186
        test    byte [esi], 10h
4187
        jnz     .1dir
4188
        test    byte [edi], 10h
4189
        jnz     .greater
4190
.eq1:
4191
        add     esi, 40
4192
        add     edi, 40
4193
        jmp     strcmpi
4194
.greater:
4195
        test    esi, esi
4196
        ret
4197
.1dir:
4198
        test    byte [edi], 10h
4199
        jnz     .eq1
4200
.less:
4201
        xor     edi, edi
4202
        stc
4203
        ret
4204
 
4205
compare_name_rev:
4206
        test    byte [esi], 10h
4207
        jnz     .1dir
4208
        test    byte [edi], 10h
4209
        jnz     .greater
4210
.eq1:
4211
        add     esi, 40
4212
        add     edi, 40
4213
        xchg    esi, edi
4214
        jmp     strcmpi
4215
.greater:
4216
        test    esi, esi
4217
        ret
4218
.1dir:
4219
        test    byte [edi], 10h
4220
        jnz     .eq1
4221
.less:
4222
        xor     edi, edi
4223
        stc
4224
        ret
4225
 
4226
strcmpi:
4227
        push    eax
4228
@@:
4229
        lodsb
4230
        call    match_symbol
4231
        jnz     .ret
4232
        inc     edi
4233
        test    al, al
4234
        jnz     @b
4235
.ret:
4236
        pop     eax
4237
        ret
4238
 
4239
compare_ext:
4240
        test    byte [esi], 10h
4241
        jnz     .1dir
4242
        test    byte [edi], 10h
4243
        jnz     .greater
4244
.eq1:
4245
        add     esi, 40
4246
        add     edi, 40
4247
        push    esi edi
4248
        call    seek_ext
4249
        xchg    esi, edi
4250
        call    seek_ext
4251
        xchg    esi, edi
4252
        call    strcmpi
4253
        jnz     .ret
4254
        pop     edi esi
4255
        jmp     strcmpi
4256
.ret:
4257
        pop     edi esi
4258
        ret
4259
.greater:
4260
        test    esi, esi
4261
        ret
4262
.1dir:
4263
        test    byte [edi], 10h
4264
        jnz     .eq1
4265
.less:
4266
        xor     edi, edi
4267
        stc
4268
        ret
4269
 
4270
compare_ext_rev:
4271
        test    byte [esi], 10h
4272
        jnz     .1dir
4273
        test    byte [edi], 10h
4274
        jnz     .greater
4275
.eq1:
4276
        add     esi, 40
4277
        add     edi, 40
4278
        push    esi edi
4279
        call    seek_ext
4280
        xchg    esi, edi
4281
        call    seek_ext
4282
        call    strcmpi
4283
        jnz     .ret
4284
        pop     edi esi
4285
        xchg    esi, edi
4286
        jmp     strcmpi
4287
.ret:
4288
        pop     edi esi
4289
        ret
4290
.greater:
4291
        test    esi, esi
4292
        ret
4293
.1dir:
4294
        test    byte [edi], 10h
4295
        jnz     .eq1
4296
.less:
4297
        xor     edi, edi
4298
        stc
4299
        ret
4300
 
4301
seek_ext:
4302
        push    eax
4303
        xor     eax, eax
4304
.l:
4305
        inc     esi
4306
        cmp     byte [esi-1], '.'
4307
        jnz     @f
4308
        mov     eax, esi
4309
@@:
4310
        cmp     byte [esi-1], 0
4311
        jnz     .l
4312
        test    eax, eax
4313
        jnz     @f
4314
        lea     eax, [esi-1]
4315
@@:
4316
        mov     esi, eax
4317
        pop     eax
4318
        ret
4319
 
4320
compare_modified:
4321
        test    byte [esi], 10h
4322
        jnz     .1dir
4323
        test    byte [edi], 10h
4324
        jnz     .greater
4325
.eq1:
4326
        push    edi
4327
        mov     edi, [edi+28]
4328
        cmp     edi, [esi+28]
4329
        pop     edi
4330
        jnz     @f
4331
        push    edi
4332
        mov     edi, [edi+24]
4333
        cmp     edi, [esi+24]
4334
        pop     edi
4335
        jnz     @f
4336
        add     esi, 40
4337
        add     edi, 40
4338
        jmp     strcmpi
4339
@@:
4340
        ret
4341
.greater:
4342
        test    esi, esi
4343
        ret
4344
.1dir:
4345
        test    byte [edi], 10h
4346
        jnz     .eq1
4347
.less:
4348
        xor     edi, edi
4349
        stc
4350
        ret
4351
 
4352
compare_modified_rev:
4353
        test    byte [esi], 10h
4354
        jnz     .1dir
4355
        test    byte [edi], 10h
4356
        jnz     .greater
4357
.eq1:
4358
        push    esi
4359
        mov     esi, [esi+28]
4360
        cmp     esi, [edi+28]
4361
        pop     esi
4362
        jnz     @f
4363
        push    esi
4364
        mov     esi, [esi+24]
4365
        cmp     esi, [edi+24]
4366
        pop     esi
4367
        jnz     @f
4368
        add     esi, 40
4369
        add     edi, 40
4370
        xchg    esi, edi
4371
        jmp     strcmpi
4372
@@:
4373
        ret
4374
.greater:
4375
        test    esi, esi
4376
        ret
4377
.1dir:
4378
        test    byte [edi], 10h
4379
        jnz     .eq1
4380
.less:
4381
        xor     edi, edi
4382
        stc
4383
        ret
4384
 
4385
compare_size:
4386
        test    byte [esi], 10h
4387
        jnz     .1dir
4388
        test    byte [edi], 10h
4389
        jnz     .greater
4390
.eq1:
4391
        push    edi
4392
        mov     edi, [edi+36]
4393
        cmp     edi, [esi+36]
4394
        pop     edi
4395
        jnz     @f
4396
        push    edi
4397
        mov     edi, [edi+32]
4398
        cmp     edi, [esi+32]
4399
        pop     edi
4400
        jnz     @f
4401
        add     esi, 40
4402
        add     edi, 40
4403
        jmp     strcmpi
4404
@@:
4405
        ret
4406
.greater:
4407
        test    esi, esi
4408
        ret
4409
.1dir:
4410
        test    byte [edi], 10h
4411
        jnz     .eq1
4412
.less:
4413
        xor     edi, edi
4414
        stc
4415
        ret
4416
 
4417
compare_size_rev:
4418
        test    byte [esi], 10h
4419
        jnz     .1dir
4420
        test    byte [edi], 10h
4421
        jnz     .greater
4422
.eq1:
4423
        push    esi
4424
        mov     esi, [esi+36]
4425
        cmp     esi, [edi+36]
4426
        pop     esi
4427
        jnz     @f
4428
        push    esi
4429
        mov     esi, [esi+32]
4430
        cmp     esi, [edi+32]
4431
        pop     esi
4432
        jnz     @f
4433
        add     esi, 40
4434
        add     edi, 40
4435
        xchg    esi, edi
4436
        jmp     strcmpi
4437
@@:
4438
        ret
4439
.greater:
4440
        test    esi, esi
4441
        ret
4442
.1dir:
4443
        test    byte [edi], 10h
4444
        jnz     .eq1
4445
.less:
4446
        xor     edi, edi
4447
        stc
4448
        ret
4449
 
4450
compare_unordered:
4451
        cmp     esi, edi
4452
        ret
4453
compare_unordered_rev:
4454
        cmp     edi, esi
4455
        ret
4456
 
4457
compare_created:
4458
        test    byte [esi], 10h
4459
        jnz     .1dir
4460
        test    byte [edi], 10h
4461
        jnz     .greater
4462
.eq1:
4463
        push    edi
4464
        mov     edi, [edi+12]
4465
        cmp     edi, [esi+12]
4466
        pop     edi
4467
        jnz     @f
4468
        push    edi
4469
        mov     edi, [edi+8]
4470
        cmp     edi, [esi+8]
4471
        pop     edi
4472
        jnz     @f
4473
        add     esi, 40
4474
        add     edi, 40
4475
        jmp     strcmpi
4476
@@:
4477
        ret
4478
.greater:
4479
        test    esi, esi
4480
        ret
4481
.1dir:
4482
        test    byte [edi], 10h
4483
        jnz     .eq1
4484
.less:
4485
        xor     edi, edi
4486
        stc
4487
        ret
4488
 
4489
compare_created_rev:
4490
        test    byte [esi], 10h
4491
        jnz     .1dir
4492
        test    byte [edi], 10h
4493
        jnz     .greater
4494
.eq1:
4495
        push    esi
4496
        mov     esi, [esi+12]
4497
        cmp     esi, [edi+12]
4498
        pop     esi
4499
        jnz     @f
4500
        push    esi
4501
        mov     esi, [esi+8]
4502
        cmp     esi, [edi+8]
4503
        pop     esi
4504
        jnz     @f
4505
        add     esi, 40
4506
        add     edi, 40
4507
        xchg    esi, edi
4508
        jmp     strcmpi
4509
@@:
4510
        ret
4511
.greater:
4512
        test    esi, esi
4513
        ret
4514
.1dir:
4515
        test    byte [edi], 10h
4516
        jnz     .eq1
4517
.less:
4518
        xor     edi, edi
4519
        stc
4520
        ret
4521
 
4522
compare_accessed:
4523
        test    byte [esi], 10h
4524
        jnz     .1dir
4525
        test    byte [edi], 10h
4526
        jnz     .greater
4527
.eq1:
4528
        push    edi
4529
        mov     edi, [edi+20]
4530
        cmp     edi, [esi+20]
4531
        pop     edi
4532
        jnz     @f
4533
        push    edi
4534
        mov     edi, [edi+16]
4535
        cmp     edi, [esi+16]
4536
        pop     edi
4537
        jnz     @f
4538
        add     esi, 40
4539
        add     edi, 40
4540
        jmp     strcmpi
4541
@@:
4542
        ret
4543
.greater:
4544
        test    esi, esi
4545
        ret
4546
.1dir:
4547
        test    byte [edi], 10h
4548
        jnz     .eq1
4549
.less:
4550
        xor     edi, edi
4551
        stc
4552
        ret
4553
 
4554
compare_accessed_rev:
4555
        test    byte [esi], 10h
4556
        jnz     .1dir
4557
        test    byte [edi], 10h
4558
        jnz     .greater
4559
.eq1:
4560
        push    esi
4561
        mov     esi, [esi+20]
4562
        cmp     esi, [edi+20]
4563
        pop     esi
4564
        jnz     @f
4565
        push    esi
4566
        mov     esi, [esi+16]
4567
        cmp     esi, [edi+16]
4568
        pop     esi
4569
        jnz     @f
4570
        add     esi, 40
4571
        add     edi, 40
4572
        xchg    esi, edi
4573
        jmp     strcmpi
4574
@@:
4575
        ret
4576
.greater:
4577
        test    esi, esi
4578
        ret
4579
.1dir:
4580
        test    byte [edi], 10h
4581
        jnz     .eq1
4582
.less:
4583
        xor     edi, edi
4584
        stc
4585
        ret
4586
 
283 diamond 4587
if 0
180 heavyiron 4588
match_mask:
4589
; in: esi->name, edi->mask
4590
; out: CF clear <=> match
4591
        pusha
4592
        xchg    esi, edi
4593
.main_cycle:
4594
        push    esi
4595
@@:
4596
        lodsb
4597
        test    al, al
4598
        jz      @f
4599
        cmp     al, ','
4600
        jz      @f
4601
        cmp     al, '|'
4602
        jnz     @b
4603
@@:
4604
        mov     [esi-1], byte 0
4605
        xchg    esi, [esp]
4606
        call    match_single_mask
4607
        pop     esi
4608
        mov     [esi-1], al
4609
        jnc     .found
4610
        cmp     al, ','
4611
        jz      .main_cycle
4612
.done_fail:
4613
        stc
4614
        popa
4615
        ret
4616
.found:
4617
        test    al, al
4618
        jz      .done_succ
4619
        cmp     al, '|'
4620
        jz      .test_exclude
4621
        lodsb
4622
        jmp     .found
4623
.done_succ:
4624
        clc
4625
        popa
4626
        ret
4627
.test_exclude:
4628
        push    esi
4629
@@:
4630
        lodsb
4631
        test    al, al
4632
        jz      @f
4633
        cmp     al, ','
4634
        jnz     @b
4635
@@:
4636
        mov     byte [esi-1], 0
4637
        xchg    esi, [esp]
4638
        call    match_single_mask
4639
        pop     esi
4640
        mov     [esi-1], al
4641
        jnc     .done_fail
4642
        test    al, al
4643
        jz      .done_succ
4644
        jmp     .test_exclude
4645
 
4646
match_single_mask:
4647
; in: esi->mask, edi->name
4648
; out: CF clear <=> match
4649
        pusha
4650
.mask_symbol:
4651
        lodsb
4652
        test    al, al
4653
        jz      .mask_done
4654
        cmp     al, '*'
4655
        jz      .asterisk
4656
        cmp     al, '?'
4657
        jz      .quest
4658
        cmp     al, '['
4659
        jz      .list
4660
        call    match_symbol
4661
        jnz     .done_fail
4662
        inc     edi
4663
        jmp     .mask_symbol
4664
.done_fail:
4665
        stc
4666
        popa
4667
        ret
4668
.mask_done:
4669
        scasb
4670
        jnz     .done_fail
4671
.done_succ:
4672
        clc
4673
        popa
4674
        ret
4675
.quest:
4676
        mov     al, 0
4677
        scasb
4678
        jz      .done_fail
4679
        jmp     .mask_symbol
4680
.list:
4681
        lodsb
4682
        cmp     al, ']'
4683
        jz      .done_fail
4684
        cmp     byte [esi+1], '-'
4685
        jz      .range
4686
        call    match_symbol
4687
        jnz     .list
4688
.listok:
4689
        inc     edi
4690
@@:
4691
        lodsb
4692
        cmp     al, ']'
4693
        jnz     @b
4694
        jmp     .mask_symbol
4695
.range:
4696
        call    match_symbol
4697
        ja      @f
4698
        mov     al, [esi+2]
4699
        call    match_symbol
4700
        jae     .listok
4701
@@:
4702
        inc     esi
4703
        jmp     .list
4704
.asterisk:
283 diamond 4705
        cmp     byte [esi], 0
4706
        jz      .done_succ
4707
        cmp     byte [esi], '?'
4708
        jnz     @f
4709
        mov     al, 0
4710
        scasb
4711
        jz      .done_fail
4712
        inc     esi
4713
        jmp     .asterisk
4714
@@:
4715
        cmp     byte [esi], '['
4716
        jz      .asterisk_common
4717
; the mask is ...*...
4718
.asterisk_normal:
4719
        mov     al, [esi]
4720
@@:
4721
        cmp     byte [edi], 0
4722
        jz      .done_fail
4723
        call    match_symbol
4724
        jz      @f
4725
        inc     edi
4726
        jmp     @b
4727
@@:
4728
        inc     edi
4729
        inc     esi
4730
        call    match_single_mask
4731
        jnc     .done_succ
4732
        dec     esi
4733
        jmp     .asterisk_normal
4734
.asterisk_common:
180 heavyiron 4735
        push    edi
4736
@@:
4737
        call    match_single_mask
4738
        jnc     @f
4739
        mov     al, 0
4740
        scasb
4741
        jnz     @b
4742
        pop     edi
4743
        jmp     .done_fail
4744
@@:
4745
        pop     edi
4746
        jmp     .done_succ
4747
 
283 diamond 4748
match_mask_rev:
4749
; in: esi->name, edx->end of name, edi->mask
4750
; out: CF clear <=> match
4751
        pusha
4752
        xchg    esi, edx
4753
        xchg    esi, edi
4754
.main_cycle:
4755
        mov     ecx, esi
4756
@@:
4757
        lodsb
4758
        test    al, al
4759
        jz      @f
4760
        cmp     al, ','
4761
        jz      @f
4762
        cmp     al, '|'
4763
        jnz     @b
4764
@@:
4765
        dec     esi
4766
        mov     [esi], byte 0
4767
        call    match_single_mask_rev2
4768
        mov     [esi], al
4769
        inc     esi
4770
        jnc     .found
4771
        cmp     al, ','
4772
        jz      .main_cycle
4773
.done_fail:
4774
        stc
4775
        popa
4776
        ret
4777
.found:
4778
        test    al, al
4779
        jz      .done_succ
4780
        cmp     al, '|'
4781
        jz      .test_exclude
4782
        lodsb
4783
        jmp     .found