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

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

#include <apu.h>

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 &
 
uint64_t GetCycles () const
 
void set_handshake_tracker (debug::ApuHandshakeTracker *tracker)
 
uint8_t GetStatus () const
 
uint8_t GetControl () const
 
void GetSamples (int16_t *buffer, int count, bool loop=false)
 
void WriteDma (uint16_t address, const uint8_t *data, int count)
 

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
 
uint8_t transfer_size_ = 0
 
bool in_transfer_ = false
 
MemoryImplmemory_
 
std::array< Timer, 3 > timer_
 
debug::ApuHandshakeTrackerhandshake_tracker_ = nullptr
 
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::emu::Apu::Apu ( MemoryImpl memory)
inline

Definition at line 55 of file apu.h.

Member Function Documentation

◆ Init()

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

◆ Reset()

◆ RunCycles()

◆ SpcRead()

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

Definition at line 334 of file apu.cc.

References Cycle(), and Read().

Here is the call graph for this function:

◆ SpcWrite()

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

Definition at line 339 of file apu.cc.

References Cycle(), and Write().

Here is the call graph for this function:

◆ SpcIdle()

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

Definition at line 344 of file apu.cc.

References Cycle().

Here is the call graph for this function:

◆ Cycle()

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

Definition at line 161 of file apu.cc.

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

Referenced by RunCycles(), SpcIdle(), SpcRead(), SpcWrite(), and yaze::emu::TEST().

Here is the call graph for this function:

◆ Read()

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

Definition at line 186 of file apu.cc.

References dsp_, dsp_adr_, in_ports_, LOG_DEBUG, yaze::emu::Spc700::PC, ram, yaze::emu::Dsp::Read(), rom_readable_, spc700_, and timer_.

Referenced by SpcRead().

Here is the call graph for this function:

◆ Write()

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

◆ dsp()

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

Definition at line 70 of file apu.h.

References dsp_.

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

◆ spc700()

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

Definition at line 71 of file apu.h.

References spc700_.

Referenced by yaze::emu::TEST(), and yaze::emu::TEST_F().

◆ GetCycles()

uint64_t yaze::emu::Apu::GetCycles ( ) const
inline

Definition at line 73 of file apu.h.

References cycles_.

Referenced by yaze::emu::Snes::ReadBBus().

◆ set_handshake_tracker()

void yaze::emu::Apu::set_handshake_tracker ( debug::ApuHandshakeTracker tracker)
inline

Definition at line 76 of file apu.h.

References handshake_tracker_.

Referenced by yaze::emu::Snes::Init().

◆ GetStatus()

uint8_t yaze::emu::Apu::GetStatus ( ) const
inline

Definition at line 79 of file apu.h.

References ram.

◆ GetControl()

uint8_t yaze::emu::Apu::GetControl ( ) const
inline

Definition at line 80 of file apu.h.

References ram.

◆ GetSamples()

void yaze::emu::Apu::GetSamples ( int16_t *  buffer,
int  count,
bool  loop = false 
)
inline

Definition at line 81 of file apu.h.

References dsp_, and yaze::emu::Dsp::GetSamples().

Here is the call graph for this function:

◆ WriteDma()

void yaze::emu::Apu::WriteDma ( uint16_t  address,
const uint8_t *  data,
int  count 
)
inline

Definition at line 84 of file apu.h.

References ram.

Member Data Documentation

◆ in_ports_

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

Definition at line 91 of file apu.h.

Referenced by Read(), Reset(), RunCycles(), Write(), and yaze::emu::Snes::WriteBBus().

◆ out_ports_

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

Definition at line 92 of file apu.h.

Referenced by yaze::emu::Snes::ReadBBus(), Reset(), RunCycles(), and Write().

◆ ram

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

Definition at line 93 of file apu.h.

Referenced by GetControl(), GetStatus(), Init(), Read(), Reset(), RunCycles(), Write(), and WriteDma().

◆ rom_readable_

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

Definition at line 96 of file apu.h.

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

◆ dsp_adr_

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

Definition at line 98 of file apu.h.

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

◆ cycles_

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

Definition at line 99 of file apu.h.

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

◆ transfer_size_

uint8_t yaze::emu::Apu::transfer_size_ = 0
private

Definition at line 102 of file apu.h.

Referenced by Reset(), and Write().

◆ in_transfer_

bool yaze::emu::Apu::in_transfer_ = false
private

Definition at line 103 of file apu.h.

Referenced by Reset(), and Write().

◆ memory_

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

Definition at line 105 of file apu.h.

Referenced by RunCycles().

◆ timer_

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

Definition at line 106 of file apu.h.

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

◆ handshake_tracker_

debug::ApuHandshakeTracker* yaze::emu::Apu::handshake_tracker_ = nullptr
private

Definition at line 109 of file apu.h.

Referenced by Reset(), RunCycles(), set_handshake_tracker(), and Write().

◆ callbacks_

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

Definition at line 111 of file apu.h.

◆ dsp_

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

Definition at line 116 of file apu.h.

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

◆ spc700_

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

Definition at line 117 of file apu.h.

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


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