Remove the ComplexBitMap
This commit is contained in:
@@ -32,41 +32,41 @@ namespace JabyEngine {
|
||||
};
|
||||
|
||||
__declare_io_type(IndexStatus, uint8_t,
|
||||
static constexpr auto PortIndex = IOValueSet::from_to(0, 1);
|
||||
static constexpr auto HasXAFifoData = IOBitSet(2);
|
||||
static constexpr auto IsParameterFifoEmpty = IOBitSet(3);
|
||||
static constexpr auto HasParameterFifoSpace = IOBitSet(4);
|
||||
static constexpr auto HasResponseFifoData = IOBitSet(5);
|
||||
static constexpr auto HasDataFifoData = IOBitSet(6);
|
||||
static constexpr auto IsTransmissionBusy = IOBitSet(7);
|
||||
static constexpr auto PortIndex = BitRange::from_to(0, 1);
|
||||
static constexpr auto HasXAFifoData = Bit(2);
|
||||
static constexpr auto IsParameterFifoEmpty = Bit(3);
|
||||
static constexpr auto HasParameterFifoSpace = Bit(4);
|
||||
static constexpr auto HasResponseFifoData = Bit(5);
|
||||
static constexpr auto HasDataFifoData = Bit(6);
|
||||
static constexpr auto IsTransmissionBusy = Bit(7);
|
||||
);
|
||||
|
||||
__declare_io_type(InterruptEnable, uint8_t,
|
||||
static constexpr auto InterruptTypValue = IOValueSet::from_to(0, 2);
|
||||
static constexpr auto InterruptExtended = IOValueSet::from_to(0, 4);
|
||||
static constexpr auto UnknownIRQ = IOBitSet(3);
|
||||
static constexpr auto CommandStartIRQ = IOBitSet(4);
|
||||
static constexpr auto InterruptTypValue = BitRange::from_to(0, 2);
|
||||
static constexpr auto InterruptExtended = BitRange::from_to(0, 4);
|
||||
static constexpr auto UnknownIRQ = Bit(3);
|
||||
static constexpr auto CommandStartIRQ = Bit(4);
|
||||
);
|
||||
typedef InterruptEnable_v InterruptFlag_v;
|
||||
|
||||
__declare_io_type(Request, uint8_t,
|
||||
static constexpr auto WantCommandStartIRQ = IOBitSet(5);
|
||||
static constexpr auto WantData = IOBitSet(7);
|
||||
static constexpr auto WantCommandStartIRQ = Bit(5);
|
||||
static constexpr auto WantData = Bit(7);
|
||||
);
|
||||
|
||||
__declare_io_type(SoundMapCoding, uint8_t,
|
||||
static constexpr auto Stereo = IOBitSet(0);
|
||||
static constexpr auto Stereo = Bit(0);
|
||||
static constexpr auto Mono = !Stereo;
|
||||
static constexpr auto SampleRate_18900hz = IOBitSet(2);
|
||||
static constexpr auto SampleRate_18900hz = Bit(2);
|
||||
static constexpr auto SampleRate_37800hz = !SampleRate_18900hz;
|
||||
static constexpr auto BitsPerSample8 = IOBitSet(4);
|
||||
static constexpr auto BitsPerSample8 = Bit(4);
|
||||
static constexpr auto BitsPerSample4 = !BitsPerSample8;
|
||||
static constexpr auto Emphasis = IOBitSet(6);
|
||||
static constexpr auto Emphasis = Bit(6);
|
||||
);
|
||||
|
||||
__declare_io_type(AudioVolumeApply, uint8_t,
|
||||
static constexpr auto Mute = IOBitSet(0);
|
||||
static constexpr auto ApplyChanges = IOBitSet(5);
|
||||
static constexpr auto Mute = Bit(0);
|
||||
static constexpr auto ApplyChanges = Bit(5);
|
||||
);
|
||||
|
||||
__declare_io_type(ResponseFifo, uint8_t,);
|
||||
|
@@ -5,18 +5,18 @@
|
||||
namespace JabyEngine {
|
||||
namespace DMA_IO {
|
||||
__declare_io_type(MADR, uint32_t,
|
||||
static constexpr auto MemoryAdr = IOValueSet::from_to(0, 23);
|
||||
static constexpr auto MemoryAdr = BitRange::from_to(0, 23);
|
||||
);
|
||||
|
||||
__declare_io_type(BCR, uint32_t,
|
||||
struct __no_align SyncMode0 {
|
||||
static constexpr auto NumberOfWords = IOValueSet::from_to(0, 15);
|
||||
static constexpr auto CD_OneBlock = IOBitSet(16);
|
||||
struct SyncMode0 {
|
||||
static constexpr auto NumberOfWords = BitRange::from_to(0, 15);
|
||||
static constexpr auto CD_OneBlock = Bit(16);
|
||||
};
|
||||
|
||||
struct SyncMode1 : public ComplexBitMap<uint32_t> {
|
||||
static constexpr auto BlockSize = IOValueSet::from_to(0, 15);
|
||||
static constexpr auto BlockAmount = IOValueSet::from_to(16, 31);
|
||||
struct SyncMode1 {
|
||||
static constexpr auto BlockSize = BitRange::from_to(0, 15);
|
||||
static constexpr auto BlockAmount = BitRange::from_to(16, 31);
|
||||
};
|
||||
|
||||
struct SyncMode2 {
|
||||
@@ -30,25 +30,25 @@ namespace JabyEngine {
|
||||
Sync2 = 2, //Linked List
|
||||
};
|
||||
|
||||
static constexpr auto ManualStart = IOBitSet(28);
|
||||
static constexpr auto ManualStart = Bit(28);
|
||||
|
||||
static constexpr auto Start = IOBitSet(24);
|
||||
static constexpr auto Start = Bit(24);
|
||||
static constexpr auto Busy = Start;
|
||||
|
||||
static constexpr auto ChoppingCPUWindowSize = IOValueSet::from_to(20, 22);
|
||||
static constexpr auto ChoppingDMAWindowSize = IOValueSet::from_to(16, 18);
|
||||
static constexpr auto ChoppingCPUWindowSize = BitRange::from_to(20, 22);
|
||||
static constexpr auto ChoppingDMAWindowSize = BitRange::from_to(16, 18);
|
||||
|
||||
static constexpr auto SyncMode = IOValueSet::from_to(9, 10);
|
||||
static constexpr auto SyncMode = BitRange::from_to(9, 10);
|
||||
static constexpr auto UseSyncMode0 = SyncMode.with(Sync0);
|
||||
static constexpr auto UseSyncMode1 = SyncMode.with(Sync1);
|
||||
static constexpr auto UseSyncMode2 = SyncMode.with(Sync2);
|
||||
|
||||
static constexpr auto UseChopping = IOBitSet(8);
|
||||
static constexpr auto UseChopping = Bit(8);
|
||||
|
||||
static constexpr auto MemoryAdrDecreaseBy4 = IOBitSet(1);
|
||||
static constexpr auto MemoryAdrDecreaseBy4 = Bit(1);
|
||||
static constexpr auto MemoryAdrIncreaseBy4 = !MemoryAdrDecreaseBy4;
|
||||
|
||||
static constexpr auto FromMainRAM = IOBitSet(0);
|
||||
static constexpr auto FromMainRAM = Bit(0);
|
||||
static constexpr auto ToMainRAM = !FromMainRAM;
|
||||
|
||||
static constexpr Self StartMDECin() {
|
||||
@@ -105,34 +105,34 @@ namespace JabyEngine {
|
||||
static constexpr Priority LowestPriority = 7;
|
||||
|
||||
__declare_io_type(DPCR, uint32_t,
|
||||
static constexpr auto OTCEnable = IOBitSet(27);
|
||||
static constexpr auto OTCPriority = IOValueSet::from_to(24, 26);
|
||||
static constexpr auto OTCEnable = Bit(27);
|
||||
static constexpr auto OTCPriority = BitRange::from_to(24, 26);
|
||||
|
||||
static constexpr auto PIOEnable = IOBitSet(23);
|
||||
static constexpr auto PIOPriority = IOValueSet::from_to(20, 22);
|
||||
static constexpr auto PIOEnable = Bit(23);
|
||||
static constexpr auto PIOPriority = BitRange::from_to(20, 22);
|
||||
|
||||
static constexpr auto SPUEnable = IOBitSet(19);
|
||||
static constexpr auto SPUPriority = IOValueSet::from_to(16, 18);
|
||||
static constexpr auto SPUEnable = Bit(19);
|
||||
static constexpr auto SPUPriority = BitRange::from_to(16, 18);
|
||||
|
||||
static constexpr auto CDROMEnable = IOBitSet(15);
|
||||
static constexpr auto CDROMPriority = IOValueSet::from_to(12, 14);
|
||||
static constexpr auto CDROMEnable = Bit(15);
|
||||
static constexpr auto CDROMPriority = BitRange::from_to(12, 14);
|
||||
|
||||
static constexpr auto GPUEnable = IOBitSet(11);
|
||||
static constexpr auto GPUPriority = IOValueSet::from_to(8, 10);
|
||||
static constexpr auto GPUEnable = Bit(11);
|
||||
static constexpr auto GPUPriority = BitRange::from_to(8, 10);
|
||||
|
||||
static constexpr auto MDECoutEnable = IOBitSet(7);
|
||||
static constexpr auto MDECoutPriority = IOValueSet::from_to(4, 6);
|
||||
static constexpr auto MDECoutEnable = Bit(7);
|
||||
static constexpr auto MDECoutPriority = BitRange::from_to(4, 6);
|
||||
|
||||
static constexpr auto MDECinEnable = IOBitSet(3);
|
||||
static constexpr auto MDECinPriority = IOValueSet::from_to(0, 2);
|
||||
static constexpr auto MDECinEnable = Bit(3);
|
||||
static constexpr auto MDECinPriority = BitRange::from_to(0, 2);
|
||||
);
|
||||
|
||||
__declare_io_type(DICR, uint32_t,
|
||||
static constexpr auto MasterEnable = IOBitSet(31);
|
||||
static constexpr auto Flags = IOValueSet::from_to(24, 30);
|
||||
static constexpr auto MasterEnableDPCR = IOBitSet(23);
|
||||
static constexpr auto EnableDPCR = IOValueSet::from_to(16, 22);
|
||||
static constexpr auto ForceIRQ = IOBitSet(15);
|
||||
static constexpr auto MasterEnable = Bit(31);
|
||||
static constexpr auto Flags = BitRange::from_to(24, 30);
|
||||
static constexpr auto MasterEnableDPCR = Bit(23);
|
||||
static constexpr auto EnableDPCR = BitRange::from_to(16, 22);
|
||||
static constexpr auto ForceIRQ = Bit(15);
|
||||
);
|
||||
|
||||
__declare_new_io_port(MDECin, 0x1F801080);
|
||||
|
@@ -53,12 +53,12 @@ namespace JabyEngine {
|
||||
PAL = 1,
|
||||
};
|
||||
|
||||
static constexpr auto HorizontalResolution368 = IOBitSet(6);
|
||||
static constexpr auto VerticalInterlace = IOBitSet(5);
|
||||
static constexpr auto DisplayAreaColorDepth = IOValueSet::from_to(4, 4);
|
||||
static constexpr auto VideoMode = IOValueSet::from_to(3, 3);
|
||||
static constexpr auto VerticalResolution = IOValueSet::from_to(2, 2);
|
||||
static constexpr auto HorizontalResolution = IOValueSet::from_to(0, 1);
|
||||
static constexpr auto HorizontalResolution368 = Bit(6);
|
||||
static constexpr auto VerticalInterlace = Bit(5);
|
||||
static constexpr auto DisplayAreaColorDepth = BitRange::from_to(4, 4);
|
||||
static constexpr auto VideoMode = BitRange::from_to(3, 3);
|
||||
static constexpr auto VerticalResolution = BitRange::from_to(2, 2);
|
||||
static constexpr auto HorizontalResolution = BitRange::from_to(0, 1);
|
||||
|
||||
static constexpr Self PAL() {
|
||||
return Self::from(
|
||||
@@ -86,12 +86,12 @@ namespace JabyEngine {
|
||||
);
|
||||
|
||||
|
||||
struct Command {
|
||||
struct Command {
|
||||
struct Helper {
|
||||
static constexpr GP0_t DrawAreaTemplate(uint8_t code, uint16_t x, uint16_t y) {
|
||||
constexpr auto Command = IOValueSet::from_to(24, 31);
|
||||
constexpr auto Y = IOValueSet::from_to(10, 18);
|
||||
constexpr auto X = IOValueSet::from_to(0, 9);
|
||||
constexpr auto Command = BitRange::from_to(24, 31);
|
||||
constexpr auto Y = BitRange::from_to(10, 18);
|
||||
constexpr auto X = BitRange::from_to(0, 9);
|
||||
|
||||
return GP0_t::from(Command.with(code), Y.with(y), X.with(x));
|
||||
}
|
||||
@@ -142,24 +142,24 @@ namespace JabyEngine {
|
||||
}
|
||||
|
||||
static constexpr GP1_t DisplayArea(uint16_t x, uint16_t y) {
|
||||
constexpr auto X = BitRange<uint32_t>::from_to(0, 9);
|
||||
constexpr auto Y = BitRange<uint32_t>::from_to(10, 18);
|
||||
constexpr auto X = BitRange::from_to(0, 9);
|
||||
constexpr auto Y = BitRange::from_to(10, 18);
|
||||
|
||||
return {Helper::construct_cmd(0x05, ComplexBitMap<uint32_t>::with(X.with(x), Y.with(y)).raw)};
|
||||
return {Helper::construct_cmd(0x05, X.as_value(x) | Y.as_value(y))};
|
||||
}
|
||||
|
||||
static constexpr GP1_t HorizontalDisplayRange(uint32_t x1, uint32_t x2) {
|
||||
constexpr auto X1 = BitRange<uint32_t>::from_to(0, 11);
|
||||
constexpr auto X2 = BitRange<uint32_t>::from_to(12, 23);
|
||||
constexpr auto X1 = BitRange::from_to(0, 11);
|
||||
constexpr auto X2 = BitRange::from_to(12, 23);
|
||||
|
||||
return {Helper::construct_cmd(0x06, ComplexBitMap<uint32_t>::with(X1.with(x1), X2.with(x2)).raw)};
|
||||
return {Helper::construct_cmd(0x06, X1.as_value(x1) | X2.as_value(x2))};
|
||||
}
|
||||
|
||||
static constexpr GP1_t VerticalDisplayRange(uint32_t y1, uint32_t y2) {
|
||||
constexpr auto Y1 = BitRange<uint32_t>::from_to(0, 9);
|
||||
constexpr auto Y2 = BitRange<uint32_t>::from_to(10, 19);
|
||||
constexpr auto Y1 = BitRange::from_to(0, 9);
|
||||
constexpr auto Y2 = BitRange::from_to(10, 19);
|
||||
|
||||
return {Helper::construct_cmd(0x07, ComplexBitMap<uint32_t>::with(Y1.with(y1), Y2.with(y2)).raw)};
|
||||
return {Helper::construct_cmd(0x07, Y1.as_value(y1) | Y2.as_value(y2))};
|
||||
}
|
||||
|
||||
static constexpr GP1_t DisplayMode(DisplayMode_t mode) {
|
||||
@@ -168,32 +168,32 @@ namespace JabyEngine {
|
||||
};
|
||||
|
||||
__declare_io_type(GPUSTAT, uint32_t,
|
||||
static constexpr auto DrawingOddLinesInterlaced = IOBitSet(31);
|
||||
static constexpr auto DMADirectionValue = IOValueSet::from_to(29, 30);
|
||||
static constexpr auto DMAReady = IOBitSet(28);
|
||||
static constexpr auto VRAMtoCPUtransferReay = IOBitSet(27);
|
||||
static constexpr auto GP0ReadyForCMD = IOBitSet(26);
|
||||
static constexpr auto FifoNotFull = IOBitSet(25); // Only for Fifo
|
||||
static constexpr auto InterruptRequest = IOBitSet(24);
|
||||
static constexpr auto DisplayDisabled = IOBitSet(23);
|
||||
static constexpr auto VerticalInterlaceOn = IOBitSet(22);
|
||||
static constexpr auto DisplayAreaColorDepth = IOValueSet::from_to(21, 21);
|
||||
static constexpr auto VideoModePal = IOBitSet(20);
|
||||
static constexpr auto VerticalResolutionValue = IOValueSet::from_to(19, 19);
|
||||
static constexpr auto HorizontalResolutionValue = IOValueSet::from_to(17, 18);
|
||||
static constexpr auto HorizontalResolution368 = IOBitSet(16);
|
||||
static constexpr auto TexturesDisabled = IOBitSet(15);
|
||||
static constexpr auto NotDrawingMaskedPixels = IOBitSet(12);
|
||||
static constexpr auto MaskBitSetDuringDrawEnabled = IOBitSet(11);
|
||||
static constexpr auto DrawingToDisplayAreadAllowed = IOBitSet(10);
|
||||
static constexpr auto DitherEnabled = IOBitSet(9);
|
||||
static constexpr auto TexturePageColorValue = IOValueSet::from_to(7, 8);
|
||||
static constexpr auto SemiTransparencyValue = IOValueSet::from_to(5, 6);
|
||||
static constexpr auto TexturePageY = IOValueSet::from_to(4, 4); // N*256
|
||||
static constexpr auto TexturePageX = IOValueSet::from_to(0, 3); // N*64
|
||||
static constexpr auto DrawingOddLinesInterlaced = Bit(31);
|
||||
static constexpr auto DMADirectionValue = BitRange::from_to(29, 30);
|
||||
static constexpr auto DMAReady = Bit(28);
|
||||
static constexpr auto VRAMtoCPUtransferReay = Bit(27);
|
||||
static constexpr auto GP0ReadyForCMD = Bit(26);
|
||||
static constexpr auto FifoNotFull = Bit(25); // Only for Fifo
|
||||
static constexpr auto InterruptRequest = Bit(24);
|
||||
static constexpr auto DisplayDisabled = Bit(23);
|
||||
static constexpr auto VerticalInterlaceOn = Bit(22);
|
||||
static constexpr auto DisplayAreaColorDepth = BitRange::from_to(21, 21);
|
||||
static constexpr auto VideoModePal = Bit(20);
|
||||
static constexpr auto VerticalResolutionValue = BitRange::from_to(19, 19);
|
||||
static constexpr auto HorizontalResolutionValue = BitRange::from_to(17, 18);
|
||||
static constexpr auto HorizontalResolution368 = Bit(16);
|
||||
static constexpr auto TexturesDisabled = Bit(15);
|
||||
static constexpr auto NotDrawingMaskedPixels = Bit(12);
|
||||
static constexpr auto MaskBitSetDuringDrawEnabled = Bit(11);
|
||||
static constexpr auto DrawingToDisplayAreadAllowed = Bit(10);
|
||||
static constexpr auto DitherEnabled = Bit(9);
|
||||
static constexpr auto TexturePageColorValue = BitRange::from_to(7, 8);
|
||||
static constexpr auto SemiTransparencyValue = BitRange::from_to(5, 6);
|
||||
static constexpr auto TexturePageY = BitRange::from_to(4, 4); // N*256
|
||||
static constexpr auto TexturePageX = BitRange::from_to(0, 3); // N*64
|
||||
|
||||
static constexpr auto VerticalResolution480 = IOBitSet(19);
|
||||
static constexpr auto TexturePageY256 = IOBitSet(4);
|
||||
static constexpr auto VerticalResolution480 = Bit(19);
|
||||
static constexpr auto TexturePageY256 = Bit(4);
|
||||
);
|
||||
|
||||
typedef volatile uint32_t GPUREAD_v;
|
||||
|
@@ -4,17 +4,17 @@
|
||||
|
||||
namespace JabyEngine {
|
||||
struct Interrupt {
|
||||
static constexpr auto VBlank = IOBitSet(0);
|
||||
static constexpr auto GPU = IOBitSet(1);
|
||||
static constexpr auto CDROM = IOBitSet(2);
|
||||
static constexpr auto DMA = IOBitSet(3);
|
||||
static constexpr auto Timer0 = IOBitSet(4);
|
||||
static constexpr auto Timer1 = IOBitSet(5);
|
||||
static constexpr auto Timer2 = IOBitSet(6);
|
||||
static constexpr auto Periphery = IOBitSet(7);
|
||||
static constexpr auto SIO = IOBitSet(8);
|
||||
static constexpr auto SPU = IOBitSet(9);
|
||||
static constexpr auto Controller = IOBitSet(10);
|
||||
static constexpr auto VBlank = Bit(0);
|
||||
static constexpr auto GPU = Bit(1);
|
||||
static constexpr auto CDROM = Bit(2);
|
||||
static constexpr auto DMA = Bit(3);
|
||||
static constexpr auto Timer0 = Bit(4);
|
||||
static constexpr auto Timer1 = Bit(5);
|
||||
static constexpr auto Timer2 = Bit(6);
|
||||
static constexpr auto Periphery = Bit(7);
|
||||
static constexpr auto SIO = Bit(8);
|
||||
static constexpr auto SPU = Bit(9);
|
||||
static constexpr auto Controller = Bit(10);
|
||||
static constexpr auto LightPen = Controller;
|
||||
|
||||
__declare_io_type(Status, uint32_t,
|
||||
@@ -26,19 +26,19 @@ namespace JabyEngine {
|
||||
__declare_new_io_port(Status, 0x1F801070);
|
||||
__declare_new_io_port(Mask, 0x1F801074);
|
||||
|
||||
static constexpr bool is_irq(IOBitSet irq) {
|
||||
static constexpr bool is_irq(Bit irq) {
|
||||
return Status.is_set(irq);
|
||||
}
|
||||
|
||||
static constexpr void ack_irq(IOBitSet irq) {
|
||||
static constexpr void ack_irq(Bit irq) {
|
||||
Status.clear(irq);
|
||||
}
|
||||
|
||||
static constexpr void disable_irq(IOBitSet irq) {
|
||||
static constexpr void disable_irq(Bit irq) {
|
||||
Mask.clear(irq);
|
||||
}
|
||||
|
||||
static void enable_irq(IOBitSet irq) {
|
||||
static void enable_irq(Bit irq) {
|
||||
Mask.set(irq);
|
||||
}
|
||||
};
|
||||
|
@@ -4,49 +4,6 @@
|
||||
#include "../../Auxiliary/types.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
struct IOBitUnset {
|
||||
uint16_t pos;
|
||||
|
||||
constexpr IOBitUnset(uint16_t bit_pos) : pos(bit_pos) {
|
||||
}
|
||||
};
|
||||
|
||||
struct IOBitSet {
|
||||
uint16_t pos;
|
||||
|
||||
constexpr IOBitSet(uint16_t bit_pos) : pos(bit_pos) {
|
||||
}
|
||||
|
||||
constexpr IOBitUnset operator!() const {
|
||||
return IOBitUnset(this->pos);
|
||||
}
|
||||
};
|
||||
|
||||
struct IOValueSet {
|
||||
template<typename T>
|
||||
using IOValueSetPair = pair<IOValueSet, T>;
|
||||
|
||||
uint16_t pos;
|
||||
uint16_t length;
|
||||
|
||||
constexpr IOValueSet(uint16_t pos, uint16_t length) : pos(pos), length(length) {
|
||||
}
|
||||
|
||||
static constexpr IOValueSet from_to(uint16_t first_bit, uint16_t last_bit) {
|
||||
return IOValueSet(first_bit, (last_bit - first_bit) + 1);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr IOValueSetPair<T> with(T value) const {
|
||||
return {*this, value};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr IOValueSetPair<T> range_max() const {
|
||||
return IOValueSet::with<T>((1 << this->length) - 1);
|
||||
}
|
||||
};
|
||||
|
||||
namespace IOPort {
|
||||
struct IOValueType {
|
||||
template<typename T>
|
||||
@@ -91,24 +48,24 @@ namespace JabyEngine {
|
||||
return Self().set_va(args...); \
|
||||
} \
|
||||
\
|
||||
constexpr Self& set(IOBitSet bit) { \
|
||||
this->raw_value = bit::set(this->raw_value, bit.pos); \
|
||||
constexpr Self& set(Bit bit) { \
|
||||
this->raw_value = bit::set(this->raw_value, bit); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
constexpr Self& set(IOBitUnset bit) { \
|
||||
this->raw_value = bit::clear(this->raw_value, bit.pos); \
|
||||
constexpr Self& set(ClearBit bit) { \
|
||||
this->raw_value = bit::set(this->raw_value, bit); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
constexpr Self& set(IOValueSet bits, UnderlyingValue value) { \
|
||||
this->raw_value = bit::value::set_normalized(this->raw_value, value, bits.pos, bits.length); \
|
||||
constexpr Self& set(BitRange bits, UnderlyingValue value) { \
|
||||
this->raw_value = bit::value::set_normalized(this->raw_value, bits, value); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
template<typename S> \
|
||||
constexpr Self& set(const IOValueSet::IOValueSetPair<S>& value) { \
|
||||
this->set(value.first, static_cast<UnderlyingValue>(value.second)); \
|
||||
constexpr Self& set(const BitRange::RangeValuePair<S>& value) { \
|
||||
this->raw_value = bit::value::set_normalized(this->raw_value, value); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
@@ -122,17 +79,17 @@ namespace JabyEngine {
|
||||
return this->set(head).set_va(tail...); \
|
||||
} \
|
||||
\
|
||||
constexpr UnderlyingValue get(IOValueSet bits) const { \
|
||||
constexpr UnderlyingValue get(BitRange bits) const { \
|
||||
return bit::value::get_normalized(this->raw_value, bits.pos, bits.length); \
|
||||
} \
|
||||
\
|
||||
constexpr Self& clear(IOBitSet bit) { \
|
||||
this->raw_value = bit::clear(this->raw_value, bit.pos); \
|
||||
constexpr Self& clear(Bit bit) { \
|
||||
this->raw_value = bit::clear(this->raw_value, bit); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
constexpr bool is_set(IOBitSet bit) const { \
|
||||
return bit::is_set(this->raw_value, bit.pos); \
|
||||
constexpr bool is_set(Bit bit) const { \
|
||||
return bit::is_set(this->raw_value, bit); \
|
||||
} \
|
||||
\
|
||||
constexpr void operator=(UnderlyingValue value) { \
|
||||
@@ -160,38 +117,6 @@ namespace JabyEngine {
|
||||
}
|
||||
};
|
||||
|
||||
// For use with ComplexBitMaps or what else satisfies this API
|
||||
template<typename T>
|
||||
struct VolatileBitMapPOD {
|
||||
typedef typename T::UnderlyingType Raw;
|
||||
|
||||
VolatilePOD<Raw> pod;
|
||||
|
||||
constexpr Raw read_raw() const {
|
||||
return this->pod.read();
|
||||
}
|
||||
|
||||
constexpr T read() const {
|
||||
return T{this->pod.read()};
|
||||
}
|
||||
|
||||
constexpr Raw read(const BitRange<Raw>& range) const {
|
||||
return VolatileBitMapPOD<T>::read().get_value(range);
|
||||
}
|
||||
|
||||
constexpr void write_raw(Raw value) {
|
||||
this->pod.write(value);
|
||||
}
|
||||
|
||||
constexpr void write(const T& value) {
|
||||
this->pod.write(static_cast<Raw>(value));
|
||||
}
|
||||
|
||||
constexpr void write(const BitRangeValue<Raw>& value) {
|
||||
VolatileBitMapPOD<T>::write(T{T::with(value)});
|
||||
}
|
||||
};
|
||||
|
||||
struct __no_align ubus32_t {
|
||||
__declare_io_type(uint16_t, uint16_t,);
|
||||
uint16_t_v low;
|
||||
|
@@ -42,33 +42,33 @@ namespace JabyEngine {
|
||||
|
||||
__declare_io_type(SweepVolume, int16_t,
|
||||
// For Volume Mode
|
||||
static constexpr auto SweepEnable = IOBitSet(15);
|
||||
static constexpr auto SweepEnable = Bit(15);
|
||||
static constexpr auto VolumeEnable = !SweepEnable;
|
||||
static constexpr auto Volume = IOValueSet::from_to(0, 14);
|
||||
static constexpr auto Volume = BitRange::from_to(0, 14);
|
||||
|
||||
// For Sweep Mode
|
||||
static constexpr auto SweepMode = IOBitSet(14);
|
||||
static constexpr auto SweepDirection = IOBitSet(13);
|
||||
static constexpr auto SweepPhase = IOBitSet(12);
|
||||
static constexpr auto SweepShift = IOValueSet::from_to(2, 6);
|
||||
static constexpr auto SweepStep = IOValueSet::from_to(0, 1);
|
||||
static constexpr auto SweepMode = Bit(14);
|
||||
static constexpr auto SweepDirection = Bit(13);
|
||||
static constexpr auto SweepPhase = Bit(12);
|
||||
static constexpr auto SweepShift = BitRange::from_to(2, 6);
|
||||
static constexpr auto SweepStep = BitRange::from_to(0, 1);
|
||||
);
|
||||
|
||||
__declare_io_type(SR, uint16_t,
|
||||
static constexpr auto SustainMode = IOBitSet(31 - 16);
|
||||
static constexpr auto SustainDirection = IOBitSet(30 - 16);
|
||||
static constexpr auto SustainShift = IOValueSet::from_to((24 - 16), (28 - 16));
|
||||
static constexpr auto SustainStep = IOValueSet::from_to((22 - 16), (23 - 16));
|
||||
static constexpr auto ReleaseMode = IOBitSet(21 - 16);
|
||||
static constexpr auto ReleaseShift = IOValueSet::from_to((16 - 16), (20 - 16));
|
||||
static constexpr auto SustainMode = Bit(31 - 16);
|
||||
static constexpr auto SustainDirection = Bit(30 - 16);
|
||||
static constexpr auto SustainShift = BitRange::from_to((24 - 16), (28 - 16));
|
||||
static constexpr auto SustainStep = BitRange::from_to((22 - 16), (23 - 16));
|
||||
static constexpr auto ReleaseMode = Bit(21 - 16);
|
||||
static constexpr auto ReleaseShift = BitRange::from_to((16 - 16), (20 - 16));
|
||||
);
|
||||
|
||||
__declare_io_type(AD, uint16_t,
|
||||
static constexpr auto AttackMode = IOBitSet(15);
|
||||
static constexpr auto AttackShift = IOValueSet::from_to(10, 14);
|
||||
static constexpr auto AttackStep = IOValueSet::from_to(8, 9);
|
||||
static constexpr auto DecayShift = IOValueSet::from_to(4, 7);
|
||||
static constexpr auto SustainLevel = IOValueSet::from_to(0, 3);
|
||||
static constexpr auto AttackMode = Bit(15);
|
||||
static constexpr auto AttackShift = BitRange::from_to(10, 14);
|
||||
static constexpr auto AttackStep = BitRange::from_to(8, 9);
|
||||
static constexpr auto DecayShift = BitRange::from_to(4, 7);
|
||||
static constexpr auto SustainLevel = BitRange::from_to(0, 3);
|
||||
);
|
||||
|
||||
struct __no_align Voice_v {
|
||||
@@ -90,29 +90,29 @@ namespace JabyEngine {
|
||||
DMARead = 3
|
||||
};
|
||||
|
||||
static constexpr auto Enable = IOBitSet(15);
|
||||
static constexpr auto Unmute = IOBitSet(14);
|
||||
static constexpr auto NoiseFrequcenyShift = IOValueSet::from_to(10, 13);
|
||||
static constexpr auto NoiseFrequcenyStep = IOValueSet::from_to(8, 9);
|
||||
static constexpr auto ReverbMasterEnable = IOBitSet(7);
|
||||
static constexpr auto IRQ9Enable = IOBitSet(6);
|
||||
static constexpr auto TransferMode = IOValueSet::from_to(4, 5);
|
||||
static constexpr auto ExternalAudioReverb = IOBitSet(3);
|
||||
static constexpr auto CDAudioReverb = IOBitSet(2);
|
||||
static constexpr auto ExternalAudioEnable = IOBitSet(1);
|
||||
static constexpr auto CDAudioEnable = IOBitSet(0);
|
||||
static constexpr auto Enable = Bit(15);
|
||||
static constexpr auto Unmute = Bit(14);
|
||||
static constexpr auto NoiseFrequcenyShift = BitRange::from_to(10, 13);
|
||||
static constexpr auto NoiseFrequcenyStep = BitRange::from_to(8, 9);
|
||||
static constexpr auto ReverbMasterEnable = Bit(7);
|
||||
static constexpr auto IRQ9Enable = Bit(6);
|
||||
static constexpr auto TransferMode = BitRange::from_to(4, 5);
|
||||
static constexpr auto ExternalAudioReverb = Bit(3);
|
||||
static constexpr auto CDAudioReverb = Bit(2);
|
||||
static constexpr auto ExternalAudioEnable = Bit(1);
|
||||
static constexpr auto CDAudioEnable = Bit(0);
|
||||
);
|
||||
|
||||
__declare_io_type(PMON, uint16_t,
|
||||
static constexpr auto EnableBits = IOValueSet::from_to(1, 23);
|
||||
static constexpr auto EnableBits = BitRange::from_to(1, 23);
|
||||
);
|
||||
|
||||
__declare_io_type(NON, uint16_t,
|
||||
static constexpr auto NoiseBits = IOValueSet::from_to(0, 23);
|
||||
static constexpr auto NoiseBits = BitRange::from_to(0, 23);
|
||||
);
|
||||
|
||||
__declare_io_type(EON, uint16_t,
|
||||
static constexpr auto EchoBits = IOValueSet::from_to(0, 23);
|
||||
static constexpr auto EchoBits = BitRange::from_to(0, 23);
|
||||
);
|
||||
|
||||
static constexpr size_t VoiceCount = 24;
|
||||
|
@@ -5,28 +5,28 @@
|
||||
namespace JabyEngine {
|
||||
namespace Timer_IO {
|
||||
__declare_io_type(CounterMode, uint32_t,
|
||||
static constexpr auto SyncEnable = IOBitSet(0);
|
||||
static constexpr auto SyncEnable = Bit(0);
|
||||
static constexpr auto FreeRun = !SyncEnable;
|
||||
static constexpr auto SyncMode = IOValueSet::from_to(1, 2);
|
||||
static constexpr auto ResetAfterTarget = IOBitSet(3);
|
||||
static constexpr auto IRQAtTarget = IOBitSet(4);
|
||||
static constexpr auto IRQAtMax = IOBitSet(5);
|
||||
static constexpr auto IRQEveryTime = IOBitSet(6);
|
||||
static constexpr auto SyncMode = BitRange::from_to(1, 2);
|
||||
static constexpr auto ResetAfterTarget = Bit(3);
|
||||
static constexpr auto IRQAtTarget = Bit(4);
|
||||
static constexpr auto IRQAtMax = Bit(5);
|
||||
static constexpr auto IRQEveryTime = Bit(6);
|
||||
static constexpr auto IRQOneShot = !IRQEveryTime;
|
||||
static constexpr auto IRQToggle = IOBitSet(7);
|
||||
static constexpr auto IRQToggle = Bit(7);
|
||||
static constexpr auto IRQPulse = !IRQToggle;
|
||||
static constexpr auto ClockSource = IOValueSet::from_to(8, 9);
|
||||
static constexpr auto HasIRQRequest = IOBitSet(10);
|
||||
static constexpr auto IsTargetReached = IOBitSet(11);
|
||||
static constexpr auto IsMaxReached = IOBitSet(12);
|
||||
static constexpr auto ClockSource = BitRange::from_to(8, 9);
|
||||
static constexpr auto HasIRQRequest = Bit(10);
|
||||
static constexpr auto IsTargetReached = Bit(11);
|
||||
static constexpr auto IsMaxReached = Bit(12);
|
||||
);
|
||||
|
||||
__declare_io_type(CounterTarget, uint32_t,
|
||||
static constexpr auto CounterTargetValue = IOValueSet::from_to(0, 15);
|
||||
static constexpr auto CounterTargetValue = BitRange::from_to(0, 15);
|
||||
);
|
||||
|
||||
__declare_io_type(CounterValue, uint32_t,
|
||||
static constexpr auto Value = IOValueSet::from_to(0, 15);
|
||||
static constexpr auto Value = BitRange::from_to(0, 15);
|
||||
);
|
||||
|
||||
struct __no_align Counter {
|
||||
|
Reference in New Issue
Block a user