diff --git a/src/emulator.c b/src/emulator.c index 39aca6e..8fb7c8a 100644 --- 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) { - getcolors(&ppu, &m[0x8]); + putcolors(&ppu, genpeek16(m, 0x8), genpeek16(m, 0xa), genpeek16(m, 0xc)); 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 index 53481ed..4868b30 100644 --- a/src/ppu.c +++ b/src/ppu.c @@ -111,14 +111,14 @@ drawdebugger(Ppu *p, Uint8 *stack, Uint8 ptr) } void -getcolors(Ppu *p, Uint8 *addr) +putcolors(Ppu *p, Uint16 rr, Uint16 gg, Uint16 bb) { int i; for(i = 0; i < 4; ++i) { 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; + 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; p->colors[i] = (r << 20) + (r << 16) + (g << 12) + (g << 8) + (b << 4) + b; } } diff --git a/src/ppu.h b/src/ppu.h index a99c039..7c6e155 100644 --- 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 getcolors(Ppu *p, Uint8 *addr); +void putcolors(Ppu *p, Uint16 rr, Uint16 gg, Uint16 bb); 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