Rev 1438 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1438 | Rev 1469 | ||
---|---|---|---|
1 | ;***************************************************************************** |
1 | ;***************************************************************************** |
2 | ; Macro for use Open Dialog - for Kolibri OS |
2 | ; Macro for use Open Dialog - for Kolibri OS |
3 | ; Copyright (c) 2009 2010, Marat Zakiyanov aka Mario79, aka Mario |
3 | ; Copyright (c) 2009 2010, Marat Zakiyanov aka Mario79, aka Mario |
4 | ; All rights reserved. |
4 | ; All rights reserved. |
5 | ; |
5 | ; |
6 | ; Redistribution and use in source and binary forms, with or without |
6 | ; Redistribution and use in source and binary forms, with or without |
7 | ; modification, are permitted provided that the following conditions are met: |
7 | ; modification, are permitted provided that the following conditions are met: |
8 | ; * Redistributions of source code must retain the above copyright |
8 | ; * Redistributions of source code must retain the above copyright |
9 | ; notice, this list of conditions and the following disclaimer. |
9 | ; notice, this list of conditions and the following disclaimer. |
10 | ; * Redistributions in binary form must reproduce the above copyright |
10 | ; * Redistributions in binary form must reproduce the above copyright |
11 | ; notice, this list of conditions and the following disclaimer in the |
11 | ; notice, this list of conditions and the following disclaimer in the |
12 | ; documentation and/or other materials provided with the distribution. |
12 | ; documentation and/or other materials provided with the distribution. |
13 | ; * Neither the name of the |
13 | ; * Neither the name of the |
14 | ; names of its contributors may be used to endorse or promote products |
14 | ; names of its contributors may be used to endorse or promote products |
15 | ; derived from this software without specific prior written permission. |
15 | ; derived from this software without specific prior written permission. |
16 | ; |
16 | ; |
17 | ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY |
17 | ; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY |
18 | ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
19 | ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
20 | ; DISCLAIMED. IN NO EVENT SHALL |
20 | ; DISCLAIMED. IN NO EVENT SHALL |
21 | ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
22 | ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 | ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 | ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
26 | ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | ;***************************************************************************** |
27 | ;***************************************************************************** |
28 | ;***************************************************************************** |
28 | ;***************************************************************************** |
29 | macro OpenDialog_exit |
29 | macro OpenDialog_exit |
30 | { |
30 | { |
31 | popa |
31 | popa |
32 | ret |
32 | ret |
33 | } |
33 | } |
34 | ;***************************************************************************** |
34 | ;***************************************************************************** |
35 | macro use_OpenDialog |
35 | macro use_OpenDialog |
36 | { |
36 | { |
37 | OpenDialog: |
37 | OpenDialog: |
38 | od_type equ dword [ebp] ; 0-Open, 1-Save, 2-Dir |
38 | od_type equ dword [ebp] ; 0-Open, 1-Save, 2-Dir |
39 | od_procinfo equ dword [ebp+4] ; Process info area for function 9 |
39 | od_procinfo equ dword [ebp+4] ; Process info area for function 9 |
40 | od_com_area_name equ dword [ebp+8] ; Name for shared area |
40 | od_com_area_name equ dword [ebp+8] ; Name for shared area |
41 | od_com_area equ dword [ebp+12] ; Adress of shared area |
41 | od_com_area equ dword [ebp+12] ; Adress of shared area |
42 | od_opendir_pach equ dword [ebp+16] ; Temp area the directory for show |
42 | od_opendir_pach equ dword [ebp+16] ; Temp area the directory for show |
43 | od_dir_default_pach equ dword [ebp+20] ; Default path of directory, |
43 | od_dir_default_pach equ dword [ebp+20] ; Default path of directory, |
44 | od_start_path equ dword [ebp+24] ; Location path to OpenDialog |
44 | od_start_path equ dword [ebp+24] ; Location path to OpenDialog |
45 | od_draw_window equ dword [ebp+28] ; Adress of procedure - draw_window |
45 | od_draw_window equ dword [ebp+28] ; Adress of procedure - draw_window |
46 | od_status equ dword [ebp+32] ; 0-Cancel, 1-Get path OK, 2-Use alternatives |
46 | od_status equ dword [ebp+32] ; 0-Cancel, 1-Get path OK, 2-Use alternatives |
47 | od_openfile_pach equ dword [ebp+36] ; Getting path to file |
47 | od_openfile_pach equ dword [ebp+36] ; Getting path to file |
48 | od_filename_area equ dword [ebp+40] ; Adress of file name area |
48 | od_filename_area equ dword [ebp+40] ; Adress of file name area |
49 | od_filter_area equ dword [ebp+44] ; Adress of filter area |
49 | od_filter_area equ dword [ebp+44] ; Adress of filter area |
50 | ;***************************************************************************** |
50 | ;***************************************************************************** |
51 | .init: |
51 | .init: |
52 | pusha |
52 | pusha |
53 | mcall 9,od_procinfo,-1 |
53 | mcall 9,od_procinfo,-1 |
54 | mov ebx,[ebx+30] |
54 | mov ebx,[ebx+30] |
55 | mov edi,od_com_area_name |
55 | mov edi,od_com_area_name |
56 | add edi,7 |
56 | add edi,7 |
57 | std |
57 | std |
58 | mov ecx,4 |
58 | mov ecx,4 |
59 | @@: |
59 | @@: |
60 | mov al,bl |
60 | mov al,bl |
61 | and al,1111b |
61 | and al,1111b |
62 | add al,0x30 |
62 | add al,0x30 |
63 | stosb |
63 | stosb |
64 | mov al,bl |
64 | mov al,bl |
65 | shr al,4 |
65 | shr al,4 |
66 | and al,1111b |
66 | and al,1111b |
67 | add al,0x30 |
67 | add al,0x30 |
68 | stosb |
68 | stosb |
69 | shr ebx,8 |
69 | shr ebx,8 |
70 | dec ecx |
70 | dec ecx |
71 | jnz @r |
71 | jnz @r |
72 | cld |
72 | cld |
73 | 73 | ||
74 | mcall 68,22,od_com_area_name,8192,0x09 |
74 | mcall 68,22,od_com_area_name,8192,0x09 |
75 | mov od_com_area,eax |
75 | mov od_com_area,eax |
76 | 76 | ||
77 | mov esi,od_openfile_pach |
77 | mov esi,od_openfile_pach |
78 | mov edi,od_opendir_pach |
78 | mov edi,od_opendir_pach |
79 | call .copy_dir_path |
79 | call .copy_dir_path |
80 | 80 | ||
81 | OpenDialog_exit |
81 | OpenDialog_exit |
82 | ;***************************************************************************** |
82 | ;***************************************************************************** |
83 | ;***************************************************************************** |
83 | ;***************************************************************************** |
84 | .start: |
84 | .start: |
85 | pusha |
85 | pusha |
86 | mov eax,od_com_area |
86 | mov eax,od_com_area |
87 | test eax,eax |
87 | test eax,eax |
88 | jz .1 |
88 | jz .1 |
89 | mov ebx,od_type |
89 | mov ebx,od_type |
90 | mov [eax+2],bx |
90 | mov [eax+2],bx |
91 | 91 | ||
92 | mov [eax],word 2 ; folder for open |
92 | mov [eax],word 2 ; folder for open |
93 | mov edi,eax |
93 | mov edi,eax |
94 | add edi,4 |
94 | add edi,4 |
95 | 95 | ||
96 | mov esi,od_opendir_pach |
96 | mov esi,od_opendir_pach |
97 | xor eax,eax |
97 | xor eax,eax |
98 | mov al,[esi] |
98 | mov al,[esi] |
99 | test eax,eax |
99 | test eax,eax |
100 | jnz @f |
100 | jnz @f |
101 | mov esi,od_dir_default_pach ;communication_area_default_pach |
101 | mov esi,od_dir_default_pach ;communication_area_default_pach |
102 | @@: |
102 | @@: |
103 | call .copy |
103 | call .copy |
104 | ;---------------------------------------------- |
104 | ;---------------------------------------------- |
105 | ; copy file name to shared area |
105 | ; copy file name to shared area |
106 | cmp od_type,dword 2 |
106 | cmp od_type,dword 2 |
107 | je .4 |
107 | je .4 |
108 | mov edi,od_com_area |
108 | mov edi,od_com_area |
109 | add edi,4096-256 |
109 | add edi,4096-256 |
110 | 110 | ||
111 | mov esi,od_filename_area |
111 | mov esi,od_filename_area |
112 | ; xor eax,eax |
- | |
113 | ; mov al,[esi] |
- | |
114 | ; test eax,eax |
- | |
115 | test esi,esi |
112 | test esi,esi |
116 | jnz @f |
113 | jnz @f |
117 | mov esi,.null |
114 | mov esi,.null |
118 | @@: |
115 | @@: |
119 | call .copy |
116 | call .copy |
120 | .4: |
117 | .4: |
121 | ;---------------------------------------------- |
118 | ;---------------------------------------------- |
122 | cmp od_type,dword 2 |
119 | cmp od_type,dword 2 |
123 | je @f |
120 | je @f |
124 | call .get_filter_data |
121 | call .get_filter_data |
125 | @@: |
122 | @@: |
126 | ;---------------------------------------------- |
123 | ;---------------------------------------------- |
127 | mov eax,od_com_area_name |
124 | mov eax,od_com_area_name |
128 | mov [start_open_dialog.parameter],eax |
125 | mov [start_open_dialog.parameter],eax |
129 | 126 | ||
130 | mov eax,od_start_path |
127 | mov eax,od_start_path |
131 | mov [start_open_dialog.name],eax |
128 | mov [start_open_dialog.name],eax |
132 | 129 | ||
133 | mcall 70,start_open_dialog |
130 | mcall 70,start_open_dialog |
134 | shr eax,31 |
131 | shr eax,31 |
135 | test eax,eax |
132 | test eax,eax |
136 | jnz .1 |
133 | jnz .1 |
137 | jmp .still |
- | |
138 | .red: |
- | |
139 | pusha |
- | |
140 | call od_draw_window |
- | |
141 | popa |
- | |
142 | .still: |
134 | .still: |
143 | mcall 23,50 |
135 | mcall 23,50 |
144 | cmp eax,1 |
136 | cmp eax,1 |
145 | je .red |
137 | jne @f |
- | 138 | pusha |
|
- | 139 | call od_draw_window |
|
- | 140 | popa |
|
- | 141 | @@: |
|
146 | mov eax,od_com_area |
142 | mov eax,od_com_area |
147 | movzx ebx,word [eax] |
143 | movzx ebx,word [eax] |
148 | test ebx,ebx |
144 | test ebx,ebx |
149 | jz .still |
145 | jz .still |
150 | cmp ebx,3 |
146 | cmp ebx,3 |
151 | je .2 |
147 | je .2 |
152 | cmp ebx,1 |
148 | cmp ebx,1 |
153 | jne .still |
149 | jne .still |
154 | 150 | ||
155 | mov esi,od_com_area |
151 | mov esi,od_com_area |
156 | add esi,4 |
152 | add esi,4 |
157 | mov edi,od_openfile_pach |
153 | mov edi,od_openfile_pach |
158 | call .copy |
154 | call .copy |
159 | mov od_status,1 |
155 | mov od_status,1 |
160 | mov esi,od_openfile_pach |
156 | mov esi,od_openfile_pach |
161 | mov edi,od_opendir_pach |
157 | mov edi,od_opendir_pach |
162 | call .copy_dir_path |
158 | call .copy_dir_path |
163 | ;---------------------------------------------- |
159 | ;---------------------------------------------- |
164 | ; copy file name from shared area |
160 | ; copy file name from shared area |
165 | cmp od_type,dword 2 |
161 | cmp od_type,dword 2 |
166 | je @f |
162 | je @f |
167 | mov esi,od_com_area |
163 | mov esi,od_com_area |
168 | add esi,4096-256 |
164 | add esi,4096-256 |
169 | mov edi,od_filename_area |
165 | mov edi,od_filename_area |
170 | ; xor eax,eax |
166 | ; xor eax,eax |
171 | ; mov al,[edi] |
167 | ; mov al,[edi] |
172 | ; test eax,eax |
168 | ; test eax,eax |
173 | test edi,edi |
169 | test edi,edi |
174 | jz @f |
170 | jz @f |
175 | call .copy |
171 | call .copy |
176 | @@: |
172 | @@: |
177 | ;---------------------------------------------- |
173 | ;---------------------------------------------- |
178 | jmp .3 |
174 | jmp .3 |
179 | .2: |
175 | .2: |
180 | mov od_status,0 |
176 | mov od_status,0 |
181 | jmp .3 |
177 | jmp .3 |
182 | .1: |
178 | .1: |
183 | mov od_status,2 |
179 | mov od_status,2 |
184 | .3: |
180 | .3: |
185 | OpenDialog_exit |
181 | OpenDialog_exit |
186 | ;---------------------------------------------- |
182 | ;---------------------------------------------- |
187 | .null: |
183 | .null: |
188 | dd 0 |
184 | dd 0 |
189 | ;---------------------------------------------- |
185 | ;---------------------------------------------- |
190 | .get_filter_data: |
186 | .get_filter_data: |
191 | mov edi,od_com_area |
187 | mov edi,od_com_area |
192 | test edi,edi |
188 | test edi,edi |
193 | jnz @f |
189 | jnz @f |
194 | ; add esp,4 |
190 | ; add esp,4 |
195 | ; jmp still |
191 | ; jmp still |
196 | ret |
192 | ret |
197 | @@: |
193 | @@: |
198 | add edi,4096+4 |
194 | add edi,4096+4 |
199 | mov esi,od_filter_area |
195 | mov esi,od_filter_area |
200 | mov ecx,[esi] |
196 | mov ecx,[esi] |
201 | test ecx,ecx |
197 | test ecx,ecx |
202 | jnz @f |
198 | jnz @f |
203 | mov edi,od_com_area |
199 | mov edi,od_com_area |
204 | mov [edi+4096],dword 0 |
200 | mov [edi+4096],dword 0 |
205 | ret |
201 | ret |
206 | @@: |
202 | @@: |
207 | inc ecx |
203 | inc ecx |
208 | cld |
204 | cld |
209 | rep movsb |
205 | rep movsb |
210 | mov edi,od_com_area |
206 | mov edi,od_com_area |
211 | mov [edi+4096],dword 1 |
207 | mov [edi+4096],dword 1 |
212 | ret |
208 | ret |
213 | ;---------------------------------------------- |
209 | ;---------------------------------------------- |
214 | .copy: |
210 | .copy: |
215 | xor eax,eax |
211 | xor eax,eax |
216 | cld |
212 | cld |
217 | @@: |
213 | @@: |
218 | lodsb |
214 | lodsb |
219 | stosb |
215 | stosb |
220 | test eax,eax |
216 | test eax,eax |
221 | jnz @b |
217 | jnz @b |
222 | ret |
218 | ret |
223 | ;---------------------------------------------- |
219 | ;---------------------------------------------- |
224 | .copy_dir_path: |
220 | .copy_dir_path: |
225 | xor eax,eax |
221 | xor eax,eax |
226 | cmp [esi],al |
222 | cmp [esi],al |
227 | jne @f |
223 | jne @f |
228 | mov [edi],al |
224 | mov [edi],al |
229 | mov [ebx],al |
225 | mov [ebx],al |
230 | xor ebx,ebx |
226 | xor ebx,ebx |
231 | inc ebx |
227 | inc ebx |
232 | ret |
228 | ret |
233 | @@: |
229 | @@: |
234 | cld |
230 | cld |
235 | lodsb |
231 | lodsb |
236 | stosb |
232 | stosb |
237 | test eax,eax |
233 | test eax,eax |
238 | jnz @b |
234 | jnz @b |
239 | cmp od_type,dword 2 |
235 | cmp od_type,dword 2 |
240 | jne @f |
236 | jne @f |
241 | ret |
237 | ret |
242 | @@: |
238 | @@: |
243 | mov esi,edi |
239 | mov esi,edi |
244 | dec esi |
240 | dec esi |
245 | @@: |
241 | @@: |
246 | std |
242 | std |
247 | lodsb |
243 | lodsb |
248 | cmp al,'/' |
244 | cmp al,'/' |
249 | jnz @b |
245 | jnz @b |
250 | 246 | ||
251 | mov [esi+1],byte 0 |
247 | mov [esi+1],byte 0 |
252 | cld |
248 | cld |
253 | ret |
249 | ret |
254 | ;---------------------------------------------- |
250 | ;---------------------------------------------- |
255 | align 4 |
251 | align 4 |
256 | start_open_dialog: |
252 | start_open_dialog: |
257 | .subfunction dd 7 |
253 | .subfunction dd 7 |
258 | .flags dd 0 |
254 | .flags dd 0 |
259 | .parameter dd 0 ;od_com_area_name |
255 | .parameter dd 0 ;od_com_area_name |
260 | .reserved1 dd 0 |
256 | .reserved1 dd 0 |
261 | .reserved2 dd 0 |
257 | .reserved2 dd 0 |
262 | db 0 |
258 | db 0 |
263 | .name: dd 0 ;od_start_path |
259 | .name: dd 0 ;od_start_path |
264 | } |
260 | } |
265 | ;***************************************************************************** |
261 | ;***************************************************************************** |
266 | macro init_OpenDialog od_ptr |
262 | macro init_OpenDialog od_ptr |
267 | { |
263 | { |
268 | mov ebp,od_ptr |
264 | mov ebp,od_ptr |
269 | call OpenDialog.init |
265 | call OpenDialog.init |
270 | } |
266 | } |
271 | ;***************************************************************************** |
267 | ;***************************************************************************** |
272 | macro start_OpenDialog od_ptr |
268 | macro start_OpenDialog od_ptr |
273 | { |
269 | { |
274 | mov ebp,od_ptr |
270 | mov ebp,od_ptr |
275 | call OpenDialog.start |
271 | call OpenDialog.start |
276 | } |
272 | } |
277 | ;***************************************************************************** |
273 | ;***************************************************************************** |