Add new IOPort design
This commit is contained in:
@@ -27,20 +27,16 @@ namespace JabyEngine {
|
||||
|
||||
typedef int16_t SimpleVolume;
|
||||
|
||||
struct __no_align SampleRate : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(SampleRate);
|
||||
|
||||
struct SampleRate : public ComplexBitMap<uint16_t> {
|
||||
static constexpr SampleRate from_HZ(double freq) {
|
||||
//4096 == 44100Hz
|
||||
constexpr double Base = (4096.0 / 44100.0);
|
||||
|
||||
return ComplexBitMap<uint16_t>{static_cast<uint16_t>((freq*Base))};
|
||||
return {static_cast<uint16_t>((freq*Base))};
|
||||
}
|
||||
};
|
||||
|
||||
struct __no_align SweepVolume : public ComplexBitMap<int16_t> {
|
||||
__io_port_inherit_complex_bit_map(SweepVolume);
|
||||
|
||||
struct SweepVolume : public ComplexBitMap<int16_t> {
|
||||
// For Volume Mode
|
||||
static constexpr auto SweepEnable = Bit<int16_t>(15);
|
||||
static constexpr auto VolumeEnable = !SweepEnable;
|
||||
@@ -54,9 +50,7 @@ namespace JabyEngine {
|
||||
static constexpr auto SweepStep = BitRange<Step>::from_to(0, 1);
|
||||
};
|
||||
|
||||
struct __no_align SR : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(SR);
|
||||
|
||||
struct SR : public ComplexBitMap<uint16_t> {
|
||||
static constexpr auto SustainMode = Bit<Mode>(31 - 16);
|
||||
static constexpr auto SustainDirection = Bit<Direction>(30 - 16);
|
||||
static constexpr auto SustainShift = BitRange<Shift>::from_to((24 - 16), (28 - 16));
|
||||
@@ -65,9 +59,7 @@ namespace JabyEngine {
|
||||
static constexpr auto ReleaseShift = BitRange<Shift>::from_to((16 - 16), (20 - 16));
|
||||
};
|
||||
|
||||
struct __no_align AD : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(AD);
|
||||
|
||||
struct AD : public ComplexBitMap<uint16_t> {
|
||||
static constexpr auto AttackMode = Bit<Mode>(15);
|
||||
static constexpr auto AttackShift = BitRange<Shift>::from_to(10, 14);
|
||||
static constexpr auto AttackStep = BitRange<Step>::from_to(8, 9);
|
||||
@@ -76,19 +68,17 @@ namespace JabyEngine {
|
||||
};
|
||||
|
||||
struct __no_align Voice {
|
||||
IOPort<SweepVolume> volumeLeft; //Offset: 0x0
|
||||
IOPort<SweepVolume> volumeRight; //Offset: 0x2
|
||||
IOPort<SampleRate> sampleRate; //Offset: 0x4;
|
||||
IOPort<uint16_t> adr; //Offset: 0x6
|
||||
IOPort<AD> ad; //Offset: 0x8
|
||||
IOPort<SR> sr; //Offset: 0xA
|
||||
IOPort<SimpleVolume> currentVolume; //Offset: 0xC
|
||||
IOPort<uint16_t> repeatAdr; //Offset: 0xE
|
||||
IOPort<SweepVolume::UnderlyingType, SweepVolume> volumeLeft; //Offset: 0x0
|
||||
IOPort<SweepVolume::UnderlyingType, SweepVolume> volumeRight; //Offset: 0x2
|
||||
IOPort<SampleRate::UnderlyingType, SampleRate> sampleRate; //Offset: 0x4;
|
||||
IOPort<uint16_t, uint16_t> adr; //Offset: 0x6
|
||||
IOPort<AD::UnderlyingType, AD> ad; //Offset: 0x8
|
||||
IOPort<SR::UnderlyingType, SR> sr; //Offset: 0xA
|
||||
IOPort<SimpleVolume, SimpleVolume> currentVolume; //Offset: 0xC
|
||||
IOPort<uint16_t, uint16_t> repeatAdr; //Offset: 0xE
|
||||
};
|
||||
|
||||
struct __no_align ControlRegister : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(ControlRegister);
|
||||
|
||||
struct ControlRegister : public ComplexBitMap<uint16_t> {
|
||||
enum RAMTransferMode {
|
||||
Stop = 0,
|
||||
ManualWrite = 1,
|
||||
@@ -109,30 +99,24 @@ namespace JabyEngine {
|
||||
static constexpr auto CDAudioEnable = Bit<uint16_t>(0);
|
||||
};
|
||||
|
||||
struct __no_align PitchModFlags : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(PitchModFlags);
|
||||
|
||||
struct PitchModFlags : public ComplexBitMap<uint16_t> {
|
||||
static constexpr BitRange<uint16_t> EnableBits = BitRange<uint16_t>::from_to(1, 23);
|
||||
};
|
||||
|
||||
struct __no_align NoiseGenerator : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(NoiseGenerator);
|
||||
|
||||
struct NoiseGenerator : public ComplexBitMap<uint16_t> {
|
||||
static constexpr BitRange<uint16_t> NoiseBits = BitRange<uint16_t>::from_to(0, 23);
|
||||
};
|
||||
|
||||
struct __no_align EchoOn : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(EchoOn);
|
||||
|
||||
struct EchoOn : public ComplexBitMap<uint16_t> {
|
||||
static constexpr BitRange<uint16_t> EchoBits = BitRange<uint16_t>::from_to(0, 23);
|
||||
};
|
||||
|
||||
static constexpr size_t VoiceCount = 24;
|
||||
|
||||
struct Key {
|
||||
__declare_io_port_member(ubus32_t, On, 0x1F801D88);
|
||||
__declare_io_port_member(ubus32_t, Off, 0x1F801D8C);
|
||||
__declare_io_port_member(ubus32_t, Status, 0x1F801D9C);
|
||||
__declare_global_raw(inline, ubus32_t, On, 0x1F801D88);
|
||||
__declare_global_raw(inline, ubus32_t, Off, 0x1F801D8C);
|
||||
__declare_global_raw(inline, ubus32_t, Status, 0x1F801D9C);
|
||||
};
|
||||
|
||||
struct MainVolume {
|
||||
@@ -141,28 +125,28 @@ namespace JabyEngine {
|
||||
};
|
||||
|
||||
struct CDVolume {
|
||||
__declare_io_port_member(SimpleVolume, Left, 0x1F801DB0);
|
||||
__declare_io_port_member(SimpleVolume, Right, 0x1F801DB2);
|
||||
__declare_io_port_member_simple(SimpleVolume, Left, 0x1F801DB0);
|
||||
__declare_io_port_member_simple(SimpleVolume, Right, 0x1F801DB2);
|
||||
};
|
||||
|
||||
struct ExternalAudioInputVolume {
|
||||
__declare_io_port_member(SimpleVolume, Left, 0x1F801DB4);
|
||||
__declare_io_port_member(SimpleVolume, Right, 0x1F801DB6);
|
||||
__declare_io_port_member_simple(SimpleVolume, Left, 0x1F801DB4);
|
||||
__declare_io_port_member_simple(SimpleVolume, Right, 0x1F801DB6);
|
||||
};
|
||||
|
||||
struct Reverb {
|
||||
struct Volume {
|
||||
__declare_io_port_member(SimpleVolume, Left, 0x1F801D84);
|
||||
__declare_io_port_member(SimpleVolume, Right, 0x1F801D86);
|
||||
__declare_io_port_member_simple(SimpleVolume, Left, 0x1F801D84);
|
||||
__declare_io_port_member_simple(SimpleVolume, Right, 0x1F801D86);
|
||||
};
|
||||
__declare_io_port_member(uint16_t, WorkAreaAdr, 0x1F801DA2);
|
||||
__declare_io_port_member_simple(uint16_t, WorkAreaAdr, 0x1F801DA2);
|
||||
};
|
||||
|
||||
__declare_io_port_global(ControlRegister, Control, 0x1F801DAA);
|
||||
__declare_io_port_global(uint16_t, DataTransferControl, 0x1F801DAC);
|
||||
__declare_io_port_global(PitchModFlags, PMON, 0x1F801D90);
|
||||
__declare_io_port_global(NoiseGenerator, NON, 0x1F801D94);
|
||||
__declare_io_port_global(EchoOn, EON, 0x1F801D98);
|
||||
__declare_io_port_global(ControlRegister, Control, 0x1F801DAA);
|
||||
__declare_io_port_global_simple(uint16_t, DataTransferControl, 0x1F801DAC);
|
||||
__declare_io_port_global(PitchModFlags, PMON, 0x1F801D90);
|
||||
__declare_io_port_global(NoiseGenerator, NON, 0x1F801D94);
|
||||
__declare_io_port_global(EchoOn, EON, 0x1F801D98);
|
||||
|
||||
__declare_io_port_global_array(struct Voice, Voice, 0x1F801C00, VoiceCount);
|
||||
}
|
||||
|
Reference in New Issue
Block a user