[net.sources.games] Curse-d version of Chris Torek's "adv"

chris@hwcs.UUCP (Chris Miller) (09/20/85)

These are the patches for converting the Maryland Windows version of
Chris Torek's "adv", posted some time ago to this group, to use
curses.  The main difference is that with the curse-d version the upper
window, displaying the current room, is of constant size (half the
screen) instead of shrinking to stay as small as possible.

The fixes really require a version of "curses" that will exploit the
add-/delete-line capability of many terminals, and a terminal with
these capabilities; patches to "curses" to achieve this were posted
recently by Tom Truscott as part of the distribution of the "wm" window
manager.  However, the program should run even without such fixes; just
slowly!

To install these patches, type "| patch -d ADVDIR" at your news-reading
program if (a) it understands how to pipe articles to commands,
(b) you have "patch", (c) ADVDIR is the name of the directory containing
the unpacked distribution of "adv" and (d) you have write permission
therein.

Failing (a), save the article and run patch by hand afterwards;
failing (b) you will have quite a lot of work to do installing about
200 lines of new code by hand - after one such attempt you will probably
want to get hold of "patch"! Failing (c), I can't help you much; I am
certainly NOT going to repost the whole of "adv", so you will have to go
begging from your neighbours.
-------------------------------
diff -rc orig/Makefile cursed/Makefile
*** orig/Makefile	Fri Aug 23 13:06:32 1985
--- cursed/Makefile	Sun Sep  1 14:49:04 1985
***************
*** 1,5
  DESTDIR=
! CFLAGS=	-O
  OBJS=	main.o alc.o str.o readin.o nxtwrd.o rdr.o init.o\
  	play.o misc.o prt.o file.o disply.o
  SRCS=	main.c alc.c str.c readin.c nxtwrd.c rdr.c init.c\

--- 1,6 -----
  DESTDIR=
! CFLAGS=	-O -DCURSED
! # Use -DCURSED to get the "curses" version
  OBJS=	main.o alc.o str.o readin.o nxtwrd.o rdr.o init.o\
  	play.o misc.o prt.o file.o disply.o
  SRCS=	main.c alc.c str.c readin.c nxtwrd.c rdr.c init.c\
***************
*** 4,9
  	play.o misc.o prt.o file.o disply.o
  SRCS=	main.c alc.c str.c readin.c nxtwrd.c rdr.c init.c\
  	play.c misc.c prt.c file.c disply.c
  
  adv:	$(OBJS)
  	$(CC) $(CFLAGS) -o adv $(OBJS) -lwinlib -ltermlib

--- 5,12 -----
  	play.o misc.o prt.o file.o disply.o
  SRCS=	main.c alc.c str.c readin.c nxtwrd.c rdr.c init.c\
  	play.c misc.c prt.c file.c disply.c
+ LIB=	curses
+ # LIB=curses for the "curses" version, LIB=winlib" for the original
  
  adv:	$(OBJS)
  	$(CC) $(CFLAGS) -o adv $(OBJS) -l$(LIB) -ltermlib
***************
*** 6,12
  	play.c misc.c prt.c file.c disply.c
  
  adv:	$(OBJS)
! 	$(CC) $(CFLAGS) -o adv $(OBJS) -lwinlib -ltermlib
  
  $(OBJS): adv.h
  

--- 9,15 -----
  # LIB=curses for the "curses" version, LIB=winlib" for the original
  
  adv:	$(OBJS)
! 	$(CC) $(CFLAGS) -o adv $(OBJS) -l$(LIB) -ltermlib
  
  $(OBJS): adv.h
  
diff -rc orig/adv.h cursed/adv.h
*** orig/adv.h	Fri Aug 23 13:06:32 1985
--- cursed/adv.h	Sat Aug 31 15:44:46 1985
***************
*** 1,4
  #include <stdio.h>
  #include <local/window.h>
  
  #define	refresh() (WRCurRow = BaseWin->w_cursor.row, \

--- 1,5 -----
  #include <stdio.h>
+ #ifndef CURSED
  #include <local/window.h>
  #else CURSED
  #include <curses.h>
***************
*** 1,5
  #include <stdio.h>
  #include <local/window.h>
  
  #define	refresh() (WRCurRow = BaseWin->w_cursor.row, \
  		   WRCurCol = BaseWin->w_cursor.col, \

--- 1,9 -----
  #include <stdio.h>
  #ifndef CURSED
  #include <local/window.h>
+ #else CURSED
+ #include <curses.h>
+ #endif CURSED
  
  #ifndef CURSED
  #define	refresh() (WRCurRow = BaseWin->w_cursor.row, \
***************
*** 1,6
  #include <stdio.h>
  #include <local/window.h>
  
  #define	refresh() (WRCurRow = BaseWin->w_cursor.row, \
  		   WRCurCol = BaseWin->w_cursor.col, \
  		   Wrefresh(0))

--- 5,11 -----
  #include <curses.h>
  #endif CURSED
  
+ #ifndef CURSED
  #define	refresh() (WRCurRow = BaseWin->w_cursor.row, \
  		   WRCurCol = BaseWin->w_cursor.col, \
  		   Wrefresh(0))
***************
*** 4,9
  #define	refresh() (WRCurRow = BaseWin->w_cursor.row, \
  		   WRCurCol = BaseWin->w_cursor.col, \
  		   Wrefresh(0))
  
  #define BOOL		char
  #ifndef TRUE

--- 9,27 -----
  #define	refresh() (WRCurRow = BaseWin->w_cursor.row, \
  		   WRCurCol = BaseWin->w_cursor.col, \
  		   Wrefresh(0))
+ #else CURSED
+ #undef	refresh
+ typedef	WINDOW	Win;
+ #define	refresh() (wrefresh(TopWin), wrefresh(BaseWin))
+ #define	Wrefresh(n) (n ? wrefresh(n) : (wrefresh(TopWin), wrefresh(BaseWin)))
+ #define	Wclear(w, n) wclear(w)
+ #define	WAcursor(w, x, y) wmove(w, (x), (y))
+ #define Wputs(s, w) waddstr(w, s)
+ #define Wputc(c, w) waddch(w, c)
+ #define	Wcleanup() endwin()
+ #define	Wexit(n) (endwin(), exit(n))
+ #define ROWS LINES
+ #endif CURSED
  
  #define BOOL		char
  #ifndef TRUE
***************
*** 26,31
  FILE	*file;			/* Adventure file for reader */
  Win	*TopWin;		/* Top window - room description */
  Win	*BaseWin;		/* Base window - commands, etc */
  int	ROWS, COLS;		/* Screen size */
  int	ReadingTerminal;	/* True => in a getchar() */
  int	rm;			/* Current room */

--- 44,52 -----
  FILE	*file;			/* Adventure file for reader */
  Win	*TopWin;		/* Top window - room description */
  Win	*BaseWin;		/* Base window - commands, etc */
+ #ifdef CURSED
+ Win	*CurWin;		/* Current window */
+ #endif CURSED
  int	ROWS, COLS;		/* Screen size */
  int	ReadingTerminal;	/* True => in a getchar() */
  int	rm;			/* Current room */
diff -rc orig/disply.c cursed/disply.c
*** orig/disply.c	Fri Aug 23 13:06:32 1985
--- cursed/disply.c	Fri Aug 23 14:20:50 1985
***************
*** 1,5
  #include "adv.h"
  
  extern int (*nl_proc)();	/* called by prt before writing newline */
  
  static int dlleft;		/* display lines left */

--- 1,6 -----
  #include "adv.h"
  
+ #ifndef CURSED
  extern int (*nl_proc)();	/* called by prt before writing newline */
  
  static int dlleft;		/* display lines left */
***************
*** 20,25
  	Wsize(TopWin, COLS, ROWS);
  	fullsize = TRUE;
  }
  
  /*
   * Display the current room in the top window.

--- 21,27 -----
  	Wsize(TopWin, COLS, ROWS);
  	fullsize = TRUE;
  }
+ #endif CURSED
  
  /*
   * Display the current room in the top window.
***************
*** 30,35
  	register struct room *rp;
  	register struct item *ip;
  	register char *s;
  	static int f1, f2, f3, f4, f5, f6, f7, f8;
  	int (*oldnlproc)();
  

--- 32,38 -----
  	register struct room *rp;
  	register struct item *ip;
  	register char *s;
+ #ifndef CURSED
  	static int f1, f2, f3, f4, f5, f6, f7, f8;
  	int (*oldnlproc)();
  
***************
*** 40,45
  	 */
  	if (f1 == 0)
  		Wgetframe(&f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8);
  
  	/*
  	 * Flush pending line (if any).  Switch output to top window,

--- 43,49 -----
  	 */
  	if (f1 == 0)
  		Wgetframe(&f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8);
+ #endif CURSED
  
  	/*
  	 * Flush pending line (if any).  Switch output to top window,
***************
*** 50,55
  	Wclear(TopWin, 2);
  	WAcursor(TopWin, 0, 0);
  
  	/*
  	 * We now have TopWin->IYE lines available to us for printing
  	 * description text.  Set the newline procedure so that we can

--- 54,60 -----
  	Wclear(TopWin, 2);
  	WAcursor(TopWin, 0, 0);
  
+ #ifndef CURSED
  	/*
  	 * We now have TopWin->IYE lines available to us for printing
  	 * description text.  Set the newline procedure so that we can
***************
*** 58,63
  	dlleft = TopWin->IYE;
  	oldnlproc = nl_proc;
  	nl_proc = dl_newline;
  
  	/*
  	 * If it's dark, just say so.  Otherwise find all the items

--- 63,69 -----
  	dlleft = TopWin->IYE;
  	oldnlproc = nl_proc;
  	nl_proc = dl_newline;
+ #endif CURSED
  
  	/*
  	 * If it's dark, just say so.  Otherwise find all the items
***************
*** 85,90
  			else
  				prt(". ");
  			prt(0);		/* fix w_cursor */
  			if (TopWin->w_cursor.col + strlen(ip->desc) > COLS-3)
  				prt("\n");
  			prt(ip->desc);

--- 91,97 -----
  			else
  				prt(". ");
  			prt(0);		/* fix w_cursor */
+ #ifndef CURSED
  			if (TopWin->w_cursor.col + strlen(ip->desc) > COLS-3)
  				prt("\n");
  #else CURSED
***************
*** 87,92
  			prt(0);		/* fix w_cursor */
  			if (TopWin->w_cursor.col + strlen(ip->desc) > COLS-3)
  				prt("\n");
  			prt(ip->desc);
  		}
  	}

--- 94,107 -----
  #ifndef CURSED
  			if (TopWin->w_cursor.col + strlen(ip->desc) > COLS-3)
  				prt("\n");
+ #else CURSED
+ 			{
+ 				int	y, x;
+ 				getyx(TopWin, y, x);
+ 				if (x + strlen(ip->desc) > COLS-3)
+ 					prt("\n");
+ 			}
+ #endif CURSED
  			prt(ip->desc);
  		}
  	}
***************
*** 111,116
  		prt("\n");
  
  cleanup:
  	/*
  	 * Put up a nice bottom border, adjusting the window size to
  	 * the number of lines used.  Set the margins so that the

--- 126,132 -----
  		prt("\n");
  
  cleanup:
+ #ifndef CURSED
  	/*
  	 * Put up a nice bottom border, adjusting the window size to
  	 * the number of lines used.  Set the margins so that the
***************
*** 125,130
  		Wsetmargins(TopWin, 0, 0, COLS, TopWin->OYE - 1);
  		fullsize = FALSE;
  	}
  
  	/*
  	 * Switch output back to the base window.

--- 141,147 -----
  		Wsetmargins(TopWin, 0, 0, COLS, TopWin->OYE - 1);
  		fullsize = FALSE;
  	}
+ #endif CURSED
  
  	/*
  	 * Switch output back to the base window.
***************
*** 130,134
  	 * Switch output back to the base window.
  	 */
  	CurWin = BaseWin;
  	nl_proc = oldnlproc;		/* restore */
  }

--- 147,153 -----
  	 * Switch output back to the base window.
  	 */
  	CurWin = BaseWin;
+ #ifndef CURSED
  	nl_proc = oldnlproc;		/* restore */
  #endif CURSED
  }
***************
*** 131,134
  	 */
  	CurWin = BaseWin;
  	nl_proc = oldnlproc;		/* restore */
  }

--- 149,153 -----
  	CurWin = BaseWin;
  #ifndef CURSED
  	nl_proc = oldnlproc;		/* restore */
+ #endif CURSED
  }
diff -rc orig/main.c cursed/main.c
*** orig/main.c	Fri Aug 23 13:06:33 1985
--- cursed/main.c	Sat Aug 31 13:57:57 1985
***************
*** 6,11
   * advent [-name] [adventure file]
   *
   * Lots of hacks sometime in '85
   */
  
  #include "adv.h"

--- 6,14 -----
   * advent [-name] [adventure file]
   *
   * Lots of hacks sometime in '85
+  *
+  * Amendments to use "curses" library (#ifdef CURSED) by Chris Miller,
+  *  August '85.
   */
  
  #include "adv.h"
***************
*** 9,14
   */
  
  #include "adv.h"
  #undef TRUE
  #undef FALSE
  #undef LL

--- 12,18 -----
   */
  
  #include "adv.h"
+ #ifndef	CURSED
  #undef TRUE
  #undef FALSE
  #endif CURSED
***************
*** 11,16
  #include "adv.h"
  #undef TRUE
  #undef FALSE
  #undef LL
  #include <pwd.h>
  #include <ctype.h>

--- 15,21 -----
  #ifndef	CURSED
  #undef TRUE
  #undef FALSE
+ #endif CURSED
  #undef LL
  #include <pwd.h>
  #include <ctype.h>
***************
*** 68,73
  	/*
  	 * Fire up windows.
  	 */
  	if (Winit(0, 0)) {
  		printf ("Sorry, this program won't run on your terminal.\n");
  		exit(1);

--- 73,79 -----
  	/*
  	 * Fire up windows.
  	 */
+ #ifndef CURSED
  	if (Winit(0, 0)) {
  		printf ("Sorry, this program won't run on your terminal.\n");
  		exit(1);
***************
*** 72,77
  		printf ("Sorry, this program won't run on your terminal.\n");
  		exit(1);
  	}
  	printf("Hi %s, just a second while I create the world...\r\n", name);
  	fflush(stdout);
  

--- 78,84 -----
  		printf ("Sorry, this program won't run on your terminal.\n");
  		exit(1);
  	}
+ #endif CURSED
  	printf("Hi %s, just a second while I create the world...\r\n", name);
  	fflush(stdout);
  
***************
*** 75,80
  	printf("Hi %s, just a second while I create the world...\r\n", name);
  	fflush(stdout);
  
  	/*
  	 * Get some windows and set them up our way (no cursor, nice
  	 * newline mode); we'll use the real screen cursor for input.

--- 82,88 -----
  	printf("Hi %s, just a second while I create the world...\r\n", name);
  	fflush(stdout);
  
+ #ifndef CURSED
  	/*
  	 * Get some windows and set them up our way (no cursor, nice
  	 * newline mode); we'll use the real screen cursor for input.
***************
*** 89,94
  	Wnewline(BaseWin, 1);
  	Wnewline(TopWin, 1);
  	WSetRealCursor++;
  
  	/*
  	 * Read in the adventure file.

--- 97,109 -----
  	Wnewline(BaseWin, 1);
  	Wnewline(TopWin, 1);
  	WSetRealCursor++;
+ #else CURSED
+ 	initscr();
+ 	crmode();
+ 	noecho();
+ 	{
+ 		int	i;
+ 		int	boundary;
  
  		boundary = ROWS/2;		
  		TopWin = newwin(boundary, COLS, 0, 0);
***************
*** 90,95
  	Wnewline(TopWin, 1);
  	WSetRealCursor++;
  
  	/*
  	 * Read in the adventure file.
  	 */

--- 105,128 -----
  		int	i;
  		int	boundary;
  
+ 		boundary = ROWS/2;		
+ 		TopWin = newwin(boundary, COLS, 0, 0);
+ 		CurWin = BaseWin = newwin(ROWS-boundary-1, COLS,
+ 				boundary+1, 0);
+ 		if (TopWin == NULL || BaseWin == NULL) {
+ 		    Wcleanup();
+ 		    fprintf(stderr, "adv: cannot set up windows\n");
+ 		    exit(100);
+ 		}
+ 		move(boundary, 0);
+ 		for (i = 0; i < COLS; i++) {
+ 		    addch('-');
+ 		}
+ 		wrefresh(stdscr);
+ 	}
+ 	scrollok(BaseWin, TRUE);
+ #endif CURSED
+ 
  	/*
  	 * Read in the adventure file.
  	 */
***************
*** 138,143
  		Wputs(msg, TopWin);
  	}
  	else {
  		if (BaseWin->w_cursor.col)
  			Wputc('\n', BaseWin);
  		Wputs(msg, BaseWin);

--- 171,177 -----
  		Wputs(msg, TopWin);
  	}
  	else {
+ #ifndef CURSED
  		if (BaseWin->w_cursor.col)
  #endif	CURSED
  			Wputc('\n', BaseWin);
***************
*** 139,144
  	}
  	else {
  		if (BaseWin->w_cursor.col)
  			Wputc('\n', BaseWin);
  		Wputs(msg, BaseWin);
  		Wputc('\n', BaseWin);

--- 173,179 -----
  	else {
  #ifndef CURSED
  		if (BaseWin->w_cursor.col)
+ #endif	CURSED
  			Wputc('\n', BaseWin);
  		Wputs(msg, BaseWin);
  		Wputc('\n', BaseWin);
diff -rc orig/misc.c cursed/misc.c
*** orig/misc.c	Fri Aug 23 13:06:34 1985
--- cursed/misc.c	Fri Aug 23 13:59:53 1985
***************
*** 162,167
  	/*
  	 * What is this doing here?
  	 */
  	if (COLS - CurWin->w_cursor.col > bs) {
  		if (COLS - CurWin->w_cursor.col < 4)
  			Wputc('\n', CurWin);

--- 162,168 -----
  	/*
  	 * What is this doing here?
  	 */
+ #ifndef CURSED
  	if (COLS - CurWin->w_cursor.col > bs) {
  		if (COLS - CurWin->w_cursor.col < 4)
  			Wputc('\n', CurWin);
***************
*** 167,172
  			Wputc('\n', CurWin);
  		if (COLS - CurWin->w_cursor.col > bs)
  			bs = COLS - CurWin->w_cursor.col;
  	}
  
  	/*

--- 168,187 -----
  			Wputc('\n', CurWin);
  		if (COLS - CurWin->w_cursor.col > bs)
  			bs = COLS - CurWin->w_cursor.col;
+ #else CURSED
+ 	{
+ 		int	y, x;
+ 		getyx(CurWin, y, x);
+ 
+ 		if (COLS - x > bs) {
+ 			if (COLS - x < 4) {
+ 				waddch(CurWin, '\n');
+ 				x = 0;
+ 			}
+ 			if (COLS - x > bs)
+ 				bs = COLS - x;
+ 		}
+ #endif CURSED
  	}
  
  	/*
***************
*** 196,201
  			nch++;
  		}
  		else if (c == Ctl('l'))	/* redraw screen */
  			ScreenGarbaged++;
  		else if (c >= ' ' && c < 0177) {
  			bp[nch++] =c;

--- 211,217 -----
  			nch++;
  		}
  		else if (c == Ctl('l'))	/* redraw screen */
+ #ifndef CURSED
  			ScreenGarbaged++;
  #else CURSED
  			wrefresh(curscr);
***************
*** 197,202
  		}
  		else if (c == Ctl('l'))	/* redraw screen */
  			ScreenGarbaged++;
  		else if (c >= ' ' && c < 0177) {
  			bp[nch++] =c;
  			if (nch > bs)

--- 213,221 -----
  		else if (c == Ctl('l'))	/* redraw screen */
  #ifndef CURSED
  			ScreenGarbaged++;
+ #else CURSED
+ 			wrefresh(curscr);
+ #endif CURSED
  		else if (c >= ' ' && c < 0177) {
  			bp[nch++] =c;
  			if (nch > bs)
diff -rc orig/play.c cursed/play.c
*** orig/play.c	Fri Aug 23 13:06:34 1985
--- cursed/play.c	Sat Aug 31 20:00:59 1985
***************
*** 290,295
  			prt(":\n");
  			test = FALSE;
  		    }
  		    if (CurWin->w_cursor.col + strlen(ip->desc) > COLS-3)
  			prt("\n");
  		    prt(ip->desc);

--- 290,296 -----
  			prt(":\n");
  			test = FALSE;
  		    }
+ #ifndef CURSED
  		    if (CurWin->w_cursor.col + strlen(ip->desc) > COLS-3)
  			prt("\n");
  #else CURSED
***************
*** 292,297
  		    }
  		    if (CurWin->w_cursor.col + strlen(ip->desc) > COLS-3)
  			prt("\n");
  		    prt(ip->desc);
  		    prt(". ");
  		}

--- 293,307 -----
  #ifndef CURSED
  		    if (CurWin->w_cursor.col + strlen(ip->desc) > COLS-3)
  			prt("\n");
+ #else CURSED
+ 		    {
+ 		    	int	y, x;
+ 			getyx(CurWin, y, x);
+ 
+ 		 	if (x + strlen(ip->desc) > COLS-3)
+ 				prt("\n");
+ 		    }
+ #endif CURSED
  		    prt(ip->desc);
  		    prt(". ");
  		}
***************
*** 306,311
  	    items[lititm].rm = -1;
  	    isdark = FALSE;
  	when 8:				/* Score */
  	    temp = 0;
  	    for (ip = &items[1]; ip < iteme; ip++)
  		if (ip->rm == trsrm && *ip->desc == '*')

--- 316,325 -----
  	    items[lititm].rm = -1;
  	    isdark = FALSE;
  	when 8:				/* Score */
+ 	    if (tottrs == 0) {	/* Fix: Chris Miller */
+ 		prt("There aren't any treasures in this game.\n");
+ 		break;
+ 	    }			/* End of fix. */
  	    temp = 0;
  	    for (ip = &items[1]; ip < iteme; ip++)
  		if (ip->rm == trsrm && *ip->desc == '*')
diff -rc orig/prt.c cursed/prt.c
*** orig/prt.c	Fri Aug 23 13:06:35 1985
--- cursed/prt.c	Fri Aug 23 14:00:03 1985
***************
*** 5,10
  
  #include "adv.h"
  
  int (*nl_proc)();		/* if not null, called before printing \n */
  
  static char pbuf[256];

--- 5,11 -----
  
  #include "adv.h"
  
+ #ifndef CURSED
  int (*nl_proc)();		/* if not null, called before printing \n */
  
  #endif CURSED
***************
*** 7,12
  
  int (*nl_proc)();		/* if not null, called before printing \n */
  
  static char pbuf[256];
  static int pp;
  

--- 8,14 -----
  #ifndef CURSED
  int (*nl_proc)();		/* if not null, called before printing \n */
  
+ #endif CURSED
  static char pbuf[256];
  static int pp;
  
***************
*** 20,25
  	while (*s)
  		if (*s == '\n') {
  			pflush();
  			if (nl_proc)
  				(*nl_proc)();
  			Wputc(*s++, CurWin);

--- 22,28 -----
  	while (*s)
  		if (*s == '\n') {
  			pflush();
+ #ifndef CURSED
  			if (nl_proc)
  				(*nl_proc)();
  #endif CURSED
***************
*** 22,27
  			pflush();
  			if (nl_proc)
  				(*nl_proc)();
  			Wputc(*s++, CurWin);
  		}
  		else

--- 25,31 -----
  #ifndef CURSED
  			if (nl_proc)
  				(*nl_proc)();
+ #endif CURSED
  			Wputc(*s++, CurWin);
  		}
  		else
***************
*** 36,41
  	register int c;
  {
  	register char *p;
  
  	pbuf[pp++] = c;
  	if (CurWin->w_cursor.col + pp >= COLS) {

--- 40,48 -----
  	register int c;
  {
  	register char *p;
+ #ifdef CURSED
+ 	int	y, x;
+ #endif CURSED
  
  	pbuf[pp++] = c;
  #ifndef CURSED
***************
*** 38,43
  	register char *p;
  
  	pbuf[pp++] = c;
  	if (CurWin->w_cursor.col + pp >= COLS) {
  		p = &pbuf[pp];
  		*p = 0;

--- 45,51 -----
  #endif CURSED
  
  	pbuf[pp++] = c;
+ #ifndef CURSED
  	if (CurWin->w_cursor.col + pp >= COLS) {
  #else CURSED
  	getyx(CurWin, y, x);
***************
*** 39,44
  
  	pbuf[pp++] = c;
  	if (CurWin->w_cursor.col + pp >= COLS) {
  		p = &pbuf[pp];
  		*p = 0;
  		while (--p >= pbuf)

--- 47,56 -----
  	pbuf[pp++] = c;
  #ifndef CURSED
  	if (CurWin->w_cursor.col + pp >= COLS) {
+ #else CURSED
+ 	getyx(CurWin, y, x);
+ 	if (x + pp >= COLS) {
+ #endif CURSED
  		p = &pbuf[pp];
  		*p = 0;
  		while (--p >= pbuf)
***************
*** 50,55
  		*p = 0;
  		Wputs(pbuf, CurWin);
  		*p = c;
  		if (CurWin->w_cursor.col) {
  			if (nl_proc)
  				(*nl_proc)();

--- 62,68 -----
  		*p = 0;
  		Wputs(pbuf, CurWin);
  		*p = c;
+ #ifndef CURSED
  		if (CurWin->w_cursor.col) {
  			if (nl_proc)
  				(*nl_proc)();
***************
*** 53,58
  		if (CurWin->w_cursor.col) {
  			if (nl_proc)
  				(*nl_proc)();
  			Wputc('\n', CurWin);
  		}
  		while (*p == ' ')

--- 66,75 -----
  		if (CurWin->w_cursor.col) {
  			if (nl_proc)
  				(*nl_proc)();
+ #else CURSED
+ 		getyx(CurWin, y, x);
+ 		if (x) {
+ #endif CURSED
  			Wputc('\n', CurWin);
  		}
  		while (*p == ' ')
diff -rc orig/readin.c cursed/readin.c
*** orig/readin.c	Fri Aug 23 13:06:35 1985
--- cursed/readin.c	Sat Aug 31 13:59:18 1985
***************
*** 22,27
  	wrdsiz = 3;
  	s = rdr();
  
  	/*
  	 * Init specials
  	 */

--- 22,32 -----
  	wrdsiz = 3;
  	s = rdr();
  
+ 	/*  Allow #! construct as first line - Chris Miller, August 1985 */
+ 	if (*s == '#' && s[1] == '!') {
+ 	    s = rdr();
+ 	} /*  End of #! modification */
+ 
  	/*
  	 * Init specials
  	 */
-- 
	Chris Miller, Heriot-Watt University, Edinburgh
	...!ukc!hwcs!chris   chris@hwcs.uucp	chris@cs.hw.ac.uk