yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::emu::Emulator Class Reference

A class for emulating and debugging SNES games. More...

#include <emulator.h>

Classes

struct  Bookmark
 
struct  EmulatorMetrics
 

Public Member Functions

 Emulator ()=default
 
 ~Emulator ()
 
void Initialize (gfx::IRenderer *renderer, const std::vector< uint8_t > &rom_data)
 
void Run (Rom *rom)
 
void Cleanup ()
 
void set_card_registry (editor::EditorCardRegistry *registry)
 
auto snes () -> Snes &
 
auto running () const -> bool
 
void set_running (bool running)
 
audio::IAudioBackendaudio_backend ()
 
void set_audio_buffer (int16_t *audio_buffer)
 
auto set_audio_device_id (SDL_AudioDeviceID audio_device)
 
void set_use_sdl_audio_stream (bool enabled)
 
bool use_sdl_audio_stream () const
 
auto wanted_samples () const -> int
 
void set_renderer (gfx::IRenderer *renderer)
 
gfx::IRendererrenderer ()
 
void * ppu_texture ()
 
bool is_turbo_mode () const
 
void set_turbo_mode (bool turbo)
 
BreakpointManagerbreakpoint_manager ()
 
debug::DisassemblyViewerdisassembly_viewer ()
 
input::InputManagerinput_manager ()
 
bool is_debugging () const
 
void set_debugging (bool debugging)
 
bool is_initialized () const
 
bool is_snes_initialized () const
 
bool IsEmulatorReady () const
 
double GetCurrentFPS () const
 
uint64_t GetCurrentCycle ()
 
uint16_t GetCPUPC ()
 
uint8_t GetCPUB ()
 
void StepSingleInstruction ()
 
void SetBreakpoint (uint32_t address)
 
void ClearAllBreakpoints ()
 
std::vector< uint32_t > GetBreakpoints ()
 
EmulatorMetrics GetMetrics ()
 

Private Member Functions

void RenderNavBar ()
 
void RenderEmulatorInterface ()
 
void RenderSnesPpu ()
 
void RenderBreakpointList ()
 
void RenderMemoryViewer ()
 
void RenderModernCpuDebugger ()
 
void RenderPerformanceMonitor ()
 
void RenderAIAgentPanel ()
 
void RenderSaveStates ()
 
void RenderKeyboardConfig ()
 
void RenderApuDebugger ()
 
void RenderCpuInstructionLog (const std::vector< InstructionEntry > &instructionLog)
 

Private Attributes

std::vector< Bookmarkbookmarks
 
bool step_ = true
 
bool power_ = false
 
bool loading_ = false
 
bool running_ = false
 
bool turbo_mode_ = false
 
float wanted_frames_
 
int wanted_samples_
 
uint8_t manual_pb_ = 0
 
uint16_t manual_pc_ = 0
 
uint64_t count_frequency
 
uint64_t last_count
 
double time_adder = 0.0
 
int frame_count_ = 0
 
double fps_timer_ = 0.0
 
double current_fps_ = 0.0
 
int16_t * audio_buffer_
 
SDL_AudioDeviceID audio_device_
 
std::unique_ptr< audio::IAudioBackendaudio_backend_
 
Snes snes_
 
bool initialized_ = false
 
bool snes_initialized_ = false
 
bool debugging_ = false
 
gfx::IRendererrenderer_ = nullptr
 
void * ppu_texture_ = nullptr
 
bool use_sdl_audio_stream_ = false
 
bool audio_stream_config_dirty_ = false
 
bool audio_stream_active_ = false
 
bool audio_stream_env_checked_ = false
 
BreakpointManager breakpoint_manager_
 
debug::DisassemblyViewer disassembly_viewer_
 
std::vector< uint8_t > rom_data_
 
input::InputManager input_manager_
 
editor::EditorCardRegistrycard_registry_ = nullptr
 

Detailed Description

A class for emulating and debugging SNES games.

Definition at line 36 of file emulator.h.

Constructor & Destructor Documentation

◆ Emulator()

yaze::emu::Emulator::Emulator ( )
default

◆ ~Emulator()

yaze::emu::Emulator::~Emulator ( )

Definition at line 33 of file emulator.cc.

References running_.

Member Function Documentation

◆ Initialize()

◆ Run()

void yaze::emu::Emulator::Run ( Rom rom)

◆ Cleanup()

void yaze::emu::Emulator::Cleanup ( )

Definition at line 39 of file emulator.cc.

References audio_stream_active_, ppu_texture_, running_, and snes_initialized_.

◆ set_card_registry()

void yaze::emu::Emulator::set_card_registry ( editor::EditorCardRegistry registry)
inline

Definition at line 45 of file emulator.h.

References card_registry_.

Referenced by yaze::editor::EditorManager::Initialize().

◆ snes()

◆ running()

auto yaze::emu::Emulator::running ( ) const -> bool
inline

◆ set_running()

void yaze::emu::Emulator::set_running ( bool  running)
inline

◆ audio_backend()

◆ set_audio_buffer()

void yaze::emu::Emulator::set_audio_buffer ( int16_t *  audio_buffer)
inline

Definition at line 53 of file emulator.h.

References audio_buffer_.

◆ set_audio_device_id()

auto yaze::emu::Emulator::set_audio_device_id ( SDL_AudioDeviceID  audio_device)
inline

Definition at line 54 of file emulator.h.

References audio_device_.

◆ set_use_sdl_audio_stream()

void yaze::emu::Emulator::set_use_sdl_audio_stream ( bool  enabled)

Definition at line 54 of file emulator.cc.

References audio_stream_config_dirty_, and use_sdl_audio_stream_.

Referenced by Initialize(), yaze::emu::ui::RenderNavBar(), and Run().

◆ use_sdl_audio_stream()

bool yaze::emu::Emulator::use_sdl_audio_stream ( ) const
inline

Definition at line 58 of file emulator.h.

References use_sdl_audio_stream_.

Referenced by yaze::emu::ui::RenderNavBar().

◆ wanted_samples()

auto yaze::emu::Emulator::wanted_samples ( ) const -> int
inline

Definition at line 59 of file emulator.h.

References wanted_samples_.

◆ set_renderer()

void yaze::emu::Emulator::set_renderer ( gfx::IRenderer renderer)
inline

Definition at line 60 of file emulator.h.

References renderer(), and renderer_.

Referenced by yaze::editor::EditorManager::LoadAssets().

Here is the call graph for this function:

◆ renderer()

gfx::IRenderer * yaze::emu::Emulator::renderer ( )
inline

Definition at line 63 of file emulator.h.

References renderer_.

Referenced by Initialize(), yaze::emu::ui::RenderNavBar(), and set_renderer().

◆ ppu_texture()

void * yaze::emu::Emulator::ppu_texture ( )
inline

Definition at line 64 of file emulator.h.

References ppu_texture_.

Referenced by yaze::emu::ui::RenderSnesPpu().

◆ is_turbo_mode()

bool yaze::emu::Emulator::is_turbo_mode ( ) const
inline

Definition at line 67 of file emulator.h.

References turbo_mode_.

Referenced by yaze::emu::ui::RenderNavBar().

◆ set_turbo_mode()

void yaze::emu::Emulator::set_turbo_mode ( bool  turbo)
inline

Definition at line 68 of file emulator.h.

References turbo_mode_.

Referenced by yaze::emu::ui::RenderNavBar().

◆ breakpoint_manager()

◆ disassembly_viewer()

debug::DisassemblyViewer & yaze::emu::Emulator::disassembly_viewer ( )
inline

Definition at line 72 of file emulator.h.

References disassembly_viewer_.

Referenced by yaze::emu::ui::RenderCpuInstructionLog().

◆ input_manager()

◆ is_debugging()

bool yaze::emu::Emulator::is_debugging ( ) const
inline

Definition at line 74 of file emulator.h.

References debugging_.

Referenced by yaze::emu::ui::RenderNavBar().

◆ set_debugging()

void yaze::emu::Emulator::set_debugging ( bool  debugging)
inline

◆ is_initialized()

bool yaze::emu::Emulator::is_initialized ( ) const
inline

Definition at line 76 of file emulator.h.

References initialized_.

◆ is_snes_initialized()

◆ IsEmulatorReady()

bool yaze::emu::Emulator::IsEmulatorReady ( ) const
inline

Definition at line 80 of file emulator.h.

References rom_data_, yaze::emu::Snes::running(), and snes_.

Referenced by yaze::emu::ui::RenderAIAgentPanel().

Here is the call graph for this function:

◆ GetCurrentFPS()

double yaze::emu::Emulator::GetCurrentFPS ( ) const
inline

◆ GetCurrentCycle()

uint64_t yaze::emu::Emulator::GetCurrentCycle ( )
inline

Definition at line 82 of file emulator.h.

References yaze::emu::Snes::mutable_cycles(), and snes_.

Referenced by yaze::agent::EmulatorServiceImpl::GetDebugStatus(), and yaze::agent::EmulatorServiceImpl::StepInstruction().

Here is the call graph for this function:

◆ GetCPUPC()

uint16_t yaze::emu::Emulator::GetCPUPC ( )
inline

Definition at line 83 of file emulator.h.

References yaze::emu::Snes::cpu(), and snes_.

Here is the call graph for this function:

◆ GetCPUB()

uint8_t yaze::emu::Emulator::GetCPUB ( )
inline

Definition at line 84 of file emulator.h.

References yaze::emu::Snes::cpu(), and snes_.

Here is the call graph for this function:

◆ StepSingleInstruction()

void yaze::emu::Emulator::StepSingleInstruction ( )
inline

Definition at line 85 of file emulator.h.

References yaze::emu::Snes::cpu(), and snes_.

Referenced by yaze::agent::EmulatorServiceImpl::RunToBreakpoint(), and yaze::agent::EmulatorServiceImpl::StepInstruction().

Here is the call graph for this function:

◆ SetBreakpoint()

void yaze::emu::Emulator::SetBreakpoint ( uint32_t  address)
inline

Definition at line 86 of file emulator.h.

References yaze::emu::Snes::cpu(), and snes_.

Referenced by yaze::emu::ui::RenderModernCpuDebugger().

Here is the call graph for this function:

◆ ClearAllBreakpoints()

void yaze::emu::Emulator::ClearAllBreakpoints ( )
inline

Definition at line 87 of file emulator.h.

References yaze::emu::Snes::cpu(), and snes_.

Referenced by yaze::emu::ui::RenderModernCpuDebugger().

Here is the call graph for this function:

◆ GetBreakpoints()

std::vector< uint32_t > yaze::emu::Emulator::GetBreakpoints ( )
inline

Definition at line 88 of file emulator.h.

References yaze::emu::Snes::cpu(), and snes_.

Referenced by yaze::emu::ui::RenderBreakpointList(), and yaze::emu::ui::RenderModernCpuDebugger().

Here is the call graph for this function:

◆ GetMetrics()

EmulatorMetrics yaze::emu::Emulator::GetMetrics ( )
inline

◆ RenderNavBar()

void yaze::emu::Emulator::RenderNavBar ( )
private

Definition at line 483 of file emulator.cc.

References yaze::emu::ui::RenderNavBar().

Referenced by RenderEmulatorInterface().

Here is the call graph for this function:

◆ RenderEmulatorInterface()

◆ RenderSnesPpu()

void yaze::emu::Emulator::RenderSnesPpu ( )
private

Definition at line 478 of file emulator.cc.

References yaze::emu::ui::RenderSnesPpu().

Referenced by RenderEmulatorInterface().

Here is the call graph for this function:

◆ RenderBreakpointList()

void yaze::emu::Emulator::RenderBreakpointList ( )
private

Definition at line 492 of file emulator.cc.

References yaze::emu::ui::RenderBreakpointList().

Referenced by RenderEmulatorInterface().

Here is the call graph for this function:

◆ RenderMemoryViewer()

void yaze::emu::Emulator::RenderMemoryViewer ( )
private

Definition at line 497 of file emulator.cc.

References yaze::emu::ui::RenderMemoryViewer().

Referenced by RenderEmulatorInterface().

Here is the call graph for this function:

◆ RenderModernCpuDebugger()

◆ RenderPerformanceMonitor()

void yaze::emu::Emulator::RenderPerformanceMonitor ( )
private

Definition at line 718 of file emulator.cc.

References yaze::emu::ui::RenderPerformanceMonitor().

Referenced by RenderEmulatorInterface().

Here is the call graph for this function:

◆ RenderAIAgentPanel()

void yaze::emu::Emulator::RenderAIAgentPanel ( )
private

Definition at line 723 of file emulator.cc.

References yaze::emu::ui::RenderAIAgentPanel().

Referenced by RenderEmulatorInterface().

Here is the call graph for this function:

◆ RenderSaveStates()

void yaze::emu::Emulator::RenderSaveStates ( )
private
Todo:
Create ui::RenderSaveStates() when save state system is implemented

Definition at line 734 of file emulator.cc.

References yaze::gui::ThemeManager::Get(), and ICON_MD_SAVE.

Referenced by RenderEmulatorInterface().

Here is the call graph for this function:

◆ RenderKeyboardConfig()

void yaze::emu::Emulator::RenderKeyboardConfig ( )
private

Definition at line 744 of file emulator.cc.

References input_manager_, and yaze::emu::ui::RenderKeyboardConfig().

Referenced by RenderEmulatorInterface().

Here is the call graph for this function:

◆ RenderApuDebugger()

void yaze::emu::Emulator::RenderApuDebugger ( )
private

Definition at line 749 of file emulator.cc.

References yaze::emu::ui::RenderApuDebugger().

Referenced by RenderEmulatorInterface().

Here is the call graph for this function:

◆ RenderCpuInstructionLog()

void yaze::emu::Emulator::RenderCpuInstructionLog ( const std::vector< InstructionEntry > &  instructionLog)
private

Definition at line 728 of file emulator.cc.

References yaze::emu::ui::RenderCpuInstructionLog().

Here is the call graph for this function:

Member Data Documentation

◆ bookmarks

std::vector<Bookmark> yaze::emu::Emulator::bookmarks
private

Definition at line 128 of file emulator.h.

◆ step_

bool yaze::emu::Emulator::step_ = true
private

Definition at line 133 of file emulator.h.

◆ power_

bool yaze::emu::Emulator::power_ = false
private

Definition at line 134 of file emulator.h.

◆ loading_

bool yaze::emu::Emulator::loading_ = false
private

Definition at line 135 of file emulator.h.

◆ running_

bool yaze::emu::Emulator::running_ = false
private

◆ turbo_mode_

bool yaze::emu::Emulator::turbo_mode_ = false
private

Definition at line 137 of file emulator.h.

Referenced by is_turbo_mode(), Run(), and set_turbo_mode().

◆ wanted_frames_

float yaze::emu::Emulator::wanted_frames_
private

Definition at line 139 of file emulator.h.

Referenced by Run().

◆ wanted_samples_

int yaze::emu::Emulator::wanted_samples_
private

Definition at line 140 of file emulator.h.

Referenced by GetMetrics(), Run(), and wanted_samples().

◆ manual_pb_

uint8_t yaze::emu::Emulator::manual_pb_ = 0
private

Definition at line 142 of file emulator.h.

◆ manual_pc_

uint16_t yaze::emu::Emulator::manual_pc_ = 0
private

Definition at line 143 of file emulator.h.

◆ count_frequency

uint64_t yaze::emu::Emulator::count_frequency
private

Definition at line 146 of file emulator.h.

Referenced by Run().

◆ last_count

uint64_t yaze::emu::Emulator::last_count
private

Definition at line 147 of file emulator.h.

Referenced by Run().

◆ time_adder

double yaze::emu::Emulator::time_adder = 0.0
private

Definition at line 148 of file emulator.h.

Referenced by Run().

◆ frame_count_

int yaze::emu::Emulator::frame_count_ = 0
private

Definition at line 151 of file emulator.h.

Referenced by Run().

◆ fps_timer_

double yaze::emu::Emulator::fps_timer_ = 0.0
private

Definition at line 152 of file emulator.h.

Referenced by Run().

◆ current_fps_

double yaze::emu::Emulator::current_fps_ = 0.0
private

Definition at line 153 of file emulator.h.

Referenced by GetCurrentFPS(), GetMetrics(), and Run().

◆ audio_buffer_

int16_t* yaze::emu::Emulator::audio_buffer_
private

Definition at line 155 of file emulator.h.

Referenced by Run(), and set_audio_buffer().

◆ audio_device_

SDL_AudioDeviceID yaze::emu::Emulator::audio_device_
private

Definition at line 156 of file emulator.h.

Referenced by GetMetrics(), and set_audio_device_id().

◆ audio_backend_

std::unique_ptr<audio::IAudioBackend> yaze::emu::Emulator::audio_backend_
private

Definition at line 159 of file emulator.h.

Referenced by audio_backend(), Initialize(), and Run().

◆ snes_

◆ initialized_

bool yaze::emu::Emulator::initialized_ = false
private

Definition at line 162 of file emulator.h.

Referenced by Initialize(), and is_initialized().

◆ snes_initialized_

bool yaze::emu::Emulator::snes_initialized_ = false
private

Definition at line 163 of file emulator.h.

Referenced by Cleanup(), Initialize(), is_snes_initialized(), and Run().

◆ debugging_

bool yaze::emu::Emulator::debugging_ = false
private

Definition at line 164 of file emulator.h.

Referenced by is_debugging(), and set_debugging().

◆ renderer_

gfx::IRenderer* yaze::emu::Emulator::renderer_ = nullptr
private

Definition at line 165 of file emulator.h.

Referenced by Initialize(), renderer(), Run(), and set_renderer().

◆ ppu_texture_

void* yaze::emu::Emulator::ppu_texture_ = nullptr
private

Definition at line 166 of file emulator.h.

Referenced by Cleanup(), ppu_texture(), and Run().

◆ use_sdl_audio_stream_

bool yaze::emu::Emulator::use_sdl_audio_stream_ = false
private

Definition at line 167 of file emulator.h.

Referenced by Run(), set_use_sdl_audio_stream(), and use_sdl_audio_stream().

◆ audio_stream_config_dirty_

bool yaze::emu::Emulator::audio_stream_config_dirty_ = false
private

Definition at line 168 of file emulator.h.

Referenced by Initialize(), Run(), and set_use_sdl_audio_stream().

◆ audio_stream_active_

bool yaze::emu::Emulator::audio_stream_active_ = false
private

Definition at line 169 of file emulator.h.

Referenced by Cleanup(), and Run().

◆ audio_stream_env_checked_

bool yaze::emu::Emulator::audio_stream_env_checked_ = false
private

Definition at line 170 of file emulator.h.

Referenced by Initialize(), and Run().

◆ breakpoint_manager_

BreakpointManager yaze::emu::Emulator::breakpoint_manager_
private

Definition at line 175 of file emulator.h.

Referenced by breakpoint_manager(), Initialize(), and RenderModernCpuDebugger().

◆ disassembly_viewer_

debug::DisassemblyViewer yaze::emu::Emulator::disassembly_viewer_
private

Definition at line 176 of file emulator.h.

Referenced by disassembly_viewer(), and Initialize().

◆ rom_data_

std::vector<uint8_t> yaze::emu::Emulator::rom_data_
private

Definition at line 178 of file emulator.h.

Referenced by Initialize(), IsEmulatorReady(), and Run().

◆ input_manager_

input::InputManager yaze::emu::Emulator::input_manager_
private

Definition at line 181 of file emulator.h.

Referenced by input_manager(), RenderKeyboardConfig(), and Run().

◆ card_registry_

editor::EditorCardRegistry* yaze::emu::Emulator::card_registry_ = nullptr
private

Definition at line 184 of file emulator.h.

Referenced by RenderEmulatorInterface(), and set_card_registry().


The documentation for this class was generated from the following files: