ite_cc.c revision 1.4 1 1.4 leo /* $NetBSD: ite_cc.c,v 1.4 1995/05/28 19:45:39 leo Exp $ */
2 1.1 leo
3 1.1 leo /*
4 1.1 leo * Copyright (c) 1994 Christian E. Hopps
5 1.1 leo * All rights reserved.
6 1.1 leo *
7 1.1 leo * Redistribution and use in source and binary forms, with or without
8 1.1 leo * modification, are permitted provided that the following conditions
9 1.1 leo * are met:
10 1.1 leo * 1. Redistributions of source code must retain the above copyright
11 1.1 leo * notice, this list of conditions and the following disclaimer.
12 1.1 leo * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 leo * notice, this list of conditions and the following disclaimer in the
14 1.1 leo * documentation and/or other materials provided with the distribution.
15 1.1 leo * 3. All advertising materials mentioning features or use of this software
16 1.1 leo * must display the following acknowledgement:
17 1.1 leo * This product includes software developed by Christian E. Hopps.
18 1.1 leo * 4. The name of the author may not be used to endorse or promote products
19 1.1 leo * derived from this software without specific prior written permission
20 1.1 leo *
21 1.1 leo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 leo * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 leo * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 leo * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 leo * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 leo * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 leo * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 leo * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 leo * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 leo * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 leo */
32 1.1 leo
33 1.1 leo #include "grf.h"
34 1.1 leo #if NGRF > 0
35 1.1 leo
36 1.1 leo #include <sys/param.h>
37 1.1 leo #include <sys/conf.h>
38 1.1 leo #include <sys/proc.h>
39 1.1 leo #include <sys/device.h>
40 1.1 leo #include <sys/ioctl.h>
41 1.1 leo #include <sys/tty.h>
42 1.1 leo #include <sys/systm.h>
43 1.1 leo #include <sys/queue.h>
44 1.1 leo #include <sys/termios.h>
45 1.1 leo #include <sys/malloc.h>
46 1.1 leo #include <dev/cons.h>
47 1.1 leo #include <machine/cpu.h>
48 1.1 leo #include <atari/dev/itevar.h>
49 1.1 leo #include <atari/dev/iteioctl.h>
50 1.1 leo #include <atari/dev/grfioctl.h>
51 1.1 leo #include <atari/dev/grfabs_reg.h>
52 1.1 leo #include <atari/dev/grfvar.h>
53 1.1 leo #include <atari/dev/font.h>
54 1.1 leo #include <atari/dev/viewioctl.h>
55 1.1 leo #include <atari/dev/viewvar.h>
56 1.1 leo
57 1.1 leo /*
58 1.1 leo * This is what ip->priv points to;
59 1.1 leo * it contains local variables for custom-chip ites.
60 1.1 leo */
61 1.1 leo struct ite_priv {
62 1.1 leo u_char **row_ptr; /* array of pointers into the bitmap */
63 1.1 leo u_long row_bytes;
64 1.1 leo u_long cursor_opt;
65 1.1 leo u_short *column_offset; /* array of offsets for columns */
66 1.1 leo u_int row_offset; /* the row offset */
67 1.1 leo u_short width; /* the bitmap width */
68 1.1 leo u_short underline; /* where the underline goes */
69 1.1 leo u_short ft_x; /* the font width */
70 1.1 leo u_short ft_y; /* the font height */
71 1.1 leo u_char *font_cell[256];/* the font pointer */
72 1.1 leo };
73 1.1 leo typedef struct ite_priv ipriv_t;
74 1.1 leo
75 1.1 leo /*
76 1.1 leo * We need the following space to get an ite-console setup before
77 1.1 leo * the VM-system is brought up. We setup for a 1280x960 monitor with
78 1.1 leo * an 8x8 font.
79 1.1 leo */
80 1.1 leo extern int atari_realconfig;
81 1.1 leo
82 1.1 leo #define CONS_MAXROW 120 /* Max. number of rows on console */
83 1.1 leo #define CONS_MAXCOL 160 /* Max. number of columns on console */
84 1.1 leo static u_short con_columns[CONS_MAXCOL];
85 1.1 leo static u_char *con_rows[CONS_MAXROW];
86 1.1 leo static ipriv_t con_ipriv;
87 1.1 leo
88 1.1 leo extern font_info font_info_8x8;
89 1.1 leo extern font_info font_info_8x16;
90 1.1 leo
91 1.1 leo static void view_init __P((struct ite_softc *));
92 1.1 leo static void view_deinit __P((struct ite_softc *));
93 1.1 leo static int ite_newsize __P((struct ite_softc *, struct itewinsize *));
94 1.1 leo static void cursor32 __P((struct ite_softc *, int));
95 1.1 leo static void putc8 __P((struct ite_softc *, int, int, int, int));
96 1.1 leo static void clear8 __P((struct ite_softc *, int, int, int, int));
97 1.1 leo static void scroll8 __P((struct ite_softc *, int, int, int, int));
98 1.1 leo static void scrollbmap __P((bmap_t *, u_short, u_short, u_short, u_short,
99 1.1 leo short, short));
100 1.1 leo
101 1.1 leo /*
102 1.1 leo * Patchable
103 1.1 leo */
104 1.1 leo int ite_default_x = 0; /* def leftedge offset */
105 1.1 leo int ite_default_y = 0; /* def topedge offset */
106 1.1 leo int ite_default_width = 640; /* def width */
107 1.1 leo int ite_default_depth = 1; /* def depth */
108 1.1 leo int ite_default_height = 400; /* def height */
109 1.1 leo
110 1.1 leo /*
111 1.1 leo * called from grf_cc to return console priority
112 1.1 leo */
113 1.1 leo int
114 1.1 leo grfcc_cnprobe()
115 1.1 leo {
116 1.1 leo return(CN_INTERNAL);
117 1.1 leo }
118 1.1 leo /*
119 1.1 leo * called from grf_cc to init ite portion of
120 1.1 leo * grf_softc struct
121 1.1 leo */
122 1.1 leo void
123 1.1 leo grfcc_iteinit(gp)
124 1.1 leo struct grf_softc *gp;
125 1.1 leo {
126 1.1 leo
127 1.1 leo gp->g_itecursor = cursor32;
128 1.1 leo gp->g_iteputc = putc8;
129 1.1 leo gp->g_iteclear = clear8;
130 1.1 leo gp->g_itescroll = scroll8;
131 1.1 leo gp->g_iteinit = view_init;
132 1.1 leo gp->g_itedeinit = view_deinit;
133 1.1 leo }
134 1.1 leo
135 1.1 leo static void
136 1.1 leo view_deinit(ip)
137 1.1 leo struct ite_softc *ip;
138 1.1 leo {
139 1.1 leo ip->flags &= ~ITE_INITED;
140 1.1 leo }
141 1.1 leo
142 1.1 leo static void
143 1.1 leo view_init(ip)
144 1.1 leo register struct ite_softc *ip;
145 1.1 leo {
146 1.1 leo struct itewinsize wsz;
147 1.1 leo ipriv_t *cci;
148 1.1 leo
149 1.1 leo if(cci = ip->priv)
150 1.1 leo return;
151 1.1 leo
152 1.1 leo #if defined(KFONT_8X8)
153 1.1 leo ip->font = font_info_8x8;
154 1.1 leo #else
155 1.1 leo ip->font = font_info_8x16;
156 1.1 leo #endif
157 1.1 leo
158 1.1 leo /* Find the correct set of rendering routines for this font. */
159 1.1 leo if(ip->font.width != 8)
160 1.1 leo panic("kernel font size not supported");
161 1.1 leo
162 1.1 leo if(!atari_realconfig)
163 1.1 leo ip->priv = cci = &con_ipriv;
164 1.1 leo else ip->priv = cci = (ipriv_t*)malloc(sizeof(*cci), M_DEVBUF,M_WAITOK);
165 1.1 leo if(cci == NULL)
166 1.1 leo panic("No memory for ite-view");
167 1.1 leo bzero(cci, sizeof(*cci));
168 1.1 leo
169 1.1 leo cci->cursor_opt = 0;
170 1.1 leo cci->row_ptr = NULL;
171 1.1 leo cci->column_offset = NULL;
172 1.1 leo
173 1.1 leo wsz.x = ite_default_x;
174 1.1 leo wsz.y = ite_default_y;
175 1.1 leo wsz.width = ite_default_width;
176 1.1 leo wsz.height = ite_default_height;
177 1.1 leo wsz.depth = ite_default_depth;
178 1.1 leo
179 1.1 leo ite_newsize (ip, &wsz);
180 1.1 leo
181 1.1 leo /*
182 1.1 leo * Only console will be turned on by default..
183 1.1 leo */
184 1.1 leo if(ip->flags & ITE_ISCONS)
185 1.1 leo ip->grf->g_mode(ip->grf, GM_GRFON, NULL, 0, 0);
186 1.1 leo }
187 1.1 leo
188 1.1 leo static int
189 1.1 leo ite_newsize(ip, winsz)
190 1.1 leo struct ite_softc *ip;
191 1.1 leo struct itewinsize *winsz;
192 1.1 leo {
193 1.4 leo struct view_size vs;
194 1.4 leo ipriv_t *cci = ip->priv;
195 1.4 leo u_long fbp, i, j;
196 1.4 leo int error = 0;
197 1.4 leo view_t *view;
198 1.1 leo
199 1.1 leo vs.x = winsz->x;
200 1.1 leo vs.y = winsz->y;
201 1.1 leo vs.width = winsz->width;
202 1.1 leo vs.height = winsz->height;
203 1.1 leo vs.depth = winsz->depth;
204 1.2 leo
205 1.1 leo error = viewioctl(ip->grf->g_viewdev, VIOCSSIZE, &vs, 0, -1);
206 1.4 leo view = viewview(ip->grf->g_viewdev);
207 1.1 leo
208 1.1 leo /*
209 1.1 leo * Reinitialize our structs
210 1.1 leo */
211 1.1 leo ip->cols = view->display.width / ip->font.width;
212 1.1 leo ip->rows = view->display.height / ip->font.height;
213 1.1 leo
214 1.1 leo /*
215 1.1 leo * save new values so that future opens use them
216 1.1 leo * this may not be correct when we implement Virtual Consoles
217 1.1 leo */
218 1.1 leo ite_default_height = view->display.height;
219 1.1 leo ite_default_width = view->display.width;
220 1.1 leo ite_default_x = view->display.x;
221 1.1 leo ite_default_y = view->display.y;
222 1.1 leo ite_default_depth = view->bitmap->depth;
223 1.1 leo
224 1.1 leo if(cci->row_ptr && (cci->row_ptr != con_rows)) {
225 1.1 leo free(cci->row_ptr, M_DEVBUF);
226 1.1 leo cci->row_ptr = NULL;
227 1.1 leo }
228 1.1 leo if(cci->column_offset && (cci->column_offset != con_columns)) {
229 1.1 leo free(cci->column_offset, M_DEVBUF);
230 1.1 leo cci->column_offset = NULL;
231 1.1 leo }
232 1.1 leo
233 1.1 leo if(!atari_realconfig) {
234 1.1 leo cci->row_ptr = con_rows;
235 1.1 leo cci->column_offset = con_columns;
236 1.1 leo }
237 1.1 leo else {
238 1.2 leo cci->row_ptr = malloc(sizeof(u_char *) * ip->rows,M_DEVBUF,M_NOWAIT);
239 1.2 leo cci->column_offset = malloc(sizeof(u_int)*ip->cols,M_DEVBUF,M_NOWAIT);
240 1.1 leo }
241 1.1 leo
242 1.1 leo if(!cci->row_ptr || !cci->column_offset)
243 1.1 leo panic("No memory for ite-view");
244 1.1 leo
245 1.1 leo cci->width = view->bitmap->bytes_per_row << 3;
246 1.1 leo cci->underline = ip->font.baseline + 1;
247 1.1 leo cci->row_offset = view->bitmap->bytes_per_row;
248 1.1 leo cci->ft_x = ip->font.width;
249 1.1 leo cci->ft_y = ip->font.height;
250 1.1 leo cci->row_bytes = cci->row_offset * cci->ft_y;
251 1.1 leo cci->row_ptr[0] = view->bitmap->plane;
252 1.1 leo for(i = 1; i < ip->rows; i++)
253 1.1 leo cci->row_ptr[i] = cci->row_ptr[i-1] + cci->row_bytes;
254 1.1 leo
255 1.1 leo /*
256 1.1 leo * Initialize the column offsets to point at the correct location
257 1.1 leo * in the first plane. This definitely assumes a font width of 8!
258 1.1 leo */
259 1.1 leo j = view->bitmap->depth * 2;
260 1.1 leo cci->column_offset[0] = 0;
261 1.1 leo for(i = 1; i < ip->cols; i++)
262 1.1 leo cci->column_offset[i] = ((i >> 1) * j) + (i & 1);
263 1.1 leo
264 1.1 leo /* initialize the font cell pointers */
265 1.1 leo cci->font_cell[ip->font.font_lo] = ip->font.font_p;
266 1.1 leo for(i = ip->font.font_lo+1; i <= ip->font.font_hi; i++)
267 1.1 leo cci->font_cell[i] = cci->font_cell[i-1] + ip->font.height;
268 1.1 leo
269 1.1 leo return(error);
270 1.2 leo }
271 1.2 leo
272 1.2 leo int
273 1.2 leo ite_grf_ioctl(ip, cmd, addr, flag, p)
274 1.2 leo struct ite_softc *ip;
275 1.2 leo u_long cmd;
276 1.2 leo caddr_t addr;
277 1.2 leo int flag;
278 1.2 leo struct proc *p;
279 1.2 leo {
280 1.2 leo struct winsize ws;
281 1.2 leo struct itewinsize *is;
282 1.2 leo struct itebell *ib;
283 1.2 leo int error = 0;
284 1.2 leo ipriv_t *cci = ip->priv;
285 1.4 leo view_t *view = viewview(ip->grf->g_viewdev);
286 1.2 leo
287 1.2 leo switch (cmd) {
288 1.2 leo case ITEIOCGWINSZ:
289 1.2 leo is = (struct itewinsize *)addr;
290 1.2 leo is->x = view->display.x;
291 1.2 leo is->y = view->display.y;
292 1.2 leo is->width = view->display.width;
293 1.2 leo is->height = view->display.height;
294 1.2 leo is->depth = view->bitmap->depth;
295 1.2 leo break;
296 1.2 leo case ITEIOCSWINSZ:
297 1.2 leo is = (struct itewinsize *)addr;
298 1.2 leo
299 1.2 leo if(ite_newsize(ip, is))
300 1.2 leo error = ENOMEM;
301 1.2 leo else {
302 1.4 leo view = viewview(ip->grf->g_viewdev);
303 1.2 leo ws.ws_row = ip->rows;
304 1.2 leo ws.ws_col = ip->cols;
305 1.2 leo ws.ws_xpixel = view->display.width;
306 1.2 leo ws.ws_ypixel = view->display.height;
307 1.2 leo ite_reset(ip);
308 1.2 leo /*
309 1.2 leo * XXX tell tty about the change
310 1.2 leo * XXX this is messy, but works
311 1.2 leo */
312 1.2 leo iteioctl(ip->grf->g_itedev,TIOCSWINSZ,(caddr_t)&ws,0,p);
313 1.2 leo }
314 1.2 leo break;
315 1.2 leo case ITEIOCDSPWIN:
316 1.2 leo ip->grf->g_mode(ip->grf, GM_GRFON, NULL, 0, 0);
317 1.2 leo break;
318 1.2 leo case ITEIOCREMWIN:
319 1.2 leo ip->grf->g_mode(ip->grf, GM_GRFOFF, NULL, 0, 0);
320 1.2 leo break;
321 1.2 leo case ITEIOCGBELL:
322 1.2 leo #if 0 /* LWP */
323 1.2 leo /* XXX This won't work now */
324 1.2 leo /* XXX Should the bell be device dependent? */
325 1.2 leo ib = (struct itebell *)addr;
326 1.2 leo ib->volume = bvolume;
327 1.2 leo ib->pitch = bpitch;
328 1.2 leo ib->msec = bmsec;
329 1.2 leo #endif
330 1.2 leo break;
331 1.2 leo case ITEIOCSBELL:
332 1.2 leo #if 0 /* LWP */
333 1.2 leo /* XXX See above */
334 1.2 leo ib = (struct itebell *)addr;
335 1.2 leo /* bounds check */
336 1.2 leo if(ib->pitch > MAXBPITCH || ib->pitch < MINBPITCH ||
337 1.2 leo ib->volume > MAXBVOLUME || ib->msec > MAXBTIME)
338 1.2 leo error = EINVAL;
339 1.2 leo else {
340 1.2 leo bvolume = ib->volume;
341 1.2 leo bpitch = ib->pitch;
342 1.2 leo bmsec = ib->msec;
343 1.2 leo }
344 1.2 leo #endif
345 1.2 leo break;
346 1.2 leo case VIOCSCMAP:
347 1.2 leo case VIOCGCMAP:
348 1.2 leo /*
349 1.2 leo * XXX watchout for that -1 its not really the kernel talking
350 1.2 leo * XXX these two commands don't use the proc pointer though
351 1.2 leo */
352 1.2 leo error = viewioctl(ip->grf->g_viewdev, cmd, addr, flag, -1);
353 1.2 leo break;
354 1.2 leo default:
355 1.2 leo error = -1;
356 1.2 leo break;
357 1.2 leo }
358 1.2 leo return (error);
359 1.1 leo }
360 1.1 leo
361 1.1 leo static void
362 1.1 leo cursor32(struct ite_softc *ip, int flag)
363 1.1 leo {
364 1.1 leo int cend;
365 1.1 leo u_char *pl;
366 1.1 leo ipriv_t *cci;
367 1.1 leo
368 1.1 leo cci = ip->priv;
369 1.1 leo
370 1.1 leo if(flag == END_CURSOROPT)
371 1.1 leo cci->cursor_opt--;
372 1.1 leo else if(flag == START_CURSOROPT) {
373 1.1 leo if(!cci->cursor_opt)
374 1.1 leo cursor32(ip, ERASE_CURSOR);
375 1.1 leo cci->cursor_opt++;
376 1.1 leo return; /* if we are already opted. */
377 1.1 leo }
378 1.1 leo
379 1.1 leo if(cci->cursor_opt)
380 1.1 leo return; /* if we are still nested. */
381 1.1 leo /* else we draw the cursor. */
382 1.1 leo
383 1.1 leo if(flag != DRAW_CURSOR && flag != END_CURSOROPT) {
384 1.1 leo /*
385 1.1 leo * erase the cursor
386 1.1 leo */
387 1.1 leo cend = ip->font.height-1;
388 1.1 leo pl = cci->column_offset[ip->cursorx]
389 1.1 leo + cci->row_ptr[ip->cursory];
390 1.1 leo __asm__ __volatile__
391 1.1 leo ("1: notb %0@ ; addaw %4,%0\n\t"
392 1.1 leo "dbra %1,1b"
393 1.1 leo : "=a" (pl), "=d" (cend)
394 1.1 leo : "0" (pl), "1" (cend),
395 1.1 leo "d" (cci->row_offset)
396 1.1 leo );
397 1.1 leo }
398 1.1 leo
399 1.1 leo if(flag != DRAW_CURSOR && flag != MOVE_CURSOR && flag != END_CURSOROPT)
400 1.1 leo return;
401 1.1 leo
402 1.1 leo /*
403 1.1 leo * draw the cursor
404 1.1 leo */
405 1.1 leo ip->cursorx = min(ip->curx, ip->cols-1);
406 1.1 leo ip->cursory = ip->cury;
407 1.1 leo cend = ip->font.height-1;
408 1.1 leo pl = cci->column_offset[ip->cursorx]
409 1.1 leo + cci->row_ptr[ip->cursory];
410 1.1 leo
411 1.1 leo __asm__ __volatile__
412 1.1 leo ("1: notb %0@ ; addaw %4,%0\n\t"
413 1.1 leo "dbra %1,1b"
414 1.1 leo : "=a" (pl), "=d" (cend)
415 1.1 leo : "0" (pl), "1" (cend),
416 1.1 leo "d" (cci->row_offset)
417 1.1 leo );
418 1.1 leo }
419 1.1 leo
420 1.1 leo static void
421 1.1 leo putc8(struct ite_softc *ip, int c, int dy, int dx, int mode)
422 1.1 leo {
423 1.1 leo register ipriv_t *cci = (ipriv_t *)ip->priv;
424 1.1 leo register u_char *pl = cci->column_offset[dx] + cci->row_ptr[dy];
425 1.1 leo register u_int fh = cci->ft_y;
426 1.1 leo register u_int ro = cci->row_offset;
427 1.1 leo register u_char eor_mask;
428 1.1 leo register u_char bl, tmp, ul;
429 1.1 leo register u_char *ft;
430 1.1 leo
431 1.1 leo if(c < ip->font.font_lo || c > ip->font.font_hi)
432 1.1 leo return;
433 1.1 leo
434 1.1 leo ft = cci->font_cell[c];
435 1.1 leo
436 1.1 leo if(!mode) {
437 1.1 leo while(fh--) {
438 1.1 leo *pl = *ft++; pl += ro;
439 1.1 leo }
440 1.1 leo return;
441 1.1 leo }
442 1.1 leo
443 1.1 leo eor_mask = (mode & ATTR_INV) ? 0xff : 0x00;
444 1.1 leo bl = (mode & ATTR_BOLD) ? 1 : 0;
445 1.3 leo ul = (mode & ATTR_UL) ? fh - cci->underline : fh;
446 1.3 leo for(; fh--; pl += ro) {
447 1.3 leo if(fh != ul) {
448 1.3 leo tmp = *ft++;
449 1.3 leo if(bl)
450 1.3 leo tmp |= (tmp >> 1);
451 1.3 leo *pl = tmp ^ eor_mask;
452 1.3 leo }
453 1.3 leo else {
454 1.3 leo *pl = 0xff ^ eor_mask;
455 1.3 leo ft++;
456 1.3 leo }
457 1.1 leo }
458 1.1 leo }
459 1.1 leo
460 1.1 leo static void
461 1.1 leo clear8(struct ite_softc *ip, int sy, int sx, int h, int w)
462 1.1 leo {
463 1.1 leo ipriv_t *cci = (ipriv_t *) ip->priv;
464 1.4 leo view_t *v = viewview(ip->grf->g_viewdev);
465 1.1 leo bmap_t *bm = v->bitmap;
466 1.1 leo
467 1.1 leo if((sx == 0) && (w == ip->cols)) {
468 1.1 leo /* common case: clearing whole lines */
469 1.1 leo while (h--) {
470 1.1 leo int i;
471 1.1 leo u_char *ptr = cci->row_ptr[sy];
472 1.1 leo for(i = 0; i < ip->font.height; i++) {
473 1.1 leo bzero(ptr, bm->bytes_per_row);
474 1.1 leo ptr += bm->bytes_per_row;
475 1.1 leo }
476 1.1 leo sy++;
477 1.1 leo }
478 1.1 leo }
479 1.1 leo else {
480 1.1 leo /*
481 1.1 leo * clearing only part of a line
482 1.1 leo * XXX could be optimized MUCH better, but is it worth the
483 1.1 leo * trouble?
484 1.1 leo */
485 1.1 leo
486 1.1 leo int i;
487 1.1 leo u_char *pls, *ple;
488 1.1 leo
489 1.1 leo pls = cci->row_ptr[sy];
490 1.1 leo ple = pls + cci->column_offset[sx + w-1];
491 1.1 leo pls = pls + cci->column_offset[sx];
492 1.1 leo
493 1.1 leo for(i = ((ip->font.height) * h)-1; i >= 0; i--) {
494 1.1 leo u_char *p = pls;
495 1.1 leo while(p <= ple)
496 1.1 leo *p++ = 0;
497 1.1 leo pls += bm->bytes_per_row;
498 1.1 leo ple += bm->bytes_per_row;
499 1.1 leo }
500 1.1 leo }
501 1.1 leo }
502 1.1 leo
503 1.1 leo /* Note: sx is only relevant for SCROLL_LEFT or SCROLL_RIGHT. */
504 1.1 leo static void
505 1.1 leo scroll8(ip, sy, sx, count, dir)
506 1.1 leo register struct ite_softc *ip;
507 1.1 leo register int sy;
508 1.1 leo int dir, sx, count;
509 1.1 leo {
510 1.4 leo bmap_t *bm = viewview(ip->grf->g_viewdev)->bitmap;
511 1.1 leo u_char *pl = ((ipriv_t *)ip->priv)->row_ptr[sy];
512 1.1 leo
513 1.1 leo if(dir == SCROLL_UP) {
514 1.1 leo int dy = sy - count;
515 1.1 leo int height = ip->bottom_margin - sy + 1;
516 1.1 leo int i;
517 1.1 leo
518 1.1 leo cursor32(ip, ERASE_CURSOR);
519 1.1 leo scrollbmap(bm, 0, dy*ip->font.height, bm->bytes_per_row >> 3,
520 1.1 leo (ip->bottom_margin-dy+1)*ip->font.height,
521 1.1 leo 0, -(count*ip->font.height));
522 1.1 leo }
523 1.1 leo else if(dir == SCROLL_DOWN) {
524 1.1 leo int dy = sy + count;
525 1.1 leo int height = ip->bottom_margin - dy + 1;
526 1.1 leo int i;
527 1.1 leo
528 1.1 leo cursor32(ip, ERASE_CURSOR);
529 1.1 leo scrollbmap(bm, 0, sy*ip->font.height, bm->bytes_per_row >> 3,
530 1.1 leo (ip->bottom_margin-sy+1)*ip->font.height,
531 1.1 leo 0, count*ip->font.height);
532 1.1 leo }
533 1.1 leo else if(dir == SCROLL_RIGHT) {
534 1.1 leo int sofs = (ip->cols - count) * ip->font.width;
535 1.1 leo int dofs = (ip->cols) * ip->font.width;
536 1.1 leo int i, j;
537 1.1 leo
538 1.1 leo cursor32(ip, ERASE_CURSOR);
539 1.1 leo for(j = ip->font.height-1; j >= 0; j--) {
540 1.1 leo int sofs2 = sofs, dofs2 = dofs;
541 1.1 leo for (i = (ip->cols - (sx + count))-1; i >= 0; i--) {
542 1.1 leo int t;
543 1.1 leo sofs2 -= ip->font.width;
544 1.1 leo dofs2 -= ip->font.width;
545 1.1 leo asm("bfextu %1@{%2:%3},%0" : "=d" (t)
546 1.1 leo : "a" (pl), "d" (sofs2), "d" (ip->font.width));
547 1.1 leo asm("bfins %3,%0@{%1:%2}" :
548 1.1 leo : "a" (pl), "d" (dofs2), "d" (ip->font.width),
549 1.1 leo "d" (t));
550 1.1 leo }
551 1.1 leo pl += bm->bytes_per_row;
552 1.1 leo }
553 1.1 leo }
554 1.1 leo else { /* SCROLL_LEFT */
555 1.1 leo int sofs = (sx) * ip->font.width;
556 1.1 leo int dofs = (sx - count) * ip->font.width;
557 1.1 leo int i, j;
558 1.1 leo
559 1.1 leo cursor32(ip, ERASE_CURSOR);
560 1.1 leo for(j = ip->font.height-1; j >= 0; j--) {
561 1.1 leo int sofs2 = sofs, dofs2 = dofs;
562 1.1 leo for(i = (ip->cols - sx)-1; i >= 0; i--) {
563 1.1 leo int t;
564 1.1 leo
565 1.1 leo asm("bfextu %1@{%2:%3},%0" : "=d" (t)
566 1.1 leo : "a" (pl), "d" (sofs2), "d" (ip->font.width));
567 1.1 leo asm("bfins %3,%0@{%1:%2}"
568 1.1 leo : : "a" (pl), "d" (dofs2),"d" (ip->font.width),
569 1.1 leo "d" (t));
570 1.1 leo sofs2 += ip->font.width;
571 1.1 leo dofs2 += ip->font.width;
572 1.1 leo }
573 1.1 leo pl += bm->bytes_per_row;
574 1.1 leo }
575 1.1 leo }
576 1.1 leo }
577 1.1 leo
578 1.1 leo static void
579 1.1 leo scrollbmap (bmap_t *bm, u_short x, u_short y, u_short width, u_short height, short dx, short dy)
580 1.1 leo {
581 1.1 leo u_short depth = bm->depth;
582 1.1 leo u_short lwpr = bm->bytes_per_row >> 2;
583 1.1 leo
584 1.1 leo if(dx) {
585 1.1 leo /* FIX: */ panic ("delta x not supported in scroll bitmap yet.");
586 1.1 leo }
587 1.1 leo
588 1.1 leo if(dy == 0) {
589 1.1 leo return;
590 1.1 leo }
591 1.1 leo if(dy > 0) {
592 1.1 leo u_long *pl = (u_long *)bm->plane;
593 1.1 leo u_long *src_y = pl + (lwpr*y);
594 1.1 leo u_long *dest_y = pl + (lwpr*(y+dy));
595 1.1 leo u_long count = lwpr*(height-dy);
596 1.1 leo u_long *clr_y = src_y;
597 1.1 leo u_long clr_count = dest_y - src_y;
598 1.1 leo u_long bc, cbc;
599 1.1 leo
600 1.1 leo src_y += count - 1;
601 1.1 leo dest_y += count - 1;
602 1.1 leo
603 1.1 leo bc = count >> 4;
604 1.1 leo count &= 0xf;
605 1.1 leo
606 1.1 leo while (bc--) {
607 1.1 leo *dest_y-- = *src_y--; *dest_y-- = *src_y--;
608 1.1 leo *dest_y-- = *src_y--; *dest_y-- = *src_y--;
609 1.1 leo *dest_y-- = *src_y--; *dest_y-- = *src_y--;
610 1.1 leo *dest_y-- = *src_y--; *dest_y-- = *src_y--;
611 1.1 leo *dest_y-- = *src_y--; *dest_y-- = *src_y--;
612 1.1 leo *dest_y-- = *src_y--; *dest_y-- = *src_y--;
613 1.1 leo *dest_y-- = *src_y--; *dest_y-- = *src_y--;
614 1.1 leo *dest_y-- = *src_y--; *dest_y-- = *src_y--;
615 1.1 leo }
616 1.1 leo while (count--)
617 1.1 leo *dest_y-- = *src_y--;
618 1.1 leo
619 1.1 leo cbc = clr_count >> 4;
620 1.1 leo clr_count &= 0xf;
621 1.1 leo
622 1.1 leo while (cbc--) {
623 1.1 leo *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
624 1.1 leo *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
625 1.1 leo *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
626 1.1 leo *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
627 1.1 leo }
628 1.1 leo while(clr_count--)
629 1.1 leo *clr_y++ = 0;
630 1.1 leo }
631 1.1 leo else {
632 1.1 leo u_long *pl = (u_long *)bm->plane;
633 1.1 leo u_long *src_y = pl + (lwpr*(y-dy));
634 1.1 leo u_long *dest_y = pl + (lwpr*y);
635 1.1 leo long count = lwpr*(height + dy);
636 1.1 leo u_long *clr_y = dest_y + count;
637 1.1 leo u_long clr_count = src_y - dest_y;
638 1.1 leo u_long bc, cbc;
639 1.1 leo
640 1.1 leo bc = count >> 4;
641 1.1 leo count &= 0xf;
642 1.1 leo
643 1.1 leo while(bc--) {
644 1.1 leo *dest_y++ = *src_y++; *dest_y++ = *src_y++;
645 1.1 leo *dest_y++ = *src_y++; *dest_y++ = *src_y++;
646 1.1 leo *dest_y++ = *src_y++; *dest_y++ = *src_y++;
647 1.1 leo *dest_y++ = *src_y++; *dest_y++ = *src_y++;
648 1.1 leo *dest_y++ = *src_y++; *dest_y++ = *src_y++;
649 1.1 leo *dest_y++ = *src_y++; *dest_y++ = *src_y++;
650 1.1 leo *dest_y++ = *src_y++; *dest_y++ = *src_y++;
651 1.1 leo *dest_y++ = *src_y++; *dest_y++ = *src_y++;
652 1.1 leo }
653 1.1 leo while(count--)
654 1.1 leo *dest_y++ = *src_y++;
655 1.1 leo
656 1.1 leo cbc = clr_count >> 4;
657 1.1 leo clr_count &= 0xf;
658 1.1 leo
659 1.1 leo while (cbc--) {
660 1.1 leo *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
661 1.1 leo *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
662 1.1 leo *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
663 1.1 leo *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
664 1.1 leo }
665 1.1 leo while (clr_count--)
666 1.1 leo *clr_y++ = 0;
667 1.1 leo }
668 1.1 leo }
669 1.1 leo #else
670 1.1 leo #error Must be defined
671 1.1 leo #endif /* NGRF */
672