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