Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
31 halyavin 1
;constants
2
;for keys
3
KEY_ESC      equ 27
4
KEY_PGDN     equ 183
5
KEY_PGUP     equ 184
6
KEY_LNDN     equ 177
7
KEY_LNUP     equ 178
8
KEY_RIGHT    equ 179
9
KEY_LEFT     equ 176
10
KEY_HOME     equ 180
11
KEY_END      equ 181
12
KEY_HOMETOP  equ 251  ;Ctrl + '['
13
KEY_ENDBOTTOM equ 253 ;Ctrl + ']'
14
 
15
 use32
16
 org 0x0
17
 db 'MENUET01'  ; 8 byte id
18
 dd 0x01        ; header version
19
 dd START       ; start of code
20
 dd I_END       ; size of image
21
 dd 0x80000     ; memory for app
22
 dd 0x80000     ; esp
23
 dd 0x0 , 0x0   ; I_Param , I_Icon
24
 
25
 include 'lang.inc'
26
 include 'macros.inc'
27
 
28
 
29
START: ; start of execution
30
 
31
  mov  eax,40
32
  mov  ebx,100111b ;event mouse
33
  int  0x40
34
  mov  dword [process_info+42],540
35
  mov  dword [process_info+46],414
36
  call draw_window
37
 
38
still:
39
  mov  eax,10  ; wait here for event
40
  int  0x40
41
  dec  al      ; redraw request ?
42
  je   red
43
  dec  al      ; key in buffer ?
44
  je   key
45
  dec  al      ; button in buffer ?
46
  je   button
47
               ; mouse event received
48
 mouse:
49
  mov  eax,37
50
  mov  ebx,2
51
  int  0x40
52
  or   eax,eax
53
  jz   still
54
  cmp  [menu_opened],1
55
  jne  still
56
  mov  [menu_opened],0
57
 
58
 red:          ; redraw
59
  call redraw_window
60
  jmp  still
61
 
62
 key:          ; key
63
  mov  eax,2
64
  int  0x40
65
; test al,al
66
; jnz  still
67
  cmp  ah,KEY_ESC
68
  jz   close
69
  mov  al,[o_s_flag]
70
  and  al,8  ;set bit 3?
71
  jz   edit_keys ;not - no output to filename area
72
  cmp  ah,8  ;BACKSPACE
73
  jnz  no_backspace
74
  dec  [name_l]
75
  cmp  [name_l],0
76
  mov  edx,filename
77
  je   A1
78
  jg   @f
79
  mov  [name_l],0
80
  jmp  A1
81
 @@:
82
  add  dl,[name_l]
83
 A1:
84
  sub  [x_cursor],0x60000
85
  mov  [edx],byte 0
86
  cmp  [x_cursor],0xb0005
87
  jge  @f
88
  mov  [x_cursor],0xb0005
89
@@:
90
  call redraw_window
91
  jmp  still  ;END BACKSPACE
92
 
93
 no_backspace:
94
  cmp  ah,0x30 ;'0'
95
  jl   A2
96
  cmp  ah,0x39 ;'9'
97
  jle  bigsym
98
  cmp  ah,65 ;'A'
99
  jbe  bigsym
100
  cmp  ah,90 ;'Z'
101
  jle  bigsym
102
  cmp  ah,97 ;'a'
103
  jbe  smsym
104
  cmp  ah,122;'z'
105
  jle  smsym
106
  jmp  still
107
 A2:
108
  cmp  ah,46 ;'.'
109
  jz   bigsym
110
  cmp  ah,0x20
111
  jz   bigsym
112
  jmp  still
113
 smsym:
114
  sub  ah,32
115
 bigsym:
116
  cmp  [name_l],13 ;yes. filename length <13
117
  jl   @f
118
  sub  [o_s_flag],8 ;not - disable output to filename area
119
  mov  [x_cursor],0x680005; - set x-base & x-size
120
  jmp  _end_keys
121
 @@:
122
  mov  edx,filename  ;
123
  add  dl,[name_l]
124
  mov  [edx],ah
125
  inc  [name_l]
126
  add  [x_cursor],0x60000
127
 _end_keys:
128
  call redraw_window
129
  jmp  still
130
 edit_keys:
131
  cmp  ah,KEY_PGDN
132
  jnz  @f
133
  call PgDn
134
  jmp  still
135
 @@:
136
  cmp  ah,KEY_PGUP
137
  jnz  @f
138
  call PgUp
139
  jmp  still
140
 @@:
141
  cmp  ah,KEY_HOME ;Home
142
  jnz  @f
143
  call Home
144
  jmp  still
145
 @@:
146
  cmp  ah,KEY_END ;Home
147
  jnz  @f
148
  call _End
149
  jmp  still
150
 @@:
151
  cmp  ah,KEY_HOMETOP
152
  jnz  @f
153
  call CtrlHome
154
  jmp  still
155
 @@:
156
  cmp  ah,KEY_ENDBOTTOM
157
  jnz  @f
158
  call CtrlEnd
159
  jmp  still
160
 @@:
161
  cmp  ah,KEY_LNDN
162
  jnz  @f
163
  call LnDn
164
  jmp  still
165
 @@:
166
  cmp  ah,KEY_LNUP
167
  jnz  @f
168
  call LnUp
169
  jmp  still
170
 @@:
171
  cmp  ah,KEY_RIGHT ;Right
172
  jnz  @f
173
  call Right
174
  jmp  still
175
 @@:
176
  cmp  ah,KEY_LEFT ;Left
177
  jnz  @f
178
  call Left
179
 @@:
180
  ;редактирование строки в hex-представлении
181
  mov  esi,[current]
182
  mov  bl,[posx]
183
  add  esi,0x10000 ;0x80000
184
  cmp  ah,0x30
185
  jl   still   ;ah<'0'
186
  cmp  ah,0x39
187
  jle  A23   ;ah='0'...'9' - перевод из символов в hex
188
;проверка на коды старших hex-цифр
189
  cmp  ah,0x61 ;ah<'a'
190
  jl   A27   ;может быть вводятся большие буквы?
191
  cmp  ah,0x66 ;ah>'f'
192
  jg   still
193
  sub  ah,0x20 ;конвертируем в большие буквы
194
  jmp  A24
195
 A27:
196
  cmp  ah,0x41
197
  jl   still   ;ah<'A'
198
  cmp  ah,0x46
199
  jg   still   ;ah>'F'
200
 A24:
201
  add  ah,9
202
 A23:
203
  mov  dl,[esi];оригинальный байт
204
  and  bl,1    ;если нечет - редактируется младший полубайт, чет - старший
205
  jz   hi_half_byte
206
  ;младший полубайт
207
  and  ah,0x0f ;обнуляем старший полубайт введенной цифры
208
 ;если ah = 0x30...0x39, то все нормально
209
 ;если ah = 0x41...0x46, то на метке А24 получим
210
 ;ah = 0x4A...0x4F и тоже все нормально
211
  and  dl,0xf0 ;обнуляем младший полубайт у оригинального байта
212
  jmp  patch_byte
213
 hi_half_byte:
214
  ;старший полубайт
215
  shl  ah,4    ;одновременно сдвигаем нужное значение в старший полубайт
216
 ;и обнуляем младший
217
  and  dl,0x0f ;обнуляем старший полубайт у оригинального байта
218
 patch_byte:
219
  or   ah,dl   ;объединяем полубайты
220
  mov  [esi],ah;патчим в памяти
221
  mov  ebx,0x20100
222
  movzx ecx,ah ;для функции вывода числа
223
  ;теперь надо расчитать координаты вывода для числа
224
  ;edx = x shl 16 + y
225
  mov  edx,[x_cursor]
226
  mov  edi,[y_cursor]
227
  and  edx,0xffff0000
228
  shr  edi,0x10
229
  xor  esi,esi
230
  or   edx,edi
231
  mov  eax,47
232
  add  edx,8
233
  int  0x40
234
  call redraw_window
235
  jmp  still
236
 
237
 button:   ; button
238
  mov  eax,17 ; get id
239
  int  0x40
240
  dec  ah  ;close programm button
241
  jne  @f
242
 close:
243
  mov  eax,-1 ; close this program
244
  int  0x40
245
 @@:
246
  dec  ah
247
  jne  @f
248
  call redraw_window
249
  call menufile
250
  jmp  still
251
 @@:
252
  dec  ah  ;menu 'coding' button
253
  jne  @f
254
  call redraw_window
255
  call menucoding
256
  jmp  still
257
 @@:
258
  dec  ah  ;menu 'Help' button
259
  jne  @f
260
  call redraw_window
261
  call menuhelp
262
  jmp  still
263
 @@:
264
  ;now processed low_level menu buttons
265
  ;id m_open = 5
266
  ;id m_save = 6
267
  ;id m_exit = 7
268
  ;id m_win2dos 8
269
  ;id m_win2koi 9
270
  ;id m_win2iso 10
271
  ;id m_dos2win 11
272
  ;id m_dos2koi 12
273
  ;id m_dos2iso 13
274
  ;id m_help 14
275
  ;id m_about 15
276
  dec  ah ;open?
277
  jne  @f
278
  cmp  [o_s_flag],0  ;disable 'Open' if flag !=0
279
  jnz  no_open
280
;  call redraw_window
281
  mov  [color],0x0072b9fc
282
  call f2 ;set x_cursor & y_cursor for input filename
283
  mov  [o_s_flag],8   ;for output to filename area
284
 no_open:
285
  call redraw_window
286
  jmp  still
287
 @@:
288
  dec  ah ;save?
289
  jne  @f
290
  cmp  [o_s_flag],1  ;enable save if flag = 1
291
  jnz  no_save
292
  movzx ecx,[name_l] ;begin clear filename string
293
  mov  edi,filename
294
  xor  al,al
295
  jecxz no_clear
296
 clear:
297
  mov  [edi+ecx],al
298
  loop clear
299
  mov  [name_l],al ;set filename length = 0
300
 no_clear:  ;ebd clear
301
  call f2 ;set x_cursor & y_cursor for input filename
302
  mov  [o_s_flag],9 ;for output to filename area
303
 no_save:
304
  call redraw_window
305
  jmp  still
306
 @@:
307
  dec  ah ;exit?
308
  jne  @f
309
  jmp  close
310
 @@:
311
  dec  ah ;m_win2dos?
312
  jne  @f
313
  push dword WIN_TABLE
314
  push dword DOS_TABLE
315
  call coding
316
  call redraw_window
317
  jmp  still
318
 @@:
319
  dec  ah ;m_win2koi?
320
  jne  @f
321
  push WIN_TABLE
322
  push KOI_TABLE
323
  call coding
324
  call redraw_window
325
  jmp  still
326
 @@:
327
  dec  ah ;m_win2iso?
328
  jne  @f
329
  push WIN_TABLE
330
  push ISO_TABLE
331
  call coding
332
  call redraw_window
333
  jmp  still
334
 @@:
335
  dec  ah ;m_dos2win?
336
  jne  @f
337
  push DOS_TABLE
338
  push WIN_TABLE
339
  call coding
340
  call redraw_window
341
  jmp  still
342
 @@:
343
  dec  ah ;m_dos2koi?
344
  jne  @f
345
  push DOS_TABLE
346
  push KOI_TABLE
347
  call coding
348
  call redraw_window
349
  jmp  still
350
 @@:
351
  dec  ah ;dos2iso?
352
  jne  @f
353
  push DOS_TABLE
354
  push ISO_TABLE
355
  call coding
356
  call redraw_window
357
  jmp  still
358
 @@:
359
  dec  ah ;m_help?
360
  jne  @f
361
  ;create new thread for output help info
362
  ;parameter: address for entry_point thread
363
  push help_thread
364
  call create_process
365
  call redraw_window
366
  jmp  still
367
 @@:
368
  dec  ah ;m_about?
369
  jne  @f
370
  ;create new thread for output about info
371
  ;parameter: address for entry_point thread
372
  push about_thread
373
  call create_process
374
  call redraw_window
375
  jmp  still
376
 @@:
377
  ;button 'Go'
378
  and  [o_s_flag],1
379
  jnz  _savefile
380
  ;open file
381
  mov  eax,6
382
  mov  ebx,filename
383
  xor  ecx,ecx
384
  or   edx,-1
385
  mov  esi,0x10000
386
  int  0x40
387
  inc  [o_s_flag]
388
  mov  [sizefile],eax
389
  jmp  end_Go
390
 _savefile:
391
  ;save file
392
  mov  ebx,filename
393
  mov  ecx,0x10000
394
  mov  edx,[sizefile]
395
  xor  esi,esi
396
  dec  edx
397
  mov  eax,33
398
  int  0x40
399
 end_Go:
400
  call CtrlHome
401
  jmp  still
402
 
403
Right:
404
  pushad
405
  mov  al,[posx]
406
  inc  al
407
  cmp  al,0x20
408
  jl   @f
409
  mov  [posx],0
410
  mov  [x_cursor],0x680005
411
  mov  [text_cursor],0x01200000
412
  sub  [current],0xf ;because [current] add 0x10 in LnDn
413
  call LnDn
414
  popad
415
  ret
416
 @@:
417
  mov  [posx],al
418
  and  al,1
419
  jnz  @f ;not increment [current]
420
  ;increment
421
  add  [x_cursor],0xa0000
422
  sub  [text_cursor],0x40000
423
  inc  [current]
424
  jmp  end_r
425
 @@:
426
  add  [x_cursor],0x60000
427
  sub  [text_cursor],0x60000
428
 end_r:
429
  call redraw_window
430
  popad
431
  ret
432
 
433
Left:
434
  pushad
435
  mov  al,[posx]
436
  dec  al
437
  jge  @f
438
  mov  [posx],0x1f
439
  mov  [x_cursor],0x015e0005
440
  mov  [text_cursor],0x00840000
441
  add  [current],0x0f
442
  call LnUp
443
  popad
444
  ret
445
 @@:
446
  mov  [posx],al
447
  and  al,1
448
  jnz @f ;decrement [current]
449
  ;not decrement
450
  sub  [x_cursor],0x60000
451
  add  [text_cursor],0x60000
452
  jmp  end_l
453
 @@:
454
  cmp  [current],0
455
  jle  end_l
456
  sub  [x_cursor],0xa0000
457
  add  [text_cursor],0x40000
458
  dec  [current]
459
 end_l:
460
  call redraw_window
461
  popad
462
  ret
463
 
464
LnDn:
465
  pushad
466
  add  [current],0x10
467
  movzx ecx,[lines]
468
  cmp  cl,[posy]
469
  jl   @f ;when counter strings >= number strings in window
470
  add  [y_cursor],0xa0000
471
  inc  [posy]
472
  call redraw_window
473
  popad
474
  ret
475
 @@:
476
  mov  eax,0x10
477
  xor  edx,edx
478
  imul ecx
479
  sub  eax,0x10
480
  sub  [end_str],eax
481
;  mov  eax,[sizefile]
482
;  add  eax,0x80000
483
;  cmp  eax,[end_str]
484
;  jge  @f
485
;  mov  [end_str],eax
486
; @@:
487
  call draw_window
488
  popad
489
  ret
490
 
491
LnUp:
492
  pushad
493
  sub  [current],0x10
494
  cmp  [current],0
495
  jge  @f
496
  mov  [current],0
497
 @@:
498
  cmp  [posy],3
499
  jle @f ;when counter strings < number top string
500
  sub  [y_cursor],0xa0000
501
  dec  [posy]
502
  call redraw_window
503
  popad
504
  ret
505
 @@:
506
;  movzx ecx,[lines]
507
;  mov  eax,0x10
508
;  xor  edx,edx
509
;  imul ecx
510
;  add  eax,0x10
511
  sub  [end_str],0x10
512
  cmp  [end_str],0x10000
513
  jge  @f
514
  mov  [end_str],0x10000
515
 @@:
516
  call redraw_window
517
  popad
518
  ret
519
 
520
CtrlEnd:
521
  pushad
522
  popad
523
  ret
524
 
525
CtrlHome:
526
  pushad
527
  mov  [x_cursor],0x00680005   ;устанавливаются значения, как при открытии
528
  mov  [y_cursor],0x00280008
529
  mov  [text_cursor],0x01200000
530
  mov  [posx],0
531
  mov  [posy],3
532
  call b_in_screen
533
  mov  [end_str],0x10000
534
  mov  [current],0
535
  call redraw_window
536
  popad
537
  ret
538
 
539
_End:
540
  pushad
541
  mov  [x_cursor],0x015e0005
542
  mov  [posx],0x1f
543
  mov  [text_cursor],0x00840000
544
  or   [current],0xf
545
  call b_in_screen
546
  call redraw_window
547
  popad
548
  ret
549
 
550
Home:
551
  pushad
552
  mov  [x_cursor],0x00680005 ;устанавливаются значения для начала строки
553
  mov  [posx],0
554
  mov  [text_cursor],0x01200000
555
  and  [current],0xfffffff0
556
  call b_in_screen
557
  call redraw_window
558
  popad
559
  ret
560
 
561
PgDn:
562
  pushad
563
  xor  edx,edx
564
  movzx ecx,[lines]
565
  mov  eax,0x10
566
  imul ecx
567
  add  [current],eax
568
  add  [end_str],eax
569
  call redraw_window
570
  popad
571
  ret
572
 
573
PgUp:
574
  pushad
575
  xor  edx,edx
576
  movzx ecx,[lines]
577
  mov  eax,0x10
578
  imul ecx
579
  sub  [current],eax
580
  cmp  [current],0
581
  jge  @f
582
  mov  [current],0
583
 @@:
584
  sub  [end_str],eax
585
  cmp  [end_str],0x10000
586
  jge  @f
587
;  call CtrlHome
588
  mov  [end_str],0x10000
589
 @@:
590
  call redraw_window
591
  popad
592
  ret
593
 
594
b_in_screen:
595
  pushad
596
  call get_process_info
597
  mov  eax,[process_info+0x2e]
598
  mov  ebx,0x0a
599
  sub  eax,0x3c
600
  cmp  eax,0x10   ;now
601
  jg   @f   ;now
602
  mov  [lines],0  ;now
603
  jmp  C1   ;now
604
 @@:
605
  xor  edx,edx
606
  div  ebx
607
  mov  [lines],al
608
 C1:
609
  popad
610
  ret
611
 
612
 
613
 
614
output_screen:
615
  pushad
616
  movzx ecx,[lines]
617
  jecxz no_out ;now
618
  cmp  [rflag],1
619
  jz   _redraw
620
  mov  eax,[end_str]
621
  sub  eax,0x80001
622
  cmp  eax,[sizefile]
623
  jl   @f
624
 _redraw:
625
  xor  edx,edx
626
  mov  eax,0x10
627
  imul ecx
628
  sub  [end_str],eax
629
  cmp  [end_str],0x10000
630
  jge  A3
631
  mov  [end_str],0x10000
632
 A3:
633
  mov  [rflag],0
634
 @@:
635
  mov  eax,0x28
636
 @@:
637
  push ecx
638
  push eax
639
  call form_str
640
  mov  ebx,0x01880000
641
  add  ebx,eax
642
  mov  ecx,0x00ffffff
643
  add  eax,10
644
  mov  edx,[end_str]
645
  push eax
646
  sub  edx,0x10
647
  mov  esi,0x10
648
  mov  eax,4
649
  int  0x40
650
  pop  eax
651
  pop  ecx
652
  loop @b
653
 no_out:
654
  popad
655
  ret
656
 
657
 
658
 
659
form_str:
660
  pushad
661
  mov  ebp,[end_str]  ;последний выведенный байт
662
  xor  edi,edi ;счетчик байт <= 16
663
  ;вывести адрес
664
  mov  ecx,ebp
665
  mov  ebx,0x80100  ;8 цифр, 16-ричные, число в ecx
666
  sub  ecx,0x10000  ;нормализация адреса
667
  mov  edx,0x80000  ;начало по Х
668
  add  edx,[esp+0x24]  ;начало по У
669
  mov  esi,0x00ffffff ;цвет
670
  mov  eax,47 ;вывести число
671
  int  0x40
672
  add  edx,0x600000   ;0x40 - 8chars + 0x20 - space
673
  mov  ebx,0x20100    ;2 цифры, 16-ричные, число в ecx
674
 @@:
675
  mov  ecx,[ebp+edi]   ;число в ecx
676
  inc  edi
677
  and  ecx,0xff
678
  cmp  edi,0x11
679
  jz   endstr
680
  int  0x40
681
  add  edx,0x100000
682
  jmp  @b
683
 endstr:
684
  dec  edi
685
  add  ebp,edi
686
  mov  [end_str],ebp
687
  popad
688
  ret  4
689
 
690
 
691
 
692
draw_cursor:
693
  pushad
694
  mov  ebx,[x_cursor]
695
  mov  ecx,[esp+0x24]
696
  mov  edx,[color]
697
  mov  eax,13
698
  int  0x40
699
  movzx edi,[o_s_flag]
700
  and  edi,8
701
  jnz  @f
702
  add  ebx,[text_cursor]
703
  int  0x40
704
 @@:
705
  popad
706
  ret  4
707
 
708
f2:
709
  mov  eax,[process_info+46]
710
  mov  [x_cursor],0xb0005
711
  sub  eax,0x11
712
;  mov  [text_cursor],-1
713
  shl  eax,0x10
714
 
715
  mov  [y_filename_area],eax
716
  ret
717
 
718
menufile:
719
  mov  [menu_opened],1
720
  mov  ebx,[xf_menu];x-base+x_size for hi-level menu button
721
  mov  edx,5;first id button for this group
722
  mov  edi,3;counter buttons
723
  call f1
724
  ;output text for menu
725
  shr  ecx,0x10  ;y-base button
726
  and  ebx,0xffff0000
727
  add  ecx,0x6000f ;for y-base text
728
  mov  esi,4 ;length text
729
  add  ebx,ecx ;full base text
730
  mov  edx,m_open
731
  mov  ecx,[sc.work_button_text]
732
  or   ecx,0x10000000
733
  sub  eax,4
734
  int  0x40
735
  add  ebx,0x0c ;next full base text
736
  add  edx,4 ;next string
737
  int  0x40
738
  add  ebx,0x0c
739
  add  edx,4
740
  int  0x40
741
  ret
742
 
743
menucoding:
744
  mov  [menu_opened],1
745
  mov  ebx,[xe_menu]
746
  mov  edx,8 ;first id
747
  mov  edi,6 ;counter
748
  add  ebx,0x10 ;add width buttons
749
  push edi
750
  call f1
751
  pop  edi
752
  shr  ecx,0x10
753
  and  ebx,0xffff0000
754
  add  ecx,0x8000f
755
  mov  esi,8 ;length text
756
  add  ebx,ecx
757
  mov  edx,m_win2dos
758
  mov  ecx,[sc.work_button_text]
759
  or   ecx,0x10000000
760
  sub  eax,4
761
 @@:
762
  int  0x40
763
  add  ebx,0x0c
764
  add  edx,8 ;next string
765
  dec  edi
766
  jnz  @b
767
  ret
768
 
769
menuhelp:
770
  mov  [menu_opened],1
771
  mov  ebx,[xh_menu]
772
  mov  edx,14 ;first id
773
  add  ebx,6 ;add width buttons
774
  mov  edi,2 ;counter
775
  call f1
776
  shr  ecx,0x10
777
  and  ebx,0xffff0000
778
  add  ecx,0x8000f
779
  mov  esi,4 ;length text
780
  add  ebx,ecx
781
  mov  edx,m_help
782
  mov  ecx,[sc.work_button_text]
783
  or   ecx,0x10000000
784
  sub  eax,4
785
  int  0x40
786
  add  ebx,0x0c
787
  inc  esi ;add lebgth output text
788
  add  edx,4
789
  int  0x40
790
  ret
791
 
792
f1:;uses for drawing low-level menu buttons
793
  ;counter buttons get into
794
  ;menufile,menucoding,menuhelp funcs.
795
  mov  ecx,[y_menu]         ;y-base+y_size for hi-level menu button
796
  mov  esi,[sc.work_button] ;color buttons
797
  mov  eax,8
798
  push ecx                  ;for output text
799
 @@:
800
  add  ecx,0xc0000
801
  int  0x40
802
  inc  edx ;id
803
  dec  edi ;counter
804
  jnz  @b
805
  pop  ecx ;for output text
806
  ret
807
 
808
redraw_window:
809
  call get_process_info
810
  mov  [rflag],1
811
  call draw_window
812
  ret
813
 
814
;this is debug func
815
debug:
816
  pushad
817
  mov  ecx,[esp+0x24]
818
  mov  ebx,0x80100
819
  mov  edx,0x10000a0
820
  mov  eax,47
821
  mov  esi,0x00ffffff
822
  int  0x40
823
  popad
824
  ret  4
825
 
826
;   *********************************************
827
;   *******  WINDOW DEFINITIONS AND DRAW ********
828
;   *********************************************
829
 
830
draw_window:
831
  pushad
832
  mov  eax,48
833
  mov  ebx,3
834
  mov  ecx,sc
835
  mov  edx,sizeof.system_colors
836
  int  0x40
837
 
838
  mov  eax,12                 ; function 12:tell os about windowdraw
839
  mov  ebx,1                  ; 1, start of draw
840
  int  0x40
841
     ; DRAW WINDOW
842
  mov  eax,0                  ; function 0 : define and draw window
843
                              ; [x start] *65536 + [x size]
844
  mov  ebx,[process_info+42]
845
                              ; [y start] *65536 + [y size]
846
  mov  ecx,[process_info+46]
847
  mov  edx,0x03000000         ; color of work area RRGGBB,8->color gl
848
  int  0x40
849
     ; WINDOW LABEL
850
  mov  eax,4                  ; function 4 : write text to window
851
  mov  ebx,8*65536+8          ; [x start] *65536 + [y start]
852
  mov  ecx,[sc.grab_text]
853
  or   ecx,0x10000000         ; font 1 & color ( 0xF0RRGGBB )
854
  mov  edx,labelt             ; pointer to text beginning
855
  mov  esi,labellen-labelt    ; text length
856
  int  0x40
857
    ;check for only header window output
858
  cmp  dword [process_info+46],25
859
  jle  minimaze_view
860
 
861
     ;MENU AREA
862
  mov  eax,[process_info+42] ;x-size window
863
  mov  ecx,[process_info+46] ;y-size window
864
  push ecx ;for using done
865
  mov  ebx,0x40000
866
  sub  eax,8
867
  mov  edi,ecx
868
  add  ebx,eax ;x-base + x-size
869
  sub  edi,22 ;temporary value for menu area
870
  push ebx ;for drawing buttons area
871
  sub  ecx,edi ;y-base menu area
872
  mov  edx,[sc.work_graph]
873
  shl  ecx,0x10
874
  mov  eax,13
875
  add  ecx,0x10
876
  int  0x40
877
     ;MENU BUTTONS
878
  ;now in hi-half ecx register begin Y-coord. menu area
879
  ;in hi-half ebx begin X-coord.
880
  ;menu 'File'
881
  mov  esi,edx ;color
882
  and  ecx,0xffff0000
883
  and  ebx,0xffff0000
884
  add  ecx,0x1000c
885
  add  ebx,0x20028   ;40x12
886
  mov  edx,2 ;menu 'File' id = 2
887
  mov  [y_menu],ecx ;for low-level menus func.
888
  mov  [xf_menu],ebx;for low-level menus func.
889
  mov  eax,8
890
  push ebx ;for output buttons texts
891
  int  0x40
892
  ;registers is't change
893
  ;menu 'Coding'
894
  add  ebx,0x290018 ;80x12
895
  inc  edx ;menu 'coding' id = 3
896
  mov  [xe_menu],ebx;for low-level menus func.
897
  int  0x40
898
  ;menu 'Help'
899
  add  ebx,0x40ffe8 ;+0x280000 - 0x28, 40x12
900
  inc  edx ;menu 'Help' id = 4
901
  mov  [xh_menu],ebx;for low-level menus func.
902
  int  0x40
903
     ;MENU BUTTONS TEXTS
904
  ;'File'
905
  pop  ebx
906
  shr  ecx,0x10
907
  and  ebx,0xffff0000
908
  add  ecx,3
909
  mov  eax,4                     ; function 4 : write text to window
910
  add  ebx,0x80000
911
  mov  edx,f_menu
912
  add  ebx,ecx                   ; [x start] *65536 + [y start]
913
  mov  esi,4
914
  mov  ecx,[sc.work_button_text]
915
  or   ecx,0x10000000            ; font 1 & color ( 0xF0RRGGBB )
916
  push esi                       ;for 'Help' menu text
917
  int  0x40
918
  ;'coding'
919
  ;registers is't change
920
  add  ebx,0x2d0000
921
  ;mov  esi,6
922
  add  esi,2
923
;  mov  edx,e_menu
924
  add  edx,4
925
  int  0x40
926
  ;'Help'
927
  add  ebx,0x3b0000
928
;   mov  esi,4
929
  pop  esi
930
;  mov  edx,h_menu
931
  add  edx,6
932
  int  0x40
933
 ;LOW_LEVEL MENU
934
  ;for every hi-level menu exists one procedure
935
  ;in begin programm they are not calls,
936
  ;but when user click on one item hi-level menu
937
  ;or press hot keys, call one func. and after
938
  ;end work this func. she is redraw window -
939
  ;low-level menu is hide. Functions:
940
  ;menufile,menucoding,menuhelp.
941
  ;Thay uses global virables, top-left corner every
942
  ;hi-level menu buttons: [xf_menu],[xe_menu],[xh_menu],[y_menu]
943
 
944
     ;DRAW BUTTONS AREA
945
  pop  ebx ;for push ebx into processed menu area: x-bzse + x-size
946
;  mov  ecx,[process_info+46]
947
  pop  ecx
948
  push ecx
949
  sub  ecx,24
950
  mov  edx,[sc.work_graph]
951
  shl  ecx,16              ;y start
952
  mov  eax,13
953
  add  ecx,20
954
  int  0x40
955
 
956
;filename input area
957
;  mov  ecx,[process_info+46]
958
  pop  ecx
959
  push ecx ;for info strings
960
  mov  ebx,0x0008005a
961
  sub  ecx,21
962
  xor  edx,edx
963
  shl  ecx,16
964
  mov  [y_filename_area],ecx
965
  dec  edx
966
  add  ecx,16
967
  mov  eax,13
968
  push ecx ;for button 'Go'
969
  int  0x40
970
 
971
;button 'Go', press in case open/save if filename input complete
972
  ;button size = 24x16
973
  mov  eax,8
974
  pop  ecx ;y-base+y-size
975
  mov  ebx,0x00680018;x-base+x-size
976
  dec  ecx
977
  mov  edx,0xff ;id
978
  mov  esi,[sc.work_button]
979
  int  0x40
980
  shr  ecx,0x10
981
  and  ebx,0xffff0000
982
  add  ecx,0x50004
983
  mov  edx,b_go
984
  add  ebx,ecx
985
  mov  esi,2
986
  mov  ecx,[sc.work_button_text]
987
  or   ecx,0x10000000
988
  sub  eax,4
989
  int  0x40
990
 
991
;where output cursor?
992
  mov  al,[o_s_flag]
993
  and  al,8
994
  je   @f
995
  mov  ecx,[y_filename_area]
996
  add  ecx,0x40008
997
  jmp  cursor
998
 @@:  ;o_s_flag<0 - not output cursor into filename area
999
  mov  ecx,[y_cursor]
1000
 cursor:
1001
  push ecx
1002
  call draw_cursor
1003
 
1004
  mov  eax,[y_filename_area]
1005
  mov  ebx,0xa0000
1006
  mov  edx,filename
1007
  shr  eax,0x10
1008
  and  ebx,0xffff0000
1009
  add  eax,4
1010
  xor  ecx,ecx
1011
  add  ebx,eax
1012
  movzx esi,[name_l]
1013
  mov  eax,4
1014
  int  0x40
1015
 
1016
;info strings
1017
     ; sizefile text
1018
;    mov  eax,[process_info+46]
1019
  pop  eax
1020
  mov  ebx,0x00840000
1021
  sub  eax,18
1022
  xor  ecx,ecx
1023
  add  ebx,eax
1024
  mov  edx,sizestr   ; pointer to text beginning
1025
  mov  eax,4
1026
  mov  esi,5
1027
  int  0x40
1028
  add  ebx,0x00530000
1029
  inc  esi
1030
;    mov  edx,offst
1031
  add  edx,5
1032
  inc  esi
1033
  int  0x40
1034
    ;sizefile
1035
  mov  ecx,[sizefile]
1036
  mov  edx,ebx
1037
  xor  esi,esi
1038
  sub  edx,0x00350000
1039
  mov  eax,47
1040
  mov  ebx,0x80100
1041
  int  0x40
1042
  mov  ecx,[current]
1043
  add  edx,0x005f0000
1044
  int  0x40
1045
 
1046
  push [text_cursor] ;это позиция курсора в текстовой строке
1047
  call draw_cursor
1048
  mov  ecx,[sizefile]
1049
  jecxz minimaze_view
1050
  call output_screen
1051
 
1052
 minimaze_view:
1053
  mov  eax,12  ; function 12:tell os about windowdraw
1054
  mov  ebx,2 ; 2, end of draw
1055
  int  0x40
1056
  popad
1057
  ret
1058
 
1059
 
1060
 
1061
 
1062
 
1063
get_process_info:
1064
  pushad
1065
  mov  eax,9
1066
  mov  ebx,process_info
1067
  xor  ecx,ecx
1068
  dec  ecx
1069
  int  0x40
1070
  popad
1071
  ret
1072
 
1073
coding:
1074
  pushad
1075
  mov  ebp,0x10000 ;0x80000
1076
  mov  edi,[esp+0x28] ;source table
1077
  mov  esi,[esp+0x24] ;destination table
1078
  xor  ecx,ecx ;index in file
1079
 new_char:
1080
  xor  ebx,ebx ;index in tables
1081
 not_c:
1082
  mov  ah,[ebp+ecx] ;load char
1083
  cmp  ah,[edi+ebx] ;
1084
  jz   @f
1085
  inc  ebx
1086
  cmp  ebx,0x40
1087
  jge  end_table
1088
  jmp  not_c
1089
 @@:
1090
  mov  al,[esi+ebx]
1091
  inc  ebx
1092
  mov  [ebp+ecx],al
1093
 end_table:
1094
  inc  ecx
1095
  cmp  ecx,[sizefile]
1096
  jle  new_char
1097
  popad
1098
  ret  8
1099
 
1100
create_process:
1101
  pushad
1102
  mov  eax,51
1103
  xor  ebx,ebx
1104
  mov  ecx,[esp+0x24]
1105
  inc  ebx
1106
  mov  edx,0x7E000 ;0x1000
1107
  int  0x40
1108
  popad
1109
  ret  4
1110
 
1111
help_thread:
1112
  call help_window
1113
 help_still:
1114
  mov  eax,10
1115
  int  0x40
1116
  dec  eax
1117
  jz   help_red
1118
  dec  eax
1119
  jz   help_key
1120
  dec  eax
1121
  jz   help_button
1122
  jmp  help_still
1123
 help_red:
1124
  call help_window
1125
  jmp  help_still
1126
 help_key:
1127
  inc  eax
1128
  inc  eax
1129
  int  0x40
1130
  jmp  help_still
1131
 help_button:
1132
  mov  eax,17
1133
  int  0x40
1134
  dec  ah
1135
  jne  help_still
1136
  shr  eax,8
1137
  dec  eax
1138
  int  0x40
1139
 
1140
help_window:
1141
  pushad
1142
  mov  eax,12  ; function 12:tell os about windowdraw
1143
  mov  ebx,1 ; 1, start of draw
1144
  int  0x40
1145
     ; DRAW WINDOW
1146
  mov  eax,0 ; function 0 : define and draw window
1147
  mov  ebx,0x500140 ; [x start] *65536 + [x size]
1148
  mov  ecx,0x700110 ; [y start] *65536 + [y size]
1149
  mov  edx,0x03000000 ; color of work area RRGGBB,8->color gl
1150
  int  0x40
1151
     ; WINDOW LABEL
1152
  mov  eax,4 ; function 4 : write text to window
1153
  mov  ebx,8*65536+8 ; [x start] *65536 + [y start]
1154
  mov  ecx,0x10ffffff ; font 1 & color ( 0xF0RRGGBB )
1155
  mov  edx,help_label ; pointer to text beginning
1156
  mov  esi,14 ; text length
1157
  int  0x40
1158
     ; HELP TEXT
1159
  add  edx,14 ;help_text addr.
1160
  add  esi,37 ; = 51 - length 1 line
1161
  mov  ecx,0x00ffffff
131 diamond 1162
  mov  edi,(help_end-help_text)/51
31 halyavin 1163
 @@:
1164
  add  ebx,0x10
1165
  int  0x40
1166
  add  edx,51
1167
  dec  edi
1168
  jnz  @b
1169
 
1170
 
1171
  mov  eax,12  ; function 12:tell os about windowdraw
1172
  mov  ebx,2 ; 2, end of draw
1173
  int  0x40
1174
  popad
1175
  ret
1176
 
1177
about_thread:
1178
  call about_window
1179
 about_still:
1180
  mov  eax,10
1181
  int  0x40
1182
  dec  eax
1183
  jz   about_red
1184
  dec  eax
1185
  jz   about_key
1186
  dec  eax
1187
  jz   about_button
1188
  jmp  about_still
1189
 about_red:
1190
  call about_window
1191
  jmp  about_still
1192
 about_key:
1193
  inc  eax
1194
  inc  eax
1195
  int  0x40
1196
  jmp  about_still
1197
 about_button:
1198
  mov  eax,17
1199
  int  0x40
1200
  dec  ah
1201
  jne  about_still
1202
  shr  eax,8
1203
  dec  eax
1204
  int  0x40
1205
 
1206
about_window:
1207
  pushad
1208
  mov  eax,12  ; function 12:tell os about windowdraw
1209
  mov  ebx,1 ; 1, start of draw
1210
  int  0x40
1211
     ; DRAW WINDOW
1212
  mov  eax,0           ; function 0 : define and draw window
1213
  mov  ebx,0x500140    ; [x start] *65536 + [x size]
1214
  mov  ecx,0x700110    ; [y start] *65536 + [y size]
1215
  mov  edx,0x03000000  ; color of work area RRGGBB,8->color gl
1216
  int  0x40
1217
     ; WINDOW LABEL
1218
  mov  eax,4           ; function 4 : write text to window
1219
  mov  ebx,8*65536+8   ; [x start] *65536 + [y start]
1220
  mov  ecx,[sc.work_button_text]
1221
  or   ecx,0x10000000  ; font 1 & color ( 0xF0RRGGBB )
1222
  mov  edx,about_label ; pointer to text beginning
1223
  mov  esi,17          ; text length
1224
  int  0x40
1225
     ; ABOUT TEXT
1226
  add  edx,17 ;about_text addr.
1227
  add  esi,34 ; = 51 - length 1 line
1228
  mov  ecx,0x00ddeeff
1229
  mov  edi,15
1230
 @@:
1231
  add  ebx,0x10
1232
  int  0x40
1233
  add  edx,51
1234
  dec  edi
1235
  jnz  @b
1236
 
1237
  mov  eax,12  ; function 12:tell os about windowdraw
1238
  mov  ebx,2 ; 2, end of draw
1239
  int  0x40
1240
  popad
1241
  ret
1242
 
1243
; DATA AREA
1244
sizefile dd 0
1245
current  dd 0 ;current offset relative begin file. Uses as offset for patch.
1246
;Coordinates left hi-level menu buttons
1247
;Uses into low-level menu output.
1248
xf_menu  dd 0
1249
xe_menu  dd 0
1250
xh_menu  dd 0
1251
y_menu dd 0 ;top coord. menu
1252
y_filename_area dd 0 ;top coord. filename input area
1253
color dd 0
1254
y_cursor dd 0x280008 ;y coord. shl 16 + y size for cursor
1255
x_cursor dd 0x680005 ;x coord. shl 16 + x size for cursor
1256
name_l db 0 ;counter chars into filename
1257
o_s_flag db 0 ;
1258
rflag dd 0;
1259
posx db 0
1260
posy db 3
1261
lines db 0
1262
end_str dd 0x10000 ;addr. first byte for output
1263
text_cursor dd 0x01200000
1264
 
1265
filename: rb 13
1266
 
1267
b_go: db 'Go'
1268
 
1269
sizestr: db 'SIZE:'
1270
 
1271
offst: db 'OFFSET:'
1272
 
1273
labelt: db   'HeEd'
1274
labellen:
1275
 
1276
;text for hi-level menu buttons
1277
f_menu: db 'File'
1278
e_menu: db 'Coding'
1279
h_menu: db 'Help'
1280
;text for low-level menu buttons
1281
;menu File
1282
m_open: db 'Open'
1283
m_save: db 'Save'
1284
m_exit: db 'Exit'
1285
;menu coding
1286
m_win2dos: db 'Win->Dos'
1287
m_win2koi: db 'Win->Koi'
1288
m_win2iso: db 'Win->Iso'
1289
m_dos2win: db 'Dos->Win'
1290
m_dos2koi: db 'Dos->Koi'
1291
m_dos2iso: db 'Dos->Iso'
1292
;menu Help
1293
m_help: db 'Help'
1294
m_about: db 'About'
1295
;tables for coding
1296
WIN_TABLE:
1297
db 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9
1298
db 0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3
1299
db 0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD
1300
db 0xDE,0xDF,0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7
1301
db 0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1
1302
db 0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB
1303
db 0xFC,0xFD,0xFE,0xFF
1304
DOS_TABLE:
1305
db 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89
1306
db 0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93
1307
db 0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D
1308
db 0x9E,0x9F,0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7
1309
db 0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xE0,0xE1
1310
db 0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB
1311
db 0xEC,0xED,0xEE,0xEF
1312
KOI_TABLE:
1313
db 0xE1,0xE2,0xF7,0xE7,0xE4,0xE5,0xF6,0xFA,0xE9,0xEA
1314
db 0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF2,0xF3,0xF4,0xF5
1315
db 0xE6,0xE8,0xE3,0xFE,0xFB,0xFD,0xFF,0xF9,0xF8,0xFC
1316
db 0xE0,0xF1,0xC1,0xC2,0xD7,0xC7,0xC4,0xC5,0xD6,0xDA
1317
db 0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD2,0xD3
1318
db 0xD4,0xD5,0xC6,0xC8,0xC3,0xDE,0xDB,0xDD,0xDF,0xD9
1319
db 0xD8,0xDC,0xC0,0xD1
1320
ISO_TABLE:
1321
db 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9
1322
db 0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,0xC0,0xC1,0xC2,0xC3
1323
db 0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD
1324
db 0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7
1325
db 0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0,0xE1
1326
db 0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB
1327
db 0xEC,0xED,0xEE,0xEF
1328
 
1329
;text for help_window
1330
help_label: db 'Help for HeEd.'
1331
help_text:
131 diamond 1332
if lang eq ru
31 halyavin 1333
 db '1.HeEd в состоянии открыть файл только один раз и  '
1334
 db '  нужное число раз сохранить его.                  '
1335
 db '2.При открытии файла без расширения надо это расши-'
1336
 db '  ширение все равно указывать как три пробела после'
1337
 db '  точки.                                           '
1338
 db '3.Само открытие файла происходит при нажатии кнопки'
1339
 db '  "Go".                                            '
1340
 db '4.Создание новых файлов в меню не предусмотрено, но'
1341
 db '  можно же редактировать...                        '
1342
 db '5.В файл записывается только количество байт, кото-'
1343
 db '  рое было размером файла до открытия.             '
1344
 db '6.При нажатии "Go" с пустым полем имени файла выво-'
1345
 db '  дится память с адреса 0х80000, но размер файла   '
1346
 db '  равен 0xFFFFFFFF.                                '
1347
 db '               (см. инфо "About")                  '
131 diamond 1348
else
1349
 db '1.HeEd can once open file and many times save it.  '
1350
 db '2.To open file without extension it is required to '
1351
 db '  specify anyway as three spaces after a dot.      '
1352
 db '3.File is opened when the button "Go" is pressed.  '
1353
 db '4.Creation of new files in the menu is not provided'
1354
 db '  but you can edit...                              '
1355
 db '5.Only number of bytes which was file size when    '
1356
 db '  opening is written to file.                      '
1357
 db '6.If you press "Go" with empty filename field,     '
1358
 db '  memory starting from address 0x80000 is output,  '
1359
 db '  but file size equals to 0xFFFFFFFF.              '
1360
 db '               (see info "About")                  '
1361
end if
31 halyavin 1362
help_end:
1363
;text for about_window
1364
about_label: db 'About this funny.'
1365
about_text:
131 diamond 1366
if lang eq ru
31 halyavin 1367
 db 'Некоторая информация для тех, кто захочет дописать '
131 diamond 1368
 db 'сюда что-то свое: код практически не оптимизирован,'
31 halyavin 1369
 db 'так что разобраться будет не так уж сложно. Строки '
1370
 db 'для кнопок меню должны идти прямо друг за другом,  '
1371
 db 'т. к. я при выводе использую не mov esi,размер и   '
1372
 db 'mov  edx,адрес а просто прибавляю смещения. Что ка-'
1373
 db 'сается кодировок и размеров файла для сохранения,  '
1374
 db 'то остается только добавить кнопки меню с текстом  '
1375
 db '(при добавлении надо учитывать, что ID кнопки опоз-'
1376
 db 'наются dec ah, а не как cmp ah,ID). Если все же бу-'
1377
 db 'дет неприятно разбираться, то можете написать и    '
1378
 db 'спросить. Эта программа была написана в ходе разбо-'
1379
 db 'рок с GUI MeOS и поэтому не претендует на что-то   '
1380
 db 'большее, чем пример. Просто надоела эта тема, а вы-'
1381
 db 'кинуть жалко.            mailto:babalbes@yandex.ru '
131 diamond 1382
else
1383
 db 'Some information for those who want add to this    '
1384
 db 'something their own: the code is practically not   '
1385
 db 'optimized, so investigation is not complicated.    '
1386
 db 'Strings for menu buttons must rank after each other'
1387
 db 'as I use not mov esi,size and mov edx,address when '
1388
 db 'output but simply add offsets. For encodins and    '
1389
 db 'file sizes for save, it remains only add buttons   '
1390
 db 'with text in menu (at addition one should take into'
1391
 db 'account that buttons ID are recognized as dec ah   '
1392
 db 'rather than cmp ah,ID). Nevertheless if study is   '
1393
 db 'unpleasant, you can write and ask. This program has'
1394
 db 'been written in course of study GUI MeOS and does  '
1395
 db 'not therefore pretend on some more than example.   '
1396
 db 'Just this theme bothers, but I regret to delete.   '
1397
 db '                         mailto:babalbes@yandex.ru '
1398
end if
31 halyavin 1399
about_end:
1400
 
1401
I_END:
1402
 
1403
sc system_colors
1404
 
1405
process_info:
1406
  rb 1024
1407
menu_opened db ?
1408
m_text: