Rev 178 | Go to most recent revision | Details | Compare with Previous | 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 | |||
259 | mikedld | 13 | mov esi,[cur_tab.Editor.Data] ;! AREA_EDIT ; 0x70000 = 448 Kbytes (maximum) |
14 | mov edi,0 ;!!! AREA_TEMP |
||
178 | heavyiron | 15 | |
16 | .new_string: |
||
17 | call save_string |
||
18 | cmp dword[esi],0 |
||
19 | jne .new_string |
||
259 | mikedld | 20 | sub edi,0 ;!!! AREA_TEMP+2 ; minus last CRLF |
178 | heavyiron | 21 | ;! mov [filelen],edi |
22 | cmp byte[f_info.path],'/' |
||
23 | je .systree_save |
||
259 | mikedld | 24 | mcall 33,f_info.path,0,edi,0 ;!!! AREA_TEMP,edi,0;[filelen],0 |
178 | heavyiron | 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 |
||
259 | mikedld | 43 | mov [f_info70+16],0 ;!!! AREA_TEMP |
178 | heavyiron | 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: |
||
259 | mikedld | 54 | mov [cur_tab.Editor.Modified],0 ;! [modified],0 |
178 | heavyiron | 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 |
||
259 | mikedld | 148 | call draw_statusbar |
178 | heavyiron | 149 | ret |
150 | endf |
||
151 | |||
152 | ;----------------------------------------------------------------------------- |
||
259 | mikedld | 153 | func load_file ;////////////////////////////////////////////////////////////// |
178 | heavyiron | 154 | ;----------------------------------------------------------------------------- |
259 | mikedld | 155 | mov esi,tb_opensave.text |
156 | mov edi,f_info.path |
||
157 | movzx ecx,[tb_opensave.length] |
||
158 | mov [f_info.length],ecx |
||
159 | cld |
||
160 | rep movsb |
||
161 | mov byte[edi],0 |
||
178 | heavyiron | 162 | |
259 | mikedld | 163 | xor eax,eax |
164 | mov [f_info70+0],5 |
||
165 | mov [f_info70+4],eax |
||
166 | mov [f_info70+8],eax |
||
167 | mov [f_info70+12],eax |
||
168 | mov [f_info70+16],file_info |
||
169 | mov byte[f_info70+20],al |
||
178 | heavyiron | 170 | mov [f_info70+21],f_info.path |
171 | mcall 70,f_info70 |
||
259 | mikedld | 172 | mov [f_info70+0],0 |
173 | mov eax,dword[file_info.Size] |
||
174 | mov [f_info70+12],eax |
||
175 | call mem.Alloc |
||
176 | mov [f_info70+16],eax |
||
177 | mcall 70,f_info70 |
||
178 | heavyiron | 178 | |
179 | call set_status_fs_error |
||
180 | |||
259 | mikedld | 181 | mov esi,[f_info70+16] |
182 | |||
178 | heavyiron | 183 | xchg eax,ebx |
184 | test ebx,ebx |
||
259 | mikedld | 185 | je .file_found |
178 | heavyiron | 186 | cmp ebx,6 ;// ATV driver fix (6 instead of 5) |
259 | mikedld | 187 | je .file_found |
188 | |||
189 | mov eax,[f_info70+16] |
||
190 | call mem.Free |
||
178 | heavyiron | 191 | stc |
192 | ret |
||
193 | |||
259 | mikedld | 194 | .file_found: |
195 | mov ecx,eax |
||
196 | call create_tab |
||
197 | push ecx esi edi |
||
178 | heavyiron | 198 | mov esi,tb_opensave.text |
259 | mikedld | 199 | lea edi,[ebp+TABITEM.Editor.FilePath] |
200 | ;mov ecx,[f_info.length] |
||
178 | heavyiron | 201 | movzx ecx,[tb_opensave.length] |
202 | rep movsb |
||
203 | mov byte[edi],0 |
||
259 | mikedld | 204 | lea edi,[ebp+TABITEM.Editor.FilePath] |
205 | movzx ecx,[tb_opensave.length] |
||
206 | @@: cmp byte[edi+ecx-1],'/' |
||
207 | je @f |
||
208 | dec ecx |
||
209 | jmp @b |
||
210 | @@: mov [ebp+TABITEM.Editor.FileName],ecx |
||
211 | call flush_cur_tab |
||
212 | pop edi esi ecx |
||
213 | call load_from_memory |
||
214 | mov eax,[f_info70+16] |
||
215 | call mem.Free |
||
216 | clc |
||
217 | ret |
||
218 | endf |
||
178 | heavyiron | 219 | |
259 | mikedld | 220 | ;----------------------------------------------------------------------------- |
221 | func load_from_memory ;/////////////////////////////////////////////////////// |
||
222 | ;----------------------------------------------------------------------------- |
||
223 | ; ECX = data length |
||
224 | ; ESI = data pointer |
||
225 | ; EBP = EDITOR* |
||
226 | ;----------------------------------------------------------------------------- |
||
227 | call get_lines_in_file |
||
228 | mov [ebp+EDITOR.Lines],eax |
||
229 | imul ebx,eax,14 |
||
230 | add ebx,ecx |
||
231 | mov eax,[ebp+EDITOR.Data] |
||
232 | call mem.ReAlloc |
||
233 | mov [ebp+EDITOR.Data],eax |
||
178 | heavyiron | 234 | |
259 | mikedld | 235 | mov [ebp+EDITOR.Columns],0 |
236 | mov edi,eax |
||
237 | mov edx,ecx |
||
178 | heavyiron | 238 | |
239 | .next_line: |
||
240 | mov ebx,edi |
||
241 | add edi,4 |
||
242 | .next_char: |
||
243 | or edx,edx |
||
244 | jle .exit |
||
245 | lodsb |
||
246 | dec edx |
||
247 | cmp al,13 |
||
248 | je .CR |
||
249 | cmp al,10 |
||
250 | je .LF |
||
251 | cmp al,9 |
||
252 | je .TB |
||
253 | cmp al,0 |
||
254 | je .exit |
||
255 | stosb |
||
256 | jmp .next_char |
||
257 | |||
258 | .exit: |
||
259 | mov ecx,10 |
||
260 | mov al,' ' |
||
261 | rep stosb |
||
262 | lea eax,[edi-4] |
||
263 | sub eax,ebx |
||
264 | mov [ebx],eax |
||
265 | mov dword[ebx+eax+4],0 |
||
266 | sub eax,10 |
||
267 | jnz @f |
||
268 | inc eax |
||
259 | mikedld | 269 | @@: cmp eax,[ebp+EDITOR.Columns] ;! eax,[columns] |
178 | heavyiron | 270 | jbe @f |
259 | mikedld | 271 | mov [ebp+EDITOR.Columns],eax ;! [columns],eax |
272 | @@: mov [ebp+EDITOR.Modified],0 ;! [modified],0 |
||
178 | heavyiron | 273 | ret |
274 | |||
275 | .CR: cmp byte[esi],10 |
||
276 | jne .LF |
||
277 | lodsb |
||
278 | dec edx |
||
279 | .LF: mov ecx,10 |
||
280 | mov al,' ' |
||
281 | rep stosb |
||
282 | lea eax,[edi-4] |
||
283 | sub eax,ebx |
||
284 | mov [ebx],eax |
||
259 | mikedld | 285 | ;inc [cur_tab.Editor.Lines] ;! [lines] |
178 | heavyiron | 286 | add eax,-10 |
259 | mikedld | 287 | cmp eax,[ebp+EDITOR.Columns] ;! eax,[columns] |
178 | heavyiron | 288 | jbe .next_line |
259 | mikedld | 289 | mov [ebp+EDITOR.Columns],eax ;! [columns],eax |
178 | heavyiron | 290 | jmp .next_line |
291 | |||
292 | .TB: lea eax,[edi-4] |
||
293 | sub eax,ebx |
||
294 | mov ecx,eax |
||
295 | add ecx,ATABW |
||
296 | and ecx,not(ATABW-1) |
||
297 | sub ecx,eax |
||
298 | mov al,' ' |
||
299 | rep stosb |
||
300 | jmp .next_char |
||
301 | endf |