Home | History | Annotate | Line # | Download | only in dev
ite_rh.c revision 1.3
      1  1.3     cgd /*	$NetBSD: ite_rh.c,v 1.3 1994/10/26 02:04:00 cgd Exp $	*/
      2  1.1  chopps 
      3  1.2  chopps #include "grfrh.h"
      4  1.2  chopps #if NGRFRH > 0
      5  1.1  chopps 
      6  1.1  chopps #include <sys/param.h>
      7  1.1  chopps #include <sys/conf.h>
      8  1.1  chopps #include <sys/proc.h>
      9  1.1  chopps #include <sys/device.h>
     10  1.1  chopps #include <sys/ioctl.h>
     11  1.1  chopps #include <sys/tty.h>
     12  1.1  chopps #include <sys/systm.h>
     13  1.1  chopps #include <dev/cons.h>
     14  1.1  chopps #include <machine/cpu.h>
     15  1.1  chopps #include <amiga/amiga/device.h>
     16  1.1  chopps #include <amiga/dev/grfioctl.h>
     17  1.1  chopps #include <amiga/dev/grfvar.h>
     18  1.1  chopps #include <amiga/dev/grf_rhreg.h>
     19  1.1  chopps #include <amiga/dev/itevar.h>
     20  1.1  chopps 
     21  1.1  chopps 
     22  1.1  chopps /*
     23  1.1  chopps  * grfrh_cnprobe is called when the console is being initialized
     24  1.1  chopps  * i.e. very early.  grfconfig() has been called, so this implies
     25  1.1  chopps  * that rt_init() was called.  If we are functioning rh_inited
     26  1.1  chopps  * will be true.
     27  1.1  chopps  */
     28  1.1  chopps int
     29  1.1  chopps grfrh_cnprobe()
     30  1.1  chopps {
     31  1.1  chopps 	static int done;
     32  1.1  chopps 	int rv;
     33  1.1  chopps 
     34  1.1  chopps 	if (done == 0)
     35  1.1  chopps 		rv = CN_INTERNAL;
     36  1.1  chopps 	else
     37  1.1  chopps 		rv = CN_NORMAL;
     38  1.1  chopps 	done = 1;
     39  1.1  chopps 	return(rv);
     40  1.1  chopps }
     41  1.1  chopps 
     42  1.1  chopps void
     43  1.1  chopps grfrh_iteinit(gp)
     44  1.1  chopps 	struct grf_softc *gp;
     45  1.1  chopps {
     46  1.1  chopps 	gp->g_iteinit = rh_init;
     47  1.1  chopps 	gp->g_itedeinit = rh_deinit;
     48  1.1  chopps 	gp->g_iteclear = rh_clear;
     49  1.1  chopps 	gp->g_iteputc = rh_putc;
     50  1.1  chopps 	gp->g_itescroll = rh_scroll;
     51  1.1  chopps 	gp->g_itecursor = rh_cursor;
     52  1.1  chopps }
     53  1.1  chopps 
     54  1.1  chopps void
     55  1.1  chopps rh_init(ip)
     56  1.1  chopps 	struct ite_softc *ip;
     57  1.1  chopps {
     58  1.1  chopps 	struct MonDef *md;
     59  1.1  chopps 	extern unsigned char RZ3StdPalette[];
     60  1.1  chopps 
     61  1.1  chopps #if 0 /* Not in ite_rt.c - DC */
     62  1.1  chopps 	if (ip->grf == 0)
     63  1.1  chopps 		ip->grf = &grf_softc[ip - ite_softc];
     64  1.1  chopps #endif
     65  1.1  chopps 
     66  1.1  chopps 	ip->priv = ip->grf->g_data;
     67  1.1  chopps 	md = (struct MonDef *) ip->priv;
     68  1.1  chopps 
     69  1.1  chopps 	ip->cols = md->TX;
     70  1.1  chopps 	ip->rows = md->TY;
     71  1.1  chopps }
     72  1.1  chopps 
     73  1.1  chopps 
     74  1.1  chopps void
     75  1.1  chopps rh_cursor(ip, flag)
     76  1.1  chopps 	struct ite_softc *ip;
     77  1.1  chopps 	int flag;
     78  1.1  chopps {
     79  1.1  chopps 	volatile u_char *ba = ip->grf->g_regkva;
     80  1.1  chopps 
     81  1.1  chopps 	if (flag == START_CURSOROPT || flag == END_CURSOROPT)
     82  1.1  chopps 		return;
     83  1.1  chopps 
     84  1.1  chopps 	if (flag == ERASE_CURSOR) {
     85  1.1  chopps #if 0
     86  1.1  chopps 		/* disable cursor */
     87  1.1  chopps 		WCrt (ba, CRT_ID_CURSOR_START,
     88  1.1  chopps 		    RCrt (ba, CRT_ID_CURSOR_START) | 0x20);
     89  1.1  chopps #endif
     90  1.1  chopps 	} else {
     91  1.1  chopps 		int pos = ip->curx + ip->cury * ip->cols;
     92  1.1  chopps #if 0
     93  1.1  chopps 		/* make sure to enable cursor */
     94  1.1  chopps 		WCrt (ba, CRT_ID_CURSOR_START,
     95  1.1  chopps 		    RCrt (ba, CRT_ID_CURSOR_START) & ~0x20);
     96  1.1  chopps #endif
     97  1.1  chopps 
     98  1.1  chopps 		/* and position it */
     99  1.1  chopps 		RZ3SetCursorPos (ip->grf, pos);
    100  1.1  chopps 
    101  1.1  chopps 		ip->cursorx = ip->curx;
    102  1.1  chopps 		ip->cursory = ip->cury;
    103  1.1  chopps 	}
    104  1.1  chopps }
    105  1.1  chopps 
    106  1.1  chopps 
    107  1.1  chopps 
    108  1.1  chopps static void
    109  1.1  chopps screen_up(ip, top, bottom, lines)
    110  1.1  chopps 	struct ite_softc *ip;
    111  1.1  chopps 	int top;
    112  1.1  chopps 	int bottom;
    113  1.1  chopps 	int lines;
    114  1.1  chopps {
    115  1.1  chopps 	volatile u_char * ba = ip->grf->g_regkva;
    116  1.1  chopps 	volatile u_char * fb = ip->grf->g_fbkva;
    117  1.1  chopps 
    118  1.1  chopps 	/* do some bounds-checking here.. */
    119  1.1  chopps 	if (top >= bottom)
    120  1.1  chopps 		return;
    121  1.1  chopps 
    122  1.1  chopps 	if (top + lines >= bottom) {
    123  1.1  chopps 		RZ3AlphaErase(ip->grf, 0, top, bottom - top, ip->cols);
    124  1.1  chopps 		return;
    125  1.1  chopps 	}
    126  1.1  chopps 
    127  1.1  chopps 	RZ3AlphaCopy(ip->grf, 0, top+lines, 0, top, ip->cols, bottom-top-lines+1);
    128  1.1  chopps 	RZ3AlphaErase(ip->grf, 0, bottom - lines + 1, ip->cols, lines);
    129  1.1  chopps }
    130  1.1  chopps 
    131  1.1  chopps static void
    132  1.1  chopps screen_down (ip, top, bottom, lines)
    133  1.1  chopps 	struct ite_softc *ip;
    134  1.1  chopps 	int top;
    135  1.1  chopps 	int bottom;
    136  1.1  chopps 	int lines;
    137  1.1  chopps {
    138  1.1  chopps 	volatile u_char * ba = ip->grf->g_regkva;
    139  1.1  chopps 	volatile u_char * fb = ip->grf->g_fbkva;
    140  1.1  chopps 
    141  1.1  chopps 	/* do some bounds-checking here.. */
    142  1.1  chopps 	if (top >= bottom)
    143  1.1  chopps 		return;
    144  1.1  chopps 
    145  1.1  chopps 	if (top + lines >= bottom) {
    146  1.1  chopps 		RZ3AlphaErase(ip->grf, 0, top, bottom - top, ip->cols);
    147  1.1  chopps 		return;
    148  1.1  chopps 	}
    149  1.1  chopps 
    150  1.1  chopps 	RZ3AlphaCopy(ip->grf, 0, top, 0, top+lines, ip->cols, bottom-top-lines+1);
    151  1.1  chopps 	RZ3AlphaErase(ip->grf, 0, top, ip->cols, lines);
    152  1.1  chopps }
    153  1.1  chopps 
    154  1.1  chopps void
    155  1.1  chopps rh_deinit(ip)
    156  1.1  chopps 	struct ite_softc *ip;
    157  1.1  chopps {
    158  1.1  chopps 	ip->flags &= ~ITE_INITED;
    159  1.1  chopps }
    160  1.1  chopps 
    161  1.1  chopps 
    162  1.1  chopps void
    163  1.1  chopps rh_putc(ip, c, dy, dx, mode)
    164  1.1  chopps 	struct ite_softc *ip;
    165  1.1  chopps 	int c;
    166  1.1  chopps 	int dy;
    167  1.1  chopps 	int dx;
    168  1.1  chopps 	int mode;
    169  1.1  chopps {
    170  1.1  chopps 	volatile u_char * ba = ip->grf->g_regkva;
    171  1.1  chopps 	volatile u_char * fb = ip->grf->g_fbkva;
    172  1.1  chopps 	register u_char attr;
    173  1.1  chopps 
    174  1.1  chopps 	attr = (mode & ATTR_INV) ? 0x21 : 0x10;
    175  1.1  chopps 	if (mode & ATTR_UL)     attr  = 0x01;	/* ???????? */
    176  1.1  chopps 	if (mode & ATTR_BOLD)   attr |= 0x08;
    177  1.1  chopps 	if (mode & ATTR_BLINK)  attr |= 0x80;
    178  1.1  chopps 
    179  1.1  chopps 	fb += 4 * (dy * ip->cols + dx);
    180  1.1  chopps 	*fb++ = c; *fb = attr;
    181  1.1  chopps }
    182  1.1  chopps 
    183  1.1  chopps void
    184  1.1  chopps rh_clear(ip, sy, sx, h, w)
    185  1.1  chopps 	struct ite_softc *ip;
    186  1.1  chopps 	int sy;
    187  1.1  chopps 	int sx;
    188  1.1  chopps 	int h;
    189  1.1  chopps 	int w;
    190  1.1  chopps {
    191  1.1  chopps 	RZ3AlphaErase (ip->grf, sx, sy, w, h);
    192  1.1  chopps }
    193  1.1  chopps 
    194  1.1  chopps void
    195  1.1  chopps rh_scroll(ip, sy, sx, count, dir)
    196  1.1  chopps 	struct ite_softc *ip;
    197  1.1  chopps 	int sy;
    198  1.1  chopps 	int sx;
    199  1.1  chopps 	int count;
    200  1.1  chopps 	int dir;
    201  1.1  chopps {
    202  1.1  chopps 	volatile u_char * ba = ip->grf->g_regkva;
    203  1.1  chopps 	u_long * fb = (u_long *) ip->grf->g_fbkva;
    204  1.1  chopps 	register int height, dy, i;
    205  1.1  chopps 
    206  1.1  chopps 	rh_cursor(ip, ERASE_CURSOR);
    207  1.1  chopps 
    208  1.1  chopps 	if (dir == SCROLL_UP) {
    209  1.1  chopps 		screen_up(ip, sy - count, ip->bottom_margin, count);
    210  1.1  chopps 		/* bcopy(fb + sy * ip->cols, fb + (sy - count) * ip->cols,
    211  1.1  chopps 		    4 * (ip->bottom_margin - sy + 1) * ip->cols); */
    212  1.1  chopps 		/* rh_clear(ip, ip->bottom_margin + 1 - count, 0,
    213  1.1  chopps 		    count, ip->cols); */
    214  1.1  chopps 	} else if (dir == SCROLL_DOWN) {
    215  1.1  chopps 		screen_down(ip, sy, ip->bottom_margin, count);
    216  1.1  chopps 		/* bcopy(fb + sy * ip->cols, fb + (sy + count) * ip->cols,
    217  1.1  chopps 		    4 * (ip->bottom_margin - sy - count + 1) * ip->cols); */
    218  1.1  chopps 		/* rh_clear(ip, sy, 0, count, ip->cols); */
    219  1.1  chopps 	} else if (dir == SCROLL_RIGHT) {
    220  1.1  chopps 		RZ3AlphaCopy(ip->grf, sx, sy, sx + count, sy,
    221  1.1  chopps 		    ip->cols - (sx + count), 1);
    222  1.1  chopps 		RZ3AlphaErase(ip->grf, sx, sy, count, 1);
    223  1.1  chopps 	} else {
    224  1.1  chopps 		RZ3AlphaCopy(ip->grf, sx + count, sy, sx, sy,
    225  1.1  chopps 		    ip->cols - (sx + count), 1);
    226  1.1  chopps 		RZ3AlphaErase(ip->grf, ip->cols - count, sy, count, 1);
    227  1.1  chopps 	}
    228  1.1  chopps }
    229  1.2  chopps #endif /* NGRFRH */
    230