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