Rev 297 | Rev 617 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 297 | Rev 327 | ||
---|---|---|---|
1 | ;----------------------------------------------------------------------------- |
1 | ;----------------------------------------------------------------------------- |
2 | func clear_selection ;//////////////////////////////////////////////////////// |
2 | func clear_selection ;//////////////////////////////////////////////////////// |
3 | ;----------------------------------------------------------------------------- |
3 | ;----------------------------------------------------------------------------- |
4 | push eax ebx |
4 | push eax ebx |
5 | mov eax,[cur_editor.SelStart.Y] |
5 | mov eax,[cur_editor.SelStart.Y] |
6 | mov ebx,[cur_editor.Caret.Y] |
6 | mov ebx,[cur_editor.Caret.Y] |
7 | cmp eax,ebx |
7 | cmp eax,ebx |
8 | jle @f |
8 | jle @f |
9 | xchg eax,ebx |
9 | xchg eax,ebx |
10 | @@: push [cur_editor.Caret.X] [cur_editor.Caret.Y] |
10 | @@: push [cur_editor.Caret.X] [cur_editor.Caret.Y] |
11 | pop [cur_editor.SelStart.Y] [cur_editor.SelStart.X] |
11 | pop [cur_editor.SelStart.Y] [cur_editor.SelStart.X] |
12 | pop ebx eax |
12 | pop ebx eax |
13 | ret |
13 | ret |
14 | endf |
14 | endf |
15 | 15 | ||
16 | ;----------------------------------------------------------------------------- |
16 | ;----------------------------------------------------------------------------- |
17 | func pt_in_rect ;///////////////////////////////////////////////////////////// |
17 | func pt_in_rect ;///////////////////////////////////////////////////////////// |
18 | ;----------------------------------------------------------------------------- |
18 | ;----------------------------------------------------------------------------- |
19 | cmp eax,[ecx+0x0] |
19 | cmp eax,[ecx+0x0] |
20 | jl @f |
20 | jl @f |
21 | cmp ebx,[ecx+0x4] |
21 | cmp ebx,[ecx+0x4] |
22 | jl @f |
22 | jl @f |
23 | cmp eax,[ecx+0x8] |
23 | cmp eax,[ecx+0x8] |
24 | jg @f |
24 | jg @f |
25 | cmp ebx,[ecx+0xC] |
25 | cmp ebx,[ecx+0xC] |
26 | jg @f |
26 | jg @f |
27 | stc |
27 | stc |
28 | ret |
28 | ret |
29 | @@: clc |
29 | @@: clc |
30 | ret |
30 | ret |
31 | endf |
31 | endf |
32 | 32 | ||
33 | ;----------------------------------------------------------------------------- |
33 | ;----------------------------------------------------------------------------- |
34 | func check_bottom_right ;///////////////////////////////////////////////////// |
34 | func check_bottom_right ;///////////////////////////////////////////////////// |
35 | ;----------------------------------------------------------------------------- |
35 | ;----------------------------------------------------------------------------- |
36 | push eax |
36 | push eax |
37 | mov eax,[cur_editor.TopLeft.Y] |
37 | mov eax,[cur_editor.TopLeft.Y] |
38 | add eax,[lines.scr] |
38 | add eax,[lines.scr] |
39 | cmp eax,[cur_editor.Lines.Count] |
39 | cmp eax,[cur_editor.Lines.Count] |
40 | jbe .lp1 |
40 | jbe .lp1 |
41 | mov eax,[cur_editor.Lines.Count] |
41 | mov eax,[cur_editor.Lines.Count] |
42 | sub eax,[lines.scr] |
42 | sub eax,[lines.scr] |
43 | jns @f |
43 | jns @f |
44 | xor eax,eax |
44 | xor eax,eax |
45 | @@: mov [cur_editor.TopLeft.Y],eax |
45 | @@: mov [cur_editor.TopLeft.Y],eax |
46 | .lp1: mov eax,[cur_editor.TopLeft.X] |
46 | .lp1: mov eax,[cur_editor.TopLeft.X] |
47 | add eax,[columns.scr] |
47 | add eax,[columns.scr] |
48 | cmp eax,[cur_editor.Columns.Count] |
48 | cmp eax,[cur_editor.Columns.Count] |
49 | jbe .exit |
49 | jbe .exit |
50 | mov eax,[cur_editor.Columns.Count] |
50 | mov eax,[cur_editor.Columns.Count] |
51 | sub eax,[columns.scr] |
51 | sub eax,[columns.scr] |
52 | jns @f |
52 | jns @f |
53 | xor eax,eax |
53 | xor eax,eax |
54 | @@: mov [cur_editor.TopLeft.X],eax |
54 | @@: mov [cur_editor.TopLeft.X],eax |
55 | .exit: |
55 | .exit: |
56 | pop eax |
56 | pop eax |
57 | ret |
57 | ret |
58 | endf |
58 | endf |
59 | 59 | ||
60 | ;----------------------------------------------------------------------------- |
60 | ;----------------------------------------------------------------------------- |
61 | func get_real_length ;//////////////////////////////////////////////////////// |
61 | func get_real_length ;//////////////////////////////////////////////////////// |
62 | ;----------------------------------------------------------------------------- |
62 | ;----------------------------------------------------------------------------- |
63 | movzx eax,word[esi] |
63 | movzx eax,word[esi] |
64 | @@: cmp byte[esi+eax+4-1],' ' |
64 | @@: cmp byte[esi+eax+4-1],' ' |
65 | jne @f |
65 | jne @f |
66 | dec eax |
66 | dec eax |
67 | jnz @b |
67 | jnz @b |
68 | @@: ret |
68 | @@: ret |
69 | endf |
69 | endf |
70 | 70 | ||
71 | ;----------------------------------------------------------------------------- |
71 | ;----------------------------------------------------------------------------- |
72 | func get_line_offset ;//////////////////////////////////////////////////////// |
72 | func get_line_offset ;//////////////////////////////////////////////////////// |
73 | ;----------------------------------------------------------------------------- |
73 | ;----------------------------------------------------------------------------- |
74 | ; Input: |
74 | ; Input: |
75 | ; ECX = line number |
75 | ; ECX = line number |
76 | ; Output: |
76 | ; Output: |
77 | ; ESI = line data offset |
77 | ; ESI = line data offset |
78 | ;----------------------------------------------------------------------------- |
78 | ;----------------------------------------------------------------------------- |
79 | push eax ecx |
79 | push eax ecx |
80 | mov esi,[cur_editor.Lines] |
80 | mov esi,[cur_editor.Lines] |
81 | @@: dec ecx |
81 | @@: dec ecx |
82 | js .exit |
82 | js .exit |
83 | movzx eax,word[esi] |
83 | movzx eax,word[esi] |
84 | lea esi,[esi+eax+4] |
84 | lea esi,[esi+eax+4] |
85 | jmp @b |
85 | jmp @b |
86 | .exit: |
86 | .exit: |
87 | pop ecx eax |
87 | pop ecx eax |
88 | ret |
88 | ret |
89 | endf |
89 | endf |
90 | 90 | ||
91 | ;----------------------------------------------------------------------------- |
91 | ;----------------------------------------------------------------------------- |
92 | func init_sel_vars ;////////////////////////////////////////////////////////// |
92 | func init_sel_vars ;////////////////////////////////////////////////////////// |
93 | ;----------------------------------------------------------------------------- |
93 | ;----------------------------------------------------------------------------- |
94 | pushad |
94 | pushad |
95 | mov [sel.selected],1 |
95 | mov [sel.selected],1 |
96 | mov eax,[ebp+EDITOR.SelStart.X] |
96 | mov eax,[ebp+EDITOR.SelStart.X] |
97 | mov ebx,[ebp+EDITOR.SelStart.Y] |
97 | mov ebx,[ebp+EDITOR.SelStart.Y] |
98 | mov ecx,[ebp+EDITOR.Caret.X] |
98 | mov ecx,[ebp+EDITOR.Caret.X] |
99 | mov edx,[ebp+EDITOR.Caret.Y] |
99 | mov edx,[ebp+EDITOR.Caret.Y] |
100 | cmp ebx,edx |
100 | cmp ebx,edx |
101 | jl .lp2 |
101 | jl .lp2 |
102 | jne @f |
102 | jne @f |
103 | cmp eax,ecx |
103 | cmp eax,ecx |
104 | jl .lp2 |
104 | jl .lp2 |
105 | jne .lp1 |
105 | jne .lp1 |
106 | dec [sel.selected] |
106 | dec [sel.selected] |
107 | jmp .lp2 |
107 | jmp .lp2 |
108 | @@: xchg ebx,edx |
108 | @@: xchg ebx,edx |
109 | .lp1: xchg eax,ecx |
109 | .lp1: xchg eax,ecx |
110 | .lp2: mov [sel.begin.x],eax |
110 | .lp2: mov [sel.begin.x],eax |
111 | mov [sel.begin.y],ebx |
111 | mov [sel.begin.y],ebx |
112 | mov [sel.end.x],ecx |
112 | mov [sel.end.x],ecx |
113 | mov [sel.end.y],edx |
113 | mov [sel.end.y],edx |
114 | popad |
114 | popad |
115 | ret |
115 | ret |
116 | endf |
116 | endf |
117 | 117 | ||
118 | ;----------------------------------------------------------------------------- |
118 | ;----------------------------------------------------------------------------- |
119 | func get_scroll_vars ;//////////////////////////////////////////////////////// |
119 | func get_scroll_vars ;//////////////////////////////////////////////////////// |
120 | ;----------------------------------------------------------------------------- |
120 | ;----------------------------------------------------------------------------- |
121 | ; Input: |
121 | ; Input: |
122 | ; EAX = maximum data size (units) |
122 | ; EAX = maximum data size (units) |
123 | ; EBX = visible data size (units) |
123 | ; EBX = visible data size (units) |
124 | ; ECX = current data position (units) |
124 | ; ECX = current data position (units) |
125 | ; EDX = scrolling area size (pixels) |
125 | ; EDX = scrolling area size (pixels) |
126 | ; Output: |
126 | ; Output: |
127 | ; EAX = srcoller offset (pixels) |
127 | ; EAX = srcoller offset (pixels) |
128 | ; EBX = scroller size (pixels) |
128 | ; EBX = scroller size (pixels) |
129 | ;----------------------------------------------------------------------------- |
129 | ;----------------------------------------------------------------------------- |
130 | push eax ebx edx |
130 | push eax ebx edx |
131 | ; sub eax,ebx |
131 | ; sub eax,ebx |
132 | mov esi,eax |
132 | mov esi,eax |
133 | mov eax,edx |
133 | mov eax,edx |
134 | imul ebx |
134 | imul ebx |
135 | idiv esi |
135 | idiv esi |
136 | cmp eax,[esp] |
136 | cmp eax,[esp] |
137 | jge .null |
137 | jge .null |
138 | cmp eax,AMINS |
138 | cmp eax,AMINS |
139 | jge @f |
139 | jge @f |
140 | neg eax |
140 | neg eax |
141 | add eax,AMINS |
141 | add eax,AMINS |
142 | sub [esp],eax |
142 | sub [esp],eax |
143 | mov eax,AMINS |
143 | mov eax,AMINS |
144 | @@: mov [esp+4],eax ; scroller size |
144 | @@: mov [esp+4],eax ; scroller size |
145 | mov eax,[esp] |
145 | mov eax,[esp] |
146 | imul ecx |
146 | imul ecx |
147 | idiv esi |
147 | idiv esi |
148 | or eax,eax |
148 | or eax,eax |
149 | jns @f |
149 | jns @f |
150 | xor eax,eax |
150 | xor eax,eax |
151 | @@: mov [esp+8],eax ; scroller offset |
151 | @@: mov [esp+8],eax ; scroller offset |
152 | add eax,[esp+4] |
152 | add eax,[esp+4] |
153 | cmp eax,[esp] |
153 | cmp eax,[esp] |
154 | jle @f |
154 | jle @f |
155 | @@: |
155 | @@: |
156 | pop edx ebx eax |
156 | pop edx ebx eax |
157 | ret |
157 | ret |
158 | .null: |
158 | .null: |
159 | mov dword[esp+4],0 |
159 | mov dword[esp+4],0 |
160 | mov dword[esp+8],0 |
160 | mov dword[esp+8],0 |
161 | jmp @b |
161 | jmp @b |
162 | endf |
162 | endf |
163 | 163 | ||
164 | ;----------------------------------------------------------------------------- |
164 | ;----------------------------------------------------------------------------- |
165 | func uint2strz ;////////////////////////////////////////////////////////////// |
165 | func uint2strz ;////////////////////////////////////////////////////////////// |
166 | ;----------------------------------------------------------------------------- |
166 | ;----------------------------------------------------------------------------- |
167 | dec ebx |
167 | dec ebx |
168 | jz @f |
168 | jz @f |
169 | xor edx,edx |
169 | xor edx,edx |
170 | div ecx |
170 | div ecx |
171 | push edx |
171 | push edx |
172 | call uint2strz |
172 | call uint2strz |
173 | pop eax |
173 | pop eax |
174 | @@: cmp al,10 |
174 | @@: cmp al,10 |
175 | sbb al,$69 |
175 | sbb al,$69 |
176 | das |
176 | das |
177 | stosb |
177 | stosb |
178 | ret |
178 | ret |
179 | endf |
179 | endf |
180 | 180 | ||
181 | ;----------------------------------------------------------------------------- |
181 | ;----------------------------------------------------------------------------- |
182 | func uint2str ;/////////////////////////////////////////////////////////////// |
182 | func uint2str ;/////////////////////////////////////////////////////////////// |
183 | ;----------------------------------------------------------------------------- |
183 | ;----------------------------------------------------------------------------- |
184 | cmp eax,ecx |
184 | cmp eax,ecx |
185 | jb @f |
185 | jb @f |
186 | xor edx,edx |
186 | xor edx,edx |
187 | div ecx |
187 | div ecx |
188 | push edx |
188 | push edx |
189 | call uint2str |
189 | call uint2str |
190 | pop eax |
190 | pop eax |
191 | @@: cmp al,10 |
191 | @@: cmp al,10 |
192 | sbb al,$69 |
192 | sbb al,$69 |
193 | das |
193 | das |
194 | stosb |
194 | stosb |
195 | ret |
195 | ret |
196 | endf |
196 | endf |
197 | 197 | ||
198 | ;----------------------------------------------------------------------------- |
198 | ;----------------------------------------------------------------------------- |
199 | func strlen ;///////////////////////////////////////////////////////////////// |
199 | func strlen ;///////////////////////////////////////////////////////////////// |
200 | ;----------------------------------------------------------------------------- |
200 | ;----------------------------------------------------------------------------- |
201 | push ebx |
201 | push ebx |
202 | mov ebx,eax |
202 | mov ebx,eax |
203 | xor eax,eax |
203 | xor eax,eax |
204 | @@: cmp byte[ebx+eax],0 |
204 | @@: cmp byte[ebx+eax],0 |
205 | je @f |
205 | je @f |
206 | inc eax |
206 | inc eax |
207 | jmp @b |
207 | jmp @b |
208 | @@: pop ebx |
208 | @@: pop ebx |
209 | ret |
209 | ret |
210 | endf |
210 | endf |
211 | 211 | ||
212 | ;----------------------------------------------------------------------------- |
212 | ;----------------------------------------------------------------------------- |
213 | func rgb_to_gray ;//////////////////////////////////////////////////////////// |
213 | func rgb_to_gray ;//////////////////////////////////////////////////////////// |
214 | ;----------------------------------------------------------------------------- |
214 | ;----------------------------------------------------------------------------- |
215 | push 0 eax |
215 | push 0 eax |
216 | and dword[esp],0x000000FF |
216 | and dword[esp],0x000000FF |
217 | fild dword[esp] |
217 | fild dword[esp] |
218 | fmul [float_gray_b] |
218 | fmul [float_gray_b] |
219 | shr eax,8 |
219 | shr eax,8 |
220 | mov [esp],eax |
220 | mov [esp],eax |
221 | and dword[esp],0x000000FF |
221 | and dword[esp],0x000000FF |
222 | fild dword[esp] |
222 | fild dword[esp] |
223 | fmul [float_gray_g] |
223 | fmul [float_gray_g] |
224 | faddp |
224 | faddp |
225 | shr eax,8 |
225 | shr eax,8 |
226 | and eax,0x000000FF |
226 | and eax,0x000000FF |
227 | mov [esp],eax |
227 | mov [esp],eax |
228 | fild dword[esp] |
228 | fild dword[esp] |
229 | fmul [float_gray_r] |
229 | fmul [float_gray_r] |
230 | faddp |
230 | faddp |
231 | frndint |
231 | frndint |
232 | fist dword[esp] |
232 | fist dword[esp] |
233 | fist dword[esp+1] |
233 | fist dword[esp+1] |
234 | fistp dword[esp+2] |
234 | fistp dword[esp+2] |
235 | pop eax |
235 | pop eax |
236 | add esp,4 |
236 | add esp,4 |
237 | ret |
237 | ret |
238 | endf |
238 | endf |
239 | 239 | ||
240 | ;float_gray_r dd 0.30f |
240 | ;float_gray_r dd 0.30f |
241 | ;float_gray_g dd 0.59f |
241 | ;float_gray_g dd 0.59f |
242 | ;float_gray_b dd 0.11f |
242 | ;float_gray_b dd 0.11f |
243 | 243 | ||
244 | ;----------------------------------------------------------------------------- |
244 | ;----------------------------------------------------------------------------- |
245 | func get_active_menu_item ;/////////////////////////////////////////////////// |
245 | func get_active_menu_item ;/////////////////////////////////////////////////// |
246 | ;----------------------------------------------------------------------------- |
246 | ;----------------------------------------------------------------------------- |
247 | pushad |
247 | pushad |
248 | mov [mi_cur],0 |
248 | mov [mi_cur],0 |
249 | mcall 37,1 |
249 | mcall 37,1 |
250 | movsx ebx,ax |
250 | movsx ebx,ax |
251 | sar eax,16 |
251 | sar eax,16 |
252 | mov ecx,__rc |
252 | mov ecx,__rc |
253 | pushd 2 0 (main_menu.width+7) (ATOPH-2) |
253 | pushd 2 0 (main_menu.width+7) (ATOPH-2) |
254 | popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0] |
254 | popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0] |
255 | ; add [__rc+0xC],ATOPH-2 |
255 | ; add [__rc+0xC],ATOPH-2 |
256 | call pt_in_rect |
256 | call pt_in_rect |
257 | jnc .outside_menu |
257 | jnc .outside_menu |
258 | m2m dword[ecx+0x8],dword[ecx+0x0] |
258 | m2m dword[ecx+0x8],dword[ecx+0x0] |
259 | mov edx,main_menu |
259 | mov edx,main_menu |
260 | @@: inc [mi_cur] |
260 | @@: inc [mi_cur] |
261 | movzx esi,word[edx+0] |
261 | movzx esi,word[edx+0] |
262 | add [ecx+0x8],esi |
262 | add [ecx+0x8],esi |
263 | call pt_in_rect |
263 | call pt_in_rect |
264 | jc .exit |
264 | jc .exit |
265 | m2m dword[ecx+0x0],dword[ecx+0x8] |
265 | m2m dword[ecx+0x0],dword[ecx+0x8] |
266 | add edx,8+1 |
266 | add edx,8+1 |
267 | movzx esi,byte[edx-1] |
267 | movzx esi,byte[edx-1] |
268 | add edx,esi |
268 | add edx,esi |
269 | cmp byte[edx+8],0 |
269 | cmp byte[edx+8],0 |
270 | jne @b |
270 | jne @b |
271 | mov [mi_cur],0 |
271 | mov [mi_cur],0 |
272 | .exit: |
272 | .exit: |
273 | popad |
273 | popad |
274 | ret |
274 | ret |
275 | .outside_menu: |
275 | .outside_menu: |
276 | or [mi_cur],-1 |
276 | or [mi_cur],-1 |
277 | @@: popad |
277 | @@: popad |
278 | ret |
278 | ret |
279 | endf |
279 | endf |
280 | 280 | ||
281 | ;----------------------------------------------------------------------------- |
281 | ;----------------------------------------------------------------------------- |
282 | func get_active_popup_item ;////////////////////////////////////////////////// |
282 | func get_active_popup_item ;////////////////////////////////////////////////// |
283 | ;----------------------------------------------------------------------------- |
283 | ;----------------------------------------------------------------------------- |
284 | pushad |
284 | pushad |
285 | mov [pi_cur],0 |
285 | mov [pi_cur],0 |
286 | mcall 37,1 |
286 | mcall 37,1 |
287 | movsx ebx,ax |
287 | movsx ebx,ax |
288 | sar eax,16 |
288 | sar eax,16 |
289 | mov ecx,__rc |
289 | mov ecx,__rc |
290 | mov dword[ecx+0x0],0 |
290 | mov dword[ecx+0x0],0 |
291 | mov dword[ecx+0x4],0 |
291 | mov dword[ecx+0x4],0 |
292 | movzx edx,[ebp+POPUP.width] |
292 | movzx edx,[ebp+POPUP.width] |
293 | mov dword[ecx+0x8],edx |
293 | mov dword[ecx+0x8],edx |
294 | movzx edx,[ebp+POPUP.height] |
294 | movzx edx,[ebp+POPUP.height] |
295 | mov dword[ecx+0xC],edx |
295 | mov dword[ecx+0xC],edx |
296 | call pt_in_rect |
296 | call pt_in_rect |
297 | jnc .outside_window |
297 | jnc .outside_window |
298 | inc dword[ecx+0x0] |
298 | inc dword[ecx+0x0] |
299 | mov dword[ecx+0x4],3 |
299 | mov dword[ecx+0x4],3 |
300 | dec dword[ecx+0x8] |
300 | dec dword[ecx+0x8] |
301 | mov dword[ecx+0xC],3+POP_IHEIGHT-1 |
301 | mov dword[ecx+0xC],3+POP_IHEIGHT-1 |
302 | mov edx,[ebp+POPUP.data] |
302 | mov edx,[ebp+POPUP.data] |
303 | @@: inc [pi_cur] |
303 | @@: inc [pi_cur] |
304 | inc edx |
304 | inc edx |
305 | movzx esi,byte[edx-1] |
305 | movzx esi,byte[edx-1] |
306 | cmp byte[edx],'-' |
306 | cmp byte[edx],'-' |
307 | jne .lp1 |
307 | jne .lp1 |
308 | pushd [ecx+0xC] |
308 | pushd [ecx+0xC] |
309 | sub dword[ecx+0xC],POP_IHEIGHT-4 |
309 | sub dword[ecx+0xC],POP_IHEIGHT-4 |
310 | call pt_in_rect |
310 | call pt_in_rect |
311 | popd [ecx+0xC] |
311 | popd [ecx+0xC] |
312 | jc .separator |
312 | jc .separator |
313 | add dword[ecx+0x4],4 |
313 | add dword[ecx+0x4],4 |
314 | add dword[ecx+0xC],4 |
314 | add dword[ecx+0xC],4 |
315 | jmp .lp3 |
315 | jmp .lp3 |
316 | .lp1: call pt_in_rect |
316 | .lp1: call pt_in_rect |
317 | jnc .lp2 |
317 | jnc .lp2 |
318 | mov eax,[pi_cur] |
318 | mov eax,[pi_cur] |
319 | test byte[ebp+eax-1],1 |
319 | test byte[ebp+eax-1],1 |
320 | jnz .exit |
320 | jnz .exit |
321 | jmp .separator |
321 | jmp .separator |
322 | .lp2: add dword[ecx+0x4],POP_IHEIGHT |
322 | .lp2: add dword[ecx+0x4],POP_IHEIGHT |
323 | add dword[ecx+0xC],POP_IHEIGHT |
323 | add dword[ecx+0xC],POP_IHEIGHT |
324 | add edx,esi |
324 | add edx,esi |
325 | inc edx |
325 | inc edx |
326 | movzx esi,byte[edx-1] |
326 | movzx esi,byte[edx-1] |
327 | .lp3: add edx,esi |
327 | .lp3: add edx,esi |
328 | cmp byte[edx],0 |
328 | cmp byte[edx],0 |
329 | jne @b |
329 | jne @b |
330 | .separator: |
330 | .separator: |
331 | mov [pi_cur],0 |
331 | mov [pi_cur],0 |
332 | .exit: |
332 | .exit: |
333 | popad |
333 | popad |
334 | ret |
334 | ret |
335 | .outside_window: |
335 | .outside_window: |
336 | or [pi_cur],-1 |
336 | or [pi_cur],-1 |
337 | jmp .exit |
337 | jmp .exit |
338 | endf |
338 | endf |
339 | 339 | ||
340 | ;----------------------------------------------------------------------------- |
340 | ;----------------------------------------------------------------------------- |
341 | func line_add_spaces ;//////////////////////////////////////////////////////// |
341 | func line_add_spaces ;//////////////////////////////////////////////////////// |
342 | ;----------------------------------------------------------------------------- |
342 | ;----------------------------------------------------------------------------- |
343 | ; Input: |
343 | ; Input: |
344 | ; ESI = line offset |
344 | ; ESI = line offset |
345 | ; ECX = needed line length |
345 | ; ECX = needed line length |
346 | ; Output: |
346 | ; Output: |
347 | ; EAX = delta |
347 | ; EAX = delta |
348 | ;----------------------------------------------------------------------------- |
348 | ;----------------------------------------------------------------------------- |
349 | xor eax,eax |
349 | xor eax,eax |
350 | pushad |
350 | pushad |
351 | movzx edx,word[esi] |
351 | movzx edx,word[esi] |
352 | cmp ecx,edx |
352 | cmp ecx,edx |
353 | jbe .exit |
353 | jbe .exit |
354 | sub ecx,edx |
354 | sub ecx,edx |
355 | lea eax,[ecx+4] |
355 | lea eax,[ecx+4] |
356 | call editor_realloc_lines |
356 | call editor_realloc_lines |
357 | mov [esp+4*7],eax |
357 | mov [esp+4*7],eax |
358 | add esi,eax |
358 | add esi,eax |
359 | push ecx |
359 | push ecx |
360 | mov edi,[cur_editor.Lines] |
360 | mov edi,[cur_editor.Lines] |
361 | add edi,[edi-4] |
361 | add edi,[edi-4] |
362 | dec edi |
362 | dec edi |
363 | mov eax,esi |
363 | mov eax,esi |
364 | mov esi,edi |
364 | mov esi,edi |
365 | sub esi,ecx |
365 | sub esi,ecx |
366 | lea ecx,[eax+4] |
366 | lea ecx,[eax+4] |
367 | add ecx,edx |
367 | add ecx,edx |
368 | push ecx |
368 | push ecx |
369 | neg ecx |
369 | neg ecx |
370 | lea ecx,[esi+ecx+1] |
370 | lea ecx,[esi+ecx+1] |
371 | std |
371 | std |
372 | rep movsb |
372 | rep movsb |
373 | pop edi ecx |
373 | pop edi ecx |
374 | add [eax],cx |
374 | add [eax],cx |
375 | mov al,' ' |
375 | mov al,' ' |
376 | cld |
376 | cld |
377 | rep stosb |
377 | rep stosb |
378 | .exit: |
378 | .exit: |
379 | popad |
379 | popad |
380 | ret |
380 | ret |
381 | endf |
381 | endf |
382 | 382 | ||
383 | ;----------------------------------------------------------------------------- |
383 | ;----------------------------------------------------------------------------- |
384 | func delete_selection ;/////////////////////////////////////////////////////// |
384 | func delete_selection ;/////////////////////////////////////////////////////// |
385 | ;----------------------------------------------------------------------------- |
385 | ;----------------------------------------------------------------------------- |
386 | ; call init_sel_vars |
386 | ; call init_sel_vars |
387 | 387 | ||
388 | cmp [sel.selected],0 |
388 | cmp [sel.selected],0 |
389 | je .exit.2 |
389 | je .exit.2 |
390 | 390 | ||
391 | pushad |
391 | pushad |
392 | mov ecx,[sel.begin.y] |
392 | mov ecx,[sel.begin.y] |
393 | cmp ecx,[sel.end.y] |
393 | cmp ecx,[sel.end.y] |
394 | je .single_line |
394 | je .single_line |
395 | call get_line_offset |
395 | call get_line_offset |
396 | and dword[esi],not 0x00020000 |
396 | and dword[esi],not 0x00020000 |
397 | or dword[esi],0x00010000 |
397 | or dword[esi],0x00010000 |
398 | mov ecx,[sel.begin.x] |
398 | mov ecx,[sel.begin.x] |
399 | call line_add_spaces |
399 | call line_add_spaces |
400 | add esi,eax |
400 | add esi,eax |
401 | lea edi,[esi+4] |
401 | lea edi,[esi+4] |
402 | mov ecx,[sel.end.y] |
402 | mov ecx,[sel.end.y] |
403 | call get_line_offset |
403 | call get_line_offset |
404 | call get_real_length |
404 | call get_real_length |
405 | cmp eax,[sel.end.x] |
405 | cmp eax,[sel.end.x] |
406 | jbe @f |
406 | jbe @f |
407 | mov eax,[sel.end.x] |
407 | mov eax,[sel.end.x] |
408 | @@: movzx ecx,word[esi] |
408 | @@: movzx ecx,word[esi] |
409 | sub ecx,eax |
409 | sub ecx,eax |
410 | mov ebx,[sel.begin.x] |
410 | mov ebx,[sel.begin.x] |
411 | add ebx,ecx |
411 | add ebx,ecx |
412 | mov [edi-4],bx |
412 | mov [edi-4],bx |
413 | add edi,[sel.begin.x] |
413 | add edi,[sel.begin.x] |
414 | lea esi,[esi+eax+4] |
414 | lea esi,[esi+eax+4] |
415 | mov ecx,[cur_editor.Lines] |
415 | mov ecx,[cur_editor.Lines] |
416 | add ecx,[ecx-4] |
416 | add ecx,[ecx-4] |
417 | sub ecx,esi |
417 | sub ecx,esi |
418 | cld |
418 | cld |
419 | rep movsb |
419 | rep movsb |
420 | mov eax,[sel.end.y] |
420 | mov eax,[sel.end.y] |
421 | sub eax,[sel.begin.y] |
421 | sub eax,[sel.begin.y] |
422 | sub [cur_editor.Lines.Count],eax |
422 | sub [cur_editor.Lines.Count],eax |
423 | jmp .exit |
423 | jmp .exit |
424 | 424 | ||
425 | .single_line: |
425 | .single_line: |
426 | call get_line_offset |
426 | call get_line_offset |
427 | and dword[esi],not 0x00020000 |
427 | and dword[esi],not 0x00020000 |
428 | or dword[esi],0x00010000 |
428 | or dword[esi],0x00010000 |
429 | call get_real_length |
429 | call get_real_length |
430 | cmp eax,[sel.begin.x] |
430 | cmp eax,[sel.begin.x] |
431 | jbe .exit |
431 | jbe .exit |
432 | mov ecx,[sel.end.x] |
432 | mov ecx,[sel.end.x] |
433 | cmp ecx,eax |
433 | cmp ecx,eax |
434 | jbe @f |
434 | jbe @f |
435 | mov ecx,eax |
435 | mov ecx,eax |
436 | @@: sub ecx,[sel.begin.x] |
436 | @@: sub ecx,[sel.begin.x] |
437 | sub [esi],cx |
437 | sub [esi],cx |
438 | lea edi,[esi+4] |
438 | lea edi,[esi+4] |
439 | add edi,[sel.begin.x] |
439 | add edi,[sel.begin.x] |
440 | lea esi,[edi+ecx] |
440 | lea esi,[edi+ecx] |
441 | mov ecx,[cur_editor.Lines] |
441 | mov ecx,[cur_editor.Lines] |
442 | add ecx,[ecx-4] |
442 | add ecx,[ecx-4] |
443 | sub ecx,esi |
443 | sub ecx,esi |
444 | cld |
444 | cld |
445 | rep movsb |
445 | rep movsb |
446 | 446 | ||
447 | .exit: |
447 | .exit: |
448 | mov eax,[sel.begin.x] |
448 | mov eax,[sel.begin.x] |
449 | mov [cur_editor.Caret.X],eax |
449 | mov [cur_editor.Caret.X],eax |
450 | mov [cur_editor.SelStart.X],eax |
450 | mov [cur_editor.SelStart.X],eax |
451 | mov eax,[sel.begin.y] |
451 | mov eax,[sel.begin.y] |
452 | mov [cur_editor.Caret.Y],eax |
452 | mov [cur_editor.Caret.Y],eax |
453 | mov [cur_editor.SelStart.Y],eax |
453 | mov [cur_editor.SelStart.Y],eax |
454 | 454 | ||
455 | mov ecx,[cur_editor.Lines.Count] |
455 | mov ecx,[cur_editor.Lines.Count] |
456 | call get_line_offset |
456 | call get_line_offset |
457 | movzx eax,word[esi] |
457 | movzx eax,word[esi] |
458 | lea esi,[esi+eax+4] |
458 | lea esi,[esi+eax+4] |
459 | mov eax,[cur_editor.Lines] |
459 | mov eax,[cur_editor.Lines] |
460 | add eax,[eax-4] |
460 | add eax,[eax-4] |
461 | sub esi,eax |
461 | sub esi,eax |
462 | lea eax,[esi+4096] |
462 | lea eax,[esi+4096] |
463 | call editor_realloc_lines |
463 | call editor_realloc_lines |
464 | 464 | ||
465 | popad |
465 | popad |
466 | mov [cur_editor.Modified],1 |
466 | mov [cur_editor.Modified],1 |
467 | clc |
467 | clc |
468 | ret |
468 | ret |
469 | 469 | ||
470 | .exit.2: |
470 | .exit.2: |
471 | stc |
471 | stc |
472 | ret |
472 | ret |
473 | endf |
473 | endf |
474 | 474 | ||
475 | ;----------------------------------------------------------------------------- |
475 | ;----------------------------------------------------------------------------- |
476 | func get_selection_size ;///////////////////////////////////////////////////// |
476 | func get_selection_size ;///////////////////////////////////////////////////// |
477 | ;----------------------------------------------------------------------------- |
477 | ;----------------------------------------------------------------------------- |
478 | push ecx esi |
478 | push ecx esi |
479 | mov ecx,[sel.end.y] |
479 | mov ecx,[sel.end.y] |
480 | inc ecx |
480 | inc ecx |
481 | call get_line_offset |
481 | call get_line_offset |
482 | mov eax,esi |
482 | mov eax,esi |
483 | mov ecx,[sel.begin.y] |
483 | mov ecx,[sel.begin.y] |
484 | call get_line_offset |
484 | call get_line_offset |
485 | sub eax,esi |
485 | sub eax,esi |
486 | pop esi ecx |
486 | pop esi ecx |
487 | ret |
487 | ret |
488 | endf |
488 | endf |
489 | 489 | ||
490 | ;----------------------------------------------------------------------------- |
490 | ;----------------------------------------------------------------------------- |
491 | func get_lines_in_file ;////////////////////////////////////////////////////// |
491 | func get_lines_in_file ;////////////////////////////////////////////////////// |
492 | ;----------------------------------------------------------------------------- |
492 | ;----------------------------------------------------------------------------- |
493 | ; Input: |
493 | ; Input: |
494 | ; ESI = data pointer |
494 | ; ESI = data pointer |
495 | ; ECX = data length |
495 | ; ECX = data length |
496 | ; Output: |
496 | ; Output: |
497 | ; EAX = lines number |
497 | ; EAX = lines number |
498 | ; EBX = extra length after tabs expansion |
498 | ; EBX = extra length after tabs expansion |
499 | ;----------------------------------------------------------------------------- |
499 | ;----------------------------------------------------------------------------- |
500 | push ecx edx esi 0 |
500 | push ecx edx esi 0 |
501 | or ebx,-1 |
501 | or ebx,-1 |
502 | xor edx,edx |
502 | xor edx,edx |
503 | .lp0: inc ebx |
503 | .lp0: inc ebx |
504 | .lp1: dec ecx |
504 | .lp1: dec ecx |
505 | jle .lp2 |
505 | jle .lp2 |
506 | lodsb |
506 | lodsb |
507 | cmp al,0 |
507 | cmp al,0 |
508 | je .lp2 |
508 | je .lp2 |
509 | cmp al,9 |
509 | cmp al,9 |
510 | je .TB |
510 | je .TB |
511 | cmp al,10 |
511 | cmp al,10 |
512 | je .LF |
512 | je .LF |
513 | cmp al,13 |
513 | cmp al,13 |
514 | je .CR |
514 | je .CR |
515 | inc edx |
515 | inc edx |
516 | jmp .lp1 |
516 | jmp .lp1 |
517 | .lp2: lea eax,[ebx+1] |
517 | .lp2: lea eax,[ebx+1] |
518 | pop ebx esi edx ecx |
518 | pop ebx esi edx ecx |
519 | ret |
519 | ret |
520 | 520 | ||
521 | .CR: cmp byte[esi],10 |
521 | .CR: cmp byte[esi],10 |
522 | jne .LF |
522 | jne .LF |
523 | lodsb |
523 | lodsb |
524 | .LF: xor edx,edx |
524 | .LF: xor edx,edx |
525 | jmp .lp0 |
525 | jmp .lp0 |
526 | .TB: and edx,00000111b |
526 | .TB: and edx,00000111b |
527 | add dword[esp],ATABW |
527 | add dword[esp],ATABW |
528 | sub [esp],edx |
528 | sub [esp],edx |
529 | xor edx,edx |
529 | xor edx,edx |
530 | jmp .lp1 |
530 | jmp .lp1 |
531 | endf |
531 | endf |
532 | 532 | ||
533 | ;----------------------------------------------------------------------------- |
533 | ;----------------------------------------------------------------------------- |
534 | func update_caption ;///////////////////////////////////////////////////////// |
534 | func update_caption ;///////////////////////////////////////////////////////// |
535 | ;----------------------------------------------------------------------------- |
535 | ;----------------------------------------------------------------------------- |
536 | lea esi,[cur_editor.FilePath] |
536 | lea esi,[cur_editor.FilePath] |
537 | mov edi,s_title |
537 | mov edi,s_title |
- | 538 | ||
538 | 539 | xor ecx,ecx |
|
539 | @@: lodsb |
540 | @@: lodsb |
540 | cmp al,0 |
541 | cmp al,0 |
541 | je @f |
542 | je @f |
542 | stosb |
543 | stosb |
- | 544 | inc ecx |
|
543 | jmp @b |
545 | jmp @b |
544 | @@: |
546 | @@: |
- | 547 | push ecx |
|
545 | mov dword[edi],' - ' |
548 | mov dword[edi],' - ' |
546 | add edi,3 |
549 | add edi,3 |
547 | @@: mov esi,htext |
550 | mov esi,htext |
548 | mov ecx,htext.size |
551 | mov ecx,htext.size |
549 | cld |
552 | cld |
550 | rep movsb |
553 | rep movsb |
551 | 554 | ||
552 | mov al,0 |
555 | mov al,0 |
553 | stosb |
556 | stosb |
554 | 557 | ||
555 | mcall 71,1,s_title |
558 | mcall 71,1,s_title |
- | 559 | ||
- | 560 | cmp [do_not_draw],0 |
|
- | 561 | jne @f |
|
- | 562 | lea esi,[cur_editor.FilePath] |
|
- | 563 | mov edi,tb_opensave.text |
|
- | 564 | mov ecx,[esp] |
|
- | 565 | cld |
|
- | 566 | rep movsb |
|
- | 567 | pop ecx |
|
- | 568 | mov [tb_opensave.length],cl |
|
- | 569 | clc |
|
- | 570 | ret |
|
- | 571 | @@: |
|
556 | 572 | add esp,4 |
|
557 | clc |
573 | clc |
558 | ret |
574 | ret |
559 | endf |
575 | endf |
560 | 576 | ||
561 | ;----------------------------------------------------------------------------- |
577 | ;----------------------------------------------------------------------------- |
562 | func mem.Alloc ;////////////////////////////////////////////////////////////// |
578 | func mem.Alloc ;////////////////////////////////////////////////////////////// |
563 | ;----------------------------------------------------------------------------- |
579 | ;----------------------------------------------------------------------------- |
564 | push ebx ecx |
580 | push ebx ecx |
565 | lea ecx,[eax+4+4095] |
581 | lea ecx,[eax+4+4095] |
566 | and ecx,not 4095 |
582 | and ecx,not 4095 |
567 | mcall 68,12 |
583 | mcall 68,12 |
568 | add ecx,-4 |
584 | add ecx,-4 |
569 | mov [eax],ecx |
585 | mov [eax],ecx |
570 | add eax,4 |
586 | add eax,4 |
571 | pop ecx ebx |
587 | pop ecx ebx |
572 | ret |
588 | ret |
573 | endf |
589 | endf |
574 | 590 | ||
575 | ;----------------------------------------------------------------------------- |
591 | ;----------------------------------------------------------------------------- |
576 | func mem.ReAlloc ;//////////////////////////////////////////////////////////// |
592 | func mem.ReAlloc ;//////////////////////////////////////////////////////////// |
577 | ;----------------------------------------------------------------------------- |
593 | ;----------------------------------------------------------------------------- |
578 | push ebx ecx esi edi eax |
594 | push ebx ecx esi edi eax |
579 | or eax,eax |
595 | or eax,eax |
580 | jz @f |
596 | jz @f |
581 | lea ecx,[ebx+4+4095] |
597 | lea ecx,[ebx+4+4095] |
582 | and ecx,not 4095 |
598 | and ecx,not 4095 |
583 | add ecx,-4 |
599 | add ecx,-4 |
584 | cmp ecx,[eax-4] |
600 | cmp ecx,[eax-4] |
585 | je .exit |
601 | je .exit |
586 | @@: mov eax,ebx |
602 | @@: mov eax,ebx |
587 | call mem.Alloc |
603 | call mem.Alloc |
588 | xchg eax,[esp] |
604 | xchg eax,[esp] |
589 | or eax,eax |
605 | or eax,eax |
590 | jz .exit |
606 | jz .exit |
591 | mov esi,eax |
607 | mov esi,eax |
592 | xchg eax,[esp] |
608 | xchg eax,[esp] |
593 | mov edi,eax |
609 | mov edi,eax |
594 | mov ecx,[esi-4] |
610 | mov ecx,[esi-4] |
595 | cmp ecx,[edi-4] |
611 | cmp ecx,[edi-4] |
596 | jbe @f |
612 | jbe @f |
597 | mov ecx,[edi-4] |
613 | mov ecx,[edi-4] |
598 | @@: add ecx,3 |
614 | @@: add ecx,3 |
599 | shr ecx,2 |
615 | shr ecx,2 |
600 | cld |
616 | cld |
601 | rep movsd |
617 | rep movsd |
602 | xchg eax,[esp] |
618 | xchg eax,[esp] |
603 | call mem.Free |
619 | call mem.Free |
604 | .exit: |
620 | .exit: |
605 | pop eax edi esi ecx ebx |
621 | pop eax edi esi ecx ebx |
606 | ret |
622 | ret |
607 | endf |
623 | endf |
608 | 624 | ||
609 | ;----------------------------------------------------------------------------- |
625 | ;----------------------------------------------------------------------------- |
610 | func mem.Free ;/////////////////////////////////////////////////////////////// |
626 | func mem.Free ;/////////////////////////////////////////////////////////////// |
611 | ;----------------------------------------------------------------------------- |
627 | ;----------------------------------------------------------------------------- |
612 | push ebx ecx |
628 | push ebx ecx |
613 | lea ecx,[eax-4] |
629 | lea ecx,[eax-4] |
614 | mcall 68,13 |
630 | mcall 68,13 |
615 | pop ecx ebx |
631 | pop ecx ebx |
616 | ret |
632 | ret |
617 | endf |
633 | endf |