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) |
| void | SaveState (std::ostream &stream) |
| void | LoadState (std::istream &stream) |
| 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 | dsp () const -> const 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) |
| void | BootstrapDirect (uint16_t entry_point) |
| Bootstrap SPC directly to driver code (bypasses IPL ROM handshake) | |
| bool | IsDriverRunning () const |
| Check if SPC has completed IPL ROM boot and is running driver code. | |
| const Timer & | GetTimer (int timer_index) const |
| Get timer state for debug UI. | |
| void | WriteToDsp (uint8_t address, uint8_t value) |
| Write directly to DSP register Used for direct instrument/note preview without going through driver. | |
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 |
| uint64_t | cycles_ = 0 |
| uint64_t | last_master_cycles_ = 0 |
| uint8_t | transfer_size_ = 0 |
| bool | in_transfer_ = false |
| MemoryImpl & | memory_ |
| std::array< Timer, 3 > | timer_ |
| debug::ApuHandshakeTracker * | handshake_tracker_ = nullptr |
| ApuCallbacks | callbacks_ |
| Dsp | dsp_ {ram} |
| Spc700 | spc700_ {callbacks_} |
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.
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.
|
inline |
| void yaze::emu::Apu::Init | ( | ) |
| void yaze::emu::Apu::Reset | ( | ) |
Definition at line 54 of file apu.cc.
References cycles_, dsp_, dsp_adr_, handshake_tracker_, in_ports_, in_transfer_, last_master_cycles_, LOG_DEBUG, LOG_INFO, out_ports_, ram, yaze::emu::Spc700::read_word(), yaze::emu::Dsp::Reset(), yaze::emu::debug::ApuHandshakeTracker::Reset(), yaze::emu::Spc700::Reset(), rom_readable_, spc700_, timer_, and transfer_size_.
Referenced by yaze::emu::Snes::Reset().

| void yaze::emu::Apu::RunCycles | ( | uint64_t | cycles | ) |
Definition at line 88 of file apu.cc.
References Cycle(), cycles_, handshake_tracker_, in_ports_, last_master_cycles_, LOG_DEBUG, LOG_INFO, memory_, yaze::emu::debug::ApuHandshakeTracker::OnSpcPCChange(), out_ports_, yaze::emu::MemoryImpl::pal_timing(), yaze::emu::Spc700::PC, ram, rom_readable_, spc700_, yaze::emu::Spc700::Step(), and yaze::emu::Spc700::Y.
Referenced by yaze::emu::Snes::CatchUpApu().

| void yaze::emu::Apu::SaveState | ( | std::ostream & | stream | ) |
Definition at line 426 of file apu.cc.
References cycles_, dsp_, dsp_adr_, in_ports_, in_transfer_, out_ports_, ram, rom_readable_, yaze::emu::Dsp::SaveState(), yaze::emu::Spc700::SaveState(), spc700_, timer_, and transfer_size_.
Referenced by yaze::emu::Snes::saveState().

| void yaze::emu::Apu::LoadState | ( | std::istream & | stream | ) |
Definition at line 449 of file apu.cc.
References cycles_, dsp_, dsp_adr_, in_ports_, in_transfer_, yaze::emu::Dsp::LoadState(), yaze::emu::Spc700::LoadState(), out_ports_, ram, rom_readable_, spc700_, timer_, and transfer_size_.
Referenced by yaze::emu::Snes::LoadLegacyState(), and yaze::emu::Snes::loadState().

| uint8_t yaze::emu::Apu::SpcRead | ( | uint16_t | address | ) |
| void yaze::emu::Apu::SpcWrite | ( | uint16_t | address, |
| uint8_t | data ) |
| void yaze::emu::Apu::SpcIdle | ( | bool | waiting | ) |
| void yaze::emu::Apu::Cycle | ( | ) |
Definition at line 226 of file apu.cc.
References yaze::emu::Dsp::Cycle(), cycles_, dsp_, and timer_.
Referenced by RunCycles(), SpcIdle(), SpcRead(), and SpcWrite().

| uint8_t yaze::emu::Apu::Read | ( | uint16_t | address | ) |
Definition at line 253 of file apu.cc.
References dsp_, dsp_adr_, in_ports_, ram, yaze::emu::Dsp::Read(), rom_readable_, and timer_.
Referenced by SpcRead().

| void yaze::emu::Apu::Write | ( | uint16_t | address, |
| uint8_t | data ) |
Definition at line 300 of file apu.cc.
References cycles_, dsp_, dsp_adr_, handshake_tracker_, in_ports_, in_transfer_, LOG_DEBUG, LOG_INFO, yaze::emu::debug::ApuHandshakeTracker::OnSpcPCChange(), yaze::emu::debug::ApuHandshakeTracker::OnSpcPortWrite(), out_ports_, yaze::emu::Spc700::PC, ram, rom_readable_, spc700_, timer_, transfer_size_, and yaze::emu::Dsp::Write().
Referenced by SpcWrite().

|
inline |
Definition at line 74 of file apu.h.
References dsp_.
Referenced by yaze::emu::Snes::RunCycle(), and yaze::emu::Snes::SetSamples().
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 81 of file apu.h.
References handshake_tracker_.
Referenced by yaze::emu::Snes::Init().
|
inline |
|
inline |
|
inline |
Definition at line 86 of file apu.h.
References dsp_, and yaze::emu::Dsp::GetSamples().

|
inline |
| void yaze::emu::Apu::BootstrapDirect | ( | uint16_t | entry_point | ) |
Bootstrap SPC directly to driver code (bypasses IPL ROM handshake)
This method allows direct control of the SPC700 by:
Use this after uploading audio driver code via WriteDma() to bypass the normal IPL ROM handshake protocol.
| entry_point | The ARAM address where the driver code starts (typically $0800) |
Definition at line 478 of file apu.cc.
References yaze::emu::Spc700::A, yaze::emu::Spc700::Flags::B, yaze::emu::Spc700::Flags::C, yaze::emu::Spc700::Flags::H, yaze::emu::Spc700::Flags::I, in_ports_, in_transfer_, LOG_INFO, yaze::emu::Spc700::Flags::N, out_ports_, yaze::emu::Spc700::Flags::P, yaze::emu::Spc700::PC, yaze::emu::Spc700::PSW, ram, rom_readable_, yaze::emu::Spc700::SP, spc700_, transfer_size_, yaze::emu::Spc700::Flags::V, yaze::emu::Spc700::X, yaze::emu::Spc700::Y, and yaze::emu::Spc700::Flags::Z.
|
inline |
Check if SPC has completed IPL ROM boot and is running driver code.
Definition at line 114 of file apu.h.
References rom_readable_.
|
inline |
|
inline |
Write directly to DSP register Used for direct instrument/note preview without going through driver.
Definition at line 130 of file apu.h.
References dsp_, and yaze::emu::Dsp::Write().

| std::array<uint8_t, 6> yaze::emu::Apu::in_ports_ |
Definition at line 137 of file apu.h.
Referenced by BootstrapDirect(), LoadState(), Read(), Reset(), RunCycles(), SaveState(), Write(), and yaze::emu::Snes::WriteBBus().
| std::array<uint8_t, 4> yaze::emu::Apu::out_ports_ |
Definition at line 138 of file apu.h.
Referenced by BootstrapDirect(), LoadState(), yaze::emu::Snes::ReadBBus(), Reset(), RunCycles(), SaveState(), and Write().
| std::vector<uint8_t> yaze::emu::Apu::ram = std::vector<uint8_t>(0x10000, 0) |
Definition at line 139 of file apu.h.
Referenced by BootstrapDirect(), GetControl(), GetStatus(), Init(), LoadState(), Read(), Reset(), RunCycles(), SaveState(), Write(), and WriteDma().
|
private |
Definition at line 142 of file apu.h.
Referenced by BootstrapDirect(), IsDriverRunning(), LoadState(), Read(), Reset(), RunCycles(), SaveState(), and Write().
|
private |
Definition at line 144 of file apu.h.
Referenced by LoadState(), Read(), Reset(), SaveState(), and Write().
|
private |
Definition at line 145 of file apu.h.
Referenced by Cycle(), GetCycles(), LoadState(), Reset(), RunCycles(), SaveState(), and Write().
|
private |
Definition at line 146 of file apu.h.
Referenced by Reset(), and RunCycles().
|
private |
Definition at line 149 of file apu.h.
Referenced by BootstrapDirect(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 150 of file apu.h.
Referenced by BootstrapDirect(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 152 of file apu.h.
Referenced by RunCycles().
|
private |
Definition at line 153 of file apu.h.
Referenced by Cycle(), GetTimer(), LoadState(), Read(), Reset(), SaveState(), and Write().
|
private |
Definition at line 156 of file apu.h.
Referenced by Reset(), RunCycles(), set_handshake_tracker(), and Write().
|
private |
Definition at line 163 of file apu.h.
Referenced by Cycle(), dsp(), dsp(), GetSamples(), LoadState(), Read(), Reset(), SaveState(), Write(), and WriteToDsp().
|
private |
Definition at line 164 of file apu.h.
Referenced by BootstrapDirect(), LoadState(), Reset(), RunCycles(), SaveState(), spc700(), and Write().