I am having this weird "corruption" in Super Mario (see below). Entire game plays out fine tho (sprites collisions and what not). Also worth mentioning games like Donkey Kong, Pacman, Balloon Fight and Bomberman play out fine.
https://imgur.com/GabbMk6
Did some debugging, here is what I found:
- these random visuals appear in spaces where it should be background color (e.g. the sky); I noticed the pixel is 0 there but the color fetched is the green color, from $3F01 in this case; I read from
Code: Select all
0x3F00 + ((palette as u16) << 2) + pixel as u16
Code: Select all
let (bg_pixel, bg_palette) = if self.mask.render_background {
let bit_offset = 0x8000 >> self.fine_x;
let pixel_lo = ((self.bg_shifter_pattern_lo & bit_offset) != 0) as u8;
let pixel_hi = ((self.bg_shifter_pattern_hi & bit_offset) != 0) as u8;
let palette_lo = ((self.bg_shifter_attrib_lo & bit_offset) != 0) as u8;
let palette_hi = ((self.bg_shifter_attrib_hi & bit_offset) != 0) as u8;
((pixel_hi << 1) | pixel_lo, (palette_hi << 1) | palette_lo)
} else {
(0x00, 0x00)
};