From 906755d37e395ce04a8a239d941d63a93366fa6e Mon Sep 17 00:00:00 2001 From: kstailey Date: Thu, 10 Jul 1997 04:25:58 +0000 Subject: fix backward scrolling --- sys/arch/alpha/dev/vga.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/alpha/dev/vga.c b/sys/arch/alpha/dev/vga.c index fccac6205ec..fa97e6a9ff6 100644 --- a/sys/arch/alpha/dev/vga.c +++ b/sys/arch/alpha/dev/vga.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vga.c,v 1.2 1997/07/09 03:07:39 deraadt Exp $ */ +/* $OpenBSD: vga.c,v 1.3 1997/07/10 04:25:57 kstailey Exp $ */ /* $NetBSD: vga.c,v 1.3 1996/12/02 22:24:54 cgd Exp $ */ /* @@ -322,6 +322,8 @@ vga_erasecols(id, row, startcol, ncols) bus_space_set_region_2(vc->vc_memt, vc->vc_memh, off, val, ncols); } +/* be careful not to call bus_space_copy_2() with overlapping regions */ + void vga_copyrows(id, srcrow, dstrow, nrows) void *id; @@ -333,9 +335,19 @@ vga_copyrows(id, srcrow, dstrow, nrows) srcoff = (srcrow * vc->vc_ncol + 0) * 2; dstoff = (dstrow * vc->vc_ncol + 0) * 2; - /* XXX SHOULDN'T USE THIS IF REGIONS OVERLAP... */ - bus_space_copy_2(vc->vc_memt, vc->vc_memh, srcoff, vc->vc_memh, dstoff, - nrows * vc->vc_ncol); + if (nrows == 0 || srcrow == dstrow) + return; + + if (srcrow < dstrow && srcrow + nrows > dstrow) { + int srow, drow; + + for (srow = srcrow + nrows - 1, drow = dstrow + nrows - 1; + srow >= srcrow; srow--, drow--) { + vga_copyrows(id, srow, drow, 1); + } + } else + bus_space_copy_2(vc->vc_memt, vc->vc_memh, srcoff, + vc->vc_memh, dstoff, nrows * vc->vc_ncol); } void -- cgit v1.2.3