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

The Apu class represents the Audio Processing Unit (APU) of a system. More...

#include <apu.h>

Collaboration diagram for yaze::app::emu::audio::Apu:

Public Member Functions

 Apu (MemoryImpl &memory)
 
void Init ()
 
void Reset ()
 
void RunCycles (uint64_t cycles)
 
uint8_t SpcRead (uint16_t address)
 
void SpcWrite (uint16_t address, uint8_t data)
 
void SpcIdle (bool waiting)
 
void Cycle ()
 
uint8_t Read (uint16_t address)
 
void Write (uint16_t address, uint8_t data)
 
auto dsp () -> Dsp &
 
auto spc700 () -> Spc700 &
 

Public Attributes

std::array< uint8_t, 6 > in_ports_
 
std::array< uint8_t, 4 > out_ports_
 
std::vector< uint8_t > ram = std::vector<uint8_t>(0x10000, 0)
 

Private Attributes

bool rom_readable_ = false
 
uint8_t dsp_adr_ = 0
 
uint32_t cycles_ = 0
 
MemoryImplmemory_
 
std::array< Timer, 3 > timer_
 
ApuCallbacks callbacks_
 
Dsp dsp_ {ram}
 
Spc700 spc700_ {callbacks_}
 

Detailed Description

The Apu class represents the Audio Processing Unit (APU) of a system.

The Apu class is responsible for generating audio samples and managing the APU state. It interacts with the Memory, AudioRam, and Clock classes to read/write data and update the clock. The class also implements the Observer interface to receive notifications from the system.

IPL ROM Info
64 kilobytes of RAM are mapped across the 16-bit memory space of the SPC-700. Some regions of this space are overlaid with special hardware functions.
Range Note
$0000-00EF Zero Page RAM $00F0-00FF Sound CPU Registers $0100-01FF Stack Page RAM $0200-FFBF RAM $FFC0-FFFF IPL ROM or RAM

The region at $FFC0-FFFF will normally read from the 64-byte IPL ROM, but the underlying RAM can always be written to, and the high bit of the Control register $F1 can be cleared to unmap the IPL ROM and allow read access to this RAM.

Definition at line 53 of file apu.h.

Constructor & Destructor Documentation

◆ Apu()

yaze::app::emu::audio::Apu::Apu ( MemoryImpl & memory)
inline

Definition at line 55 of file apu.h.

Member Function Documentation

◆ Init()

void yaze::app::emu::audio::Apu::Init ( )

Definition at line 31 of file apu.cc.

References ram.

Referenced by yaze::app::emu::SNES::Init().

◆ Reset()

void yaze::app::emu::audio::Apu::Reset ( )

Definition at line 42 of file apu.cc.

References cycles_, dsp_, dsp_adr_, in_ports_, out_ports_, ram, yaze::app::emu::audio::Dsp::Reset(), yaze::app::emu::audio::Spc700::Reset(), rom_readable_, spc700_, and timer_.

Referenced by yaze::app::emu::SNES::Reset().

Here is the call graph for this function:

◆ RunCycles()

void yaze::app::emu::audio::Apu::RunCycles ( uint64_t cycles)

Definition at line 66 of file apu.cc.

References cycles_, memory_, yaze::app::emu::memory::MemoryImpl::pal_timing(), yaze::app::emu::audio::Spc700::RunOpcode(), and spc700_.

Referenced by yaze::app::emu::SNES::CatchUpApu().

Here is the call graph for this function:

◆ SpcRead()

uint8_t yaze::app::emu::audio::Apu::SpcRead ( uint16_t address)

Definition at line 192 of file apu.cc.

References Cycle(), and Read().

Here is the call graph for this function:

◆ SpcWrite()

void yaze::app::emu::audio::Apu::SpcWrite ( uint16_t address,
uint8_t data )

Definition at line 197 of file apu.cc.

References Cycle(), and Write().

Here is the call graph for this function:

◆ SpcIdle()

void yaze::app::emu::audio::Apu::SpcIdle ( bool waiting)

Definition at line 202 of file apu.cc.

References Cycle().

Here is the call graph for this function:

◆ Cycle()

void yaze::app::emu::audio::Apu::Cycle ( )

Definition at line 76 of file apu.cc.

References yaze::app::emu::audio::Dsp::Cycle(), cycles_, dsp_, and timer_.

Referenced by SpcIdle(), SpcRead(), and SpcWrite().

Here is the call graph for this function:

◆ Read()

uint8_t yaze::app::emu::audio::Apu::Read ( uint16_t address)

Definition at line 101 of file apu.cc.

References dsp_, dsp_adr_, in_ports_, ram, yaze::app::emu::audio::Dsp::Read(), rom_readable_, and timer_.

Referenced by SpcRead().

Here is the call graph for this function:

◆ Write()

void yaze::app::emu::audio::Apu::Write ( uint16_t address,
uint8_t data )

Definition at line 138 of file apu.cc.

References dsp_, dsp_adr_, in_ports_, out_ports_, ram, rom_readable_, timer_, and yaze::app::emu::audio::Dsp::Write().

Referenced by SpcWrite().

Here is the call graph for this function:

◆ dsp()

auto yaze::app::emu::audio::Apu::dsp ( ) -> Dsp &
inline

Definition at line 70 of file apu.h.

References dsp_.

Referenced by yaze::app::emu::SNES::RunCycle(), and yaze::app::emu::SNES::SetSamples().

◆ spc700()

auto yaze::app::emu::audio::Apu::spc700 ( ) -> Spc700 &
inline

Definition at line 71 of file apu.h.

References spc700_.

Member Data Documentation

◆ in_ports_

std::array<uint8_t, 6> yaze::app::emu::audio::Apu::in_ports_

Definition at line 74 of file apu.h.

Referenced by Read(), Reset(), Write(), and yaze::app::emu::SNES::WriteBBus().

◆ out_ports_

std::array<uint8_t, 4> yaze::app::emu::audio::Apu::out_ports_

Definition at line 75 of file apu.h.

Referenced by yaze::app::emu::SNES::ReadBBus(), Reset(), and Write().

◆ ram

std::vector<uint8_t> yaze::app::emu::audio::Apu::ram = std::vector<uint8_t>(0x10000, 0)

Definition at line 76 of file apu.h.

Referenced by Init(), Read(), Reset(), and Write().

◆ rom_readable_

bool yaze::app::emu::audio::Apu::rom_readable_ = false
private

Definition at line 79 of file apu.h.

Referenced by Read(), Reset(), and Write().

◆ dsp_adr_

uint8_t yaze::app::emu::audio::Apu::dsp_adr_ = 0
private

Definition at line 81 of file apu.h.

Referenced by Read(), Reset(), and Write().

◆ cycles_

uint32_t yaze::app::emu::audio::Apu::cycles_ = 0
private

Definition at line 82 of file apu.h.

Referenced by Cycle(), Reset(), and RunCycles().

◆ memory_

MemoryImpl& yaze::app::emu::audio::Apu::memory_
private

Definition at line 84 of file apu.h.

Referenced by RunCycles().

◆ timer_

std::array<Timer, 3> yaze::app::emu::audio::Apu::timer_
private

Definition at line 85 of file apu.h.

Referenced by Cycle(), Read(), Reset(), and Write().

◆ callbacks_

ApuCallbacks yaze::app::emu::audio::Apu::callbacks_
private
Initial value:
= {
[&](uint16_t adr, uint8_t val) { SpcWrite(adr, val); },
[&](uint16_t adr) { return SpcRead(adr); },
[&](bool waiting) { SpcIdle(waiting); },
}
void SpcWrite(uint16_t address, uint8_t data)
Definition apu.cc:197
void SpcIdle(bool waiting)
Definition apu.cc:202
uint8_t SpcRead(uint16_t address)
Definition apu.cc:192

Definition at line 87 of file apu.h.

◆ dsp_

Dsp yaze::app::emu::audio::Apu::dsp_ {ram}
private

Definition at line 92 of file apu.h.

Referenced by Cycle(), dsp(), Read(), Reset(), and Write().

◆ spc700_

Spc700 yaze::app::emu::audio::Apu::spc700_ {callbacks_}
private

Definition at line 93 of file apu.h.

Referenced by Reset(), RunCycles(), and spc700().


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