PPU Mosaic fixes imported from higan

This commit is contained in:
Ruslan Tretiakov 2020-09-30 07:27:37 -04:00 committed by Screwtapello
parent 9517080349
commit fcc982dff0
2 changed files with 12 additions and 12 deletions

View File

@ -28,13 +28,13 @@ auto PPU::Line::renderBackground(PPU::IO::Background& self, uint8 source) -> voi
uint vmask = (width << self.tileSize << !!(self.screenSize & 2)) - 1; uint vmask = (width << self.tileSize << !!(self.screenSize & 2)) - 1;
uint y = this->y; uint y = this->y;
if(self.mosaicEnable) y -= io.mosaic.size - io.mosaic.counter;
if(hires) { if(hires) {
hscroll <<= 1; hscroll <<= 1;
if(io.interlace) { if(io.interlace) y = y << 1 | (field() && !self.mosaicEnable);
y = y << 1 | field(); }
if(self.mosaicEnable) y -= io.mosaic.size - io.mosaic.counter + field(); if(self.mosaicEnable) {
} y -= (io.mosaic.size - io.mosaic.counter) << (hires && io.interlace);
} }
uint mosaicCounter = 1; uint mosaicCounter = 1;
@ -112,7 +112,7 @@ auto PPU::Line::renderBackground(PPU::IO::Background& self, uint8 source) -> voi
color += data >> shift + 49 & 128; color += data >> shift + 49 & 128;
} }
mosaicCounter = self.mosaicEnable ? io.mosaic.size : 1; mosaicCounter = self.mosaicEnable ? io.mosaic.size << hires : 1;
mosaicPalette = color; mosaicPalette = color;
mosaicPriority = tilePriority; mosaicPriority = tilePriority;
if(directColorMode) { if(directColorMode) {

View File

@ -37,13 +37,12 @@ auto PPU::Background::fetchNameTable() -> void {
uint hscroll = io.hoffset; uint hscroll = io.hoffset;
uint vscroll = io.voffset; uint vscroll = io.voffset;
if(mosaic.enable) vpixel -= ppu.mosaic.voffset();
if(hires()) { if(hires()) {
hscroll <<= 1; hscroll <<= 1;
if(ppu.io.interlace) { if(ppu.io.interlace) vpixel = vpixel << 1 | (ppu.field() && !mosaic.enable);
vpixel = vpixel << 1 | ppu.field(); }
if(mosaic.enable) vpixel -= ppu.mosaic.voffset() + ppu.field(); if(mosaic.enable) {
} vpixel -= ppu.mosaic.voffset() << (hires() && ppu.io.interlace);
} }
bool repeated = false; bool repeated = false;
@ -197,7 +196,8 @@ auto PPU::Background::run(bool screen) -> void {
if(++pixelCounter == 0) renderingIndex++; if(++pixelCounter == 0) renderingIndex++;
uint x = ppu.hcounter() - 56 >> 2; uint x = ppu.hcounter() - 56 >> 2;
if(x == 0) {
if(x == 0 && (!hires() || screen == Screen::Below)) {
mosaic.hcounter = ppu.mosaic.size; mosaic.hcounter = ppu.mosaic.size;
mosaic.pixel = pixel; mosaic.pixel = pixel;
} else if((!hires() || screen == Screen::Below) && --mosaic.hcounter == 0) { } else if((!hires() || screen == Screen::Below) && --mosaic.hcounter == 0) {