From f40b9527afdda5bd1187a03bf5fb496a6b1d62f8 Mon Sep 17 00:00:00 2001 From: Sour Date: Wed, 10 Jul 2019 23:13:06 -0400 Subject: [PATCH] PPU: Mosaic "start" scanline should not be reset when writing to the mosaic register while mosaic is already enabled (Fixes FF3 battle mosaic) --- Core/Ppu.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Core/Ppu.cpp b/Core/Ppu.cpp index 47a56ee..bea5cc0 100644 --- a/Core/Ppu.cpp +++ b/Core/Ppu.cpp @@ -1786,15 +1786,18 @@ void Ppu::Write(uint32_t addr, uint8_t value) _layerConfig[3].LargeTiles = (value & 0x80) != 0; break; - case 0x2106: + case 0x2106: { //MOSAIC - Screen Pixelation _mosaicSize = ((value & 0xF0) >> 4) + 1; - _mosaicEnabled = value & 0x0F; - if(_mosaicEnabled) { + uint8_t mosaicEnabled = value & 0x0F; + if(!_mosaicEnabled && mosaicEnabled) { //"If this register is set during the frame, the starting scanline is the current scanline, otherwise it is the first visible scanline of the frame." + //This is only done when mosaic is turned on from an off state (FF3 mosaic effect looks wrong otherwise) _mosaicStartScanline = _scanline; } + _mosaicEnabled = mosaicEnabled; break; + } case 0x2107: case 0x2108: case 0x2109: case 0x210A: //BG 1-4 Tilemap Address and Size (BG1SC, BG2SC, BG3SC, BG4SC) @@ -2157,7 +2160,7 @@ void Ppu::RenderTilemap() template void Ppu::RenderTilemapMode7() { - bool applyMosaic = forMainScreen && ((_mosaicEnabled >> layerIndex) & 0x01) != 0; + bool applyMosaic = ((_mosaicEnabled >> layerIndex) & 0x01) != 0; if(applyMosaic) { RenderTilemapMode7();