[net.micro.pc] ibm-pc-xt termcap

nckary@ndsuvax.UUCP (Dan Kary) (09/21/85)

I have seen requests for an ibm pc termcap several times.  This seems to be a
point of confusion among some pc users.  Termcap is the terminal capability
data base, it contains descriptions of terminals in terms of what capabilities
they have, the sizes of things like how many lines the screen displays and what 
sequence of characters must be sent to make the terminal perform some act, such 
as moving the cursor or clearing the screen.

The ibm pc is not a terminal, and for that reason there is not and can not be
a termcap entry that applies to the ibm pc.  Frequently ibm pc's are used as
terminals.  This is accomplished by running a program that reads the keyboard
and transmits the ascii value of the character that was typed over the rs-232
port while simultaneously reading the input of the rs-232 port and sending 
those characters to the screen.  This program is frequently called a 'terminal
emulator', because it makes an ibm pc (which is not a terminal) behave as if
it were a terminal.

In most video terminals the input data stream is interpreted; not all 
characters that are received are sent to the screen.  Some sequences of 
characters cause actions to occur (move the cursor, clear the screen, etc.).
The way the data stream is interpreted on the ibm pc (and thus, the termcap
entry you need) is determined entirely by the terminal emulation software you
are using.  In the simplest case the terminal emulation software can do no
data stream interpretation and send all charaters to the display.  A program
of this low a level of sophistication would probably be available for free.
Commercial emulation software (and most freeware) will interpret the input
data stream in the same manner that some popular terminal does.  The most
popular emulations (in my limited experience) are vt52 and vt100.  It is also
my experience that software emulators implement a subset of the emulated 
terminals capabilities.  A correct termcap entry can be constructed by looking
at your terminal emulator manual to see which terminal the software emulates.
Find that entry in /etc/termcap, make a copy of that entry (with another name)
and remove all the capabilities that terminal has that your emulator does not
support (the technical section of your manual will optimistically list the
capabilities it does support while ignoring the ones it does not support, so
this may involve some effort).

Lets consider the case where the emulation software does no data stream 
interpretation.  Now the question is how is the data stream interpreted by
the ibm pc?  We send a data stream to a terminal over a communication line,
how do we send a data stream to a pc?  Well, we can get data from the keyboard
or the disk or some other I/O device, but when does it get interpreted?  If it
gets interpreted at all, will depend both on the device it gets sent to and
how it gets sent to that device.  The device of interest is the screen, so now
the question is how does data get sent to the screen?  Ultimately, there is
one way to put a character on the ibm pc screen, and that is to write the ascii
value of the character into the display RAM of the display adapter.  Programs
usually do not do this directly, since they would have to know about the 
differences between the monochrome and color/graphics adapters.  Usually the 
BIOS is used to put characters on the screen.  BIOS means Basic Input and
Output System; it is software contained within the imb pc's ROM.  The BIOS
knows how to put characters into the display RAM of both types of adapters
so other programs don't have to worry about that particular detail.  Simply
tell BIOS which character to display and it does the job.

The BIOS does not do any data stream interpretation (unless you consider 
translating 'carriage return' or 'line feed' into what amounts to be a cursor
move to be 'interpretation').  If you send a sequence of characters to the 
BIOS that would cause the cursor to move if that same sequence were sent to a 
vt100, you will see some graphic characters and perhaps some alphanumeric 
characters displayed.  

Moving back one level, we can also send characters to the screen by using
MS-DOS.  Simply tell MS-DOS which character(s) to display and it will
translate this request into one or more BIOS requests to display the
characters.  This description also gives some indication of the issues
involved in 'ibm pc compatibility'.  If a program makes only MS-DOS requests
only thru MS-DOS defined entry points, it will run on any machine that runs
MS-DOS.  Likewise, any program that uses BIOS facilities will run on machines
that have an ibm compatible BIOS.  Programs which write directly to the ibm
hardware will work only with hardware that is functionally identical to ibm's.

MS-DOS 2.1 as distributed by IBM (and most compatibles) includes a device 
driver called ANSI.SYS, which is a data stream interpreter which makes an ibm
pc (in an *extremely* limited sense) behave as a vt100 (ANSI X3.64) terminal.
ANSI.SYS is installed by creating a file named CONFIG.SYS which includes the
line:

DEVICE=ANSI.SYS

This line causes the file named ANSI.SYS to be installed as a device driver.
This device driver causes some MS-DOS requests (int 21h and int 40h(or there
abouts)) to be rerouted to this driver.  ANSI.SYS then looks to see if the
data is intended for the screen, if it is intended for the screen, then 
ANSI.SYS looks to see if one of the pre-defined 'Escape sequences' is being
sent.  ANSI.SYS translates the data stream into BIOS requests for cursor 
movement, print character or whatever.  I hasten to add that ANSI.SYS works
ONLY with screen requests that use the MS-DOS mechanisms for writing to the
screen.  Programs that use BIOS calls or write directly to the display adapter
will be unaffected by this device driver.  

Finally, at long loving last, I can say that I have a termcap entry that is in
some extended sense 'for the ibm-pc-xt' (it is in fact specific to ANSI.SYS).
This could be used with a terminal emulator that did no data stream 
interpretation *if* that emulator uses the MS-DOS entry points.

ansi.sys|IBM PC with ANSI.SYS installed as a device driver:\
	:co#80:li#25:cl=\E[2J:\
	:bs:am:cm=\E[%i%d;%dH:do=\E[B:nd=\E[C:up=\E[A:\
	:so=\E[7m:se=\E[0m:kb=^H:\
	:ce=\E[K:ho=\E[H:pt:



	Dan Kary
	North Dakota State University
	Computer Science Department
	300 Minard Hall
	Fargo, ND   58102
	ihnp4!dicomed!nckary

jabusch@uiucdcsb.CS.UIUC.EDU (09/29/85)

	Actually, there *is* a termcap for the IBM-PC family for using a
PC without a terminal emulator or the ANSI.SYS driver.  It's 'sd'. :-)

John W. Jabusch
        CSNET:	jabusch%uiuc@csnet-relay.ARPA
	UUCP:	{ihnp4,convex,pur-ee}!uiucdcs!jabusch
        USENET:	...!{pur-ee,ihnp4}!uiucdcs!jabusch
        ARPA:	jabusch@uiuc.arpa