GB: Palette I/O fixes

This commit is contained in:
Jeffrey Pfau 2016-06-25 00:58:50 -07:00
parent ca46fedd34
commit 74caccd6df
2 changed files with 10 additions and 4 deletions

View File

@ -408,7 +408,7 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) {
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 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) {
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 @@ uint8_t GBIORead(struct GB* gb, unsigned address) {
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

View File

@ -354,7 +354,9 @@ 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];
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 @@ 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)];
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;
}