Subversion Repositories Kolibri OS

Rev

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

Rev 485 Rev 539
1
macro opendialog redproc,openoff,erroff,path
1
macro opendialog redproc,openoff,erroff,path
2
{
2
{
3
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
3
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
4
local run_fileinfo, param
4
local run_fileinfo, param
5
local getmesloop, loox, mred, mkey, mbutton, mgetmes
5
local getmesloop, loox, mred, mkey, mbutton, mgetmes
6
local dlg_is_work, ready, procinfo
6
local dlg_is_work, ready, procinfo
7
;
7
;
8
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
8
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
9
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
9
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
10
;
10
;
11
 
11
 
12
    cld
12
    cld
13
;;    mov esi,path
13
;;    mov esi,path
14
    mov edi,path
14
    mov edi,path
15
    xor eax,eax
15
    xor eax,eax
16
    mov ecx,(1024+16)/4
16
    mov ecx,(1024+16)/4
17
    rep stosd
17
    rep stosd
18
 
18
 
19
;mov [get_loops],0
19
;mov [get_loops],0
20
mov [dlg_pid_get],0
20
mov [dlg_pid_get],0
21
 
21
 
22
; Get my PID in dec format 4 bytes
22
; Get my PID in dec format 4 bytes
23
    mov eax,9
23
    mov eax,9
24
    mov ebx,procinfo
24
    mov ebx,procinfo
25
    or  ecx,-1
25
    or  ecx,-1
26
    mcall
26
    mcall
27
 
27
 
28
; convert eax bin to param dec
28
; convert eax bin to param dec
29
    mov eax,dword [procinfo+30]  ;offset of myPID
29
    mov eax,dword [procinfo+30]  ;offset of myPID
30
    mov edi,param+4-1		 ;offset to 4 bytes
30
    mov edi,param+4-1		 ;offset to 4 bytes
31
    mov ecx,4
31
    mov ecx,4
32
    mov ebx,10
32
    mov ebx,10
33
    cld
33
    cld
34
new_d:
34
new_d:
35
    xor edx,edx
35
    xor edx,edx
36
    div ebx
36
    div ebx
37
    add dl,'0'
37
    add dl,'0'
38
    mov [edi],dl
38
    mov [edi],dl
39
    dec edi
39
    dec edi
40
    loop new_d
40
    loop new_d
41
 
41
 
42
; wirite 1 byte space to param
42
; wirite 1 byte space to param
43
    mov [param+4],byte 32    ;Space for next parametr
43
    mov [param+4],byte 32    ;Space for next parametr
44
; and 1 byte type of dialog to param
44
; and 1 byte type of dialog to param
45
    mov [param+5],byte 'O'   ;Get Open dialog (Use 'S' for Save dialog)
45
    mov [param+5],byte 'O'   ;Get Open dialog (Use 'S' for Save dialog)
46
 
46
 
47
;
47
;
48
; STEP2 prepare IPC area for get messages
48
; STEP2 prepare IPC area for get messages
49
;
49
;
50
 
50
 
51
; prepare IPC area
51
; prepare IPC area
52
    mov [path],dword 0
52
    mov [path],dword 0
53
    mov [path+4],dword 8
53
    mov [path+4],dword 8
54
 
54
 
55
; define IPC memory
55
; define IPC memory
56
    mov eax,60
56
    mov eax,60
57
    mov ebx,1	     ; define IPC
57
    mov ebx,1	     ; define IPC
58
    mov ecx,path     ; offset of area
58
    mov ecx,path     ; offset of area
59
    mov edx,1024+16  ; size
59
    mov edx,1024+16  ; size
60
    mcall
60
    mcall
61
 
61
 
62
; change wanted events list 7-bit IPC event
62
; change wanted events list 7-bit IPC event
63
    mov eax,40
63
    mov eax,40
64
    mov ebx,01000111b
64
    mov ebx,01000111b
65
    mcall
65
    mcall
66
 
66
 
67
;
67
;
68
; STEP 3 run SYSTEM XTREE with parameters
68
; STEP 3 run SYSTEM XTREE with parameters
69
;
69
;
70
 
70
 
71
    mov eax,70
71
    mov eax,70
72
    mov ebx,run_fileinfo
72
    mov ebx,run_fileinfo
73
    mcall
73
    mcall
74
 
74
 
75
    call redproc
75
    call redproc
76
 
76
 
77
    mov [get_loops],0
77
    mov [get_loops],0
78
getmesloop:
78
getmesloop:
79
    mov eax,23
79
    mov eax,23
80
    mov ebx,50	   ;0.5 sec
80
    mov ebx,50	   ;0.5 sec
81
    mcall
81
    mcall
82
        dec     eax
82
        dec     eax
83
        jz      mred
83
        jz      mred
84
        dec     eax
84
        dec     eax
85
        jz      mkey
85
        jz      mkey
86
        dec     eax
86
        dec     eax
87
        jz      mbutton
87
        jz      mbutton
88
        cmp     al, 7-3
88
        cmp     al, 7-3
89
        jz      mgetmes
89
        jz      mgetmes
90
 
90
 
91
; Get number of procces
91
; Get number of procces
92
    mov ebx,procinfo
92
    mov ebx,procinfo
93
    mov ecx,-1
93
    mov ecx,-1
94
    mov eax,9
94
    mov eax,9
95
    mcall
95
    mcall
96
    mov ebp,eax
96
    mov ebp,eax
97
 
97
 
98
loox:
98
loox:
99
    mov eax,9
99
    mov eax,9
100
    mov ebx,procinfo
100
    mov ebx,procinfo
101
    mov ecx,ebp
101
    mov ecx,ebp
102
    mcall
102
    mcall
103
    mov eax,[DLGPID]
103
    mov eax,[DLGPID]
104
    cmp [procinfo+30],eax    ;IF Dialog find
104
    cmp [procinfo+30],eax    ;IF Dialog find
105
    je	dlg_is_work	     ;jmp to dlg_is_work
105
    je	dlg_is_work	     ;jmp to dlg_is_work
106
    dec ebp
106
    dec ebp
107
    jnz loox
107
    jnz loox
108
 
108
 
109
    jmp erroff
109
    jmp erroff
110
 
110
 
111
dlg_is_work:
111
dlg_is_work:
112
    cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
112
    cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
113
    je	erroff		       ;TESTODP2 terminated too
113
    je	erroff		       ;TESTODP2 terminated too
114
 
114
 
115
    cmp [dlg_pid_get],dword 1
115
    cmp [dlg_pid_get],dword 1
116
    je	getmesloop
116
    je	getmesloop
117
    inc [get_loops]
117
    inc [get_loops]
118
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
118
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
119
    jae erroff
119
    jae erroff
120
    jmp getmesloop
120
    jmp getmesloop
121
 
121
 
122
mred:
122
mred:
123
    call redproc
123
    call redproc
124
    jmp  getmesloop
124
    jmp  getmesloop
125
mkey:
125
mkey:
126
    mov  eax,2
126
    mov  eax,2
127
    mcall			; read (eax=2)
127
    mcall			; read (eax=2)
128
    jmp  getmesloop
128
    jmp  getmesloop
129
mbutton:
129
mbutton:
130
    mov  eax,17 		; get id
130
    mov  eax,17 		; get id
131
    mcall
131
    mcall
132
    cmp  ah,1			; button id=1 ?
132
    cmp  ah,1			; button id=1 ?
133
    jne  getmesloop
133
    jne  getmesloop
134
    mov  eax,-1 		; close this program
134
    mov  eax,-1 		; close this program
135
    mcall
135
    mcall
136
mgetmes:
136
mgetmes:
137
 
137
 
138
; If dlg_pid_get then second message get jmp to still
138
; If dlg_pid_get then second message get jmp to still
139
    cmp  [dlg_pid_get],dword 1
139
    cmp  [dlg_pid_get],dword 1
140
    je	 ready
140
    je	 ready
141
 
141
 
142
; First message is number of PID SYSXTREE dialog
142
; First message is number of PID SYSXTREE dialog
143
 
143
 
144
; convert PID dec to PID bin
144
; convert PID dec to PID bin
145
    movzx eax,byte [path+16]
145
    movzx eax,byte [path+16]
146
    sub eax,48
146
    sub eax,48
147
    imul eax,10
147
    imul eax,10
148
    movzx ebx,byte [path+16+1]
148
    movzx ebx,byte [path+16+1]
149
    add eax,ebx
149
    add eax,ebx
150
    sub eax,48
150
    sub eax,48
151
    imul eax,10
151
    imul eax,10
152
    movzx ebx,byte [path+16+2]
152
    movzx ebx,byte [path+16+2]
153
    add eax,ebx
153
    add eax,ebx
154
    sub eax,48
154
    sub eax,48
155
    imul eax,10
155
    imul eax,10
156
    movzx ebx,byte [path+16+3]
156
    movzx ebx,byte [path+16+3]
157
    add eax,ebx
157
    add eax,ebx
158
    sub eax,48
158
    sub eax,48
159
    mov [DLGPID],eax
159
    mov [DLGPID],eax
160
 
160
 
161
; Claear and prepare IPC area for next message
161
; Claear and prepare IPC area for next message
162
    mov [path],dword 0
162
    mov [path],dword 0
163
    mov [path+4],dword 8
163
    mov [path+4],dword 8
164
    mov [path+8],dword 0
164
    mov [path+8],dword 0
165
    mov [path+12],dword 0
165
    mov [path+12],dword 0
166
    mov [path+16],dword 0
166
    mov [path+16],dword 0
167
 
167
 
168
; Set dlg_pid_get for get next message
168
; Set dlg_pid_get for get next message
169
    mov [dlg_pid_get],dword 1
169
    mov [dlg_pid_get],dword 1
170
    call redproc   ;show DLG_PID
170
    call redproc   ;show DLG_PID
171
    jmp  getmesloop
171
    jmp  getmesloop
172
 
172
 
173
ready:
173
ready:
174
;
174
;
175
; The second message get
175
; The second message get
176
; Second message is 100 bytes path to SAVE/OPEN file
176
; Second message is 100 bytes path to SAVE/OPEN file
177
; shl path string on 16 bytes
177
; shl path string on 16 bytes
178
;
178
;
179
    cld
179
    cld
180
    mov esi,path+16
180
    mov esi,path+16
181
    mov edi,path
181
    mov edi,path
182
    mov ecx,1024/4
182
    mov ecx,1024/4
183
    rep movsd
183
    rep movsd
184
    mov [edi],byte 0
184
    mov [edi],byte 0
185
 
185
 
186
    jmp openoff
186
    jmp openoff
187
 
187
 
188
 
188
 
189
; DATA AREA
189
; DATA AREA
190
get_loops   dd 0
190
get_loops   dd 0
191
dlg_pid_get dd 0
191
dlg_pid_get dd 0
192
DLGPID	    dd 0
192
DLGPID	    dd 0
193
 
193
 
194
param:
194
param:
195
   dd 0    ; My dec PID
195
   dd 0    ; My dec PID
196
   dd 0,0  ; Type of dialog
196
   dd 0,0  ; Type of dialog
197
 
197
 
198
run_fileinfo:
198
run_fileinfo:
199
 dd 7
199
 dd 7
200
 dd 0
200
 dd 0
201
 dd param
201
 dd param
202
 dd 0
202
 dd 0
203
 dd 0
203
 dd 0
204
;run_filepath
204
;run_filepath
205
 db '/RD/1/SYSXTREE',0
205
 db '/sys/SYSXTREE',0
206
 
206
 
207
procinfo:
207
procinfo:
208
times 1024 db 0
208
times 1024 db 0
209
}
209
}
210
 
210
 
211
 
211
 
212
macro savedialog redproc,openoff,erroff,path
212
macro savedialog redproc,openoff,erroff,path
213
{
213
{
214
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
214
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
215
local run_fileinfo, run_filepath, param
215
local run_fileinfo, run_filepath, param
216
local getmesloop, loox, mred, mkey, mbutton, mgetmes
216
local getmesloop, loox, mred, mkey, mbutton, mgetmes
217
local dlg_is_work, ready, procinfo
217
local dlg_is_work, ready, procinfo
218
;
218
;
219
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
219
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
220
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
220
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
221
;
221
;
222
 
222
 
223
    cld
223
    cld
224
;;    mov esi,path
224
;;    mov esi,path
225
    mov edi,path
225
    mov edi,path
226
    xor eax,eax
226
    xor eax,eax
227
    mov ecx,(1024+16)/4
227
    mov ecx,(1024+16)/4
228
    rep stosb
228
    rep stosb
229
 
229
 
230
;mov [get_loops],0
230
;mov [get_loops],0
231
mov [dlg_pid_get],0
231
mov [dlg_pid_get],0
232
 
232
 
233
; Get my PID in dec format 4 bytes
233
; Get my PID in dec format 4 bytes
234
    mov eax,9
234
    mov eax,9
235
    mov ebx,procinfo
235
    mov ebx,procinfo
236
    mov ecx,-1
236
    mov ecx,-1
237
    mcall
237
    mcall
238
 
238
 
239
; convert eax bin to param dec
239
; convert eax bin to param dec
240
    mov eax,dword [procinfo+30]  ;offset of myPID
240
    mov eax,dword [procinfo+30]  ;offset of myPID
241
    mov edi,param+4-1		 ;offset to 4 bytes
241
    mov edi,param+4-1		 ;offset to 4 bytes
242
    mov ecx,4
242
    mov ecx,4
243
    mov ebx,10
243
    mov ebx,10
244
    cld
244
    cld
245
new_d:
245
new_d:
246
    xor edx,edx
246
    xor edx,edx
247
    div ebx
247
    div ebx
248
    add dl,'0'
248
    add dl,'0'
249
    mov [edi],dl
249
    mov [edi],dl
250
    dec edi
250
    dec edi
251
    loop new_d
251
    loop new_d
252
 
252
 
253
; wirite 1 byte space to param
253
; wirite 1 byte space to param
254
    mov [param+4],byte 32    ;Space for next parametr
254
    mov [param+4],byte 32    ;Space for next parametr
255
; and 1 byte type of dialog to param
255
; and 1 byte type of dialog to param
256
    mov [param+5],byte 'S'   ;Get Open dialog (Use 'S' for Save dialog)
256
    mov [param+5],byte 'S'   ;Get Open dialog (Use 'S' for Save dialog)
257
 
257
 
258
;
258
;
259
; STEP2 prepare IPC area for get messages
259
; STEP2 prepare IPC area for get messages
260
;
260
;
261
 
261
 
262
; prepare IPC area
262
; prepare IPC area
263
    mov [path],dword 0
263
    mov [path],dword 0
264
    mov [path+4],dword 8
264
    mov [path+4],dword 8
265
 
265
 
266
; define IPC memory
266
; define IPC memory
267
    mov eax,60
267
    mov eax,60
268
    mov ebx,1	     ; define IPC
268
    mov ebx,1	     ; define IPC
269
    mov ecx,path     ; offset of area
269
    mov ecx,path     ; offset of area
270
    mov edx,1024+16  ; size
270
    mov edx,1024+16  ; size
271
    mcall
271
    mcall
272
 
272
 
273
; change wanted events list 7-bit IPC event
273
; change wanted events list 7-bit IPC event
274
    mov eax,40
274
    mov eax,40
275
    mov ebx,01000111b
275
    mov ebx,01000111b
276
    mcall
276
    mcall
277
 
277
 
278
;
278
;
279
; STEP 3 run SYSTEM XTREE with parameters
279
; STEP 3 run SYSTEM XTREE with parameters
280
;
280
;
281
 
281
 
282
    mov eax,70
282
    mov eax,70
283
    mov ebx,run_fileinfo
283
    mov ebx,run_fileinfo
284
    mcall
284
    mcall
285
 
285
 
286
    call redproc
286
    call redproc
287
 
287
 
288
    mov [get_loops],0
288
    mov [get_loops],0
289
getmesloop:
289
getmesloop:
290
    mov eax,23
290
    mov eax,23
291
    mov ebx,50	   ;0.5 sec
291
    mov ebx,50	   ;0.5 sec
292
    mcall
292
    mcall
293
        dec     eax
293
        dec     eax
294
        jz      mred
294
        jz      mred
295
        dec     eax
295
        dec     eax
296
        jz      mkey
296
        jz      mkey
297
        dec     eax
297
        dec     eax
298
        jz      mbutton
298
        jz      mbutton
299
        cmp     al, 7-3
299
        cmp     al, 7-3
300
        jz      mgetmes
300
        jz      mgetmes
301
 
301
 
302
; Get number of procces
302
; Get number of procces
303
    mov ebx,procinfo
303
    mov ebx,procinfo
304
    mov ecx,-1
304
    mov ecx,-1
305
    mov eax,9
305
    mov eax,9
306
    mcall
306
    mcall
307
    mov ebp,eax
307
    mov ebp,eax
308
 
308
 
309
loox:
309
loox:
310
    mov eax,9
310
    mov eax,9
311
    mov ebx,procinfo
311
    mov ebx,procinfo
312
    mov ecx,ebp
312
    mov ecx,ebp
313
    mcall
313
    mcall
314
    mov eax,[DLGPID]
314
    mov eax,[DLGPID]
315
    cmp [procinfo+30],eax    ;IF Dialog find
315
    cmp [procinfo+30],eax    ;IF Dialog find
316
    je	dlg_is_work	     ;jmp to dlg_is_work
316
    je	dlg_is_work	     ;jmp to dlg_is_work
317
    dec ebp
317
    dec ebp
318
    jnz loox
318
    jnz loox
319
 
319
 
320
    jmp erroff
320
    jmp erroff
321
 
321
 
322
dlg_is_work:
322
dlg_is_work:
323
    cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
323
    cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
324
    je	erroff		       ;TESTODP2 terminated too
324
    je	erroff		       ;TESTODP2 terminated too
325
 
325
 
326
    cmp [dlg_pid_get],dword 1
326
    cmp [dlg_pid_get],dword 1
327
    je	getmesloop
327
    je	getmesloop
328
    inc [get_loops]
328
    inc [get_loops]
329
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
329
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
330
    jae erroff
330
    jae erroff
331
    jmp getmesloop
331
    jmp getmesloop
332
 
332
 
333
mred:
333
mred:
334
    call redproc
334
    call redproc
335
    jmp  getmesloop
335
    jmp  getmesloop
336
mkey:
336
mkey:
337
    mov  eax,2
337
    mov  eax,2
338
    mcall			; read (eax=2)
338
    mcall			; read (eax=2)
339
    jmp  getmesloop
339
    jmp  getmesloop
340
mbutton:
340
mbutton:
341
    mov  eax,17 		; get id
341
    mov  eax,17 		; get id
342
    mcall
342
    mcall
343
    cmp  ah,1			; button id=1 ?
343
    cmp  ah,1			; button id=1 ?
344
    jne  getmesloop
344
    jne  getmesloop
345
    mov  eax,-1 		; close this program
345
    mov  eax,-1 		; close this program
346
    mcall
346
    mcall
347
mgetmes:
347
mgetmes:
348
 
348
 
349
; If dlg_pid_get then second message get jmp to still
349
; If dlg_pid_get then second message get jmp to still
350
    cmp  [dlg_pid_get],dword 1
350
    cmp  [dlg_pid_get],dword 1
351
    je	 ready
351
    je	 ready
352
 
352
 
353
; First message is number of PID SYSXTREE dialog
353
; First message is number of PID SYSXTREE dialog
354
 
354
 
355
; convert PID dec to PID bin
355
; convert PID dec to PID bin
356
    movzx eax,byte [path+16]
356
    movzx eax,byte [path+16]
357
    sub eax,48
357
    sub eax,48
358
    imul eax,10
358
    imul eax,10
359
    movzx ebx,byte [path+16+1]
359
    movzx ebx,byte [path+16+1]
360
    add eax,ebx
360
    add eax,ebx
361
    sub eax,48
361
    sub eax,48
362
    imul eax,10
362
    imul eax,10
363
    movzx ebx,byte [path+16+2]
363
    movzx ebx,byte [path+16+2]
364
    add eax,ebx
364
    add eax,ebx
365
    sub eax,48
365
    sub eax,48
366
    imul eax,10
366
    imul eax,10
367
    movzx ebx,byte [path+16+3]
367
    movzx ebx,byte [path+16+3]
368
    add eax,ebx
368
    add eax,ebx
369
    sub eax,48
369
    sub eax,48
370
    mov [DLGPID],eax
370
    mov [DLGPID],eax
371
 
371
 
372
; Claear and prepare IPC area for next message
372
; Claear and prepare IPC area for next message
373
    mov [path],dword 0
373
    mov [path],dword 0
374
    mov [path+4],dword 8
374
    mov [path+4],dword 8
375
    mov [path+8],dword 0
375
    mov [path+8],dword 0
376
    mov [path+12],dword 0
376
    mov [path+12],dword 0
377
    mov [path+16],dword 0
377
    mov [path+16],dword 0
378
 
378
 
379
; Set dlg_pid_get for get next message
379
; Set dlg_pid_get for get next message
380
    mov [dlg_pid_get],dword 1
380
    mov [dlg_pid_get],dword 1
381
    call redproc   ;show DLG_PID
381
    call redproc   ;show DLG_PID
382
    jmp  getmesloop
382
    jmp  getmesloop
383
 
383
 
384
ready:
384
ready:
385
;
385
;
386
; The second message get
386
; The second message get
387
; Second message is 100 bytes path to SAVE/OPEN file
387
; Second message is 100 bytes path to SAVE/OPEN file
388
; shl path string on 16 bytes
388
; shl path string on 16 bytes
389
;
389
;
390
    cld
390
    cld
391
    mov esi,path+16
391
    mov esi,path+16
392
    mov edi,path
392
    mov edi,path
393
    mov ecx,1024/4
393
    mov ecx,1024/4
394
    rep movsd
394
    rep movsd
395
    mov [edi],byte 0
395
    mov [edi],byte 0
396
 
396
 
397
    jmp openoff
397
    jmp openoff
398
 
398
 
399
 
399
 
400
; DATA AREA
400
; DATA AREA
401
get_loops   dd 0
401
get_loops   dd 0
402
dlg_pid_get dd 0
402
dlg_pid_get dd 0
403
DLGPID	    dd 0
403
DLGPID	    dd 0
404
 
404
 
405
param:
405
param:
406
   dd 0  ; My dec PID
406
   dd 0  ; My dec PID
407
   dd 0,0  ; Type of dialog
407
   dd 0,0  ; Type of dialog
408
 
408
 
409
run_fileinfo:
409
run_fileinfo:
410
 dd 7
410
 dd 7
411
 dd 0
411
 dd 0
412
 dd param
412
 dd param
413
 dd 0
413
 dd 0
414
 dd 0
414
 dd 0
415
;run_filepath:
415
;run_filepath:
416
 db '/RD/1/SYSXTREE',0
416
 db '/sys/SYSXTREE',0
417
 
417
 
418
procinfo:
418
procinfo:
419
times 1024 db 0
419
times 1024 db 0
420
}
420
}
421
;-----------------------------------------------------------
421
;-----------------------------------------------------------