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