home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / k95source.tar.gz / k95source.tar / ckodg.c < prev    next >
C/C++ Source or Header  |  2011-07-19  |  63KB  |  1,785 lines

  1. /*  C K O D G . C  --  Data General Emulation  */
  2.  
  3. /*
  4.   Author: Jeffrey Altman <jaltman@secure-endpoints.com>,
  5.             Secure Endpoints Inc., New York City.
  6.  
  7.   Copyright (C) 1985, 2004, Trustees of Columbia University in the City of New
  8.   York.
  9. */
  10.  
  11. #include "ckcdeb.h"
  12. #ifndef NOTERM
  13. #ifdef NT
  14. #include <windows.h>
  15. #else /* NT */
  16. #include <os2.h>
  17. #undef COMMENT
  18. #endif /* NT */
  19.  
  20. #include "ckcker.h"
  21. #include "ckcasc.h"
  22. #include "ckuusr.h"
  23. #include "ckcxla.h"
  24. #include "ckuxla.h"
  25. #include "ckcuni.h"
  26. #include "ckocon.h"
  27. #include "ckodg.h"
  28. #ifdef NETCONN
  29. #ifdef TCPSOCKET
  30. #include "ckcnet.h"
  31. extern int network, nettype, ttnproto, u_binary;
  32. #endif /* TCPSOCKET */
  33. #endif /* NETCONN */
  34.  
  35. extern bool keyclick ;
  36. extern int  cursorena[], keylock, duplex, duplex_sav, screenon ;
  37. extern int  printon, aprint, uprint, cprint, xprint, seslog ;
  38. extern int  insertmode, tnlm ;
  39. extern int  escstate, debses, decscnm, tt_cursor;
  40. extern int  tt_type, tt_type_mode, tt_type_vt52, tt_max, tt_answer, tt_status[VNUM], tt_szchng[] ;
  41. extern int  tt_cols[], tt_rows[], tt_wrap ;
  42. extern int  wherex[], wherey[], margintop, marginbot ;
  43. extern int  marginbell, marginbellcol, parity, cmask ;
  44. extern int  wy_monitor;
  45. extern char answerback[], htab[] ;
  46. extern struct tt_info_rec tt_info[] ;
  47. extern vtattrib attrib ;
  48. extern unsigned char attribute;
  49. extern int autoscroll, protect ;
  50. extern CHAR (*xls[MAXTCSETS+1][MAXFCSETS+1])(CHAR);  /* Character set xlate */
  51. extern CHAR (*xlr[MAXTCSETS+1][MAXFCSETS+1])(CHAR);  /* functions. */
  52. extern struct csinfo fcsinfo[]; /* File character set info */
  53. extern int tcsr, tcsl;          /* Terminal character sets, remote & local. */
  54. extern struct _vtG G[4];
  55. extern struct _vtG *GL, *SSGL ;  /* GL and single shift GL */
  56. extern struct _vtG *GR;          /* GR */
  57. extern struct _vtG *GNOW;
  58.  
  59. int    dgunix = FALSE ;         /* DG Unix mode */
  60. int    dgunix_usr = FALSE;
  61.  
  62. static unsigned char escchar=XRS;/* Remember which was used to enter GOTESC */
  63.  
  64. unsigned char
  65. charset( enum charsetsize size, unsigned short achar, struct _vtG * pG );
  66.  
  67. extern int ttpush;
  68. int
  69. dginc(void)
  70. {
  71.     extern int pmask, cmask;
  72.     extern int tt_utf8;
  73.     int ch;
  74.  
  75.   loop:
  76.     ch = ttinc(0);
  77.     if ( ch < 0 )
  78.         return ch;
  79.  
  80.     if ( seslog )
  81.         logchar(ch);
  82.  
  83.     /* Handle the UTF8 conversion if we are in that mode */
  84.     if ( tt_utf8 ) {
  85.         USHORT * ucs2 = NULL;
  86.         int rc = utf8_to_ucs2( (CHAR)(ch & 0xFF), &ucs2 );
  87.         if ( rc > 0 )
  88.             goto loop;
  89.         else if ( rc < 0 )
  90.             ch = 0xfffd;
  91.         else
  92.             ch = *ucs2;
  93.     }
  94.  
  95.     if ( !xprint ) {
  96. #ifndef NOXFER
  97.         autodown(ch);
  98. #endif /* NOXFER */
  99.         autoexitchk(ch);
  100.     }
  101.  
  102.     if ( !xprint )
  103.         ch = ch & pmask & cmask;
  104.     debugses(ch);
  105.     if (printon && (is_xprint() || is_uprint()))
  106.         prtchar(ch);
  107.  
  108.     return ch;
  109. }
  110.  
  111. static char
  112. int2unixhex( int n )
  113. {
  114.     char c;
  115.     switch ( n ) {
  116.     case 0:     c = '0'; break;
  117.     case 1:     c = '1'; break;
  118.     case 2:     c = '2'; break;
  119.     case 3:     c = '3'; break;
  120.     case 4:     c = '4'; break;
  121.     case 5:     c = '5'; break;
  122.     case 6:     c = '6'; break;
  123.     case 7:     c = '7'; break;
  124.     case 8:     c = '8'; break;
  125.     case 9:     c = '9'; break;
  126.     case 10:    c = 'A'; break;
  127.     case 11:    c = 'B'; break;
  128.     case 12:    c = 'C'; break;
  129.     case 13:    c = 'D'; break;
  130.     case 14:    c = 'E'; break;
  131.     case 15:    c = 'F'; break;
  132.     default:    c = '0';
  133.     }
  134.     return c;
  135. }
  136.  
  137. static int
  138. unixhex2int( char c )
  139. {
  140.     int n=-1;
  141.     switch ( c ) {
  142.     case '0': n = 0; break;
  143.     case '1': n = 1; break;
  144.     case '2': n = 2; break;
  145.     case '3': n = 3; break;
  146.     case '4': n = 4; break;
  147.     case '5': n = 5; break;
  148.     case '6': n = 6; break;
  149.     case '7': n = 7; break;
  150.     case '8': n = 8; break;
  151.     case '9': n = 9; break;
  152.     case 'A': case 'a': n = 10; break;
  153.     case 'B': case 'b': n = 11; break;
  154.     case 'C': case 'c': n = 12; break;
  155.     case 'D': case 'd': n = 13; break;
  156.     case 'E': case 'e': n = 14; break;
  157.     case 'F': case 'f': n = 15; break;
  158.     }
  159.     return n;
  160. }
  161.  
  162. int
  163. dgcmd2int( char arg1, char arg2, char arg3 )
  164. {
  165.     int n = 0;
  166.  
  167.     if ( dgunix ) {
  168.         n += unixhex2int(arg1) * 256;
  169.         n += unixhex2int(arg2) * 16;
  170.         n += unixhex2int(arg3);
  171.     }
  172.     else {
  173.         n += (arg1 & 0x0F) * 256;
  174.         n += (arg2 & 0x0F) * 16;
  175.         n += (arg3 & 0x0F);
  176.     }
  177.     return n;
  178. }
  179.  
  180. void
  181. dgint2cmd( int n, char * arg1, char * arg2, char * arg3 )
  182. {
  183.     if ( dgunix ) {
  184.         n %= 4096;                              /* max DG-Hex value */
  185.         *arg1 = int2unixhex(n/256);
  186.         n %= 256 ;
  187.         *arg2 = int2unixhex(n/16);
  188.         n %= 16 ;
  189.         *arg3 = int2unixhex(n);
  190.     }
  191.     else {
  192.         n %= 4096;                              /* max DG-Hex value */
  193.         *arg1 = '0' + n / 256;
  194.         n %= 256 ;
  195.         *arg2 = '0' + n / 16;
  196.         n %= 16 ;
  197.         *arg3 = '0' + n;
  198.     }
  199. }
  200.  
  201. int
  202. dgloc2int( char arg1, char arg2, char arg3 )
  203. {
  204.     int n = 0 ;
  205.  
  206.     if ( dgunix ) {
  207.         n += unixhex2int(arg1) * 256;
  208.         n += unixhex2int(arg2) * 16;
  209.         n += unixhex2int(arg3);
  210.     }
  211.     else {
  212.         n += (arg1 - '@')%32 * 1024;
  213.         n += (arg2 - '@')%32 * 32;
  214.         n += (arg3 - '@')%32 ;
  215.     }
  216.     return n;
  217. }
  218.  
  219. void
  220. dgint2loc( int n, char * arg1, char * arg2, char * arg3 )
  221. {
  222.     if ( dgunix ) {
  223.         n %= 3072;                              /* max DG-Location value */
  224.         *arg1 = int2unixhex(n/256);
  225.         n %= 256 ;
  226.         *arg2 = int2unixhex(n/16);
  227.         n %= 16 ;
  228.         *arg3 = int2unixhex(n);
  229.     }
  230.     else {
  231.         n %= 3072;                              /* max DG-Location value */
  232.         *arg1 = '@' + n / 1024;
  233.         n %= 1024 ;
  234.         *arg2 = '@' + n / 32;
  235.         n %= 32 ;
  236.         *arg3 = '@' + n;
  237.     }
  238. }
  239.  
  240. void
  241. dgctrl( int ch )
  242. {
  243.     int i,j;
  244.  
  245.  
  246.     if ( !xprint ) {
  247.         if (printon && is_uprint())
  248.             prtchar(ch);
  249.         switch ( ch ) {
  250.         case SOH:
  251.             /* Print all unprotected characters */
  252.             debug(F110,"Data General","SOH",0);
  253.             prtscreen( VTERM, wherey[VTERM], VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0));
  254.             sendchar(ACK);
  255.             break;
  256.         case STX:
  257.             /* Reverse off */
  258.             debug(F110,"Data General","STX",0);
  259.             if ( debses )
  260.                 break;
  261.             attrib.reversed = FALSE ;
  262.             break;
  263.         case ETX:
  264.             debug(F110,"Data General","ETX",0);
  265.             /* Blink Enable */
  266.             break;
  267.         case EOT:
  268.             debug(F110,"Data General","EOT",0);
  269.             /* Blink Disable */
  270.             break;
  271.         case ENQ: {
  272.             /* Report cursor address */
  273.             debug(F110,"Data General","ENQ",0);
  274.             if ( debses || dgunix )
  275.                 break;
  276.             sendchar(US);
  277.             sendchar(wherex[VTERM]-1);
  278.             sendchar(wherey[VTERM]-1);
  279.             break;
  280.         }
  281.         case ACK:
  282.             debug(F110,"Data General","ACK",0);
  283.             break;
  284.         case BEL:
  285.             debug(F110,"Data General","BEL",0);
  286.             if ( debses )
  287.                 break;
  288.             bleep(BP_BEL);
  289.             break;
  290.         case BS:
  291.             debug(F110,"Data General","BS",0);
  292.             if ( !dgunix ) {
  293.                 /* Home Cursor */
  294.                 if ( debses )
  295.                     break;
  296.                 lgotoxy( VTERM, 1, 1 ) ;
  297.             } else {
  298.                 /* Backspace */
  299.                 if ( debses )
  300.                     break;
  301.                 if ( wherex[VTERM] > 1 )
  302.                     cursorleft(0);
  303.             }
  304.             break;
  305.         case HT:
  306.             debug(F110,"Data General","HT",0);
  307.             if ( debses )
  308.                 break;
  309.             i = wherex[VTERM];
  310.             if (i < VscrnGetWidth(VTERM))
  311.             {
  312.                 do {
  313.                     i++;
  314.                     cursorright(0);
  315.                 } while ( (dgunix ? (wherex[VTERM]%8) : ((htab[i] != 'T'))) &&
  316.                             (i <= VscrnGetWidth(VTERM)-1));
  317.                 VscrnIsDirty(VTERM);
  318.             }
  319.             break;
  320.         case LF:
  321.             /* Cursor to start on next line */
  322.             debug(F110,"Data General","LF",0);
  323.             if ( debses )
  324.                 break;
  325.             if ( dgunix )
  326.             {
  327.                 wrtch((CHAR)LF);
  328.             }
  329.             else if ( autoscroll ||
  330.                       wherey[VTERM] < VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0) ) {
  331.                 wrtch((CHAR)CR);
  332.                 wrtch((CHAR)LF);
  333.             }
  334.             else { /* Home Cursor */
  335.                 lgotoxy( VTERM, 1, 1 ) ;
  336.             }
  337.             break;
  338.         case VT: /* Erase Field */
  339.             debug(F110,"Data General","VT",0);
  340.             if ( debses || dgunix )
  341.                 break;
  342.             clrtoeoln( VTERM, SP ) ;
  343.             break;
  344.         case FF:
  345.             debug(F110,"Data General","FF",0);
  346.             if ( debses || dgunix )
  347.                 break;
  348.             clrscreen(VTERM,SP);
  349.             lgotoxy(VTERM,1,1);       /* and home the cursor */
  350.             attrib.blinking = FALSE;
  351.             attrib.underlined = FALSE;
  352.             attrib.reversed = FALSE;
  353.             attrib.dim = FALSE;
  354.             break;
  355.         case CR:
  356.             debug(F110,"Data General","CR",0);
  357.             if ( debses )
  358.                 break;
  359.             wrtch((char) CR);
  360.             break;
  361.         case SO:
  362.             debug(F110,"Data General","SO",0);
  363.             if ( debses )
  364.                 break;
  365.             if ( dgunix )
  366.                 GL = &G[1];
  367.             else
  368.                 attrib.blinking = TRUE ;
  369.             break;
  370.         case SI:
  371.             debug(F110,"Data General","SI",0);
  372.             if ( debses )
  373.                 break;
  374.             if ( dgunix )
  375.                 GL = &G[0];
  376.             else
  377.                 attrib.blinking = FALSE ;
  378.             break;
  379.         case DLE: {
  380.             /* Address cursor in current page */
  381.             int col, line ;
  382.             debug(F110,"Data General","DLE",0);
  383.             col  = dginc();
  384. #ifdef NETCONN
  385. #ifdef TCPSOCKET
  386.             if ( network && IS_TELNET() && !TELOPT_U(TELOPT_BINARY) && col == CR ) {
  387.                 /* Handle TELNET CR-NUL or CR-LF if necessary */
  388.                 int dummy = ttinc(0);
  389.                 debug(F111,"Data General","Addr cursor in page found CR",dummy);
  390.                 if ( dummy != NUL )
  391.                     ttpush = dummy;
  392.             }
  393. #endif /* TCPSOCKET */
  394. #endif /* NETCONN */
  395.             line = dginc();
  396. #ifdef COMMENT
  397. #ifdef NETCONN
  398. #ifdef TCPSOCKET
  399.             if ( network && IS_TELNET() && !TELOPT_U(TELOPT_BINARY) && line == CR ) {
  400.                 /* Handle TELNET CR-NUL or CR-LF if necessary */
  401.                 int dummy = ttinc(0);
  402.                 debug(F111,"Data General","Addr cursor in page found CR",dummy);
  403.                 if ( dummy != NUL )
  404.                     ttpush = dummy;
  405.             }
  406. #endif /* TCPSOCKET */
  407. #endif /* NETCONN */
  408. #endif /* COMMENT */
  409.             if ( debses )
  410.                 break;
  411.  
  412.             if ( col == 127 )
  413.                 col = wherex[VTERM] - 1;
  414.             if ( line == 127 )
  415.                 line = wherey[VTERM] - 1;
  416.  
  417.             lgotoxy(VTERM,col+1,line+1);
  418.             break;
  419.         }
  420.         case DC1: {
  421.             /* Print - current line to end of screen */
  422.             /* Send Ctrl-F ACK when print is complete */
  423.             debug(F110,"Data General","DC1",0);
  424.             if ( debses || dgunix )
  425.                 break;
  426.             debug(F110,"Data General","Print current line to end of screen",0);
  427.             prtscreen( VTERM, wherey[VTERM], VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0));
  428.             sendchar(ACK);
  429.             break;
  430.         }
  431.         case DC2:
  432.             debug(F110,"Data General","DC2",0);
  433.             if ( debses )
  434.                 break;
  435.             autoscroll = TRUE ;
  436.             break;
  437.         case DC3:
  438.             debug(F110,"Data General","DC3",0);
  439.             if ( debses || dgunix )
  440.                 break;
  441.             autoscroll = FALSE ;
  442.             break;
  443.         case DC4:
  444.             debug(F110,"Data General","DC4",0);
  445.             if ( debses )
  446.                 break;
  447.             attrib.underlined = TRUE ;
  448.             break;
  449.         case NAK:
  450.             debug(F110,"Data General","NAK",0);
  451.             if ( debses )
  452.                 break;
  453.             attrib.underlined = FALSE ;
  454.             break;
  455.         case SYN:
  456.             debug(F110,"Data General","SYN",0);
  457.             if ( debses )
  458.                 break;
  459.             attrib.reversed = TRUE ;
  460.             break;
  461.         case ETB:
  462.             debug(F110,"Data General","ETB",0);
  463.             if ( debses || dgunix )
  464.                 break;
  465.             cursorup(0);
  466.             break;
  467.         case CAN:
  468.             debug(F110,"Data General","CAN",0);
  469.             if ( debses || dgunix )
  470.                 break;
  471.             cursorright(0);
  472.             break;
  473.         case XEM:
  474.             debug(F110,"Data General","EM",0);
  475.             if ( debses || dgunix )
  476.                 break;
  477.             cursorleft(0);
  478.             break;
  479.         case SUB:
  480.             debug(F110,"Data General","SUB",0);
  481.             if ( debses || dgunix )
  482.                 break;
  483.             cursordown(0);
  484.             break;
  485.         case ESC:
  486.             /* We will treat RS and ESC to be equivalent for our purposes            */
  487.             /* initiate escape sequence */
  488.             debug(F110,"Data General","ESC",0);
  489.             escstate = ES_GOTESC ;
  490.             escchar  = ESC;
  491.             break;
  492.         case XFS:
  493.             debug(F110,"Data General","FS",0);
  494.             if ( debses )
  495.                 break;
  496.             attrib.dim = TRUE ;
  497.             break;
  498.         case XGS:
  499.             debug(F110,"Data General","GS",0);
  500.             if ( debses )
  501.                 break;
  502.             attrib.dim = FALSE ;
  503.             break;
  504.         case XRS:
  505.             /* This appears to be the beginning of escape character on the DG series */
  506.             /* We will treat RS and ESC to be equivalent for our purposes            */
  507.             /* initiate escape sequence */
  508.             debug(F110,"Data General","RS",0);
  509.             escstate = ES_GOTESC ;
  510.             escchar  = XRS;
  511.             break;
  512.         case US:
  513.             debug(F110,"Data General","US",0);
  514.             break;
  515.         }
  516.     }
  517.     else {      /* xprint */
  518.         switch ( ch ) {
  519.         case ESC:
  520.             /* We will treat RS and ESC to be equivalent for our purposes            */
  521.             /* initiate escape sequence */
  522.             escstate = ES_GOTESC ;
  523.             escchar  = ESC;
  524.             break;
  525.         case XRS:
  526.             /* This appears to be the beginning of escape character on the DG series */
  527.             /* We will treat RS and ESC to be equivalent for our purposes            */
  528.             /* initiate escape sequence */
  529.             escstate = ES_GOTESC ;
  530.             escchar  = XRS;
  531.             break;
  532.         default:
  533.             if (printon && is_uprint())
  534.                 prtchar(ch);
  535.         }
  536.     }
  537. }
  538.  
  539. void
  540. dgascii( int ch )
  541. {
  542.     int i,j,k,n,x,y,z;
  543.     vtattrib attr ;
  544.     viocell blankvcell;
  545.     char arg1, arg2, arg3, arg4, arg5;
  546.  
  547.     if ( escstate == ES_GOTESC )/* Process character as part of an escstate sequence */
  548.     {
  549.         if ( ch < SP ) {
  550.             escstate = ES_NORMAL ;
  551.             dgctrl(ch) ;
  552.         }
  553.         else
  554.         {
  555.             escstate = ES_ESCSEQ ;
  556.             if ( !xprint ) {
  557.  
  558.                 /* We don't print escape sequences */
  559.  
  560.             switch ( ch ) {
  561.             case '"':
  562.                 /* Unlock Keyboard */
  563.                 debug(F110,"Data General","Unlock Keyboard",0);
  564.                 if ( debses )
  565.                     break;
  566.                 keylock = FALSE ;
  567.                 break;
  568.             case '#':
  569.                 /* Lock Keyboard */
  570.                 debug(F110,"Data General","Lock Keyboard",0);
  571.                 if ( debses )
  572.                     break;
  573.                 keylock = TRUE ;
  574.                 break;
  575.             case 'A': 
  576.                 /* DG411 - Set Foreground Color */
  577.                 debug(F110,"Data General","Set Foreground Color",0);
  578.                 arg1 = dginc();
  579.                 if ( debses )
  580.                     break;
  581.                 break;
  582.             case 'C': {
  583.                 /* Send Terminal ID */
  584.                 /* RS o # <m> <x> <y>                    */
  585.                 /* <m> = model: d217 '5'; d413/d463 '6'  */
  586.                 /* <x> = bits  01TC PRRR                 */
  587.                 /*      T - 0:self test passed; 1:errors */
  588.                 /*      C - 0:7bit; 1:8bit               */
  589.                 /*      P - 0:no printer; 1:printer      */
  590.                 /*      R - 3bit revision number         */
  591.                 /* <y> = bits  01GK LLLL                 */
  592.                 /*      G - 0:no graphics; 1:graphics    */
  593.                 /*      K - 0:no keyboard; 1:keyboard    */
  594.                 /*      L - keyboard mode (1001 - US)    */
  595.                 char response[7];
  596.                 if ( debses )
  597.                     break;
  598.                 response[0] = XRS;
  599.                 response[1] = 'o';
  600.                 response[2] = '#';
  601.  
  602.                 switch ( tt_type_mode ) {
  603.                 case TT_DG200:
  604.                     response[3] = '!';
  605.                     break;
  606.                 case TT_DG210:
  607.                     response[3] = '(';
  608.                     break;
  609.                 case TT_DG217:
  610.                     response[3] = '5';
  611.                     break;
  612. #ifdef COMMENT
  613.                 case TT_DG413:
  614.                 case TT_DG463:
  615.                     response[3] = '6';
  616.                     break;
  617. #endif /* COMMENT */
  618.                 }
  619.  
  620.                 if ( cmask == 0177 )
  621.                     response[4] = 0x48 | 0x03; /* 7-bit; printer */
  622.                 else
  623.                     response[4] = 0x58 | 0x03;  /* 8-bit; printer */
  624.                 response[5] = 0x59;     /* keyboard; US */
  625.                 response[6] = '\0';
  626.                 debug(F110,"Data General Read Model ID",response,0);
  627.                 sendchars(response,6);
  628.                 break;
  629.             }
  630.             case 'D':
  631.                 debug(F110,"Data General","Reverse On",0);
  632.                 if ( debses )
  633.                     break;
  634.                 attrib.reversed = TRUE ;
  635.                 break;
  636.             case 'E':
  637.                 debug(F110,"Data General","Reverse Off",0);
  638.                 if ( debses )
  639.                     break;
  640.                 attrib.reversed = FALSE ;
  641.                 break;
  642.             case 'F': {
  643.                 ch = dginc() ;
  644.                 switch ( ch ) {
  645.                 case '?': {
  646.                     ch = dginc() ;
  647.                     if ( debses )
  648.                         break;
  649.                     switch ( ch ) {
  650.                     case ':':   /* Print Screen */
  651.                         debug(F110,"Data General","Print Screen",0);
  652.                         prtscreen( VTERM, 1, VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0));
  653.                         sendchar(ACK);
  654.                         break;
  655.                     case '0':
  656.                         debug(F110,"Data General 4xx","Simulprint Off",0);
  657.                         break;
  658.                     case '1':
  659.                         debug(F110,"Data General 4xx","Simulprint On",0);
  660.                         break;
  661.                     case '2':
  662.                         debug(F110,"Data General","Xprint Off",0);
  663.                         xprint = FALSE ;
  664.                         if ( !uprint && !xprint && !aprint && printon )
  665.                             printeroff();
  666.                         sendchar(ACK);
  667.                         break;
  668.                     case '3':
  669.                         debug(F110,"Data General","Xprint On",0);
  670.                         xprint = TRUE;
  671.                         printeron();
  672.                         break;
  673.                     case '5':
  674.                         debug(F110,"Data General 4xx","Window Bit Dump",0);
  675.                         break;
  676.                     case '6':
  677.                         debug(F110,"Data General 4xx","Form Bit Dump",0);
  678.                         break;
  679.                     case '7':   /* VT220 AutoPrint off */
  680.                         debug(F110,"Data General","Aprint Off",0);
  681.                         setaprint(FALSE);
  682.                         if ( !uprint && !xprint && !aprint && printon )
  683.                             printeroff();
  684.                         sendchar(ACK);
  685.                     case '8':   /* VT220 AutoPrint on */
  686.                         debug(F110,"Data General","Aprint On",0);
  687.                         setaprint(TRUE);
  688.                         printeron();
  689.                         break;
  690.                     case '9':   /* DG UNIX - Print Window */
  691.                         if ( dgunix ) {
  692.                             /* Print - current line to end of screen */
  693.                             /* Send Ctrl-F ACK when print is complete */
  694.                             debug(F110,"Data General",
  695.                                    "Print current line to end of screen",0);
  696.                             prtscreen( VTERM, wherey[VTERM],
  697.                                        VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0));
  698.                             sendchar(ACK);
  699.                         }
  700.                         break;
  701.                     }
  702.                     break;
  703.                 }
  704.                 case ';': {
  705.                     /* Data Trap Mode */
  706.                     int cmd = dginc();
  707.  
  708.                     debug(F111,"Data General","Data Trap Mode",cmd);
  709.  
  710.                     switch ( cmd ) {
  711.                     case 'T':
  712.                         if ( wy_monitor )
  713.                             break;
  714.                         setdebses(FALSE);
  715.                         break;
  716.                     case 'H':
  717.                     case 'O':
  718.                     case DEL:
  719.                         if ( debses || wy_monitor )
  720.                             break;
  721.                         setdebses(TRUE);
  722.                         wy_monitor = TRUE ;
  723.                         break;
  724.                     }
  725.                 }
  726.                 case '~': {
  727.                     /* Switch Emulations */
  728.                     int emulation = 0 ;
  729.                     char response[5] = "";
  730.  
  731.                     arg1 = '0';
  732.                     arg2 = dginc();
  733.                     arg3 = dginc();
  734.  
  735.                     emulation = dgcmd2int( arg1, arg2, arg3 );
  736.  
  737.                     debug(F111,"Data General","Switch Emulation",emulation);
  738.  
  739.                     if ( debses )
  740.                         break;
  741.                     response[0] = XRS;
  742.                     response[1] = 'o';
  743.                     response[2] = '~';
  744.  
  745.                     switch ( emulation ) {
  746.                     case 0x00:  /* DG Native mode */
  747.                         response[3] = '1';
  748.                         break;
  749.                     case 0x08:  /* VT52 mode */
  750.                         tt_type_vt52 = tt_type_mode;
  751.                         tt_type_mode = TT_VT52;
  752.                         response[3] = '1';
  753.                         ipadl25();
  754.                         break;
  755.                     case 0x09:  /* VT100 mode */
  756.                         tt_type_mode = TT_VT102;
  757.                         response[3] = '1';
  758.                         ipadl25();
  759.                         break;
  760.                     case 0x0C:  /* VT320 mode */
  761.                         tt_type_mode = TT_VT320;
  762.                         response[3] = '1';
  763.                         ipadl25();
  764.                         break;
  765.                     case 0x10:  /* Tektronix 4010 */
  766.                         response[3] = '0';
  767.                         ipadl25();
  768.                         break;
  769.                     }
  770.                     response[4] = '\0';
  771.                     debug(F110,"Data General Switch Emulation Mode",response,0);
  772.                     sendchars( response, 4 );
  773.                     break;
  774.                 }
  775.                 case '{': {
  776.                     /* Set Model ID */
  777.                     int model = 0 ;
  778.                     int graphics = 0;
  779.  
  780.                     arg1 = '0';
  781.                     arg2 = dginc();
  782.                     arg3 = dginc();
  783.                     model = dgcmd2int( arg1, arg2, arg3 );
  784.  
  785.                     arg2 = '0';
  786.                     arg3 = dginc();
  787.                     graphics = dgcmd2int( arg1, arg2, arg3 );
  788.  
  789.                     debug(F110,"Data General Set Model ID","not supported",0);
  790.                     if ( debses )
  791.                         break;
  792.                     break;
  793.                 }
  794.                 case '7': {
  795.                     /* Select Printer National Character Set */
  796.                     int lang;
  797.  
  798.                     arg1 = '0';
  799.                     arg2 = dginc();
  800.                     arg3 = dginc();
  801.                     lang = dgcmd2int( arg1, arg2, arg3 );
  802.                     debug(F101,"Data General Select Printer National CS","",lang);
  803.  
  804.                     if ( debses )
  805.                         break;
  806.  
  807.                     break;
  808.                 }
  809.                 case '8':
  810.                     debug(F110,"Data General 4xx","Display Character Generator Contents",0);
  811.                     if ( debses )
  812.                         break;
  813.                     break;
  814.                 case '9':
  815.                     debug(F110,"Data General 4xx","Fill Screen with Grid",0);
  816.                     if ( debses )
  817.                         break;
  818.                     break;
  819.                 case '<':
  820.                     debug(F110,"Data General 4xx","DG411 - Perform Uart Loopback Test",0);
  821.                     if ( debses )
  822.                         break;
  823.                     break;
  824.                 case '>':
  825.                     debug(F110,"Data General 4xx","Fill Screen with Character",0);
  826.                     arg1 = dginc();
  827.                     if ( debses )
  828.                         break;
  829.                     break;
  830.                 case '@':
  831.                     debug(F110,"Data General 4xx","Select ANSI mode",0);
  832.                     break;
  833.                 case 'A':
  834.                     debug(F110,"Data General 4xx","Reset",0);
  835.                     if ( debses )
  836.                         break;
  837.                     doreset(1);
  838.                     break;
  839.                 case 'B':
  840.                     debug(F110,"Data General 4xx","Set Windows",0);
  841.                     /* <row count><normal>...<row count><normal>
  842.                      * how do we know when the sequence ends?
  843.                      */
  844.                     arg1 = dginc();     
  845.                     break;
  846.                 case 'C': {
  847.                     /* Scroll Left - Pan Right */
  848.                     viocell cell ;
  849.                     debug(F110,"Data General 4xx","Scroll Left",0);
  850.                     arg1 = dginc(); /* Column count */
  851.  
  852.                     if ( debses )
  853.                         break;
  854.  
  855.                     cell.c = SP ;
  856.                     cell.a = geterasecolor(VTERM) ;
  857.                     if ( arg1 == 0 )
  858.                         arg1 = 1 ;
  859.                     else if ( arg1 > VscrnGetWidth(VTERM)-1 )
  860.                         arg1 = VscrnGetWidth(VTERM)-1 ;
  861.                     VscrnScrollLf( VTERM,
  862.                                    0,
  863.                                    0,
  864.                                    VscrnGetHeight(VTERM)
  865.                                    -(tt_status[VTERM]?2:1),
  866.                                    VscrnGetWidth(VTERM)-1,
  867.                                    arg1,
  868.                                    cell);
  869.                     break;
  870.                 }
  871.                 case 'D': {
  872.                     /* Scroll Right - Pan Left */
  873.                     viocell cell ;
  874.                     debug(F110,"Data General 4xx","Scroll Right",0);
  875.                     arg1 = dginc(); /* Column count */
  876.  
  877.                     if ( debses )
  878.                         break;
  879.  
  880.                     cell.c = SP ;
  881.                     cell.a = geterasecolor(VTERM) ;
  882.                     if ( arg1 == 0 )
  883.                         arg1 = 1 ;
  884.                     else if ( arg1 > VscrnGetWidth(VTERM)-1 )
  885.                         arg1 = VscrnGetWidth(VTERM)-1 ;
  886.                         VscrnScrollRt( VTERM,
  887.                                        0,
  888.                                        0,
  889.                                        VscrnGetHeight(VTERM)
  890.                                        -(tt_status[VTERM]?2:1),
  891.                                        VscrnGetWidth(VTERM)-1,
  892.                                        arg1,
  893.                                        cell);
  894.                     break; 
  895.                 }
  896.                 case 'E':
  897.                     debug(F110,"Data General 4xx","Erase Screen",0);
  898.                     if ( debses )
  899.                         break;
  900.                     clrscreen(VTERM, SP);
  901.                     break;
  902.                 case 'F':
  903.                     /* D413 Clear Unprotected (cursor to EOS) */
  904.                     debug(F110,"Data General 4xx","Erase Unprotected",0);
  905.                     if ( debses )
  906.                         break;
  907.                     if ( protect )
  908.                         selclreoscr_escape(VTERM, SP);
  909.                     else
  910.                         clreoscr_escape(VTERM, SP);
  911.                     break;
  912.                 case 'G':
  913.                     debug(F110,"Data General 4xx","Screen Home",0);
  914.                     break;
  915.                 case 'H':
  916.                     debug(F110,"Data General 4xx","Insert Line",0);
  917.                     break;
  918.                 case 'I':
  919.                     debug(F110,"Data General 4xx","Delete Line",0);
  920.                     break;
  921.                 case 'J':
  922.                     debug(F110,"Data General 4xx","Select Normal Spacing",0);
  923.                     break;
  924.                 case 'K':
  925.                     debug(F110,"Data General 4xx","Select Compressed Spacing",0);
  926.                     break;
  927.                 case 'L':
  928.                     debug(F110,"Data General 4xx","Protect On",0);
  929.                     if ( debses )
  930.                         break;
  931.                     attrib.unerasable = TRUE;
  932.                     break;
  933.                 case 'M':
  934.                     debug(F110,"Data General 4xx","Protect Off",0);
  935.                     if ( debses )
  936.                         break;
  937.                     attrib.unerasable = FALSE;
  938.                     break;
  939.                 case 'N': {
  940.                     /* D413 Change Attributes <nnn> <n> <n> */
  941.                     int chars = 0 ;
  942.                     int toset = 0 ;
  943.                     int toreset = 0;
  944.  
  945.                     debug(F110,"Data General 4xx","Change Attributes",0);
  946.  
  947.                     arg1 = dginc();
  948.                     arg2 = dginc();
  949.                     arg3 = dginc();
  950.                     chars = dgcmd2int( arg1, arg2, arg3 );
  951.  
  952.                     arg1 = '0';
  953.                     arg2 = '0';
  954.                     arg3 = dginc();
  955.                     toset = dgcmd2int( arg1, arg2, arg3 );
  956.  
  957.                     arg3 = dginc();
  958.                     toreset = dgcmd2int( arg1, arg2, arg3 );
  959.  
  960.                     if ( debses )
  961.                         break;
  962.                     break;
  963.                 }
  964.                 case 'O':
  965.                     debug(F110,"Data General 4xx","Read Horizontal Scroll Offset",0);
  966.                     break;
  967.                 case 'P': {
  968.                     /* Write Screen Address <nn> <nn> */
  969.                     int col=0, row=0;
  970.                     arg1 = '0';
  971.                     arg2 = dginc();
  972.                     arg3 = dginc();
  973.                     col = dgcmd2int( arg1, arg2, arg3 );
  974.  
  975.                     arg2 = dginc();
  976.                     arg3 = dginc();
  977.                     row = dgcmd2int( arg1, arg2, arg3 );
  978.  
  979.                     debug(F110,"Data General","Write Screen Address",0);
  980.  
  981.                     if ( debses )
  982.                         break;
  983.  
  984.                     if ( col == 255 )
  985.                         col = wherex[VTERM] - 1 ;
  986.                     if ( row == 255 )
  987.                         row = wherey[VTERM] - 1 ;
  988.  
  989.                     lgotoxy( VTERM, col+1, row+1 );
  990.                     break;
  991.                 }
  992.                 case 'Q': {
  993.                     /* Set Cursor Type - DG411/461 */
  994.                     arg1 = dginc();
  995.  
  996.                     debug(F111,"Data General","Set Cursor Type",arg1-'0');
  997.  
  998.                     if ( debses )
  999.                         break;
  1000.                     switch ( arg1 ) {
  1001.                     case '0':
  1002.                         cursorena[VTERM] = FALSE;
  1003.                         break;
  1004.                     case '5':
  1005.                         cursorena[VTERM] = TRUE;
  1006.                         break;
  1007.                     case '1': /* blink */
  1008.                     case '4': /* no blink */
  1009.                         tt_cursor = TTC_ULINE;
  1010.                         setcursormode();
  1011.                         cursorena[VTERM] = TRUE;
  1012.                         break;
  1013.                     case '2': /* no blink */
  1014.                     case '3': /* blink */
  1015.                         tt_cursor = TTC_BLOCK;
  1016.                         setcursormode();
  1017.                         cursorena[VTERM] = TRUE;
  1018.                         break;
  1019.                     }
  1020.                     break;
  1021.                 }
  1022.                 case 'R':
  1023.                     debug(F110,"Data General 4xx","Define Character",0);
  1024.                     arg1 = dginc(); /* character */
  1025.                     arg2 = dginc(); /* row 0 */
  1026.                     arg3 = dginc(); /* row 9 */
  1027.                     break;
  1028.                 case 'S': {
  1029.                     /* Select Character Set <nn> (p 2-27) */
  1030.                     int cs ;
  1031.                     arg1 = '0' ;
  1032.                     arg2 = dginc();
  1033.                     arg3 = dginc();
  1034.                     if ( debses )
  1035.                         break;
  1036.                     cs = dgcmd2int( arg1, arg2, arg3 );
  1037.                     debug( F111, "Data General Switch to Character Set",
  1038.                            (GL==&G[0])?"G0":"G1",cs);
  1039.                     switch ( cs ) {
  1040.                     case 0:     /* Keyboard language */
  1041.                     case 1:     /* US ASCII */
  1042.                         charset( cs94, 'B', GL );
  1043.                         break;
  1044.                     case 2:     /* UK ASCII */
  1045.                         charset( cs94, 'A', GL );
  1046.                         break;
  1047.                     case 3:     /* French */
  1048.                         charset( cs94, 'R', GL );
  1049.                         break;
  1050.                     case 4:     /* German */
  1051.                         charset( cs94, 'K', GL );
  1052.                         break;
  1053.                     case 5:     /* Swedish/Finnish */
  1054.                         charset( cs94, 'C', GL );
  1055.                         break;
  1056.                     case 6:     /* Spanish */
  1057.                         charset( cs94, 'Y', GL );
  1058.                         break;
  1059.                     case 7:     /* Danish/Nowegian */
  1060.                         charset( cs94, 'E', GL );
  1061.                         break;
  1062.                     case 8:     /* Swiss */
  1063.                         charset( cs94, '=', GL );
  1064.                         break;
  1065.                     case 9:     /* Kata Kana (G0) */
  1066.                         charset( cs94, 'B', GL );
  1067.                         break;
  1068.                     case 14:    /* DG International */
  1069.                         charset( cs96, 'd', GL );
  1070.                         break;
  1071.                     case 15:    /* Kata Kana (G1) */
  1072.                         charset( cs94, 'I', GL );
  1073.                         break;
  1074.                     case 16:    /* DG Word Processing, Greek, Math */
  1075.                         charset( cs96, 'g', GL );
  1076.                         break;
  1077.                     case 17:    /* DG Line Drawing */
  1078.                         charset( cs96, 'f', GL );
  1079.                         break;
  1080.                     case 19:    /* DG Special Graphics */
  1081.                         charset( cs96, 'e', GL );
  1082.                         break;
  1083.                     case 20:    /* DEC Multinational */
  1084.                         charset( cs94, '<', GL );
  1085.                         break;
  1086.                     case 21:    /* DEC Special Graphics */
  1087.                         charset( cs94, '0', GL );
  1088.                         break;
  1089.                     case 29:    /* Low PC Term */
  1090.                         charset( cs94, 'B', GL );
  1091.                         break;
  1092.                     case 30:    /* High PC Term */
  1093.                         charset( cs94, '?', GL );
  1094.                         break;
  1095.                     case 31:    /* ISO 8859/1.2 */
  1096.                         charset( cs96, 'A', GL );
  1097.                         break;
  1098.                     default:
  1099.                         if ( cs >= 32 || cs <= 45 )
  1100.                             ; /* Downloadable Character Sets */
  1101.                     }
  1102.                     break;
  1103.                 }
  1104.                 case 'T':
  1105.                     debug(F110,"Data General 4xx","Set Scroll Rate",0);
  1106.                     break;
  1107.                 case 'U': {
  1108.                     /* Select 7/8 Bit Operation */
  1109.                     int bits = 0 ;
  1110.  
  1111.                     arg1 = '0' ;
  1112.                     arg2 = '0' ;
  1113.                     arg3 = dginc();
  1114.                     bits = dgcmd2int( arg1, arg2, arg3 );
  1115.  
  1116.                     debug(F110,"Data General","Select 7/8 Bit Operation",0);
  1117.  
  1118.                     if ( debses )
  1119.                         break;
  1120.  
  1121.                     if ( bits ) {
  1122.                         /* 8-bits */
  1123.                         setcmask(8);
  1124.                         parity = 0;
  1125.                     }
  1126.                     else {
  1127.                         /* 7-bits */
  1128.                         setcmask(7);
  1129.                     }
  1130.                     break;
  1131.                 }
  1132.                 case 'V':
  1133.                     debug(F110,"Data General 4xx","Protect Enable",0);
  1134.                     if ( debses )
  1135.                         break;
  1136.                   protect = TRUE;
  1137.                     break;
  1138.                 case 'W':
  1139.                     debug(F110,"Data General 4xx","Protect Disable",0);
  1140.                     if ( debses )
  1141.                         break;
  1142.                   protect = FALSE;
  1143.                     break;
  1144.                 case 'X':
  1145.                     debug(F110,"Data General 4xx","Set Margins",0);
  1146.                     arg1 = dginc(); /* left */
  1147.                     arg2 = dginc(); /* right */
  1148.                     break;
  1149.                 case 'Y':
  1150.                     debug(F110,"Data General 4xx","Set Alternate Margins",0);
  1151.                     arg1 = dginc(); /* row */
  1152.                     arg2 = dginc(); /* left */
  1153.                     arg3 = dginc(); /* right */
  1154.                     break;
  1155.                 case 'Z':
  1156.                     debug(F110,"Data General 4xx","Restore Normal Margins",0);
  1157.                     break;
  1158.                 case '[':
  1159.                     debug(F110,"Data General 4xx","Insert Line Between Margins",0);
  1160.                     break;
  1161.                 case '\\':
  1162.                     debug(F110,"Data General 4xx","Delete Line Between Margins",0);
  1163.                     break;
  1164.                 case ']':
  1165.                     debug(F110,"Data General 4xx","Horizontal Scroll Disable",0);
  1166.                     break;
  1167.                 case '^':
  1168.                     debug(F110,"Data General 4xx","Horizontal Scroll Enable",0);
  1169.                     break;
  1170.                 case '_':
  1171.                     debug(F110,"Data General 4xx","Show Columns",0);
  1172.                     arg1 = dginc(); /* left */
  1173.                     arg2 = dginc(); /* right */
  1174.                     break;
  1175.                 case '`':
  1176.                     if ( debses )
  1177.                         break;
  1178.                     debug(F110,"Data General","Xprint On",0);
  1179.                     xprint = TRUE;
  1180.                     printeron();
  1181.                     break;
  1182.                 case 'a':
  1183.                     if ( debses )
  1184.                         break;
  1185.                     debug(F110,"Data General","Xprint Off",0);
  1186.                     xprint = FALSE ;
  1187.                     if ( !uprint && !xprint && !aprint && printon )
  1188.                         printeroff();
  1189.                     sendchar(ACK);
  1190.                     break;
  1191.                 case 'b':
  1192.                     debug(F110,"Data General 4xx","Read Screen Address",0);
  1193.                     break;
  1194.                 case 'd':
  1195.                     debug(F110,"Data General 4xx","Read Characters Remaining",0);
  1196.                     break;
  1197.                 case 'e':
  1198.                     debug(F110,"Data General 4xx","Initialize Draw",0);
  1199.                     arg1 = dginc(); /* set */
  1200.                     arg2 = dginc(); /* number */
  1201.                     break;
  1202.                 case 'f': {
  1203.                     /* Set Keyboard Language */
  1204.                     int lang=0;
  1205.  
  1206.                     arg1='0';
  1207.                     arg2='0';
  1208.                     arg3=dginc();
  1209.                     lang = dgcmd2int( arg1, arg2, arg3 );
  1210.  
  1211.                     debug(F111,"Data General","Set Keyboard Language",lang);
  1212.  
  1213.                     if ( debses )
  1214.                         break;
  1215.  
  1216.                     for ( i = 0 ; i < 4 ; i++ )
  1217.                     {
  1218.                         if ( i == 0 ) {
  1219.                             switch ( lang ) {
  1220.                             case 0:     /* Default (national) */
  1221.                                 G[i].designation = G[i].def_designation ;
  1222.                                 G[i].size = G[i].def_size ;
  1223.                                 G[i].c1 = G[i].def_c1 ;
  1224.                                 break;
  1225.                             case 1:     /* DG International */
  1226.                             case 2:     /* Latin 1 */
  1227.                                 G[i].designation = TX_ASCII ;
  1228.                                 G[i].size = cs94 ;
  1229.                                 G[i].c1 = TRUE ;
  1230.                                 break;
  1231.                             }
  1232.                         }
  1233.                         else {
  1234.                             switch ( lang ) {
  1235.                             case 0:     /* Default (national) */
  1236.                                 G[i].designation = G[i].def_designation ;
  1237.                                 G[i].size = G[i].def_size ;
  1238.                                 G[i].c1 = G[i].def_c1 ;
  1239.                                 break;
  1240.                             case 1:     /* DG International */
  1241.                                 G[i].designation = TX_DGI ;
  1242.                                 G[i].size = cs96 ;
  1243.                                 G[i].c1 = TRUE ;
  1244.                                 break;
  1245.                             case 2:     /* Latin 1 */
  1246.                                 G[i].designation = TX_8859_1 ;
  1247.                                 G[i].size = cs96 ;
  1248.                                 G[i].c1 = TRUE ;
  1249.                                 break;
  1250.                             }
  1251.                         }
  1252.                         G[i].national = CSisNRC(G[i].designation) ;
  1253.                         if ( G[i].designation == TX_TRANSP ) {
  1254.                             debug(F111,"Data General - ERROR","G(i).designation == TX_TRANSP",i);
  1255.                             G[i].rtoi = NULL ;
  1256.                             G[i].itol = NULL ;
  1257.                             G[i].ltoi = NULL ;
  1258.                             G[i].itor = NULL ;
  1259.                         }
  1260.                         else
  1261.                         {
  1262.                             G[i].rtoi = xl_u[G[i].designation];
  1263.                             G[i].itol = xl_tx[tcsl] ;
  1264.                             G[i].ltoi = xl_u[tcsl] ;
  1265.                             G[i].itor = xl_tx[G[i].designation];
  1266.                         }
  1267.                         G[i].init = FALSE ;
  1268.                     }
  1269.                     GNOW = GL = &G[0] ;
  1270.                     GR = &G[1] ;
  1271.                     SSGL = NULL ;
  1272.                     break;
  1273.                 }
  1274.                 case 'h':
  1275.                     debug(F110,"Data General 4xx","Push",0);
  1276.                     break;
  1277.                 case 'i':
  1278.                     debug(F110,"Data General 4xx","Pop",0);
  1279.                     break;
  1280.                 case 'm': {
  1281.                     ch = dginc() ;
  1282.                     switch ( ch ) {
  1283.                     case '0':
  1284.                         debug(F110,"Data General 4xx","Read Cursor Contents",0);
  1285.                         break;
  1286.                     }
  1287.                     break;
  1288.                 }
  1289.                 case 'r': {
  1290.                     /* Set Clock Time */
  1291.                     int status=0, hh = 0, mm = 0;
  1292.  
  1293.                     arg1='0';
  1294.                     arg2='0';
  1295.                     arg3=dginc();
  1296.                     status = dgcmd2int( arg1, arg2, arg3 );
  1297.  
  1298.                     if ( status == 2 || status == 3 ) {
  1299.                         dginc();        /* unused clock position */
  1300.                         dginc();
  1301.                         dginc();
  1302.                         dginc();
  1303.  
  1304.                         arg2=dginc();
  1305.                         arg3=dginc();
  1306.                         hh = 10 * (arg2-'0') + (arg3-'0');
  1307.  
  1308.                         if ( dginc() != ':' )
  1309.                             debug(F100,"Data General Set Time - Invalid spacing character","",0);
  1310.  
  1311.                         arg2=dginc();
  1312.                         arg3=dginc();
  1313.                         mm = 10 * (arg2-'0') + (arg3-'0');
  1314.                     }
  1315.  
  1316.                     debug(F110,"Data General","Set Clock Time",0);
  1317.  
  1318.                     if ( debses )
  1319.                         break;
  1320.                     loadtod( hh, mm );
  1321.                     break;
  1322.                 }
  1323.                 case 't': {
  1324.                     /* Report Screen Size */
  1325.                     /* Responds <036> o < <nn> <nn> <nn> <nn> <status> */
  1326.                     char response[13] ;
  1327.                     if ( debses )
  1328.                         break;
  1329.                     response[0] = XRS;
  1330.                     response[1] = 'o';
  1331.                     response[2] = '<';
  1332.  
  1333.                     dgint2loc( VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0),&arg1,&arg2,&arg3);
  1334.                     response[3] = arg2;
  1335.                     response[4] = arg3;
  1336.                     response[7] = arg2;
  1337.                     response[8] = arg3;
  1338.  
  1339.                     dgint2loc( VscrnGetWidth(VTERM),&arg1,&arg2,&arg3);
  1340.                     response[5] = arg2;
  1341.                     response[6] = arg3;
  1342.                     response[9] = arg2;
  1343.                     response[10] = arg3;
  1344.  
  1345.                     response[11] = 'p'; /* one host; screen save not enabled */
  1346.                     response[12] = '\0';
  1347.  
  1348.                     debug(F110,"Data General Report Screen Size",response,0);
  1349.                     sendchars( response, 12 );
  1350.                     break;
  1351.                 }
  1352.                 case 'v': {
  1353.                     /* Read Window Contents <nn> <nn> <nn> <nn> */
  1354.                     int r1=0, c1=0, r2=0, c2=0;
  1355.                     arg1 = '0';
  1356.                     arg2 = dginc();
  1357.                     arg3 = dginc();
  1358.                     r1 = dgcmd2int( arg1, arg2, arg3 );
  1359.  
  1360.                     arg2 = dginc();
  1361.                     arg3 = dginc();
  1362.                     c1 = dgcmd2int( arg1, arg2, arg3 );
  1363.  
  1364.                     arg2 = dginc();
  1365.                     arg3 = dginc();
  1366.                     r2 = dgcmd2int( arg1, arg2, arg3 );
  1367.  
  1368.                     arg2 = dginc();
  1369.                     arg3 = dginc();
  1370.                     c2 = dgcmd2int( arg1, arg2, arg3 );
  1371.  
  1372.                     debug(F110,"Data General","Read Window Contents",0);
  1373.  
  1374.                     if ( debses )
  1375.                         break;
  1376.  
  1377.                     /* response with text bounded by rectangle <r1,c1>,<r2,c2>      */
  1378.                     /* each line separated with CR-LF.                              */
  1379.                     /* Terminate with ACK if configured to do so                    */
  1380.                     /* Characters from screen are to be translated using G0,G1 sets */
  1381.                     break;
  1382.                 }
  1383.                 case 'w': {
  1384.                     /* Read New Model ID */
  1385.  
  1386.                     char response[21] = "" ;
  1387.  
  1388.                     if ( debses )
  1389.                         break;
  1390.                     response[0] = XRS ;
  1391.                     response[1] = 'o';
  1392.                     response[2] = 'w';
  1393.                     switch ( tt_type_mode ) {
  1394.                     case TT_DG200:
  1395.                     case TT_DG210:
  1396.                     case TT_DG217:
  1397.                         response[3] = '1';      /* D200 series terminal */
  1398.                         break;
  1399. #ifdef COMMENT
  1400.                     case TT_DG413:
  1401.                         response[3] = '3';
  1402.                         break;
  1403. #endif /* COMMENT */
  1404.                     }
  1405.  
  1406.                     response[4] = '0';
  1407.                     response[5] = '1';
  1408.  
  1409.                     response[6] = '0';
  1410.                     response[7] = '0';
  1411.  
  1412.                     response[8] = 'D';
  1413.                     switch ( tt_type_mode ) {
  1414.                     case TT_DG200:
  1415.                         response[9] =  '2';
  1416.                         response[10] = '0';
  1417.                         response[11] = '0';
  1418.                         break;
  1419.                     case TT_DG210:
  1420.                         response[9] =  '2';
  1421.                         response[10] = '1';
  1422.                         response[11] = '0';
  1423.                         break;
  1424.                     case TT_DG217:
  1425.                         response[9] =  '2';
  1426.                         response[10] = '1';
  1427.                         response[11] = '7';
  1428.                         break;
  1429. #ifdef COMMENT
  1430.                     case TT_DG413:
  1431.                         response[9] =  '4';
  1432.                         response[10] = '1';
  1433.                         response[11] = '3';
  1434.                         break;
  1435. #endif
  1436.                     }
  1437.                     response[12] = response[13] = response[14] = response[15] = SP;
  1438.                     response[16] = response[17] = response[18] = response[19] = SP;
  1439.                     response[20] = '\0';
  1440.                     debug(F110,"Data General Read new Model ID",response,0);
  1441.                     sendchars(response,20);
  1442.                     break;
  1443.                 }
  1444.                 case 'x': {
  1445.                     /* Printer Pass Back to Host */
  1446.                     int mode;
  1447.                     char response[5];
  1448.                     arg1=arg2='0';
  1449.                     arg3=dginc();
  1450.                     mode=dgcmd2int(arg1, arg2, arg3);
  1451.  
  1452.                     if ( debses )
  1453.                         break;
  1454.                     response[0] = XRS;
  1455.                     response[1] = 'R';
  1456.                     response[2] = 'x';
  1457.                     response[3] = '0';
  1458.                     response[4] = '\0';
  1459.                     debug(F110,"Data General Printer Pass Back to Host",response,0);
  1460.                     sendchars(response,4);
  1461.                     break;
  1462.                 }
  1463.                 case 'z': {
  1464.                     /* Set 25th Line Mode <n> */
  1465.                     /* 0 - Status Line */
  1466.                     /* 1 - Message <nn> <Text> */
  1467.                     /* 2 - Extra screen row */
  1468.                     /* 3 - disabled */
  1469.                     int mode=0 ;
  1470.                     int length=0;
  1471.                     char message[128]="" ;
  1472.                     arg1 = '0';
  1473.                     arg2 = '0';
  1474.                     arg3 = dginc();
  1475.                     mode = dgcmd2int( arg1, arg2, arg3 );
  1476.                     if ( mode == 1 ) {
  1477.                         arg2 = dginc();
  1478.                         arg3 = dginc();
  1479.                         length = dgcmd2int( arg1, arg2, arg3 );
  1480.                         for ( i=0;i<length;i++ )
  1481.                             message[i] = dginc();
  1482.                         message[i] = '\0';
  1483.                     }
  1484.  
  1485.                     debug(F110,"Data General","Set 25th Line Mode",0);
  1486.  
  1487.                     if ( debses )
  1488.                         break;
  1489.                     break;
  1490.                 }
  1491.                 } /* F */
  1492.                 break;
  1493.             }
  1494.             case 'G': {
  1495.                 ch = dginc() ;
  1496.                 switch ( ch ) {
  1497.                 case 'F':
  1498.                     debug(F110,"Data General 4xx","Arc",0);
  1499.                     arg1 = dginc(); /* x */
  1500.                     arg2 = dginc(); /* y */
  1501.                     arg3 = dginc(); /* radius */
  1502.                     arg4 = dginc(); /* start */
  1503.                     arg5 = dginc(); /* end */
  1504.                     break;
  1505.                 case 'G':
  1506.                     debug(F110,"Data General 4xx","Bar",0);
  1507.                     arg1 = dginc(); /* x */
  1508.                     arg2 = dginc(); /* y */
  1509.                     arg3 = dginc(); /* width */
  1510.                     arg4 = dginc(); /* height */
  1511.                     arg5 = dginc(); /* color */
  1512.                     break;
  1513.                 case '8':
  1514.                     debug(F110,"Data General 4xx","Line",0);
  1515.                     do {
  1516.                         arg1 = dginc(); /* loc list */
  1517.                     } while (arg1 != NUL);
  1518.                     break;
  1519.                 case ':':
  1520.                     debug(F110,"Data General 4xx","Polygon Fill",0);
  1521.                     do {
  1522.                         arg1 = dginc(); /* loc list */
  1523.                     } while (arg1 != NUL);
  1524.                     break;
  1525.                 case '>':
  1526.                     ch = dginc();
  1527.                     switch ( ch ) {
  1528.                     case '|':
  1529.                         debug(F110,"Data General 4xx","Write Cursor Location",0);
  1530.                         arg1 = dginc(); /* x */
  1531.                         arg2 = dginc(); /* y */
  1532.                         break;
  1533.                     }
  1534.                     break;
  1535.                 case '?':
  1536.                     ch = dginc();
  1537.                     switch ( ch ) {
  1538.                     case '|':
  1539.                         debug(F110,"Data General 4xx","Read Cursor Location",0);
  1540.                         break;
  1541.                     }
  1542.                     break;
  1543.                 case '@':
  1544.                     debug(F110,"Data General 4xx","Read Cursor Attributes",0);
  1545.                     break;
  1546.                 case 'A':
  1547.                     debug(F110,"Data General 4xx","Cursor Reset",0);
  1548.                     break;
  1549.                 case 'B':
  1550.                     debug(F110,"Data General 4xx","Cursor On",0);
  1551.                     break;
  1552.                 case 'C':
  1553.                     debug(F110,"Data General 4xx","Cursor Off",0);
  1554.                     break;
  1555.                 case 'H':
  1556.                     debug(F110,"Data General 4xx","Cursor Track",0);
  1557.                     arg1 = dginc(); /* device */
  1558.                     break;
  1559.                 case 'p':
  1560.                     ch = dginc();
  1561.                     switch ( ch ) {
  1562.                     case '1':
  1563.                         debug(F110,"Data General 4xx","Set Pattern",0);
  1564.                         arg1 = dginc(); /* offset */
  1565.                         do {
  1566.                             arg2 = dginc(); /* pattern definition */
  1567.                         } while (arg2 != NUL);
  1568.                         break;
  1569.                     }
  1570.                     break;
  1571.                 }
  1572.                 break;
  1573.             } /* G */
  1574.             case 'H':
  1575.                 debug(F110,"Data General 4xx","Scroll Up",0);
  1576.                 VscrnScroll( VTERM, 
  1577.                              UPWARD,
  1578.                              margintop-1, 
  1579.                              wherex[VTERM]-1,
  1580.                              1,
  1581.                              margintop == 1,
  1582.                              SP);
  1583.                 break; 
  1584.             case 'I':
  1585.                 debug(F110,"Data General 4xx","Scroll Down",0);
  1586.                 VscrnScroll( VTERM,
  1587.                              DOWNWARD,
  1588.                              wherex[VTERM]-1,
  1589.                              marginbot-1,
  1590.                              1,
  1591.                              FALSE,
  1592.                              SP);
  1593.                 break;
  1594.             case 'J':
  1595.                 debug(F110,"Data General 4xx","Insert Character",0);
  1596.                 break;
  1597.             case 'K':
  1598.                 debug(F110,"Data General 4xx","Delete Character",0);
  1599.                 break;
  1600.             case 'L':
  1601.                 debug(F110,"Data General 4xx","Line",0);
  1602.                 do {
  1603.                     arg1 = dginc(); /* loc list */
  1604.                 } while (arg1 != NUL);
  1605.                 break;
  1606.             case 'N':   /* Shift-Out */
  1607.                 debug(F110,"Data General","Shift-Out",0);
  1608.  
  1609.                 if ( debses )
  1610.                     break;
  1611.                 GL = &G[1];
  1612.                 break;
  1613.             case 'O':   /* Shift-In */
  1614.                 debug(F110,"Data General","Shift-In",0);
  1615.  
  1616.                 if ( debses )
  1617.                     break;
  1618.                 GL = &G[0];
  1619.                 break;
  1620.             case 'P': {
  1621.                 ch = dginc() ;
  1622.                 switch ( ch ) {
  1623.                 case '@': {
  1624.                     /* Unix Mode 0:exit 1:enter */
  1625.                     int mode=0;
  1626.                     arg1='0';
  1627.                     arg2='0';
  1628.                     arg3=dginc();
  1629.                     mode = dgcmd2int(arg1, arg2, arg3);
  1630.  
  1631.                     debug(F111,"Data General","Unide Mode",mode-'0');
  1632.  
  1633.                     if ( debses )
  1634.                         break;
  1635.                     dgunix = mode;
  1636.                     break;
  1637.                 }
  1638.                 case 'A': { /* DG UNIX - Cursor Up */
  1639.                     debug(F110,"Data General","Unix Cursor Up",0);
  1640.                     if ( debses || !dgunix )
  1641.                         break;
  1642.                     cursorup(0);
  1643.                     break;
  1644.                 }
  1645.                 case 'B': { /* DG UNIX - Cursor Down */
  1646.                     debug(F110,"Data General","Unix Cursor Down",0);
  1647.                     if ( debses || !dgunix )
  1648.                         break;
  1649.                     cursordown(0);
  1650.                     break;
  1651.                 }
  1652.                 case 'C': { /* DG UNIX - Cursor Right */
  1653.                     debug(F110,"Data General","Unix Cursor Right",0);
  1654.                     if ( debses || !dgunix )
  1655.                         break;
  1656.                     cursorright(0);
  1657.                     break;
  1658.                 }
  1659.                 case 'D': { /* DG UNIX - Cursor Left */
  1660.                     debug(F110,"Data General","Unix Cursor Left",0);
  1661.                     if ( debses || !dgunix )
  1662.                         break;
  1663.                     cursorleft(0);
  1664.                     break;
  1665.                 }
  1666.                 case 'E': { /* DG UNIX - Erase Field */
  1667.                     debug(F110,"Data General","Unix Erase Field",0);
  1668.                     if ( debses || !dgunix )
  1669.                         break;
  1670.                     clrtoeoln( VTERM, SP ) ;
  1671.                     break;
  1672.                 }
  1673.                 case 'F': { /* DG UNIX - Window Home */
  1674.                     debug(F110,"Data General","Unix Window Home",0);
  1675.                     if ( debses || !dgunix )
  1676.                         break;
  1677.                     lgotoxy( VTERM, 1, 1 ) ;
  1678.                     break;
  1679.                 }
  1680.                 case 'G': { /* DG UNIX - Roll Disable */
  1681.                     debug(F110,"Data General","Unix Roll Disable",0);
  1682.                     if ( debses || !dgunix )
  1683.                         break;
  1684.                     autoscroll = FALSE ;
  1685.                     break;
  1686.                 }
  1687.                 case 'H': { /* DG UNIX - Erase Window */
  1688.                     debug(F110,"Data General","Unix Erase Window",0);
  1689.                     if ( debses || !dgunix )
  1690.                         break;
  1691.                     clrscreen(VTERM,SP);
  1692.                     lgotoxy(VTERM,1,1);       /* and home the cursor */
  1693.                     attrib.blinking = FALSE;
  1694.                     attrib.underlined = FALSE;
  1695.                     attrib.reversed = FALSE;
  1696.                     attrib.dim = FALSE;
  1697.                     break;
  1698.                 }
  1699.                 case 'I': { /* DG UNIX - Blink On */
  1700.                     debug(F110,"Data General","Unix Blink On",0);
  1701.                     if ( debses || !dgunix )
  1702.                         break;
  1703.                     attrib.blinking = TRUE ;
  1704.                     break;
  1705.                 }
  1706.                 case 'J': { /* DG UNIX - Blink Off */
  1707.                     debug(F110,"Data General","Unix Blink Off",0);
  1708.                     if ( debses || !dgunix )
  1709.                         break;
  1710.                     attrib.blinking = FALSE ;
  1711.                     break;
  1712.                 }
  1713.                 }
  1714.             } /* P */
  1715.             }
  1716.             } else {      /* xprint */
  1717.                 switch ( ch ) {
  1718.                 case 'F': {
  1719.                     ch = dginc() ;
  1720.                     switch ( ch ) {
  1721.                     case '?': {
  1722.                         ch = dginc() ;
  1723.                         if ( debses )
  1724.                             break;
  1725.                         switch ( ch ) {
  1726.                         case '2':
  1727.                             debug(F110,"Data General","Xprint Off",0);
  1728.                             xprint = FALSE ;
  1729.                             if ( !uprint && !xprint && !aprint && printon )
  1730.                                 printeroff();
  1731.                             sendchar(ACK);
  1732.                             break;
  1733.                         default:
  1734.                             if (printon && (is_xprint() || is_uprint())) {
  1735.                                 prtchar(escchar);
  1736.                                 prtchar('F');
  1737.                                 prtchar('?');
  1738.                                 prtchar(ch);
  1739.                             }
  1740.                         }
  1741.                         break;
  1742.                     }
  1743.                     case 'a':
  1744.                         if ( debses )
  1745.                             break;
  1746.                         debug(F110,"Data General","Xprint Off",0);
  1747.                         xprint = FALSE ;
  1748.                         if ( !uprint && !xprint && !aprint && printon )
  1749.                             printeroff();
  1750.                         sendchar(ACK);
  1751.                         break;
  1752.                     default:
  1753.                         if ( !cprint && printon ) {
  1754.                             prtchar(escchar);
  1755.                             prtchar('F');
  1756.                             prtchar(ch);
  1757.                         }
  1758.                     }
  1759.                 }
  1760.                 default:
  1761.                     if (printon && (is_xprint() || is_uprint())) {
  1762.                         prtchar(escchar);
  1763.                         prtchar(ch);
  1764.                     }
  1765.                 }
  1766.             }
  1767.             escstate = ES_NORMAL ;      /* Done parsing escstate sequence */
  1768.         }
  1769.     }
  1770.     else                /* Handle as a normal character */
  1771.     {
  1772.         if ( ch < SP ) {
  1773.             dgctrl(ch) ;
  1774.         }
  1775.         else if ( !debses ) {
  1776.             wrtch(ch);
  1777.             if (printon && (is_xprint() || is_uprint()))
  1778.                 prtchar(ch);
  1779.         }
  1780.     }
  1781.     VscrnIsDirty(VTERM) ;
  1782. }
  1783. #endif /* NOTERM */
  1784.  
  1785.