Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
31 halyavin 1
 
2
;   2003-2004 (C) Mike Semenyako aka mike.dld
3
;   Compile with FASM for Menuet
4
5
 
6
org 0
7
8
 
9
  dd $01        ; header version
10
  dd START      ; start of code
11
  dd I_END      ; size of image
12
  dd MEM_USED   ; memory for app
13
  dd $007FF0    ; esp
14
  dd $00,$00    ; I_Param , I_Icon
15
16
 
17
;     START:SIZE
18
;
19
; +00000000:00007FF0 - image
20
; +00007FF0:00007FF0 - stack
21
; +00008000:00000300 - path strings buffer
22
; +00008300:0003FD00 - files data
23
; +00048000:00000300 - temporary file read area
24
; +00048300:00004000 - memory for OS (read/write buffer)
25
; +0004C300:FFFB3CFF - dinamically allocated for copy, view, edit etc.
26
;
27
28
 
29
include 'menuet.inc'
30
include 'mfar.inc'
31
32
 
33
34
 
35
36
 
37
        mov     edi,f_path0
38
        mov     ecx,p_rd.size
39
        rep     movsb
40
        mov     esi,p_hd                ; right panel = HD
41
        mov     edi,f_path1
42
        mov     ecx,p_hd.size
43
        rep     movsb
44
45
 
46
        call    draw_window_full
47
        jmp     still
48
redraw_files:
49
        call    draw_files
50
still:
51
        mcall   MF_WAITEVWTO,100        ; waiting 1 sec
52
        jmpe    al,,\
53
          EV_REDRAW,redraw_all,\
54
          EV_KEY,key,\
55
          EV_BUTTON,button
56
57
 
58
;  eg. requesting ACTIVE panel files data and drawing it
59
;; timed redraw {
60
        mov     dl,[active_panel]
61
        cmp     dl,0
62
        jne    ._00
63
        push    [d_ltsz]
64
        jmp     @f
65
   ._00:
66
        push    [d_rtsz]
67
    @@:
68
        call    get_files_data
69
        pop     eax
70
        cmp     dl,0
71
        jne    ._01
72
        cmp     eax,[d_ltsz]
73
        jmp     @f
74
   ._01:
75
        cmp     eax,[d_rtsz]
76
    @@:
77
        je      still                   ; nothing happened, waiting again
78
        mov     al,dl
79
        jmp     redraw_files
80
;; }
81
82
 
83
 key:
84
        mcall   MF_GETKEY               ; get key-code
85
86
 
87
88
 
89
          VK_RETURN,k_return,\          ; execute something
90
          VK_TAB,k_tab,\                ; change active panel
91
          VK_F5,k_f5,\                  ; copy
92
          VK_F10,mfar_exit,\            ; terminate
93
          VK_CTRLF3,k_ctrl_f3,\         ; sort by name
94
          VK_CTRLF4,k_ctrl_f4           ; sort by extension
95
;------------------------------------------------------------------------------
96
  k_return:
97
        call    execute_current_file
98
        jmp     still
99
;------------------------------------------------------------------------------
100
  k_tab:
101
        mov     edi,[fc.background]
102
        call    draw_sel                ; hide current file selection
103
        xor     [active_panel],1        ; changing active panel
104
        call    draw_path               ; drawing path of new panel
105
        mov     dl,[active_panel]
106
        call    get_files_data          ; requesting panel files info
107
        mov     edi,sel_color
108
        call    draw_sel                ; show current file
109
        mov     al,[active_panel]
110
        call    draw_file_info          ; and its info (size,date)
111
        jmp     still
112
;------------------------------------------------------------------------------
113
  k_f5:
114
        call    copy_file
115
        jc      still
116
        jmp     redraw_all
117
;------------------------------------------------------------------------------
118
  k_ctrl_f3:
119
        jecxz  ._00
120
        cmp     [r_sort],0
121
        je      still
122
        mov     [r_sort],0
123
        jmp     @f
124
   ._00:
125
        cmp     [l_sort],0
126
        je      still
127
        mov     [l_sort],0
128
    @@:
129
        mov     al,cl
130
        call    mfar_sort
131
        jmp     redraw_files
132
;------------------------------------------------------------------------------
133
  k_ctrl_f4:
134
        jecxz  ._00
135
        cmp     [r_sort],1
136
        je      still
137
        mov     [r_sort],1
138
        jmp     @f
139
   ._00:
140
        cmp     [l_sort],1
141
        je      still
142
        mov     [l_sort],1
143
    @@:
144
        mov     al,al
145
        call    mfar_sort
146
        jmp     redraw_files
147
;------------------------------------------------------------------------------
148
  k_directional:
149
        cmp     ah,VK_LEFT              ; non-directional keys ?
150
        jb      still                   ; ignore them
151
        cmp     ah,VK_END
152
        ja      still
153
        jecxz  ._00
154
        mov     edx,[d_rpos]
155
        mov     ebx,[d_rtop]
156
        mov     esi,[d_rcnt]
157
        jmp     @f
158
   ._00:
159
        mov     edx,[d_lpos]
160
        mov     ebx,[d_ltop]
161
        mov     esi,[d_lcnt]
162
    @@:
163
        xor     ebp,ebp                 ; redraw whole panel [0-no, 1-yes]
164
;------------------------------------------------------------------------------
165
        jmpe    ah,show_cur,\
166
          VK_LEFT,k_left,\
167
          VK_DOWN,k_down,\
168
          VK_UP,k_up,\
169
          VK_RIGHT,k_right,\
170
          VK_HOME,k_home,\
171
          VK_END,k_end
172
  k_left:
173
        cmp     edx,0
174
        je      still
175
        sub     edx,FPC
176
        jge     @f
177
        xor     edx,edx
178
    @@:
179
        mov     eax,edx
180
        sub     eax,ebx
181
        jge     show_cur
182
        inc     ebp
183
        sub     ebx,FPC
184
        jge     show_cur
185
        xor     ebx,ebx
186
        jmp     show_cur
187
;------------------------------------------------------------------------------
188
  k_down:
189
        lea     eax,[esi-1]
190
        cmp     edx,eax
191
        je      still
192
        inc     edx
193
        mov     eax,edx
194
        sub     eax,ebx
195
        cmp     eax,FPC*3-1
196
        jle     show_cur
197
        inc     ebp
198
        inc     ebx
199
        jmp     show_cur
200
;------------------------------------------------------------------------------
201
  k_up:
202
        cmp     edx,0
203
        je      still
204
        dec     edx
205
        mov     eax,ebx
206
        cmp     edx,eax
207
        jge     show_cur
208
        inc     ebp
209
        dec     ebx
210
        jmp     show_cur
211
;------------------------------------------------------------------------------
212
  k_right:
213
        lea     eax,[esi-1]
214
        cmp     edx,eax
215
        je      still
216
        add     edx,FPC
217
        cmp     edx,eax
218
        jle     @f
219
        mov     edx,eax
220
    @@:
221
        mov     eax,edx
222
        sub     eax,ebx
223
        cmp     eax,FPC*3-1
224
        jle     show_cur
225
        inc     ebp
226
        add     ebx,FPC
227
        jmp     show_cur
228
;------------------------------------------------------------------------------
229
  k_home:
230
        cmp     edx,0
231
        je      still
232
        inc     ebp
233
        xor     edx,edx
234
        xor     ebx,ebx
235
        jmp     show_cur
236
;------------------------------------------------------------------------------
237
  k_end:
238
        lea     eax,[esi-1]
239
        cmp     edx,eax
240
        je      still
241
        mov     edx,eax
242
        mov     edi,eax
243
        sub     edi,ebx
244
        cmp     edi,FPC*3-1
245
        jle     show_cur
246
        inc     ebp
247
        sub     eax,FPC*3-1
248
        mov     ebx,eax
249
;------------------------------------------------------------------------------
250
251
 
252
253
 
254
        call    draw_sel
255
256
 
257
        mov     [d_rpos],edx
258
        mov     [d_rtop],ebx
259
        jmp     @f
260
   ._00:
261
        mov     [d_lpos],edx
262
        mov     [d_ltop],ebx
263
    @@:
264
265
 
266
        mov     al,cl
267
        jne     redraw_files
268
269
 
270
        call    draw_sel
271
        call    draw_file_info
272
        jmp     still
273
274
 
275
        mcall   MF_GETPRSDBTNID
276
        cmp     ah,1
277
        jne     noclose
278
279
 
280
        mcall   MF_RDDELFILE,fcfile             ; delete existing mfar.dat
281
        mcall   MF_RDWRITEFILE,fcfile,fc,12*4,0 ; create new mfar.dat
282
283
 
284
  noclose:
285
        jmp     still
286
287
 
288
;///// DRAW WINDOW ////////////////////////////////////////////////////////////
289
;------------------------------------------------------------------------------
290
291
 
7649 leency 292
        mcall   MF_WINPROPS,WP_GETSYSCLRS,sc,sizeof.system_colors
31 halyavin 293
294
 
295
        mov     edx,[fc.background]
296
        or      edx,$14000000
7649 leency 297
		mov     edi,caption
298
        mcall2  MF_DEFWINDOW,90,oX+tW*80+4,45,oY+tH*25+4
31 halyavin 299
300
 
301
        mmov    edi,oY+3,oY+tH*22+3
302
        mov     edx,[fc.default]
303
        call    draw_frame
304
        mmov    esi,oX+tW*40+2,oX+tW*79+2
305
        call    draw_frame
306
307
 
308
        madd    ebx,tW*13,tW*13
309
        mcall
310
        mcall2  ,oX+3,oX+tW*39+1,oY+tH*20+3,oY+tH*20+3
311
        mcall2  ,oX+tW*53+2,oX+tW*53+2,oY+tH,oY+tH*20+3
312
        madd    ebx,tW*13,tW*13
313
        mcall
314
        mcall2  ,oX+tW*40+3,oX+tW*79+1,oY+tH*20+3,oY+tH*20+3
315
316
 
317
        mcall1  ,oX+tW*18,oY+tH
318
        mcall1  ,oX+tW*31,oY+tH
319
        mcall1  ,oX+tW*45,oY+tH
320
        mcall1  ,oX+tW*58,oY+tH
321
        mcall1  ,oX+tW*71,oY+tH
322
323
 
324
        lea     edx,[edi+sort_kind]
325
        mcall1  ,oX+tW,oY+tH,$00ffff00,,1
326
        movzx   edi,[r_sort]
327
        lea     edx,[edi+sort_kind]
328
        mcall1  ,oX+tW*41,oY+tH
329
330
 
331
        call    draw_bottom_keys
332
333
 
334
        ret
335
endf
336
337
 
338
;//////////////////////////////////////////////////////////////////////////////
339
;------------------------------------------------------------------------------
340
341
 
7649 leency 342
        call    draw_window
31 halyavin 343
        mov     edx,1
344
        call    get_files_data
345
        mov     al,1
346
        call    draw_files
347
        mov     edx,0
348
        call    get_files_data
349
        mov     al,0
350
        call    draw_files
351
        ret
352
endf
353
354
 
355
;//////////////////////////////////////////////////////////////////////////////
356
;------------------------------------------------------------------------------
357
358
 
359
len dd ?
360
361
 
7649 leency 362
        pusha
31 halyavin 363
        mov     ecx,5
364
        rep     movsb
365
        dec     esi
366
        dec     edi
367
        mov     ecx,5
368
        push    eax
369
    @@:
370
        dec     dword[esp]
371
        jz      @f
372
        lodsb
373
        cmp     al,0
374
        je      @b
375
        cmp     al,' '
376
        je      @b
377
        stosb
378
        inc     ecx
379
        jmp     @b
380
    @@:
381
        pop     eax
382
        mov     byte[edi],'>'
383
        mov     [len],ecx
384
        popa
385
        ret
386
endf
387
388
 
389
;//////////////////////////////////////////////////////////////////////////////
390
;------------------------------------------------------------------------------
391
392
 
393
; ECX = current length
394
; EDI = path string
395
func get_path_ellipses
7649 leency 396
        cmp     ecx,eax
31 halyavin 397
        jbe     @f
398
        pushad
399
        lea     esi,[edi+ecx+3+6]       ; ... + /??/?/
400
        sub     esi,eax
401
        add     ecx,edi
402
        sub     ecx,esi
403
        mov     dword[edi+6],'... '
404
        add     edi,9
405
        cld
406
        rep     movsb
407
        mov     [len],eax
408
        popad
409
    @@:
410
        ret
411
endf
412
413
 
414
;//////////////////////////////////////////////////////////////////////////////
415
;------------------------------------------------------------------------------
416
417
 
7649 leency 418
        pushad
31 halyavin 419
        cmp     [active_panel],0
420
        jne    ._00
421
        mov     esi,f_path0
422
        mov     eax,[f_plen0]
423
        jmp     @f
424
   ._00:
425
        mov     esi,f_path1
426
        mov     eax,[f_plen1]
427
    @@:
428
        mov     edi,f_pathn
429
        call    get_normal_path
430
        mov     eax,39
431
        mov     ecx,[len]
432
        mov     edi,f_pathn
433
        call    get_path_ellipses
434
        mcall2  MF_FILLRECT,oX-1,tW*80+1,oY+tH*23-1,tH,[fc.pathbg]
435
        mcall1  MF_DRAWTEXT,oX,oY+tH*23,[fc.path],f_pathn,[len]
436
        popad
437
        ret
438
endf
439
440
 
441
;//////////////////////////////////////////////////////////////////////////////
442
;------------------------------------------------------------------------------
443
444
 
445
func draw_files
7649 leency 446
        push    eax
31 halyavin 447
        mmov    ecx,oY+tH*2-1,tH*FPC
448
        mov     edx,[fc.background]
449
        cmp     al,0
450
        mov     eax,MF_FILLRECT
451
        jne    ._00
452
        mcall1  ,oX+tW-2,tW*12+3
453
        mcall1  ,oX+tW*14-2,tW*12+3
454
        mcall1  ,oX+tW*27-2,tW*12+3
455
        mmov    ebx,oX+tW,oY+tH*2
456
        mov     edx,[d_ltop]
457
        shl     edx,4
458
        add     edx,lstart
459
        mov     edi,[d_lcnt]
460
        mov     esi,edi
461
        sub     edi,[d_ltop]
462
        jmp     @f
463
   ._00:
464
        mcall1  ,oX+tW*41-2,tW*12+3
465
        mcall1  ,oX+tW*54-2,tW*12+3
466
        mcall1  ,oX+tW*67-2,tW*12+3
467
        mmov    ebx,oX+tW*41,oY+tH*2
468
        mov     edx,[d_rtop]
469
        shl     edx,4
470
        add     edx,rstart
471
        mov     edi,[d_rcnt]
472
        mov     esi,edi
473
        sub     edi,[d_rtop]
474
    @@:
475
        cmp     esi,0
476
        je     .exit_nok                ; no files
477
478
 
479
   .next_col:
480
        push    ecx
481
        mov     ecx,FPC
482
   .next_row:
483
        dec     edi
484
        jge     @f
485
        pop     eax
486
        jmp    .exit_ok
487
    @@:
488
        push    ecx
489
        call    get_file_color
490
        mov     esi,edx
491
        call    get_file_name
492
        push    edx
493
        mcall   4,,,f_name,12           ; draw file name
494
        pop     edx ecx
495
        add     ebx,tH
496
497
 
498
        dec     ecx
499
        jnz    .next_row
500
        pop     ecx
501
        dec     ecx
502
        jz     .exit_ok
503
        madd    ebx,tW*13,0
504
        mov     bx,oY+tH*2
505
        jmp    .next_col
506
507
 
508
        mov     edi,sel_color
509
        call    draw_sel
510
   .exit_nok:
511
        pop     eax
512
        call    draw_file_info
513
        ret
514
endf
515
516
 
517
;//////////////////////////////////////////////////////////////////////////////
518
;------------------------------------------------------------------------------
519
520
 
7649 leency 521
        pushad
31 halyavin 522
        mcall2  MF_FILLRECT,oX-1,tW*80+1,oY+tH*24-1,tH+1,[fc.pathbg]
523
        dec     ecx
524
        mcall1  ,oX+tW-1,tW*6+1,,[fc.keysbg]
525
        mov     esi,7
526
    @@:
527
        madd    ebx,tW*8,0
528
        mcall
529
        dec     esi
530
        jge     @b
531
        mcall1  ,oX+tW*73-1,tW*7+1
532
        mcall   MF_DRAWNUMBER,$00010100,1,oX*65536+(oY+tH*24),[fc.path]
533
        sub     edx,$00010000
534
    @@:
535
        inc     cl
536
        madd    edx,tW*8,0
537
        mcall
538
        cmp     cl,10
539
        jb      @b
540
        mcall1  MF_DRAWTEXT,oX+tW,oY+tH*24,[fc.keys],btmkeys,btmkeys.size
541
        popad
542
        ret
543
endf
544
545
 
546
;//////////////////////////////////////////////////////////////////////////////
547
;------------------------------------------------------------------------------
548
549
 
550
; EDI = Y1*65536+Y2
551
; EDX = color
552
func draw_frame
7649 leency 553
        mov     ecx,edi
31 halyavin 554
        mov     ebx,edi
555
        shr     ebx,16
556
        mov     cx,bx
557
        mcall   MF_DRAWLINE,esi
558
        mov     ecx,edi
559
        shl     ecx,16
560
        mov     cx,di
561
        mcall
562
        mov     ebx,esi
563
        mov     ecx,esi
564
        shr     ecx,16
565
        mov     bx,cx
566
        mcall   ,,edi
567
        mov     ebx,esi
568
        shl     ebx,16
569
        mov     bx,si
570
        mcall
571
        ret
572
endf
573
574
 
575
;//////////////////////////////////////////////////////////////////////////////
576
;------------------------------------------------------------------------------
577
578
 
579
func get_file_color
7649 leency 580
        push    esi
31 halyavin 581
        mov     cl,[edx+11]
582
        test    cl,(FA_HIDDEN or FA_SYSTEM)
583
        jz      @f
584
        mov     ecx,[fc.system]
585
        jmp    .exit
586
    @@:
587
        test    cl,FA_FOLDER
588
        jz      @f
589
        mov     ecx,[fc.folder]
590
        jmp    .exit
591
    @@:
592
        mov     ecx,[edx+7]
593
        and     ecx,$ffffff00
594
        or      ecx,$00000020
595
596
 
597
    @@:
598
        lodsd
599
        or      eax,eax
600
        jz      @f
601
        cmp     ecx,eax
602
        jne     @b
603
        mov     ecx,[fc.executable]
604
        jmp    .exit
605
    @@:
606
        lodsd
607
        or      eax,eax
608
        jz      @f
609
        cmp     ecx,eax
610
        jne     @b
611
        mov     ecx,[fc.bitmap]
612
        jmp    .exit
613
    @@:
614
        lodsd
615
        or      eax,eax
616
        je      @f
617
        cmp     ecx,eax
618
        jne     @b
619
        mov     ecx,[fc.source]
620
        jmp    .exit
621
    @@:
622
        mov     ecx,[fc.default]
623
   .exit:
624
        pop     esi
625
        ret
626
endf
627
628
 
629
;//////////////////////////////////////////////////////////////////////////////
630
;------------------------------------------------------------------------------
631
632
 
633
func draw_sel
7649 leency 634
        pushad
31 halyavin 635
        cmp     [active_panel],0
636
        jne    ._00
637
        mov     eax,[d_lpos]
638
        sub     eax,[d_ltop]
639
        mov     esi,[d_lcnt]
640
        jmp     @f
641
   ._00:
642
        mov     eax,[d_rpos]
643
        sub     eax,[d_rtop]
644
        mov     esi,[d_rcnt]
645
    @@:
646
        cmp     esi,0
647
        je     .exit
648
        mov     cl,FPC
649
        div     cl
650
        mov     bp,ax
651
        and     eax,$000000FF
652
        mov     cl,tW*13
653
        mul     cl
654
        add     ax,oX+tW-2
655
        push    eax
656
        shl     eax,16
657
        mov     ax,tW*12+3
658
        mov     ebx,eax
659
        mov     ax,bp
660
        shr     eax,8
661
        and     eax,$000000FF
662
        mov     cl,tH
663
        mul     cl
664
        add     ax,oY+tH*2-1
665
        push    eax
666
        shl     eax,16
667
        mov     ax,tH
668
        mov     ecx,eax
669
        mov     edx,edi
670
        cmp     [active_panel],0
671
        je      @f
672
        madd    ebx,(40*6),0
673
    @@:
674
        mcall   MF_FILLRECT
675
676
 
677
        movzx   ebx,ax
678
        inc     bx
679
        pop     eax
680
        add     ax,2
681
        shl     eax,16
682
        or      ebx,eax
683
        cmp     [active_panel],0
684
        jne    ._01
685
        mov     edx,[d_lpos]
686
        shl     edx,4
687
        add     edx,lstart
688
        jmp     @f
689
   ._01:
690
        mov     edx,[d_rpos]
691
        shl     edx,4
692
        add     edx,rstart
693
    @@:
694
        mov     esi,edx
695
        call    get_file_name
696
        call    get_file_color
697
        cmp     ecx,edi
698
        jne     @f
699
        xor     ecx,ecx
700
    @@:
701
        cmp     [active_panel],0
702
        je      @f
703
        madd    ebx,tW*40,0
704
    @@:
705
        mcall   MF_DRAWTEXT,,,f_name,12
706
   .exit:
707
        popad
708
        ret
709
endf
710
711
 
712
;//////////////////////////////////////////////////////////////////////////////
713
;------------------------------------------------------------------------------
714
715
 
716
func draw_file_info
7649 leency 717
        push    eax
31 halyavin 718
        mmov    ecx,oY+tH*21,tH
719
        mov     edx,[fc.background]
720
        cmp     al,0
721
        mov     eax,MF_FILLRECT
722
        jne    ._00
723
        mcall1  ,oX+tW,tW*38+1
724
        mov     esi,[d_lpos]
725
        shl     esi,4
726
        add     esi,lstart
727
        mov     edi,[d_lcnt]
728
        jmp     @f
729
   ._00:
730
        mcall1  ,oX+tW*41,tW*38+1
731
        mov     esi,[d_rpos]
732
        shl     esi,4
733
        add     esi,rstart
734
        mov     edi,[d_rcnt]
735
    @@:
736
        cmp     edi,0
737
        jne     @f
738
        pop     eax
739
        ret
740
    @@:
741
        call    get_file_info
742
        mov     dword[file_info+17],'    '
743
        mov     word[file_info+15],'  '
744
        test    byte[esi+11],FA_FOLDER
745
        jz      @f
746
        mov     dword[file_info+21],' DIR'
747
        jmp    .no_size
748
    @@:
749
        mov     dword[file_info+21],'    '
750
        mov     eax,[f_size]
751
        mov     esi,file_info+24
752
        mov     ebx,10
753
        mov     ecx,ebx
754
    @@:
755
        xor     edx,edx
756
        div     ebx
757
        add     dl,'0'
758
        mov     [esi],dl
759
        or      eax,eax
760
        jz     .no_size
761
        dec     esi
762
        loop    @b
763
   .no_size:
764
        pop     eax
765
        mmov    edx,oX+tW*35,oY+tH*21
766
        mmov    ebx,oX+tW,oY+tH*21
767
        cmp     al,0
768
        je      @f
769
        madd    edx,tW*40,0
770
        madd    ebx,tW*40,0
771
    @@:
772
        push    edx
773
        mcall   MF_DRAWTEXT,,[fc.default],file_info,34
774
        pop     edx
775
        mov     esi,ecx
776
        mov     cx,[f_year]
777
        mcall   MF_DRAWNUMBER,$00040000
778
        sub     edx,$00240000 ; 6*6 = $24
779
        movzx   ecx,[f_day]
780
        mcall   ,$00020000
781
        add     edx,$00120000
782
        mov     cl,[f_mnth]
783
        mcall
784
        ret
785
endf
786
787
 
788
;//////////////////////////////////////////////////////////////////////////////
789
;------------------------------------------------------------------------------
790
791
 
7649 leency 792
        pushad
31 halyavin 793
        mov     eax,[esi+0]
794
        mov     [f_name+0],eax
795
        mov     eax,[esi+4]
796
        mov     [f_name+4],eax
797
        mov     eax,[esi+8]
798
        shl     eax,8
799
        and     eax,$FFFFFF00
800
        or      al,$00000020
801
        mov     [f_name+8],eax
802
        popad
803
        ret
804
endf
805
806
 
807
;//////////////////////////////////////////////////////////////////////////////
808
;------------------------------------------------------------------------------
809
810
 
811
func get_file_info
7649 leency 812
        pushad
31 halyavin 813
        mov     eax,[esi+12]
814
        mov     dword[f_info],FS_READ
815
        mov     [f_info+4],eax
816
        mov     dword[f_info+12],read_area
817
        mcall   MF_FSACCESS,f_info
818
        cmp     eax,ERR_SUCCESS
819
        je      @f
820
        cmp     eax,ERR_FS_LAST
821
        ja      @f
822
        popad
823
        stc
824
        ret
825
    @@:
826
        mov     eax,read_area
827
        mov     ecx,16
828
   .next_file:
829
        mov     edx,[esi+0]
830
        cmp     [eax+0],edx
831
        jne     @f
832
        mov     edx,[esi+4]
833
        cmp     [eax+4],edx
834
        jne     @f
835
        mov     edx,[esi+8]
836
        cmp     [eax+8],edx
837
        jne     @f
838
        mov     esi,eax
839
        jmp     .found
840
    @@:
841
        add     eax,32
842
        loop   .next_file
843
   .found:
844
        push    esi
845
        mov     eax,'    '
846
        mov     ecx,3
847
        mov     edi,file_info
848
        rep     stosd
849
        mov     edi,file_info
850
        mov     ecx,2
851
        rep     movsd
852
        mov     edi,file_info
853
    @@:
854
        cmp     byte[edi],' '
855
        jbe     @f
856
        inc     edi
857
        jmp     @b
858
    @@:
859
        mov     eax,[esi]
860
        shl     eax,8
861
        mov     al,'.'
862
        cmp     eax,'.   '
863
        je      @f
864
        mov     [edi],eax
865
    @@:
866
        pop     esi
867
        mov     eax,[esi+28]
868
        mov     [f_size],eax
869
        mov     eax,[esi+24]
870
        mov     [f_day],al
871
        and     [f_day],00011111b
872
        shr     eax,5
873
        mov     [f_mnth],al
874
        and     [f_mnth],00001111b
875
        shr     eax,4
876
        mov     [f_year],ax
877
        and     [f_year],01111111b
878
        add     [f_year],1980
879
        popad
880
        clc
881
        ret
882
endf
883
884
 
885
;//////////////////////////////////////////////////////////////////////////////
886
;------------------------------------------------------------------------------
887
888
 
889
func get_files_data
7649 leency 890
        pushad
31 halyavin 891
        mov     [d_tcnt],0
892
        mov     [d_ttsz],0
893
        cmp     dl,0
894
        jne    ._00
895
        mov     esi,f_path0
896
        mov     ecx,[f_plen0]
897
        jmp     @f
898
   ._00:
899
        mov     esi,f_path1
900
        mov     ecx,[f_plen1]
901
    @@:
902
        push    edi
903
        mov     edi,f_info.path
904
        mov     byte[edi+ecx],0
905
        rep     movsb
906
        pop     edi
907
        cmp     dl,0
908
        jne    ._01
909
        mov     edi,lstart
910
        jmp     @f
911
   ._01:
912
        mov     edi,rstart
913
    @@:
914
        push    edx
915
        xor     ebp,ebp
916
        mov     dword[f_info],FS_READ          ; read
917
        mov     dword[f_info+8],1              ; 1 block
918
        mov     dword[f_info+12],read_area     ; to read_area
919
   .next_block:
920
        mov     dword[f_info+4],ebp            ; starting from block #ebp
921
        mcall   MF_FSACCESS,f_info
922
        cmp     eax,ERR_SUCCESS
923
        je      @f
924
        cmp     eax,ERR_FS_LAST
925
        ja      @f
926
        jmp    .exit
927
    @@:
928
        mov     esi,read_area
929
        mov     ecx,16
930
   .next_file:
931
        cmp     word[esi],0             ; end of entries
932
        je     .exit
933
        cmp     word[esi],'. '          ; self-pointer
934
        je     .skip
935
        test    byte[esi+11],FA_LABEL   ; disk label
936
        jnz    .skip
937
        cmp     byte[esi+11],$0F        ; fat32
938
        je     .skip
939
        cmp     byte[esi],$E5           ; erased
940
        je     .skip
941
        mov     eax,[esi+28]            ; add file size
942
        add     [d_ttsz],eax            ; to folder size
943
        push    ecx
944
        mov     ecx,3
945
        rep     movsd                   ; copy name, attriputes
946
        mov     [edi],ebp               ; and block number
947
        add     edi,4
948
        add     esi,20
949
        inc     [d_tcnt]                ; increase folder files counter
950
;       cmp     [d_tcnt],max_cnt
951
;       je     .exit
952
        pop     ecx
953
        jmp     @f
954
   .skip:
955
        add     esi,32
956
    @@:
957
        loop   .next_file
958
959
 
960
        je     .exit
961
        inc     ebp
962
        jmp    .next_block
963
   .exit:
964
        pop     edx
965
        push    [d_ttsz]
966
        mov     eax,[d_tcnt]
967
        cmp     dl,0
968
        jne    ._02
969
        mov     [d_lcnt],eax
970
        pop     [d_ltsz]
971
        jmp     @f
972
   ._02:
973
        mov     [d_rcnt],eax
974
        pop     [d_rtsz]
975
    @@:
976
        popad
977
        mov     al,dl
978
        call    mfar_sort
979
        ret
980
endf
981
982
 
983
;//////////////////////////////////////////////////////////////////////////////
984
;------------------------------------------------------------------------------
985
986
 
7649 leency 987
        pushad
31 halyavin 988
        cmp     [active_panel],0
989
        jne    ._00
990
        mov     esi,[d_lpos]
991
        shl     esi,4
992
        add     esi,lstart
993
        mov     edi,f_path0
994
        mov     ecx,f_plen0
995
        jmp     @f
996
   ._00:
997
        mov     esi,[d_rpos]
998
        shl     esi,4
999
        add     esi,rstart
1000
        mov     edi,f_path1
1001
        mov     ecx,f_plen1
1002
    @@:
1003
        call    get_file_info
1004
        test    byte[esi+11],FA_FOLDER
1005
        jz     .file
1006
        cmp     word[esi],'..'
1007
        jne    .enter_dir
1008
        add     edi,[ecx]
1009
        dec     edi
1010
    @@:
1011
        dec     [f_plen1]
1012
        cmp     byte[edi],'/'
1013
        je      @f
1014
        dec     edi
1015
        jmp     @b
1016
    @@:
1017
        mov     dword[edi],0
1018
        jmp     @f
1019
   .enter_dir:
1020
        add     edi,[ecx]
1021
        push    ecx edi
1022
        mov     byte[edi],'/'
1023
        inc     edi
1024
        mov     esi,file_info
1025
        mov     ecx,3
1026
        cld
1027
        rep     movsd
1028
        mov     dword[edi],0
1029
        pop     esi ecx
1030
        sub     edi,esi
1031
        add     dword[ecx],edi
1032
        mov     [d_rpos],0
1033
        mov     [d_rtop],0
1034
    @@:
1035
        mov     dl,[active_panel]
1036
        call    get_files_data
1037
        call    draw_path
1038
        mov     al,dl
1039
        call    draw_files
1040
        jmp    .exit
1041
   .file:
1042
        mov     eax,[esi+8]
1043
        shl     eax,8
1044
        and     eax,$FFFFFF00
1045
        or      eax,$00000020
1046
        cmp     eax,'    '
1047
        jne    .exit
1048
1049
 
1050
        mov     eax,[ecx]
1051
        mov     edi,f_pathn
1052
        call    get_normal_path
1053
        mov     esi,f_pathn
1054
        mov     ecx,[len]
1055
        dec     ecx
1056
        mov     edi,f_info.path
1057
        rep     movsb
1058
        mov     byte[edi],'/'
1059
        inc     edi
1060
        mov     esi,file_info
1061
    @@:
1062
        movsb
1063
        cmp     byte[esi],0
1064
        je      @f
1065
        cmp     byte[esi],' '
1066
        jne     @b
1067
    @@:
1068
        mov     byte[edi],0
1069
        mov     dword[f_info],FS_EXECUTE
1070
        mov     dword[f_info+12],0
1071
        mcall   MF_FSACCESS,f_info
1072
   .exit:
1073
        popad
1074
        ret
1075
endf
1076
1077
 
1078
;//////////////////////////////////////////////////////////////////////////////
1079
;------------------------------------------------------------------------------
1080
1081
 
7649 leency 1082
        pushad
31 halyavin 1083
        popad
1084
        ret
1085
endf
1086
1087
 
1088
;///// INCLUDES ///////////////////////////////////////////////////////////////
1089
;------------------------------------------------------------------------------
1090
1091
 
1092
include 'mf-sort.inc'
1093
1094
 
1095
;///// DATA ///////////////////////////////////////////////////////////////////
1096
;------------------------------------------------------------------------------
1097
1098
 
1099
1100
 
1101
f_day  db ?
1102
f_mnth db ?
1103
f_year dw ?
1104
1105
 
1106
d_ltop dd 0
1107
d_lcnt dd 0
1108
d_ltsz dd 0
1109
d_rpos dd 0
1110
d_rtop dd 0
1111
d_rcnt dd 0
1112
d_rtsz dd 0
1113
d_tpos dd ?
1114
d_ttop dd ?
1115
d_tcnt dd ?
1116
d_ttsz dd ?
1117
1118
 
1119
 dd 0
1120
 dd 0
1121
 dd ?
1122
 dd read_area
1123
 dd MEM_FOR_OS
1124
.path:
1125
 rb 255
7649 leency 1126
31 halyavin 1127
 
1128
f_plen1 dd 5
1129
1130
 
7649 leency 1131
sz fcfile,'MFAR    DAT'
31 halyavin 1132
sz p_hd,'/HD/1',0
1133
sz p_rd,'/RD/1',0
1134
ext0:
1135
  db '     EXE COM BAT CMD'
1136
  dd 0
1137
ext1:
1138
  db ' BMP GIF JPG PNG WMF'
1139
  dd 0
1140
ext2:
1141
  db ' ASM INC'
1142
  dd 0
1143
1144
 
1145
include 'mf-lang.inc'
1146
;-------------------------------------
1147
1148
 
1149
file_info: db '                              .  .'
1150
active_panel db 0
1151
;---------------------------------
1152
1153
 
1154
1155
 
1156
1157
 
1158
MEM_USED   = $4C300
1159
read_area  = $48000
1160
fdata_size = $40000-$300
1161
max_cnt    = fdata_size/32
1162
lstart     = $8000+$300
1163
rstart     = lstart+max_cnt*16
1164
1165
 
1166
f_path1    = $8000+$100
1167
f_pathn    = $8000+$200
1168
1169
 
1170
1171
 
1172
fc mfar_colors
1173
1174
 
1175
; 16 bytes per entry:
1176
;  -> 8 bytes - name
1177
;  -> 3 bytes - extension
1178
;  -> 1 byte  - attributes
1179
;  -> 4 bytes - block number
1180