Improve IOPort code
This commit is contained in:
@@ -26,19 +26,19 @@ namespace SPU {
|
||||
//0..3 = +7, +6, +5, +4 or -6, -7, -6, -5
|
||||
typedef uint8_t Step;
|
||||
|
||||
struct __no_align SampleRate : public IOPort<uint16_t> {
|
||||
__io_port_inherit(SampleRate);
|
||||
struct __no_align SampleRate : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(SampleRate);
|
||||
|
||||
static constexpr SampleRate from_HZ(double freq) {
|
||||
//4096 == 44100Hz
|
||||
constexpr double Base = (4096.0 / 44100.0);
|
||||
|
||||
return IOPort(static_cast<uint16_t>((freq*Base)));
|
||||
return ComplexBitMap(static_cast<uint16_t>((freq*Base)));
|
||||
}
|
||||
};
|
||||
|
||||
struct __no_align SweepVolume : public IOPort<int16_t> {
|
||||
__io_port_inherit(SweepVolume);
|
||||
struct __no_align SweepVolume : public ComplexBitMap<int16_t> {
|
||||
__io_port_inherit_complex_bit_map(SweepVolume);
|
||||
|
||||
// For Volume Mode
|
||||
static constexpr Bit<int16_t> SweepEnable = 15; // 0 Volume Mode; 1 Sweep Mode
|
||||
@@ -52,8 +52,8 @@ namespace SPU {
|
||||
static constexpr BitRange<Step> SweepStep = BitRange<Step>::from_to(0, 1);
|
||||
};
|
||||
|
||||
struct __no_align SR : public IOPort<uint16_t> {
|
||||
__io_port_inherit(SR);
|
||||
struct __no_align SR : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(SR);
|
||||
|
||||
static constexpr Bit<Mode> SustainMode = (31 - 16);
|
||||
static constexpr Bit<Direction> SustainDirection = (30 - 16);
|
||||
@@ -63,8 +63,8 @@ namespace SPU {
|
||||
static constexpr BitRange<Shift> ReleaseShift = BitRange<Shift>::from_to((16 - 16), (20 - 16));
|
||||
};
|
||||
|
||||
struct __no_align AD : public IOPort<uint16_t> {
|
||||
__io_port_inherit(AD);
|
||||
struct __no_align AD : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(AD);
|
||||
|
||||
static constexpr Bit<Mode> AttackMode = 15;
|
||||
static constexpr BitRange<Shift> AttackShift = BitRange<Shift>::from_to(10, 14);
|
||||
@@ -74,9 +74,9 @@ namespace SPU {
|
||||
};
|
||||
|
||||
struct __no_align Voice {
|
||||
SweepVolume volumeLeft; //Offset: 0x0
|
||||
SweepVolume volumeRight; //Offset: 0x2
|
||||
SampleRate sampleRate; //Offset: 0x4;
|
||||
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
|
||||
@@ -84,8 +84,8 @@ namespace SPU {
|
||||
IOPort<uint16_t> repeatAdr; //Offset: 0xE
|
||||
};
|
||||
|
||||
struct __no_align ControlRegister : public IOPort<uint16_t> {
|
||||
__io_port_inherit(ControlRegister);
|
||||
struct __no_align ControlRegister : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(ControlRegister);
|
||||
|
||||
enum RAMTransferMode {
|
||||
Stop = 0,
|
||||
@@ -107,20 +107,20 @@ namespace SPU {
|
||||
static constexpr Bit<uint16_t> CDAudioEnable = 0;
|
||||
};
|
||||
|
||||
struct __no_align PitchModFlags : public IOPort<uint16_t> {
|
||||
__io_port_inherit(PitchModFlags);
|
||||
struct __no_align PitchModFlags : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(PitchModFlags);
|
||||
|
||||
static constexpr BitRange<uint16_t> EnableBits = BitRange<uint16_t>::from_to(1, 23);
|
||||
};
|
||||
|
||||
struct __no_align NoiseGenerator : public IOPort<uint16_t> {
|
||||
__io_port_inherit(NoiseGenerator);
|
||||
struct __no_align NoiseGenerator : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(NoiseGenerator);
|
||||
|
||||
static constexpr BitRange<uint16_t> NoiseBits = BitRange<uint16_t>::from_to(0, 23);
|
||||
};
|
||||
|
||||
struct __no_align EchoOn : public IOPort<uint16_t> {
|
||||
__io_port_inherit(EchoOn);
|
||||
struct __no_align EchoOn : public ComplexBitMap<uint16_t> {
|
||||
__io_port_inherit_complex_bit_map(EchoOn);
|
||||
|
||||
static constexpr BitRange<uint16_t> EchoBits = BitRange<uint16_t>::from_to(0, 23);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user