I've been trying to fix a bug in my emulator for 2 weeks, and I'm going crazy. You will probably laugh at my issue, since it must be very simple.
When I'm making my quadrant calculations for applying colors, it works perfectly, except on games with scrolling (only tested horizontal, but I'm sure vertical will also fail).
What I'm doing is this:
Code: Select all
int row32 = scanline % 32;
int column32 = (i + ppuX) % 32;
if (row32 <= 15) {
if (column32 <= 15) {
quadrant = attrib & 0x03; // bits 0-1
} else {
quadrant = (attrib & 0x0C) >> 2; // bits 2-3
}
} else {
if (column32 <= 15) {
quadrant = (attrib & 0x30) >> 4; // bits 4-5
} else {
quadrant = (attrib & 0xC0) >> 6; // bits 6-7
}
}
I debugged, and looks like the issue is with my "column32" variable, that sometimes will pick the 4th quadrant instead of the third one which has the correct white color for the clouds.
How am I supposed to make this calculation correctly ? Something regarding the scrolling is throwing it off.
Thanks for your help