ppu_palette: rewrite for more readability
This commit is contained in:
parent
8d4e7d54e1
commit
69cfef46be
|
@ -40,13 +40,14 @@ static Uint8 font[][8] = {
|
||||||
void
|
void
|
||||||
ppu_palette(Ppu *p, Uint8 *addr)
|
ppu_palette(Ppu *p, Uint8 *addr)
|
||||||
{
|
{
|
||||||
int i;
|
int i, shift;
|
||||||
for(i = 0; i < 4; ++i) {
|
for(i = 0, shift = 4; i < 4; ++i, shift ^= 4) {
|
||||||
Uint8
|
Uint8
|
||||||
r = (*(addr + i / 2) >> (!(i % 2) << 2)) & 0x0f,
|
r = (addr[0 + i / 2] >> shift) & 0x0f,
|
||||||
g = (*(addr + 2 + i / 2) >> (!(i % 2) << 2)) & 0x0f,
|
g = (addr[2 + i / 2] >> shift) & 0x0f,
|
||||||
b = (*(addr + 4 + i / 2) >> (!(i % 2) << 2)) & 0x0f;
|
b = (addr[4 + i / 2] >> shift) & 0x0f;
|
||||||
p->palette[i] = 0xff000000 | (r << 20) | (r << 16) | (g << 12) | (g << 8) | (b << 4) | b;
|
p->palette[i] = 0x0f000000 | r << 16 | g << 8 | b;
|
||||||
|
p->palette[i] |= p->palette[i] << 4;
|
||||||
}
|
}
|
||||||
p->fg.changed = p->bg.changed = 1;
|
p->fg.changed = p->bg.changed = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue