Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
178 | heavyiron | 1 | ;----------------------------------------------------------------------------- |
2 | func save_file ;////////////////////////////////////////////////////////////// |
||
3 | ;----------------------------------------------------------------------------- |
||
4 | |||
5 | mov esi,tb_opensave.text |
||
6 | mov edi,f_info.path |
||
7 | movzx ecx,[tb_opensave.length] |
||
8 | mov [f_info.length],ecx |
||
9 | cld |
||
10 | rep movsb |
||
11 | mov byte[edi],0 |
||
12 | |||
13 | mov esi,AREA_EDIT ; 0x70000 = 448 Kbytes (maximum) |
||
14 | mov edi,AREA_TEMP |
||
15 | |||
16 | .new_string: |
||
17 | call save_string |
||
18 | cmp dword[esi],0 |
||
19 | jne .new_string |
||
20 | sub edi,AREA_TEMP+2 ; minus last CRLF |
||
21 | ;! mov [filelen],edi |
||
22 | cmp byte[f_info.path],'/' |
||
23 | je .systree_save |
||
24 | mcall 33,f_info.path,AREA_TEMP,edi,0;[filelen],0 |
||
25 | or eax,eax |
||
26 | jz .exit |
||
27 | ; call file_not_found |
||
28 | jmp .exit.2 |
||
29 | |||
30 | .systree_save: |
||
31 | ;! mov eax,[filelen] |
||
32 | ; mov [f_info+8],edi ;! eax |
||
33 | ; mov [f_info+0],1 |
||
34 | ; mov esi,s_fname |
||
35 | ; mov edi,f_info.path |
||
36 | ; mov ecx,PATHL |
||
37 | ; cld |
||
38 | ; rep movsb |
||
39 | ;mcall 58,f_info |
||
40 | |||
41 | mov [f_info70+0],2 |
||
42 | mov [f_info70+12],edi |
||
43 | mov [f_info70+16],AREA_TEMP |
||
44 | mov byte[f_info70+20],0 |
||
45 | mov [f_info70+21],f_info.path |
||
46 | mcall 70,f_info70 |
||
47 | |||
48 | call set_status_fs_error |
||
49 | |||
50 | or eax,eax |
||
51 | jnz .exit.2 |
||
52 | |||
53 | .exit: |
||
54 | mov [modified],0 |
||
55 | clc |
||
56 | ret |
||
57 | |||
58 | .exit.2: |
||
59 | stc |
||
60 | ret |
||
61 | endf |
||
62 | |||
63 | ;----------------------------------------------------------------------------- |
||
64 | func save_string ;//////////////////////////////////////////////////////////// |
||
65 | ;----------------------------------------------------------------------------- |
||
66 | movzx ecx,word[esi] |
||
67 | test dword[esi],0x00010000 |
||
68 | jz @f |
||
69 | or dword[esi],0x00020000 |
||
70 | @@: add esi,4 |
||
71 | ; mov ecx,eax |
||
72 | |||
73 | @@: cmp byte[esi+ecx-1],' ' |
||
74 | jne @f |
||
75 | loop @b |
||
76 | @@: jecxz .endcopy |
||
77 | xor edx,edx |
||
78 | mov ebx,edx |
||
79 | mov ah,dl |
||
80 | |||
81 | .next_char: |
||
82 | mov al,[esi+ebx] |
||
83 | inc ebx |
||
84 | ; cmp [asm_mode],0 |
||
85 | ; je .put |
||
86 | test [options],OPTS_OPTIMSAVE |
||
87 | jz .put |
||
88 | test ah,00000001b |
||
89 | jnz .char |
||
90 | cmp al,'"' |
||
91 | jne @f |
||
92 | xor ah,00000100b |
||
93 | jmp .char |
||
94 | @@: cmp al,"'" |
||
95 | jne @f |
||
96 | xor ah,00000010b |
||
97 | jmp .char |
||
98 | @@: test ah,00000110b |
||
99 | jnz .char |
||
100 | cmp al,';' |
||
101 | jne @f |
||
102 | test ah,00000001b |
||
103 | jnz .char |
||
104 | xor ah,00000001b |
||
105 | jmp .char |
||
106 | @@: cmp al,' ' |
||
107 | jne .char |
||
108 | inc edx |
||
109 | test ebx,ATABW-1 |
||
110 | jnz @f |
||
111 | dec edx |
||
112 | jle .put |
||
113 | mov al,9 |
||
114 | xor edx,edx |
||
115 | jmp .put |
||
116 | .char: |
||
117 | or edx,edx |
||
118 | jz .put |
||
119 | push ecx eax |
||
120 | mov ecx,edx |
||
121 | mov al,' ' |
||
122 | rep stosb |
||
123 | pop eax ecx |
||
124 | xor edx,edx |
||
125 | .put: |
||
126 | stosb |
||
127 | @@: loop .next_char |
||
128 | |||
129 | .endcopy: |
||
130 | mov eax,0x0A0D |
||
131 | stosw |
||
132 | movzx eax,word[esi-4] |
||
133 | add esi,eax;[esi-4] |
||
134 | ret |
||
135 | endf |
||
136 | |||
137 | func set_status_fs_error |
||
138 | push eax |
||
139 | mov esi,s_fs_error |
||
140 | @@: dec eax |
||
141 | js @f |
||
142 | movzx ecx,byte[esi] |
||
143 | lea esi,[esi+ecx+1] |
||
144 | jmp @b |
||
145 | @@: inc esi |
||
146 | mov [s_status],esi |
||
147 | pop eax |
||
148 | call writepos |
||
149 | ret |
||
150 | endf |
||
151 | |||
152 | ;----------------------------------------------------------------------------- |
||
153 | func load_hd_file ;/////////////////////////////////////////////////////////// |
||
154 | ;----------------------------------------------------------------------------- |
||
155 | mov [f_info+0],0 |
||
156 | mov [f_info+8],300000/512 |
||
157 | ; mov esi,s_fname |
||
158 | ; mov edi,f_info.path;pathfile_read |
||
159 | ; mov ecx,PATHL |
||
160 | ; cld |
||
161 | ; rep movsb |
||
162 | ;mcall 58,f_info ; fileinfo_read |
||
163 | |||
164 | mov [f_info70+0],0 |
||
165 | mov [f_info70+4],0 |
||
166 | mov [f_info70+8],0 |
||
167 | mov [f_info70+12],300000;/512 |
||
168 | mov [f_info70+16],AREA_TEMP |
||
169 | mov byte[f_info70+20],0 |
||
170 | mov [f_info70+21],f_info.path |
||
171 | mcall 70,f_info70 |
||
172 | |||
173 | call set_status_fs_error |
||
174 | |||
175 | xchg eax,ebx |
||
176 | inc eax |
||
177 | test ebx,ebx |
||
178 | je load_file.file_found |
||
179 | cmp ebx,6 ;// ATV driver fix (6 instead of 5) |
||
180 | je load_file.file_found |
||
181 | ; jmp file_not_found |
||
182 | stc |
||
183 | ret |
||
184 | endf |
||
185 | |||
186 | ;----------------------------------------------------------------------------- |
||
187 | func load_file ;////////////////////////////////////////////////////////////// |
||
188 | ;----------------------------------------------------------------------------- |
||
189 | |||
190 | mov esi,tb_opensave.text |
||
191 | mov edi,f_info.path |
||
192 | movzx ecx,[tb_opensave.length] |
||
193 | mov [f_info.length],ecx |
||
194 | cld |
||
195 | rep movsb |
||
196 | mov byte[edi],0 |
||
197 | |||
198 | cmp byte[f_info.path],'/' |
||
199 | je load_hd_file |
||
200 | |||
201 | mcall 6,f_info.path,0,16800,AREA_TEMP ; 6 = open file |
||
202 | inc eax ; eax = -1 -> file not found |
||
203 | jnz .file_found |
||
204 | ; jmp file_not_found |
||
205 | stc |
||
206 | ret |
||
207 | |||
208 | .file_found: |
||
209 | dec eax |
||
210 | mov [filesize],eax |
||
211 | mov [lines],1 |
||
212 | mov [columns],0 |
||
213 | mov esi,AREA_TEMP |
||
214 | mov edi,AREA_EDIT |
||
215 | mov edx,eax |
||
216 | |||
217 | .next_line: |
||
218 | mov ebx,edi |
||
219 | add edi,4 |
||
220 | .next_char: |
||
221 | or edx,edx |
||
222 | jle .exit |
||
223 | lodsb |
||
224 | dec edx |
||
225 | cmp al,13 |
||
226 | je .CR |
||
227 | cmp al,10 |
||
228 | je .LF |
||
229 | cmp al,9 |
||
230 | je .TB |
||
231 | cmp al,0 |
||
232 | je .exit |
||
233 | stosb |
||
234 | jmp .next_char |
||
235 | |||
236 | .exit: |
||
237 | mov ecx,10 |
||
238 | mov al,' ' |
||
239 | rep stosb |
||
240 | lea eax,[edi-4] |
||
241 | sub eax,ebx |
||
242 | mov [ebx],eax |
||
243 | mov dword[ebx+eax+4],0 |
||
244 | sub eax,10 |
||
245 | jnz @f |
||
246 | inc eax |
||
247 | @@: cmp eax,[columns] |
||
248 | jbe @f |
||
249 | mov [columns],eax |
||
250 | @@: mov [modified],0 |
||
251 | clc |
||
252 | ret |
||
253 | |||
254 | .CR: cmp byte[esi],10 |
||
255 | jne .LF |
||
256 | lodsb |
||
257 | dec edx |
||
258 | .LF: mov ecx,10 |
||
259 | mov al,' ' |
||
260 | rep stosb |
||
261 | lea eax,[edi-4] |
||
262 | sub eax,ebx |
||
263 | mov [ebx],eax |
||
264 | inc [lines] |
||
265 | add eax,-10 |
||
266 | cmp eax,[columns] |
||
267 | jbe .next_line |
||
268 | mov [columns],eax |
||
269 | jmp .next_line |
||
270 | |||
271 | .TB: lea eax,[edi-4] |
||
272 | sub eax,ebx |
||
273 | mov ecx,eax |
||
274 | add ecx,ATABW |
||
275 | and ecx,not(ATABW-1) |
||
276 | sub ecx,eax |
||
277 | mov al,' ' |
||
278 | rep stosb |
||
279 | jmp .next_char |
||
280 | endf |
||
281 | |||
282 | ;----------------------------------------------------------------------------- |
||
283 | func new_file ;/////////////////////////////////////////////////////////////// |
||
284 | ;----------------------------------------------------------------------------- |
||
285 | ; mcall 55,eax,error_beep ; beep |
||
286 | mov [lines],1 ; open empty document |
||
287 | mov [columns],1 |
||
288 | xor eax,eax |
||
289 | mov [top_line],eax |
||
290 | mov [pos.x],eax |
||
291 | mov [pos.y],eax |
||
292 | mov edi,AREA_EDIT+4 |
||
293 | mov ecx,10 |
||
294 | mov [edi-4],ecx |
||
295 | mov [edi+10],eax |
||
296 | mov al,' ' |
||
297 | cld |
||
298 | rep stosb |
||
299 | |||
300 | mov [f_info.length],0 |
||
301 | mov [modified],0 |
||
302 | mov [asm_mode],0 |
||
303 | call update_caption |
||
304 | call drawwindow |
||
305 | |||
306 | ret |
||
307 | endf |