Isn't upper and lower flipped in the render function?
pub fn render(ppu: &NesPPU, frame: &mut Frame) {
let bank = ppu.ctrl.bknd_pattern_addr();
for i in 0..0x03c0 { // just for now, lets use the first nametable
let tile = ppu.vram[i] as u16;
let tile_x = i % 32;
let tile_y = i / 32;
let tile = &ppu.chr_rom[(bank + tile * 16) as usize..=(bank + tile * 16 + 15) as usize];
for y in 0..=7 {
let mut upper = tile[y]; //<--- Shouldn't this be lower?
let mut lower = tile[y + 8]; //<--- Shouldn't this be upper?
I did the same in my emulator, and had wrong colors because bits from upper and lower end up in the wrong positions.
Isn't upper and lower flipped in the render function?
I did the same in my emulator, and had wrong colors because bits from upper and lower end up in the wrong positions.