From 371f6913e7570a5cede360262f1e04bc1ef46435 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 17 Feb 2016 19:42:06 -0800 Subject: [PATCH] GB IO: Make palettes readable --- src/gb/io.c | 6 +++++- src/gb/video.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gb/io.c b/src/gb/io.c index bafccc14c..d1aab6aa0 100644 --- a/src/gb/io.c +++ b/src/gb/io.c @@ -329,6 +329,7 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) { case REG_BCPS: gb->video.bcpIndex = value & 0x3F; gb->video.bcpIncrement = value & 0x80; + gb->memory.io[REG_BCPD] = gb->video.palette[gb->video.bcpIndex >> 1]; break; case REG_BCPD: GBVideoProcessDots(&gb->video); @@ -337,6 +338,7 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) { case REG_OCPS: gb->video.ocpIndex = value & 0x3F; gb->video.ocpIncrement = value & 0x80; + gb->memory.io[REG_OCPD] = gb->video.palette[8 * 4 + (gb->video.ocpIndex >> 1)]; break; case REG_OCPD: GBVideoProcessDots(&gb->video); @@ -453,14 +455,16 @@ uint8_t GBIORead(struct GB* gb, unsigned address) { default: if (gb->model >= GB_MODEL_CGB) { switch (address) { + case REG_KEY1: case REG_VBK: case REG_HDMA1: case REG_HDMA2: case REG_HDMA3: case REG_HDMA4: case REG_HDMA5: + case REG_BCPD: + case REG_OCPD: case REG_SVBK: - case REG_KEY1: // Handled transparently by the registers goto success; default: diff --git a/src/gb/video.c b/src/gb/video.c index b11ef2c6a..9a97c3407 100644 --- a/src/gb/video.c +++ b/src/gb/video.c @@ -314,6 +314,7 @@ void GBVideoWritePalette(struct GBVideo* video, uint16_t address, uint8_t value) if (video->bcpIncrement) { ++video->bcpIndex; video->bcpIndex &= 0x3F; + video->p->memory.io[REG_BCPD] = video->palette[video->bcpIndex >> 1]; } break; case REG_OCPD: @@ -328,6 +329,7 @@ void GBVideoWritePalette(struct GBVideo* video, uint16_t address, uint8_t value) if (video->ocpIncrement) { ++video->ocpIndex; video->ocpIndex &= 0x3F; + video->p->memory.io[REG_OCPD] = video->palette[8 * 4 + (video->ocpIndex >> 1)]; } break; }