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