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