yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::app::emu::SNES Class Reference

#include <snes.h>

Collaboration diagram for yaze::app::emu::SNES:

Public Member Functions

 SNES ()=default
 
 ~SNES ()=default
 
void Init (std::vector< uint8_t > &rom_data)
 
void Reset (bool hard=false)
 
void RunFrame ()
 
void CatchUpApu ()
 
void HandleInput ()
 
void RunCycle ()
 
void RunCycles (int cycles)
 
void SyncCycles (bool start, int sync_cycles)
 
uint8_t ReadBBus (uint8_t adr)
 
uint8_t ReadReg (uint16_t adr)
 
uint8_t Rread (uint32_t adr)
 
uint8_t Read (uint32_t adr)
 
void WriteBBus (uint8_t adr, uint8_t val)
 
void WriteReg (uint16_t adr, uint8_t val)
 
void Write (uint32_t adr, uint8_t val)
 
int GetAccessTime (uint32_t adr)
 
uint8_t CpuRead (uint32_t adr)
 
void CpuWrite (uint32_t adr, uint8_t val)
 
void CpuIdle (bool waiting)
 
void SetSamples (int16_t *sample_data, int wanted_samples)
 
void SetPixels (uint8_t *pixel_data)
 
void SetButtonState (int player, int button, bool pressed)
 
bool running () const
 
auto cpu () -> Cpu &
 
auto ppu () -> video::Ppu &
 
auto apu () -> audio::Apu &
 
auto Memory () -> memory::MemoryImpl &
 
auto get_ram () -> uint8_t *
 
auto mutable_cycles () -> uint64_t &
 
void InitAccessTime (bool recalc)
 

Public Attributes

std::vector< uint8_t > access_time
 

Private Attributes

ClockImpl clock_
 
memory::MemoryImpl memory_
 
memory::CpuCallbacks cpu_callbacks_
 
Cpu cpu_ {memory_, clock_, cpu_callbacks_}
 
video::Ppu ppu_ {memory_, clock_}
 
audio::Apu apu_ {memory_}
 
std::vector< uint8_t > rom_data
 
bool running_ = false
 
uint8_t ram [0x20000]
 
uint32_t ram_adr_
 
uint32_t frames_ = 0
 
uint64_t cycles_ = 0
 
uint64_t sync_cycle_ = 0
 
double apu_catchup_cycles_
 
uint32_t next_horiz_event
 
bool h_irq_enabled_ = false
 
bool v_irq_enabled_ = false
 
bool nmi_enabled_ = false
 
uint16_t h_timer_ = 0
 
uint16_t v_timer_ = 0
 
bool in_nmi_ = false
 
bool irq_condition_ = false
 
bool in_irq_ = false
 
bool in_vblank_
 
uint8_t multiply_a_
 
uint16_t multiply_result_
 
uint16_t divide_a_
 
uint16_t divide_result_
 
Input input1
 
Input input2
 
uint16_t port_auto_read_ [4]
 
bool auto_joy_read_ = false
 
uint16_t auto_joy_timer_ = 0
 
bool ppu_latch_
 
bool fast_mem_ = false
 

Detailed Description

Definition at line 30 of file snes.h.

Constructor & Destructor Documentation

◆ SNES()

yaze::app::emu::SNES::SNES ( )
default

◆ ~SNES()

yaze::app::emu::SNES::~SNES ( )
default

Member Function Documentation

◆ Init()

void yaze::app::emu::SNES::Init ( std::vector< uint8_t > & rom_data)

◆ Reset()

◆ RunFrame()

void yaze::app::emu::SNES::RunFrame ( )

Definition at line 88 of file snes.cc.

References cpu_, frames_, in_vblank_, and yaze::app::emu::Cpu::RunOpcode().

Referenced by main(), and yaze::app::emu::Emulator::Run().

Here is the call graph for this function:

◆ CatchUpApu()

void yaze::app::emu::SNES::CatchUpApu ( )

Definition at line 98 of file snes.cc.

References apu_, cycles_, and yaze::app::emu::audio::Apu::RunCycles().

Referenced by ReadBBus(), RunCycle(), and WriteBBus().

Here is the call graph for this function:

◆ HandleInput()

void yaze::app::emu::SNES::HandleInput ( )

Definition at line 100 of file snes.cc.

References input1, input2, and port_auto_read_.

Referenced by RunCycle().

◆ RunCycle()

◆ RunCycles()

void yaze::app::emu::SNES::RunCycles ( int cycles)

◆ SyncCycles()

void yaze::app::emu::SNES::SyncCycles ( bool start,
int sync_cycles )

Definition at line 242 of file snes.cc.

References cycles_, RunCycles(), and sync_cycle_.

Referenced by yaze::app::emu::memory::dma::DoDma(), yaze::app::emu::memory::dma::DoHdma(), and yaze::app::emu::memory::dma::InitHdma().

Here is the call graph for this function:

◆ ReadBBus()

uint8_t yaze::app::emu::SNES::ReadBBus ( uint8_t adr)

◆ ReadReg()

uint8_t yaze::app::emu::SNES::ReadReg ( uint16_t adr)

◆ Rread()

uint8_t yaze::app::emu::SNES::Rread ( uint32_t adr)

◆ Read()

uint8_t yaze::app::emu::SNES::Read ( uint32_t adr)

◆ WriteBBus()

void yaze::app::emu::SNES::WriteBBus ( uint8_t adr,
uint8_t val )

Definition at line 358 of file snes.cc.

References apu_, CatchUpApu(), yaze::app::emu::audio::Apu::in_ports_, ppu_, ram, ram_adr_, and yaze::app::emu::video::Ppu::Write().

Referenced by yaze::app::emu::memory::dma::TransferByte(), and Write().

Here is the call graph for this function:

◆ WriteReg()

◆ Write()

void yaze::app::emu::SNES::Write ( uint32_t adr,
uint8_t val )

◆ GetAccessTime()

int yaze::app::emu::SNES::GetAccessTime ( uint32_t adr)

Definition at line 506 of file snes.cc.

References fast_mem_.

Referenced by InitAccessTime().

◆ CpuRead()

uint8_t yaze::app::emu::SNES::CpuRead ( uint32_t adr)

Definition at line 520 of file snes.cc.

References access_time, cpu_, yaze::app::emu::memory::dma::HandleDma(), memory_, Read(), RunCycles(), and yaze::app::emu::Cpu::set_int_delay().

Here is the call graph for this function:

◆ CpuWrite()

void yaze::app::emu::SNES::CpuWrite ( uint32_t adr,
uint8_t val )

Definition at line 531 of file snes.cc.

References access_time, cpu_, yaze::app::emu::memory::dma::HandleDma(), memory_, RunCycles(), yaze::app::emu::Cpu::set_int_delay(), and Write().

Here is the call graph for this function:

◆ CpuIdle()

void yaze::app::emu::SNES::CpuIdle ( bool waiting)

Definition at line 539 of file snes.cc.

References cpu_, yaze::app::emu::memory::dma::HandleDma(), memory_, RunCycles(), and yaze::app::emu::Cpu::set_int_delay().

Here is the call graph for this function:

◆ SetSamples()

void yaze::app::emu::SNES::SetSamples ( int16_t * sample_data,
int wanted_samples )

Definition at line 545 of file snes.cc.

References apu_, yaze::app::emu::audio::Apu::dsp(), memory_, and yaze::app::emu::memory::MemoryImpl::pal_timing().

Referenced by main(), and yaze::app::emu::Emulator::Run().

Here is the call graph for this function:

◆ SetPixels()

void yaze::app::emu::SNES::SetPixels ( uint8_t * pixel_data)

Definition at line 549 of file snes.cc.

References ppu_, and yaze::app::emu::video::Ppu::PutPixels().

Referenced by main(), and yaze::app::emu::Emulator::Run().

Here is the call graph for this function:

◆ SetButtonState()

void yaze::app::emu::SNES::SetButtonState ( int player,
int button,
bool pressed )

Definition at line 551 of file snes.cc.

References yaze::app::emu::Input::current_state_, input1, and input2.

Referenced by yaze::app::emu::Emulator::HandleEvents().

◆ running()

bool yaze::app::emu::SNES::running ( ) const
inline

Definition at line 68 of file snes.h.

References running_.

Referenced by yaze::app::emu::Emulator::RenderSnesPpu(), and yaze::app::emu::Emulator::Run().

◆ cpu()

◆ ppu()

auto yaze::app::emu::SNES::ppu ( ) -> video::Ppu&
inline

Definition at line 70 of file snes.h.

References ppu_.

◆ apu()

auto yaze::app::emu::SNES::apu ( ) -> audio::Apu&
inline

◆ Memory()

auto yaze::app::emu::SNES::Memory ( ) -> memory::MemoryImpl&
inline

◆ get_ram()

auto yaze::app::emu::SNES::get_ram ( ) -> uint8_t*
inline

Definition at line 73 of file snes.h.

References ram.

Referenced by yaze::app::emu::Emulator::RenderMemoryViewer().

◆ mutable_cycles()

auto yaze::app::emu::SNES::mutable_cycles ( ) -> uint64_t&
inline

Definition at line 74 of file snes.h.

References cycles_.

Referenced by yaze::app::emu::Emulator::Emulator().

◆ InitAccessTime()

void yaze::app::emu::SNES::InitAccessTime ( bool recalc)

Definition at line 568 of file snes.cc.

References access_time, and GetAccessTime().

Referenced by Reset().

Here is the call graph for this function:

Member Data Documentation

◆ access_time

std::vector<uint8_t> yaze::app::emu::SNES::access_time

Definition at line 77 of file snes.h.

Referenced by CpuRead(), CpuWrite(), and InitAccessTime().

◆ clock_

ClockImpl yaze::app::emu::SNES::clock_
private

Definition at line 81 of file snes.h.

◆ memory_

memory::MemoryImpl yaze::app::emu::SNES::memory_
private

◆ cpu_callbacks_

memory::CpuCallbacks yaze::app::emu::SNES::cpu_callbacks_
private
Initial value:
= {
[&](uint32_t adr) { return CpuRead(adr); },
[&](uint32_t adr, uint8_t val) { CpuWrite(adr, val); },
[&](bool waiting) { CpuIdle(waiting); },
}
void CpuIdle(bool waiting)
Definition snes.cc:539
uint8_t CpuRead(uint32_t adr)
Definition snes.cc:520
void CpuWrite(uint32_t adr, uint8_t val)
Definition snes.cc:531

Definition at line 84 of file snes.h.

◆ cpu_

Cpu yaze::app::emu::SNES::cpu_ {memory_, clock_, cpu_callbacks_}
private

Definition at line 89 of file snes.h.

Referenced by cpu(), CpuIdle(), CpuRead(), CpuWrite(), ReadReg(), Reset(), RunCycle(), RunFrame(), and WriteReg().

◆ ppu_

video::Ppu yaze::app::emu::SNES::ppu_ {memory_, clock_}
private

Definition at line 90 of file snes.h.

Referenced by Init(), ppu(), ReadBBus(), Reset(), RunCycle(), SetPixels(), WriteBBus(), and WriteReg().

◆ apu_

audio::Apu yaze::app::emu::SNES::apu_ {memory_}
private

Definition at line 91 of file snes.h.

Referenced by apu(), CatchUpApu(), Init(), ReadBBus(), Reset(), RunCycle(), SetSamples(), and WriteBBus().

◆ rom_data

std::vector<uint8_t> yaze::app::emu::SNES::rom_data
private

Definition at line 94 of file snes.h.

Referenced by Init().

◆ running_

bool yaze::app::emu::SNES::running_ = false
private

Definition at line 97 of file snes.h.

Referenced by Init(), and running().

◆ ram

uint8_t yaze::app::emu::SNES::ram[0x20000]
private

Definition at line 100 of file snes.h.

Referenced by get_ram(), ReadBBus(), Reset(), Rread(), Write(), and WriteBBus().

◆ ram_adr_

uint32_t yaze::app::emu::SNES::ram_adr_
private

Definition at line 101 of file snes.h.

Referenced by ReadBBus(), Reset(), and WriteBBus().

◆ frames_

uint32_t yaze::app::emu::SNES::frames_ = 0
private

Definition at line 104 of file snes.h.

Referenced by Reset(), RunCycle(), and RunFrame().

◆ cycles_

uint64_t yaze::app::emu::SNES::cycles_ = 0
private

Definition at line 105 of file snes.h.

Referenced by CatchUpApu(), mutable_cycles(), Reset(), RunCycle(), and SyncCycles().

◆ sync_cycle_

uint64_t yaze::app::emu::SNES::sync_cycle_ = 0
private

Definition at line 106 of file snes.h.

Referenced by Reset(), and SyncCycles().

◆ apu_catchup_cycles_

double yaze::app::emu::SNES::apu_catchup_cycles_
private

Definition at line 107 of file snes.h.

Referenced by Reset().

◆ next_horiz_event

uint32_t yaze::app::emu::SNES::next_horiz_event
private

Definition at line 108 of file snes.h.

Referenced by Reset(), and RunCycle().

◆ h_irq_enabled_

bool yaze::app::emu::SNES::h_irq_enabled_ = false
private

Definition at line 111 of file snes.h.

Referenced by Reset(), RunCycle(), and WriteReg().

◆ v_irq_enabled_

bool yaze::app::emu::SNES::v_irq_enabled_ = false
private

Definition at line 112 of file snes.h.

Referenced by Reset(), RunCycle(), and WriteReg().

◆ nmi_enabled_

bool yaze::app::emu::SNES::nmi_enabled_ = false
private

Definition at line 113 of file snes.h.

Referenced by Reset(), RunCycle(), and WriteReg().

◆ h_timer_

uint16_t yaze::app::emu::SNES::h_timer_ = 0
private

Definition at line 114 of file snes.h.

Referenced by Reset(), RunCycle(), and WriteReg().

◆ v_timer_

uint16_t yaze::app::emu::SNES::v_timer_ = 0
private

Definition at line 115 of file snes.h.

Referenced by Reset(), RunCycle(), and WriteReg().

◆ in_nmi_

bool yaze::app::emu::SNES::in_nmi_ = false
private

Definition at line 116 of file snes.h.

Referenced by ReadReg(), Reset(), RunCycle(), and WriteReg().

◆ irq_condition_

bool yaze::app::emu::SNES::irq_condition_ = false
private

Definition at line 117 of file snes.h.

Referenced by Reset(), and RunCycle().

◆ in_irq_

bool yaze::app::emu::SNES::in_irq_ = false
private

Definition at line 118 of file snes.h.

Referenced by ReadReg(), Reset(), RunCycle(), and WriteReg().

◆ in_vblank_

bool yaze::app::emu::SNES::in_vblank_
private

Definition at line 119 of file snes.h.

Referenced by ReadReg(), Reset(), RunCycle(), and RunFrame().

◆ multiply_a_

uint8_t yaze::app::emu::SNES::multiply_a_
private

Definition at line 122 of file snes.h.

Referenced by Reset(), and WriteReg().

◆ multiply_result_

uint16_t yaze::app::emu::SNES::multiply_result_
private

Definition at line 123 of file snes.h.

Referenced by ReadReg(), Reset(), and WriteReg().

◆ divide_a_

uint16_t yaze::app::emu::SNES::divide_a_
private

Definition at line 124 of file snes.h.

Referenced by Reset(), and WriteReg().

◆ divide_result_

uint16_t yaze::app::emu::SNES::divide_result_
private

Definition at line 125 of file snes.h.

Referenced by ReadReg(), Reset(), and WriteReg().

◆ input1

Input yaze::app::emu::SNES::input1
private

Definition at line 128 of file snes.h.

Referenced by HandleInput(), Reset(), Rread(), SetButtonState(), and Write().

◆ input2

Input yaze::app::emu::SNES::input2
private

Definition at line 129 of file snes.h.

Referenced by HandleInput(), Reset(), Rread(), SetButtonState(), and Write().

◆ port_auto_read_

uint16_t yaze::app::emu::SNES::port_auto_read_[4]
private

Definition at line 130 of file snes.h.

Referenced by HandleInput(), ReadReg(), and Reset().

◆ auto_joy_read_

bool yaze::app::emu::SNES::auto_joy_read_ = false
private

Definition at line 131 of file snes.h.

Referenced by Reset(), RunCycle(), and WriteReg().

◆ auto_joy_timer_

uint16_t yaze::app::emu::SNES::auto_joy_timer_ = 0
private

Definition at line 132 of file snes.h.

Referenced by ReadReg(), Reset(), RunCycle(), and WriteReg().

◆ ppu_latch_

bool yaze::app::emu::SNES::ppu_latch_
private

Definition at line 133 of file snes.h.

Referenced by ReadBBus(), ReadReg(), Reset(), and WriteReg().

◆ fast_mem_

bool yaze::app::emu::SNES::fast_mem_ = false
private

Definition at line 135 of file snes.h.

Referenced by GetAccessTime(), Reset(), and WriteReg().


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