Home | History | Annotate | Line # | Download | only in dev
ite_cc.c revision 1.23
      1  1.23  chopps /*	$NetBSD: ite_cc.c,v 1.23 1995/03/02 04:42:39 chopps Exp $	*/
      2   1.9  chopps 
      3  1.22  chopps /*
      4  1.22  chopps  * Copyright (c) 1994 Christian E. Hopps
      5  1.22  chopps  * All rights reserved.
      6  1.22  chopps  *
      7  1.22  chopps  * Redistribution and use in source and binary forms, with or without
      8  1.22  chopps  * modification, are permitted provided that the following conditions
      9  1.22  chopps  * are met:
     10  1.22  chopps  * 1. Redistributions of source code must retain the above copyright
     11  1.22  chopps  *    notice, this list of conditions and the following disclaimer.
     12  1.22  chopps  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.22  chopps  *    notice, this list of conditions and the following disclaimer in the
     14  1.22  chopps  *    documentation and/or other materials provided with the distribution.
     15  1.22  chopps  * 3. All advertising materials mentioning features or use of this software
     16  1.22  chopps  *    must display the following acknowledgement:
     17  1.22  chopps  *      This product includes software developed by Christian E. Hopps.
     18  1.22  chopps  * 4. The name of the author may not be used to endorse or promote products
     19  1.22  chopps  *    derived from this software without specific prior written permission
     20  1.22  chopps  *
     21  1.22  chopps  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.22  chopps  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.22  chopps  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.22  chopps  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.22  chopps  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.22  chopps  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.22  chopps  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.22  chopps  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.22  chopps  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.22  chopps  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.22  chopps  */
     32  1.19  chopps #include "grfcc.h"
     33  1.19  chopps #if NGRFCC > 0
     34  1.19  chopps 
     35  1.10  chopps #include <sys/param.h>
     36  1.10  chopps #include <sys/conf.h>
     37  1.10  chopps #include <sys/proc.h>
     38  1.16  chopps #include <sys/device.h>
     39  1.10  chopps #include <sys/ioctl.h>
     40  1.10  chopps #include <sys/tty.h>
     41  1.10  chopps #include <sys/systm.h>
     42  1.12  chopps #include <sys/queue.h>
     43  1.16  chopps #include <sys/termios.h>
     44  1.11  chopps #include <dev/cons.h>
     45  1.16  chopps #include <machine/cpu.h>
     46  1.10  chopps #include <amiga/dev/itevar.h>
     47  1.10  chopps #include <amiga/dev/iteioctl.h>
     48  1.10  chopps #include <amiga/amiga/cc.h>
     49  1.16  chopps #include <amiga/amiga/device.h>
     50  1.10  chopps #include <amiga/dev/grfabs_reg.h>
     51  1.16  chopps #include <amiga/dev/grfioctl.h>
     52  1.16  chopps #include <amiga/dev/grfvar.h>
     53  1.16  chopps #include <amiga/dev/grf_ccreg.h>
     54  1.10  chopps #include <amiga/dev/viewioctl.h>
     55  1.10  chopps #include <amiga/dev/viewvar.h>
     56  1.10  chopps 
     57  1.14  chopps #ifndef KFONT_CUSTOM
     58  1.14  chopps #ifdef KFONT_8X11
     59  1.16  chopps #define kernel_font_width       kernel_font_width_8x11
     60  1.16  chopps #define kernel_font_height      kernel_font_height_8x11
     61  1.16  chopps #define kernel_font_baseline    kernel_font_baseline_8x11
     62  1.16  chopps #define kernel_font_boldsmear   kernel_font_boldsmear_8x11
     63  1.16  chopps #define kernel_font_lo  kernel_font_lo_8x11
     64  1.16  chopps #define kernel_font_hi  kernel_font_hi_8x11
     65  1.16  chopps #define kernel_font     kernel_font_8x11
     66  1.16  chopps #define kernel_cursor   kernel_cursor_8x11
     67  1.14  chopps #else
     68  1.16  chopps #define kernel_font_width       kernel_font_width_8x8
     69  1.16  chopps #define kernel_font_height      kernel_font_height_8x8
     70  1.16  chopps #define kernel_font_baseline    kernel_font_baseline_8x8
     71  1.16  chopps #define kernel_font_boldsmear   kernel_font_boldsmear_8x8
     72  1.16  chopps #define kernel_font_lo  kernel_font_lo_8x8
     73  1.16  chopps #define kernel_font_hi  kernel_font_hi_8x8
     74  1.16  chopps #define kernel_font     kernel_font_8x8
     75  1.16  chopps #define kernel_cursor   kernel_cursor_8x8
     76  1.14  chopps #endif
     77  1.14  chopps #endif
     78   1.3      mw 
     79  1.13  chopps extern u_char kernel_font_width, kernel_font_height, kernel_font_baseline;
     80  1.13  chopps extern short  kernel_font_boldsmear;
     81  1.13  chopps extern u_char kernel_font_lo, kernel_font_hi;
     82  1.13  chopps extern u_char kernel_font[], kernel_cursor[];
     83   1.1      mw 
     84   1.3      mw /*
     85   1.3      mw  * This is what ip->priv points to;
     86   1.3      mw  * it contains local variables for custom-chip ites.
     87   1.3      mw  */
     88  1.13  chopps struct ite_priv {
     89  1.13  chopps 	view_t *view;		/* the view for this ite. */
     90  1.13  chopps 	u_char **row_ptr;	/* array of pointers into the bitmap  */
     91  1.13  chopps 	u_long row_bytes;
     92  1.13  chopps 	u_long cursor_opt;
     93  1.13  chopps 	u_int  *column_offset;	/* array of offsets for columns */
     94  1.13  chopps 	u_int  row_offset;	/* the row offset */
     95  1.13  chopps 	u_short width;		/* the bitmap width */
     96  1.13  chopps 	u_short underline;	/* where the underline goes */
     97  1.13  chopps 	u_short ft_x;		/* the font width */
     98  1.13  chopps 	u_short ft_y;		/* the font height */
     99  1.13  chopps 	u_char *font_cell[256];	/* the font pointer */
    100  1.13  chopps };
    101  1.13  chopps typedef struct ite_priv ipriv_t;
    102   1.3      mw 
    103  1.16  chopps void view_deinit __P((struct ite_softc *));
    104  1.16  chopps void view_init __P((struct ite_softc *));
    105   1.3      mw 
    106  1.13  chopps static void putc8 __P((struct ite_softc *, int, int, int, int));
    107  1.13  chopps static void clear8 __P((struct ite_softc *, int, int, int, int));
    108  1.13  chopps static void scroll8 __P((struct ite_softc *, int, int, int, int));
    109  1.13  chopps static void cursor32 __P((struct ite_softc *, int));
    110  1.13  chopps static void scrollbmap __P((bmap_t *, u_short, u_short, u_short, u_short,
    111  1.13  chopps     short, short, u_char));
    112  1.13  chopps 
    113  1.13  chopps /* patchable */
    114  1.13  chopps int ite_default_x = 0;		/* def leftedge offset */
    115  1.13  chopps int ite_default_y = 0;		/* def topedge offset */
    116  1.13  chopps int ite_default_width = 640;	/* def width */
    117  1.13  chopps int ite_default_depth = 2;	/* def depth */
    118   1.6      mw #if defined (GRF_NTSC)
    119  1.13  chopps int ite_default_height = 400;	/* def NTSC height */
    120   1.6      mw #elif defined (GRF_PAL)
    121  1.13  chopps int ite_default_height = 512;	/* def PAL height */
    122   1.6      mw #else
    123  1.13  chopps int ite_default_height = 400;	/* def NON-PAL/NTSC height (?) */
    124   1.6      mw #endif
    125   1.3      mw 
    126   1.6      mw /* audio bell stuff */
    127  1.13  chopps u_int bvolume = 10;
    128  1.13  chopps u_int bpitch = 660;
    129  1.13  chopps u_int bmsec = 75;
    130  1.13  chopps 
    131  1.13  chopps static char *bsamplep;
    132  1.13  chopps static char sample[20] = {
    133  1.13  chopps 	0,39,75,103,121,127,121,103,75,39,0,
    134  1.13  chopps 	-39,-75,-103,-121,-127,-121,-103,-75,-39
    135  1.13  chopps };
    136   1.3      mw 
    137  1.16  chopps /*
    138  1.16  chopps  * called from grf_cc to return console priority
    139  1.16  chopps  */
    140  1.16  chopps int
    141  1.16  chopps grfcc_cnprobe()
    142  1.16  chopps {
    143  1.16  chopps 	return(CN_INTERNAL);
    144  1.16  chopps }
    145  1.16  chopps 
    146  1.16  chopps /*
    147  1.18  chopps  * called from grf_cc to init ite portion of
    148  1.16  chopps  * grf_softc struct
    149  1.16  chopps  */
    150  1.16  chopps void
    151  1.16  chopps grfcc_iteinit(gp)
    152  1.16  chopps 	struct grf_softc *gp;
    153   1.1      mw {
    154  1.16  chopps 	gp->g_itecursor = cursor32;
    155  1.16  chopps 	gp->g_iteputc = putc8;
    156  1.16  chopps 	gp->g_iteclear = clear8;
    157  1.16  chopps 	gp->g_itescroll = scroll8;
    158  1.16  chopps 	gp->g_iteinit = view_init;
    159  1.16  chopps 	gp->g_itedeinit = view_deinit;
    160   1.1      mw }
    161   1.1      mw 
    162  1.13  chopps void
    163  1.13  chopps init_bell()
    164   1.1      mw {
    165  1.13  chopps 	short i;
    166   1.6      mw 
    167  1.13  chopps 	if (bsamplep != NULL)
    168  1.13  chopps 		return;
    169  1.13  chopps 	bsamplep = alloc_chipmem(20);
    170  1.13  chopps 	if (bsamplep == NULL)
    171  1.13  chopps 		panic("no chipmem for ccbell");
    172   1.3      mw 
    173  1.13  chopps 	bcopy(sample, bsamplep, 20);
    174   1.3      mw }
    175   1.3      mw 
    176  1.13  chopps void
    177  1.13  chopps cc_bell()
    178   1.3      mw {
    179  1.13  chopps 	u_int clock;
    180  1.13  chopps 	u_int period;
    181  1.13  chopps 	u_int count;
    182  1.13  chopps 
    183  1.13  chopps 	clock = 3579545; 	/* PAL 3546895 */
    184  1.13  chopps 
    185  1.13  chopps 	/*
    186  1.13  chopps 	 * the number of clock ticks per sample byte must be > 124
    187  1.13  chopps 	 * ergo bpitch must be < clock / 124*20
    188  1.13  chopps 	 * i.e. ~1443, 1300 to be safe (PAL etc.). also not zero obviously
    189  1.13  chopps 	 */
    190  1.13  chopps 	period = clock / (bpitch * 20);
    191  1.13  chopps 	count = bmsec * bpitch / 1000;
    192  1.13  chopps 
    193  1.13  chopps 	play_sample(10, PREP_DMA_MEM(bsamplep), period, bvolume, 0x3, count);
    194   1.1      mw }
    195   1.1      mw 
    196   1.1      mw 
    197   1.6      mw int
    198  1.13  chopps ite_newsize(ip, winsz)
    199  1.13  chopps 	struct ite_softc *ip;
    200  1.13  chopps 	struct itewinsize *winsz;
    201   1.1      mw {
    202  1.13  chopps 	extern struct view_softc views[];
    203  1.13  chopps 	struct view_size vs;
    204  1.13  chopps 	ipriv_t *cci = ip->priv;
    205  1.13  chopps 	u_long fbp, i;
    206  1.13  chopps 	int error;
    207  1.13  chopps 
    208  1.13  chopps 	vs.x = winsz->x;
    209  1.13  chopps 	vs.y = winsz->y;
    210  1.13  chopps 	vs.width = winsz->width;
    211  1.13  chopps 	vs.height = winsz->height;
    212  1.13  chopps 	vs.depth = winsz->depth;
    213  1.16  chopps 	error = viewioctl(0, VIOCSSIZE, &vs, 0, -1);
    214  1.13  chopps 
    215  1.13  chopps 	/*
    216  1.13  chopps 	 * Reinitialize our structs
    217  1.13  chopps 	 */
    218  1.16  chopps 	cci->view = views[0].view;
    219  1.13  chopps 
    220  1.13  chopps 	/* -1 for bold. */
    221  1.13  chopps 	ip->cols = (cci->view->display.width - 1) / ip->ftwidth;
    222  1.13  chopps 	ip->rows = cci->view->display.height / ip->ftheight;
    223  1.13  chopps 
    224  1.13  chopps 	/*
    225  1.13  chopps 	 * save new values so that future opens use them
    226  1.13  chopps 	 * this may not be correct when we implement Virtual Consoles
    227  1.13  chopps 	 */
    228  1.13  chopps 	ite_default_height = cci->view->display.height;
    229  1.13  chopps 	ite_default_width = cci->view->display.width;
    230  1.13  chopps 	ite_default_x = cci->view->display.x;
    231  1.13  chopps 	ite_default_y = cci->view->display.y;
    232  1.13  chopps 	ite_default_depth = cci->view->bitmap->depth;
    233  1.13  chopps 
    234  1.13  chopps 	if (cci->row_ptr)
    235  1.13  chopps 		free_chipmem(cci->row_ptr);
    236  1.13  chopps 	if (cci->column_offset)
    237  1.13  chopps 		free_chipmem(cci->column_offset);
    238   1.3      mw 
    239  1.13  chopps 	cci->row_ptr = alloc_chipmem(sizeof(u_char *) * ip->rows);
    240  1.13  chopps 	cci->column_offset = alloc_chipmem(sizeof(u_int) * ip->cols);
    241   1.6      mw 
    242  1.13  chopps 	if (cci->row_ptr == NULL || cci->column_offset == NULL)
    243  1.13  chopps 		panic("no chipmem for itecc data");
    244  1.13  chopps 
    245   1.6      mw 
    246  1.13  chopps 	cci->width = cci->view->bitmap->bytes_per_row << 3;
    247  1.13  chopps 	cci->underline = ip->ftbaseline + 1;
    248  1.13  chopps 	cci->row_offset = cci->view->bitmap->bytes_per_row
    249  1.13  chopps 	    + cci->view->bitmap->row_mod;
    250  1.13  chopps 	cci->ft_x = ip->ftwidth;
    251  1.13  chopps 	cci->ft_y = ip->ftheight;
    252   1.6      mw 
    253  1.13  chopps 	cci->row_bytes = cci->row_offset * ip->ftheight;
    254   1.6      mw 
    255  1.13  chopps 	cci->row_ptr[0] = VDISPLAY_LINE (cci->view, 0, 0);
    256  1.13  chopps 	for (i = 1; i < ip->rows; i++)
    257  1.13  chopps 		cci->row_ptr[i] = cci->row_ptr[i-1] + cci->row_bytes;
    258  1.13  chopps 
    259  1.13  chopps 	/* initialize the column offsets */
    260  1.13  chopps 	cci->column_offset[0] = 0;
    261  1.13  chopps 	for (i = 1; i < ip->cols; i++)
    262  1.13  chopps 		cci->column_offset[i] = cci->column_offset[i - 1] + cci->ft_x;
    263  1.13  chopps 
    264  1.13  chopps 	/* initialize the font cell pointers */
    265  1.13  chopps 	cci->font_cell[ip->font_lo] = ip->font;
    266  1.13  chopps 	for (i=ip->font_lo+1; i<=ip->font_hi; i++)
    267  1.13  chopps 		cci->font_cell[i] = cci->font_cell[i-1] + ip->ftheight;
    268   1.6      mw 
    269  1.13  chopps 	return (error);
    270   1.3      mw }
    271   1.3      mw 
    272  1.11  chopps void
    273  1.11  chopps view_init(ip)
    274   1.3      mw 	register struct ite_softc *ip;
    275   1.3      mw {
    276  1.13  chopps 	struct itewinsize wsz;
    277  1.13  chopps 	ipriv_t *cci;
    278  1.13  chopps 
    279  1.13  chopps 	cci = ip->priv;
    280   1.6      mw 
    281  1.13  chopps 	if (cci)
    282  1.13  chopps 		return;
    283  1.13  chopps 
    284  1.13  chopps 	init_bell();
    285   1.6      mw 
    286   1.6      mw 	ip->font     = kernel_font;
    287   1.6      mw 	ip->font_lo  = kernel_font_lo;
    288   1.6      mw 	ip->font_hi  = kernel_font_hi;
    289   1.6      mw 	ip->ftwidth  = kernel_font_width;
    290   1.6      mw 	ip->ftheight = kernel_font_height;
    291   1.6      mw 	ip->ftbaseline = kernel_font_baseline;
    292   1.6      mw 	ip->ftboldsmear = kernel_font_boldsmear;
    293   1.6      mw 
    294   1.6      mw 	/* Find the correct set of rendering routines for this font.  */
    295  1.13  chopps 	if (ip->ftwidth > 8)
    296   1.6      mw 		panic("kernel font size not supported");
    297  1.13  chopps 	cci = alloc_chipmem(sizeof (*cci));
    298  1.13  chopps 	if (cci == NULL)
    299  1.13  chopps 		panic("no memory for console device.");
    300   1.1      mw 
    301   1.6      mw 	ip->priv = cci;
    302   1.6      mw 	cci->cursor_opt = 0;
    303   1.6      mw 	cci->view = NULL;
    304   1.6      mw 	cci->row_ptr = NULL;
    305   1.6      mw 	cci->column_offset = NULL;
    306   1.1      mw 
    307  1.13  chopps 	wsz.x = ite_default_x;
    308  1.13  chopps 	wsz.y = ite_default_y;
    309  1.13  chopps 	wsz.width = ite_default_width;
    310  1.13  chopps 	wsz.height = ite_default_height;
    311  1.13  chopps 	wsz.depth = ite_default_depth;
    312  1.13  chopps 
    313  1.13  chopps 	ite_newsize (ip, &wsz);
    314  1.16  chopps 	cc_mode(ip->grf, GM_GRFON, NULL, 0, 0);
    315   1.6      mw }
    316   1.6      mw 
    317   1.6      mw int
    318   1.8  chopps ite_grf_ioctl (ip, cmd, addr, flag, p)
    319   1.8  chopps 	struct ite_softc *ip;
    320  1.21  chopps 	u_long cmd;
    321   1.8  chopps 	caddr_t addr;
    322  1.21  chopps 	int flag;
    323   1.8  chopps 	struct proc *p;
    324   1.6      mw {
    325  1.13  chopps 	struct winsize ws;
    326  1.13  chopps 	struct itewinsize *is;
    327  1.13  chopps 	struct itebell *ib;
    328  1.13  chopps 	ipriv_t *cci;
    329  1.13  chopps 	int error;
    330  1.13  chopps 
    331  1.13  chopps 	cci = ip->priv;
    332  1.13  chopps 	error = 0;
    333  1.13  chopps 
    334  1.13  chopps 	switch (cmd) {
    335  1.13  chopps 	case ITEIOCGWINSZ:
    336  1.13  chopps 		is = (struct itewinsize *)addr;
    337  1.13  chopps 		is->x = cci->view->display.x;
    338  1.13  chopps 		is->y = cci->view->display.y;
    339  1.13  chopps 		is->width = cci->view->display.width;
    340  1.13  chopps 		is->height = cci->view->display.height;
    341  1.13  chopps 		is->depth = cci->view->bitmap->depth;
    342  1.13  chopps 		break;
    343  1.13  chopps 	case ITEIOCSWINSZ:
    344  1.13  chopps 		is = (struct itewinsize *)addr;
    345  1.13  chopps 
    346  1.13  chopps 		if (ite_newsize(ip, is))
    347  1.13  chopps 			error = ENOMEM;
    348  1.13  chopps 		else {
    349  1.13  chopps 			ws.ws_row = ip->rows;
    350  1.13  chopps 			ws.ws_col = ip->cols;
    351  1.13  chopps 			ws.ws_xpixel = cci->view->display.width;
    352  1.13  chopps 			ws.ws_ypixel = cci->view->display.height;
    353  1.13  chopps 			ite_reset (ip);
    354  1.13  chopps 			/*
    355  1.13  chopps 			 * XXX tell tty about the change
    356  1.13  chopps 			 * XXX this is messy, but works
    357  1.13  chopps 			 */
    358  1.13  chopps 			iteioctl(0, TIOCSWINSZ, (caddr_t)&ws, 0, p);
    359  1.13  chopps 		}
    360  1.13  chopps 		break;
    361  1.13  chopps 	case ITEIOCDSPWIN:
    362  1.16  chopps 		cc_mode(ip->grf, GM_GRFON, NULL, 0, 0);
    363  1.13  chopps 		break;
    364  1.13  chopps 	case ITEIOCREMWIN:
    365  1.16  chopps 		cc_mode(ip->grf, GM_GRFOFF, NULL, 0, 0);
    366  1.13  chopps 		break;
    367  1.13  chopps 	case ITEIOCGBELL:
    368  1.13  chopps 		ib = (struct itebell *)addr;
    369  1.13  chopps 		ib->volume = bvolume;
    370  1.13  chopps 		ib->pitch = bpitch;
    371  1.13  chopps 		ib->msec = bmsec;
    372  1.13  chopps 		break;
    373  1.13  chopps 	case ITEIOCSBELL:
    374  1.13  chopps 		ib = (struct itebell *)addr;
    375  1.13  chopps 		/* bounds check */
    376  1.13  chopps 		if (ib->pitch > MAXBPITCH || ib->pitch < MINBPITCH ||
    377  1.13  chopps 		    ib->volume > MAXBVOLUME || ib->msec > MAXBTIME)
    378  1.13  chopps 			error = EINVAL;
    379  1.13  chopps 		else {
    380  1.13  chopps 			bvolume = ib->volume;
    381  1.13  chopps 			bpitch = ib->pitch;
    382  1.13  chopps 			bmsec = ib->msec;
    383  1.13  chopps 		}
    384  1.13  chopps 		break;
    385  1.13  chopps 	case VIOCSCMAP:
    386  1.13  chopps 	case VIOCGCMAP:
    387  1.13  chopps 		/*
    388  1.13  chopps 		 * XXX needs to be fixed when multiple console implemented
    389  1.13  chopps 		 * XXX watchout for that -1 its not really the kernel talking
    390  1.13  chopps 		 * XXX these two commands don't use the proc pointer though
    391  1.13  chopps 		 */
    392  1.13  chopps 		error = viewioctl(0, cmd, addr, flag, -1);
    393  1.13  chopps 		break;
    394  1.13  chopps 	default:
    395  1.13  chopps 		error = -1;
    396  1.13  chopps 		break;
    397  1.13  chopps 	}
    398  1.13  chopps 	return (error);
    399   1.1      mw }
    400   1.1      mw 
    401  1.11  chopps void
    402  1.11  chopps view_deinit(ip)
    403   1.6      mw 	struct ite_softc *ip;
    404   1.1      mw {
    405  1.13  chopps 	ip->flags &= ~ITE_INITED;
    406   1.1      mw }
    407   1.1      mw 
    408   1.6      mw /*** (M<8)-by-N routines ***/
    409   1.6      mw 
    410   1.3      mw static void
    411  1.13  chopps cursor32(struct ite_softc *ip, int flag)
    412   1.3      mw {
    413  1.13  chopps 	int cend, ofs, h, cstart, dr_plane;
    414  1.13  chopps 	u_char *pl, opclr, opset;
    415  1.13  chopps 	ipriv_t *cci;
    416  1.13  chopps 	bmap_t *bm;
    417  1.13  chopps 	view_t *v;
    418  1.13  chopps 
    419  1.13  chopps 	cci = ip->priv;
    420  1.13  chopps 	v = cci->view;
    421  1.13  chopps    	bm = v->bitmap;
    422  1.13  chopps 	dr_plane = (bm->depth > 1 ? bm->depth-1 : 0);
    423  1.13  chopps 
    424  1.13  chopps 	if (flag == END_CURSOROPT)
    425  1.13  chopps 		cci->cursor_opt--;
    426  1.13  chopps 	else if (flag == START_CURSOROPT) {
    427  1.13  chopps 		if (!cci->cursor_opt)
    428  1.13  chopps 			cursor32 (ip, ERASE_CURSOR);
    429  1.13  chopps 		cci->cursor_opt++;
    430  1.13  chopps 		return;		  /* if we are already opted. */
    431   1.6      mw 	}
    432   1.6      mw 
    433  1.13  chopps 	if (cci->cursor_opt)
    434  1.13  chopps 		return;		  /* if we are still nested. */
    435  1.13  chopps 				  /* else we draw the cursor. */
    436  1.13  chopps 	cstart = 0;
    437  1.13  chopps 	cend = ip->ftheight-1;
    438  1.13  chopps 	pl = VDISPLAY_LINE(v, dr_plane, (ip->cursory * ip->ftheight + cstart));
    439  1.13  chopps 	ofs = (ip->cursorx * ip->ftwidth);
    440   1.6      mw 
    441  1.13  chopps 	if (flag != DRAW_CURSOR && flag != END_CURSOROPT) {
    442  1.13  chopps 		/*
    443  1.13  chopps 		 * erase the cursor
    444  1.13  chopps 		 */
    445  1.13  chopps 		int h;
    446  1.13  chopps 
    447  1.13  chopps 		if (dr_plane) {
    448  1.13  chopps 			for (h = cend; h >= 0; h--) {
    449  1.13  chopps 				asm("bfclr %0@{%1:%2}" : : "a" (pl),
    450  1.13  chopps 				    "d" (ofs), "d" (ip->ftwidth));
    451  1.13  chopps 				pl += cci->row_offset;
    452  1.13  chopps 			}
    453  1.13  chopps 		} else {
    454  1.13  chopps 			for (h = cend; h >= 0; h--) {
    455  1.13  chopps 				asm("bfchg %0@{%1:%2}" : : "a" (pl),
    456  1.13  chopps 				    "d" (ofs), "d" (ip->ftwidth));
    457  1.13  chopps 				pl += cci->row_offset;
    458  1.13  chopps 			}
    459  1.13  chopps 		}
    460   1.6      mw 	}
    461   1.6      mw 
    462  1.13  chopps 	if (flag != DRAW_CURSOR && flag != MOVE_CURSOR &&
    463  1.13  chopps 	    flag != END_CURSOROPT)
    464  1.13  chopps 		return;
    465   1.6      mw 
    466  1.13  chopps 	/*
    467  1.13  chopps 	 * draw the cursor
    468  1.13  chopps 	 */
    469  1.13  chopps 
    470  1.17  chopps 	ip->cursorx = min(ip->curx, ip->cols-1);
    471   1.6      mw 	ip->cursory = ip->cury;
    472   1.6      mw 	cstart = 0;
    473   1.6      mw 	cend = ip->ftheight-1;
    474  1.13  chopps 	pl = VDISPLAY_LINE(v, dr_plane, ip->cursory * ip->ftheight + cstart);
    475  1.13  chopps 	ofs = ip->cursorx * ip->ftwidth;
    476  1.13  chopps 
    477   1.6      mw 	if (dr_plane) {
    478  1.13  chopps 		for (h = cend; h >= 0; h--) {
    479  1.13  chopps 			asm("bfset %0@{%1:%2}" : : "a" (pl),
    480  1.13  chopps 			    "d" (ofs), "d" (ip->ftwidth));
    481  1.13  chopps 			pl += cci->row_offset;
    482  1.13  chopps 		}
    483   1.6      mw 	} else {
    484  1.13  chopps 		for (h = cend; h >= 0; h--) {
    485  1.13  chopps 			asm("bfchg %0@{%1:%2}" : : "a" (pl),
    486  1.13  chopps 			    "d" (ofs), "d" (ip->ftwidth));
    487  1.13  chopps 			pl += cci->row_offset;
    488  1.13  chopps 		}
    489   1.6      mw 	}
    490   1.3      mw }
    491   1.3      mw 
    492   1.6      mw 
    493   1.6      mw static inline
    494   1.6      mw int expbits (int data)
    495   1.3      mw {
    496  1.13  chopps 	int i, nd = 0;
    497  1.13  chopps 
    498  1.13  chopps 	if (data & 1)
    499  1.13  chopps 		nd |= 0x02;
    500  1.13  chopps 	for (i=1; i < 32; i++) {
    501  1.13  chopps 		if (data & (1 << i))
    502  1.13  chopps 			nd |= 0x5 << (i-1);
    503   1.6      mw 	}
    504  1.13  chopps 	nd &= ~data;
    505  1.13  chopps 	return(~nd);
    506   1.6      mw }
    507   1.3      mw 
    508   1.3      mw 
    509   1.6      mw /* Notes: optimizations given the kernel_font_(width|height) #define'd.
    510   1.6      mw  *        the dbra loops could be elminated and unrolled using height,
    511   1.6      mw  *        the :width in the bfxxx instruction could be made immediate instead
    512   1.6      mw  *        of a data register as it now is.
    513   1.6      mw  *        the underline could be added when the loop is unrolled
    514   1.6      mw  *
    515   1.6      mw  *        It would look like hell but be very fast.*/
    516   1.6      mw 
    517   1.6      mw static void
    518   1.6      mw putc_nm (cci,p,f,co,ro,fw,fh)
    519   1.6      mw     register ipriv_t *cci;
    520   1.6      mw     register u_char  *p;
    521   1.6      mw     register u_char  *f;
    522   1.6      mw     register u_int    co;
    523   1.6      mw     register u_int    ro;
    524   1.6      mw     register u_int    fw;
    525   1.6      mw     register u_int    fh;
    526   1.6      mw {
    527   1.6      mw     while (fh--) {
    528   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    529   1.6      mw 	     "d" (*f++), "a" (p), "d" (co), "d" (fw));
    530   1.6      mw 	p += ro;
    531   1.6      mw     }
    532   1.6      mw }
    533   1.6      mw 
    534   1.6      mw static void
    535   1.6      mw putc_in (cci,p,f,co,ro,fw,fh)
    536   1.6      mw     register ipriv_t *cci;
    537   1.6      mw     register u_char  *p;
    538   1.6      mw     register u_char  *f;
    539   1.6      mw     register u_int    co;
    540   1.6      mw     register u_int    ro;
    541   1.6      mw     register u_int    fw;
    542   1.6      mw     register u_int    fh;
    543   1.6      mw {
    544   1.6      mw     while (fh--) {
    545   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    546   1.6      mw 	     "d" (~(*f++)), "a" (p), "d" (co), "d" (fw));
    547   1.6      mw 	p += ro;
    548   1.6      mw     }
    549   1.6      mw }
    550   1.6      mw 
    551   1.6      mw 
    552   1.6      mw static void
    553   1.6      mw putc_ul (cci,p,f,co,ro,fw,fh)
    554   1.6      mw     register ipriv_t *cci;
    555   1.6      mw     register u_char  *p;
    556   1.6      mw     register u_char  *f;
    557   1.6      mw     register u_int    co;
    558   1.6      mw     register u_int    ro;
    559   1.6      mw     register u_int    fw;
    560   1.6      mw     register u_int    fh;
    561   1.6      mw {
    562   1.6      mw     int underline = cci->underline;
    563   1.6      mw     while (underline--) {
    564   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    565   1.6      mw 	     "d" (*f++), "a" (p), "d" (co), "d" (fw));
    566   1.6      mw 	p += ro;
    567   1.6      mw     }
    568   1.6      mw 
    569   1.6      mw     asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    570   1.6      mw 	 "d" (expbits(*f++)), "a" (p), "d" (co), "d" (fw));
    571   1.6      mw     p += ro;
    572   1.6      mw 
    573   1.6      mw     underline = fh - cci->underline - 1;
    574   1.6      mw     while (underline--) {
    575   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    576   1.6      mw 	     "d" (*f++), "a" (p), "d" (co), "d" (fw));
    577   1.6      mw 	p += ro;
    578   1.6      mw     }
    579   1.6      mw }
    580   1.6      mw 
    581   1.6      mw 
    582   1.6      mw static void
    583   1.6      mw putc_ul_in (cci,p,f,co,ro,fw,fh)
    584   1.6      mw     register ipriv_t *cci;
    585   1.6      mw     register u_char  *p;
    586   1.6      mw     register u_char  *f;
    587   1.6      mw     register u_int    co;
    588   1.6      mw     register u_int    ro;
    589   1.6      mw     register u_int    fw;
    590   1.6      mw     register u_int    fh;
    591   1.6      mw {
    592   1.6      mw     int underline = cci->underline;
    593   1.6      mw     while (underline--) {
    594   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    595   1.6      mw 	     "d" (~(*f++)), "a" (p), "d" (co), "d" (fw));
    596   1.6      mw 	p += ro;
    597   1.6      mw     }
    598   1.6      mw 
    599   1.6      mw     asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    600   1.6      mw 	 "d" (~expbits(*f++)), "a" (p), "d" (co), "d" (fw));
    601   1.6      mw     p += ro;
    602   1.6      mw 
    603   1.6      mw     underline = fh - cci->underline - 1;
    604   1.6      mw     while (underline--) {
    605   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    606   1.6      mw 	     "d" (~(*f++)), "a" (p), "d" (co), "d" (fw));
    607   1.6      mw 	p += ro;
    608   1.6      mw     }
    609   1.6      mw }
    610   1.6      mw 
    611   1.6      mw /* bold */
    612   1.6      mw static void
    613   1.6      mw putc_bd (cci,p,f,co,ro,fw,fh)
    614   1.6      mw     register ipriv_t *cci;
    615   1.6      mw     register u_char  *p;
    616   1.6      mw     register u_char  *f;
    617   1.6      mw     register u_int    co;
    618   1.6      mw     register u_int    ro;
    619   1.6      mw     register u_int    fw;
    620   1.6      mw     register u_int    fh;
    621   1.6      mw {
    622  1.10  chopps     u_short ch;
    623   1.6      mw 
    624   1.6      mw     while (fh--) {
    625   1.6      mw 	ch = *f++;
    626   1.6      mw 	ch |= ch << 1;
    627   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    628   1.6      mw 	     "d" (ch), "a" (p), "d" (co), "d" (fw+1));
    629   1.6      mw 	p += ro;
    630   1.3      mw     }
    631   1.6      mw }
    632   1.3      mw 
    633   1.6      mw static void
    634   1.6      mw putc_bd_in (cci,p,f,co,ro,fw,fh)
    635   1.6      mw     register ipriv_t *cci;
    636   1.6      mw     register u_char  *p;
    637   1.6      mw     register u_char  *f;
    638   1.6      mw     register u_int    co;
    639   1.6      mw     register u_int    ro;
    640   1.6      mw     register u_int    fw;
    641   1.6      mw     register u_int    fh;
    642   1.6      mw {
    643  1.10  chopps     u_short ch;
    644   1.6      mw 
    645   1.6      mw     while (fh--) {
    646   1.6      mw 	ch = *f++;
    647   1.6      mw 	ch |= ch << 1;
    648   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    649   1.6      mw 	     "d" (~(ch)), "a" (p), "d" (co), "d" (fw+1));
    650   1.6      mw 	p += ro;
    651   1.3      mw     }
    652   1.6      mw }
    653   1.6      mw 
    654   1.3      mw 
    655   1.6      mw static void
    656   1.6      mw putc_bd_ul (cci,p,f,co,ro,fw,fh)
    657   1.6      mw     register ipriv_t *cci;
    658   1.6      mw     register u_char  *p;
    659   1.6      mw     register u_char  *f;
    660   1.6      mw     register u_int    co;
    661   1.6      mw     register u_int    ro;
    662   1.6      mw     register u_int    fw;
    663   1.6      mw     register u_int    fh;
    664   1.6      mw {
    665   1.6      mw     int underline = cci->underline;
    666  1.10  chopps     u_short ch;
    667   1.6      mw 
    668   1.6      mw     while (underline--) {
    669   1.6      mw 	ch = *f++;
    670   1.6      mw 	ch |= ch << 1;
    671   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    672   1.6      mw 	     "d" (ch), "a" (p), "d" (co), "d" (fw+1));
    673   1.6      mw 	p += ro;
    674   1.6      mw     }
    675   1.6      mw 
    676   1.6      mw     ch = *f++;
    677   1.6      mw     ch |= ch << 1;
    678   1.6      mw     asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    679   1.6      mw 	 "d" (expbits(ch)), "a" (p), "d" (co), "d" (fw+1));
    680   1.6      mw     p += ro;
    681   1.6      mw 
    682   1.6      mw     underline = fh - cci->underline - 1;
    683   1.6      mw     while (underline--) {
    684   1.6      mw 	ch = *f++;
    685   1.6      mw 	ch |= ch << 1;
    686   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    687   1.6      mw 	     "d" (ch), "a" (p), "d" (co), "d" (fw+1));
    688   1.6      mw 	p += ro;
    689   1.3      mw     }
    690   1.3      mw }
    691   1.3      mw 
    692   1.3      mw 
    693   1.6      mw static void
    694   1.6      mw putc_bd_ul_in (cci,p,f,co,ro,fw,fh)
    695   1.6      mw     register ipriv_t *cci;
    696   1.6      mw     register u_char  *p;
    697   1.6      mw     register u_char  *f;
    698   1.6      mw     register u_int    co;
    699   1.6      mw     register u_int    ro;
    700   1.6      mw     register u_int    fw;
    701   1.6      mw     register u_int    fh;
    702   1.1      mw {
    703   1.6      mw     int underline = cci->underline;
    704  1.10  chopps     u_short ch;
    705   1.6      mw 
    706   1.6      mw     while (underline--) {
    707   1.6      mw 	ch = *f++;
    708   1.6      mw 	ch |= ch << 1;
    709   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    710   1.6      mw 	     "d" (~(ch)), "a" (p), "d" (co), "d" (fw+1));
    711   1.6      mw 	p += ro;
    712   1.6      mw     }
    713   1.6      mw 
    714   1.6      mw     ch = *f++;
    715   1.6      mw     ch |= ch << 1;
    716   1.6      mw     asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    717   1.6      mw 	 "d" (~expbits(ch)), "a" (p), "d" (co), "d" (fw+1));
    718   1.6      mw     p += ro;
    719   1.6      mw 
    720   1.6      mw     underline = fh - cci->underline - 1;
    721   1.6      mw     while (underline--) {
    722   1.6      mw 	ch = *f++;
    723   1.6      mw 	ch |= ch << 1;
    724   1.6      mw 	asm ("bfins %0,%1@{%2:%3}" : /* no output */ :
    725   1.6      mw 	     "d" (~(ch)), "a" (p), "d" (co), "d" (fw+1));
    726   1.6      mw 	p += ro;
    727   1.6      mw     }
    728   1.6      mw }
    729   1.1      mw 
    730   1.3      mw 
    731   1.6      mw typedef void cc_putc_func ();
    732   1.6      mw 
    733   1.6      mw cc_putc_func *put_func[ATTR_ALL+1] = {
    734   1.6      mw     putc_nm,
    735   1.6      mw     putc_in,
    736   1.6      mw     putc_ul,
    737   1.6      mw     putc_ul_in,
    738   1.6      mw     putc_bd,
    739   1.6      mw     putc_bd_in,
    740   1.6      mw     putc_bd_ul,
    741   1.6      mw     putc_bd_ul_in,
    742   1.6      mw /* no support for blink */
    743   1.6      mw     putc_nm,
    744   1.6      mw     putc_in,
    745   1.6      mw     putc_ul,
    746   1.6      mw     putc_ul_in,
    747   1.6      mw     putc_bd,
    748   1.6      mw     putc_bd_in,
    749   1.6      mw     putc_bd_ul,
    750   1.6      mw     putc_bd_ul_in
    751   1.6      mw };
    752   1.3      mw 
    753   1.3      mw 
    754   1.6      mw /* FIX: shouldn't this advance the cursor even if the character to
    755   1.6      mw         be output is not available in the font? -ch */
    756   1.1      mw 
    757   1.3      mw static void
    758  1.23  chopps putc8(ip, c, dy, dx, mode)
    759  1.23  chopps 	struct ite_softc *ip;
    760  1.23  chopps 	int c, dy, dx, mode;
    761   1.1      mw {
    762  1.23  chopps 	ipriv_t *cci = (ipriv_t *) ip->priv;
    763  1.23  chopps 	/*
    764  1.23  chopps 	 * if character is higher than font has glyphs, substitute
    765  1.23  chopps 	 * highest glyph.
    766  1.23  chopps 	 */
    767  1.23  chopps 	c = (u_char)c;
    768  1.23  chopps 	if (c < ip->font_lo || c > ip->font_hi)
    769  1.23  chopps 		c = ip->font_hi;
    770  1.23  chopps 	put_func[mode](cci, cci->row_ptr[dy], cci->font_cell[c],
    771  1.23  chopps 	    cci->column_offset[dx], cci->row_offset, cci->ft_x, cci->ft_y);
    772   1.1      mw }
    773   1.1      mw 
    774   1.3      mw static void
    775  1.13  chopps clear8(struct ite_softc *ip, int sy, int sx, int h, int w)
    776   1.1      mw {
    777   1.6      mw   ipriv_t *cci = (ipriv_t *) ip->priv;
    778   1.6      mw   view_t *v = cci->view;
    779   1.6      mw   bmap_t *bm = cci->view->bitmap;
    780   1.1      mw 
    781   1.3      mw   if ((sx == 0) && (w == ip->cols))
    782   1.3      mw     {
    783   1.3      mw       /* common case: clearing whole lines */
    784   1.3      mw       while (h--)
    785   1.3      mw 	{
    786   1.6      mw 	  int i;
    787   1.6      mw 	  u_char *ptr = cci->row_ptr[sy];
    788   1.6      mw 	  for (i=0; i < ip->ftheight; i++) {
    789   1.6      mw             bzero(ptr, bm->bytes_per_row);
    790   1.6      mw             ptr += bm->bytes_per_row + bm->row_mod;			/* don't get any smart
    791   1.6      mw                                                    ideas, becuase this is for
    792   1.6      mw                                                    interleaved bitmaps */
    793   1.6      mw           }
    794   1.3      mw 	  sy++;
    795   1.3      mw 	}
    796   1.3      mw     }
    797   1.3      mw   else
    798   1.3      mw     {
    799   1.3      mw       /* clearing only part of a line */
    800   1.3      mw       /* XXX could be optimized MUCH better, but is it worth the trouble? */
    801   1.3      mw       while (h--)
    802   1.3      mw 	{
    803   1.6      mw 	  u_char *pl = cci->row_ptr[sy];
    804   1.3      mw           int ofs = sx * ip->ftwidth;
    805   1.3      mw 	  int i, j;
    806   1.3      mw 	  for (i = w-1; i >= 0; i--)
    807   1.3      mw 	    {
    808   1.3      mw 	      u_char *ppl = pl;
    809   1.3      mw               for (j = ip->ftheight-1; j >= 0; j--)
    810   1.3      mw 	        {
    811   1.3      mw 	          asm("bfclr %0@{%1:%2}"
    812   1.3      mw 	              : : "a" (ppl), "d" (ofs), "d" (ip->ftwidth));
    813   1.6      mw 	          ppl += bm->row_mod + bm->bytes_per_row;
    814   1.3      mw 	        }
    815   1.3      mw 	      ofs += ip->ftwidth;
    816   1.3      mw 	    }
    817   1.3      mw 	  sy++;
    818   1.3      mw 	}
    819   1.3      mw     }
    820   1.1      mw }
    821   1.1      mw 
    822   1.3      mw /* Note: sx is only relevant for SCROLL_LEFT or SCROLL_RIGHT.  */
    823   1.3      mw static void
    824  1.13  chopps scroll8(ip, sy, sx, count, dir)
    825   1.1      mw         register struct ite_softc *ip;
    826   1.1      mw         register int sy;
    827   1.1      mw         int dir, sx, count;
    828   1.1      mw {
    829   1.6      mw   bmap_t *bm = ((ipriv_t *)ip->priv)->view->bitmap;
    830   1.6      mw   u_char *pl = ((ipriv_t *)ip->priv)->row_ptr[sy];
    831   1.6      mw 
    832   1.1      mw   if (dir == SCROLL_UP)
    833   1.1      mw     {
    834   1.3      mw       int dy = sy - count;
    835   1.6      mw       int height = ip->bottom_margin - sy + 1;
    836   1.3      mw       int i;
    837   1.3      mw 
    838   1.6      mw       /*FIX: add scroll bitmap call */
    839  1.13  chopps         cursor32(ip, ERASE_CURSOR);
    840  1.13  chopps 	scrollbmap (bm, 0, dy*ip->ftheight,
    841   1.6      mw 		       bm->bytes_per_row >> 3, (ip->bottom_margin-dy+1)*ip->ftheight,
    842   1.6      mw 		       0, -(count*ip->ftheight), 0x1);
    843   1.6      mw /*	if (ip->cursory <= bot || ip->cursory >= dy) {
    844   1.6      mw 	    ip->cursory -= count;
    845   1.6      mw 	} */
    846   1.1      mw     }
    847   1.1      mw   else if (dir == SCROLL_DOWN)
    848   1.1      mw     {
    849   1.3      mw       int dy = sy + count;
    850   1.6      mw       int height = ip->bottom_margin - dy + 1;
    851   1.3      mw       int i;
    852   1.3      mw 
    853   1.6      mw       /* FIX: add scroll bitmap call */
    854  1.13  chopps         cursor32(ip, ERASE_CURSOR);
    855  1.13  chopps 	scrollbmap (bm, 0, sy*ip->ftheight,
    856   1.6      mw 		       bm->bytes_per_row >> 3, (ip->bottom_margin-sy+1)*ip->ftheight,
    857   1.6      mw 		       0, count*ip->ftheight, 0x1);
    858   1.6      mw /*	if (ip->cursory <= bot || ip->cursory >= sy) {
    859   1.6      mw 	    ip->cursory += count;
    860   1.6      mw 	} */
    861   1.1      mw     }
    862   1.1      mw   else if (dir == SCROLL_RIGHT)
    863   1.1      mw     {
    864   1.3      mw       int sofs = (ip->cols - count) * ip->ftwidth;
    865   1.3      mw       int dofs = (ip->cols) * ip->ftwidth;
    866   1.3      mw       int i, j;
    867   1.3      mw 
    868  1.13  chopps       cursor32(ip, ERASE_CURSOR);
    869   1.3      mw       for (j = ip->ftheight-1; j >= 0; j--)
    870   1.3      mw 	{
    871   1.3      mw 	  int sofs2 = sofs, dofs2 = dofs;
    872   1.3      mw 	  for (i = (ip->cols - (sx + count))-1; i >= 0; i--)
    873   1.3      mw 	    {
    874   1.3      mw 	      int t;
    875   1.3      mw 	      sofs2 -= ip->ftwidth;
    876   1.3      mw 	      dofs2 -= ip->ftwidth;
    877   1.3      mw 	      asm("bfextu %1@{%2:%3},%0"
    878   1.3      mw 	          : "=d" (t)
    879   1.3      mw 		  : "a" (pl), "d" (sofs2), "d" (ip->ftwidth));
    880   1.3      mw 	      asm("bfins %3,%0@{%1:%2}"
    881   1.3      mw 	          : : "a" (pl), "d" (dofs2), "d" (ip->ftwidth), "d" (t));
    882   1.3      mw 	    }
    883   1.6      mw 	  pl += bm->row_mod + bm->bytes_per_row;
    884   1.3      mw 	}
    885   1.1      mw     }
    886   1.3      mw   else /* SCROLL_LEFT */
    887   1.1      mw     {
    888   1.3      mw       int sofs = (sx) * ip->ftwidth;
    889   1.3      mw       int dofs = (sx - count) * ip->ftwidth;
    890   1.3      mw       int i, j;
    891   1.3      mw 
    892  1.13  chopps       cursor32(ip, ERASE_CURSOR);
    893   1.3      mw       for (j = ip->ftheight-1; j >= 0; j--)
    894   1.3      mw 	{
    895   1.3      mw 	  int sofs2 = sofs, dofs2 = dofs;
    896   1.3      mw 	  for (i = (ip->cols - sx)-1; i >= 0; i--)
    897   1.3      mw 	    {
    898   1.3      mw 	      int t;
    899   1.3      mw 	      asm("bfextu %1@{%2:%3},%0"
    900   1.3      mw 	          : "=d" (t)
    901   1.3      mw 		  : "a" (pl), "d" (sofs2), "d" (ip->ftwidth));
    902   1.3      mw 	      asm("bfins %3,%0@{%1:%2}"
    903   1.3      mw 	          : : "a" (pl), "d" (dofs2), "d" (ip->ftwidth), "d" (t));
    904   1.3      mw 	      sofs2 += ip->ftwidth;
    905   1.3      mw 	      dofs2 += ip->ftwidth;
    906   1.3      mw 	    }
    907   1.6      mw 	  pl += bm->row_mod + bm->bytes_per_row;
    908   1.3      mw 	}
    909   1.1      mw     }
    910   1.1      mw }
    911   1.1      mw 
    912   1.6      mw void
    913  1.13  chopps scrollbmap (bmap_t *bm, u_short x, u_short y, u_short width, u_short height, short dx, short dy, u_char mask)
    914   1.6      mw {
    915  1.10  chopps     u_short depth = bm->depth;
    916  1.10  chopps     u_short lwpr = bm->bytes_per_row >> 2;
    917   1.6      mw     if (dx) {
    918   1.6      mw     	/* FIX: */ panic ("delta x not supported in scroll bitmap yet.");
    919   1.6      mw     }
    920   1.6      mw     if (bm->flags & BMF_INTERLEAVED) {
    921   1.6      mw 	height *= depth;
    922   1.6      mw 	depth = 1;
    923   1.6      mw     }
    924   1.6      mw     if (dy == 0) {
    925   1.6      mw         return;
    926   1.6      mw     }
    927   1.6      mw     if (dy > 0) {
    928   1.6      mw     	int i;
    929   1.6      mw     	for (i=0; i < depth && mask; i++, mask >>= 1) {
    930   1.6      mw     	    if (0x1 & mask) {
    931   1.6      mw 	    	u_long *pl = (u_long *)bm->plane[i];
    932   1.6      mw 		u_long *src_y = pl + (lwpr*y);
    933   1.6      mw 		u_long *dest_y = pl + (lwpr*(y+dy));
    934   1.6      mw 		u_long count = lwpr*(height-dy);
    935   1.6      mw 		u_long *clr_y = src_y;
    936   1.6      mw 		u_long clr_count = dest_y - src_y;
    937   1.6      mw 		u_long bc, cbc;
    938   1.6      mw 
    939   1.6      mw 		src_y += count - 1;
    940   1.6      mw 		dest_y += count - 1;
    941   1.6      mw 
    942   1.6      mw 		bc = count >> 4;
    943   1.6      mw 		count &= 0xf;
    944   1.6      mw 
    945   1.6      mw 		while (bc--) {
    946   1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    947   1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    948   1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    949   1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    950   1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    951   1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    952   1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    953   1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    954   1.6      mw 		}
    955   1.6      mw 		while (count--) {
    956   1.6      mw 		    *dest_y-- = *src_y--;
    957   1.6      mw 		}
    958   1.6      mw 
    959   1.6      mw 		cbc = clr_count >> 4;
    960   1.6      mw 		clr_count &= 0xf;
    961   1.6      mw 
    962   1.6      mw 		while (cbc--) {
    963   1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    964   1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    965   1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    966   1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    967   1.6      mw 		}
    968   1.6      mw 		while (clr_count--) {
    969   1.6      mw 		    *clr_y++ = 0;
    970   1.6      mw 		}
    971   1.6      mw     	    }
    972   1.6      mw 	}
    973   1.6      mw     } else if (dy < 0) {
    974   1.6      mw     	int i;
    975   1.6      mw     	for (i=0; i < depth && mask; i++, mask >>= 1) {
    976   1.6      mw     	    if (0x1 & mask) {
    977   1.6      mw     		u_long *pl = (u_long *)bm->plane[i];
    978   1.6      mw     		u_long *src_y = pl + (lwpr*(y-dy));
    979   1.6      mw     		u_long *dest_y = pl + (lwpr*y);
    980   1.6      mw 		long count = lwpr*(height + dy);
    981   1.6      mw 		u_long *clr_y = dest_y + count;
    982   1.6      mw 		u_long clr_count = src_y - dest_y;
    983   1.6      mw 		u_long bc, cbc;
    984   1.6      mw 
    985   1.6      mw 		bc = count >> 4;
    986   1.6      mw 		count &= 0xf;
    987   1.6      mw 
    988   1.6      mw 		while (bc--) {
    989   1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    990   1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    991   1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    992   1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    993   1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    994   1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    995   1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    996   1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    997   1.6      mw 		}
    998   1.6      mw 		while (count--) {
    999   1.6      mw 		    *dest_y++ = *src_y++;
   1000   1.6      mw 		}
   1001   1.6      mw 
   1002   1.6      mw 		cbc = clr_count >> 4;
   1003   1.6      mw 		clr_count &= 0xf;
   1004   1.6      mw 
   1005   1.6      mw 		while (cbc--) {
   1006   1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
   1007   1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
   1008   1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
   1009   1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
   1010   1.6      mw 		}
   1011   1.6      mw 		while (clr_count--) {
   1012   1.6      mw 		    *clr_y++ = 0;
   1013   1.6      mw 		}
   1014   1.6      mw 	    }
   1015   1.6      mw 	}
   1016   1.6      mw     }
   1017   1.6      mw }
   1018  1.19  chopps 
   1019  1.19  chopps #endif /* NGRFCC */
   1020