But one attribute byte consists of a 32x32 pixel grid, so it overlaps multiple tiles and is in 4 quadrants. And my thought is, this discoloration only happens on tiles that happen to be next to something different. In the screenshot above, the only tiles that happen to be discolored are the bricks next to blank spaces (which could potentially be a different palette). Is this thinking totally off the rails? Am I understanding attribute bytes incorrectly?
My attribute byte fetching is done via:
Code:
// Now get attribute byte
//address = baseAddress + 0x3c0;
let address = 0x23c0 | (v & 0x0c00) | ((v >> 4) & 0x38) | ((v >> 2) & 0x07);
// Shift top 8 bits to the right
this.attributeTableByte = (this.attributeTableByte >>> 8) | (this.vram.get(address) << 8);
And the determination of color is:
Code:
// Note: x is the cycle on the scanline (x coordinate of screen
// this.x is fine X position
if (((x % 32) + this.x) < 16) {
if (y % 32 < 16) {
// top left
palette = this.attributeTableByte & 0b00000011;
} else {
// bottom left
palette = (this.attributeTableByte & 0b00110000) >>> 4;
}
} else {
if (y % 32 < 16) {
// top right
palette = (this.attributeTableByte & 0b00001100) >>> 2;
} else {
// bottom right
palette = (this.attributeTableByte & 0b11000000) >>> 6;
}
}
TD