gb::CPU class

Emulates Gameboy CPU instructions.

Contents

Public types

struct Status
CPU state.
enum Flags { Z = 1 << 7, N = 1 << 6, H = 1 << 5, C = 1 << 4 }
Flags set by the most recent instruction.
using Ptr = std::unique_ptr<CPU>
Smart pointer type.

Public functions

void step()
void reset()
auto isHalted() const -> bool noexcept
void setDebugMode(bool debug_mode) noexcept
void setInstructionCallback(std::function<void(const Instruction&, const uint16_t addr)>) noexcept
auto serialize() const -> std::array<uint8_t, 12> noexcept
void deserialize(const std::array<uint8_t, 12>& data) noexcept
auto getStatus() const -> Status

Function documentation

void gb::CPU::step()

Run one CPU fetch, decode, execute cycle

void gb::CPU::reset()

Reset the CPU state

bool gb::CPU::isHalted() const noexcept

Returns true if the CPU is halted

void gb::CPU::setDebugMode(bool debug_mode) noexcept

Set CPU debug mode

void gb::CPU::setInstructionCallback(std::function<void(const Instruction&, const uint16_t addr)>) noexcept

Set a callback for every CPU instruction.

std::array<uint8_t, 12> gb::CPU::serialize() const noexcept

Serialize the CPU state

void gb::CPU::deserialize(const std::array<uint8_t, 12>& data) noexcept

Deserialize the CPU state

Status gb::CPU::getStatus() const

Get the current status of the CPU