From 74629db149379f2d67cd2b1cf575b46ef6e317b6 Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Sun, 13 May 2012 21:25:05 -0700 Subject: [PATCH] fixed palette-to-color conversion wups, was shifting the wrong number of bits --- hw_lem1802.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hw_lem1802.c b/hw_lem1802.c index 92e5149..dd8d33f 100644 --- a/hw_lem1802.c +++ b/hw_lem1802.c @@ -65,7 +65,7 @@ static const DCPU16_WORD palette_default_[PALETTE_ENTRIES] = { 0x0f55, /* light red */ 0x0f5f, /* light magenta */ 0x0ff5, /* light yellow */ - 0x0fff, /* white */ + 0x0fff /* white */ }; struct pixel_ { @@ -97,10 +97,19 @@ struct lem1802_ { static inline void pixel_color_(struct pixel_ *pix, DCPU16_WORD color) { - pix->r = (color & 0x000f) | ((color & 0x000f) << 8); - pix->g = ((color & 0x00f0) >> 8) | (color & 0x00f0); - pix->b = ((color & 0x0f00) >> 8) | ((color & 0x0f00) >> 16); - pix->a = ((color & 0xf000) >> 16) | ((color & 0xf000) >> 24); + unsigned char x; + + x = (color >> 0) & 0x000f; + pix->r = x | (x << 4); + + x = (color >> 4) & 0x000f; + pix->g = x | (x << 4); + + x = (color >> 8) & 0x000f; + pix->b = x | (x << 4); + + x = (color >> 12) & 0x000f; + pix->a = x | (x << 4); } static -- 2.43.2