Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / atari / dev / ite_cc.c
blobf4a213cfa2a328cebd8f4b90e2142df37befa042
1 /* $NetBSD: ite_cc.c,v 1.33 2009/03/18 17:06:43 cegger Exp $ */
3 /*
4 * Copyright (c) 1996 Leo Weppelman
5 * Copyright (c) 1994 Christian E. Hopps
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Christian E. Hopps.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/cdefs.h>
35 __KERNEL_RCSID(0, "$NetBSD: ite_cc.c,v 1.33 2009/03/18 17:06:43 cegger Exp $");
37 #include <sys/param.h>
38 #include <sys/conf.h>
39 #include <sys/proc.h>
40 #include <sys/ioctl.h>
41 #include <sys/tty.h>
42 #include <sys/systm.h>
43 #include <sys/queue.h>
44 #include <sys/termios.h>
45 #include <sys/malloc.h>
46 #include <sys/device.h>
47 #include <dev/cons.h>
48 #include <machine/cpu.h>
49 #include <atari/atari/device.h>
50 #include <atari/dev/itevar.h>
51 #include <atari/dev/iteioctl.h>
52 #include <atari/dev/grfioctl.h>
53 #include <atari/dev/grfabs_reg.h>
54 #include <atari/dev/grfvar.h>
55 #include <atari/dev/font.h>
56 #include <atari/dev/viewioctl.h>
57 #include <atari/dev/viewvar.h>
59 #include "grfcc.h"
62 * This is what ip->priv points to;
63 * it contains local variables for custom-chip ites.
65 struct ite_priv {
66 u_char **row_ptr; /* array of pointers into the bitmap */
67 u_long row_bytes;
68 u_long cursor_opt;
69 u_short *column_offset; /* array of offsets for columns */
70 u_int row_offset; /* the row offset */
71 u_short width; /* the bitmap width */
72 u_short underline; /* where the underline goes */
73 u_short ft_x; /* the font width */
74 u_short ft_y; /* the font height */
75 u_char *font_cell[256];/* the font pointer */
77 typedef struct ite_priv ipriv_t;
80 * We need the following space to get an ite-console setup before
81 * the VM-system is brought up. We setup for a 1280x960 monitor with
82 * an 8x8 font.
84 #define CONS_MAXROW 120 /* Max. number of rows on console */
85 #define CONS_MAXCOL 160 /* Max. number of columns on console */
86 static u_short con_columns[CONS_MAXCOL];
87 static u_char *con_rows[CONS_MAXROW];
88 static ipriv_t con_ipriv;
90 extern font_info font_info_8x8;
91 extern font_info font_info_8x16;
93 static void view_init(struct ite_softc *);
94 static void view_deinit(struct ite_softc *);
95 static int itecc_ioctl(struct ite_softc *, u_long, void *, int,
96 struct lwp *);
97 static int ite_newsize(struct ite_softc *, struct itewinsize *);
98 static void cursor32(struct ite_softc *, int);
99 static void putc8(struct ite_softc *, int, int, int, int);
100 static void clear8(struct ite_softc *, int, int, int, int);
101 static void scroll8(struct ite_softc *, int, int, int, int);
102 static void scrollbmap(bmap_t *, u_short, u_short, u_short, u_short,
103 short, short);
106 * grfcc config stuff
108 void grfccattach(struct device *, struct device *, void *);
109 int grfccmatch(struct device *, struct cfdata *, void *);
110 int grfccprint(void *, const char *);
112 CFATTACH_DECL(grfcc, sizeof(struct grf_softc),
113 grfccmatch, grfccattach, NULL, NULL);
116 * only used in console init.
118 static struct cfdata *cfdata_grf = NULL;
121 * Probe functions we can use:
123 #ifdef TT_VIDEO
124 void tt_probe_video(MODES *);
125 #endif /* TT_VIDEO */
126 #ifdef FALCON_VIDEO
127 void falcon_probe_video(MODES *);
128 #endif /* FALCON_VIDEO */
131 grfccmatch(struct device *pdp, struct cfdata *cfp, void *auxp)
133 static int did_consinit = 0;
134 static int must_probe = 1;
135 grf_auxp_t *grf_auxp = auxp;
136 extern const struct cdevsw view_cdevsw;
138 if (must_probe) {
140 * Check if the layers we depend on exist
142 if (!(machineid & (ATARI_TT|ATARI_FALCON)))
143 return (0);
144 #ifdef TT_VIDEO
145 if ((machineid & ATARI_TT) && !grfabs_probe(&tt_probe_video))
146 return (0);
147 #endif /* TT_VIDEO */
148 #ifdef FALCON_VIDEO
149 if ((machineid & ATARI_FALCON)
150 && !grfabs_probe(&falcon_probe_video))
151 return (0);
152 #endif /* FALCON_VIDEO */
154 viewprobe();
155 must_probe = 0;
158 if (atari_realconfig == 0) {
160 * Early console init. Only match first unit.
162 if (did_consinit)
163 return(0);
164 if ((*view_cdevsw.d_open)(cfp->cf_unit, 0, 0, NULL))
165 return(0);
166 cfdata_grf = cfp;
167 did_consinit = 1;
168 return (1);
172 * Normal config. When we are called directly from the grfbus,
173 * we only match the first unit. The attach function will call us for
174 * the other configured units.
176 if (grf_auxp->from_bus_match && (did_consinit > 1))
177 return (0);
179 if (!grf_auxp->from_bus_match && (grf_auxp->unit != cfp->cf_unit))
180 return (0);
183 * Final constraint: each grf needs a view....
185 if((cfdata_grf == NULL) || (did_consinit > 1)) {
186 if((*view_cdevsw.d_open)(cfp->cf_unit, 0, 0, NULL))
187 return(0);
189 did_consinit = 2;
190 return(1);
194 * attach: initialize the grf-structure and try to attach an ite to us.
195 * note : dp is NULL during early console init.
197 void
198 grfccattach(struct device *pdp, struct device *dp, void *auxp)
200 static struct grf_softc congrf;
201 static int first_attach = 1;
202 grf_auxp_t *grf_bus_auxp = auxp;
203 grf_auxp_t grf_auxp;
204 struct grf_softc *gp;
205 int maj;
206 extern const struct cdevsw grf_cdevsw;
209 * find our major device number
211 maj = cdevsw_lookup_major(&grf_cdevsw);
214 * Handle exeption case: early console init
216 if(dp == NULL) {
217 congrf.g_unit = cfdata_grf->cf_unit;
218 congrf.g_grfdev = makedev(maj, congrf.g_unit);
219 congrf.g_itedev = (dev_t)-1;
220 congrf.g_flags = GF_ALIVE;
221 congrf.g_mode = grf_mode;
222 congrf.g_conpri = grfcc_cnprobe();
223 congrf.g_viewdev = congrf.g_unit;
224 grfcc_iteinit(&congrf);
225 grf_viewsync(&congrf);
227 /* Attach console ite */
228 atari_config_found(cfdata_grf, NULL, &congrf, grfccprint);
229 return;
232 gp = (struct grf_softc *)dp;
233 gp->g_unit = device_unit(&gp->g_device);
234 grfsp[gp->g_unit] = gp;
236 if((cfdata_grf != NULL) && (gp->g_unit == congrf.g_unit)) {
238 * We inited earlier just copy the info, take care
239 * not to copy the device struct though.
241 memcpy(&gp->g_display, &congrf.g_display,
242 (char *)&gp[1] - (char *)&gp->g_display);
244 else {
245 gp->g_grfdev = makedev(maj, gp->g_unit);
246 gp->g_itedev = (dev_t)-1;
247 gp->g_flags = GF_ALIVE;
248 gp->g_mode = grf_mode;
249 gp->g_conpri = 0;
250 gp->g_viewdev = gp->g_unit;
251 grfcc_iteinit(gp);
252 grf_viewsync(gp);
255 printf(": width %d height %d", gp->g_display.gd_dwidth,
256 gp->g_display.gd_dheight);
257 if(gp->g_display.gd_colors == 2)
258 printf(" monochrome\n");
259 else printf(" colors %d\n", gp->g_display.gd_colors);
262 * try and attach an ite
264 config_found(dp, gp, grfccprint);
267 * If attaching the first unit, go ahead and 'find' the rest of us
269 if (first_attach) {
270 first_attach = 0;
271 grf_auxp.from_bus_match = 0;
272 for (grf_auxp.unit=1; grf_auxp.unit < NGRFCC; grf_auxp.unit++) {
273 config_found(pdp, (void*)&grf_auxp, grf_bus_auxp->busprint);
279 grfccprint(void *auxp, const char *pnp)
281 if(pnp)
282 aprint_normal("ite at %s", pnp);
283 return(UNCONF);
287 * called from grf_cc to return console priority
290 grfcc_cnprobe(void)
292 return(CN_INTERNAL);
295 * called from grf_cc to init ite portion of
296 * grf_softc struct
298 void
299 grfcc_iteinit(struct grf_softc *gp)
302 gp->g_itecursor = cursor32;
303 gp->g_iteputc = putc8;
304 gp->g_iteclear = clear8;
305 gp->g_itescroll = scroll8;
306 gp->g_iteinit = view_init;
307 gp->g_itedeinit = view_deinit;
310 static void
311 view_deinit(struct ite_softc *ip)
313 ip->flags &= ~ITE_INITED;
316 static void
317 view_init(register struct ite_softc *ip)
319 struct itewinsize wsz;
320 ipriv_t *cci;
322 if((cci = ip->priv) != NULL)
323 return;
325 ip->itexx_ioctl = itecc_ioctl;
327 #if defined(KFONT_8X8)
328 ip->font = font_info_8x8;
329 #else
330 ip->font = font_info_8x16;
331 #endif
333 /* Find the correct set of rendering routines for this font. */
334 if(ip->font.width != 8)
335 panic("kernel font size not supported");
337 if(!atari_realconfig)
338 ip->priv = cci = &con_ipriv;
339 else ip->priv = cci = (ipriv_t*)malloc(sizeof(*cci), M_DEVBUF,M_WAITOK);
340 if(cci == NULL)
341 panic("No memory for ite-view");
342 memset(cci, 0, sizeof(*cci));
344 cci->cursor_opt = 0;
345 cci->row_ptr = NULL;
346 cci->column_offset = NULL;
348 wsz.x = ite_default_x;
349 wsz.y = ite_default_y;
350 wsz.width = ite_default_width;
351 wsz.height = ite_default_height;
352 wsz.depth = ite_default_depth;
354 ite_newsize (ip, &wsz);
357 * Only console will be turned on by default..
359 if(ip->flags & ITE_ISCONS)
360 ip->grf->g_mode(ip->grf, GM_GRFON, NULL, 0, 0);
363 static int
364 ite_newsize(struct ite_softc *ip, struct itewinsize *winsz)
366 struct view_size vs;
367 ipriv_t *cci = ip->priv;
368 u_long i, j;
369 int error = 0;
370 view_t *view;
371 extern const struct cdevsw view_cdevsw;
373 vs.x = winsz->x;
374 vs.y = winsz->y;
375 vs.width = winsz->width;
376 vs.height = winsz->height;
377 vs.depth = winsz->depth;
379 error = (*view_cdevsw.d_ioctl)(ip->grf->g_viewdev, VIOCSSIZE,
380 (void *)&vs, 0, NOLWP);
381 view = viewview(ip->grf->g_viewdev);
384 * Reinitialize our structs
386 ip->cols = view->display.width / ip->font.width;
387 ip->rows = view->display.height / ip->font.height;
390 * save new values so that future opens use them
391 * this may not be correct when we implement Virtual Consoles
393 ite_default_height = view->display.height;
394 ite_default_width = view->display.width;
395 ite_default_x = view->display.x;
396 ite_default_y = view->display.y;
397 ite_default_depth = view->bitmap->depth;
399 if(cci->row_ptr && (cci->row_ptr != con_rows)) {
400 free(cci->row_ptr, M_DEVBUF);
401 cci->row_ptr = NULL;
403 if(cci->column_offset && (cci->column_offset != con_columns)) {
404 free(cci->column_offset, M_DEVBUF);
405 cci->column_offset = NULL;
408 if(!atari_realconfig) {
409 cci->row_ptr = con_rows;
410 cci->column_offset = con_columns;
412 else {
413 cci->row_ptr = malloc(sizeof(u_char *) * ip->rows,M_DEVBUF,M_NOWAIT);
414 cci->column_offset = malloc(sizeof(u_int)*ip->cols,M_DEVBUF,M_NOWAIT);
417 if(!cci->row_ptr || !cci->column_offset)
418 panic("No memory for ite-view");
420 cci->width = view->bitmap->bytes_per_row << 3;
421 cci->underline = ip->font.baseline + 1;
422 cci->row_offset = view->bitmap->bytes_per_row;
423 cci->ft_x = ip->font.width;
424 cci->ft_y = ip->font.height;
425 cci->row_bytes = cci->row_offset * cci->ft_y;
426 cci->row_ptr[0] = view->bitmap->plane;
427 for(i = 1; i < ip->rows; i++)
428 cci->row_ptr[i] = cci->row_ptr[i-1] + cci->row_bytes;
431 * Initialize the column offsets to point at the correct location
432 * in the first plane. This definitely assumes a font width of 8!
434 j = view->bitmap->depth * 2;
435 cci->column_offset[0] = 0;
436 for(i = 1; i < ip->cols; i++)
437 cci->column_offset[i] = ((i >> 1) * j) + (i & 1);
439 /* initialize the font cell pointers */
440 cci->font_cell[ip->font.font_lo] = ip->font.font_p;
441 for(i = ip->font.font_lo+1; i <= ip->font.font_hi; i++)
442 cci->font_cell[i] = cci->font_cell[i-1] + ip->font.height;
444 return(error);
448 itecc_ioctl(struct ite_softc *ip, u_long cmd, void * addr, int flag, struct lwp *l)
450 struct winsize ws;
451 struct itewinsize *is;
452 int error = 0;
453 view_t *view = viewview(ip->grf->g_viewdev);
454 extern const struct cdevsw ite_cdevsw;
455 extern const struct cdevsw view_cdevsw;
457 switch (cmd) {
458 case ITEIOCSWINSZ:
459 is = (struct itewinsize *)addr;
461 if(ite_newsize(ip, is))
462 error = ENOMEM;
463 else {
464 view = viewview(ip->grf->g_viewdev);
465 ws.ws_row = ip->rows;
466 ws.ws_col = ip->cols;
467 ws.ws_xpixel = view->display.width;
468 ws.ws_ypixel = view->display.height;
469 ite_reset(ip);
471 * XXX tell tty about the change
472 * XXX this is messy, but works
474 (*ite_cdevsw.d_ioctl)(ip->grf->g_itedev, TIOCSWINSZ,
475 (void *)&ws, 0, l);
477 break;
478 case VIOCSCMAP:
479 case VIOCGCMAP:
481 * XXX watchout for that NOLWP. its not really the kernel
482 * XXX talking these two commands don't use the proc pointer
483 * XXX though.
485 error = (*view_cdevsw.d_ioctl)(ip->grf->g_viewdev, cmd, addr,
486 flag, NOLWP);
487 break;
488 default:
489 error = EPASSTHROUGH;
490 break;
492 return (error);
495 static void
496 cursor32(struct ite_softc *ip, int flag)
498 int cend;
499 u_char *pl;
500 ipriv_t *cci;
502 cci = ip->priv;
504 if(flag == END_CURSOROPT)
505 cci->cursor_opt--;
506 else if(flag == START_CURSOROPT) {
507 if(!cci->cursor_opt)
508 cursor32(ip, ERASE_CURSOR);
509 cci->cursor_opt++;
510 return; /* if we are already opted. */
513 if(cci->cursor_opt)
514 return; /* if we are still nested. */
515 /* else we draw the cursor. */
517 if(flag != DRAW_CURSOR && flag != END_CURSOROPT) {
519 * erase the cursor
521 cend = ip->font.height-1;
522 pl = cci->column_offset[ip->cursorx]
523 + cci->row_ptr[ip->cursory];
524 __asm volatile
525 ("1: notb %0@ ; addaw %4,%0\n\t"
526 "dbra %1,1b"
527 : "=a" (pl), "=d" (cend)
528 : "0" (pl), "1" (cend),
529 "d" (cci->row_offset)
533 if(flag != DRAW_CURSOR && flag != MOVE_CURSOR && flag != END_CURSOROPT)
534 return;
537 * draw the cursor
539 cend = min(ip->curx, ip->cols-1);
540 if (flag == DRAW_CURSOR
541 && ip->cursorx == cend && ip->cursory == ip->cury)
542 return;
543 ip->cursorx = cend;
544 ip->cursory = ip->cury;
545 cend = ip->font.height-1;
546 pl = cci->column_offset[ip->cursorx]
547 + cci->row_ptr[ip->cursory];
549 __asm volatile
550 ("1: notb %0@ ; addaw %4,%0\n\t"
551 "dbra %1,1b"
552 : "=a" (pl), "=d" (cend)
553 : "0" (pl), "1" (cend),
554 "d" (cci->row_offset)
558 static void
559 putc8(struct ite_softc *ip, int c, int dy, int dx, int mode)
561 register ipriv_t *cci = (ipriv_t *)ip->priv;
562 register u_char *pl = cci->column_offset[dx] + cci->row_ptr[dy];
563 register u_int fh = cci->ft_y;
564 register u_int ro = cci->row_offset;
565 register u_char eor_mask;
566 register u_char bl, tmp, ul;
567 register u_char *ft;
569 if(c < ip->font.font_lo || c > ip->font.font_hi)
570 return;
572 ft = cci->font_cell[c];
574 if(!mode) {
575 while(fh--) {
576 *pl = *ft++; pl += ro;
578 return;
581 eor_mask = (mode & ATTR_INV) ? 0xff : 0x00;
582 bl = (mode & ATTR_BOLD) ? 1 : 0;
583 ul = (mode & ATTR_UL) ? fh - cci->underline : fh;
584 for(; fh--; pl += ro) {
585 if(fh != ul) {
586 tmp = *ft++;
587 if(bl)
588 tmp |= (tmp >> 1);
589 *pl = tmp ^ eor_mask;
591 else {
592 *pl = 0xff ^ eor_mask;
593 ft++;
598 static void
599 clear8(struct ite_softc *ip, int sy, int sx, int h, int w)
601 ipriv_t *cci = (ipriv_t *) ip->priv;
602 view_t *v = viewview(ip->grf->g_viewdev);
603 bmap_t *bm = v->bitmap;
605 if((sx == 0) && (w == ip->cols)) {
606 /* common case: clearing whole lines */
607 while (h--) {
608 int i;
609 u_char *ptr = cci->row_ptr[sy];
610 for(i = 0; i < ip->font.height; i++) {
611 memset(ptr, 0, bm->bytes_per_row);
612 ptr += bm->bytes_per_row;
614 sy++;
617 else {
619 * clearing only part of a line
620 * XXX could be optimized MUCH better, but is it worth the
621 * trouble?
624 int i;
625 u_char *pls, *ple;
627 pls = cci->row_ptr[sy];
628 ple = pls + cci->column_offset[sx + w-1];
629 pls = pls + cci->column_offset[sx];
631 for(i = ((ip->font.height) * h)-1; i >= 0; i--) {
632 u_char *p = pls;
633 while(p <= ple)
634 *p++ = 0;
635 pls += bm->bytes_per_row;
636 ple += bm->bytes_per_row;
641 /* Note: sx is only relevant for SCROLL_LEFT or SCROLL_RIGHT. */
642 static void
643 scroll8(register struct ite_softc *ip, register int sy, int sx, int count, int dir)
645 bmap_t *bm = viewview(ip->grf->g_viewdev)->bitmap;
646 u_char *pl = ((ipriv_t *)ip->priv)->row_ptr[sy];
648 if(dir == SCROLL_UP) {
649 int dy = sy - count;
651 cursor32(ip, ERASE_CURSOR);
652 scrollbmap(bm, 0, dy*ip->font.height, bm->bytes_per_row >> 3,
653 (ip->bottom_margin-dy+1)*ip->font.height,
654 0, -(count*ip->font.height));
656 else if(dir == SCROLL_DOWN) {
657 cursor32(ip, ERASE_CURSOR);
658 scrollbmap(bm, 0, sy*ip->font.height, bm->bytes_per_row >> 3,
659 (ip->bottom_margin-sy+1)*ip->font.height,
660 0, count*ip->font.height);
662 else if(dir == SCROLL_RIGHT) {
663 int sofs = (ip->cols - count) * ip->font.width;
664 int dofs = (ip->cols) * ip->font.width;
665 int i, j;
667 cursor32(ip, ERASE_CURSOR);
668 for(j = ip->font.height-1; j >= 0; j--) {
669 int sofs2 = sofs, dofs2 = dofs;
670 for (i = (ip->cols - (sx + count))-1; i >= 0; i--) {
671 int t;
672 sofs2 -= ip->font.width;
673 dofs2 -= ip->font.width;
674 __asm("bfextu %1@{%2:%3},%0" : "=d" (t)
675 : "a" (pl), "d" (sofs2), "d" (ip->font.width));
676 __asm("bfins %3,%0@{%1:%2}" :
677 : "a" (pl), "d" (dofs2), "d" (ip->font.width),
678 "d" (t));
680 pl += bm->bytes_per_row;
683 else { /* SCROLL_LEFT */
684 int sofs = (sx) * ip->font.width;
685 int dofs = (sx - count) * ip->font.width;
686 int i, j;
688 cursor32(ip, ERASE_CURSOR);
689 for(j = ip->font.height-1; j >= 0; j--) {
690 int sofs2 = sofs, dofs2 = dofs;
691 for(i = (ip->cols - sx)-1; i >= 0; i--) {
692 int t;
694 __asm("bfextu %1@{%2:%3},%0" : "=d" (t)
695 : "a" (pl), "d" (sofs2), "d" (ip->font.width));
696 __asm("bfins %3,%0@{%1:%2}"
697 : : "a" (pl), "d" (dofs2),"d" (ip->font.width),
698 "d" (t));
699 sofs2 += ip->font.width;
700 dofs2 += ip->font.width;
702 pl += bm->bytes_per_row;
707 static void
708 scrollbmap (bmap_t *bm, u_short x, u_short y, u_short width, u_short height, short dx, short dy)
710 u_short lwpr = bm->bytes_per_row >> 2;
712 if(dx) {
713 /* FIX: */ panic ("delta x not supported in scroll bitmap yet.");
716 if(dy == 0) {
717 return;
719 if(dy > 0) {
720 u_long *pl = (u_long *)bm->plane;
721 u_long *src_y = pl + (lwpr*y);
722 u_long *dest_y = pl + (lwpr*(y+dy));
723 u_long count = lwpr*(height-dy);
724 u_long *clr_y = src_y;
725 u_long clr_count = dest_y - src_y;
726 u_long bc, cbc;
728 src_y += count - 1;
729 dest_y += count - 1;
731 bc = count >> 4;
732 count &= 0xf;
734 while (bc--) {
735 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
736 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
737 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
738 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
739 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
740 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
741 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
742 *dest_y-- = *src_y--; *dest_y-- = *src_y--;
744 while (count--)
745 *dest_y-- = *src_y--;
747 cbc = clr_count >> 4;
748 clr_count &= 0xf;
750 while (cbc--) {
751 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
752 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
753 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
754 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
756 while(clr_count--)
757 *clr_y++ = 0;
759 else {
760 u_long *pl = (u_long *)bm->plane;
761 u_long *src_y = pl + (lwpr*(y-dy));
762 u_long *dest_y = pl + (lwpr*y);
763 long count = lwpr*(height + dy);
764 u_long *clr_y = dest_y + count;
765 u_long clr_count = src_y - dest_y;
766 u_long bc, cbc;
768 bc = count >> 4;
769 count &= 0xf;
771 while(bc--) {
772 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
773 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
774 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
775 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
776 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
777 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
778 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
779 *dest_y++ = *src_y++; *dest_y++ = *src_y++;
781 while(count--)
782 *dest_y++ = *src_y++;
784 cbc = clr_count >> 4;
785 clr_count &= 0xf;
787 while (cbc--) {
788 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
789 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
790 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
791 *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0; *clr_y++ = 0;
793 while (clr_count--)
794 *clr_y++ = 0;