Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ;****************************************************************************** |
2 | ; project name: TINYPAD |
||
3 | ; compiler: flat assembler 1.60 |
||
4 | ; memory to compile: 2 Mbytes + |
||
5 | ; version: 3.78a |
||
6 | ; last update: 13/05/2005 |
||
7 | ; maintained by: Ivan Poddubny, Mike Semenyako (aka mike.dld) |
||
8 | ; e-mail: ivan-yar@bk.ru, mike.dld@tut.by |
||
9 | ;****************************************************************************** |
||
10 | ; HISTORY: |
||
11 | ; 3.79 (just some ideas for further releases) |
||
12 | ; optimize drawing (reduce flickering) |
||
13 | ; optimize memory usage (allocate only needed amount, not static 3 Mbytes) |
||
14 | ; improve keyboard handling (use 66th function) |
||
15 | ; introduce real selection capabilities (including block selection) |
||
16 | ; and of course other small speed and size optimizations ;) |
||
17 | ; 3.78a (mike.dld) |
||
18 | ; fixed termination while typing in x positions higher than (line_length+10) |
||
19 | ; improved drawing on small heights |
||
20 | ; don't draw window while its height equals 0 |
||
21 | ; 3.78 (mike.dld) |
||
22 | ; now lines may be of ANY length; |
||
23 | ; optimized memory usage (less memory for internal file representation) |
||
24 | ; after loading file, it's internal size equals to its real size |
||
25 | ; plus 14 bytes for each line (4 bytes for line length |
||
26 | ; and 10 spaced to the end - to reduce data relocations) |
||
27 | ; completely rewritten keyboard handling; |
||
28 | ; added horizontal scrollbar; |
||
29 | ; all line feed formats are supported: WIN(CRLF),*NIX(LF),MAC(CR); |
||
30 | ; etc. |
||
31 | ; 3.77 (mike.dld) |
||
32 | ; changed save_string to collapse SPACEs into TABs; |
||
33 | ; rewrote drawfile from scratch (speed++) |
||
34 | ; through some drawing improvements still needed |
||
35 | ; (some checkups to reduce flickering); |
||
36 | ; writepos (size--); |
||
37 | ; fixed drawing window while height < 100px, and for non-asm files; |
||
38 | ; several small fixes; speed/size optimizations |
||
39 | ; 3.76 (mike.dld) |
||
40 | ; changed loadfile/loadhdfile to expand TABs into SPACEs; |
||
41 | ; changed TAB,ENTER,DELETE,BSPACE keys behaviour (rewritten from scratch); |
||
42 | ; vertical scrollbar; |
||
43 | ; extra window resizing capabilities (added a couple of constants); |
||
44 | ; completely new text cursor management & moving text cursor with mouse; |
||
45 | ; improved search function, moving cursor to beginning of text found; |
||
46 | ; adjustable max line width (change LINE_WIDTH & recompile) // (obsolete) |
||
47 | ; 3.75a |
||
48 | ; fixed converting char to upper case in read_string |
||
49 | ; 3.75 |
||
50 | ; rewrote save_file from scratch; bugfix in loadfile; |
||
51 | ; 3.74 |
||
52 | ; optimisation |
||
53 | ; 3.73 |
||
54 | ; completly new load_file function |
||
55 | ; 3.72 |
||
56 | ; speed++ |
||
57 | ; 3.71 |
||
58 | ; error beep |
||
59 | ; 3.6,3.7: |
||
60 | ; many bugs fixed |
||
61 | ; simple toolbar |
||
62 | ; compile, run applications from TINYPAD, all fasm output is in debug board |
||
63 | ; TAB button |
||
64 | ; auto-indent |
||
65 | ; Ctrl+L - insert comment string |
||
66 | ;****************************************************************************** |
||
67 | ; Memory 0x300000: |
||
68 | ; stack 0x00eff0 - стэк |
||
69 | ; stack for help 0x00fff0 - |
||
70 | ; load position 0x010000 + адрес загрузки файла |
||
71 | ; screen comp 0x078000 + содержимое экрана (obsolete) |
||
72 | ; edit area 0x080000 + документ |
||
73 | ; copy/paste area 0x2f0000 + область для копирования/вставки |
||
74 | ;****************************************************************************** |
||
75 | |||
76 | include 'lang.inc' |
||
77 | include 'macros.inc' ; useful stuff |
||
78 | purge mov ; SPEED |
||
79 | |||
80 | macro mov op1,op2 { |
||
81 | if (op1 in __regs) & (op2 eq -1) |
||
82 | or op1,-1 |
||
83 | else |
||
84 | mov op1,op2 |
||
85 | end if |
||
86 | } |
||
87 | |||
88 | header '01',1,@CODE,TINYPAD_END,0x300000,0xeff0,@PARAMS,0 |
||
89 | |||
90 | ASEPC = '-' |
||
91 | RBTNW = rstr.size*6/3 |
||
92 | LBTNW = lstr.size*6/2 |
||
93 | ABTNH = 16 |
||
94 | ATOPH = 24 |
||
95 | OLEFT = 5+1 |
||
96 | SCRLW = 16 |
||
97 | ATABW = 8 |
||
98 | PATHL = 260 |
||
99 | |||
100 | AMINS = 8 |
||
101 | |||
102 | ;----------------------------------------------------------------------------- |
||
103 | section @CODE ;/////////////////////////////////////////////////////////////// |
||
104 | ;----------------------------------------------------------------------------- |
||
105 | |||
106 | ;****************************************************************************** |
||
107 | ; INITIALIZING |
||
108 | |||
109 | cld |
||
110 | mov esi,s_example |
||
111 | mov edi,s_fname |
||
112 | mov ecx,s_example.size |
||
113 | mov [s_fname.size],ecx |
||
114 | rep movsb |
||
115 | mov esi,s_still |
||
116 | mov edi,s_search |
||
117 | mov ecx,s_still.size |
||
118 | mov [s_search.size],ecx |
||
119 | rep movsb |
||
120 | cmp byte[@PARAMS],0 |
||
121 | jz no_params |
||
122 | |||
123 | ; parameters are at @PARAMS |
||
124 | mov esi,@PARAMS |
||
125 | mov edi,s_fname |
||
126 | mov ecx,PATHL |
||
127 | rep movsb |
||
128 | mov edi,s_fname |
||
129 | mov ecx,PATHL |
||
130 | xor al,al |
||
131 | repne scasb |
||
132 | sub edi,s_fname+1 |
||
133 | mov [s_fname.size],edi |
||
134 | |||
135 | no_params: |
||
136 | mcall 40,00100111b |
||
137 | jmp do_load_file |
||
138 | |||
139 | ;****************************************************************************** |
||
140 | ; MAIN LOOP |
||
141 | still: |
||
142 | call writepos ; write current position & number of strings |
||
143 | |||
144 | .skip_write: |
||
145 | mcall 10;23,50; wait here until event |
||
146 | dec eax ; redraw ? |
||
147 | jz red |
||
148 | dec eax ; key ? |
||
149 | jz key |
||
150 | dec eax ; button ? |
||
151 | jz button |
||
152 | sub eax,3 ; mouse ? |
||
153 | jz mouse |
||
154 | |||
155 | ;d |
||
156 | |||
157 | jmp still.skip_write |
||
158 | ;****************************************************************************** |
||
159 | |||
160 | mouse: |
||
161 | mcall 9,p_info,-1 |
||
162 | cmp ax,[p_info.window_stack_position] |
||
163 | jne still |
||
164 | |||
165 | mcall 37,2 |
||
166 | test al,1 |
||
167 | jz .capture_off |
||
168 | |||
169 | mcall 37,1 |
||
170 | mov ebx,eax |
||
171 | and ebx,0x0000FFFF |
||
172 | shr eax,16 |
||
173 | |||
174 | mov ecx,[top_ofs] |
||
175 | inc ecx |
||
176 | pushd OLEFT ecx [p_info.x_size] ecx |
||
177 | popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0] |
||
178 | sub [__rc+0x8],SCRLW+5+3 |
||
179 | imul ecx,[slines],10 |
||
180 | dec ecx |
||
181 | add [__rc+0xC],ecx |
||
182 | mov ecx,__rc |
||
183 | call pt_in_rect |
||
184 | jnc .check_vscroll |
||
185 | sub eax,OLEFT |
||
186 | sub ebx,[__rc+0x4] |
||
187 | push eax |
||
188 | mov eax,ebx |
||
189 | xor edx,edx |
||
190 | mov ecx,10 |
||
191 | div ecx |
||
192 | @@: add eax,[top_line] |
||
193 | mov ebx,eax |
||
194 | pop eax |
||
195 | xor edx,edx |
||
196 | mov ecx,6 |
||
197 | div ecx |
||
198 | @@: add eax,[left_col] |
||
199 | |||
200 | cmp eax,[columns] |
||
201 | jb @f |
||
202 | mov eax,[columns] |
||
203 | @@: cmp ebx,[lines] |
||
204 | jb @f |
||
205 | mov ebx,[lines] |
||
206 | dec ebx |
||
207 | @@: |
||
208 | cmp [posx],eax |
||
209 | jne .change_cur_pos |
||
210 | cmp [posy],ebx |
||
211 | je still.skip_write |
||
212 | |||
213 | .change_cur_pos: |
||
214 | mov [posx],eax |
||
215 | mov eax,[posy] |
||
216 | pushd ebx |
||
217 | popd [posy] |
||
218 | cmp eax,ebx |
||
219 | je @f |
||
220 | push ebx |
||
221 | mov ebx,eax |
||
222 | call drawfile.ex |
||
223 | pop eax |
||
224 | @@: mov ebx,eax |
||
225 | call drawfile.ex |
||
226 | jmp still |
||
227 | |||
228 | .check_vscroll: |
||
229 | mov ecx,[p_info.x_size] |
||
230 | sub ecx,SCRLW+5-2 |
||
231 | pushd ecx [top_ofs] ecx [bot_ofs] |
||
232 | popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0] |
||
233 | add [__rc+0x8],SCRLW-2 |
||
234 | add [__rc+0x4],SCRLW+1 |
||
235 | sub [__rc+0xC],SCRLW*2+3 |
||
236 | mov ecx,__rc |
||
237 | call pt_in_rect |
||
238 | jnc .check_hscroll |
||
239 | |||
240 | sub ebx,[__rc+0x4] |
||
241 | cmp [vscrl_capt],0 |
||
242 | jge .vcaptured |
||
243 | mov eax,[vscrl_top] |
||
244 | cmp ebx,eax |
||
245 | jb .center_vcapture |
||
246 | add eax,[vscrl_size] |
||
247 | cmp ebx,eax |
||
248 | jae .center_vcapture |
||
249 | mov eax,ebx |
||
250 | sub eax,[vscrl_top] |
||
251 | dec eax |
||
252 | mov [vscrl_capt],eax |
||
253 | dec ebx |
||
254 | jmp .vcaptured |
||
255 | .center_vcapture: |
||
256 | mov eax,[vscrl_size] |
||
257 | shr eax,1 |
||
258 | mov [vscrl_capt],eax |
||
259 | .vcaptured: |
||
260 | sub ebx,[vscrl_capt] |
||
261 | jns @f |
||
262 | xor ebx,ebx |
||
263 | @@: |
||
264 | mov [vscrl_top],ebx |
||
265 | mov eax,[lines] |
||
266 | sub eax,[slines] |
||
267 | mul ebx |
||
268 | mov ebx,[bot_ofs] |
||
269 | sub ebx,[top_ofs] |
||
270 | sub ebx,SCRLW*3+2+2 ;** |
||
271 | sub ebx,[vscrl_size] |
||
272 | div ebx |
||
273 | cmp eax,[top_line] |
||
274 | je still.skip_write |
||
275 | mov [top_line],eax |
||
276 | call check_bottom_right |
||
277 | call drawfile |
||
278 | jmp still.skip_write |
||
279 | |||
280 | .check_hscroll: |
||
281 | pushd (OLEFT+SCRLW+1) [bot_ofs] [p_info.x_size] [bot_ofs] |
||
282 | popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0] |
||
283 | add [__rc+0x8],-SCRLW*2-10-1 |
||
284 | add [__rc+0x4],-SCRLW |
||
285 | add [__rc+0xC],-2 |
||
286 | mov ecx,__rc |
||
287 | call pt_in_rect |
||
288 | jnc .capture_off |
||
289 | |||
290 | mov ebx,eax |
||
291 | sub ebx,[__rc+0x0] |
||
292 | cmp [hscrl_capt],0 |
||
293 | jge .hcaptured |
||
294 | mov eax,[hscrl_top] |
||
295 | cmp ebx,eax |
||
296 | jb .center_hcapture |
||
297 | add eax,[hscrl_size] |
||
298 | cmp ebx,eax |
||
299 | jae .center_hcapture |
||
300 | mov eax,ebx |
||
301 | sub eax,[hscrl_top] |
||
302 | dec eax |
||
303 | mov [hscrl_capt],eax |
||
304 | dec ebx |
||
305 | jmp .hcaptured |
||
306 | .center_hcapture: |
||
307 | mov eax,[hscrl_size] |
||
308 | shr eax,1 |
||
309 | mov [hscrl_capt],eax |
||
310 | .hcaptured: |
||
311 | sub ebx,[hscrl_capt] |
||
312 | jns @f |
||
313 | xor ebx,ebx |
||
314 | @@: |
||
315 | mov [hscrl_top],ebx |
||
316 | mov eax,[columns] |
||
317 | sub eax,[scolumns] |
||
318 | mul ebx |
||
319 | mov ebx,[p_info.x_size] |
||
320 | sub ebx,SCRLW*3+10+2 ;** |
||
321 | sub ebx,[hscrl_size] |
||
322 | div ebx |
||
323 | cmp eax,[left_col] |
||
324 | je still.skip_write |
||
325 | mov [left_col],eax |
||
326 | call check_bottom_right |
||
327 | call drawfile |
||
328 | jmp still.skip_write |
||
329 | |||
330 | .capture_off: |
||
331 | or [vscrl_capt],-1 |
||
332 | or [hscrl_capt],-1 |
||
333 | jmp still.skip_write |
||
334 | |||
335 | func pt_in_rect |
||
336 | cmp eax,[ecx+0x0] |
||
337 | jl @f |
||
338 | cmp ebx,[ecx+0x4] |
||
339 | jl @f |
||
340 | cmp eax,[ecx+0x8] |
||
341 | jg @f |
||
342 | cmp ebx,[ecx+0xC] |
||
343 | jg @f |
||
344 | stc |
||
345 | ret |
||
346 | @@: clc |
||
347 | ret |
||
348 | endf |
||
349 | |||
350 | func check_bottom_right |
||
351 | push eax |
||
352 | mov eax,[top_line] |
||
353 | add eax,[slines] |
||
354 | cmp eax,[lines] |
||
355 | jbe .lp1 |
||
356 | mov eax,[lines] |
||
357 | sub eax,[slines] |
||
358 | jns @f |
||
359 | xor eax,eax |
||
360 | @@: mov [top_line],eax |
||
361 | .lp1: mov eax,[left_col] |
||
362 | add eax,[scolumns] |
||
363 | cmp eax,[columns] |
||
364 | jbe .exit |
||
365 | mov eax,[columns] |
||
366 | sub eax,[scolumns] |
||
367 | jns @f |
||
368 | xor eax,eax |
||
369 | @@: mov [left_col],eax |
||
370 | .exit: |
||
371 | pop eax |
||
372 | ret |
||
373 | endf |
||
374 | |||
375 | ; ********************************* |
||
376 | ; * BUTTON HANDLER * |
||
377 | ; ********************************* |
||
378 | |||
379 | button: |
||
380 | |||
381 | mcall 17 |
||
382 | shr eax,8 |
||
383 | |||
384 | cmp eax,'UP' |
||
385 | jne not_up |
||
386 | dec [top_line] |
||
387 | jns check_inv_all.skip_check |
||
388 | mov [top_line],0 |
||
389 | jmp still.skip_write |
||
390 | not_up: |
||
391 | |||
392 | cmp eax,'DN' |
||
393 | jne not_down |
||
394 | inc [top_line] |
||
395 | mov eax,[lines] |
||
396 | sub eax,[slines] |
||
397 | cmp eax,[top_line] |
||
398 | jae check_inv_all.skip_check |
||
399 | dec eax |
||
400 | mov [top_line],eax |
||
401 | jmp still.skip_write |
||
402 | not_down: |
||
403 | |||
404 | cmp eax,'LT' |
||
405 | jne not_left |
||
406 | dec [left_col] |
||
407 | jns check_inv_all.skip_check |
||
408 | mov [left_col],0 |
||
409 | jmp still.skip_write |
||
410 | not_left: |
||
411 | |||
412 | cmp eax,'RT' |
||
413 | jne not_right |
||
414 | inc [left_col] |
||
415 | mov eax,[columns] |
||
416 | sub eax,[scolumns] |
||
417 | cmp eax,[left_col] |
||
418 | jae check_inv_all.skip_check |
||
419 | dec eax |
||
420 | mov [left_col],eax |
||
421 | jmp still.skip_write |
||
422 | not_right: |
||
423 | |||
424 | ; SEARCH { |
||
425 | search: |
||
426 | cmp al,50 |
||
427 | jne no_search |
||
428 | |||
429 | .skip_check: |
||
430 | |||
431 | cld |
||
432 | mov ecx,[posy] |
||
433 | mov edx,ecx |
||
434 | call get_line_offset |
||
435 | cmp dword[esi],0 |
||
436 | je still |
||
437 | call get_real_length |
||
438 | add esi,4 |
||
439 | or eax,eax |
||
440 | jz .end_line.2 |
||
441 | mov ecx,eax |
||
442 | sub ecx,[posx] |
||
443 | push esi |
||
444 | add esi,[posx] |
||
445 | dec ecx |
||
446 | inc esi |
||
447 | jmp @f |
||
448 | |||
449 | .next_line: |
||
450 | push esi |
||
451 | @@: |
||
452 | sub ecx,[s_search.size] |
||
453 | inc ecx |
||
454 | |||
455 | .next_char: |
||
456 | dec ecx |
||
457 | js .end_line |
||
458 | xor edi,edi |
||
459 | |||
460 | .next_ok: |
||
461 | movzx eax,byte[edi+esi] |
||
462 | movzx ebx,byte[edi+s_search] |
||
463 | |||
464 | cmp al,$61 |
||
465 | jb @f |
||
466 | add al,[eax+add_table-$61] |
||
467 | @@: cmp bl,$61 |
||
468 | jb @f |
||
469 | add bl,[ebx+add_table-$61] |
||
470 | @@: |
||
471 | |||
472 | cmp al,bl |
||
473 | je @f |
||
474 | |||
475 | inc esi |
||
476 | jmp .next_char |
||
477 | @@: |
||
478 | inc edi |
||
479 | cmp edi,[s_search.size] |
||
480 | jne .next_ok |
||
481 | |||
482 | .found: |
||
483 | add esp,4 |
||
484 | mov [posy],edx |
||
485 | mov ecx,edx |
||
486 | lea eax,[esi-4] |
||
487 | call get_line_offset |
||
488 | sub eax,esi |
||
489 | mov [posx],eax |
||
490 | jmp check_inv_all |
||
491 | |||
492 | .end_line: |
||
493 | pop esi |
||
494 | .end_line.2: |
||
495 | add esi,[esi-4] |
||
496 | inc edx |
||
497 | call get_real_length |
||
498 | mov ecx,eax |
||
499 | lodsd |
||
500 | or eax,eax |
||
501 | jnz .next_line |
||
502 | jmp still |
||
503 | |||
504 | ; SEARCH } |
||
505 | |||
506 | no_search: |
||
507 | |||
508 | ; TOOLBAR { |
||
509 | cmp eax,10000 |
||
510 | jb no_toolbar |
||
511 | |||
512 | add eax,-10000 |
||
513 | jnz @f |
||
514 | mov bl,0;[run_outfile],0 |
||
515 | call start_fasm |
||
516 | jmp still |
||
517 | @@: dec eax |
||
518 | jnz @f |
||
519 | mov bl,1;[run_outfile],1 |
||
520 | call start_fasm |
||
521 | jmp still |
||
522 | @@: dec eax |
||
523 | jnz @f |
||
524 | call open_debug_board |
||
525 | jmp still |
||
526 | @@: dec eax |
||
527 | jnz still |
||
528 | call open_sysfuncs_txt |
||
529 | jmp still |
||
530 | ; TOOLBAR } |
||
531 | |||
532 | no_toolbar: |
||
533 | |||
534 | cmp al,4 |
||
535 | jne noid4 |
||
536 | |||
537 | ; LOAD_FILE { |
||
538 | do_load_file: |
||
539 | cmp [s_fname],'/' |
||
540 | jne @f |
||
541 | call loadhdfile |
||
542 | jmp .restorecursor |
||
543 | @@: call loadfile |
||
544 | |||
545 | .restorecursor: |
||
546 | xor eax,eax |
||
547 | mov [top_line],eax |
||
548 | mov [posx],eax |
||
549 | mov [posy],eax |
||
550 | |||
551 | ; enable color syntax for ASM and INC files: |
||
552 | mov [asm_mode],al |
||
553 | |||
554 | mov eax,[s_fname.size] |
||
555 | add eax,s_fname |
||
556 | mov byte[eax],0 |
||
557 | cmp dword[eax-3],'ASM' |
||
558 | jne @f |
||
559 | inc [asm_mode] |
||
560 | jmp .nocol |
||
561 | @@: cmp dword[eax-3],'INC' |
||
562 | jne .nocol |
||
563 | inc [asm_mode] |
||
564 | .nocol: |
||
565 | |||
566 | ; if the header is the same as previous, |
||
567 | ; just redraw the text area |
||
568 | ; else redraw the window |
||
569 | |||
570 | mov ecx, [s_fname.size] |
||
571 | add ecx, 10 ; strlen(" - TINYPAD"); |
||
572 | cmp ecx, [s_title.size] |
||
573 | jne @f |
||
574 | add ecx, -10 |
||
575 | mov esi, s_fname ; strcmp(s_fname,header); |
||
576 | mov edi, s_title |
||
577 | rep cmpsb |
||
578 | jne @f |
||
579 | call drawfile |
||
580 | jmp still |
||
581 | @@: |
||
582 | |||
583 | ; set window title: |
||
584 | mov esi,s_fname |
||
585 | mov edi,s_title |
||
586 | mov ecx,[s_fname.size] |
||
587 | lea eax,[ecx+10] |
||
588 | mov [s_title.size],eax |
||
589 | cld |
||
590 | rep movsb |
||
591 | |||
592 | mov dword[edi],' - ' |
||
593 | add edi,3 |
||
594 | mov esi,htext |
||
595 | mov ecx,htext.size |
||
596 | rep movsb |
||
597 | |||
598 | call drawwindow |
||
599 | jmp still |
||
600 | ; LOAD_FILE } |
||
601 | |||
602 | noid4: |
||
603 | |||
604 | cmp al, 2 |
||
605 | jz yessave |
||
606 | |||
607 | dec al ; close if butid == 1 |
||
608 | jnz nosave |
||
609 | ; EXIT: |
||
610 | mov [main_closed],1 |
||
611 | mcall -1 |
||
612 | |||
613 | ; SAVE_FILE { |
||
614 | yessave: |
||
615 | call save_file |
||
616 | jmp still |
||
617 | ; SAVE_FILE } |
||
618 | |||
619 | nosave: |
||
620 | inc al |
||
621 | call read_string |
||
622 | jmp still |
||
623 | |||
624 | ;********************************** |
||
625 | ;* REDRAW HANDLER * |
||
626 | ;********************************** |
||
627 | |||
628 | func red |
||
629 | ; перерисовка окна |
||
630 | call drawwindow |
||
631 | jmp check_inv_all.skip_check |
||
632 | endf |
||
633 | |||
634 | ;********************************** |
||
635 | ;* KEY HANDLER * |
||
636 | ;********************************** |
||
637 | |||
638 | key: |
||
639 | mcall 2 ; GET KEY |
||
640 | cmp al,1 |
||
641 | je still |
||
642 | |||
643 | shr eax,8 |
||
644 | |||
645 | ; HELP_WND { |
||
646 | cmp al,0xD2;210 ; Ctrl + F1 |
||
647 | jne no_help_text |
||
648 | |||
649 | mcall 51,1,help_thread_start,0xfff0 |
||
650 | jmp still |
||
651 | ; HELP_WND } |
||
652 | |||
653 | no_help_text: |
||
654 | ; LOAD_FILE { |
||
655 | cmp al,211 ; Ctrl + F2 |
||
656 | je do_load_file |
||
657 | ; LOAD_FILE } |
||
658 | |||
659 | ; SEARCH { |
||
660 | cmp al,212 ; Ctrl + F3 |
||
661 | je search.skip_check |
||
662 | ; SEARCH } |
||
663 | |||
664 | ; SAVE_FILE { |
||
665 | cmp al,213 ; Ctrl + F4 |
||
666 | je yessave |
||
667 | ; SAVE_FILE } |
||
668 | |||
669 | ; ENTER_FILENAME { |
||
670 | cmp al,214 ; Ctrl + F5 |
||
671 | jne @f |
||
672 | mov al,5 |
||
673 | call read_string |
||
674 | jmp still |
||
675 | @@: |
||
676 | ; ENTER_FILENAME } |
||
677 | |||
678 | ; ENTER_SEARCH { |
||
679 | cmp al,215 ; Ctrl + F6 |
||
680 | jne @f |
||
681 | mov al,51 |
||
682 | call read_string |
||
683 | jmp still |
||
684 | @@: |
||
685 | ; ENTER_SEARCH } |
||
686 | |||
687 | ; CHANGE_LANG_LAYOUT { |
||
688 | cmp al,217 ; Ctrl + F8 |
||
689 | jne @f |
||
690 | call layout |
||
691 | jmp still |
||
692 | @@: |
||
693 | ; CHANGE_LANG_LAYOUT } |
||
694 | |||
695 | ; 3 times english -> русский |
||
696 | ; 2 times русский -> english |
||
697 | |||
698 | ; COPY START { |
||
699 | cmp al,19 |
||
700 | jne no_copy_start |
||
701 | push [posy] |
||
702 | pop [copy_start] |
||
703 | jmp still |
||
704 | ; COPY START } |
||
705 | |||
706 | no_copy_start: |
||
707 | |||
708 | ; COPY END { |
||
709 | cmp al,5 |
||
710 | jne no_copy_end |
||
711 | mov eax,[posy] |
||
712 | cmp eax,[copy_start] |
||
713 | jae @f |
||
714 | xchg eax,[copy_start] |
||
715 | @@: sub eax,[copy_start] |
||
716 | inc eax |
||
717 | mov [copy_count],eax |
||
718 | |||
719 | mov ecx,[copy_start] |
||
720 | call get_line_offset |
||
721 | push esi |
||
722 | mov ecx,eax |
||
723 | @@: lodsd |
||
724 | add esi,eax |
||
725 | loop @b |
||
726 | mov ecx,esi |
||
727 | pop esi |
||
728 | sub ecx,esi |
||
729 | mov [copy_size],ecx |
||
730 | |||
731 | mov edi,0x2f0000 |
||
732 | cld |
||
733 | rep movsb |
||
734 | jmp still |
||
735 | ; COPY END } |
||
736 | |||
737 | no_copy_end: |
||
738 | |||
739 | ; PASTE { |
||
740 | cmp al,16 |
||
741 | jne no_copy_paste |
||
742 | mov ebx,[copy_count] |
||
743 | or ebx,ebx |
||
744 | jz still |
||
745 | add [lines],ebx |
||
746 | |||
747 | mov ecx,[posy] |
||
748 | call get_line_offset |
||
749 | mov ebx,esi |
||
750 | mov edi,0x2E0000 |
||
751 | mov esi,edi |
||
752 | mov ecx,[copy_size] |
||
753 | sub esi,ecx |
||
754 | lea ecx,[esi+4] |
||
755 | sub ecx,ebx |
||
756 | std |
||
757 | rep movsb |
||
758 | mov edi,ebx |
||
759 | mov esi,0x2F0000 |
||
760 | mov ecx,[copy_size] |
||
761 | cld |
||
762 | rep movsb |
||
763 | |||
764 | jmp check_inv_all |
||
765 | ; PASTE } |
||
766 | |||
767 | no_copy_paste: |
||
768 | |||
769 | ; INSERT_SEPARATOR { |
||
770 | cmp al,0x0C ; Ctrl+L |
||
771 | jne no_insert_separator |
||
772 | |||
773 | mov ecx,[posy] |
||
774 | call get_line_offset |
||
775 | mov ebx,esi |
||
776 | |||
777 | mov ecx,[lines] |
||
778 | call get_line_offset |
||
779 | lea edi,[esi+90+4] |
||
780 | lea ecx,[esi+4] |
||
781 | sub ecx,ebx |
||
782 | std |
||
783 | rep movsb |
||
784 | |||
785 | lea edi,[ebx+5] |
||
786 | mov dword[ebx],90 |
||
787 | mov al,ASEPC |
||
788 | mov ecx,79 |
||
789 | cld |
||
790 | rep stosb |
||
791 | mov al,' ' |
||
792 | mov ecx,10 |
||
793 | rep stosb |
||
794 | mov byte[ebx+4],';' |
||
795 | |||
796 | inc [lines] |
||
797 | inc [posy] |
||
798 | |||
799 | jmp check_inv_all |
||
800 | ; INSERT_SEPARATOR } |
||
801 | |||
802 | no_insert_separator: |
||
803 | |||
804 | ; DEL_LINE { |
||
805 | cmp al,4 |
||
806 | jne no_delete_line |
||
807 | |||
808 | mov eax,[posy] |
||
809 | inc eax |
||
810 | cmp eax,[lines] |
||
811 | jge still |
||
812 | |||
813 | mov ecx,[posy] |
||
814 | call get_line_offset |
||
815 | mov edi,esi |
||
816 | lodsd |
||
817 | add esi,eax |
||
818 | |||
819 | dec [lines] |
||
820 | mov ecx,0x2e0000 |
||
821 | sub ecx,esi |
||
822 | shr ecx,2 ;// fixed (was 4) |
||
823 | cld |
||
824 | rep movsd |
||
825 | jmp check_inv_all |
||
826 | ; DEL_LINE } |
||
827 | |||
828 | no_delete_line: |
||
829 | |||
830 | ; ENTER { |
||
831 | cmp al,13 |
||
832 | jnz noenter |
||
833 | |||
834 | mov ecx,[posy] |
||
835 | call get_line_offset |
||
836 | |||
837 | mov ebx,[posx] |
||
838 | cmp ebx,[esi] |
||
839 | jb @f |
||
840 | mov ebx,[esi] |
||
841 | dec ebx |
||
842 | jns @f |
||
843 | xor ebx,ebx |
||
844 | @@: |
||
845 | |||
846 | cld |
||
847 | |||
848 | mov edi,0x10000 |
||
849 | mov ebp,esi |
||
850 | mov ecx,ebx |
||
851 | inc ecx |
||
852 | @@: dec ecx |
||
853 | jz @f |
||
854 | cmp byte[esi+ecx+4-1],' ' |
||
855 | je @b |
||
856 | @@: lea eax,[ecx+10] |
||
857 | stosd |
||
858 | jecxz @f |
||
859 | push esi |
||
860 | add esi,4 |
||
861 | rep movsb |
||
862 | pop esi |
||
863 | @@: mov al,' ' |
||
864 | mov ecx,10 |
||
865 | rep stosb |
||
866 | |||
867 | mov ecx,[esi] |
||
868 | sub ecx,ebx;[posx] |
||
869 | add esi,ebx;[posx] |
||
870 | add esi,4 |
||
871 | inc ecx |
||
872 | @@: dec ecx |
||
873 | jz @f |
||
874 | cmp byte[esi+ecx-1],' ' |
||
875 | je @b |
||
876 | @@: jz .lp1 |
||
877 | @@: cmp byte[esi],' ' |
||
878 | jne .lp1 |
||
879 | inc esi |
||
880 | loop @b |
||
881 | .lp1: push edi ecx |
||
882 | mov ecx,[ebp] |
||
883 | lea edi,[ebp+4] |
||
884 | mov al,' ' |
||
885 | repe scasb |
||
886 | mov eax,ecx |
||
887 | pop ecx edi |
||
888 | je .lp2 |
||
889 | neg eax |
||
890 | add eax,[ebp] |
||
891 | dec eax |
||
892 | jmp @f |
||
893 | .lp2: xor eax,eax |
||
894 | @@: mov edx,edi |
||
895 | add edi,4 |
||
896 | mov [posx],eax |
||
897 | jecxz @f |
||
898 | push ecx |
||
899 | mov ecx,eax |
||
900 | mov al,' ' |
||
901 | rep stosb |
||
902 | pop ecx |
||
903 | @@: jecxz @f |
||
904 | rep movsb |
||
905 | @@: mov ecx,10 |
||
906 | mov al,' ' |
||
907 | rep stosb |
||
908 | |||
909 | lea eax,[edi-4] |
||
910 | sub eax,edx |
||
911 | mov [edx],eax |
||
912 | |||
913 | lea ecx,[edi-0x10000] |
||
914 | |||
915 | push ecx |
||
916 | mov edi,0x2E0000 |
||
917 | lea esi,[edi+4] |
||
918 | sub esi,ecx |
||
919 | add esi,[ebp] |
||
920 | lea ecx,[esi-4] |
||
921 | sub ecx,ebp |
||
922 | std |
||
923 | cmp esi,edi |
||
924 | jb @f |
||
925 | je .lp3 |
||
926 | lea esi,[ebp+4] |
||
927 | mov eax,[esp] |
||
928 | lea edi,[esi+eax-4] |
||
929 | add esi,[ebp] |
||
930 | mov ecx,0x2E0000 |
||
931 | sub ecx,esi |
||
932 | cld |
||
933 | @@: rep movsb |
||
934 | .lp3: pop ecx |
||
935 | mov esi,0x10000 |
||
936 | mov edi,ebp |
||
937 | cld |
||
938 | rep movsb |
||
939 | |||
940 | inc [posy] |
||
941 | inc [lines] |
||
942 | |||
943 | jmp check_inv_all |
||
944 | ; ENTER } |
||
945 | |||
946 | noenter: |
||
947 | |||
948 | ; UP { |
||
949 | cmp al,130+48 |
||
950 | jnz noup |
||
951 | |||
952 | mov eax,[posy] |
||
953 | dec eax |
||
954 | jns @f |
||
955 | xor eax,eax |
||
956 | @@: mov ecx,[top_line] |
||
957 | cmp eax,ecx |
||
958 | jae @f |
||
959 | dec ecx |
||
960 | jns @f |
||
961 | xor ecx,ecx |
||
962 | @@: jmp check_inv_all.skip_init |
||
963 | ; UP } |
||
964 | |||
965 | noup: |
||
966 | |||
967 | ; DOWN { |
||
968 | cmp al,129+48 |
||
969 | jnz nodown |
||
970 | |||
971 | mov eax,[posy] |
||
972 | inc eax |
||
973 | cmp eax,[lines] |
||
974 | jb @f |
||
975 | dec eax |
||
976 | @@: mov ecx,[top_line] |
||
977 | mov edx,eax |
||
978 | sub edx,ecx |
||
979 | cmp edx,[slines] |
||
980 | jb @f |
||
981 | inc ecx |
||
982 | @@: jmp check_inv_all.skip_init |
||
983 | ; DOWN } |
||
984 | |||
985 | nodown: |
||
986 | |||
987 | ; LEFT { |
||
988 | cmp al,128+48 |
||
989 | jnz noleft |
||
990 | mov eax,[posx] |
||
991 | dec eax |
||
992 | jns @f |
||
993 | inc eax |
||
994 | @@: mov [posx],eax |
||
995 | jmp check_inv_all |
||
996 | ; LEFT } |
||
997 | |||
998 | noleft: |
||
999 | |||
1000 | ; RIGHT { |
||
1001 | cmp al,131+48 |
||
1002 | jnz noright |
||
1003 | mov eax,[posx] |
||
1004 | inc eax |
||
1005 | cmp eax,[columns] |
||
1006 | jbe @f |
||
1007 | dec eax |
||
1008 | @@: mov [posx],eax |
||
1009 | jmp check_inv_all |
||
1010 | ; RIGHT } |
||
1011 | |||
1012 | noright: |
||
1013 | |||
1014 | ; PAGE_UP { |
||
1015 | page_up: |
||
1016 | cmp al,136+48 |
||
1017 | jnz nopu |
||
1018 | mov edx,[slines] |
||
1019 | dec edx |
||
1020 | mov eax,[posy] |
||
1021 | mov ecx,[top_line] |
||
1022 | sub eax,edx |
||
1023 | jns @f |
||
1024 | xor eax,eax |
||
1025 | @@: sub ecx,edx |
||
1026 | jns @f |
||
1027 | xor ecx,ecx |
||
1028 | @@: jmp check_inv_all.skip_init |
||
1029 | ; PAGE_UP } |
||
1030 | |||
1031 | nopu: |
||
1032 | |||
1033 | ; PAGE_DOWN { |
||
1034 | page_down: |
||
1035 | cmp al,135+48 |
||
1036 | jnz nopd |
||
1037 | mov edx,[slines] |
||
1038 | dec edx |
||
1039 | mov eax,[posy] |
||
1040 | mov ecx,[top_line] |
||
1041 | add eax,edx |
||
1042 | add ecx,edx |
||
1043 | cmp eax,[lines] |
||
1044 | jb @f |
||
1045 | mov eax,[lines] |
||
1046 | dec eax |
||
1047 | @@: jmp check_inv_all.skip_init |
||
1048 | ; PAGE_DOWN } |
||
1049 | |||
1050 | nopd: |
||
1051 | |||
1052 | ; HOME { |
||
1053 | cmp al,132+48 |
||
1054 | jnz nohome |
||
1055 | mov [posx],0 |
||
1056 | jmp check_inv_all |
||
1057 | ; HOME } |
||
1058 | |||
1059 | nohome: |
||
1060 | |||
1061 | ; END { |
||
1062 | end_key: |
||
1063 | cmp al,133+48 |
||
1064 | jnz noend |
||
1065 | |||
1066 | mov ecx,[posy] |
||
1067 | call get_line_offset |
||
1068 | call get_real_length |
||
1069 | mov [posx],eax |
||
1070 | jmp check_inv_all |
||
1071 | ; END } |
||
1072 | |||
1073 | noend: |
||
1074 | |||
1075 | ; GO_START { |
||
1076 | cmp al,251 ; Ctrl + [ |
||
1077 | jnz no_go_to_start |
||
1078 | xor eax,eax |
||
1079 | mov [top_line],eax |
||
1080 | mov [posy],eax |
||
1081 | jmp check_inv_all.skip_check |
||
1082 | ; GO_START } |
||
1083 | |||
1084 | no_go_to_start: |
||
1085 | |||
1086 | ; GO_END { |
||
1087 | cmp al,253 ; Ctrl + ] |
||
1088 | jnz no_go_to_end |
||
1089 | mov eax,[lines] ; eax = lines in the file |
||
1090 | mov [posy],eax |
||
1091 | sub eax,[slines] ; eax -= lines on the screen |
||
1092 | jns @f |
||
1093 | xor eax,eax |
||
1094 | @@: mov [top_line],eax |
||
1095 | dec [posy] |
||
1096 | jmp check_inv_all.skip_check |
||
1097 | ; GO_END } |
||
1098 | |||
1099 | no_go_to_end: |
||
1100 | |||
1101 | ; DELETE { |
||
1102 | __key_delete: |
||
1103 | cmp al,134+48 |
||
1104 | jne nodel |
||
1105 | |||
1106 | mov ecx,[posy] |
||
1107 | call get_line_offset |
||
1108 | lea ebx,[esi+4] |
||
1109 | mov ebp,esi |
||
1110 | |||
1111 | call get_real_length |
||
1112 | or eax,eax |
||
1113 | je .line_up |
||
1114 | |||
1115 | mov ecx,[posx] |
||
1116 | cmp ecx,eax |
||
1117 | jae .line_up |
||
1118 | lea edi,[ebx+ecx] |
||
1119 | neg ecx |
||
1120 | add ecx,[ebp] |
||
1121 | repe scasb |
||
1122 | je .line_up |
||
1123 | |||
1124 | mov edi,ebx |
||
1125 | mov ecx,[posx] |
||
1126 | add edi,ecx |
||
1127 | lea esi,[edi+1] |
||
1128 | neg ecx |
||
1129 | add ecx,[ebp] |
||
1130 | dec ecx |
||
1131 | rep movsb |
||
1132 | mov byte[edi],' ' |
||
1133 | |||
1134 | jmp check_inv_all |
||
1135 | |||
1136 | .line_up: |
||
1137 | mov eax,[lines] |
||
1138 | dec eax |
||
1139 | cmp eax,[posy] |
||
1140 | je still;.ok |
||
1141 | mov edi,0x10004 |
||
1142 | mov esi,ebx |
||
1143 | mov ecx,[posx] |
||
1144 | rep movsb |
||
1145 | mov ecx,[posx] |
||
1146 | mov [0x10000],ecx |
||
1147 | cmp ecx,[ebp] |
||
1148 | jbe @f |
||
1149 | sub ecx,[ebp] |
||
1150 | sub edi,ecx |
||
1151 | mov al,' ' |
||
1152 | rep stosb |
||
1153 | @@: lea esi,[ebx+4] |
||
1154 | add esi,[ebp] |
||
1155 | mov ecx,[esi-4] |
||
1156 | add [0x10000],ecx |
||
1157 | rep movsb |
||
1158 | |||
1159 | lea ecx,[edi-0x10000] |
||
1160 | |||
1161 | mov esi,0x10000 |
||
1162 | call get_real_length |
||
1163 | cmp eax,[columns] |
||
1164 | jbe @f |
||
1165 | mov [columns],eax |
||
1166 | @@: |
||
1167 | |||
1168 | push ecx |
||
1169 | mov edi,0x2E0000 |
||
1170 | lea esi,[edi+8] |
||
1171 | sub esi,ecx |
||
1172 | add esi,[ebp] |
||
1173 | lea eax,[ebp+4] |
||
1174 | add eax,[ebp] |
||
1175 | add esi,[eax] |
||
1176 | lea ecx,[esi-4] |
||
1177 | sub ecx,ebp |
||
1178 | std |
||
1179 | cmp esi,edi |
||
1180 | jb @f |
||
1181 | jz .lp1 |
||
1182 | mov edi,ebp |
||
1183 | add edi,[esp] |
||
1184 | lea esi,[ebp+8] |
||
1185 | add esi,[esi-8] |
||
1186 | add esi,[esi-4] |
||
1187 | mov ecx,0x2E0000 |
||
1188 | sub ecx,esi |
||
1189 | cld |
||
1190 | @@: rep movsb |
||
1191 | .lp1: pop ecx |
||
1192 | mov esi,0x10000 |
||
1193 | mov edi,ebp |
||
1194 | cld |
||
1195 | rep movsb |
||
1196 | |||
1197 | .ok.dec.lines: |
||
1198 | dec [lines] |
||
1199 | mov eax,[lines] |
||
1200 | cmp [posy],eax |
||
1201 | jb check_inv_all |
||
1202 | dec eax |
||
1203 | mov [posy],eax |
||
1204 | jmp check_inv_all |
||
1205 | ; DELETE } |
||
1206 | |||
1207 | nodel: |
||
1208 | |||
1209 | ; INSERT { |
||
1210 | cmp al,137+48 |
||
1211 | jnz noins |
||
1212 | ;// ... toggle insert/overwrite mode here ... |
||
1213 | jmp still;check_inv_str |
||
1214 | ; INSERT } |
||
1215 | |||
1216 | noins: |
||
1217 | |||
1218 | ; BACKSPACE { |
||
1219 | cmp al,8 |
||
1220 | jnz nobs |
||
1221 | |||
1222 | mov eax,[posx] |
||
1223 | dec eax |
||
1224 | js .line_up |
||
1225 | |||
1226 | dec [posx] |
||
1227 | mov ecx,[posy] |
||
1228 | call get_line_offset |
||
1229 | |||
1230 | mov ebx,eax |
||
1231 | call get_real_length |
||
1232 | cmp eax,[posx] |
||
1233 | jb check_inv_all |
||
1234 | |||
1235 | lea edi,[esi+4+ebx] |
||
1236 | mov ecx,ebx |
||
1237 | neg ecx |
||
1238 | add ecx,[esi] |
||
1239 | dec ecx |
||
1240 | lea esi,[edi+1] |
||
1241 | cld |
||
1242 | rep movsb |
||
1243 | mov byte[edi],' ' |
||
1244 | |||
1245 | jmp check_inv_str |
||
1246 | |||
1247 | .line_up: |
||
1248 | cmp [posy],0 |
||
1249 | je still |
||
1250 | mov ecx,[posy] |
||
1251 | dec ecx |
||
1252 | call get_line_offset |
||
1253 | mov ebp,esi |
||
1254 | lea ebx,[esi+4] |
||
1255 | mov ecx,[ebp] |
||
1256 | @@: cmp byte[ebx+ecx-1],' ' |
||
1257 | jne @f |
||
1258 | dec ecx |
||
1259 | jg @b |
||
1260 | @@: mov [posx],ecx |
||
1261 | dec [posy] |
||
1262 | cld |
||
1263 | jmp __key_delete.line_up |
||
1264 | ; BACKSPACE } |
||
1265 | |||
1266 | nobs: |
||
1267 | |||
1268 | ; TAB { |
||
1269 | __key_tab: |
||
1270 | cmp eax,9 ; Tab |
||
1271 | jne notab |
||
1272 | |||
1273 | mov eax,[posx] |
||
1274 | |||
1275 | mov ecx,eax |
||
1276 | add eax,ATABW |
||
1277 | and eax,not(ATABW-1) |
||
1278 | push eax ' ' |
||
1279 | sub eax,ecx |
||
1280 | .direct: |
||
1281 | mov ecx,[posy] |
||
1282 | call get_line_offset |
||
1283 | |||
1284 | xchg eax,ecx |
||
1285 | |||
1286 | call get_real_length |
||
1287 | cmp eax,[posx] |
||
1288 | jae @f |
||
1289 | mov eax,[posx] |
||
1290 | @@: mov edx,[esi] |
||
1291 | sub edx,eax |
||
1292 | cmp ecx,edx |
||
1293 | jl @f |
||
1294 | pushad; esi ecx eax |
||
1295 | mov ecx,0x2E0000-10+1 |
||
1296 | lea eax,[esi+4] |
||
1297 | add eax,[esi] |
||
1298 | sub ecx,eax |
||
1299 | mov edi,0x2E0000 |
||
1300 | mov esi,0x2E0000-10 |
||
1301 | std |
||
1302 | rep movsb |
||
1303 | mov ecx,10 |
||
1304 | mov al,' ' |
||
1305 | rep stosb |
||
1306 | popad; eax ecx esi |
||
1307 | add dword[esi],10 |
||
1308 | jmp @b |
||
1309 | @@: lea ebx,[esi+4] |
||
1310 | push ecx |
||
1311 | lea edi,[ebx-1] |
||
1312 | add edi,[esi] |
||
1313 | mov esi,edi |
||
1314 | sub esi,ecx |
||
1315 | lea ecx,[esi+1] |
||
1316 | sub ecx,ebx |
||
1317 | sub ecx,[posx] |
||
1318 | std |
||
1319 | rep movsb |
||
1320 | .ok: pop ecx |
||
1321 | pop eax |
||
1322 | rep stosb |
||
1323 | |||
1324 | cld |
||
1325 | |||
1326 | pop [posx] |
||
1327 | |||
1328 | lea esi,[ebx-4] |
||
1329 | call get_real_length |
||
1330 | cmp eax,[posx] |
||
1331 | jae @f |
||
1332 | mov eax,[posx] |
||
1333 | @@: cmp eax,[columns] |
||
1334 | jbe @f |
||
1335 | mov [columns],eax |
||
1336 | @@: |
||
1337 | jmp check_inv_all |
||
1338 | ; TAB } |
||
1339 | |||
1340 | notab: |
||
1341 | |||
1342 | ; ADD_KEY { |
||
1343 | push [posx] eax |
||
1344 | inc dword[esp+4] |
||
1345 | mov eax,1 |
||
1346 | jmp __key_tab.direct |
||
1347 | ; ADD_KEY } |
||
1348 | |||
1349 | check_inv_str = check_inv_all |
||
1350 | @^ |
||
1351 | func check_inv_str |
||
1352 | mov eax,[posy] |
||
1353 | mov ecx,[top_line] |
||
1354 | .skip_init: |
||
1355 | call check_cur_vis |
||
1356 | mov [posy],eax |
||
1357 | mov [top_line],ecx |
||
1358 | .skip_check: |
||
1359 | ; call invalidate_string |
||
1360 | call drawfile |
||
1361 | jmp still |
||
1362 | endf |
||
1363 | ^@ |
||
1364 | func check_inv_all |
||
1365 | mov eax,[posy] |
||
1366 | mov ecx,[top_line] |
||
1367 | .skip_init: |
||
1368 | call check_cur_vis |
||
1369 | mov [posy],eax |
||
1370 | mov [top_line],ecx |
||
1371 | .skip_check: |
||
1372 | ; call clear_screen |
||
1373 | call drawfile |
||
1374 | jmp still |
||
1375 | endf |
||
1376 | |||
1377 | func check_cur_vis |
||
1378 | cmp eax,ecx |
||
1379 | jb .low |
||
1380 | mov edx,ecx |
||
1381 | add edx,[slines] |
||
1382 | cmp edx,[lines] |
||
1383 | jbe @f |
||
1384 | mov edx,[lines] |
||
1385 | @@: cmp eax,edx |
||
1386 | jb @f |
||
1387 | lea ecx,[eax+1] |
||
1388 | sub ecx,[slines] |
||
1389 | jns @f |
||
1390 | xor ecx,ecx |
||
1391 | jmp @f |
||
1392 | .low: mov ecx,eax |
||
1393 | @@: |
||
1394 | mov edx,ecx |
||
1395 | add edx,[slines] |
||
1396 | cmp edx,[lines] |
||
1397 | jbe @f |
||
1398 | mov ecx,[lines] |
||
1399 | sub ecx,[slines] |
||
1400 | jns @f |
||
1401 | xor ecx,ecx |
||
1402 | @@:;mov [top_line],eax |
||
1403 | |||
1404 | pushad |
||
1405 | mov eax,[posx] |
||
1406 | mov ebx,[left_col] |
||
1407 | mov ecx,ebx |
||
1408 | add ecx,[scolumns] |
||
1409 | cmp eax,ebx |
||
1410 | jb .lp1 |
||
1411 | cmp eax,ecx |
||
1412 | jb .exit.2 |
||
1413 | lea ebx,[eax] |
||
1414 | sub ebx,[scolumns] |
||
1415 | jmp @f |
||
1416 | .lp1: mov ebx,eax |
||
1417 | @@: mov [left_col],ebx |
||
1418 | .exit.2: |
||
1419 | mov [posx],eax |
||
1420 | popad |
||
1421 | |||
1422 | ret |
||
1423 | endf |
||
1424 | |||
1425 | func get_real_length |
||
1426 | mov eax,[esi] |
||
1427 | @@: cmp byte[esi+eax+4-1],' ' |
||
1428 | jne @f |
||
1429 | dec eax |
||
1430 | jnz @b |
||
1431 | @@: ret |
||
1432 | endf |
||
1433 | |||
1434 | ;****************************************************************************** |
||
1435 | |||
1436 | ;---------------------------------------------------------------------------- |
||
1437 | func start_fasm ;//////////////////////////////////////////////////////////// |
||
1438 | ;---------------------------------------------------------------------------- |
||
1439 | ; BL = run after compile |
||
1440 | ;---------------------------------------------------------------------------- |
||
1441 | cmp [asm_mode],0 |
||
1442 | jne @f |
||
1443 | ret |
||
1444 | @@: mov esi,s_fname |
||
1445 | mov edi,fasm_parameters |
||
1446 | |||
1447 | cmp byte[esi],'/' |
||
1448 | je .yes_systree |
||
1449 | |||
1450 | mov ecx,[s_fname.size] |
||
1451 | rep movsb |
||
1452 | |||
1453 | mov al,',' |
||
1454 | stosb |
||
1455 | |||
1456 | mov ecx,[s_fname.size] |
||
1457 | add ecx,-4 |
||
1458 | mov esi,s_fname |
||
1459 | rep movsb |
||
1460 | |||
1461 | mov al,',' |
||
1462 | stosb |
||
1463 | |||
1464 | mov dword[edi],'/RD/' |
||
1465 | mov word[edi+4],'1/' |
||
1466 | add edi,6 |
||
1467 | |||
1468 | mov al,0 |
||
1469 | stosb |
||
1470 | |||
1471 | jmp .run |
||
1472 | |||
1473 | .yes_systree: |
||
1474 | add esi,[s_fname.size] |
||
1475 | dec esi |
||
1476 | |||
1477 | xor ecx,ecx |
||
1478 | mov al,'/' |
||
1479 | @@: cmp [esi],al |
||
1480 | je @f |
||
1481 | dec esi |
||
1482 | inc ecx |
||
1483 | jmp @b |
||
1484 | @@: inc esi |
||
1485 | |||
1486 | push esi esi ecx |
||
1487 | |||
1488 | rep movsb |
||
1489 | |||
1490 | mov al,',' |
||
1491 | stosb |
||
1492 | |||
1493 | pop ecx esi |
||
1494 | |||
1495 | add ecx,-4 |
||
1496 | rep movsb |
||
1497 | |||
1498 | mov al,',' |
||
1499 | stosb |
||
1500 | |||
1501 | pop ecx |
||
1502 | sub ecx,s_fname |
||
1503 | mov esi,s_fname |
||
1504 | |||
1505 | rep movsb |
||
1506 | |||
1507 | mov al,0 |
||
1508 | stosb |
||
1509 | |||
1510 | .run: |
||
1511 | cmp bl,0 ; run outfile ? |
||
1512 | je @f |
||
1513 | mov dword[edi-1],',run' |
||
1514 | mov byte[edi+3],0 |
||
1515 | @@: mcall 19,fasm_filename,fasm_parameters |
||
1516 | ret |
||
1517 | endf |
||
1518 | |||
1519 | func open_debug_board |
||
1520 | mcall 19,debug_filename,0 |
||
1521 | ret |
||
1522 | endf |
||
1523 | |||
1524 | func open_sysfuncs_txt |
||
1525 | mcall 19,tinypad_filename,sysfuncs_filename |
||
1526 | ret |
||
1527 | endf |
||
1528 | |||
1529 | func layout |
||
1530 | ; сменить раскладку клавиатуры |
||
1531 | mcall 19,setup,param_setup |
||
1532 | mcall 5,eax |
||
1533 | ; call activate_me |
||
1534 | ; ret |
||
1535 | ;endf |
||
1536 | |||
1537 | ;func activate_me |
||
1538 | mcall 9,p_info,-1 |
||
1539 | inc eax |
||
1540 | inc eax |
||
1541 | mov ecx,eax |
||
1542 | mov edi,[p_info.PID] |
||
1543 | mov ebx,p_info |
||
1544 | @@: dec ecx |
||
1545 | jz @f ; counter=0 => not found? => return |
||
1546 | mcall 9 |
||
1547 | cmp edi,[p_info.PID] |
||
1548 | jne @b |
||
1549 | mcall 18,3 |
||
1550 | mcall 5,eax |
||
1551 | @@: ret |
||
1552 | endf |
||
1553 | |||
1554 | ; ******************************************************************* |
||
1555 | ; ************************** DRAW WINDOW ************************** |
||
1556 | ; ******************************************************************* |
||
1557 | |||
1558 | func drawwindow |
||
1559 | |||
1560 | mcall 48,3,sc,sizeof.system_colors |
||
1561 | |||
1562 | mcall 12,1 |
||
1563 | |||
1564 | push [color_tbl+4*5] |
||
1565 | pop [sc.work] |
||
1566 | |||
1567 | mov edx,[sc.work] |
||
1568 | add edx,0x03000000 |
||
1569 | mov esi,[sc.grab] |
||
1570 | or esi,0x80000000 |
||
1571 | mcall 0,<100,6*80+6+OLEFT+SCRLW>,<75,402>,,,[sc.frame] |
||
1572 | |||
1573 | mcall 48,4 |
||
1574 | mov [skinh],eax |
||
1575 | push eax |
||
1576 | |||
1577 | mcall 9,p_info,-1 |
||
1578 | pop eax |
||
1579 | cmp [p_info.y_size],0 |
||
1580 | je .exit.2 |
||
1581 | |||
1582 | mov [top_ofs],eax |
||
1583 | dec [top_ofs] |
||
1584 | cmp [asm_mode],0 |
||
1585 | je @f |
||
1586 | add [top_ofs],ATOPH+1 |
||
1587 | @@: |
||
1588 | ; header string |
||
1589 | mov ebx,eax |
||
1590 | shr ebx,1 |
||
1591 | adc ebx,1+0x000A0000-4 |
||
1592 | mcall 4,,[sc.grab_text],s_title,[s_title.size] |
||
1593 | |||
1594 | mov eax,[p_info.x_size] |
||
1595 | sub eax,5*2+SCRLW+2 |
||
1596 | cdq |
||
1597 | mov ebx,6 |
||
1598 | div ebx |
||
1599 | mov [scolumns],eax |
||
1600 | |||
1601 | mov eax,[p_info.y_size] ; calculate buttons position |
||
1602 | add eax,-5-ABTNH*3-2-2 |
||
1603 | mov [bot_ofs],eax |
||
1604 | |||
1605 | ; mov eax,[procinfo.y_size] |
||
1606 | mov [do_not_draw],1 ; do_not_draw = true |
||
1607 | |||
1608 | mov ebx,eax |
||
1609 | sub ebx,[skinh] |
||
1610 | sub ebx,ATOPH+SCRLW*3+AMINS+5 |
||
1611 | js .no_draw |
||
1612 | |||
1613 | ; cmp eax,100 |
||
1614 | ; jb .no_draw ; do not draw text & buttons if height < 100 |
||
1615 | |||
1616 | mov [do_not_draw],0 ; do_not_draw = false |
||
1617 | sub eax,SCRLW+2+2 |
||
1618 | sub eax,[top_ofs] |
||
1619 | cdq |
||
1620 | mov ebx,10 |
||
1621 | div ebx |
||
1622 | mov [slines],eax |
||
1623 | |||
1624 | mov ebx,[p_info.x_size] |
||
1625 | add ebx,5*65536-5 |
||
1626 | mov ecx,[top_ofs-2] |
||
1627 | mov cx,word[top_ofs] |
||
1628 | mcall 38,,,[sc.work_text] |
||
1629 | mov ecx,[bot_ofs-2] |
||
1630 | mov cx,word[bot_ofs] |
||
1631 | sub ecx,0x00010001 |
||
1632 | push ecx |
||
1633 | mcall |
||
1634 | add ecx,(ABTNH+2)*65536+ABTNH+2 |
||
1635 | mcall |
||
1636 | add ecx,(ABTNH+2)*65536+ABTNH+2 |
||
1637 | mcall |
||
1638 | pop ecx |
||
1639 | add cx,(ABTNH+2)*3 |
||
1640 | mov ebx,[p_info.x_size] |
||
1641 | sub ebx,RBTNW+5+1 |
||
1642 | push bx |
||
1643 | shl ebx,16 |
||
1644 | pop bx |
||
1645 | mcall |
||
1646 | mov ebx,(5+LBTNW+1)*65536+(5+LBTNW+1) |
||
1647 | add ecx,(ABTNH+2)*65536 |
||
1648 | mcall |
||
1649 | |||
1650 | inc [top_ofs] |
||
1651 | |||
1652 | mov ebx,5*65536 |
||
1653 | mov bx,word[p_info.x_size] |
||
1654 | sub bx,9 |
||
1655 | push bx |
||
1656 | sub bx,RBTNW+2 |
||
1657 | mov ecx,[bot_ofs-2] |
||
1658 | mov cx,ABTNH+1 |
||
1659 | mcall 13,,,[sc.work_graph] ; BAR STRIPE |
||
1660 | |||
1661 | pop bx |
||
1662 | cmp [asm_mode],0 |
||
1663 | je .skip_top_btns |
||
1664 | mov ecx,[skinh-2] |
||
1665 | mov cx,ATOPH |
||
1666 | mcall ; UPPER BAR |
||
1667 | |||
1668 | mov eax,8 |
||
1669 | mov ebx,6*65536+52 |
||
1670 | mov ecx,[skinh] |
||
1671 | inc ecx |
||
1672 | shl ecx,16 |
||
1673 | add ecx,ATOPH-3 |
||
1674 | mov edx,10000 |
||
1675 | mov esi,[sc.work_button] |
||
1676 | @@: |
||
1677 | mcall ; TOOLBAR BUTTONS |
||
1678 | add ebx,54*65536 |
||
1679 | inc edx |
||
1680 | cmp edx,10004 |
||
1681 | jb @b |
||
1682 | |||
1683 | .skip_top_btns: |
||
1684 | mov ebx,5*65536+LBTNW |
||
1685 | mov ecx,[bot_ofs] |
||
1686 | shl ecx,16 |
||
1687 | add ecx,(ABTNH+2)*65536+ABTNH |
||
1688 | mcall 8,,,5,[sc.work_button] ; FILE BUTTON |
||
1689 | |||
1690 | add ecx,(ABTNH+2)*65536 |
||
1691 | mcall ,,,51 ; STRING BUTTON |
||
1692 | |||
1693 | push ebx ecx |
||
1694 | |||
1695 | mov ebx,[p_info.x_size] |
||
1696 | shl ebx,16 |
||
1697 | add ebx,(-5-RBTNW)*65536+RBTNW |
||
1698 | mov ecx,[bot_ofs] |
||
1699 | shl ecx,16 |
||
1700 | add ecx,ABTNH |
||
1701 | mov edx,2 |
||
1702 | mcall ,,,2 ; SAVE BUTTON |
||
1703 | |||
1704 | add ecx,(ABTNH+2)*65536 |
||
1705 | mcall ,,,4 ; FILE BUTTON |
||
1706 | |||
1707 | add ecx,(ABTNH+2)*65536 |
||
1708 | mcall ,,,50 ; SEARCH BUTTON |
||
1709 | |||
1710 | shr ecx,16 |
||
1711 | mov bx,cx |
||
1712 | add ebx,-ABTNH-2-ABTNH/2-2-3 |
||
1713 | mcall 4,,[sc.work_button_text],rstr,rstr.size/3 |
||
1714 | add ebx,ABTNH+2 |
||
1715 | add edx,rstr.size/3 |
||
1716 | mcall |
||
1717 | add ebx,ABTNH+2 |
||
1718 | add edx,rstr.size/3 |
||
1719 | mcall |
||
1720 | |||
1721 | pop edi ebx |
||
1722 | shr edi,16 |
||
1723 | mov bx,di |
||
1724 | add ebx,-1-ABTNH/2-2-2 |
||
1725 | mcall ,,,lstr,lstr.size/2 |
||
1726 | add ebx,ABTNH+2 |
||
1727 | add edx,lstr.size/2 |
||
1728 | mcall |
||
1729 | |||
1730 | cmp [asm_mode],0 |
||
1731 | je @f |
||
1732 | mov ebx,[skinh] |
||
1733 | add ebx,0x000C0000+ATOPH/2-4 |
||
1734 | mcall ,,,toolbar_btn_text,toolbar_btn_text.size |
||
1735 | @@: |
||
1736 | mov eax,[bot_ofs] |
||
1737 | add eax,ABTNH+2 |
||
1738 | mov [ya],eax |
||
1739 | mov [addr],s_fname |
||
1740 | call print_text |
||
1741 | |||
1742 | add eax,ABTNH+2 |
||
1743 | mov [ya],eax |
||
1744 | mov [addr],s_search |
||
1745 | call print_text |
||
1746 | jmp .exit |
||
1747 | |||
1748 | .no_draw: |
||
1749 | mov ebx,[skinh] |
||
1750 | mov [top_ofs],ebx |
||
1751 | mov eax,[p_info.y_size] |
||
1752 | add eax,-3 |
||
1753 | mov [bot_ofs],eax |
||
1754 | sub eax,ebx |
||
1755 | push eax |
||
1756 | add eax,-2-SCRLW |
||
1757 | cdq |
||
1758 | mov ebx,10 |
||
1759 | idiv ebx |
||
1760 | mov [slines],eax |
||
1761 | pop eax |
||
1762 | |||
1763 | mov ebx,[p_info.y_size] |
||
1764 | sub ebx,[skinh] |
||
1765 | sub ebx,SCRLW*3++AMINS+7 |
||
1766 | jns @f |
||
1767 | |||
1768 | inc [do_not_draw] |
||
1769 | |||
1770 | add eax,-2 |
||
1771 | cdq |
||
1772 | mov ebx,10 |
||
1773 | idiv ebx |
||
1774 | mov [slines],eax |
||
1775 | |||
1776 | mov eax,[p_info.x_size] |
||
1777 | sub eax,5*2 |
||
1778 | cdq |
||
1779 | mov ebx,6 |
||
1780 | idiv ebx |
||
1781 | mov [scolumns],eax |
||
1782 | @@: |
||
1783 | |||
1784 | .exit: |
||
1785 | call drawfile |
||
1786 | .exit.2: |
||
1787 | mcall 12,2 |
||
1788 | ret |
||
1789 | endf |
||
1790 | |||
1791 | ;-------------------------------------------- |
||
1792 | func get_line_offset |
||
1793 | ;-------------------------------------------- |
||
1794 | ; Input: |
||
1795 | ; ECX = line number |
||
1796 | ; Output: |
||
1797 | ; ESI = line data offset |
||
1798 | ;-------------------------------------------- |
||
1799 | push eax |
||
1800 | mov esi,0x80000 |
||
1801 | jecxz .exit |
||
1802 | @@: lodsd |
||
1803 | add esi,eax |
||
1804 | loop @b |
||
1805 | .exit: |
||
1806 | pop eax |
||
1807 | ret |
||
1808 | endf |
||
1809 | |||
1810 | ; ********************************** |
||
1811 | ; *********** DRAWFILE *********** |
||
1812 | ; ********************************** |
||
1813 | |||
1814 | ;--------------------------------------------------- |
||
1815 | func drawfile.ex |
||
1816 | ;--------------------------------------------------- |
||
1817 | ; Input: |
||
1818 | ; EAX = start line |
||
1819 | ; EBX = end line |
||
1820 | ;--------------------------------------------------- |
||
1821 | cmp [p_info.y_size],0 |
||
1822 | jne @f |
||
1823 | ret |
||
1824 | @@: |
||
1825 | call check_bottom_right |
||
1826 | |||
1827 | pushad |
||
1828 | |||
1829 | cmp [slines],0 |
||
1830 | jle drawfile.exit |
||
1831 | |||
1832 | cmp eax,ebx |
||
1833 | jae @f |
||
1834 | xchg eax,ebx |
||
1835 | @@: cmp eax,[top_line] |
||
1836 | jae @f |
||
1837 | mov eax,[top_line] |
||
1838 | @@: mov ecx,[top_line] |
||
1839 | add ecx,[slines] |
||
1840 | cmp ebx,ecx |
||
1841 | jb @f |
||
1842 | dec ecx |
||
1843 | mov ebx,ecx |
||
1844 | @@: cmp eax,ebx |
||
1845 | ja drawfile.exit |
||
1846 | |||
1847 | mov ecx,eax |
||
1848 | call get_line_offset |
||
1849 | |||
1850 | .start: |
||
1851 | mov ecx,ebx |
||
1852 | sub ecx,eax |
||
1853 | |||
1854 | mov ebx,[top_ofs] |
||
1855 | add ebx,OLEFT*65536+1 |
||
1856 | sub eax,[top_line] |
||
1857 | imul eax,10 |
||
1858 | add ebx,eax |
||
1859 | |||
1860 | imul ebp,[left_col],6*65536 |
||
1861 | |||
1862 | jmp drawfile.next_line |
||
1863 | endf |
||
1864 | |||
1865 | func drawfile |
||
1866 | cmp [p_info.y_size],0 |
||
1867 | jne @f |
||
1868 | ret |
||
1869 | @@: |
||
1870 | call check_bottom_right |
||
1871 | |||
1872 | pushad |
||
1873 | |||
1874 | mov ebx,[top_ofs] |
||
1875 | add ebx,OLEFT*65536+1 |
||
1876 | |||
1877 | mov ecx,[top_line] |
||
1878 | call get_line_offset |
||
1879 | |||
1880 | .start: |
||
1881 | mov ecx,[slines] |
||
1882 | or ecx,ecx |
||
1883 | jle .exit |
||
1884 | |||
1885 | imul ebp,[left_col],6*65536 |
||
1886 | |||
1887 | .next_line: |
||
1888 | |||
1889 | push ecx ebx |
||
1890 | |||
1891 | mov ecx,ebx |
||
1892 | shl ecx,16 |
||
1893 | mov cl,10 |
||
1894 | mov ebx,[p_info.x_size] |
||
1895 | add ebx,(OLEFT-1)*65536-10-SCRLW ; |
||
1896 | mcall 13,,,[color_tbl+4*5] |
||
1897 | |||
1898 | xor ecx,ecx |
||
1899 | lodsd |
||
1900 | mov [cur_line_len],eax |
||
1901 | |||
1902 | or eax,eax |
||
1903 | ja .next_block |
||
1904 | add esp,4*2 |
||
1905 | jmp .draw_cursor |
||
1906 | |||
1907 | .next_block: |
||
1908 | |||
1909 | push esi |
||
1910 | push ecx |
||
1911 | call get_next_part |
||
1912 | pop ebx |
||
1913 | push ecx |
||
1914 | mov ecx,eax |
||
1915 | |||
1916 | push esi ebx |
||
1917 | mov eax,ebx |
||
1918 | sub ebx,[left_col] |
||
1919 | cmp ebx,[scolumns] |
||
1920 | jge @f |
||
1921 | add ebx,esi |
||
1922 | jle @f |
||
1923 | mov ebx,[esp+8+4*2] ;// 4*2=esi+ebx |
||
1924 | sub eax,[left_col] |
||
1925 | jge .qqq |
||
1926 | sub edx,eax |
||
1927 | add esi,eax |
||
1928 | mov eax,OLEFT*65536 |
||
1929 | jmp .qqq2 |
||
1930 | .qqq: |
||
1931 | inc eax |
||
1932 | imul eax,6*65536 |
||
1933 | .qqq2: |
||
1934 | and ebx,0x0000FFFF |
||
1935 | add ebx,eax |
||
1936 | |||
1937 | mov eax,[esp] |
||
1938 | add eax,[esp+4];esi |
||
1939 | sub eax,[left_col] |
||
1940 | sub eax,[scolumns] |
||
1941 | jle .qweqwe |
||
1942 | sub esi,eax |
||
1943 | .qweqwe: |
||
1944 | |||
1945 | mcall 4;[esp+8] |
||
1946 | @@: |
||
1947 | pop eax eax ; ebx esi |
||
1948 | imul eax,6 |
||
1949 | add [esp+10],ax |
||
1950 | pop ecx esi |
||
1951 | cmp ecx,[cur_line_len];LINE_WIDTH |
||
1952 | jl .next_block |
||
1953 | |||
1954 | pop ebx ecx |
||
1955 | and ebx,0x0000FFFF |
||
1956 | add ebx,OLEFT*65536+10 |
||
1957 | add esi,[cur_line_len];LINE_WIDTH |
||
1958 | dec ecx |
||
1959 | jg .next_line |
||
1960 | |||
1961 | ;-------------------------------------------------------------------------- |
||
1962 | .draw_cursor: |
||
1963 | mov eax,[posy] |
||
1964 | sub eax,[top_line] |
||
1965 | js @f |
||
1966 | mov ecx,[slines] |
||
1967 | sub ecx,eax |
||
1968 | jle @f |
||
1969 | imul eax,10 |
||
1970 | add eax,[top_ofs] |
||
1971 | inc eax |
||
1972 | shl eax,16 |
||
1973 | add eax,10-1 |
||
1974 | mov ecx,eax |
||
1975 | mov ebx,[posx] |
||
1976 | sub ebx,[left_col] |
||
1977 | js @f |
||
1978 | cmp ebx,[scolumns] |
||
1979 | ja @f |
||
1980 | imul ebx,6 |
||
1981 | add ebx,OLEFT-1 |
||
1982 | shl ebx,16 |
||
1983 | inc ebx |
||
1984 | inc ebx |
||
1985 | mov edx,[color_tbl+4*5] |
||
1986 | not edx |
||
1987 | and edx,0x00FFFFFF |
||
1988 | mcall 13 |
||
1989 | @@: |
||
1990 | ;-------------------------------------------------------------------------- |
||
1991 | cmp [do_not_draw],2 |
||
1992 | je .exit |
||
1993 | |||
1994 | mov ebx,[p_info.x_size] |
||
1995 | shl ebx,16 |
||
1996 | add ebx,(-SCRLW-5+2)*65536+SCRLW-2 |
||
1997 | mov ecx,[top_ofs-2] |
||
1998 | mov cx,SCRLW-1 |
||
1999 | mcall 8,,,'UP',[sc.work_button] |
||
2000 | pushad |
||
2001 | push 0x18 |
||
2002 | shr ecx,16 |
||
2003 | mov bx,cx |
||
2004 | add ebx,(SCRLW/2-3)*65536+SCRLW/2-4 |
||
2005 | mcall 4,,[sc.work_button_text],esp,1 |
||
2006 | add esp,4 |
||
2007 | popad |
||
2008 | mov ecx,[bot_ofs] |
||
2009 | shl ecx,16 |
||
2010 | add ecx,(-SCRLW*2-1)*65536+SCRLW-1 |
||
2011 | mcall ,,,'DN' |
||
2012 | pushad |
||
2013 | push 0x19 |
||
2014 | shr ecx,16 |
||
2015 | mov bx,cx |
||
2016 | add ebx,(SCRLW/2-3)*65536+SCRLW/2-4 |
||
2017 | mcall 4,,[sc.work_button_text],esp,1 |
||
2018 | add esp,4 |
||
2019 | popad |
||
2020 | sub ebx,1*65536-2 |
||
2021 | |||
2022 | push ebx |
||
2023 | mov eax,[lines] |
||
2024 | mov ebx,[slines] |
||
2025 | mov ecx,[top_line] |
||
2026 | mov edx,[bot_ofs] |
||
2027 | sub edx,[top_ofs] |
||
2028 | add edx,-(SCRLW*3+2) |
||
2029 | call get_scroll_vars |
||
2030 | mov [vscrl_top],eax |
||
2031 | mov [vscrl_size],ebx |
||
2032 | pop ebx |
||
2033 | |||
2034 | mov ecx,eax |
||
2035 | add ecx,[top_ofs] |
||
2036 | shl ecx,16 |
||
2037 | mov cx,word[vscrl_size] |
||
2038 | add ecx,(SCRLW+1)*65536 |
||
2039 | mcall 13,,,[sc.work_button] |
||
2040 | mov ecx,[top_ofs-2] |
||
2041 | mov cx,word[vscrl_top] |
||
2042 | add ecx,(SCRLW+1)*65536 |
||
2043 | mov edx,[color_tbl+4*5] |
||
2044 | or cx,cx |
||
2045 | jle @f |
||
2046 | mcall |
||
2047 | @@: |
||
2048 | mov ecx,[top_ofs] |
||
2049 | add ecx,[vscrl_top] |
||
2050 | add ecx,[vscrl_size] |
||
2051 | add ecx,SCRLW+1 |
||
2052 | mov di,cx |
||
2053 | shl ecx,16 |
||
2054 | mov cx,word[bot_ofs] |
||
2055 | sub cx,di |
||
2056 | sub cx,(SCRLW+1)*2 |
||
2057 | jle @f |
||
2058 | mcall |
||
2059 | @@: |
||
2060 | ;------------------------------- |
||
2061 | @^ |
||
2062 | pushad |
||
2063 | mov eax,ebx |
||
2064 | shr eax,16 |
||
2065 | mov bx,ax |
||
2066 | add ebx,0x00010001 |
||
2067 | mov ecx,[top_ofs] |
||
2068 | add ecx,[vscrl_top] |
||
2069 | add ecx,SCRLW+1 |
||
2070 | mov eax,ecx |
||
2071 | shl ecx,16 |
||
2072 | add eax,[vscrl_size] |
||
2073 | dec eax |
||
2074 | add ecx,eax |
||
2075 | mov edx,[sc.work_button] |
||
2076 | add edx,0x00202020 |
||
2077 | mcall 38 |
||
2078 | add ebx,(SCRLW-2)*65536+(SCRLW-2) |
||
2079 | mov edx,[sc.work_button] |
||
2080 | sub edx,0x00202020 |
||
2081 | mcall 38 |
||
2082 | sub ebx,(SCRLW-2)*65536 |
||
2083 | mov ax,cx |
||
2084 | shl ecx,16 |
||
2085 | mov cx,ax |
||
2086 | mcall 38 |
||
2087 | mov eax,[vscrl_size-2] |
||
2088 | mov ax,word[vscrl_size] |
||
2089 | sub eax,0x00010001 |
||
2090 | sub ecx,eax |
||
2091 | mov edx,[sc.work_button] |
||
2092 | add edx,0x00202020 |
||
2093 | mcall 38 |
||
2094 | popad |
||
2095 | ^@ |
||
2096 | ;------------------------------- |
||
2097 | mov eax,ebx |
||
2098 | shr eax,16 |
||
2099 | add bx,ax |
||
2100 | mov ecx,[top_ofs-2] |
||
2101 | mov cx,word[top_ofs] |
||
2102 | add ecx,SCRLW*65536+SCRLW |
||
2103 | mcall 38,,,[sc.work_text] |
||
2104 | mov ecx,[bot_ofs-2] |
||
2105 | mov cx,word[bot_ofs] |
||
2106 | sub ecx,(SCRLW*2+2)*65536+(SCRLW*2+2) |
||
2107 | mcall |
||
2108 | rol ebx,16 |
||
2109 | push bx |
||
2110 | rol ebx,16 |
||
2111 | pop bx |
||
2112 | mov ecx,[top_ofs-2] |
||
2113 | mov cx,word[bot_ofs] |
||
2114 | add ecx,-2 |
||
2115 | mcall |
||
2116 | ;-------------------------------------------------------------------------- |
||
2117 | mov ebx,5*65536+SCRLW-1 |
||
2118 | mov ecx,[bot_ofs] |
||
2119 | shl ecx,16 |
||
2120 | add ecx,(-SCRLW)*65536+SCRLW-2 |
||
2121 | mcall 8,,,'LT',[sc.work_button] |
||
2122 | pushad |
||
2123 | push 0x1B |
||
2124 | shr ecx,16 |
||
2125 | mov bx,cx |
||
2126 | add ebx,(SCRLW/2-3)*65536+SCRLW/2-4 |
||
2127 | mcall 4,,[sc.work_button_text],esp,1 |
||
2128 | add esp,4 |
||
2129 | popad |
||
2130 | mov ebx,[p_info.x_size] |
||
2131 | shl ebx,16 |
||
2132 | add ebx,(-SCRLW*2-5)*65536+SCRLW |
||
2133 | mcall ,,,'RT' |
||
2134 | pushad |
||
2135 | push 0x1A |
||
2136 | shr ecx,16 |
||
2137 | mov bx,cx |
||
2138 | add ebx,(SCRLW/2-2)*65536+SCRLW/2-4 |
||
2139 | mcall 4,,[sc.work_button_text],esp,1 |
||
2140 | add esp,4 |
||
2141 | popad |
||
2142 | inc ecx |
||
2143 | |||
2144 | push ecx |
||
2145 | mov eax,[columns] |
||
2146 | mov ebx,[scolumns] |
||
2147 | mov ecx,[left_col] |
||
2148 | mov edx,[p_info.x_size] |
||
2149 | add edx,-(SCRLW*3+10) |
||
2150 | call get_scroll_vars |
||
2151 | mov [hscrl_top],eax |
||
2152 | mov [hscrl_size],ebx |
||
2153 | pop ecx |
||
2154 | |||
2155 | mov ebx,eax |
||
2156 | add ebx,OLEFT+SCRLW |
||
2157 | shl ebx,16 |
||
2158 | mov bx,word[hscrl_size] |
||
2159 | mcall 13,,,[sc.work_button] |
||
2160 | mov ebx,(OLEFT+SCRLW)*65536 |
||
2161 | mov bx,word[hscrl_top] |
||
2162 | mcall ,,,[color_tbl+4*5] |
||
2163 | mov ebx,OLEFT+SCRLW-1 |
||
2164 | add ebx,[hscrl_top] |
||
2165 | add ebx,[hscrl_size] |
||
2166 | mov di,bx |
||
2167 | shl ebx,16 |
||
2168 | mov bx,word[p_info.x_size] |
||
2169 | sub bx,di |
||
2170 | sub bx,SCRLW*2+6 |
||
2171 | jle @f |
||
2172 | mcall |
||
2173 | @@: |
||
2174 | mov eax,ebx |
||
2175 | shr eax,16 |
||
2176 | add bx,ax |
||
2177 | mov ecx,[bot_ofs-2] |
||
2178 | mov cx,word[bot_ofs] |
||
2179 | sub ecx,SCRLW*65536+2 |
||
2180 | mcall 38, |
||
2181 | mov ebx,[p_info.x_size-2] |
||
2182 | mov bx,word[p_info.x_size] |
||
2183 | sub ebx,(SCRLW*2+6)*65536+(SCRLW*2+6) |
||
2184 | mcall |
||
2185 | mov ebx,[p_info.x_size] |
||
2186 | add ebx,5*65536-5 |
||
2187 | mov ecx,[bot_ofs-2] |
||
2188 | mov cx,word[bot_ofs] |
||
2189 | sub ecx,(SCRLW+1)*65536+(SCRLW+1) |
||
2190 | mcall |
||
2191 | ;-------------------------------------------------------------------------- |
||
2192 | |||
2193 | .exit: |
||
2194 | popad |
||
2195 | ret |
||
2196 | endf |
||
2197 | |||
2198 | ;-------------------------------------------- |
||
2199 | func get_scroll_vars |
||
2200 | ;-------------------------------------------- |
||
2201 | ; Input: |
||
2202 | ; EAX = maximum data size (units) |
||
2203 | ; EBX = visible data size (units) |
||
2204 | ; ECX = current data position (units) |
||
2205 | ; EDX = scrolling area size (pixels) |
||
2206 | ; Output: |
||
2207 | ; EAX = srcoller offset (pixels) |
||
2208 | ; EBX = scroller size (pixels) |
||
2209 | ;-------------------------------------------- |
||
2210 | push eax ebx ecx edx |
||
2211 | ; sub eax,ebx |
||
2212 | mov esi,eax |
||
2213 | mov eax,edx |
||
2214 | mul ebx |
||
2215 | idiv esi |
||
2216 | cmp eax,[esp] |
||
2217 | jae .null |
||
2218 | cmp eax,AMINS |
||
2219 | jae @f |
||
2220 | neg eax |
||
2221 | add eax,AMINS |
||
2222 | sub [esp],eax |
||
2223 | mov eax,AMINS |
||
2224 | @@: mov [esp+8],eax ; scroller size |
||
2225 | mov eax,[esp] |
||
2226 | mul ecx |
||
2227 | idiv esi |
||
2228 | mov [esp+12],eax ; scroller offset |
||
2229 | add eax,[esp+8] |
||
2230 | cmp eax,[esp] |
||
2231 | jbe @f |
||
2232 | dec dword[esp+12] |
||
2233 | @@: |
||
2234 | pop edx ecx ebx eax |
||
2235 | ret |
||
2236 | .null: |
||
2237 | mov dword[esp+8],0 |
||
2238 | mov dword[esp+12],0 |
||
2239 | jmp @b |
||
2240 | endf |
||
2241 | |||
2242 | ;-------------------------------------------- |
||
2243 | func get_next_part |
||
2244 | ;-------------------------------------------- |
||
2245 | ; Input: |
||
2246 | ; ECX = current letter |
||
2247 | ; ESI = string |
||
2248 | ; Output: |
||
2249 | ; ECX = color |
||
2250 | ; EDX = string |
||
2251 | ; ESI = length |
||
2252 | ;-------------------------------------------- |
||
2253 | cmp [asm_mode],0 |
||
2254 | je .plain.text |
||
2255 | xor ebx,ebx |
||
2256 | mov edx,ecx |
||
2257 | add esi,ecx |
||
2258 | mov edi,symbols |
||
2259 | mov al,[esi] |
||
2260 | cmp al,';' |
||
2261 | je .comment |
||
2262 | mov ecx,symbols.size |
||
2263 | repne scasb |
||
2264 | je .symbol |
||
2265 | cmp al,'$' |
||
2266 | jne @f |
||
2267 | mov edi,symbols |
||
2268 | mov al,[esi+1] |
||
2269 | mov ecx,symbols.size |
||
2270 | repne scasb |
||
2271 | je .not_symbol |
||
2272 | jmp .number |
||
2273 | @@: cmp al,'0' |
||
2274 | jb @f |
||
2275 | cmp al,'9' |
||
2276 | jbe .number |
||
2277 | @@: cmp al,"'" |
||
2278 | je .string |
||
2279 | cmp al,'"' |
||
2280 | je .string |
||
2281 | .not_symbol: |
||
2282 | inc ebx |
||
2283 | inc edx |
||
2284 | cmp edx,[cur_line_len];LINE_WIDTH |
||
2285 | jge @f |
||
2286 | mov edi,symbols |
||
2287 | mov al,[esi+ebx] |
||
2288 | cmp al,';' |
||
2289 | je @f |
||
2290 | mov ecx,symbols.size |
||
2291 | repne scasb |
||
2292 | jne .not_symbol |
||
2293 | @@: mov ecx,edx |
||
2294 | mov edx,esi |
||
2295 | mov esi,ebx |
||
2296 | mov eax,[color_tbl+4*0] |
||
2297 | ret |
||
2298 | .symbol: |
||
2299 | inc ebx |
||
2300 | inc edx |
||
2301 | cmp edx,[cur_line_len];LINE_WIDTH |
||
2302 | jge @f |
||
2303 | mov edi,symbols |
||
2304 | mov al,[esi+ebx] |
||
2305 | mov ecx,symbols.size |
||
2306 | repne scasb |
||
2307 | je .symbol |
||
2308 | @@: mov ecx,edx |
||
2309 | mov edx,esi |
||
2310 | mov esi,ebx |
||
2311 | mov eax,[color_tbl+4*4] |
||
2312 | ret |
||
2313 | .comment: |
||
2314 | neg edx |
||
2315 | add edx,[cur_line_len];LINE_WIDTH |
||
2316 | xchg edx,esi |
||
2317 | mov ecx,[cur_line_len];LINE_WIDTH |
||
2318 | mov eax,[color_tbl+4*3] |
||
2319 | ret |
||
2320 | .number: |
||
2321 | inc ebx |
||
2322 | inc edx |
||
2323 | cmp edx,[cur_line_len];LINE_WIDTH |
||
2324 | jge @f |
||
2325 | mov edi,symbols |
||
2326 | mov al,[esi+ebx] |
||
2327 | cmp al,';' |
||
2328 | je @f |
||
2329 | mov ecx,symbols.size |
||
2330 | repne scasb |
||
2331 | jne .number |
||
2332 | @@: mov ecx,edx |
||
2333 | mov edx,esi |
||
2334 | mov esi,ebx |
||
2335 | mov eax,[color_tbl+4*1] |
||
2336 | ret |
||
2337 | .string: |
||
2338 | inc ebx |
||
2339 | inc edx |
||
2340 | cmp edx,[cur_line_len];LINE_WIDTH |
||
2341 | jge @f |
||
2342 | cmp [esi+ebx],al |
||
2343 | jne .string |
||
2344 | inc ebx |
||
2345 | inc edx |
||
2346 | @@: |
||
2347 | mov ecx,edx |
||
2348 | mov edx,esi |
||
2349 | mov esi,ebx |
||
2350 | mov eax,[color_tbl+4*2] |
||
2351 | ret |
||
2352 | .plain.text: |
||
2353 | mov edx,[cur_line_len];LINE_WIDTH |
||
2354 | xchg edx,esi |
||
2355 | mov ecx,[cur_line_len];LINE_WIDTH |
||
2356 | mov eax,[color_tbl+4*0] |
||
2357 | ret |
||
2358 | endf |
||
2359 | |||
2360 | ; ******************************************** |
||
2361 | ; **************** SAVEFILE **************** |
||
2362 | ; ******************************************** |
||
2363 | func save_file |
||
2364 | mov esi,0x80000 ; 0x70000 = 448 Kbytes (maximum) |
||
2365 | mov edi,0x10000 |
||
2366 | |||
2367 | .new_string: |
||
2368 | call save_string |
||
2369 | cmp dword[esi],0 |
||
2370 | jne .new_string |
||
2371 | sub edi,0x10000+2 ; minus last CRLF |
||
2372 | ;! mov [filelen],edi |
||
2373 | cmp byte[s_fname],'/' |
||
2374 | je .systree_save |
||
2375 | mcall 33,s_fname,0x10000,edi,0;[filelen],0 |
||
2376 | test eax,eax |
||
2377 | je .exit |
||
2378 | call file_not_found |
||
2379 | jmp .exit |
||
2380 | |||
2381 | .systree_save: |
||
2382 | ;! mov eax,[filelen] |
||
2383 | mov [f_info+8],edi ;! eax |
||
2384 | mov [f_info+0],1 |
||
2385 | mov esi,s_fname |
||
2386 | mov edi,f_info.path |
||
2387 | mov ecx,PATHL |
||
2388 | cld |
||
2389 | rep movsb |
||
2390 | mcall 58,f_info |
||
2391 | |||
2392 | .exit: |
||
2393 | ret |
||
2394 | endf |
||
2395 | |||
2396 | func save_string |
||
2397 | lodsd |
||
2398 | mov ecx,eax |
||
2399 | |||
2400 | @@: cmp byte[esi+ecx-1],' ' |
||
2401 | jne @f |
||
2402 | loop @b |
||
2403 | @@: jecxz .endcopy |
||
2404 | xor edx,edx |
||
2405 | mov ebx,edx |
||
2406 | mov ah,dl |
||
2407 | |||
2408 | .next_char: |
||
2409 | mov al,[esi+ebx] |
||
2410 | inc ebx |
||
2411 | test ah,00000001b |
||
2412 | jnz .char |
||
2413 | cmp al,'"' |
||
2414 | jne @f |
||
2415 | xor ah,00000100b |
||
2416 | jmp .char |
||
2417 | @@: cmp al,"'" |
||
2418 | jne @f |
||
2419 | xor ah,00000010b |
||
2420 | jmp .char |
||
2421 | @@: test ah,00000110b |
||
2422 | jnz .char |
||
2423 | cmp al,';' |
||
2424 | jne @f |
||
2425 | test ah,00000001b |
||
2426 | jnz .char |
||
2427 | xor ah,00000001b |
||
2428 | jmp .char |
||
2429 | @@: cmp al,' ' |
||
2430 | jne .char |
||
2431 | inc edx |
||
2432 | test ebx,ATABW-1 |
||
2433 | jnz @f |
||
2434 | dec edx |
||
2435 | jle .put |
||
2436 | mov al,9 |
||
2437 | xor edx,edx |
||
2438 | jmp .put |
||
2439 | .char: |
||
2440 | or edx,edx |
||
2441 | jz .put |
||
2442 | push ecx eax |
||
2443 | mov ecx,edx |
||
2444 | mov al,' ' |
||
2445 | rep stosb |
||
2446 | pop eax ecx |
||
2447 | xor edx,edx |
||
2448 | .put: |
||
2449 | stosb |
||
2450 | @@: loop .next_char |
||
2451 | |||
2452 | .endcopy: |
||
2453 | mov eax,0x0A0D |
||
2454 | stosw |
||
2455 | add esi,[esi-4] |
||
2456 | ret |
||
2457 | endf |
||
2458 | |||
2459 | ; ******************************************** |
||
2460 | ; **************** LOADFILE **************** |
||
2461 | ; ******************************************** |
||
2462 | |||
2463 | func loadhdfile |
||
2464 | mov [f_info+0],0 |
||
2465 | mov [f_info+8],300000/512 |
||
2466 | mov esi,s_fname |
||
2467 | mov edi,f_info.path;pathfile_read |
||
2468 | mov ecx,PATHL |
||
2469 | cld |
||
2470 | rep movsb |
||
2471 | mcall 58,f_info ; fileinfo_read |
||
2472 | xchg eax,ebx |
||
2473 | inc eax |
||
2474 | test ebx,ebx |
||
2475 | je file_found |
||
2476 | cmp ebx,6 ;// ATV driver fix (6 instead of 5) |
||
2477 | je file_found |
||
2478 | call file_not_found |
||
2479 | ret |
||
2480 | endf |
||
2481 | |||
2482 | func loadfile |
||
2483 | mcall 6,s_fname,0,16800,0x10000 ; 6 = open file |
||
2484 | inc eax ; eax = -1 -> file not found |
||
2485 | jnz file_found |
||
2486 | call file_not_found |
||
2487 | ret |
||
2488 | |||
2489 | file_found: |
||
2490 | dec eax |
||
2491 | mov [filesize],eax |
||
2492 | mov [lines],1 |
||
2493 | mov [columns],0 |
||
2494 | mov esi,0x10000 |
||
2495 | mov edi,0x80000 |
||
2496 | mov edx,eax |
||
2497 | |||
2498 | .next_line: |
||
2499 | mov ebx,edi |
||
2500 | add edi,4 |
||
2501 | .next_char: |
||
2502 | or edx,edx |
||
2503 | jle .exit |
||
2504 | lodsb |
||
2505 | dec edx |
||
2506 | cmp al,13 |
||
2507 | je .CR |
||
2508 | cmp al,10 |
||
2509 | je .LF |
||
2510 | cmp al,9 |
||
2511 | je .TB |
||
2512 | cmp al,0 |
||
2513 | je .exit |
||
2514 | stosb |
||
2515 | jmp .next_char |
||
2516 | |||
2517 | .exit: |
||
2518 | mov ecx,10 |
||
2519 | mov al,' ' |
||
2520 | rep stosb |
||
2521 | lea eax,[edi-4] |
||
2522 | sub eax,ebx |
||
2523 | mov [ebx],eax |
||
2524 | mov dword[ebx+eax+4],0 |
||
2525 | sub eax,10 |
||
2526 | jnz @f |
||
2527 | inc eax |
||
2528 | @@: cmp eax,[columns] |
||
2529 | jbe @f |
||
2530 | mov [columns],eax |
||
2531 | @@: ret |
||
2532 | |||
2533 | .CR: cmp byte[esi],10 |
||
2534 | jne .LF |
||
2535 | lodsb |
||
2536 | dec edx |
||
2537 | .LF: mov ecx,10 |
||
2538 | mov al,' ' |
||
2539 | rep stosb |
||
2540 | lea eax,[edi-4] |
||
2541 | sub eax,ebx |
||
2542 | mov [ebx],eax |
||
2543 | inc [lines] |
||
2544 | add eax,-10 |
||
2545 | cmp eax,[columns] |
||
2546 | jbe .next_line |
||
2547 | mov [columns],eax |
||
2548 | jmp .next_line |
||
2549 | |||
2550 | .TB: lea eax,[edi-4] |
||
2551 | sub eax,ebx |
||
2552 | mov ecx,eax |
||
2553 | add ecx,ATABW |
||
2554 | and ecx,not(ATABW-1) |
||
2555 | sub ecx,eax |
||
2556 | mov al,' ' |
||
2557 | rep stosb |
||
2558 | jmp .next_char |
||
2559 | |||
2560 | file_not_found: |
||
2561 | mcall 55,eax,error_beep ; beep |
||
2562 | mov [lines],1 ; open empty document |
||
2563 | mov [columns],1 |
||
2564 | xor eax,eax |
||
2565 | mov [top_line],eax |
||
2566 | mov [posx],eax |
||
2567 | mov [posy],eax |
||
2568 | mov edi,0x80000+4 |
||
2569 | mov ecx,10 |
||
2570 | mov [edi-4],ecx |
||
2571 | mov [edi+10],eax |
||
2572 | mov al,' ' |
||
2573 | cld |
||
2574 | rep stosb |
||
2575 | ret |
||
2576 | endf |
||
2577 | |||
2578 | ; ***************************** |
||
2579 | ; ****** WRITE POSITION ****** |
||
2580 | ; ***************************** |
||
2581 | |||
2582 | func writepos |
||
2583 | cmp [do_not_draw],1 ; return if drawing is not permitted |
||
2584 | jae .exit |
||
2585 | pusha |
||
2586 | mov eax,[posx] |
||
2587 | inc eax |
||
2588 | mov ebx,5 |
||
2589 | mov ecx,10 |
||
2590 | mov edi,htext2.pos1 |
||
2591 | cld |
||
2592 | call uint2strz |
||
2593 | mov eax,[posy] |
||
2594 | inc eax |
||
2595 | mov ebx,5 |
||
2596 | mov edi,htext2.pos2 |
||
2597 | call uint2strz |
||
2598 | mov eax,[lines] ; number of lines |
||
2599 | mov ebx,5 |
||
2600 | mov edi,htext2.pos3 |
||
2601 | call uint2strz |
||
2602 | mov ebx,5*65536+htext2.size*6 |
||
2603 | mov ecx,[bot_ofs] |
||
2604 | shl ecx,16 |
||
2605 | add ecx,ABTNH |
||
2606 | mcall 13,,,[sc.work_graph] ; draw bar |
||
2607 | mov ebx,12*65536 |
||
2608 | mov bx,word[bot_ofs] |
||
2609 | add ebx,(ABTNH+2)/2-4 |
||
2610 | mcall 4,,[sc.work_button_text],htext2,htext2.size ; write position |
||
2611 | popa |
||
2612 | |||
2613 | .exit: |
||
2614 | ret |
||
2615 | endf |
||
2616 | |||
2617 | ;----------------------------------------------------------------------------- |
||
2618 | func uint2strz ;////////////////////////////////////////////////////////////// |
||
2619 | ;----------------------------------------------------------------------------- |
||
2620 | dec ebx |
||
2621 | jz @f |
||
2622 | xor edx,edx |
||
2623 | div ecx |
||
2624 | push edx |
||
2625 | call uint2strz |
||
2626 | pop eax |
||
2627 | @@: cmp al,10 |
||
2628 | sbb al,$69 |
||
2629 | das |
||
2630 | stosb |
||
2631 | ret |
||
2632 | endf |
||
2633 | |||
2634 | ; **************************** |
||
2635 | ; ******* READ STRING ******** |
||
2636 | ; **************************** |
||
2637 | |||
2638 | func read_string |
||
2639 | cmp al,5 |
||
2640 | jz .f1 |
||
2641 | cmp al,51 |
||
2642 | jz .f2 |
||
2643 | ret |
||
2644 | |||
2645 | .f1: mov [addr],s_fname |
||
2646 | mov eax,[bot_ofs] |
||
2647 | add eax,ABTNH+2 |
||
2648 | mov [ya],eax |
||
2649 | push 0 ; case insensitive |
||
2650 | jmp .rk |
||
2651 | .f2: mov [addr],s_search |
||
2652 | mov eax,[bot_ofs] |
||
2653 | add eax,(ABTNH+2)*2 |
||
2654 | mov [ya],eax |
||
2655 | push 1 ; case sensitive |
||
2656 | .rk: |
||
2657 | mov edi,[addr] |
||
2658 | mov ecx,PATHL |
||
2659 | sub ecx,[edi-4] |
||
2660 | add edi,[edi-4] |
||
2661 | mov al,$1C |
||
2662 | cld |
||
2663 | rep stosb |
||
2664 | |||
2665 | mov edi,[addr] |
||
2666 | mov eax,[edi-4] |
||
2667 | mov [temp],eax |
||
2668 | add edi,eax |
||
2669 | call print_text |
||
2670 | mcall 40,00000111b |
||
2671 | |||
2672 | .waitev: |
||
2673 | |||
2674 | mcall 10 |
||
2675 | cmp eax,2 |
||
2676 | jne .read_done |
||
2677 | mcall ;2 |
||
2678 | shr eax,8 |
||
2679 | cmp al,13 |
||
2680 | je .read_done |
||
2681 | cmp al,8 |
||
2682 | jne .nobs |
||
2683 | cmp edi,[addr] |
||
2684 | je .waitev |
||
2685 | dec [temp] |
||
2686 | mov eax,[addr] |
||
2687 | dec dword[eax-4] |
||
2688 | sub edi,1 |
||
2689 | mov byte[edi],$1C |
||
2690 | call print_text |
||
2691 | jmp .waitev |
||
2692 | .nobs: |
||
2693 | movzx ebx,al |
||
2694 | sub ebx,$20 |
||
2695 | jle .waitev |
||
2696 | cmp byte[esp],0 |
||
2697 | jne .keyok |
||
2698 | sub ebx,$40 |
||
2699 | jl .keyok |
||
2700 | add al,[ebx+add_table] |
||
2701 | .keyok: |
||
2702 | mov ecx,[addr] |
||
2703 | add ecx,PATHL |
||
2704 | cmp edi,ecx |
||
2705 | jae .waitev |
||
2706 | mov [edi],al |
||
2707 | inc [temp] |
||
2708 | mov eax,[addr] |
||
2709 | inc dword[eax-4] |
||
2710 | |||
2711 | call print_text |
||
2712 | inc edi |
||
2713 | jmp .waitev |
||
2714 | |||
2715 | .read_done: |
||
2716 | add esp,4 |
||
2717 | mov ecx,PATHL |
||
2718 | sub ecx,[temp] |
||
2719 | mov edi,[addr] |
||
2720 | add edi,[temp] |
||
2721 | mov al,' ' |
||
2722 | cld |
||
2723 | rep stosb |
||
2724 | mov [temp],987 |
||
2725 | call print_text |
||
2726 | mcall 40,00100111b |
||
2727 | ret |
||
2728 | endf |
||
2729 | |||
2730 | func print_text |
||
2731 | pusha |
||
2732 | mov ebx,(LBTNW+5+2)*65536 |
||
2733 | mov bx,word[p_info.x_size] |
||
2734 | sub bx,LBTNW+RBTNW+10+3 |
||
2735 | mov ecx,[ya-2] |
||
2736 | mov cx,ABTNH+1 |
||
2737 | mcall 13,,,[sc.work] |
||
2738 | mov ebx,(LBTNW+5+2+4)*65536+ABTNH/2-3 |
||
2739 | add ebx,[ya] |
||
2740 | mov eax,[p_info.x_size] |
||
2741 | sub eax,LBTNW+RBTNW+10+8 |
||
2742 | push eax |
||
2743 | cdq |
||
2744 | mov ecx,6 |
||
2745 | div ecx |
||
2746 | cmp eax,PATHL |
||
2747 | jbe @f |
||
2748 | mov eax,PATHL |
||
2749 | @@: mov esi,eax |
||
2750 | mcall 4,,[color_tbl+0],[addr] |
||
2751 | |||
2752 | mov eax,[ya] |
||
2753 | mov ebx,eax |
||
2754 | add eax,ABTNH/2-6 |
||
2755 | shl eax,16 |
||
2756 | add eax,ebx |
||
2757 | add eax,ABTNH/2-6+11 |
||
2758 | mov ecx,eax |
||
2759 | imul eax,[temp],6 |
||
2760 | pop ebx |
||
2761 | cmp eax,ebx |
||
2762 | jae @f |
||
2763 | add eax,LBTNW+5+2+4 |
||
2764 | mov ebx,eax |
||
2765 | shl eax,16 |
||
2766 | add ebx,eax |
||
2767 | mcall 38,,,[color_tbl+0] |
||
2768 | |||
2769 | @@: popa |
||
2770 | ret |
||
2771 | endf |
||
2772 | |||
2773 | include 'helpwnd.asm' |
||
2774 | |||
2775 | ;----------------------------------------------------------------------------- |
||
2776 | section @DATA ;/////////////////////////////////////////////////////////////// |
||
2777 | ;----------------------------------------------------------------------------- |
||
2778 | |||
2779 | addr dd s_fname ; address of input string |
||
2780 | temp dd 0xabc ; used in read_string |
||
2781 | vscrl_capt dd -1 |
||
2782 | hscrl_capt dd -1 |
||
2783 | |||
2784 | label color_tbl dword |
||
2785 | dd 0x00000000 ;0x00FFFF00 ; text |
||
2786 | dd 0x00009000 ;0x0000FF00 ; numbers |
||
2787 | dd 0x00A00000 ;0x0000FFFF ; strings |
||
2788 | dd 0x00909090 ;0x00C0C0C0 ; comments |
||
2789 | dd 0x003030f0 ;0x00FFFFFF ; symbols |
||
2790 | dd 0x00E0E0E0 ;0x00000080 ; background |
||
2791 | |||
2792 | add_table: |
||
2793 | ; times $61 db -$00 |
||
2794 | times $1A db -$20 |
||
2795 | times $25 db -$00 |
||
2796 | times $10 db -$20 |
||
2797 | times $30 db -$00 |
||
2798 | times $10 db -$50 |
||
2799 | times $04 db -$00,-$01 |
||
2800 | times $08 db -$00 |
||
2801 | |||
2802 | error_beep db 0xA0,0x30,0 |
||
2803 | |||
2804 | sz s_example,'README.TXT' |
||
2805 | sz s_still ,'still' |
||
2806 | |||
2807 | ;sz param_setup,<'LANG',0> ; parameter for SETUP |
||
2808 | param_setup db 'LANG',0 |
||
2809 | |||
2810 | sz fasm_filename ,'FASM ' |
||
2811 | sz debug_filename ,'BOARD ' |
||
2812 | sz tinypad_filename,'TINYPAD ' |
||
2813 | sz setup ,'SETUP ' ; to change keyboard layout |
||
2814 | |||
2815 | lsz sysfuncs_filename,\ |
||
2816 | ru,<'SYSFUNCR.TXT',0>,\ |
||
2817 | en,<'SYSFUNCS.TXT',0> |
||
2818 | |||
2819 | sz htext,'TINYPAD' |
||
2820 | sz toolbar_btn_text,'COMPILE RUN BOARD SYSFUNC' |
||
2821 | |||
2822 | lsz lstr,\ |
||
2823 | ru,<' ФАЙЛ > ',' СТРОКА > '>,\ |
||
2824 | en,<' FILE > ',' STRING > '> |
||
2825 | lsz rstr,\ |
||
2826 | ru,<' СОХРАНИТЬ ',' ЗАГРУЗИТЬ ',' ПОИСК '>,\ |
||
2827 | en,<' SAVE ' ,' LOAD ' ,' SEARCH ' > |
||
2828 | |||
2829 | lsz htext2,\ |
||
2830 | ru,'ПОЗИЦИЯ 00000:00000 ДЛИНА 00000 СТРОК',\ |
||
2831 | en,'POSITION 00000:00000 LENGTH 00000 LINES' |
||
2832 | if lang eq ru |
||
2833 | htext2.pos1 = htext2+8 |
||
2834 | htext2.pos2 = htext2+14 |
||
2835 | htext2.pos3 = htext2+28 |
||
2836 | else |
||
2837 | htext2.pos1 = htext2+9 |
||
2838 | htext2.pos2 = htext2+15 |
||
2839 | htext2.pos3 = htext2+30 |
||
2840 | end if |
||
2841 | |||
2842 | lszc help_text,b,\ |
||
2843 | ru,'КОМАНДЫ:',\ |
||
2844 | ru,' ',\ |
||
2845 | ru,' CTRL+F1 : Это окно',\ |
||
2846 | ru,' CTRL+S : Первая строка для копирования',\ |
||
2847 | ru,' CTRL+E : Последняя строка для копирования',\ |
||
2848 | ru,' CTRL+P : Вставить выбранное на текущую позицию',\ |
||
2849 | ru,' CTRL+D : Удалить строку',\ |
||
2850 | ru,' CTRL+L : Вставить строку-разделитель',\ |
||
2851 | ru,' CTRL+[ : Перейти в начало файла',\ |
||
2852 | ru,' CTRL+] : Перейти в конец файла',\ |
||
2853 | ru,' CTRL+F2 : Загрузить файл',\ |
||
2854 | ru,' CTRL+F3 : Поиск',\ |
||
2855 | ru,' CTRL+F4 : Сохранить файл',\ |
||
2856 | ru,' CTRL+F5 : Ввести имя файла',\ |
||
2857 | ru,' CTRL+F6 : Ввести строку для поиска',\ |
||
2858 | ru,' CTRL+F8 : Сменить раскладку клавиатуры',\ |
||
2859 | ru,'',\ |
||
2860 | en,'COMMANDS:',\ |
||
2861 | en,' ',\ |
||
2862 | en,' CTRL+F1 : SHOW THIS WINDOW',\ |
||
2863 | en,' CTRL+S : SELECT FIRST STRING TO COPY',\ |
||
2864 | en,' CTRL+E : SELECT LAST STRING TO COPY',\ |
||
2865 | en,' CTRL+P : PASTE SELECTED TO CURRENT POSITION',\ |
||
2866 | en,' CTRL+D : DELETE CURRENT LINE',\ |
||
2867 | en,' CTRL+L : INSERT SEPARATOR LINE',\ |
||
2868 | en,' CTRL+[ : GO TO THE BEGINNING OF FILE',\ |
||
2869 | en,' CTRL+] : GO TO THE END OF FILE',\ |
||
2870 | en,' CTRL+F2 : LOAD FILE',\ |
||
2871 | en,' CTRL+F3 : SEARCH',\ |
||
2872 | en,' CTRL+F4 : SAVE FILE',\ |
||
2873 | en,' CTRL+F5 : ENTER FILENAME',\ |
||
2874 | en,' CTRL+F6 : ENTER SEARCH STRING',\ |
||
2875 | en,' CTRL+F8 : CHANGE KEYBOARD LAYOUT',\ |
||
2876 | en,'' |
||
2877 | |||
2878 | lsz help_title,\ |
||
2879 | ru,'ПОМОЩЬ',\ |
||
2880 | en,'TINYPAD HELP' |
||
2881 | |||
2882 | sz symbols,'#&*\:/<>|{}()[]=+-, '; %.' |
||
2883 | |||
2884 | align 4 |
||
2885 | label f_info dword |
||
2886 | dd ? |
||
2887 | dd 0 |
||
2888 | dd ? |
||
2889 | dd 0x10000 |
||
2890 | dd 0x70000 |
||
2891 | .path: |
||
2892 | times PATHL+1 db ? |
||
2893 | |||
2894 | TINYPAD_END: ; end of file |
||
2895 | |||
2896 | ;----------------------------------------------------------------------------- |
||
2897 | section @UDATA ;////////////////////////////////////////////////////////////// |
||
2898 | ;----------------------------------------------------------------------------- |
||
2899 | |||
2900 | posx dd ? ; global X position (text cursor) |
||
2901 | posy dd ? ; global Y position (text cursor) |
||
2902 | lines dd ? ; number of lines in file |
||
2903 | slines dd ? ; number of lines on the screen |
||
2904 | columns dd ? ; number of columns in file |
||
2905 | scolumns dd ? ; number of columns on the screen |
||
2906 | top_ofs dd ? ; height occupied by top buttons |
||
2907 | bot_ofs dd ? ; height occupied by bottom buttons |
||
2908 | top_line dd ? ; topmost visible line on screen |
||
2909 | left_col dd ? ; leftmost visible char on line |
||
2910 | vscrl_top dd ? |
||
2911 | vscrl_size dd ? |
||
2912 | hscrl_top dd ? |
||
2913 | hscrl_size dd ? |
||
2914 | skinh dd ? ; skin height |
||
2915 | __rc dd ?,?,?,? |
||
2916 | ;filelen dd ? ; file size (on save) ??? |
||
2917 | filesize dd ? ; file size (on load) ??? |
||
2918 | ya dd ? ; for read_string |
||
2919 | copy_start dd ? ; first line for copying (Ctrl+S) |
||
2920 | copy_count dd ? ; number of lines for copying (Ctrl+E) |
||
2921 | copy_size dd ? ; size of data to copy |
||
2922 | s_title.size dd ? ; caption length |
||
2923 | |||
2924 | cur_line_len dd ? |
||
2925 | |||
2926 | asm_mode db ? ; ASM highlight? |
||
2927 | do_not_draw db ? ; draw top and bottom buttons? |
||
2928 | main_closed db ? ; main window closed? (to close help window) |
||
2929 | |||
2930 | align 4 |
||
2931 | s_fname.size dd ? |
||
2932 | s_fname rb PATHL+1 |
||
2933 | align 4 |
||
2934 | s_search.size dd ? |
||
2935 | s_search rb PATHL+1 |
||
2936 | |||
2937 | s_title rb 256 ; window caption |
||
2938 | |||
2939 | ;----------------------------------------------------------------------------- |
||
2940 | section @PARAMS ;///////////////////////////////////////////////////////////// |
||
2941 | ;----------------------------------------------------------------------------- |
||
2942 | |||
2943 | fasm_parameters: |
||
2944 | |||
2945 | p_info process_information |
||
2946 | sc system_colors>'>'>'>'>'SYSFUNCS.TXT',0>'SYSFUNCR.TXT',0>'LANG',0>>75,402>100,6*80+6+OLEFT+SCRLW>> |