88 lines
4.4 KiB
C++
88 lines
4.4 KiB
C++
#pragma once
|
|
#include "IOValues/spu_io_values.hpp"
|
|
#include <limits.hpp>
|
|
|
|
namespace JabyEngine {
|
|
namespace SPU_IO {
|
|
using namespace SPU_IO_Values;
|
|
|
|
static constexpr size_t VoiceCount = 24;
|
|
static constexpr size_t ReverbCount = 1;
|
|
|
|
struct ControlRegisterIO : public IOPort<SPU_IO_Values::ControlRegister> {
|
|
using TransferMode = Value::RAMTransferMode;
|
|
|
|
void set_transfer_mode(TransferMode mode) {
|
|
this->write(this->read().set(ControlRegister::TransferMode.with(mode)));
|
|
while(this->read().get(ControlRegister::TransferMode) != mode);
|
|
}
|
|
};
|
|
|
|
using ADIO = IOPort<SPU_IO_Values::AD>;
|
|
using DataTransferControlIO = IOPort<SPU_IO_Values::DataTransferControl>;
|
|
using EchoIO = IOPort32<SPU_IO_Values::Echo>;
|
|
using KeyOffIO = IOPort32<SPU_IO_Values::KeyOff>;
|
|
using KeyOnIO = IOPort32<SPU_IO_Values::KeyOn>;
|
|
using KeyStatusIO = IOPort32<SPU_IO_Values::KeyStatus>;
|
|
using NoiseIO = IOPort<SPU_IO_Values::Noise>;
|
|
using PitchModulationIO = IOPort32<SPU_IO_Values::PitchModulation>;
|
|
using SampleRateIO = IOPort<SPU_IO_Values::SampleRate>;
|
|
using SimpleVolumeIO = IOPort<SPU_IO_Values::SimpleVolume>;
|
|
using StatusRegisterIO = IOPort<SPU_IO_Values::StatusRegister>;
|
|
using SRIO = IOPort<SPU_IO_Values::SR>;
|
|
using SRAMAdrIO = IOPort<SPU_IO_Values::SRAMAdr>;
|
|
using SweepVolumeIO = IOPort<SweepVolume>;
|
|
|
|
#pragma pack(push, 1)
|
|
struct Voice {
|
|
SweepVolumeIO volumeLeft; //Offset: 0x0
|
|
SweepVolumeIO volumeRight; //Offset: 0x2
|
|
SampleRateIO sampleRate; //Offset: 0x4;
|
|
SRAMAdrIO adr; //Offset: 0x6
|
|
ADIO ad; //Offset: 0x8
|
|
SRIO sr; //Offset: 0xA
|
|
SimpleVolumeIO currentVolume; //Offset: 0xC
|
|
SRAMAdrIO repeatAdr; //Offset: 0xE
|
|
};
|
|
#pragma pack(pop)
|
|
|
|
static auto& Voice = __new_declare_io_port_array(struct Voice, VoiceCount, 0x1F801C00);
|
|
static auto& PMON = __new_declare_io_port(PitchModulationIO, 0x1F801D90);
|
|
static auto& NON = __new_declare_io_port(NoiseIO, 0x1F801D94);
|
|
static auto& EON = __new_declare_io_port(EchoIO, 0x1F801D98);
|
|
static auto& SRAMTransferAdr = __new_declare_io_port(SRAMAdrIO, 0x1F801DA6);
|
|
static auto& ControlRegister = __new_declare_io_port(ControlRegisterIO, 0x1F801DAA);
|
|
static auto& DataTransferControl = __new_declare_io_port(DataTransferControlIO, 0x1F801DAC);
|
|
static auto& StatusRegister = __new_declare_io_port(StatusRegisterIO, 0x1F801DAE);
|
|
|
|
struct CDVolume {
|
|
static inline auto& Left = __new_declare_io_port(SimpleVolumeIO, 0x1F801DB0);
|
|
static inline auto& Right = __new_declare_io_port(SimpleVolumeIO, 0x1F801DB2);
|
|
};
|
|
|
|
struct ExternalAudioInputVolume {
|
|
static inline auto& Left = __new_declare_io_port(SimpleVolumeIO, 0x1F801DB4);
|
|
static inline auto& Right = __new_declare_io_port(SimpleVolumeIO, 0x1F801DB6);
|
|
};
|
|
|
|
struct Key {
|
|
static inline auto& On = __new_declare_io_port(KeyOnIO, 0x1F801D88);
|
|
static inline auto& Off = __new_declare_io_port(KeyOffIO, 0x1F801D8C);
|
|
static inline auto& Status = __new_declare_io_port(KeyStatusIO, 0x1F801D9C);
|
|
};
|
|
|
|
struct MainVolume {
|
|
static inline auto& Left = __new_declare_io_port(SweepVolumeIO, 0x1F801D80);
|
|
static inline auto& Right = __new_declare_io_port(SweepVolumeIO, 0x1F801D82);
|
|
};
|
|
|
|
struct Reverb {
|
|
struct Volume {
|
|
static inline auto& Left = __new_declare_io_port(SimpleVolumeIO, 0x1F801D84);
|
|
static inline auto& Right = __new_declare_io_port(SimpleVolumeIO, 0x1F801D86);
|
|
};
|
|
static inline auto& On = EON;
|
|
static inline auto& WorkAreaAdr = __new_declare_io_port(SRAMAdrIO, 0x1F801DA2);
|
|
};
|
|
}
|
|
} |