Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ; SYSTEM HAEDER: |
2 | use32 |
||
3 | org 0x0 |
||
4 | db 'MENUET01' ; identifier |
||
5 | dd 0x01 ; version |
||
6 | dd START ; pointer to start |
||
7 | dd TINYPAD_END ; size of file |
||
8 | dd 0x300f00 ;0x500000; 0x3fff00;0x300000 ; size of memory |
||
9 | dd 0xeff0 ;0x4fffff ;0x3ff000;0xeff0 ; esp |
||
10 | dd I_PARAM ; parameters |
||
11 | dd 0 ; reserved |
||
12 | include 'lang.inc' |
||
13 | include 'ascl.inc' |
||
14 | include 'macros.inc' ; useful stuff |
||
15 | include 'dialogs1.inc' |
||
16 | include 'scroll.inc' |
||
17 | ;include 'debug.inc' |
||
18 | purge mov ; SPEED |
||
19 | ;****************************************************************************** |
||
20 | ; INITIALIZING |
||
21 | START: |
||
22 | ;debug_print_hex TINYPAD_END |
||
23 | call mask_events |
||
24 | |||
25 | cmp [I_PARAM],byte 0 |
||
26 | jz noparams |
||
27 | |||
28 | ; parameters are at I_PARAM |
||
29 | mov esi,I_PARAM |
||
30 | mov edi,filename |
||
31 | mov ecx,50 |
||
32 | cld |
||
33 | rep movsb |
||
34 | |||
35 | mov edi,filename |
||
36 | mov ecx,50 |
||
37 | xor eax,eax |
||
38 | repne scasb |
||
39 | sub edi,filename |
||
40 | dec edi |
||
41 | mov [filename_len],edi |
||
42 | jmp do_load_file |
||
43 | noparams: |
||
44 | jmp newfile |
||
45 | ;****************************************************************************** |
||
46 | ; MAIN LOOP |
||
47 | still: |
||
48 | call writepos ; write current position & number of strings |
||
49 | call mouse_info |
||
50 | |||
51 | mov eax,10 ; wait here until event |
||
52 | int 0x40 |
||
53 | |||
54 | cmp eax,1 |
||
55 | je red |
||
56 | cmp eax,2 |
||
57 | je key |
||
58 | cmp eax,3 |
||
59 | je button |
||
60 | cmp eax,6 |
||
61 | je mouse |
||
62 | jmp still |
||
63 | ;****************************************************************************** |
||
64 | ; ********************************* |
||
65 | ; * MOUSE * |
||
66 | ; ********************************* |
||
67 | mouse: |
||
68 | mov eax,37 ;mouse click |
||
69 | mov ebx,2 |
||
70 | int 0x40 |
||
71 | cmp eax,0 |
||
72 | je .leave_now |
||
73 | ;if exit window is on |
||
74 | cmp [exit_wnd_on],1 |
||
75 | jne @f |
||
76 | mov [exit_wnd_on],0 |
||
77 | jmp red |
||
78 | ;else |
||
79 | @@: |
||
80 | cmp eax,1 ;mouse 1 |
||
81 | jne .leave_now |
||
82 | |||
83 | mov eax,37 ;mouse position |
||
84 | mov ebx,1 |
||
85 | int 0x40 |
||
86 | |||
87 | mov word[mouse_y],ax |
||
88 | shr eax,16 |
||
89 | mov word[mouse_x],ax |
||
90 | |||
91 | |||
92 | cmp [mouse_x],7 |
||
93 | jb .leave_now ;.leave_now ;if < |
||
94 | cmp [mouse_x],485;487 |
||
95 | ja .leave_now ;.leave_now ;if > |
||
96 | |||
97 | cmp [mouse_y],45 |
||
98 | jb .leave_now ;.leave_now ;if < |
||
99 | cmp [mouse_y],342 ;345 |
||
100 | ja .leave_now ;.leave_now ;if > |
||
101 | |||
102 | call main_cursor_move |
||
103 | |||
104 | .leave_now: |
||
105 | jmp still |
||
106 | |||
107 | ; ********************************* |
||
108 | ; * BUTTON HANDLER * |
||
109 | ; ********************************* |
||
110 | |||
111 | button: |
||
112 | |||
113 | mov eax,17 |
||
114 | int 0x40 |
||
115 | ;;;;;;;;;;;;;;;exit dialog box check;;;;;;;;;;;;; |
||
116 | cmp ah,49 |
||
117 | je save_and_exit |
||
118 | cmp ah,48 |
||
119 | je exit_now |
||
120 | cmp ah,47 |
||
121 | mov [exit_wnd_on],0 |
||
122 | je red |
||
123 | cmp ah,46 |
||
124 | jne @f |
||
125 | |||
126 | call save_file |
||
127 | jmp newfile |
||
128 | @@: |
||
129 | cmp ah,45 |
||
130 | je newfile |
||
131 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
132 | ;;;;;;;;;;;;;;;;MENU CHECK;;;;;;;;;;;;;;;;;;;;;;; |
||
133 | cmp ah,15 |
||
134 | jne no_d_w |
||
135 | call draw_window_for_dialogs |
||
136 | jmp still |
||
137 | no_d_w: |
||
138 | cmp ah,97 |
||
139 | je draw_win_menu_file |
||
140 | cmp ah,98 |
||
141 | je draw_win_menu_code |
||
142 | cmp ah,96 |
||
143 | je draw_win_menu_text |
||
144 | cmp ah,95 |
||
145 | je goto_string |
||
146 | cmp ah,92 |
||
147 | je search_window |
||
148 | cmp ah,94 |
||
149 | je red |
||
150 | cmp ah,99 |
||
151 | je help_wnd |
||
152 | cmp ah,100 |
||
153 | je new_pad_wnd |
||
154 | cmp ah,101 |
||
155 | je doyouwannasave |
||
156 | cmp ah,102 |
||
157 | jne nosavenow |
||
158 | for_key_save: |
||
159 | savedialog draw_window_for_dialogs,copy_fpath_s,saveerror,mypath |
||
160 | nosavenow: |
||
161 | cmp ah,103 |
||
162 | jne noopennow |
||
163 | for_key_open: |
||
164 | opendialog draw_window_for_dialogs,copy_fpath,openerror,mypath |
||
165 | noopennow: |
||
166 | cmp ah,104 |
||
167 | je exit |
||
168 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
169 | shr eax,8 |
||
170 | |||
171 | cmp al,50 |
||
172 | jne no_search |
||
173 | |||
174 | ; SEARCH { |
||
175 | search: |
||
176 | |||
177 | cmp [lines],1 ;something like bug fix |
||
178 | je red ;still |
||
179 | |||
180 | xor esi,esi |
||
181 | mov edi,[post] |
||
182 | add edi,80 |
||
183 | imul ecx,[lines],80 |
||
184 | sub ecx,edi ; ecx (loop counter) = lines*80-(post+80) |
||
185 | news: |
||
186 | push edi |
||
187 | news2: |
||
188 | |||
189 | ; 1) LOAD BYTES |
||
190 | mov al,[esi+search_string] |
||
191 | mov bl,[edi+0x80000] |
||
192 | |||
193 | ; 2) COMPARE BYTES |
||
194 | cmp al,bl |
||
195 | je yes_char |
||
196 | |||
197 | ; 3) LETTER? |
||
198 | cmp al,'A' |
||
199 | jb notequal |
||
200 | cmp al,'z' |
||
201 | ja notequal |
||
202 | |||
203 | ; 4) A->a OR a->A |
||
204 | cmp al,'a' |
||
205 | jb @f |
||
206 | add al,-32 |
||
207 | jmp compare_bytes |
||
208 | @@: |
||
209 | cmp al,'Z' |
||
210 | ja notequal |
||
211 | add al,32 |
||
212 | |||
213 | compare_bytes: |
||
214 | cmp al,bl |
||
215 | jne notequal |
||
216 | |||
217 | yes_char: |
||
218 | inc edi |
||
219 | inc esi |
||
220 | cmp esi,[search_len] |
||
221 | jge sfound |
||
222 | jmp news2 |
||
223 | |||
224 | notequal: |
||
225 | pop edi |
||
226 | xor esi,esi |
||
227 | inc edi |
||
228 | loop news |
||
229 | call string_not_found |
||
230 | jmp still |
||
231 | |||
232 | sfound: |
||
233 | mov eax,edi |
||
234 | cdq ; edx = 0; |
||
235 | mov ebx,80 |
||
236 | div ebx |
||
237 | ;;;;; imul eax,80 |
||
238 | ; lea eax,[eax+eax*4] ; eax *= 5; |
||
239 | ; shl eax,4 ; eax *= 16; |
||
240 | |||
241 | ; mov [post],eax |
||
242 | mov [posy],0 |
||
243 | ;--------------- |
||
244 | ; mov ebx,80 |
||
245 | ; div ebx |
||
246 | call goto_pos |
||
247 | call draw_vertical_scroll |
||
248 | jmp still |
||
249 | ; SEARCH } |
||
250 | |||
251 | no_search: |
||
252 | |||
253 | ; TOOLBAR { |
||
254 | cmp eax,10000 |
||
255 | jb no_toolbar |
||
256 | |||
257 | add eax,-10000 |
||
258 | jne @f |
||
259 | lbl_compile_file: |
||
260 | mov [run_outfile],0 |
||
261 | call start_fasm |
||
262 | jmp still |
||
263 | @@: |
||
264 | dec eax |
||
265 | jnz @f |
||
266 | lbl_run_outfile: |
||
267 | mov [run_outfile],1 |
||
268 | call start_fasm |
||
269 | jmp still |
||
270 | @@: |
||
271 | dec eax |
||
272 | jnz @f |
||
273 | call open_debug_board |
||
274 | jmp still |
||
275 | @@: |
||
276 | dec eax |
||
277 | jnz still |
||
278 | call open_sysfuncs_txt |
||
279 | jmp still |
||
280 | ; TOOLBAR } |
||
281 | |||
282 | no_toolbar: |
||
283 | |||
284 | cmp al,4 |
||
285 | jne noid4 |
||
286 | |||
287 | ; LOAD_FILE { |
||
288 | do_load_file: |
||
289 | mov [modified],0 |
||
290 | |||
291 | call empty_work_space |
||
292 | |||
293 | |||
294 | cmp [filename],'/' |
||
295 | jne @f |
||
296 | |||
297 | call loadhdfile |
||
298 | jmp .restorecursor |
||
299 | @@: |
||
300 | call loadfile1 |
||
301 | .restorecursor: |
||
302 | mov edi,0x78000 |
||
303 | mov ecx,80*80/4 |
||
304 | mov eax,0x01010101 |
||
305 | cld |
||
306 | rep stosd |
||
307 | xor eax,eax |
||
308 | mov [post],eax |
||
309 | mov [posx],eax |
||
310 | mov [posy],eax |
||
311 | |||
312 | ; enable color syntax for ASM and INC files: |
||
313 | mov [asm_mode], 0 |
||
314 | |||
315 | mov eax, [filename_len] |
||
316 | add eax, filename |
||
317 | cmp word [eax-3],'AS' |
||
318 | jne @f |
||
319 | cmp byte [eax-1],'M' |
||
320 | jne @f |
||
321 | mov [asm_mode], 1 |
||
322 | jmp .nocol |
||
323 | @@: |
||
324 | cmp word [eax-3],'IN' |
||
325 | jne @f |
||
326 | cmp byte [eax-1],'C' |
||
327 | jne @f |
||
328 | mov [asm_mode], 1 |
||
329 | @@: |
||
330 | .nocol: |
||
331 | |||
332 | ; if the header is the same as the previous, |
||
333 | ; just redraw the text area |
||
334 | ; else redraw the window |
||
335 | |||
336 | ;------pos00=filename_len |
||
337 | mov eax,[filename_len] |
||
338 | mov [pos00],eax |
||
339 | ;------------------------- |
||
340 | mov ecx, [filename_len] |
||
341 | add ecx, 10 ; strlen(" - TINYPAD"); |
||
342 | cmp ecx, [headlen] |
||
343 | jne @f |
||
344 | add ecx, -10 |
||
345 | mov esi, filename ; strcmp(filename,header); |
||
346 | mov edi, header |
||
347 | rep cmpsb |
||
348 | jne @f |
||
349 | call drawfile |
||
350 | call draw_window_for_dialogs ;redraw, because it's needed |
||
351 | cmp [to_return],0 |
||
352 | je still |
||
353 | ret |
||
354 | ;jmp still |
||
355 | @@: |
||
356 | call set_title |
||
357 | cmp [to_return],0 |
||
358 | je still |
||
359 | ret |
||
360 | ; jmp still |
||
361 | ; LOAD_FILE } |
||
362 | |||
363 | noid4: |
||
364 | |||
365 | cmp al, 2 |
||
366 | jz yessave |
||
367 | |||
368 | dec al ; close if butid == 0 |
||
369 | jnz nosave |
||
370 | ; EXIT: |
||
371 | exit: |
||
372 | cmp [modified],0 |
||
373 | je exit_now |
||
374 | |||
375 | mov eax,55 ; beep |
||
376 | mov ebx,eax |
||
377 | mov esi,save_beep1 |
||
378 | int 0x40 |
||
379 | delay 4 |
||
380 | mov eax,55 ; beep |
||
381 | mov ebx,eax |
||
382 | mov esi,save_beep2 |
||
383 | int 0x40 |
||
384 | |||
385 | ;---------"EXIT" dialog box |
||
386 | |||
387 | mov eax,13 |
||
388 | mov ebx,150*65536+200 |
||
389 | mov ecx,100*65536+70 |
||
390 | mov edx,[sc.work_graph] ;0x00dd9438 ;0x00ff7512 |
||
391 | int 0x40 |
||
392 | |||
393 | |||
394 | mov eax,38 |
||
395 | mov ebx,150*65536+350 |
||
396 | mov ecx,100*65536+100 |
||
397 | mov edx,cl_White |
||
398 | int 0x40 |
||
399 | mov eax,38 |
||
400 | mov ebx,150*65536+350 |
||
401 | mov ecx,170*65536+170 |
||
402 | mov edx,cl_White |
||
403 | int 0x40 |
||
404 | mov eax,38 |
||
405 | mov ebx,150*65536+150 |
||
406 | mov ecx,100*65536+170 |
||
407 | mov edx,cl_White |
||
408 | int 0x40 |
||
409 | mov eax,38 |
||
410 | mov ebx,350*65536+350 |
||
411 | mov ecx,100*65536+170 |
||
412 | mov edx,cl_White |
||
413 | int 0x40 |
||
414 | |||
415 | |||
416 | |||
417 | putlabel 190,120,'Сохранить документ?',cl_White |
||
418 | |||
419 | drawlbut 170,140,30,15,'Да',49,[sc.work_button],cl_White |
||
420 | drawlbut 230,140,30,15,'Нет',48,[sc.work_button],cl_White |
||
421 | drawlbut 290,140,45,15,'Отмена',47,[sc.work_button],cl_White |
||
422 | |||
423 | mov [exit_wnd_on],1 |
||
424 | ;---------------- |
||
425 | |||
426 | jmp still |
||
427 | |||
428 | exit_now: |
||
429 | mov [MainWndClosed], 1 |
||
430 | or eax, -1 |
||
431 | int 0x40 |
||
432 | |||
433 | save_and_exit: |
||
434 | call save_file |
||
435 | jmp exit_now |
||
436 | ; mov [MainWndClosed], 1 |
||
437 | ; or eax, -1 |
||
438 | ; int 0x40 |
||
439 | |||
440 | ; SAVE_FILE { |
||
441 | yessave: |
||
442 | call clear_screen |
||
443 | call drawwindow |
||
444 | call save_file |
||
445 | ; call clear_screen |
||
446 | ; call drawwindow |
||
447 | mov [modified],0 |
||
448 | |||
449 | jmp still |
||
450 | ; SAVE_FILE } |
||
451 | |||
452 | nosave: |
||
453 | |||
454 | inc al |
||
455 | call read_string |
||
456 | |||
457 | jmp still |
||
458 | |||
459 | ;********************************** |
||
460 | ;* REDRAW HANDLER * |
||
461 | ;********************************** |
||
462 | |||
463 | red: |
||
464 | ; перерисовка окна |
||
465 | call clear_screen |
||
466 | call drawwindow |
||
467 | jmp still |
||
468 | |||
469 | |||
470 | |||
471 | ;********************************** |
||
472 | ;* KEY HANDLER * |
||
473 | ;********************************** |
||
474 | |||
475 | key: |
||
476 | mov eax, 2 ; GET KEY |
||
477 | int 0x40 |
||
478 | |||
479 | cmp [exit_wnd_on],1 ;exit window is ON? |
||
480 | jne no_exit_wnd ; no - goto other checks |
||
481 | |||
482 | ; cmp eax,13 ;enter - save n exit |
||
483 | ; je save_and_exit |
||
484 | |||
485 | ; cmp eax,173 ;ctrl+enter - exit |
||
486 | ; je exit_now |
||
487 | mov [exit_wnd_on],0 ;other keys - cancel |
||
488 | ; call draw_window_for_dialogs |
||
489 | |||
490 | jmp red ;redraw and still |
||
491 | |||
492 | |||
493 | no_exit_wnd: |
||
494 | shr eax, 8 |
||
495 | |||
496 | ; HELP_TEXT { |
||
497 | cmp al, 210 ; Ctrl + F1 |
||
498 | jne no_help_text |
||
499 | help_wnd: |
||
500 | call clear_screen |
||
501 | call drawwindow |
||
502 | mov eax, 51 |
||
503 | mov ebx, 1 |
||
504 | mov ecx, help_thread_start |
||
505 | mov edx, 0xfff0 |
||
506 | int 0x40 |
||
507 | jmp still |
||
508 | |||
509 | help_thread_start: |
||
510 | call draw_help_wnd |
||
511 | |||
512 | still_hw: |
||
513 | cmp [MainWndClosed], 1 |
||
514 | je exit_hw |
||
515 | mov eax, 10 |
||
516 | int 0x40 |
||
517 | cmp eax, 1 |
||
518 | je red_hw |
||
519 | cmp eax, 2 |
||
520 | je key_hw |
||
521 | cmp eax, 3 |
||
522 | je button_hw |
||
523 | jmp still_hw |
||
524 | |||
525 | red_hw: |
||
526 | call draw_help_wnd |
||
527 | jmp still_hw |
||
528 | |||
529 | key_hw: |
||
530 | ; mov eax, 2 |
||
531 | int 0x40 |
||
532 | cmp ah, 27 |
||
533 | jne still_hw |
||
534 | |||
535 | button_hw: |
||
536 | mov eax, 17 |
||
537 | int 0x40 |
||
538 | exit_hw: |
||
539 | or eax, -1 |
||
540 | int 0x40 |
||
541 | |||
542 | ; draw help window |
||
543 | draw_help_wnd: |
||
544 | mov eax, 12 |
||
545 | mov ebx, 1 |
||
546 | int 0x40 |
||
547 | |||
548 | xor eax, eax |
||
549 | mov ebx, 200 shl 16 + 320 |
||
550 | mov ecx, 200 shl 16 + 260 |
||
551 | mov edx, 0x03e0e0e0 ; work |
||
552 | mov esi, [sc.grab] |
||
553 | or esi, 0x80000000 ; grab |
||
554 | mov edi, [sc.frame] ; frame |
||
555 | int 0x40 |
||
556 | |||
557 | mov eax, 4 |
||
558 | mov ebx, 8 shl 16 + 8 |
||
559 | mov ecx, 0xffffff |
||
560 | mov edx, help_wnd_header |
||
561 | mov esi, hlphead_len |
||
562 | int 0x40 |
||
563 | |||
564 | mov eax, 4 |
||
565 | mov ebx, 8 shl 16 + 34 |
||
566 | xor ecx, ecx |
||
567 | mov esi, 51 |
||
568 | mov edx, help_text |
||
569 | .new_help_line: |
||
570 | int 0x40 |
||
571 | add ebx, 10 |
||
572 | add edx, esi |
||
573 | cmp [edx], byte 'x' |
||
574 | jne .new_help_line |
||
575 | |||
576 | mov eax, 12 |
||
577 | mov ebx, 2 |
||
578 | int 0x40 |
||
579 | ret |
||
580 | ; HELP_TEXT } |
||
581 | |||
582 | no_help_text: |
||
583 | ; LOAD_FILE { |
||
584 | cmp al, 211 ; Ctrl + F2 |
||
585 | je for_key_open ;do_load_file |
||
586 | ; LOAD_FILE } |
||
587 | |||
588 | ; SEARCH { |
||
589 | cmp al, 212 ; Ctrl + F3 |
||
590 | je search |
||
591 | ; SEARCH } |
||
592 | |||
593 | ; SAVE_FILE { |
||
594 | cmp al, 213 ; Ctrl + F4 |
||
595 | je yessave |
||
596 | ; SAVE_FILE } |
||
597 | |||
598 | ; ENTER_FILENAME { |
||
599 | cmp al, 214 ; Ctrl + F5 |
||
600 | jne @f |
||
601 | jmp for_key_save |
||
602 | @@: |
||
603 | ; ENTER_FILENAME } |
||
604 | |||
605 | ; ENTER_SEARCH { |
||
606 | cmp al, 215 ; Ctrl + F6 |
||
607 | jne @f |
||
608 | ; mov al, 51 |
||
609 | ; call read_string |
||
610 | ; jmp still |
||
611 | jmp search_window |
||
612 | @@: |
||
613 | ; ENTER_SEARCH } |
||
614 | |||
615 | ; CHANGE_LAYOUT { |
||
616 | cmp al, 217 ; Ctrl + F8 |
||
617 | jne @f |
||
618 | call layout |
||
619 | jmp still |
||
620 | @@: |
||
621 | ; CHANGE_LAYOUT } |
||
622 | |||
623 | ; COMPILE_FILE { |
||
624 | cmp al, 208 |
||
625 | je lbl_compile_file |
||
626 | ; COMPILE_FILE } |
||
627 | |||
628 | ; RUN_OUTFILE { |
||
629 | cmp al, 209 |
||
630 | je lbl_run_outfile |
||
631 | |||
632 | ; RUN_OUTFILE } |
||
633 | |||
634 | ;run debug board { ----- |
||
635 | cmp al,255 |
||
636 | jne @f |
||
637 | call open_debug_board |
||
638 | call activate_me |
||
639 | jmp still |
||
640 | ;} |
||
641 | @@: |
||
642 | ;open sysfuncR { ----- |
||
643 | ; cmp al,228 |
||
644 | ; jne @f |
||
645 | ; call open_sysfuncs_txt |
||
646 | ; jmp still |
||
647 | ; @@: |
||
648 | |||
649 | ;fast_save_and_open { |
||
650 | cmp al,216 |
||
651 | jne @f |
||
652 | call make_fast_so |
||
653 | jmp still |
||
654 | ;} |
||
655 | @@: |
||
656 | ; 3 times english -> русский |
||
657 | ; 2 times русский -> english |
||
658 | |||
659 | ; COPY START { |
||
660 | cmp al, 19 |
||
661 | jne no_copy_start |
||
662 | mov eax, [post] |
||
663 | imul ebx, [posy], 80 |
||
664 | add eax, ebx |
||
665 | mov [copy_start], eax |
||
666 | jmp still |
||
667 | ; COPY START } |
||
668 | |||
669 | no_copy_start: |
||
670 | ; COPY END { |
||
671 | cmp al, 5 |
||
672 | jne no_copy_end |
||
673 | cmp [copy_start], 0 |
||
674 | je still |
||
675 | mov ecx, [post] |
||
676 | imul ebx, [posy], 80 |
||
677 | add ecx, ebx |
||
678 | add ecx, 80 |
||
679 | cmp ecx, [copy_count] |
||
680 | jb still |
||
681 | sub ecx, [copy_start] |
||
682 | mov [copy_count], ecx |
||
683 | mov esi, [copy_start] |
||
684 | add esi, 0x80000 |
||
685 | mov edi, 0x2f0000 |
||
686 | cld |
||
687 | rep movsb |
||
688 | jmp still |
||
689 | ; COPY END } |
||
690 | |||
691 | no_copy_end: |
||
692 | |||
693 | ; PASTE { |
||
694 | cmp al, 16 |
||
695 | jne no_copy_paste |
||
696 | cmp [copy_count], 0 |
||
697 | je still |
||
698 | mov eax,[copy_count] |
||
699 | cdq |
||
700 | mov ebx, 80 |
||
701 | div ebx |
||
702 | add [lines], eax |
||
703 | mov ecx, 0x2e0000 |
||
704 | mov eax, [post] |
||
705 | imul ebx, [posy], 80 |
||
706 | add eax, ebx |
||
707 | add eax, 0x80000 |
||
708 | sub ecx, eax |
||
709 | mov esi, 0x2e0000 |
||
710 | sub esi, [copy_count] |
||
711 | mov edi, 0x2e0000 |
||
712 | std |
||
713 | rep movsb |
||
714 | mov esi, 0x2f0000 |
||
715 | mov edi, [post] |
||
716 | imul eax, [posy], 80 |
||
717 | add edi, eax |
||
718 | add edi, 0x80000 |
||
719 | mov ecx, [copy_count] |
||
720 | cld |
||
721 | rep movsb |
||
722 | |||
723 | call clear_screen |
||
724 | call drawfile |
||
725 | call draw_vertical_scroll |
||
726 | mov [modified],1 |
||
727 | |||
728 | jmp still |
||
729 | ; PASTE } |
||
730 | |||
731 | |||
732 | no_copy_paste: |
||
733 | |||
734 | |||
735 | ; INSERT_SEPARATOR { |
||
736 | cmp al,0xc ; Ctrl+L |
||
737 | jne no_insert_separator |
||
738 | |||
739 | imul eax,[posy],80 |
||
740 | add eax,[post] |
||
741 | add eax,0x80000 |
||
742 | mov ebx,eax |
||
743 | |||
744 | imul eax,[lines],80 |
||
745 | add eax,0x80000 ; теперь указывает на конец файла |
||
746 | |||
747 | mov ecx,eax ; size |
||
748 | sub ecx,ebx |
||
749 | inc ecx |
||
750 | |||
751 | mov esi,eax ; from |
||
752 | mov edi,eax |
||
753 | add edi,80 ; to |
||
754 | |||
755 | std |
||
756 | rep movsb |
||
757 | |||
758 | mov ecx,80/4 |
||
759 | mov esi,comment_string |
||
760 | mov edi,ebx |
||
761 | cld |
||
762 | rep movsd |
||
763 | |||
764 | inc [lines] |
||
765 | |||
766 | call clear_screen |
||
767 | call drawfile |
||
768 | ;call calc_scroll_size_and_pos |
||
769 | call draw_vertical_scroll |
||
770 | mov [modified],1 |
||
771 | |||
772 | jmp still |
||
773 | ; INSERT_SEPARATOR } |
||
774 | |||
775 | |||
776 | no_insert_separator: |
||
777 | |||
778 | |||
779 | ; DEL_LINE { |
||
780 | cmp al,4 |
||
781 | jne no_delete_line |
||
782 | mov eax,[post] |
||
783 | cdq |
||
784 | mov ebx,80 |
||
785 | div ebx |
||
786 | add eax,[posy] |
||
787 | inc eax |
||
788 | cmp eax,[lines] |
||
789 | jge still |
||
790 | dec dword [lines] |
||
791 | imul edi,[posy],80 |
||
792 | add edi,[post] |
||
793 | add edi,0x80000 |
||
794 | mov esi,edi |
||
795 | add esi,80 |
||
796 | mov ecx,0x2e0000 |
||
797 | sub ecx,esi |
||
798 | shr ecx,4 |
||
799 | cld |
||
800 | rep movsd |
||
801 | call clear_screen |
||
802 | call drawfile |
||
803 | ;call calc_scroll_size_and_pos |
||
804 | call draw_vertical_scroll |
||
805 | mov [modified],1 |
||
806 | |||
807 | jmp still |
||
808 | ; DEL_LINE } |
||
809 | |||
810 | no_delete_line: |
||
811 | |||
812 | ; ENTER { |
||
813 | cmp al,13 |
||
814 | jnz noenter |
||
815 | |||
816 | ; lines down |
||
817 | mov eax,[posy] |
||
818 | inc eax |
||
819 | ; imul eax,80 |
||
820 | lea eax,[eax+eax*4] ; eax *= 5 |
||
821 | shl eax,4 ; eax *= 16 |
||
822 | add eax,0x80000 |
||
823 | add eax,[post] |
||
824 | mov ebx,eax |
||
825 | |||
826 | ; ebx = ([posy]+1)*80 + 0x80000 + [post] |
||
827 | ; ebx -> first byte of next string |
||
828 | |||
829 | imul eax,[lines],80 |
||
830 | add eax,0x80000 |
||
831 | mov ecx,eax |
||
832 | |||
833 | ; ecx = [lines]*80 + 0x80000 |
||
834 | ; ecx -> end of the document |
||
835 | |||
836 | cmp ebx,ecx |
||
837 | jz .bug_fixed |
||
838 | |||
839 | @@: |
||
840 | dec ecx |
||
841 | mov dl,[ecx] |
||
842 | mov [ecx+80],dl |
||
843 | |||
844 | cmp ecx,ebx |
||
845 | jnz @b |
||
846 | |||
847 | .bug_fixed: |
||
848 | |||
849 | ; save for later |
||
850 | imul eax,[posy],80 |
||
851 | add eax,0x80000 |
||
852 | add eax,[post] |
||
853 | mov ebx,eax |
||
854 | add eax,[posx] |
||
855 | ; eax = 0x80000 + [post] + [posy]*80 + [posx] |
||
856 | |||
857 | push eax |
||
858 | |||
859 | dec ebx |
||
860 | xor ecx,ecx |
||
861 | @@: |
||
862 | cmp ecx,80 |
||
863 | je @f |
||
864 | inc ecx |
||
865 | inc ebx |
||
866 | cmp byte [ebx],' ' |
||
867 | je @b |
||
868 | @@: |
||
869 | dec ecx |
||
870 | |||
871 | cmp ecx,80-1 |
||
872 | jne @f |
||
873 | ; mov [posx],0 |
||
874 | jmp .lbl |
||
875 | @@: |
||
876 | |||
877 | cmp [posx],ecx |
||
878 | jbe @f |
||
879 | mov [posx],ecx |
||
880 | jmp .lbl |
||
881 | @@: |
||
882 | mov [posx],0 |
||
883 | |||
884 | .lbl: |
||
885 | inc [posy] |
||
886 | |||
887 | ;clear line |
||
888 | imul eax,[posy],80 |
||
889 | add eax,0x80000 |
||
890 | add eax,[post] |
||
891 | |||
892 | mov edi,eax |
||
893 | mov eax,' ' |
||
894 | mov ecx,80/4 |
||
895 | cld |
||
896 | rep stosd |
||
897 | |||
898 | |||
899 | ; end of line to next line beginning |
||
900 | imul eax,[posy],80 |
||
901 | add eax,0x80000 |
||
902 | add eax,[post] |
||
903 | ; add eax,[posx] |
||
904 | mov ebx,eax |
||
905 | ; ebx -> beginning of this line |
||
906 | |||
907 | pop esi |
||
908 | mov edi,eax |
||
909 | |||
910 | @@: |
||
911 | mov al,[esi] |
||
912 | mov [ebx],al |
||
913 | mov [esi],byte ' ' |
||
914 | |||
915 | inc esi |
||
916 | inc ebx |
||
917 | |||
918 | cmp esi,edi |
||
919 | jb @b |
||
920 | |||
921 | inc [lines] |
||
922 | |||
923 | mov ecx,[posy] |
||
924 | cmp ecx,[slines] |
||
925 | jne @f |
||
926 | |||
927 | dec [posy] |
||
928 | add [post],80 |
||
929 | |||
930 | @@: |
||
931 | call clear_screen |
||
932 | call drawfile |
||
933 | ;call calc_scroll_size_and_pos |
||
934 | |||
935 | call draw_vertical_scroll |
||
936 | mov [modified],1 |
||
937 | |||
938 | jmp still |
||
939 | ; ENTER } |
||
940 | |||
941 | |||
942 | noenter: |
||
943 | |||
944 | |||
945 | ; UP { |
||
946 | cmp al,130+48 |
||
947 | jnz noup |
||
948 | mov ecx,[posy] |
||
949 | test ecx,ecx |
||
950 | jnz .up1 |
||
951 | mov ecx,[post] |
||
952 | test ecx,ecx |
||
953 | jz still |
||
954 | add ecx,-80 |
||
955 | mov [post],ecx |
||
956 | call clear_screen |
||
957 | jmp .finish |
||
958 | .up1: |
||
959 | dec ecx |
||
960 | mov [posy],ecx |
||
961 | .finish: |
||
962 | call drawfile |
||
963 | call draw_vertical_scroll |
||
964 | ;call calc_scroll_size_and_pos |
||
965 | |||
966 | jmp still |
||
967 | ; UP } |
||
968 | |||
969 | noup: |
||
970 | |||
971 | ; DOWN { |
||
972 | cmp al,129+48 |
||
973 | jnz nodown |
||
974 | |||
975 | mov ecx,[posy] |
||
976 | mov eax,[slines] |
||
977 | dec eax |
||
978 | cmp ecx,eax |
||
979 | jb .do1 ; goto do1 if [posy] < [slines]-1 |
||
980 | |||
981 | mov eax,[lines] |
||
982 | sub eax,[slines] |
||
983 | dec eax |
||
984 | jb still ; goto still if [lines] < [slines]-1 |
||
985 | ; imul eax,80 |
||
986 | lea eax,[eax+eax*4] |
||
987 | shl eax,4 |
||
988 | cmp [post],eax |
||
989 | jg still ; goto still if [post] > ([lines]-[slines]-1)*80 |
||
990 | |||
991 | add [post],80 |
||
992 | call clear_screen |
||
993 | call drawfile |
||
994 | call draw_vertical_scroll |
||
995 | ;call calc_scroll_size_and_pos |
||
996 | |||
997 | jmp still |
||
998 | |||
999 | .do1: |
||
1000 | pusha |
||
1001 | mov eax,[post] |
||
1002 | cdq |
||
1003 | mov ebx,80 |
||
1004 | div ebx |
||
1005 | add eax,[posy] |
||
1006 | inc eax |
||
1007 | cmp eax,[lines] |
||
1008 | jb .do10 |
||
1009 | popa |
||
1010 | jmp still |
||
1011 | |||
1012 | .do10: |
||
1013 | popa |
||
1014 | inc ecx |
||
1015 | mov [posy],ecx |
||
1016 | call drawfile |
||
1017 | call draw_vertical_scroll |
||
1018 | ;call calc_scroll_size_and_pos |
||
1019 | |||
1020 | jmp still |
||
1021 | ; DOWN } |
||
1022 | |||
1023 | |||
1024 | nodown: |
||
1025 | |||
1026 | |||
1027 | ; LEFT { |
||
1028 | cmp al,128+48 |
||
1029 | jnz noleft |
||
1030 | cmp [posx],0 |
||
1031 | je still |
||
1032 | dec [posx] |
||
1033 | call drawfile |
||
1034 | jmp still |
||
1035 | ; LEFT } |
||
1036 | |||
1037 | |||
1038 | noleft: |
||
1039 | |||
1040 | |||
1041 | ; RIGHT { |
||
1042 | cmp al,131+48 |
||
1043 | jnz noright |
||
1044 | cmp [posx],79 |
||
1045 | je still |
||
1046 | inc [posx] |
||
1047 | call drawfile |
||
1048 | jmp still |
||
1049 | ; RIGHT } |
||
1050 | |||
1051 | |||
1052 | noright: |
||
1053 | |||
1054 | |||
1055 | ; PAGE_UP { |
||
1056 | page_up: |
||
1057 | cmp al,136+48 |
||
1058 | jnz nopu |
||
1059 | scrl_up: |
||
1060 | mov eax,[slines] |
||
1061 | dec eax |
||
1062 | ; imul eax,80 |
||
1063 | lea eax,[eax+eax*4] |
||
1064 | shl eax,4 |
||
1065 | mov ecx,[post] |
||
1066 | cmp eax,ecx |
||
1067 | jbe pu1 |
||
1068 | mov ecx,eax |
||
1069 | pu1: |
||
1070 | sub ecx,eax |
||
1071 | mov [post],ecx |
||
1072 | |||
1073 | call clear_screen |
||
1074 | call drawfile |
||
1075 | call draw_vertical_scroll |
||
1076 | ;call calc_scroll_size_and_pos |
||
1077 | jmp still |
||
1078 | ; PAGE_UP } |
||
1079 | |||
1080 | |||
1081 | nopu: |
||
1082 | |||
1083 | |||
1084 | ; PAGE_DOWN { |
||
1085 | page_down: |
||
1086 | cmp al,135+48 |
||
1087 | jnz nopd |
||
1088 | scrl_down: |
||
1089 | mov eax,[lines] |
||
1090 | cmp eax,[slines] |
||
1091 | jb still |
||
1092 | |||
1093 | mov eax,[post] ; eax = offset |
||
1094 | cdq |
||
1095 | mov ebx,80 |
||
1096 | div ebx ; eax /= 80 |
||
1097 | mov ecx,[lines] ; ecx = lines in the file |
||
1098 | cmp eax,ecx ; if eax < ecx goto pfok |
||
1099 | jnb still |
||
1100 | mov eax,[slines] ; eax = lines on the screen |
||
1101 | dec eax ; eax-- |
||
1102 | ; imul eax,80 ; eax *= 80 |
||
1103 | lea eax,[eax+eax*4] |
||
1104 | shl eax,4 |
||
1105 | add [post],eax ; offset += eax |
||
1106 | |||
1107 | mov eax,[lines] ; eax = lines in the file |
||
1108 | sub eax,[slines] ; eax -= lines on the screen |
||
1109 | ; imul eax,80 ; eax *= 80 |
||
1110 | lea eax,[eax+eax*4] |
||
1111 | shl eax,4 |
||
1112 | cmp [post],eax |
||
1113 | jb @f |
||
1114 | mov [post],eax |
||
1115 | @@: |
||
1116 | |||
1117 | call clear_screen |
||
1118 | call drawfile |
||
1119 | call draw_vertical_scroll |
||
1120 | ;call calc_scroll_size_and_pos |
||
1121 | |||
1122 | jmp still |
||
1123 | ; PAGE_DOWN } |
||
1124 | |||
1125 | nopd: |
||
1126 | |||
1127 | ; HOME { |
||
1128 | cmp al,132+48 |
||
1129 | jnz nohome |
||
1130 | |||
1131 | push 0 |
||
1132 | pop [posx] |
||
1133 | |||
1134 | call drawfile |
||
1135 | jmp still |
||
1136 | ; HOME } |
||
1137 | |||
1138 | |||
1139 | nohome: |
||
1140 | |||
1141 | |||
1142 | ; END { |
||
1143 | end_key: |
||
1144 | cmp al,133+48 |
||
1145 | jnz noend |
||
1146 | |||
1147 | imul eax,[posy],80 |
||
1148 | add eax,0x80000 |
||
1149 | add eax,[post] |
||
1150 | |||
1151 | mov esi,eax |
||
1152 | add eax,80+1 |
||
1153 | |||
1154 | @@: dec eax |
||
1155 | cmp eax,esi |
||
1156 | je @f |
||
1157 | cmp byte [eax-1],' ' |
||
1158 | jbe @b |
||
1159 | @@: |
||
1160 | sub eax,esi |
||
1161 | cmp eax,80-1 |
||
1162 | jbe @f |
||
1163 | dec eax |
||
1164 | @@: |
||
1165 | mov [posx],eax |
||
1166 | |||
1167 | call drawfile |
||
1168 | jmp still |
||
1169 | ; END } |
||
1170 | |||
1171 | |||
1172 | noend: |
||
1173 | |||
1174 | |||
1175 | ; GO_START { |
||
1176 | cmp al,251 ; Ctrl + [ |
||
1177 | jnz no_go_to_start |
||
1178 | |||
1179 | push 0 |
||
1180 | pop [post] ; offset = 0 |
||
1181 | |||
1182 | call clear_screen |
||
1183 | call drawfile ; draw file |
||
1184 | call draw_vertical_scroll |
||
1185 | ;call calc_scroll_size_and_pos |
||
1186 | jmp still ; go to still |
||
1187 | ; GO_START } |
||
1188 | |||
1189 | |||
1190 | no_go_to_start: |
||
1191 | |||
1192 | |||
1193 | ; GO_END { |
||
1194 | cmp al,253 ; Ctrl + ] |
||
1195 | jnz no_go_to_end |
||
1196 | cmp [lines],30 ;to fix ctrl+] bug |
||
1197 | jb @f |
||
1198 | mov eax,[lines] ; eax = lines in the file |
||
1199 | sub eax,[slines] ; eax -= lines on the screen |
||
1200 | ; imul eax,80 ; eax *= 80 (length of line) |
||
1201 | lea eax,[eax+eax*4] |
||
1202 | shl eax,4 |
||
1203 | mov [post],eax ; offset in the file |
||
1204 | |||
1205 | call clear_screen |
||
1206 | call drawfile ; draw file |
||
1207 | call draw_vertical_scroll |
||
1208 | @@: |
||
1209 | jmp still ; go to still |
||
1210 | ; GO_END } |
||
1211 | |||
1212 | |||
1213 | no_go_to_end: |
||
1214 | |||
1215 | |||
1216 | ; DELETE { |
||
1217 | cmp al,134+48 |
||
1218 | jne nodel |
||
1219 | |||
1220 | imul eax,[posy],80 |
||
1221 | add eax,0x80000 |
||
1222 | add eax,[post] |
||
1223 | add eax,[posx] |
||
1224 | mov ecx,eax |
||
1225 | |||
1226 | imul eax,[posy],80 |
||
1227 | add eax,0x80000+79 |
||
1228 | add eax,[post] |
||
1229 | mov ebx,eax |
||
1230 | |||
1231 | push ebx |
||
1232 | |||
1233 | dec ecx |
||
1234 | dec ebx |
||
1235 | |||
1236 | |||
1237 | push ecx ebx |
||
1238 | |||
1239 | push ebx |
||
1240 | |||
1241 | imul eax,[posy],80 |
||
1242 | add eax,0x80000 |
||
1243 | add eax,[post] |
||
1244 | mov ecx,eax |
||
1245 | |||
1246 | xor eax,eax |
||
1247 | cdq |
||
1248 | |||
1249 | pop ebx |
||
1250 | |||
1251 | dec ecx |
||
1252 | @@: |
||
1253 | inc ecx |
||
1254 | mov dh,[ecx] |
||
1255 | cmp dh,33 |
||
1256 | jb .nok |
||
1257 | xor eax,eax |
||
1258 | inc eax |
||
1259 | .nok: |
||
1260 | cmp ecx,ebx |
||
1261 | jb @b |
||
1262 | |||
1263 | pop ebx ecx |
||
1264 | |||
1265 | @@: |
||
1266 | inc ecx |
||
1267 | mov dl,[ecx+1] |
||
1268 | mov [ecx],dl |
||
1269 | cmp ecx,ebx |
||
1270 | jb @b |
||
1271 | |||
1272 | |||
1273 | pop ebx |
||
1274 | mov [ebx],byte 32 |
||
1275 | |||
1276 | test eax,eax |
||
1277 | jz dellinesup |
||
1278 | |||
1279 | call clear_screen |
||
1280 | call drawfile |
||
1281 | mov [modified],1 |
||
1282 | |||
1283 | jmp still |
||
1284 | |||
1285 | dellinesup: |
||
1286 | |||
1287 | ; lines -1 |
||
1288 | |||
1289 | pusha |
||
1290 | |||
1291 | mov eax,[post] |
||
1292 | cdq |
||
1293 | mov ebx,80 |
||
1294 | div ebx |
||
1295 | add eax,[posy] |
||
1296 | inc eax |
||
1297 | |||
1298 | cmp eax,[lines] |
||
1299 | jb @f |
||
1300 | |||
1301 | popa |
||
1302 | mov [modified],1 |
||
1303 | |||
1304 | jmp still |
||
1305 | |||
1306 | @@: |
||
1307 | |||
1308 | popa |
||
1309 | |||
1310 | dec [lines] |
||
1311 | |||
1312 | ; lines up |
||
1313 | |||
1314 | mov [posx],dword 0 |
||
1315 | |||
1316 | imul eax,[posy],80 |
||
1317 | add eax,0x80000-1 |
||
1318 | add eax,[post] |
||
1319 | mov ebx,eax |
||
1320 | |||
1321 | push ebx |
||
1322 | |||
1323 | imul eax,[lines],80 |
||
1324 | add eax,0x80000-1 |
||
1325 | add eax,[post] |
||
1326 | mov ecx,eax |
||
1327 | |||
1328 | pop ebx |
||
1329 | |||
1330 | @@: |
||
1331 | mov dl,[ebx+80] |
||
1332 | mov [ebx],dl |
||
1333 | inc ebx |
||
1334 | |||
1335 | cmp ecx,ebx |
||
1336 | jnz @b |
||
1337 | |||
1338 | call clear_screen |
||
1339 | call drawfile |
||
1340 | mov [modified],1 |
||
1341 | |||
1342 | jmp still |
||
1343 | ; DELETE } |
||
1344 | |||
1345 | |||
1346 | nodel: |
||
1347 | |||
1348 | |||
1349 | ; INSERT { |
||
1350 | cmp al,137+48 |
||
1351 | jnz noins |
||
1352 | |||
1353 | imul eax,[posy],80 |
||
1354 | add eax,0x80000 |
||
1355 | add eax,[post] |
||
1356 | add eax,[posx] |
||
1357 | mov ecx,eax |
||
1358 | ; ecx = [posy]*80+0x80000+[post]+[posx] |
||
1359 | |||
1360 | imul eax,[posy],80 |
||
1361 | add eax,0x80000+79 |
||
1362 | add eax,[post] |
||
1363 | mov ebx,eax |
||
1364 | ; ebx = [posy]*80+0x80000+79+[post] |
||
1365 | |||
1366 | .movstr: |
||
1367 | dec ebx |
||
1368 | mov dl,[ebx] |
||
1369 | mov [ebx+1],dl |
||
1370 | cmp ecx,ebx |
||
1371 | jb .movstr |
||
1372 | |||
1373 | mov [ecx],byte ' ' |
||
1374 | |||
1375 | call invalidate_string |
||
1376 | call drawfile |
||
1377 | mov [modified],1 |
||
1378 | |||
1379 | jmp still |
||
1380 | ; INSERT } |
||
1381 | |||
1382 | |||
1383 | noins: |
||
1384 | |||
1385 | |||
1386 | ; BACKSPACE { |
||
1387 | cmp al,8 |
||
1388 | jnz nobs |
||
1389 | mov ecx,[posx] |
||
1390 | test ecx,ecx |
||
1391 | jz still |
||
1392 | dec ecx |
||
1393 | mov [posx],ecx |
||
1394 | |||
1395 | imul eax,[posy],80 |
||
1396 | add eax,0x80000 |
||
1397 | add eax,[post] |
||
1398 | add eax,[posx] |
||
1399 | mov ebx,eax |
||
1400 | |||
1401 | push ebx |
||
1402 | |||
1403 | imul eax,[posy],80 |
||
1404 | add eax,0x80000+79 |
||
1405 | add eax,[post] |
||
1406 | mov ebx,eax |
||
1407 | |||
1408 | pop ecx |
||
1409 | |||
1410 | push ebx |
||
1411 | |||
1412 | dec ecx |
||
1413 | .movleft: |
||
1414 | inc ecx |
||
1415 | mov dl,[ecx+1] |
||
1416 | mov [ecx],dl |
||
1417 | cmp ecx,ebx |
||
1418 | jb .movleft |
||
1419 | |||
1420 | pop ebx |
||
1421 | mov [ebx],byte ' ' |
||
1422 | |||
1423 | call invalidate_string |
||
1424 | call drawfile |
||
1425 | mov [modified],1 |
||
1426 | |||
1427 | jmp still |
||
1428 | ; BACKSPACE } |
||
1429 | |||
1430 | |||
1431 | nobs: |
||
1432 | |||
1433 | |||
1434 | ; TAB { |
||
1435 | cmp eax,9 ; Tab |
||
1436 | jne notab |
||
1437 | |||
1438 | mov eax,[posx] |
||
1439 | cmp eax,80-1 |
||
1440 | jae still |
||
1441 | add eax,5 ; 9 5 3 |
||
1442 | and eax,11111100b ; ...1000b, ...100b, ...10b |
||
1443 | dec eax |
||
1444 | mov [posx], eax |
||
1445 | |||
1446 | call drawfile |
||
1447 | mov [modified],1 |
||
1448 | |||
1449 | jmp still |
||
1450 | ; TAB } |
||
1451 | |||
1452 | |||
1453 | notab: |
||
1454 | |||
1455 | |||
1456 | ; ADD_KEY { |
||
1457 | push eax ; add key |
||
1458 | |||
1459 | imul eax,[posy],80 |
||
1460 | add eax,0x80000 |
||
1461 | add eax,[post] |
||
1462 | add eax,[posx] |
||
1463 | mov ecx,eax |
||
1464 | |||
1465 | push ecx |
||
1466 | |||
1467 | imul eax,[posy],80 |
||
1468 | add eax,0x80000+79 |
||
1469 | add eax,[post] |
||
1470 | mov ebx,eax |
||
1471 | |||
1472 | .movright: |
||
1473 | dec ebx |
||
1474 | mov al,[ebx] |
||
1475 | mov [ebx+1],al |
||
1476 | cmp ecx,ebx |
||
1477 | jbe .movright |
||
1478 | |||
1479 | pop ebx |
||
1480 | |||
1481 | pop eax |
||
1482 | |||
1483 | mov [ebx],al |
||
1484 | mov edx,78 |
||
1485 | mov ecx,[posx] |
||
1486 | cmp edx,ecx |
||
1487 | jb noxp |
||
1488 | inc ecx |
||
1489 | mov [posx],ecx |
||
1490 | noxp: |
||
1491 | |||
1492 | call invalidate_string |
||
1493 | call drawfile |
||
1494 | mov [modified],1 |
||
1495 | ; call draw_vertical_scroll |
||
1496 | jmp still |
||
1497 | ; ADD_KEY } |
||
1498 | |||
1499 | |||
1500 | ;****************************************************************************** |
||
1501 | |||
1502 | start_fasm: |
||
1503 | cmp [asm_mode],1 |
||
1504 | je @f |
||
1505 | ret |
||
1506 | @@: |
||
1507 | mov esi,filename |
||
1508 | mov edi,fasm_parameters |
||
1509 | |||
1510 | cmp byte [esi],'/' |
||
1511 | je .yes_systree |
||
1512 | |||
1513 | mov ecx,[filename_len] |
||
1514 | rep movsb |
||
1515 | |||
1516 | mov al,',' |
||
1517 | stosb |
||
1518 | |||
1519 | mov ecx,[filename_len] |
||
1520 | add ecx,-4 |
||
1521 | mov esi,filename |
||
1522 | rep movsb |
||
1523 | |||
1524 | mov al,',' |
||
1525 | stosb |
||
1526 | |||
1527 | mov [edi],dword '/RD/' |
||
1528 | add edi,4 |
||
1529 | mov [edi],word '1/' |
||
1530 | inc edi |
||
1531 | inc edi |
||
1532 | |||
1533 | mov al,0 |
||
1534 | stosb |
||
1535 | |||
1536 | jmp .run |
||
1537 | |||
1538 | .yes_systree: |
||
1539 | add esi,[filename_len] |
||
1540 | dec esi |
||
1541 | |||
1542 | xor ecx,ecx |
||
1543 | mov al,'/' |
||
1544 | @@: |
||
1545 | cmp [esi],al |
||
1546 | je @f |
||
1547 | dec esi |
||
1548 | inc ecx |
||
1549 | jmp @b |
||
1550 | @@: |
||
1551 | inc esi |
||
1552 | |||
1553 | push esi |
||
1554 | push esi |
||
1555 | push ecx |
||
1556 | |||
1557 | rep movsb |
||
1558 | |||
1559 | mov al,',' |
||
1560 | stosb |
||
1561 | |||
1562 | pop ecx |
||
1563 | pop esi |
||
1564 | |||
1565 | add ecx,-4 |
||
1566 | rep movsb |
||
1567 | |||
1568 | mov al,',' |
||
1569 | stosb |
||
1570 | |||
1571 | pop ecx |
||
1572 | sub ecx,filename |
||
1573 | mov esi,filename |
||
1574 | |||
1575 | rep movsb |
||
1576 | |||
1577 | mov al,0 |
||
1578 | stosb |
||
1579 | |||
1580 | .run: |
||
1581 | cmp [run_outfile],1 |
||
1582 | jne @f |
||
1583 | dec edi |
||
1584 | mov eax,',run' |
||
1585 | stosd |
||
1586 | mov al,0 |
||
1587 | stosb |
||
1588 | @@: |
||
1589 | |||
1590 | mov eax,19 |
||
1591 | mov ebx,fasm_filename |
||
1592 | mov ecx,fasm_parameters |
||
1593 | int 0x40 |
||
1594 | ret |
||
1595 | |||
1596 | open_debug_board: |
||
1597 | mov eax,19 |
||
1598 | mov ebx,debug_filename |
||
1599 | xor ecx,ecx |
||
1600 | int 0x40 |
||
1601 | ret |
||
1602 | |||
1603 | open_sysfuncs_txt: |
||
1604 | mov eax,19 |
||
1605 | mov ebx,tinypad_filename |
||
1606 | mov ecx,sysfuncs_filename |
||
1607 | int 0x40 |
||
1608 | ret |
||
1609 | |||
1610 | |||
1611 | empty_work_space: |
||
1612 | ; очистить все |
||
1613 | mov eax,' ' |
||
1614 | mov edi,0x80000 |
||
1615 | mov ecx,(0x300000-0x90000)/4 |
||
1616 | cld |
||
1617 | rep stosd |
||
1618 | mov edi,0x10000 |
||
1619 | mov ecx,0x60000/4 |
||
1620 | rep stosd |
||
1621 | ret |
||
1622 | |||
1623 | |||
1624 | clear_screen: |
||
1625 | ; очистить экран |
||
1626 | mov ecx,80*40 |
||
1627 | mov edi,0x78000 |
||
1628 | xor eax,eax |
||
1629 | @@: |
||
1630 | mov [edi],eax |
||
1631 | add edi,4 |
||
1632 | dec ecx |
||
1633 | jnz @b |
||
1634 | ret |
||
1635 | |||
1636 | invalidate_string: |
||
1637 | imul eax,[posy],80 |
||
1638 | add eax,0x78000 |
||
1639 | mov edi,eax |
||
1640 | mov al,1 |
||
1641 | mov ecx,80/4 |
||
1642 | rep stosd |
||
1643 | ret |
||
1644 | |||
1645 | layout: |
||
1646 | ; сменить раскладку клавиатуры |
||
1647 | mov eax,19 |
||
1648 | mov ebx,setup |
||
1649 | mov ecx,param_setup |
||
1650 | int 0x40 |
||
1651 | mov eax,5 |
||
1652 | mov ebx,eax |
||
1653 | int 0x40 |
||
1654 | call activate_me |
||
1655 | ret |
||
1656 | |||
1657 | |||
1658 | activate_me: |
||
1659 | ; 1) get info about me |
||
1660 | mov eax,9 |
||
1661 | mov ebx,procinfo |
||
1662 | mov ecx,-1 |
||
1663 | int 0x40 |
||
1664 | ; eax = number of processes |
||
1665 | |||
1666 | ; save process counter |
||
1667 | inc eax |
||
1668 | inc eax |
||
1669 | mov [proccount],eax |
||
1670 | |||
1671 | mov eax,[procinfo.PID] |
||
1672 | mov [PID],eax |
||
1673 | |||
1674 | ; 2) get my process number |
||
1675 | mov eax,9 |
||
1676 | mov ebx,procinfo |
||
1677 | mov ecx,[proccount] |
||
1678 | @@: |
||
1679 | dec ecx |
||
1680 | jz @f ; counter=0 => not found? => return |
||
1681 | mov eax,9 |
||
1682 | int 0x40 |
||
1683 | mov edx,[procinfo.PID] |
||
1684 | cmp edx,[PID] |
||
1685 | jne @b |
||
1686 | |||
1687 | ;found: ecx = process_number |
||
1688 | mov eax,18 |
||
1689 | mov ebx,3 |
||
1690 | int 0x40 |
||
1691 | |||
1692 | mov eax,5 |
||
1693 | mov ebx,eax |
||
1694 | int 0x40 |
||
1695 | |||
1696 | @@: |
||
1697 | ret |
||
1698 | |||
1699 | |||
1700 | |||
1701 | |||
1702 | ; ******************************************************************* |
||
1703 | ; ************************** DRAW WINDOW ************************** |
||
1704 | ; ******************************************************************* |
||
1705 | |||
1706 | align 4 |
||
1707 | drawwindow: |
||
1708 | |||
1709 | mov eax,12 ; WINDOW DRAW START |
||
1710 | mov ebx,1 |
||
1711 | int 0x40 |
||
1712 | mov [menu_is_on],0 |
||
1713 | mov eax,48 ; get system colors |
||
1714 | mov ebx,3 |
||
1715 | mov ecx,sc |
||
1716 | mov edx,sizeof.system_colors |
||
1717 | int 0x40 |
||
1718 | |||
1719 | mov [sc.work],0xe0e0e0 |
||
1720 | |||
1721 | xor eax,eax ; DEFINE WINDOW |
||
1722 | mov ebx,100*65536+506 ; 496 |
||
1723 | mov ecx,75*65536+400 ;385;400 ; sum < 480 for 640x480 |
||
1724 | mov edx,[sc.work] |
||
1725 | add edx,0x03000000 |
||
1726 | mov esi,[sc.grab] |
||
1727 | or esi,0x80000000 |
||
1728 | mov edi,[sc.frame] |
||
1729 | int 0x40 |
||
1730 | |||
1731 | ; header string |
||
1732 | mov eax,4 |
||
1733 | mov ebx,10*65536+8 |
||
1734 | mov ecx,[sc.grab_text] |
||
1735 | mov edx,header |
||
1736 | mov esi,[headlen] |
||
1737 | int 0x40 |
||
1738 | |||
1739 | mov eax,9 ; get info about me |
||
1740 | mov ebx,procinfo |
||
1741 | or ecx,-1 |
||
1742 | int 0x40 |
||
1743 | |||
1744 | mov eax,[procinfo.y_size] |
||
1745 | |||
1746 | mov [do_not_draw],1 ; do_not_draw = true |
||
1747 | cmp eax,100 |
||
1748 | jb .no_draw ; do not draw text & buttons if height < 100 |
||
1749 | mov [do_not_draw],0 ; do_not_draw = false |
||
1750 | add eax,-(46+47) ; 46 = y offs |
||
1751 | cdq |
||
1752 | mov ebx,10 |
||
1753 | div ebx |
||
1754 | mov [slines],eax |
||
1755 | |||
1756 | cmp eax,[posy] |
||
1757 | jnb @f |
||
1758 | dec eax |
||
1759 | mov [posy],eax |
||
1760 | @@: |
||
1761 | |||
1762 | mov eax,[procinfo.y_size] ; calculate buttons position |
||
1763 | add eax,-47 |
||
1764 | mov [dstart],eax |
||
1765 | |||
1766 | ; mov eax,8 ; STRING BUTTON |
||
1767 | ; mov ebx,5*65536+57 |
||
1768 | ; mov ecx,[dstart] |
||
1769 | ; add ecx,29 |
||
1770 | ; shl ecx,16 |
||
1771 | ; add ecx,13 |
||
1772 | ; mov edx,51 ;;;;;-----string button ID=51 |
||
1773 | ; mov esi,[sc.work_button] |
||
1774 | ; int 0x40 |
||
1775 | ; SEARCH BUTTON |
||
1776 | ; mov ebx,(505-129)*65536+125 |
||
1777 | ; mov edx,50 |
||
1778 | ; mov esi,[sc.work_button] |
||
1779 | ; int 0x40 |
||
1780 | |||
1781 | ; mov eax,4 ; SEARCH TEXT |
||
1782 | ; mov ebx,[dstart] |
||
1783 | ; add ebx,7*65536+32 |
||
1784 | ; mov ecx,[sc.work_button_text] |
||
1785 | ; mov edx,searcht |
||
1786 | ; mov esi,searchtl-searcht |
||
1787 | ; int 0x40 |
||
1788 | |||
1789 | |||
1790 | mov eax,13 ; BAR STRIPE |
||
1791 | mov ebx,5*65536+497 |
||
1792 | mov ecx,[dstart] |
||
1793 | shl ecx,16 |
||
1794 | add ecx,30 ;15 |
||
1795 | |||
1796 | mov edx,0x00aaaaaa |
||
1797 | int 0x40 |
||
1798 | |||
1799 | ; mov eax,4 ; FIRST TEXT LINE (POSITION...) |
||
1800 | ; mov ebx,12*65536 |
||
1801 | ; add ebx,[dstart] |
||
1802 | ; add ebx,38 ;18 |
||
1803 | ; mov ecx,[sc.work_button_text] |
||
1804 | ; mov edx,htext2 |
||
1805 | ; mov esi,htextlen2-htext2 |
||
1806 | ; int 0x40 |
||
1807 | |||
1808 | |||
1809 | call drawfile |
||
1810 | |||
1811 | ; mov eax,[dstart] |
||
1812 | |||
1813 | ; add eax,31 |
||
1814 | ; mov [ya],eax |
||
1815 | ; mov [addr],search_string |
||
1816 | ; call print_text |
||
1817 | |||
1818 | .no_draw: |
||
1819 | call draw_win_menu |
||
1820 | |||
1821 | call draw_vertical_scroll |
||
1822 | |||
1823 | mov eax,12 ; WINDOW DRAW END |
||
1824 | mov ebx,2 |
||
1825 | int 0x40 |
||
1826 | |||
1827 | ret |
||
1828 | |||
1829 | |||
1830 | |||
1831 | |||
1832 | ; ********************************** |
||
1833 | ; *********** DRAWFILE *********** |
||
1834 | ; ********************************** |
||
1835 | |||
1836 | drawfile: |
||
1837 | ;--------------- |
||
1838 | cmp [menu_is_on],1 |
||
1839 | jne .ff |
||
1840 | call drawwindow |
||
1841 | .ff: |
||
1842 | ;--------------- |
||
1843 | mov [next_not_quote],1 |
||
1844 | mov [next_not_quote2],1 |
||
1845 | |||
1846 | mov eax,[post] ; print from position |
||
1847 | |||
1848 | pusha |
||
1849 | |||
1850 | mov edi,[post] |
||
1851 | mov [posl],edi |
||
1852 | |||
1853 | mov ebx,8*65536+46 ; letters (46 = y offs) |
||
1854 | xor ecx,ecx |
||
1855 | |||
1856 | mov edx,0x80000 |
||
1857 | add edx,eax |
||
1858 | mov edi,edx |
||
1859 | |||
1860 | imul esi,[slines],80 |
||
1861 | add edi,esi |
||
1862 | |||
1863 | |||
1864 | nd: |
||
1865 | |||
1866 | pusha |
||
1867 | |||
1868 | mov edx,ebx |
||
1869 | mov edi,ebx |
||
1870 | add edi,(6*65536)*80 |
||
1871 | |||
1872 | wi1: |
||
1873 | |||
1874 | |||
1875 | ; draw ? |
||
1876 | |||
1877 | |||
1878 | pusha |
||
1879 | |||
1880 | push ecx |
||
1881 | |||
1882 | imul eax,[posx],6 |
||
1883 | add eax,8 |
||
1884 | shl eax,16 |
||
1885 | mov ecx,eax |
||
1886 | |||
1887 | ; ecx = ([posx]*6+8)<<16 |
||
1888 | |||
1889 | imul eax,[posy],10 |
||
1890 | add eax,46 ; y offs |
||
1891 | add eax,ecx |
||
1892 | |||
1893 | ; eax = [posy]*10+46+ecx |
||
1894 | |||
1895 | pop ecx |
||
1896 | |||
1897 | cmp edx,eax |
||
1898 | jnz drwa |
||
1899 | |||
1900 | mov eax,0x7ffff |
||
1901 | call check_pos |
||
1902 | jmp drlet |
||
1903 | |||
1904 | drwa: |
||
1905 | |||
1906 | popa |
||
1907 | |||
1908 | |||
1909 | pusha |
||
1910 | |||
1911 | imul eax,[posxm],6 |
||
1912 | add eax,8 |
||
1913 | shl eax,16 |
||
1914 | mov ecx,eax |
||
1915 | |||
1916 | imul eax,[posym],10 |
||
1917 | add eax,46 ; y offs |
||
1918 | add eax,ecx |
||
1919 | |||
1920 | cmp edx,eax |
||
1921 | jnz drwa2 |
||
1922 | |||
1923 | mov eax,0x7ffff |
||
1924 | call check_pos |
||
1925 | jmp drlet |
||
1926 | |||
1927 | drwa2: |
||
1928 | |||
1929 | popa |
||
1930 | |||
1931 | pusha |
||
1932 | |||
1933 | mov eax,0x78000 ; screen |
||
1934 | add eax,[posl] ; screen+abs |
||
1935 | sub eax,[post] ; eax = screen+abs-base = y*80+x + screen |
||
1936 | |||
1937 | mov edx,0x80000 ; file |
||
1938 | add edx,[posl] ; edx = absolute |
||
1939 | mov bl,[edx] ; in the file |
||
1940 | |||
1941 | call check_pos |
||
1942 | |||
1943 | mov cl,[eax] ; on the screen |
||
1944 | cmp bl,cl |
||
1945 | jnz drlet |
||
1946 | |||
1947 | popa |
||
1948 | |||
1949 | jmp nodraw |
||
1950 | |||
1951 | |||
1952 | ; draw letter |
||
1953 | |||
1954 | |||
1955 | drlet: |
||
1956 | |||
1957 | mov [eax],bl ; mov byte to the screen |
||
1958 | mov [tmpabc],bl |
||
1959 | popa ; restore regs |
||
1960 | |||
1961 | ;!!!!!!!!!!!! |
||
1962 | |||
1963 | cmp [tmpabc],' ' |
||
1964 | je @f |
||
1965 | call draw_letter |
||
1966 | jmp nodraw |
||
1967 | @@: |
||
1968 | call clear_char |
||
1969 | |||
1970 | nodraw: |
||
1971 | |||
1972 | inc [posl] |
||
1973 | |||
1974 | add edx,6*65536 |
||
1975 | cmp edx,edi |
||
1976 | jz wi3 |
||
1977 | jmp wi1 |
||
1978 | |||
1979 | wi3: |
||
1980 | |||
1981 | popa |
||
1982 | |||
1983 | add ebx,10 |
||
1984 | add edx,80 |
||
1985 | cmp edi,edx |
||
1986 | jbe nde |
||
1987 | jmp nd |
||
1988 | |||
1989 | nde: |
||
1990 | |||
1991 | mov eax,[posx] |
||
1992 | mov ebx,[posy] |
||
1993 | |||
1994 | mov [posxm],eax |
||
1995 | mov [posym],ebx |
||
1996 | |||
1997 | popa |
||
1998 | |||
1999 | ret |
||
2000 | |||
2001 | stText = 0 |
||
2002 | stInstr = 1 |
||
2003 | stReg = 2 |
||
2004 | stNum = 3 |
||
2005 | stQuote = 4 |
||
2006 | stComment = 5 |
||
2007 | stSymbol = 6 |
||
2008 | |||
2009 | align 4 |
||
2010 | |||
2011 | clear_char: |
||
2012 | |||
2013 | pusha |
||
2014 | mov ebx,[sc.work] |
||
2015 | |||
2016 | push ecx |
||
2017 | |||
2018 | imul eax,[posx],6 |
||
2019 | add eax,8 |
||
2020 | shl eax,16 |
||
2021 | mov ecx,eax |
||
2022 | |||
2023 | imul eax,[posy],10 |
||
2024 | add eax,46 ; 26 |
||
2025 | add eax,ecx |
||
2026 | |||
2027 | pop ecx |
||
2028 | cmp edx,eax |
||
2029 | jnz @f |
||
2030 | mov ebx,0xffffff ; light blue 0x00ffff |
||
2031 | @@: |
||
2032 | |||
2033 | ; draw bar |
||
2034 | push ebx |
||
2035 | mov eax,13 |
||
2036 | mov ebx,edx |
||
2037 | mov bx,6 |
||
2038 | mov ecx,edx |
||
2039 | shl ecx,16 |
||
2040 | add ecx,10 |
||
2041 | pop edx |
||
2042 | int 0x40 |
||
2043 | popa |
||
2044 | ret |
||
2045 | |||
2046 | align 4 |
||
2047 | |||
2048 | ; CHECK_POSITION { |
||
2049 | check_pos: |
||
2050 | cmp [asm_mode],1 |
||
2051 | je @f |
||
2052 | |||
2053 | mov [d_status],stText |
||
2054 | ret |
||
2055 | |||
2056 | @@: |
||
2057 | pushad |
||
2058 | |||
2059 | ; COMMENT TERMINATOR |
||
2060 | cmp [d_status],stComment |
||
2061 | jnz @f |
||
2062 | mov eax,[posl] |
||
2063 | sub eax,[post] |
||
2064 | cdq |
||
2065 | mov ebx,80 |
||
2066 | div ebx |
||
2067 | test edx,edx |
||
2068 | jnz end_check_pos |
||
2069 | mov [d_status],stText |
||
2070 | @@: |
||
2071 | |||
2072 | ; QUOTE TERMINATOR B |
||
2073 | cmp [next_not_quote],1 |
||
2074 | jne @f |
||
2075 | mov [d_status],stText |
||
2076 | @@: |
||
2077 | |||
2078 | mov eax,[posl] |
||
2079 | add eax,0x80000 |
||
2080 | mov edx,eax |
||
2081 | mov al,[eax] |
||
2082 | |||
2083 | ; QUOTE TERMINATOR A |
||
2084 | cmp [d_status],stQuote |
||
2085 | jnz @f |
||
2086 | cmp al,[quote] |
||
2087 | jne end_check_pos |
||
2088 | mov [next_not_quote],1 |
||
2089 | jmp end_check_pos |
||
2090 | @@: |
||
2091 | mov [next_not_quote],0 |
||
2092 | |||
2093 | ; START QUOTE 1 |
||
2094 | cmp al,"'" |
||
2095 | jne @f |
||
2096 | mov [d_status],stQuote |
||
2097 | mov [quote],al |
||
2098 | jmp end_check_pos |
||
2099 | @@: |
||
2100 | |||
2101 | ; START QUOTE 2 |
||
2102 | cmp al,'"' |
||
2103 | jne @f |
||
2104 | mov [d_status],stQuote |
||
2105 | mov [quote],al |
||
2106 | jmp end_check_pos |
||
2107 | @@: |
||
2108 | |||
2109 | ; START COMMENT |
||
2110 | cmp al,';' |
||
2111 | jne @f |
||
2112 | mov [d_status],stComment |
||
2113 | jmp end_check_pos |
||
2114 | @@: |
||
2115 | |||
2116 | ; NUMBER TERMINATOR |
||
2117 | cmp [d_status],stNum |
||
2118 | jne nonumt |
||
2119 | mov ecx,23 |
||
2120 | @@: |
||
2121 | dec ecx |
||
2122 | jz nonumt |
||
2123 | cmp al,[symbols+ecx] |
||
2124 | jne @b |
||
2125 | |||
2126 | nonumt1: |
||
2127 | mov [d_status],stText |
||
2128 | nonumt: |
||
2129 | |||
2130 | ; START NUMBER |
||
2131 | cmp [d_status],stNum |
||
2132 | je end_check_pos |
||
2133 | cmp al,'0' |
||
2134 | jb nonum |
||
2135 | cmp al,'9' |
||
2136 | ja nonum |
||
2137 | mov bl,[edx-1] |
||
2138 | mov ecx,23 |
||
2139 | @@: |
||
2140 | dec ecx |
||
2141 | jz nonum |
||
2142 | cmp bl,[symbols+ecx] |
||
2143 | jne @b |
||
2144 | @@: |
||
2145 | mov [d_status],stNum |
||
2146 | jmp end_check_pos |
||
2147 | nonum: |
||
2148 | |||
2149 | ; SYMBOL |
||
2150 | mov esi,symbols |
||
2151 | mov ecx,21 |
||
2152 | @@: |
||
2153 | cmp byte [esi],al |
||
2154 | je @f |
||
2155 | dec ecx |
||
2156 | jz nosymbol |
||
2157 | inc esi |
||
2158 | jmp @b |
||
2159 | @@: |
||
2160 | mov [d_status],stSymbol |
||
2161 | jmp end_check_pos |
||
2162 | |||
2163 | nosymbol: |
||
2164 | mov [d_status],stText |
||
2165 | |||
2166 | end_check_pos: |
||
2167 | popad |
||
2168 | ret |
||
2169 | ; CHECK_POSITION } |
||
2170 | |||
2171 | |||
2172 | ;;;;;;;;;;;;;;;;; |
||
2173 | ;; DRAW LETTER ;; |
||
2174 | ;;;;;;;;;;;;;;;;; |
||
2175 | draw_letter: |
||
2176 | |||
2177 | call clear_char |
||
2178 | |||
2179 | pusha |
||
2180 | |||
2181 | mov ebx,edx ; x & y |
||
2182 | |||
2183 | mov eax,[d_status] |
||
2184 | mov ecx,[eax*4+color_tbl] |
||
2185 | mov eax,4 |
||
2186 | |||
2187 | xor esi,esi |
||
2188 | inc esi |
||
2189 | mov edx,0x80000 |
||
2190 | mov edi,[posl] |
||
2191 | add edx,edi |
||
2192 | int 0x40 |
||
2193 | |||
2194 | popa |
||
2195 | |||
2196 | ret |
||
2197 | |||
2198 | |||
2199 | ; ******************************************** |
||
2200 | ; **************** SAVEFILE **************** |
||
2201 | ; ******************************************** |
||
2202 | save_file: |
||
2203 | mov esi,0x80000 |
||
2204 | mov edi,0x10000 |
||
2205 | or ecx,-1 |
||
2206 | .new_string: |
||
2207 | inc ecx |
||
2208 | call save_string |
||
2209 | cmp ecx,[lines] |
||
2210 | jb .new_string |
||
2211 | |||
2212 | sub edi,0x10004 ; why??? |
||
2213 | mov [filelen],edi |
||
2214 | |||
2215 | cmp byte [filename],'/' |
||
2216 | je .systree_save |
||
2217 | |||
2218 | mov eax,33 |
||
2219 | mov ebx,filename |
||
2220 | mov ecx,0x10000 |
||
2221 | mov edx,[filelen] |
||
2222 | xor esi,esi |
||
2223 | int 0x40 |
||
2224 | |||
2225 | test eax,eax |
||
2226 | je .finish |
||
2227 | ; call file_not_found |
||
2228 | call disk_is_full |
||
2229 | ;============================== |
||
2230 | jmp .finish |
||
2231 | |||
2232 | .systree_save: |
||
2233 | mov eax,[filelen] |
||
2234 | mov [fileinfo_write+8],eax |
||
2235 | |||
2236 | mov esi,filename |
||
2237 | mov edi,pathfile_write |
||
2238 | mov ecx,50 |
||
2239 | cld |
||
2240 | rep movsb |
||
2241 | |||
2242 | mov eax,58 |
||
2243 | mov ebx,fileinfo_write |
||
2244 | int 0x40 |
||
2245 | cmp eax,0 |
||
2246 | je .finish |
||
2247 | call disk_is_full |
||
2248 | .finish: |
||
2249 | call draw_window_for_dialogs |
||
2250 | mov [modified],0 |
||
2251 | ret |
||
2252 | |||
2253 | save_string: |
||
2254 | push ecx |
||
2255 | push esi |
||
2256 | mov eax,esi |
||
2257 | mov ebx,eax |
||
2258 | add ebx,79 |
||
2259 | .countlen: |
||
2260 | cmp ebx,eax |
||
2261 | jb .endcount |
||
2262 | cmp byte [ebx],' ' |
||
2263 | jne .endcount |
||
2264 | dec ebx |
||
2265 | jmp .countlen |
||
2266 | .endcount: |
||
2267 | inc ebx |
||
2268 | sub ebx,eax |
||
2269 | |||
2270 | mov ecx,ebx |
||
2271 | jecxz .endcopy |
||
2272 | .copystr: |
||
2273 | mov al,[esi] |
||
2274 | mov [edi],al |
||
2275 | inc esi |
||
2276 | inc edi |
||
2277 | dec ecx |
||
2278 | jnz .copystr |
||
2279 | .endcopy: |
||
2280 | |||
2281 | mov eax,0x0a0d |
||
2282 | stosw |
||
2283 | |||
2284 | pop esi |
||
2285 | add esi,80 |
||
2286 | pop ecx |
||
2287 | ret |
||
2288 | |||
2289 | |||
2290 | |||
2291 | ; ******************************************** |
||
2292 | ; **************** LOADFILE **************** |
||
2293 | ; ******************************************** |
||
2294 | |||
2295 | loadhdfile: |
||
2296 | |||
2297 | mov esi,filename |
||
2298 | mov edi,pathfile_read |
||
2299 | mov ecx,250 ;50 |
||
2300 | cld |
||
2301 | rep movsb |
||
2302 | |||
2303 | mov eax,58 |
||
2304 | mov ebx,fileinfo_read |
||
2305 | int 0x40 |
||
2306 | |||
2307 | xchg eax,ebx |
||
2308 | inc eax |
||
2309 | test ebx,ebx ;errorcode=0 - ok |
||
2310 | je file_found |
||
2311 | cmp ebx,6 ;errorcode=5 - ok |
||
2312 | je file_found |
||
2313 | call file_not_found |
||
2314 | ret |
||
2315 | |||
2316 | |||
2317 | loadfile1: |
||
2318 | |||
2319 | mov eax,6 ; 6 = open file |
||
2320 | mov ebx,filename |
||
2321 | xor ecx,ecx |
||
2322 | mov edx,16800 |
||
2323 | mov esi,0x10000 |
||
2324 | int 0x40 |
||
2325 | |||
2326 | inc eax ; eax = -1 -> file not found |
||
2327 | jnz file_found ;strannaya proverka (Ed) |
||
2328 | |||
2329 | call file_not_found |
||
2330 | ret |
||
2331 | |||
2332 | |||
2333 | file_found: |
||
2334 | dec eax |
||
2335 | ; eax = file size |
||
2336 | jz .finish |
||
2337 | mov [filesize],eax |
||
2338 | |||
2339 | mov edi,0x80000 ; clear all |
||
2340 | @@: |
||
2341 | mov [edi],byte ' ' |
||
2342 | inc edi |
||
2343 | cmp edi,0x2effff |
||
2344 | jnz @b |
||
2345 | |||
2346 | mov [lines],0 |
||
2347 | mov edi,0x10000 |
||
2348 | mov ebx,0x80000 |
||
2349 | |||
2350 | ; edi = from |
||
2351 | ; ebx = to |
||
2352 | ; eax = filesize |
||
2353 | |||
2354 | .new_char: |
||
2355 | mov cl,[edi] ; get_char(); |
||
2356 | cmp cl,13 ; if (char==13) |
||
2357 | je .new_str1 ; goto .new_str1; |
||
2358 | cmp cl,10 ; if (char==10) |
||
2359 | je .new_str2 ; goto .new_str2; |
||
2360 | mov [ebx],cl ; store_char(); |
||
2361 | inc ebx ; dest++; |
||
2362 | .back: |
||
2363 | inc edi ; src++; |
||
2364 | dec eax ; counter--; |
||
2365 | jnz .new_char ; if (counter!=0) goto .new_char; |
||
2366 | |||
2367 | .finish: |
||
2368 | inc [lines] ; [lines]++; |
||
2369 | ret |
||
2370 | |||
2371 | .new_str1: |
||
2372 | pusha |
||
2373 | mov eax,ebx ; eax = destination |
||
2374 | add eax,-0x80000 ; eax = offset |
||
2375 | cdq |
||
2376 | mov ecx,80 |
||
2377 | div ecx ; offset /= 80; |
||
2378 | test edx,edx ; if not the first char in the string |
||
2379 | jne @f ; go forward |
||
2380 | test eax,eax ; if first line |
||
2381 | je @f ; go forward |
||
2382 | cmp [edi-1],byte 10; if previous char != 10 continue without line feed |
||
2383 | jne .contin |
||
2384 | @@: |
||
2385 | inc eax ; offset++; |
||
2386 | imul eax,80 ; offset *= 80; |
||
2387 | add eax,0x80000 |
||
2388 | mov [esp+4*4],eax ; to ebx |
||
2389 | .contin: |
||
2390 | popa |
||
2391 | inc edi ; do not look on the next char (10) |
||
2392 | dec eax ; counter--; |
||
2393 | inc [lines] ; [lines]++; |
||
2394 | jmp .back |
||
2395 | |||
2396 | |||
2397 | .new_str2: |
||
2398 | pusha |
||
2399 | mov eax,ebx |
||
2400 | add eax,-0x80000 |
||
2401 | cdq |
||
2402 | mov ecx,80 |
||
2403 | div ecx |
||
2404 | inc eax |
||
2405 | imul eax,80 |
||
2406 | add eax,0x80000 |
||
2407 | mov [esp+4*4],eax ; to ebx |
||
2408 | popa |
||
2409 | inc [lines] |
||
2410 | jmp .back |
||
2411 | |||
2412 | |||
2413 | file_not_found: |
||
2414 | mov eax,55 ; beep |
||
2415 | mov ebx,eax |
||
2416 | mov esi,error_beep |
||
2417 | int 0x40 |
||
2418 | mov [lines],1 ; open empty document |
||
2419 | |||
2420 | mov [to_return2],1 |
||
2421 | call openerror |
||
2422 | |||
2423 | ret |
||
2424 | |||
2425 | disk_is_full: |
||
2426 | mov eax,55 ; beep |
||
2427 | mov ebx,eax |
||
2428 | mov esi,error_beep |
||
2429 | int 0x40 |
||
2430 | mov [to_return2],1 |
||
2431 | call saveerror |
||
2432 | mov [error2_found],1 |
||
2433 | ret |
||
2434 | |||
2435 | |||
2436 | ; ***************************** |
||
2437 | ; ****** WRITE POSITION ****** |
||
2438 | ; ***************************** |
||
2439 | |||
2440 | writepos: |
||
2441 | |||
2442 | cmp [do_not_draw],1 ; return if drawing is not permitted |
||
2443 | jne @f |
||
2444 | ret |
||
2445 | @@: |
||
2446 | |||
2447 | pusha |
||
2448 | |||
2449 | mov eax,[posx] |
||
2450 | inc eax |
||
2451 | cdq |
||
2452 | mov ebx,10 |
||
2453 | div ebx |
||
2454 | add al,'0' |
||
2455 | add dl,'0' |
||
2456 | mov [htext2+ 9],al |
||
2457 | mov [htext2+10],dl |
||
2458 | |||
2459 | mov eax,[post] |
||
2460 | cdq |
||
2461 | mov ebx,80 |
||
2462 | div ebx |
||
2463 | mov [real_posy],eax ;=====!!!!!!!!! |
||
2464 | |||
2465 | add eax,[posy] |
||
2466 | inc eax |
||
2467 | mov ebx,10 |
||
2468 | cdq |
||
2469 | div ebx |
||
2470 | add dl,'0' |
||
2471 | mov [htext2+16],dl ; 00001 |
||
2472 | cdq |
||
2473 | div ebx |
||
2474 | add dl,'0' |
||
2475 | mov [htext2+15],dl ; 00010 |
||
2476 | cdq |
||
2477 | div ebx |
||
2478 | add dl,'0' |
||
2479 | mov [htext2+14],dl ; 00100 |
||
2480 | cdq |
||
2481 | div ebx |
||
2482 | add dl,'0' |
||
2483 | add al,'0' |
||
2484 | mov [htext2+13],dl ; 01000 |
||
2485 | mov [htext2+12],al ; 10000 |
||
2486 | |||
2487 | |||
2488 | mov eax,[lines] ; number of lines |
||
2489 | cdq |
||
2490 | mov ebx,10 |
||
2491 | div ebx |
||
2492 | add dl,'0' |
||
2493 | mov [htext2+31],dl ; 0001 |
||
2494 | cdq |
||
2495 | div ebx |
||
2496 | add dl,'0' |
||
2497 | mov [htext2+30],dl ; 0010 |
||
2498 | cdq |
||
2499 | div ebx |
||
2500 | add dl,'0' |
||
2501 | mov [htext2+29],dl ; 0100 |
||
2502 | cdq |
||
2503 | div ebx |
||
2504 | add dl,'0' |
||
2505 | add al,'0' |
||
2506 | mov [htext2+28],dl |
||
2507 | mov [htext2+27],al ; 10000 |
||
2508 | |||
2509 | ; НАДО БЫ ОТОБРАЖАТЬ РАСКЛАДКУ КЛАВИАТУРЫ! |
||
2510 | ; mov [htext2+42], word 'RU' |
||
2511 | |||
2512 | ; mov eax,13 ; draw bar |
||
2513 | ; mov ebx,5*65536+38*6 |
||
2514 | ; mov ecx,[dstart] |
||
2515 | ; shl ecx,16 |
||
2516 | ; add ecx,15 |
||
2517 | ; mov edx,[sc.work_graph] |
||
2518 | ; int 0x40 |
||
2519 | |||
2520 | mov eax,13 ; BAR STRIPE |
||
2521 | mov ebx,5*65536+497 |
||
2522 | mov ecx,[dstart] |
||
2523 | add ecx,29;30 ;15 |
||
2524 | shl ecx,16 |
||
2525 | add ecx,14 |
||
2526 | mov edx,[sc.work_graph] |
||
2527 | int 0x40 |
||
2528 | |||
2529 | mov eax,4 ; write position |
||
2530 | mov ebx,12*65536 |
||
2531 | mov bx,word [dstart] |
||
2532 | add ebx,33 ;18 |
||
2533 | mov ecx,[sc.work_button_text] |
||
2534 | mov edx,htext2 |
||
2535 | mov esi,38 |
||
2536 | int 0x40 |
||
2537 | |||
2538 | cmp [modified],1 |
||
2539 | jne no_mod |
||
2540 | putlabel 270,386,'ИЗМЕНЕН',[sc.work_button_text] |
||
2541 | no_mod: |
||
2542 | popa |
||
2543 | |||
2544 | ret |
||
2545 | |||
2546 | ;----------------------------- |
||
2547 | ; search window |
||
2548 | ;----------------------------- |
||
2549 | search_window: |
||
2550 | |||
2551 | mov eax,13 |
||
2552 | mov ebx,55*65536+380 |
||
2553 | mov ecx,100*65536+60 |
||
2554 | mov edx,[sc.work_graph] |
||
2555 | int 0x40 |
||
2556 | |||
2557 | mov eax,38 |
||
2558 | mov ebx,55*65536+435 |
||
2559 | mov ecx,100*65536+100 |
||
2560 | mov edx,cl_White |
||
2561 | int 0x40 |
||
2562 | mov eax,38 |
||
2563 | mov ebx,55*65536+55 |
||
2564 | mov ecx,100*65536+160 |
||
2565 | mov edx,cl_White |
||
2566 | int 0x40 |
||
2567 | mov eax,38 |
||
2568 | mov ebx,435*65536+435 |
||
2569 | mov ecx,100*65536+160 |
||
2570 | mov edx,cl_White |
||
2571 | int 0x40 |
||
2572 | mov eax,38 |
||
2573 | mov ebx,55*65536+435 |
||
2574 | mov ecx,160*65536+160 |
||
2575 | mov edx,cl_White |
||
2576 | int 0x40 |
||
2577 | |||
2578 | |||
2579 | drawlbut 375,110,50,15,'Поиск',50,[sc.work_button],[sc.work_button_text] |
||
2580 | drawlbut 375,130,50,15,'Отмена',94,[sc.work_button],[sc.work_button_text] |
||
2581 | |||
2582 | call read_string |
||
2583 | |||
2584 | ; add eax,31 |
||
2585 | ; mov [ya],eax |
||
2586 | ; mov [addr],search_string |
||
2587 | ; call print_text |
||
2588 | |||
2589 | |||
2590 | |||
2591 | jmp search |
||
2592 | |||
2593 | string_not_found: |
||
2594 | mov eax,13 |
||
2595 | mov ebx,150*65536+200 |
||
2596 | mov ecx,100*65536+70 |
||
2597 | mov edx,[sc.work_graph] ;0x00dd9438 ;0x00ff7512 |
||
2598 | int 0x40 |
||
2599 | |||
2600 | mov eax,38 |
||
2601 | mov ebx,150*65536+350 |
||
2602 | mov ecx,100*65536+100 |
||
2603 | mov edx,cl_White |
||
2604 | int 0x40 |
||
2605 | mov eax,38 |
||
2606 | mov ebx,150*65536+350 |
||
2607 | mov ecx,170*65536+170 |
||
2608 | mov edx,cl_White |
||
2609 | int 0x40 |
||
2610 | mov eax,38 |
||
2611 | mov ebx,150*65536+150 |
||
2612 | mov ecx,100*65536+170 |
||
2613 | mov edx,cl_White |
||
2614 | int 0x40 |
||
2615 | mov eax,38 |
||
2616 | mov ebx,350*65536+350 |
||
2617 | mov ecx,100*65536+170 |
||
2618 | mov edx,cl_White |
||
2619 | int 0x40 |
||
2620 | |||
2621 | |||
2622 | putlabel 195,120,'Строка не найденна!',cl_White |
||
2623 | |||
2624 | drawlbut 235,140,30,15,'Ок',94,[sc.work_button],cl_White |
||
2625 | |||
2626 | ret |
||
2627 | |||
2628 | read_string: |
||
2629 | |||
2630 | push eax |
||
2631 | ;---------------- |
||
2632 | mov eax,40 |
||
2633 | mov ebx,00000000000000000000000000000111b |
||
2634 | int 0x40 |
||
2635 | ;---------------- |
||
2636 | pop eax |
||
2637 | |||
2638 | ; cmp al,51 |
||
2639 | ; jz .f2 |
||
2640 | ; ret |
||
2641 | |||
2642 | .f2: |
||
2643 | mov [addr],dword search_string |
||
2644 | mov eax,[dstart] |
||
2645 | add eax,17+14 |
||
2646 | mov [ya],eax |
||
2647 | mov [case_sens],1 |
||
2648 | |||
2649 | .rk: |
||
2650 | |||
2651 | mov edi,[addr] |
||
2652 | |||
2653 | mov eax,[addr] |
||
2654 | mov eax,[eax-4] |
||
2655 | mov [temp],eax |
||
2656 | |||
2657 | add edi,eax |
||
2658 | |||
2659 | call print_text |
||
2660 | |||
2661 | .waitev: |
||
2662 | mov eax, 10 |
||
2663 | int 0x40 |
||
2664 | cmp eax, 2 |
||
2665 | jne .read_done |
||
2666 | int 0x40 |
||
2667 | shr eax, 8 |
||
2668 | |||
2669 | cmp al, 13 ; enter |
||
2670 | je .read_done |
||
2671 | |||
2672 | cmp al,27 |
||
2673 | jne ._f |
||
2674 | jmp red |
||
2675 | ._f: |
||
2676 | cmp al, 192 ; Ctrl + space |
||
2677 | jne .noclear |
||
2678 | |||
2679 | xor eax, eax |
||
2680 | mov [temp], eax |
||
2681 | mov edi, [addr] |
||
2682 | mov [edi-4], eax |
||
2683 | mov ecx, 49 |
||
2684 | cld |
||
2685 | rep stosb |
||
2686 | mov edi, [addr] |
||
2687 | call print_text |
||
2688 | jmp .waitev |
||
2689 | |||
2690 | .noclear: |
||
2691 | |||
2692 | cmp al, 8 ; backspace |
||
2693 | jnz .nobsl |
||
2694 | cmp [temp], 0 |
||
2695 | jz .waitev |
||
2696 | dec [temp] |
||
2697 | mov edi, [addr] |
||
2698 | add edi, [temp] |
||
2699 | mov [edi], byte 0 |
||
2700 | |||
2701 | mov eax,[addr] |
||
2702 | dec dword [eax-4] |
||
2703 | |||
2704 | call print_text |
||
2705 | jmp .waitev |
||
2706 | |||
2707 | .nobsl: |
||
2708 | cmp [temp],50 |
||
2709 | jae .read_done |
||
2710 | |||
2711 | ; CONVERT CHAR TO UPPER CASE: |
||
2712 | cmp al, ' ' ; below "space" - ignore |
||
2713 | jb .waitev |
||
2714 | cmp [case_sens], 1 ; case sensitive? |
||
2715 | je .keyok |
||
2716 | cmp al, 'a' |
||
2717 | jb .keyok |
||
2718 | cmp al, 'z' |
||
2719 | ja .keyok |
||
2720 | sub al, 32 |
||
2721 | .keyok: |
||
2722 | |||
2723 | mov edi,[addr] |
||
2724 | add edi,[temp] |
||
2725 | mov [edi],al |
||
2726 | |||
2727 | inc [temp] |
||
2728 | |||
2729 | mov eax,[addr] |
||
2730 | inc dword [eax-4] |
||
2731 | call print_text |
||
2732 | |||
2733 | cmp [temp],50 |
||
2734 | jbe .waitev |
||
2735 | |||
2736 | .read_done: |
||
2737 | mov ecx,50 |
||
2738 | sub ecx,[temp] |
||
2739 | mov edi,[addr] |
||
2740 | add edi,[temp] |
||
2741 | xor eax,eax |
||
2742 | cld |
||
2743 | rep stosb |
||
2744 | |||
2745 | mov [temp],987 |
||
2746 | |||
2747 | call print_text |
||
2748 | call mask_events |
||
2749 | ret |
||
2750 | |||
2751 | |||
2752 | print_text: |
||
2753 | |||
2754 | pusha |
||
2755 | |||
2756 | mov eax,13 |
||
2757 | mov ebx,64*65536+50*6+2 |
||
2758 | ; mov ecx,[ya] |
||
2759 | ; shl ecx,16 |
||
2760 | ; add ecx,12 |
||
2761 | mov ecx,110*65536+12 |
||
2762 | mov edx,[sc.work] |
||
2763 | int 0x40 |
||
2764 | |||
2765 | mov edx,[addr] |
||
2766 | mov esi,[edx-4] |
||
2767 | mov eax,4 |
||
2768 | mov ebx,65*65536+112 ;2 |
||
2769 | ; add ebx,[ya] |
||
2770 | mov ecx,[color_tbl+0] |
||
2771 | int 0x40 |
||
2772 | |||
2773 | cmp [temp],50 |
||
2774 | ja @f |
||
2775 | |||
2776 | ; draw cursor |
||
2777 | ; { |
||
2778 | ; mov eax,[ya] |
||
2779 | mov eax,18*65536+102 ;65 |
||
2780 | mov ebx,eax |
||
2781 | shl eax,16 |
||
2782 | add eax,ebx |
||
2783 | add eax,10 |
||
2784 | mov ecx,eax |
||
2785 | |||
2786 | mov eax,[temp] |
||
2787 | ; imul eax,6 |
||
2788 | lea eax,[eax+eax*2] |
||
2789 | shl eax,1 |
||
2790 | add eax,65 |
||
2791 | mov ebx,eax |
||
2792 | shl eax,16 |
||
2793 | add ebx,eax |
||
2794 | |||
2795 | mov eax,38 |
||
2796 | mov edx,[color_tbl+0] |
||
2797 | int 0x40 |
||
2798 | ; } |
||
2799 | |||
2800 | @@: |
||
2801 | popa |
||
2802 | |||
2803 | ret |
||
2804 | |||
2805 | |||
2806 | |||
2807 | ; mov eax,8 ; STRING BUTTON |
||
2808 | ; mov ebx,5*65536+57 |
||
2809 | ; mov ecx,[dstart] |
||
2810 | ; add ecx,29 |
||
2811 | ; shl ecx,16 |
||
2812 | ; add ecx,13 |
||
2813 | ; mov edx,51 ;;;;;-----string button ID=51 |
||
2814 | ; mov esi,[sc.work_button] |
||
2815 | ; int 0x40 |
||
2816 | ; SEARCH BUTTON |
||
2817 | ; mov ebx,(505-129)*65536+125 |
||
2818 | ; mov edx,50 |
||
2819 | ; mov esi,[sc.work_button] |
||
2820 | ; int 0x40 |
||
2821 | |||
2822 | ; mov eax,4 ; SEARCH TEXT |
||
2823 | ; mov ebx,[dstart] |
||
2824 | ; add ebx,7*65536+32 |
||
2825 | ; mov ecx,[sc.work_button_text] |
||
2826 | ; mov edx,searcht |
||
2827 | ; mov esi,searchtl-searcht |
||
2828 | ; int 0x40 |
||
2829 | |||
2830 | |||
2831 | |||
2832 | ; **************************** |
||
2833 | ; ******* READ STRING ******** |
||
2834 | ; **************************** |
||
2835 | goto_string: |
||
2836 | |||
2837 | mov [num_goto_string],0 |
||
2838 | call read_str_num |
||
2839 | mov eax,[num_goto_string] |
||
2840 | cmp eax,[lines] |
||
2841 | ja .leave |
||
2842 | |||
2843 | ;--------------- |
||
2844 | mov [posy],0 |
||
2845 | call goto_pos |
||
2846 | |||
2847 | .leave: |
||
2848 | call draw_window_for_dialogs |
||
2849 | call mask_events |
||
2850 | |||
2851 | jmp still |
||
2852 | |||
2853 | |||
2854 | read_str_num: |
||
2855 | push eax |
||
2856 | ;---------------- |
||
2857 | mov eax,40 |
||
2858 | mov ebx,00000000000000000000000000000111b |
||
2859 | int 0x40 |
||
2860 | ;---------------- |
||
2861 | pop eax |
||
2862 | |||
2863 | mov eax,13 |
||
2864 | mov ebx,100*65536+100 |
||
2865 | mov ecx,70*65536+60 |
||
2866 | mov edx,[sc.work_button] |
||
2867 | int 0x40 |
||
2868 | |||
2869 | |||
2870 | mov eax,38 |
||
2871 | mov ebx,100*65536+200 |
||
2872 | mov ecx,70*65536+70 |
||
2873 | mov edx,cl_White |
||
2874 | int 0x40 |
||
2875 | mov eax,38 |
||
2876 | mov ebx,100*65536+200 |
||
2877 | mov ecx,130*65536+130 |
||
2878 | mov edx,cl_White |
||
2879 | int 0x40 |
||
2880 | mov eax,38 |
||
2881 | mov ebx,100*65536+100 |
||
2882 | mov ecx,70*65536+130 |
||
2883 | mov edx,cl_White |
||
2884 | int 0x40 |
||
2885 | mov eax,38 |
||
2886 | mov ebx,200*65536+200 |
||
2887 | mov ecx,70*65536+130 |
||
2888 | mov edx,cl_White |
||
2889 | int 0x40 |
||
2890 | |||
2891 | |||
2892 | |||
2893 | putlabel 105,75,'GoTo Line #',cl_White |
||
2894 | mov eax,13 |
||
2895 | mov ebx,110*65536+40 |
||
2896 | mov ecx,90*65536+12;[ya] |
||
2897 | mov edx,[sc.work] |
||
2898 | int 0x40 |
||
2899 | |||
2900 | outcount [num_goto_string],112,92,cl_Black,6*65536 |
||
2901 | drawlbut 110,105,40,15,'GoTo',93,cl_Grey,cl_Black |
||
2902 | drawlbut 153,105,40,15,'Cancel',94,cl_Grey,cl_Black |
||
2903 | .waitev: |
||
2904 | mov eax, 10 |
||
2905 | int 0x40 |
||
2906 | ; cmp eax,6 |
||
2907 | ; je .mouse |
||
2908 | cmp eax,3 |
||
2909 | je .but |
||
2910 | cmp eax, 2 |
||
2911 | ; jne .read_done |
||
2912 | jne .waitev |
||
2913 | int 0x40 |
||
2914 | shr eax, 8 |
||
2915 | |||
2916 | cmp al, 13 ; enter |
||
2917 | je .read_done |
||
2918 | cmp al,27 |
||
2919 | je goto_string.leave |
||
2920 | cmp al, 8 ; backspace |
||
2921 | jnz .nobsl |
||
2922 | |||
2923 | xor edx,edx |
||
2924 | |||
2925 | mov eax,[num_goto_string] |
||
2926 | mov ebx,dword 10 |
||
2927 | div ebx |
||
2928 | mov [num_goto_string],eax |
||
2929 | call print_text2 |
||
2930 | jmp .waitev |
||
2931 | |||
2932 | ;.mouse: |
||
2933 | ;mov eax,37 |
||
2934 | ;mov ebx,2 |
||
2935 | ;int 0x40 |
||
2936 | ;cmp eax,2 |
||
2937 | ;je goto_string.leave |
||
2938 | ;jmp .waitev |
||
2939 | |||
2940 | .but: |
||
2941 | mov eax,17 |
||
2942 | int 0x40 |
||
2943 | cmp ah,94 |
||
2944 | je goto_string.leave |
||
2945 | cmp ah,93 |
||
2946 | je .read_done |
||
2947 | jmp .waitev |
||
2948 | |||
2949 | |||
2950 | .nobsl: |
||
2951 | xor ecx,ecx |
||
2952 | xor edx,edx |
||
2953 | |||
2954 | sub al,48 |
||
2955 | mov cl,al |
||
2956 | |||
2957 | mov eax,[num_goto_string] |
||
2958 | cmp eax,99999 |
||
2959 | ja .read_done |
||
2960 | mov ebx,10 |
||
2961 | mul ebx |
||
2962 | add eax,ecx |
||
2963 | mov [num_goto_string],eax |
||
2964 | |||
2965 | call print_text2 |
||
2966 | jmp .waitev |
||
2967 | |||
2968 | .read_done: |
||
2969 | mov eax,[num_goto_string] |
||
2970 | dec eax |
||
2971 | mov [num_goto_string],eax |
||
2972 | call print_text2 |
||
2973 | ret |
||
2974 | |||
2975 | |||
2976 | print_text2: |
||
2977 | |||
2978 | pusha |
||
2979 | |||
2980 | mov eax,13 |
||
2981 | mov ebx,110*65536+40 |
||
2982 | mov ecx,90*65536+12;[ya] |
||
2983 | mov edx,[sc.work] |
||
2984 | int 0x40 |
||
2985 | |||
2986 | outcount [num_goto_string],112,92,cl_Black,6*65536 |
||
2987 | popa |
||
2988 | |||
2989 | ret |
||
2990 | |||
2991 | ;****************************************************************************** |
||
2992 | calc_scroll_size_and_pos: |
||
2993 | |||
2994 | ;cmp [menu_is_on],0 |
||
2995 | ;je ._ff |
||
2996 | ;call drawwindow |
||
2997 | ;mov [menu_is_on],0 |
||
2998 | ;._ff: |
||
2999 | |||
3000 | cmp [lines],30 |
||
3001 | jbe .lines_less_30 |
||
3002 | |||
3003 | xor edx,edx |
||
3004 | mov eax,[post] |
||
3005 | mov ebx,80 |
||
3006 | div ebx |
||
3007 | add eax,[posy] |
||
3008 | ;add eax,[slines] |
||
3009 | |||
3010 | ;checking for bug |
||
3011 | mov ebx,[lines] |
||
3012 | sub ebx,30 |
||
3013 | |||
3014 | cmp eax,ebx |
||
3015 | ja .f |
||
3016 | mov [VScroll_1+16],eax |
||
3017 | jmp .ff |
||
3018 | .f: |
||
3019 | mov [VScroll_1+16],ebx |
||
3020 | |||
3021 | .ff: |
||
3022 | ;--------------------- |
||
3023 | mov eax,[lines] |
||
3024 | sub eax,30 ;---max=lines-30 |
||
3025 | mov [VScroll_1+12],eax |
||
3026 | jmp .leave |
||
3027 | |||
3028 | .lines_less_30: |
||
3029 | |||
3030 | mov [VScroll_1+16],dword 0 |
||
3031 | mov [VScroll_1+12],dword 1 |
||
3032 | |||
3033 | .leave: |
||
3034 | |||
3035 | ret |
||
3036 | ;============Draw vertical scroll bar========= |
||
3037 | draw_vertical_scroll: |
||
3038 | call calc_scroll_size_and_pos |
||
3039 | ;======================== |
||
3040 | xor ecx,ecx ;start at top of controls list |
||
3041 | Draw_Controls_Loop: ;Redraw Controls Loop |
||
3042 | mov ebp, [App_Controls+ecx] ;get controls data location |
||
3043 | or ebp,ebp ;is this the last control? |
||
3044 | jz Draw_Controls_Done ; |
||
3045 | call dword [App_Controls+ecx+4] ;call controls draw function |
||
3046 | add ecx, 12 ;get next control |
||
3047 | jmp Draw_Controls_Loop ;loop till done |
||
3048 | Draw_Controls_Done: ;all done |
||
3049 | ;======================== |
||
3050 | |||
3051 | mov eax,38 |
||
3052 | mov ebx,488*65536+488 |
||
3053 | mov ecx,43*65536+388 |
||
3054 | mov edx,0x00000000 |
||
3055 | int 0x40 |
||
3056 | ret |
||
3057 | |||
3058 | mouse_info: |
||
3059 | ;call |
||
3060 | mov eax, 37 ;get mouse cordinates |
||
3061 | mov ebx, 1 ; |
||
3062 | int 0x40 ; |
||
3063 | mov ecx, eax ; |
||
3064 | push ecx ; |
||
3065 | mov eax, 37 ;get mouse buttons |
||
3066 | mov ebx, 2 ; |
||
3067 | int 0x40 ; |
||
3068 | ;------------------ |
||
3069 | ; if menu is on - then we need to redraw window before continue |
||
3070 | cmp eax,1 |
||
3071 | jne ._f1 |
||
3072 | |||
3073 | pusha |
||
3074 | cmp [menu_is_on],0 |
||
3075 | je ._ff |
||
3076 | call drawwindow |
||
3077 | mov [menu_is_on],0 |
||
3078 | ._ff: |
||
3079 | popa |
||
3080 | |||
3081 | ._f1: |
||
3082 | ;------------------ |
||
3083 | cmp [mouseb], eax ;compare old mouse states to new states |
||
3084 | jne redraw_mouse_info ; |
||
3085 | cmp [mousey], cx ; |
||
3086 | jne redraw_mouse_info ; |
||
3087 | shr ecx, 16 ; |
||
3088 | cmp [mousex], cx ; |
||
3089 | jne redraw_mouse_info ; |
||
3090 | pop ecx ; |
||
3091 | ret ;return if no change in states |
||
3092 | redraw_mouse_info: |
||
3093 | pop ecx |
||
3094 | mov [mouseb], eax ;save new mouse states |
||
3095 | mov dword [mousey], ecx |
||
3096 | xor ecx, ecx |
||
3097 | Check_Mouse_Over_Controls_Loop: |
||
3098 | mov ebp, [App_Controls+ecx] |
||
3099 | or ebp, ebp |
||
3100 | jz Check_Mouse_Over_Controls_Loop_done |
||
3101 | |||
3102 | movzx eax,word [ebp+2] |
||
3103 | cmp ax, [mousex] |
||
3104 | ja mouse_not_on_control |
||
3105 | movzx eax,word [ebp+6] |
||
3106 | cmp ax, [mousey] |
||
3107 | ja mouse_not_on_control |
||
3108 | movzx eax,word [ebp] |
||
3109 | add ax, [ebp+2] |
||
3110 | cmp ax, [mousex] |
||
3111 | jb mouse_not_on_control |
||
3112 | movzx eax,word [ebp+4] |
||
3113 | add ax, [ebp+6] |
||
3114 | cmp ax, [mousey] |
||
3115 | jb mouse_not_on_control |
||
3116 | call dword [App_Controls+ecx+8] |
||
3117 | ;------------------------------ |
||
3118 | cmp [mouseb],1 |
||
3119 | jne mouse_not_on_control |
||
3120 | mov eax,[VScroll_1+16] |
||
3121 | call goto_pos |
||
3122 | ;------------------------------ |
||
3123 | |||
3124 | mouse_not_on_control: |
||
3125 | add ecx, 12 |
||
3126 | jmp Check_Mouse_Over_Controls_Loop |
||
3127 | Check_Mouse_Over_Controls_Loop_done: |
||
3128 | |||
3129 | ret |
||
3130 | ;****************************************************************************** |
||
3131 | goto_pos: |
||
3132 | ;pusha |
||
3133 | |||
3134 | mov ecx,eax ;save new position number in ecx for future |
||
3135 | |||
3136 | cmp [lines],30 ;check for 'cursor' bug |
||
3137 | jbe .lines_less_30 |
||
3138 | ;--------------- |
||
3139 | |||
3140 | mov edx,[lines] ;if new pos is > than (lines-30) |
||
3141 | sub edx,30 |
||
3142 | |||
3143 | cmp eax,edx |
||
3144 | ja .f1 |
||
3145 | jmp .ff |
||
3146 | |||
3147 | .f1: |
||
3148 | mov eax,edx ;than newpos is = (lines-30) |
||
3149 | |||
3150 | sub ecx,edx ;and posY=newpos-(lines-30) |
||
3151 | mov [posy],ecx |
||
3152 | |||
3153 | .ff: |
||
3154 | |||
3155 | ;----------------------- |
||
3156 | ;in eax must be string number |
||
3157 | mov ecx,80 |
||
3158 | mul ecx |
||
3159 | |||
3160 | ; add eax,[slines] |
||
3161 | ; sub |
||
3162 | ;------------------------ |
||
3163 | mov [post],eax |
||
3164 | |||
3165 | .lines_less_30: |
||
3166 | call clear_screen |
||
3167 | call drawfile |
||
3168 | ;popa |
||
3169 | ret |
||
3170 | ;****************************************************************************** |
||
3171 | mask_events: |
||
3172 | mov eax,40 |
||
3173 | mov ebx,00100111b |
||
3174 | int 0x40 |
||
3175 | ret |
||
3176 | ;****************************************************************************** |
||
3177 | main_cursor_move: |
||
3178 | ;call drawwindow |
||
3179 | sub [mouse_x],7 |
||
3180 | sub [mouse_y],45 |
||
3181 | |||
3182 | xor edx,edx |
||
3183 | mov eax,[mouse_x] |
||
3184 | mov ebx,6 |
||
3185 | div ebx ;eax=result |
||
3186 | mov [posx],eax |
||
3187 | |||
3188 | xor edx,edx |
||
3189 | mov eax,dword [mouse_y] |
||
3190 | mov ebx,dword 10 |
||
3191 | div ebx ;eax=result=new posY |
||
3192 | |||
3193 | ;error checking ------ |
||
3194 | cmp [lines],dword 1 ;for "1st line" bug |
||
3195 | je ._do_nothing |
||
3196 | |||
3197 | mov ebx,[lines] |
||
3198 | sub ebx,dword 1 |
||
3199 | |||
3200 | cmp eax,ebx ;[lines] |
||
3201 | ja ._do_nothing |
||
3202 | |||
3203 | ;---------------------- |
||
3204 | mov [posy],eax |
||
3205 | |||
3206 | ._do_nothing: |
||
3207 | call clear_screen |
||
3208 | call drawfile |
||
3209 | call draw_vertical_scroll |
||
3210 | ret |
||
3211 | |||
3212 | ;****************************************************************************** |
||
3213 | make_fast_so: |
||
3214 | ;=========================== |
||
3215 | ; 1) get info about me |
||
3216 | mov eax,9 |
||
3217 | mov ebx,procinfo |
||
3218 | mov ecx,-1 |
||
3219 | int 0x40 |
||
3220 | ; eax = number of processes |
||
3221 | |||
3222 | ; save process counter |
||
3223 | inc eax |
||
3224 | inc eax |
||
3225 | mov [proccount],eax |
||
3226 | |||
3227 | mov eax,[procinfo.PID] |
||
3228 | mov [PID],eax |
||
3229 | ;========================== |
||
3230 | |||
3231 | |||
3232 | mov eax,51 |
||
3233 | mov ebx,1 |
||
3234 | mov ecx,fast_so_thread_start |
||
3235 | mov edx,so_stack |
||
3236 | int 0x40 |
||
3237 | ret |
||
3238 | ;****************************************************************************** |
||
3239 | |||
3240 | ;fast save & fast open |
||
3241 | draw_fastso_window: |
||
3242 | startwd |
||
3243 | colorwindow 120,100,454,70,window_Type1+0x00cccccc,0x00cccccc,cl_Black |
||
3244 | |||
3245 | call draw_string00 |
||
3246 | drawlbut 10,40,30,20,'Save',17,cl_Grey,cl_Black |
||
3247 | |||
3248 | drawlbut 50,40,30,20,'Open',18,cl_Grey,cl_Black |
||
3249 | |||
3250 | drawlbut 90,40,37,20,'Close',19,cl_Grey,cl_Black |
||
3251 | endwd |
||
3252 | ret |
||
3253 | |||
3254 | draw_string00: |
||
3255 | mov ebx,10*65536+433 |
||
3256 | mov ecx,10*65536+20 |
||
3257 | mov edx,0x00ffffff |
||
3258 | mov eax,13 |
||
3259 | int 0x40 |
||
3260 | |||
3261 | push eax |
||
3262 | mov eax,6*65536 |
||
3263 | mul dword [pos00] |
||
3264 | add eax,10*65536+6 |
||
3265 | mov ebx,eax |
||
3266 | pop eax |
||
3267 | mov edx,0x6a73d0 |
||
3268 | int 0x40 |
||
3269 | |||
3270 | mov eax,4 |
||
3271 | mov ebx,12*65536+17 |
||
3272 | mov ecx,cl_Black ;0x00000000 |
||
3273 | mov edx,mypath ;filename ;path |
||
3274 | mov esi,71 ;200 |
||
3275 | int 0x40 |
||
3276 | ret |
||
3277 | |||
3278 | fast_so_thread_start: |
||
3279 | ;copy filename to mypath |
||
3280 | cld |
||
3281 | mov esi,filename |
||
3282 | mov edi,mypath |
||
3283 | mov ecx,71 ;200 |
||
3284 | rep movsb |
||
3285 | mov edi,mypath |
||
3286 | mov ecx,71 ;200 |
||
3287 | xor eax,eax |
||
3288 | repne scasb |
||
3289 | ;end copy |
||
3290 | call draw_fastso_window |
||
3291 | |||
3292 | fastso_still: |
||
3293 | wtevent fred,fkey,fbut |
||
3294 | jmp fastso_still |
||
3295 | |||
3296 | fred: |
||
3297 | call draw_fastso_window |
||
3298 | jmp fastso_still |
||
3299 | |||
3300 | ;====KEY |
||
3301 | fkey: |
||
3302 | |||
3303 | mov eax,2 |
||
3304 | int 0x40 |
||
3305 | |||
3306 | cmp ah,179 |
||
3307 | jne noright00 |
||
3308 | mov eax,[pos00] |
||
3309 | cmp eax,70 ;41 |
||
3310 | ja fastso_still |
||
3311 | inc eax |
||
3312 | mov [pos00],eax |
||
3313 | call draw_string00 |
||
3314 | jmp fastso_still |
||
3315 | noright00: |
||
3316 | cmp ah,176 |
||
3317 | jne noleft00 |
||
3318 | mov eax,[pos00] |
||
3319 | test eax,eax |
||
3320 | je fastso_still |
||
3321 | dec eax |
||
3322 | mov [pos00],eax |
||
3323 | call draw_string00 |
||
3324 | jmp fastso_still |
||
3325 | noleft00: |
||
3326 | cmp ah,182 |
||
3327 | jne nodelete00 |
||
3328 | call shiftback00 |
||
3329 | call draw_string00 |
||
3330 | jmp fastso_still |
||
3331 | nodelete00: |
||
3332 | cmp ah,8 |
||
3333 | jne noback00 |
||
3334 | mov eax,[pos00] |
||
3335 | test eax,eax |
||
3336 | je fastso_still |
||
3337 | dec eax |
||
3338 | mov [pos00],eax |
||
3339 | call shiftback00 |
||
3340 | call draw_string00 |
||
3341 | jmp fastso_still |
||
3342 | noback00: |
||
3343 | enter00: |
||
3344 | |||
3345 | cmp ah,19 ;ctrl+s |
||
3346 | je fast_save |
||
3347 | cmp ah,15 ;ctrl+o |
||
3348 | je fast_open |
||
3349 | |||
3350 | cmp ah,27 ;esli escape |
||
3351 | jne noesc00 |
||
3352 | jmp closethis ;to zakrivaem okno i nifiga ne delayem |
||
3353 | |||
3354 | noesc00: |
||
3355 | cmp dword [pos00],71 ;200 ;42 |
||
3356 | jae fastso_still ;if pos>71 then jump to still |
||
3357 | |||
3358 | ;============letters================== |
||
3359 | ;~~~~~~~TEST CODE~~~~~~~~~ |
||
3360 | ; upper case |
||
3361 | shr eax,8 |
||
3362 | cmp eax,dword 31 |
||
3363 | jbe no_lit |
||
3364 | cmp eax,dword 95 |
||
3365 | jb capital |
||
3366 | sub eax,32 |
||
3367 | capital: |
||
3368 | ;~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
3369 | mov edi,mypath ;filename ;mypath ;**************PATHNAME |
||
3370 | add edi,71 ;200 ;count of letters |
||
3371 | mov esi,edi |
||
3372 | dec esi |
||
3373 | mov ecx,71 ;200 ;again??? |
||
3374 | sub ecx,[pos00] |
||
3375 | std |
||
3376 | rep movsb |
||
3377 | |||
3378 | ;shr eax,8 |
||
3379 | mov esi,mypath ;filename ;*************PATH AGAIN |
||
3380 | add esi,[pos00] |
||
3381 | mov byte [esi],al |
||
3382 | inc dword [pos00] |
||
3383 | call draw_string00 |
||
3384 | |||
3385 | no_lit: |
||
3386 | jmp fastso_still |
||
3387 | ;=============================== |
||
3388 | shiftback00: |
||
3389 | mov edi,mypath ;filename ;******PATH |
||
3390 | add edi,[pos00] |
||
3391 | mov esi,edi |
||
3392 | inc esi |
||
3393 | mov ecx,71 ;200 ; count??? |
||
3394 | sub ecx,[pos00] |
||
3395 | cld |
||
3396 | rep movsb |
||
3397 | ret |
||
3398 | |||
3399 | ;****************************************************************************** |
||
3400 | |||
3401 | ;====button |
||
3402 | fbut: |
||
3403 | mov eax,17 |
||
3404 | int 0x40 |
||
3405 | cmp ah,17 |
||
3406 | je fast_save |
||
3407 | cmp ah,18 |
||
3408 | je fast_open |
||
3409 | cmp ah,19 |
||
3410 | je closethis |
||
3411 | jmp fastso_still |
||
3412 | ;****************************************************************************** |
||
3413 | ;****************************************************************************** |
||
3414 | |||
3415 | fast_open: |
||
3416 | call path_copy |
||
3417 | call set_title |
||
3418 | mov [to_return],1 |
||
3419 | call do_load_file |
||
3420 | jmp closethis |
||
3421 | fast_save: |
||
3422 | call path_copy |
||
3423 | call save_file |
||
3424 | call set_title |
||
3425 | ;call copy_fpath_s |
||
3426 | closethis: |
||
3427 | mov [to_return],0 |
||
3428 | cmp [error_found],1 |
||
3429 | je @f |
||
3430 | call activate_main |
||
3431 | @@: |
||
3432 | mov [error_found],0 |
||
3433 | close |
||
3434 | |||
3435 | |||
3436 | activate_main: |
||
3437 | mov eax,9 |
||
3438 | mov ebx,procinfo |
||
3439 | mov ecx,[proccount] |
||
3440 | @@: |
||
3441 | dec ecx |
||
3442 | jz @f ; counter=0 => not found? => return |
||
3443 | mov eax,9 |
||
3444 | int 0x40 |
||
3445 | mov edx,[procinfo.PID] |
||
3446 | cmp edx,[PID] |
||
3447 | jne @b |
||
3448 | |||
3449 | ;found: ecx = process_number |
||
3450 | mov eax,18 |
||
3451 | mov ebx,3 |
||
3452 | int 0x40 |
||
3453 | |||
3454 | mov eax,5 |
||
3455 | mov ebx,eax |
||
3456 | int 0x40 |
||
3457 | |||
3458 | @@: |
||
3459 | ret |
||
3460 | |||
3461 | |||
3462 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
3463 | doyouwannasave: |
||
3464 | ;****************************************************************************** |
||
3465 | cmp [modified],0 |
||
3466 | je newfile |
||
3467 | mov eax,55 ; beep |
||
3468 | mov ebx,eax |
||
3469 | mov esi,save_beep1 |
||
3470 | int 0x40 |
||
3471 | delay 4 |
||
3472 | mov eax,55 ; beep |
||
3473 | mov ebx,eax |
||
3474 | mov esi,save_beep2 |
||
3475 | int 0x40 |
||
3476 | |||
3477 | mov eax,13 |
||
3478 | mov ebx,150*65536+200 |
||
3479 | mov ecx,100*65536+70 |
||
3480 | mov edx,[sc.work_graph] ;0x00dd9438 ;0x00ff7512 |
||
3481 | int 0x40 |
||
3482 | |||
3483 | mov eax,38 |
||
3484 | mov ebx,150*65536+350 |
||
3485 | mov ecx,100*65536+100 |
||
3486 | mov edx,cl_White |
||
3487 | int 0x40 |
||
3488 | mov eax,38 |
||
3489 | mov ebx,150*65536+350 |
||
3490 | mov ecx,170*65536+170 |
||
3491 | mov edx,cl_White |
||
3492 | int 0x40 |
||
3493 | mov eax,38 |
||
3494 | mov ebx,150*65536+150 |
||
3495 | mov ecx,100*65536+170 |
||
3496 | mov edx,cl_White |
||
3497 | int 0x40 |
||
3498 | mov eax,38 |
||
3499 | mov ebx,350*65536+350 |
||
3500 | mov ecx,100*65536+170 |
||
3501 | mov edx,cl_White |
||
3502 | int 0x40 |
||
3503 | |||
3504 | |||
3505 | putlabel 190,120,'Сохранить документ?',cl_White |
||
3506 | |||
3507 | drawlbut 170,140,30,15,'Да',46,[sc.work_button],cl_White |
||
3508 | drawlbut 230,140,30,15,'Нет',45,[sc.work_button],cl_White |
||
3509 | drawlbut 290,140,45,15,'Отмена',47,[sc.work_button],cl_White |
||
3510 | |||
3511 | mov [exit_wnd_on],1 |
||
3512 | jmp still |
||
3513 | ;------------- |
||
3514 | newfile: |
||
3515 | ;if filename is not NEWDOC## than change it to it! |
||
3516 | mov eax,dword [orig_filename] |
||
3517 | cmp dword [filename],eax ;[orig_filename] |
||
3518 | je @f |
||
3519 | cld |
||
3520 | mov esi,orig_filename |
||
3521 | mov edi,filename |
||
3522 | mov ecx,71 ;50 |
||
3523 | rep movsb |
||
3524 | mov edi,filename |
||
3525 | mov ecx,71 ;50 |
||
3526 | xor eax,eax |
||
3527 | repne scasb |
||
3528 | sub edi,filename |
||
3529 | dec edi |
||
3530 | mov [filename_len],edi |
||
3531 | |||
3532 | @@: |
||
3533 | |||
3534 | call change_fname |
||
3535 | call set_title |
||
3536 | call draw_window_for_dialogs |
||
3537 | call empty_work_space |
||
3538 | mov [lines],1 |
||
3539 | jmp do_load_file.restorecursor |
||
3540 | |||
3541 | change_fname: |
||
3542 | cmp [filename+7],'9' |
||
3543 | jne addfname |
||
3544 | cmp [filename+6],'9' |
||
3545 | je error_creating_new_file |
||
3546 | mov [filename+7],'0' |
||
3547 | add [filename+6],0x1 |
||
3548 | jmp leavenow |
||
3549 | addfname: |
||
3550 | add [filename+7],0x1 |
||
3551 | leavenow: |
||
3552 | ret |
||
3553 | |||
3554 | set_title: |
||
3555 | cmp [error2_found],1 |
||
3556 | je no_set_title |
||
3557 | mov esi, filename |
||
3558 | mov edi, header |
||
3559 | mov ecx, [filename_len] |
||
3560 | mov eax, ecx |
||
3561 | add eax, 10 |
||
3562 | mov [headlen], eax |
||
3563 | cld |
||
3564 | rep movsb |
||
3565 | |||
3566 | mov [edi], dword ' - ' |
||
3567 | add edi, 3 |
||
3568 | mov esi, htext |
||
3569 | mov ecx, htext.size |
||
3570 | rep movsb |
||
3571 | |||
3572 | call drawwindow |
||
3573 | no_set_title: |
||
3574 | mov [error2_found],0 |
||
3575 | ret |
||
3576 | |||
3577 | draw_window_for_dialogs: |
||
3578 | call clear_screen |
||
3579 | call drawwindow |
||
3580 | ret |
||
3581 | |||
3582 | copy_fpath: |
||
3583 | call mask_events |
||
3584 | call path_copy |
||
3585 | call set_title |
||
3586 | call draw_window_for_dialogs |
||
3587 | jmp do_load_file |
||
3588 | |||
3589 | copy_fpath_s: |
||
3590 | call mask_events |
||
3591 | call path_copy |
||
3592 | call save_file |
||
3593 | call set_title |
||
3594 | call draw_window_for_dialogs |
||
3595 | jmp still |
||
3596 | |||
3597 | path_copy: |
||
3598 | cld |
||
3599 | mov esi,mypath |
||
3600 | mov edi,filename |
||
3601 | mov ecx,250 ;71 ;50 |
||
3602 | rep movsb |
||
3603 | mov edi,filename |
||
3604 | mov ecx,250 ;71 ;50 |
||
3605 | xor eax,eax |
||
3606 | repne scasb |
||
3607 | sub edi,filename |
||
3608 | dec edi |
||
3609 | mov [filename_len],edi |
||
3610 | ret |
||
3611 | |||
3612 | openerror: |
||
3613 | mov eax,360 |
||
3614 | mov ebx,openerrtext |
||
3615 | mov ecx,1 |
||
3616 | call alert_box |
||
3617 | |||
3618 | cmp [to_return2],1 |
||
3619 | jne jmp_to_still |
||
3620 | mov [to_return2],0 |
||
3621 | mov [error_found],1 |
||
3622 | call mask_events |
||
3623 | |||
3624 | ret |
||
3625 | |||
3626 | saveerror: |
||
3627 | mov eax,390 |
||
3628 | mov ebx,saveerrtext |
||
3629 | mov ecx,1 |
||
3630 | call alert_box |
||
3631 | cmp [to_return2],0 |
||
3632 | je jmp_to_still |
||
3633 | mov [to_return2],0 |
||
3634 | mov [error_found],1 |
||
3635 | call mask_events |
||
3636 | ret |
||
3637 | ;jmp still |
||
3638 | jmp_to_still: |
||
3639 | call mask_events |
||
3640 | jmp still |
||
3641 | |||
3642 | error_creating_new_file: |
||
3643 | mov eax,200 |
||
3644 | mov ebx,newfileerror |
||
3645 | mov ecx,1 |
||
3646 | call alert_box |
||
3647 | jmp still |
||
3648 | |||
3649 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
3650 | ;;;;;;;;;;;;;;MENU;;;;;;;;;;;;;;;;;;;;;; |
||
3651 | draw_win_menu: |
||
3652 | |||
3653 | ;mov eax,8 |
||
3654 | ;mov ebx,145*65536+276 |
||
3655 | ;mov ecx,22*65536+15 |
||
3656 | ;mov edx,00100000000000000000000000001111b |
||
3657 | ;mov esi,0x00aaaaaa |
||
3658 | ;int 0x40 |
||
3659 | |||
3660 | mov eax,13 |
||
3661 | mov ebx,5*65536+497 |
||
3662 | mov ecx,22*65536+17 |
||
3663 | mov edx,[sc.work_graph] ;0x00999999 |
||
3664 | int 0x40 |
||
3665 | mov ecx,39*65536+5 |
||
3666 | mov edx,0x00aaaaaa |
||
3667 | int 0x40 |
||
3668 | |||
3669 | drawlbut 5,22,70,15,'Файл',97,[sc.work_button],[sc.work_button_text] |
||
3670 | drawlbut 75,22,70,15,'Код',98,[sc.work_button],[sc.work_button_text] |
||
3671 | drawlbut 145,22,70,15,'Текст',96,[sc.work_button],[sc.work_button_text] |
||
3672 | drawlbut 431,22,70,15,'Справка',99,[sc.work_button],[sc.work_button_text] |
||
3673 | |||
3674 | ret |
||
3675 | |||
3676 | draw_win_menu_file: |
||
3677 | call clear_screen |
||
3678 | call drawwindow |
||
3679 | ;mov eax,13 |
||
3680 | ;mov ebx,5*65536+71 |
||
3681 | ;mov ecx,35*65536+90 |
||
3682 | ;mov edx,[sc.grab_button];0x00999999 |
||
3683 | ;int 0x40 |
||
3684 | ;mov eax,38 |
||
3685 | ;mov ebx,5*65536+35 |
||
3686 | ;mov ecx,40*65536+47 |
||
3687 | ;mov edx,0x00ff0000 |
||
3688 | ;int 0x40 |
||
3689 | mov [menu_is_on],1 |
||
3690 | |||
3691 | drawlbut 5,38,70,15,'Новое окно',100,[sc.grab_button],[sc.grab_button_text] |
||
3692 | drawlbut 5,53,70,15,'Новый',101,[sc.grab_button],[sc.grab_button_text] |
||
3693 | drawlbut 5,68,70,15,'Сохранить',2,[sc.grab_button],[sc.grab_button_text] |
||
3694 | drawlbut 5,83,70,15,'Сохр. как',102,[sc.grab_button],[sc.grab_button_text] |
||
3695 | drawlbut 5,98,70,15,'Открыть',103,[sc.grab_button],[sc.grab_button_text] |
||
3696 | drawlbut 5,113,70,15,'Выход',104,[sc.grab_button],[sc.grab_button_text] |
||
3697 | jmp still |
||
3698 | |||
3699 | draw_win_menu_code: |
||
3700 | call clear_screen |
||
3701 | call drawwindow |
||
3702 | drawlbut 75,38,70,15,'Компил.',10000,[sc.grab_button],[sc.grab_button_text] |
||
3703 | drawlbut 75,53,70,15,'Запустить',10001,[sc.grab_button],[sc.grab_button_text] |
||
3704 | drawlbut 75,68,70,15,'Доска отл.',10002,[sc.grab_button],[sc.grab_button_text] |
||
3705 | drawlbut 75,83,70,15,'SysFunc',10003,[sc.grab_button],[sc.grab_button_text] |
||
3706 | mov [menu_is_on],1 |
||
3707 | jmp still |
||
3708 | |||
3709 | draw_win_menu_text: |
||
3710 | call clear_screen |
||
3711 | call drawwindow |
||
3712 | drawlbut 145,38,70,15,'GoTo Line#',95,[sc.grab_button],[sc.grab_button_text] |
||
3713 | drawlbut 145,53,70,15,'Найти',92,[sc.grab_button],[sc.grab_button_text] |
||
3714 | drawlbut 145,68,70,15,'Найти далее',50,[sc.grab_button],[sc.grab_button_text] |
||
3715 | mov [menu_is_on],1 |
||
3716 | jmp still |
||
3717 | |||
3718 | new_pad_wnd: |
||
3719 | mov eax,19 |
||
3720 | mov ebx,tinypad_filename |
||
3721 | mov ecx,0 |
||
3722 | int 0x40 |
||
3723 | jmp still |
||
3724 | |||
3725 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
3726 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
3727 | openerrtext db 'Ошибка открытия файла или открытие отменено!',0 |
||
3728 | saveerrtext db 'Ошибка сохранения файла или сохранение отменено!',0 |
||
3729 | newfileerror db 'Невозможно сохдать новый файл',0 |
||
3730 | ; ******************** |
||
3731 | ; ****** DATA ****** |
||
3732 | ; ******************** |
||
3733 | sz fasm_filename, 'FASM ' |
||
3734 | sz debug_filename, 'BOARD ' |
||
3735 | sz tinypad_filename, 'TINYPAD ' |
||
3736 | |||
3737 | lsz sysfuncs_filename,\ |
||
3738 | ru, <'SYSFUNCR.TXT',0>,\ |
||
3739 | en, <'SYSFUNCS.TXT',0> |
||
3740 | |||
3741 | sz setup, 'SETUP ' ; we need to run SETUP to change keyboard layout |
||
3742 | param_setup db 'LANG',0 ; parameter for SETUP |
||
3743 | |||
3744 | |||
3745 | addr dd filename ; address of input string |
||
3746 | |||
3747 | filename_len dd 12 |
||
3748 | filename db 'NEWDOC00.TXT' |
||
3749 | times 256 db 0;51-12 db 0 |
||
3750 | ;times db 0 ; я не знаю почему Вилл не поставил эту строчку |
||
3751 | orig_filename db 'NEWDOC00.TXT' |
||
3752 | rb 256 |
||
3753 | search_len dd 5 |
||
3754 | search_string db 'still' |
||
3755 | times 51-5 db 0 |
||
3756 | |||
3757 | case_sens db 0 ; for search function |
||
3758 | |||
3759 | align 4 |
||
3760 | comment_string: |
||
3761 | db ';***************************************' |
||
3762 | db '*************************************** ' |
||
3763 | |||
3764 | |||
3765 | |||
3766 | ; INTERFACE DATA: |
||
3767 | |||
3768 | |||
3769 | sz htext, 'TINYPAD' |
||
3770 | ;sz toolbar_btn_text, 'COMPILE RUN BOARD SYSFUNC' |
||
3771 | |||
3772 | |||
3773 | searcht: |
||
3774 | if lang eq ru |
||
3775 | db ' СТРОКА > ' |
||
3776 | db ' ПОИСК ' |
||
3777 | else |
||
3778 | db ' STRING > ' |
||
3779 | db ' SEARCH ' |
||
3780 | end if |
||
3781 | searchtl: |
||
3782 | |||
3783 | |||
3784 | htext2: |
||
3785 | if lang eq ru |
||
3786 | db ' ПОЗИЦИЯ 00:00000 ДЛИНА 00000 СТРОК ' |
||
3787 | else |
||
3788 | db 'POSITION 00:00000 LENGTH 00000 LINES ' |
||
3789 | end if |
||
3790 | htextlen2: |
||
3791 | |||
3792 | help_text: |
||
3793 | if lang eq ru |
||
3794 | db ' КОМАНДЫ: ' |
||
3795 | db ' ' |
||
3796 | db ' CTRL+F1 : Это окно ' |
||
3797 | db ' CTRL+S : Первая строка для копирования ' |
||
3798 | db ' CTRL+E : Последняя строка для копирования ' |
||
3799 | db ' CTRL+P : Вставить выбранное на текущую позицию ' |
||
3800 | db ' CTRL+D : Удалить строку ' |
||
3801 | db ' CTRL+L : Вставить строку-разделитель ' |
||
3802 | db ' CTRL+[ : Перейти в начало файла ' |
||
3803 | db ' CTRL+] : Перейти в конец файла ' |
||
3804 | db ' CTRL+F2 : Загрузить файл ' |
||
3805 | db ' CTRL+F3 : Поиск ' |
||
3806 | db ' CTRL+F4 : Сохранить файл ' |
||
3807 | db ' CTRL+F5 : Сохранить файл как... ' |
||
3808 | db ' CTRL+F6 : Ввести строку для поиска ' |
||
3809 | db ' CTRL+F7 : "Окно быстрого сохранения и загрузки" ' |
||
3810 | db ' CTRL+F8 : Сменить раскладку клавиатуры ' |
||
3811 | db ' CTRL+F9 : Компилировать файл ' |
||
3812 | db ' CTRL+F10 : Компилировать и запустить ' |
||
3813 | db ' F12 : Запустить доску отладки ' |
||
3814 | db 'x' |
||
3815 | else |
||
3816 | db ' COMMANDS: ' |
||
3817 | db ' ' |
||
3818 | db ' CTRL+F1 : SHOW THIS WINDOW ' |
||
3819 | db ' CTRL+S : SELECT FIRST STRING TO COPY ' |
||
3820 | db ' CTRL+E : SELECT LAST STRING TO COPY ' |
||
3821 | db ' CTRL+P : PASTE SELECTED TO CURRENT POSITION ' |
||
3822 | db ' CTRL+D : DELETE CURRENT LINE ' |
||
3823 | db ' CTRL+L : INSERT SEPARATOR LINE ' |
||
3824 | db ' CTRL+[ : GO TO THE BEGINNING OF FILE ' |
||
3825 | db ' CTRL+] : GO TO THE END OF FILE ' |
||
3826 | db ' CTRL+F2 : LOAD FILE ' |
||
3827 | db ' CTRL+F3 : SEARCH ' |
||
3828 | db ' CTRL+F4 : SAVE FILE ' |
||
3829 | db ' CTRL+F5 : SAVE FILE AS... ' |
||
3830 | db ' CTRL+F6 : ENTER SEARCH STRING ' |
||
3831 | db ' CTRL+F7 : DRAW "FAST SAVE AND OPEN" WINDOW ' |
||
3832 | db ' CTRL+F8 : CHANGE KEYBOARD LAYOUT ' |
||
3833 | db ' CTRL+F9 : COMPILE FILE ' |
||
3834 | db ' CTRL+F10 : RUN OUTFILE ' |
||
3835 | db ' F12 : OPEN DEBUG BOARD ' |
||
3836 | db 'x' |
||
3837 | end if |
||
3838 | |||
3839 | help_wnd_header: |
||
3840 | if lang eq ru |
||
3841 | db 'ПОМОЩЬ',0 |
||
3842 | else |
||
3843 | db 'TINYPAD HELP',0 |
||
3844 | end if |
||
3845 | |||
3846 | hlphead_len = $ - help_wnd_header |
||
3847 | |||
3848 | save_yes_no: |
||
3849 | if lang eq ru |
||
3850 | db 'Сохранить файл перед выходом?',0 |
||
3851 | else |
||
3852 | db 'Save file before exit?',0 |
||
3853 | end if |
||
3854 | |||
3855 | VScroll_1: |
||
3856 | dw 13 ;width +0 |
||
3857 | dw 489 ;x +2 |
||
3858 | dw 341 ;326 ;height +4 |
||
3859 | dw 43 ;y +6 |
||
3860 | dd 0 ;min +8 |
||
3861 | dd 100 ;scrl_max ;lines ;max +12 |
||
3862 | dd 0 ;cur_pos ;current +16 |
||
3863 | dd 1 ;small change +20 |
||
3864 | dd 10 ;big change +24 |
||
3865 | |||
3866 | App_Controls: |
||
3867 | dd VScroll_1 , drawvscroll, VScroll_mouse_over ; |
||
3868 | dd 0,0,0 ;last control do not delete |
||
3869 | |||
3870 | ; END OF INTERFACE DATA |
||
3871 | |||
3872 | symbols db '%#&*\:/<>|{}()[]=+-,. ' |
||
3873 | |||
3874 | error_beep: |
||
3875 | db 0xA0,0x30,0 |
||
3876 | save_beep1: |
||
3877 | db 0x84,0x43,0 |
||
3878 | save_beep2: |
||
3879 | db 0x84,0x48,0 |
||
3880 | |||
3881 | |||
3882 | align 4 |
||
3883 | fileinfo_read: |
||
3884 | dd 0 |
||
3885 | dd 0 |
||
3886 | dd 300000/512 |
||
3887 | dd 0x10000 |
||
3888 | dd 0x70000 |
||
3889 | pathfile_read: |
||
3890 | times 250 db 0 ;51 db 0 |
||
3891 | |||
3892 | align 4 |
||
3893 | fileinfo_write: |
||
3894 | dd 1 |
||
3895 | dd 0 |
||
3896 | dd 0 |
||
3897 | dd 0x10000 |
||
3898 | dd 0x70000 |
||
3899 | pathfile_write: |
||
3900 | times 250 db 0 ; 51 db 0 |
||
3901 | |||
3902 | align 4 |
||
3903 | |||
3904 | temp dd 0xabc ; used in read_string |
||
3905 | d_status dd 0 |
||
3906 | |||
3907 | color_tbl: |
||
3908 | dd 0x00000000 ; text |
||
3909 | dd 0x00000000 ; instruction |
||
3910 | dd 0x00000000 ; register |
||
3911 | dd 0x00009000 ; number |
||
3912 | dd 0x00a00000 ; quote |
||
3913 | dd 0x00909090 ; comment |
||
3914 | dd 0x003030f0 ; symbol |
||
3915 | |||
3916 | |||
3917 | next_not_quote2 db 0 ; " |
||
3918 | next_not_quote db 0 ; ' |
||
3919 | quote db 0 |
||
3920 | asm_mode db 0 ; ASM highlight? |
||
3921 | tmpabc db 0 |
||
3922 | |||
3923 | |||
3924 | I_PARAM db 0 ; parameters are HERE - параметры будут начинаться ЗДЕСЬ! |
||
3925 | TINYPAD_END: ; end of file |
||
3926 | |||
3927 | |||
3928 | ; Uninitialised data |
||
3929 | ; Неинициализированные данные |
||
3930 | align 4 |
||
3931 | |||
3932 | posx dd ? ; x на экране (on the screen) |
||
3933 | posy dd ? ; y на экране |
||
3934 | post dd ? ; смещение от начала - offset |
||
3935 | posl dd ? |
||
3936 | lines dd ? ; количество строк в документе |
||
3937 | posxm dd ? |
||
3938 | posym dd ? |
||
3939 | |||
3940 | dstart dd ? ; смещение по оси y для отрисовки кнопок и др. |
||
3941 | |||
3942 | filelen dd ? ; длина файла |
||
3943 | |||
3944 | PID dd ? ; идентификатор процесса |
||
3945 | proccount dd ? ; количество процессов |
||
3946 | |||
3947 | filesize dd ? ; размер файла |
||
3948 | ya dd ? ; для read_string |
||
3949 | slines dd ? ; number of strings on the screen - количество строк на экране |
||
3950 | |||
3951 | run_outfile dd ? ; for FASM |
||
3952 | copy_start dd ? ; Ctrl+S |
||
3953 | copy_count dd ? ; Ctrl+E |
||
3954 | headlen dd ? ; header length |
||
3955 | do_not_draw dd ? ; to draw or not to draw - this is a serious question ;) |
||
3956 | |||
3957 | MainWndClosed dd ? |
||
3958 | sc system_colors |
||
3959 | |||
3960 | to_return db 0 |
||
3961 | to_return2 db 0 |
||
3962 | error_found db 0 |
||
3963 | error2_found db 0 |
||
3964 | |||
3965 | header: ; window header - заголовок окна |
||
3966 | rb 256 |
||
3967 | |||
3968 | ; информация о процессе записывается в эту структуру |
||
3969 | procinfo process_information |
||
3970 | |||
3971 | virtual at procinfo |
||
3972 | fasm_parameters rb 256 |
||
3973 | end virtual |
||
3974 | pos00 dd 0 |
||
3975 | newdoc db ? |
||
3976 | mypath: |
||
3977 | times 258 db 0 |
||
3978 | real_posy dd 0 |
||
3979 | vscroll_size dd 0 |
||
3980 | vscroll_pos dd 0 |
||
3981 | cur_pos dd 0 |
||
3982 | scrl_max dd 100 |
||
3983 | |||
3984 | mouse_x dd 0 |
||
3985 | mouse_y dd 0 |
||
3986 | mousey dw 0 |
||
3987 | mousex dw 0 |
||
3988 | mouseb dd 0 |
||
3989 | |||
3990 | num_goto_string dd 0 |
||
3991 | |||
3992 | menu_is_on db 0 |
||
3993 | exit_wnd_on db 0 |
||
3994 | modified db 0 |
||
3995 | ;fast save n open stack |
||
3996 | rb 1024 |
||
3997 | so_stack: |
||
3998 | ;growing down |
||
3999 | ; the end!>'SYSFUNCS.TXT',0>'SYSFUNCR.TXT',0>16 |
||
4000 | |||
4001 |