Home | History | Annotate | Line # | Download | only in dev
ite_tv.c revision 1.8.4.2
      1  1.8.4.2  nathanw /*	$NetBSD: ite_tv.c,v 1.8.4.2 2002/01/08 00:28:40 nathanw Exp $	*/
      2  1.8.4.2  nathanw 
      3  1.8.4.2  nathanw /*
      4  1.8.4.2  nathanw  * Copyright (c) 1997 Masaru Oki.
      5  1.8.4.2  nathanw  * All rights reserved.
      6  1.8.4.2  nathanw  *
      7  1.8.4.2  nathanw  * Redistribution and use in source and binary forms, with or without
      8  1.8.4.2  nathanw  * modification, are permitted provided that the following conditions
      9  1.8.4.2  nathanw  * are met:
     10  1.8.4.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     11  1.8.4.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     12  1.8.4.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.8.4.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     14  1.8.4.2  nathanw  *    documentation and/or other materials provided with the distribution.
     15  1.8.4.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     16  1.8.4.2  nathanw  *    must display the following acknowledgement:
     17  1.8.4.2  nathanw  *      This product includes software developed by Masaru Oki.
     18  1.8.4.2  nathanw  * 4. The name of the author may not be used to endorse or promote products
     19  1.8.4.2  nathanw  *    derived from this software without specific prior written permission
     20  1.8.4.2  nathanw  *
     21  1.8.4.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.8.4.2  nathanw  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.8.4.2  nathanw  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.8.4.2  nathanw  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.8.4.2  nathanw  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.8.4.2  nathanw  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.8.4.2  nathanw  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.8.4.2  nathanw  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.8.4.2  nathanw  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.8.4.2  nathanw  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.8.4.2  nathanw  */
     32  1.8.4.2  nathanw 
     33  1.8.4.2  nathanw #include <sys/param.h>
     34  1.8.4.2  nathanw #include <sys/device.h>
     35  1.8.4.2  nathanw #include <sys/proc.h>
     36  1.8.4.2  nathanw #include <sys/systm.h>
     37  1.8.4.2  nathanw 
     38  1.8.4.2  nathanw #include <machine/bus.h>
     39  1.8.4.2  nathanw #include <machine/grfioctl.h>
     40  1.8.4.2  nathanw 
     41  1.8.4.2  nathanw #include <arch/x68k/x68k/iodevice.h>
     42  1.8.4.2  nathanw #include <arch/x68k/dev/itevar.h>
     43  1.8.4.2  nathanw #include <arch/x68k/dev/grfvar.h>
     44  1.8.4.2  nathanw #include <arch/x68k/dev/mfp.h>
     45  1.8.4.2  nathanw 
     46  1.8.4.2  nathanw /*
     47  1.8.4.2  nathanw  * ITE device dependent routine for X680x0 Text-Video framebuffer.
     48  1.8.4.2  nathanw  * Use X680x0 ROM fixed width font (8x16)
     49  1.8.4.2  nathanw  */
     50  1.8.4.2  nathanw 
     51  1.8.4.2  nathanw #define CRTC    (IODEVbase->io_crtc)
     52  1.8.4.2  nathanw 
     53  1.8.4.2  nathanw /*
     54  1.8.4.2  nathanw  * font constant
     55  1.8.4.2  nathanw  */
     56  1.8.4.2  nathanw #define FONTWIDTH   8
     57  1.8.4.2  nathanw #define FONTHEIGHT  16
     58  1.8.4.2  nathanw #define UNDERLINE   14
     59  1.8.4.2  nathanw 
     60  1.8.4.2  nathanw /*
     61  1.8.4.2  nathanw  * framebuffer constant
     62  1.8.4.2  nathanw  */
     63  1.8.4.2  nathanw #define PLANEWIDTH  1024
     64  1.8.4.2  nathanw #define PLANEHEIGHT 1024
     65  1.8.4.2  nathanw #define PLANELINES  (PLANEHEIGHT / FONTHEIGHT)
     66  1.8.4.2  nathanw #define ROWBYTES    (PLANEWIDTH  / FONTWIDTH)
     67  1.8.4.2  nathanw #define PLANESIZE   (PLANEHEIGHT * ROWBYTES)
     68  1.8.4.2  nathanw 
     69  1.8.4.2  nathanw u_int  tv_top;
     70  1.8.4.2  nathanw u_char *tv_row[PLANELINES];
     71  1.8.4.2  nathanw char   *tv_font[256];
     72  1.8.4.2  nathanw __volatile char *tv_kfont[0x7f];
     73  1.8.4.2  nathanw 
     74  1.8.4.2  nathanw u_char kern_font[256 * FONTHEIGHT];
     75  1.8.4.2  nathanw 
     76  1.8.4.2  nathanw #define PHYSLINE(y)  ((tv_top + (y)) % PLANELINES)
     77  1.8.4.2  nathanw #define ROWOFFSET(y) ((y) * FONTHEIGHT * ROWBYTES)
     78  1.8.4.2  nathanw #define CHADDR(y, x) (tv_row[PHYSLINE(y)] + (x))
     79  1.8.4.2  nathanw 
     80  1.8.4.2  nathanw #define SETGLYPH(to,from) memcpy(&kern_font[(from)*16],&kern_font[(to)*16], 16)
     81  1.8.4.2  nathanw #define KFONTBASE(left)   ((left) * 32 * 0x5e - 0x21 * 32)
     82  1.8.4.2  nathanw 
     83  1.8.4.2  nathanw /* prototype */
     84  1.8.4.2  nathanw void tv_init	__P((struct ite_softc *));
     85  1.8.4.2  nathanw void tv_deinit	__P((struct ite_softc *));
     86  1.8.4.2  nathanw void tv_putc	__P((struct ite_softc *, int, int, int, int));
     87  1.8.4.2  nathanw void tv_cursor	__P((struct ite_softc *, int));
     88  1.8.4.2  nathanw void tv_clear	__P((struct ite_softc *, int, int, int, int));
     89  1.8.4.2  nathanw void tv_scroll	__P((struct ite_softc *, int, int, int, int));
     90  1.8.4.2  nathanw 
     91  1.8.4.2  nathanw __inline static int expbits __P((int));
     92  1.8.4.2  nathanw __inline static void txrascpy __P((u_char, u_char, short, signed short));
     93  1.8.4.2  nathanw 
     94  1.8.4.2  nathanw static __inline void
     95  1.8.4.2  nathanw txrascpy (src, dst, size, mode)
     96  1.8.4.2  nathanw 	u_char src, dst;
     97  1.8.4.2  nathanw 	short size;
     98  1.8.4.2  nathanw 	signed short mode;
     99  1.8.4.2  nathanw {
    100  1.8.4.2  nathanw 	/*int s;*/
    101  1.8.4.2  nathanw 	u_short saved_r21 = CRTC.r21;
    102  1.8.4.2  nathanw 	char d;
    103  1.8.4.2  nathanw 
    104  1.8.4.2  nathanw 	d = (mode < 0) ? -1 : 1;
    105  1.8.4.2  nathanw 	src *= FONTHEIGHT / 4;
    106  1.8.4.2  nathanw 	dst *= FONTHEIGHT / 4;
    107  1.8.4.2  nathanw 	size *= 4;
    108  1.8.4.2  nathanw 	if (d < 0) {
    109  1.8.4.2  nathanw 		src += (FONTHEIGHT / 4) - 1;
    110  1.8.4.2  nathanw 		dst += (FONTHEIGHT / 4) - 1;
    111  1.8.4.2  nathanw 	}
    112  1.8.4.2  nathanw 
    113  1.8.4.2  nathanw 	/* specify same time write mode & page */
    114  1.8.4.2  nathanw 	CRTC.r21 = (mode & 0x0f) | 0x0100;
    115  1.8.4.2  nathanw 	/*mfp.ddr = 0;*/			/* port is input */
    116  1.8.4.2  nathanw 
    117  1.8.4.2  nathanw 	/*s = splhigh();*/
    118  1.8.4.2  nathanw 	while (--size >= 0) {
    119  1.8.4.2  nathanw 		/* wait for hsync */
    120  1.8.4.2  nathanw 		mfp_wait_for_hsync ();
    121  1.8.4.2  nathanw 		CRTC.r22 = (src << 8) | dst;	/* specify raster number */
    122  1.8.4.2  nathanw 		/* start raster copy */
    123  1.8.4.2  nathanw 		CRTC.crtctrl = 8;
    124  1.8.4.2  nathanw 
    125  1.8.4.2  nathanw 		src += d;
    126  1.8.4.2  nathanw 		dst += d;
    127  1.8.4.2  nathanw 	}
    128  1.8.4.2  nathanw 	/*splx(s);*/
    129  1.8.4.2  nathanw 
    130  1.8.4.2  nathanw 	/* wait for hsync */
    131  1.8.4.2  nathanw 	mfp_wait_for_hsync ();
    132  1.8.4.2  nathanw 
    133  1.8.4.2  nathanw 	/* stop raster copy */
    134  1.8.4.2  nathanw 	CRTC.crtctrl = 0;
    135  1.8.4.2  nathanw 
    136  1.8.4.2  nathanw 	CRTC.r21 = saved_r21;
    137  1.8.4.2  nathanw }
    138  1.8.4.2  nathanw 
    139  1.8.4.2  nathanw /*
    140  1.8.4.2  nathanw  * Change glyphs from SRAM switch.
    141  1.8.4.2  nathanw  */
    142  1.8.4.2  nathanw void
    143  1.8.4.2  nathanw ite_set_glyph(void)
    144  1.8.4.2  nathanw {
    145  1.8.4.2  nathanw 	u_char glyph = IODEVbase->io_sram[0x59];
    146  1.8.4.2  nathanw 
    147  1.8.4.2  nathanw 	if (glyph & 4)
    148  1.8.4.2  nathanw 		SETGLYPH(0x82, '|');
    149  1.8.4.2  nathanw 	if (glyph & 2)
    150  1.8.4.2  nathanw 		SETGLYPH(0x81, '~');
    151  1.8.4.2  nathanw 	if (glyph & 1)
    152  1.8.4.2  nathanw 		SETGLYPH(0x80, '\\');
    153  1.8.4.2  nathanw }
    154  1.8.4.2  nathanw 
    155  1.8.4.2  nathanw /*
    156  1.8.4.2  nathanw  * Initialize
    157  1.8.4.2  nathanw  */
    158  1.8.4.2  nathanw void
    159  1.8.4.2  nathanw tv_init(ip)
    160  1.8.4.2  nathanw 	struct ite_softc *ip;
    161  1.8.4.2  nathanw {
    162  1.8.4.2  nathanw 	short i;
    163  1.8.4.2  nathanw 
    164  1.8.4.2  nathanw 	/*
    165  1.8.4.2  nathanw 	 * initialize private variables
    166  1.8.4.2  nathanw 	 */
    167  1.8.4.2  nathanw 	tv_top = 0;
    168  1.8.4.2  nathanw 	for (i = 0; i < PLANELINES; i++)
    169  1.8.4.2  nathanw 		tv_row[i] = (void *)&IODEVbase->tvram[ROWOFFSET(i)];
    170  1.8.4.2  nathanw 	/* shadow ANK font */
    171  1.8.4.2  nathanw 	memcpy(kern_font, (void *)&IODEVbase->cgrom0_8x16, 256 * FONTHEIGHT);
    172  1.8.4.2  nathanw 	ite_set_glyph();
    173  1.8.4.2  nathanw 	/* set font address cache */
    174  1.8.4.2  nathanw 	for (i = 0; i < 256; i++)
    175  1.8.4.2  nathanw 		tv_font[i] = &kern_font[i * FONTHEIGHT];
    176  1.8.4.2  nathanw 	for (i = 0x21; i < 0x30; i++)
    177  1.8.4.2  nathanw 		tv_kfont[i] = &IODEVbase->cgrom0_16x16[KFONTBASE(i-0x21)];
    178  1.8.4.2  nathanw 	for (; i < 0x50; i++)
    179  1.8.4.2  nathanw 		tv_kfont[i] = &IODEVbase->cgrom1_16x16[KFONTBASE(i-0x30)];
    180  1.8.4.2  nathanw 	for (; i < 0x7f; i++)
    181  1.8.4.2  nathanw 		tv_kfont[i] = &IODEVbase->cgrom2_16x16[KFONTBASE(i-0x50)];
    182  1.8.4.2  nathanw 
    183  1.8.4.2  nathanw 	/*
    184  1.8.4.2  nathanw 	 * initialize part of ip
    185  1.8.4.2  nathanw 	 */
    186  1.8.4.2  nathanw 	ip->cols = ip->grf->g_display.gd_dwidth  / FONTWIDTH;
    187  1.8.4.2  nathanw 	ip->rows = ip->grf->g_display.gd_dheight / FONTHEIGHT;
    188  1.8.4.2  nathanw 	/* set draw routine dynamically */
    189  1.8.4.2  nathanw 	ip->isw->ite_putc   = tv_putc;
    190  1.8.4.2  nathanw 	ip->isw->ite_cursor = tv_cursor;
    191  1.8.4.2  nathanw 	ip->isw->ite_clear  = tv_clear;
    192  1.8.4.2  nathanw 	ip->isw->ite_scroll = tv_scroll;
    193  1.8.4.2  nathanw 
    194  1.8.4.2  nathanw 	/*
    195  1.8.4.2  nathanw 	 * Intialize colormap
    196  1.8.4.2  nathanw 	 */
    197  1.8.4.2  nathanw #define RED   (0x1f << 6)
    198  1.8.4.2  nathanw #define BLUE  (0x1f << 1)
    199  1.8.4.2  nathanw #define GREEN (0x1f << 11)
    200  1.8.4.2  nathanw 	IODEVbase->tpalet[0] = 0;			/* black */
    201  1.8.4.2  nathanw 	IODEVbase->tpalet[1] = 1 | RED;			/* red */
    202  1.8.4.2  nathanw 	IODEVbase->tpalet[2] = 1 | GREEN;		/* green */
    203  1.8.4.2  nathanw 	IODEVbase->tpalet[3] = 1 | RED | GREEN;		/* yellow */
    204  1.8.4.2  nathanw 	IODEVbase->tpalet[4] = 1 | BLUE;		/* blue */
    205  1.8.4.2  nathanw 	IODEVbase->tpalet[5] = 1 | BLUE | RED;		/* magenta */
    206  1.8.4.2  nathanw 	IODEVbase->tpalet[6] = 1 | BLUE | GREEN;	/* cyan */
    207  1.8.4.2  nathanw 	IODEVbase->tpalet[7] = 1 | BLUE | RED | GREEN;	/* white */
    208  1.8.4.2  nathanw }
    209  1.8.4.2  nathanw 
    210  1.8.4.2  nathanw /*
    211  1.8.4.2  nathanw  * Deinitialize
    212  1.8.4.2  nathanw  */
    213  1.8.4.2  nathanw void
    214  1.8.4.2  nathanw tv_deinit(ip)
    215  1.8.4.2  nathanw 	struct ite_softc *ip;
    216  1.8.4.2  nathanw {
    217  1.8.4.2  nathanw 	ip->flags &= ~ITE_INITED; /* XXX? */
    218  1.8.4.2  nathanw }
    219  1.8.4.2  nathanw 
    220  1.8.4.2  nathanw typedef void tv_putcfunc __P((struct ite_softc *, int, char *));
    221  1.8.4.2  nathanw static tv_putcfunc tv_putc_nm;
    222  1.8.4.2  nathanw static tv_putcfunc tv_putc_in;
    223  1.8.4.2  nathanw static tv_putcfunc tv_putc_ul;
    224  1.8.4.2  nathanw static tv_putcfunc tv_putc_ul_in;
    225  1.8.4.2  nathanw static tv_putcfunc tv_putc_bd;
    226  1.8.4.2  nathanw static tv_putcfunc tv_putc_bd_in;
    227  1.8.4.2  nathanw static tv_putcfunc tv_putc_bd_ul;
    228  1.8.4.2  nathanw static tv_putcfunc tv_putc_bd_ul_in;
    229  1.8.4.2  nathanw 
    230  1.8.4.2  nathanw static tv_putcfunc *putc_func[ATTR_ALL + 1] = {
    231  1.8.4.2  nathanw 	tv_putc_nm,
    232  1.8.4.2  nathanw 	tv_putc_in,
    233  1.8.4.2  nathanw 	tv_putc_ul,
    234  1.8.4.2  nathanw 	tv_putc_ul_in,
    235  1.8.4.2  nathanw 	tv_putc_bd,
    236  1.8.4.2  nathanw 	tv_putc_bd_in,
    237  1.8.4.2  nathanw 	tv_putc_bd_ul,
    238  1.8.4.2  nathanw 	tv_putc_bd_ul_in,
    239  1.8.4.2  nathanw 	/* no support for blink */
    240  1.8.4.2  nathanw 	tv_putc_nm,
    241  1.8.4.2  nathanw 	tv_putc_in,
    242  1.8.4.2  nathanw 	tv_putc_ul,
    243  1.8.4.2  nathanw 	tv_putc_ul_in,
    244  1.8.4.2  nathanw 	tv_putc_bd,
    245  1.8.4.2  nathanw 	tv_putc_bd_in,
    246  1.8.4.2  nathanw 	tv_putc_bd_ul,
    247  1.8.4.2  nathanw 	tv_putc_bd_ul_in,
    248  1.8.4.2  nathanw };
    249  1.8.4.2  nathanw 
    250  1.8.4.2  nathanw /*
    251  1.8.4.2  nathanw  * simple put character function
    252  1.8.4.2  nathanw  */
    253  1.8.4.2  nathanw void
    254  1.8.4.2  nathanw tv_putc(ip, ch, y, x, mode)
    255  1.8.4.2  nathanw 	struct ite_softc *ip;
    256  1.8.4.2  nathanw 	int ch, y, x, mode;
    257  1.8.4.2  nathanw {
    258  1.8.4.2  nathanw 	char *p = CHADDR(y, x);
    259  1.8.4.2  nathanw 	short fh;
    260  1.8.4.2  nathanw 
    261  1.8.4.2  nathanw 	/* multi page write mode */
    262  1.8.4.2  nathanw 	CRTC.r21 = 0x0100 | ip->fgcolor << 4;
    263  1.8.4.2  nathanw 
    264  1.8.4.2  nathanw 	/* draw plane */
    265  1.8.4.2  nathanw 	putc_func[mode](ip, ch, p);
    266  1.8.4.2  nathanw 
    267  1.8.4.2  nathanw 	/* erase plane */
    268  1.8.4.2  nathanw 	CRTC.r21 ^= 0x00f0;
    269  1.8.4.2  nathanw 	if (ip->save_char) {
    270  1.8.4.2  nathanw 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    271  1.8.4.2  nathanw 			*(u_short *)p = 0;
    272  1.8.4.2  nathanw 	} else {
    273  1.8.4.2  nathanw 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    274  1.8.4.2  nathanw 			*p = 0;
    275  1.8.4.2  nathanw 	}
    276  1.8.4.2  nathanw 
    277  1.8.4.2  nathanw 	/* crtc mode reset */
    278  1.8.4.2  nathanw 	CRTC.r21 = 0;
    279  1.8.4.2  nathanw }
    280  1.8.4.2  nathanw 
    281  1.8.4.2  nathanw void
    282  1.8.4.2  nathanw tv_putc_nm(ip, ch, p)
    283  1.8.4.2  nathanw 	struct ite_softc *ip;
    284  1.8.4.2  nathanw 	int ch;
    285  1.8.4.2  nathanw 	char *p;
    286  1.8.4.2  nathanw {
    287  1.8.4.2  nathanw 	short fh, hi;
    288  1.8.4.2  nathanw 	char *f;
    289  1.8.4.2  nathanw 	short *kf;
    290  1.8.4.2  nathanw 
    291  1.8.4.2  nathanw 	hi = ip->save_char & 0x7f;
    292  1.8.4.2  nathanw 
    293  1.8.4.2  nathanw 	if (hi >= 0x21 && hi <= 0x7e) {
    294  1.8.4.2  nathanw 		/* multibyte character */
    295  1.8.4.2  nathanw 		kf = (short *)tv_kfont[hi];
    296  1.8.4.2  nathanw 		kf += (ch & 0x7f) * FONTHEIGHT;
    297  1.8.4.2  nathanw 		/* draw plane */
    298  1.8.4.2  nathanw 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    299  1.8.4.2  nathanw 			*(u_short *)p = *kf++;
    300  1.8.4.2  nathanw 		return;
    301  1.8.4.2  nathanw 	}
    302  1.8.4.2  nathanw 
    303  1.8.4.2  nathanw 	/* singlebyte character */
    304  1.8.4.2  nathanw 	if (*ip->GL == CSET_JISKANA)
    305  1.8.4.2  nathanw 		ch |= 0x80;
    306  1.8.4.2  nathanw 	f = tv_font[ch];
    307  1.8.4.2  nathanw 
    308  1.8.4.2  nathanw 	/* draw plane */
    309  1.8.4.2  nathanw 	for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    310  1.8.4.2  nathanw 		*p = *f++;
    311  1.8.4.2  nathanw }
    312  1.8.4.2  nathanw 
    313  1.8.4.2  nathanw void
    314  1.8.4.2  nathanw tv_putc_in(ip, ch, p)
    315  1.8.4.2  nathanw 	struct ite_softc *ip;
    316  1.8.4.2  nathanw 	int ch;
    317  1.8.4.2  nathanw 	char *p;
    318  1.8.4.2  nathanw {
    319  1.8.4.2  nathanw 	short fh, hi;
    320  1.8.4.2  nathanw 	char *f;
    321  1.8.4.2  nathanw 	short *kf;
    322  1.8.4.2  nathanw 
    323  1.8.4.2  nathanw 	hi = ip->save_char & 0x7f;
    324  1.8.4.2  nathanw 
    325  1.8.4.2  nathanw 	if (hi >= 0x21 && hi <= 0x7e) {
    326  1.8.4.2  nathanw 		/* multibyte character */
    327  1.8.4.2  nathanw 		kf = (short *)tv_kfont[hi];
    328  1.8.4.2  nathanw 		kf += (ch & 0x7f) * FONTHEIGHT;
    329  1.8.4.2  nathanw 		/* draw plane */
    330  1.8.4.2  nathanw 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    331  1.8.4.2  nathanw 			*(u_short *)p = ~*kf++;
    332  1.8.4.2  nathanw 		return;
    333  1.8.4.2  nathanw 	}
    334  1.8.4.2  nathanw 
    335  1.8.4.2  nathanw 	/* singlebyte character */
    336  1.8.4.2  nathanw 	if (*ip->GL == CSET_JISKANA)
    337  1.8.4.2  nathanw 		ch |= 0x80;
    338  1.8.4.2  nathanw 	f = tv_font[ch];
    339  1.8.4.2  nathanw 
    340  1.8.4.2  nathanw 	/* draw plane */
    341  1.8.4.2  nathanw 	for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    342  1.8.4.2  nathanw 		*p = ~*f++;
    343  1.8.4.2  nathanw }
    344  1.8.4.2  nathanw 
    345  1.8.4.2  nathanw void
    346  1.8.4.2  nathanw tv_putc_bd(ip, ch, p)
    347  1.8.4.2  nathanw 	struct ite_softc *ip;
    348  1.8.4.2  nathanw 	int ch;
    349  1.8.4.2  nathanw 	char *p;
    350  1.8.4.2  nathanw {
    351  1.8.4.2  nathanw 	short fh, hi;
    352  1.8.4.2  nathanw 	char *f;
    353  1.8.4.2  nathanw 	short *kf;
    354  1.8.4.2  nathanw 
    355  1.8.4.2  nathanw 	hi = ip->save_char & 0x7f;
    356  1.8.4.2  nathanw 
    357  1.8.4.2  nathanw 	if (hi >= 0x21 && hi <= 0x7e) {
    358  1.8.4.2  nathanw 		/* multibyte character */
    359  1.8.4.2  nathanw 		kf = (short *)tv_kfont[hi];
    360  1.8.4.2  nathanw 		kf += (ch & 0x7f) * FONTHEIGHT;
    361  1.8.4.2  nathanw 		/* draw plane */
    362  1.8.4.2  nathanw 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
    363  1.8.4.2  nathanw 			ch = *kf++;
    364  1.8.4.2  nathanw 			*(u_short *)p = ch | (ch >> 1);
    365  1.8.4.2  nathanw 		}
    366  1.8.4.2  nathanw 		return;
    367  1.8.4.2  nathanw 	}
    368  1.8.4.2  nathanw 
    369  1.8.4.2  nathanw 	/* singlebyte character */
    370  1.8.4.2  nathanw 	if (*ip->GL == CSET_JISKANA)
    371  1.8.4.2  nathanw 		ch |= 0x80;
    372  1.8.4.2  nathanw 	f = tv_font[ch];
    373  1.8.4.2  nathanw 
    374  1.8.4.2  nathanw 	/* draw plane */
    375  1.8.4.2  nathanw 	for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
    376  1.8.4.2  nathanw 		ch = *f++;
    377  1.8.4.2  nathanw 		*p = ch | (ch >> 1);
    378  1.8.4.2  nathanw 	}
    379  1.8.4.2  nathanw }
    380  1.8.4.2  nathanw 
    381  1.8.4.2  nathanw __inline static int
    382  1.8.4.2  nathanw expbits (data)
    383  1.8.4.2  nathanw 	int data;
    384  1.8.4.2  nathanw {
    385  1.8.4.2  nathanw 	int i, nd = 0;
    386  1.8.4.2  nathanw 	if (data & 1)
    387  1.8.4.2  nathanw 		nd |= 0x02;
    388  1.8.4.2  nathanw 	for (i=1; i < 32; i++) {
    389  1.8.4.2  nathanw 		if (data & (1 << i))
    390  1.8.4.2  nathanw 			nd |= 0x5 << (i-1);
    391  1.8.4.2  nathanw 	}
    392  1.8.4.2  nathanw 	nd &= ~data;
    393  1.8.4.2  nathanw 	return (~nd);
    394  1.8.4.2  nathanw }
    395  1.8.4.2  nathanw 
    396  1.8.4.2  nathanw void
    397  1.8.4.2  nathanw tv_putc_ul(ip, ch, p)
    398  1.8.4.2  nathanw 	struct ite_softc *ip;
    399  1.8.4.2  nathanw 	int ch;
    400  1.8.4.2  nathanw 	char *p;
    401  1.8.4.2  nathanw {
    402  1.8.4.2  nathanw 	short fh, hi;
    403  1.8.4.2  nathanw 	char *f;
    404  1.8.4.2  nathanw 	short *kf;
    405  1.8.4.2  nathanw 
    406  1.8.4.2  nathanw 	hi = ip->save_char & 0x7f;
    407  1.8.4.2  nathanw 
    408  1.8.4.2  nathanw 	if (hi >= 0x21 && hi <= 0x7e) {
    409  1.8.4.2  nathanw 		/* multibyte character */
    410  1.8.4.2  nathanw 		kf = (short *)tv_kfont[hi];
    411  1.8.4.2  nathanw 		kf += (ch & 0x7f) * FONTHEIGHT;
    412  1.8.4.2  nathanw 		/* draw plane */
    413  1.8.4.2  nathanw 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES)
    414  1.8.4.2  nathanw 			*(u_short *)p = *kf++;
    415  1.8.4.2  nathanw 		*(u_short *)p = expbits(*kf++);
    416  1.8.4.2  nathanw 		p += ROWBYTES;
    417  1.8.4.2  nathanw 		for (fh++; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    418  1.8.4.2  nathanw 			*(u_short *)p = *kf++;
    419  1.8.4.2  nathanw 		return;
    420  1.8.4.2  nathanw 	}
    421  1.8.4.2  nathanw 
    422  1.8.4.2  nathanw 	/* singlebyte character */
    423  1.8.4.2  nathanw 	if (*ip->GL == CSET_JISKANA)
    424  1.8.4.2  nathanw 		ch |= 0x80;
    425  1.8.4.2  nathanw 	f = tv_font[ch];
    426  1.8.4.2  nathanw 
    427  1.8.4.2  nathanw 	/* draw plane */
    428  1.8.4.2  nathanw 	for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES)
    429  1.8.4.2  nathanw 		*p = *f++;
    430  1.8.4.2  nathanw 	*p = expbits(*f++);
    431  1.8.4.2  nathanw 	p += ROWBYTES;
    432  1.8.4.2  nathanw 	for (fh++; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    433  1.8.4.2  nathanw 		*p = *f++;
    434  1.8.4.2  nathanw }
    435  1.8.4.2  nathanw 
    436  1.8.4.2  nathanw void
    437  1.8.4.2  nathanw tv_putc_bd_in(ip, ch, p)
    438  1.8.4.2  nathanw 	struct ite_softc *ip;
    439  1.8.4.2  nathanw 	int ch;
    440  1.8.4.2  nathanw 	char *p;
    441  1.8.4.2  nathanw {
    442  1.8.4.2  nathanw 	short fh, hi;
    443  1.8.4.2  nathanw 	char *f;
    444  1.8.4.2  nathanw 	short *kf;
    445  1.8.4.2  nathanw 
    446  1.8.4.2  nathanw 	hi = ip->save_char & 0x7f;
    447  1.8.4.2  nathanw 
    448  1.8.4.2  nathanw 	if (hi >= 0x21 && hi <= 0x7e) {
    449  1.8.4.2  nathanw 		/* multibyte character */
    450  1.8.4.2  nathanw 		kf = (short *)tv_kfont[hi];
    451  1.8.4.2  nathanw 		kf += (ch & 0x7f) * FONTHEIGHT;
    452  1.8.4.2  nathanw 		/* draw plane */
    453  1.8.4.2  nathanw 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
    454  1.8.4.2  nathanw 			ch = *kf++;
    455  1.8.4.2  nathanw 			*(u_short *)p = ~(ch | (ch >> 1));
    456  1.8.4.2  nathanw 		}
    457  1.8.4.2  nathanw 		return;
    458  1.8.4.2  nathanw 	}
    459  1.8.4.2  nathanw 
    460  1.8.4.2  nathanw 	/* singlebyte character */
    461  1.8.4.2  nathanw 	if (*ip->GL == CSET_JISKANA)
    462  1.8.4.2  nathanw 		ch |= 0x80;
    463  1.8.4.2  nathanw 	f = tv_font[ch];
    464  1.8.4.2  nathanw 
    465  1.8.4.2  nathanw 	/* draw plane */
    466  1.8.4.2  nathanw 	for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
    467  1.8.4.2  nathanw 		ch = *f++;
    468  1.8.4.2  nathanw 		*p = ~(ch | (ch >> 1));
    469  1.8.4.2  nathanw 	}
    470  1.8.4.2  nathanw }
    471  1.8.4.2  nathanw 
    472  1.8.4.2  nathanw void
    473  1.8.4.2  nathanw tv_putc_ul_in(ip, ch, p)
    474  1.8.4.2  nathanw 	struct ite_softc *ip;
    475  1.8.4.2  nathanw 	int ch;
    476  1.8.4.2  nathanw 	char *p;
    477  1.8.4.2  nathanw {
    478  1.8.4.2  nathanw 	short fh, hi;
    479  1.8.4.2  nathanw 	char *f;
    480  1.8.4.2  nathanw 	short *kf;
    481  1.8.4.2  nathanw 
    482  1.8.4.2  nathanw 	hi = ip->save_char & 0x7f;
    483  1.8.4.2  nathanw 
    484  1.8.4.2  nathanw 	if (hi >= 0x21 && hi <= 0x7e) {
    485  1.8.4.2  nathanw 		/* multibyte character */
    486  1.8.4.2  nathanw 		kf = (short *)tv_kfont[hi];
    487  1.8.4.2  nathanw 		kf += (ch & 0x7f) * FONTHEIGHT;
    488  1.8.4.2  nathanw 		/* draw plane */
    489  1.8.4.2  nathanw 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES)
    490  1.8.4.2  nathanw 			*(u_short *)p = ~*kf++;
    491  1.8.4.2  nathanw 		*(u_short *)p = ~expbits(*kf++);
    492  1.8.4.2  nathanw 		p += ROWBYTES;
    493  1.8.4.2  nathanw 		for (fh++; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    494  1.8.4.2  nathanw 			*(u_short *)p = ~*kf++;
    495  1.8.4.2  nathanw 		return;
    496  1.8.4.2  nathanw 	}
    497  1.8.4.2  nathanw 
    498  1.8.4.2  nathanw 	/* singlebyte character */
    499  1.8.4.2  nathanw 	if (*ip->GL == CSET_JISKANA)
    500  1.8.4.2  nathanw 		ch |= 0x80;
    501  1.8.4.2  nathanw 	f = tv_font[ch];
    502  1.8.4.2  nathanw 
    503  1.8.4.2  nathanw 	/* draw plane */
    504  1.8.4.2  nathanw 	for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES)
    505  1.8.4.2  nathanw 		*p = ~*f++;
    506  1.8.4.2  nathanw 	*p = ~expbits(*f++);
    507  1.8.4.2  nathanw 	p += ROWBYTES;
    508  1.8.4.2  nathanw 	for (fh++; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    509  1.8.4.2  nathanw 		*p = ~*f++;
    510  1.8.4.2  nathanw }
    511  1.8.4.2  nathanw 
    512  1.8.4.2  nathanw void
    513  1.8.4.2  nathanw tv_putc_bd_ul(ip, ch, p)
    514  1.8.4.2  nathanw 	struct ite_softc *ip;
    515  1.8.4.2  nathanw 	int ch;
    516  1.8.4.2  nathanw 	char *p;
    517  1.8.4.2  nathanw {
    518  1.8.4.2  nathanw 	short fh, hi;
    519  1.8.4.2  nathanw 	char *f;
    520  1.8.4.2  nathanw 	short *kf;
    521  1.8.4.2  nathanw 
    522  1.8.4.2  nathanw 	hi = ip->save_char & 0x7f;
    523  1.8.4.2  nathanw 
    524  1.8.4.2  nathanw 	if (hi >= 0x21 && hi <= 0x7e) {
    525  1.8.4.2  nathanw 		/* multibyte character */
    526  1.8.4.2  nathanw 		kf = (short *)tv_kfont[hi];
    527  1.8.4.2  nathanw 		kf += (ch & 0x7f) * FONTHEIGHT;
    528  1.8.4.2  nathanw 		/* draw plane */
    529  1.8.4.2  nathanw 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES) {
    530  1.8.4.2  nathanw 			ch = *kf++;
    531  1.8.4.2  nathanw 			*(u_short *)p = ch | (ch >> 1);
    532  1.8.4.2  nathanw 		}
    533  1.8.4.2  nathanw 		ch = *kf++;
    534  1.8.4.2  nathanw 		*(u_short *)p = expbits(ch | (ch >> 1));
    535  1.8.4.2  nathanw 		p += ROWBYTES;
    536  1.8.4.2  nathanw 		for (fh++; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
    537  1.8.4.2  nathanw 			ch = *kf++;
    538  1.8.4.2  nathanw 			*(u_short *)p = ch | (ch >> 1);
    539  1.8.4.2  nathanw 		}
    540  1.8.4.2  nathanw 		return;
    541  1.8.4.2  nathanw 	}
    542  1.8.4.2  nathanw 
    543  1.8.4.2  nathanw 	/* singlebyte character */
    544  1.8.4.2  nathanw 	if (*ip->GL == CSET_JISKANA)
    545  1.8.4.2  nathanw 		ch |= 0x80;
    546  1.8.4.2  nathanw 	f = tv_font[ch];
    547  1.8.4.2  nathanw 
    548  1.8.4.2  nathanw 	/* draw plane */
    549  1.8.4.2  nathanw 	for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES) {
    550  1.8.4.2  nathanw 		ch = *f++;
    551  1.8.4.2  nathanw 		*p = ch | (ch >> 1);
    552  1.8.4.2  nathanw 	}
    553  1.8.4.2  nathanw 	ch = *f++;
    554  1.8.4.2  nathanw 	*p = expbits(ch | (ch >> 1));
    555  1.8.4.2  nathanw 	p += ROWBYTES;
    556  1.8.4.2  nathanw 	for (fh++; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
    557  1.8.4.2  nathanw 		ch = *f++;
    558  1.8.4.2  nathanw 		*p = ch | (ch >> 1);
    559  1.8.4.2  nathanw 	}
    560  1.8.4.2  nathanw }
    561  1.8.4.2  nathanw 
    562  1.8.4.2  nathanw void
    563  1.8.4.2  nathanw tv_putc_bd_ul_in(ip, ch, p)
    564  1.8.4.2  nathanw 	struct ite_softc *ip;
    565  1.8.4.2  nathanw 	int ch;
    566  1.8.4.2  nathanw 	char *p;
    567  1.8.4.2  nathanw {
    568  1.8.4.2  nathanw 	short fh, hi;
    569  1.8.4.2  nathanw 	char *f;
    570  1.8.4.2  nathanw 	short *kf;
    571  1.8.4.2  nathanw 
    572  1.8.4.2  nathanw 	hi = ip->save_char & 0x7f;
    573  1.8.4.2  nathanw 
    574  1.8.4.2  nathanw 	if (hi >= 0x21 && hi <= 0x7e) {
    575  1.8.4.2  nathanw 		/* multibyte character */
    576  1.8.4.2  nathanw 		kf = (short *)tv_kfont[hi];
    577  1.8.4.2  nathanw 		kf += (ch & 0x7f) * FONTHEIGHT;
    578  1.8.4.2  nathanw 		/* draw plane */
    579  1.8.4.2  nathanw 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES) {
    580  1.8.4.2  nathanw 			ch = *kf++;
    581  1.8.4.2  nathanw 			*(u_short *)p = ~(ch | (ch >> 1));
    582  1.8.4.2  nathanw 		}
    583  1.8.4.2  nathanw 		ch = *kf++;
    584  1.8.4.2  nathanw 		*(u_short *)p = ~expbits(ch | (ch >> 1));
    585  1.8.4.2  nathanw 		p += ROWBYTES;
    586  1.8.4.2  nathanw 		for (fh++; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
    587  1.8.4.2  nathanw 			ch = *kf++;
    588  1.8.4.2  nathanw 			*(u_short *)p = ~(ch | (ch >> 1));
    589  1.8.4.2  nathanw 		}
    590  1.8.4.2  nathanw 		return;
    591  1.8.4.2  nathanw 	}
    592  1.8.4.2  nathanw 
    593  1.8.4.2  nathanw 	/* singlebyte character */
    594  1.8.4.2  nathanw 	if (*ip->GL == CSET_JISKANA)
    595  1.8.4.2  nathanw 		ch |= 0x80;
    596  1.8.4.2  nathanw 	f = tv_font[ch];
    597  1.8.4.2  nathanw 
    598  1.8.4.2  nathanw 	/* draw plane */
    599  1.8.4.2  nathanw 	for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES) {
    600  1.8.4.2  nathanw 		ch = *f++;
    601  1.8.4.2  nathanw 		*p = ~(ch | (ch >> 1));
    602  1.8.4.2  nathanw 	}
    603  1.8.4.2  nathanw 	ch = *f++;
    604  1.8.4.2  nathanw 	*p = ~expbits(ch | (ch >> 1));
    605  1.8.4.2  nathanw 	p += ROWBYTES;
    606  1.8.4.2  nathanw 	for (fh++; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
    607  1.8.4.2  nathanw 		ch = *f++;
    608  1.8.4.2  nathanw 		ch |= ch >> 1;
    609  1.8.4.2  nathanw 		*p = ~(ch | (ch >> 1));
    610  1.8.4.2  nathanw 	}
    611  1.8.4.2  nathanw }
    612  1.8.4.2  nathanw 
    613  1.8.4.2  nathanw /*
    614  1.8.4.2  nathanw  * draw/erase/move cursor
    615  1.8.4.2  nathanw  */
    616  1.8.4.2  nathanw void
    617  1.8.4.2  nathanw tv_cursor(ip, flag)
    618  1.8.4.2  nathanw 	struct ite_softc *ip;
    619  1.8.4.2  nathanw 	int flag;
    620  1.8.4.2  nathanw {
    621  1.8.4.2  nathanw 	u_char *p;
    622  1.8.4.2  nathanw 	short fh;
    623  1.8.4.2  nathanw 
    624  1.8.4.2  nathanw 	/* erase */
    625  1.8.4.2  nathanw 	switch (flag) {
    626  1.8.4.2  nathanw 	/*case DRAW_CURSOR:*/
    627  1.8.4.2  nathanw 	/*case ERASE_CURSOR:*/
    628  1.8.4.2  nathanw 	/*case MOVE_CURSOR:*/
    629  1.8.4.2  nathanw 	case START_CURSOROPT:
    630  1.8.4.2  nathanw 		/*
    631  1.8.4.2  nathanw 		 * old: ip->cursorx, ip->cursory
    632  1.8.4.2  nathanw 		 * new: ip->curx, ip->cury
    633  1.8.4.2  nathanw 		 */
    634  1.8.4.2  nathanw 		p = CHADDR(ip->cursory, ip->cursorx);
    635  1.8.4.2  nathanw 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    636  1.8.4.2  nathanw 			*p = ~*p;
    637  1.8.4.2  nathanw 		break;
    638  1.8.4.2  nathanw 	}
    639  1.8.4.2  nathanw 
    640  1.8.4.2  nathanw 	/* draw */
    641  1.8.4.2  nathanw 	switch (flag) {
    642  1.8.4.2  nathanw 	/*case MOVE_CURSOR:*/
    643  1.8.4.2  nathanw 	case END_CURSOROPT:
    644  1.8.4.2  nathanw 		/*
    645  1.8.4.2  nathanw 		 * Use exclusive-or.
    646  1.8.4.2  nathanw 		 */
    647  1.8.4.2  nathanw 		p = CHADDR(ip->cury, ip->curx);
    648  1.8.4.2  nathanw 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    649  1.8.4.2  nathanw 			*p = ~*p;
    650  1.8.4.2  nathanw 
    651  1.8.4.2  nathanw 		ip->cursorx = ip->curx;
    652  1.8.4.2  nathanw 		ip->cursory = ip->cury;
    653  1.8.4.2  nathanw 		break;
    654  1.8.4.2  nathanw 	}
    655  1.8.4.2  nathanw }
    656  1.8.4.2  nathanw 
    657  1.8.4.2  nathanw /*
    658  1.8.4.2  nathanw  * clear rectangle
    659  1.8.4.2  nathanw  */
    660  1.8.4.2  nathanw void
    661  1.8.4.2  nathanw tv_clear(ip, y, x, height, width)
    662  1.8.4.2  nathanw 	struct ite_softc *ip;
    663  1.8.4.2  nathanw 	int y, x, height, width;
    664  1.8.4.2  nathanw {
    665  1.8.4.2  nathanw 	char *p;
    666  1.8.4.2  nathanw 	short fh;
    667  1.8.4.2  nathanw 
    668  1.8.4.2  nathanw 	/* XXX: reset scroll register on clearing whole screen */
    669  1.8.4.2  nathanw 	if (y == 0 && x == 0 && height == ip->rows && width == ip->cols) {
    670  1.8.4.2  nathanw 		CRTC.r10 = 0;
    671  1.8.4.2  nathanw 		CRTC.r11 = tv_top * FONTHEIGHT;
    672  1.8.4.2  nathanw 	}
    673  1.8.4.2  nathanw 
    674  1.8.4.2  nathanw 	CRTC.r21 = 0x01f0;
    675  1.8.4.2  nathanw 	while (height--) {
    676  1.8.4.2  nathanw 		p = CHADDR(y++, x);
    677  1.8.4.2  nathanw 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
    678  1.8.4.2  nathanw 			memset(p, 0, width);
    679  1.8.4.2  nathanw 	}
    680  1.8.4.2  nathanw 	/* crtc mode reset */
    681  1.8.4.2  nathanw 	CRTC.r21 = 0;
    682  1.8.4.2  nathanw }
    683  1.8.4.2  nathanw 
    684  1.8.4.2  nathanw /*
    685  1.8.4.2  nathanw  * scroll lines/columns
    686  1.8.4.2  nathanw  */
    687  1.8.4.2  nathanw void
    688  1.8.4.2  nathanw tv_scroll(ip, srcy, srcx, count, dir)
    689  1.8.4.2  nathanw 	struct ite_softc *ip;
    690  1.8.4.2  nathanw 	int srcy, srcx, count, dir;
    691  1.8.4.2  nathanw {
    692  1.8.4.2  nathanw 	int dst, siz, pl;
    693  1.8.4.2  nathanw 
    694  1.8.4.2  nathanw 	switch (dir) {
    695  1.8.4.2  nathanw 	case SCROLL_UP:
    696  1.8.4.2  nathanw 		/*
    697  1.8.4.2  nathanw 		 * src: srcy
    698  1.8.4.2  nathanw 		 * dst: (srcy - count)
    699  1.8.4.2  nathanw 		 * siz: (ip->bottom_margin - sy + 1)
    700  1.8.4.2  nathanw 		 */
    701  1.8.4.2  nathanw 		dst = srcy - count;
    702  1.8.4.2  nathanw 		siz = ip->bottom_margin - srcy + 1;
    703  1.8.4.2  nathanw 		if (dst == 0 && ip->bottom_margin == ip->rows - 1) {
    704  1.8.4.2  nathanw 			/* special case, hardware scroll */
    705  1.8.4.2  nathanw 			tv_top = (tv_top + count) % PLANELINES;
    706  1.8.4.2  nathanw 			CRTC.r11 = tv_top * FONTHEIGHT;
    707  1.8.4.2  nathanw 		} else {
    708  1.8.4.2  nathanw 			srcy = PHYSLINE(srcy);
    709  1.8.4.2  nathanw 			dst = PHYSLINE(dst);
    710  1.8.4.2  nathanw 			txrascpy(srcy, dst, siz, 0x0f);
    711  1.8.4.2  nathanw 		}
    712  1.8.4.2  nathanw 		break;
    713  1.8.4.2  nathanw 
    714  1.8.4.2  nathanw 	case SCROLL_DOWN:
    715  1.8.4.2  nathanw 		/*
    716  1.8.4.2  nathanw 		 * src: srcy
    717  1.8.4.2  nathanw 		 * dst: (srcy + count)
    718  1.8.4.2  nathanw 		 * siz: (ip->bottom_margin - dy + 1)
    719  1.8.4.2  nathanw 		 */
    720  1.8.4.2  nathanw 		dst = srcy + count;
    721  1.8.4.2  nathanw 		siz = ip->bottom_margin - dst + 1;
    722  1.8.4.2  nathanw 		if (srcy == 0 && ip->bottom_margin == ip->rows - 1) {
    723  1.8.4.2  nathanw 			/* special case, hardware scroll */
    724  1.8.4.2  nathanw 			tv_top = (tv_top + PLANELINES - count) % PLANELINES;
    725  1.8.4.2  nathanw 			CRTC.r11 = tv_top * FONTHEIGHT;
    726  1.8.4.2  nathanw 		} else {
    727  1.8.4.2  nathanw 			srcy = PHYSLINE(srcy) + siz - 1;
    728  1.8.4.2  nathanw 			dst = PHYSLINE(dst) + siz - 1;
    729  1.8.4.2  nathanw 			txrascpy(srcy, dst, siz, 0x0f | 0x8000);
    730  1.8.4.2  nathanw 		}
    731  1.8.4.2  nathanw 		break;
    732  1.8.4.2  nathanw 
    733  1.8.4.2  nathanw 	case SCROLL_LEFT:
    734  1.8.4.2  nathanw 		for (pl = 0; pl < PLANESIZE * 4; pl += PLANESIZE) {
    735  1.8.4.2  nathanw 			short fh;
    736  1.8.4.2  nathanw 			char *src = CHADDR(srcy, srcx) + pl;
    737  1.8.4.2  nathanw 			char *dst = CHADDR(srcy, srcx - count) + pl;
    738  1.8.4.2  nathanw 
    739  1.8.4.2  nathanw 			siz = ip->cols - srcx;
    740  1.8.4.2  nathanw 			for (fh = 0; fh < FONTHEIGHT; fh++) {
    741  1.8.4.2  nathanw 				memcpy(dst, src, siz);
    742  1.8.4.2  nathanw 				src += ROWBYTES;
    743  1.8.4.2  nathanw 				dst += ROWBYTES;
    744  1.8.4.2  nathanw 			}
    745  1.8.4.2  nathanw 		}
    746  1.8.4.2  nathanw 		break;
    747  1.8.4.2  nathanw 
    748  1.8.4.2  nathanw 	case SCROLL_RIGHT:
    749  1.8.4.2  nathanw 		for (pl = 0; pl < PLANESIZE * 4; pl += PLANESIZE) {
    750  1.8.4.2  nathanw 			short fh;
    751  1.8.4.2  nathanw 			char *src = CHADDR(srcy, srcx) + pl;
    752  1.8.4.2  nathanw 			char *dst = CHADDR(srcy, srcx + count) + pl;
    753  1.8.4.2  nathanw 
    754  1.8.4.2  nathanw 			siz = ip->cols - (srcx + count);
    755  1.8.4.2  nathanw 			for (fh = 0; fh < FONTHEIGHT; fh++) {
    756  1.8.4.2  nathanw 				memcpy(dst, src, siz);
    757  1.8.4.2  nathanw 				src += ROWBYTES;
    758  1.8.4.2  nathanw 				dst += ROWBYTES;
    759  1.8.4.2  nathanw 			}
    760  1.8.4.2  nathanw 		}
    761  1.8.4.2  nathanw 		break;
    762  1.8.4.2  nathanw 	}
    763  1.8.4.2  nathanw }
    764