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