uxn

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

commit 9c4df351748b3328ba60a67a648eeec53df9e31c
parent a4e54062b837991c1ede8fc377cd2650c3860fbf
Author: neauoire <aliceffekt@gmail.com>
Date:   Tue, 20 Apr 2021 20:06:30 -0700

Tiny fix to PPU

Diffstat:
Msrc/emulator.c | 2+-
Msrc/ppu.c | 8++++----
Msrc/ppu.h | 2+-
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) { - 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 @@ -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 @@ -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