diff --git a/Core/Ppu.cpp b/Core/Ppu.cpp index d6fb066..af496c8 100644 --- a/Core/Ppu.cpp +++ b/Core/Ppu.cpp @@ -949,7 +949,7 @@ void Ppu::RenderTilemap() TileData* tileData = _layerData[layerIndex].Tiles; - uint8_t mosaicCounter = applyMosaic ? (_drawStartX % _state.MosaicSize) : 0; + uint8_t mosaicCounter = applyMosaic ? _state.MosaicSize - (_drawStartX % _state.MosaicSize) : 0; uint8_t lookupIndex; uint8_t chrDataOffset; @@ -988,7 +988,7 @@ void Ppu::RenderTilemap() uint8_t priority = (tilemapData & 0x2000) ? highPriority : normalPriority; if(applyMosaic) { - if(mosaicCounter == 0) { + if(mosaicCounter == _state.MosaicSize) { mosaicCounter = 1; if(hiResMode) { color = hiresSubColor; @@ -997,9 +997,6 @@ void Ppu::RenderTilemap() _mosaicPriority[layerIndex] = priority; } else { mosaicCounter++; - if(mosaicCounter == _state.MosaicSize) { - mosaicCounter = 0; - } color = _mosaicColor[layerIndex] & 0xFF; paletteIndex = _mosaicColor[layerIndex] >> 8; priority = _mosaicPriority[layerIndex]; @@ -1111,7 +1108,7 @@ void Ppu::RenderTilemapMode7() //Keep the "scanline" to what it was at the start of this mosaic block realY -= _state.MosaicSize - _mosaicScanlineCounter; } - uint8_t mosaicCounter = applyMosaic ? (_drawStartX % _state.MosaicSize) : 0; + uint8_t mosaicCounter = applyMosaic ? _state.MosaicSize - (_drawStartX % _state.MosaicSize) : 0; int32_t xValue = ( ((_state.Mode7.Matrix[0] * clip(hScroll - centerX)) & ~63) + @@ -1178,15 +1175,12 @@ void Ppu::RenderTilemapMode7() } if(applyMosaic) { - if(mosaicCounter == 0) { + if(mosaicCounter == _state.MosaicSize) { mosaicCounter = 1; _mosaicColor[layerIndex] = colorIndex; _mosaicPriority[layerIndex] = priority; } else { mosaicCounter++; - if(mosaicCounter == _state.MosaicSize) { - mosaicCounter = 0; - } colorIndex = _mosaicColor[layerIndex]; priority = _mosaicPriority[layerIndex]; }