277. Nametable with nes palette
Render a nametable framebuffer using the default NES RGB palette.
Lesson 277 of 356 · tests/chapter_05_rendering_pipeline/test_277_nametable_with_nes_palette.py
File to update
emulator/rendering/nametable_renderer.pyWhy this step exists
The generic nametable renderer supports custom palettes
nametable_to_framebuffer(nametable_bytes, pattern_table_bytes, palette)That is useful for tests and debug palettes. Now that we have NES_PALETTE_RGB, we add a default-palette helper:
nametable_to_nes_framebuffer(nametable_bytes, pattern_table_bytes)This mirrors the pattern-table helper from the previous rendering step.
What it should do
nametable_to_nes_framebuffer(nametable_bytes, pattern_table_bytes)
-> nametable_to_framebuffer(
nametable_bytes,
pattern_table_bytes,
NES_PALETTE_RGB,
)Suggested implementation example
from emulator.rendering.nes_palette import NES_PALETTE_RGB
def nametable_to_nes_framebuffer(
nametable_bytes: bytes,
pattern_table_bytes: bytes,
) -> Framebuffer:
return nametable_to_framebuffer(
nametable_bytes,
pattern_table_bytes,
NES_PALETTE_RGB,
)Important simplification
This still uses one shared palette for every tile. It does not decode the 64-byte attribute table yet, and it does not read PPU palette RAM at $3F00-$3F1F yet. This is useful as a debug/simple renderer. A later renderer will use the attribute table to choose between different background palettes.
Important fixture rule
Use synthetic nametable/CHR bytes only. Do not use commercial ROM data in this test.
Out of scope
- attribute table palette selection
- PPU palette RAM lookup
- scrolling
- sprites
- OAMDMA
- pygame display
Run this lesson
uv run pytest tests/chapter_05_rendering_pipeline/test_277_nametable_with_nes_palette.py -v