#include <snes.h>
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 |
|
default |
|
default |
void yaze::app::emu::SNES::Init | ( | std::vector< uint8_t > & | rom_data | ) |
Definition at line 36 of file snes.cc.
References apu_, yaze::app::emu::audio::Apu::Init(), yaze::app::emu::video::Ppu::Init(), yaze::app::emu::memory::MemoryImpl::Initialize(), memory_, ppu_, Reset(), rom_data, and running_.
Referenced by main(), yaze::app::emu::Emulator::RenderNavBar(), and yaze::app::emu::Emulator::Run().
void yaze::app::emu::SNES::Reset | ( | bool | hard = false | ) |
Definition at line 48 of file snes.cc.
References apu_, apu_catchup_cycles_, auto_joy_read_, auto_joy_timer_, cpu_, cycles_, divide_a_, divide_result_, fast_mem_, frames_, h_irq_enabled_, h_timer_, in_irq_, in_nmi_, in_vblank_, InitAccessTime(), input1, input2, irq_condition_, yaze::app::emu::Input::latch_line_, yaze::app::emu::Input::latched_state_, memory_, multiply_a_, multiply_result_, next_horiz_event, nmi_enabled_, port_auto_read_, ppu_, ppu_latch_, ram, ram_adr_, yaze::app::emu::audio::Apu::Reset(), yaze::app::emu::Cpu::Reset(), yaze::app::emu::memory::dma::Reset(), yaze::app::emu::video::Ppu::Reset(), yaze::app::emu::memory::MemoryImpl::set_h_pos(), yaze::app::emu::memory::MemoryImpl::set_open_bus(), yaze::app::emu::memory::MemoryImpl::set_v_pos(), sync_cycle_, v_irq_enabled_, and v_timer_.
Referenced by Init(), and yaze::app::emu::Emulator::RenderNavBar().
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().
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().
void yaze::app::emu::SNES::HandleInput | ( | ) |
Definition at line 100 of file snes.cc.
References input1, input2, and port_auto_read_.
Referenced by RunCycle().
void yaze::app::emu::SNES::RunCycle | ( | ) |
Definition at line 117 of file snes.cc.
References apu_, auto_joy_read_, auto_joy_timer_, CatchUpApu(), yaze::app::emu::video::Ppu::CheckOverscan(), cpu_, cycles_, yaze::app::emu::audio::Apu::dsp(), yaze::app::emu::video::Ppu::even_frame, yaze::app::emu::video::Ppu::frame_interlace, frames_, h_irq_enabled_, yaze::app::emu::memory::MemoryImpl::h_pos(), h_timer_, yaze::app::emu::video::Ppu::HandleFrameStart(), HandleInput(), yaze::app::emu::video::Ppu::HandleVblank(), in_irq_, in_nmi_, in_vblank_, yaze::app::emu::memory::MemoryImpl::init_hdma_request(), irq_condition_, memory_, next_horiz_event, yaze::app::emu::Cpu::Nmi(), nmi_enabled_, yaze::app::emu::memory::MemoryImpl::pal_timing(), ppu_, yaze::app::emu::memory::MemoryImpl::run_hdma_request(), yaze::app::emu::video::Ppu::RunLine(), yaze::app::emu::memory::MemoryImpl::set_h_pos(), yaze::app::emu::memory::MemoryImpl::set_v_pos(), yaze::app::emu::Cpu::SetIrq(), v_irq_enabled_, yaze::app::emu::memory::MemoryImpl::v_pos(), and v_timer_.
Referenced by RunCycles().
void yaze::app::emu::SNES::RunCycles | ( | int | cycles | ) |
Definition at line 232 of file snes.cc.
References yaze::app::emu::memory::MemoryImpl::h_pos(), memory_, and RunCycle().
Referenced by CpuIdle(), CpuRead(), CpuWrite(), yaze::app::emu::memory::dma::DoHdma(), yaze::app::emu::memory::dma::InitHdma(), SyncCycles(), and yaze::app::emu::memory::dma::WaitCycle().
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().
uint8_t yaze::app::emu::SNES::ReadBBus | ( | uint8_t | adr | ) |
Definition at line 253 of file snes.cc.
References apu_, CatchUpApu(), memory_, yaze::app::emu::memory::MemoryImpl::open_bus(), yaze::app::emu::audio::Apu::out_ports_, ppu_, ppu_latch_, ram, ram_adr_, and yaze::app::emu::video::Ppu::Read().
Referenced by Rread(), and yaze::app::emu::memory::dma::TransferByte().
uint8_t yaze::app::emu::SNES::ReadReg | ( | uint16_t | adr | ) |
Definition at line 269 of file snes.cc.
References auto_joy_timer_, cpu_, divide_result_, yaze::app::emu::memory::MemoryImpl::h_pos(), in_irq_, in_nmi_, in_vblank_, memory_, multiply_result_, yaze::app::emu::memory::MemoryImpl::open_bus(), port_auto_read_, ppu_latch_, and yaze::app::emu::Cpu::SetIrq().
Referenced by Rread().
uint8_t yaze::app::emu::SNES::Rread | ( | uint32_t | adr | ) |
Definition at line 322 of file snes.cc.
References yaze::app::emu::memory::MemoryImpl::cart_read(), input1, input2, memory_, yaze::app::emu::memory::MemoryImpl::open_bus(), ram, yaze::app::emu::memory::dma::Read(), ReadBBus(), and ReadReg().
Referenced by Read().
uint8_t yaze::app::emu::SNES::Read | ( | uint32_t | adr | ) |
Definition at line 352 of file snes.cc.
References memory_, Rread(), and yaze::app::emu::memory::MemoryImpl::set_open_bus().
Referenced by CpuRead(), yaze::app::emu::memory::dma::DoHdma(), yaze::app::emu::memory::dma::InitHdma(), and yaze::app::emu::memory::dma::TransferByte().
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().
void yaze::app::emu::SNES::WriteReg | ( | uint16_t | adr, |
uint8_t | val ) |
Definition at line 389 of file snes.cc.
References auto_joy_read_, auto_joy_timer_, cpu_, divide_a_, divide_result_, fast_mem_, h_irq_enabled_, h_timer_, in_irq_, in_nmi_, yaze::app::emu::video::Ppu::LatchHV(), memory_, multiply_a_, multiply_result_, yaze::app::emu::Cpu::Nmi(), nmi_enabled_, ppu_, ppu_latch_, yaze::app::emu::Cpu::set_int_delay(), yaze::app::emu::Cpu::SetIrq(), yaze::app::emu::memory::dma::StartDma(), v_irq_enabled_, and v_timer_.
Referenced by Write().
void yaze::app::emu::SNES::Write | ( | uint32_t | adr, |
uint8_t | val ) |
Definition at line 476 of file snes.cc.
References yaze::app::emu::memory::MemoryImpl::cart_write(), input1, input2, memory_, ram, yaze::app::emu::memory::MemoryImpl::set_open_bus(), yaze::app::emu::memory::dma::Write(), WriteBBus(), and WriteReg().
Referenced by CpuWrite(), and yaze::app::emu::memory::dma::TransferByte().
int yaze::app::emu::SNES::GetAccessTime | ( | uint32_t | adr | ) |
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().
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().
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().
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().
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().
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().
|
inline |
Definition at line 68 of file snes.h.
References running_.
Referenced by yaze::app::emu::Emulator::RenderSnesPpu(), and yaze::app::emu::Emulator::Run().
|
inline |
Definition at line 69 of file snes.h.
References cpu_.
Referenced by yaze::app::emu::memory::dma::DoDma(), yaze::app::emu::memory::dma::DoHdma(), yaze::app::emu::Emulator::Emulator(), yaze::app::emu::memory::dma::InitHdma(), yaze::app::emu::Emulator::RenderBreakpointList(), and yaze::app::emu::Emulator::RenderNavBar().
|
inline |
|
inline |
Definition at line 71 of file snes.h.
References apu_.
Referenced by yaze::app::emu::Emulator::Emulator(), yaze::app::emu::Emulator::RenderBreakpointList(), and yaze::app::emu::Emulator::RenderMemoryViewer().
|
inline |
Definition at line 72 of file snes.h.
References memory_.
Referenced by yaze::app::emu::Emulator::Emulator(), main(), yaze::app::emu::Emulator::RenderMemoryViewer(), and yaze::app::emu::Emulator::Run().
|
inline |
Definition at line 73 of file snes.h.
References ram.
Referenced by yaze::app::emu::Emulator::RenderMemoryViewer().
|
inline |
Definition at line 74 of file snes.h.
References cycles_.
Referenced by yaze::app::emu::Emulator::Emulator().
void yaze::app::emu::SNES::InitAccessTime | ( | bool | recalc | ) |
Definition at line 568 of file snes.cc.
References access_time, and GetAccessTime().
Referenced by Reset().
std::vector<uint8_t> yaze::app::emu::SNES::access_time |
Definition at line 77 of file snes.h.
Referenced by CpuRead(), CpuWrite(), and InitAccessTime().
|
private |
Definition at line 82 of file snes.h.
Referenced by CpuIdle(), CpuRead(), CpuWrite(), Init(), Memory(), Read(), ReadBBus(), ReadReg(), Reset(), Rread(), RunCycle(), RunCycles(), SetSamples(), Write(), and WriteReg().
|
private |
|
private |
Definition at line 89 of file snes.h.
Referenced by cpu(), CpuIdle(), CpuRead(), CpuWrite(), ReadReg(), Reset(), RunCycle(), RunFrame(), and WriteReg().
|
private |
Definition at line 90 of file snes.h.
Referenced by Init(), ppu(), ReadBBus(), Reset(), RunCycle(), SetPixels(), WriteBBus(), and WriteReg().
|
private |
Definition at line 91 of file snes.h.
Referenced by apu(), CatchUpApu(), Init(), ReadBBus(), Reset(), RunCycle(), SetSamples(), and WriteBBus().
|
private |
|
private |
|
private |
Definition at line 100 of file snes.h.
Referenced by get_ram(), ReadBBus(), Reset(), Rread(), Write(), and WriteBBus().
|
private |
Definition at line 101 of file snes.h.
Referenced by ReadBBus(), Reset(), and WriteBBus().
|
private |
Definition at line 104 of file snes.h.
Referenced by Reset(), RunCycle(), and RunFrame().
|
private |
Definition at line 105 of file snes.h.
Referenced by CatchUpApu(), mutable_cycles(), Reset(), RunCycle(), and SyncCycles().
|
private |
Definition at line 106 of file snes.h.
Referenced by Reset(), and SyncCycles().
|
private |
|
private |
Definition at line 108 of file snes.h.
Referenced by Reset(), and RunCycle().
|
private |
Definition at line 111 of file snes.h.
Referenced by Reset(), RunCycle(), and WriteReg().
|
private |
Definition at line 112 of file snes.h.
Referenced by Reset(), RunCycle(), and WriteReg().
|
private |
Definition at line 113 of file snes.h.
Referenced by Reset(), RunCycle(), and WriteReg().
|
private |
Definition at line 114 of file snes.h.
Referenced by Reset(), RunCycle(), and WriteReg().
|
private |
Definition at line 115 of file snes.h.
Referenced by Reset(), RunCycle(), and WriteReg().
|
private |
Definition at line 116 of file snes.h.
Referenced by ReadReg(), Reset(), RunCycle(), and WriteReg().
|
private |
Definition at line 117 of file snes.h.
Referenced by Reset(), and RunCycle().
|
private |
Definition at line 118 of file snes.h.
Referenced by ReadReg(), Reset(), RunCycle(), and WriteReg().
|
private |
Definition at line 119 of file snes.h.
Referenced by ReadReg(), Reset(), RunCycle(), and RunFrame().
|
private |
Definition at line 122 of file snes.h.
Referenced by Reset(), and WriteReg().
|
private |
Definition at line 123 of file snes.h.
Referenced by ReadReg(), Reset(), and WriteReg().
|
private |
Definition at line 124 of file snes.h.
Referenced by Reset(), and WriteReg().
|
private |
Definition at line 125 of file snes.h.
Referenced by ReadReg(), Reset(), and WriteReg().
|
private |
Definition at line 128 of file snes.h.
Referenced by HandleInput(), Reset(), Rread(), SetButtonState(), and Write().
|
private |
Definition at line 129 of file snes.h.
Referenced by HandleInput(), Reset(), Rread(), SetButtonState(), and Write().
|
private |
Definition at line 130 of file snes.h.
Referenced by HandleInput(), ReadReg(), and Reset().
|
private |
Definition at line 131 of file snes.h.
Referenced by Reset(), RunCycle(), and WriteReg().
|
private |
Definition at line 132 of file snes.h.
Referenced by ReadReg(), Reset(), RunCycle(), and WriteReg().
|
private |
Definition at line 133 of file snes.h.
Referenced by ReadBBus(), ReadReg(), Reset(), and WriteReg().
|
private |
Definition at line 135 of file snes.h.
Referenced by GetAccessTime(), Reset(), and WriteReg().