uxn

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

commit 69cfef46beafe0ee7cc5122ef01d88adea8e62f4
parent 8d4e7d54e199f5858d8f81ef2407b37d827ea945
Author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
Date:   Sat, 25 Dec 2021 22:42:34 +0100

ppu_palette: rewrite for more readability

Diffstat:
Msrc/devices/ppu.c | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/devices/ppu.c b/src/devices/ppu.c @@ -40,13 +40,14 @@ static Uint8 font[][8] = { void ppu_palette(Ppu *p, Uint8 *addr) { - int i; - for(i = 0; i < 4; ++i) { + int i, shift; + for(i = 0, shift = 4; i < 4; ++i, shift ^= 4) { Uint8 - r = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f, - g = (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f, - b = (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f; - p->palette[i] = 0xff000000 | (r << 20) | (r << 16) | (g << 12) | (g << 8) | (b << 4) | b; + r = (addr[0 + i / 2] >> shift) & 0x0f, + g = (addr[2 + i / 2] >> shift) & 0x0f, + b = (addr[4 + i / 2] >> shift) & 0x0f; + p->palette[i] = 0x0f000000 | r << 16 | g << 8 | b; + p->palette[i] |= p->palette[i] << 4; } p->fg.changed = p->bg.changed = 1; }