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