Subversion Repositories Kolibri OS

Rev

Rev 503 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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