Subversion Repositories Kolibri OS

Rev

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

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;                                           ;
  3. ; FILE COPY - system module for copy        ;
  4. ; files.Prog for SYS X-TREE BROWSER v22     ;
  5. ;                                           ;
  6. ; Create by Pavlushin Evgeni waptap@mail.ru ;
  7. ;              homepage www.deck4.narod.ru  ;
  8. ;                                           ;
  9. ; On base SYSTREE FILE COPIER 1.02          ;
  10. ;    Ivan Poddubny ivan-yar@bk.ru           ;
  11. ;                                           ;
  12. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  13.  
  14. ;„ ­­ ï ¯à®£  ¥é¥ áëà ï ¨ £«îç­ ï ­® 㦥 ª®¥ ª ª à ¡®â ¥â
  15.     use32
  16.     org     0x0
  17.  
  18.     db      'MENUET01'     ; 8 byte id
  19.     dd      0x01           ; header version
  20.     dd      START          ; start of code
  21.     dd      I_END          ; size of image
  22.     dd      0x20000        ; memory for app
  23.     dd      0x10000        ; esp
  24.     dd      param_area , 0x0      ; I_Param , I_Icon
  25.  
  26. include 'lang.inc'
  27. include 'macros.inc'       ; very useful stuff for MeOS
  28. include 'ascl.inc'
  29.  
  30. STRLEN = 48                ; maximal length of filename
  31.  
  32.  
  33. START:                     ; start of execution
  34.  
  35. ;  à ¬¥âàë:
  36. ; ®â 0 ¤® 100 ¯ãâì ª ¨áâ®ç­¨ªã
  37. ; ®â 100 ¤® 200 ¯ãâì ª ¯à¨¥¬­¨ªã
  38. ;
  39. ;get param
  40.     mov eax,15
  41.     cmp byte [param_area],0
  42.     je  err_exit   ;source not found
  43.     mov eax,16
  44.     cmp byte [param_area+100],0
  45.     je  err_exit   ;dest not found
  46.  
  47.     mov ecx,199
  48. cdf:
  49.     mov al,[param_area+ecx]
  50.     cmp al,byte 32
  51.     jne nor
  52.     mov al,byte 0
  53. nor:
  54.     mov al,[param_area+ecx]
  55.     dec ecx
  56.     jns cdf
  57.  
  58.     mov ecx,STRLEN - 4
  59. copysp:
  60.     mov al,[param_area+ecx]
  61.     mov [source+ecx],al
  62.     dec ecx
  63.     jns copysp
  64.     mov [source+42],byte 0
  65.  
  66.     mov ecx,STRLEN - 4
  67. copydp:
  68.     mov al,[param_area+ecx+100]
  69.     mov [destination+ecx],al
  70.     dec ecx
  71.     jns copydp
  72.     mov [destination+42],byte 0
  73.  
  74.     call draw_window
  75.     call copy_file
  76.  
  77. dexit:
  78.     wtevent red,key,button
  79.     jmp dexit
  80. red:
  81.     call draw_window
  82.     jmp dexit
  83. key:
  84. button:
  85.  
  86. exit:
  87.     close
  88.  
  89. err_exit:
  90.     push eax
  91.     call draw_window
  92.     pop  eax
  93.     jmp copy_error
  94.  
  95. ; print message now
  96. copy_error:
  97.     mov  ebp,43
  98.     mul  ebp
  99.     mov  ebp,eax
  100.  
  101.     mov  eax,4
  102.     mov  ebx,20*65536+70
  103.     mov  ecx,0x10ff0000
  104.     mov  edx,errors ;*8]
  105.     add  edx,ebp
  106.     mov  esi,43  ;[errors+edi*8+4]
  107.     int  0x40
  108.     jmp dexit
  109.  
  110. ;closep:
  111. ;    or   eax,-1        ; close program
  112. ;    int  0x40
  113.  
  114.  
  115. ;====================================================
  116. ; copy_file
  117. ;   This piece of code copies src file to dst file,
  118. ;   then it pass the control to copy_error routine,
  119. ;   which returns to the main cycle of the app.
  120. ;   It's NOT a function! It's reached by direct jump
  121. ;   from the button handler.
  122. ;====================================================
  123. copy_file:
  124.     ; at first we must get the size of the source file
  125.     mov  [source_info.blocks],1 ; load only 512 bytes
  126.     mov  eax,58
  127.     mov  ebx,source_info
  128.     int  0x40
  129.  
  130.     ; now eax contains error code
  131.     ; and ebx contains file size in bytes
  132.     test eax,eax      ; check if eax is equal to zero (success)
  133.     je   .ok_getsize  ;   eax = 0 => continue
  134.     cmp  eax,6
  135.     jna  @f
  136.     mov  eax,7        ; if error code is above 6, it will be 7
  137.   @@:
  138.     cmp  eax,5        ; file might be copied successfully altrough
  139.                       ; the system reports an error 5
  140.     jne  copy_error   ; print error code now
  141.   .ok_getsize:
  142.  
  143.     ; allocate memory
  144.     push ebx         ; save file size
  145.     mov  ecx,ebx
  146.     add  ecx,0x20000 ; size of memory needed = 0x20000+filesize
  147.     mov  eax,64      ; func 64
  148.     mov  ebx,1       ; resize application memory
  149.     int  0x40
  150.     pop  ebx         ; restore filesize
  151.  
  152.     ; check if alloc function failed
  153.     test eax,eax     ; non-zero value means error
  154.     je   .ok_memory
  155.     mov  eax,5       ; error 5 - out of memory
  156.     jmp  copy_error  ; print error code now
  157.   .ok_memory:
  158.  
  159.     ; save number of blocks to source_info
  160.     shr  ebx,9       ; divide by 512
  161.     inc  ebx         ; blocks++
  162.     mov  [source_info.blocks],ebx
  163.     ; read the source file
  164.     mov  eax,58
  165.     mov  ebx,source_info
  166.     int  0x40
  167.  
  168.     ; ebx = file size
  169.     ; save loaded file
  170.     mov  [dest_info.bytes2write],ebx ; file size in bytes
  171.     mov  eax,58
  172.     mov  ebx,dest_info
  173.     int  0x40
  174.  
  175.     ; check if 58 function failed
  176.     test eax,eax
  177.     je   .ok_write
  178.     add  eax,7        ; error number += 7
  179.     cmp  eax,6+7
  180.     jna  copy_error
  181.     mov  eax,7+7
  182.     jmp  copy_error
  183.   .ok_write:
  184.  
  185.     ; return to the initial amount of memory
  186.     mov  eax,64
  187.     mov  ebx,1
  188.     mov  ecx,0x20000
  189.     int  0x40
  190.  
  191.     xor  eax,eax      ; eax = message number (0-OK)
  192.  
  193. ; print strings (source & destination)
  194. print_text:
  195.     mov  eax,13
  196.     mov  ebx,107*65536+STRLEN*6
  197.     mov  ecx,[ya]
  198.     shl  ecx,16
  199.     add  ecx,9
  200.     mov  edx,0xf2f2f2
  201.     int  0x40
  202.  
  203.     mov  eax,4
  204.     mov  ebx,109*65536
  205.     add  ebx,[ya]
  206.     xor  ecx,ecx
  207.     mov  edx,[addr]
  208.     mov  esi,STRLEN
  209.     int  0x40
  210.  
  211.     ret
  212.  
  213.  
  214. ;   *********************************************
  215. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  216. ;   *********************************************
  217.  
  218.  
  219. draw_window:
  220.  
  221.     mov  eax,12                    ; function 12:tell os about windowdraw
  222.     mov  ebx,1                     ; 1, start of draw
  223.     int  0x40
  224.  
  225.                                    ; DRAW WINDOW
  226.     xor  eax,eax                   ; function 0 : define and draw window
  227.     mov  ebx,160*65536+415         ; [x start] *65536 + [x size]
  228.     mov  ecx,160*65536+90         ; [y start] *65536 + [y size]
  229.     mov  edx,0x03DDDDDD            ; color of work area RRGGBB
  230.     int  0x40
  231.  
  232.                                    ; WINDOW LABEL
  233.     mov  eax,4                     ; function 4 : write text to window
  234.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  235.     mov  ecx,0x10ffffff            ; color of text RRGGBB
  236.     mov  edx,labelt                ; pointer to text beginning
  237.     mov  esi,labellen-labelt       ; text length
  238.     int  0x40
  239.  
  240.     mov  eax,8
  241.     mov  ebx,105*65536+290
  242.     mov  ecx,33*65536+12
  243.     mov  edx,4
  244.     mov  esi,0xEBEBEB
  245.     int  0x40
  246.     mov  ebx,105*65536+290
  247.     mov  ecx,49*65536+12
  248.     mov  edx,5
  249.     mov  esi,0xEBEBEB
  250.     int  0x40
  251.  
  252.     mov  esi,source
  253.     mov  edi,text+14
  254.     mov  ecx,STRLEN
  255.     rep  movsb
  256.  
  257.     mov  esi,destination
  258.     mov  edi,text+STRLEN+59-45+14
  259.     mov  ecx,STRLEN
  260.     rep  movsb
  261.  
  262.     mov  ebx,25*65536+36   ; print filenames
  263.     xor  ecx,ecx
  264.     mov  edx,text
  265.     mov  esi,STRLEN+59-45
  266.   newline:
  267.     mov  eax,4
  268.     int  0x40
  269.     add  ebx,16
  270.     add  edx,STRLEN+59-45
  271.     cmp  [edx],byte 'x'
  272.     jnz  newline
  273.  
  274.     mov  eax,12                    ; function 12:tell os about windowdraw
  275.     mov  ebx,2                     ; 2, end of draw
  276.     int  0x40
  277.  
  278.     ret
  279.  
  280.  
  281. ; DATA AREA
  282. align 4
  283.  
  284. param_area:
  285. times 256 db 0
  286.  
  287. source_info:                 ; SOURCE FILEINFO
  288.   .mode            dd 0      ; read file
  289.   .start_block     dd 0x0    ; block to read
  290.   .blocks          dd 0x700  ; num of blocks
  291.   .address         dd 0x20000
  292.   .workarea        dd 0x10000
  293.   source:
  294.   times (STRLEN) db 32
  295.   db 0
  296.  
  297. dest_info:                   ; DESTINATION FILEINFO
  298.   .mode            dd 1      ; write
  299.   .notused         dd 0x0    ; not used
  300.   .bytes2write     dd 0      ; bytes to write
  301.   .address         dd 0x20000
  302.   .workarea        dd 0x10000
  303.   destination:
  304.   times (STRLEN) db 32
  305.   db 0
  306.  
  307.   align 4
  308.   addr  dd  0x0
  309.   ya    dd  0x0
  310.   temp  dd  0
  311.  
  312. text:
  313.       db '   Ž’Š“„€:    |®áá¨ï, ‘¥«ï⨭®, ŒŠ Œ®áª¢   , 1 Šãàá         '
  314.       db '    Š“„€:     |         ¢«î設 …¢£¥­¨©, waptap@mail.ru       '
  315.       db '                                                              '
  316.       db 'x' ; <- END MARKER, DONT DELETE
  317. labelt:
  318.       db   'ŠŽˆŽ‚€ˆ… ”€‰‹€'
  319. labellen:
  320.  
  321. errors:
  322.   db     "ä ©« ᪮¯¨à®¢ ­ ãᯥ譮                    "
  323.   db     "(ç⥭¨¥) ­¥ § ¤ ­  ¡ §  ¦¤                 "
  324.   db     "(ç⥭¨¥) ä ©«®¢ ï á¨á⥬  ­¥ ¯®¤¤¥à¦¨¢ ¥âáï"
  325.   db     "(ç⥭¨¥) ­¥¨§¢¥áâ­ ï ä ©«®¢ ï á¨á⥬       "
  326.   db     "(ç⥭¨¥) ­¥ § ¤ ­ à §¤¥« ¦¤                "
  327.   db     "­¥¤®áâ â®ç­® ¯ ¬ï⨠                       "
  328.   db     "(ç⥭¨¥) ª®­¥æ ä ©«                        "
  329.   db     "(ç⥭¨¥) ­¥¨§¢¥áâ­ ï ®è¨¡ª                 "
  330.   db     "(§ ¯¨áì) ­¥ § ¤ ­ à §¤¥« ¦¤                "
  331.   db     "(§ ¯¨áì) ä ©«®¢ ï á¨á⥬  ­¥ ¯®¤¤¥à¦¨¢ ¥âáï"
  332.   db     "(§ ¯¨áì) ­¥¨§¢¥áâ­ ï ä ©«®¢ ï á¨á⥬       "
  333.   db     "(§ ¯¨áì) ­¥ § ¤ ­ à §¤¥« ¦¤                "
  334.   db     "oh shit!                                   "
  335.   db     "(§ ¯¨áì) ä ©« ­¥ ­ ©¤¥­                    "
  336.   db     "(§ ¯¨áì) ­¥¨§¢¥áâ­ ï ®è¨¡ª                 "
  337.   db     "ãâì ª ¨áâ®ç­¨ªã ¨ ¯à¨¥¬­¨ªã ­¥ 㪠§ ­ë!!! "
  338.   db     "ãâì ª ¯à¨¥¬­¨ªã ­¥ 㪠§ ­!!!              "
  339.  
  340.          ;0123456789012345678901234567890123456789012
  341. I_END: