uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 09f435216178c0749118e3700de9861b5e232e70
parent c91bf304e62344302a01d381c06a8ca6134db8bd
Author: neauoire <aliceffekt@gmail.com>
Date:   Sun, 28 Mar 2021 12:09:21 -0700

Cleaned up screen colors code

Diffstat:
Msrc/emulator.c | 17++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c @@ -148,15 +148,14 @@ error(char *msg, const char *err) void loadtheme(Uint8 *addr) { - Uint8 r, g, b; - r = *(addr + 0) >> 4 & 0xf, g = *(addr + 2) >> 4 & 0xf, b = *(addr + 4) >> 4 & 0xf; - theme[0] = ((r + (r << 4)) << 16) + ((g + (g << 4)) << 8) + (b + (b << 4)); - r = *(addr + 0) & 0xf, g = *(addr + 2) & 0xf, b = *(addr + 4) & 0xf; - theme[1] = ((r + (r << 4)) << 16) + ((g + (g << 4)) << 8) + (b + (b << 4)); - r = *(addr + 1) >> 4 & 0xf, g = *(addr + 3) >> 4 & 0xf, b = *(addr + 5) >> 4 & 0xf; - theme[2] = ((r + (r << 4)) << 16) + ((g + (g << 4)) << 8) + (b + (b << 4)); - r = *(addr + 1) & 0xf, g = *(addr + 3) & 0xf, b = *(addr + 5) & 0xf; - theme[3] = ((r + (r << 4)) << 16) + ((g + (g << 4)) << 8) + (b + (b << 4)); + int i; + for(i = 0; i < 4; ++i) { + Uint8 + r = (*(addr + i / 2) >> (!(i % 2) * 4)) & 0x0f, + g = (*(addr + 2 + i / 2) >> (!(i % 2) * 4)) & 0x0f, + b = (*(addr + 4 + i / 2) >> (!(i % 2) * 4)) & 0x0f; + theme[i] = ((r << 4) << 16) + ((g << 4) << 8) + (b << 4); + } screen.reqdraw = 1; }