Re-Update SPU IO
This commit is contained in:
parent
e6c17e8f6f
commit
5ff7e0db9f
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace SPU {
|
namespace SPU {
|
||||||
using SPU_IO::operator""_vol;
|
using SPU_IO_Values::operator""_vol;
|
||||||
|
|
||||||
using SRAMAdr = SPU_IO::SRAMAdr;
|
using SRAMAdr = SPU_IO_Values::SRAMAdr;
|
||||||
using SimpleVolume = SPU_IO::SimpleVolume;
|
using SimpleVolume = SPU_IO_Values::SimpleVolume;
|
||||||
using SweepVolume = SPU_IO::SweepVolume;
|
using SweepVolume = SPU_IO_Values::SweepVolume;
|
||||||
|
|
||||||
struct Voice {
|
struct Voice {
|
||||||
size_t get_id() const {
|
size_t get_id() const {
|
||||||
|
@ -15,10 +15,10 @@ namespace JabyEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
SRAMAdr allocate(size_t size);
|
SRAMAdr allocate(size_t size);
|
||||||
SRAMAdr allocate(SPU_IO::SampleRate frequency, size_t size);
|
SRAMAdr allocate(SPU_IO_Values::SampleRate frequency, size_t size);
|
||||||
void deallocate();
|
void deallocate();
|
||||||
|
|
||||||
void set_sample_rate(SPU_IO::SampleRate frequency) {
|
void set_sample_rate(SPU_IO_Values::SampleRate frequency) {
|
||||||
SPU_IO::Voice[Voice::get_id()].sampleRate.write(frequency);
|
SPU_IO::Voice[Voice::get_id()].sampleRate.write(frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace JabyEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
void play() {
|
void play() {
|
||||||
SPU_IO::Key::On.write(SPU_IO::KeyOn::for_specific(Voice::get_id()));
|
SPU_IO::Key::On.write(SPU_IO_Values::KeyOn::for_specific(Voice::get_id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void play_if_end() {
|
void play_if_end() {
|
||||||
|
@ -38,7 +38,7 @@ namespace JabyEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop() {
|
void stop() {
|
||||||
SPU_IO::Key::Off.write(SPU_IO::KeyOff::for_specific(Voice::get_id()));
|
SPU_IO::Key::Off.write(SPU_IO_Values::KeyOff::for_specific(Voice::get_id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_end() const {
|
bool is_end() const {
|
||||||
|
|
|
@ -4,34 +4,34 @@
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace SPU_IO {
|
namespace SPU_IO {
|
||||||
using namespace SPU_IO_Values;
|
namespace Value = SPU_IO_Values;
|
||||||
|
|
||||||
static constexpr size_t VoiceCount = 24;
|
static constexpr size_t VoiceCount = 24;
|
||||||
static constexpr size_t ReverbCount = 1;
|
static constexpr size_t ReverbCount = 1;
|
||||||
|
|
||||||
struct ControlRegisterIO : public IOPort<SPU_IO_Values::ControlRegister> {
|
struct ControlRegisterIO : public IOPort<Value::ControlRegister> {
|
||||||
using TransferMode = Value::RAMTransferMode;
|
using TransferMode = Value::RAMTransferMode;
|
||||||
|
|
||||||
void set_transfer_mode(TransferMode mode) {
|
void set_transfer_mode(TransferMode mode) {
|
||||||
this->write(this->read().set(ControlRegister::TransferMode.with(mode)));
|
this->write(this->read().set(Value::ControlRegister::TransferMode.with(mode)));
|
||||||
while(this->read().get(ControlRegister::TransferMode) != mode);
|
while(this->read().get(Value::ControlRegister::TransferMode) != mode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using ADIO = IOPort<SPU_IO_Values::AD>;
|
using ADIO = IOPort<Value::AD>;
|
||||||
using DataTransferControlIO = IOPort<SPU_IO_Values::DataTransferControl>;
|
using DataTransferControlIO = IOPort<Value::DataTransferControl>;
|
||||||
using EchoIO = IOPort32<SPU_IO_Values::Echo>;
|
using EchoIO = IOPort32<Value::Echo>;
|
||||||
using KeyOffIO = IOPort32<SPU_IO_Values::KeyOff>;
|
using KeyOffIO = IOPort32<Value::KeyOff>;
|
||||||
using KeyOnIO = IOPort32<SPU_IO_Values::KeyOn>;
|
using KeyOnIO = IOPort32<Value::KeyOn>;
|
||||||
using KeyStatusIO = IOPort32<SPU_IO_Values::KeyStatus>;
|
using KeyStatusIO = IOPort32<Value::KeyStatus>;
|
||||||
using NoiseIO = IOPort<SPU_IO_Values::Noise>;
|
using NoiseIO = IOPort<Value::Noise>;
|
||||||
using PitchModulationIO = IOPort32<SPU_IO_Values::PitchModulation>;
|
using PitchModulationIO = IOPort32<Value::PitchModulation>;
|
||||||
using SampleRateIO = IOPort<SPU_IO_Values::SampleRate>;
|
using SampleRateIO = IOPort<Value::SampleRate>;
|
||||||
using SimpleVolumeIO = IOPort<SPU_IO_Values::SimpleVolume>;
|
using SimpleVolumeIO = IOPort<Value::SimpleVolume>;
|
||||||
using StatusRegisterIO = IOPort<SPU_IO_Values::StatusRegister>;
|
using StatusRegisterIO = IOPort<Value::StatusRegister>;
|
||||||
using SRIO = IOPort<SPU_IO_Values::SR>;
|
using SRIO = IOPort<Value::SR>;
|
||||||
using SRAMAdrIO = IOPort<SPU_IO_Values::SRAMAdr>;
|
using SRAMAdrIO = IOPort<Value::SRAMAdr>;
|
||||||
using SweepVolumeIO = IOPort<SweepVolume>;
|
using SweepVolumeIO = IOPort<Value::SweepVolume>;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
struct Voice {
|
struct Voice {
|
||||||
|
|
|
@ -12,14 +12,14 @@ namespace JabyEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void end() {
|
static void end() {
|
||||||
SPU_IO::ControlRegister.set_transfer_mode(SPU_IO::ControlRegister::Stop);
|
SPU_IO::ControlRegister.set_transfer_mode(SPU_IO_Values::ControlRegister::Stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Receive {
|
struct Receive {
|
||||||
static void prepare() {
|
static void prepare() {
|
||||||
end();
|
end();
|
||||||
SPU_IO::DataTransferControl.write(SPU_IO::DataTransferControl::NormalTransferMode());
|
SPU_IO::DataTransferControl.write(SPU_IO_Values::DataTransferControl::NormalTransferMode());
|
||||||
SPU_IO::ControlRegister.set_transfer_mode(SPU_IO::ControlRegister::Stop);
|
SPU_IO::ControlRegister.set_transfer_mode(SPU_IO_Values::ControlRegister::Stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_src(uintptr_t adr) {
|
static void set_src(uintptr_t adr) {
|
||||||
|
@ -28,7 +28,7 @@ namespace JabyEngine {
|
||||||
|
|
||||||
static void set_dst(SPU::SRAMAdr adr) {
|
static void set_dst(SPU::SRAMAdr adr) {
|
||||||
SPU_IO::SRAMTransferAdr.write(adr);
|
SPU_IO::SRAMTransferAdr.write(adr);
|
||||||
SPU_IO::ControlRegister.set_transfer_mode(SPU_IO::ControlRegister::DMAWrite);
|
SPU_IO::ControlRegister.set_transfer_mode(SPU_IO_Values::ControlRegister::DMAWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void start(uint16_t blockCount, uint16_t wordsPerBlock = 0x10) {
|
static void start(uint16_t blockCount, uint16_t wordsPerBlock = 0x10) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace JabyEngine {
|
||||||
namespace SPU {
|
namespace SPU {
|
||||||
using namespace JabyEngine;
|
using namespace JabyEngine;
|
||||||
using namespace SPU_IO;
|
using namespace SPU_IO;
|
||||||
|
using namespace SPU_IO_Values;
|
||||||
|
|
||||||
static void clear_main_volume() {
|
static void clear_main_volume() {
|
||||||
static constexpr auto StartVol = SweepVolume::from(SweepVolume::VolumeMode::Enable, SweepVolume::VolumeMode::Volume.with(SweepVolume::VolumeMode::MaxVolume >> 1));
|
static constexpr auto StartVol = SweepVolume::from(SweepVolume::VolumeMode::Enable, SweepVolume::VolumeMode::Volume.with(SweepVolume::VolumeMode::MaxVolume >> 1));
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace JabyEngine {
|
||||||
|
|
||||||
static void test_spu_alloc() {
|
static void test_spu_alloc() {
|
||||||
static const auto calculate_spu_adr = [](size_t size) -> const uint8_t* {
|
static const auto calculate_spu_adr = [](size_t size) -> const uint8_t* {
|
||||||
return reinterpret_cast<const uint8_t*>(SPU_IO::MemoryMap::ADPCM + size);
|
return reinterpret_cast<const uint8_t*>(SPU_IO_Values::MemoryMap::ADPCM + size);
|
||||||
};
|
};
|
||||||
static const auto simple_assert = [](uint32_t test_id, const uint8_t* adr, const uint8_t* expected) {
|
static const auto simple_assert = [](uint32_t test_id, const uint8_t* adr, const uint8_t* expected) {
|
||||||
static const char* ok_text = "Test %i: 0x%p == 0x%p; OK\n";
|
static const char* ok_text = "Test %i: 0x%p == 0x%p; OK\n";
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace JabyEngine {
|
||||||
|
|
||||||
state.words_left = words;
|
state.words_left = words;
|
||||||
|
|
||||||
auto sram_adr = SPU::voice[state.voice_id].allocate(SPU_IO::SampleRate::from_HZ(header.get_sample_frequency()), bytes);
|
auto sram_adr = SPU::voice[state.voice_id].allocate(SPU_IO_Values::SampleRate::from_HZ(header.get_sample_frequency()), bytes);
|
||||||
|
|
||||||
SPU::voice[state.voice_id].set_volume(state.inital_vol, state.inital_vol);
|
SPU::voice[state.voice_id].set_volume(state.inital_vol, state.inital_vol);
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace JabyEngine {
|
||||||
return adr;
|
return adr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRAMAdr Voice :: allocate(SPU_IO::SampleRate frequency, size_t size) {
|
SRAMAdr Voice :: allocate(SPU_IO_Values::SampleRate frequency, size_t size) {
|
||||||
const auto result = Voice::allocate(size);
|
const auto result = Voice::allocate(size);
|
||||||
Voice::set_sample_rate(frequency);
|
Voice::set_sample_rate(frequency);
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace SPU_MMU {
|
namespace SPU_MMU {
|
||||||
namespace SPU_MemoryMap = SPU_IO::MemoryMap;
|
namespace SPU_MemoryMap = SPU_IO_Values::MemoryMap;
|
||||||
|
|
||||||
struct SPUMemory {
|
struct SPUMemory {
|
||||||
const uint8_t* adr;
|
const uint8_t* adr;
|
||||||
|
|
Loading…
Reference in New Issue