Subversion Repositories Kolibri OS

Rev

Rev 1146 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1146 maximYCH 1
;
2
;     Slovarik 0.3.1 (10 August 2005)
3
;                    DoomEd Archangel
4
;
5
 
6
;*********HEADER************
7
	use32
8
	org 0x0
9
	db 'MENUET01'
10
	dd 0x01
11
	dd lblSTART
12
	dd lblIMG_END
13
	dd lblMEMORY
14
	dd lblSTACK
15
	dd 0x0,0x0
16
;****************************
17
include 'ascl.inc'
18
lblSTART:
19
 
20
	call load_ini  ;Load ini file (path to last opened dictionary
21
	call load_dict ;Load dictionary
22
 
23
;----if no errors then continue
24
 
25
win_redraw:
26
call draw_window
27
 
28
still:
29
	mov eax,10
30
	int 0x40
31
	cmp eax,1
32
	je win_redraw
33
	cmp eax,2
34
	je key_pressed
35
	cmp eax,3
36
	je button_pressed
37
jmp still
38
 
39
 
40
key_pressed:
41
	;mov eax,2
42
	int 0x40
43
	cmp ah,27
44
	je clear_all_2
45
	cmp ah,13
46
	je translate_now
47
 
48
	cmp [inputboxpressed],1
49
	jne not_print
50
 
51
	cmp ah,8
52
	jne not_backspace
53
	mov bl,[inputboxlen]
54
	cmp bl,1
55
	jb not_print
56
	dec [inputboxcurchar]
57
	dec [inputboxlen]
58
	xor ebx,ebx
59
	mov bl,[inputboxcurchar]
60
	mov byte [inputbox+ebx],0
61
	sub [xcursor],6
62
	call draw_inputbox
63
	call draw_cursor
64
	jmp still
65
 
66
	not_backspace:
67
	cmp [inputboxlen],52
68
	je not_print
69
	xor ebx,ebx
70
 
71
	mov bl,[inputboxcurchar]
72
	mov [inputbox+ebx],ah
73
 
74
	inc [inputboxcurchar]
75
	inc [inputboxlen]
76
	call draw_inputbox
77
 
78
	add [xcursor],6
79
	call draw_cursor
80
	not_print:
81
 
82
jmp still
83
 
84
button_pressed:
85
	mov eax,17
86
	int 0x40
87
	cmp ah,1
88
	je lbl_close_now
89
	cmp ah,2
90
	je inputbox_pressed
91
	cmp ah,3
92
	je translate_now
93
	cmp ah,4
94
	je change_dict
95
jmp still
96
 
97
 
98
draw_window:
99
pusha
100
	mov eax,12
101
	mov ebx,1
102
	int 0x40
103
 
104
	mov eax,0
105
	mov ebx,30*65536+400
106
	mov ecx,30*65536+170
2221 leency 107
	mov edx,0x14cccccc
108
	mov edi,win_header
1146 maximYCH 109
	int 0x40
110
 
111
 
112
	mov eax,4
113
	mov ebx,10*65536+41
114
	mov ecx,0x00000000
115
	mov edx,txtWord
116
	mov esi,txtWord_l-txtWord ; 6
117
	int 0x40
118
 
2221 leency 119
	;mov eax,4
1146 maximYCH 120
	mov ebx,10*65536+67
2221 leency 121
	;mov ecx,0x00000000
1146 maximYCH 122
	mov edx,txtVariants
123
	mov esi,txtVariants_l-txtVariants ;9
124
	int 0x40
125
 
2221 leency 126
	;mov eax,4
1146 maximYCH 127
	mov ebx,10*65536+91
2221 leency 128
	;mov ecx,0x00000000
1146 maximYCH 129
	mov edx,txtTranslate
130
	mov esi,txtTranslate_l-txtTranslate ;8
131
	int 0x40
132
 
2221 leency 133
	;mov eax,4
1146 maximYCH 134
	mov ebx,10*65536+115
2221 leency 135
	;mov ecx,0x00000000
1146 maximYCH 136
	mov edx,txtTranscript
137
	mov esi,txtTranscript_l-txtTranscript ;9
138
	int 0x40
139
 
140
	mov eax,8
141
	mov ebx,125*65536+150
142
	mov ecx,135*65536+20
143
	mov edx,3
144
	mov esi,0x00dddddd
145
	int 0x40
2221 leency 146
 
1146 maximYCH 147
	mov eax,4
148
	mov ebx,168*65536+142
149
	mov ecx,0x00000000
150
	mov edx,txtTranslatenow
151
	mov esi,txtTranslatenow_l-txtTranslatenow ;9
152
	int 0x40
153
 
154
 
155
 
156
 
157
	mov eax,8
158
	mov ebx,10*65536+50
159
	mov ecx,135*65536+20
160
	mov edx,4
161
	mov esi,0x00dddddd
162
	int 0x40
163
	mov eax,4
164
	mov ebx,14*65536+142
165
	mov ecx,0x00000000
166
	mov edx,txtChangeDict
167
	mov esi,txtChangeDict_l-txtChangeDict  ;7
168
	int 0x40
169
;-------------------------------
170
	call draw_inputbox
171
	call print_variants
172
	call print_trans_word
173
	call print_transcript
174
;--------------------------------
175
	mov eax,12
176
	mov ebx,2
177
	int 0x40
178
popa
179
ret
180
 
181
draw_inputbox:
182
	mov eax,8
183
	mov ebx,68*65536+320
184
	mov ecx,38*65536+14
185
	mov edx,2
186
	int 0x40
187
 
188
	mov eax,13
189
	mov ebx,68*65536+320
190
	mov ecx,38*65536+14
191
	mov edx,0x00ffffff
192
	int 0x40
193
	call draw_inputbox_text
194
ret
195
 
196
draw_inputbox_text:
197
	mov eax,4
198
	mov ebx,70*65536+40
199
	mov ecx,0x00000000
200
	mov edx,inputbox
201
	mov esi,52
202
	int 0x40
203
ret
204
 
205
draw_cursor:
206
	mov eax,13
207
	mov bx,[xcursor]
208
	shl ebx,16
209
	mov bx,1
210
;        mov ebx,68*65536+1
211
	mov ecx,40*65536+10
212
	mov edx,0x000000ff
213
	int 0x40
214
ret
215
; END DRAW WINDOW
216
 
217
;-------------------PROGRAM-------------------
218
 
219
lbl_close_now:
220
	call save_ini
221
	mov eax,-1
222
	int 0x40
223
 
224
inputbox_pressed:
225
	mov [inputboxpressed],1
226
jmp still
227
 
228
print_variants:
229
	mov eax,13
230
	mov ebx,68*65536+320
231
	mov ecx,65*65536+14
232
	mov edx,0x00eeeeee
233
	int 0x40
234
 
235
	mov eax,4
236
	mov ebx,70*65536+67
237
	mov ecx,0x00000000
238
	mov edx,variants
239
	mov esi,52
240
	int 0x40
241
ret
242
 
243
translate_now:
244
	mov [inputboxpressed],0
245
 
246
	mov    edi,inputbox	;определяем длину введённой строки
247
	mov    ecx,52 ;50
248
	xor    eax,eax
249
	repne  scasb
250
	sub    edi,inputbox
251
	dec    edi
252
	mov    [search_len],edi
253
	inc    [search_len]   ;------------increase
254
 
255
	cmp    [search_len],1
256
	je     nothing_in_inputbox
257
	call count_dict_size
258
 
259
	cmp [dict_size],0
260
	je still
261
 
262
	call   clear_tr_word
263
	call   clear_variants
264
	call clear_transcript
265
jmp search
266
 
267
count_dict_size:
268
pusha
269
	mov    edi,dictionary	  ;определяем длину словаря
270
	mov    ecx,0x7FFFF
271
	xor    eax,eax
272
	repne  scasb
273
	sub    edi,dictionary
274
	dec    edi
275
	mov    [dict_size],edi
276
popa
277
ret
278
 
279
nothing_in_inputbox:
280
	call clear_tr_word
281
	call clear_variants
282
	call clear_transcript
283
	cld
284
	mov esi,errNothingEntered
285
	mov edi,tr_word
286
	mov ecx,14
287
	rep movsb
288
jmp win_redraw
289
 
290
clear_inputbox:
291
    cld
292
    mov edi,inputbox
293
    mov ecx,13 ;52/4
294
    xor eax,eax
295
    rep stosd
296
    mov [inputboxcurchar],0
297
    mov [xcursor],69
298
ret
299
 
300
clear_tr_word:
301
    cld
302
    mov edi,tr_word
303
    mov ecx,13 ;52/4
304
    xor eax,eax
305
    rep stosd
306
ret
307
 
308
clear_variants:
309
    cld
310
    mov edi,variants
311
    mov ecx,13 ;52/4
312
    xor eax,eax
313
    rep stosd
314
ret
315
 
316
clear_transcript:
317
    cld
318
    mov edi,trscript_word
319
    mov ecx,13 ;52/4
320
    xor eax,eax
321
    rep stosd
322
ret
323
 
324
clear_all_in_1:
325
    cld
326
    mov edi,inputbox ; 52*4 = 208 / 4 = 52
327
    mov ecx,52
328
    xor eax,eax
329
    rep stosd
330
    mov [inputboxpressed],1
331
    mov [inputboxcurchar],0
332
    mov [xcursor],69
333
 
334
 
335
ret
336
 
337
clear_all_2:
338
	call clear_all_in_1
339
	call draw_window
340
jmp still
341
 
342
print_trans_word:
343
 
344
	mov eax,13
345
	mov ebx,68*65536+320
346
	mov ecx,89*65536+14
347
	mov edx,0x00eeeeee
348
	int 0x40
349
 
350
	mov eax,4
351
	mov ebx,70*65536+91
352
	mov ecx,0x00000000
353
	mov edx,tr_word
354
	mov esi,52
355
	int 0x40
356
ret
357
 
358
trans_not_found:
359
    cld
360
    mov esi,tr_not_found_text
361
    mov edi,tr_word
362
    mov ecx,18 ;200
363
    rep movsb
364
    call clear_transcript
365
    call clear_variants
366
    call draw_window
367
ret
368
 
369
print_transcript:
370
	mov eax,13
371
	mov ebx,68*65536+320
372
	mov ecx,113*65536+14
373
	mov edx,0x00eeeeee
374
	int 0x40
375
 
376
	mov eax,4
377
	mov ebx,70*65536+115
378
	mov ecx,0x00000000
379
	mov edx,trscript_word
380
	mov esi,52
381
	int 0x40
382
ret
383
;-----------------------------------------------------
384
; ПОИСК ПО ФАЙЛУ СПРАВОЧНИКА
385
search:
386
    xor  esi,esi
387
    mov edi,dictionary	;НАЧАЛО В ЕДИ
388
    mov ecx,[dict_size] ;РАЗМЕР В ЕСХ
389
 
390
  news:
391
    push edi
392
  news2:
393
 
394
     ; 1) LOAD BYTES
395
     mov  al,[esi+inputboxplus] ; [esi+inputbox]
396
     mov  bl,[edi]
397
 
398
     ; 2) COMPARE BYTES
399
     cmp  al,bl
400
     je   yes_char
401
 
402
     ; 3) LETTER?
403
      cmp al,'A'
404
      jb notequal
405
      cmp al,'ё'
406
      ja notequal
407
      ;----------
408
 
409
      cmp al,'z' ;122 ;z=122
410
      jbe cpLAT
411
;cpCYR
412
;---------------------TEST
413
     cmp  al,'а' ;cyr A
414
     jb   .bigletter ;if letter<128
415
       ;--------
416
	  cmp al,'р'
417
	  jae .more_175  ;if letter>175
418
	  sub  al,32
419
     jmp  compare_bytes
420
	  .more_175:
421
	  sub al,80
422
	  jmp compare_bytes
423
 
424
    .bigletter:
425
     cmp  al,'Р'
426
     jae   .more_175_2
427
     add  al,32
428
     jmp compare_bytes
429
     .more_175_2:
430
     add al,80
431
     jmp compare_bytes
432
;---------------TEST
433
 
434
;cpLAT
435
      cpLAT:
436
     ; 4) A->a OR a->A
437
     cmp  al,'a'
438
     jb   @f
439
     add  al,-32
440
     jmp  compare_bytes
441
    @@:
442
     cmp  al,'Z'
443
     ja   notequal
444
     add  al,32
445
;-----
446
    compare_bytes:
447
     cmp  al,bl
448
     jne  notequal
449
 
450
  yes_char:
451
    inc  edi
452
    inc  esi
453
    cmp  esi,[search_len]
454
    jge  sfound
455
    jmp  news2
456
 
457
  notequal:
458
    pop  edi
459
    xor  esi,esi
460
    inc  edi
461
    loop news
462
    call trans_not_found
463
    jmp  still
464
 
465
    sfound:
466
    mov [total_smesh],edi ;смещение по файлу словаря
467
 
468
;-------------------
469
;-------search for transcription
470
 
471
    mov esi,[total_smesh]
472
    cld
473
  again0:
474
    lodsb
475
    cmp al,'|'
476
    jne again0
477
 
478
    mov [starting_transcrtiontion],esi
479
 
480
    cld
481
  again00:
482
    lodsb
483
    cmp al,'|' ;13
484
    jne again00
485
    mov [ending_transcrtiontion],esi
486
    mov eax,[starting_transcrtiontion]
487
    sub [ending_transcrtiontion],eax
488
    dec [ending_transcrtiontion]
489
 
490
 
491
 
492
	cld  ;ВЫВОД СЛОВА
493
	mov esi,[starting_transcrtiontion]
494
	mov edi,trscript_word
495
	mov ecx,[ending_transcrtiontion]
496
	rep movsb
497
 
498
;-------search for translation
499
    mov esi,[starting_transcrtiontion]
500
    add esi,[ending_transcrtiontion]
501
    cld
502
  again:
503
    lodsb
504
    cmp al,'|'
505
    jne again
506
 
507
    mov [starting_kav],esi
508
 
509
    cld
510
  again2:
511
    lodsb
512
    cmp al,10 ;13
513
    jne again2
514
    mov [ending_kav],esi
515
    mov eax,[starting_kav]
516
    sub [ending_kav],eax
517
    dec [ending_kav]
518
 
519
;-----------------------------------------------
520
 
521
    cld  ;ВЫВОД СЛОВА
522
    mov esi,[starting_kav]
523
    mov edi,tr_word
524
    mov ecx,[ending_kav]
525
    rep movsb
526
 
527
;--------
528
;search backward
529
 
530
 
531
	mov esi,[total_smesh]
532
 
533
	cld
534
	again3:
535
	lodsb
536
	cmp al,'|'
537
	jne again3
538
	mov [endingword],esi
539
	dec [endingword]
540
	again4:
541
	dec esi
542
	dec esi
543
 
544
	cld
545
	lodsb
546
	cmp al,10 ;13;' '
547
	jne again4
548
	mov [startingword],esi
549
	mov eax,[startingword]
550
	sub [endingword],eax
551
 
552
 
553
	cld  ;ВЫВОД СЛОВА
554
	mov esi,[startingword]
555
	mov edi,variants
556
	mov ecx,[endingword]
557
	rep movsb
558
 
559
;-----------------------------------------------
560
 
561
 
562
 
563
 
564
 
565
    call draw_window
566
jmp still
567
 
568
 
569
;-----------------------------------------------------
570
 
571
;---clear dictionary
572
clear_dict:
573
    mov edi,dictionary
574
    mov ecx,131072 ; 0x80000 / 4
575
    xor eax,eax
576
    rep stosd
577
ret
578
 
579
;---- change dictionary
580
change_dict:
581
	opendialog draw_window,open_ok,open_err,fileinfo.path
582
open_ok:
583
	call clear_dict
584
	call clear_all_in_1
585
	call load_dict
586
jmp still
587
open_err:
588
	call load_dict.call_error
589
jmp still
590
 
591
 
592
;---- load dictionary
593
load_dict:
594
;-open                from ASCL 9
595
       mov  dword [fileinfo+8],1
596
       mov  eax,58
597
       mov  ebx,fileinfo
598
       int  0x40
599
       mov  eax,[dictionary+2]
600
       shr  eax,9
601
       inc  eax
602
       mov  dword [fileinfo+8],eax
603
       mov  eax,58
604
       mov  ebx,fileinfo
605
       int  0x40
606
;--------
607
	cmp eax,0  ;0- open ok
608
	je .return ; win_redraw
609
	cmp eax,5  ;5- open ok
610
	je .return
611
	cmp eax,6  ;6- open ok???????????
612
	je .return
613
; if we can't open the dictionary
614
	.call_error:
615
	cld
616
	mov esi,errDictNotFound
617
	mov edi,tr_word
618
	mov ecx,errDictNotFound_l-errDictNotFound ;23
619
	rep movsb
620
 
621
	call draw_window
622
 
623
	mov eax,5   ;delay
624
	mov ebx,100 ;1 sec
625
	int 0x40
626
 
627
	.return:
628
	call check_header
629
ret
630
 
631
 
632
 
633
 
634
;--- copy path to dictionary
635
copy_path:
636
	call count_dict_size ;int [dict_size] will be size of path to dictionary
637
	mov esi,dictionary
638
	mov edi,fileinfo.path ;40
639
	mov ecx,[dict_size]
640
	cld
641
	rep movsb
642
ret
643
 
644
 
645
;----------load config file
646
load_ini:
647
       cld
648
       mov esi,fileinfo_ini.inipath
649
       mov edi,fileinfo.path
650
       mov ecx,19
651
       rep movsb
652
 
653
       mov  eax,58
654
       mov  ebx,fileinfo
655
       int  0x40
656
 
657
       call copy_path
658
       mov [dict_size],0
659
       call clear_dict
660
ret
661
;----------------------------
662
 
663
clear_fileinfo_path:
664
    mov edi,fileinfo.path
665
    mov ecx,256/4
666
    xor eax,eax
667
    rep stosd
668
ret
669
 
670
;-------save config file
671
save_ini:
672
       cmp dword [dictionary],0
673
       jne .save
674
 
675
       call clear_fileinfo_path
676
 
677
       cld
678
       mov esi,default_dict_path
679
       mov edi,fileinfo.path
680
       mov ecx,14
681
       rep movsb
682
 
683
       .save:
684
       mov    edi,fileinfo.path     ;определяем длину словаря
685
       mov    ecx,256
686
       xor    eax,eax
687
       repne  scasb
688
       sub    edi,fileinfo.path
689
       dec    edi
690
       mov    [fileinfo_ini.size],edi
691
 
692
       mov  eax,58
693
       mov  ebx,fileinfo_ini
694
       int  0x40
695
 
696
ret
697
 
698
;------ check dictionary header
699
check_header:
700
 
701
	mov eax,'DICT'
702
	cmp dword [dictionary],eax
703
	je .return
704
		call clear_tr_word
705
	cld
706
	mov esi,errDictHeader
707
	mov edi,tr_word
708
	mov ecx,errDictHeader_l-errDictHeader ;23
709
	rep movsb
710
	.return:
711
ret
712
 
713
 
714
;;;;;;;;;;;;;;;;;;;;;;;;;;;
715
;;;;;;;;;;;data;;;;;;;;;;;;
716
;;;;;;;;;;;;;;;;;;;;;;;;;;;
717
 
718
 
719
 
720
win_header:
2221 leency 721
db 'Словарик', 0
1146 maximYCH 722
win_header_l:
723
 
724
tr_not_found_text:
725
db 'ПЕРЕВОД НЕ НАЙДЕН!'
726
tr_not_found_text_l:
727
 
728
txtWord:
729
db 'Слово:'
730
txtWord_l:
731
 
732
txtTranslate:
733
db 'Перевод:'
734
txtTranslate_l:
735
 
736
txtVariants:
737
db 'Варианты:'
738
txtVariants_l:
739
 
740
errDictNotFound:
741
db 'Ошибка открытия файла или открытие отменено!'
742
errDictNotFound_l:
743
 
744
txtTranslatenow:
745
db 'Перевести'
746
txtTranslatenow_l:
747
 
748
errNothingEntered:
749
db 'Введите слово!'
750
errNothingEntered_l:
751
 
752
txtTranscript:
753
db 'Транскр.:'
754
txtTranscript_l:
755
 
756
txtChangeDict:
757
db 'Словарь'
758
txtChangeDict_l:
759
 
760
errDictHeader:
761
db 'Этот файл не является словарем!'
762
errDictHeader_l:
763
 
764
xcursor dw 69
765
 
766
default_dict_path db '/RD/1/DICT.TXT'
767
 
768
fileinfo_ini:
769
.oper:
770
dd   1
771
dd   0x0
772
.size:
773
dd   256
774
dd   fileinfo.path
775
dd  os_work_mem
776
.inipath:
777
db '/rd/1/slovarik.ini',0
778
 
779
fileinfo:
780
dd   0	     ; 0 = ЧТЕНИЕ ФАЙЛА
781
dd   0x0       ; номер блока файла (512 байт, нумерация начинается с нуля)
782
dd   0x1       ; сколько блоков считывать
783
dd   dictionary  ; куда считывать
784
dd   os_work_mem ; 0x10000  ; память для работы ОС - 4096 байт
785
.path:
786
db '',0  ;'/RD/1/DICT.TXT',0
787
 
788
lblIMG_END:
789
rb 257 ;times 257 db 0 ;for path
790
 
791
 
792
starting_kav dd 0
793
ending_kav dd 0
794
starting_transcrtiontion dd 0
795
ending_transcrtiontion dd 0
796
 
797
total_smesh dd 0
798
 
799
inputboxpressed db 0
800
search_len  dd 0
801
inputboxcurchar db 0
802
inputboxlen db 0
803
 
804
inputboxplus:
805
;db ' '
806
db 10 ;for search
807
 
808
inputbox:
809
rb 52 ;times 52 db 0
810
 
811
tr_word:
812
rb 52 ;times 52 db 0
813
 
814
trscript_word:
815
rb 52 ;times 52 db 0
816
 
817
variants:
818
rb 52  ;times 52 db 0
819
 
820
startingword dd 0
821
endingword dd 0
822
 
823
 
824
dict_size dd 0
825
 
826
dictionary:
827
rb 0x80000;~524 kb for dictionary
828
;0x100000 ;1 mb for future BIG dictionary :)
829
 
830
os_work_mem:
831
rb  0x10000
832
 
833
rb 4096
834
lblMEMORY:
835
lblSTACK: