On a better way
This commit is contained in:
parent
bde5656f38
commit
98743f7948
|
@ -11,6 +11,14 @@ namespace JabyEngine {
|
|||
Index3 = 3,
|
||||
};
|
||||
|
||||
struct CDDAVolume {
|
||||
typedef uint8_t Type;
|
||||
|
||||
static constexpr uint8_t Off = 0x0;
|
||||
static constexpr uint8_t Default = 0x80;
|
||||
static constexpr uint8_t Max = 0xFF;
|
||||
};
|
||||
|
||||
typedef struct IndexStatus : public ComplexBitMap<uint8_t> {
|
||||
static constexpr auto PortIndex = BitRange<Index>::from_to(0, 1);
|
||||
static constexpr auto HasXAFifoData = Bit<uint8_t>(2);
|
||||
|
@ -33,6 +41,21 @@ namespace JabyEngine {
|
|||
static constexpr auto WantData = Bit<uint8_t>(7);
|
||||
};
|
||||
|
||||
struct SoundMapCoding : public ComplexBitMap<uint8_t> {
|
||||
static constexpr auto Stereo = Bit<uint8_t>(0);
|
||||
static constexpr auto Mono = !Stereo;
|
||||
static constexpr auto SampleRate_18900hz = Bit<uint8_t>(2);
|
||||
static constexpr auto SampleRate_37800hz = !SampleRate_18900hz;
|
||||
static constexpr auto BitsPerSample8 = Bit<uint8_t>(4);
|
||||
static constexpr auto BitsPerSample4 = !BitsPerSample8;
|
||||
static constexpr auto Emphasis = Bit<uint8_t>(6);
|
||||
};
|
||||
|
||||
struct AudioVolumeApply : public ComplexBitMap<uint8_t> {
|
||||
static constexpr auto Mute = Bit<uint8_t>(0);
|
||||
static constexpr auto ApplyChanges = Bit<uint8_t>(5);
|
||||
};
|
||||
|
||||
struct Interrupt {
|
||||
static void enable_all(VolatileBitMapPOD<InterruptEnable>& port) {
|
||||
port.write({InterruptEnable::with(InterruptEnable::InterruptTypValue.max(), InterruptEnable::UnknownIRQ, InterruptEnable::CommandStartIRQ)});
|
||||
|
@ -47,39 +70,117 @@ namespace JabyEngine {
|
|||
}
|
||||
};
|
||||
|
||||
typedef uint8_t ResponseFifo;
|
||||
typedef uint8_t CommandFifo;
|
||||
typedef uint8_t DataFifo;
|
||||
typedef uint16_t DataFifo16;
|
||||
typedef uint8_t ParameterFifo;
|
||||
__declare_io_port_global(IndexStatus_t, IndexStatus, 0x1F801800);
|
||||
|
||||
static constexpr auto IORegister1Adr = 0x1F801801;
|
||||
static constexpr auto IORegister2Adr = 0x1F801802;
|
||||
static constexpr auto IORegister3Adr = 0x1F801803;
|
||||
|
||||
struct Index0 {
|
||||
__declare_io_port_member_const_simple(uint8_t, ResponseFifo, IORegister1Adr);
|
||||
__declare_io_port_member_simple(uint8_t, CommandFifo, IORegister1Adr);
|
||||
|
||||
__declare_io_port_member_const_simple(uint8_t, DataFifo, IORegister2Adr);
|
||||
__declare_io_port_member_const_simple(uint16_t, DataFifo16, IORegister2Adr);
|
||||
};
|
||||
|
||||
typedef VolatilePOD<uint8_t> ResponseFifo;
|
||||
typedef VolatilePOD<uint8_t> CommandFifo;
|
||||
typedef VolatilePOD<uint8_t> DataFifo;
|
||||
typedef VolatilePOD<uint16_t> DataFifo16;
|
||||
typedef VolatilePOD<uint8_t> ParameterFifo;
|
||||
typedef VolatilePOD<uint8_t> SoundMapDataOut;
|
||||
typedef VolatilePOD<CDDAVolume::Type> VolumeRegister;
|
||||
typedef VolatileBitMapPOD<InterruptEnable> InterruptEnableRegister;
|
||||
typedef VolatileBitMapPOD<InterruptFlag> InterruptFlagRegister;
|
||||
typedef VolatileBitMapPOD<Request> RequestRegister;
|
||||
typedef VolatileBitMapPOD<SoundMapCoding> SoundMapCodingInfo;
|
||||
typedef VolatileBitMapPOD<AudioVolumeApply> AudioVolumeApplyChange;
|
||||
|
||||
namespace Index0Types {
|
||||
struct __no_align IndexTriplet {
|
||||
// Replace with proper types later
|
||||
union __no_align {
|
||||
const VolatilePOD<ResponseFifo> response_fifo;
|
||||
VolatilePOD<CommandFifo> command;
|
||||
const ResponseFifo response_fifo;
|
||||
CommandFifo command;
|
||||
};
|
||||
|
||||
union __no_align {
|
||||
const VolatilePOD<DataFifo> data_fifo;
|
||||
VolatilePOD<ParameterFifo> parameter_fifo;
|
||||
const DataFifo data_fifo;
|
||||
ParameterFifo parameter_fifo;
|
||||
};
|
||||
|
||||
union __no_align {
|
||||
const VolatileBitMapPOD<InterruptEnable> irq_enable;
|
||||
VolatileBitMapPOD<Request> request;
|
||||
const InterruptEnableRegister irq_enable;
|
||||
RequestRegister request;
|
||||
};
|
||||
|
||||
const VolatilePOD<DataFifo16>& get_data_fifo_16() const {
|
||||
return *reinterpret_cast<const VolatilePOD<DataFifo16>*>(&this->data_fifo);
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(sizeof(IndexTriplet) == 3);
|
||||
}
|
||||
|
||||
__declare_io_port_global(IndexStatus_t, IndexStatus, 0x1F801800);
|
||||
namespace Index1Types {
|
||||
struct __no_align IndexTriplet {
|
||||
union __no_align {
|
||||
const ResponseFifo response_fifo;
|
||||
SoundMapDataOut sound_map_data_out;
|
||||
};
|
||||
|
||||
union __no_align {
|
||||
const DataFifo data_fifo;
|
||||
InterruptEnableRegister irq_enable;
|
||||
};
|
||||
|
||||
union __no_align {
|
||||
InterruptFlagRegister irq_flag;
|
||||
};
|
||||
};
|
||||
|
||||
static_assert(sizeof(IndexTriplet) == 3);
|
||||
}
|
||||
|
||||
namespace Index2Types {
|
||||
struct __no_align IndexTriplet {
|
||||
union __no_align {
|
||||
const ResponseFifo response_fifo;
|
||||
SoundMapCodingInfo sound_map_coding_info;
|
||||
};
|
||||
|
||||
union __no_align {
|
||||
const DataFifo data_fifo;
|
||||
VolumeRegister left_cd_2_left_spu;
|
||||
};
|
||||
|
||||
union __no_align {
|
||||
const InterruptEnableRegister irq_enable;
|
||||
VolumeRegister left_cd_2_right_spu;
|
||||
};
|
||||
};
|
||||
|
||||
static_assert(sizeof(IndexTriplet) == 3);
|
||||
}
|
||||
|
||||
namespace Index3Types {
|
||||
struct __no_align IndexTriplet {
|
||||
union __no_align {
|
||||
const ResponseFifo response_fifo;
|
||||
VolumeRegister right_cd_2_right_spu;
|
||||
};
|
||||
|
||||
union __no_align {
|
||||
const DataFifo data_fifo;
|
||||
VolumeRegister right_cd_2_left_spu;
|
||||
};
|
||||
|
||||
union __no_align {
|
||||
const InterruptFlagRegister irq_flag;
|
||||
AudioVolumeApplyChange audio_volume_change;
|
||||
};
|
||||
};
|
||||
|
||||
static_assert(sizeof(IndexTriplet) == 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace Helper {
|
||||
template<typename S>
|
||||
|
@ -92,6 +193,18 @@ namespace JabyEngine {
|
|||
static Index0Types::IndexTriplet& change_to_index0() {
|
||||
return Helper::change_to<Index0Types::IndexTriplet>(Index::Index0);
|
||||
}
|
||||
|
||||
static Index1Types::IndexTriplet& change_to_index1() {
|
||||
return Helper::change_to<Index1Types::IndexTriplet>(Index::Index1);
|
||||
}
|
||||
|
||||
static Index2Types::IndexTriplet& change_to_index2() {
|
||||
return Helper::change_to<Index2Types::IndexTriplet>(Index::Index2);
|
||||
}
|
||||
|
||||
static Index3Types::IndexTriplet& change_to_index3() {
|
||||
return Helper::change_to<Index3Types::IndexTriplet>(Index::Index2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,12 @@ namespace JabyEngine {
|
|||
namespace boot {
|
||||
namespace CD {
|
||||
void setup() {
|
||||
CD_IO::change_to_index0();
|
||||
|
||||
}
|
||||
|
||||
uint16_t miau() {
|
||||
CD_IO::Index0::DataFifo.read();
|
||||
return CD_IO::Index0::DataFifo16.read();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue