This commit is contained in:
2024-09-29 17:27:23 +02:00
parent 5292b7bf9f
commit 6680c4d5a3
18 changed files with 167 additions and 173 deletions

View File

@@ -3,7 +3,7 @@
namespace JabyEngine {
namespace CD_IO_Values {
__declare_io_value(AudioVolumeApply, uint8_t) {
__declare_io_struct(AudioVolumeApply, uint8_t) {
static constexpr auto Mute = Bit(0);
static constexpr auto ApplyChanges = Bit(5);
};
@@ -16,16 +16,16 @@ namespace JabyEngine {
static constexpr uint8_t Max = 0xFF;
};
__declare_io_value(CommandFifo, uint8_t) {
__declare_io_struct(CommandFifo, uint8_t) {
};
__declare_io_value(DataFifo, uint8_t) {
__declare_io_struct(DataFifo, uint8_t) {
};
__declare_io_value(DataFifo16, uint16_t) {
__declare_io_struct(DataFifo16, uint16_t) {
};
__declare_io_value(InterruptEnable, uint8_t) {
__declare_io_struct(InterruptEnable, uint8_t) {
static constexpr auto InterruptTypValue = BitRange::from_to(0, 2);
static constexpr auto InterruptExtended = BitRange::from_to(0, 4);
static constexpr auto UnknownIRQ = Bit(3);
@@ -33,7 +33,7 @@ namespace JabyEngine {
};
using InterruptFlag = InterruptEnable;
__declare_io_value(IndexStatus, uint8_t) {
__declare_io_struct(IndexStatus, uint8_t) {
static constexpr auto PortIndex = BitRange::from_to(0, 1);
static constexpr auto HasXAFifoData = Bit(2);
static constexpr auto IsParameterFifoEmpty = Bit(3);
@@ -43,13 +43,13 @@ namespace JabyEngine {
static constexpr auto IsTransmissionBusy = Bit(7);
};
__declare_io_value(LeftCD2LeftSPU, CDDAVolume::Type) {
__declare_io_struct(LeftCD2LeftSPU, CDDAVolume::Type) {
};
__declare_io_value(LeftCD2RightSPU, CDDAVolume::Type) {
__declare_io_struct(LeftCD2RightSPU, CDDAVolume::Type) {
};
__declare_io_value(Mode, uint8_t) {
__declare_io_struct(Mode, uint8_t) {
static constexpr auto DoubleSpeed = Bit(7);
static constexpr auto SingleSpeed = !DoubleSpeed;
static constexpr auto XADPCM = Bit(6);
@@ -65,10 +65,10 @@ namespace JabyEngine {
}
};
__declare_io_value(ParameterFifo, uint8_t) {
__declare_io_struct(ParameterFifo, uint8_t) {
};
__declare_io_value(Request, uint8_t) {
__declare_io_struct(Request, uint8_t) {
static constexpr auto WantCommandStartIRQ = Bit(5);
static constexpr auto WantData = Bit(7);
@@ -81,16 +81,16 @@ namespace JabyEngine {
}
};
__declare_io_value(ResponseFifo, uint8_t) {
__declare_io_struct(ResponseFifo, uint8_t) {
};
__declare_io_value(RightCD2LeftSPU, CDDAVolume::Type) {
__declare_io_struct(RightCD2LeftSPU, CDDAVolume::Type) {
};
__declare_io_value(RightCD2RightSPU, CDDAVolume::Type) {
__declare_io_struct(RightCD2RightSPU, CDDAVolume::Type) {
};
__declare_io_value(SoundMapCoding, uint8_t) {
__declare_io_struct(SoundMapCoding, uint8_t) {
static constexpr auto Stereo = Bit(0);
static constexpr auto Mono = !Stereo;
static constexpr auto SampleRate_18900hz = Bit(2);
@@ -100,7 +100,7 @@ namespace JabyEngine {
static constexpr auto Emphasis = Bit(6);
};
__declare_io_value(SoundMapDataOut, uint8_t) {
__declare_io_struct(SoundMapDataOut, uint8_t) {
};
}
}

View File

@@ -7,7 +7,7 @@ namespace JabyEngine {
static constexpr Priority HighestPriority = 0;
static constexpr Priority LowestPriority = 7;
__declare_io_value(BCR, uint32_t) {
__declare_io_struct(BCR, uint32_t) {
struct SyncMode0 {
static constexpr auto NumberOfWords = BitRange::from_to(0, 15);
static constexpr auto CD_OneBlock = Bit(16);
@@ -29,7 +29,7 @@ namespace JabyEngine {
};
};
__declare_io_value(CHCHR, uint32_t) {
__declare_io_struct(CHCHR, uint32_t) {
enum SyncMode_t {
Sync0 = 0, //Start immediately,
Sync1 = 1, //Sync blocks to DMA requests
@@ -86,7 +86,7 @@ namespace JabyEngine {
}
};
__declare_io_value(DICR, uint32_t) {
__declare_io_struct(DICR, uint32_t) {
static constexpr auto MasterEnable = Bit(31);
static constexpr auto Flags = BitRange::from_to(24, 30);
static constexpr auto MasterEnableDPCR = Bit(23);
@@ -98,7 +98,7 @@ namespace JabyEngine {
}
};
__declare_io_value(DPCR, uint32_t) {
__declare_io_struct(DPCR, uint32_t) {
struct DMASetting {
uint16_t master_bit;
@@ -145,7 +145,7 @@ namespace JabyEngine {
static constexpr auto MDECinPriority = BitRange::from_to(0, 2);
};
__declare_io_value(MADR, uint32_t) {
__declare_io_struct(MADR, uint32_t) {
static constexpr auto MemoryAdr = BitRange::from_to(0, 23);
};
}

View File

@@ -11,7 +11,7 @@ namespace JabyEngine {
}
}
__declare_io_value(DisplayMode, uint32_t) {
__declare_io_struct(DisplayMode, uint32_t) {
enum AreaColorDepth {
$15bit = 0,
$24bit = 1,
@@ -65,10 +65,10 @@ namespace JabyEngine {
}
};
__declare_io_value(GPUREAD, uint32_t) {
__declare_io_struct(GPUREAD, uint32_t) {
};
__declare_io_value(GPUSTAT, uint32_t) {
__declare_io_struct(GPUSTAT, uint32_t) {
enum DMADirection {
Off = 0,
Fifo = 1,
@@ -104,7 +104,7 @@ namespace JabyEngine {
static constexpr auto TexturePageY256 = Bit(4);
};
__declare_io_value(GP0, uint32_t) {
__declare_io_struct(GP0, uint32_t) {
static constexpr auto ID = BitRange::from_to(24, 31);
static constexpr auto Value = BitRange::from_to(0, 23);
@@ -171,7 +171,7 @@ namespace JabyEngine {
}
};
__declare_io_value(GP1, uint32_t) {
__declare_io_struct(GP1, uint32_t) {
static constexpr auto ID = BitRange::from_to(24, 31);
static constexpr auto Value = BitRange::from_to(0, 23);

View File

@@ -3,10 +3,10 @@
namespace JabyEngine {
namespace Interrupt_IO_Values {
__declare_io_value(Mask, uint32_t) {
__declare_io_struct(Mask, uint32_t) {
};
__declare_io_value(Status, uint32_t) {
__declare_io_struct(Status, uint32_t) {
};
}
}

View File

@@ -111,14 +111,8 @@ namespace JabyEngine {
}
};
#define __declare_io_value(name, type) struct name : public ::JabyEngine::internal::IOValue<struct name, type>
#define __declare_value_at(cv, type, name, adr) static cv auto& name = *reinterpret_cast<type*>(::JabyEngine::IOAdress::patch_adr(adr))
#define __declare_array_at(cv, type, name, size, adr) static cv auto& name = reinterpret_cast<type(&)[size]>(*reinterpret_cast<type*>(IOAdress::patch_adr(adr)))
#define __declare_io_port_w_type(cv, type, name, adr) __declare_value_at(cv, ::JabyEngine::IOPort<type>, name, adr)
#define __declare_io_port(cv, name, adr) __declare_io_port_w_type(cv, struct name, name, adr)
#define __declare_io_port_array(cv, name, size, adr) __declare_array_at(cv, struct name, name, size, adr)
#define __new_declare_io_port(type, adr) *reinterpret_cast<type*>(adr)
#define __new_declare_io_value(type, adr) __new_declare_io_port(type, adr)
#define __new_declare_io_port_array(type, size, adr) reinterpret_cast<type(&)[size]>(*reinterpret_cast<type*>(adr))
#define __declare_io_struct(name, type) struct name : public ::JabyEngine::internal::IOValue<struct name, type>
#define __declare_io_port(type, adr) *reinterpret_cast<type*>(adr)
#define __declare_io_value(type, adr) __declare_io_port(type, adr)
#define __declare_io_port_array(type, size, adr) reinterpret_cast<type(&)[size]>(*reinterpret_cast<type*>(adr))
}

View File

@@ -3,13 +3,13 @@
namespace JabyEngine {
namespace Memory_IO_Values {
__declare_io_value(CD_DELAY, uint32_t) {
__declare_io_struct(CD_DELAY, uint32_t) {
static constexpr CD_DELAY create() {
return CD_DELAY{0x20943};
}
};
__declare_io_value(COM_DELAY, uint32_t) {
__declare_io_struct(COM_DELAY, uint32_t) {
static constexpr COM_DELAY create() {
return COM_DELAY{0x1325};
}

View File

@@ -3,13 +3,13 @@
namespace JabyEngine {
namespace Periphery_IO_Values {
__declare_io_value(JOY_BAUD, uint16_t) {
__declare_io_struct(JOY_BAUD, uint16_t) {
static constexpr JOY_BAUD create() {
return JOY_BAUD{0x0088};
}
};
__declare_io_value(JOY_CTRL, uint16_t) {
__declare_io_struct(JOY_CTRL, uint16_t) {
static constexpr auto TXEnable = Bit(0);
static constexpr auto SelectJoy = Bit(1);
static constexpr auto ACK = Bit(4);
@@ -26,16 +26,16 @@ namespace JabyEngine {
}
};
__declare_io_value(JOY_MODE, uint16_t) {
__declare_io_struct(JOY_MODE, uint16_t) {
static constexpr JOY_MODE create() {
return JOY_MODE{0x000D};
}
};
__declare_io_value(JOY_RX_DATA, uint8_t) {
__declare_io_struct(JOY_RX_DATA, uint8_t) {
};
__declare_io_value(JOY_STAT, uint32_t) {
__declare_io_struct(JOY_STAT, uint32_t) {
static constexpr auto TXReadyStart = Bit(0);
static constexpr auto RXFifoNonEmpty = Bit(1);
static constexpr auto TXReadyFinished = Bit(2);
@@ -43,7 +43,7 @@ namespace JabyEngine {
static constexpr auto ACKIrqLow = Bit(7);
};
__declare_io_value(JOY_TX_DATA, uint32_t) {
__declare_io_struct(JOY_TX_DATA, uint32_t) {
static constexpr JOY_TX_DATA create(uint8_t byte) {
return JOY_TX_DATA{byte};
}

View File

@@ -9,7 +9,7 @@ namespace JabyEngine {
static constexpr uintptr_t End = 0x7FFFF;
}
__declare_io_value(AD, uint16_t) {
__declare_io_struct(AD, uint16_t) {
static constexpr auto AttackMode = Bit(15);
static constexpr auto AttackShift = BitRange::from_to(10, 14);
static constexpr auto AttackStep = BitRange::from_to(8, 9);
@@ -21,7 +21,7 @@ namespace JabyEngine {
}
};
__declare_io_value(ControlRegister, uint16_t) {
__declare_io_struct(ControlRegister, uint16_t) {
enum RAMTransferMode {
Stop = 0,
ManualWrite = 1,
@@ -42,13 +42,13 @@ namespace JabyEngine {
static constexpr auto CDAudioEnable = Bit(0);
};
__declare_io_value(DataTransferControl, uint16_t) {
__declare_io_struct(DataTransferControl, uint16_t) {
static constexpr DataTransferControl NormalTransferMode() {
return DataTransferControl{0x0004};
}
};
__declare_io_value(Echo, uint32_t) {
__declare_io_struct(Echo, uint32_t) {
static constexpr auto EchoBits = BitRange::from_to(0, 23);
static constexpr Echo AllOff() {
@@ -56,7 +56,7 @@ namespace JabyEngine {
}
};
__declare_io_value(KeyOff, uint32_t) {
__declare_io_struct(KeyOff, uint32_t) {
static constexpr KeyOff for_specific(uint32_t id) {
return KeyOff{1u << id};
}
@@ -66,7 +66,7 @@ namespace JabyEngine {
}
};
__declare_io_value(KeyOn, uint32_t) {
__declare_io_struct(KeyOn, uint32_t) {
static constexpr KeyOn for_specific(uint32_t id) {
return KeyOn{1u << id};
}
@@ -76,10 +76,10 @@ namespace JabyEngine {
}
};
__declare_io_value(KeyStatus, uint32_t) {
__declare_io_struct(KeyStatus, uint32_t) {
};
__declare_io_value(Noise, uint16_t) {
__declare_io_struct(Noise, uint16_t) {
static constexpr auto NoiseBits = BitRange::from_to(0, 23);
static constexpr Noise AllOff() {
@@ -87,7 +87,7 @@ namespace JabyEngine {
}
};
__declare_io_value(PitchModulation, uint32_t) {
__declare_io_struct(PitchModulation, uint32_t) {
static constexpr auto EnableBits = BitRange::from_to(1, 23);
static constexpr PitchModulation AllOff() {
@@ -95,7 +95,7 @@ namespace JabyEngine {
}
};
__declare_io_value(SampleRate, uint16_t) {
__declare_io_struct(SampleRate, uint16_t) {
static constexpr SampleRate stop() {
return SampleRate{0};
}
@@ -112,7 +112,7 @@ namespace JabyEngine {
}
};
__declare_io_value(SimpleVolume, int16_t) {
__declare_io_struct(SimpleVolume, int16_t) {
static constexpr auto MaxVolume = I16_MAX;
static constexpr SimpleVolume mute() {
@@ -128,7 +128,7 @@ namespace JabyEngine {
return {static_cast<int16_t>(static_cast<long double>(SimpleVolume::MaxVolume)*fraction)};
}
__declare_io_value(SR, uint16_t) {
__declare_io_struct(SR, uint16_t) {
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));
@@ -141,7 +141,7 @@ namespace JabyEngine {
}
};
__declare_io_value(SRAMAdr, uint16_t) {
__declare_io_struct(SRAMAdr, uint16_t) {
static constexpr SRAMAdr null() {
return SRAMAdr{0x0};
}
@@ -151,7 +151,7 @@ namespace JabyEngine {
}
};
__declare_io_value(StatusRegister, uint16_t) {
__declare_io_struct(StatusRegister, uint16_t) {
enum CapureBufferHalf {
First = 0,
Second = 1
@@ -172,7 +172,7 @@ namespace JabyEngine {
static constexpr auto CDAudioEnable = Bit(0);
};
__declare_io_value(SweepVolume, int16_t) {
__declare_io_struct(SweepVolume, int16_t) {
struct VolumeMode {
static constexpr auto MaxVolume = (I16_MAX >> 1);
static constexpr auto EnableSweep = Bit(15);

View File

@@ -3,7 +3,7 @@
namespace JabyEngine {
namespace Timer_IO_Values {
__declare_io_value(CounterMode, uint32_t) {
__declare_io_struct(CounterMode, uint32_t) {
static constexpr auto SyncEnable = Bit(0);
static constexpr auto FreeRun = !SyncEnable;
static constexpr auto SyncMode = BitRange::from_to(1, 2);
@@ -20,11 +20,11 @@ namespace JabyEngine {
static constexpr auto IsMaxReached = Bit(12);
};
__declare_io_value(CounterTarget, uint32_t) {
__declare_io_struct(CounterTarget, uint32_t) {
static constexpr auto CounterTargetValue = BitRange::from_to(0, 15);
};
__declare_io_value(CounterValue, uint32_t) {
__declare_io_struct(CounterValue, uint32_t) {
static constexpr auto Value = BitRange::from_to(0, 15);
};
}