Home | History | Annotate | Line # | Download | only in dev
ite_cc.c revision 1.28.4.1
      1  1.28.4.1      is /*	$NetBSD: ite_cc.c,v 1.28.4.1 2000/06/25 20:49:49 is 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.13  chopps 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.28.4.1      is #if !defined(USE_C_BFOPS) && !defined(__m68k__)
     89      1.27      is #define USE_C_BFOPS
     90  1.28.4.1      is #endif
     91  1.28.4.1      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.16  chopps void view_deinit __P((struct ite_softc *));
    131      1.16  chopps void view_init __P((struct ite_softc *));
    132       1.3      mw 
    133      1.13  chopps static void putc8 __P((struct ite_softc *, int, int, int, int));
    134      1.13  chopps static void clear8 __P((struct ite_softc *, int, int, int, int));
    135      1.13  chopps static void scroll8 __P((struct ite_softc *, int, int, int, int));
    136      1.13  chopps static void cursor32 __P((struct ite_softc *, int));
    137      1.13  chopps static void scrollbmap __P((bmap_t *, u_short, u_short, u_short, u_short,
    138      1.13  chopps     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.25   veego int ite_newsize __P((struct ite_softc *, struct itewinsize *));
    154      1.25   veego static void putc_nm __P((ipriv_t *, u_char *, u_char *, u_int, u_int,
    155      1.25   veego 			u_int, u_int));
    156      1.25   veego static void putc_in __P((ipriv_t *, u_char *, u_char *, u_int, u_int,
    157      1.25   veego 			u_int, u_int));
    158      1.25   veego static void putc_ul __P((ipriv_t *, u_char *, u_char *, u_int, u_int,
    159      1.25   veego 			u_int, u_int));
    160      1.25   veego static void putc_ul_in __P((ipriv_t *, u_char *, u_char *, u_int, u_int,
    161      1.25   veego 			u_int, u_int));
    162      1.25   veego static void putc_bd __P((ipriv_t *, u_char *, u_char *, u_int, u_int,
    163      1.25   veego 			u_int, u_int));
    164      1.25   veego static void putc_bd_in __P((ipriv_t *, u_char *, u_char *, u_int, u_int,
    165      1.25   veego 			u_int, u_int));
    166      1.25   veego static void putc_bd_ul __P((ipriv_t *, u_char *, u_char *, u_int, u_int,
    167      1.25   veego 			u_int, u_int));
    168      1.25   veego static void putc_bd_ul_in __P((ipriv_t *, u_char *, u_char *, u_int, u_int,
    169      1.25   veego 			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.16  chopps grfcc_cnprobe()
    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.18  chopps  * 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.16  chopps grfcc_iteinit(gp)
    186      1.16  chopps 	struct grf_softc *gp;
    187       1.1      mw {
    188      1.16  chopps 	gp->g_itecursor = cursor32;
    189      1.16  chopps 	gp->g_iteputc = putc8;
    190      1.16  chopps 	gp->g_iteclear = clear8;
    191      1.16  chopps 	gp->g_itescroll = scroll8;
    192      1.16  chopps 	gp->g_iteinit = view_init;
    193      1.16  chopps 	gp->g_itedeinit = view_deinit;
    194       1.1      mw }
    195       1.1      mw 
    196       1.6      mw int
    197      1.13  chopps ite_newsize(ip, winsz)
    198      1.13  chopps 	struct ite_softc *ip;
    199      1.13  chopps 	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.13  chopps 	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.16  chopps 	cci->view = views[0].view;
    218      1.13  chopps 
    219  1.28.4.1      is 	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.13  chopps 	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.6      mw 
    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.13  chopps 
    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.13  chopps 	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.6      mw 
    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.13  chopps 	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.13  chopps 	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.6      mw 
    267      1.13  chopps 	return (error);
    268       1.3      mw }
    269       1.3      mw 
    270      1.11  chopps void
    271      1.11  chopps view_init(ip)
    272       1.3      mw 	register struct ite_softc *ip;
    273       1.3      mw {
    274      1.13  chopps 	struct itewinsize wsz;
    275      1.13  chopps 	ipriv_t *cci;
    276      1.13  chopps 
    277      1.13  chopps 	cci = ip->priv;
    278       1.6      mw 
    279      1.13  chopps 	if (cci)
    280      1.13  chopps 		return;
    281       1.6      mw 
    282       1.6      mw 	ip->font     = kernel_font;
    283       1.6      mw 	ip->font_lo  = kernel_font_lo;
    284       1.6      mw 	ip->font_hi  = kernel_font_hi;
    285       1.6      mw 	ip->ftwidth  = kernel_font_width;
    286       1.6      mw 	ip->ftheight = kernel_font_height;
    287       1.6      mw 	ip->ftbaseline = kernel_font_baseline;
    288       1.6      mw 	ip->ftboldsmear = kernel_font_boldsmear;
    289       1.6      mw 
    290       1.6      mw 	/* Find the correct set of rendering routines for this font.  */
    291      1.13  chopps 	if (ip->ftwidth > 8)
    292       1.6      mw 		panic("kernel font size not supported");
    293      1.13  chopps 	cci = alloc_chipmem(sizeof (*cci));
    294      1.13  chopps 	if (cci == NULL)
    295      1.13  chopps 		panic("no memory for console device.");
    296       1.1      mw 
    297       1.6      mw 	ip->priv = cci;
    298       1.6      mw 	cci->cursor_opt = 0;
    299       1.6      mw 	cci->view = NULL;
    300       1.6      mw 	cci->row_ptr = NULL;
    301       1.6      mw 	cci->column_offset = NULL;
    302       1.1      mw 
    303      1.13  chopps 	wsz.x = ite_default_x;
    304      1.13  chopps 	wsz.y = ite_default_y;
    305      1.13  chopps 	wsz.width = ite_default_width;
    306      1.13  chopps 	wsz.height = ite_default_height;
    307      1.13  chopps 	wsz.depth = ite_default_depth;
    308      1.13  chopps 
    309      1.13  chopps 	ite_newsize (ip, &wsz);
    310      1.16  chopps 	cc_mode(ip->grf, GM_GRFON, NULL, 0, 0);
    311       1.6      mw }
    312       1.6      mw 
    313       1.6      mw int
    314       1.8  chopps ite_grf_ioctl (ip, cmd, addr, flag, p)
    315       1.8  chopps 	struct ite_softc *ip;
    316      1.21  chopps 	u_long cmd;
    317       1.8  chopps 	caddr_t addr;
    318      1.21  chopps 	int flag;
    319       1.8  chopps 	struct proc *p;
    320       1.6      mw {
    321      1.13  chopps 	struct winsize ws;
    322      1.13  chopps 	struct itewinsize *is;
    323      1.13  chopps 	ipriv_t *cci;
    324      1.13  chopps 	int error;
    325      1.13  chopps 
    326      1.13  chopps 	cci = ip->priv;
    327      1.13  chopps 	error = 0;
    328      1.13  chopps 
    329      1.13  chopps 	switch (cmd) {
    330      1.13  chopps 	case ITEIOCGWINSZ:
    331      1.13  chopps 		is = (struct itewinsize *)addr;
    332      1.13  chopps 		is->x = cci->view->display.x;
    333      1.13  chopps 		is->y = cci->view->display.y;
    334      1.13  chopps 		is->width = cci->view->display.width;
    335      1.13  chopps 		is->height = cci->view->display.height;
    336      1.13  chopps 		is->depth = cci->view->bitmap->depth;
    337      1.13  chopps 		break;
    338      1.13  chopps 	case ITEIOCSWINSZ:
    339      1.13  chopps 		is = (struct itewinsize *)addr;
    340      1.13  chopps 
    341      1.13  chopps 		if (ite_newsize(ip, is))
    342      1.13  chopps 			error = ENOMEM;
    343      1.13  chopps 		else {
    344      1.13  chopps 			ws.ws_row = ip->rows;
    345      1.13  chopps 			ws.ws_col = ip->cols;
    346      1.13  chopps 			ws.ws_xpixel = cci->view->display.width;
    347      1.13  chopps 			ws.ws_ypixel = cci->view->display.height;
    348      1.13  chopps 			ite_reset (ip);
    349      1.13  chopps 			/*
    350      1.13  chopps 			 * XXX tell tty about the change
    351      1.13  chopps 			 * XXX this is messy, but works
    352      1.13  chopps 			 */
    353      1.13  chopps 			iteioctl(0, TIOCSWINSZ, (caddr_t)&ws, 0, p);
    354      1.13  chopps 		}
    355      1.13  chopps 		break;
    356      1.13  chopps 	case ITEIOCDSPWIN:
    357      1.16  chopps 		cc_mode(ip->grf, GM_GRFON, NULL, 0, 0);
    358      1.13  chopps 		break;
    359      1.13  chopps 	case ITEIOCREMWIN:
    360      1.16  chopps 		cc_mode(ip->grf, GM_GRFOFF, NULL, 0, 0);
    361      1.13  chopps 		break;
    362      1.13  chopps 	case VIOCSCMAP:
    363      1.13  chopps 	case VIOCGCMAP:
    364      1.13  chopps 		/*
    365      1.13  chopps 		 * XXX needs to be fixed when multiple console implemented
    366      1.13  chopps 		 * XXX watchout for that -1 its not really the kernel talking
    367      1.13  chopps 		 * XXX these two commands don't use the proc pointer though
    368      1.13  chopps 		 */
    369      1.25   veego 		error = viewioctl(0, cmd, addr, -1, p);
    370      1.13  chopps 		break;
    371      1.13  chopps 	default:
    372      1.13  chopps 		error = -1;
    373      1.13  chopps 		break;
    374      1.13  chopps 	}
    375      1.13  chopps 	return (error);
    376       1.1      mw }
    377       1.1      mw 
    378      1.11  chopps void
    379      1.11  chopps view_deinit(ip)
    380       1.6      mw 	struct ite_softc *ip;
    381       1.1      mw {
    382      1.13  chopps 	ip->flags &= ~ITE_INITED;
    383       1.1      mw }
    384       1.1      mw 
    385       1.6      mw /*** (M<8)-by-N routines ***/
    386       1.6      mw 
    387       1.3      mw static void
    388      1.13  chopps cursor32(struct ite_softc *ip, int flag)
    389       1.3      mw {
    390      1.13  chopps 	int cend, ofs, h, cstart, dr_plane;
    391      1.25   veego 	u_char *pl;
    392      1.13  chopps 	ipriv_t *cci;
    393      1.13  chopps 	bmap_t *bm;
    394      1.13  chopps 	view_t *v;
    395      1.13  chopps 
    396      1.13  chopps 	cci = ip->priv;
    397      1.13  chopps 	v = cci->view;
    398      1.13  chopps    	bm = v->bitmap;
    399      1.13  chopps 	dr_plane = (bm->depth > 1 ? bm->depth-1 : 0);
    400      1.13  chopps 
    401      1.13  chopps 	if (flag == END_CURSOROPT)
    402      1.13  chopps 		cci->cursor_opt--;
    403      1.13  chopps 	else if (flag == START_CURSOROPT) {
    404      1.13  chopps 		if (!cci->cursor_opt)
    405      1.13  chopps 			cursor32 (ip, ERASE_CURSOR);
    406      1.13  chopps 		cci->cursor_opt++;
    407      1.13  chopps 		return;		  /* if we are already opted. */
    408       1.6      mw 	}
    409       1.6      mw 
    410      1.13  chopps 	if (cci->cursor_opt)
    411      1.13  chopps 		return;		  /* if we are still nested. */
    412      1.13  chopps 				  /* else we draw the cursor. */
    413      1.13  chopps 	cstart = 0;
    414      1.13  chopps 	cend = ip->ftheight-1;
    415      1.13  chopps 	pl = VDISPLAY_LINE(v, dr_plane, (ip->cursory * ip->ftheight + cstart));
    416      1.13  chopps 	ofs = (ip->cursorx * ip->ftwidth);
    417       1.6      mw 
    418      1.13  chopps 	if (flag != DRAW_CURSOR && flag != END_CURSOROPT) {
    419      1.13  chopps 		/*
    420      1.13  chopps 		 * erase the cursor
    421      1.13  chopps 		 */
    422      1.13  chopps 		int h;
    423      1.13  chopps 
    424      1.13  chopps 		if (dr_plane) {
    425      1.13  chopps 			for (h = cend; h >= 0; h--) {
    426      1.27      is 				BFCLR(pl, ofs, ip->ftwidth);
    427      1.13  chopps 				pl += cci->row_offset;
    428      1.13  chopps 			}
    429      1.13  chopps 		} else {
    430      1.13  chopps 			for (h = cend; h >= 0; h--) {
    431      1.27      is 				BFCHG(pl, ofs, ip->ftwidth);
    432      1.13  chopps 				pl += cci->row_offset;
    433      1.13  chopps 			}
    434      1.13  chopps 		}
    435       1.6      mw 	}
    436       1.6      mw 
    437      1.13  chopps 	if (flag != DRAW_CURSOR && flag != MOVE_CURSOR &&
    438      1.13  chopps 	    flag != END_CURSOROPT)
    439      1.13  chopps 		return;
    440       1.6      mw 
    441      1.13  chopps 	/*
    442      1.13  chopps 	 * draw the cursor
    443      1.13  chopps 	 */
    444      1.13  chopps 
    445      1.17  chopps 	ip->cursorx = min(ip->curx, ip->cols-1);
    446       1.6      mw 	ip->cursory = ip->cury;
    447       1.6      mw 	cstart = 0;
    448       1.6      mw 	cend = ip->ftheight-1;
    449      1.13  chopps 	pl = VDISPLAY_LINE(v, dr_plane, ip->cursory * ip->ftheight + cstart);
    450      1.13  chopps 	ofs = ip->cursorx * ip->ftwidth;
    451      1.13  chopps 
    452       1.6      mw 	if (dr_plane) {
    453      1.13  chopps 		for (h = cend; h >= 0; h--) {
    454      1.27      is 			BFSET(pl, ofs, ip->ftwidth);
    455      1.13  chopps 			pl += cci->row_offset;
    456      1.13  chopps 		}
    457       1.6      mw 	} else {
    458      1.13  chopps 		for (h = cend; h >= 0; h--) {
    459      1.27      is 			BFCHG(pl, ofs, ip->ftwidth);
    460      1.13  chopps 			pl += cci->row_offset;
    461      1.13  chopps 		}
    462       1.6      mw 	}
    463       1.3      mw }
    464       1.3      mw 
    465       1.6      mw 
    466       1.6      mw static inline
    467       1.6      mw int expbits (int data)
    468       1.3      mw {
    469      1.13  chopps 	int i, nd = 0;
    470      1.13  chopps 
    471      1.13  chopps 	if (data & 1)
    472      1.13  chopps 		nd |= 0x02;
    473      1.13  chopps 	for (i=1; i < 32; i++) {
    474      1.13  chopps 		if (data & (1 << i))
    475      1.13  chopps 			nd |= 0x5 << (i-1);
    476       1.6      mw 	}
    477      1.13  chopps 	nd &= ~data;
    478      1.13  chopps 	return(~nd);
    479       1.6      mw }
    480       1.3      mw 
    481       1.3      mw 
    482       1.6      mw /* Notes: optimizations given the kernel_font_(width|height) #define'd.
    483       1.6      mw  *        the dbra loops could be elminated and unrolled using height,
    484       1.6      mw  *        the :width in the bfxxx instruction could be made immediate instead
    485       1.6      mw  *        of a data register as it now is.
    486       1.6      mw  *        the underline could be added when the loop is unrolled
    487       1.6      mw  *
    488       1.6      mw  *        It would look like hell but be very fast.*/
    489       1.6      mw 
    490       1.6      mw static void
    491       1.6      mw putc_nm (cci,p,f,co,ro,fw,fh)
    492       1.6      mw     register ipriv_t *cci;
    493       1.6      mw     register u_char  *p;
    494       1.6      mw     register u_char  *f;
    495       1.6      mw     register u_int    co;
    496       1.6      mw     register u_int    ro;
    497       1.6      mw     register u_int    fw;
    498       1.6      mw     register u_int    fh;
    499       1.6      mw {
    500       1.6      mw     while (fh--) {
    501      1.27      is 	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 static void
    507       1.6      mw putc_in (cci,p,f,co,ro,fw,fh)
    508       1.6      mw     register ipriv_t *cci;
    509       1.6      mw     register u_char  *p;
    510       1.6      mw     register u_char  *f;
    511       1.6      mw     register u_int    co;
    512       1.6      mw     register u_int    ro;
    513       1.6      mw     register u_int    fw;
    514       1.6      mw     register u_int    fh;
    515       1.6      mw {
    516       1.6      mw     while (fh--) {
    517      1.27      is 	BFINS(~(*f++),p,co,fw);
    518       1.6      mw 	p += ro;
    519       1.6      mw     }
    520       1.6      mw }
    521       1.6      mw 
    522       1.6      mw 
    523       1.6      mw static void
    524       1.6      mw putc_ul (cci,p,f,co,ro,fw,fh)
    525       1.6      mw     register ipriv_t *cci;
    526       1.6      mw     register u_char  *p;
    527       1.6      mw     register u_char  *f;
    528       1.6      mw     register u_int    co;
    529       1.6      mw     register u_int    ro;
    530       1.6      mw     register u_int    fw;
    531       1.6      mw     register u_int    fh;
    532       1.6      mw {
    533       1.6      mw     int underline = cci->underline;
    534       1.6      mw     while (underline--) {
    535      1.27      is 	BFINS(*f++,p,co,fw);
    536       1.6      mw 	p += ro;
    537       1.6      mw     }
    538       1.6      mw 
    539      1.27      is     BFINS(expbits(*f++),p,co,fw);
    540       1.6      mw     p += ro;
    541       1.6      mw 
    542       1.6      mw     underline = fh - cci->underline - 1;
    543       1.6      mw     while (underline--) {
    544      1.27      is 	BFINS(*f++,p,co,fw);
    545       1.6      mw 	p += ro;
    546       1.6      mw     }
    547       1.6      mw }
    548       1.6      mw 
    549       1.6      mw 
    550       1.6      mw static void
    551       1.6      mw putc_ul_in (cci,p,f,co,ro,fw,fh)
    552       1.6      mw     register ipriv_t *cci;
    553       1.6      mw     register u_char  *p;
    554       1.6      mw     register u_char  *f;
    555       1.6      mw     register u_int    co;
    556       1.6      mw     register u_int    ro;
    557       1.6      mw     register u_int    fw;
    558       1.6      mw     register u_int    fh;
    559       1.6      mw {
    560       1.6      mw     int underline = cci->underline;
    561       1.6      mw     while (underline--) {
    562      1.27      is 	BFINS(~(*f++),p,co,fw);
    563       1.6      mw 	p += ro;
    564       1.6      mw     }
    565       1.6      mw 
    566      1.27      is     BFINS(~expbits(*f++),p,co,fw);
    567       1.6      mw     p += ro;
    568       1.6      mw 
    569       1.6      mw     underline = fh - cci->underline - 1;
    570       1.6      mw     while (underline--) {
    571      1.27      is 	BFINS(~(*f++),p,co,fw);
    572       1.6      mw 	p += ro;
    573       1.6      mw     }
    574       1.6      mw }
    575       1.6      mw 
    576       1.6      mw /* bold */
    577       1.6      mw static void
    578       1.6      mw putc_bd (cci,p,f,co,ro,fw,fh)
    579       1.6      mw     register ipriv_t *cci;
    580       1.6      mw     register u_char  *p;
    581       1.6      mw     register u_char  *f;
    582       1.6      mw     register u_int    co;
    583       1.6      mw     register u_int    ro;
    584       1.6      mw     register u_int    fw;
    585       1.6      mw     register u_int    fh;
    586       1.6      mw {
    587      1.10  chopps     u_short ch;
    588       1.6      mw 
    589       1.6      mw     while (fh--) {
    590       1.6      mw 	ch = *f++;
    591  1.28.4.1      is 	ch |= ch >> 1;
    592  1.28.4.1      is 	BFINS(ch,p,co,fw);
    593       1.6      mw 	p += ro;
    594       1.3      mw     }
    595       1.6      mw }
    596       1.3      mw 
    597       1.6      mw static void
    598       1.6      mw putc_bd_in (cci,p,f,co,ro,fw,fh)
    599       1.6      mw     register ipriv_t *cci;
    600       1.6      mw     register u_char  *p;
    601       1.6      mw     register u_char  *f;
    602       1.6      mw     register u_int    co;
    603       1.6      mw     register u_int    ro;
    604       1.6      mw     register u_int    fw;
    605       1.6      mw     register u_int    fh;
    606       1.6      mw {
    607      1.10  chopps     u_short ch;
    608       1.6      mw 
    609       1.6      mw     while (fh--) {
    610       1.6      mw 	ch = *f++;
    611  1.28.4.1      is 	ch |= ch >> 1;
    612  1.28.4.1      is 	BFINS(~ch,p,co,fw);
    613       1.6      mw 	p += ro;
    614       1.3      mw     }
    615       1.6      mw }
    616       1.6      mw 
    617       1.3      mw 
    618       1.6      mw static void
    619       1.6      mw putc_bd_ul (cci,p,f,co,ro,fw,fh)
    620       1.6      mw     register ipriv_t *cci;
    621       1.6      mw     register u_char  *p;
    622       1.6      mw     register u_char  *f;
    623       1.6      mw     register u_int    co;
    624       1.6      mw     register u_int    ro;
    625       1.6      mw     register u_int    fw;
    626       1.6      mw     register u_int    fh;
    627       1.6      mw {
    628       1.6      mw     int underline = cci->underline;
    629      1.10  chopps     u_short ch;
    630       1.6      mw 
    631       1.6      mw     while (underline--) {
    632       1.6      mw 	ch = *f++;
    633  1.28.4.1      is 	ch |= ch >> 1;
    634  1.28.4.1      is 	BFINS(ch,p,co,fw);
    635       1.6      mw 	p += ro;
    636       1.6      mw     }
    637       1.6      mw 
    638       1.6      mw     ch = *f++;
    639  1.28.4.1      is     ch |= ch >> 1;
    640  1.28.4.1      is     BFINS(expbits(ch),p,co,fw);
    641       1.6      mw     p += ro;
    642       1.6      mw 
    643       1.6      mw     underline = fh - cci->underline - 1;
    644       1.6      mw     while (underline--) {
    645       1.6      mw 	ch = *f++;
    646  1.28.4.1      is 	ch |= ch >> 1;
    647  1.28.4.1      is 	BFINS(ch,p,co,fw);
    648       1.6      mw 	p += ro;
    649       1.3      mw     }
    650       1.3      mw }
    651       1.3      mw 
    652       1.3      mw 
    653       1.6      mw static void
    654       1.6      mw putc_bd_ul_in (cci,p,f,co,ro,fw,fh)
    655       1.6      mw     register ipriv_t *cci;
    656       1.6      mw     register u_char  *p;
    657       1.6      mw     register u_char  *f;
    658       1.6      mw     register u_int    co;
    659       1.6      mw     register u_int    ro;
    660       1.6      mw     register u_int    fw;
    661       1.6      mw     register u_int    fh;
    662       1.1      mw {
    663       1.6      mw     int underline = cci->underline;
    664      1.10  chopps     u_short ch;
    665       1.6      mw 
    666       1.6      mw     while (underline--) {
    667       1.6      mw 	ch = *f++;
    668  1.28.4.1      is 	ch |= ch >> 1;
    669  1.28.4.1      is 	BFINS(~ch,p,co,fw);
    670       1.6      mw 	p += ro;
    671       1.6      mw     }
    672       1.6      mw 
    673       1.6      mw     ch = *f++;
    674  1.28.4.1      is     ch |= ch >> 1;
    675  1.28.4.1      is     BFINS(~expbits(ch),p,co,fw);
    676       1.6      mw     p += ro;
    677       1.6      mw 
    678       1.6      mw     underline = fh - cci->underline - 1;
    679       1.6      mw     while (underline--) {
    680       1.6      mw 	ch = *f++;
    681  1.28.4.1      is 	ch |= ch >> 1;
    682  1.28.4.1      is 	BFINS(~ch,p,co,fw);
    683       1.6      mw 	p += ro;
    684       1.6      mw     }
    685       1.6      mw }
    686       1.1      mw 
    687       1.3      mw 
    688      1.25   veego typedef void cc_putc_func __P((ipriv_t *, u_char *, u_char *, u_int, u_int,
    689      1.25   veego 			u_int, u_int));
    690       1.6      mw 
    691       1.6      mw cc_putc_func *put_func[ATTR_ALL+1] = {
    692       1.6      mw     putc_nm,
    693       1.6      mw     putc_in,
    694       1.6      mw     putc_ul,
    695       1.6      mw     putc_ul_in,
    696       1.6      mw     putc_bd,
    697       1.6      mw     putc_bd_in,
    698       1.6      mw     putc_bd_ul,
    699       1.6      mw     putc_bd_ul_in,
    700       1.6      mw /* no support for blink */
    701       1.6      mw     putc_nm,
    702       1.6      mw     putc_in,
    703       1.6      mw     putc_ul,
    704       1.6      mw     putc_ul_in,
    705       1.6      mw     putc_bd,
    706       1.6      mw     putc_bd_in,
    707       1.6      mw     putc_bd_ul,
    708       1.6      mw     putc_bd_ul_in
    709       1.6      mw };
    710       1.3      mw 
    711       1.3      mw 
    712       1.6      mw /* FIX: shouldn't this advance the cursor even if the character to
    713       1.6      mw         be output is not available in the font? -ch */
    714       1.1      mw 
    715       1.3      mw static void
    716      1.23  chopps putc8(ip, c, dy, dx, mode)
    717      1.23  chopps 	struct ite_softc *ip;
    718      1.23  chopps 	int c, dy, dx, mode;
    719       1.1      mw {
    720      1.23  chopps 	ipriv_t *cci = (ipriv_t *) ip->priv;
    721      1.23  chopps 	/*
    722      1.23  chopps 	 * if character is higher than font has glyphs, substitute
    723      1.23  chopps 	 * highest glyph.
    724      1.23  chopps 	 */
    725      1.23  chopps 	c = (u_char)c;
    726      1.23  chopps 	if (c < ip->font_lo || c > ip->font_hi)
    727      1.23  chopps 		c = ip->font_hi;
    728      1.23  chopps 	put_func[mode](cci, cci->row_ptr[dy], cci->font_cell[c],
    729      1.23  chopps 	    cci->column_offset[dx], cci->row_offset, cci->ft_x, cci->ft_y);
    730       1.1      mw }
    731       1.1      mw 
    732       1.3      mw static void
    733      1.13  chopps clear8(struct ite_softc *ip, int sy, int sx, int h, int w)
    734       1.1      mw {
    735       1.6      mw   ipriv_t *cci = (ipriv_t *) ip->priv;
    736       1.6      mw   bmap_t *bm = cci->view->bitmap;
    737       1.1      mw 
    738       1.3      mw   if ((sx == 0) && (w == ip->cols))
    739       1.3      mw     {
    740       1.3      mw       /* common case: clearing whole lines */
    741       1.3      mw       while (h--)
    742       1.3      mw 	{
    743       1.6      mw 	  int i;
    744       1.6      mw 	  u_char *ptr = cci->row_ptr[sy];
    745       1.6      mw 	  for (i=0; i < ip->ftheight; i++) {
    746       1.6      mw             bzero(ptr, bm->bytes_per_row);
    747       1.6      mw             ptr += bm->bytes_per_row + bm->row_mod;			/* don't get any smart
    748       1.6      mw                                                    ideas, becuase this is for
    749       1.6      mw                                                    interleaved bitmaps */
    750       1.6      mw           }
    751       1.3      mw 	  sy++;
    752       1.3      mw 	}
    753       1.3      mw     }
    754       1.3      mw   else
    755       1.3      mw     {
    756       1.3      mw       /* clearing only part of a line */
    757       1.3      mw       /* XXX could be optimized MUCH better, but is it worth the trouble? */
    758       1.3      mw       while (h--)
    759       1.3      mw 	{
    760       1.6      mw 	  u_char *pl = cci->row_ptr[sy];
    761       1.3      mw           int ofs = sx * ip->ftwidth;
    762       1.3      mw 	  int i, j;
    763       1.3      mw 	  for (i = w-1; i >= 0; i--)
    764       1.3      mw 	    {
    765       1.3      mw 	      u_char *ppl = pl;
    766       1.3      mw               for (j = ip->ftheight-1; j >= 0; j--)
    767       1.3      mw 	        {
    768      1.27      is 		  BFCLR(ppl, ofs, ip->ftwidth);
    769       1.6      mw 	          ppl += bm->row_mod + bm->bytes_per_row;
    770       1.3      mw 	        }
    771       1.3      mw 	      ofs += ip->ftwidth;
    772       1.3      mw 	    }
    773       1.3      mw 	  sy++;
    774       1.3      mw 	}
    775       1.3      mw     }
    776       1.1      mw }
    777       1.1      mw 
    778       1.3      mw /* Note: sx is only relevant for SCROLL_LEFT or SCROLL_RIGHT.  */
    779       1.3      mw static void
    780      1.13  chopps scroll8(ip, sy, sx, count, dir)
    781       1.1      mw         register struct ite_softc *ip;
    782       1.1      mw         register int sy;
    783       1.1      mw         int dir, sx, count;
    784       1.1      mw {
    785       1.6      mw   bmap_t *bm = ((ipriv_t *)ip->priv)->view->bitmap;
    786       1.6      mw   u_char *pl = ((ipriv_t *)ip->priv)->row_ptr[sy];
    787       1.6      mw 
    788       1.1      mw   if (dir == SCROLL_UP)
    789       1.1      mw     {
    790       1.3      mw       int dy = sy - count;
    791       1.3      mw 
    792       1.6      mw       /*FIX: add scroll bitmap call */
    793      1.13  chopps         cursor32(ip, ERASE_CURSOR);
    794      1.13  chopps 	scrollbmap (bm, 0, dy*ip->ftheight,
    795       1.6      mw 		       bm->bytes_per_row >> 3, (ip->bottom_margin-dy+1)*ip->ftheight,
    796       1.6      mw 		       0, -(count*ip->ftheight), 0x1);
    797       1.6      mw /*	if (ip->cursory <= bot || ip->cursory >= dy) {
    798       1.6      mw 	    ip->cursory -= count;
    799       1.6      mw 	} */
    800       1.1      mw     }
    801       1.1      mw   else if (dir == SCROLL_DOWN)
    802       1.1      mw     {
    803       1.3      mw 
    804       1.6      mw       /* FIX: add scroll bitmap call */
    805      1.13  chopps         cursor32(ip, ERASE_CURSOR);
    806      1.13  chopps 	scrollbmap (bm, 0, sy*ip->ftheight,
    807       1.6      mw 		       bm->bytes_per_row >> 3, (ip->bottom_margin-sy+1)*ip->ftheight,
    808       1.6      mw 		       0, count*ip->ftheight, 0x1);
    809       1.6      mw /*	if (ip->cursory <= bot || ip->cursory >= sy) {
    810       1.6      mw 	    ip->cursory += count;
    811       1.6      mw 	} */
    812       1.1      mw     }
    813       1.1      mw   else if (dir == SCROLL_RIGHT)
    814       1.1      mw     {
    815       1.3      mw       int sofs = (ip->cols - count) * ip->ftwidth;
    816       1.3      mw       int dofs = (ip->cols) * ip->ftwidth;
    817       1.3      mw       int i, j;
    818       1.3      mw 
    819      1.13  chopps       cursor32(ip, ERASE_CURSOR);
    820       1.3      mw       for (j = ip->ftheight-1; j >= 0; j--)
    821       1.3      mw 	{
    822       1.3      mw 	  int sofs2 = sofs, dofs2 = dofs;
    823       1.3      mw 	  for (i = (ip->cols - (sx + count))-1; i >= 0; i--)
    824       1.3      mw 	    {
    825       1.3      mw 	      int t;
    826       1.3      mw 	      sofs2 -= ip->ftwidth;
    827       1.3      mw 	      dofs2 -= ip->ftwidth;
    828      1.27      is 	      BFEXT(t, pl, sofs2, ip->ftwidth);
    829      1.27      is 	      BFINS(t, pl, dofs2, ip->ftwidth);
    830       1.3      mw 	    }
    831       1.6      mw 	  pl += bm->row_mod + bm->bytes_per_row;
    832       1.3      mw 	}
    833       1.1      mw     }
    834       1.3      mw   else /* SCROLL_LEFT */
    835       1.1      mw     {
    836       1.3      mw       int sofs = (sx) * ip->ftwidth;
    837       1.3      mw       int dofs = (sx - count) * ip->ftwidth;
    838       1.3      mw       int i, j;
    839       1.3      mw 
    840      1.13  chopps       cursor32(ip, ERASE_CURSOR);
    841       1.3      mw       for (j = ip->ftheight-1; j >= 0; j--)
    842       1.3      mw 	{
    843       1.3      mw 	  int sofs2 = sofs, dofs2 = dofs;
    844       1.3      mw 	  for (i = (ip->cols - sx)-1; i >= 0; i--)
    845       1.3      mw 	    {
    846       1.3      mw 	      int t;
    847      1.27      is 	      BFEXT(t, pl, sofs2, ip->ftwidth);
    848      1.27      is 	      BFINS(t, pl, dofs2, ip->ftwidth);
    849       1.3      mw 	      sofs2 += ip->ftwidth;
    850       1.3      mw 	      dofs2 += ip->ftwidth;
    851       1.3      mw 	    }
    852       1.6      mw 	  pl += bm->row_mod + bm->bytes_per_row;
    853       1.3      mw 	}
    854       1.1      mw     }
    855       1.1      mw }
    856       1.1      mw 
    857       1.6      mw void
    858      1.13  chopps scrollbmap (bmap_t *bm, u_short x, u_short y, u_short width, u_short height, short dx, short dy, u_char mask)
    859       1.6      mw {
    860      1.10  chopps     u_short depth = bm->depth;
    861      1.10  chopps     u_short lwpr = bm->bytes_per_row >> 2;
    862       1.6      mw     if (dx) {
    863       1.6      mw     	/* FIX: */ panic ("delta x not supported in scroll bitmap yet.");
    864       1.6      mw     }
    865       1.6      mw     if (bm->flags & BMF_INTERLEAVED) {
    866       1.6      mw 	height *= depth;
    867       1.6      mw 	depth = 1;
    868       1.6      mw     }
    869       1.6      mw     if (dy == 0) {
    870       1.6      mw         return;
    871       1.6      mw     }
    872       1.6      mw     if (dy > 0) {
    873       1.6      mw     	int i;
    874       1.6      mw     	for (i=0; i < depth && mask; i++, mask >>= 1) {
    875       1.6      mw     	    if (0x1 & mask) {
    876       1.6      mw 	    	u_long *pl = (u_long *)bm->plane[i];
    877       1.6      mw 		u_long *src_y = pl + (lwpr*y);
    878       1.6      mw 		u_long *dest_y = pl + (lwpr*(y+dy));
    879       1.6      mw 		u_long count = lwpr*(height-dy);
    880       1.6      mw 		u_long *clr_y = src_y;
    881       1.6      mw 		u_long clr_count = dest_y - src_y;
    882       1.6      mw 		u_long bc, cbc;
    883       1.6      mw 
    884       1.6      mw 		src_y += count - 1;
    885       1.6      mw 		dest_y += count - 1;
    886       1.6      mw 
    887       1.6      mw 		bc = count >> 4;
    888       1.6      mw 		count &= 0xf;
    889       1.6      mw 
    890       1.6      mw 		while (bc--) {
    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 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    894       1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    895       1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    896       1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    897       1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    898       1.6      mw 		    *dest_y-- = *src_y--; *dest_y-- = *src_y--;
    899       1.6      mw 		}
    900       1.6      mw 		while (count--) {
    901       1.6      mw 		    *dest_y-- = *src_y--;
    902       1.6      mw 		}
    903       1.6      mw 
    904       1.6      mw 		cbc = clr_count >> 4;
    905       1.6      mw 		clr_count &= 0xf;
    906       1.6      mw 
    907       1.6      mw 		while (cbc--) {
    908       1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    909       1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    910       1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    911       1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    912       1.6      mw 		}
    913       1.6      mw 		while (clr_count--) {
    914       1.6      mw 		    *clr_y++ = 0;
    915       1.6      mw 		}
    916       1.6      mw     	    }
    917       1.6      mw 	}
    918       1.6      mw     } else if (dy < 0) {
    919       1.6      mw     	int i;
    920       1.6      mw     	for (i=0; i < depth && mask; i++, mask >>= 1) {
    921       1.6      mw     	    if (0x1 & mask) {
    922       1.6      mw     		u_long *pl = (u_long *)bm->plane[i];
    923       1.6      mw     		u_long *src_y = pl + (lwpr*(y-dy));
    924       1.6      mw     		u_long *dest_y = pl + (lwpr*y);
    925       1.6      mw 		long count = lwpr*(height + dy);
    926       1.6      mw 		u_long *clr_y = dest_y + count;
    927       1.6      mw 		u_long clr_count = src_y - dest_y;
    928       1.6      mw 		u_long bc, cbc;
    929       1.6      mw 
    930       1.6      mw 		bc = count >> 4;
    931       1.6      mw 		count &= 0xf;
    932       1.6      mw 
    933       1.6      mw 		while (bc--) {
    934       1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    935       1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    936       1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    937       1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    938       1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    939       1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    940       1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    941       1.6      mw 		    *dest_y++ = *src_y++; *dest_y++ = *src_y++;
    942       1.6      mw 		}
    943       1.6      mw 		while (count--) {
    944       1.6      mw 		    *dest_y++ = *src_y++;
    945       1.6      mw 		}
    946       1.6      mw 
    947       1.6      mw 		cbc = clr_count >> 4;
    948       1.6      mw 		clr_count &= 0xf;
    949       1.6      mw 
    950       1.6      mw 		while (cbc--) {
    951       1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    952       1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    953       1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    954       1.6      mw 		    *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
    955       1.6      mw 		}
    956       1.6      mw 		while (clr_count--) {
    957       1.6      mw 		    *clr_y++ = 0;
    958       1.6      mw 		}
    959       1.6      mw 	    }
    960       1.6      mw 	}
    961       1.6      mw     }
    962       1.6      mw }
    963      1.19  chopps 
    964      1.19  chopps #endif /* NGRFCC */
    965