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
6
local dlg_is_work, ready
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 stosb
17
    rep stosb
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,prcinfo
24
;    mov ebx,prcinfo
25
;    mov ecx,-1
25
;    mov ecx,-1
26
;    mcall
26
;    mcall
27
    mov eax,[parentPID]
27
    mov eax,[parentPID]
28
; convert eax bin to param dec
28
; convert eax bin to param dec
29
;    mov eax,dword [prcinfo+30]  ;offset of myPID
29
;    mov eax,dword [prcinfo+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,prcinfo
92
    mov ebx,prcinfo
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,prcinfo
100
    mov ebx,prcinfo
101
    mov ecx,ebp
101
    mov ecx,ebp
102
    mcall
102
    mcall
103
    mov eax,[DLGPID]
103
    mov eax,[DLGPID]
104
    cmp [prcinfo+30],eax    ;IF Dialog find
104
    cmp [prcinfo+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 [prcinfo+50],word 9 ;If slot state 9 - dialog is terminated
112
    cmp [prcinfo+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
    or  eax,-1                 ; close this program
134
    or  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 1024 bytes path to SAVE/OPEN file
176
; Second message is 1024 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
;prcinfo:
207
;prcinfo:
208
;times 256 db 0
208
;times 256 db 0
209
}
209
}