Rename APU to Apu

This commit is contained in:
scawful
2024-04-13 23:25:41 -05:00
parent 89cc0703f1
commit 3effd03f1f
5 changed files with 22 additions and 22 deletions

View File

@@ -14,7 +14,7 @@ namespace yaze {
namespace app {
namespace emu {
void APU::Init() {
void Apu::Init() {
// Set the clock frequency
clock_.SetFrequency(kApuClockSpeed);
@@ -27,17 +27,17 @@ void APU::Init() {
[this](int16_t sample) { this->PushToAudioBuffer(sample); });
}
void APU::Reset() {
void Apu::Reset() {
clock_.ResetAccumulatedTime();
spc700_.Reset();
dsp_.Reset();
}
void APU::Update() {
void Apu::Update() {
auto cycles_to_run = clock_.GetCycleCount();
for (auto i = 0; i < cycles_to_run; ++i) {
// Update the APU
// Update the Apu
UpdateChannelSettings();
// Update the SPC700
@@ -49,14 +49,14 @@ void APU::Update() {
ProcessSamples();
}
void APU::Notify(uint32_t address, uint8_t data) {
void Apu::Notify(uint32_t address, uint8_t data) {
if (address < 0x2140 || address > 0x2143) {
return;
}
auto offset = address - 0x2140;
spc700_.write(offset, data);
// HACK - This is a temporary solution to get the APU to play audio
// HACK - This is a temporary solution to get the Apu to play audio
ports_[address - 0x2140] = data;
switch (address) {
case 0x2140:
@@ -76,7 +76,7 @@ void APU::Notify(uint32_t address, uint8_t data) {
}
}
void APU::ProcessSamples() {
void Apu::ProcessSamples() {
// Fetch sample data from AudioRam
// Iterate over all voices
for (uint8_t voice_num = 0; voice_num < 8; voice_num++) {
@@ -91,17 +91,17 @@ void APU::ProcessSamples() {
}
}
uint8_t APU::FetchSampleForVoice(uint8_t voice_num) {
uint8_t Apu::FetchSampleForVoice(uint8_t voice_num) {
uint16_t address = CalculateAddressForVoice(voice_num);
return aram_.read(address);
}
uint16_t APU::CalculateAddressForVoice(uint8_t voice_num) {
uint16_t Apu::CalculateAddressForVoice(uint8_t voice_num) {
// TODO: Calculate the address for the specified voice
return voice_num;
}
int16_t APU::GetNextSample() {
int16_t Apu::GetNextSample() {
if (!audio_samples_.empty()) {
int16_t sample = audio_samples_.front();
audio_samples_.erase(audio_samples_.begin());
@@ -110,27 +110,27 @@ int16_t APU::GetNextSample() {
return 0; // TODO: Return the last sample instead of 0.
}
const std::vector<int16_t>& APU::GetAudioSamples() const {
const std::vector<int16_t>& Apu::GetAudioSamples() const {
return audio_samples_;
}
void APU::UpdateChannelSettings() {
void Apu::UpdateChannelSettings() {
// TODO: Implement this method to update the channel settings.
}
int16_t APU::GenerateSample(int channel) {
int16_t Apu::GenerateSample(int channel) {
// TODO: Implement this method to generate a sample for the specified channel.
}
void APU::ApplyEnvelope(int channel) {
void Apu::ApplyEnvelope(int channel) {
// TODO: Implement this method to apply an envelope to the specified channel.
}
uint8_t APU::ReadDspMemory(uint16_t address) {
uint8_t Apu::ReadDspMemory(uint16_t address) {
return dsp_.ReadGlobalReg(address);
}
void APU::WriteDspMemory(uint16_t address, uint8_t value) {
void Apu::WriteDspMemory(uint16_t address, uint8_t value) {
dsp_.WriteGlobalReg(address, value);
}

View File

@@ -37,9 +37,9 @@ const int kApuClockSpeed = 1024000; // 1.024 MHz
const int apuSampleRate = 32000; // 32 KHz
const int apuClocksPerSample = 64; // 64 clocks per sample
class APU : public Observer {
class Apu : public Observer {
public:
APU(MemoryImpl &memory, AudioRam &aram, Clock &clock)
Apu(MemoryImpl &memory, AudioRam &aram, Clock &clock)
: aram_(aram), clock_(clock), memory_(memory) {}
void Init();

View File

@@ -13,7 +13,7 @@ class Debugger {
public:
Debugger() = default;
// Attach the debugger to the emulator
// Debugger(CPU &cpu, PPU &ppu, APU &apu);
// Debugger(CPU &cpu, PPU &ppu, Apu &apu);
// Set a breakpoint
void SetBreakpoint(uint16_t address);
@@ -43,7 +43,7 @@ class Debugger {
// References to the emulator's components
// CPU &cpu;
// PPU &ppu;
// APU &apu;
// Apu &apu;
// Breakpoints, watchpoints, etc.
// ...

View File

@@ -46,7 +46,7 @@ uint16_t GetHeaderOffset(const Memory& memory) {
}
void audio_callback(void* userdata, uint8_t* stream, int len) {
auto* apu = static_cast<APU*>(userdata);
auto* apu = static_cast<Apu*>(userdata);
auto* buffer = reinterpret_cast<int16_t*>(stream);
for (int i = 0; i < len / 2; i++) { // Assuming 16-bit samples

View File

@@ -92,7 +92,7 @@ class SNES : public DMA {
CPU cpu_{memory_, clock_};
Ppu ppu_{memory_, clock_};
APU apu_{memory_, audio_ram_, clock_};
Apu apu_{memory_, audio_ram_, clock_};
// Helper classes
ROMInfo rom_info_;