Converted SPU IO
This commit is contained in:
@@ -6,65 +6,66 @@ namespace JabyEngine {
|
||||
namespace boot {
|
||||
namespace SPU {
|
||||
using namespace JabyEngine;
|
||||
using namespace SPU_IO;
|
||||
|
||||
static void clear_main_volume() {
|
||||
static constexpr auto StartVol = SPU_IO::SweepVolume::with(SPU_IO::SweepVolume::VolumeEnable, SPU_IO::SweepVolume::Volume.with(I16_MAX >> 2));
|
||||
static constexpr auto StartVol = SweepVolume_t::from(SweepVolume_t::VolumeEnable, SweepVolume_t::Volume.with(static_cast<int16_t>(I16_MAX >> 2)));
|
||||
|
||||
SPU_IO::MainVolume::Left.write({StartVol});
|
||||
SPU_IO::MainVolume::Right.write({StartVol});
|
||||
MainVolume::Left = *StartVol;
|
||||
MainVolume::Right = *StartVol;
|
||||
}
|
||||
|
||||
static void clear_cd_and_ext_audio_volume() {
|
||||
SPU_IO::CDVolume::Left.write(0);
|
||||
SPU_IO::CDVolume::Right.write(0);
|
||||
CDVolume::Left = 0;
|
||||
CDVolume::Right = 0;
|
||||
|
||||
SPU_IO::ExternalAudioInputVolume::Left.write(0);
|
||||
SPU_IO::ExternalAudioInputVolume::Right.write(0);
|
||||
ExternalAudioInputVolume::Left = 0;
|
||||
ExternalAudioInputVolume::Right = 0;
|
||||
}
|
||||
|
||||
static void clear_control_register() {
|
||||
SPU_IO::Control.write(SPU_IO::ControlRegister());
|
||||
ControlRegister = 0;
|
||||
}
|
||||
|
||||
static void clear_voice() {
|
||||
for(auto& voice : SPU_IO::Voice) {
|
||||
voice.volumeLeft.write(SPU_IO::SweepVolume());
|
||||
voice.volumeRight.write(SPU_IO::SweepVolume());
|
||||
voice.sampleRate.write(SPU_IO::SampleRate());
|
||||
voice.ad.write(SPU_IO::AD());
|
||||
voice.sr.write(SPU_IO::SR());
|
||||
voice.currentVolume.write(SPU_IO::SimpleVolume(0));
|
||||
voice.volumeLeft = *SweepVolume_t();
|
||||
voice.volumeRight = *SweepVolume_t();
|
||||
voice.sampleRate = *SampleRate_t();
|
||||
voice.ad = *AD_t();
|
||||
voice.sr = *SR_t();
|
||||
voice.currentVolume = 0;
|
||||
|
||||
voice.adr.write(0x200);
|
||||
voice.repeatAdr.write(0x200);
|
||||
voice.adr = 0x200;
|
||||
voice.repeatAdr = 0x200;
|
||||
}
|
||||
}
|
||||
|
||||
static void clear_pmon() {
|
||||
SPU_IO::PMON.write(SPU_IO::PitchModFlags());
|
||||
SPU_IO::PMON = *PMON_t();
|
||||
}
|
||||
|
||||
static void clear_noise_and_echo() {
|
||||
SPU_IO::NON.write(SPU_IO::NoiseGenerator());
|
||||
SPU_IO::EON.write(SPU_IO::EchoOn());
|
||||
SPU_IO::NON = *NON_t();
|
||||
SPU_IO::EON = *EON_t();
|
||||
}
|
||||
|
||||
static void clear_reverb() {
|
||||
SPU_IO::Reverb::Volume::Left.write(0);
|
||||
SPU_IO::Reverb::Volume::Right.write(0);
|
||||
SPU_IO::Reverb::WorkAreaAdr.write(0);
|
||||
Reverb::Volume::Left = 0;
|
||||
Reverb::Volume::Right = 0;
|
||||
Reverb::WorkAreaAdr = 0;
|
||||
}
|
||||
|
||||
static void setup_control_register() {
|
||||
static constexpr auto SetupValue = SPU_IO::ControlRegister::with(SPU_IO::ControlRegister::Enable, SPU_IO::ControlRegister::Unmute, SPU_IO::ControlRegister::CDAudioEnable);
|
||||
static constexpr auto SetupValue = ControlRegister_t::from(ControlRegister_t::Enable, ControlRegister_t::Unmute, ControlRegister_t::CDAudioEnable);
|
||||
|
||||
SPU_IO::Control.write({SetupValue});
|
||||
SPU_IO::ControlRegister = *SetupValue;
|
||||
}
|
||||
|
||||
static void setup_data_transfer_control() {
|
||||
static constexpr uint16_t RequiredValue = (2 << 1);
|
||||
|
||||
SPU_IO::DataTransferControl.write(RequiredValue);
|
||||
DataTransferControl = RequiredValue;
|
||||
}
|
||||
|
||||
static void wait_voices() {
|
||||
@@ -72,7 +73,7 @@ namespace JabyEngine {
|
||||
|
||||
try_again:
|
||||
for(const auto& voice : SPU_IO::Voice) {
|
||||
if(voice.currentVolume.read() > Treshhold) {
|
||||
if(voice.currentVolume > Treshhold) {
|
||||
goto try_again;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user