Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
31 halyavin 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;
3
;    TERMINAL
331 heavyiron 4
 
31 halyavin 5
use32
331 heavyiron 6
 org	0x0
7
 db	'MENUET01'    ; header
8
 dd	0x01	      ; header version
9
 dd	START	      ; entry point
10
 dd	I_END	      ; image size
11
 dd	I_END+0x10000 ; required memory
12
 dd	I_END+0x10000 ; esp
13
 dd	0x0 , 0x0     ; I_Param , I_Path
31 halyavin 14
 
15
include 'lang.inc'
485 heavyiron 16
include '..\..\..\macros.inc'
31 halyavin 17
 
18
 
331 heavyiron 19
START:				; start of execution
31 halyavin 20
 
21
    call draw_window
22
 
23
    call set_variables
24
 
25
still:
26
 
331 heavyiron 27
    mov  eax,23 		; wait here for event
31 halyavin 28
    mov  ebx,20
485 heavyiron 29
    mcall
31 halyavin 30
 
331 heavyiron 31
    cmp  eax,1			; redraw request ?
32
    je	 red
33
    cmp  eax,2			; key in buffer ?
34
    je	 key
35
    cmp  eax,3			; button in buffer ?
36
    je	 button
31 halyavin 37
    cmp  eax,16+4
331 heavyiron 38
    je	 read_input
31 halyavin 39
 
40
    jmp  still
41
 
42
 
43
read_input:
1247 diamond 44
    mcall 42,4,text+120*80
45
    test eax, eax
46
    jle  still
47
 
48
read_input_loop:
49
    mov  bl,[ecx]
50
    inc  ecx
51
    push eax ecx
331 heavyiron 52
    cmp  bl,27				; ESCAPE COMMAND
31 halyavin 53
    jne  no_esc
54
    call esc_command
55
    jmp  newdata
56
  no_esc:
57
 
331 heavyiron 58
    cmp  bl,13				; BEGINNING OF LINE
31 halyavin 59
    jne  nobol
60
    mov  ecx,[pos]
61
    add  ecx,1
62
  boll1:
63
    sub  ecx,1
64
    mov  eax,ecx
65
    xor  edx,edx
66
    mov  ebx,80
67
    div  ebx
68
    cmp  edx,0
69
    jne  boll1
70
    mov  [pos],ecx
71
    jmp  newdata
72
  nobol:
73
 
331 heavyiron 74
    cmp  bl,10				  ; LINE DOWN
31 halyavin 75
    jne  nolf
76
   addx1:
77
    add  [pos],dword 1
78
    mov  eax,[pos]
79
    xor  edx,edx
80
    mov  ecx,80
81
    div  ecx
82
    cmp  edx,0
83
    jnz  addx1
84
    mov  eax,[pos]
85
    jmp  cm1
86
  nolf:
87
 
331 heavyiron 88
    cmp  bl,8				 ; BACKSPACE
31 halyavin 89
    jne  nobasp
90
    mov  eax,[pos]
91
    dec  eax
92
    mov  [pos],eax
93
    mov  [eax+text],byte 32
94
    mov  [eax+text+60*80],byte 0
95
    jmp  newdata
96
   nobasp:
97
 
331 heavyiron 98
    cmp  bl,15				 ; CHARACTER
31 halyavin 99
    jbe  newdata
100
    mov  eax,[pos]
101
    call draw_data
102
    mov  eax,[pos]
103
    add  eax,1
104
  cm1:
105
    mov  ebx,[scroll+4]
106
    imul ebx,80
107
    cmp  eax,ebx
331 heavyiron 108
    jb	 noeaxz
31 halyavin 109
    mov  esi,text+80
110
    mov  edi,text
111
    mov  ecx,ebx
112
    cld
113
    rep  movsb
114
    mov  esi,text+80+60*80
115
    mov  edi,text+60*80
116
    mov  ecx,ebx
117
    cld
118
    rep  movsb
119
    mov  eax,ebx
120
    sub  eax,80
121
  noeaxz:
122
    mov  [pos],eax
123
  newdata:
1247 diamond 124
    pop  ecx eax
125
    dec  eax
126
    jnz  read_input_loop
31 halyavin 127
    call draw_text
128
    jmp  still
129
 
130
 
331 heavyiron 131
  red:				; REDRAW WINDOW
31 halyavin 132
    call draw_window
133
    jmp  still
134
 
331 heavyiron 135
  key:				; KEY
136
    mov  eax,2			; send to modem
485 heavyiron 137
    mcall
31 halyavin 138
    shr  eax,8
331 heavyiron 139
    cmp  eax,178		; ARROW KEYS
31 halyavin 140
    jne  noaup
141
    mov  al,'A'
142
    call arrow
143
    jmp  still
144
  noaup:
145
    cmp  eax,177
146
    jne  noadown
147
    mov  al,'B'
148
    call arrow
149
    jmp  still
150
  noadown:
151
    cmp  eax,179
152
    jne  noaright
153
    mov  al,'C'
154
    call arrow
155
    jmp  still
156
  noaright:
157
    cmp  eax,176
158
    jne  noaleft
159
    mov  al,'D'
160
    call arrow
161
    jmp  still
162
  noaleft:
163
  modem_out:
1247 diamond 164
    mov  dx,0x3f8
165
    out  dx,al
31 halyavin 166
    jmp  still
167
 
331 heavyiron 168
  button:			; BUTTON
31 halyavin 169
    mov  eax,17
485 heavyiron 170
    mcall
331 heavyiron 171
    cmp  ah,1			; CLOSE PROGRAM
31 halyavin 172
    jne  noclose
331 heavyiron 173
    mov  eax,45 		; FREE IRQ
31 halyavin 174
    mov  ebx,1
175
    mov  ecx,4
485 heavyiron 176
    mcall
31 halyavin 177
    mov  eax,46
178
    mov  ebx,1
179
    mov  ecx,0x3f0
180
    mov  edx,0x3ff
485 heavyiron 181
    mcall
182
     or  eax,-1
183
     mcall
31 halyavin 184
  noclose:
185
 
186
    jmp  still
187
 
188
 
189
arrow:
190
 
191
    push eax
192
    mov  al,27
193
    call to_modem
194
    mov  al,'['
195
    call to_modem
196
    pop  eax
197
    call to_modem
198
 
199
    ret
200
 
201
 
202
to_modem:
203
 
204
    pusha
205
 
1247 diamond 206
    mov  dx,0x3f8
207
    out  dx,al
31 halyavin 208
    mov  eax,5
209
    mov  ebx,5
485 heavyiron 210
    mcall
31 halyavin 211
 
212
    popa
213
    ret
214
 
215
 
216
draw_data:
217
 
218
    pusha
219
 
220
    cmp  bl,0xe4   ; Á
221
    jne  noe4
222
    mov  bl,0xc1
223
  noe4:
224
    cmp  bl,0xc4   ; É
225
    jne  noc4
226
    mov  bl,0xc9
227
  noc4:
228
    mov  [eax+text],bl
229
    mov  bl,byte [attribute]
230
    mov  [eax+text+60*80],bl
231
 
232
    popa
233
    ret
234
 
235
 
236
irqtable:
237
 
331 heavyiron 238
    dd	0x3f8  + 0x01000000  ; read port 0x3f8, byte
239
    dd	0
240
    dd	0
241
    dd	0
242
    dd	0
243
    dd	0
244
    dd	0
245
    dd	0
246
    dd	0
247
    dd	0
248
    dd	0
249
    dd	0
250
    dd	0
251
    dd	0
252
    dd	0
253
    dd	0
31 halyavin 254
 
255
 
256
 
257
 
258
set_variables:
259
 
260
    pusha
261
 
262
    mov  eax,46
263
    mov  ebx,0
264
    mov  ecx,0x3f0
265
    mov  edx,0x3ff
485 heavyiron 266
    mcall
31 halyavin 267
 
331 heavyiron 268
    mov  eax,45 	 ; reserve irq 4
31 halyavin 269
    mov  ebx,0
270
    mov  ecx,4
485 heavyiron 271
    mcall
31 halyavin 272
 
273
    mov  eax,44
274
    mov  ebx,irqtable
275
    mov  ecx,4
485 heavyiron 276
    mcall
31 halyavin 277
 
278
;    jmp  noportint
279
 
1247 diamond 280
    mov  dx,0x3f8+3
281
    mov  al,0x80
282
    out  dx,al
31 halyavin 283
 
1247 diamond 284
    mov  dx,0x3f8+1
285
    mov  al,0
286
    out  dx,al
31 halyavin 287
 
1247 diamond 288
    mov  dx,0x3f8+0
289
    mov  al,0x30 / 16
290
    out  dx,al
31 halyavin 291
 
1247 diamond 292
    mov  dx,0x3f8+3
293
    mov  al,3
294
    out  dx,al
31 halyavin 295
 
1247 diamond 296
    mov  dx,0x3f8+4
297
    mov  al,0xB
298
    out  dx,al
31 halyavin 299
 
1247 diamond 300
    mov  dx,0x3f8+1
301
    mov  al,1
302
    out  dx,al
31 halyavin 303
 
304
  noportint:
305
 
306
     mov  eax,40
307
     mov  ebx,0000000000010000b shl 16 + 111b
485 heavyiron 308
    mcall
31 halyavin 309
 
310
    popa
311
 
312
    ret
313
 
314
 
315
 
316
;   *********************************************
317
;   *******  WINDOW DEFINITIONS AND DRAW ********
318
;   *********************************************
319
 
320
 
321
draw_window:
322
 
323
    pusha
324
 
325
    mov  eax,12
326
    mov  ebx,1
485 heavyiron 327
    mcall
31 halyavin 328
 
331 heavyiron 329
    mov  eax,0			   ; DRAW WINDOW
31 halyavin 330
    mov  ebx,100*65536+491
331
    mov  ecx,100*65536+270
331 heavyiron 332
    mov  edx,0x13000000
485 heavyiron 333
    mov  edi,title
334
    mcall
31 halyavin 335
 
336
    xor  eax,eax
337
    mov  edi,text+80*30
338
    mov  ecx,80*30 /4
339
    cld
340
    rep  stosd
341
 
342
    call draw_text
343
 
344
    mov  eax,12
345
    mov  ebx,2
485 heavyiron 346
    mcall
31 halyavin 347
 
348
    popa
349
 
350
    ret
351
 
352
 
353
bgc  dd  0x000000
354
     dd  0x000000
355
     dd  0x00ff00
356
     dd  0x0000ff
357
     dd  0x005500
358
     dd  0xff00ff
359
     dd  0x00ffff
360
     dd  0x770077
361
 
362
tc   dd  0xffffff
363
     dd  0xff00ff
364
     dd  0xffffff
365
     dd  0xffffff
366
     dd  0xffffff
367
     dd  0xffffff
368
     dd  0xffffff
369
     dd  0xffffff
370
 
371
 
372
draw_text:
373
 
374
    pusha
375
 
376
    mov  esi,text
377
    mov  eax,0
378
    mov  ebx,0
379
  newletter:
380
    mov  cl,[esi]
381
    mov  dl,[esi+60*80]
382
    cmp  cl,[esi+30*80]
383
    jne  yesletter
384
    cmp  dl,[esi+90*80]
385
    jne  yesletter
386
    jmp  noletter
387
  yesletter:
388
    mov  [esi+30*80],cl
389
    mov  [esi+90*80],dl
390
 
391
    pusha
392
    and  edx,0xff
393
    shl  edx,2
394
    add  edx,bgc
395
    mov  edx,[edx]
396
    mov  ecx,ebx
397
    add  ecx,26
398
    shl  ecx,16
399
    mov  cx,9
400
    mov  ebx,eax
401
    add  ebx,6
402
    shl  ebx,16
403
    mov  bx,6
404
    mov  eax,13
485 heavyiron 405
    mcall
31 halyavin 406
    popa
407
 
408
    pusha
409
    and  edx,0xff
410
    shl  edx,2
411
    add  edx,tc
412
    mov  ecx,[edx]
413
    push bx
414
    mov  ebx,eax
415
    add  ebx,6
416
    shl  ebx,16
417
    pop  bx
418
    add  bx,26
419
    mov  eax,4
420
    mov  edx,esi
421
    mov  esi,1
485 heavyiron 422
    mcall
31 halyavin 423
    popa
424
 
425
  noletter:
426
 
427
    add  esi,1
428
    add  eax,6
429
    cmp  eax,80*6
331 heavyiron 430
    jb	 newletter
31 halyavin 431
    mov  eax,0
432
    add  ebx,10
433
    cmp  ebx,24*10
331 heavyiron 434
    jb	 newletter
31 halyavin 435
 
436
    popa
437
    ret
438
 
439
 
440
esc_command:
441
 
442
     mov   eax,32
443
     mov   edi,esccmd
444
     mov   ecx,10
445
     cld
446
     rep   stosb
447
     mov   edi,esccmd
448
   newescc:
449
     mov   eax,42
450
     mov   ebx,4
485 heavyiron 451
     mcall
31 halyavin 452
     cmp   ecx,0
453
     je    escok
454
     mov   eax,5
455
     mov   ebx,1
485 heavyiron 456
     mcall
31 halyavin 457
     jmp   newescc
458
   escok:
459
     mov   [edi],bl
460
     add   edi,1
461
     cmp   edi,esccmd+20
462
     je    dontunderstand
463
     mov   esi,escend
464
   nec:
465
     cmp   bl,[esi]
466
     jz    com_ok
467
     add   esi,1
468
     cmp   [esi],byte 0
469
     je    newescc
470
     jmp   nec
471
   com_ok:
472
 
473
     call  get_numbers
474
 
331 heavyiron 475
     cmp   bl,'H'		      ; SET CURSOR POSITION
31 halyavin 476
     jne   no_cursor_position
477
     cmp   [escnumbers],0
478
     jne   ncp1
479
     mov   [pos],dword 0
480
     jmp   cmd_done
481
    ncp1:
482
     mov    eax,[escnumbers]
483
     dec    eax
484
     imul   eax,80
485
     add    eax,[escnumbers+4]
486
     dec    eax
487
     mov    [pos],eax
488
     jmp    cmd_done
489
   no_cursor_position:
490
 
331 heavyiron 491
     cmp    bl,'K'			; ERASE LINE
31 halyavin 492
     jne    no_erase_end_of_line
493
     cmp    [escnumbers],0
494
     jne    no_end_line
495
     mov    ecx,[pos]
496
   eeol:
497
     mov    [ecx+text],byte ' '
498
     mov    [ecx+text+60*80],byte 0
499
     add    ecx,1
500
     xor    edx,edx
501
     mov    eax,ecx
502
     mov    ebx,80
503
     div    ebx
504
     cmp    edx,0
505
     jne    eeol
506
     jmp    cmd_done
507
    no_end_line:
331 heavyiron 508
     cmp    [escnumbers],1		; BEGINNING OF LINE
31 halyavin 509
     jne    no_beg_line
510
     mov    ecx,[pos]
511
   ebol:
512
     mov    [ecx+text],byte ' '
513
     mov    [ecx+text+60*80],byte 0
514
     sub    ecx,1
515
     xor    edx,edx
516
     mov    eax,ecx
517
     mov    ebx,80
518
     div    ebx
519
     cmp    edx,0
520
     jne    ebol
521
     mov    [pos],ecx
522
     jmp    cmd_done
523
    no_beg_line:
524
   no_erase_end_of_line:
525
 
331 heavyiron 526
     cmp    bl,'J'			    ; ERASE TO END OF SCREEN
31 halyavin 527
     jne    no_erase_to_end_of_screen
528
     cmp    [escnumbers],dword 0
529
     jne    no_erase_to_end_of_screen
530
     mov    ecx,[pos]
531
   eteos:
532
     mov    [ecx+text],byte ' '
533
     mov    [ecx+text+60*80],byte 0
534
     add    ecx,1
535
     cmp    ecx,80*24+1
536
     jb     eteos
537
     jmp    cmd_done
538
   no_erase_to_end_of_screen:
539
 
331 heavyiron 540
     cmp    bl,'r'			     ; SET SCROLL REGION
31 halyavin 541
     jne    no_scroll_region
542
     mov    eax,[escnumbers]
543
     dec    eax
544
     mov    [scroll+0],eax
545
     mov    eax,[escnumbers+4]
546
     mov    [scroll+4],eax
547
     jmp    cmd_done
548
   no_scroll_region:
549
 
331 heavyiron 550
     cmp    bl,'A'			      ; CURSOR UP
31 halyavin 551
     jne    no_cursor_up
552
     mov    eax,[pos]
553
     sub    eax,80
554
     mov    [pos],eax
555
     jmp    cmd_done
556
   no_cursor_up:
557
 
331 heavyiron 558
     cmp    bl,'C'			      ; CURSOR LEFT
31 halyavin 559
     jne    no_cursor_left
560
     mov    eax,[pos]
561
     mov    ebx,[escnumbers]
562
     sub    eax,ebx
563
     mov    [pos],eax
564
     call   cmd_done
565
   no_cursor_left:
566
 
331 heavyiron 567
     cmp    bl,'m'			     ; CHARACTER ATTRIBUTE
31 halyavin 568
     jne    no_char_attribute
569
     mov    eax,[escnumbers]
570
     mov    [attribute],eax
571
     jmp    cmd_done
572
   no_char_attribute:
573
 
331 heavyiron 574
     cmp    bl,'Z'			      ; TERMINAL TYPE
31 halyavin 575
     jne    no_terminal_type
576
     mov    al,27
577
     call   to_modem
578
     mov    al,'?'
579
     call   to_modem
580
     mov    al,'1'
581
     call   to_modem
582
     mov    al,';'
583
     call   to_modem
584
     mov    al,'0'
585
     call   to_modem
586
     mov    al,'c'
587
     call   to_modem
588
     jmp    cmd_done
589
   no_terminal_type:
590
 
591
   dontunderstand:
592
 
593
   cmd_done:
594
 
595
     ret
596
 
597
 
598
draw_numbers:
599
 
600
     pusha
601
 
602
     mov  eax,13
603
     mov  ebx,250*65536+100
604
     mov  ecx,8*65536+8
605
     mov  edx,0x000000
485 heavyiron 606
     mcall
31 halyavin 607
 
608
     mov  eax,[escnumbers]
609
     xor  edx,edx
610
     mov  ebx,10
611
     div  ebx
612
     add  eax,48
613
     add  edx,48
614
     mov  byte [numtext+0],al
615
     mov  byte [numtext+1],dl
616
 
617
     mov  eax,[escnumbers+4]
618
     xor  edx,edx
619
     mov  ebx,10
620
     div  ebx
621
     add  eax,48
622
     add  edx,48
623
     mov  [numtext+3],al
624
     mov  [numtext+4],dl
625
 
626
     mov  eax,4
627
     mov  ebx,250*65536+8
628
     mov  ecx,0xffffff
629
     mov  edx,numtext
630
     mov  esi,10
485 heavyiron 631
     mcall
31 halyavin 632
 
633
     popa
634
 
635
     ret
636
 
637
draw_event:
638
 
639
     pusha
640
 
641
     mov  eax,13
642
     mov  ebx,150*65536+100
643
     mov  ecx,8*65536+8
644
     mov  edx,0xffffff
485 heavyiron 645
     mcall
31 halyavin 646
 
647
     mov  eax,4
648
     mov  ebx,150*65536+8
649
     mov  ecx,0x000000
650
     mov  edx,esccmd
651
     mov  esi,20
485 heavyiron 652
     mcall
31 halyavin 653
 
654
     popa
655
     ret
656
 
657
 
658
get_numbers:
659
 
660
     pusha
661
 
662
     mov   [escnumbers+0],0
663
     mov   [escnumbers+4],0
664
     mov   [escnumbers+8],0
665
     mov   ecx,esccmd
666
     cmp   [ecx+1],byte '0'
667
     jb    gn_over
668
     cmp   [ecx+1],byte '9'
669
     jg    gn_over
670
     mov   edi,escnumbers
671
   gn_new:
672
     add   ecx,1
673
     movzx eax,byte [ecx]
674
     sub   eax,48
675
     add   ecx,1
676
     cmp   [ecx],byte '0'
677
     jb    gnl1
678
     cmp   [ecx],byte '9'
679
     jg    gnl1
680
     mov   ebx,10
681
     xor   edx,edx
682
     mul   ebx
683
     movzx ebx,byte[ecx]
684
     add   eax,ebx
685
     sub   eax,48
686
     add   ecx,1
687
   gnl1:
688
     mov   [edi],eax
689
     add   edi,4
690
     cmp   [ecx],byte ';'
691
     je    gn_new
692
  gn_over:
693
     popa
694
     ret
695
 
696
 
697
 
698
 
699
; DATA AREA
700
 
701
 
331 heavyiron 702
pos	    dd	80*10
703
irc_data    dd	0x0
704
print	    db	0x0
705
attribute   dd	0
706
scroll	    dd	1
707
	    dd	24
708
numtext     db	'                     '
709
esccmd	    dd	0,0,0,0,0,0,0,0,0,0,0,0,0
710
escend	    db	'ZrhlABCDHfDME=>NmKJgincoyq',0
711
escnumbers  dd	0,0,0,0,0
712
wcolor	    dd	0x000000
485 heavyiron 713
title	    db	'TERMINAL FOR MODEM IN COM1  0.03',0
31 halyavin 714
 
715
text:
716
db '                                                                   '
717
db '             '
718
db '*** A TELNET APPLICATION FOR HAYES COMPATIBLE MODEMS IN COM1       '
719
db '             '
720
db '*** USE HAYES COMMANDS TO CONNECT TO A SERVER                      '
721
db '             '
722
db '*** ATDT (PHONENUMBER)                                             '
723
db '             '
724
db '                                                                   '
725
db '             '
726
 
727
I_END: