Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Frontend/Wasm/WasmFramebuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
6 changes: 6 additions & 0 deletions src/Ppu/ArrayFramebuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
8 changes: 8 additions & 0 deletions src/Ppu/FramebufferInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions src/Ppu/Ppu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Expand Down