diff --git a/Core/MemoryManager.cpp b/Core/MemoryManager.cpp index 2c4607a2..d6b00e28 100644 --- a/Core/MemoryManager.cpp +++ b/Core/MemoryManager.cpp @@ -121,6 +121,9 @@ uint8_t MemoryManager::ReadVRAM(uint16_t addr) } else { if(addr >= 0x3F00) { addr &= 0x3F1F; + if(addr == 0x3F10 || addr == 0x3F14 || addr == 0x3F18 || addr == 0x3F1C) { + addr &= ~0x0010; + } } return _videoRAM[addr & 0x3FFF]; } @@ -134,6 +137,9 @@ void MemoryManager::WriteVRAM(uint16_t addr, uint8_t value) } else { if(addr >= 0x3F00) { addr &= 0x3F1F; + if(addr == 0x3F10 || addr == 0x3F14 || addr == 0x3F18 || addr == 0x3F1C) { + addr &= ~0x0010; + } //std::cout << "palette:" << std::hex << (short)addr << " = " << (short)value << std::endl; } if(addr == 0x2000) { diff --git a/Core/PPU.cpp b/Core/PPU.cpp index b776ec78..52ae3d21 100644 --- a/Core/PPU.cpp +++ b/Core/PPU.cpp @@ -301,7 +301,8 @@ void PPU::DrawPixel() //p->palettebuffer[fbRow].color = PPU_PALETTE_RGB[palette % 64]; uint32_t bufferPosition = _scanline * 256 + _cycle; - ((uint32_t*)_outputBuffer)[bufferPosition] = PPU_PALETTE_RGB[palette % 64] | (0xFF << 24); + uint32_t paletteColor = PPU_PALETTE_RGB[palette % 64]; + ((uint32_t*)_outputBuffer)[bufferPosition] = (paletteColor & 0xFF00) | ((paletteColor & 0xFF) << 16) | ((paletteColor & 0xFF0000) >> 16) | (0xFF << 24); //p->palettebuffer[fbRow].value = pixel; //p->palettebuffer[fbRow].pindex = -1; } @@ -315,8 +316,7 @@ void PPU::ProcessVisibleScanline() LoadShiftRegisters(); LoadTileInfo(); } - - + if(_cycle > 0 && _cycle <= 255) { DrawPixel(); }