234. Ppu bus basic shape
Create the basic PpuBus shape.
Lesson 234 of 356 · tests/chapter_03_ppu_memory_and_graphics_data/test_234_ppu_bus_basic_shape.py
Files to create/update
emulator/bus/ppu_bus.pyClass to implement
PpuBusWhy this step exists
The NES has two different address spaces
CPU address space: $0000-$FFFF
routed by CpuBus
PPU address space: $0000-$3FFF
routed by PpuBusThe PPU should not write directly to raw VRAM forever. It should talk to a stable
PPU-address-space boundary
PPU -> PpuBus -> VRAM / mapper CHR / palette RAM laterThis allows PPUDATA behavior to stay stable while PpuBus internals become more accurate over time.
Important constant
PPU_ADDRESS_MASK = 0x3FFFWhy
PPU addresses are 14-bit. Masking with 0x3FFF folds any address into the PPU addressable range $0000-$3FFF.
Initial storage
For now, PpuBus owns a big VRAM backing store. This is a temporary simplification that lets us build PPUADDR/PPUDATA before full nametable/palette accuracy.
Suggested implementation pseudocode
from dataclasses import dataclass, field
from typing import Optional
from emulator.memory.vram import VRAM
from emulator.cartridge.mapper_interface import MapperInterface
PPU_ADDRESS_MASK = 0x3FFF
@dataclass
class PpuBus:
vram: VRAM = field(default_factory=VRAM)
mapper: Optional[MapperInterface] = NoneRun this lesson
uv run pytest tests/chapter_03_ppu_memory_and_graphics_data/test_234_ppu_bus_basic_shape.py -v