The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/i386/isa/pcvt/pcvt_vtf.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1999, 2000 Hellmuth Michaelis
    3  *
    4  * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
    5  *
    6  * Copyright (c) 1992, 1993 Brian Dunford-Shore.
    7  *
    8  * All rights reserved.
    9  *
   10  * This code is derived from software contributed to Berkeley by
   11  * William Jolitz and Don Ahn.
   12  *
   13  * Redistribution and use in source and binary forms, with or without
   14  * modification, are permitted provided that the following conditions
   15  * are met:
   16  * 1. Redistributions of source code must retain the above copyright
   17  *    notice, this list of conditions and the following disclaimer.
   18  * 2. Redistributions in binary form must reproduce the above copyright
   19  *    notice, this list of conditions and the following disclaimer in the
   20  *    documentation and/or other materials provided with the distribution.
   21  * 3. All advertising materials mentioning features or use of this software
   22  *    must display the following acknowledgement:
   23  *      This product includes software developed by Hellmuth Michaelis,
   24  *      Brian Dunford-Shore and Joerg Wunsch.
   25  * 4. The name authors may not be used to endorse or promote products
   26  *    derived from this software without specific prior written permission.
   27  *
   28  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
   29  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   30  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   31  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   32  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   33  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   34  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   35  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   36  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   37  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 /*---------------------------------------------------------------------------*
   41  *
   42  *      pcvt_vtf.c      VT220 Terminal Emulator Functions
   43  *      -------------------------------------------------
   44  *
   45  *      Last Edit-Date: [Sun Mar 26 10:38:52 2000]
   46  *
   47  * $FreeBSD: releng/6.1/sys/i386/isa/pcvt/pcvt_vtf.c 139790 2005-01-06 22:18:23Z imp $
   48  *
   49  *---------------------------------------------------------------------------*/
   50 
   51 #define PCVT_INCLUDE_VT_SELATTR /* get inline function from pcvt_hdr.h */
   52 
   53 #include <i386/isa/pcvt/pcvt_hdr.h>     /* global include */
   54 #include <i386/isa/pcvt/pcvt_tbl.h>     /* character set conversion tables */
   55 
   56 static void clear_dld ( struct video_state *svsp );
   57 static void init_dld ( struct video_state *svsp );
   58 static void init_udk ( struct video_state *svsp );
   59 static void respond ( struct video_state *svsp );
   60 static void roll_down ( struct video_state *svsp, int n );
   61 static void selective_erase ( struct video_state *svsp, u_short *pcrtat,
   62                               int length );
   63 static void swcsp ( struct video_state *svsp, u_short *ctp );
   64 
   65 /*---------------------------------------------------------------------------*
   66  *      DECSTBM - set top and bottom margins
   67  *---------------------------------------------------------------------------*/
   68 void
   69 vt_stbm(struct video_state *svsp)
   70 {
   71         /* both 0 => scrolling region = entire screen */
   72 
   73         if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
   74         {
   75                 svsp->cur_offset = 0;
   76                 svsp->scrr_beg = 0;
   77                 svsp->scrr_len = svsp->screen_rows;
   78                 svsp->scrr_end = svsp->scrr_len - 1;
   79                 svsp->col = 0;
   80                 return;
   81         }
   82 
   83         if(svsp->parms[1] <= svsp->parms[0])
   84                 return;
   85 
   86         /* range parm 1 */
   87 
   88         if(svsp->parms[0] < 1)
   89                 svsp->parms[0] = 1;
   90         else if(svsp->parms[0] > svsp->screen_rows-1)
   91                 svsp->parms[0] = svsp->screen_rows-1;
   92 
   93         /* range parm 2 */
   94 
   95         if(svsp->parms[1] < 2)
   96                 svsp->parms[1] = 2;
   97         else if(svsp->parms[1] > svsp->screen_rows)
   98                 svsp->parms[1] = svsp->screen_rows;
   99 
  100         svsp->scrr_beg = svsp->parms[0]-1;      /* begin of scrolling region */
  101         svsp->scrr_len = svsp->parms[1] - svsp->parms[0] + 1; /* no of lines */
  102         svsp->scrr_end = svsp->parms[1]-1;
  103 
  104         /* cursor to first pos */
  105         if(svsp->m_om)
  106                 svsp->cur_offset = svsp->scrr_beg * svsp->maxcol;
  107         else
  108                 svsp->cur_offset = 0;
  109 
  110         svsp->col = 0;
  111 }
  112 
  113 /*---------------------------------------------------------------------------*
  114  *      SGR - set graphic rendition
  115  *---------------------------------------------------------------------------*/
  116 void
  117 vt_sgr(struct video_state *svsp)
  118 {
  119         register int i = 0;
  120         u_short setcolor = 0;
  121         char colortouched = 0;
  122 
  123         do
  124         {
  125                 switch(svsp->parms[i++])
  126                 {
  127                         case 0:         /* reset to normal attributes */
  128                                 svsp->vtsgr = VT_NORMAL;
  129                                 break;
  130 
  131                         case 1:         /* bold */
  132                                 svsp->vtsgr |= VT_BOLD;
  133                                 break;
  134 
  135                         case 4:         /* underline */
  136                                 svsp->vtsgr |= VT_UNDER;
  137                                 break;
  138 
  139                         case 5:         /* blinking */
  140                                 svsp->vtsgr |= VT_BLINK;
  141                                 break;
  142 
  143                         case 7:         /* reverse */
  144                                 svsp->vtsgr |= VT_INVERSE;
  145                                 break;
  146 
  147                         case 22:        /* not bold */
  148                                 svsp->vtsgr &= ~VT_BOLD;
  149                                 break;
  150 
  151                         case 24:        /* not underlined */
  152                                 svsp->vtsgr &= ~VT_UNDER;
  153                                 break;
  154 
  155                         case 25:        /* not blinking */
  156                                 svsp->vtsgr &= ~VT_BLINK;
  157                                 break;
  158 
  159                         case 27:        /* not reverse */
  160                                 svsp->vtsgr &= ~VT_INVERSE;
  161                                 break;
  162 
  163                         case 30:        /* foreground colors */
  164                         case 31:
  165                         case 32:
  166                         case 33:
  167                         case 34:
  168                         case 35:
  169                         case 36:
  170                         case 37:
  171                                 if(color)
  172                                 {
  173                                  colortouched = 1;
  174                                  setcolor |= ((fgansitopc[(svsp->parms[i-1]-30) & 7]) << 8);
  175                                 }
  176                                 break;
  177 
  178                         case 40:        /* background colors */
  179                         case 41:
  180                         case 42:
  181                         case 43:
  182                         case 44:
  183                         case 45:
  184                         case 46:
  185                         case 47:
  186                                 if(color)
  187                                 {
  188                                  colortouched = 1;
  189                                  setcolor |= ((bgansitopc[(svsp->parms[i-1]-40) & 7]) << 8);
  190                                 }
  191                                 break;
  192                 }
  193         }
  194         while(i <= svsp->parmi);
  195         if(color)
  196         {
  197                 if(colortouched)
  198                         svsp->c_attr = setcolor;
  199                 else
  200                         svsp->c_attr = ((sgr_tab_color[svsp->vtsgr]) << 8);
  201         }
  202         else
  203         {
  204                 if(adaptor_type == MDA_ADAPTOR)
  205                         svsp->c_attr = ((sgr_tab_imono[svsp->vtsgr]) << 8);
  206                 else
  207                         svsp->c_attr = ((sgr_tab_mono[svsp->vtsgr]) << 8);
  208         }
  209 }
  210 
  211 /*---------------------------------------------------------------------------*
  212  *      CUU - cursor up
  213  *---------------------------------------------------------------------------*/
  214 void
  215 vt_cuu(struct video_state *svsp)
  216 {
  217         register int p = svsp->parms[0];
  218 
  219         if (p <= 0)                             /* parameter min */
  220                 p = 1;
  221 
  222         p = min(p, svsp->row - svsp->scrr_beg);
  223 
  224         if (p <= 0)
  225                 return;
  226 
  227         svsp->cur_offset -= (svsp->maxcol * p);
  228 }
  229 
  230 /*---------------------------------------------------------------------------*
  231  *      CUD - cursor down
  232  *---------------------------------------------------------------------------*/
  233 void
  234 vt_cud(struct video_state *svsp)
  235 {
  236         register int p = svsp->parms[0];
  237 
  238         if (p <= 0)
  239                 p = 1;
  240 
  241         p = min(p, svsp->scrr_end - svsp->row);
  242 
  243         if (p <= 0)
  244                 return;
  245 
  246         svsp->cur_offset += (svsp->maxcol * p);
  247 }
  248 
  249 /*---------------------------------------------------------------------------*
  250  *      CUF - cursor forward
  251  *---------------------------------------------------------------------------*/
  252 void
  253 vt_cuf(struct video_state *svsp)
  254 {
  255         register int p = svsp->parms[0];
  256 
  257         if(svsp->col == ((svsp->maxcol)-1))     /* already at right margin */
  258                 return;
  259 
  260         if(p <= 0)                              /* parameter min = 1 */
  261                 p = 1;
  262         else if(p > ((svsp->maxcol)-1))         /* parameter max = 79 */
  263                 p = ((svsp->maxcol)-1);
  264 
  265         if((svsp->col + p) > ((svsp->maxcol)-1))/* not more than right margin */
  266                 p = ((svsp->maxcol)-1) - svsp->col;
  267 
  268         svsp->cur_offset += p;
  269         svsp->col += p;
  270 }
  271 
  272 /*---------------------------------------------------------------------------*
  273  *      CUB - cursor backward
  274  *---------------------------------------------------------------------------*/
  275 void
  276 vt_cub(struct video_state *svsp)
  277 {
  278         register int p = svsp->parms[0];
  279 
  280         if(svsp->col == 0)                      /* already at left margin ? */
  281                 return;
  282 
  283         if(p <= 0)                              /* parameter min = 1 */
  284                 p = 1;
  285         else if(p > ((svsp->maxcol)-1))         /* parameter max = 79 */
  286                 p = ((svsp->maxcol)-1);
  287 
  288         if((svsp->col - p) <= 0)                /* not more than left margin */
  289                 p = svsp->col;
  290 
  291         svsp->cur_offset -= p;
  292         svsp->col -= p;
  293 }
  294 
  295 /*---------------------------------------------------------------------------*
  296  *      ED - erase in display
  297  *---------------------------------------------------------------------------*/
  298 void
  299 vt_clreos(struct video_state *svsp)
  300 {
  301         switch(svsp->parms[0])
  302         {
  303                 case 0:
  304                         fillw(user_attr | ' ', svsp->Crtat + svsp->cur_offset,
  305                                 svsp->Crtat +
  306                                 (svsp->maxcol * svsp->screen_rows) -
  307                                 (svsp->Crtat + svsp->cur_offset));
  308                         break;
  309 
  310                 case 1:
  311                         fillw(user_attr | ' ', svsp->Crtat,
  312                                 svsp->Crtat + svsp->cur_offset -
  313                                 svsp->Crtat + 1 );
  314                         break;
  315 
  316                 case 2:
  317                         fillw(user_attr | ' ', svsp->Crtat,
  318                                 svsp->maxcol * svsp->screen_rows);
  319                         break;
  320         }
  321 }
  322 
  323 /*---------------------------------------------------------------------------*
  324  *      EL - erase in line
  325  *---------------------------------------------------------------------------*/
  326 void
  327 vt_clreol(struct video_state *svsp)
  328 {
  329         switch(svsp->parms[0])
  330         {
  331                 case 0:
  332                         fillw(user_attr | ' ',
  333                                 svsp->Crtat + svsp->cur_offset,
  334                                 svsp->maxcol-svsp->col);
  335                         break;
  336 
  337                 case 1:
  338                         fillw(user_attr | ' ',
  339                                 svsp->Crtat + svsp->cur_offset - svsp->col,
  340                                 svsp->col + 1);
  341                         break;
  342 
  343                 case 2:
  344                         fillw(user_attr | ' ',
  345                                 svsp->Crtat + svsp->cur_offset - svsp->col,
  346                                 svsp->maxcol);
  347                         break;
  348         }
  349 }
  350 
  351 /*---------------------------------------------------------------------------*
  352  *      CUP - cursor position / HVP - horizontal & vertical position
  353  *---------------------------------------------------------------------------*/
  354 void
  355 vt_curadr(struct video_state *svsp)
  356 {
  357         if(svsp->m_om)  /* relative to scrolling region */
  358         {
  359                 if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
  360                 {
  361                         svsp->cur_offset = svsp->scrr_beg * svsp->maxcol;
  362                         svsp->col = 0;
  363                         svsp->abs_write = 0;
  364                         return;
  365                 }
  366 
  367                 if(svsp->parms[0] <= 0)
  368                         svsp->parms[0] = 1;
  369                 else if(svsp->parms[0] > svsp->scrr_len)
  370                         svsp->parms[0] = svsp->scrr_len;
  371 
  372                 if(svsp->parms[1] <= 0 )
  373                         svsp->parms[1] = 1;
  374                 if(svsp->parms[1] > svsp->maxcol)
  375                         svsp->parms[1] = svsp->maxcol;
  376 
  377                 svsp->cur_offset = (svsp->scrr_beg * svsp->maxcol) +
  378                                    ((svsp->parms[0] - 1) * svsp->maxcol) +
  379                                    svsp->parms[1] - 1;
  380                 svsp->col = svsp->parms[1] - 1;
  381                 svsp->abs_write = 0;
  382         }
  383         else    /* relative to screen start */
  384         {
  385                 if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
  386                 {
  387                         svsp->cur_offset = 0;
  388                         svsp->col = 0;
  389                         svsp->abs_write = 0;
  390                         return;
  391                 }
  392 
  393                 if(svsp->parms[0] <= 0)
  394                         svsp->parms[0] = 1;
  395                 else if(svsp->parms[0] > svsp->screen_rows)
  396                         svsp->parms[0] = svsp->screen_rows;
  397 
  398                 if(svsp->parms[1] <= 0 )
  399                         svsp->parms[1] = 1;
  400                 if(svsp->parms[1] > svsp->maxcol)       /* col */
  401                         svsp->parms[1] = svsp->maxcol;
  402 
  403                 svsp->cur_offset = (((svsp->parms[0]-1)*svsp->maxcol) +
  404                                     (svsp->parms[1]-1));
  405                 svsp->col = svsp->parms[1]-1;
  406 
  407                 if (svsp->cur_offset >=
  408                         ((svsp->scrr_beg + svsp->scrr_len + 1) * svsp->maxcol))
  409 
  410                         svsp->abs_write = 1;
  411                 else
  412                         svsp->abs_write = 0;
  413         }
  414 }
  415 
  416 /*---------------------------------------------------------------------------*
  417  *      RIS - reset to initial state (hard emulator runtime reset)
  418  *---------------------------------------------------------------------------*/
  419 void
  420 vt_ris(struct video_state *svsp)
  421 {
  422         fillw(user_attr | ' ', svsp->Crtat, svsp->maxcol * svsp->screen_rows);
  423         svsp->cur_offset = 0;           /* cursor upper left corner */
  424         svsp->col = 0;
  425         svsp->row = 0;
  426         svsp->lnm = 0;                  /* CR only */
  427         clear_dld(svsp);                /* clear download charset */
  428         vt_clearudk(svsp);              /* clear user defined keys */
  429         svsp->selchar = 0;              /* selective attribute off */
  430         vt_str(svsp);                   /* and soft terminal reset */
  431 }
  432 
  433 /*---------------------------------------------------------------------------*
  434  *      DECSTR - soft terminal reset (SOFT emulator runtime reset)
  435  *---------------------------------------------------------------------------*/
  436 void
  437 vt_str(struct video_state *svsp)
  438 {
  439         int i;
  440 
  441         clr_parms(svsp);                        /* escape parameter init */
  442         svsp->state = STATE_INIT;               /* initial state */
  443 
  444         svsp->dis_fnc = 0;                      /* display functions reset */
  445 
  446         svsp->sc_flag = 0;                      /* save cursor position */
  447         svsp->transparent = 0;                  /* enable control code processing */
  448 
  449         for(i = 0; i < MAXTAB; i++)             /* setup tabstops */
  450         {
  451                 if(!(i % 8))
  452                         svsp->tab_stops[i] = 1;
  453                 else
  454                         svsp->tab_stops[i] = 0;
  455         }
  456 
  457         svsp->irm = 0;                          /* replace mode */
  458         svsp->m_om = 0;                         /* origin mode */
  459         svsp->m_awm = 1;                        /* auto wrap mode */
  460 
  461 #if PCVT_INHIBIT_NUMLOCK
  462         svsp->num_lock = 0;                     /* keypad application mode */
  463 #else
  464         svsp->num_lock = 1;                     /* keypad numeric mode */
  465 #endif
  466 
  467         svsp->scroll_lock = 0;                  /* reset keyboard modes */
  468         svsp->caps_lock = 0;
  469 
  470         svsp->ckm = 1;                          /* cursor key mode = "normal" ... */
  471         svsp->scrr_beg = 0;                     /* start of scrolling region */
  472         svsp->scrr_len = svsp->screen_rows;     /* no. of lines in scrolling region */
  473         svsp->abs_write = 0;                    /* scrr is complete screen */
  474         svsp->scrr_end = svsp->scrr_len - 1;
  475 
  476         if(adaptor_type == EGA_ADAPTOR || adaptor_type == VGA_ADAPTOR)
  477         {
  478                 svsp->G0 = cse_ascii;           /* G0 = ascii   */
  479                 svsp->G1 = cse_ascii;           /* G1 = ascii   */
  480                 svsp->G2 = cse_supplemental;    /* G2 = supplemental */
  481                 svsp->G3 = cse_supplemental;    /* G3 = supplemental */
  482                 svsp->GL = &svsp->G0;           /* GL = G0 */
  483                 svsp->GR = &svsp->G2;           /* GR = G2 */
  484         }
  485         else
  486         {
  487                 svsp->G0 = csd_ascii;           /* G0 = ascii   */
  488                 svsp->G1 = csd_ascii;           /* G1 = ascii   */
  489                 svsp->G2 = csd_supplemental;    /* G2 = supplemental */
  490                 svsp->G3 = csd_supplemental;    /* G3 = supplemental */
  491                 svsp->GL = &svsp->G0;           /* GL = G0 */
  492                 svsp->GR = &svsp->G2;           /* GR = G2 */
  493         }
  494 
  495         svsp->vtsgr = VT_NORMAL;                /* no attributes */
  496         svsp->c_attr = user_attr;               /* reset sgr to normal */
  497 
  498         svsp->selchar = 0;                      /* selective attribute off */
  499         vt_initsel(svsp);
  500 
  501         init_ufkl(svsp);                        /* init user fkey labels */
  502         init_sfkl(svsp);                        /* init system fkey labels */
  503 
  504         update_led();                           /* update keyboard LED's */
  505 }
  506 
  507 /*---------------------------------------------------------------------------*
  508  *      RI - reverse index, move cursor up
  509  *---------------------------------------------------------------------------*/
  510 void
  511 vt_ri(struct video_state *svsp)
  512 {
  513         if(svsp->cur_offset >= ((svsp->scrr_beg * svsp->maxcol) + svsp->maxcol))
  514                 svsp->cur_offset -= svsp->maxcol;
  515         else
  516                 roll_down(svsp, 1);
  517 }
  518 
  519 /*---------------------------------------------------------------------------*
  520  *      IND - index, move cursor down
  521  *---------------------------------------------------------------------------*/
  522 void
  523 vt_ind(struct video_state *svsp)
  524 {
  525         if(svsp->cur_offset < (svsp->scrr_end * svsp->maxcol))
  526                 svsp->cur_offset += svsp->maxcol;
  527         else
  528                 roll_up(svsp, 1);
  529 }
  530 
  531 /*---------------------------------------------------------------------------*
  532  *      NEL - next line, first pos of next line
  533  *---------------------------------------------------------------------------*/
  534 void
  535 vt_nel(struct video_state *svsp)
  536 {
  537         if(svsp->cur_offset < (svsp->scrr_end * svsp->maxcol))
  538         {
  539                 svsp->cur_offset += (svsp->maxcol-svsp->col);
  540                 svsp->col = 0;
  541         }
  542         else
  543         {
  544                 roll_up(svsp, 1);
  545                 svsp->cur_offset -= svsp->col;
  546                 svsp->col = 0;
  547         }
  548 }
  549 
  550 /*---------------------------------------------------------------------------*
  551  *      set dec private modes, esc [ ? x h
  552  *---------------------------------------------------------------------------*/
  553 void
  554 vt_set_dec_priv_qm(struct video_state *svsp)
  555 {
  556         switch(svsp->parms[0])
  557         {
  558                 case 0:         /* error, ignored */
  559                 case 1:         /* CKM - cursor key mode */
  560                         svsp->ckm = 1;
  561                         break;
  562 
  563                 case 2:         /* ANM - ansi/vt52 mode */
  564                         break;
  565 
  566                 case 3:         /* COLM - column mode */
  567                         vt_col(svsp, SCR_COL132);
  568                         break;
  569 
  570                 case 4:         /* SCLM - scrolling mode */
  571                 case 5:         /* SCNM - screen mode */
  572                         break;
  573 
  574                 case 6:         /* OM - origin mode */
  575                         svsp->m_om = 1;
  576                         break;
  577 
  578                 case 7:         /* AWM - auto wrap mode */
  579                         svsp->m_awm = 1;
  580                         swritefkl(7,(u_char *)"AUTOWRAPENABLE *",svsp);
  581                         break;
  582 
  583                 case 8:         /* ARM - auto repeat mode */
  584                         kbrepflag = 1;
  585                         break;
  586 
  587                 case 9:         /* INLM - interlace mode */
  588                 case 10:        /* EDM - edit mode */
  589                 case 11:        /* LTM - line transmit mode */
  590                 case 12:        /* */
  591                 case 13:        /* SCFDM - space compression / field delimiting */
  592                 case 14:        /* TEM - transmit execution mode */
  593                 case 15:        /* */
  594                 case 16:        /* EKEM - edit key execution mode */
  595                         break;
  596 
  597                 case 25:        /* TCEM - text cursor enable mode */
  598                         if(vsp == svsp)
  599                                 sw_cursor(1);   /* cursor on */
  600                         svsp->cursor_on = 1;
  601                         break;
  602 
  603                 case 42:        /* NRCM - 7bit NRC characters */
  604                         break;
  605         }
  606 }
  607 
  608 /*---------------------------------------------------------------------------*
  609  *      reset dec private modes, esc [ ? x l
  610  *---------------------------------------------------------------------------*/
  611 void
  612 vt_reset_dec_priv_qm(struct video_state *svsp)
  613 {
  614         switch(svsp->parms[0])
  615         {
  616                 case 0:         /* error, ignored */
  617                 case 1:         /* CKM - cursor key mode */
  618                         svsp->ckm = 0;
  619                         break;
  620 
  621                 case 2:         /* ANM - ansi/vt52 mode */
  622                         break;
  623 
  624                 case 3:         /* COLM - column mode */
  625                         vt_col(svsp, SCR_COL80);
  626                         break;
  627 
  628                 case 4:         /* SCLM - scrolling mode */
  629                 case 5:         /* SCNM - screen mode */
  630                         break;
  631 
  632                 case 6:         /* OM - origin mode */
  633                         svsp->m_om = 0;
  634                         break;
  635 
  636                 case 7:         /* AWM - auto wrap mode */
  637                         svsp->m_awm = 0;
  638                         swritefkl(7,(u_char *)"AUTOWRAPENABLE  ",svsp);
  639                         break;
  640 
  641                 case 8:         /* ARM - auto repeat mode */
  642                         kbrepflag = 0;
  643                         break;
  644 
  645                 case 9:         /* INLM - interlace mode */
  646                 case 10:        /* EDM - edit mode */
  647                 case 11:        /* LTM - line transmit mode */
  648                 case 12:        /* */
  649                 case 13:        /* SCFDM - space compression / field delimiting */
  650                 case 14:        /* TEM - transmit execution mode */
  651                 case 15:        /* */
  652                 case 16:        /* EKEM - edit key execution mode */
  653                         break;
  654 
  655                 case 25:        /* TCEM - text cursor enable mode */
  656                         if(vsp == svsp)
  657                                 sw_cursor(0);   /* cursor off */
  658                         svsp->cursor_on = 0;
  659                         break;
  660 
  661                 case 42:        /* NRCM - 7bit NRC characters */
  662                         break;
  663         }
  664 }
  665 
  666 /*---------------------------------------------------------------------------*
  667  *      set ansi modes, esc [ x
  668  *---------------------------------------------------------------------------*/
  669 void
  670 vt_set_ansi(struct video_state *svsp)
  671 {
  672         switch(svsp->parms[0])
  673         {
  674                 case 0:         /* error, ignored */
  675                 case 1:         /* GATM - guarded area transfer mode */
  676                 case 2:         /* KAM - keyboard action mode */
  677                 case 3:         /* CRM - Control Representation mode */
  678                         break;
  679 
  680                 case 4:         /* IRM - insert replacement mode */
  681                         svsp->irm = 1; /* Insert mode */
  682                         break;
  683 
  684                 case 5:         /* SRTM - status report transfer mode */
  685                 case 6:         /* ERM - erasue mode */
  686                 case 7:         /* VEM - vertical editing mode */
  687                 case 10:        /* HEM - horizontal editing mode */
  688                 case 11:        /* PUM - position unit mode */
  689                 case 12:        /* SRM - send-receive mode */
  690                 case 13:        /* FEAM - format effector action mode */
  691                 case 14:        /* FETM - format effector transfer mode */
  692                 case 15:        /* MATM - multiple area transfer mode */
  693                 case 16:        /* TTM - transfer termination */
  694                 case 17:        /* SATM - selected area transfer mode */
  695                 case 18:        /* TSM - tabulation stop mode */
  696                 case 19:        /* EBM - editing boundary mode */
  697                         break;
  698 
  699                 case 20:        /* LNM - line feed / newline mode */
  700                         svsp->lnm = 1;
  701                         break;
  702         }
  703 }
  704 
  705 /*---------------------------------------------------------------------------*
  706  *      reset ansi modes, esc [ x
  707  *---------------------------------------------------------------------------*/
  708 void
  709 vt_reset_ansi(struct video_state *svsp)
  710 {
  711         switch(svsp->parms[0])
  712         {
  713                 case 0:         /* error, ignored */
  714                 case 1:         /* GATM - guarded area transfer mode */
  715                 case 2:         /* KAM - keyboard action mode */
  716                 case 3:         /* CRM - Control Representation mode */
  717                         break;
  718 
  719                 case 4:         /* IRM - insert replacement mode */
  720                         svsp->irm = 0;  /* Replace mode */
  721                         break;
  722 
  723                 case 5:         /* SRTM - status report transfer mode */
  724                 case 6:         /* ERM - erasue mode */
  725                 case 7:         /* VEM - vertical editing mode */
  726                 case 10:        /* HEM - horizontal editing mode */
  727                 case 11:        /* PUM - position unit mode */
  728                 case 12:        /* SRM - send-receive mode */
  729                 case 13:        /* FEAM - format effector action mode */
  730                 case 14:        /* FETM - format effector transfer mode */
  731                 case 15:        /* MATM - multiple area transfer mode */
  732                 case 16:        /* TTM - transfer termination */
  733                 case 17:        /* SATM - selected area transfer mode */
  734                 case 18:        /* TSM - tabulation stop mode */
  735                 case 19:        /* EBM - editing boundary mode */
  736                         break;
  737 
  738                 case 20:        /* LNM - line feed / newline mode */
  739                         svsp->lnm = 0;
  740                         break;
  741         }
  742 }
  743 
  744 /*---------------------------------------------------------------------------*
  745  *      clear tab stop(s)
  746  *---------------------------------------------------------------------------*/
  747 void
  748 vt_clrtab(struct video_state *svsp)
  749 {
  750         int i;
  751 
  752         if(svsp->parms[0] == 0)
  753                 svsp->tab_stops[svsp->col] = 0;
  754         else if(svsp->parms[0] == 3)
  755         {
  756                 for(i=0; i<MAXTAB; i++)
  757                         svsp->tab_stops[i] = 0;
  758         }
  759 }
  760 
  761 /*---------------------------------------------------------------------------*
  762  *      DECSC - save cursor & attributes
  763  *---------------------------------------------------------------------------*/
  764 void
  765 vt_sc(struct video_state *svsp)
  766 {
  767         svsp->sc_flag = 1;
  768         svsp->sc_row = svsp->row;
  769         svsp->sc_col = svsp->col;
  770         svsp->sc_cur_offset = svsp->cur_offset;
  771         svsp->sc_attr = svsp->c_attr;
  772         svsp->sc_awm = svsp->m_awm;
  773         svsp->sc_om = svsp->m_om;
  774         svsp->sc_G0 = svsp->G0;
  775         svsp->sc_G1 = svsp->G1;
  776         svsp->sc_G2 = svsp->G2;
  777         svsp->sc_G3 = svsp->G3;
  778         svsp->sc_GL = svsp->GL;
  779         svsp->sc_GR = svsp->GR;
  780         svsp->sc_sel = svsp->selchar;
  781         svsp->sc_vtsgr = svsp->vtsgr;
  782 }
  783 
  784 /*---------------------------------------------------------------------------*
  785  *      DECRC - restore cursor & attributes
  786  *---------------------------------------------------------------------------*/
  787 void
  788 vt_rc(struct video_state *svsp)
  789 {
  790         if(svsp->sc_flag == 1)
  791         {
  792                 svsp->sc_flag = 0;
  793                 svsp->row = svsp->sc_row;
  794                 svsp->col = svsp->sc_col;
  795                 svsp->cur_offset = svsp->sc_cur_offset;
  796                 svsp->c_attr = svsp->sc_attr;
  797                 svsp->m_awm = svsp->sc_awm;
  798                 svsp->m_om = svsp->sc_om;
  799                 svsp->G0 = svsp->sc_G0;
  800                 svsp->G1 = svsp->sc_G1;
  801                 svsp->G2 = svsp->sc_G2;
  802                 svsp->G3 = svsp->sc_G3;
  803                 svsp->GL = svsp->sc_GL;
  804                 svsp->GR = svsp->sc_GR;
  805                 svsp->selchar = svsp->sc_sel;
  806                 svsp->vtsgr = svsp->sc_vtsgr;
  807         }
  808 }
  809 
  810 /*---------------------------------------------------------------------------*
  811  *      designate a character set as G0, G1, G2 or G3 for 94/96 char sets
  812  *---------------------------------------------------------------------------*/
  813 void
  814 vt_designate(struct video_state *svsp)
  815 {
  816         u_short *ctp = NULL;
  817         u_char ch;
  818 
  819         if(svsp->whichi == 1)
  820                 ch = svsp->which[0];
  821         else
  822         {
  823                 int i;
  824 
  825                 if(svsp->dld_id[0] == '\0')
  826                         return;
  827 
  828                 if(!(((adaptor_type == EGA_ADAPTOR) ||
  829                      (adaptor_type == VGA_ADAPTOR)) &&
  830                      (vgacs[svsp->vga_charset].secondloaded)))
  831                 {
  832                         return;
  833                 }
  834 
  835                 for(i = (svsp->whichi)-1; i >= 0; i--)
  836                 {
  837                          if(svsp->which[i] != svsp->dld_id[i])
  838                                 return;
  839                 }
  840 #ifdef HAVECSE_DOWNLOADABLE
  841                 ctp = cse_downloadable;
  842                 swcsp(svsp, ctp);
  843 #endif
  844                 return;
  845         }
  846 
  847         if(((adaptor_type == EGA_ADAPTOR) || (adaptor_type == VGA_ADAPTOR)) &&
  848            (vgacs[svsp->vga_charset].secondloaded))
  849         {
  850                 if((ch == svsp->dld_id[0]) && (svsp->dld_id[1] == '\0'))
  851                 {
  852 #ifdef HAVECSE_DOWNLOADABLE
  853                         ctp = cse_downloadable;
  854                         swcsp(svsp, ctp);
  855 #endif
  856                         return;
  857                 }
  858 
  859                 switch(ch)
  860                 {
  861                         case 'A': /* British or ISO-Latin-1 */
  862                                 switch(svsp->state)
  863                                 {
  864                                         case STATE_BROPN: /* designate G0 */
  865                                         case STATE_BRCLO: /* designate G1 */
  866                                         case STATE_STAR:  /* designate G2 */
  867                                         case STATE_PLUS:  /* designate G3 */
  868 #ifdef HAVECSE_BRITISH
  869                                                 ctp = cse_british;
  870 #endif
  871                                                 break;
  872 
  873                                         case STATE_MINUS: /* designate G1 (96)*/
  874                                         case STATE_DOT:   /* designate G2 (96)*/
  875                                         case STATE_SLASH: /* designate G3 (96)*/
  876 #ifdef HAVECSE_ISOLATIN
  877                                                 ctp = cse_isolatin;
  878 #endif
  879                                                 break;
  880                                 }
  881                                 break;
  882 
  883                         case 'B': /* USASCII */
  884 #ifdef HAVECSE_ASCII
  885                                 ctp = cse_ascii;
  886 #endif
  887                                 break;
  888 
  889                         case 'C': /* Finnish */
  890                         case '5': /* Finnish */
  891 #ifdef HAVECSE_FINNISH
  892                                 ctp = cse_finnish;
  893 #endif
  894                                 break;
  895 
  896                         case 'E': /* Norwegian/Danish */
  897                         case '6': /* Norwegian/Danish */
  898 #ifdef HAVECSE_NORWEGIANDANISH
  899                                 ctp = cse_norwegiandanish;
  900 #endif
  901                                 break;
  902 
  903                         case 'H': /* Swedish */
  904                         case '7': /* Swedish */
  905 #ifdef HAVECSE_SWEDISH
  906                                 ctp = cse_swedish;
  907 #endif
  908                                 break;
  909 
  910                         case 'K': /* German */
  911 #ifdef HAVECSE_GERMAN
  912                                 ctp = cse_german;
  913 #endif
  914                                 break;
  915 
  916                         case 'Q': /* French Canadien */
  917 #ifdef HAVECSE_FRENCHCANADA
  918                                 ctp = cse_frenchcanada;
  919 #endif
  920                                 break;
  921 
  922                         case 'R': /* French */
  923 #ifdef HAVECSE_FRENCH
  924                                 ctp = cse_french;
  925 #endif
  926                                 break;
  927 
  928                         case 'Y': /* Italian */
  929 #ifdef HAVECSE_ITALIAN
  930                                 ctp = cse_italian;
  931 #endif
  932                                 break;
  933 
  934                         case 'Z': /* Spanish */
  935 #ifdef HAVECSE_SPANISH
  936                                 ctp = cse_spanish;
  937 #endif
  938                                 break;
  939 
  940                         case '': /* special graphics */
  941 #ifdef HAVECSE_SPECIAL
  942                                 ctp = cse_special;
  943 #endif
  944                                 break;
  945 
  946                         case '1': /* alternate ROM */
  947 #ifdef HAVECSE_ALTERNATEROM1
  948                                 ctp = cse_alternaterom1;
  949 #endif
  950                                 break;
  951 
  952                         case '2': /* alt ROM, spec graphics */
  953 #ifdef HAVECSE_ALTERNATEROM2
  954                                 ctp = cse_alternaterom2;
  955 #endif
  956                                 break;
  957 
  958                         case '3': /* HP Roman 8, upper 128 chars*/
  959 #ifdef HAVECSE_ROMAN8
  960                                 ctp = cse_roman8;
  961 #endif
  962                                 break;
  963 
  964                         case '4': /* Dutch */
  965 #ifdef HAVECSE_DUTCH
  966                                 ctp = cse_dutch;
  967 #endif
  968                                 break;
  969 
  970                         case '<': /* DEC Supplemental */
  971 #ifdef HAVECSE_SUPPLEMENTAL
  972                                 ctp = cse_supplemental;
  973 #endif
  974                                 break;
  975 
  976                         case '=': /* Swiss */
  977 #ifdef HAVECSE_SWISS
  978                                 ctp = cse_swiss;
  979 #endif
  980                                 break;
  981 
  982                         case '>': /* DEC Technical */
  983 #ifdef HAVECSE_TECHNICAL
  984                                 ctp = cse_technical;
  985 #endif
  986                                 break;
  987 
  988                         default:
  989                                 break;
  990                 }
  991         }
  992         else
  993         {
  994                 switch(ch)
  995                 {
  996                         case 'A': /* British or ISO-Latin-1 */
  997                                 switch(svsp->state)
  998                                 {
  999                                         case STATE_BROPN: /* designate G0 */
 1000                                         case STATE_BRCLO: /* designate G1 */
 1001                                         case STATE_STAR:  /* designate G2 */
 1002                                         case STATE_PLUS:  /* designate G3 */
 1003 #ifdef HAVECSD_BRITISH
 1004                                                 ctp = csd_british;
 1005 #endif
 1006                                                 break;
 1007 
 1008                                         case STATE_MINUS: /* designate G1 (96)*/
 1009                                         case STATE_DOT:   /* designate G2 (96)*/
 1010                                         case STATE_SLASH: /* designate G3 (96)*/
 1011 #ifdef HAVECSD_ISOLATIN
 1012                                                 ctp = csd_isolatin;
 1013 #endif
 1014                                                 break;
 1015                                 }
 1016                                 break;
 1017 
 1018                         case 'B': /* USASCII */
 1019 #ifdef HAVECSD_ASCII
 1020                                 ctp = csd_ascii;
 1021 #endif
 1022                                 break;
 1023 
 1024                         case 'C': /* Finnish */
 1025                         case '5': /* Finnish */
 1026 #ifdef HAVECSD_FINNISH
 1027                                 ctp = csd_finnish;
 1028 #endif
 1029                                 break;
 1030 
 1031                         case 'E': /* Norwegian/Danish */
 1032                         case '6': /* Norwegian/Danish */
 1033 #ifdef HAVECSD_NORWEGIANDANISH
 1034                                 ctp = csd_norwegiandanish;
 1035 #endif
 1036                                 break;
 1037 
 1038                         case 'H': /* Swedish */
 1039                         case '7': /* Swedish */
 1040 #ifdef HAVECSD_SWEDISH
 1041                                 ctp = csd_swedish;
 1042 #endif
 1043                                 break;
 1044 
 1045                         case 'K': /* German */
 1046 #ifdef HAVECSD_GERMAN
 1047                                 ctp = csd_german;
 1048 #endif
 1049                                 break;
 1050 
 1051                         case 'Q': /* French Canadien */
 1052 #ifdef HAVECSD_FRENCHCANADA
 1053                                 ctp = csd_frenchcanada;
 1054 #endif
 1055                                 break;
 1056 
 1057                         case 'R': /* French */
 1058 #ifdef HAVECSD_FRENCH
 1059                                 ctp = csd_french;
 1060 #endif
 1061                                 break;
 1062 
 1063                         case 'Y': /* Italian */
 1064 #ifdef HAVECSD_ITALIAN
 1065                                 ctp = csd_italian;
 1066 #endif
 1067                                 break;
 1068 
 1069                         case 'Z': /* Spanish */
 1070 #ifdef HAVECSD_SPANISH
 1071                                 ctp = csd_spanish;
 1072 #endif
 1073                                 break;
 1074 
 1075                         case '': /* special graphics */
 1076 #ifdef HAVECSD_SPECIAL
 1077                                 ctp = csd_special;
 1078 #endif
 1079                                 break;
 1080 
 1081                         case '1': /* alternate ROM */
 1082 #ifdef HAVECSD_ALTERNATEROM1
 1083                                 ctp = csd_alternaterom1;
 1084 #endif
 1085                                 break;
 1086 
 1087                         case '2': /* alt ROM, spec graphics */
 1088 #ifdef HAVECSD_ALTERNATEROM2
 1089                                 ctp = csd_alternaterom2;
 1090 #endif
 1091                                 break;
 1092 
 1093                         case '3': /* HP Roman 8, upper 128 chars*/
 1094 #ifdef HAVECSD_ROMAN8
 1095                                 ctp = csd_roman8;
 1096 #endif
 1097                                 break;
 1098 
 1099                         case '4': /* Dutch */
 1100 #ifdef HAVECSD_DUTCH
 1101                                 ctp = csd_dutch;
 1102 #endif
 1103                                 break;
 1104 
 1105                         case '<': /* DEC Supplemental */
 1106 #ifdef HAVECSD_SUPPLEMENTAL
 1107                                 ctp = csd_supplemental;
 1108 #endif
 1109                                 break;
 1110 
 1111                         case '=': /* Swiss */
 1112 #ifdef HAVECSD_SWISS
 1113                                 ctp = csd_swiss;
 1114 #endif
 1115                                 break;
 1116 
 1117                         case '>': /* DEC Technical */
 1118 #ifdef HAVECSD_TECHNICAL
 1119                                 ctp = csd_technical;
 1120 #endif
 1121                                 break;
 1122 
 1123                         default:
 1124                                 break;
 1125                 }
 1126         }
 1127         swcsp(svsp, ctp);
 1128 }
 1129 
 1130 /*---------------------------------------------------------------------------*
 1131  *      device attributes
 1132  *---------------------------------------------------------------------------*/
 1133 void
 1134 vt_da(struct video_state *svsp)
 1135 {
 1136         static u_char *response = (u_char *)DA_VT220;
 1137 
 1138         svsp->report_chars = response;
 1139         svsp->report_count = 18;
 1140         respond(svsp);
 1141 }
 1142 
 1143 /*---------------------------------------------------------------------------*
 1144  *      screen alignment display
 1145  *---------------------------------------------------------------------------*/
 1146 void
 1147 vt_aln(struct video_state *svsp)
 1148 {
 1149         register int i;
 1150 
 1151         svsp->cur_offset = 0;
 1152         svsp->col = 0;
 1153 
 1154         for(i=0; i < (svsp->screen_rows*svsp->maxcol); i++)
 1155         {
 1156                 *(svsp->Crtat + svsp->cur_offset) = user_attr | 'E';
 1157                 vt_selattr(svsp);
 1158                 svsp->cur_offset++;
 1159                 svsp->col++;
 1160         }
 1161 
 1162         svsp->cur_offset = 0;   /* reset everything ! */
 1163         svsp->col = 0;
 1164         svsp->row = 0;
 1165 }
 1166 
 1167 /*---------------------------------------------------------------------------*
 1168  *      request terminal parameters
 1169  *---------------------------------------------------------------------------*/
 1170 void
 1171 vt_reqtparm(struct video_state *svsp)
 1172 {
 1173         static u_char *answr = (u_char *)"\033[3;1;1;120;120;1;0x";
 1174 
 1175         svsp->report_chars = answr;
 1176         svsp->report_count = 20;
 1177         respond(svsp);
 1178 }
 1179 
 1180 /*---------------------------------------------------------------------------*
 1181  *      invoke selftest
 1182  *---------------------------------------------------------------------------*/
 1183 void
 1184 vt_tst(struct video_state *svsp)
 1185 {
 1186         clear_dld(svsp);
 1187 }
 1188 
 1189 /*---------------------------------------------------------------------------*
 1190  *      device status reports
 1191  *---------------------------------------------------------------------------*/
 1192 void
 1193 vt_dsr(struct video_state *svsp)
 1194 {
 1195         static u_char *answr = (u_char *)"\033[0n";
 1196         static u_char *panswr = (u_char *)"\033[?13n"; /* Printer Unattached */
 1197         static u_char *udkanswr = (u_char *)"\033[?21n"; /* UDK Locked */
 1198         static u_char *langanswr = (u_char *)"\033[?27;1n"; /* North American*/
 1199         static u_char buffer[16];
 1200         int i = 0;
 1201 
 1202         switch(svsp->parms[0])
 1203         {
 1204                 case 5:         /* return status */
 1205                         svsp->report_chars = answr;
 1206                         svsp->report_count = 4;
 1207                         respond(svsp);
 1208                         break;
 1209 
 1210                 case 6:         /* return cursor position */
 1211                         buffer[i++] = 0x1b;
 1212                         buffer[i++] = '[';
 1213                         if((svsp->row+1) > 10)
 1214                                 buffer[i++] = ((svsp->row+1) / 10) + '';
 1215                         buffer[i++] = ((svsp->row+1) % 10) + '';
 1216                         buffer[i++] = ';';
 1217                         if((svsp->col+1) > 10)
 1218                                 buffer[i++] = ((svsp->col+1) / 10) + '';
 1219                         buffer[i++] = ((svsp->col+1) % 10) + '';
 1220                         buffer[i++] = 'R';
 1221                         buffer[i++] = '\0';
 1222 
 1223                         svsp->report_chars = buffer;
 1224                         svsp->report_count = i;
 1225                         respond(svsp);
 1226                         break;
 1227 
 1228                 case 15:        /* return printer status */
 1229                         svsp->report_chars = panswr;
 1230                         svsp->report_count = 6;
 1231                         respond(svsp);
 1232                         break;
 1233 
 1234                 case 25:        /* return udk status */
 1235                         svsp->report_chars = udkanswr;
 1236                         svsp->report_count = 6;
 1237                         respond(svsp);
 1238                         break;
 1239 
 1240                 case 26:        /* return language status */
 1241                         svsp->report_chars = langanswr;
 1242                         svsp->report_count = 8;
 1243                         respond(svsp);
 1244                         break;
 1245 
 1246                 default:        /* nothing else valid */
 1247                         break;
 1248         }
 1249 }
 1250 
 1251 /*---------------------------------------------------------------------------*
 1252  *      IL - insert line
 1253  *---------------------------------------------------------------------------*/
 1254 void
 1255 vt_il(struct video_state *svsp)
 1256 {
 1257         register int p = svsp->parms[0];
 1258 
 1259         if((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end))
 1260         {
 1261                 if(p <= 0)
 1262                         p = 1;
 1263                 else if(p > svsp->scrr_end - svsp->row)
 1264                         p = svsp->scrr_end - svsp->row;
 1265 
 1266                 svsp->cur_offset -= svsp->col;
 1267                 svsp->col = 0;
 1268                 if(svsp->row == svsp->scrr_beg)
 1269                         roll_down(svsp, p);
 1270                 else
 1271                 {
 1272                     bcopy(svsp->Crtat + svsp->cur_offset,
 1273                           svsp->Crtat + svsp->cur_offset + (p * svsp->maxcol),
 1274                           svsp->maxcol * (svsp->scrr_end-svsp->row+1-p) * CHR );
 1275 
 1276                     fillw(user_attr | ' ',
 1277                           svsp->Crtat + svsp->cur_offset,
 1278                           p * svsp->maxcol);
 1279                 }
 1280         }
 1281 }
 1282 
 1283 /*---------------------------------------------------------------------------*
 1284  *      ICH - insert character
 1285  *---------------------------------------------------------------------------*/
 1286 void
 1287 vt_ic(struct video_state *svsp)
 1288 {
 1289         register int p = svsp->parms[0];
 1290 
 1291         if(p <= 0)
 1292                 p = 1;
 1293         else if(p > svsp->maxcol-svsp->col)
 1294                 p = svsp->maxcol-svsp->col;
 1295 
 1296         while(p--)
 1297         {
 1298                 bcopy((svsp->Crtat + svsp->cur_offset),
 1299                       (svsp->Crtat + svsp->cur_offset) + 1,
 1300                       (((svsp->maxcol)-1)-svsp->col) * CHR);
 1301 
 1302                 *(svsp->Crtat + svsp->cur_offset) = user_attr | ' ';
 1303                 vt_selattr(svsp);
 1304         }
 1305 }
 1306 
 1307 /*---------------------------------------------------------------------------*
 1308  *      DL - delete line
 1309  *---------------------------------------------------------------------------*/
 1310 void
 1311 vt_dl(struct video_state *svsp)
 1312 {
 1313         register int p = svsp->parms[0];
 1314 
 1315         if((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end))
 1316         {
 1317                 if(p <= 0)
 1318                         p = 1;
 1319                 else if(p > svsp->scrr_end - svsp->row)
 1320                         p = svsp->scrr_end - svsp->row;
 1321 
 1322                 svsp->cur_offset -= svsp->col;
 1323                 svsp->col = 0;
 1324 
 1325                 if(svsp->row == svsp->scrr_beg)
 1326                         roll_up(svsp, p);
 1327                 else
 1328                 {
 1329                     bcopy(svsp->Crtat + svsp->cur_offset + (p * svsp->maxcol),
 1330                           svsp->Crtat + svsp->cur_offset,
 1331                           svsp->maxcol * (svsp->scrr_end-svsp->row+1-p) * CHR );
 1332 
 1333                     fillw(user_attr | ' ',
 1334                           svsp->Crtat + ((svsp->scrr_end-p+1) * svsp->maxcol),
 1335                           p * svsp->maxcol);
 1336                 }
 1337         }
 1338 }
 1339 
 1340 /*---------------------------------------------------------------------------*
 1341  *      DCH - delete character
 1342  *---------------------------------------------------------------------------*/
 1343 void
 1344 vt_dch(struct video_state *svsp)
 1345 {
 1346         register int p = svsp->parms[0];
 1347 
 1348         if(p <= 0)
 1349                 p = 1;
 1350         else if(p > svsp->maxcol-svsp->col)
 1351                 p = svsp->maxcol-svsp->col;
 1352 
 1353         while(p--)
 1354         {
 1355                 bcopy((svsp->Crtat + svsp->cur_offset)+1,
 1356                       (svsp->Crtat + svsp->cur_offset),
 1357                       (((svsp->maxcol)-1) - svsp->col)* CHR );
 1358 
 1359                 *((svsp->Crtat + svsp->cur_offset) +
 1360                         ((svsp->maxcol)-1)-svsp->col) = user_attr | ' ';
 1361         }
 1362 }
 1363 
 1364 /*---------------------------------------------------------------------------*
 1365  *      scroll up
 1366  *---------------------------------------------------------------------------*/
 1367 void
 1368 vt_su(struct video_state *svsp)
 1369 {
 1370         register int p = svsp->parms[0];
 1371 
 1372         if(p <= 0)
 1373                 p = 1;
 1374         else if(p > svsp->screen_rows-1)
 1375                 p = svsp->screen_rows-1;
 1376 
 1377         roll_up(svsp, p);
 1378 }
 1379 
 1380 /*---------------------------------------------------------------------------*
 1381  *      scroll down
 1382  *---------------------------------------------------------------------------*/
 1383 void
 1384 vt_sd(struct video_state *svsp)
 1385 {
 1386         register int p = svsp->parms[0];
 1387 
 1388         if(p <= 0)
 1389                 p = 1;
 1390         else if(p > svsp->screen_rows-1)
 1391                 p = svsp->screen_rows-1;
 1392 
 1393         roll_down(svsp, p);
 1394 }
 1395 
 1396 /*---------------------------------------------------------------------------*
 1397  *      ECH - erase character
 1398  *---------------------------------------------------------------------------*/
 1399 void
 1400 vt_ech(struct video_state *svsp)
 1401 {
 1402         register int p = svsp->parms[0];
 1403 
 1404         if(p <= 0)
 1405                 p = 1;
 1406         else if(p > svsp->maxcol-svsp->col)
 1407                 p = svsp->maxcol-svsp->col;
 1408 
 1409         fillw(user_attr | ' ', (svsp->Crtat + svsp->cur_offset), p);
 1410 }
 1411 
 1412 /*---------------------------------------------------------------------------*
 1413  *      media copy      (NO PRINTER AVAILABLE IN KERNEL ...)
 1414  *---------------------------------------------------------------------------*/
 1415 void
 1416 vt_mc(struct video_state *svsp)
 1417 {
 1418 }
 1419 
 1420 /*---------------------------------------------------------------------------*
 1421  *      Device Control String State Machine Entry for:
 1422  *
 1423  *      DECUDK - user-defined keys      and
 1424  *      DECDLD - downloadable charset
 1425  *
 1426  *---------------------------------------------------------------------------*/
 1427 void
 1428 vt_dcsentry(int ch, struct video_state *svsp)
 1429 {
 1430         switch(svsp->dcs_state)
 1431         {
 1432                 case DCS_INIT:
 1433                         switch(ch)
 1434                         {
 1435                                 case '':
 1436                                 case '1':
 1437                                 case '2':
 1438                                 case '3':
 1439                                 case '4':
 1440                                 case '5':
 1441                                 case '6':
 1442                                 case '7':
 1443                                 case '8':
 1444                                 case '9':       /* parameters */
 1445                                         svsp->parms[svsp->parmi] *= 10;
 1446                                         svsp->parms[svsp->parmi] += (ch -'');
 1447                                         break;
 1448 
 1449                                 case ';':       /* next parameter */
 1450                                         svsp->parmi =
 1451                                                 (svsp->parmi+1 < MAXPARMS) ?
 1452                                                 svsp->parmi+1 : svsp->parmi;
 1453                                         break;
 1454 
 1455                                 case '|':       /* DECUDK */
 1456                                         svsp->transparent = 1;
 1457                                         init_udk(svsp);
 1458                                         svsp->dcs_state = DCS_AND_UDK;
 1459                                         break;
 1460 
 1461                                 case '{':       /* DECDLD */
 1462                                         svsp->transparent = 1;
 1463                                         init_dld(svsp);
 1464                                         svsp->dcs_state = DCS_DLD_DSCS;
 1465                                         break;
 1466 
 1467                                 default:         /* failsafe */
 1468                                         svsp->transparent = 0;
 1469                                         svsp->state = STATE_INIT;
 1470                                         svsp->dcs_state = DCS_INIT;
 1471                                         break;
 1472                         }
 1473                         break;
 1474 
 1475                 case DCS_AND_UDK:        /* DCS ... | */
 1476                         switch(ch)
 1477                         {
 1478                                 case '':
 1479                                 case '1':
 1480                                 case '2':
 1481                                 case '3':
 1482                                 case '4':
 1483                                 case '5':
 1484                                 case '6':
 1485                                 case '7':
 1486                                 case '8':
 1487                                 case '9':       /* fkey number */
 1488                                         svsp->udk_fnckey *= 10;
 1489                                         svsp->udk_fnckey += (ch -'');
 1490                                         break;
 1491 
 1492                                 case '/':       /* Key */
 1493                                         svsp->dcs_state = DCS_UDK_DEF;
 1494                                         break;
 1495 
 1496                                 case 0x1b:       /* ESC */
 1497                                         svsp->dcs_state = DCS_UDK_ESC;
 1498                                         break;
 1499 
 1500                                 default:
 1501                                         svsp->transparent = 0;
 1502                                         svsp->state = STATE_INIT;
 1503                                         svsp->dcs_state = DCS_INIT;
 1504                                         break;
 1505                         }
 1506                         break;
 1507 
 1508                 case DCS_UDK_DEF:        /* DCS ... | fnckey / */
 1509                         switch(ch)
 1510                         {
 1511                                 case '':
 1512                                 case '1':
 1513                                 case '2':
 1514                                 case '3':
 1515                                 case '4':
 1516                                 case '5':
 1517                                 case '6':
 1518                                 case '7':
 1519                                 case '8':
 1520                                 case '9':
 1521                                         if(svsp->udk_deflow)    /* low nibble */
 1522                                         {
 1523                                                 svsp->udk_def[svsp->udk_defi] |= (ch -'');
 1524                                                 svsp->udk_deflow = 0;
 1525                                                 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
 1526                                                 svsp->udk_defi : svsp->udk_defi+1;
 1527                                         }
 1528                                         else                    /* high nibble */
 1529                                         {
 1530                                                 svsp->udk_def[svsp->udk_defi] = ((ch -'') << 4);
 1531                                                 svsp->udk_deflow = 1;
 1532                                         }
 1533                                         break;
 1534 
 1535                                 case 'a':
 1536                                 case 'b':
 1537                                 case 'c':
 1538                                 case 'd':
 1539                                 case 'e':
 1540                                 case 'f':
 1541                                         if(svsp->udk_deflow)    /* low nibble */
 1542                                         {
 1543                                                 svsp->udk_def[svsp->udk_defi] |= (ch - 'a' + 10);
 1544                                                 svsp->udk_deflow = 0;
 1545                                                 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
 1546                                                 svsp->udk_defi : svsp->udk_defi+1;
 1547                                         }
 1548                                         else                    /* high nibble */
 1549                                         {
 1550                                                 svsp->udk_def[svsp->udk_defi] = ((ch - 'a' + 10) << 4);
 1551                                                 svsp->udk_deflow = 1;
 1552                                         }
 1553                                         break;
 1554 
 1555 
 1556 
 1557                                 case 'A':
 1558                                 case 'B':
 1559                                 case 'C':
 1560                                 case 'D':
 1561                                 case 'E':
 1562                                 case 'F':
 1563                                         if(svsp->udk_deflow)    /* low nibble */
 1564                                         {
 1565                                                 svsp->udk_def[svsp->udk_defi] |= (ch - 'A' + 10);
 1566                                                 svsp->udk_deflow = 0;
 1567                                                 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
 1568                                                 svsp->udk_defi : svsp->udk_defi+1;
 1569                                         }
 1570                                         else                    /* high nibble */
 1571                                         {
 1572                                                 svsp->udk_def[svsp->udk_defi] = ((ch - 'A' + 10) << 4);
 1573                                                 svsp->udk_deflow = 1;
 1574                                         }
 1575                                         break;
 1576 
 1577                                 case ';':       /* next function key */
 1578                                         vt_udk(svsp);
 1579                                         svsp->dcs_state = DCS_AND_UDK;
 1580                                         break;
 1581 
 1582                                 case 0x1b:       /* ESC */
 1583                                         svsp->dcs_state = DCS_UDK_ESC;
 1584                                         break;
 1585 
 1586                                 default:
 1587                                         svsp->transparent = 0;
 1588                                         svsp->state = STATE_INIT;
 1589                                         svsp->dcs_state = DCS_INIT;
 1590                                         break;
 1591                         }
 1592                         break;
 1593 
 1594                 case DCS_UDK_ESC:        /* DCS ... | fkey/def ... ESC */
 1595                         switch(ch)
 1596                         {
 1597                                 case '\\':      /* ST */
 1598                                         vt_udk(svsp);
 1599                                         svsp->transparent = 0;
 1600                                         svsp->state = STATE_INIT;
 1601                                         svsp->dcs_state = DCS_INIT;
 1602                                         break;
 1603 
 1604                                 default:
 1605                                         svsp->transparent = 0;
 1606                                         svsp->state = STATE_INIT;
 1607                                         svsp->dcs_state = DCS_INIT;
 1608                                         break;
 1609                         }
 1610                         break;
 1611 
 1612 
 1613                 case DCS_DLD_DSCS:       /* got DCS ... { */
 1614                         if(ch >= ' ' && ch <= '/')      /* intermediates ... */
 1615                         {
 1616                                 svsp->dld_dscs[svsp->dld_dscsi] = ch;
 1617                                 svsp->dld_id[svsp->dld_dscsi] = ch;
 1618                                 if(svsp->dld_dscsi >= DSCS_LENGTH)
 1619                                 {
 1620                                         svsp->transparent = 0;
 1621                                         svsp->state = STATE_INIT;
 1622                                         svsp->dcs_state = DCS_INIT;
 1623                                         svsp->dld_id[0] = '\0';
 1624                                 }
 1625                                 else
 1626                                 {
 1627                                         svsp->dld_dscsi++;
 1628                                 }
 1629                         }
 1630                         else if(ch >= '' && ch <= '~') /* final .... */
 1631                         {
 1632                                 svsp->dld_dscs[svsp->dld_dscsi] = ch;
 1633                                 svsp->dld_id[svsp->dld_dscsi++] = ch;
 1634                                 svsp->dld_id[svsp->dld_dscsi] = '\0';
 1635                                 svsp->dcs_state = DCS_DLD_DEF;
 1636                         }
 1637                         else
 1638                         {
 1639                                 svsp->transparent = 0;
 1640                                 svsp->state = STATE_INIT;
 1641                                 svsp->dcs_state = DCS_INIT;
 1642                                 svsp->dld_id[0] = '\0';
 1643                         }
 1644                         break;
 1645 
 1646                 case DCS_DLD_DEF:        /* DCS ... { dscs */
 1647                         switch(ch)
 1648                         {
 1649                                 case 0x1b:       /* ESC */
 1650                                         svsp->dcs_state = DCS_DLD_ESC;
 1651                                         break;
 1652 
 1653                                 case '/':        /* sixel upper / lower divider */
 1654                                         svsp->dld_sixel_lower = 1;
 1655                                         break;
 1656 
 1657                                 case ';':        /* character divider */
 1658                                         vt_dld(svsp);
 1659                                         svsp->parms[1]++;       /* next char */
 1660                                         break;
 1661 
 1662                                 default:
 1663                                         if (svsp->dld_sixel_lower)
 1664                                         {
 1665                                                 if(ch >= '?' && ch <= '~')
 1666                                                         svsp->sixel.lower[svsp->dld_sixelli] = ch - '?';
 1667                                                 svsp->dld_sixelli =
 1668                                                  (svsp->dld_sixelli+1 < MAXSIXEL) ?
 1669                                                  svsp->dld_sixelli+1 : svsp->dld_sixelli;
 1670                                         }
 1671                                         else
 1672                                         {
 1673                                                 if(ch >= '?' && ch <= '~')
 1674                                                         svsp->sixel.upper[svsp->dld_sixelui] = ch - '?';
 1675                                                 svsp->dld_sixelui =
 1676                                                  (svsp->dld_sixelui+1 < MAXSIXEL) ?
 1677                                                  svsp->dld_sixelui+1 : svsp->dld_sixelui;
 1678                                         }
 1679                                         break;
 1680                         }
 1681                         break;
 1682 
 1683                 case DCS_DLD_ESC:        /* DCS ... { dscs ... / ... ESC */
 1684                         switch(ch)
 1685                         {
 1686                                 case '\\':      /* String Terminator ST */
 1687                                         vt_dld(svsp);
 1688                                         svsp->transparent = 0;
 1689                                         svsp->state = STATE_INIT;
 1690                                         svsp->dcs_state = DCS_INIT;
 1691                                         break;
 1692 
 1693                                 default:
 1694                                         svsp->transparent = 0;
 1695                                         svsp->state = STATE_INIT;
 1696                                         svsp->dcs_state = DCS_INIT;
 1697                                         svsp->dld_id[0] = '\0';
 1698                                         break;
 1699                         }
 1700                         break;
 1701 
 1702                 default:
 1703                         svsp->transparent = 0;
 1704                         svsp->state = STATE_INIT;
 1705                         svsp->dcs_state = DCS_INIT;
 1706                         break;
 1707         }
 1708 }
 1709 
 1710 /*---------------------------------------------------------------------------*
 1711  *      User Defineable Keys
 1712  *---------------------------------------------------------------------------*/
 1713 void
 1714 vt_udk(struct video_state *svsp)
 1715 {
 1716         int key, start, max, i;
 1717         int usedff = 0;
 1718 
 1719         if(svsp->parms[0] != 1)         /* clear all ? */
 1720         {
 1721                 vt_clearudk(svsp);
 1722                 svsp->parms[0] = 1;
 1723         }
 1724 
 1725         if(svsp->udk_fnckey < 17 || svsp->udk_fnckey > 34)
 1726         {
 1727                 init_udk(svsp);
 1728                 return;
 1729         }
 1730 
 1731         key = svsp->udk_fnckey - 17;    /* index into table */
 1732 
 1733         if(svsp->ukt.length[key] == 0)                  /* never used ? */
 1734         {
 1735                 if(svsp->udkff < MAXUDKDEF-2)           /* space available ? */
 1736                 {
 1737                         start = svsp->udkff;            /* next sequential */
 1738                         max = MAXUDKDEF - svsp->udkff;  /* space available */
 1739                         svsp->ukt.first[key] = start;   /* start entry */
 1740                         usedff = 1;                     /* flag to update later */
 1741                 }
 1742                 else                                    /* no space */
 1743                 {
 1744                         init_udk(svsp);
 1745                         return;
 1746                 }
 1747         }
 1748         else                                            /* in use, redefine */
 1749         {
 1750                 start = svsp->ukt.first[key];           /* start entry */
 1751                 max = svsp->ukt.length[key];            /* space available */
 1752         }
 1753 
 1754         if(max < 2)                             /* hmmm .. */
 1755         {
 1756                 init_udk(svsp);
 1757                 return;
 1758         }
 1759 
 1760         max--;          /* adjust for tailing '\0' */
 1761 
 1762         for(i = 0; i < max && i < svsp->udk_defi; i++)
 1763                 svsp->udkbuf[start++] = svsp->udk_def[i];
 1764 
 1765         svsp->udkbuf[start] = '\0';     /* make it a string, see pcvt_kbd.c */
 1766         svsp->ukt.length[key] = i+1;    /* count for tailing '\0' */
 1767         if(usedff)
 1768                 svsp->udkff += (i+2);   /* new start location */
 1769 
 1770         init_udk(svsp);
 1771 }
 1772 
 1773 /*---------------------------------------------------------------------------*
 1774  *      clear all User Defineable Keys
 1775  *---------------------------------------------------------------------------*/
 1776 void
 1777 vt_clearudk(struct video_state *svsp)
 1778 {
 1779         register int i;
 1780 
 1781         for(i = 0; i < MAXUDKEYS; i++)
 1782         {
 1783                 svsp->ukt.first[i] = 0;
 1784                 svsp->ukt.length[i] = 0;
 1785         }
 1786         svsp->udkff = 0;
 1787 }
 1788 
 1789 /*---------------------------------------------------------------------------*
 1790  *      Down line LoaDable Fonts
 1791  *---------------------------------------------------------------------------*/
 1792 void
 1793 vt_dld(struct video_state *svsp)
 1794 {
 1795         unsigned char vgacharset;
 1796         unsigned char vgachar[16];
 1797         unsigned char vgacharb[16];
 1798 
 1799         if(vgacs[svsp->vga_charset].secondloaded)
 1800                 vgacharset = vgacs[svsp->vga_charset].secondloaded;
 1801         else
 1802                 return;
 1803 
 1804         svsp->parms[1] = (svsp->parms[1] < 1) ? 1 :
 1805                 ((svsp->parms[1] > 0x7E) ? 0x7E : svsp->parms[1]);
 1806 
 1807         if(svsp->parms[2] != 1)   /* Erase all characters ? */
 1808         {
 1809                 clear_dld(svsp);
 1810                 svsp->parms[2] = 1;   /* Only erase all characters once per sequence */
 1811         }
 1812 
 1813         sixel_vga(&(svsp->sixel),vgachar);
 1814 
 1815         switch(vgacs[vgacharset].char_scanlines & 0x1F)
 1816         {
 1817                 case 7:
 1818                         vga10_vga8(vgachar,vgacharb);
 1819                         break;
 1820 
 1821                 case 9:
 1822                 default:
 1823                         vga10_vga10(vgachar,vgacharb);
 1824                         break;
 1825 
 1826                 case 13:
 1827                         vga10_vga14(vgachar,vgacharb);
 1828                         break;
 1829 
 1830                 case 15:
 1831                         vga10_vga16(vgachar,vgacharb);
 1832                         break;
 1833         }
 1834 
 1835         loadchar(vgacharset, svsp->parms[1] + 0xA0, 16, vgacharb);
 1836 
 1837         init_dld(svsp);
 1838 }
 1839 
 1840 /*---------------------------------------------------------------------------*
 1841  *      select character attributes
 1842  *---------------------------------------------------------------------------*/
 1843 void
 1844 vt_sca(struct video_state *svsp)
 1845 {
 1846         switch(svsp->parms[0])
 1847         {
 1848                 case 1:
 1849                         svsp->selchar = 1;
 1850                         break;
 1851                 case 0:
 1852                 case 2:
 1853                 default:
 1854                         svsp->selchar = 0;
 1855                         break;
 1856         }
 1857 }
 1858 
 1859 /*---------------------------------------------------------------------------*
 1860  *      initalize selective attribute bit array
 1861  *---------------------------------------------------------------------------*/
 1862 void
 1863 vt_initsel(struct video_state *svsp)
 1864 {
 1865         register int i;
 1866 
 1867         for(i = 0;i < MAXDECSCA;i++)
 1868                 svsp->decsca[i] = 0;
 1869 }
 1870 
 1871 /*---------------------------------------------------------------------------*
 1872  *      DECSEL - selective erase in line
 1873  *---------------------------------------------------------------------------*/
 1874 void
 1875 vt_sel(struct video_state *svsp)
 1876 {
 1877         switch(svsp->parms[0])
 1878         {
 1879                 case 0:
 1880                         selective_erase(svsp, (svsp->Crtat + svsp->cur_offset),
 1881                                          svsp->maxcol-svsp->col);
 1882                         break;
 1883 
 1884                 case 1:
 1885                         selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)-
 1886                                         svsp->col, svsp->col + 1);
 1887                         break;
 1888 
 1889                 case 2:
 1890                         selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)-
 1891                                         svsp->col, svsp->maxcol);
 1892                         break;
 1893         }
 1894 }
 1895 
 1896 /*---------------------------------------------------------------------------*
 1897  *      DECSED - selective erase in display
 1898  *---------------------------------------------------------------------------*/
 1899 void
 1900 vt_sed(struct video_state *svsp)
 1901 {
 1902         switch(svsp->parms[0])
 1903         {
 1904                 case 0:
 1905                         selective_erase(svsp, (svsp->Crtat + svsp->cur_offset),
 1906                               svsp->Crtat + (svsp->maxcol * svsp->screen_rows) -
 1907                               (svsp->Crtat + svsp->cur_offset));
 1908                         break;
 1909 
 1910                 case 1:
 1911                         selective_erase(svsp, svsp->Crtat,
 1912                            (svsp->Crtat + svsp->cur_offset) - svsp->Crtat + 1 );
 1913                         break;
 1914 
 1915                 case 2:
 1916                         selective_erase(svsp, svsp->Crtat,
 1917                                 svsp->maxcol * svsp->screen_rows);
 1918                         break;
 1919         }
 1920 }
 1921 
 1922 /*---------------------------------------------------------------------------*
 1923  *      scroll screen n lines up
 1924  *---------------------------------------------------------------------------*/
 1925 void
 1926 roll_up(struct video_state *svsp, int n)
 1927 {
 1928         if(svsp->scrr_beg == 0 &&       /* if scroll region is whole screen */
 1929            svsp->scrr_len == svsp->screen_rows &&
 1930            (svsp != vsp ||              /* and either running in memory */
 1931             (svsp->screen_rows == svsp->screen_rowsize && /* or no fkeys */
 1932              adaptor_type != MDA_ADAPTOR)))     /* and not on MDA/Hercules */
 1933         {
 1934                 u_short *Memory =
 1935 #ifdef XSERVER
 1936                     (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ?
 1937 #else
 1938                     (vsp != svsp) ?
 1939 #endif
 1940                                 svsp->Memory : Crtat;
 1941 
 1942                 if(svsp->Crtat > (Memory + (svsp->screen_rows - n) *
 1943                                         svsp->maxcol))
 1944                 {
 1945                         bcopy(svsp->Crtat + svsp->maxcol * n, Memory,
 1946                               svsp->maxcol * (svsp->screen_rows - n) * CHR);
 1947 
 1948                         svsp->Crtat = Memory;
 1949                 }
 1950                 else
 1951                 {
 1952                         svsp->Crtat += n * svsp->maxcol;
 1953                 }
 1954 #ifdef XSERVER
 1955                 if(vsp == svsp && !(vsp->vt_status & VT_GRAFX))
 1956 #else
 1957                 if(vsp == svsp)
 1958 #endif
 1959                 {
 1960                         outb(addr_6845, CRTC_STARTADRH);
 1961                         outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8);
 1962                         outb(addr_6845, CRTC_STARTADRL);
 1963                         outb(addr_6845+1, (svsp->Crtat - Crtat));
 1964                 }
 1965         }
 1966         else
 1967         {
 1968                 bcopy(  svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol),
 1969                         svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
 1970                         svsp->maxcol * (svsp->scrr_len - n) * CHR );
 1971         }
 1972         fillw(  user_attr | ' ',
 1973                 svsp->Crtat + ((svsp->scrr_end - n + 1) * svsp->maxcol),
 1974                 n * svsp->maxcol);
 1975 
 1976 /*XXX*/ if(svsp->scroll_lock && svsp->openf && curproc)
 1977                 tsleep((caddr_t)&(svsp->scroll_lock), PPAUSE, "scrlck", 0);
 1978 }
 1979 
 1980 /*---------------------------------------------------------------------------*
 1981  *      scroll screen n lines down
 1982  *---------------------------------------------------------------------------*/
 1983 static void
 1984 roll_down(struct video_state *svsp, int n)
 1985 {
 1986         if(svsp->scrr_beg == 0 &&       /* if scroll region is whole screen */
 1987            svsp->scrr_len == svsp->screen_rows &&
 1988            (svsp != vsp ||              /* and either running in memory */
 1989             (svsp->screen_rows == svsp->screen_rowsize && /* or no fkeys */
 1990              adaptor_type != MDA_ADAPTOR)))     /* and not on MDA/Hercules */
 1991         {
 1992                 u_short *Memory =
 1993 #ifdef XSERVER
 1994                     (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ?
 1995 #else
 1996                     (vsp != svsp) ?
 1997 #endif
 1998                                 svsp->Memory : Crtat;
 1999 
 2000                 if (svsp->Crtat < (Memory + n * svsp->maxcol))
 2001                 {
 2002                         bcopy(svsp->Crtat,
 2003                               Memory + svsp->maxcol * (svsp->screen_rows + n),
 2004                               svsp->maxcol * (svsp->screen_rows - n) * CHR);
 2005 
 2006                         svsp->Crtat = Memory + svsp->maxcol * svsp->screen_rows;
 2007                 }
 2008                 else
 2009                 {
 2010                         svsp->Crtat -= n * svsp->maxcol;
 2011                 }
 2012 #ifdef XSERVER
 2013                 if(vsp == svsp && !(vsp->vt_status & VT_GRAFX))
 2014 #else
 2015                 if(vsp == svsp)
 2016 #endif
 2017                 {
 2018                         outb(addr_6845, CRTC_STARTADRH);
 2019                         outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8);
 2020                         outb(addr_6845, CRTC_STARTADRL);
 2021                         outb(addr_6845+1, (svsp->Crtat - Crtat));
 2022                 }
 2023         }
 2024         else
 2025         {
 2026                 bcopy(  svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
 2027                         svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol),
 2028                         svsp->maxcol * (svsp->scrr_len - n) * CHR );
 2029         }
 2030         fillw(  user_attr | ' ',
 2031                 svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
 2032                 n * svsp->maxcol);
 2033 
 2034 /*XXX*/ if(svsp->scroll_lock && svsp->openf && curproc)
 2035                 tsleep((caddr_t)&(svsp->scroll_lock), PPAUSE, "scrlck", 0);
 2036 }
 2037 
 2038 /*---------------------------------------------------------------------------*
 2039  *      switch charset pointers
 2040  *---------------------------------------------------------------------------*/
 2041 static void
 2042 swcsp(struct video_state *svsp, u_short *ctp)
 2043 {
 2044         if(ctp == NULL)
 2045                 return;
 2046 
 2047         switch(svsp->state)
 2048         {
 2049                 case STATE_BROPN:       /* designate G0 */
 2050                         svsp->G0 = ctp;
 2051                         break;
 2052 
 2053                 case STATE_BRCLO:       /* designate G1 */
 2054                 case STATE_MINUS:       /* designate G1 (96) */
 2055                         svsp->G1 = ctp;
 2056                         break;
 2057 
 2058                 case STATE_STAR:        /* designate G2 */
 2059                 case STATE_DOT:         /* designate G2 (96) */
 2060                         svsp->G2 = ctp;
 2061                         break;
 2062 
 2063                 case STATE_PLUS:        /* designate G3 */
 2064                 case STATE_SLASH:       /* designate G3 (96) */
 2065                         svsp->G3 = ctp;
 2066                         break;
 2067         }
 2068 }
 2069 
 2070 /*---------------------------------------------------------------------------*
 2071  *      process terminal responses
 2072  *---------------------------------------------------------------------------*/
 2073 static void
 2074 respond(struct video_state *svsp)
 2075 {
 2076         if(!(svsp->openf))              /* are we opened ? */
 2077                 return;
 2078 
 2079         while (*svsp->report_chars && svsp->report_count > 0)
 2080         {
 2081                 ttyld_rint(svsp->vs_tty, *svsp->report_chars++ & 0xff);
 2082                 svsp->report_count--;
 2083         }
 2084 }
 2085 
 2086 /*---------------------------------------------------------------------------*
 2087  *      Initialization for User Defineable Keys
 2088  *---------------------------------------------------------------------------*/
 2089 static void
 2090 init_udk(struct video_state *svsp)
 2091 {
 2092         svsp->udk_defi = 0;
 2093         svsp->udk_deflow = 0;
 2094         svsp->udk_fnckey = 0;
 2095 }
 2096 
 2097 /*---------------------------------------------------------------------------*
 2098  *      Clear loaded downloadable (DLD) character set
 2099  *---------------------------------------------------------------------------*/
 2100 static void
 2101 clear_dld(struct video_state *svsp)
 2102 {
 2103         register int i;
 2104         unsigned char vgacharset;
 2105         unsigned char vgachar[16];
 2106 
 2107         if(vgacs[svsp->vga_charset].secondloaded)
 2108                 vgacharset = vgacs[svsp->vga_charset].secondloaded;
 2109         else
 2110                 return;
 2111 
 2112         for(i=0;i < 16;i++)  /* A zeroed character, vt220 has inverted '?' */
 2113                 vgachar[i] = 0x00;
 2114 
 2115         for(i=1;i <= 94;i++) /* Load (erase) all characters */
 2116                 loadchar(vgacharset, i + 0xA0, 16, vgachar);
 2117 }
 2118 
 2119 /*---------------------------------------------------------------------------*
 2120  *      Initialization for Down line LoaDable Fonts
 2121  *---------------------------------------------------------------------------*/
 2122 static void
 2123 init_dld(struct video_state *svsp)
 2124 {
 2125         register int i;
 2126 
 2127         svsp->dld_dscsi = 0;
 2128         svsp->dld_sixel_lower = 0;
 2129         svsp->dld_sixelli = 0;
 2130         svsp->dld_sixelui = 0;
 2131 
 2132         for(i = 0;i < MAXSIXEL;i++)
 2133                 svsp->sixel.lower[i] = svsp->sixel.upper[i] = 0;
 2134 }
 2135 
 2136 /*---------------------------------------------------------------------------*
 2137  *      selective erase a region
 2138  *---------------------------------------------------------------------------*/
 2139 static void
 2140 selective_erase(struct video_state *svsp, u_short *pcrtat, int length)
 2141 {
 2142         register int i, j;
 2143 
 2144         for(j = pcrtat - svsp->Crtat, i = 0;i < length;i++,pcrtat++)
 2145         {
 2146                 if(!(svsp->decsca[INT_INDEX(j+i)] & (1 << BIT_INDEX(j+i))))
 2147                 {
 2148                         *pcrtat &= 0xFF00; /* Keep the video character attributes */
 2149                         *pcrtat += ' ';    /* Erase the character */
 2150                 }
 2151         }
 2152 }
 2153 
 2154 /* ------------------------- E O F ------------------------------------------*/

Cache object: 079d035a4733d380fa48c79108eb05ce


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.