X-Git-Url: http://git.squeep.com/?p=dcpu16;a=blobdiff_plain;f=hw_lem1802.c;fp=hw_lem1802.c;h=dd8d33fdcb48fcdda46cef9f0dd718fc09042f30;hp=92e5149c64d5be7b42489b4f9a371222949b1b5f;hb=74629db149379f2d67cd2b1cf575b46ef6e317b6;hpb=e1a0aecf189adf6befb6ad708685813191af48bc 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