shithub: riscv

Download patch

ref: c71c05dd64fba4305f799170b117ce220753967f
parent: b9ca8e83784b94e709e7d412eb4f87fa0a1885a8
author: cinap_lenrek <[email protected]>
date: Wed Jul 18 11:08:01 EDT 2012

screen: cleanup

--- a/sys/src/9/pc/screen.c
+++ b/sys/src/9/pc/screen.c
@@ -176,7 +176,7 @@
 {
 	VGAscr *scr;
 	uchar *sp, *disp, *sdisp, *edisp;
-	int y, len, incs, off, xoff, page;
+	int y, len, incs, off, page;
 
 	scr = &vgascreen[0];
 	if(scr->gscreen == nil || scr->useflush == 0)
@@ -188,45 +188,32 @@
 	if(rectclip(&r, scr->gscreen->r) == 0)
 		return;
 	disp = scr->vaddr;
-	incs = scr->gscreen->width * BY2WD;
-	xoff = (r.min.x*scr->gscreen->depth) / 8;
-	off = r.min.y*incs + xoff;
+	incs = scr->gscreen->width*BY2WD;
+	off = (r.min.x*scr->gscreen->depth) / 8;
+	len = (r.max.x*scr->gscreen->depth + 7) / 8;
+	len -= off;
+	off += r.min.y*incs;
 	sp = scr->gscreendata->bdata + scr->gscreen->zero + off;
 
 	/*
-	 * Linear framebuffer but with softscreen.
+	 * Linear framebuffer with softscreen.
 	 */
 	if(scr->paddr){
-		len = (r.max.x*scr->gscreen->depth + 7) / 8;
-		len -= xoff;
-		sdisp = disp + off;
-		edisp = sdisp + Dy(r)*incs;
-		while(sdisp < edisp){
+		sdisp = disp+off;
+		for(y = r.min.y; y < r.max.y; y++) {
 			memmove(sdisp, sp, len);
-			sdisp += incs;
 			sp += incs;
+			sdisp += incs;
 		}
 		return;
 	}
 
-
 	/*
-	 * Paged access thru 64K window.
-	 * It would be fair to say that this doesn't work for >8-bit screens.
+	 * Paged framebuffer window.
 	 */
 	if(scr->dev == nil || scr->dev->page == nil)
 		return;
 
-	switch(scr->gscreen->depth){
-	default:
-		len = 0;
-		break;
-	case 8:
-		len = Dx(r);
-		break;
-	}
-	if(len < 1)
-		return;
 	page = off/scr->apsize;
 	off %= scr->apsize;
 	sdisp = disp+off;