diff --git a/src/Frontend/Wasm/WasmFramebuffer.php b/src/Frontend/Wasm/WasmFramebuffer.php index 8905518..2ae98f8 100644 --- a/src/Frontend/Wasm/WasmFramebuffer.php +++ b/src/Frontend/Wasm/WasmFramebuffer.php @@ -125,4 +125,15 @@ public function getHeight(): int { return self::HEIGHT; } + + /** + * Present the framebuffer. + * + * For WASM, this is a no-op since JavaScript explicitly polls + * for pixel data via getPixelsRGBA() in the render loop. + */ + public function present(): void + { + // No-op for WASM - JavaScript polls for pixel data + } } diff --git a/src/Ppu/ArrayFramebuffer.php b/src/Ppu/ArrayFramebuffer.php index d39965c..0c347b2 100644 --- a/src/Ppu/ArrayFramebuffer.php +++ b/src/Ppu/ArrayFramebuffer.php @@ -43,4 +43,10 @@ public function clear(): void $this->buffer[$y] = array_fill(0, self::WIDTH, $white); } } + + public function present(): void + { + // No-op for array framebuffer (used for testing) + // Actual rendering implementations (CLI, WASM) should override this + } } diff --git a/src/Ppu/FramebufferInterface.php b/src/Ppu/FramebufferInterface.php index a5168a6..d734826 100644 --- a/src/Ppu/FramebufferInterface.php +++ b/src/Ppu/FramebufferInterface.php @@ -34,4 +34,12 @@ public function getFramebuffer(): array; * Clear the framebuffer (typically to white). */ public function clear(): void; + + /** + * Present the framebuffer (display/render the current frame). + * + * Called by the PPU at the end of each frame to signal that + * the frame is complete and ready to be displayed. + */ + public function present(): void; } diff --git a/src/Ppu/Ppu.php b/src/Ppu/Ppu.php index afb1ad8..f3e9d90 100644 --- a/src/Ppu/Ppu.php +++ b/src/Ppu/Ppu.php @@ -191,6 +191,9 @@ private function stepVBlank(): void $this->ly = 0; $this->updateLycCoincidence(); $this->setMode(PpuMode::OamSearch); + + // Frame complete - present the framebuffer + $this->framebuffer->present(); } } }