Home | History | Annotate | Line # | Download | only in common
ite_hy.c revision 1.10
      1  1.10    rmind /*	$NetBSD: ite_hy.c,v 1.10 2011/02/08 20:20:14 rmind Exp $	*/
      2   1.1  thorpej 
      3   1.1  thorpej /*
      4  1.10    rmind  * Copyright (c) 1988 University of Utah.
      5   1.1  thorpej  * Copyright (c) 1990, 1993
      6   1.1  thorpej  *	The Regents of the University of California.  All rights reserved.
      7   1.2      agc  *
      8   1.2      agc  * This code is derived from software contributed to Berkeley by
      9   1.2      agc  * the Systems Programming Group of the University of Utah Computer
     10   1.2      agc  * Science Department and Mark Davies of the Department of Computer
     11   1.2      agc  * Science, Victoria University of Wellington, New Zealand.
     12   1.2      agc  *
     13   1.2      agc  * Redistribution and use in source and binary forms, with or without
     14   1.2      agc  * modification, are permitted provided that the following conditions
     15   1.2      agc  * are met:
     16   1.2      agc  * 1. Redistributions of source code must retain the above copyright
     17   1.2      agc  *    notice, this list of conditions and the following disclaimer.
     18   1.2      agc  * 2. Redistributions in binary form must reproduce the above copyright
     19   1.2      agc  *    notice, this list of conditions and the following disclaimer in the
     20   1.2      agc  *    documentation and/or other materials provided with the distribution.
     21   1.2      agc  * 3. Neither the name of the University nor the names of its contributors
     22   1.2      agc  *    may be used to endorse or promote products derived from this software
     23   1.2      agc  *    without specific prior written permission.
     24   1.2      agc  *
     25   1.2      agc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26   1.2      agc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27   1.2      agc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28   1.2      agc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29   1.2      agc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30   1.2      agc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31   1.2      agc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32   1.2      agc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33   1.2      agc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34   1.2      agc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35   1.2      agc  * SUCH DAMAGE.
     36   1.2      agc  *
     37   1.2      agc  * from: Utah $Hdr: ite_hy.c 1.1 92/01/22$
     38   1.2      agc  *
     39   1.2      agc  *	@(#)ite_hy.c	8.1 (Berkeley) 6/10/93
     40   1.2      agc  */
     41   1.2      agc 
     42   1.1  thorpej #ifdef ITECONSOLE
     43   1.1  thorpej 
     44   1.1  thorpej #include <sys/param.h>
     45   1.1  thorpej 
     46   1.9  tsutsui #include <hp300/stand/common/itereg.h>
     47   1.9  tsutsui #include <hp300/stand/common/grf_hyreg.h>
     48   1.1  thorpej 
     49   1.1  thorpej #include <hp300/stand/common/samachdep.h>
     50   1.1  thorpej #include <hp300/stand/common/itevar.h>
     51   1.1  thorpej 
     52   1.1  thorpej #define WINDOWMOVER     hyper_windowmove
     53   1.1  thorpej 
     54   1.1  thorpej #undef charX
     55   1.1  thorpej #define	charX(ip,c)	\
     56   1.1  thorpej 	(((c) % (ip)->cpl) * ((((ip)->ftwidth + 7) / 8) * 8) + (ip)->fontx)
     57   1.1  thorpej 
     58   1.3  tsutsui void hyper_ite_fontinit(struct ite_data *);
     59   1.3  tsutsui void hyper_windowmove(struct ite_data *, int, int, int, int, int, int, int);
     60   1.1  thorpej 
     61   1.1  thorpej void
     62   1.4  tsutsui hyper_init(struct ite_data *ip)
     63   1.1  thorpej {
     64   1.3  tsutsui 	struct hyboxfb *regbase = (void *)ip->regbase;
     65   1.1  thorpej 	int width;
     66   1.1  thorpej 
     67   1.1  thorpej 	ite_fontinfo(ip);
     68   1.1  thorpej 	width = ((ip->ftwidth + 7) / 8) * 8;
     69   1.1  thorpej 	ip->cpl      = (ip->fbwidth - ip->dwidth) / width;
     70   1.1  thorpej 	ip->cblanky  = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
     71   1.1  thorpej 
     72   1.3  tsutsui 	regbase->nblank = 0x05;
     73   1.1  thorpej 
     74   1.1  thorpej 	/*
     75   1.1  thorpej 	 * Clear the framebuffer on all planes.
     76   1.1  thorpej 	 */
     77   1.1  thorpej 	hyper_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
     78   1.1  thorpej 
     79   1.1  thorpej 	hyper_ite_fontinit(ip);
     80   1.1  thorpej 
     81   1.1  thorpej 	/*
     82   1.1  thorpej 	 * Stash the inverted cursor.
     83   1.1  thorpej 	 */
     84   1.1  thorpej 	hyper_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
     85   1.1  thorpej 			 ip->cblanky, ip->cblankx, ip->ftheight,
     86   1.1  thorpej 			 ip->ftwidth, RR_COPYINVERTED);
     87   1.1  thorpej }
     88   1.1  thorpej 
     89   1.1  thorpej void
     90   1.4  tsutsui hyper_ite_fontinit(struct ite_data *ip)
     91   1.1  thorpej {
     92   1.3  tsutsui 	u_char *fbmem, *dp;
     93   1.1  thorpej 	int c, l, b;
     94   1.1  thorpej 	int stride, width;
     95   1.1  thorpej 
     96   1.1  thorpej 	dp = (u_char *)(getword(ip, getword(ip, FONTROM) + FONTADDR) +
     97   1.8       he 	    (char *)ip->regbase) + FONTDATA;
     98   1.1  thorpej 	stride = ip->fbwidth >> 3;
     99   1.1  thorpej 	width = (ip->ftwidth + 7) / 8;
    100   1.1  thorpej 
    101   1.1  thorpej 	for (c = 0; c < 128; c++) {
    102   1.1  thorpej 		fbmem = (u_char *) FBBASE +
    103   1.1  thorpej 			(ip->fonty + (c / ip->cpl) * ip->ftheight) *
    104   1.1  thorpej 			stride;
    105   1.1  thorpej 		fbmem += (ip->fontx >> 3) + (c % ip->cpl) * width;
    106   1.1  thorpej 		for (l = 0; l < ip->ftheight; l++) {
    107   1.1  thorpej 			for (b = 0; b < width; b++) {
    108   1.1  thorpej 				*fbmem++ = *dp;
    109   1.1  thorpej 				dp += 2;
    110   1.1  thorpej 			}
    111   1.1  thorpej 			fbmem -= width;
    112   1.1  thorpej 			fbmem += stride;
    113   1.1  thorpej 		}
    114   1.1  thorpej 	}
    115   1.1  thorpej }
    116   1.1  thorpej 
    117   1.1  thorpej void
    118   1.6  tsutsui hyper_putc(struct ite_data *ip, int c, int dy, int dx, int mode)
    119   1.1  thorpej {
    120   1.4  tsutsui 
    121   1.1  thorpej 	hyper_windowmove(ip, charY(ip, c), charX(ip, c),
    122   1.1  thorpej 			 dy * ip->ftheight, dx * ip->ftwidth,
    123   1.1  thorpej 			 ip->ftheight, ip->ftwidth, RR_COPY);
    124   1.1  thorpej }
    125   1.1  thorpej 
    126   1.1  thorpej void
    127   1.4  tsutsui hyper_cursor(struct ite_data *ip, int flag)
    128   1.1  thorpej {
    129   1.4  tsutsui 
    130   1.1  thorpej 	switch (flag) {
    131   1.1  thorpej 	case MOVE_CURSOR:
    132   1.1  thorpej 		erase_cursor(ip);
    133   1.1  thorpej 		/* fall through ... */
    134   1.1  thorpej 	case DRAW_CURSOR:
    135   1.1  thorpej 		draw_cursor(ip);
    136   1.1  thorpej 		break;
    137   1.1  thorpej 	default:
    138   1.1  thorpej 		erase_cursor(ip);
    139   1.1  thorpej 		break;
    140   1.1  thorpej 	}
    141   1.1  thorpej }
    142   1.1  thorpej 
    143   1.1  thorpej void
    144   1.4  tsutsui hyper_clear(struct ite_data *ip, int sy, int sx, int h, int w)
    145   1.1  thorpej {
    146   1.4  tsutsui 
    147   1.1  thorpej 	hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
    148   1.1  thorpej 			 sy * ip->ftheight, sx * ip->ftwidth,
    149   1.1  thorpej 			 h  * ip->ftheight, w  * ip->ftwidth,
    150   1.1  thorpej 			 RR_CLEAR);
    151   1.1  thorpej }
    152   1.1  thorpej 
    153   1.1  thorpej void
    154   1.6  tsutsui hyper_scroll(struct ite_data *ip, int sy, int sx, int count, int dir)
    155   1.1  thorpej {
    156   1.3  tsutsui 	int dy = sy - count;
    157   1.3  tsutsui 	int height = ip->rows - sy;
    158   1.1  thorpej 
    159   1.1  thorpej 	hyper_cursor(ip, ERASE_CURSOR);
    160   1.1  thorpej 
    161   1.1  thorpej 	hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
    162   1.1  thorpej 			 dy * ip->ftheight, sx * ip->ftwidth,
    163   1.1  thorpej 			 height * ip->ftheight,
    164   1.1  thorpej 			 ip->cols  * ip->ftwidth, RR_COPY);
    165   1.1  thorpej }
    166   1.1  thorpej 
    167   1.9  tsutsui #include <hp300/stand/common/maskbits.h>
    168   1.1  thorpej 
    169   1.1  thorpej /* NOTE:
    170   1.1  thorpej  * the first element in starttab could be 0xffffffff.  making it 0
    171   1.1  thorpej  * lets us deal with a full first word in the middle loop, rather
    172   1.1  thorpej  * than having to do the multiple reads and masks that we'd
    173   1.1  thorpej  * have to do if we thought it was partial.
    174   1.1  thorpej  */
    175   1.3  tsutsui int starttab[32] = {
    176   1.1  thorpej 	0x00000000,
    177   1.1  thorpej 	0x7FFFFFFF,
    178   1.1  thorpej 	0x3FFFFFFF,
    179   1.1  thorpej 	0x1FFFFFFF,
    180   1.1  thorpej 	0x0FFFFFFF,
    181   1.1  thorpej 	0x07FFFFFF,
    182   1.1  thorpej 	0x03FFFFFF,
    183   1.1  thorpej 	0x01FFFFFF,
    184   1.1  thorpej 	0x00FFFFFF,
    185   1.1  thorpej 	0x007FFFFF,
    186   1.1  thorpej 	0x003FFFFF,
    187   1.1  thorpej 	0x001FFFFF,
    188   1.1  thorpej 	0x000FFFFF,
    189   1.1  thorpej 	0x0007FFFF,
    190   1.1  thorpej 	0x0003FFFF,
    191   1.1  thorpej 	0x0001FFFF,
    192   1.1  thorpej 	0x0000FFFF,
    193   1.1  thorpej 	0x00007FFF,
    194   1.1  thorpej 	0x00003FFF,
    195   1.1  thorpej 	0x00001FFF,
    196   1.1  thorpej 	0x00000FFF,
    197   1.1  thorpej 	0x000007FF,
    198   1.1  thorpej 	0x000003FF,
    199   1.1  thorpej 	0x000001FF,
    200   1.1  thorpej 	0x000000FF,
    201   1.1  thorpej 	0x0000007F,
    202   1.1  thorpej 	0x0000003F,
    203   1.1  thorpej 	0x0000001F,
    204   1.1  thorpej 	0x0000000F,
    205   1.1  thorpej 	0x00000007,
    206   1.1  thorpej 	0x00000003,
    207   1.1  thorpej 	0x00000001
    208   1.3  tsutsui };
    209   1.1  thorpej 
    210   1.3  tsutsui int endtab[32] = {
    211   1.1  thorpej 	0x00000000,
    212   1.1  thorpej 	0x80000000,
    213   1.1  thorpej 	0xC0000000,
    214   1.1  thorpej 	0xE0000000,
    215   1.1  thorpej 	0xF0000000,
    216   1.1  thorpej 	0xF8000000,
    217   1.1  thorpej 	0xFC000000,
    218   1.1  thorpej 	0xFE000000,
    219   1.1  thorpej 	0xFF000000,
    220   1.1  thorpej 	0xFF800000,
    221   1.1  thorpej 	0xFFC00000,
    222   1.1  thorpej 	0xFFE00000,
    223   1.1  thorpej 	0xFFF00000,
    224   1.1  thorpej 	0xFFF80000,
    225   1.1  thorpej 	0xFFFC0000,
    226   1.1  thorpej 	0xFFFE0000,
    227   1.1  thorpej 	0xFFFF0000,
    228   1.1  thorpej 	0xFFFF8000,
    229   1.1  thorpej 	0xFFFFC000,
    230   1.1  thorpej 	0xFFFFE000,
    231   1.1  thorpej 	0xFFFFF000,
    232   1.1  thorpej 	0xFFFFF800,
    233   1.1  thorpej 	0xFFFFFC00,
    234   1.1  thorpej 	0xFFFFFE00,
    235   1.1  thorpej 	0xFFFFFF00,
    236   1.1  thorpej 	0xFFFFFF80,
    237   1.1  thorpej 	0xFFFFFFC0,
    238   1.1  thorpej 	0xFFFFFFE0,
    239   1.1  thorpej 	0xFFFFFFF0,
    240   1.1  thorpej 	0xFFFFFFF8,
    241   1.1  thorpej 	0xFFFFFFFC,
    242   1.1  thorpej 	0xFFFFFFFE
    243   1.3  tsutsui };
    244   1.1  thorpej 
    245   1.1  thorpej void
    246   1.4  tsutsui hyper_windowmove(struct ite_data *ip, int sy, int sx, int dy, int dx,
    247   1.4  tsutsui     int h, int w, int func)
    248   1.1  thorpej {
    249   1.1  thorpej 	int width;		/* add to get to same position in next line */
    250   1.1  thorpej 
    251   1.1  thorpej 	unsigned int *psrcLine, *pdstLine;
    252   1.3  tsutsui 				/* pointers to line with current src and dst */
    253   1.3  tsutsui 	unsigned int *psrc;	/* pointer to current src longword */
    254   1.3  tsutsui 	unsigned int *pdst;	/* pointer to current dst longword */
    255   1.1  thorpej 
    256   1.3  tsutsui 				/* following used for looping through a line */
    257   1.1  thorpej 	unsigned int startmask, endmask;  /* masks for writing ends of dst */
    258   1.1  thorpej 	int nlMiddle;		/* whole longwords in dst */
    259   1.3  tsutsui 	int nl;			/* temp copy of nlMiddle */
    260   1.3  tsutsui 	unsigned int tmpSrc;
    261   1.3  tsutsui 				/* place to store full source word */
    262   1.3  tsutsui 	int xoffSrc;		/* offset (>= 0, < 32) from which to
    263   1.3  tsutsui 				   fetch whole longwords fetched
    264   1.3  tsutsui 				   in src */
    265   1.1  thorpej 	int nstart;		/* number of ragged bits at start of dst */
    266   1.1  thorpej 	int nend;		/* number of ragged bits at end of dst */
    267   1.1  thorpej 	int srcStartOver;	/* pulling nstart bits from src
    268   1.3  tsutsui 				   overflows into the next word? */
    269   1.1  thorpej 
    270   1.1  thorpej 	if (h == 0 || w == 0)
    271   1.1  thorpej 		return;
    272   1.1  thorpej 
    273   1.1  thorpej 	width = ip->fbwidth >> 5;
    274   1.1  thorpej 	psrcLine = ((unsigned int *) ip->fbbase) + (sy * width);
    275   1.1  thorpej 	pdstLine = ((unsigned int *) ip->fbbase) + (dy * width);
    276   1.1  thorpej 
    277   1.1  thorpej 	/* x direction doesn't matter for < 1 longword */
    278   1.3  tsutsui 	if (w <= 32) {
    279   1.3  tsutsui 		int srcBit, dstBit;     /* bit offset of src and dst */
    280   1.3  tsutsui 
    281   1.3  tsutsui 		pdstLine += (dx >> 5);
    282   1.3  tsutsui 		psrcLine += (sx >> 5);
    283   1.3  tsutsui 		psrc = psrcLine;
    284   1.1  thorpej 		pdst = pdstLine;
    285   1.1  thorpej 
    286   1.3  tsutsui 		srcBit = sx & 0x1f;
    287   1.3  tsutsui 		dstBit = dx & 0x1f;
    288   1.1  thorpej 
    289   1.3  tsutsui 		while (h--) {
    290   1.7  tsutsui 			getandputrop(psrc, srcBit, dstBit, w, pdst, func);
    291   1.3  tsutsui 		        pdst += width;
    292   1.3  tsutsui 			psrc += width;
    293   1.1  thorpej 		}
    294   1.3  tsutsui 	} else {
    295   1.7  tsutsui 		maskbits(dx, w, startmask, endmask, nlMiddle);
    296   1.3  tsutsui 		if (startmask)
    297   1.3  tsutsui 			nstart = 32 - (dx & 0x1f);
    298   1.3  tsutsui 		else
    299   1.3  tsutsui 			nstart = 0;
    300   1.3  tsutsui 		if (endmask)
    301   1.3  tsutsui 			nend = (dx + w) & 0x1f;
    302   1.1  thorpej 		else
    303   1.3  tsutsui 			nend = 0;
    304   1.3  tsutsui 
    305   1.3  tsutsui 		xoffSrc = ((sx & 0x1f) + nstart) & 0x1f;
    306   1.3  tsutsui 		srcStartOver = ((sx & 0x1f) + nstart) > 31;
    307   1.3  tsutsui 
    308   1.3  tsutsui 		pdstLine += (dx >> 5);
    309   1.3  tsutsui 		psrcLine += (sx >> 5);
    310   1.3  tsutsui 
    311   1.3  tsutsui 		while (h--) {
    312   1.3  tsutsui 		        psrc = psrcLine;
    313   1.3  tsutsui 			pdst = pdstLine;
    314   1.3  tsutsui 
    315   1.3  tsutsui 			if (startmask) {
    316   1.3  tsutsui 				getandputrop(psrc, (sx & 0x1f),
    317   1.7  tsutsui 				    (dx & 0x1f), nstart, pdst, func);
    318   1.3  tsutsui 				pdst++;
    319   1.3  tsutsui 				if (srcStartOver)
    320   1.3  tsutsui 					psrc++;
    321   1.3  tsutsui 			}
    322   1.3  tsutsui 
    323   1.3  tsutsui 			/* special case for aligned operations */
    324   1.3  tsutsui 			if (xoffSrc == 0) {
    325   1.3  tsutsui 				nl = nlMiddle;
    326   1.3  tsutsui 				while (nl--) {
    327   1.3  tsutsui 					DoRop (*pdst, func, *psrc++, *pdst);
    328   1.3  tsutsui 					pdst++;
    329   1.3  tsutsui 		    		}
    330   1.3  tsutsui 			} else {
    331   1.3  tsutsui 				nl = nlMiddle + 1;
    332   1.3  tsutsui 				while (--nl) {
    333   1.7  tsutsui 					getunalignedword(psrc, xoffSrc, tmpSrc);
    334   1.3  tsutsui 					DoRop(*pdst, func, tmpSrc, *pdst);
    335   1.3  tsutsui 					pdst++;
    336   1.3  tsutsui 					psrc++;
    337   1.3  tsutsui 				}
    338   1.3  tsutsui 			}
    339   1.3  tsutsui 
    340   1.3  tsutsui 			if (endmask) {
    341   1.3  tsutsui 				getandputrop0(psrc, xoffSrc, nend, pdst, func);
    342   1.3  tsutsui 			}
    343   1.1  thorpej 
    344   1.3  tsutsui 			pdstLine += width;
    345   1.3  tsutsui 			psrcLine += width;
    346   1.1  thorpej 		}
    347   1.1  thorpej 	}
    348   1.1  thorpej }
    349   1.1  thorpej #endif
    350