cleanup spc700 and add todos
This commit is contained in:
@@ -28,11 +28,9 @@ void APU::Init() {
|
||||
}
|
||||
|
||||
void APU::Reset() {
|
||||
// Reset the clock
|
||||
clock_.ResetAccumulatedTime();
|
||||
|
||||
// Reset the SPC700
|
||||
// ...
|
||||
spc700_.Reset();
|
||||
dsp_.Reset();
|
||||
}
|
||||
|
||||
void APU::Update() {
|
||||
@@ -51,6 +49,33 @@ void APU::Update() {
|
||||
ProcessSamples();
|
||||
}
|
||||
|
||||
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
|
||||
ports_[address - 0x2140] = data;
|
||||
switch (address) {
|
||||
case 0x2140:
|
||||
if (data == BEGIN_SIGNAL) {
|
||||
SignalReady();
|
||||
}
|
||||
break;
|
||||
case 0x2141:
|
||||
// TODO: Handle data byte transfer here
|
||||
break;
|
||||
case 0x2142:
|
||||
// TODO: Handle the setup of destination address
|
||||
break;
|
||||
case 0x2143:
|
||||
// TODO: Handle additional communication/commands
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void APU::ProcessSamples() {
|
||||
// Fetch sample data from AudioRam
|
||||
// Iterate over all voices
|
||||
@@ -62,63 +87,51 @@ void APU::ProcessSamples() {
|
||||
int16_t processed_sample = dsp_.ProcessSample(voice_num, sample);
|
||||
|
||||
// Add the processed sample to the audio buffer
|
||||
audioSamples_.push_back(processed_sample);
|
||||
audio_samples_.push_back(processed_sample);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t APU::FetchSampleForVoice(uint8_t voice_num) {
|
||||
// Define how you determine the address based on the voice_num
|
||||
uint16_t address = CalculateAddressForVoice(voice_num);
|
||||
return aram_.read(address);
|
||||
}
|
||||
|
||||
uint16_t APU::CalculateAddressForVoice(uint8_t voice_num) {
|
||||
// Placeholder logic to calculate the address in the AudioRam
|
||||
// based on the voice number.
|
||||
return voice_num; // Assuming each voice has a fixed size
|
||||
// TODO: Calculate the address for the specified voice
|
||||
return voice_num;
|
||||
}
|
||||
|
||||
int16_t APU::GetNextSample() {
|
||||
// This method fetches the next sample. If there's no sample available, it can
|
||||
// return 0 or the last sample.
|
||||
if (!audioSamples_.empty()) {
|
||||
int16_t sample = audioSamples_.front();
|
||||
audioSamples_.erase(audioSamples_.begin());
|
||||
if (!audio_samples_.empty()) {
|
||||
int16_t sample = audio_samples_.front();
|
||||
audio_samples_.erase(audio_samples_.begin());
|
||||
return sample;
|
||||
}
|
||||
return 0; // or return the last sample
|
||||
}
|
||||
|
||||
uint8_t APU::ReadRegister(uint16_t address) {
|
||||
// ...
|
||||
}
|
||||
|
||||
void APU::WriteRegister(uint16_t address, uint8_t value) {
|
||||
// ...
|
||||
return 0; // TODO: Return the last sample instead of 0.
|
||||
}
|
||||
|
||||
const std::vector<int16_t>& APU::GetAudioSamples() const {
|
||||
// ...
|
||||
return audio_samples_;
|
||||
}
|
||||
|
||||
void APU::UpdateChannelSettings() {
|
||||
// ...
|
||||
// TODO: Implement this method to update the channel settings.
|
||||
}
|
||||
|
||||
int16_t APU::GenerateSample(int channel) {
|
||||
// ...
|
||||
// TODO: Implement this method to generate a sample for the specified 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);
|
||||
}
|
||||
|
||||
} // namespace emu
|
||||
|
||||
Reference in New Issue
Block a user