r1905 - in trunk/user/microwin/src

dslinux_amadeus at dslinux.in-berlin.de dslinux_amadeus at dslinux.in-berlin.de
Mon Sep 17 22:58:17 CEST 2007


Author: amadeus
Date: 2007-09-17 22:58:11 +0200 (Mon, 17 Sep 2007)
New Revision: 1905

Log:
Fix the wrong color mapping.

Modified: trunk/user/microwin/src/drivers/fblin16.c
===================================================================
--- trunk/user/microwin/src/drivers/fblin16.c	2007-09-17 18:15:19 UTC (rev 1904)
+++ trunk/user/microwin/src/drivers/fblin16.c	2007-09-17 20:58:11 UTC (rev 1905)
@@ -10,6 +10,12 @@
 #include <assert.h>
 #include <stdlib.h>
 
+#if NDSDRIVER
+#define ALPHA_1B (1 << 15)
+#else
+#define ALPHA_1B (0)
+#endif
+
 /* We want to do string copying fast, so inline assembly if possible */
 #ifndef __OPTIMIZE__
 #define __OPTIMIZE__
@@ -19,11 +25,7 @@
 #include "device.h"
 #include "fb.h"
 
-#if NDSDRIVER
-#define ALPHA_1B  (1 << 15)
-#else
-#define ALPHA_1B 0
-#endif
+DEFINE_applyOpR			/* define inline rop calculator*/
 
 #define USE_16BIT_ACCESS 0	/* =1 to force 16 bit display access*/
 
@@ -62,12 +64,11 @@
 	assert (c < psd->ncolors);
 
 	DRAWON;
+	addr += x + y * psd->linelen;
 	if(gr_mode == MWMODE_COPY)
-		addr[x + y * psd->linelen] = c | ALPHA_1B;
-	else {
-		applyOp(gr_mode, c, &addr[x + y * psd->linelen], ADDR16);
-		addr[x + y * psd->linelen] |= ALPHA_1B;
-	}
+		*addr = c;
+	else
+		*addr = applyOpR(gr_mode, c, *addr) | ALPHA_1B;
 	DRAWOFF;
 }
 
@@ -81,7 +82,7 @@
 	assert (x >= 0 && x < psd->xres);
 	assert (y >= 0 && y < psd->yres);
 
-	return addr[x + y * psd->linelen] & ~(ALPHA_1B);
+	return addr[x + y * psd->linelen];
 }
 
 /* Draw horizontal line from x1,y to x2,y including final point*/
@@ -101,14 +102,12 @@
 	addr += x1 + y * psd->linelen;
 	if(gr_mode == MWMODE_COPY) {
 		/* FIXME: memsetw(dst, c, x2-x1+1)*/
-		c |= ALPHA_1B;
 		while(x1++ <= x2)
 			*addr++ = c;
 	} else {
 		while (x1++ <= x2) {
-			applyOp(gr_mode, c, addr, ADDR16);
-			*addr |= ALPHA_1B;
-			++addr;
+			*addr = applyOpR(gr_mode, c, *addr) | ALPHA_1B;
+			addr++;
 		}
 	}
 	DRAWOFF;
@@ -131,15 +130,13 @@
 	DRAWON;
 	addr += x + y1 * linelen;
 	if(gr_mode == MWMODE_COPY) {
-		c |= ALPHA_1B;
 		while(y1++ <= y2) {
 			*addr = c;
 			addr += linelen;
 		}
 	} else {
 		while (y1++ <= y2) {
-			applyOp(gr_mode, c, addr, ADDR16);
-			*addr |= ALPHA_1B;
+			*addr = applyOpR(gr_mode, c, *addr) | ALPHA_1B;
 			addr += linelen;
 		}
 	}
@@ -241,8 +238,7 @@
 	} else {
 		while (--h >= 0) {
 			for (i=0; i<w; i++) {
-				applyOp(MWROP_TO_MODE(op), *src, dst, ADDR16);
-				*dst |= ALPHA_1B;
+				*dst = applyOpR(MWROP_TO_MODE(op), *src, *dst) | ALPHA_1B;
 				++src;
 				++dst;
 			}
@@ -313,7 +309,7 @@
 				pixel = *src++;
 				col_pos -= 0x10000L;
 			}
-			*dst++ = pixel | ALPHA_1B;
+			*dst++ = pixel;
 			col_pos += col_inc;
 		}
 
@@ -511,7 +507,7 @@
 
 			x_count = width;
 			while (x_count-- > 0) {
-				*dest_ptr++ = *src_ptr | ALPHA_1B;
+				*dest_ptr++ = *src_ptr;
 
 				src_ptr += src_x_step_normal;
 				x_error += x_error_step_normal;
@@ -556,8 +552,7 @@
 
 			x_count = width;
 			while (x_count-- > 0) {
-				applyOp(MWROP_TO_MODE(op), *src_ptr, dest_ptr, ADDR16);
-				*dest_ptr |= ALPHA_1B;
+				*dest_ptr = applyOpR(MWROP_TO_MODE(op), *src_ptr, *dest_ptr) | ALPHA_1B;
 				dest_ptr++;
 
 				src_ptr += src_x_step_normal;

Modified: trunk/user/microwin/src/include/device.h
===================================================================
--- trunk/user/microwin/src/include/device.h	2007-09-17 18:15:19 UTC (rev 1904)
+++ trunk/user/microwin/src/include/device.h	2007-09-17 20:58:11 UTC (rev 1905)
@@ -462,8 +462,13 @@
 	((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
 
 /* create 16 bit 5/5/5 format pixel from RGB triplet */
+#if NDSDRIVER
 #define RGB2PIXEL555(r,g,b)	\
+	((1 << 15) | (((b) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((r) & 0xf8) >> 3))
+#else
+#define RGB2PIXEL555(r,g,b)	\
 	((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3))
+#endif
 
 /* create 8 bit 3/3/2 format pixel from RGB triplet*/
 #define RGB2PIXEL332(r,g,b)	\
@@ -489,8 +494,13 @@
 
 /* create 16 bit 5/5/5 format pixel from RGB colorval (0x00BBGGRR)*/
 /* In this format, alpha is ignored. */
+#if NDSDRIVER
 #define COLOR2PIXEL555(c)	\
+	((((c) & 0xf8) >> 3) | (((c) & 0xf800) >> 6) | (((c) & 0xf80000) >> 9) | (1 << 15))
+#else
+#define COLOR2PIXEL555(c)	\
 	((((c) & 0xf8) << 7) | (((c) & 0xf800) >> 6) | (((c) & 0xf80000) >> 19))
+#endif
 
 /* create 8 bit 3/3/2 format pixel from RGB colorval (0x00BBGGRR)*/
 /* In this format, alpha is ignored. */
@@ -516,10 +526,16 @@
 #define PIXEL565GREEN(pixelval)		(((pixelval) >> 5) & 0x3f)
 #define PIXEL565BLUE(pixelval)		((pixelval) & 0x1f)
 
-/* return 5/5/5 bit r, g or b component of 16 bit pixelval*/
+/* return 5/5/5 bit r, g or b component of 15 bit pixelval*/
+#if NDSDRIVER
+#define PIXEL555RED(pixelval)		((pixelval) & 0x1f)
+#define PIXEL555GREEN(pixelval)		(((pixelval) >> 5) & 0x1f)
+#define PIXEL555BLUE(pixelval)		(((pixelval) >> 10) & 0x1f)
+#else
 #define PIXEL555RED(pixelval)		(((pixelval) >> 10) & 0x1f)
 #define PIXEL555GREEN(pixelval)		(((pixelval) >> 5) & 0x1f)
 #define PIXEL555BLUE(pixelval)		((pixelval) & 0x1f)
+#endif
 
 /* return 3/3/2 bit r, g or b component of 8 bit pixelval*/
 #define PIXEL332RED(pixelval)		(((pixelval) >> 5) & 0x07)
@@ -530,10 +546,10 @@
  * Conversion from MWPIXELVAL to normal 8-bit red, green or blue components
  */
 /* return 8/8/8/8 bit a, r, g or b component of 32 bit pixelval*/
-#define PIXEL8888ALPHA8(pixelval)		(((pixelval) >> 24) & 0xff)
+#define PIXEL8888ALPHA8(pixelval)	(((pixelval) >> 24) & 0xff)
 #define PIXEL8888RED8(pixelval)		(((pixelval) >> 16) & 0xff)
-#define PIXEL8888GREEN8(pixelval)		(((pixelval) >> 8) & 0xff)
-#define PIXEL8888BLUE8(pixelval)		((pixelval) & 0xff)
+#define PIXEL8888GREEN8(pixelval)	(((pixelval) >> 8) & 0xff)
+#define PIXEL8888BLUE8(pixelval)	((pixelval) & 0xff)
 
 /* return 8 bit r, g or b component of 8/8/8 24 bit pixelval*/
 #define PIXEL888RED8(pixelval)          (((pixelval) >> 16) & 0xff)
@@ -545,10 +561,16 @@
 #define PIXEL565GREEN8(pixelval)        (((pixelval) >> 3) & 0xfc)
 #define PIXEL565BLUE8(pixelval)         (((pixelval) << 3) & 0xf8)
 
-/* return 8 bit r, g or b component of 5/5/5 16 bit pixelval*/
+/* return 8 bit r, g or b component of 5/5/5 15 bit pixelval*/
+#if NDSDRIVER
+#define PIXEL555RED8(pixelval)          (((pixelval) << 3) & 0xf8)
+#define PIXEL555GREEN8(pixelval)        (((pixelval) >> 2) & 0xf8)
+#define PIXEL555BLUE8(pixelval)         (((pixelval) >> 7) & 0xf8)
+#else
 #define PIXEL555RED8(pixelval)          (((pixelval) >> 7) & 0xf8)
 #define PIXEL555GREEN8(pixelval)        (((pixelval) >> 2) & 0xf8)
 #define PIXEL555BLUE8(pixelval)         (((pixelval) << 3) & 0xf8)
+#endif
 
 /* return 8 bit r, g or b component of 3/3/2 8 bit pixelval*/
 #define PIXEL332RED8(pixelval)          ( (pixelval)       & 0xe0)
@@ -576,10 +598,16 @@
 #define PIXEL565GREEN32(pixelval)        ((((unsigned long)(pixelval)) << 21) & 0xfc000000UL)
 #define PIXEL565BLUE32(pixelval)         ((((unsigned long)(pixelval)) << 27) & 0xf8000000UL)
 
-/* return 32 bit r, g or b component of 5/5/5 16 bit pixelval*/
+/* return 32 bit r, g or b component of 5/5/5 15 bit pixelval*/
+#if NDSDRIVER
+#define PIXEL555RED32(pixelval)          ((((unsigned long)(pixelval)) << 27) & 0xf8000000UL)
+#define PIXEL555GREEN32(pixelval)        ((((unsigned long)(pixelval)) << 22) & 0xf8000000UL)
+#define PIXEL555BLUE32(pixelval)         ((((unsigned long)(pixelval)) << 17) & 0xf8000000UL)
+#else
 #define PIXEL555RED32(pixelval)          ((((unsigned long)(pixelval)) << 17) & 0xf8000000UL)
 #define PIXEL555GREEN32(pixelval)        ((((unsigned long)(pixelval)) << 22) & 0xf8000000UL)
 #define PIXEL555BLUE32(pixelval)         ((((unsigned long)(pixelval)) << 27) & 0xf8000000UL)
+#endif
 
 /* return 32 bit r, g or b component of 3/3/2 8 bit pixelval*/
 #define PIXEL332RED32(pixelval)          ((((unsigned long)(pixelval)) << 24) & 0xe0000000UL)
@@ -601,8 +629,14 @@
 #define PIXEL565TOCOLORVAL(p)	\
 	(0xff000000ul | (((p) & 0xf800u) >> 8) | (((p) & 0x07e0u) << 5) | (((p) & 0x1ful) << 19) | 0xff000000ul)
 
+/* create RGB colorval (0xAABBGGRR) from 5/5/5 format pixel*/
+#if NDSDRIVER
 #define PIXEL555TOCOLORVAL(p)	\
+	(0xff000000ul | (((p) & 0x7c00u) << 6) | (((p) & 0x03e0u) << 3) | ((p) & 0x1ful))
+#else
+#define PIXEL555TOCOLORVAL(p)	\
 	(0xff000000ul | (((p) & 0x7c00u) >> 7) | (((p) & 0x03e0u) << 6) | (((p) & 0x1ful) << 19) | 0xff000000ul)
+#endif
 
 /* create RGB colorval (0xAABBGGRR) from 3/3/2 format pixel*/
 #define PIXEL332TOCOLORVAL(p)	\
@@ -636,13 +670,8 @@
 #endif
 
 #if MWPIXEL_FORMAT == MWPF_TRUECOLOR555
-#if NDSDRIVER
-#define RGB2PIXEL(r,g,b)	(RGB2PIXEL555(r,g,b) | 1 << 15)
-#define COLORVALTOPIXELVAL(c)	(COLOR2PIXEL555(c) | 1 << 15)
-#else
 #define RGB2PIXEL(r,g,b)	RGB2PIXEL555(r,g,b)
 #define COLORVALTOPIXELVAL(c)	COLOR2PIXEL555(c)
-#endif
 #define PIXELVALTOCOLORVAL(p)	PIXEL555TOCOLORVAL(p)
 #define PIXEL2RED(p)		PIXEL555RED(p)
 #define PIXEL2GREEN(p)		PIXEL555GREEN(p)




More information about the dslinux-commit mailing list