Subversion Repositories Kolibri OS

Rev

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