251. Cpu bus connects mapper to ppu bus
Connect the cartridge mapper to PpuBus.
Lesson 251 of 356 · tests/chapter_03_ppu_memory_and_graphics_data/test_251_cpu_bus_connects_mapper_to_ppu_bus.py
File to update
emulator/bus/cpu_bus.pyWhy this step exists
The CPU uses the mapper for PRG ROM reads. The PPU also needs the same mapper for CHR ROM reads in $0000-$1FFF.
Expected wiring
if cartridge is not None:
self.mapper = create_mapper(cartridge)
self.ppu.ppu_bus.mapper = self.mapperImportant
Use the same mapper object for CpuBus and PpuBus. Later mappers may have internal bank-switching state, so CPU and PPU must see the same mapper state.
Run this lesson
uv run pytest tests/chapter_03_ppu_memory_and_graphics_data/test_251_cpu_bus_connects_mapper_to_ppu_bus.py -v