gb::GPU class

Handle LCD state, compute scanlines and send to an external renderer.

Contents

Public types

using Ptr = std::unique_ptr<GPU>
Smart pointer type.
using Scanline = std::array<Pixel, 160>
Array on Pixel objects representing a single scan line produced by the GPU.
using RenderScanlineCallback = std::function<void(const Scanline&, int linenum)>
using VBlankCallback = std::function<void()>

Public functions

void update(uint8_t cycles, bool ime)
void setRenderCallback(RenderScanlineCallback callback)
void setVBlankCallback(VBlankCallback callback)
void setPaletteColor(uint8_t r, uint8_t g, uint8_t b, int idx)
auto getBackgroundTileMap() -> std::vector<uint8_t>
auto getSpriteCache() const -> std::array<Sprite, 40>
auto getBackgroundHash() -> std::size_t

Typedef documentation

using gb::GPU::RenderScanlineCallback = std::function<void(const Scanline&, int linenum)>

Callback function called by the GPU when it has produced a new scan line Provides the Scanline and the line number

using gb::GPU::VBlankCallback = std::function<void()>

Callback function call by the GPU when VBlank is reached

Function documentation

void gb::GPU::update(uint8_t cycles, bool ime)

Update the GPU with elasped cycles. Used by the CPU

void gb::GPU::setRenderCallback(RenderScanlineCallback callback)

Set the host system callback

void gb::GPU::setVBlankCallback(VBlankCallback callback)

Set the host system vblank callback

void gb::GPU::setPaletteColor(uint8_t r, uint8_t g, uint8_t b, int idx)

Set Default Palette Color

std::vector<uint8_t> gb::GPU::getBackgroundTileMap()

Returns Background tilemap data

std::array<Sprite, 40> gb::GPU::getSpriteCache() const

Returns currently cached tile data

std::size_t gb::GPU::getBackgroundHash()

Returns Hashed background map