commit c9e35a5ad803adfb8eda34346ab7c5daacbeaf07
parent 9c4df351748b3328ba60a67a648eeec53df9e31c
Author: neauoire <aliceffekt@gmail.com>
Date: Tue, 20 Apr 2021 20:09:10 -0700
Revert "Tiny fix to PPU"
This reverts commit 9c4df351748b3328ba60a67a648eeec53df9e31c.
Diffstat:
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
@@ -184,7 +184,7 @@ doctrl(Uxn *u, SDL_Event *event, int z)
Uint8
system_poke(Uxn *u, Uint8 *m, Uint8 b0, Uint8 b1)
{
- putcolors(&ppu, genpeek16(m, 0x8), genpeek16(m, 0xa), genpeek16(m, 0xc));
+ getcolors(&ppu, &m[0x8]);
printf("%02x%02x %02x%02x %02x%02x\n", m[0x8], m[0x9], m[0xa], m[0xb], m[0xc], m[0xd]);
reqdraw = 1;
(void)u;
diff --git a/src/ppu.c b/src/ppu.c
@@ -111,14 +111,14 @@ drawdebugger(Ppu *p, Uint8 *stack, Uint8 ptr)
}
void
-putcolors(Ppu *p, Uint16 rr, Uint16 gg, Uint16 bb)
+getcolors(Ppu *p, Uint8 *addr)
{
int i;
for(i = 0; i < 4; ++i) {
Uint8
- r = ((rr >> (1 - i / 2) * 8) >> (!(i % 2) << 2)) & 0x0f,
- g = ((gg >> (1 - i / 2) * 8) >> (!(i % 2) << 2)) & 0x0f,
- b = ((bb >> (1 - i / 2) * 8) >> (!(i % 2) << 2)) & 0x0f;
+ 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->colors[i] = (r << 20) + (r << 16) + (g << 12) + (g << 8) + (b << 4) + b;
}
}
diff --git a/src/ppu.h b/src/ppu.h
@@ -26,7 +26,7 @@ typedef struct Ppu {
int initppu(Ppu *p, Uint8 hor, Uint8 ver, Uint8 pad);
void drawppu(Ppu *p);
void drawdebugger(Ppu *p, Uint8 *stack, Uint8 ptr);
-void putcolors(Ppu *p, Uint16 rr, Uint16 gg, Uint16 bb);
+void getcolors(Ppu *p, Uint8 *addr);
void putpixel(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 color);
void puticn(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color);
void putchr(Ppu *p, Uint8 *layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color);
\ No newline at end of file