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