Expose current background framebuffer data from Console.
Lesson 283 of 356 · tests/chapter_05_rendering_pipeline/test_283_console_background_framebuffer.py
File to update
emulator/console.py
Why this step exists
The renderer can now extract a background framebuffer from the current PPU memory:
ppu_background_to_framebuffer(ppu)
Console is the top-level machine coordinator that owns the CPU/PPU relationship. Frontend code should eventually be able to ask Console for the current background framebuffer without knowing the details of PPU memory extraction.
Console.step()
advances emulation time
Console.render_background_framebuffer()
observes current PPU memory and returns pure framebuffer data
Do not render inside Console.step(). A real frame contains many CPU instructions; rendering after every CPU instruction would be wasteful and would mix timing with observation.
Suggested implementation example
from emulator.rendering.framebuffer import Framebuffer
from emulator.rendering.ppu_background_renderer import ppu_background_to_framebuffer
classConsole:
...
defrender_background_framebuffer(self) -> Framebuffer:
return ppu_background_to_framebuffer(self.ppu)
Architecture rule
This still returns pure framebuffer data. Do not import pygame here.
Out of scope
pygame display
step_until_frame/run_frame
sprites
OAMDMA
controller input
Run this lesson
uv run pytest tests/chapter_05_rendering_pipeline/test_283_console_background_framebuffer.py -v