2 * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
4 * Copyright (c) 1992, 1993 Brian Dunford-Shore.
8 * This code is derived from software contributed to Berkeley by
9 * William Jolitz and Don Ahn.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by Hellmuth Michaelis,
22 * Brian Dunford-Shore and Joerg Wunsch.
23 * 4. The name authors may not be used to endorse or promote products
24 * derived from this software without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 * @(#)pcvt_vtf.c, 3.20, Last Edit-Date: [Wed Apr 5 18:08:50 1995]
41 /*---------------------------------------------------------------------------*
43 * pcvt_vtf.c VT220 Terminal Emulator Functions
44 * -------------------------------------------------
45 * -hm ------------ Release 3.00 --------------
46 * -hm integrating NetBSD-current patches
47 * -hm integrating patch from Thomas Gellekum
48 * -hm fixed bug fkey labels not properly (re)set after ris
49 * -hm Michael Havemester fixed NOFASTSCROLL define bug
50 * -hm set caps/scroll/num_lock in vt_str() and made led_update()
51 * -hm applying patch from Joerg fixing Crtat bug
52 * -hm fixing NOFASTSCROLL operation for MDA/Hercules
53 * -jw/hm fixing bug in roll_up() and roll_down()
54 * -hm fastscroll/Crtat bugfix from Lon Willett
55 * -hm patch for non-XSERVER/UCONSOLE compiles from Rafal Boni
56 * -hm bugfix: PCVT_USL_COMPAT renamed to PCVT_USL_VT_COMPAT ...
58 *---------------------------------------------------------------------------*/
63 #define PCVT_INCLUDE_VT_SELATTR /* get inline function from pcvt_hdr.h */
65 #include <i386/isa/pcvt/pcvt_hdr.h> /* global include */
66 #include <i386/isa/pcvt/pcvt_tbl.h> /* character set conversion tables */
68 static void clear_dld ( struct video_state *svsp );
69 static void init_dld ( struct video_state *svsp );
70 static void init_udk ( struct video_state *svsp );
71 static void respond ( struct video_state *svsp );
72 static void roll_down ( struct video_state *svsp, int n );
73 static void selective_erase ( struct video_state *svsp, u_short *pcrtat,
75 static void swcsp ( struct video_state *svsp, u_short *ctp );
77 /*---------------------------------------------------------------------------*
78 * DECSTBM - set top and bottom margins
79 *---------------------------------------------------------------------------*/
81 vt_stbm(struct video_state *svsp)
83 /* both 0 => scrolling region = entire screen */
85 if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
89 svsp->scrr_len = svsp->screen_rows;
90 svsp->scrr_end = svsp->scrr_len - 1;
95 if(svsp->parms[1] <= svsp->parms[0])
100 if(svsp->parms[0] < 1)
102 else if(svsp->parms[0] > svsp->screen_rows-1)
103 svsp->parms[0] = svsp->screen_rows-1;
107 if(svsp->parms[1] < 2)
109 else if(svsp->parms[1] > svsp->screen_rows)
110 svsp->parms[1] = svsp->screen_rows;
112 svsp->scrr_beg = svsp->parms[0]-1; /* begin of scrolling region */
113 svsp->scrr_len = svsp->parms[1] - svsp->parms[0] + 1; /* no of lines */
114 svsp->scrr_end = svsp->parms[1]-1;
116 /* cursor to first pos */
118 svsp->cur_offset = svsp->scrr_beg * svsp->maxcol;
120 svsp->cur_offset = 0;
125 /*---------------------------------------------------------------------------*
126 * SGR - set graphic rendition
127 *---------------------------------------------------------------------------*/
129 vt_sgr(struct video_state *svsp)
132 u_short setcolor = 0;
133 char colortouched = 0;
137 switch(svsp->parms[i++])
139 case 0: /* reset to normal attributes */
140 svsp->vtsgr = VT_NORMAL;
144 svsp->vtsgr |= VT_BOLD;
147 case 4: /* underline */
148 svsp->vtsgr |= VT_UNDER;
151 case 5: /* blinking */
152 svsp->vtsgr |= VT_BLINK;
155 case 7: /* reverse */
156 svsp->vtsgr |= VT_INVERSE;
159 case 22: /* not bold */
160 svsp->vtsgr &= ~VT_BOLD;
163 case 24: /* not underlined */
164 svsp->vtsgr &= ~VT_UNDER;
167 case 25: /* not blinking */
168 svsp->vtsgr &= ~VT_BLINK;
171 case 27: /* not reverse */
172 svsp->vtsgr &= ~VT_INVERSE;
175 case 30: /* foreground colors */
186 setcolor |= ((fgansitopc[(svsp->parms[i-1]-30) & 7]) << 8);
190 case 40: /* background colors */
201 setcolor |= ((bgansitopc[(svsp->parms[i-1]-40) & 7]) << 8);
206 while(i <= svsp->parmi);
210 svsp->c_attr = setcolor;
212 svsp->c_attr = ((sgr_tab_color[svsp->vtsgr]) << 8);
216 if(adaptor_type == MDA_ADAPTOR)
217 svsp->c_attr = ((sgr_tab_imono[svsp->vtsgr]) << 8);
219 svsp->c_attr = ((sgr_tab_mono[svsp->vtsgr]) << 8);
223 /*---------------------------------------------------------------------------*
225 *---------------------------------------------------------------------------*/
227 vt_cuu(struct video_state *svsp)
229 register int p = svsp->parms[0];
231 if (p <= 0) /* parameter min */
234 p = min(p, svsp->row - svsp->scrr_beg);
239 svsp->cur_offset -= (svsp->maxcol * p);
242 /*---------------------------------------------------------------------------*
244 *---------------------------------------------------------------------------*/
246 vt_cud(struct video_state *svsp)
248 register int p = svsp->parms[0];
253 p = min(p, svsp->scrr_end - svsp->row);
258 svsp->cur_offset += (svsp->maxcol * p);
261 /*---------------------------------------------------------------------------*
262 * CUF - cursor forward
263 *---------------------------------------------------------------------------*/
265 vt_cuf(struct video_state *svsp)
267 register int p = svsp->parms[0];
269 if(svsp->col == ((svsp->maxcol)-1)) /* already at right margin */
272 if(p <= 0) /* parameter min = 1 */
274 else if(p > ((svsp->maxcol)-1)) /* parameter max = 79 */
275 p = ((svsp->maxcol)-1);
277 if((svsp->col + p) > ((svsp->maxcol)-1))/* not more than right margin */
278 p = ((svsp->maxcol)-1) - svsp->col;
280 svsp->cur_offset += p;
284 /*---------------------------------------------------------------------------*
285 * CUB - cursor backward
286 *---------------------------------------------------------------------------*/
288 vt_cub(struct video_state *svsp)
290 register int p = svsp->parms[0];
292 if(svsp->col == 0) /* already at left margin ? */
295 if(p <= 0) /* parameter min = 1 */
297 else if(p > ((svsp->maxcol)-1)) /* parameter max = 79 */
298 p = ((svsp->maxcol)-1);
300 if((svsp->col - p) <= 0) /* not more than left margin */
303 svsp->cur_offset -= p;
307 /*---------------------------------------------------------------------------*
308 * ED - erase in display
309 *---------------------------------------------------------------------------*/
311 vt_clreos(struct video_state *svsp)
313 switch(svsp->parms[0])
316 fillw(user_attr | ' ', svsp->Crtat + svsp->cur_offset,
318 (svsp->maxcol * svsp->screen_rows) -
319 (svsp->Crtat + svsp->cur_offset));
323 fillw(user_attr | ' ', svsp->Crtat,
324 svsp->Crtat + svsp->cur_offset -
329 fillw(user_attr | ' ', svsp->Crtat,
330 svsp->maxcol * svsp->screen_rows);
335 /*---------------------------------------------------------------------------*
337 *---------------------------------------------------------------------------*/
339 vt_clreol(struct video_state *svsp)
341 switch(svsp->parms[0])
344 fillw(user_attr | ' ',
345 svsp->Crtat + svsp->cur_offset,
346 svsp->maxcol-svsp->col);
350 fillw(user_attr | ' ',
351 svsp->Crtat + svsp->cur_offset - svsp->col,
356 fillw(user_attr | ' ',
357 svsp->Crtat + svsp->cur_offset - svsp->col,
363 /*---------------------------------------------------------------------------*
364 * CUP - cursor position / HVP - horizontal & vertical position
365 *---------------------------------------------------------------------------*/
367 vt_curadr(struct video_state *svsp)
369 if(svsp->m_om) /* relative to scrolling region */
371 if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
373 svsp->cur_offset = svsp->scrr_beg * svsp->maxcol;
379 if(svsp->parms[0] <= 0)
381 else if(svsp->parms[0] > svsp->scrr_len)
382 svsp->parms[0] = svsp->scrr_len;
384 if(svsp->parms[1] <= 0 )
386 if(svsp->parms[1] > svsp->maxcol)
387 svsp->parms[1] = svsp->maxcol;
389 svsp->cur_offset = (svsp->scrr_beg * svsp->maxcol) +
390 ((svsp->parms[0] - 1) * svsp->maxcol) +
392 svsp->col = svsp->parms[1] - 1;
395 else /* relative to screen start */
397 if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
399 svsp->cur_offset = 0;
405 if(svsp->parms[0] <= 0)
407 else if(svsp->parms[0] > svsp->screen_rows)
408 svsp->parms[0] = svsp->screen_rows;
410 if(svsp->parms[1] <= 0 )
412 if(svsp->parms[1] > svsp->maxcol) /* col */
413 svsp->parms[1] = svsp->maxcol;
415 svsp->cur_offset = (((svsp->parms[0]-1)*svsp->maxcol) +
417 svsp->col = svsp->parms[1]-1;
419 if (svsp->cur_offset >=
420 ((svsp->scrr_beg + svsp->scrr_len + 1) * svsp->maxcol))
428 /*---------------------------------------------------------------------------*
429 * RIS - reset to initial state (hard emulator runtime reset)
430 *---------------------------------------------------------------------------*/
432 vt_ris(struct video_state *svsp)
434 fillw(user_attr | ' ', svsp->Crtat, svsp->maxcol * svsp->screen_rows);
435 svsp->cur_offset = 0; /* cursor upper left corner */
438 svsp->lnm = 0; /* CR only */
439 clear_dld(svsp); /* clear download charset */
440 vt_clearudk(svsp); /* clear user defined keys */
441 svsp->selchar = 0; /* selective attribute off */
442 vt_str(svsp); /* and soft terminal reset */
445 /*---------------------------------------------------------------------------*
446 * DECSTR - soft terminal reset (SOFT emulator runtime reset)
447 *---------------------------------------------------------------------------*/
449 vt_str(struct video_state *svsp)
453 clr_parms(svsp); /* escape parameter init */
454 svsp->state = STATE_INIT; /* initial state */
456 svsp->dis_fnc = 0; /* display functions reset */
458 svsp->sc_flag = 0; /* save cursor position */
459 svsp->transparent = 0; /* enable control code processing */
461 for(i = 0; i < MAXTAB; i++) /* setup tabstops */
464 svsp->tab_stops[i] = 1;
466 svsp->tab_stops[i] = 0;
469 svsp->irm = 0; /* replace mode */
470 svsp->m_om = 0; /* origin mode */
471 svsp->m_awm = 1; /* auto wrap mode */
473 #if PCVT_INHIBIT_NUMLOCK
474 svsp->num_lock = 0; /* keypad application mode */
476 svsp->num_lock = 1; /* keypad numeric mode */
479 svsp->scroll_lock = 0; /* reset keyboard modes */
482 svsp->ckm = 1; /* cursor key mode = "normal" ... */
483 svsp->scrr_beg = 0; /* start of scrolling region */
484 svsp->scrr_len = svsp->screen_rows; /* no. of lines in scrolling region */
485 svsp->abs_write = 0; /* scrr is complete screen */
486 svsp->scrr_end = svsp->scrr_len - 1;
488 if(adaptor_type == EGA_ADAPTOR || adaptor_type == VGA_ADAPTOR)
490 svsp->G0 = cse_ascii; /* G0 = ascii */
491 svsp->G1 = cse_ascii; /* G1 = ascii */
492 svsp->G2 = cse_supplemental; /* G2 = supplemental */
493 svsp->G3 = cse_supplemental; /* G3 = supplemental */
494 svsp->GL = &svsp->G0; /* GL = G0 */
495 svsp->GR = &svsp->G2; /* GR = G2 */
499 svsp->G0 = csd_ascii; /* G0 = ascii */
500 svsp->G1 = csd_ascii; /* G1 = ascii */
501 svsp->G2 = csd_supplemental; /* G2 = supplemental */
502 svsp->G3 = csd_supplemental; /* G3 = supplemental */
503 svsp->GL = &svsp->G0; /* GL = G0 */
504 svsp->GR = &svsp->G2; /* GR = G2 */
507 svsp->vtsgr = VT_NORMAL; /* no attributes */
508 svsp->c_attr = user_attr; /* reset sgr to normal */
510 svsp->selchar = 0; /* selective attribute off */
513 init_ufkl(svsp); /* init user fkey labels */
514 init_sfkl(svsp); /* init system fkey labels */
516 update_led(); /* update keyboard LED's */
519 /*---------------------------------------------------------------------------*
520 * RI - reverse index, move cursor up
521 *---------------------------------------------------------------------------*/
523 vt_ri(struct video_state *svsp)
525 if(svsp->cur_offset >= ((svsp->scrr_beg * svsp->maxcol) + svsp->maxcol))
526 svsp->cur_offset -= svsp->maxcol;
531 /*---------------------------------------------------------------------------*
532 * IND - index, move cursor down
533 *---------------------------------------------------------------------------*/
535 vt_ind(struct video_state *svsp)
537 if(svsp->cur_offset < (svsp->scrr_end * svsp->maxcol))
538 svsp->cur_offset += svsp->maxcol;
543 /*---------------------------------------------------------------------------*
544 * NEL - next line, first pos of next line
545 *---------------------------------------------------------------------------*/
547 vt_nel(struct video_state *svsp)
549 if(svsp->cur_offset < (svsp->scrr_end * svsp->maxcol))
551 svsp->cur_offset += (svsp->maxcol-svsp->col);
557 svsp->cur_offset -= svsp->col;
562 /*---------------------------------------------------------------------------*
563 * set dec private modes, esc [ ? x h
564 *---------------------------------------------------------------------------*/
566 vt_set_dec_priv_qm(struct video_state *svsp)
568 switch(svsp->parms[0])
570 case 0: /* error, ignored */
571 case 1: /* CKM - cursor key mode */
575 case 2: /* ANM - ansi/vt52 mode */
578 case 3: /* COLM - column mode */
579 vt_col(svsp, SCR_COL132);
582 case 4: /* SCLM - scrolling mode */
583 case 5: /* SCNM - screen mode */
586 case 6: /* OM - origin mode */
590 case 7: /* AWM - auto wrap mode */
592 swritefkl(7,(u_char *)"AUTOWRAPENABLE *",svsp);
595 case 8: /* ARM - auto repeat mode */
599 case 9: /* INLM - interlace mode */
600 case 10: /* EDM - edit mode */
601 case 11: /* LTM - line transmit mode */
603 case 13: /* SCFDM - space compression / field delimiting */
604 case 14: /* TEM - transmit execution mode */
606 case 16: /* EKEM - edit key execution mode */
609 case 25: /* TCEM - text cursor enable mode */
611 sw_cursor(1); /* cursor on */
615 case 42: /* NRCM - 7bit NRC characters */
620 /*---------------------------------------------------------------------------*
621 * reset dec private modes, esc [ ? x l
622 *---------------------------------------------------------------------------*/
624 vt_reset_dec_priv_qm(struct video_state *svsp)
626 switch(svsp->parms[0])
628 case 0: /* error, ignored */
629 case 1: /* CKM - cursor key mode */
633 case 2: /* ANM - ansi/vt52 mode */
636 case 3: /* COLM - column mode */
637 vt_col(svsp, SCR_COL80);
640 case 4: /* SCLM - scrolling mode */
641 case 5: /* SCNM - screen mode */
644 case 6: /* OM - origin mode */
648 case 7: /* AWM - auto wrap mode */
650 swritefkl(7,(u_char *)"AUTOWRAPENABLE ",svsp);
653 case 8: /* ARM - auto repeat mode */
657 case 9: /* INLM - interlace mode */
658 case 10: /* EDM - edit mode */
659 case 11: /* LTM - line transmit mode */
661 case 13: /* SCFDM - space compression / field delimiting */
662 case 14: /* TEM - transmit execution mode */
664 case 16: /* EKEM - edit key execution mode */
667 case 25: /* TCEM - text cursor enable mode */
669 sw_cursor(0); /* cursor off */
673 case 42: /* NRCM - 7bit NRC characters */
678 /*---------------------------------------------------------------------------*
679 * set ansi modes, esc [ x
680 *---------------------------------------------------------------------------*/
682 vt_set_ansi(struct video_state *svsp)
684 switch(svsp->parms[0])
686 case 0: /* error, ignored */
687 case 1: /* GATM - guarded area transfer mode */
688 case 2: /* KAM - keyboard action mode */
689 case 3: /* CRM - Control Representation mode */
692 case 4: /* IRM - insert replacement mode */
693 svsp->irm = 1; /* Insert mode */
696 case 5: /* SRTM - status report transfer mode */
697 case 6: /* ERM - erasue mode */
698 case 7: /* VEM - vertical editing mode */
699 case 10: /* HEM - horizontal editing mode */
700 case 11: /* PUM - position unit mode */
701 case 12: /* SRM - send-receive mode */
702 case 13: /* FEAM - format effector action mode */
703 case 14: /* FETM - format effector transfer mode */
704 case 15: /* MATM - multiple area transfer mode */
705 case 16: /* TTM - transfer termination */
706 case 17: /* SATM - selected area transfer mode */
707 case 18: /* TSM - tabulation stop mode */
708 case 19: /* EBM - editing boundary mode */
711 case 20: /* LNM - line feed / newline mode */
717 /*---------------------------------------------------------------------------*
718 * reset ansi modes, esc [ x
719 *---------------------------------------------------------------------------*/
721 vt_reset_ansi(struct video_state *svsp)
723 switch(svsp->parms[0])
725 case 0: /* error, ignored */
726 case 1: /* GATM - guarded area transfer mode */
727 case 2: /* KAM - keyboard action mode */
728 case 3: /* CRM - Control Representation mode */
731 case 4: /* IRM - insert replacement mode */
732 svsp->irm = 0; /* Replace mode */
735 case 5: /* SRTM - status report transfer mode */
736 case 6: /* ERM - erasue mode */
737 case 7: /* VEM - vertical editing mode */
738 case 10: /* HEM - horizontal editing mode */
739 case 11: /* PUM - position unit mode */
740 case 12: /* SRM - send-receive mode */
741 case 13: /* FEAM - format effector action mode */
742 case 14: /* FETM - format effector transfer mode */
743 case 15: /* MATM - multiple area transfer mode */
744 case 16: /* TTM - transfer termination */
745 case 17: /* SATM - selected area transfer mode */
746 case 18: /* TSM - tabulation stop mode */
747 case 19: /* EBM - editing boundary mode */
750 case 20: /* LNM - line feed / newline mode */
756 /*---------------------------------------------------------------------------*
758 *---------------------------------------------------------------------------*/
760 vt_clrtab(struct video_state *svsp)
764 if(svsp->parms[0] == 0)
765 svsp->tab_stops[svsp->col] = 0;
766 else if(svsp->parms[0] == 3)
768 for(i=0; i<MAXTAB; i++)
769 svsp->tab_stops[i] = 0;
773 /*---------------------------------------------------------------------------*
774 * DECSC - save cursor & attributes
775 *---------------------------------------------------------------------------*/
777 vt_sc(struct video_state *svsp)
780 svsp->sc_row = svsp->row;
781 svsp->sc_col = svsp->col;
782 svsp->sc_cur_offset = svsp->cur_offset;
783 svsp->sc_attr = svsp->c_attr;
784 svsp->sc_awm = svsp->m_awm;
785 svsp->sc_om = svsp->m_om;
786 svsp->sc_G0 = svsp->G0;
787 svsp->sc_G1 = svsp->G1;
788 svsp->sc_G2 = svsp->G2;
789 svsp->sc_G3 = svsp->G3;
790 svsp->sc_GL = svsp->GL;
791 svsp->sc_GR = svsp->GR;
792 svsp->sc_sel = svsp->selchar;
793 svsp->sc_vtsgr = svsp->vtsgr;
796 /*---------------------------------------------------------------------------*
797 * DECRC - restore cursor & attributes
798 *---------------------------------------------------------------------------*/
800 vt_rc(struct video_state *svsp)
802 if(svsp->sc_flag == 1)
805 svsp->row = svsp->sc_row;
806 svsp->col = svsp->sc_col;
807 svsp->cur_offset = svsp->sc_cur_offset;
808 svsp->c_attr = svsp->sc_attr;
809 svsp->m_awm = svsp->sc_awm;
810 svsp->m_om = svsp->sc_om;
811 svsp->G0 = svsp->sc_G0;
812 svsp->G1 = svsp->sc_G1;
813 svsp->G2 = svsp->sc_G2;
814 svsp->G3 = svsp->sc_G3;
815 svsp->GL = svsp->sc_GL;
816 svsp->GR = svsp->sc_GR;
817 svsp->selchar = svsp->sc_sel;
818 svsp->vtsgr = svsp->sc_vtsgr;
822 /*---------------------------------------------------------------------------*
823 * designate a character set as G0, G1, G2 or G3 for 94/96 char sets
824 *---------------------------------------------------------------------------*/
826 vt_designate(struct video_state *svsp)
831 if(svsp->whichi == 1)
837 if(svsp->dld_id[0] == '\0')
840 if(!(((adaptor_type == EGA_ADAPTOR) ||
841 (adaptor_type == VGA_ADAPTOR)) &&
842 (vgacs[svsp->vga_charset].secondloaded)))
847 for(i = (svsp->whichi)-1; i >= 0; i--)
849 if(svsp->which[i] != svsp->dld_id[i])
852 #ifdef HAVECSE_DOWNLOADABLE
853 ctp = cse_downloadable;
859 if(((adaptor_type == EGA_ADAPTOR) || (adaptor_type == VGA_ADAPTOR)) &&
860 (vgacs[svsp->vga_charset].secondloaded))
862 if((ch == svsp->dld_id[0]) && (svsp->dld_id[1] == '\0'))
864 #ifdef HAVECSE_DOWNLOADABLE
865 ctp = cse_downloadable;
873 case 'A': /* British or ISO-Latin-1 */
876 case STATE_BROPN: /* designate G0 */
877 case STATE_BRCLO: /* designate G1 */
878 case STATE_STAR: /* designate G2 */
879 case STATE_PLUS: /* designate G3 */
880 #ifdef HAVECSE_BRITISH
885 case STATE_MINUS: /* designate G1 (96)*/
886 case STATE_DOT: /* designate G2 (96)*/
887 case STATE_SLASH: /* designate G3 (96)*/
888 #ifdef HAVECSE_ISOLATIN
895 case 'B': /* USASCII */
901 case 'C': /* Finnish */
902 case '5': /* Finnish */
903 #ifdef HAVECSE_FINNISH
908 case 'E': /* Norwegian/Danish */
909 case '6': /* Norwegian/Danish */
910 #ifdef HAVECSE_NORWEGIANDANISH
911 ctp = cse_norwegiandanish;
915 case 'H': /* Swedish */
916 case '7': /* Swedish */
917 #ifdef HAVECSE_SWEDISH
922 case 'K': /* German */
923 #ifdef HAVECSE_GERMAN
928 case 'Q': /* French Canadien */
929 #ifdef HAVECSE_FRENCHCANADA
930 ctp = cse_frenchcanada;
934 case 'R': /* French */
935 #ifdef HAVECSE_FRENCH
940 case 'Y': /* Italian */
941 #ifdef HAVECSE_ITALIAN
946 case 'Z': /* Spanish */
947 #ifdef HAVECSE_SPANISH
952 case '0': /* special graphics */
953 #ifdef HAVECSE_SPECIAL
958 case '1': /* alternate ROM */
959 #ifdef HAVECSE_ALTERNATEROM1
960 ctp = cse_alternaterom1;
964 case '2': /* alt ROM, spec graphics */
965 #ifdef HAVECSE_ALTERNATEROM2
966 ctp = cse_alternaterom2;
970 case '3': /* HP Roman 8, upper 128 chars*/
971 #ifdef HAVECSE_ROMAN8
976 case '4': /* Dutch */
982 case '<': /* DEC Supplemental */
983 #ifdef HAVECSE_SUPPLEMENTAL
984 ctp = cse_supplemental;
988 case '=': /* Swiss */
994 case '>': /* DEC Technical */
995 #ifdef HAVECSE_TECHNICAL
1008 case 'A': /* British or ISO-Latin-1 */
1011 case STATE_BROPN: /* designate G0 */
1012 case STATE_BRCLO: /* designate G1 */
1013 case STATE_STAR: /* designate G2 */
1014 case STATE_PLUS: /* designate G3 */
1015 #ifdef HAVECSD_BRITISH
1020 case STATE_MINUS: /* designate G1 (96)*/
1021 case STATE_DOT: /* designate G2 (96)*/
1022 case STATE_SLASH: /* designate G3 (96)*/
1023 #ifdef HAVECSD_ISOLATIN
1030 case 'B': /* USASCII */
1031 #ifdef HAVECSD_ASCII
1036 case 'C': /* Finnish */
1037 case '5': /* Finnish */
1038 #ifdef HAVECSD_FINNISH
1043 case 'E': /* Norwegian/Danish */
1044 case '6': /* Norwegian/Danish */
1045 #ifdef HAVECSD_NORWEGIANDANISH
1046 ctp = csd_norwegiandanish;
1050 case 'H': /* Swedish */
1051 case '7': /* Swedish */
1052 #ifdef HAVECSD_SWEDISH
1057 case 'K': /* German */
1058 #ifdef HAVECSD_GERMAN
1063 case 'Q': /* French Canadien */
1064 #ifdef HAVECSD_FRENCHCANADA
1065 ctp = csd_frenchcanada;
1069 case 'R': /* French */
1070 #ifdef HAVECSD_FRENCH
1075 case 'Y': /* Italian */
1076 #ifdef HAVECSD_ITALIAN
1081 case 'Z': /* Spanish */
1082 #ifdef HAVECSD_SPANISH
1087 case '0': /* special graphics */
1088 #ifdef HAVECSD_SPECIAL
1093 case '1': /* alternate ROM */
1094 #ifdef HAVECSD_ALTERNATEROM1
1095 ctp = csd_alternaterom1;
1099 case '2': /* alt ROM, spec graphics */
1100 #ifdef HAVECSD_ALTERNATEROM2
1101 ctp = csd_alternaterom2;
1105 case '3': /* HP Roman 8, upper 128 chars*/
1106 #ifdef HAVECSD_ROMAN8
1111 case '4': /* Dutch */
1112 #ifdef HAVECSD_DUTCH
1117 case '<': /* DEC Supplemental */
1118 #ifdef HAVECSD_SUPPLEMENTAL
1119 ctp = csd_supplemental;
1123 case '=': /* Swiss */
1124 #ifdef HAVECSD_SWISS
1129 case '>': /* DEC Technical */
1130 #ifdef HAVECSD_TECHNICAL
1131 ctp = csd_technical;
1142 /*---------------------------------------------------------------------------*
1144 *---------------------------------------------------------------------------*/
1146 vt_da(struct video_state *svsp)
1148 static u_char *response = (u_char *)DA_VT220;
1150 svsp->report_chars = response;
1151 svsp->report_count = 18;
1155 /*---------------------------------------------------------------------------*
1156 * screen alignment display
1157 *---------------------------------------------------------------------------*/
1159 vt_aln(struct video_state *svsp)
1163 svsp->cur_offset = 0;
1166 for(i=0; i < (svsp->screen_rows*svsp->maxcol); i++)
1168 *(svsp->Crtat + svsp->cur_offset) = user_attr | 'E';
1174 svsp->cur_offset = 0; /* reset everything ! */
1179 /*---------------------------------------------------------------------------*
1180 * request terminal parameters
1181 *---------------------------------------------------------------------------*/
1183 vt_reqtparm(struct video_state *svsp)
1185 static u_char *answr = (u_char *)"\033[3;1;1;120;120;1;0x";
1187 svsp->report_chars = answr;
1188 svsp->report_count = 20;
1192 /*---------------------------------------------------------------------------*
1194 *---------------------------------------------------------------------------*/
1196 vt_tst(struct video_state *svsp)
1201 /*---------------------------------------------------------------------------*
1202 * device status reports
1203 *---------------------------------------------------------------------------*/
1205 vt_dsr(struct video_state *svsp)
1207 static u_char *answr = (u_char *)"\033[0n";
1208 static u_char *panswr = (u_char *)"\033[?13n"; /* Printer Unattached */
1209 static u_char *udkanswr = (u_char *)"\033[?21n"; /* UDK Locked */
1210 static u_char *langanswr = (u_char *)"\033[?27;1n"; /* North American*/
1211 static u_char buffer[16];
1214 switch(svsp->parms[0])
1216 case 5: /* return status */
1217 svsp->report_chars = answr;
1218 svsp->report_count = 4;
1222 case 6: /* return cursor position */
1225 if((svsp->row+1) > 10)
1226 buffer[i++] = ((svsp->row+1) / 10) + '0';
1227 buffer[i++] = ((svsp->row+1) % 10) + '0';
1229 if((svsp->col+1) > 10)
1230 buffer[i++] = ((svsp->col+1) / 10) + '0';
1231 buffer[i++] = ((svsp->col+1) % 10) + '0';
1235 svsp->report_chars = buffer;
1236 svsp->report_count = i;
1240 case 15: /* return printer status */
1241 svsp->report_chars = panswr;
1242 svsp->report_count = 6;
1246 case 25: /* return udk status */
1247 svsp->report_chars = udkanswr;
1248 svsp->report_count = 6;
1252 case 26: /* return language status */
1253 svsp->report_chars = langanswr;
1254 svsp->report_count = 8;
1258 default: /* nothing else valid */
1263 /*---------------------------------------------------------------------------*
1265 *---------------------------------------------------------------------------*/
1267 vt_il(struct video_state *svsp)
1269 register int p = svsp->parms[0];
1271 if((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end))
1275 else if(p > svsp->scrr_end - svsp->row)
1276 p = svsp->scrr_end - svsp->row;
1278 svsp->cur_offset -= svsp->col;
1280 if(svsp->row == svsp->scrr_beg)
1284 bcopy(svsp->Crtat + svsp->cur_offset,
1285 svsp->Crtat + svsp->cur_offset + (p * svsp->maxcol),
1286 svsp->maxcol * (svsp->scrr_end-svsp->row+1-p) * CHR );
1288 fillw(user_attr | ' ',
1289 svsp->Crtat + svsp->cur_offset,
1295 /*---------------------------------------------------------------------------*
1296 * ICH - insert character
1297 *---------------------------------------------------------------------------*/
1299 vt_ic(struct video_state *svsp)
1301 register int p = svsp->parms[0];
1305 else if(p > svsp->maxcol-svsp->col)
1306 p = svsp->maxcol-svsp->col;
1310 bcopy((svsp->Crtat + svsp->cur_offset),
1311 (svsp->Crtat + svsp->cur_offset) + 1,
1312 (((svsp->maxcol)-1)-svsp->col) * CHR);
1314 *(svsp->Crtat + svsp->cur_offset) = user_attr | ' ';
1319 /*---------------------------------------------------------------------------*
1321 *---------------------------------------------------------------------------*/
1323 vt_dl(struct video_state *svsp)
1325 register int p = svsp->parms[0];
1327 if((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end))
1331 else if(p > svsp->scrr_end - svsp->row)
1332 p = svsp->scrr_end - svsp->row;
1334 svsp->cur_offset -= svsp->col;
1337 if(svsp->row == svsp->scrr_beg)
1341 bcopy(svsp->Crtat + svsp->cur_offset + (p * svsp->maxcol),
1342 svsp->Crtat + svsp->cur_offset,
1343 svsp->maxcol * (svsp->scrr_end-svsp->row+1-p) * CHR );
1345 fillw(user_attr | ' ',
1346 svsp->Crtat + ((svsp->scrr_end-p+1) * svsp->maxcol),
1352 /*---------------------------------------------------------------------------*
1353 * DCH - delete character
1354 *---------------------------------------------------------------------------*/
1356 vt_dch(struct video_state *svsp)
1358 register int p = svsp->parms[0];
1362 else if(p > svsp->maxcol-svsp->col)
1363 p = svsp->maxcol-svsp->col;
1367 bcopy((svsp->Crtat + svsp->cur_offset)+1,
1368 (svsp->Crtat + svsp->cur_offset),
1369 (((svsp->maxcol)-1) - svsp->col)* CHR );
1371 *((svsp->Crtat + svsp->cur_offset) +
1372 ((svsp->maxcol)-1)-svsp->col) = user_attr | ' ';
1376 /*---------------------------------------------------------------------------*
1378 *---------------------------------------------------------------------------*/
1380 vt_su(struct video_state *svsp)
1382 register int p = svsp->parms[0];
1386 else if(p > svsp->screen_rows-1)
1387 p = svsp->screen_rows-1;
1392 /*---------------------------------------------------------------------------*
1394 *---------------------------------------------------------------------------*/
1396 vt_sd(struct video_state *svsp)
1398 register int p = svsp->parms[0];
1402 else if(p > svsp->screen_rows-1)
1403 p = svsp->screen_rows-1;
1408 /*---------------------------------------------------------------------------*
1409 * ECH - erase character
1410 *---------------------------------------------------------------------------*/
1412 vt_ech(struct video_state *svsp)
1414 register int p = svsp->parms[0];
1418 else if(p > svsp->maxcol-svsp->col)
1419 p = svsp->maxcol-svsp->col;
1421 fillw(user_attr | ' ', (svsp->Crtat + svsp->cur_offset), p);
1424 /*---------------------------------------------------------------------------*
1425 * media copy (NO PRINTER AVAILABLE IN KERNEL ...)
1426 *---------------------------------------------------------------------------*/
1428 vt_mc(struct video_state *svsp)
1432 /*---------------------------------------------------------------------------*
1433 * Device Control String State Machine Entry for:
1435 * DECUDK - user-defined keys and
1436 * DECDLD - downloadable charset
1438 *---------------------------------------------------------------------------*/
1440 vt_dcsentry(U_char ch, struct video_state *svsp)
1442 switch(svsp->dcs_state)
1456 case '9': /* parameters */
1457 svsp->parms[svsp->parmi] *= 10;
1458 svsp->parms[svsp->parmi] += (ch -'0');
1461 case ';': /* next parameter */
1463 (svsp->parmi+1 < MAXPARMS) ?
1464 svsp->parmi+1 : svsp->parmi;
1467 case '|': /* DECUDK */
1468 svsp->transparent = 1;
1470 svsp->dcs_state = DCS_AND_UDK;
1473 case '{': /* DECDLD */
1474 svsp->transparent = 1;
1476 svsp->dcs_state = DCS_DLD_DSCS;
1479 default: /* failsafe */
1480 svsp->transparent = 0;
1481 svsp->state = STATE_INIT;
1482 svsp->dcs_state = DCS_INIT;
1487 case DCS_AND_UDK: /* DCS ... | */
1499 case '9': /* fkey number */
1500 svsp->udk_fnckey *= 10;
1501 svsp->udk_fnckey += (ch -'0');
1505 svsp->dcs_state = DCS_UDK_DEF;
1508 case 0x1b: /* ESC */
1509 svsp->dcs_state = DCS_UDK_ESC;
1513 svsp->transparent = 0;
1514 svsp->state = STATE_INIT;
1515 svsp->dcs_state = DCS_INIT;
1520 case DCS_UDK_DEF: /* DCS ... | fnckey / */
1533 if(svsp->udk_deflow) /* low nibble */
1535 svsp->udk_def[svsp->udk_defi] |= (ch -'0');
1536 svsp->udk_deflow = 0;
1537 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
1538 svsp->udk_defi : svsp->udk_defi+1;
1540 else /* high nibble */
1542 svsp->udk_def[svsp->udk_defi] = ((ch -'0') << 4);
1543 svsp->udk_deflow = 1;
1553 if(svsp->udk_deflow) /* low nibble */
1555 svsp->udk_def[svsp->udk_defi] |= (ch - 'a' + 10);
1556 svsp->udk_deflow = 0;
1557 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
1558 svsp->udk_defi : svsp->udk_defi+1;
1560 else /* high nibble */
1562 svsp->udk_def[svsp->udk_defi] = ((ch - 'a' + 10) << 4);
1563 svsp->udk_deflow = 1;
1575 if(svsp->udk_deflow) /* low nibble */
1577 svsp->udk_def[svsp->udk_defi] |= (ch - 'A' + 10);
1578 svsp->udk_deflow = 0;
1579 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
1580 svsp->udk_defi : svsp->udk_defi+1;
1582 else /* high nibble */
1584 svsp->udk_def[svsp->udk_defi] = ((ch - 'A' + 10) << 4);
1585 svsp->udk_deflow = 1;
1589 case ';': /* next function key */
1591 svsp->dcs_state = DCS_AND_UDK;
1594 case 0x1b: /* ESC */
1595 svsp->dcs_state = DCS_UDK_ESC;
1599 svsp->transparent = 0;
1600 svsp->state = STATE_INIT;
1601 svsp->dcs_state = DCS_INIT;
1606 case DCS_UDK_ESC: /* DCS ... | fkey/def ... ESC */
1611 svsp->transparent = 0;
1612 svsp->state = STATE_INIT;
1613 svsp->dcs_state = DCS_INIT;
1617 svsp->transparent = 0;
1618 svsp->state = STATE_INIT;
1619 svsp->dcs_state = DCS_INIT;
1625 case DCS_DLD_DSCS: /* got DCS ... { */
1626 if(ch >= ' ' && ch <= '/') /* intermediates ... */
1628 svsp->dld_dscs[svsp->dld_dscsi] = ch;
1629 svsp->dld_id[svsp->dld_dscsi] = ch;
1630 if(svsp->dld_dscsi >= DSCS_LENGTH)
1632 svsp->transparent = 0;
1633 svsp->state = STATE_INIT;
1634 svsp->dcs_state = DCS_INIT;
1635 svsp->dld_id[0] = '\0';
1642 else if(ch >= '0' && ch <= '~') /* final .... */
1644 svsp->dld_dscs[svsp->dld_dscsi] = ch;
1645 svsp->dld_id[svsp->dld_dscsi++] = ch;
1646 svsp->dld_id[svsp->dld_dscsi] = '\0';
1647 svsp->dcs_state = DCS_DLD_DEF;
1651 svsp->transparent = 0;
1652 svsp->state = STATE_INIT;
1653 svsp->dcs_state = DCS_INIT;
1654 svsp->dld_id[0] = '\0';
1658 case DCS_DLD_DEF: /* DCS ... { dscs */
1661 case 0x1b: /* ESC */
1662 svsp->dcs_state = DCS_DLD_ESC;
1665 case '/': /* sixel upper / lower divider */
1666 svsp->dld_sixel_lower = 1;
1669 case ';': /* character divider */
1671 svsp->parms[1]++; /* next char */
1675 if (svsp->dld_sixel_lower)
1677 if(ch >= '?' && ch <= '~')
1678 svsp->sixel.lower[svsp->dld_sixelli] = ch - '?';
1680 (svsp->dld_sixelli+1 < MAXSIXEL) ?
1681 svsp->dld_sixelli+1 : svsp->dld_sixelli;
1685 if(ch >= '?' && ch <= '~')
1686 svsp->sixel.upper[svsp->dld_sixelui] = ch - '?';
1688 (svsp->dld_sixelui+1 < MAXSIXEL) ?
1689 svsp->dld_sixelui+1 : svsp->dld_sixelui;
1695 case DCS_DLD_ESC: /* DCS ... { dscs ... / ... ESC */
1698 case '\\': /* String Terminator ST */
1700 svsp->transparent = 0;
1701 svsp->state = STATE_INIT;
1702 svsp->dcs_state = DCS_INIT;
1706 svsp->transparent = 0;
1707 svsp->state = STATE_INIT;
1708 svsp->dcs_state = DCS_INIT;
1709 svsp->dld_id[0] = '\0';
1715 svsp->transparent = 0;
1716 svsp->state = STATE_INIT;
1717 svsp->dcs_state = DCS_INIT;
1722 /*---------------------------------------------------------------------------*
1723 * User Defineable Keys
1724 *---------------------------------------------------------------------------*/
1726 vt_udk(struct video_state *svsp)
1728 int key, start, max, i;
1731 if(svsp->parms[0] != 1) /* clear all ? */
1737 if(svsp->udk_fnckey < 17 || svsp->udk_fnckey > 34)
1743 key = svsp->udk_fnckey - 17; /* index into table */
1745 if(svsp->ukt.length[key] == 0) /* never used ? */
1747 if(svsp->udkff < MAXUDKDEF-2) /* space available ? */
1749 start = svsp->udkff; /* next sequential */
1750 max = MAXUDKDEF - svsp->udkff; /* space available */
1751 svsp->ukt.first[key] = start; /* start entry */
1752 usedff = 1; /* flag to update later */
1760 else /* in use, redefine */
1762 start = svsp->ukt.first[key]; /* start entry */
1763 max = svsp->ukt.length[key]; /* space available */
1766 if(max < 2) /* hmmm .. */
1772 max--; /* adjust for tailing '\0' */
1774 for(i = 0; i < max && i < svsp->udk_defi; i++)
1775 svsp->udkbuf[start++] = svsp->udk_def[i];
1777 svsp->udkbuf[start] = '\0'; /* make it a string, see pcvt_kbd.c */
1778 svsp->ukt.length[key] = i+1; /* count for tailing '\0' */
1780 svsp->udkff += (i+2); /* new start location */
1785 /*---------------------------------------------------------------------------*
1786 * clear all User Defineable Keys
1787 *---------------------------------------------------------------------------*/
1789 vt_clearudk(struct video_state *svsp)
1793 for(i = 0; i < MAXUDKEYS; i++)
1795 svsp->ukt.first[i] = 0;
1796 svsp->ukt.length[i] = 0;
1801 /*---------------------------------------------------------------------------*
1802 * Down line LoaDable Fonts
1803 *---------------------------------------------------------------------------*/
1805 vt_dld(struct video_state *svsp)
1807 unsigned char vgacharset;
1808 unsigned char vgachar[16];
1809 unsigned char vgacharb[16];
1811 if(vgacs[svsp->vga_charset].secondloaded)
1812 vgacharset = vgacs[svsp->vga_charset].secondloaded;
1816 svsp->parms[1] = (svsp->parms[1] < 1) ? 1 :
1817 ((svsp->parms[1] > 0x7E) ? 0x7E : svsp->parms[1]);
1819 if(svsp->parms[2] != 1) /* Erase all characters ? */
1822 svsp->parms[2] = 1; /* Only erase all characters once per sequence */
1825 sixel_vga(&(svsp->sixel),vgachar);
1827 switch(vgacs[vgacharset].char_scanlines & 0x1F)
1830 vga10_vga8(vgachar,vgacharb);
1835 vga10_vga10(vgachar,vgacharb);
1839 vga10_vga14(vgachar,vgacharb);
1843 vga10_vga16(vgachar,vgacharb);
1847 loadchar(vgacharset, svsp->parms[1] + 0xA0, 16, vgacharb);
1852 /*---------------------------------------------------------------------------*
1853 * select character attributes
1854 *---------------------------------------------------------------------------*/
1856 vt_sca(struct video_state *svsp)
1858 switch(svsp->parms[0])
1871 /*---------------------------------------------------------------------------*
1872 * initalize selective attribute bit array
1873 *---------------------------------------------------------------------------*/
1875 vt_initsel(struct video_state *svsp)
1879 for(i = 0;i < MAXDECSCA;i++)
1880 svsp->decsca[i] = 0;
1883 /*---------------------------------------------------------------------------*
1884 * DECSEL - selective erase in line
1885 *---------------------------------------------------------------------------*/
1887 vt_sel(struct video_state *svsp)
1889 switch(svsp->parms[0])
1892 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset),
1893 svsp->maxcol-svsp->col);
1897 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)-
1898 svsp->col, svsp->col + 1);
1902 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)-
1903 svsp->col, svsp->maxcol);
1908 /*---------------------------------------------------------------------------*
1909 * DECSED - selective erase in display
1910 *---------------------------------------------------------------------------*/
1912 vt_sed(struct video_state *svsp)
1914 switch(svsp->parms[0])
1917 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset),
1918 svsp->Crtat + (svsp->maxcol * svsp->screen_rows) -
1919 (svsp->Crtat + svsp->cur_offset));
1923 selective_erase(svsp, svsp->Crtat,
1924 (svsp->Crtat + svsp->cur_offset) - svsp->Crtat + 1 );
1928 selective_erase(svsp, svsp->Crtat,
1929 svsp->maxcol * svsp->screen_rows);
1934 /*---------------------------------------------------------------------------*
1935 * scroll screen n lines up
1936 *---------------------------------------------------------------------------*/
1938 roll_up(struct video_state *svsp, int n)
1941 #if (PCVT_NOFASTSCROLL==0)
1943 if(svsp->scrr_beg == 0 && /* if scroll region is whole screen */
1944 svsp->scrr_len == svsp->screen_rows &&
1945 (svsp != vsp || /* and either running in memory */
1946 (svsp->screen_rows == svsp->screen_rowsize && /* or no fkeys */
1947 adaptor_type != MDA_ADAPTOR))) /* and not on MDA/Hercules */
1951 #if PCVT_USL_VT_COMPAT
1952 (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ?
1957 svsp->Memory : Crtat;
1959 if(svsp->Crtat > (Memory + (svsp->screen_rows - n) *
1962 bcopy(svsp->Crtat + svsp->maxcol * n, Memory,
1963 svsp->maxcol * (svsp->screen_rows - n) * CHR);
1965 svsp->Crtat = Memory;
1969 svsp->Crtat += n * svsp->maxcol;
1972 #if PCVT_USL_VT_COMPAT
1973 if(vsp == svsp && !(vsp->vt_status & VT_GRAFX))
1979 outb(addr_6845, CRTC_STARTADRH);
1980 outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8);
1981 outb(addr_6845, CRTC_STARTADRL);
1982 outb(addr_6845+1, (svsp->Crtat - Crtat));
1988 bcopy( svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol),
1989 svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
1990 svsp->maxcol * (svsp->scrr_len - n) * CHR );
1993 fillw( user_attr | ' ',
1994 svsp->Crtat + ((svsp->scrr_end - n + 1) * svsp->maxcol),
1997 /*XXX*/ if(svsp->scroll_lock && svsp->openf && curproc)
1998 tsleep((caddr_t)&(svsp->scroll_lock), PPAUSE, "scrlck", 0);
2001 /*---------------------------------------------------------------------------*
2002 * scroll screen n lines down
2003 *---------------------------------------------------------------------------*/
2005 roll_down(struct video_state *svsp, int n)
2008 #if (PCVT_NOFASTSCROLL==0)
2010 if(svsp->scrr_beg == 0 && /* if scroll region is whole screen */
2011 svsp->scrr_len == svsp->screen_rows &&
2012 (svsp != vsp || /* and either running in memory */
2013 (svsp->screen_rows == svsp->screen_rowsize && /* or no fkeys */
2014 adaptor_type != MDA_ADAPTOR))) /* and not on MDA/Hercules */
2018 #if PCVT_USL_VT_COMPAT
2019 (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ?
2023 svsp->Memory : Crtat;
2025 if (svsp->Crtat < (Memory + n * svsp->maxcol))
2028 Memory + svsp->maxcol * (svsp->screen_rows + n),
2029 svsp->maxcol * (svsp->screen_rows - n) * CHR);
2031 svsp->Crtat = Memory + svsp->maxcol * svsp->screen_rows;
2035 svsp->Crtat -= n * svsp->maxcol;
2038 #if PCVT_USL_VT_COMPAT
2039 if(vsp == svsp && !(vsp->vt_status & VT_GRAFX))
2045 outb(addr_6845, CRTC_STARTADRH);
2046 outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8);
2047 outb(addr_6845, CRTC_STARTADRL);
2048 outb(addr_6845+1, (svsp->Crtat - Crtat));
2054 bcopy( svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
2055 svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol),
2056 svsp->maxcol * (svsp->scrr_len - n) * CHR );
2059 fillw( user_attr | ' ',
2060 svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
2063 /*XXX*/ if(svsp->scroll_lock && svsp->openf && curproc)
2064 tsleep((caddr_t)&(svsp->scroll_lock), PPAUSE, "scrlck", 0);
2067 /*---------------------------------------------------------------------------*
2068 * switch charset pointers
2069 *---------------------------------------------------------------------------*/
2071 swcsp(struct video_state *svsp, u_short *ctp)
2078 case STATE_BROPN: /* designate G0 */
2082 case STATE_BRCLO: /* designate G1 */
2083 case STATE_MINUS: /* designate G1 (96) */
2087 case STATE_STAR: /* designate G2 */
2088 case STATE_DOT: /* designate G2 (96) */
2092 case STATE_PLUS: /* designate G3 */
2093 case STATE_SLASH: /* designate G3 (96) */
2099 /*---------------------------------------------------------------------------*
2100 * process terminal responses
2101 *---------------------------------------------------------------------------*/
2103 respond(struct video_state *svsp)
2105 if(!(svsp->openf)) /* are we opened ? */
2108 while (*svsp->report_chars && svsp->report_count > 0)
2110 (*linesw[svsp->vs_tty->t_line].l_rint)
2111 (*svsp->report_chars++ & 0xff, svsp->vs_tty);
2112 svsp->report_count--;
2116 /*---------------------------------------------------------------------------*
2117 * Initialization for User Defineable Keys
2118 *---------------------------------------------------------------------------*/
2120 init_udk(struct video_state *svsp)
2123 svsp->udk_deflow = 0;
2124 svsp->udk_fnckey = 0;
2127 /*---------------------------------------------------------------------------*
2128 * Clear loaded downloadable (DLD) character set
2129 *---------------------------------------------------------------------------*/
2131 clear_dld(struct video_state *svsp)
2134 unsigned char vgacharset;
2135 unsigned char vgachar[16];
2137 if(vgacs[svsp->vga_charset].secondloaded)
2138 vgacharset = vgacs[svsp->vga_charset].secondloaded;
2142 for(i=0;i < 16;i++) /* A zeroed character, vt220 has inverted '?' */
2145 for(i=1;i <= 94;i++) /* Load (erase) all characters */
2146 loadchar(vgacharset, i + 0xA0, 16, vgachar);
2149 /*---------------------------------------------------------------------------*
2150 * Initialization for Down line LoaDable Fonts
2151 *---------------------------------------------------------------------------*/
2153 init_dld(struct video_state *svsp)
2157 svsp->dld_dscsi = 0;
2158 svsp->dld_sixel_lower = 0;
2159 svsp->dld_sixelli = 0;
2160 svsp->dld_sixelui = 0;
2162 for(i = 0;i < MAXSIXEL;i++)
2163 svsp->sixel.lower[i] = svsp->sixel.upper[i] = 0;
2166 /*---------------------------------------------------------------------------*
2167 * selective erase a region
2168 *---------------------------------------------------------------------------*/
2170 selective_erase(struct video_state *svsp, u_short *pcrtat, int length)
2174 for(j = pcrtat - svsp->Crtat, i = 0;i < length;i++,pcrtat++)
2176 if(!(svsp->decsca[INT_INDEX(j+i)] & (1 << BIT_INDEX(j+i))))
2178 *pcrtat &= 0xFF00; /* Keep the video character attributes */
2179 *pcrtat += ' '; /* Erase the character */
2184 #endif /* NVT > 0 */
2186 /* ------------------------- E O F ------------------------------------------*/