Home | History | Annotate | Line # | Download | only in dev
ite_cc.c revision 1.2
      1 /*	$Id: ite_cc.c,v 1.2 1993/08/02 18:33:34 mycroft Exp $ */
      2 
      3 #include "ite.h"
      4 #if NITE > 0
      5 
      6 #include "param.h"
      7 #include "conf.h"
      8 #include "proc.h"
      9 #include "ioctl.h"
     10 #include "tty.h"
     11 #include "systm.h"
     12 
     13 #include "itevar.h"
     14 
     15 #include "machine/cpu.h"
     16 
     17 /* XXX */
     18 #include "grfioctl.h"
     19 #include "grfvar.h"
     20 #include "grf_ccreg.h"
     21 
     22 extern unsigned char kernel_font_width, kernel_font_height;
     23 extern unsigned char kernel_font_lo, kernel_font_hi;
     24 extern unsigned char kernel_font[], kernel_cursor[];
     25 
     26 
     27 customc_init(ip)
     28 	register struct ite_softc *ip;
     29 {
     30   struct ccfb *fb;
     31   int fboff, fbsize;
     32 
     33   if (ip->grf == 0)
     34     ip->grf = &grf_softc[ip - ite_softc];
     35 
     36   ip->priv = ip->grf->g_display.gd_regaddr;
     37   fb = (struct ccfb *) ip->priv;
     38   fbsize = ip->grf->g_display.gd_fbsize;
     39 
     40 #if 0
     41   /* already done in the grf layer */
     42 
     43   /* clear the display. bzero only likes regions up to 64k, so call multiple times */
     44   for (fboff = 0; fboff < fbsize; fboff += 64*1024)
     45     bzero (fb->fb + fboff, fbsize - fboff > 64*1024 ? 64*1024 : fbsize - fboff);
     46 #endif
     47 
     48   /* this is a dreadful font, but I don't have an alternative at the moment.. */
     49   ip->font     = kernel_font;
     50   ip->font_lo  = kernel_font_lo;
     51   ip->font_hi  = kernel_font_hi;
     52   ip->ftwidth  = kernel_font_width;
     53   ip->ftheight = kernel_font_height;
     54   ip->cursor   = kernel_cursor;
     55 
     56   ip->rows     = fb->disp_height / ip->ftheight;
     57   ip->cols     = fb->disp_width  / ip->ftwidth;
     58 
     59 
     60 #if 0
     61   printf ("font@%x, cursor@%x\n", ip->font, ip->cursor);
     62   dump_copperlist (fb->cop1);
     63   dump_copperlist (fb->cop2);
     64 #endif
     65 }
     66 
     67 customc_deinit(ip)
     68 	struct ite_softc *ip;
     69 {
     70   ip->flags &= ~ITE_INITED;
     71 }
     72 
     73 
     74 void static inline
     75 customc_windowmove (src, srcx, srcy, srcmod,
     76 		    dst, dstx, dsty, dstmod, h, w, op)
     77     unsigned char *src, *dst;
     78     unsigned short srcx, srcy, srcmod;
     79     unsigned short dstx, dsty, dstmod;
     80     unsigned short h, w;
     81     unsigned char op;
     82 {
     83   int i;
     84 
     85   src += srcmod*srcy + (srcx >> 3);
     86   dst += dstmod*dsty + (dstx >> 3);
     87 
     88 #if 0
     89 printf("ccwm: %x-%x-%x-%x-%c\n", src, dst, h, w,
     90 	op == RR_XOR ? '^' : op == RR_COPY ? '|' : op == RR_CLEAR ? 'C' : 'I');
     91 #endif
     92 
     93   /* currently, only drawing to byte slots is supported... */
     94   if ((srcx & 07) || (dstx & 07) || (w & 07))
     95     panic ("customc_windowmove: odd offset");
     96 
     97   w >>= 3;
     98   while (h--)
     99     {
    100       if (src > dst)
    101 	for (i = 0; i < w; i++)
    102 	  switch (op)
    103 	    {
    104 	    case RR_COPY:
    105 	      dst[i] = src[i];
    106 	      break;
    107 
    108 	    case RR_CLEAR:
    109 	      dst[i] = 0;
    110 	      break;
    111 
    112 	    case RR_XOR:
    113 	      dst[i] ^= src[i];
    114 	      break;
    115 
    116 	    case RR_COPYINVERTED:
    117 	      dst[i] = ~src[i];
    118 	      break;
    119 	    }
    120       else
    121 	for (i = w - 1; i >= 0; i--)
    122 	  switch (op)
    123 	    {
    124 	    case RR_COPY:
    125 	      dst[i] = src[i];
    126 	      break;
    127 
    128 	    case RR_CLEAR:
    129 	      dst[i] = 0;
    130 	      break;
    131 
    132 	    case RR_XOR:
    133 	      dst[i] ^= src[i];
    134 	      break;
    135 
    136 	    case RR_COPYINVERTED:
    137 	      dst[i] = ~src[i];
    138 	      break;
    139 	    }
    140 
    141 
    142       src += srcmod;
    143       dst += dstmod;
    144     }
    145 
    146 }
    147 
    148 
    149 customc_putc(ip, c, dy, dx, mode)
    150 	register struct ite_softc *ip;
    151         register int dy, dx;
    152 	int c, mode;
    153 {
    154   register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
    155   struct ccfb *fb = (struct ccfb *) ip->priv;
    156 
    157   if (c >= ip->font_lo && c <= ip->font_hi)
    158     {
    159       c -= ip->font_lo;
    160 
    161       customc_windowmove (ip->font, 0, c * ip->ftheight, 1,
    162     			  fb->fb, fb->fb_x + dx * ip->ftwidth,
    163     			  fb->fb_y + dy * ip->ftheight,
    164     			  fb->fb_width >> 3,
    165     			  ip->ftheight, ip->ftwidth, wrr);
    166     }
    167 }
    168 
    169 customc_cursor(ip, flag)
    170 	register struct ite_softc *ip;
    171         register int flag;
    172 {
    173   struct ccfb *fb = (struct ccfb *) ip->priv;
    174 
    175   if (flag != DRAW_CURSOR)
    176     {
    177       /* erase it */
    178       customc_windowmove (ip->cursor, 0, 0, 1,
    179 	  		  fb->fb, fb->fb_x + ip->cursorx * ip->ftwidth,
    180     			  fb->fb_y + ip->cursory * ip->ftheight,
    181     			  fb->fb_width >> 3,
    182     			  ip->ftheight, ip->ftwidth, RR_XOR);
    183     }
    184   if (flag == DRAW_CURSOR || flag == MOVE_CURSOR)
    185     {
    186       /* draw it */
    187       customc_windowmove (ip->cursor, 0, 0, 1,
    188 	    		  fb->fb, fb->fb_x + ip->curx * ip->ftwidth,
    189     			  fb->fb_y + ip->cury * ip->ftheight,
    190     			  fb->fb_width >> 3,
    191     			  ip->ftheight, ip->ftwidth, RR_XOR);
    192       ip->cursorx = ip->curx;
    193       ip->cursory = ip->cury;
    194     }
    195 }
    196 
    197 customc_clear(ip, sy, sx, h, w)
    198 	struct ite_softc *ip;
    199 	register int sy, sx, h, w;
    200 {
    201   struct ccfb *fb = (struct ccfb *) ip->priv;
    202 
    203   customc_windowmove (0, 0, 0, 0,
    204   		      fb->fb, fb->fb_x + sx * ip->ftwidth,
    205     		      fb->fb_y + sy * ip->ftheight,
    206     		      fb->fb_width >> 3,
    207     		      h * ip->ftheight, w * ip->ftwidth, RR_CLEAR);
    208 }
    209 
    210 customc_blockmove(ip, sy, sx, dy, dx, h, w)
    211 	register struct ite_softc *ip;
    212 	int sy, sx, dy, dx, h, w;
    213 {
    214   struct ccfb *fb = (struct ccfb *) ip->priv;
    215 
    216   customc_windowmove(fb->fb, fb->fb_x + sx * ip->ftwidth,
    217 		     fb->fb_y + sy * ip->ftheight,
    218 		     fb->fb_width >> 3,
    219 		     fb->fb, fb->fb_x + dx * ip->ftwidth,
    220 		     fb->fb_y + dy * ip->ftheight,
    221 		     fb->fb_width >> 3,
    222 		     h * ip->ftheight, w * ip->ftwidth, RR_COPY);
    223 }
    224 
    225 customc_scroll(ip, sy, sx, count, dir)
    226         register struct ite_softc *ip;
    227         register int sy;
    228         int dir, sx, count;
    229 {
    230   register int height, dy, i;
    231 
    232   customc_cursor(ip, ERASE_CURSOR);
    233 
    234   if (dir == SCROLL_UP)
    235     {
    236       dy = sy - count;
    237       height = ip->bottom_margin - sy + 1;
    238       for (i = 0; i < height; i++)
    239 	customc_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
    240     }
    241   else if (dir == SCROLL_DOWN)
    242     {
    243       dy = sy + count;
    244       height = ip->bottom_margin - dy + 1;
    245       for (i = (height - 1); i >= 0; i--)
    246 	customc_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
    247     }
    248   else if (dir == SCROLL_RIGHT)
    249     {
    250       customc_blockmove(ip, sy, sx, sy, sx + count, 1, ip->cols - (sx + count));
    251     }
    252   else
    253     {
    254       customc_blockmove(ip, sy, sx, sy, sx - count, 1, ip->cols - sx);
    255     }
    256 }
    257 
    258 #endif
    259