[comp.os.minix] Tandy 1000 tty.c

beattie@netxcom.UUCP (Brian Beattie) (05/29/87)

Below are the diffs for the the tty.c I am currently using on my
Tandy 1000.  The things I have changed are:

1).	Scan table. (f11 does mined search back, f12 does mined search
	forward).

2).	Caps lock and num lock now work.

3).	I use the scrolling code previously posted.

4).	I use (ALT)f1 etc. instead of f1 to dump process table.

----------- cut here -------------
*** tty.c.old	Tue May 19 12:40:08 1987
--- tty.c	Fri May 29 06:20:15 1987
***************
*** 62,67
  #define TAB_SIZE           8	/* distance between tabs */
  #define TAB_MASK          07	/* mask for tty_column when tabbing */
  #define MAX_OVERRUN       16	/* size of overrun input buffer */
  
  #define ERASE_CHAR      '\b'	/* default erase character */
  #define KILL_CHAR (char) 025	/* default kill character */

--- 62,68 -----
  #define TAB_SIZE           8	/* distance between tabs */
  #define TAB_MASK          07	/* mask for tty_column when tabbing */
  #define MAX_OVERRUN       16	/* size of overrun input buffer */
+ #define T1000		   1	/* Tandy 1000 */
  
  #define ERASE_CHAR      '\b'	/* default erase character */
  #define KILL_CHAR (char) 025	/* default kill character */
***************
*** 154,165
  
  /* Scan codes to ASCII for unshifted keys */
  PRIVATE char unsh[] = {
!  0,033,'1','2','3','4','5','6',        '7','8','9','0','-','=','\b','\t',
!  'q','w','e','r','t','y','u','i',      'o','p','[',']',015,0202,'a','s',
!  'd','f','g','h','j','k','l',';',      047,0140,0200,0134,'z','x','c','v',
!  'b','n','m',',','.','/',0201,'*',     0203,' ',0204,0241,0242,0243,0244,0245,
!  0246,0247,0250,0251,0252,0205,0210,0267,  0270,0271,0211,0264,0265,0266,0214
! ,0261,  0262,0263,'0',0177
  };
  
  /* Scan codes to ASCII for shifted keys */

--- 155,172 -----
  
  /* Scan codes to ASCII for unshifted keys */
  PRIVATE char unsh[] = {
! /* 00 */ 0,033,'1','2','3','4','5','6',
! /* 08 */ '7','8','9','0','-','=','\b','\t',
! /* 10 */ 'q','w','e','r','t','y','u','i',
! /* 18 */ 'o','p','[',']',015,0202,'a','s',
! /* 20 */ 'd','f','g','h','j','k','l',';',
! /* 28 */ 047,0270,0200,0264,'z','x','c','v',
! /* 30 */ 'b','n','m',',','.','/',0201,'*',
! /* 38 */ 0203,' ',0204,0241,0242,0243,0244,0245,
! /* 40 */ 0246,0247,0250,0251,0252,0205,0210,0134,
! /* 48 */ 0176,0271,0262,0174,'5','6',0266,0261,
! /* 50 */ 0140,0263,'0',0177,03,'+','.',012,0267,
! /* 58 */ 0211,0214
  };
  
  /* Scan codes to ASCII for shifted keys */
***************
*** 164,175
  
  /* Scan codes to ASCII for shifted keys */
  PRIVATE char sh[] = {
!  0,033,'!','@','#','$','%','^',        '&','*','(',')','_','+','\b','\t',
!  'Q','W','E','R','T','Y','U','I',      'O','P','{','}',015,0202,'A','S',
!  'D','F','G','H','J','K','L',':',      042,'~',0200,'|','Z','X','C','V',
!  'B','N','M','<','>','?',0201,'*',    0203,' ',0204,0221,0222,0223,0224,0225,
!  0226,0227,0230,0231,0232,0204,0213,'7',  '8','9',0211,'4','5','6',0214,'1',
!  '2','3','0',177
  };
  
  

--- 171,188 -----
  
  /* Scan codes to ASCII for shifted keys */
  PRIVATE char sh[] = {
! /* 00 */ 0,033,'!','@','#','$','%','^',
! /* 08 */ '&','*','(',')','_','+','\b','\t',
! /* 10 */ 'Q','W','E','R','T','Y','U','I',
! /* 18 */ 'O','P','{','}',012,0202,'A','S',
! /* 20 */ 'D','F','G','H','J','K','L',':',
! /* 28 */ 042,0270,0200,0264,'Z','X','C','V',
! /* 30 */ 'B','N','M','<','>','?',0201,'*',
! /* 38 */ 0203,' ',0204,0221,0222,0223,0224,0225,
! /* 40 */ 0226,0227,0230,0231,0232,0204,0210,'7',
! /* 48 */ '8','9',0262,'4','5','6',0266,'1',
! /* 50 */ '2','3','0','-',03,'+','.',012,0267,
! /* 58 */ 0211,0214
  };
  
  
***************
*** 281,287
   *				in_char					     *
   *===========================================================================*/
  PRIVATE in_char(line, ch)
! 	int line;			/* line number on which char arrived */
  char ch;			/* scan code for character that arrived */
  {
  /* A character has just been typed in.  Process, save, and echo it. */

--- 294,300 -----
   *				in_char					     *
   *===========================================================================*/
  PRIVATE in_char(line, ch)
! int line;			/* line number on which char arrived */
  char ch;			/* scan code for character that arrived */
  {
  /* A character has just been typed in.  Process, save, and echo it. */
***************
*** 291,298
    char make_break();
    tp = &tty_struct[line];	/* set 'tp' to point to proper struct */
    /* Function keys are temporarily being used for debug dumps. */
!   if (alt && ch >= F1 && ch <= F10) {
!  		 /* Check for function keys F1, F2, ... F10 */
  	func_key(ch);		/* process function key */
  	return;
    }

--- 304,310 -----
    char make_break();
    tp = &tty_struct[line];	/* set 'tp' to point to proper struct */
    /* Function keys are temporarily being used for debug dumps. */
!   if (alt && ch >= F1 && ch <= F10) {	/* Check for function keys F1, F2, ... F10 */
  	func_key(ch);		/* process function key */
  	return;
    }
***************
*** 371,377
  	}
  
  	/* Check for and process CTRL-S (terminal stop). */
! 	if (ch == tp->tty_xoff || ch == HOLD) {
  		tp->tty_inhibited = STOPPED;
  		return;
  	}

--- 383,389 -----
  	}
  
  	/* Check for and process CTRL-S (terminal stop). */
! 	if (ch == tp->tty_xoff) {
  		tp->tty_inhibited = STOPPED;
  		return;
  	}
***************
*** 377,383
  	}
  
  	/* Check for and process CTRL-Q (terminal start). */
! 	if (ch == tp->tty_xon || ch == HOLD) {
  		tp->tty_inhibited = RUNNING;
  		(*tp->tty_devstart)(tp);	/* resume output */
  		return;

--- 389,395 -----
  	}
  
  	/* Check for and process CTRL-Q (terminal start). */
! 	if (ch == tp->tty_xon) {
  		tp->tty_inhibited = RUNNING;
  		(*tp->tty_devstart)(tp);	/* resume output */
  		return;
***************
*** 415,421
  	/* Standard IBM keyboard. */
  	code = (shift1 || shift2 ? sh[c] : unsh[c]);
  	if (capslock && code >= 'a' && code <= 'z')
! 		code sh[c];
  	if (control && c < TOP_ROW) code = sh[c];	/* CTRL-(top row) */
  	if (c > 70 && numlock) code = sh[c];	/* numlock depressed */
    } else {

--- 427,433 -----
  	/* Standard IBM keyboard. */
  	code = (shift1 || shift2 ? sh[c] : unsh[c]);
  	if (capslock && code >= 'a' && code <= 'z')
! 		code -= 32;			/* capitalize alpha */
  	if (control && c < TOP_ROW) code = sh[c];	/* CTRL-(top row) */
  	if (c > 70 && numlock) code = sh[c];	/* numlock depressed */
    } else {
***************
*** 420,428
  	if (c > 70 && numlock) code = sh[c];	/* numlock depressed */
    } else {
  	/* (Olivetti M24 or AT&T 6300) with Olivetti-style keyboard. */
! 	code = (shift1 || shift2 ? m24[c] : unm24[c]);
! 	if (capslock && code >= 'a' && code <= 'z')
! 		code sh[c];
  	if (control && c < TOP_ROW) code = sh[c];	/* CTRL-(top row) */
  	if (c > 70 && numlock) code = m24[c];	/* numlock depressed */
    }

--- 432,438 -----
  	if (c > 70 && numlock) code = sh[c];	/* numlock depressed */
    } else {
  	/* (Olivetti M24 or AT&T 6300) with Olivetti-style keyboard. */
! 	code = (shift1 || shift2 || capslock ? m24[c] : unm24[c]);
  	if (control && c < TOP_ROW) code = sh[c];	/* CTRL-(top row) */
  	if (c > 70 && numlock) code = m24[c];	/* numlock depressed */
    }
***************
*** 445,451
  #ifdef T1000
      case 4:	capslock = make;	break;	/* caps lock */
      case 5:	numlock = make;		break;	/* num lock */
-     case 6:	return(HOLD);			/* scroll lock */
  #else
      case 4:	if (make) capslock = 1 - capslock; break;	/* caps lock */
      case 5:	if (make) numlock  = 1 - numlock;  break;	/* num lock */

--- 455,460 -----
  #ifdef T1000
      case 4:	capslock = make;	break;	/* caps lock */
      case 5:	numlock = make;		break;	/* num lock */
  #else
      case 4:	if (make) capslock = 1 - capslock; break;	/* caps lock */
      case 5:	if (make) numlock  = 1 - numlock;  break;	/* num lock */
***************
*** 846,852
    k = code - 0200;		/* codes > 0200 mean key release */
    if (k > 0) {
  	/* A key has been released. */
! 	if (k != 29 && k != 42 && k != 54 && k != 56 && k != 69) {
  		port_out(INT_CTL, ENABLE);	/* re-enable interrupts */
  	 	return;		/* don't call tty_task() */
  	}

--- 855,862 -----
    k = code - 0200;		/* codes > 0200 mean key release */
    if (k > 0) {
  	/* A key has been released. */
! 	if (k != 29 && k != 42 && k != 54 && k != 56 && k !=58 &&
! 			k != 69) {
  		port_out(INT_CTL, ENABLE);	/* re-enable interrupts */
  	 	return;		/* don't call tty_task() */
  	}
***************
*** 1021,1030
  register struct tty_struct *tp;	/* pointer to tty struct */
  int dir;			/* GO_FORWARD or GO_BACKWARD */
  {
-   int amount, offset;
- 
-   amount = (dir == GO_FORWARD ? 2 * LINE_WIDTH : -2 * LINE_WIDTH);
-   tp->tty_org = (tp->tty_org + amount) & vid_mask;
    if (dir == GO_FORWARD)
  	offset = (tp->tty_org + 2 * (SCR_LINES - 1) * LINE_WIDTH) & vid_mask;
    else

--- 1031,1036 -----
  register struct tty_struct *tp;	/* pointer to tty struct */
  int dir;			/* GO_FORWARD or GO_BACKWARD */
  {
    if (dir == GO_FORWARD)
    {
      scr_up(vid_base);
***************
*** 1026,1038
    amount = (dir == GO_FORWARD ? 2 * LINE_WIDTH : -2 * LINE_WIDTH);
    tp->tty_org = (tp->tty_org + amount) & vid_mask;
    if (dir == GO_FORWARD)
! 	offset = (tp->tty_org + 2 * (SCR_LINES - 1) * LINE_WIDTH) & vid_mask;
!   else
! 	offset = tp->tty_org;
! 
!   /* Blank the new line at top or bottom. */
!   vid_copy(NIL_PTR, vid_base, offset, LINE_WIDTH);
!   set_6845(VID_ORG, tp->tty_org >> 1);	/* 6845 thinks in words */
  }
  
  

--- 1032,1045 -----
  int dir;			/* GO_FORWARD or GO_BACKWARD */
  {
    if (dir == GO_FORWARD)
!   {
!     scr_up(vid_base);
!     vid_copy(NIL_PTR, vid_base, tp->tty_org+2*(SCR_LINES-1)*LINE_WIDTH,
!        LINE_WIDTH);
!   } else {
!     scr_dn(vid_base);
!     vid_copy(NIL_PTR, vid_base, tp->tty_org, LINE_WIDTH);
!   }
  }
  
  
-- 
-----------------------------------------------------------------------
Brian Beattie			| Phone: (703)749-2365
NetExpress Communications, Inc.	| uucp: seismo!sundc!netxcom!beattie
1953 Gallows Road, Suite 300	|
Vienna,VA 22180			|