all repos — mgba @ 74caccd6df2298b0d123c677fabc5b751251156c

mGBA Game Boy Advance Emulator

GB: Palette I/O fixes
Jeffrey Pfau jeffrey@endrift.com
Sat, 25 Jun 2016 00:58:50 -0700
commit

74caccd6df2298b0d123c677fabc5b751251156c

parent

ca46fedd34dad2c5982ea7ff6c371cc9d15de510

2 files changed, 10 insertions(+), 4 deletions(-)

jump to
M src/gb/io.csrc/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.csrc/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; }