GB: Palette I/O fixes
Jeffrey Pfau jeffrey@endrift.com
Sat, 25 Jun 2016 00:58:50 -0700
2 files changed,
10 insertions(+),
4 deletions(-)
M
src/gb/io.c
→
src/gb/io.c
@@ -408,7 +408,7 @@ break;
case REG_BCPD: GBVideoProcessDots(&gb->video); GBVideoWritePalette(&gb->video, address, value); - break; + return; case REG_OCPS: gb->video.ocpIndex = value & 0x3F; gb->video.ocpIncrement = value & 0x80;@@ -417,7 +417,7 @@ break;
case REG_OCPD: GBVideoProcessDots(&gb->video); GBVideoWritePalette(&gb->video, address, value); - break; + return; case REG_SVBK: GBMemorySwitchWramBank(&gb->memory, value); value = gb->memory.wramCurrentBank;@@ -537,7 +537,9 @@ case REG_HDMA2:
case REG_HDMA3: case REG_HDMA4: case REG_HDMA5: + case REG_BCPS: case REG_BCPD: + case REG_OCPS: case REG_OCPD: case REG_SVBK: // Handled transparently by the registers
M
src/gb/video.c
→
src/gb/video.c
@@ -354,7 +354,9 @@ video->renderer->writePalette(video->renderer, video->bcpIndex >> 1, video->palette[video->bcpIndex >> 1]);
if (video->bcpIncrement) { ++video->bcpIndex; video->bcpIndex &= 0x3F; - video->p->memory.io[REG_BCPD] = video->palette[video->bcpIndex >> 1]; + video->p->memory.io[REG_BCPS] &= 0x80; + video->p->memory.io[REG_BCPS] |= video->bcpIndex; + video->p->memory.io[REG_BCPD] = video->palette[video->bcpIndex >> 1] >> (8 * (video->bcpIndex & 1)); } break; case REG_OCPD:@@ -369,7 +371,9 @@ video->renderer->writePalette(video->renderer, 8 * 4 + (video->ocpIndex >> 1), video->palette[8 * 4 + (video->ocpIndex >> 1)]);
if (video->ocpIncrement) { ++video->ocpIndex; video->ocpIndex &= 0x3F; - video->p->memory.io[REG_OCPD] = video->palette[8 * 4 + (video->ocpIndex >> 1)]; + video->p->memory.io[REG_OCPS] &= 0x80; + video->p->memory.io[REG_OCPS] |= video->ocpIndex; + video->p->memory.io[REG_OCPD] = video->palette[8 * 4 + (video->ocpIndex >> 1)] >> (8 * (video->ocpIndex & 1)); } break; }