[syslinux:elflink] core/graphics.c: Fixes and cleanups

syslinux-bot for H. Peter Anvin hpa at linux.intel.com
Tue Apr 17 11:24:23 PDT 2012


Commit-ID:  429a41b4d33e8c34638de56a4a23e67337f9f34a
Gitweb:     http://www.syslinux.org/commit/429a41b4d33e8c34638de56a4a23e67337f9f34a
Author:     H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Tue, 17 Apr 2012 11:22:36 -0700
Committer:  H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Tue, 17 Apr 2012 11:22:36 -0700

core/graphics.c: Fixes and cleanups

Fix up various conversion bugs from assembly.  Eventually this whole
file should be removed and the functionality moved to using the VESA
framework.

Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>

---
 core/graphics.c |   59 +++++++++++++++++++++++-------------------------------
 1 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/core/graphics.c b/core/graphics.c
index e85787d..42ff6ec 100644
--- a/core/graphics.c
+++ b/core/graphics.c
@@ -19,6 +19,7 @@
 #include <stddef.h>
 #include "core.h"
 #include <sys/io.h>
+#include <hw/vga.h>
 #include "fs.h"
 #include "bios.h"
 
@@ -177,29 +178,26 @@ again:
  * packedpixel2vga:
  *	Convert packed-pixel to VGA bitplanes
  *
- * 'in': packed pixel string
- * 'out': output (four planes)
+ * 'in': packed pixel string (640 pixels)
+ * 'out': output (four planes @ 640/8 = 80 bytes)
  * 'count': pixel count (multiple of 8)
  */
-static void packedpixel2vga(uint8_t *in, uint8_t *out, size_t count)
+static void packedpixel2vga(const uint8_t *in, uint8_t *out)
 {
-	uint8_t bx, al, dl;
-	int plane, pixel;
-
-	for (plane = 0; plane < 4; plane++) {
-		for (bx = 0; bx < count; bx += 8) {
-			for (pixel = 0; pixel < 8; pixel++) {
-				al = *in++;
-				al >>= plane;
-
-				/*
-				 * VGA is bigendian.  Sigh.
-				 * Left rotate through carry
-				 */
-				dl = dl << 1 | (dl >> (8 - 1));
+	int i, j, k;
+
+	for (i = 0; i < 4; i++) {
+		const uint8_t *ip = in;
+
+		for (j = 0; j < 640/8; j++) {
+			uint8_t ob = 0;
+
+			for (k = 0; k < 8; k++) {
+				uint8_t px = *ip++;
+				ob = (ob << 1) | ((px >> i) & 1);
 			}
 
-			*out++ = dl;
+			*out++ = ob;
 		}
 	}
 }
@@ -211,24 +209,18 @@ static void packedpixel2vga(uint8_t *in, uint8_t *out, size_t count)
  * 'in': four planes @ 640/8=80 bytes
  * 'out': pointer into VGA memory
  */
-static void outputvga(uint32_t *in, uint32_t *out)
+static void outputvga(const void *in, void *out)
 {
-	uint8_t val, *addr;
-	int i, j;
-
-	addr = (uint8_t *)0x3C4; /* VGA Sequencer Register select port */
-	val = 2;		 /* Sequencer mask */
+	int i;
 
 	/* Select the sequencer mask */
-	outb(val, (uint32_t)addr);
+	outb(VGA_SEQ_IX_MAP_MASK, VGA_SEQ_ADDR);
 
-	addr += 1;		/* VGA Sequencer Register data port */
-	for (i = 1; i <= 8; i *= 2) {
+	for (i = 1; i <= 8; i <<= 1) {
 		/* Select the bit plane to write */
-		outb(i, (uint32_t)addr);
-
-		for (j = 0; j < (640 / 32); j++)
-			*(out + j) = *(in + j);
+		outb(i, VGA_SEQ_DATA);
+		memcpy(out, in, 640/8);
+		in = (const char *)in + 640/8;
 	}
 }
 
@@ -300,9 +292,8 @@ void vgadisplayfile(FILE *_fd)
 			/* Decode one row */
 			rledecode(VGARowBuffer, GraphXSize);
 
-			packedpixel2vga(VGARowBuffer, VGAPlaneBuffer, 640);
-			outputvga((uint32_t *)VGAPlaneBuffer,
-				  MK_PTR(0x0A000, VGAPos));
+			packedpixel2vga(VGARowBuffer, VGAPlaneBuffer);
+			outputvga(VGAPlaneBuffer, MK_PTR(0xA000, VGAPos));
 			VGAPos += 640/8;
 		}
 	}


More information about the Syslinux-commits mailing list