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

View File

@ -46,6 +46,6 @@ namespace JabyEngine {
}
};
static auto& voice = __new_declare_io_port_array(Voice, SPU_IO::VoiceCount, 0x0);
static auto& voice = __declare_io_port_array(Voice, SPU_IO::VoiceCount, 0x0);
}
}

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);
};
}

View File

@ -116,18 +116,18 @@ namespace JabyEngine {
static constexpr auto IORegister2Adr = 0x1F801802;
static constexpr auto IORegister3Adr = 0x1F801803;
static auto& IndexStatus = __new_declare_io_port(IndexStatus_IO, 0x1F801800);
static auto& IndexStatus = __declare_io_port(IndexStatus_IO, 0x1F801800);
struct PortIndex0 {
static inline const auto& ResponseFifo = __new_declare_io_port(ResponseFifo_IO, IORegister1Adr);
static inline auto& CommandFifo = __new_declare_io_port(CommandFifo_IO, IORegister1Adr);
static inline const auto& ResponseFifo = __declare_io_port(ResponseFifo_IO, IORegister1Adr);
static inline auto& CommandFifo = __declare_io_port(CommandFifo_IO, IORegister1Adr);
static inline const auto& DataFifo = __new_declare_io_port(DataFifo_IO, IORegister2Adr);
static inline const auto& DataFifo16 = __new_declare_io_port(DataFifo16_IO, IORegister2Adr);
static inline auto& ParameterFifo = __new_declare_io_port(ParameterFifo_IO, IORegister2Adr);
static inline const auto& DataFifo = __declare_io_port(DataFifo_IO, IORegister2Adr);
static inline const auto& DataFifo16 = __declare_io_port(DataFifo16_IO, IORegister2Adr);
static inline auto& ParameterFifo = __declare_io_port(ParameterFifo_IO, IORegister2Adr);
static inline const auto& InterruptEnable = __new_declare_io_port(InterruptEnable_IO, IORegister3Adr);
static inline auto& Request = __new_declare_io_port(Request_IO, IORegister3Adr);
static inline const auto& InterruptEnable = __declare_io_port(InterruptEnable_IO, IORegister3Adr);
static inline auto& Request = __declare_io_port(Request_IO, IORegister3Adr);
static void change_to() {
IndexStatus.write({Index::Index0});
@ -135,14 +135,14 @@ namespace JabyEngine {
};
struct PortIndex1 {
static inline const auto& ResponseFifo = __new_declare_io_port(ResponseFifo_IO, IORegister1Adr);
static inline auto& SoundMapDataOut = __new_declare_io_port(SoundMapDataOut_IO, IORegister1Adr);
static inline const auto& ResponseFifo = __declare_io_port(ResponseFifo_IO, IORegister1Adr);
static inline auto& SoundMapDataOut = __declare_io_port(SoundMapDataOut_IO, IORegister1Adr);
static inline const auto& DataFifo = __new_declare_io_port(DataFifo_IO, IORegister2Adr);
static inline const auto& DataFifo16 = __new_declare_io_port(DataFifo16_IO, IORegister2Adr);
static inline auto& InterruptEnable = __new_declare_io_port(InterruptEnable_IO, IORegister2Adr);
static inline const auto& DataFifo = __declare_io_port(DataFifo_IO, IORegister2Adr);
static inline const auto& DataFifo16 = __declare_io_port(DataFifo16_IO, IORegister2Adr);
static inline auto& InterruptEnable = __declare_io_port(InterruptEnable_IO, IORegister2Adr);
static inline auto& InterruptFlag = __new_declare_io_port(InterruptFlag_IO, IORegister3Adr);
static inline auto& InterruptFlag = __declare_io_port(InterruptFlag_IO, IORegister3Adr);
static void change_to() {
IndexStatus.write({Index::Index1});
@ -150,15 +150,15 @@ namespace JabyEngine {
};
struct PortIndex2 {
static inline const auto& ResponseFifo = __new_declare_io_port(ResponseFifo_IO, IORegister1Adr);
static inline auto& SoundMapCoding = __new_declare_io_port(SoundMapCoding_IO, IORegister1Adr);
static inline const auto& ResponseFifo = __declare_io_port(ResponseFifo_IO, IORegister1Adr);
static inline auto& SoundMapCoding = __declare_io_port(SoundMapCoding_IO, IORegister1Adr);
static inline const auto& DataFifo = __new_declare_io_port(DataFifo_IO, IORegister2Adr);
static inline const auto& DataFifo16 = __new_declare_io_port(DataFifo16_IO, IORegister2Adr);
static inline auto& LeftCD2LeftSPU = __new_declare_io_port(LeftCD2LeftSPU_IO, IORegister2Adr);
static inline const auto& DataFifo = __declare_io_port(DataFifo_IO, IORegister2Adr);
static inline const auto& DataFifo16 = __declare_io_port(DataFifo16_IO, IORegister2Adr);
static inline auto& LeftCD2LeftSPU = __declare_io_port(LeftCD2LeftSPU_IO, IORegister2Adr);
static inline const auto& InterruptEnable = __new_declare_io_port(InterruptEnable_IO, IORegister3Adr);
static inline auto& LeftCD2RightSPU = __new_declare_io_port(LeftCD2RightSPU_IO, IORegister3Adr);
static inline const auto& InterruptEnable = __declare_io_port(InterruptEnable_IO, IORegister3Adr);
static inline auto& LeftCD2RightSPU = __declare_io_port(LeftCD2RightSPU_IO, IORegister3Adr);
static void change_to() {
IndexStatus.write({Index::Index2});
@ -166,15 +166,15 @@ namespace JabyEngine {
};
struct PortIndex3 {
static inline const auto& ResponseFifo = __new_declare_io_port(ResponseFifo_IO, IORegister1Adr);
static inline auto& RightCD2RightSPU = __new_declare_io_port(RightCD2RightSPU_IO, IORegister1Adr);
static inline const auto& ResponseFifo = __declare_io_port(ResponseFifo_IO, IORegister1Adr);
static inline auto& RightCD2RightSPU = __declare_io_port(RightCD2RightSPU_IO, IORegister1Adr);
static inline const auto& DataFifo = __new_declare_io_port(DataFifo_IO, IORegister2Adr);
static inline const auto& DataFifo16 = __new_declare_io_port(DataFifo16_IO, IORegister2Adr);
static inline auto& RightCD2LeftSPU = __new_declare_io_port(RightCD2LeftSPU_IO, IORegister1Adr);
static inline const auto& DataFifo = __declare_io_port(DataFifo_IO, IORegister2Adr);
static inline const auto& DataFifo16 = __declare_io_port(DataFifo16_IO, IORegister2Adr);
static inline auto& RightCD2LeftSPU = __declare_io_port(RightCD2LeftSPU_IO, IORegister1Adr);
static inline const auto& InterruptFlag = __new_declare_io_port(InterruptFlag_IO, IORegister3Adr);
static inline auto& AudioVolumeApply = __new_declare_io_port(AudioVolumeApply_IO, IORegister3Adr);
static inline const auto& InterruptFlag = __declare_io_port(InterruptFlag_IO, IORegister3Adr);
static inline auto& AudioVolumeApply = __declare_io_port(AudioVolumeApply_IO, IORegister3Adr);
static void change_to() {
IndexStatus.write({Index::Index3});

View File

@ -25,15 +25,15 @@ namespace JabyEngine {
};
#pragma pack(pop)
static auto& MDECin = __new_declare_io_value(Registers, 0x1F801080);
static auto& MDECout = __new_declare_io_value(Registers, 0x1F801090);
static auto& GPU = __new_declare_io_value(Registers, 0x1F8010A0);
static auto& CDROM = __new_declare_io_value(Registers, 0x1F8010B0);
static auto& SPU = __new_declare_io_value(Registers, 0x1F8010C0);
static auto& PIO = __new_declare_io_value(Registers, 0x1F8010D0);
static auto& OTC = __new_declare_io_value(Registers, 0x1F8010E0);
static auto& MDECin = __declare_io_value(Registers, 0x1F801080);
static auto& MDECout = __declare_io_value(Registers, 0x1F801090);
static auto& GPU = __declare_io_value(Registers, 0x1F8010A0);
static auto& CDROM = __declare_io_value(Registers, 0x1F8010B0);
static auto& SPU = __declare_io_value(Registers, 0x1F8010C0);
static auto& PIO = __declare_io_value(Registers, 0x1F8010D0);
static auto& OTC = __declare_io_value(Registers, 0x1F8010E0);
static auto& DPCR = __new_declare_io_port(DPCR_IO, 0x1F8010F0);
static auto& DICR = __new_declare_io_port(DICR_IO, 0x1F8010F4);
static auto& DPCR = __declare_io_port(DPCR_IO, 0x1F8010F0);
static auto& DICR = __declare_io_port(DICR_IO, 0x1F8010F4);
}
}

View File

@ -3,7 +3,7 @@
namespace JabyEngine {
namespace GPU_IO {
struct GP0IO : public IOPort<GPU_IO_Values::GP0> {
struct GP0_IO : public IOPort<GPU_IO_Values::GP0> {
void clear_cache() {
this->write(GPU_IO_Values::GP0::ClearCache());
}
@ -45,7 +45,7 @@ namespace JabyEngine {
}
};
struct GP1IO : public IOPort<GPU_IO_Values::GP1> {
struct GP1_IO : public IOPort<GPU_IO_Values::GP1> {
void reset() {
this->write(GPU_IO_Values::GP1::Reset());
}
@ -83,9 +83,9 @@ namespace JabyEngine {
static constexpr size_t FIFOWordSize = 16;
static auto& GP0 = __new_declare_io_port(GP0IO, 0x1F801810);
static const auto& GPUREAD = __new_declare_io_port(GPUREAD_IO, 0x1F801810);
static auto& GP1 = __new_declare_io_port(GP1IO, 0x1F801814);
static const auto& GPUSTAT = __new_declare_io_port(GPUSTAT_IO, 0x1F801814);
static auto& GP0 = __declare_io_port(GP0_IO, 0x1F801810);
static const auto& GPUREAD = __declare_io_port(GPUREAD_IO, 0x1F801810);
static auto& GP1 = __declare_io_port(GP1_IO, 0x1F801814);
static const auto& GPUSTAT = __declare_io_port(GPUSTAT_IO, 0x1F801814);
}
}

View File

@ -2,8 +2,8 @@
#include "IOValues/interrupt_io_values.hpp"
namespace JabyEngine {
using StatusIO = IOPort<Interrupt_IO_Values::Status>;
using MaskIO = IOPort<Interrupt_IO_Values::Mask>;
using Status_IO = IOPort<Interrupt_IO_Values::Status>;
using Mask_IO = IOPort<Interrupt_IO_Values::Mask>;
struct Interrupt {
static constexpr auto VBlank = Bit(0);
@ -19,8 +19,8 @@ namespace JabyEngine {
static constexpr auto Controller = Bit(10);
static constexpr auto LightPen = Controller;
static inline auto& Status = __new_declare_io_port(StatusIO, 0x1F801070);
static inline auto& Mask = __new_declare_io_port(MaskIO, 0x1F801074);
static inline auto& Status = __declare_io_port(Status_IO, 0x1F801070);
static inline auto& Mask = __declare_io_port(Mask_IO, 0x1F801074);
static bool is_irq(Bit irq) {
return Status.read().is_set(irq);

View File

@ -6,7 +6,7 @@ namespace JabyEngine {
using CD_DELAY_IO = IOPort<Memory_IO_Values::CD_DELAY>;
using COM_DELAY_IO = IOPort<Memory_IO_Values::COM_DELAY>;
static auto& CD_DELAY = __new_declare_io_port(CD_DELAY_IO, 0x1F801018);
static auto& COM_DELAY = __new_declare_io_port(COM_DELAY_IO, 0x1F801020);
static auto& CD_DELAY = __declare_io_port(CD_DELAY_IO, 0x1F801018);
static auto& COM_DELAY = __declare_io_port(COM_DELAY_IO, 0x1F801020);
}
}

View File

@ -19,11 +19,11 @@ namespace JabyEngine {
using JOY_RX_DATA_IO = IOPort<Periphery_IO_Values::JOY_RX_DATA>;
using JOY_TX_DATA_IO = IOPort<Periphery_IO_Values::JOY_TX_DATA>;
static auto& JOY_TX_DATA = __new_declare_io_port(JOY_TX_DATA_IO, 0x1F801040);
static const auto& JOY_RX_DATA = __new_declare_io_port(JOY_RX_DATA_IO, 0x1F801040);
static const auto& JOY_STAT = __new_declare_io_port(JOY_STAT_IO, 0x1F801044);
static auto& JOY_MODE = __new_declare_io_port(JOY_MODE_IO, 0x1F801048);
static auto& JOY_CTRL = __new_declare_io_port(JOY_CTRL_IO, 0x1F80104A);
static auto& JOY_BAUD = __new_declare_io_port(JOY_BAUD_IO, 0x1F80104E);
static auto& JOY_TX_DATA = __declare_io_port(JOY_TX_DATA_IO, 0x1F801040);
static const auto& JOY_RX_DATA = __declare_io_port(JOY_RX_DATA_IO, 0x1F801040);
static const auto& JOY_STAT = __declare_io_port(JOY_STAT_IO, 0x1F801044);
static auto& JOY_MODE = __declare_io_port(JOY_MODE_IO, 0x1F801048);
static auto& JOY_CTRL = __declare_io_port(JOY_CTRL_IO, 0x1F80104A);
static auto& JOY_BAUD = __declare_io_port(JOY_BAUD_IO, 0x1F80104E);
}
}

View File

@ -7,7 +7,7 @@ namespace JabyEngine {
static constexpr size_t VoiceCount = 24;
static constexpr size_t ReverbCount = 1;
struct ControlRegisterIO : public IOPort<SPU_IO_Values::ControlRegister> {
struct ControlRegister_IO : public IOPort<SPU_IO_Values::ControlRegister> {
using TransferMode = Value::RAMTransferMode;
void set_transfer_mode(TransferMode mode) {
@ -16,74 +16,74 @@ namespace JabyEngine {
}
};
using ADIO = IOPort<SPU_IO_Values::AD>;
using DataTransferControlIO = IOPort<SPU_IO_Values::DataTransferControl>;
using EchoIO = IOPort32<SPU_IO_Values::Echo>;
using KeyOffIO = IOPort32<SPU_IO_Values::KeyOff>;
using KeyOnIO = IOPort32<SPU_IO_Values::KeyOn>;
using KeyStatusIO = IOPort32<SPU_IO_Values::KeyStatus>;
using NoiseIO = IOPort<SPU_IO_Values::Noise>;
using PitchModulationIO = IOPort32<SPU_IO_Values::PitchModulation>;
using SampleRateIO = IOPort<SPU_IO_Values::SampleRate>;
using SimpleVolumeIO = IOPort<SPU_IO_Values::SimpleVolume>;
using StatusRegisterIO = IOPort<SPU_IO_Values::StatusRegister>;
using SRIO = IOPort<SPU_IO_Values::SR>;
using SRAMAdrIO = IOPort<SPU_IO_Values::SRAMAdr>;
using SweepVolumeIO = IOPort<SPU_IO_Values::SweepVolume>;
using AD_IO = IOPort<SPU_IO_Values::AD>;
using DataTransferControl_IO = IOPort<SPU_IO_Values::DataTransferControl>;
using Echo_IO = IOPort32<SPU_IO_Values::Echo>;
using KeyOff_IO = IOPort32<SPU_IO_Values::KeyOff>;
using KeyOn_IO = IOPort32<SPU_IO_Values::KeyOn>;
using KeyStatus_IO = IOPort32<SPU_IO_Values::KeyStatus>;
using Noise_IO = IOPort<SPU_IO_Values::Noise>;
using PitchModulation_IO = IOPort32<SPU_IO_Values::PitchModulation>;
using SampleRate_IO = IOPort<SPU_IO_Values::SampleRate>;
using SimpleVolume_IO = IOPort<SPU_IO_Values::SimpleVolume>;
using StatusRegister_IO = IOPort<SPU_IO_Values::StatusRegister>;
using SR_IO = IOPort<SPU_IO_Values::SR>;
using SRAMAdr_IO = IOPort<SPU_IO_Values::SRAMAdr>;
using SweepVolume_IO = IOPort<SPU_IO_Values::SweepVolume>;
#pragma pack(push, 1)
struct Voice {
SweepVolumeIO volumeLeft; //Offset: 0x0
SweepVolumeIO volumeRight; //Offset: 0x2
SampleRateIO sampleRate; //Offset: 0x4;
SRAMAdrIO adr; //Offset: 0x6
ADIO ad; //Offset: 0x8
SRIO sr; //Offset: 0xA
SimpleVolumeIO adsr_volume; //Offset: 0xC
SRAMAdrIO repeatAdr; //Offset: 0xE
SweepVolume_IO volumeLeft; //Offset: 0x0
SweepVolume_IO volumeRight; //Offset: 0x2
SampleRate_IO sampleRate; //Offset: 0x4;
SRAMAdr_IO adr; //Offset: 0x6
AD_IO ad; //Offset: 0x8
SR_IO sr; //Offset: 0xA
SimpleVolume_IO adsr_volume; //Offset: 0xC
SRAMAdr_IO repeatAdr; //Offset: 0xE
};
#pragma pack(pop)
// Required so GCC does not create guards for the ReverbON reference
#define __eon_declaration __new_declare_io_port(EchoIO, 0x1F801D98)
#define __eon_declaration __declare_io_port(Echo_IO, 0x1F801D98)
static auto& Voice = __new_declare_io_port_array(struct Voice, VoiceCount, 0x1F801C00);
static auto& PMON = __new_declare_io_port(PitchModulationIO, 0x1F801D90);
static auto& NON = __new_declare_io_port(NoiseIO, 0x1F801D94);
static auto& Voice = __declare_io_port_array(struct Voice, VoiceCount, 0x1F801C00);
static auto& PMON = __declare_io_port(PitchModulation_IO, 0x1F801D90);
static auto& NON = __declare_io_port(Noise_IO, 0x1F801D94);
static auto& EON = __eon_declaration;
static auto& SRAMTransferAdr = __new_declare_io_port(SRAMAdrIO, 0x1F801DA6);
static auto& ControlRegister = __new_declare_io_port(ControlRegisterIO, 0x1F801DAA);
static auto& DataTransferControl = __new_declare_io_port(DataTransferControlIO, 0x1F801DAC);
static auto& StatusRegister = __new_declare_io_port(StatusRegisterIO, 0x1F801DAE);
static auto& SRAMTransferAdr = __declare_io_port(SRAMAdr_IO, 0x1F801DA6);
static auto& ControlRegister = __declare_io_port(ControlRegister_IO, 0x1F801DAA);
static auto& DataTransferControl = __declare_io_port(DataTransferControl_IO, 0x1F801DAC);
static auto& StatusRegister = __declare_io_port(StatusRegister_IO, 0x1F801DAE);
struct CDVolume {
static inline auto& Left = __new_declare_io_port(SimpleVolumeIO, 0x1F801DB0);
static inline auto& Right = __new_declare_io_port(SimpleVolumeIO, 0x1F801DB2);
static inline auto& Left = __declare_io_port(SimpleVolume_IO, 0x1F801DB0);
static inline auto& Right = __declare_io_port(SimpleVolume_IO, 0x1F801DB2);
};
struct ExternalAudioInputVolume {
static inline auto& Left = __new_declare_io_port(SimpleVolumeIO, 0x1F801DB4);
static inline auto& Right = __new_declare_io_port(SimpleVolumeIO, 0x1F801DB6);
static inline auto& Left = __declare_io_port(SimpleVolume_IO, 0x1F801DB4);
static inline auto& Right = __declare_io_port(SimpleVolume_IO, 0x1F801DB6);
};
struct Key {
static inline auto& On = __new_declare_io_port(KeyOnIO, 0x1F801D88);
static inline auto& Off = __new_declare_io_port(KeyOffIO, 0x1F801D8C);
static inline auto& Status = __new_declare_io_port(KeyStatusIO, 0x1F801D9C);
static inline auto& On = __declare_io_port(KeyOn_IO, 0x1F801D88);
static inline auto& Off = __declare_io_port(KeyOff_IO, 0x1F801D8C);
static inline auto& Status = __declare_io_port(KeyStatus_IO, 0x1F801D9C);
};
struct MainVolume {
static inline auto& Left = __new_declare_io_port(SweepVolumeIO, 0x1F801D80);
static inline auto& Right = __new_declare_io_port(SweepVolumeIO, 0x1F801D82);
static inline auto& Left = __declare_io_port(SweepVolume_IO, 0x1F801D80);
static inline auto& Right = __declare_io_port(SweepVolume_IO, 0x1F801D82);
};
struct Reverb {
struct Volume {
static inline auto& Left = __new_declare_io_port(SimpleVolumeIO, 0x1F801D84);
static inline auto& Right = __new_declare_io_port(SimpleVolumeIO, 0x1F801D86);
static inline auto& Left = __declare_io_port(SimpleVolume_IO, 0x1F801D84);
static inline auto& Right = __declare_io_port(SimpleVolume_IO, 0x1F801D86);
};
static inline auto& On = __eon_declaration;
static inline auto& WorkAreaAdr = __new_declare_io_port(SRAMAdrIO, 0x1F801DA2);
static inline auto& WorkAreaAdr = __declare_io_port(SRAMAdr_IO, 0x1F801DA2);
};
}
}

View File

@ -3,16 +3,16 @@
namespace JabyEngine {
namespace Timer_IO {
using CounterModeIO = IOPort<Timer_IO_Values::CounterMode>;
using CounterTargetIO = IOPort<Timer_IO_Values::CounterTarget>;
using CounterValueIO = IOPort<Timer_IO_Values::CounterValue>;
using CounterMode_IO = IOPort<Timer_IO_Values::CounterMode>;
using CounterTarget_IO = IOPort<Timer_IO_Values::CounterTarget>;
using CounterValue_IO = IOPort<Timer_IO_Values::CounterValue>;
#pragma pack(push, 1)
struct Counter {
CounterValueIO value;
CounterModeIO mode;
CounterTargetIO target;
uint32_t unused;
CounterValue_IO value;
CounterMode_IO mode;
CounterTarget_IO target;
uint32_t unused;
inline uint16_t get_current_value() const {
return this->value.read().get(Timer_IO_Values::CounterValue::Value);
@ -83,8 +83,8 @@ namespace JabyEngine {
}
// TODO: Improve this to actually use it for measurement - if possible
static auto& Counter0 = __new_declare_io_value(struct Counter0, counter_base_adr(0));
static auto& Counter1 = __new_declare_io_value(struct Counter1, counter_base_adr(1));
static auto& Counter2 = __new_declare_io_value(struct Counter2, counter_base_adr(2));
static auto& Counter0 = __declare_io_value(struct Counter0, counter_base_adr(0));
static auto& Counter1 = __declare_io_value(struct Counter1, counter_base_adr(1));
static auto& Counter2 = __declare_io_value(struct Counter2, counter_base_adr(2));
}
}