bugzmanov / nes_ebook

A mini book on writing NES emulator using rust lang

Home Page:https://bugzmanov.github.io/nes_ebook/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ppu address mirroring before accessing nametables

Saf1u opened this issue · comments

commented

Hello, your tutorial is amazing first of all. I was just wondering why we still mirror before accessing nametables as in here:
pub fn mirror_vram_addr(&self, addr: u16) -> u16 { let mirrored_vram = addr & 0b10111111111111; // mirror down 0x3000-0x3eff to 0x2000 - 0x2eff

when we never reach that range as in:

0x2000..=0x2fff => { let result = self.internal_data_buf; self.internal_data_buf = self.vram[self.mirror_vram_addr(addr) as usize]; result } 0x3000..=0x3eff => unimplemented!("addr {} shouldn't be used in reallity", addr),

or is this an error where we need to change the range from 0x2fff to 0x3eff and get rid of the second match
? Thank you