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 $
48 * $DragonFly: src/sys/dev/video/pcvt/i386/Attic/pcvt_vtf.c,v 1.4 2003/07/26 19:07:49 rob Exp $
50 *---------------------------------------------------------------------------*/
55 #define PCVT_INCLUDE_VT_SELATTR /* get inline function from pcvt_hdr.h */
57 #include <i386/isa/pcvt/pcvt_hdr.h> /* global include */
58 #include <i386/isa/pcvt/pcvt_tbl.h> /* character set conversion tables */
60 static void clear_dld ( struct video_state *svsp );
61 static void init_dld ( struct video_state *svsp );
62 static void init_udk ( struct video_state *svsp );
63 static void respond ( struct video_state *svsp );
64 static void roll_down ( struct video_state *svsp, int n );
65 static void selective_erase ( struct video_state *svsp, u_short *pcrtat,
67 static void swcsp ( struct video_state *svsp, u_short *ctp );
69 /*---------------------------------------------------------------------------*
70 * DECSTBM - set top and bottom margins
71 *---------------------------------------------------------------------------*/
73 vt_stbm(struct video_state *svsp)
75 /* both 0 => scrolling region = entire screen */
77 if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
81 svsp->scrr_len = svsp->screen_rows;
82 svsp->scrr_end = svsp->scrr_len - 1;
87 if(svsp->parms[1] <= svsp->parms[0])
92 if(svsp->parms[0] < 1)
94 else if(svsp->parms[0] > svsp->screen_rows-1)
95 svsp->parms[0] = svsp->screen_rows-1;
99 if(svsp->parms[1] < 2)
101 else if(svsp->parms[1] > svsp->screen_rows)
102 svsp->parms[1] = svsp->screen_rows;
104 svsp->scrr_beg = svsp->parms[0]-1; /* begin of scrolling region */
105 svsp->scrr_len = svsp->parms[1] - svsp->parms[0] + 1; /* no of lines */
106 svsp->scrr_end = svsp->parms[1]-1;
108 /* cursor to first pos */
110 svsp->cur_offset = svsp->scrr_beg * svsp->maxcol;
112 svsp->cur_offset = 0;
117 /*---------------------------------------------------------------------------*
118 * SGR - set graphic rendition
119 *---------------------------------------------------------------------------*/
121 vt_sgr(struct video_state *svsp)
124 u_short setcolor = 0;
125 char colortouched = 0;
129 switch(svsp->parms[i++])
131 case 0: /* reset to normal attributes */
132 svsp->vtsgr = VT_NORMAL;
136 svsp->vtsgr |= VT_BOLD;
139 case 4: /* underline */
140 svsp->vtsgr |= VT_UNDER;
143 case 5: /* blinking */
144 svsp->vtsgr |= VT_BLINK;
147 case 7: /* reverse */
148 svsp->vtsgr |= VT_INVERSE;
151 case 22: /* not bold */
152 svsp->vtsgr &= ~VT_BOLD;
155 case 24: /* not underlined */
156 svsp->vtsgr &= ~VT_UNDER;
159 case 25: /* not blinking */
160 svsp->vtsgr &= ~VT_BLINK;
163 case 27: /* not reverse */
164 svsp->vtsgr &= ~VT_INVERSE;
167 case 30: /* foreground colors */
178 setcolor |= ((fgansitopc[(svsp->parms[i-1]-30) & 7]) << 8);
182 case 40: /* background colors */
193 setcolor |= ((bgansitopc[(svsp->parms[i-1]-40) & 7]) << 8);
198 while(i <= svsp->parmi);
202 svsp->c_attr = setcolor;
204 svsp->c_attr = ((sgr_tab_color[svsp->vtsgr]) << 8);
208 if(adaptor_type == MDA_ADAPTOR)
209 svsp->c_attr = ((sgr_tab_imono[svsp->vtsgr]) << 8);
211 svsp->c_attr = ((sgr_tab_mono[svsp->vtsgr]) << 8);
215 /*---------------------------------------------------------------------------*
217 *---------------------------------------------------------------------------*/
219 vt_cuu(struct video_state *svsp)
221 int p = svsp->parms[0];
223 if (p <= 0) /* parameter min */
226 p = min(p, svsp->row - svsp->scrr_beg);
231 svsp->cur_offset -= (svsp->maxcol * p);
234 /*---------------------------------------------------------------------------*
236 *---------------------------------------------------------------------------*/
238 vt_cud(struct video_state *svsp)
240 int p = svsp->parms[0];
245 p = min(p, svsp->scrr_end - svsp->row);
250 svsp->cur_offset += (svsp->maxcol * p);
253 /*---------------------------------------------------------------------------*
254 * CUF - cursor forward
255 *---------------------------------------------------------------------------*/
257 vt_cuf(struct video_state *svsp)
259 int p = svsp->parms[0];
261 if(svsp->col == ((svsp->maxcol)-1)) /* already at right margin */
264 if(p <= 0) /* parameter min = 1 */
266 else if(p > ((svsp->maxcol)-1)) /* parameter max = 79 */
267 p = ((svsp->maxcol)-1);
269 if((svsp->col + p) > ((svsp->maxcol)-1))/* not more than right margin */
270 p = ((svsp->maxcol)-1) - svsp->col;
272 svsp->cur_offset += p;
276 /*---------------------------------------------------------------------------*
277 * CUB - cursor backward
278 *---------------------------------------------------------------------------*/
280 vt_cub(struct video_state *svsp)
282 int p = svsp->parms[0];
284 if(svsp->col == 0) /* already at left margin ? */
287 if(p <= 0) /* parameter min = 1 */
289 else if(p > ((svsp->maxcol)-1)) /* parameter max = 79 */
290 p = ((svsp->maxcol)-1);
292 if((svsp->col - p) <= 0) /* not more than left margin */
295 svsp->cur_offset -= p;
299 /*---------------------------------------------------------------------------*
300 * ED - erase in display
301 *---------------------------------------------------------------------------*/
303 vt_clreos(struct video_state *svsp)
305 switch(svsp->parms[0])
308 fillw(user_attr | ' ', svsp->Crtat + svsp->cur_offset,
310 (svsp->maxcol * svsp->screen_rows) -
311 (svsp->Crtat + svsp->cur_offset));
315 fillw(user_attr | ' ', svsp->Crtat,
316 svsp->Crtat + svsp->cur_offset -
321 fillw(user_attr | ' ', svsp->Crtat,
322 svsp->maxcol * svsp->screen_rows);
327 /*---------------------------------------------------------------------------*
329 *---------------------------------------------------------------------------*/
331 vt_clreol(struct video_state *svsp)
333 switch(svsp->parms[0])
336 fillw(user_attr | ' ',
337 svsp->Crtat + svsp->cur_offset,
338 svsp->maxcol-svsp->col);
342 fillw(user_attr | ' ',
343 svsp->Crtat + svsp->cur_offset - svsp->col,
348 fillw(user_attr | ' ',
349 svsp->Crtat + svsp->cur_offset - svsp->col,
355 /*---------------------------------------------------------------------------*
356 * CUP - cursor position / HVP - horizontal & vertical position
357 *---------------------------------------------------------------------------*/
359 vt_curadr(struct video_state *svsp)
361 if(svsp->m_om) /* relative to scrolling region */
363 if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
365 svsp->cur_offset = svsp->scrr_beg * svsp->maxcol;
371 if(svsp->parms[0] <= 0)
373 else if(svsp->parms[0] > svsp->scrr_len)
374 svsp->parms[0] = svsp->scrr_len;
376 if(svsp->parms[1] <= 0 )
378 if(svsp->parms[1] > svsp->maxcol)
379 svsp->parms[1] = svsp->maxcol;
381 svsp->cur_offset = (svsp->scrr_beg * svsp->maxcol) +
382 ((svsp->parms[0] - 1) * svsp->maxcol) +
384 svsp->col = svsp->parms[1] - 1;
387 else /* relative to screen start */
389 if((svsp->parms[0] == 0) && (svsp->parms[1] == 0))
391 svsp->cur_offset = 0;
397 if(svsp->parms[0] <= 0)
399 else if(svsp->parms[0] > svsp->screen_rows)
400 svsp->parms[0] = svsp->screen_rows;
402 if(svsp->parms[1] <= 0 )
404 if(svsp->parms[1] > svsp->maxcol) /* col */
405 svsp->parms[1] = svsp->maxcol;
407 svsp->cur_offset = (((svsp->parms[0]-1)*svsp->maxcol) +
409 svsp->col = svsp->parms[1]-1;
411 if (svsp->cur_offset >=
412 ((svsp->scrr_beg + svsp->scrr_len + 1) * svsp->maxcol))
420 /*---------------------------------------------------------------------------*
421 * RIS - reset to initial state (hard emulator runtime reset)
422 *---------------------------------------------------------------------------*/
424 vt_ris(struct video_state *svsp)
426 fillw(user_attr | ' ', svsp->Crtat, svsp->maxcol * svsp->screen_rows);
427 svsp->cur_offset = 0; /* cursor upper left corner */
430 svsp->lnm = 0; /* CR only */
431 clear_dld(svsp); /* clear download charset */
432 vt_clearudk(svsp); /* clear user defined keys */
433 svsp->selchar = 0; /* selective attribute off */
434 vt_str(svsp); /* and soft terminal reset */
437 /*---------------------------------------------------------------------------*
438 * DECSTR - soft terminal reset (SOFT emulator runtime reset)
439 *---------------------------------------------------------------------------*/
441 vt_str(struct video_state *svsp)
445 clr_parms(svsp); /* escape parameter init */
446 svsp->state = STATE_INIT; /* initial state */
448 svsp->dis_fnc = 0; /* display functions reset */
450 svsp->sc_flag = 0; /* save cursor position */
451 svsp->transparent = 0; /* enable control code processing */
453 for(i = 0; i < MAXTAB; i++) /* setup tabstops */
456 svsp->tab_stops[i] = 1;
458 svsp->tab_stops[i] = 0;
461 svsp->irm = 0; /* replace mode */
462 svsp->m_om = 0; /* origin mode */
463 svsp->m_awm = 1; /* auto wrap mode */
465 #if PCVT_INHIBIT_NUMLOCK
466 svsp->num_lock = 0; /* keypad application mode */
468 svsp->num_lock = 1; /* keypad numeric mode */
471 svsp->scroll_lock = 0; /* reset keyboard modes */
474 svsp->ckm = 1; /* cursor key mode = "normal" ... */
475 svsp->scrr_beg = 0; /* start of scrolling region */
476 svsp->scrr_len = svsp->screen_rows; /* no. of lines in scrolling region */
477 svsp->abs_write = 0; /* scrr is complete screen */
478 svsp->scrr_end = svsp->scrr_len - 1;
480 if(adaptor_type == EGA_ADAPTOR || adaptor_type == VGA_ADAPTOR)
482 svsp->G0 = cse_ascii; /* G0 = ascii */
483 svsp->G1 = cse_ascii; /* G1 = ascii */
484 svsp->G2 = cse_supplemental; /* G2 = supplemental */
485 svsp->G3 = cse_supplemental; /* G3 = supplemental */
486 svsp->GL = &svsp->G0; /* GL = G0 */
487 svsp->GR = &svsp->G2; /* GR = G2 */
491 svsp->G0 = csd_ascii; /* G0 = ascii */
492 svsp->G1 = csd_ascii; /* G1 = ascii */
493 svsp->G2 = csd_supplemental; /* G2 = supplemental */
494 svsp->G3 = csd_supplemental; /* G3 = supplemental */
495 svsp->GL = &svsp->G0; /* GL = G0 */
496 svsp->GR = &svsp->G2; /* GR = G2 */
499 svsp->vtsgr = VT_NORMAL; /* no attributes */
500 svsp->c_attr = user_attr; /* reset sgr to normal */
502 svsp->selchar = 0; /* selective attribute off */
505 init_ufkl(svsp); /* init user fkey labels */
506 init_sfkl(svsp); /* init system fkey labels */
508 update_led(); /* update keyboard LED's */
511 /*---------------------------------------------------------------------------*
512 * RI - reverse index, move cursor up
513 *---------------------------------------------------------------------------*/
515 vt_ri(struct video_state *svsp)
517 if(svsp->cur_offset >= ((svsp->scrr_beg * svsp->maxcol) + svsp->maxcol))
518 svsp->cur_offset -= svsp->maxcol;
523 /*---------------------------------------------------------------------------*
524 * IND - index, move cursor down
525 *---------------------------------------------------------------------------*/
527 vt_ind(struct video_state *svsp)
529 if(svsp->cur_offset < (svsp->scrr_end * svsp->maxcol))
530 svsp->cur_offset += svsp->maxcol;
535 /*---------------------------------------------------------------------------*
536 * NEL - next line, first pos of next line
537 *---------------------------------------------------------------------------*/
539 vt_nel(struct video_state *svsp)
541 if(svsp->cur_offset < (svsp->scrr_end * svsp->maxcol))
543 svsp->cur_offset += (svsp->maxcol-svsp->col);
549 svsp->cur_offset -= svsp->col;
554 /*---------------------------------------------------------------------------*
555 * set dec private modes, esc [ ? x h
556 *---------------------------------------------------------------------------*/
558 vt_set_dec_priv_qm(struct video_state *svsp)
560 switch(svsp->parms[0])
562 case 0: /* error, ignored */
563 case 1: /* CKM - cursor key mode */
567 case 2: /* ANM - ansi/vt52 mode */
570 case 3: /* COLM - column mode */
571 vt_col(svsp, SCR_COL132);
574 case 4: /* SCLM - scrolling mode */
575 case 5: /* SCNM - screen mode */
578 case 6: /* OM - origin mode */
582 case 7: /* AWM - auto wrap mode */
584 swritefkl(7,(u_char *)"AUTOWRAPENABLE *",svsp);
587 case 8: /* ARM - auto repeat mode */
591 case 9: /* INLM - interlace mode */
592 case 10: /* EDM - edit mode */
593 case 11: /* LTM - line transmit mode */
595 case 13: /* SCFDM - space compression / field delimiting */
596 case 14: /* TEM - transmit execution mode */
598 case 16: /* EKEM - edit key execution mode */
601 case 25: /* TCEM - text cursor enable mode */
603 sw_cursor(1); /* cursor on */
607 case 42: /* NRCM - 7bit NRC characters */
612 /*---------------------------------------------------------------------------*
613 * reset dec private modes, esc [ ? x l
614 *---------------------------------------------------------------------------*/
616 vt_reset_dec_priv_qm(struct video_state *svsp)
618 switch(svsp->parms[0])
620 case 0: /* error, ignored */
621 case 1: /* CKM - cursor key mode */
625 case 2: /* ANM - ansi/vt52 mode */
628 case 3: /* COLM - column mode */
629 vt_col(svsp, SCR_COL80);
632 case 4: /* SCLM - scrolling mode */
633 case 5: /* SCNM - screen mode */
636 case 6: /* OM - origin mode */
640 case 7: /* AWM - auto wrap mode */
642 swritefkl(7,(u_char *)"AUTOWRAPENABLE ",svsp);
645 case 8: /* ARM - auto repeat mode */
649 case 9: /* INLM - interlace mode */
650 case 10: /* EDM - edit mode */
651 case 11: /* LTM - line transmit mode */
653 case 13: /* SCFDM - space compression / field delimiting */
654 case 14: /* TEM - transmit execution mode */
656 case 16: /* EKEM - edit key execution mode */
659 case 25: /* TCEM - text cursor enable mode */
661 sw_cursor(0); /* cursor off */
665 case 42: /* NRCM - 7bit NRC characters */
670 /*---------------------------------------------------------------------------*
671 * set ansi modes, esc [ x
672 *---------------------------------------------------------------------------*/
674 vt_set_ansi(struct video_state *svsp)
676 switch(svsp->parms[0])
678 case 0: /* error, ignored */
679 case 1: /* GATM - guarded area transfer mode */
680 case 2: /* KAM - keyboard action mode */
681 case 3: /* CRM - Control Representation mode */
684 case 4: /* IRM - insert replacement mode */
685 svsp->irm = 1; /* Insert mode */
688 case 5: /* SRTM - status report transfer mode */
689 case 6: /* ERM - erasue mode */
690 case 7: /* VEM - vertical editing mode */
691 case 10: /* HEM - horizontal editing mode */
692 case 11: /* PUM - position unit mode */
693 case 12: /* SRM - send-receive mode */
694 case 13: /* FEAM - format effector action mode */
695 case 14: /* FETM - format effector transfer mode */
696 case 15: /* MATM - multiple area transfer mode */
697 case 16: /* TTM - transfer termination */
698 case 17: /* SATM - selected area transfer mode */
699 case 18: /* TSM - tabulation stop mode */
700 case 19: /* EBM - editing boundary mode */
703 case 20: /* LNM - line feed / newline mode */
709 /*---------------------------------------------------------------------------*
710 * reset ansi modes, esc [ x
711 *---------------------------------------------------------------------------*/
713 vt_reset_ansi(struct video_state *svsp)
715 switch(svsp->parms[0])
717 case 0: /* error, ignored */
718 case 1: /* GATM - guarded area transfer mode */
719 case 2: /* KAM - keyboard action mode */
720 case 3: /* CRM - Control Representation mode */
723 case 4: /* IRM - insert replacement mode */
724 svsp->irm = 0; /* Replace mode */
727 case 5: /* SRTM - status report transfer mode */
728 case 6: /* ERM - erasue mode */
729 case 7: /* VEM - vertical editing mode */
730 case 10: /* HEM - horizontal editing mode */
731 case 11: /* PUM - position unit mode */
732 case 12: /* SRM - send-receive mode */
733 case 13: /* FEAM - format effector action mode */
734 case 14: /* FETM - format effector transfer mode */
735 case 15: /* MATM - multiple area transfer mode */
736 case 16: /* TTM - transfer termination */
737 case 17: /* SATM - selected area transfer mode */
738 case 18: /* TSM - tabulation stop mode */
739 case 19: /* EBM - editing boundary mode */
742 case 20: /* LNM - line feed / newline mode */
748 /*---------------------------------------------------------------------------*
750 *---------------------------------------------------------------------------*/
752 vt_clrtab(struct video_state *svsp)
756 if(svsp->parms[0] == 0)
757 svsp->tab_stops[svsp->col] = 0;
758 else if(svsp->parms[0] == 3)
760 for(i=0; i<MAXTAB; i++)
761 svsp->tab_stops[i] = 0;
765 /*---------------------------------------------------------------------------*
766 * DECSC - save cursor & attributes
767 *---------------------------------------------------------------------------*/
769 vt_sc(struct video_state *svsp)
772 svsp->sc_row = svsp->row;
773 svsp->sc_col = svsp->col;
774 svsp->sc_cur_offset = svsp->cur_offset;
775 svsp->sc_attr = svsp->c_attr;
776 svsp->sc_awm = svsp->m_awm;
777 svsp->sc_om = svsp->m_om;
778 svsp->sc_G0 = svsp->G0;
779 svsp->sc_G1 = svsp->G1;
780 svsp->sc_G2 = svsp->G2;
781 svsp->sc_G3 = svsp->G3;
782 svsp->sc_GL = svsp->GL;
783 svsp->sc_GR = svsp->GR;
784 svsp->sc_sel = svsp->selchar;
785 svsp->sc_vtsgr = svsp->vtsgr;
788 /*---------------------------------------------------------------------------*
789 * DECRC - restore cursor & attributes
790 *---------------------------------------------------------------------------*/
792 vt_rc(struct video_state *svsp)
794 if(svsp->sc_flag == 1)
797 svsp->row = svsp->sc_row;
798 svsp->col = svsp->sc_col;
799 svsp->cur_offset = svsp->sc_cur_offset;
800 svsp->c_attr = svsp->sc_attr;
801 svsp->m_awm = svsp->sc_awm;
802 svsp->m_om = svsp->sc_om;
803 svsp->G0 = svsp->sc_G0;
804 svsp->G1 = svsp->sc_G1;
805 svsp->G2 = svsp->sc_G2;
806 svsp->G3 = svsp->sc_G3;
807 svsp->GL = svsp->sc_GL;
808 svsp->GR = svsp->sc_GR;
809 svsp->selchar = svsp->sc_sel;
810 svsp->vtsgr = svsp->sc_vtsgr;
814 /*---------------------------------------------------------------------------*
815 * designate a character set as G0, G1, G2 or G3 for 94/96 char sets
816 *---------------------------------------------------------------------------*/
818 vt_designate(struct video_state *svsp)
823 if(svsp->whichi == 1)
829 if(svsp->dld_id[0] == '\0')
832 if(!(((adaptor_type == EGA_ADAPTOR) ||
833 (adaptor_type == VGA_ADAPTOR)) &&
834 (vgacs[svsp->vga_charset].secondloaded)))
839 for(i = (svsp->whichi)-1; i >= 0; i--)
841 if(svsp->which[i] != svsp->dld_id[i])
844 #ifdef HAVECSE_DOWNLOADABLE
845 ctp = cse_downloadable;
851 if(((adaptor_type == EGA_ADAPTOR) || (adaptor_type == VGA_ADAPTOR)) &&
852 (vgacs[svsp->vga_charset].secondloaded))
854 if((ch == svsp->dld_id[0]) && (svsp->dld_id[1] == '\0'))
856 #ifdef HAVECSE_DOWNLOADABLE
857 ctp = cse_downloadable;
865 case 'A': /* British or ISO-Latin-1 */
868 case STATE_BROPN: /* designate G0 */
869 case STATE_BRCLO: /* designate G1 */
870 case STATE_STAR: /* designate G2 */
871 case STATE_PLUS: /* designate G3 */
872 #ifdef HAVECSE_BRITISH
877 case STATE_MINUS: /* designate G1 (96)*/
878 case STATE_DOT: /* designate G2 (96)*/
879 case STATE_SLASH: /* designate G3 (96)*/
880 #ifdef HAVECSE_ISOLATIN
887 case 'B': /* USASCII */
893 case 'C': /* Finnish */
894 case '5': /* Finnish */
895 #ifdef HAVECSE_FINNISH
900 case 'E': /* Norwegian/Danish */
901 case '6': /* Norwegian/Danish */
902 #ifdef HAVECSE_NORWEGIANDANISH
903 ctp = cse_norwegiandanish;
907 case 'H': /* Swedish */
908 case '7': /* Swedish */
909 #ifdef HAVECSE_SWEDISH
914 case 'K': /* German */
915 #ifdef HAVECSE_GERMAN
920 case 'Q': /* French Canadien */
921 #ifdef HAVECSE_FRENCHCANADA
922 ctp = cse_frenchcanada;
926 case 'R': /* French */
927 #ifdef HAVECSE_FRENCH
932 case 'Y': /* Italian */
933 #ifdef HAVECSE_ITALIAN
938 case 'Z': /* Spanish */
939 #ifdef HAVECSE_SPANISH
944 case '0': /* special graphics */
945 #ifdef HAVECSE_SPECIAL
950 case '1': /* alternate ROM */
951 #ifdef HAVECSE_ALTERNATEROM1
952 ctp = cse_alternaterom1;
956 case '2': /* alt ROM, spec graphics */
957 #ifdef HAVECSE_ALTERNATEROM2
958 ctp = cse_alternaterom2;
962 case '3': /* HP Roman 8, upper 128 chars*/
963 #ifdef HAVECSE_ROMAN8
968 case '4': /* Dutch */
974 case '<': /* DEC Supplemental */
975 #ifdef HAVECSE_SUPPLEMENTAL
976 ctp = cse_supplemental;
980 case '=': /* Swiss */
986 case '>': /* DEC Technical */
987 #ifdef HAVECSE_TECHNICAL
1000 case 'A': /* British or ISO-Latin-1 */
1003 case STATE_BROPN: /* designate G0 */
1004 case STATE_BRCLO: /* designate G1 */
1005 case STATE_STAR: /* designate G2 */
1006 case STATE_PLUS: /* designate G3 */
1007 #ifdef HAVECSD_BRITISH
1012 case STATE_MINUS: /* designate G1 (96)*/
1013 case STATE_DOT: /* designate G2 (96)*/
1014 case STATE_SLASH: /* designate G3 (96)*/
1015 #ifdef HAVECSD_ISOLATIN
1022 case 'B': /* USASCII */
1023 #ifdef HAVECSD_ASCII
1028 case 'C': /* Finnish */
1029 case '5': /* Finnish */
1030 #ifdef HAVECSD_FINNISH
1035 case 'E': /* Norwegian/Danish */
1036 case '6': /* Norwegian/Danish */
1037 #ifdef HAVECSD_NORWEGIANDANISH
1038 ctp = csd_norwegiandanish;
1042 case 'H': /* Swedish */
1043 case '7': /* Swedish */
1044 #ifdef HAVECSD_SWEDISH
1049 case 'K': /* German */
1050 #ifdef HAVECSD_GERMAN
1055 case 'Q': /* French Canadien */
1056 #ifdef HAVECSD_FRENCHCANADA
1057 ctp = csd_frenchcanada;
1061 case 'R': /* French */
1062 #ifdef HAVECSD_FRENCH
1067 case 'Y': /* Italian */
1068 #ifdef HAVECSD_ITALIAN
1073 case 'Z': /* Spanish */
1074 #ifdef HAVECSD_SPANISH
1079 case '0': /* special graphics */
1080 #ifdef HAVECSD_SPECIAL
1085 case '1': /* alternate ROM */
1086 #ifdef HAVECSD_ALTERNATEROM1
1087 ctp = csd_alternaterom1;
1091 case '2': /* alt ROM, spec graphics */
1092 #ifdef HAVECSD_ALTERNATEROM2
1093 ctp = csd_alternaterom2;
1097 case '3': /* HP Roman 8, upper 128 chars*/
1098 #ifdef HAVECSD_ROMAN8
1103 case '4': /* Dutch */
1104 #ifdef HAVECSD_DUTCH
1109 case '<': /* DEC Supplemental */
1110 #ifdef HAVECSD_SUPPLEMENTAL
1111 ctp = csd_supplemental;
1115 case '=': /* Swiss */
1116 #ifdef HAVECSD_SWISS
1121 case '>': /* DEC Technical */
1122 #ifdef HAVECSD_TECHNICAL
1123 ctp = csd_technical;
1134 /*---------------------------------------------------------------------------*
1136 *---------------------------------------------------------------------------*/
1138 vt_da(struct video_state *svsp)
1140 static u_char *response = (u_char *)DA_VT220;
1142 svsp->report_chars = response;
1143 svsp->report_count = 18;
1147 /*---------------------------------------------------------------------------*
1148 * screen alignment display
1149 *---------------------------------------------------------------------------*/
1151 vt_aln(struct video_state *svsp)
1155 svsp->cur_offset = 0;
1158 for(i=0; i < (svsp->screen_rows*svsp->maxcol); i++)
1160 *(svsp->Crtat + svsp->cur_offset) = user_attr | 'E';
1166 svsp->cur_offset = 0; /* reset everything ! */
1171 /*---------------------------------------------------------------------------*
1172 * request terminal parameters
1173 *---------------------------------------------------------------------------*/
1175 vt_reqtparm(struct video_state *svsp)
1177 static u_char *answr = (u_char *)"\033[3;1;1;120;120;1;0x";
1179 svsp->report_chars = answr;
1180 svsp->report_count = 20;
1184 /*---------------------------------------------------------------------------*
1186 *---------------------------------------------------------------------------*/
1188 vt_tst(struct video_state *svsp)
1193 /*---------------------------------------------------------------------------*
1194 * device status reports
1195 *---------------------------------------------------------------------------*/
1197 vt_dsr(struct video_state *svsp)
1199 static u_char *answr = (u_char *)"\033[0n";
1200 static u_char *panswr = (u_char *)"\033[?13n"; /* Printer Unattached */
1201 static u_char *udkanswr = (u_char *)"\033[?21n"; /* UDK Locked */
1202 static u_char *langanswr = (u_char *)"\033[?27;1n"; /* North American*/
1203 static u_char buffer[16];
1206 switch(svsp->parms[0])
1208 case 5: /* return status */
1209 svsp->report_chars = answr;
1210 svsp->report_count = 4;
1214 case 6: /* return cursor position */
1217 if((svsp->row+1) > 10)
1218 buffer[i++] = ((svsp->row+1) / 10) + '0';
1219 buffer[i++] = ((svsp->row+1) % 10) + '0';
1221 if((svsp->col+1) > 10)
1222 buffer[i++] = ((svsp->col+1) / 10) + '0';
1223 buffer[i++] = ((svsp->col+1) % 10) + '0';
1227 svsp->report_chars = buffer;
1228 svsp->report_count = i;
1232 case 15: /* return printer status */
1233 svsp->report_chars = panswr;
1234 svsp->report_count = 6;
1238 case 25: /* return udk status */
1239 svsp->report_chars = udkanswr;
1240 svsp->report_count = 6;
1244 case 26: /* return language status */
1245 svsp->report_chars = langanswr;
1246 svsp->report_count = 8;
1250 default: /* nothing else valid */
1255 /*---------------------------------------------------------------------------*
1257 *---------------------------------------------------------------------------*/
1259 vt_il(struct video_state *svsp)
1261 int p = svsp->parms[0];
1263 if((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end))
1267 else if(p > svsp->scrr_end - svsp->row)
1268 p = svsp->scrr_end - svsp->row;
1270 svsp->cur_offset -= svsp->col;
1272 if(svsp->row == svsp->scrr_beg)
1276 bcopy(svsp->Crtat + svsp->cur_offset,
1277 svsp->Crtat + svsp->cur_offset + (p * svsp->maxcol),
1278 svsp->maxcol * (svsp->scrr_end-svsp->row+1-p) * CHR );
1280 fillw(user_attr | ' ',
1281 svsp->Crtat + svsp->cur_offset,
1287 /*---------------------------------------------------------------------------*
1288 * ICH - insert character
1289 *---------------------------------------------------------------------------*/
1291 vt_ic(struct video_state *svsp)
1293 int p = svsp->parms[0];
1297 else if(p > svsp->maxcol-svsp->col)
1298 p = svsp->maxcol-svsp->col;
1302 bcopy((svsp->Crtat + svsp->cur_offset),
1303 (svsp->Crtat + svsp->cur_offset) + 1,
1304 (((svsp->maxcol)-1)-svsp->col) * CHR);
1306 *(svsp->Crtat + svsp->cur_offset) = user_attr | ' ';
1311 /*---------------------------------------------------------------------------*
1313 *---------------------------------------------------------------------------*/
1315 vt_dl(struct video_state *svsp)
1317 int p = svsp->parms[0];
1319 if((svsp->row >= svsp->scrr_beg) && (svsp->row <= svsp->scrr_end))
1323 else if(p > svsp->scrr_end - svsp->row)
1324 p = svsp->scrr_end - svsp->row;
1326 svsp->cur_offset -= svsp->col;
1329 if(svsp->row == svsp->scrr_beg)
1333 bcopy(svsp->Crtat + svsp->cur_offset + (p * svsp->maxcol),
1334 svsp->Crtat + svsp->cur_offset,
1335 svsp->maxcol * (svsp->scrr_end-svsp->row+1-p) * CHR );
1337 fillw(user_attr | ' ',
1338 svsp->Crtat + ((svsp->scrr_end-p+1) * svsp->maxcol),
1344 /*---------------------------------------------------------------------------*
1345 * DCH - delete character
1346 *---------------------------------------------------------------------------*/
1348 vt_dch(struct video_state *svsp)
1350 int p = svsp->parms[0];
1354 else if(p > svsp->maxcol-svsp->col)
1355 p = svsp->maxcol-svsp->col;
1359 bcopy((svsp->Crtat + svsp->cur_offset)+1,
1360 (svsp->Crtat + svsp->cur_offset),
1361 (((svsp->maxcol)-1) - svsp->col)* CHR );
1363 *((svsp->Crtat + svsp->cur_offset) +
1364 ((svsp->maxcol)-1)-svsp->col) = user_attr | ' ';
1368 /*---------------------------------------------------------------------------*
1370 *---------------------------------------------------------------------------*/
1372 vt_su(struct video_state *svsp)
1374 int p = svsp->parms[0];
1378 else if(p > svsp->screen_rows-1)
1379 p = svsp->screen_rows-1;
1384 /*---------------------------------------------------------------------------*
1386 *---------------------------------------------------------------------------*/
1388 vt_sd(struct video_state *svsp)
1390 int p = svsp->parms[0];
1394 else if(p > svsp->screen_rows-1)
1395 p = svsp->screen_rows-1;
1400 /*---------------------------------------------------------------------------*
1401 * ECH - erase character
1402 *---------------------------------------------------------------------------*/
1404 vt_ech(struct video_state *svsp)
1406 int p = svsp->parms[0];
1410 else if(p > svsp->maxcol-svsp->col)
1411 p = svsp->maxcol-svsp->col;
1413 fillw(user_attr | ' ', (svsp->Crtat + svsp->cur_offset), p);
1416 /*---------------------------------------------------------------------------*
1417 * media copy (NO PRINTER AVAILABLE IN KERNEL ...)
1418 *---------------------------------------------------------------------------*/
1420 vt_mc(struct video_state *svsp)
1424 /*---------------------------------------------------------------------------*
1425 * Device Control String State Machine Entry for:
1427 * DECUDK - user-defined keys and
1428 * DECDLD - downloadable charset
1430 *---------------------------------------------------------------------------*/
1432 vt_dcsentry(U_char ch, struct video_state *svsp)
1434 switch(svsp->dcs_state)
1448 case '9': /* parameters */
1449 svsp->parms[svsp->parmi] *= 10;
1450 svsp->parms[svsp->parmi] += (ch -'0');
1453 case ';': /* next parameter */
1455 (svsp->parmi+1 < MAXPARMS) ?
1456 svsp->parmi+1 : svsp->parmi;
1459 case '|': /* DECUDK */
1460 svsp->transparent = 1;
1462 svsp->dcs_state = DCS_AND_UDK;
1465 case '{': /* DECDLD */
1466 svsp->transparent = 1;
1468 svsp->dcs_state = DCS_DLD_DSCS;
1471 default: /* failsafe */
1472 svsp->transparent = 0;
1473 svsp->state = STATE_INIT;
1474 svsp->dcs_state = DCS_INIT;
1479 case DCS_AND_UDK: /* DCS ... | */
1491 case '9': /* fkey number */
1492 svsp->udk_fnckey *= 10;
1493 svsp->udk_fnckey += (ch -'0');
1497 svsp->dcs_state = DCS_UDK_DEF;
1500 case 0x1b: /* ESC */
1501 svsp->dcs_state = DCS_UDK_ESC;
1505 svsp->transparent = 0;
1506 svsp->state = STATE_INIT;
1507 svsp->dcs_state = DCS_INIT;
1512 case DCS_UDK_DEF: /* DCS ... | fnckey / */
1525 if(svsp->udk_deflow) /* low nibble */
1527 svsp->udk_def[svsp->udk_defi] |= (ch -'0');
1528 svsp->udk_deflow = 0;
1529 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
1530 svsp->udk_defi : svsp->udk_defi+1;
1532 else /* high nibble */
1534 svsp->udk_def[svsp->udk_defi] = ((ch -'0') << 4);
1535 svsp->udk_deflow = 1;
1545 if(svsp->udk_deflow) /* low nibble */
1547 svsp->udk_def[svsp->udk_defi] |= (ch - 'a' + 10);
1548 svsp->udk_deflow = 0;
1549 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
1550 svsp->udk_defi : svsp->udk_defi+1;
1552 else /* high nibble */
1554 svsp->udk_def[svsp->udk_defi] = ((ch - 'a' + 10) << 4);
1555 svsp->udk_deflow = 1;
1567 if(svsp->udk_deflow) /* low nibble */
1569 svsp->udk_def[svsp->udk_defi] |= (ch - 'A' + 10);
1570 svsp->udk_deflow = 0;
1571 svsp->udk_defi = (svsp->udk_defi+1 >= MAXUDKDEF) ?
1572 svsp->udk_defi : svsp->udk_defi+1;
1574 else /* high nibble */
1576 svsp->udk_def[svsp->udk_defi] = ((ch - 'A' + 10) << 4);
1577 svsp->udk_deflow = 1;
1581 case ';': /* next function key */
1583 svsp->dcs_state = DCS_AND_UDK;
1586 case 0x1b: /* ESC */
1587 svsp->dcs_state = DCS_UDK_ESC;
1591 svsp->transparent = 0;
1592 svsp->state = STATE_INIT;
1593 svsp->dcs_state = DCS_INIT;
1598 case DCS_UDK_ESC: /* DCS ... | fkey/def ... ESC */
1603 svsp->transparent = 0;
1604 svsp->state = STATE_INIT;
1605 svsp->dcs_state = DCS_INIT;
1609 svsp->transparent = 0;
1610 svsp->state = STATE_INIT;
1611 svsp->dcs_state = DCS_INIT;
1617 case DCS_DLD_DSCS: /* got DCS ... { */
1618 if(ch >= ' ' && ch <= '/') /* intermediates ... */
1620 svsp->dld_dscs[svsp->dld_dscsi] = ch;
1621 svsp->dld_id[svsp->dld_dscsi] = ch;
1622 if(svsp->dld_dscsi >= DSCS_LENGTH)
1624 svsp->transparent = 0;
1625 svsp->state = STATE_INIT;
1626 svsp->dcs_state = DCS_INIT;
1627 svsp->dld_id[0] = '\0';
1634 else if(ch >= '0' && ch <= '~') /* final .... */
1636 svsp->dld_dscs[svsp->dld_dscsi] = ch;
1637 svsp->dld_id[svsp->dld_dscsi++] = ch;
1638 svsp->dld_id[svsp->dld_dscsi] = '\0';
1639 svsp->dcs_state = DCS_DLD_DEF;
1643 svsp->transparent = 0;
1644 svsp->state = STATE_INIT;
1645 svsp->dcs_state = DCS_INIT;
1646 svsp->dld_id[0] = '\0';
1650 case DCS_DLD_DEF: /* DCS ... { dscs */
1653 case 0x1b: /* ESC */
1654 svsp->dcs_state = DCS_DLD_ESC;
1657 case '/': /* sixel upper / lower divider */
1658 svsp->dld_sixel_lower = 1;
1661 case ';': /* character divider */
1663 svsp->parms[1]++; /* next char */
1667 if (svsp->dld_sixel_lower)
1669 if(ch >= '?' && ch <= '~')
1670 svsp->sixel.lower[svsp->dld_sixelli] = ch - '?';
1672 (svsp->dld_sixelli+1 < MAXSIXEL) ?
1673 svsp->dld_sixelli+1 : svsp->dld_sixelli;
1677 if(ch >= '?' && ch <= '~')
1678 svsp->sixel.upper[svsp->dld_sixelui] = ch - '?';
1680 (svsp->dld_sixelui+1 < MAXSIXEL) ?
1681 svsp->dld_sixelui+1 : svsp->dld_sixelui;
1687 case DCS_DLD_ESC: /* DCS ... { dscs ... / ... ESC */
1690 case '\\': /* String Terminator ST */
1692 svsp->transparent = 0;
1693 svsp->state = STATE_INIT;
1694 svsp->dcs_state = DCS_INIT;
1698 svsp->transparent = 0;
1699 svsp->state = STATE_INIT;
1700 svsp->dcs_state = DCS_INIT;
1701 svsp->dld_id[0] = '\0';
1707 svsp->transparent = 0;
1708 svsp->state = STATE_INIT;
1709 svsp->dcs_state = DCS_INIT;
1714 /*---------------------------------------------------------------------------*
1715 * User Defineable Keys
1716 *---------------------------------------------------------------------------*/
1718 vt_udk(struct video_state *svsp)
1720 int key, start, max, i;
1723 if(svsp->parms[0] != 1) /* clear all ? */
1729 if(svsp->udk_fnckey < 17 || svsp->udk_fnckey > 34)
1735 key = svsp->udk_fnckey - 17; /* index into table */
1737 if(svsp->ukt.length[key] == 0) /* never used ? */
1739 if(svsp->udkff < MAXUDKDEF-2) /* space available ? */
1741 start = svsp->udkff; /* next sequential */
1742 max = MAXUDKDEF - svsp->udkff; /* space available */
1743 svsp->ukt.first[key] = start; /* start entry */
1744 usedff = 1; /* flag to update later */
1752 else /* in use, redefine */
1754 start = svsp->ukt.first[key]; /* start entry */
1755 max = svsp->ukt.length[key]; /* space available */
1758 if(max < 2) /* hmmm .. */
1764 max--; /* adjust for tailing '\0' */
1766 for(i = 0; i < max && i < svsp->udk_defi; i++)
1767 svsp->udkbuf[start++] = svsp->udk_def[i];
1769 svsp->udkbuf[start] = '\0'; /* make it a string, see pcvt_kbd.c */
1770 svsp->ukt.length[key] = i+1; /* count for tailing '\0' */
1772 svsp->udkff += (i+2); /* new start location */
1777 /*---------------------------------------------------------------------------*
1778 * clear all User Defineable Keys
1779 *---------------------------------------------------------------------------*/
1781 vt_clearudk(struct video_state *svsp)
1785 for(i = 0; i < MAXUDKEYS; i++)
1787 svsp->ukt.first[i] = 0;
1788 svsp->ukt.length[i] = 0;
1793 /*---------------------------------------------------------------------------*
1794 * Down line LoaDable Fonts
1795 *---------------------------------------------------------------------------*/
1797 vt_dld(struct video_state *svsp)
1799 unsigned char vgacharset;
1800 unsigned char vgachar[16];
1801 unsigned char vgacharb[16];
1803 if(vgacs[svsp->vga_charset].secondloaded)
1804 vgacharset = vgacs[svsp->vga_charset].secondloaded;
1808 svsp->parms[1] = (svsp->parms[1] < 1) ? 1 :
1809 ((svsp->parms[1] > 0x7E) ? 0x7E : svsp->parms[1]);
1811 if(svsp->parms[2] != 1) /* Erase all characters ? */
1814 svsp->parms[2] = 1; /* Only erase all characters once per sequence */
1817 sixel_vga(&(svsp->sixel),vgachar);
1819 switch(vgacs[vgacharset].char_scanlines & 0x1F)
1822 vga10_vga8(vgachar,vgacharb);
1827 vga10_vga10(vgachar,vgacharb);
1831 vga10_vga14(vgachar,vgacharb);
1835 vga10_vga16(vgachar,vgacharb);
1839 loadchar(vgacharset, svsp->parms[1] + 0xA0, 16, vgacharb);
1844 /*---------------------------------------------------------------------------*
1845 * select character attributes
1846 *---------------------------------------------------------------------------*/
1848 vt_sca(struct video_state *svsp)
1850 switch(svsp->parms[0])
1863 /*---------------------------------------------------------------------------*
1864 * initalize selective attribute bit array
1865 *---------------------------------------------------------------------------*/
1867 vt_initsel(struct video_state *svsp)
1871 for(i = 0;i < MAXDECSCA;i++)
1872 svsp->decsca[i] = 0;
1875 /*---------------------------------------------------------------------------*
1876 * DECSEL - selective erase in line
1877 *---------------------------------------------------------------------------*/
1879 vt_sel(struct video_state *svsp)
1881 switch(svsp->parms[0])
1884 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset),
1885 svsp->maxcol-svsp->col);
1889 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)-
1890 svsp->col, svsp->col + 1);
1894 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset)-
1895 svsp->col, svsp->maxcol);
1900 /*---------------------------------------------------------------------------*
1901 * DECSED - selective erase in display
1902 *---------------------------------------------------------------------------*/
1904 vt_sed(struct video_state *svsp)
1906 switch(svsp->parms[0])
1909 selective_erase(svsp, (svsp->Crtat + svsp->cur_offset),
1910 svsp->Crtat + (svsp->maxcol * svsp->screen_rows) -
1911 (svsp->Crtat + svsp->cur_offset));
1915 selective_erase(svsp, svsp->Crtat,
1916 (svsp->Crtat + svsp->cur_offset) - svsp->Crtat + 1 );
1920 selective_erase(svsp, svsp->Crtat,
1921 svsp->maxcol * svsp->screen_rows);
1926 /*---------------------------------------------------------------------------*
1927 * scroll screen n lines up
1928 *---------------------------------------------------------------------------*/
1930 roll_up(struct video_state *svsp, int n)
1933 #if (PCVT_NOFASTSCROLL==0)
1935 if(svsp->scrr_beg == 0 && /* if scroll region is whole screen */
1936 svsp->scrr_len == svsp->screen_rows &&
1937 (svsp != vsp || /* and either running in memory */
1938 (svsp->screen_rows == svsp->screen_rowsize && /* or no fkeys */
1939 adaptor_type != MDA_ADAPTOR))) /* and not on MDA/Hercules */
1943 #if PCVT_USL_VT_COMPAT
1944 (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ?
1949 svsp->Memory : Crtat;
1951 if(svsp->Crtat > (Memory + (svsp->screen_rows - n) *
1954 bcopy(svsp->Crtat + svsp->maxcol * n, Memory,
1955 svsp->maxcol * (svsp->screen_rows - n) * CHR);
1957 svsp->Crtat = Memory;
1961 svsp->Crtat += n * svsp->maxcol;
1964 #if PCVT_USL_VT_COMPAT
1965 if(vsp == svsp && !(vsp->vt_status & VT_GRAFX))
1971 outb(addr_6845, CRTC_STARTADRH);
1972 outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8);
1973 outb(addr_6845, CRTC_STARTADRL);
1974 outb(addr_6845+1, (svsp->Crtat - Crtat));
1980 bcopy( svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol),
1981 svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
1982 svsp->maxcol * (svsp->scrr_len - n) * CHR );
1985 fillw( user_attr | ' ',
1986 svsp->Crtat + ((svsp->scrr_end - n + 1) * svsp->maxcol),
1989 /*XXX*/ if(svsp->scroll_lock && svsp->openf && curproc)
1990 tsleep((caddr_t)&(svsp->scroll_lock), 0, "scrlck", 0);
1993 /*---------------------------------------------------------------------------*
1994 * scroll screen n lines down
1995 *---------------------------------------------------------------------------*/
1997 roll_down(struct video_state *svsp, int n)
2000 #if (PCVT_NOFASTSCROLL==0)
2002 if(svsp->scrr_beg == 0 && /* if scroll region is whole screen */
2003 svsp->scrr_len == svsp->screen_rows &&
2004 (svsp != vsp || /* and either running in memory */
2005 (svsp->screen_rows == svsp->screen_rowsize && /* or no fkeys */
2006 adaptor_type != MDA_ADAPTOR))) /* and not on MDA/Hercules */
2010 #if PCVT_USL_VT_COMPAT
2011 (vsp != svsp || (vsp->vt_status & VT_GRAFX)) ?
2015 svsp->Memory : Crtat;
2017 if (svsp->Crtat < (Memory + n * svsp->maxcol))
2020 Memory + svsp->maxcol * (svsp->screen_rows + n),
2021 svsp->maxcol * (svsp->screen_rows - n) * CHR);
2023 svsp->Crtat = Memory + svsp->maxcol * svsp->screen_rows;
2027 svsp->Crtat -= n * svsp->maxcol;
2030 #if PCVT_USL_VT_COMPAT
2031 if(vsp == svsp && !(vsp->vt_status & VT_GRAFX))
2037 outb(addr_6845, CRTC_STARTADRH);
2038 outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8);
2039 outb(addr_6845, CRTC_STARTADRL);
2040 outb(addr_6845+1, (svsp->Crtat - Crtat));
2046 bcopy( svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
2047 svsp->Crtat + ((svsp->scrr_beg + n) * svsp->maxcol),
2048 svsp->maxcol * (svsp->scrr_len - n) * CHR );
2051 fillw( user_attr | ' ',
2052 svsp->Crtat + (svsp->scrr_beg * svsp->maxcol),
2055 /*XXX*/ if(svsp->scroll_lock && svsp->openf && curproc)
2056 tsleep((caddr_t)&(svsp->scroll_lock), 0, "scrlck", 0);
2059 /*---------------------------------------------------------------------------*
2060 * switch charset pointers
2061 *---------------------------------------------------------------------------*/
2063 swcsp(struct video_state *svsp, u_short *ctp)
2070 case STATE_BROPN: /* designate G0 */
2074 case STATE_BRCLO: /* designate G1 */
2075 case STATE_MINUS: /* designate G1 (96) */
2079 case STATE_STAR: /* designate G2 */
2080 case STATE_DOT: /* designate G2 (96) */
2084 case STATE_PLUS: /* designate G3 */
2085 case STATE_SLASH: /* designate G3 (96) */
2091 /*---------------------------------------------------------------------------*
2092 * process terminal responses
2093 *---------------------------------------------------------------------------*/
2095 respond(struct video_state *svsp)
2097 if(!(svsp->openf)) /* are we opened ? */
2100 while (*svsp->report_chars && svsp->report_count > 0)
2102 (*linesw[svsp->vs_tty->t_line].l_rint)
2103 (*svsp->report_chars++ & 0xff, svsp->vs_tty);
2104 svsp->report_count--;
2108 /*---------------------------------------------------------------------------*
2109 * Initialization for User Defineable Keys
2110 *---------------------------------------------------------------------------*/
2112 init_udk(struct video_state *svsp)
2115 svsp->udk_deflow = 0;
2116 svsp->udk_fnckey = 0;
2119 /*---------------------------------------------------------------------------*
2120 * Clear loaded downloadable (DLD) character set
2121 *---------------------------------------------------------------------------*/
2123 clear_dld(struct video_state *svsp)
2126 unsigned char vgacharset;
2127 unsigned char vgachar[16];
2129 if(vgacs[svsp->vga_charset].secondloaded)
2130 vgacharset = vgacs[svsp->vga_charset].secondloaded;
2134 for(i=0;i < 16;i++) /* A zeroed character, vt220 has inverted '?' */
2137 for(i=1;i <= 94;i++) /* Load (erase) all characters */
2138 loadchar(vgacharset, i + 0xA0, 16, vgachar);
2141 /*---------------------------------------------------------------------------*
2142 * Initialization for Down line LoaDable Fonts
2143 *---------------------------------------------------------------------------*/
2145 init_dld(struct video_state *svsp)
2149 svsp->dld_dscsi = 0;
2150 svsp->dld_sixel_lower = 0;
2151 svsp->dld_sixelli = 0;
2152 svsp->dld_sixelui = 0;
2154 for(i = 0;i < MAXSIXEL;i++)
2155 svsp->sixel.lower[i] = svsp->sixel.upper[i] = 0;
2158 /*---------------------------------------------------------------------------*
2159 * selective erase a region
2160 *---------------------------------------------------------------------------*/
2162 selective_erase(struct video_state *svsp, u_short *pcrtat, int length)
2166 for(j = pcrtat - svsp->Crtat, i = 0;i < length;i++,pcrtat++)
2168 if(!(svsp->decsca[INT_INDEX(j+i)] & (1 << BIT_INDEX(j+i))))
2170 *pcrtat &= 0xFF00; /* Keep the video character attributes */
2171 *pcrtat += ' '; /* Erase the character */
2176 #endif /* NVT > 0 */
2178 /* ------------------------- E O F ------------------------------------------*/