[net.micro.pc] Compiling MicroEmacs 3.7 under Microsoft C

sharp@vax135.UUCP (08/01/86)

  At the beginning of the summer, I posted a message describing how to
port MicroEmacs to the Microsoft C compiler.  The latest release of
MicroEmacs, version 3.7, incorporates some of those changes.  I don't
have access to my machine so I can't be sure exactly what will happen
when 3.7 is compiled under MSC, but there are a few definite problems.
For example, the spawncli() routine compiles into {} with the MSC and
MSDOS symbols set.  Another problem - in termio.c, there is a line that 
reads:

#if     MSDOS & (LATTICE | MSDOS)

  This isn't particularly useful.  I assume that it is supposed to read
(LATTICE | MSC).  

  When I get back to school in September, I will look into the code in more 
detail and report on the results if anyone is interested.  My guess is that 
setting the defines will get almost everything to work.  The spawn routines 
seem to need a few minutes work; perhaps someone else has MSC and is willing 
to post the necessary changes.  

  If anyone has any questions on getting MicroEmacs to run under MSC, feel 
free to ask me about them.  I might, however, not be able to answer until I 
am back at school.

Oliver Sharp
until Aug 15: ...!ucbvax!vax135!sharp
after Sept 1: ...!decvax!yale!sharp

endot@pur-ee.UUCP (Endot lab account) (08/03/86)

  I finally got the uEmacs 3.7 to work on my XT. Since I am now using
MSC, I have made a couple patches and hope this could be helpful to some
of you.

	1. The estruct.h was updated to indicate that I am using MSC.
	2. In termio.c, there is a "if MSDOS & (LATTICE | MSDOS)" which 
	   should be LATTICE | MSC". (Thanks to Mr. Oliver Sharp)
	3. In spawn.c, line 459, there is a ")" missing.
	4. In ibmpc.c, change movmem() to memcpy() with the first two
	   arguments of movmem() swapped. Especially for the sline[0], it
	   should be &sline[0].
	5. The undefined struct comes from the fact that there is a misplaced
	   ifdef. Look for #if MSDOS | AZTEC, somehow the necessary
	   structure declaration is bound by that #if. Move the #endif up
	   a few lines to make the structure declarations available to others.

  I think these were all that I've changed. I used the large model to compile
it. Then I used it to edit a 190K+ file and it works pretty well. Most of
the other editors that I have used will either bombs or complains. I think
the uEmacs is a great editor, and my special thanks to D. Lawrence for
posting such a nice software to the net, so enjoy.

T. Chow

luke@tom.columbia.edu (Luke McCormick) (08/04/86)

I'd love to get uEmacs 3.7 without having to compile the source.  Experience
tells me that that would be a difficult task.  Does anybody have it who would
be willing to make it available for FTP?

luke

PS. I have uEmacs 3.6.  What is the difference between this and 3.7?

caf@omen.UUCP (Chuck Forsberg WA7KGX) (08/05/86)

In article <2854@columbia.UUCP> luke@tom.UUCP (Luke McCormick) writes:
:I'd love to get uEmacs 3.7 without having to compile the source.  Experience
:tells me that that would be a difficult task.  Does anybody have it who would
:be willing to make it available for FTP?
:PS. I have uEmacs 3.6.  What is the difference between this and 3.7?

The big difference is that 3.7 allows one to edit multiple files, which I
couldn't get 3.6 to do.  There is also a list of key bindings for it, and
it is more Mince-like than previous versions.

Compiling it under Xenix, the IBM dedicated driver didn't place the cursor
in the right place, a moby hassle on a screen editor.  The ANSI version
does work (with a little hacking to make output appear).  It runs nicely on
an 8 mHz 0 ws AT clone with Fansi-Console, slowly on a DG/One with ANSI.SYS.
I will put a copy of the .exe on Telegodzilla tonight.


   Chuck Forsberg WA7KGX  ...!tektronix!reed!omen!caf   CIS:70715,131
   Author of Professional-YAM communications Tools for PCDOS and Unix
 Omen Technology Inc     17505-V NW Sauvie Island Road Portland OR 97231
Voice: 503-621-3406 TeleGodzilla: 621-3746 300/1200 L.sys entry for omen:
omen Any ACU 1200 1-503-621-3746 se:--se: link ord: Giznoid in:--in: uucp
omen!/usr/spool/uucppublic/FILES lists all uucp-able files, updated hourly

bull@cs.reading.ac.uk (Stephen) (08/06/86)

Summary:
Expires:
Sender:
Followup-To:
Distribution:
Xpath: ukc eagle


In article <2854@columbia.UUCP> you write:
>I'd love to get uEmacs 3.7 without having to compile the source.  Experience
>tells me that that would be a difficult task.  Does anybody have it who would
>be willing to make it available for FTP?
>
>luke
>
>PS. I have uEmacs 3.6.  What is the difference between this and 3.7?

I'd love one too. The trouble is that each person wants a different
configuration. However, if someone post you a copy for a bog standard IBM XT
without a colour board then I'd be forever grateful.


stephen

endot@pur-ee.UUCP (Endot lab account) (08/08/86)

  Here is the three files that I have changed to get uEmacs 3.7 to work
on my XT. The changes are actually minor though.

--------CUT HERE-------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	estruct.h
#	ibmpc.c
#	termio.c
# This archive created: Fri Aug  8 13:04:30 1986
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'estruct.h'" '(13471 characters)'
if test -f 'estruct.h'
then
	echo shar: "will not over-write existing file 'estruct.h'"
else
sed 's/^	X//' << \SHAR_EOF > 'estruct.h'
	X/*	ESTRUCT:	Structure and preprocesser defined for
	X			MicroEMACS 3.7
	X
	X			written by Dave G. Conroy
	X			modified by Steve Wilhite, George Jones
	X			greatly modified by Daniel Lawrence
	X*/
	X
	X#undef	LATTICE		/* don't use their definitions...use ours	*/
	X#undef	MSDOS
	X#undef	CPM
	X#undef	AMIGA
	X
	X/*	Machine/OS definitions			*/
	X
	X#define AMIGA   0                       /* AmigaDOS			*/
	X#define ST520   0                       /* ST520, TOS                   */
	X#define MSDOS   1                       /* MS-DOS                       */
	X#define V7      0                       /* V7 UN*X or Coherent or BSD4.2*/
	X#define	BSD	0			/* UNIX BSD 4.2	and ULTRIX	*/
	X#define	USG	0			/* UNIX system V		*/
	X#define VMS     0                       /* VAX/VMS                      */
	X#define CPM     0                       /* CP/M-86                      */
	X
	X/*	Compiler definitions			*/
	X#define MWC86   0	/* marc williams compiler */
	X#define	LATTICE	0	/* either lattice compiler */
	X#define	LAT2	0	/* Lattice 2.15 */
	X#define	LAT3	0	/* Lattice 3.0 */
	X#define	AZTEC	0	/* Aztec C 3.20e */
	X#define	MSC	1	/* MicroSoft C compile version 3 */
	X
	X/*	Profiling options	*/
	X#define	APROF	0	/* turn Aztec C profiling on? */
	X#define	NBUCK	100	/* number of buckets to profile */
	X
	X/*   Special keyboard definitions            */
	X
	X#define WANGPC	0			/* WangPC - mostly escape sequences     */
	X
	X/*	Terminal Output definitions		*/
	X
	X#define ANSI    0			/* ansi escape sequences	*/
	X#define	HP150	0			/* HP150 screen driver		*/
	X#define	VMSVT	0			/* various VMS terminal entries	*/
	X#define VT52    0                       /* VT52 terminal (Zenith).      */
	X#define VT100   0                       /* Handle VT100 style keypad.   */
	X#define LK201   0                       /* Handle LK201 style keypad.   */
	X#define RAINBOW 0                       /* Use Rainbow fast video.      */
	X#define TERMCAP 0                       /* Use TERMCAP                  */
	X#define	IBMPC	1			/* IBM-PC specific driver	*/
	X#define	DG10	0			/* Data General system/10	*/
	X
	X/*	Configuration options	*/
	X
	X#define CVMVAS  1	/* arguments to page forward/back in pages	*/
	X#define	NFWORD	1	/* forward word jumps to begining of word	*/
	X#define	CLRMSG	0	/* space clears the message line with no insert	*/
	X#define	TYPEAH	1	/* type ahead causes update to be skipped	*/
	X#define	FILOCK	0	/* file locking under unix BSD 4.2		*/
	X#define	REVSTA	1	/* Status line appears in reverse video		*/
	X#define	COLOR	0	/* color commands and windows			*/
	X#define	ACMODE	1	/* auto CMODE on .C and .H files		*/
	X#define	CFENCE	1	/* fench matching in CMODE			*/
	X#define	ISRCH	1	/* Incremental searches like ITS EMACS		*/
	X#define	WORDPRO	1	/* Advanced word processing features		*/
	X
	X/*	System dependant library redefinitions, structures and includes	*/
	X
	X#if	MSDOS & AZTEC
	X#undef	fputc
	X#undef	fgetc
	X#define	fputc	aputc
	X#define	fgetc	agetc
	X#define	int86	sysint
	X#define	inp	inportb
	X
	Xstruct XREG {
	X	int ax,bx,cx,dx,si,di;
	X};
	X
	Xstruct HREG {
	X	char al,ah,bl,bh,cl,ch,dl,dh;
	X};
	X
	Xunion REGS {
	X	struct XREG x;
	X	struct HREG h;
	X};
	X#endif
	X
	X#if	MSDOS & LATTICE
	X#undef	CPM
	X#undef	LATTICE
	X#include	<dos.h>
	X#undef	CPM
	X#endif
	X
	X#if	MSDOS & MSC
	X#include	<dos.h>
	X#endif
	X
	X/*	internal constants	*/
	X
	X#define	NBINDS	200			/* max # of bound keys		*/
	X#define NFILEN  80                      /* # of bytes, file name        */
	X#define NBUFN   16                      /* # of bytes, buffer name      */
	X#define NLINE   256                     /* # of bytes, line             */
	X#define	NSTRING	256			/* # of bytes, string buffers	*/
	X#define NKBDM   256                     /* # of strokes, keyboard macro */
	X#define NPAT    80                      /* # of bytes, pattern          */
	X#define HUGE    1000                    /* Huge number                  */
	X#define	NLOCKS	100			/* max # of file locks active	*/
	X#define	NCOLORS	8			/* number of supported colors	*/
	X#define	KBLOCK	250			/* sizeof kill buffer chunks	*/
	X#define	NBLOCK	16			/* line block chunk size	*/
	X
	X#define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
	X#define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
	X#define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
	X#define EXITCH  0x1D                    /* Exit level,  Control-]       */
	X#define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
	X#define HELPCH  0x1F                    /* Help key,    Control-_       */
	X
	X#define CTRL    0x0100                  /* Control flag, or'ed in       */
	X#define META    0x0200                  /* Meta flag, or'ed in          */
	X#define CTLX    0x0400                  /* ^X flag, or'ed in            */
	X#define	SPEC	0x0800			/* special key (function keys)	*/
	X
	X#define FALSE   0                       /* False, no, bad, etc.         */
	X#define TRUE    1                       /* True, yes, good, etc.        */
	X#define ABORT   2                       /* Death, ^G, abort, etc.       */
	X
	X#define FIOSUC  0                       /* File I/O, success.           */
	X#define FIOFNF  1                       /* File I/O, file not found.    */
	X#define FIOEOF  2                       /* File I/O, end of file.       */
	X#define FIOERR  3                       /* File I/O, error.             */
	X#define	FIOLNG	4			/*line longer than allowed len	*/
	X
	X#define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
	X#define CFKILL  0x0002                  /* Last command was a kill      */
	X
	X#define	BELL	0x07			/* a bell character		*/
	X#define	TAB	0x09			/* a tab character		*/
	X
	X/*
	X * There is a window structure allocated for every active display window. The
	X * windows are kept in a big list, in top to bottom screen order, with the
	X * listhead at "wheadp". Each window contains its own values of dot and mark.
	X * The flag field contains some bits that are set by commands to guide
	X * redisplay; although this is a bit of a compromise in terms of decoupling,
	X * the full blown redisplay is just too expensive to run for every input
	X * character.
	X */
	Xtypedef struct  WINDOW {
	X        struct  WINDOW *w_wndp;         /* Next window                  */
	X        struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
	X        struct  LINE *w_linep;          /* Top line in the window       */
	X        struct  LINE *w_dotp;           /* Line containing "."          */
	X        short   w_doto;                 /* Byte offset for "."          */
	X        struct  LINE *w_markp;          /* Line containing "mark"       */
	X        short   w_marko;                /* Byte offset for "mark"       */
	X        char    w_toprow;               /* Origin 0 top row of window   */
	X        char    w_ntrows;               /* # of rows of text in window  */
	X        char    w_force;                /* If NZ, forcing row.          */
	X        char    w_flag;                 /* Flags.                       */
	X#if	COLOR
	X	char	w_fcolor;		/* current forground color	*/
	X	char	w_bcolor;		/* current background color	*/
	X#endif
	X}       WINDOW;
	X
	X#define WFFORCE 0x01                    /* Window needs forced reframe  */
	X#define WFMOVE  0x02                    /* Movement from line to line   */
	X#define WFEDIT  0x04                    /* Editing within a line        */
	X#define WFHARD  0x08                    /* Better to a full display     */
	X#define WFMODE  0x10                    /* Update mode line.            */
	X#define	WFCOLR	0x20			/* Needs a color change		*/
	X
	X/*
	X * Text is kept in buffers. A buffer header, described below, exists for every
	X * buffer in the system. The buffers are kept in a big list, so that commands
	X * that search for a buffer by name can find the buffer header. There is a
	X * safe store for the dot and mark in the header, but this is only valid if
	X * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
	X * the buffer is kept in a circularly linked list of lines, with a pointer to
	X * the header line in "b_linep".
	X * 	Buffers may be "Inactive" which means the files accosiated with them
	X * have not been read in yet. These get read in at "use buffer" time.
	X */
	Xtypedef struct  BUFFER {
	X        struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
	X        struct  LINE *b_dotp;           /* Link to "." LINE structure   */
	X        short   b_doto;                 /* Offset of "." in above LINE  */
	X        struct  LINE *b_markp;          /* The same as the above two,   */
	X        short   b_marko;                /* but for the "mark"           */
	X        struct  LINE *b_linep;          /* Link to the header LINE      */
	X	char	b_active;		/* window activated flag	*/
	X        char    b_nwnd;                 /* Count of windows on buffer   */
	X        char    b_flag;                 /* Flags                        */
	X	char	b_mode;			/* editor mode of this buffer	*/
	X        char    b_fname[NFILEN];        /* File name                    */
	X        char    b_bname[NBUFN];         /* Buffer name                  */
	X}       BUFFER;
	X
	X#define BFINVS  0x01                    /* Internal invisable buffer    */
	X#define BFCHG   0x02                    /* Changed since last write     */
	X
	X/*	mode flags	*/
	X#define	NUMMODES	7		/* # of defined modes		*/
	X
	X#define	MDWRAP	0x0001			/* word wrap			*/
	X#define	MDCMOD	0x0002			/* C indentation and fence match*/
	X#define	MDSPELL	0x0004			/* spell error parcing		*/
	X#define	MDEXACT	0x0008			/* Exact matching for searches	*/
	X#define	MDVIEW	0x0010			/* read-only buffer		*/
	X#define MDOVER	0x0020			/* overwrite mode		*/
	X#define MDMAGIC	0x0040			/* regular expresions in search */
	X
	X/*
	X * The starting position of a region, and the size of the region in
	X * characters, is kept in a region structure.  Used by the region commands.
	X */
	Xtypedef struct  {
	X        struct  LINE *r_linep;          /* Origin LINE address.         */
	X        short   r_offset;               /* Origin LINE offset.          */
	X        long	r_size;                 /* Length in characters.        */
	X}       REGION;
	X
	X/*
	X * All text is kept in circularly linked lists of "LINE" structures. These
	X * begin at the header line (which is the blank line beyond the end of the
	X * buffer). This line is pointed to by the "BUFFER". Each line contains a the
	X * number of bytes in the line (the "used" size), the size of the text array,
	X * and the text. The end of line is not stored as a byte; it's implied. Future
	X * additions will include update hints, and a list of marks into the line.
	X */
	Xtypedef struct  LINE {
	X        struct  LINE *l_fp;             /* Link to the next line        */
	X        struct  LINE *l_bp;             /* Link to the previous line    */
	X        short   l_size;                 /* Allocated size               */
	X        short   l_used;                 /* Used size                    */
	X        char    l_text[1];              /* A bunch of characters.       */
	X}       LINE;
	X
	X#define lforw(lp)       ((lp)->l_fp)
	X#define lback(lp)       ((lp)->l_bp)
	X#define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
	X#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
	X#define llength(lp)     ((lp)->l_used)
	X
	X/*
	X * The editor communicates with the display using a high level interface. A
	X * "TERM" structure holds useful variables, and indirect pointers to routines
	X * that do useful operations. The low level get and put routines are here too.
	X * This lets a terminal, in addition to having non standard commands, have
	X * funny get and put character code too. The calls might get changed to
	X * "termp->t_field" style in the future, to make it possible to run more than
	X * one terminal type.
	X */
	Xtypedef struct  {
	X        short   t_nrow;                 /* Number of rows.              */
	X        short   t_ncol;                 /* Number of columns.           */
	X	short	t_margin;		/* min margin for extended lines*/
	X	short	t_scrsiz;		/* size of scroll region "	*/
	X	int	t_pause;		/* # times thru update to pause */
	X        int     (*t_open)();            /* Open terminal at the start.  */
	X        int     (*t_close)();           /* Close terminal at end.       */
	X        int     (*t_getchar)();         /* Get character from keyboard. */
	X        int     (*t_putchar)();         /* Put character to display.    */
	X        int     (*t_flush)();           /* Flush output buffers.        */
	X        int     (*t_move)();            /* Move the cursor, origin 0.   */
	X        int     (*t_eeol)();            /* Erase to end of line.        */
	X        int     (*t_eeop)();            /* Erase to end of page.        */
	X        int     (*t_beep)();            /* Beep.                        */
	X	int	(*t_rev)();		/* set reverse video state	*/
	X#if	COLOR
	X	int	(*t_setfor)();		/* set forground color		*/
	X	int	(*t_setback)();		/* set background color		*/
	X#endif
	X}       TERM;
	X
	X/*	structure for the table of initial key bindings		*/
	X
	Xtypedef struct  {
	X        short   k_code;                 /* Key code                     */
	X        int     (*k_fp)();              /* Routine to handle it         */
	X}       KEYTAB;
	X
	X/*	structure for the name binding table		*/
	X
	Xtypedef struct {
	X	char *n_name;		/* name of function key */
	X	int (*n_func)();	/* function name is bound to */
	X}	NBIND;
	X
	X/*	The editor holds deleted text chunks in the KILL buffer. The
	X	kill buffer is logically a stream of ascii characters, however
	X	due to its unpredicatable size, it gets implemented as a linked
	X	list of chunks. (The d_ prefix is for "deleted" text, as k_
	X	was taken up by the keycode structure			*/
	X
	Xtypedef	struct KILL {
	X	struct KILL *d_next;	/* link to next chunk, NULL if last */
	X	char d_chunk[KBLOCK];	/* deleted text */
	X} KILL;
SHAR_EOF
if test 13471 -ne "`wc -c < 'estruct.h'`"
then
	echo shar: "error transmitting 'estruct.h'" '(should have been 13471 characters)'
fi
fi
echo shar: "extracting 'ibmpc.c'" '(5604 characters)'
if test -f 'ibmpc.c'
then
	echo shar: "will not over-write existing file 'ibmpc.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'ibmpc.c'
	X/*
	X * The routines in this file provide support for the IBM-PC and other
	X * compatible terminals. It goes directly to the graphics RAM to do
	X * screen output. It compiles into nothing if not an IBM-PC driver
	X */
	X
	X#define	termdef	1			/* don't define "term" external */
	X
	X#include        <stdio.h>
	X#include	"estruct.h"
	X#include        "edef.h"
	X
	X#if     IBMPC
	X#include	<memory.h>
	X
	X#define NROW    25                      /* Screen size.                 */
	X#define NCOL    80                      /* Edit if you want to.         */
	X#define	MARGIN	8			/* size of minimim margin and	*/
	X#define	SCRSIZ	64			/* scroll size for extended lines */
	X#define	NPAUSE	200			/* # times thru update to pause */
	X#define BEL     0x07                    /* BEL character.               */
	X#define ESC     0x1B                    /* ESC character.               */
	X#define	SPACE	32			/* space character		*/
	X#define	SCADD	0xb8000000L		/* address of screen RAM	*/
	X
	Xint *scptr[NROW];			/* pointer to screen lines	*/
	Xint sline[NCOL];			/* screen line image		*/
	X
	Xextern  int     ttopen();               /* Forward references.          */
	Xextern  int     ttgetc();
	Xextern  int     ttputc();
	Xextern  int     ttflush();
	Xextern  int     ttclose();
	Xextern  int     ibmmove();
	Xextern  int     ibmeeol();
	Xextern  int     ibmeeop();
	Xextern  int     ibmbeep();
	Xextern  int     ibmopen();
	Xextern	int	ibmrev();
	Xextern	int	ibmclose();
	Xextern	int	ibmputc();
	X
	X#if	COLOR
	Xextern	int	ibmfcol();
	Xextern	int	ibmbcol();
	X
	Xint	cfcolor = -1;		/* current forground color */
	Xint	cbcolor = -1;		/* current background color */
	Xint	ctrans[] =		/* ansi to ibm color translation table */
	X	{0, 4, 2, 6, 1, 5, 3, 7};
	X#endif
	X
	X/*
	X * Standard terminal interface dispatch table. Most of the fields point into
	X * "termio" code.
	X */
	XTERM    term    = {
	X        NROW-1,
	X        NCOL,
	X	MARGIN,
	X	SCRSIZ,
	X	NPAUSE,
	X        ibmopen,
	X        ibmclose,
	X        ttgetc,
	X	ibmputc,
	X        ttflush,
	X        ibmmove,
	X        ibmeeol,
	X        ibmeeop,
	X        ibmbeep,
	X	ibmrev
	X#if	COLOR
	X	, ibmfcol,
	X	ibmbcol
	X#endif
	X};
	X
	Xextern union REGS rg;
	X
	X#if	COLOR
	Xibmfcol(color)		/* set the current output color */
	X
	Xint color;	/* color to set */
	X
	X{
	X	cfcolor = ctrans[color];
	X}
	X
	Xibmbcol(color)		/* set the current background color */
	X
	Xint color;	/* color to set */
	X
	X{
	X        cbcolor = ctrans[color];
	X}
	X#endif
	X
	Xibmmove(row, col)
	X{
	X	rg.h.ah = 2;		/* set cursor position function code */
	X	rg.h.dl = col;
	X	rg.h.dh = row;
	X	rg.h.bh = 0;		/* set screen page number */
	X	int86(0x10, &rg, &rg);
	X}
	X
	Xibmeeol()	/* erase to the end of the line */
	X
	X{
	X	int attr;	/* attribute byte mask to place in RAM */
	X	int *lnptr;	/* pointer to the destination line */
	X	int i;
	X	int ccol;	/* current column cursor lives */
	X	int crow;	/*	   row	*/
	X
	X	/* find the current cursor position */
	X	rg.h.ah = 3;		/* read cursor position function code */
	X	rg.h.bh = 0;		/* current video page */
	X	int86(0x10, &rg, &rg);
	X	ccol = rg.h.dl;		/* record current column */
	X	crow = rg.h.dh;		/* and row */
	X
	X	/* build the attribute byte and setup the screen pointer */
	X#if	COLOR
	X	attr = (((cbcolor & 15) << 4) | (cfcolor & 15)) << 8;
	X#else
	X	attr = 0x0700;
	X#endif
	X	lnptr = &sline[0];
	X	for (i=0; i < NCOL; i++)
	X		*lnptr++ = SPACE | attr;
	X
	X	/* wait for vertical retrace to be off */
	X	while ((inp(0x3da) & 8))
	X		;
	X
	X	/* and to be back on */
	X	while ((inp(0x3da) & 8) == 0)
	X		;
	X
	X	/* and send the string out */
	X	memcpy(scptr[crow]+ccol, &sline[0], (NCOL-ccol)*2);
	X
	X}
	X
	Xibmputc(ch)	/* put a character at the current position in the
	X		   current colors */
	X
	Xint ch;
	X
	X{
	X	rg.h.ah = 14;		/* write char to screen with current attrs */
	X	rg.h.al = ch;
	X#if	COLOR
	X	rg.h.bl = cfcolor;
	X#else
	X	rg.h.bl = 0x07;
	X#endif
	X	int86(0x10, &rg, &rg);
	X}
	X
	Xibmeeop()
	X{
	X	int attr;		/* attribute to fill screen with */
	X
	X	rg.h.ah = 6;		/* scroll page up function code */
	X	rg.h.al = 0;		/* # lines to scroll (clear it) */
	X	rg.x.cx = 0;		/* upper left corner of scroll */
	X	rg.x.dx = 0x174f;	/* lower right corner of scroll */
	X#if	COLOR
	X	attr = ((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15);
	X#else
	X	attr = 0;
	X#endif
	X	rg.h.bh = attr;
	X	int86(0x10, &rg, &rg);
	X}
	X
	Xibmrev(state)		/* change reverse video state */
	X
	Xint state;	/* TRUE = reverse, FALSE = normal */
	X
	X{
	X	/* This never gets used under the IBM-PC driver */
	X}
	X
	Xibmbeep()
	X{
	X	bdos(6, BEL, 0);
	X}
	X
	Xibmopen()
	X{
	X	scinit();
	X	revexist = TRUE;
	X        ttopen();
	X}
	X
	Xibmclose()
	X
	X{
	X#if	COLOR
	X	ibmfcol(7);
	X	ibmbcol(0);
	X#endif
	X	ttclose();
	X}
	X
	Xscinit()	/* initialize the screen head pointers */
	X
	X{
	X	union {
	X		long laddr;	/* long form of address */
	X		int *paddr;	/* pointer form of address */
	X	} addr;
	X	int i;
	X
	X	/* initialize the screen pointer array */
	X	for (i = 0; i < NROW; i++) {
	X		addr.laddr = SCADD + (long)(NCOL * i * 2);
	X		scptr[i] = addr.paddr;
	X	}
	X}
	X
	Xscwrite(row, outstr, forg, bacg)	/* write a line out*/
	X
	Xint row;	/* row of screen to place outstr on */
	Xchar *outstr;	/* string to write out (must be NCOL long) */
	Xint forg;	/* forground color of string to write */
	Xint bacg;	/* background color */
	X
	X{
	X	int attr;	/* attribute byte mask to place in RAM */
	X	int *lnptr;	/* pointer to the destination line */
	X	int i;
	X
	X	/* build the attribute byte and setup the screen pointer */
	X#if	COLOR
	X	attr = (((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) << 8;
	X#else
	X	attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
	X#endif
	X	lnptr = &sline[0];
	X	for (i=0; i<NCOL; i++)
	X		*lnptr++ = (outstr[i] & 255) | attr;
	X
	X	/* wait for vertical retrace to be off */
	X	while ((inp(0x3da) & 8))
	X		;
	X
	X	/* and to be back on */
	X	while ((inp(0x3da) & 8) == 0)
	X		;
	X
	X	/* and send the string out */
	X	memcpy(scptr[row], &sline[0], NCOL*2);
	X}
	X#else
	Xibmhello()
	X{
	X}
	X#endif
SHAR_EOF
if test 5604 -ne "`wc -c < 'ibmpc.c'`"
then
	echo shar: "error transmitting 'ibmpc.c'" '(should have been 5604 characters)'
fi
fi
echo shar: "extracting 'termio.c'" '(12322 characters)'
if test -f 'termio.c'
then
	echo shar: "will not over-write existing file 'termio.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'termio.c'
	X/*
	X * The functions in this file negotiate with the operating system for
	X * characters, and write characters in a barely buffered fashion on the display.
	X * All operating systems.
	X */
	X#include        <stdio.h>
	X#include	"estruct.h"
	X#include        "edef.h"
	X
	X#if     AMIGA
	X#define NEW 1006
	X#define AMG_MAXBUF      1024
	Xstatic long terminal;
	Xstatic char     scrn_tmp[AMG_MAXBUF+1];
	Xstatic int      scrn_tmp_p = 0;
	X#endif
	X
	X#if     VMS
	X#include        <stsdef.h>
	X#include        <ssdef.h>
	X#include        <descrip.h>
	X#include        <iodef.h>
	X#include        <ttdef.h>
	X#include	<tt2def.h>
	X
	X#define NIBUF   128                     /* Input buffer size            */
	X#define NOBUF   1024                    /* MM says bug buffers win!     */
	X#define EFN     0                       /* Event flag                   */
	X
	Xchar    obuf[NOBUF];                    /* Output buffer                */
	Xint     nobuf;                  /* # of bytes in above    */
	Xchar    ibuf[NIBUF];                    /* Input buffer          */
	Xint     nibuf;                  /* # of bytes in above  */
	Xint     ibufi;                  /* Read index                   */
	Xint     oldmode[3];                     /* Old TTY mode bits            */
	Xint     newmode[3];                     /* New TTY mode bits            */
	Xshort   iochan;                  /* TTY I/O channel             */
	X#endif
	X
	X#if     CPM
	X#include        <bdos.h>
	X#endif
	X
	X#if     MSDOS & (LATTICE | MSC)
	Xunion REGS rg;		/* cpu register for use of DOS calls */
	Xint nxtchar = -1;	/* character held from type ahead    */
	X#endif
	X
	X#if RAINBOW
	X#include "rainbow.h"
	X#endif
	X
	X#if	USG			/* System V */
	X#include	<signal.h>
	X#include	<termio.h>
	Xstruct	termio	otermio;	/* original terminal characteristics */
	Xstruct	termio	ntermio;	/* charactoristics to use inside */
	X#endif
	X
	X#if V7 | BSD
	X#undef	CTRL
	X#include        <sgtty.h>        /* for stty/gtty functions */
	X#include	<signal.h>
	Xstruct  sgttyb  ostate;          /* saved tty state */
	Xstruct  sgttyb  nstate;          /* values for editor mode */
	Xstruct tchars	otchars;	/* Saved terminal special character set */
	Xstruct tchars	ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
	X				/* A lot of nothing */
	X#if BSD
	X#include <sys/ioctl.h>		/* to get at the typeahead */
	Xextern	int rtfrmshell();	/* return from suspended shell */
	X#define	TBUFSIZ	128
	Xchar tobuf[TBUFSIZ];		/* terminal output buffer */
	X#endif
	X#endif
	X
	X/*
	X * This function is called once to set up the terminal device streams.
	X * On VMS, it translates TT until it finds the terminal, then assigns
	X * a channel to it and sets it raw. On CPM it is a no-op.
	X */
	Xttopen()
	X{
	X	/* on all screens we are not sure of the initial position
	X	   of the cursor					*/
	X	ttrow = 999;
	X	ttcol = 999;
	X
	X#if     AMIGA
	X        terminal = Open("RAW:1/1/639/199/MicroEMACS 3.7/Amiga", NEW);
	X#endif
	X#if     VMS
	X        struct  dsc$descriptor  idsc;
	X        struct  dsc$descriptor  odsc;
	X        char    oname[40];
	X        int     iosb[2];
	X        int     status;
	X
	X        odsc.dsc$a_pointer = "TT";
	X        odsc.dsc$w_length  = strlen(odsc.dsc$a_pointer);
	X        odsc.dsc$b_dtype        = DSC$K_DTYPE_T;
	X        odsc.dsc$b_class        = DSC$K_CLASS_S;
	X        idsc.dsc$b_dtype        = DSC$K_DTYPE_T;
	X        idsc.dsc$b_class        = DSC$K_CLASS_S;
	X        do {
	X                idsc.dsc$a_pointer = odsc.dsc$a_pointer;
	X                idsc.dsc$w_length  = odsc.dsc$w_length;
	X                odsc.dsc$a_pointer = &oname[0];
	X                odsc.dsc$w_length  = sizeof(oname);
	X                status = LIB$SYS_TRNLOG(&idsc, &odsc.dsc$w_length, &odsc);
	X                if (status!=SS$_NORMAL && status!=SS$_NOTRAN)
	X                        exit(status);
	X                if (oname[0] == 0x1B) {
	X                        odsc.dsc$a_pointer += 4;
	X                        odsc.dsc$w_length  -= 4;
	X                }
	X        } while (status == SS$_NORMAL);
	X        status = SYS$ASSIGN(&odsc, &iochan, 0, 0);
	X        if (status != SS$_NORMAL)
	X                exit(status);
	X        status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0,
	X                          oldmode, sizeof(oldmode), 0, 0, 0, 0);
	X        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
	X                exit(status);
	X        newmode[0] = oldmode[0];
	X        newmode[1] = oldmode[1] | TT$M_NOECHO;
	X        newmode[1] &= ~(TT$M_TTSYNC|TT$M_HOSTSYNC);
	X        newmode[2] = oldmode[2] | TT2$M_PASTHRU;
	X        status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
	X                          newmode, sizeof(newmode), 0, 0, 0, 0);
	X        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
	X                exit(status);
	X        term.t_nrow = (newmode[1]>>24) - 1;
	X        term.t_ncol = newmode[0]>>16;
	X
	X#endif
	X#if     CPM
	X#endif
	X
	X#if     MSDOS & (HP150 == 0) & LATTICE
	X	/* kill the ctrl-break interupt */
	X	rg.h.ah = 0x33;		/* control-break check dos call */
	X	rg.h.al = 1;		/* set the current state */
	X	rg.h.dl = 0;		/* set it OFF */
	X	intdos(&rg, &rg);	/* go for it! */
	X#endif
	X
	X#if	USG
	X	ioctl(o, TCGETA, &otermio);	/* save old settings */
	X	ntermio.c_iflag = 0;		/* setup new settings */
	X	ntermio.c_oflag = 0;
	X	ntermio.c_cflag = otermio.c_cflag;
	X	ntermio.c_lflag = 0;
	X	ntermio.c_line = otermio.c_line;
	X	ntermio.c_cc[VMIN] = 1;
	X	ntermio.c_cc[VTIME] = 0;
	X	ioctl(0, TCSETA, &ntermio);	/* and activate them */
	X#endif
	X
	X#if     V7 | BSD
	X        gtty(0, &ostate);                       /* save old state */
	X        gtty(0, &nstate);                       /* get base of new state */
	X        nstate.sg_flags |= RAW;
	X        nstate.sg_flags &= ~(ECHO|CRMOD);       /* no echo for now... */
	X        stty(0, &nstate);                       /* set mode */
	X	ioctl(0, TIOCGETC, &otchars);		/* Save old characters */
	X	ioctl(0, TIOCSETC, &ntchars);		/* Place new character into K */
	X#if	BSD
	X	/* provide a smaller terminal output buffer so that
	X	   the type ahead detection works better (more often) */
	X	setbuffer(stdout, &tobuf[0], TBUFSIZ);
	X	signal(SIGTSTP,SIG_DFL);	/* set signals so that we can */
	X	signal(SIGCONT,rtfrmshell);	/* suspend & restart emacs */
	X#endif
	X#endif
	X}
	X
	X/*
	X * This function gets called just before we go back home to the command
	X * interpreter. On VMS it puts the terminal back in a reasonable state.
	X * Another no-operation on CPM.
	X */
	Xttclose()
	X{
	X#if     AMIGA
	X        amg_flush();
	X        Close(terminal);
	X#endif
	X#if     VMS
	X        int     status;
	X        int     iosb[1];
	X
	X        ttflush();
	X        status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
	X                 oldmode, sizeof(oldmode), 0, 0, 0, 0);
	X        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
	X                exit(status);
	X        status = SYS$DASSGN(iochan);
	X        if (status != SS$_NORMAL)
	X                exit(status);
	X#endif
	X#if     CPM
	X#endif
	X#if     MSDOS & (HP150 == 0) & LATTICE
	X	/* restore the ctrl-break interupt */
	X	rg.h.ah = 0x33;		/* control-break check dos call */
	X	rg.h.al = 1;		/* set the current state */
	X	rg.h.dl = 1;		/* set it ON */
	X	intdos(&rg, &rg);	/* go for it! */
	X#endif
	X
	X#if	USG
	X	ioctl(0, TCSETA, &otermio);	/* restore terminal settings */
	X#endif
	X
	X#if     V7 | BSD
	X        stty(0, &ostate);
	X	ioctl(0, TIOCSETC, &otchars);	/* Place old character into K */
	X#endif
	X}
	X
	X/*
	X * Write a character to the display. On VMS, terminal output is buffered, and
	X * we just put the characters in the big array, after checking for overflow.
	X * On CPM terminal I/O unbuffered, so we just write the byte out. Ditto on
	X * MS-DOS (use the very very raw console output routine).
	X */
	Xttputc(c)
	X#if     AMIGA
	X        char c;
	X#endif
	X{
	X#if     AMIGA
	X        scrn_tmp[scrn_tmp_p++] = c;
	X        if(scrn_tmp_p>=AMG_MAXBUF)
	X                amg_flush();
	X#endif
	X#if     VMS
	X        if (nobuf >= NOBUF)
	X                ttflush();
	X        obuf[nobuf++] = c;
	X#endif
	X
	X#if     CPM
	X        bios(BCONOUT, c, 0);
	X#endif
	X
	X#if     MSDOS & MWC86
	X        dosb(CONDIO, c, 0);
	X#endif
	X
	X#if	MSDOS & (LATTICE | AZTEC) & ~IBMPC
	X	bdos(6, c, 0);
	X#endif
	X
	X#if RAINBOW
	X        Put_Char(c);                    /* fast video */
	X#endif
	X
	X
	X#if     V7 | USG | BSD
	X        fputc(c, stdout);
	X#endif
	X}
	X
	X#if	AMIGA
	Xamg_flush()
	X{
	X        if(scrn_tmp_p)
	X                Write(terminal,scrn_tmp,scrn_tmp_p);
	X        scrn_tmp_p = 0;
	X}
	X#endif
	X
	X/*
	X * Flush terminal buffer. Does real work where the terminal output is buffered
	X * up. A no-operation on systems where byte at a time terminal I/O is done.
	X */
	Xttflush()
	X{
	X#if     AMIGA
	X        amg_flush();
	X#endif
	X#if     VMS
	X        int     status;
	X        int     iosb[2];
	X
	X        status = SS$_NORMAL;
	X        if (nobuf != 0) {
	X                status = SYS$QIOW(EFN, iochan, IO$_WRITELBLK|IO$M_NOFORMAT,
	X                         iosb, 0, 0, obuf, nobuf, 0, 0, 0, 0);
	X                if (status == SS$_NORMAL)
	X                        status = iosb[0] & 0xFFFF;
	X                nobuf = 0;
	X        }
	X        return (status);
	X#endif
	X
	X#if     CPM
	X#endif
	X
	X#if     MSDOS
	X#endif
	X
	X#if     V7 | USG | BSD
	X        fflush(stdout);
	X#endif
	X}
	X
	X/*
	X * Read a character from the terminal, performing no editing and doing no echo
	X * at all. More complex in VMS that almost anyplace else, which figures. Very
	X * simple on CPM, because the system can do exactly what you want.
	X */
	Xttgetc()
	X{
	X#if     AMIGA
	X        char ch;
	X        amg_flush();
	X        Read(terminal, &ch, 1);
	X        return(255 & (int)ch);
	X#endif
	X#if     VMS
	X        int     status;
	X        int     iosb[2];
	X        int     term[2];
	X
	X        while (ibufi >= nibuf) {
	X                ibufi = 0;
	X                term[0] = 0;
	X                term[1] = 0;
	X                status = SYS$QIOW(EFN, iochan, IO$_READLBLK|IO$M_TIMED,
	X                         iosb, 0, 0, ibuf, NIBUF, 0, term, 0, 0);
	X                if (status != SS$_NORMAL)
	X                        exit(status);
	X                status = iosb[0] & 0xFFFF;
	X                if (status!=SS$_NORMAL && status!=SS$_TIMEOUT)
	X                        exit(status);
	X                nibuf = (iosb[0]>>16) + (iosb[1]>>16);
	X                if (nibuf == 0) {
	X                        status = SYS$QIOW(EFN, iochan, IO$_READLBLK,
	X                                 iosb, 0, 0, ibuf, 1, 0, term, 0, 0);
	X                        if (status != SS$_NORMAL
	X                        || (status = (iosb[0]&0xFFFF)) != SS$_NORMAL)
	X                                exit(status);
	X                        nibuf = (iosb[0]>>16) + (iosb[1]>>16);
	X                }
	X        }
	X        return (ibuf[ibufi++] & 0xFF);    /* Allow multinational  */
	X#endif
	X
	X#if     CPM
	X        return (biosb(BCONIN, 0, 0));
	X#endif
	X
	X#if RAINBOW
	X        int Ch;
	X
	X        while ((Ch = Read_Keyboard()) < 0);
	X
	X        if ((Ch & Function_Key) == 0)
	X                if (!((Ch & 0xFF) == 015 || (Ch & 0xFF) == 0177))
	X                        Ch &= 0xFF;
	X
	X        return Ch;
	X#endif
	X
	X#if     MSDOS & MWC86
	X        return (dosb(CONRAW, 0, 0));
	X#endif
	X
	X#if	MSDOS & (LATTICE | MSC)
	X	int c;		/* character read */
	X
	X	/* if a char already is ready, return it */
	X	if (nxtchar >= 0) {
	X		c = nxtchar;
	X		nxtchar = -1;
	X		return(c);
	X	}
	X
	X	/* call the dos to get a char */
	X	rg.h.ah = 7;		/* dos Direct Console Input call */
	X	intdos(&rg, &rg);
	X	c = rg.h.al;		/* grab the char */
	X	return(c & 255);
	X#endif
	X
	X#if	MSDOS & AZTEC
	X	int c;		/* character read */
	X
	X	/* if a char already is ready, return it */
	X	if (nxtchar >= 0) {
	X		c = nxtchar;
	X		nxtchar = -1;
	X		return(c);
	X	}
	X
	X	/* call the dos to get a char */
	X	rg.h.ah = 7;		/* dos Direct Console I/O call */
	X	sysint(33, &rg, &rg);
	X	c = rg.h.al;		/* grab the char */
	X	return(c & 255);
	X#endif
	X
	X#if     V7 | USG | BSD
	X        return(127 & fgetc(stdin));
	X#endif
	X}
	X
	X#if	TYPEAH
	X/* typahead:	Check to see if any characters are already in the
	X		keyboard buffer
	X*/
	X
	Xtypahead()
	X
	X{
	X#if	MSDOS & (LATTICE | AZTEC)
	X	int c;		/* character read */
	X	int flags;	/* cpu flags from dos call */
	X
	X#if	MSC
	X	if (kbhit() != 0)
	X		return(TRUE);
	X	else
	X		return(FALSE);
	X#endif
	X
	X	if (nxtchar >= 0)
	X		return(TRUE);
	X
	X	rg.h.ah = 6;	/* Direct Console I/O call */
	X	rg.h.dl = 255;	/*         does console input */
	X#if	LATTICE
	X	flags = intdos(&rg, &rg);
	X#else
	X	flags = sysint(33, &rg, &rg);
	X#endif
	X	c = rg.h.al;	/* grab the character */
	X
	X	/* no character pending */
	X	if ((flags & 64) != 0)
	X		return(FALSE);
	X
	X	/* save the character and return true */
	X	nxtchar = c;
	X	return(TRUE);
	X#endif
	X
	X#if	BSD
	X	int x;	/* holds # of pending chars */
	X
	X	return((ioctl(0,FIONREAD,&x) < 0) ? 0 : x);
	X#endif
	X	return(FALSE);
	X}
	X#endif
SHAR_EOF
if test 12322 -ne "`wc -c < 'termio.c'`"
then
	echo shar: "error transmitting 'termio.c'" '(should have been 12322 characters)'
fi
fi
exit 0
#	End of shell archive
----------CUT HERE---------

T. Chow