2 * Copyright (c) 1999 Hellmuth Michaelis
4 * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
6 * Copyright (c) 1992, 1993 Brian Dunford-Shore.
10 * This code is derived from software contributed to Berkeley by
11 * William Jolitz and Don Ahn.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
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.
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.
40 /*---------------------------------------------------------------------------*
42 * pcvt_vtf.c VT220 Terminal Emulator Functions
43 * -------------------------------------------------
45 * Last Edit-Date: [Mon Dec 27 14:13:33 1999]
47 * $FreeBSD: src/sys/i386/isa/pcvt/pcvt_vtf.c,v 1.11 1999/12/30 16:17:11 hm Exp $
49 *---------------------------------------------------------------------------*/
54 #define PCVT_INCLUDE_VT_SELATTR /* get inline function from pcvt_hdr.h */
56 #include <i386/isa/pcvt/pcvt_hdr.h> /* global include */
57 #include <i386/isa/pcvt/pcvt_tbl.h> /* character set conversion tables */
59 static void clear_dld ( struct video_state *svsp );
60 static void init_dld ( struct video_state *svsp );
61 static void init_udk ( struct video_state *svsp );
62 static void respond ( struct video_state *svsp );
63 static void roll_down ( struct video_state *svsp, int n );
64 static void selective_erase ( struct video_state *svsp, u_short *pcrtat,
66 static void swcsp ( struct video_state *svsp, u_short *ctp );
68 /*---------------------------------------------------------------------------*
69 * DECSTBM - set top and bottom margins
70 *---------------------------------------------------------------------------*/
72 vt_stbm(struct video_state *svsp)
74 /* both 0 => scrolling region = entire screen */
76 if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
80 svsp->scrr_len = svsp->screen_rows;
81 svsp->scrr_end = svsp->scrr_len - 1;
86 if(svsp->parms[1] <= svsp->parms[0])
91 if(svsp->parms[0] < 1)
93 else if(svsp->parms[0] > svsp->screen_rows-1)
94 svsp->parms[0] = svsp->screen_rows-1;
98 if(svsp->parms[1] < 2)
100 else if(svsp->parms[1] > svsp->screen_rows)
101 svsp->parms[1] = svsp->screen_rows;
103 svsp->scrr_beg = svsp->parms[0]-1; /* begin of scrolling region */
104 svsp->scrr_len = svsp->parms[1] - svsp->parms[0] + 1; /* no of lines */
105 svsp->scrr_end = svsp->parms[1]-1;
107 /* cursor to first pos */
109 svsp->cur_offset = svsp->scrr_beg * svsp->maxcol;
111 svsp->cur_offset = 0;
116 /*---------------------------------------------------------------------------*
117 * SGR - set graphic rendition
118 *---------------------------------------------------------------------------*/
120 vt_sgr(struct video_state *svsp)
123 u_short setcolor = 0;
124 char colortouched = 0;
128 switch(svsp->parms[i++])
130 case 0: /* reset to normal attributes */
131 svsp->vtsgr = VT_NORMAL;
135 svsp->vtsgr |= VT_BOLD;
138 case 4: /* underline */
139 svsp->vtsgr |= VT_UNDER;
142 case 5: /* blinking */
143 svsp->vtsgr |= VT_BLINK;
146 case 7: /* reverse */
147 svsp->vtsgr |= VT_INVERSE;
150 case 22: /* not bold */
151 svsp->vtsgr &= ~VT_BOLD;
154 case 24: /* not underlined */
155 svsp->vtsgr &= ~VT_UNDER;
158 case 25: /* not blinking */
159 svsp->vtsgr &= ~VT_BLINK;
162 case 27: /* not reverse */
163 svsp->vtsgr &= ~VT_INVERSE;
166 case 30: /* foreground colors */
177 setcolor |= ((fgansitopc[(svsp->parms[i-1]-30) & 7]) << 8);
181 case 40: /* background colors */
192 setcolor |= ((bgansitopc[(svsp->parms[i-1]-40) & 7]) << 8);
197 while(i <= svsp->parmi);
201 svsp->c_attr = setcolor;
203 svsp->c_attr = ((sgr_tab_color[svsp->vtsgr]) << 8);
207 if(adaptor_type == MDA_ADAPTOR)
208 svsp->c_attr = ((sgr_tab_imono[svsp->vtsgr]) << 8);
210 svsp->c_attr = ((sgr_tab_mono[svsp->vtsgr]) << 8);
214 /*---------------------------------------------------------------------------*
216 *---------------------------------------------------------------------------*/
218 vt_cuu(struct video_state *svsp)
220 register int p = svsp->parms[0];
222 if (p <= 0) /* parameter min */
225 p = min(p, svsp->row - svsp->scrr_beg);
230 svsp->cur_offset -= (svsp->maxcol * p);
233 /*---------------------------------------------------------------------------*
235 *---------------------------------------------------------------------------*/
237 vt_cud(struct video_state *svsp)
239 register int p = svsp->parms[0];
244 p = min(p, svsp->scrr_end - svsp->row);
249 svsp->cur_offset += (svsp->maxcol * p);
252 /*---------------------------------------------------------------------------*
253 * CUF - cursor forward
254 *---------------------------------------------------------------------------*/
256 vt_cuf(struct video_state *svsp)
258 register int p = svsp->parms[0];
260 if(svsp->col == ((svsp->maxcol)-1)) /* already at right margin */
263 if(p <= 0) /* parameter min = 1 */
265 else if(p > ((svsp->maxcol)-1)) /* parameter max = 79 */
266 p = ((svsp->maxcol)-1);
268 if((svsp->col + p) > ((svsp->maxcol)-1))/* not more than right margin */
269 p = ((svsp->maxcol)-1) - svsp->col;
271 svsp->cur_offset += p;
275 /*---------------------------------------------------------------------------*
276 * CUB - cursor backward
277 *---------------------------------------------------------------------------*/
279 vt_cub(struct video_state *svsp)
281 register int p = svsp->parms[0];
283 if(svsp->col == 0) /* already at left margin ? */
286 if(p <= 0) /* parameter min = 1 */
288 else if(p > ((svsp->maxcol)-1)) /* parameter max = 79 */
289 p = ((svsp->maxcol)-1);
291 if((svsp->col - p) <= 0) /* not more than left margin */
294 svsp->cur_offset -= p;
298 /*---------------------------------------------------------------------------*
299 * ED - erase in display
300 *---------------------------------------------------------------------------*/
302 vt_clreos(struct video_state *svsp)
304 switch(svsp->parms[0])
307 fillw(user_attr | ' ', svsp->Crtat + svsp->cur_offset,
309 (svsp->maxcol * svsp->screen_rows) -
310 (svsp->Crtat + svsp->cur_offset));
314 fillw(user_attr | ' ', svsp->Crtat,
315 svsp->Crtat + svsp->cur_offset -
320 fillw(user_attr | ' ', svsp->Crtat,
321 svsp->maxcol * svsp->screen_rows);
326 /*---------------------------------------------------------------------------*
328 *---------------------------------------------------------------------------*/
330 vt_clreol(struct video_state *svsp)
332 switch(svsp->parms[0])
335 fillw(user_attr | ' ',
336 svsp->Crtat + svsp->cur_offset,
337 svsp->maxcol-svsp->col);
341 fillw(user_attr | ' ',
342 svsp->Crtat + svsp->cur_offset - svsp->col,
347 fillw(user_attr | ' ',
348 svsp->Crtat + svsp->cur_offset - svsp->col,
354 /*---------------------------------------------------------------------------*
355 * CUP - cursor position / HVP - horizontal & vertical position
356 *---------------------------------------------------------------------------*/
358 vt_curadr(struct video_state *svsp)
360 if(svsp->m_om) /* relative to scrolling region */
362 if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
364 svsp->cur_offset = svsp->scrr_beg * svsp->maxcol;
370 if(svsp->parms[0] <= 0)
372 else if(svsp->parms[0] > svsp->scrr_len)
373 svsp->parms[0] = svsp->scrr_len;
375 if(svsp->parms[1] <= 0 )
377 if(svsp->parms[1] > svsp->maxcol)
378 svsp->parms[1] = svsp->maxcol;
380 svsp->cur_offset = (svsp->scrr_beg * svsp->maxcol) +
381 ((svsp->parms[0] - 1) * svsp->maxcol) +
383 svsp->col = svsp->parms[1] - 1;
386 else /* relative to screen start */
388 if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
390 svsp->cur_offset = 0;
396 if(svsp->parms[0] <= 0)
398 else if(svsp->parms[0] > svsp->screen_rows)
399 svsp->parms[0] = svsp->screen_rows;
401 if(svsp->parms[1] <= 0 )
403 if(svsp->parms[1] > svsp->maxcol) /* col */
404 svsp->parms[1] = svsp->maxcol;
406 svsp->cur_offset = (((svsp->parms[0]-1)*svsp->maxcol) +
408 svsp->col = svsp->parms[1]-1;
410 if (svsp->cur_offset >=
411 ((svsp->scrr_beg + svsp->scrr_len + 1) * svsp->maxcol))
419 /*---------------------------------------------------------------------------*
420 * RIS - reset to initial state (hard emulator runtime reset)
421 *---------------------------------------------------------------------------*/
423 vt_ris(struct video_state *svsp)
425 fillw(user_attr | ' ', svsp->Crtat, svsp->maxcol * svsp->screen_rows);
426 svsp->cur_offset = 0; /* cursor upper left corner */
429 svsp->lnm = 0; /* CR only */
430 clear_dld(svsp); /* clear download charset */
431 vt_clearudk(svsp); /* clear user defined keys */
432 svsp->selchar = 0; /* selective attribute off */
433 vt_str(svsp); /* and soft terminal reset */
436 /*---------------------------------------------------------------------------*
437 * DECSTR - soft terminal reset (SOFT emulator runtime reset)
438 *---------------------------------------------------------------------------*/
440 vt_str(struct video_state *svsp)
444 clr_parms(svsp); /* escape parameter init */
445 svsp->state = STATE_INIT; /* initial state */
447 svsp->dis_fnc = 0; /* display functions reset */
449 svsp->sc_flag = 0; /* save cursor position */
450 svsp->transparent = 0; /* enable control code processing */
452 for(i = 0; i < MAXTAB; i++) /* setup tabstops */
455 svsp->tab_stops[i] = 1;
457 svsp->tab_stops[i] = 0;
460 svsp->irm = 0; /* replace mode */
461 svsp->m_om = 0; /* origin mode */
462 svsp->m_awm = 1; /* auto wrap mode */
464 #if PCVT_INHIBIT_NUMLOCK
465 svsp->num_lock = 0; /* keypad application mode */
467 svsp->num_lock = 1; /* keypad numeric mode */
470 svsp->scroll_lock = 0; /* reset keyboard modes */
473 svsp->ckm = 1; /* cursor key mode = "normal" ... */
474 svsp->scrr_beg = 0; /* start of scrolling region */
475 svsp->scrr_len = svsp->screen_rows; /* no. of lines in scrolling region */
476 svsp->abs_write = 0; /* scrr is complete screen */
477 svsp->scrr_end = svsp->scrr_len - 1;
479 if(adaptor_type == EGA_ADAPTOR || adaptor_type == VGA_ADAPTOR)
481 svsp->G0 = cse_ascii; /* G0 = ascii */
482 svsp->G1 = cse_ascii; /* G1 = ascii */
483 svsp->G2 = cse_supplemental; /* G2 = supplemental */
484 svsp->G3 = cse_supplemental; /* G3 = supplemental */
485 svsp->GL = &svsp->G0; /* GL = G0 */
486 svsp->GR = &svsp->G2; /* GR = G2 */
490 svsp->G0 = csd_ascii; /* G0 = ascii */
491 svsp->G1 = csd_ascii; /* G1 = ascii */
492 svsp->G2 = csd_supplemental; /* G2 = supplemental */
493 svsp->G3 = csd_supplemental; /* G3 = supplemental */
494 svsp->GL = &svsp->G0; /* GL = G0 */
495 svsp->GR = &svsp->G2; /* GR = G2 */
498 svsp->vtsgr = VT_NORMAL; /* no attributes */
499 svsp->c_attr = user_attr; /* reset sgr to normal */
501 svsp->selchar = 0; /* selective attribute off */
504 init_ufkl(svsp); /* init user fkey labels */
505 init_sfkl(svsp); /* init system fkey labels */
507 update_led(); /* update keyboard LED's */
510 /*---------------------------------------------------------------------------*
511 * RI - reverse index, move cursor up
512 *---------------------------------------------------------------------------*/
514 vt_ri(struct video_state *svsp)
516 if(svsp->cur_offset >= ((svsp->scrr_beg * svsp->maxcol) + svsp->maxcol))
517 svsp->cur_offset -= svsp->maxcol;
522 /*---------------------------------------------------------------------------*
523 * IND - index, move cursor down
524 *---------------------------------------------------------------------------*/
526 vt_ind(struct video_state *svsp)
528 if(svsp->cur_offset < (svsp->scrr_end * svsp->maxcol))
529 svsp->cur_offset += svsp->maxcol;
534 /*---------------------------------------------------------------------------*
535 * NEL - next line, first pos of next line
536 *---------------------------------------------------------------------------*/
538 vt_nel(struct video_state *svsp)
540 if(svsp->cur_offset < (svsp->scrr_end * svsp->maxcol))
542 svsp->cur_offset += (svsp->maxcol-svsp->col);
548 svsp->cur_offset -= svsp->col;
553 /*---------------------------------------------------------------------------*
554 * set dec private modes, esc [ ? x h
555 *---------------------------------------------------------------------------*/
557 vt_set_dec_priv_qm(struct video_state *svsp)
559 switch(svsp->parms[0])
561 case 0: /* error, ignored */
562 case 1: /* CKM - cursor key mode */
566 case 2: /* ANM - ansi/vt52 mode */
569 case 3: /* COLM - column mode */
570 vt_col(svsp, SCR_COL132);
573 case 4: /* SCLM - scrolling mode */
574 case 5: /* SCNM - screen mode */
577 case 6: /* OM - origin mode */
581 case 7: /* AWM - auto wrap mode */
583 swritefkl(7,(u_char *)"AUTOWRAPENABLE *",svsp);
586 case 8: /* ARM - auto repeat mode */
590 case 9: /* INLM - interlace mode */
591 case 10: /* EDM - edit mode */
592 case 11: /* LTM - line transmit mode */
594 case 13: /* SCFDM - space compression / field delimiting */
595 case 14: /* TEM - transmit execution mode */
597 case 16: /* EKEM - edit key execution mode */
600 case 25: /* TCEM - text cursor enable mode */
602 sw_cursor(1); /* cursor on */
606 case 42: /* NRCM - 7bit NRC characters */
611 /*---------------------------------------------------------------------------*
612 * reset dec private modes, esc [ ? x l
613 *---------------------------------------------------------------------------*/
615 vt_reset_dec_priv_qm(struct video_state *svsp)
617 switch(svsp->parms[0])
619 case 0: /* error, ignored */
620 case 1: /* CKM - cursor key mode */
624 case 2: /* ANM - ansi/vt52 mode */
627 case 3: /* COLM - column mode */
628 vt_col(svsp, SCR_COL80);
631 case 4: /* SCLM - scrolling mode */
632 case 5: /* SCNM - screen mode */
635 case 6: /* OM - origin mode */
639 case 7: /* AWM - auto wrap mode */
641 swritefkl(7,(u_char *)"AUTOWRAPENABLE ",svsp);
644 case 8: /* ARM - auto repeat mode */
648 case 9: /* INLM - interlace mode */
649 case 10: /* EDM - edit mode */
650 case 11: /* LTM - line transmit mode */
652 case 13: /* SCFDM - space compression / field delimiting */
653 case 14: /* TEM - transmit execution mode */
655 case 16: /* EKEM - edit key execution mode */
658 case 25: /* TCEM - text cursor enable mode */
660 sw_cursor(0); /* cursor off */
664 case 42: /* NRCM - 7bit NRC characters */
669 /*---------------------------------------------------------------------------*
670 * set ansi modes, esc [ x
671 *---------------------------------------------------------------------------*/
673 vt_set_ansi(struct video_state *svsp)
675 switch(svsp->parms[0])
677 case 0: /* error, ignored */
678 case 1: /* GATM - guarded area transfer mode */
679 case 2: /* KAM - keyboard action mode */
680 case 3: /* CRM - Control Representation mode */
683 case 4: /* IRM - insert replacement mode */
684 svsp->irm = 1; /* Insert mode */
687 case 5: /* SRTM - status report transfer mode */
688 case 6: /* ERM - erasue mode */
689 case 7: /* VEM - vertical editing mode */
690 case 10: /* HEM - horizontal editing mode */
691 case 11: /* PUM - position unit mode */
692 case 12: /* SRM - send-receive mode */
693 case 13: /* FEAM - format effector action mode */
694 case 14: /* FETM - format effector transfer mode */
695 case 15: /* MATM - multiple area transfer mode */
696 case 16: /* TTM - transfer termination */
697 case 17: /* SATM - selected area transfer mode */
698 case 18: /* TSM - tabulation stop mode */
699 case 19: /* EBM - editing boundary mode */
702 case 20: /* LNM - line feed / newline mode */
708 /*---------------------------------------------------------------------------*
709 * reset ansi modes, esc [ x
710 *---------------------------------------------------------------------------*/
712 vt_reset_ansi(struct video_state *svsp)
714 switch(svsp->parms[0])
716 case 0: /* error, ignored */
717 case 1: /* GATM - guarded area transfer mode */
718 case 2: /* KAM - keyboard action mode */
719 case 3: /* CRM - Control Representation mode */
722 case 4: /* IRM - insert replacement mode */
723 svsp->irm = 0; /* Replace mode */
726 case 5: /* SRTM - status report transfer mode */
727 case 6: /* ERM - erasue mode */
728 case 7: /* VEM - vertical editing mode */
729 case 10: /* HEM - horizontal editing mode */
730 case 11: /* PUM - position unit mode */
731 case 12: /* SRM - send-receive mode */
732 case 13: /* FEAM - format effector action mode */
733 case 14: /* FETM - format effector transfer mode */
734 case 15: /* MATM - multiple area transfer mode */
735 case 16: /* TTM - transfer termination */
736 case 17: /* SATM - selected area transfer mode */
737 case 18: /* TSM - tabulation stop mode */
738 case 19: /* EBM - editing boundary mode */
741 case 20: /* LNM - line feed / newline mode */
747 /*---------------------------------------------------------------------------*
749 *---------------------------------------------------------------------------*/
751 vt_clrtab(struct video_state *svsp)
755 if(svsp->parms[0] == 0)
756 svsp->tab_stops[svsp->col] = 0;
757 else if(svsp->parms[0] == 3)
759 for(i=0; i<MAXTAB; i++)
760 svsp->tab_stops[i] = 0;
764 /*---------------------------------------------------------------------------*
765 * DECSC - save cursor & attributes
766 *---------------------------------------------------------------------------*/
768 vt_sc(struct video_state *svsp)
771 svsp->sc_row = svsp->row;
772 svsp->sc_col = svsp->col;
773 svsp->sc_cur_offset = svsp->cur_offset;
774 svsp->sc_attr = svsp->c_attr;
775 svsp->sc_awm = svsp->m_awm;
776 svsp->sc_om = svsp->m_om;
777 svsp->sc_G0 = svsp->G0;
778 svsp->sc_G1 = svsp->G1;
779 svsp->sc_G2 = svsp->G2;
780 svsp->sc_G3 = svsp->G3;
781 svsp->sc_GL = svsp->GL;
782 svsp->sc_GR = svsp->GR;
783 svsp->sc_sel = svsp->selchar;
784 svsp->sc_vtsgr = svsp->vtsgr;
787 /*---------------------------------------------------------------------------*
788 * DECRC - restore cursor & attributes
789 *---------------------------------------------------------------------------*/
791 vt_rc(struct video_state *svsp)
793 if(svsp->sc_flag == 1)
796 svsp->row = svsp->sc_row;
797 svsp->col = svsp->sc_col;
798 svsp->cur_offset = svsp->sc_cur_offset;
799 svsp->c_attr = svsp->sc_attr;
800 svsp->m_awm = svsp->sc_awm;
801 svsp->m_om = svsp->sc_om;
802 svsp->G0 = svsp->sc_G0;
803 svsp->G1 = svsp->sc_G1;
804 svsp->G2 = svsp->sc_G2;
805 svsp->G3 = svsp->sc_G3;
806 svsp->GL = svsp->sc_GL;
807 svsp->GR = svsp->sc_GR;
808 svsp->selchar = svsp->sc_sel;
809 svsp->vtsgr = svsp->sc_vtsgr;
813 /*---------------------------------------------------------------------------*
814 * designate a character set as G0, G1, G2 or G3 for 94/96 char sets
815 *---------------------------------------------------------------------------*/
817 vt_designate(struct video_state *svsp)
822 if(svsp->whichi == 1)
828 if(svsp->dld_id[0] == '\0')
831 if(!(((adaptor_type == EGA_ADAPTOR) ||
832 (adaptor_type == VGA_ADAPTOR)) &&
833 (vgacs[svsp->vga_charset].secondloaded)))
838 for(i = (svsp->whichi)-1; i >= 0; i--)
840 if(svsp->which[i] != svsp->dld_id[i])
843 #ifdef HAVECSE_DOWNLOADABLE
844 ctp = cse_downloadable;
850 if(((adaptor_type == EGA_ADAPTOR) || (adaptor_type == VGA_ADAPTOR)) &&
851 (vgacs[svsp->vga_charset].secondloaded))
853 if((ch == svsp->dld_id[0]) && (svsp->dld_id[1] == '\0'))
855 #ifdef HAVECSE_DOWNLOADABLE
856 ctp = cse_downloadable;
864 case 'A': /* British or ISO-Latin-1 */
867 case STATE_BROPN: /* designate G0 */
868 case STATE_BRCLO: /* designate G1 */
869 case STATE_STAR: /* designate G2 */
870 case STATE_PLUS: /* designate G3 */
871 #ifdef HAVECSE_BRITISH
876 case STATE_MINUS: /* designate G1 (96)*/
877 case STATE_DOT: /* designate G2 (96)*/
878 case STATE_SLASH: /* designate G3 (96)*/
879 #ifdef HAVECSE_ISOLATIN
886 case 'B': /* USASCII */
892 case 'C': /* Finnish */
893 case '5': /* Finnish */
894 #ifdef HAVECSE_FINNISH
899 case 'E': /* Norwegian/Danish */
900 case '6': /* Norwegian/Danish */
901 #ifdef HAVECSE_NORWEGIANDANISH
902 ctp = cse_norwegiandanish;
906 case 'H': /* Swedish */
907 case '7': /* Swedish */
908 #ifdef HAVECSE_SWEDISH
913 case 'K': /* German */
914 #ifdef HAVECSE_GERMAN
919 case 'Q': /* French Canadien */
920 #ifdef HAVECSE_FRENCHCANADA
921 ctp = cse_frenchcanada;
925 case 'R': /* French */
926 #ifdef HAVECSE_FRENCH
931 case 'Y': /* Italian */
932 #ifdef HAVECSE_ITALIAN
937 case 'Z': /* Spanish */
938 #ifdef HAVECSE_SPANISH
943 case '0': /* special graphics */
944 #ifdef HAVECSE_SPECIAL
949 case '1': /* alternate ROM */
950 #ifdef HAVECSE_ALTERNATEROM1
951 ctp = cse_alternaterom1;
955 case '2': /* alt ROM, spec graphics */
956 #ifdef HAVECSE_ALTERNATEROM2
957 ctp = cse_alternaterom2;
961 case '3': /* HP Roman 8, upper 128 chars*/
962 #ifdef HAVECSE_ROMAN8
967 case '4': /* Dutch */
973 case '<': /* DEC Supplemental */
974 #ifdef HAVECSE_SUPPLEMENTAL
975 ctp = cse_supplemental;
979 case '=': /* Swiss */
985 case '>': /* DEC Technical */
986 #ifdef HAVECSE_TECHNICAL
999 case 'A': /* British or ISO-Latin-1 */
1002 case STATE_BROPN: /* designate G0 */
1003 case STATE_BRCLO: /* designate G1 */
1004 case STATE_STAR: /* designate G2 */
1005 case STATE_PLUS: /* designate G3 */
1006 #ifdef HAVECSD_BRITISH
1011 case STATE_MINUS: /* designate G1 (96)*/
1012 case STATE_DOT: /* designate G2 (96)*/
1013 case STATE_SLASH: /* designate G3 (96)*/
1014 #ifdef HAVECSD_ISOLATIN
1021 case 'B': /* USASCII */
1022 #ifdef HAVECSD_ASCII
1027 case 'C': /* Finnish */
1028 case '5': /* Finnish */
1029 #ifdef HAVECSD_FINNISH
1034 case 'E': /* Norwegian/Danish */
1035 case '6': /* Norwegian/Danish */
1036 #ifdef HAVECSD_NORWEGIANDANISH
1037 ctp = csd_norwegiandanish;
1041 case 'H': /* Swedish */
1042 case '7': /* Swedish */
1043 #ifdef HAVECSD_SWEDISH
1048 case 'K': /* German */
1049 #ifdef HAVECSD_GERMAN
1054 case 'Q': /* French Canadien */
1055 #ifdef HAVECSD_FRENCHCANADA
1056 ctp = csd_frenchcanada;
1060 case 'R': /* French */
1061 #ifdef HAVECSD_FRENCH
1066 case 'Y': /* Italian */
1067 #ifdef HAVECSD_ITALIAN
1072 case 'Z': /* Spanish */
1073 #ifdef HAVECSD_SPANISH
1078 case '0': /* special graphics */
1079 #ifdef HAVECSD_SPECIAL
1084 case '1': /* alternate ROM */
1085 #ifdef HAVECSD_ALTERNATEROM1
1086 ctp = csd_alternaterom1;
1090 case '2': /* alt ROM, spec graphics */
1091 #ifdef HAVECSD_ALTERNATEROM2
1092 ctp = csd_alternaterom2;
1096 case '3': /* HP Roman 8, upper 128 chars*/
1097 #ifdef HAVECSD_ROMAN8
1102 case '4': /* Dutch */
1103 #ifdef HAVECSD_DUTCH
1108 case '<': /* DEC Supplemental */
1109 #ifdef HAVECSD_SUPPLEMENTAL
1110 ctp = csd_supplemental;
1114 case '=': /* Swiss */
1115 #ifdef HAVECSD_SWISS
1120 case '>': /* DEC Technical */
1121 #ifdef HAVECSD_TECHNICAL
1122 ctp = csd_technical;
1133 /*---------------------------------------------------------------------------*
1135 *---------------------------------------------------------------------------*/
1137 vt_da(struct video_state *svsp)
1139 static u_char *response = (u_char *)DA_VT220;
1141 svsp->report_chars = response;
1142 svsp->report_count = 18;
1146 /*---------------------------------------------------------------------------*
1147 * screen alignment display
1148 *---------------------------------------------------------------------------*/
1150 vt_aln(struct video_state *svsp)
1154 svsp->cur_offset = 0;
1157 for(i=0; i < (svsp->screen_rows*svsp->maxcol); i++)
1159 *(svsp->Crtat + svsp->cur_offset) = user_attr | 'E';
1165 svsp->cur_offset = 0; /* reset everything ! */
1170 /*---------------------------------------------------------------------------*
1171 * request terminal parameters
1172 *---------------------------------------------------------------------------*/
1174 vt_reqtparm(struct video_state *svsp)
1176 static u_char *answr = (u_char *)"\033[3;1;1;120;120;1;0x";
1178 svsp->report_chars = answr;
1179 svsp->report_count = 20;
1183 /*---------------------------------------------------------------------------*
1185 *---------------------------------------------------------------------------*/
1187 vt_tst(struct video_state *svsp)
1192 /*---------------------------------------------------------------------------*
1193 * device status reports
1194 *---------------------------------------------------------------------------*/
1196 vt_dsr(struct video_state *svsp)
1198 static u_char *answr = (u_char *)"\033[0n";
1199 static u_char *panswr = (u_char *)"\033[?13n"; /* Printer Unattached */
1200 static u_char *udkanswr = (u_char *)"\033[?21n"; /* UDK Locked */
1201 static u_char *langanswr = (u_char *)"\033[?27;1n"; /* North American*/
1202 static u_char buffer[16];
1205 switch(svsp->parms[0])
1207 case 5: /* return status */
1208 svsp->report_chars = answr;
1209 svsp->report_count = 4;
1213 case 6: /* return cursor position */
1216 if((svsp->row+1) > 10)
1217 buffer[i++] = ((svsp->row+1) / 10) + '0';
1218 buffer[i++] = ((svsp->row+1) % 10) + '0';
1220 if((svsp->col+1) > 10)
1221 buffer[i++] = ((svsp->col+1) / 10) + '0';
1222 buffer[i++] = ((svsp->col+1) % 10) + '0';
1226 svsp->report_chars = buffer;
1227 svsp->report_count = i;
1231 case 15: /* return printer status */
1232 svsp->report_chars = panswr;
1233 svsp->report_count = 6;
1237 case 25: /* return udk status */
1238 svsp->report_chars = udkanswr;
1239 svsp->report_count = 6;
1243 case 26: /* return language status */
1244 svsp->report_chars = langanswr;
1245 svsp->report_count = 8;
1249 default: /* nothing else valid */
1254 /*---------------------------------------------------------------------------*
1256 *---------------------------------------------------------------------------*/
1258 vt_il(struct video_state *svsp)
1260 register int p = svsp->parms[0];
1262 if((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end))
1266 else if(p > svsp->scrr_end - svsp->row)
1267 p = svsp->scrr_end - svsp->row;
1269 svsp->cur_offset -= svsp->col;
1271 if(svsp->row == svsp->scrr_beg)
1275 bcopy(svsp->Crtat + svsp->cur_offset,
1276 svsp->Crtat + svsp->cur_offset + (p * svsp->maxcol),
1277 svsp->maxcol * (svsp->scrr_end-svsp->row+1-p) * CHR );
1279 fillw(user_attr | ' ',
1280 svsp->Crtat + svsp->cur_offset,
1286 /*---------------------------------------------------------------------------*
1287 * ICH - insert character
1288 *---------------------------------------------------------------------------*/
1290 vt_ic(struct video_state *svsp)
1292 register int p = svsp->parms[0];
1296 else if(p > svsp->maxcol-svsp->col)
1297 p = svsp->maxcol-svsp->col;
1301 bcopy((svsp->Crtat + svsp->cur_offset),
1302 (svsp->Crtat + svsp->cur_offset) + 1,
1303 (((svsp->maxcol)-1)-svsp->col) * CHR);
1305 *(svsp->Crtat + svsp->cur_offset) = user_attr | ' ';
1310 /*---------------------------------------------------------------------------*
1312 *---------------------------------------------------------------------------*/
1314 vt_dl(struct video_state *svsp)
1316 register int p = svsp->parms[0];
1318 if((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end))
1322 else if(p > svsp->scrr_end - svsp->row)
1323 p = svsp->scrr_end - svsp->row;
1325 svsp->cur_offset -= svsp->col;
1328 if(svsp->row == svsp->scrr_beg)
1332 bcopy(svsp->Crtat + svsp->cur_offset + (p * svsp->maxcol),
1333 svsp->Crtat + svsp->cur_offset,
1334 svsp->maxcol * (svsp->scrr_end-svsp->row+1-p) * CHR );
1336 fillw(user_attr | ' ',
1337 svsp->Crtat + ((svsp->scrr_end-p+1) * svsp->maxcol),
1343 /*---------------------------------------------------------------------------*
1344 * DCH - delete character
1345 *---------------------------------------------------------------------------*/
1347 vt_dch(struct video_state *svsp)
1349 register int p = svsp->parms[0];
1353 else if(p > svsp->maxcol-svsp->col)
1354 p = svsp->maxcol-svsp->col;
1358 bcopy((svsp->Crtat + svsp->cur_offset)+1,
1359 (svsp->Crtat + svsp->cur_offset),
1360 (((svsp->maxcol)-1) - svsp->col)* CHR );
1362 *((svsp->Crtat + svsp->cur_offset) +
1363 ((svsp->maxcol)-1)-svsp->col) = user_attr | ' ';
1367 /*---------------------------------------------------------------------------*
1369 *---------------------------------------------------------------------------*/
1371 vt_su(struct video_state *svsp)
1373 register int p = svsp->parms[0];
1377 else if(p > svsp->screen_rows-1)
1378 p = svsp->screen_rows-1;
1383 /*---------------------------------------------------------------------------*
1385 *---------------------------------------------------------------------------*/
1387 vt_sd(struct video_state *svsp)
1389 register int p = svsp->parms[0];
1393 else if(p > svsp->screen_rows-1)
1394 p = svsp->screen_rows-1;
1399 /*---------------------------------------------------------------------------*
1400 * ECH - erase character
1401 *---------------------------------------------------------------------------*/
1403 vt_ech(struct video_state *svsp)
1405 register int p = svsp->parms[0];
1409 else if(p > svsp->maxcol-svsp->col)
1410 p = svsp->maxcol-svsp->col;
1412 fillw(user_attr | ' ', (svsp->Crtat + svsp->cur_offset), p);
1415 /*---------------------------------------------------------------------------*
1416 * media copy (NO PRINTER AVAILABLE IN KERNEL ...)
1417 *---------------------------------------------------------------------------*/
1419 vt_mc(struct video_state *svsp)
1423 /*---------------------------------------------------------------------------*
1424 * Device Control String State Machine Entry for:
1426 * DECUDK - user-defined keys and
1427 * DECDLD - downloadable charset
1429 *---------------------------------------------------------------------------*/
1431 vt_dcsentry(U_char ch, struct video_state *svsp)
1433 switch(svsp->dcs_state)
1447 case '9': /* parameters */
1448 svsp->parms[svsp->parmi] *= 10;
1449 svsp->parms[svsp->parmi] += (ch -'0');
1452 case ';': /* next parameter */
1454 (svsp->parmi+1 < MAXPARMS) ?
1455 svsp->parmi+1 : svsp->parmi;
1458 case '|': /* DECUDK */
1459 svsp->transparent = 1;
1461 svsp->dcs_state = DCS_AND_UDK;
1464 case '{': /* DECDLD */
1465 svsp->transparent = 1;
1467 svsp->dcs_state = DCS_DLD_DSCS;
1470 default: /* failsafe */
1471 svsp->transparent = 0;
1472 svsp->state = STATE_INIT;
1473 svsp->dcs_state = DCS_INIT;
1478 case DCS_AND_UDK: /* DCS ... | */
1490 case '9': /* fkey number */
1491 svsp->udk_fnckey *= 10;
1492 svsp->udk_fnckey += (ch -'0');
1496 svsp->dcs_state = DCS_UDK_DEF;
1499 case 0x1b: /* ESC */
1500 svsp->dcs_state = DCS_UDK_ESC;
1504 svsp->transparent = 0;
1505 svsp->state = STATE_INIT;
1506 svsp->dcs_state = DCS_INIT;
1511 case DCS_UDK_DEF: /* DCS ... | fnckey / */
1524 if(svsp->udk_deflow) /* low nibble */
1526 svsp->udk_def[svsp->udk_defi] |= (ch -'0');
1527 svsp->udk_deflow = 0;
1528 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
1529 svsp->udk_defi : svsp->udk_defi+1;
1531 else /* high nibble */
1533 svsp->udk_def[svsp->udk_defi] = ((ch -'0') << 4);
1534 svsp->udk_deflow = 1;
1544 if(svsp->udk_deflow) /* low nibble */
1546 svsp->udk_def[svsp->udk_defi] |= (ch - 'a' + 10);
1547 svsp->udk_deflow = 0;
1548 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
1549 svsp->udk_defi : svsp->udk_defi+1;
1551 else /* high nibble */
1553 svsp->udk_def[svsp->udk_defi] = ((ch - 'a' + 10) << 4);
1554 svsp->udk_deflow = 1;
1566 if(svsp->udk_deflow) /* low nibble */
1568 svsp->udk_def[svsp->udk_defi] |= (ch - 'A' + 10);
1569 svsp->udk_deflow = 0;
1570 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
1571 svsp->udk_defi : svsp->udk_defi+1;
1573 else /* high nibble */
1575 svsp->udk_def[svsp->udk_defi] = ((ch - 'A' + 10) << 4);
1576 svsp->udk_deflow = 1;
1580 case ';': /* next function key */
1582 svsp->dcs_state = DCS_AND_UDK;
1585 case 0x1b: /* ESC */
1586 svsp->dcs_state = DCS_UDK_ESC;
1590 svsp->transparent = 0;
1591 svsp->state = STATE_INIT;
1592 svsp->dcs_state = DCS_INIT;
1597 case DCS_UDK_ESC: /* DCS ... | fkey/def ... ESC */
1602 svsp->transparent = 0;
1603 svsp->state = STATE_INIT;
1604 svsp->dcs_state = DCS_INIT;
1608 svsp->transparent = 0;
1609 svsp->state = STATE_INIT;
1610 svsp->dcs_state = DCS_INIT;
1616 case DCS_DLD_DSCS: /* got DCS ... { */
1617 if(ch >= ' ' && ch <= '/') /* intermediates ... */
1619 svsp->dld_dscs[svsp->dld_dscsi] = ch;
1620 svsp->dld_id[svsp->dld_dscsi] = ch;
1621 if(svsp->dld_dscsi >= DSCS_LENGTH)
1623 svsp->transparent = 0;
1624 svsp->state = STATE_INIT;
1625 svsp->dcs_state = DCS_INIT;
1626 svsp->dld_id[0] = '\0';
1633 else if(ch >= '0' && ch <= '~') /* final .... */
1635 svsp->dld_dscs[svsp->dld_dscsi] = ch;
1636 svsp->dld_id[svsp->dld_dscsi++] = ch;
1637 svsp->dld_id[svsp->dld_dscsi] = '\0';
1638 svsp->dcs_state = DCS_DLD_DEF;
1642 svsp->transparent = 0;
1643 svsp->state = STATE_INIT;
1644 svsp->dcs_state = DCS_INIT;
1645 svsp->dld_id[0] = '\0';
1649 case DCS_DLD_DEF: /* DCS ... { dscs */
1652 case 0x1b: /* ESC */
1653 svsp->dcs_state = DCS_DLD_ESC;
1656 case '/': /* sixel upper / lower divider */
1657 svsp->dld_sixel_lower = 1;
1660 case ';': /* character divider */
1662 svsp->parms[1]++; /* next char */
1666 if (svsp->dld_sixel_lower)
1668 if(ch >= '?' && ch <= '~')
1669 svsp->sixel.lower[svsp->dld_sixelli] = ch - '?';
1671 (svsp->dld_sixelli+1 < MAXSIXEL) ?
1672 svsp->dld_sixelli+1 : svsp->dld_sixelli;
1676 if(ch >= '?' && ch <= '~')
1677 svsp->sixel.upper[svsp->dld_sixelui] = ch - '?';
1679 (svsp->dld_sixelui+1 < MAXSIXEL) ?
1680 svsp->dld_sixelui+1 : svsp->dld_sixelui;
1686 case DCS_DLD_ESC: /* DCS ... { dscs ... / ... ESC */
1689 case '\\': /* String Terminator ST */
1691 svsp->transparent = 0;
1692 svsp->state = STATE_INIT;
1693 svsp->dcs_state = DCS_INIT;
1697 svsp->transparent = 0;
1698 svsp->state = STATE_INIT;
1699 svsp->dcs_state = DCS_INIT;
1700 svsp->dld_id[0] = '\0';
1706 svsp->transparent = 0;
1707 svsp->state = STATE_INIT;
1708 svsp->dcs_state = DCS_INIT;
1713 /*---------------------------------------------------------------------------*
1714 * User Defineable Keys
1715 *---------------------------------------------------------------------------*/
1717 vt_udk(struct video_state *svsp)
1719 int key, start, max, i;
1722 if(svsp->parms[0] != 1) /* clear all ? */
1728 if(svsp->udk_fnckey < 17 || svsp->udk_fnckey > 34)
1734 key = svsp->udk_fnckey - 17; /* index into table */
1736 if(svsp->ukt.length[key] == 0) /* never used ? */
1738 if(svsp->udkff < MAXUDKDEF-2) /* space available ? */
1740 start = svsp->udkff; /* next sequential */
1741 max = MAXUDKDEF - svsp->udkff; /* space available */
1742 svsp->ukt.first[key] = start; /* start entry */
1743 usedff = 1; /* flag to update later */
1751 else /* in use, redefine */
1753 start = svsp->ukt.first[key]; /* start entry */
1754 max = svsp->ukt.length[key]; /* space available */
1757 if(max < 2) /* hmmm .. */
1763 max--; /* adjust for tailing '\0' */
1765 for(i = 0; i < max && i < svsp->udk_defi; i++)
1766 svsp->udkbuf[start++] = svsp->udk_def[i];
1768 svsp->udkbuf[start] = '\0'; /* make it a string, see pcvt_kbd.c */
1769 svsp->ukt.length[key] = i+1; /* count for tailing '\0' */
1771 svsp->udkff += (i+2); /* new start location */
1776 /*---------------------------------------------------------------------------*
1777 * clear all User Defineable Keys
1778 *---------------------------------------------------------------------------*/
1780 vt_clearudk(struct video_state *svsp)
1784 for(i = 0; i < MAXUDKEYS; i++)
1786 svsp->ukt.first[i] = 0;
1787 svsp->ukt.length[i] = 0;
1792 /*---------------------------------------------------------------------------*
1793 * Down line LoaDable Fonts
1794 *---------------------------------------------------------------------------*/
1796 vt_dld(struct video_state *svsp)
1798 unsigned char vgacharset;
1799 unsigned char vgachar[16];
1800 unsigned char vgacharb[16];
1802 if(vgacs[svsp->vga_charset].secondloaded)
1803 vgacharset = vgacs[svsp->vga_charset].secondloaded;
1807 svsp->parms[1] = (svsp->parms[1] < 1) ? 1 :
1808 ((svsp->parms[1] > 0x7E) ? 0x7E : svsp->parms[1]);
1810 if(svsp->parms[2] != 1) /* Erase all characters ? */
1813 svsp->parms[2] = 1; /* Only erase all characters once per sequence */
1816 sixel_vga(&(svsp->sixel),vgachar);
1818 switch(vgacs[vgacharset].char_scanlines & 0x1F)
1821 vga10_vga8(vgachar,vgacharb);
1826 vga10_vga10(vgachar,vgacharb);
1830 vga10_vga14(vgachar,vgacharb);
1834 vga10_vga16(vgachar,vgacharb);
1838 loadchar(vgacharset, svsp->parms[1] + 0xA0, 16, vgacharb);
1843 /*---------------------------------------------------------------------------*
1844 * select character attributes
1845 *---------------------------------------------------------------------------*/
1847 vt_sca(struct video_state *svsp)
1849 switch(svsp->parms[0])
1862 /*---------------------------------------------------------------------------*
1863 * initalize selective attribute bit array
1864 *---------------------------------------------------------------------------*/
1866 vt_initsel(struct video_state *svsp)
1870 for(i = 0;i < MAXDECSCA;i++)
1871 svsp->decsca[i] = 0;
1874 /*---------------------------------------------------------------------------*
1875 * DECSEL - selective erase in line
1876 *---------------------------------------------------------------------------*/
1878 vt_sel(struct video_state *svsp)
1880 switch(svsp->parms[0])
1883 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset),
1884 svsp->maxcol-svsp->col);
1888 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)-
1889 svsp->col, svsp->col + 1);
1893 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)-
1894 svsp->col, svsp->maxcol);
1899 /*---------------------------------------------------------------------------*
1900 * DECSED - selective erase in display
1901 *---------------------------------------------------------------------------*/
1903 vt_sed(struct video_state *svsp)
1905 switch(svsp->parms[0])
1908 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset),
1909 svsp->Crtat + (svsp->maxcol * svsp->screen_rows) -
1910 (svsp->Crtat + svsp->cur_offset));
1914 selective_erase(svsp, svsp->Crtat,
1915 (svsp->Crtat + svsp->cur_offset) - svsp->Crtat + 1 );
1919 selective_erase(svsp, svsp->Crtat,
1920 svsp->maxcol * svsp->screen_rows);
1925 /*---------------------------------------------------------------------------*
1926 * scroll screen n lines up
1927 *---------------------------------------------------------------------------*/
1929 roll_up(struct video_state *svsp, int n)
1932 #if (PCVT_NOFASTSCROLL==0)
1934 if(svsp->scrr_beg == 0 && /* if scroll region is whole screen */
1935 svsp->scrr_len == svsp->screen_rows &&
1936 (svsp != vsp || /* and either running in memory */
1937 (svsp->screen_rows == svsp->screen_rowsize && /* or no fkeys */
1938 adaptor_type != MDA_ADAPTOR))) /* and not on MDA/Hercules */
1942 #if PCVT_USL_VT_COMPAT
1943 (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ?
1948 svsp->Memory : Crtat;
1950 if(svsp->Crtat > (Memory + (svsp->screen_rows - n) *
1953 bcopy(svsp->Crtat + svsp->maxcol * n, Memory,
1954 svsp->maxcol * (svsp->screen_rows - n) * CHR);
1956 svsp->Crtat = Memory;
1960 svsp->Crtat += n * svsp->maxcol;
1963 #if PCVT_USL_VT_COMPAT
1964 if(vsp == svsp && !(vsp->vt_status & VT_GRAFX))
1970 outb(addr_6845, CRTC_STARTADRH);
1971 outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8);
1972 outb(addr_6845, CRTC_STARTADRL);
1973 outb(addr_6845+1, (svsp->Crtat - Crtat));
1979 bcopy( svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol),
1980 svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
1981 svsp->maxcol * (svsp->scrr_len - n) * CHR );
1984 fillw( user_attr | ' ',
1985 svsp->Crtat + ((svsp->scrr_end - n + 1) * svsp->maxcol),
1988 /*XXX*/ if(svsp->scroll_lock && svsp->openf && curproc)
1989 tsleep((caddr_t)&(svsp->scroll_lock), PPAUSE, "scrlck", 0);
1992 /*---------------------------------------------------------------------------*
1993 * scroll screen n lines down
1994 *---------------------------------------------------------------------------*/
1996 roll_down(struct video_state *svsp, int n)
1999 #if (PCVT_NOFASTSCROLL==0)
2001 if(svsp->scrr_beg == 0 && /* if scroll region is whole screen */
2002 svsp->scrr_len == svsp->screen_rows &&
2003 (svsp != vsp || /* and either running in memory */
2004 (svsp->screen_rows == svsp->screen_rowsize && /* or no fkeys */
2005 adaptor_type != MDA_ADAPTOR))) /* and not on MDA/Hercules */
2009 #if PCVT_USL_VT_COMPAT
2010 (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ?
2014 svsp->Memory : Crtat;
2016 if (svsp->Crtat < (Memory + n * svsp->maxcol))
2019 Memory + svsp->maxcol * (svsp->screen_rows + n),
2020 svsp->maxcol * (svsp->screen_rows - n) * CHR);
2022 svsp->Crtat = Memory + svsp->maxcol * svsp->screen_rows;
2026 svsp->Crtat -= n * svsp->maxcol;
2029 #if PCVT_USL_VT_COMPAT
2030 if(vsp == svsp && !(vsp->vt_status & VT_GRAFX))
2036 outb(addr_6845, CRTC_STARTADRH);
2037 outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8);
2038 outb(addr_6845, CRTC_STARTADRL);
2039 outb(addr_6845+1, (svsp->Crtat - Crtat));
2045 bcopy( svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
2046 svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol),
2047 svsp->maxcol * (svsp->scrr_len - n) * CHR );
2050 fillw( user_attr | ' ',
2051 svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
2054 /*XXX*/ if(svsp->scroll_lock && svsp->openf && curproc)
2055 tsleep((caddr_t)&(svsp->scroll_lock), PPAUSE, "scrlck", 0);
2058 /*---------------------------------------------------------------------------*
2059 * switch charset pointers
2060 *---------------------------------------------------------------------------*/
2062 swcsp(struct video_state *svsp, u_short *ctp)
2069 case STATE_BROPN: /* designate G0 */
2073 case STATE_BRCLO: /* designate G1 */
2074 case STATE_MINUS: /* designate G1 (96) */
2078 case STATE_STAR: /* designate G2 */
2079 case STATE_DOT: /* designate G2 (96) */
2083 case STATE_PLUS: /* designate G3 */
2084 case STATE_SLASH: /* designate G3 (96) */
2090 /*---------------------------------------------------------------------------*
2091 * process terminal responses
2092 *---------------------------------------------------------------------------*/
2094 respond(struct video_state *svsp)
2096 if(!(svsp->openf)) /* are we opened ? */
2099 while (*svsp->report_chars && svsp->report_count > 0)
2101 (*linesw[svsp->vs_tty->t_line].l_rint)
2102 (*svsp->report_chars++ & 0xff, svsp->vs_tty);
2103 svsp->report_count--;
2107 /*---------------------------------------------------------------------------*
2108 * Initialization for User Defineable Keys
2109 *---------------------------------------------------------------------------*/
2111 init_udk(struct video_state *svsp)
2114 svsp->udk_deflow = 0;
2115 svsp->udk_fnckey = 0;
2118 /*---------------------------------------------------------------------------*
2119 * Clear loaded downloadable (DLD) character set
2120 *---------------------------------------------------------------------------*/
2122 clear_dld(struct video_state *svsp)
2125 unsigned char vgacharset;
2126 unsigned char vgachar[16];
2128 if(vgacs[svsp->vga_charset].secondloaded)
2129 vgacharset = vgacs[svsp->vga_charset].secondloaded;
2133 for(i=0;i < 16;i++) /* A zeroed character, vt220 has inverted '?' */
2136 for(i=1;i <= 94;i++) /* Load (erase) all characters */
2137 loadchar(vgacharset, i + 0xA0, 16, vgachar);
2140 /*---------------------------------------------------------------------------*
2141 * Initialization for Down line LoaDable Fonts
2142 *---------------------------------------------------------------------------*/
2144 init_dld(struct video_state *svsp)
2148 svsp->dld_dscsi = 0;
2149 svsp->dld_sixel_lower = 0;
2150 svsp->dld_sixelli = 0;
2151 svsp->dld_sixelui = 0;
2153 for(i = 0;i < MAXSIXEL;i++)
2154 svsp->sixel.lower[i] = svsp->sixel.upper[i] = 0;
2157 /*---------------------------------------------------------------------------*
2158 * selective erase a region
2159 *---------------------------------------------------------------------------*/
2161 selective_erase(struct video_state *svsp, u_short *pcrtat, int length)
2165 for(j = pcrtat - svsp->Crtat, i = 0;i < length;i++,pcrtat++)
2167 if(!(svsp->decsca[INT_INDEX(j+i)] & (1 << BIT_INDEX(j+i))))
2169 *pcrtat &= 0xFF00; /* Keep the video character attributes */
2170 *pcrtat += ' '; /* Erase the character */
2175 #endif /* NVT > 0 */
2177 /* ------------------------- E O F ------------------------------------------*/