-
Notifications
You must be signed in to change notification settings - Fork 0
/
cvt100.doc
726 lines (248 loc) · 16.2 KB
/
cvt100.doc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
CVT100, Terminal Emulator for Turbo C
VT100, A Simple VT100 Emulator in Turbo C 1.5
By Jerry Joplin CIS [70441,2627]
CVT100, Terminal Emulator for Turbo C
Overview
CVT100 is a simple VT100 emulator programed exclusively
in Turbo C 1.5. *All* of the code is in Turbo C. There are
no assembler routines or functions requiring an assembler.
All of the code is contained in 7 modules. These are:
comio.c communications functions
cvt100.c terminal emulator main
fileio.c file manipulation functions
keyio.c keyboard functions
vidio.c video functions
vtsetup.c setup functions
vttio.c terminal output interpretation functions
The program was designed with several objectives in mind.
1) To provide a public domain source for a VT100
emulator written in Turbo C code that was easy to
understand and modify,
2) To show the power and flexibility of Turbo C without
having to resort to assembly language routines,
3) To aid (however slightly) in the development of a C
version of Kermit for MS DOS systems,
4) To provide a terminal emulator that takes a very
small amount of memory and is capable of running in
a well behaved window in Windows or DesqView (less
than 40k).
CVT100, Terminal Emulator for Turbo C
Operation
The terminal emulator is menu driven. The top line of
the terminal screen is reserved as a status line. A list of
choices is displayed on the status line for setting the
various parameters concerning the different aspects of the
programs operation.
Function Key F5: This activates the Communications menu
setup. Here the COM port is
established along with its associated
baud rate, parity, data bits
and stop bits.
Function Key F6: This key will activate the Video setup
menu. Here the screen colors can be
set and the "snow" inhibit mode can be
set.
Function Key F7: This key when pressed enters the
keyboard setup menu. Here the
program's interpretation of the
backspace key can be set. The
keyboard can be programed to produce a
'key-click' and the state of the
keypad can be defined.
Function Key F8: An Emulation menu becomes active when
F8 is pressed. Here the many mode
settings for the emulator may be set.
These include origin mode,
insert/replace mode, auto wrap mode,
new line mode, cursor visibility,
background video attributes and the
logical screen width.
Function Key F9: Function key F9 brings up a File menu.
The current settings for the terminal
can be saved in an initialization file
that is read when the program is
started. Also a log of incoming
characters can be controlled.
Function Key F10: This is used as the exit key. When
pressed this will close any open log
files and exit.
CVT100, Terminal Emulator for Turbo C
Communications
Characters are received via receiver interrupts
generated by the UART. The interrupt service routine (ISR)
for the incoming characters is a function of type interrupt
for Turbo C. Although any serious communications program
should have the transmission interrupts in assembler, this
program has been tested at 19,200 baud on a plain vanilla
4.77 Mghz PC with no loss of characters.
An XON/XOFF 'handshake' is used to control the flow of
characters to and from the host. An XOFF is transmitted to
the host when 75% of the communications circular buffer is
full. This will tell the host to stop transmitting
characters until an XON is transmitted to it. When the
buffer is back down to 25% full an XON will be sent to the
host signaling it that it is okay to begin transmission
again.
When an XOFF has been received from the host this
program will delay for a short period of time before sending
a character to check for an XON being sent. Note that the
character will still be transmitted if the wait period passes
with no XON being received.
CVT100, Terminal Emulator for Turbo C
Video
Most video manipulations are done by reading and writing
directly to the screen's memory. This made it necessary to
provide "snow" protection on CGA systems, but much less time
is wasted on writing characters and attributes than using the
BIOS.
A check is done before each video memory access to
detect a control program such as Windows, DesqView, or
TopView. Each of these control programs will keep a video
"shadow" buffer for processes currently executing. The
address of this buffer can be queried and output directed to
this buffer instead of the actual screen. This will let
CVT100 run in a well behaved window in these environments.
There are several problems with the video system. A few
of the colors (Yellow foreground) do not work properly with
the emulation. The program tries to juggle various
attributes defined by the host's control commands and tends
to lose the defined color in the process. Also changing the
screen foreground and background colors may or may not work
during program execution. This is due to the fact that the
software tries to retain the contents of the terminal screen
while making the color changes and again may get confused by
defined attributes. To get around this problem, exit the
emulator and re-execute it. The new colors will take effect
properly upon video initialization.
CVT100, Terminal Emulator for Turbo C
Keyboard
The most controversial part of any terminal emulator
will usually be the setup of the IBM PC keyboard to try and
match the Digital Equipment Corporation VT keypad. Not an
easy task. This program tries to map as closely as possible
the keypad for an IBM PC to a DEC VT keypad. The results
are often better if NUM LOCK is left on through out the
entire session.
If you are unsatisfied with the layout of the keyboard
there are currently no means to assign keys any differently,
but that is why the source is provided with this program!
Check module KEYIO.C for changing the default setup.
CVT100, Terminal Emulator for Turbo C
Emulation
This program can best be described as a compromise
between the desire to make the code as simple and straight
forward as possible and the complexities and intricacies of a
real life DEC VT100. So many things were left out of the
terminal emulation.
Of the things left out of the emulation most notable
will be printer output commands and double high/width
character lines. Local echo is also absent.
The emulator can not change the video from 80 to 132
columns and vice-versa when these commands are received from
the host. The commands are received and recognized but it
only changes the logical width of the screen held by the
emulation software. It seems as if every video board
manufacturer that has a board capable of switching to 132
column mode has a different method of changing into this
mode. However this mode can be utilized by setting the
screen to 132 columns *before* executing the program. Then
the video system of the emulator will properly use all of the
columns.
CVT100, Terminal Emulator for Turbo C
File System
The setup information can be saved to a disk file when a
satisfactory setting has been reached. When the program is
executed it looks in the current directory for this file
named 'CVT100.SET' from which to load the setup parameters.
If this file is not found then default values are provided.
Currently the only way to have multiple setups is to have
them in separate directories that the program can be executed
out of.
Incoming characters can be logged to disk. When logging
is selected then all incoming characters are saved in a disk
file names 'CVT100.LOG'. If a file by that name exists at
the time when logging is selected then output is appended to
this file. If no file is present when logging is selected
then a file will be created in the current directory. Note
that *no interpretation* is performed on the characters
placed in the disk file.
CVT100, Terminal Emulator for Turbo C
Program Termination
Any time the program is exited the communications port
will be closed to prevent incoming characters generating
interrupts to ISR's which don't exist in memory any longer.
Additionally the log file will be closed if it is open on
program exit.
There are several errors which may cause the emulator to
force itself to exit. If memory can not be allocated from
the DOS heap for the screen save buffer then the program will
be terminated with an error message. Also the file IO
functions may terminate the program if a system error has
occurred on a read or write of a disk file. This could be
caused by a disk full error or fault media. *CAREFUL*
because the program does not currently trap the fatal error
interrupt and disk errors will produce the not-too-kind error
message:
Not ready error writing drive A:
Abort, Retry, Ignore?
Choosing Abort will cause the terminal to exit without having
turned off communications interrupts. This will cause a
quick system lockup if a character is received by the UART.
CVT100, Terminal Emulator for Turbo C
Testing
The emulation has been tested primarily on 2 systems.
The first and most important was a Digital VAX running VMS.
There are several utilities running under VMS that try even
commercial VT100 emulators. Most notable of these utilities
is the VAX TPU editor, thus importance was given to getting
this version of a VT100 emulator working under the VAX TPU
editor as well as the EDT editor provided with VAX VMS.
Other exceptionally difficult programs to get an emulator
running under were the VAX/VMS debugger in full screen mode,
VAX/VMS mail, and programs using the VAX/VMS FMS screen forms
manager.
Extensive testing was also done on the free practice
forum on CompuServ. (GO PRACTICE, I even got a good working
knowledge of the new SIG forum commands) This turned out to
be a piece of cake after working with many of the VAX/VMS
programs. As far as I can tell the CompuServ host computers
will only send cursor addressing commands and screen clearing
commands to terminals set up to be VT100's. Therefore if
your terminal is set up to be an 80 X 24 VT100 to CompuServ
(GO TERMINAL) this VT100 emulator will provide thorough
terminal emulation.
CVT100, Terminal Emulator for Turbo C
Acknowledgments
The VT100 emulation is based heavily on two versions of
Kermit. The most notable version of Kermit was MSKermit
version 2.30 written in Microsoft Macro Assembler 3.0.
CKermit for Unix was also used for program design and
nomenclature. Therefore this Copyright appears as required.
Copyright (c) 1981, 1988
Trustees of Columbia University in the City of New York
Permission is granted to any individual or institution
to use, copy, or redistribute this program and
documentation as long as it is not sold for profit and
as long as the Columbia copyright notice is retained.
This program would have never got off the ground if it
was not for the work put into a VT102 emulator written
primarily by J. R. Doupnik of Utah State University for
MSKermit. Many other people have worked on MSKermit,
including Frank da Cruz and Christine Gianone of Columbia
University. A list of these people would have been
incomplete and is not attempted here though their
work has been appreciated greatly by me over the years. If
any questions came up regarding a particular facet of VT100
emulation I would always refer to the MSKermit version 2.30
assembler source code. The assembler source to MSKermit also
served as a design outline, although it was difficult to
maintain much of this outline in a conversion from assembler
to C.
I also referred many times to a version of CKermit for
Unix systems. Although there is no terminal emulation code
supplied with this version of Kermit, it helped in the
general design layout of the source modules and also helped
with the function naming conventions used by this program.
In fact it was my original intent to get a version of CKermit
going for MS DOS systems I now understand someone has already
done this somewhere.