Skip to content

GB_set_vblank_callback

Lior Halphon edited this page Nov 30, 2024 · 3 revisions

Definition

typedef enum {
    GB_VBLANK_TYPE_NORMAL_FRAME,
    GB_VBLANK_TYPE_LCD_OFF,
    GB_VBLANK_TYPE_ARTIFICIAL,
    GB_VBLANK_TYPE_REPEAT,
} GB_vblank_type_t;
typedef void (*GB_vblank_callback_t)(GB_gameboy_t *gb, GB_vblank_type_t type);

void GB_set_vblank_callback(GB_gameboy_t *gb, GB_vblank_callback_t callback);

In display.h

Description

Sets a callback that will be called when the emulator instance finishes rendering a frame into the set pixel buffer, usually when the LCD controller enters the VBlank stage. The callback will be called even if rendering is disabled. The type argument for the callback specifies the kind of VBlank event being reported:

  • GB_VBLANK_TYPE_NORMAL_FRAME: A normal frame has finished rendering, and the pixel buffer will contain the new frame's data.
  • GB_VBLANK_TYPE_LCD_OFF: The LCD has been off for a period of time long enough that requires presenting it to the user, and the pixel buffer will contain a solid color.
  • GB_VBLANK_TYPE_ARTIFICIAL: The LCD is turned on, but the ROM is preventing the PPU (Pixel Processing Unit) from rendering a complete frame. The pixel buffer will contain a partially rendered frame that may be presented to the user.
  • GB_VBLANK_TYPE_REPEAT: The PPU has finished rendering a frame, but the LCD on a real Game Boy hardware would not display it. The pixel buffer will contain the new frame's data, but an accurate frontend should repeat the previous frame instead of displaying it.

Thread Safety

If callback is not NULL, GB_set_vblank_callback is thread-safe and can be called from any thread and context. Otherwise, it must not be called if the instance is being run in another thread, but may be called from the current one (via a callback).

See Also

Clone this wiki locally