Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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