Fix inconsistent EOL
This commit is contained in:
@@ -1,106 +1,106 @@
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace CD_IO_Values {
|
||||
__declare_io_struct(AudioVolumeApply, uint8_t) {
|
||||
static constexpr auto Mute = Bit(0);
|
||||
static constexpr auto ApplyChanges = Bit(5);
|
||||
};
|
||||
|
||||
struct CDDAVolume {
|
||||
using Type = uint8_t;
|
||||
|
||||
static constexpr uint8_t Off = 0x0;
|
||||
static constexpr uint8_t Default = 0x80;
|
||||
static constexpr uint8_t Max = 0xFF;
|
||||
};
|
||||
|
||||
__declare_io_struct(CommandFifo, uint8_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(DataFifo, uint8_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(DataFifo16, uint16_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);
|
||||
static constexpr auto CommandStartIRQ = Bit(4);
|
||||
};
|
||||
using InterruptFlag = InterruptEnable;
|
||||
|
||||
__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);
|
||||
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_struct(LeftCD2LeftSPU, CDDAVolume::Type) {
|
||||
};
|
||||
|
||||
__declare_io_struct(LeftCD2RightSPU, CDDAVolume::Type) {
|
||||
};
|
||||
|
||||
__declare_io_struct(Mode, uint8_t) {
|
||||
static constexpr auto DoubleSpeed = Bit(7);
|
||||
static constexpr auto SingleSpeed = !DoubleSpeed;
|
||||
static constexpr auto XADPCM = Bit(6);
|
||||
static constexpr auto WholeSector = Bit(5);
|
||||
static constexpr auto DataSector = !WholeSector;
|
||||
static constexpr auto UseXAFilter = Bit(3);
|
||||
static constexpr auto AudioPlayIRQ = Bit(2);
|
||||
static constexpr auto AutoPauseTrack = Bit(1);
|
||||
static constexpr auto CDDA = Bit(0);
|
||||
|
||||
operator uint8_t() const {
|
||||
return this->raw;
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(ParameterFifo, uint8_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(Request, uint8_t) {
|
||||
static constexpr auto WantCommandStartIRQ = Bit(5);
|
||||
static constexpr auto WantData = Bit(7);
|
||||
|
||||
static Request want_data() {
|
||||
return Request{static_cast<uint8_t>(Request::WantData)};
|
||||
}
|
||||
|
||||
static Request reset() {
|
||||
return Request{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(ResponseFifo, uint8_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(RightCD2LeftSPU, CDDAVolume::Type) {
|
||||
};
|
||||
|
||||
__declare_io_struct(RightCD2RightSPU, CDDAVolume::Type) {
|
||||
};
|
||||
|
||||
__declare_io_struct(SoundMapCoding, uint8_t) {
|
||||
static constexpr auto Stereo = Bit(0);
|
||||
static constexpr auto Mono = !Stereo;
|
||||
static constexpr auto SampleRate_18900hz = Bit(2);
|
||||
static constexpr auto SampleRate_37800hz = !SampleRate_18900hz;
|
||||
static constexpr auto BitsPerSample8 = Bit(4);
|
||||
static constexpr auto BitsPerSample4 = !BitsPerSample8;
|
||||
static constexpr auto Emphasis = Bit(6);
|
||||
};
|
||||
|
||||
__declare_io_struct(SoundMapDataOut, uint8_t) {
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace CD_IO_Values {
|
||||
__declare_io_struct(AudioVolumeApply, uint8_t) {
|
||||
static constexpr auto Mute = Bit(0);
|
||||
static constexpr auto ApplyChanges = Bit(5);
|
||||
};
|
||||
|
||||
struct CDDAVolume {
|
||||
using Type = uint8_t;
|
||||
|
||||
static constexpr uint8_t Off = 0x0;
|
||||
static constexpr uint8_t Default = 0x80;
|
||||
static constexpr uint8_t Max = 0xFF;
|
||||
};
|
||||
|
||||
__declare_io_struct(CommandFifo, uint8_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(DataFifo, uint8_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(DataFifo16, uint16_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);
|
||||
static constexpr auto CommandStartIRQ = Bit(4);
|
||||
};
|
||||
using InterruptFlag = InterruptEnable;
|
||||
|
||||
__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);
|
||||
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_struct(LeftCD2LeftSPU, CDDAVolume::Type) {
|
||||
};
|
||||
|
||||
__declare_io_struct(LeftCD2RightSPU, CDDAVolume::Type) {
|
||||
};
|
||||
|
||||
__declare_io_struct(Mode, uint8_t) {
|
||||
static constexpr auto DoubleSpeed = Bit(7);
|
||||
static constexpr auto SingleSpeed = !DoubleSpeed;
|
||||
static constexpr auto XADPCM = Bit(6);
|
||||
static constexpr auto WholeSector = Bit(5);
|
||||
static constexpr auto DataSector = !WholeSector;
|
||||
static constexpr auto UseXAFilter = Bit(3);
|
||||
static constexpr auto AudioPlayIRQ = Bit(2);
|
||||
static constexpr auto AutoPauseTrack = Bit(1);
|
||||
static constexpr auto CDDA = Bit(0);
|
||||
|
||||
operator uint8_t() const {
|
||||
return this->raw;
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(ParameterFifo, uint8_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(Request, uint8_t) {
|
||||
static constexpr auto WantCommandStartIRQ = Bit(5);
|
||||
static constexpr auto WantData = Bit(7);
|
||||
|
||||
static Request want_data() {
|
||||
return Request{static_cast<uint8_t>(Request::WantData)};
|
||||
}
|
||||
|
||||
static Request reset() {
|
||||
return Request{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(ResponseFifo, uint8_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(RightCD2LeftSPU, CDDAVolume::Type) {
|
||||
};
|
||||
|
||||
__declare_io_struct(RightCD2RightSPU, CDDAVolume::Type) {
|
||||
};
|
||||
|
||||
__declare_io_struct(SoundMapCoding, uint8_t) {
|
||||
static constexpr auto Stereo = Bit(0);
|
||||
static constexpr auto Mono = !Stereo;
|
||||
static constexpr auto SampleRate_18900hz = Bit(2);
|
||||
static constexpr auto SampleRate_37800hz = !SampleRate_18900hz;
|
||||
static constexpr auto BitsPerSample8 = Bit(4);
|
||||
static constexpr auto BitsPerSample4 = !BitsPerSample8;
|
||||
static constexpr auto Emphasis = Bit(6);
|
||||
};
|
||||
|
||||
__declare_io_struct(SoundMapDataOut, uint8_t) {
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,152 +1,152 @@
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace DMA_IO_Values {
|
||||
using Priority = uint32_t;
|
||||
static constexpr Priority HighestPriority = 0;
|
||||
static constexpr Priority LowestPriority = 7;
|
||||
|
||||
__declare_io_struct(BCR, uint32_t) {
|
||||
struct SyncMode0 {
|
||||
static constexpr auto NumberOfWords = BitRange::from_to(0, 15);
|
||||
static constexpr auto CD_OneBlock = Bit(16);
|
||||
|
||||
static constexpr BCR for_cd(size_t words) {
|
||||
return BCR::from(SyncMode0::CD_OneBlock, SyncMode0::NumberOfWords.with(words));
|
||||
}
|
||||
};
|
||||
|
||||
struct SyncMode1 {
|
||||
static constexpr auto BlockSize = BitRange::from_to(0, 15);
|
||||
static constexpr auto BlockAmount = BitRange::from_to(16, 31);
|
||||
};
|
||||
|
||||
struct SyncMode2 {
|
||||
static constexpr BCR for_gpu_cmd() {
|
||||
return {0};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
__declare_io_struct(CHCHR, uint32_t) {
|
||||
enum SyncMode_t {
|
||||
Sync0 = 0, //Start immediately,
|
||||
Sync1 = 1, //Sync blocks to DMA requests
|
||||
Sync2 = 2, //Linked List
|
||||
};
|
||||
|
||||
static constexpr auto ManualStart = Bit(28);
|
||||
|
||||
static constexpr auto Start = Bit(24);
|
||||
static constexpr auto Busy = Start;
|
||||
|
||||
static constexpr auto ChoppingCPUWindowSize = BitRange::from_to(20, 22);
|
||||
static constexpr auto ChoppingDMAWindowSize = BitRange::from_to(16, 18);
|
||||
|
||||
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 = Bit(8);
|
||||
|
||||
static constexpr auto MemoryAdrDecreaseBy4 = Bit(1);
|
||||
static constexpr auto MemoryAdrIncreaseBy4 = !MemoryAdrDecreaseBy4;
|
||||
|
||||
static constexpr auto FromMainRAM = Bit(0);
|
||||
static constexpr auto ToMainRAM = !FromMainRAM;
|
||||
|
||||
static constexpr CHCHR StartMDECin() {
|
||||
return CHCHR{0x01000201};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartMDECout() {
|
||||
return CHCHR{0x01000200};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartGPUReceive() {
|
||||
return CHCHR{0x01000201};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartGPULinked() {
|
||||
return CHCHR{0x01000401};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartCDROM() {
|
||||
return CHCHR{0x11000000};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartSPUReceive() {
|
||||
return CHCHR{0x01000201};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartOTC() {
|
||||
return CHCHR{0x11000002};
|
||||
}
|
||||
};
|
||||
|
||||
__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);
|
||||
static constexpr auto EnableDPCR = BitRange::from_to(16, 22);
|
||||
static constexpr auto ForceIRQ = Bit(15);
|
||||
|
||||
static constexpr DICR empty() {
|
||||
return DICR{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(DPCR, uint32_t) {
|
||||
struct DMASetting {
|
||||
uint16_t master_bit;
|
||||
|
||||
static constexpr DMASetting create(uint16_t master_bit) {
|
||||
return DMASetting{master_bit};
|
||||
}
|
||||
|
||||
constexpr BitRange::RangeValuePair<uint32_t> turn_on(uint8_t priority) const {
|
||||
return BitRange::from_to(this->master_bit - 3, this->master_bit).with(static_cast<uint32_t>(0b1000 + (priority & 0b111)));
|
||||
}
|
||||
|
||||
constexpr ClearBit turn_off() const {
|
||||
return ClearBit(this->master_bit);
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr const auto OTC = DMASetting(27);
|
||||
static constexpr const auto PIO = DMASetting(23);
|
||||
static constexpr const auto SPU = DMASetting(19);
|
||||
static constexpr const auto CDROM = DMASetting(15);
|
||||
static constexpr const auto GPU = DMASetting(11);
|
||||
static constexpr const auto MDEC_Out = DMASetting(7);
|
||||
static constexpr const auto MDEC_In = DMASetting(3);
|
||||
|
||||
static constexpr auto OTCEnabled = Bit(27);
|
||||
static constexpr auto OTCPriority = BitRange::from_to(24, 26);
|
||||
|
||||
static constexpr auto PIOEnabled = Bit(23);
|
||||
static constexpr auto PIOPriority = BitRange::from_to(20, 22);
|
||||
|
||||
static constexpr auto SPUEnabled = Bit(19);
|
||||
static constexpr auto SPUPriority = BitRange::from_to(16, 18);
|
||||
|
||||
static constexpr auto CDROMEnabled = Bit(15);
|
||||
static constexpr auto CDROMPriority = BitRange::from_to(12, 14);
|
||||
|
||||
static constexpr auto GPUEnabled = Bit(11);
|
||||
static constexpr auto GPUPriority = BitRange::from_to(8, 10);
|
||||
|
||||
static constexpr auto MDECoutEnabled = Bit(7);
|
||||
static constexpr auto MDECoutPriority = BitRange::from_to(4, 6);
|
||||
|
||||
static constexpr auto MDECinEnabled = Bit(3);
|
||||
static constexpr auto MDECinPriority = BitRange::from_to(0, 2);
|
||||
};
|
||||
|
||||
__declare_io_struct(MADR, uint32_t) {
|
||||
static constexpr auto MemoryAdr = BitRange::from_to(0, 23);
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace DMA_IO_Values {
|
||||
using Priority = uint32_t;
|
||||
static constexpr Priority HighestPriority = 0;
|
||||
static constexpr Priority LowestPriority = 7;
|
||||
|
||||
__declare_io_struct(BCR, uint32_t) {
|
||||
struct SyncMode0 {
|
||||
static constexpr auto NumberOfWords = BitRange::from_to(0, 15);
|
||||
static constexpr auto CD_OneBlock = Bit(16);
|
||||
|
||||
static constexpr BCR for_cd(size_t words) {
|
||||
return BCR::from(SyncMode0::CD_OneBlock, SyncMode0::NumberOfWords.with(words));
|
||||
}
|
||||
};
|
||||
|
||||
struct SyncMode1 {
|
||||
static constexpr auto BlockSize = BitRange::from_to(0, 15);
|
||||
static constexpr auto BlockAmount = BitRange::from_to(16, 31);
|
||||
};
|
||||
|
||||
struct SyncMode2 {
|
||||
static constexpr BCR for_gpu_cmd() {
|
||||
return {0};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
__declare_io_struct(CHCHR, uint32_t) {
|
||||
enum SyncMode_t {
|
||||
Sync0 = 0, //Start immediately,
|
||||
Sync1 = 1, //Sync blocks to DMA requests
|
||||
Sync2 = 2, //Linked List
|
||||
};
|
||||
|
||||
static constexpr auto ManualStart = Bit(28);
|
||||
|
||||
static constexpr auto Start = Bit(24);
|
||||
static constexpr auto Busy = Start;
|
||||
|
||||
static constexpr auto ChoppingCPUWindowSize = BitRange::from_to(20, 22);
|
||||
static constexpr auto ChoppingDMAWindowSize = BitRange::from_to(16, 18);
|
||||
|
||||
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 = Bit(8);
|
||||
|
||||
static constexpr auto MemoryAdrDecreaseBy4 = Bit(1);
|
||||
static constexpr auto MemoryAdrIncreaseBy4 = !MemoryAdrDecreaseBy4;
|
||||
|
||||
static constexpr auto FromMainRAM = Bit(0);
|
||||
static constexpr auto ToMainRAM = !FromMainRAM;
|
||||
|
||||
static constexpr CHCHR StartMDECin() {
|
||||
return CHCHR{0x01000201};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartMDECout() {
|
||||
return CHCHR{0x01000200};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartGPUReceive() {
|
||||
return CHCHR{0x01000201};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartGPULinked() {
|
||||
return CHCHR{0x01000401};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartCDROM() {
|
||||
return CHCHR{0x11000000};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartSPUReceive() {
|
||||
return CHCHR{0x01000201};
|
||||
}
|
||||
|
||||
static constexpr CHCHR StartOTC() {
|
||||
return CHCHR{0x11000002};
|
||||
}
|
||||
};
|
||||
|
||||
__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);
|
||||
static constexpr auto EnableDPCR = BitRange::from_to(16, 22);
|
||||
static constexpr auto ForceIRQ = Bit(15);
|
||||
|
||||
static constexpr DICR empty() {
|
||||
return DICR{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(DPCR, uint32_t) {
|
||||
struct DMASetting {
|
||||
uint16_t master_bit;
|
||||
|
||||
static constexpr DMASetting create(uint16_t master_bit) {
|
||||
return DMASetting{master_bit};
|
||||
}
|
||||
|
||||
constexpr BitRange::RangeValuePair<uint32_t> turn_on(uint8_t priority) const {
|
||||
return BitRange::from_to(this->master_bit - 3, this->master_bit).with(static_cast<uint32_t>(0b1000 + (priority & 0b111)));
|
||||
}
|
||||
|
||||
constexpr ClearBit turn_off() const {
|
||||
return ClearBit(this->master_bit);
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr const auto OTC = DMASetting(27);
|
||||
static constexpr const auto PIO = DMASetting(23);
|
||||
static constexpr const auto SPU = DMASetting(19);
|
||||
static constexpr const auto CDROM = DMASetting(15);
|
||||
static constexpr const auto GPU = DMASetting(11);
|
||||
static constexpr const auto MDEC_Out = DMASetting(7);
|
||||
static constexpr const auto MDEC_In = DMASetting(3);
|
||||
|
||||
static constexpr auto OTCEnabled = Bit(27);
|
||||
static constexpr auto OTCPriority = BitRange::from_to(24, 26);
|
||||
|
||||
static constexpr auto PIOEnabled = Bit(23);
|
||||
static constexpr auto PIOPriority = BitRange::from_to(20, 22);
|
||||
|
||||
static constexpr auto SPUEnabled = Bit(19);
|
||||
static constexpr auto SPUPriority = BitRange::from_to(16, 18);
|
||||
|
||||
static constexpr auto CDROMEnabled = Bit(15);
|
||||
static constexpr auto CDROMPriority = BitRange::from_to(12, 14);
|
||||
|
||||
static constexpr auto GPUEnabled = Bit(11);
|
||||
static constexpr auto GPUPriority = BitRange::from_to(8, 10);
|
||||
|
||||
static constexpr auto MDECoutEnabled = Bit(7);
|
||||
static constexpr auto MDECoutPriority = BitRange::from_to(4, 6);
|
||||
|
||||
static constexpr auto MDECinEnabled = Bit(3);
|
||||
static constexpr auto MDECinPriority = BitRange::from_to(0, 2);
|
||||
};
|
||||
|
||||
__declare_io_struct(MADR, uint32_t) {
|
||||
static constexpr auto MemoryAdr = BitRange::from_to(0, 23);
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,220 +1,220 @@
|
||||
#pragma once
|
||||
#include "../../../GPU/gpu_types.hpp"
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace GPU_IO_Values {
|
||||
namespace internal {
|
||||
template<typename T>
|
||||
static constexpr T construct_cmd(uint32_t cmd, uint32_t value) {
|
||||
return T::from(T::ID.with(cmd), T::Value.with(value));
|
||||
}
|
||||
}
|
||||
|
||||
__declare_io_struct(DisplayMode, uint32_t) {
|
||||
enum AreaColorDepth {
|
||||
$15bit = 0,
|
||||
$24bit = 1,
|
||||
};
|
||||
|
||||
enum State {
|
||||
On = 0,
|
||||
Off = 1
|
||||
};
|
||||
|
||||
enum HorizontalResolution {
|
||||
$256 = 0,
|
||||
$320 = 1,
|
||||
$512 = 2,
|
||||
$640 = 3,
|
||||
};
|
||||
|
||||
enum struct TVEncoding {
|
||||
NTSC = 0,
|
||||
PAL = 1,
|
||||
};
|
||||
|
||||
enum VerticalResolution {
|
||||
$240 = 0,
|
||||
$480 = 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 DisplayMode PAL() {
|
||||
return DisplayMode::from(
|
||||
HorizontalResolution.with(HorizontalResolution::$320),
|
||||
VerticalResolution.with(VerticalResolution::$240),
|
||||
VideoMode.with(TVEncoding::PAL),
|
||||
DisplayAreaColorDepth.with(AreaColorDepth::$15bit)
|
||||
);
|
||||
}
|
||||
|
||||
static constexpr DisplayMode NTSC() {
|
||||
return DisplayMode::from(
|
||||
HorizontalResolution.with(HorizontalResolution::$320),
|
||||
VerticalResolution.with(VerticalResolution::$240),
|
||||
VideoMode.with(TVEncoding::NTSC),
|
||||
DisplayAreaColorDepth.with(AreaColorDepth::$15bit)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(GPUREAD, uint32_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(GPUSTAT, uint32_t) {
|
||||
enum DMADirection {
|
||||
Off = 0,
|
||||
Fifo = 1,
|
||||
CPU2GPU = 2,
|
||||
GPU2CPU = 3,
|
||||
};
|
||||
|
||||
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 = Bit(19);
|
||||
static constexpr auto TexturePageY256 = Bit(4);
|
||||
};
|
||||
|
||||
__declare_io_struct(GP0, uint32_t) {
|
||||
static constexpr auto ID = BitRange::from_to(24, 31);
|
||||
static constexpr auto Value = BitRange::from_to(0, 23);
|
||||
|
||||
static constexpr GP0 DrawAreaTemplate(uint8_t code, uint16_t x, uint16_t y) {
|
||||
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 internal::construct_cmd<GP0>(code, Y.as_value(static_cast<uint32_t>(y)) | X.as_value(static_cast<uint32_t>(x)));
|
||||
}
|
||||
|
||||
static constexpr GP0 ClearCache() {
|
||||
return internal::construct_cmd<GP0>(0x01, 0x0);
|
||||
}
|
||||
|
||||
static constexpr GP0 QuickFill(GPU::Color24 color) {
|
||||
return internal::construct_cmd<GP0>(0x02, color.raw());
|
||||
}
|
||||
|
||||
static constexpr GP0 VRAM2VRAMBlitting() {
|
||||
return internal::construct_cmd<GP0>(0x80, 0);
|
||||
}
|
||||
|
||||
static constexpr GP0 CPU2VRAMBlitting() {
|
||||
return internal::construct_cmd<GP0>(0xA0, 0);
|
||||
}
|
||||
|
||||
static constexpr GP0 TexPage(const GPU::PositionU16& page_pos, GPU::SemiTransparency transparency, GPU::TextureColorMode tex_color, bool dither, bool draw_on_display_area) {
|
||||
constexpr auto TexXRange = BitRange::from_to(0, 3);
|
||||
constexpr auto TexYRange = BitRange::from_to(4, 4);
|
||||
constexpr auto TransparencyRange = BitRange::from_to(5, 6);
|
||||
constexpr auto TextureColorRange = BitRange::from_to(7, 8);
|
||||
constexpr auto DitherBit = BitRange::from_to(9, 9);
|
||||
constexpr auto DrawOnDisplayAreaBit = BitRange::from_to(10, 10);
|
||||
|
||||
return internal::construct_cmd<GP0>(0xE1,
|
||||
TexXRange.as_value(page_pos.x >> 6) | TexYRange.as_value(page_pos.y >> 8) |
|
||||
TransparencyRange.as_value(static_cast<uint32_t>(transparency)) | TextureColorRange.as_value(static_cast<uint32_t>(tex_color)) |
|
||||
DitherBit.as_value(static_cast<uint32_t>(dither)) | DrawOnDisplayAreaBit.as_value(static_cast<uint32_t>(draw_on_display_area))
|
||||
);
|
||||
}
|
||||
|
||||
static constexpr GP0 DrawAreaTopLeft(const GPU::PositionU16& position) {
|
||||
return GP0::DrawAreaTemplate(0xE3, position.x, position.y);
|
||||
}
|
||||
|
||||
static constexpr GP0 DrawAreaBottomRight(const GPU::PositionU16& position) {
|
||||
return GP0::DrawAreaTemplate(0xE4, position.x, position.y);
|
||||
}
|
||||
|
||||
static constexpr GP0 DrawOffset(const GPU::PositionI16& offset) {
|
||||
constexpr auto X = BitRange::from_to(0, 10);
|
||||
constexpr auto Y = BitRange::from_to(11, 21);
|
||||
|
||||
return internal::construct_cmd<GPU_IO_Values::GP0>(0xE5, X.as_value(static_cast<int32_t>(offset.x)) | Y.as_value(static_cast<int32_t>(offset.y)));
|
||||
}
|
||||
|
||||
static constexpr GP0 PostionTopLeft(const GPU::PositionU16& position) {
|
||||
return GP0{(static_cast<uint32_t>(position.y) << 16u) | position.x};
|
||||
}
|
||||
|
||||
static constexpr GP0 WidthHeight(const GPU::SizeU16& size) {
|
||||
return GP0{(static_cast<uint32_t>(size.height) << 16u) | size.width};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(GP1, uint32_t) {
|
||||
static constexpr auto ID = BitRange::from_to(24, 31);
|
||||
static constexpr auto Value = BitRange::from_to(0, 23);
|
||||
|
||||
static constexpr GP1 Reset() {
|
||||
return GP1{0};
|
||||
}
|
||||
|
||||
static constexpr GP1 ResetCMDBuffer() {
|
||||
return internal::construct_cmd<GP1>(0x01, 0);
|
||||
}
|
||||
|
||||
static constexpr GP1 DisplayState(DisplayMode::State state) {
|
||||
return internal::construct_cmd<GP1>(0x03, static_cast<uint32_t>(state));
|
||||
}
|
||||
|
||||
static constexpr GP1 DMADirection(GPUSTAT::DMADirection dir) {
|
||||
return internal::construct_cmd<GP1>(0x04, dir);
|
||||
}
|
||||
|
||||
static constexpr GP1 DisplayArea(const GPU::PositionU16& position) {
|
||||
constexpr auto X = BitRange::from_to(0, 9);
|
||||
constexpr auto Y = BitRange::from_to(10, 18);
|
||||
|
||||
return internal::construct_cmd<GP1>(0x05, X.as_value(static_cast<uint32_t>(position.x)) | Y.as_value(static_cast<uint32_t>(position.y)));
|
||||
}
|
||||
|
||||
static constexpr GP1 HorizontalDisplayRange(uint16_t x1, uint16_t x2) {
|
||||
constexpr auto X1 = BitRange::from_to(0, 11);
|
||||
constexpr auto X2 = BitRange::from_to(12, 23);
|
||||
|
||||
return internal::construct_cmd<GP1>(0x06, X1.as_value(static_cast<uint32_t>(x1)) | X2.as_value(static_cast<uint32_t>(x2)));
|
||||
}
|
||||
|
||||
static constexpr GP1 VerticalDisplayRange(uint16_t y1, uint16_t y2) {
|
||||
constexpr auto Y1 = BitRange::from_to(0, 9);
|
||||
constexpr auto Y2 = BitRange::from_to(10, 19);
|
||||
|
||||
return internal::construct_cmd<GP1>(0x07, Y1.as_value(static_cast<uint32_t>(y1)) | Y2.as_value(static_cast<uint32_t>(y2)));
|
||||
}
|
||||
|
||||
static constexpr GP1 DisplayMode(GPU_IO_Values::DisplayMode mode) {
|
||||
return internal::construct_cmd<GP1>(0x08, mode.raw);
|
||||
}
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include "../../../GPU/gpu_types.hpp"
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace GPU_IO_Values {
|
||||
namespace internal {
|
||||
template<typename T>
|
||||
static constexpr T construct_cmd(uint32_t cmd, uint32_t value) {
|
||||
return T::from(T::ID.with(cmd), T::Value.with(value));
|
||||
}
|
||||
}
|
||||
|
||||
__declare_io_struct(DisplayMode, uint32_t) {
|
||||
enum AreaColorDepth {
|
||||
$15bit = 0,
|
||||
$24bit = 1,
|
||||
};
|
||||
|
||||
enum State {
|
||||
On = 0,
|
||||
Off = 1
|
||||
};
|
||||
|
||||
enum HorizontalResolution {
|
||||
$256 = 0,
|
||||
$320 = 1,
|
||||
$512 = 2,
|
||||
$640 = 3,
|
||||
};
|
||||
|
||||
enum struct TVEncoding {
|
||||
NTSC = 0,
|
||||
PAL = 1,
|
||||
};
|
||||
|
||||
enum VerticalResolution {
|
||||
$240 = 0,
|
||||
$480 = 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 DisplayMode PAL() {
|
||||
return DisplayMode::from(
|
||||
HorizontalResolution.with(HorizontalResolution::$320),
|
||||
VerticalResolution.with(VerticalResolution::$240),
|
||||
VideoMode.with(TVEncoding::PAL),
|
||||
DisplayAreaColorDepth.with(AreaColorDepth::$15bit)
|
||||
);
|
||||
}
|
||||
|
||||
static constexpr DisplayMode NTSC() {
|
||||
return DisplayMode::from(
|
||||
HorizontalResolution.with(HorizontalResolution::$320),
|
||||
VerticalResolution.with(VerticalResolution::$240),
|
||||
VideoMode.with(TVEncoding::NTSC),
|
||||
DisplayAreaColorDepth.with(AreaColorDepth::$15bit)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(GPUREAD, uint32_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(GPUSTAT, uint32_t) {
|
||||
enum DMADirection {
|
||||
Off = 0,
|
||||
Fifo = 1,
|
||||
CPU2GPU = 2,
|
||||
GPU2CPU = 3,
|
||||
};
|
||||
|
||||
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 = Bit(19);
|
||||
static constexpr auto TexturePageY256 = Bit(4);
|
||||
};
|
||||
|
||||
__declare_io_struct(GP0, uint32_t) {
|
||||
static constexpr auto ID = BitRange::from_to(24, 31);
|
||||
static constexpr auto Value = BitRange::from_to(0, 23);
|
||||
|
||||
static constexpr GP0 DrawAreaTemplate(uint8_t code, uint16_t x, uint16_t y) {
|
||||
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 internal::construct_cmd<GP0>(code, Y.as_value(static_cast<uint32_t>(y)) | X.as_value(static_cast<uint32_t>(x)));
|
||||
}
|
||||
|
||||
static constexpr GP0 ClearCache() {
|
||||
return internal::construct_cmd<GP0>(0x01, 0x0);
|
||||
}
|
||||
|
||||
static constexpr GP0 QuickFill(GPU::Color24 color) {
|
||||
return internal::construct_cmd<GP0>(0x02, color.raw());
|
||||
}
|
||||
|
||||
static constexpr GP0 VRAM2VRAMBlitting() {
|
||||
return internal::construct_cmd<GP0>(0x80, 0);
|
||||
}
|
||||
|
||||
static constexpr GP0 CPU2VRAMBlitting() {
|
||||
return internal::construct_cmd<GP0>(0xA0, 0);
|
||||
}
|
||||
|
||||
static constexpr GP0 TexPage(const GPU::PositionU16& page_pos, GPU::SemiTransparency transparency, GPU::TextureColorMode tex_color, bool dither, bool draw_on_display_area) {
|
||||
constexpr auto TexXRange = BitRange::from_to(0, 3);
|
||||
constexpr auto TexYRange = BitRange::from_to(4, 4);
|
||||
constexpr auto TransparencyRange = BitRange::from_to(5, 6);
|
||||
constexpr auto TextureColorRange = BitRange::from_to(7, 8);
|
||||
constexpr auto DitherBit = BitRange::from_to(9, 9);
|
||||
constexpr auto DrawOnDisplayAreaBit = BitRange::from_to(10, 10);
|
||||
|
||||
return internal::construct_cmd<GP0>(0xE1,
|
||||
TexXRange.as_value(page_pos.x >> 6) | TexYRange.as_value(page_pos.y >> 8) |
|
||||
TransparencyRange.as_value(static_cast<uint32_t>(transparency)) | TextureColorRange.as_value(static_cast<uint32_t>(tex_color)) |
|
||||
DitherBit.as_value(static_cast<uint32_t>(dither)) | DrawOnDisplayAreaBit.as_value(static_cast<uint32_t>(draw_on_display_area))
|
||||
);
|
||||
}
|
||||
|
||||
static constexpr GP0 DrawAreaTopLeft(const GPU::PositionU16& position) {
|
||||
return GP0::DrawAreaTemplate(0xE3, position.x, position.y);
|
||||
}
|
||||
|
||||
static constexpr GP0 DrawAreaBottomRight(const GPU::PositionU16& position) {
|
||||
return GP0::DrawAreaTemplate(0xE4, position.x, position.y);
|
||||
}
|
||||
|
||||
static constexpr GP0 DrawOffset(const GPU::PositionI16& offset) {
|
||||
constexpr auto X = BitRange::from_to(0, 10);
|
||||
constexpr auto Y = BitRange::from_to(11, 21);
|
||||
|
||||
return internal::construct_cmd<GPU_IO_Values::GP0>(0xE5, X.as_value(static_cast<int32_t>(offset.x)) | Y.as_value(static_cast<int32_t>(offset.y)));
|
||||
}
|
||||
|
||||
static constexpr GP0 PostionTopLeft(const GPU::PositionU16& position) {
|
||||
return GP0{(static_cast<uint32_t>(position.y) << 16u) | position.x};
|
||||
}
|
||||
|
||||
static constexpr GP0 WidthHeight(const GPU::SizeU16& size) {
|
||||
return GP0{(static_cast<uint32_t>(size.height) << 16u) | size.width};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(GP1, uint32_t) {
|
||||
static constexpr auto ID = BitRange::from_to(24, 31);
|
||||
static constexpr auto Value = BitRange::from_to(0, 23);
|
||||
|
||||
static constexpr GP1 Reset() {
|
||||
return GP1{0};
|
||||
}
|
||||
|
||||
static constexpr GP1 ResetCMDBuffer() {
|
||||
return internal::construct_cmd<GP1>(0x01, 0);
|
||||
}
|
||||
|
||||
static constexpr GP1 DisplayState(DisplayMode::State state) {
|
||||
return internal::construct_cmd<GP1>(0x03, static_cast<uint32_t>(state));
|
||||
}
|
||||
|
||||
static constexpr GP1 DMADirection(GPUSTAT::DMADirection dir) {
|
||||
return internal::construct_cmd<GP1>(0x04, dir);
|
||||
}
|
||||
|
||||
static constexpr GP1 DisplayArea(const GPU::PositionU16& position) {
|
||||
constexpr auto X = BitRange::from_to(0, 9);
|
||||
constexpr auto Y = BitRange::from_to(10, 18);
|
||||
|
||||
return internal::construct_cmd<GP1>(0x05, X.as_value(static_cast<uint32_t>(position.x)) | Y.as_value(static_cast<uint32_t>(position.y)));
|
||||
}
|
||||
|
||||
static constexpr GP1 HorizontalDisplayRange(uint16_t x1, uint16_t x2) {
|
||||
constexpr auto X1 = BitRange::from_to(0, 11);
|
||||
constexpr auto X2 = BitRange::from_to(12, 23);
|
||||
|
||||
return internal::construct_cmd<GP1>(0x06, X1.as_value(static_cast<uint32_t>(x1)) | X2.as_value(static_cast<uint32_t>(x2)));
|
||||
}
|
||||
|
||||
static constexpr GP1 VerticalDisplayRange(uint16_t y1, uint16_t y2) {
|
||||
constexpr auto Y1 = BitRange::from_to(0, 9);
|
||||
constexpr auto Y2 = BitRange::from_to(10, 19);
|
||||
|
||||
return internal::construct_cmd<GP1>(0x07, Y1.as_value(static_cast<uint32_t>(y1)) | Y2.as_value(static_cast<uint32_t>(y2)));
|
||||
}
|
||||
|
||||
static constexpr GP1 DisplayMode(GPU_IO_Values::DisplayMode mode) {
|
||||
return internal::construct_cmd<GP1>(0x08, mode.raw);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Interrupt_IO_Values {
|
||||
__declare_io_struct(Mask, uint32_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(Status, uint32_t) {
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Interrupt_IO_Values {
|
||||
__declare_io_struct(Mask, uint32_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(Status, uint32_t) {
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,118 +1,118 @@
|
||||
#pragma once
|
||||
#include "../../../Auxiliary/types.hpp"
|
||||
#include "../../../Auxiliary/bits.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace IOAdress {
|
||||
constexpr uintptr_t patch_adr(uintptr_t adr) {
|
||||
constexpr uintptr_t Mask = 0xF0000000;
|
||||
constexpr uintptr_t Base = 0x10000000; // We might want to change this later to 0xB0000000 for caching and stuff (More research needed)
|
||||
|
||||
return (Base + (adr & ~Mask));
|
||||
}
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
template<typename T, typename S>
|
||||
struct IOValue {
|
||||
typedef S UnderlyingType;
|
||||
|
||||
UnderlyingType raw;
|
||||
|
||||
template<typename...ARGS>
|
||||
static constexpr T from(const ARGS&...args) {
|
||||
return T{0}.set(args...);
|
||||
}
|
||||
|
||||
constexpr T& set(Bit bit) {
|
||||
this->raw = bit::set(this->raw, bit);
|
||||
return static_cast<T&>(*this);
|
||||
}
|
||||
|
||||
constexpr T& set(ClearBit bit) {
|
||||
this->raw = bit::set(this->raw, bit);
|
||||
return static_cast<T&>(*this);
|
||||
}
|
||||
|
||||
constexpr T& set_range(const BitRange& bits, UnderlyingType value) {
|
||||
this->raw = bit::value::set_normalized(this->raw, bits, value);
|
||||
return static_cast<T&>(*this);
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
constexpr T& set(const BitRange::RangeValuePair<U>& value) {
|
||||
this->raw = bit::value::set_normalized(this->raw, value);
|
||||
return static_cast<T&>(*this);
|
||||
}
|
||||
|
||||
template<typename U, typename...ARGS>
|
||||
constexpr T& set(const U& head, const ARGS&...tail) {
|
||||
return this->set(head).set(tail...);
|
||||
}
|
||||
|
||||
constexpr IOValue<T, S>::UnderlyingType get(BitRange bits) const {
|
||||
return bit::value::get_normalized(this->raw, bits.pos, bits.length);
|
||||
}
|
||||
|
||||
constexpr T& clear(Bit bit) {
|
||||
this->raw = bit::clear(this->raw, bit);
|
||||
return static_cast<T&>(*this);
|
||||
}
|
||||
|
||||
constexpr bool is_set(Bit bit) const {
|
||||
return bit::is_set(this->raw, bit);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct IOPort {
|
||||
using Value = T;
|
||||
T value;
|
||||
|
||||
T read() const {
|
||||
return {const_cast<const volatile IOPort<T>*>(this)->value.raw};
|
||||
}
|
||||
|
||||
void write(T value) {
|
||||
const_cast<volatile IOPort<T>*>(this)->value.raw = value.raw;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct IOPort<uint32_t>;
|
||||
|
||||
template<typename T>
|
||||
struct IOPort32 {
|
||||
union ValueHelper {
|
||||
struct {
|
||||
uint16_t low;
|
||||
uint16_t high;
|
||||
};
|
||||
T value;
|
||||
};
|
||||
using Value = T;
|
||||
T value;
|
||||
|
||||
T read() const {
|
||||
const auto* cast_this = reinterpret_cast<const IOPort32<ValueHelper>*>(this);
|
||||
const volatile auto* cv_this = const_cast<volatile decltype(cast_this)>(cast_this);
|
||||
|
||||
return ValueHelper{.low = cv_this->value.low, .high = cv_this->value.high}.value;
|
||||
}
|
||||
|
||||
void write(T value) {
|
||||
const auto new_value = ValueHelper{.value = value};
|
||||
auto* cast_this = reinterpret_cast<IOPort32<ValueHelper>*>(this);
|
||||
volatile auto* v_this = const_cast<volatile decltype(cast_this)>(cast_this);
|
||||
|
||||
v_this->value.low = new_value.low;
|
||||
v_this->value.high = new_value.high;
|
||||
}
|
||||
};
|
||||
|
||||
#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))
|
||||
#pragma once
|
||||
#include "../../../Auxiliary/types.hpp"
|
||||
#include "../../../Auxiliary/bits.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace IOAdress {
|
||||
constexpr uintptr_t patch_adr(uintptr_t adr) {
|
||||
constexpr uintptr_t Mask = 0xF0000000;
|
||||
constexpr uintptr_t Base = 0x10000000; // We might want to change this later to 0xB0000000 for caching and stuff (More research needed)
|
||||
|
||||
return (Base + (adr & ~Mask));
|
||||
}
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
template<typename T, typename S>
|
||||
struct IOValue {
|
||||
typedef S UnderlyingType;
|
||||
|
||||
UnderlyingType raw;
|
||||
|
||||
template<typename...ARGS>
|
||||
static constexpr T from(const ARGS&...args) {
|
||||
return T{0}.set(args...);
|
||||
}
|
||||
|
||||
constexpr T& set(Bit bit) {
|
||||
this->raw = bit::set(this->raw, bit);
|
||||
return static_cast<T&>(*this);
|
||||
}
|
||||
|
||||
constexpr T& set(ClearBit bit) {
|
||||
this->raw = bit::set(this->raw, bit);
|
||||
return static_cast<T&>(*this);
|
||||
}
|
||||
|
||||
constexpr T& set_range(const BitRange& bits, UnderlyingType value) {
|
||||
this->raw = bit::value::set_normalized(this->raw, bits, value);
|
||||
return static_cast<T&>(*this);
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
constexpr T& set(const BitRange::RangeValuePair<U>& value) {
|
||||
this->raw = bit::value::set_normalized(this->raw, value);
|
||||
return static_cast<T&>(*this);
|
||||
}
|
||||
|
||||
template<typename U, typename...ARGS>
|
||||
constexpr T& set(const U& head, const ARGS&...tail) {
|
||||
return this->set(head).set(tail...);
|
||||
}
|
||||
|
||||
constexpr IOValue<T, S>::UnderlyingType get(BitRange bits) const {
|
||||
return bit::value::get_normalized(this->raw, bits.pos, bits.length);
|
||||
}
|
||||
|
||||
constexpr T& clear(Bit bit) {
|
||||
this->raw = bit::clear(this->raw, bit);
|
||||
return static_cast<T&>(*this);
|
||||
}
|
||||
|
||||
constexpr bool is_set(Bit bit) const {
|
||||
return bit::is_set(this->raw, bit);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct IOPort {
|
||||
using Value = T;
|
||||
T value;
|
||||
|
||||
T read() const {
|
||||
return {const_cast<const volatile IOPort<T>*>(this)->value.raw};
|
||||
}
|
||||
|
||||
void write(T value) {
|
||||
const_cast<volatile IOPort<T>*>(this)->value.raw = value.raw;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct IOPort<uint32_t>;
|
||||
|
||||
template<typename T>
|
||||
struct IOPort32 {
|
||||
union ValueHelper {
|
||||
struct {
|
||||
uint16_t low;
|
||||
uint16_t high;
|
||||
};
|
||||
T value;
|
||||
};
|
||||
using Value = T;
|
||||
T value;
|
||||
|
||||
T read() const {
|
||||
const auto* cast_this = reinterpret_cast<const IOPort32<ValueHelper>*>(this);
|
||||
const volatile auto* cv_this = const_cast<volatile decltype(cast_this)>(cast_this);
|
||||
|
||||
return ValueHelper{.low = cv_this->value.low, .high = cv_this->value.high}.value;
|
||||
}
|
||||
|
||||
void write(T value) {
|
||||
const auto new_value = ValueHelper{.value = value};
|
||||
auto* cast_this = reinterpret_cast<IOPort32<ValueHelper>*>(this);
|
||||
volatile auto* v_this = const_cast<volatile decltype(cast_this)>(cast_this);
|
||||
|
||||
v_this->value.low = new_value.low;
|
||||
v_this->value.high = new_value.high;
|
||||
}
|
||||
};
|
||||
|
||||
#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))
|
||||
}
|
@@ -1,18 +1,18 @@
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Memory_IO_Values {
|
||||
__declare_io_struct(CD_DELAY, uint32_t) {
|
||||
static constexpr CD_DELAY create() {
|
||||
return CD_DELAY{0x20943};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(COM_DELAY, uint32_t) {
|
||||
static constexpr COM_DELAY create() {
|
||||
return COM_DELAY{0x1325};
|
||||
}
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Memory_IO_Values {
|
||||
__declare_io_struct(CD_DELAY, uint32_t) {
|
||||
static constexpr CD_DELAY create() {
|
||||
return CD_DELAY{0x20943};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(COM_DELAY, uint32_t) {
|
||||
static constexpr COM_DELAY create() {
|
||||
return COM_DELAY{0x1325};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,52 +1,52 @@
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Periphery_IO_Values {
|
||||
__declare_io_struct(JOY_BAUD, uint16_t) {
|
||||
static constexpr JOY_BAUD create() {
|
||||
return JOY_BAUD{0x0088};
|
||||
}
|
||||
};
|
||||
|
||||
__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);
|
||||
static constexpr auto ACKIrqEnable = Bit(12);
|
||||
static constexpr auto PortBSelected = Bit(13);
|
||||
static constexpr auto PortASelected = !PortBSelected;
|
||||
|
||||
static constexpr JOY_CTRL create_for(uint16_t port) {
|
||||
return JOY_CTRL{static_cast<uint16_t>(port << PortBSelected)}.set(TXEnable, SelectJoy, ACKIrqEnable);
|
||||
}
|
||||
|
||||
static constexpr JOY_CTRL close() {
|
||||
return JOY_CTRL{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(JOY_MODE, uint16_t) {
|
||||
static constexpr JOY_MODE create() {
|
||||
return JOY_MODE{0x000D};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(JOY_RX_DATA, uint8_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);
|
||||
static constexpr auto RXParityError = Bit(3);
|
||||
static constexpr auto ACKIrqLow = Bit(7);
|
||||
};
|
||||
|
||||
__declare_io_struct(JOY_TX_DATA, uint32_t) {
|
||||
static constexpr JOY_TX_DATA create(uint8_t byte) {
|
||||
return JOY_TX_DATA{byte};
|
||||
}
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Periphery_IO_Values {
|
||||
__declare_io_struct(JOY_BAUD, uint16_t) {
|
||||
static constexpr JOY_BAUD create() {
|
||||
return JOY_BAUD{0x0088};
|
||||
}
|
||||
};
|
||||
|
||||
__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);
|
||||
static constexpr auto ACKIrqEnable = Bit(12);
|
||||
static constexpr auto PortBSelected = Bit(13);
|
||||
static constexpr auto PortASelected = !PortBSelected;
|
||||
|
||||
static constexpr JOY_CTRL create_for(uint16_t port) {
|
||||
return JOY_CTRL{static_cast<uint16_t>(port << PortBSelected)}.set(TXEnable, SelectJoy, ACKIrqEnable);
|
||||
}
|
||||
|
||||
static constexpr JOY_CTRL close() {
|
||||
return JOY_CTRL{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(JOY_MODE, uint16_t) {
|
||||
static constexpr JOY_MODE create() {
|
||||
return JOY_MODE{0x000D};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(JOY_RX_DATA, uint8_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);
|
||||
static constexpr auto RXParityError = Bit(3);
|
||||
static constexpr auto ACKIrqLow = Bit(7);
|
||||
};
|
||||
|
||||
__declare_io_struct(JOY_TX_DATA, uint32_t) {
|
||||
static constexpr JOY_TX_DATA create(uint8_t byte) {
|
||||
return JOY_TX_DATA{byte};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,215 +1,215 @@
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
#include <limits.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace SPU_IO_Values {
|
||||
namespace MemoryMap {
|
||||
static constexpr uintptr_t ADPCM = 0x01000;
|
||||
static constexpr uintptr_t End = 0x7FFFF;
|
||||
}
|
||||
|
||||
__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);
|
||||
static constexpr auto DecayShift = BitRange::from_to(4, 7);
|
||||
static constexpr auto SustainLevel = BitRange::from_to(0, 3);
|
||||
|
||||
static constexpr AD none() {
|
||||
return AD{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(ControlRegister, uint16_t) {
|
||||
enum RAMTransferMode {
|
||||
Stop = 0,
|
||||
ManualWrite = 1,
|
||||
DMAWrite = 2,
|
||||
DMARead = 3
|
||||
};
|
||||
|
||||
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_struct(DataTransferControl, uint16_t) {
|
||||
static constexpr DataTransferControl NormalTransferMode() {
|
||||
return DataTransferControl{0x0004};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(Echo, uint32_t) {
|
||||
static constexpr auto EchoBits = BitRange::from_to(0, 23);
|
||||
|
||||
static constexpr Echo AllOff() {
|
||||
return Echo{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(KeyOff, uint32_t) {
|
||||
static constexpr KeyOff for_specific(uint32_t id) {
|
||||
return KeyOff{1u << id};
|
||||
}
|
||||
|
||||
static constexpr KeyOff all() {
|
||||
return KeyOff{UI32_MAX};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(KeyOn, uint32_t) {
|
||||
static constexpr KeyOn for_specific(uint32_t id) {
|
||||
return KeyOn{1u << id};
|
||||
}
|
||||
|
||||
static constexpr KeyOn all() {
|
||||
return KeyOn{UI32_MAX};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(KeyStatus, uint32_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(Noise, uint16_t) {
|
||||
static constexpr auto NoiseBits = BitRange::from_to(0, 23);
|
||||
|
||||
static constexpr Noise AllOff() {
|
||||
return Noise{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(PitchModulation, uint32_t) {
|
||||
static constexpr auto EnableBits = BitRange::from_to(1, 23);
|
||||
|
||||
static constexpr PitchModulation AllOff() {
|
||||
return PitchModulation{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(SampleRate, uint16_t) {
|
||||
static constexpr SampleRate stop() {
|
||||
return SampleRate{0};
|
||||
}
|
||||
|
||||
static constexpr SampleRate from_HZ(uint32_t freq) {
|
||||
constexpr uint32_t Base1024Hz = static_cast<uint32_t>((4096.0/44100.0)*1024.0);
|
||||
return SampleRate{static_cast<uint16_t>((freq >> 10)*Base1024Hz)};
|
||||
}
|
||||
|
||||
static constexpr SampleRate from_HZ(double freq) {
|
||||
//4096 == 44100Hz
|
||||
constexpr double Base = (4096.0 / 44100.0);
|
||||
return SampleRate{static_cast<uint16_t>((freq*Base))};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(SimpleVolume, int16_t) {
|
||||
static constexpr auto MaxVolume = I16_MAX;
|
||||
|
||||
static constexpr SimpleVolume mute() {
|
||||
return SimpleVolume{0};
|
||||
}
|
||||
|
||||
constexpr operator int16_t() const {
|
||||
return this->raw;
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr SimpleVolume operator""_vol(long double fraction) {
|
||||
return {static_cast<int16_t>(static_cast<long double>(SimpleVolume::MaxVolume)*fraction)};
|
||||
}
|
||||
|
||||
__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));
|
||||
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));
|
||||
|
||||
static constexpr SR none() {
|
||||
return SR{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(SRAMAdr, uint16_t) {
|
||||
static constexpr SRAMAdr null() {
|
||||
return SRAMAdr{0x0};
|
||||
}
|
||||
|
||||
static constexpr SRAMAdr adpcm_start() {
|
||||
return SRAMAdr{MemoryMap::ADPCM};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(StatusRegister, uint16_t) {
|
||||
enum CapureBufferHalf {
|
||||
First = 0,
|
||||
Second = 1
|
||||
};
|
||||
|
||||
static constexpr auto Unused = BitRange::from_to(12, 15);
|
||||
static constexpr auto CaputreBufferHalf = Bit(11);
|
||||
static constexpr auto TransferBusy = Bit(10);
|
||||
static constexpr auto IsDMARead = Bit(9);
|
||||
static constexpr auto isDMAWrite = Bit(8);
|
||||
static constexpr auto isDMA = Bit(7);
|
||||
static constexpr auto isIRQ = Bit(6);
|
||||
// Copies of ControlRegister
|
||||
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_struct(SweepVolume, int16_t) {
|
||||
struct VolumeMode {
|
||||
static constexpr auto MaxVolume = (I16_MAX >> 1);
|
||||
static constexpr auto EnableSweep = Bit(15);
|
||||
static constexpr auto Enable = !EnableSweep;
|
||||
static constexpr auto Volume = BitRange::from_to(0, 14);
|
||||
};
|
||||
|
||||
struct SweepMode {
|
||||
enum Mode {
|
||||
Linear = 0,
|
||||
Exponential = 1,
|
||||
};
|
||||
|
||||
enum Direction {
|
||||
Increase = 0,
|
||||
Decrease = 1,
|
||||
};
|
||||
|
||||
enum Phase {
|
||||
Posititve = 0,
|
||||
Negative = 1,
|
||||
};
|
||||
|
||||
static constexpr auto Mode = Bit(14);
|
||||
static constexpr auto Direction = Bit(13);
|
||||
static constexpr auto Phase = Bit(12);
|
||||
static constexpr auto Shift = BitRange::from_to(2, 6);
|
||||
static constexpr auto Step = BitRange::from_to(0, 1);
|
||||
};
|
||||
|
||||
static constexpr SweepVolume create(SimpleVolume volume) {
|
||||
return from(VolumeMode::Enable, VolumeMode::Volume.with(volume.raw >> 1));
|
||||
}
|
||||
|
||||
static constexpr SweepVolume mute() {
|
||||
return SweepVolume{0};
|
||||
}
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
#include <limits.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace SPU_IO_Values {
|
||||
namespace MemoryMap {
|
||||
static constexpr uintptr_t ADPCM = 0x01000;
|
||||
static constexpr uintptr_t End = 0x7FFFF;
|
||||
}
|
||||
|
||||
__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);
|
||||
static constexpr auto DecayShift = BitRange::from_to(4, 7);
|
||||
static constexpr auto SustainLevel = BitRange::from_to(0, 3);
|
||||
|
||||
static constexpr AD none() {
|
||||
return AD{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(ControlRegister, uint16_t) {
|
||||
enum RAMTransferMode {
|
||||
Stop = 0,
|
||||
ManualWrite = 1,
|
||||
DMAWrite = 2,
|
||||
DMARead = 3
|
||||
};
|
||||
|
||||
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_struct(DataTransferControl, uint16_t) {
|
||||
static constexpr DataTransferControl NormalTransferMode() {
|
||||
return DataTransferControl{0x0004};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(Echo, uint32_t) {
|
||||
static constexpr auto EchoBits = BitRange::from_to(0, 23);
|
||||
|
||||
static constexpr Echo AllOff() {
|
||||
return Echo{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(KeyOff, uint32_t) {
|
||||
static constexpr KeyOff for_specific(uint32_t id) {
|
||||
return KeyOff{1u << id};
|
||||
}
|
||||
|
||||
static constexpr KeyOff all() {
|
||||
return KeyOff{UI32_MAX};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(KeyOn, uint32_t) {
|
||||
static constexpr KeyOn for_specific(uint32_t id) {
|
||||
return KeyOn{1u << id};
|
||||
}
|
||||
|
||||
static constexpr KeyOn all() {
|
||||
return KeyOn{UI32_MAX};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(KeyStatus, uint32_t) {
|
||||
};
|
||||
|
||||
__declare_io_struct(Noise, uint16_t) {
|
||||
static constexpr auto NoiseBits = BitRange::from_to(0, 23);
|
||||
|
||||
static constexpr Noise AllOff() {
|
||||
return Noise{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(PitchModulation, uint32_t) {
|
||||
static constexpr auto EnableBits = BitRange::from_to(1, 23);
|
||||
|
||||
static constexpr PitchModulation AllOff() {
|
||||
return PitchModulation{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(SampleRate, uint16_t) {
|
||||
static constexpr SampleRate stop() {
|
||||
return SampleRate{0};
|
||||
}
|
||||
|
||||
static constexpr SampleRate from_HZ(uint32_t freq) {
|
||||
constexpr uint32_t Base1024Hz = static_cast<uint32_t>((4096.0/44100.0)*1024.0);
|
||||
return SampleRate{static_cast<uint16_t>((freq >> 10)*Base1024Hz)};
|
||||
}
|
||||
|
||||
static constexpr SampleRate from_HZ(double freq) {
|
||||
//4096 == 44100Hz
|
||||
constexpr double Base = (4096.0 / 44100.0);
|
||||
return SampleRate{static_cast<uint16_t>((freq*Base))};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(SimpleVolume, int16_t) {
|
||||
static constexpr auto MaxVolume = I16_MAX;
|
||||
|
||||
static constexpr SimpleVolume mute() {
|
||||
return SimpleVolume{0};
|
||||
}
|
||||
|
||||
constexpr operator int16_t() const {
|
||||
return this->raw;
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr SimpleVolume operator""_vol(long double fraction) {
|
||||
return {static_cast<int16_t>(static_cast<long double>(SimpleVolume::MaxVolume)*fraction)};
|
||||
}
|
||||
|
||||
__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));
|
||||
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));
|
||||
|
||||
static constexpr SR none() {
|
||||
return SR{0};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(SRAMAdr, uint16_t) {
|
||||
static constexpr SRAMAdr null() {
|
||||
return SRAMAdr{0x0};
|
||||
}
|
||||
|
||||
static constexpr SRAMAdr adpcm_start() {
|
||||
return SRAMAdr{MemoryMap::ADPCM};
|
||||
}
|
||||
};
|
||||
|
||||
__declare_io_struct(StatusRegister, uint16_t) {
|
||||
enum CapureBufferHalf {
|
||||
First = 0,
|
||||
Second = 1
|
||||
};
|
||||
|
||||
static constexpr auto Unused = BitRange::from_to(12, 15);
|
||||
static constexpr auto CaputreBufferHalf = Bit(11);
|
||||
static constexpr auto TransferBusy = Bit(10);
|
||||
static constexpr auto IsDMARead = Bit(9);
|
||||
static constexpr auto isDMAWrite = Bit(8);
|
||||
static constexpr auto isDMA = Bit(7);
|
||||
static constexpr auto isIRQ = Bit(6);
|
||||
// Copies of ControlRegister
|
||||
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_struct(SweepVolume, int16_t) {
|
||||
struct VolumeMode {
|
||||
static constexpr auto MaxVolume = (I16_MAX >> 1);
|
||||
static constexpr auto EnableSweep = Bit(15);
|
||||
static constexpr auto Enable = !EnableSweep;
|
||||
static constexpr auto Volume = BitRange::from_to(0, 14);
|
||||
};
|
||||
|
||||
struct SweepMode {
|
||||
enum Mode {
|
||||
Linear = 0,
|
||||
Exponential = 1,
|
||||
};
|
||||
|
||||
enum Direction {
|
||||
Increase = 0,
|
||||
Decrease = 1,
|
||||
};
|
||||
|
||||
enum Phase {
|
||||
Posititve = 0,
|
||||
Negative = 1,
|
||||
};
|
||||
|
||||
static constexpr auto Mode = Bit(14);
|
||||
static constexpr auto Direction = Bit(13);
|
||||
static constexpr auto Phase = Bit(12);
|
||||
static constexpr auto Shift = BitRange::from_to(2, 6);
|
||||
static constexpr auto Step = BitRange::from_to(0, 1);
|
||||
};
|
||||
|
||||
static constexpr SweepVolume create(SimpleVolume volume) {
|
||||
return from(VolumeMode::Enable, VolumeMode::Volume.with(volume.raw >> 1));
|
||||
}
|
||||
|
||||
static constexpr SweepVolume mute() {
|
||||
return SweepVolume{0};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,31 +1,31 @@
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Timer_IO_Values {
|
||||
__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);
|
||||
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 = Bit(7);
|
||||
static constexpr auto IRQPulse = !IRQToggle;
|
||||
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_struct(CounterTarget, uint32_t) {
|
||||
static constexpr auto CounterTargetValue = BitRange::from_to(0, 15);
|
||||
};
|
||||
|
||||
__declare_io_struct(CounterValue, uint32_t) {
|
||||
static constexpr auto Value = BitRange::from_to(0, 15);
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include "ioport.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Timer_IO_Values {
|
||||
__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);
|
||||
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 = Bit(7);
|
||||
static constexpr auto IRQPulse = !IRQToggle;
|
||||
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_struct(CounterTarget, uint32_t) {
|
||||
static constexpr auto CounterTargetValue = BitRange::from_to(0, 15);
|
||||
};
|
||||
|
||||
__declare_io_struct(CounterValue, uint32_t) {
|
||||
static constexpr auto Value = BitRange::from_to(0, 15);
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,41 +1,41 @@
|
||||
#pragma once
|
||||
#include "IOValues/interrupt_io_values.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
using Status_IO = IOPort<Interrupt_IO_Values::Status>;
|
||||
using Mask_IO = IOPort<Interrupt_IO_Values::Mask>;
|
||||
|
||||
struct Interrupt {
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void ack_irq(Bit irq) {
|
||||
Status.write({bit::clear<uint32_t>(0b11111111111, irq)});
|
||||
}
|
||||
|
||||
static void disable_irq(Bit irq) {
|
||||
Mask.write(Mask.read().clear(irq));
|
||||
}
|
||||
|
||||
static void enable_irq(Bit irq) {
|
||||
Mask.write(Mask.read().set(irq));
|
||||
}
|
||||
};
|
||||
#pragma once
|
||||
#include "IOValues/interrupt_io_values.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
using Status_IO = IOPort<Interrupt_IO_Values::Status>;
|
||||
using Mask_IO = IOPort<Interrupt_IO_Values::Mask>;
|
||||
|
||||
struct Interrupt {
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void ack_irq(Bit irq) {
|
||||
Status.write({bit::clear<uint32_t>(0b11111111111, irq)});
|
||||
}
|
||||
|
||||
static void disable_irq(Bit irq) {
|
||||
Mask.write(Mask.read().clear(irq));
|
||||
}
|
||||
|
||||
static void enable_irq(Bit irq) {
|
||||
Mask.write(Mask.read().set(irq));
|
||||
}
|
||||
};
|
||||
}
|
@@ -1,29 +1,29 @@
|
||||
#pragma once
|
||||
#include "IOValues/periphery_io_values.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Periphery_IO {
|
||||
struct JOY_STAT_IO : public IOPort<Periphery_IO_Values::JOY_STAT> {
|
||||
inline bool has_response() const {
|
||||
return this->read().is_set(Periphery_IO_Values::JOY_STAT::RXFifoNonEmpty);
|
||||
}
|
||||
|
||||
inline bool is_ready_transfer() const {
|
||||
return this->read().is_set(Periphery_IO_Values::JOY_STAT::TXReadyFinished);
|
||||
}
|
||||
};
|
||||
|
||||
using JOY_BAUD_IO = IOPort<Periphery_IO_Values::JOY_BAUD>;
|
||||
using JOY_CTRL_IO = IOPort<Periphery_IO_Values::JOY_CTRL>;
|
||||
using JOY_MODE_IO = IOPort<Periphery_IO_Values::JOY_MODE>;
|
||||
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 = __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);
|
||||
}
|
||||
#pragma once
|
||||
#include "IOValues/periphery_io_values.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Periphery_IO {
|
||||
struct JOY_STAT_IO : public IOPort<Periphery_IO_Values::JOY_STAT> {
|
||||
inline bool has_response() const {
|
||||
return this->read().is_set(Periphery_IO_Values::JOY_STAT::RXFifoNonEmpty);
|
||||
}
|
||||
|
||||
inline bool is_ready_transfer() const {
|
||||
return this->read().is_set(Periphery_IO_Values::JOY_STAT::TXReadyFinished);
|
||||
}
|
||||
};
|
||||
|
||||
using JOY_BAUD_IO = IOPort<Periphery_IO_Values::JOY_BAUD>;
|
||||
using JOY_CTRL_IO = IOPort<Periphery_IO_Values::JOY_CTRL>;
|
||||
using JOY_MODE_IO = IOPort<Periphery_IO_Values::JOY_MODE>;
|
||||
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 = __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);
|
||||
}
|
||||
}
|
@@ -1,89 +1,89 @@
|
||||
#pragma once
|
||||
#include "IOValues/timer_io_values.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Timer_IO {
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
|
||||
inline void set_target_value(uint16_t value) {
|
||||
this->target.write(Timer_IO_Values::CounterTarget{0}.set_range(Timer_IO_Values::CounterTarget::CounterTargetValue, value));
|
||||
}
|
||||
|
||||
inline void set_mode(Timer_IO_Values::CounterMode mode) {
|
||||
this->mode.write(mode);
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct Counter0 : public Counter {
|
||||
struct SyncMode {
|
||||
static constexpr auto Zero_At_Hblank = Timer_IO_Values::CounterMode::SyncMode.with(1u);
|
||||
static constexpr auto Pause_During_Hblank = Timer_IO_Values::CounterMode::SyncMode.with(0u);
|
||||
static constexpr auto Zero_At_Hblank_Pause_Outside_Hblank = Timer_IO_Values::CounterMode::SyncMode.with(2u);
|
||||
static constexpr auto Pause_Until_Hblank_Then_Freerun = Timer_IO_Values::CounterMode::SyncMode.with(3u);
|
||||
};
|
||||
|
||||
struct Source {
|
||||
static constexpr auto System_Clock = Timer_IO_Values::CounterMode::ClockSource.with(0u);
|
||||
static constexpr auto Dot_Clock = Timer_IO_Values::CounterMode::ClockSource.with(1u);
|
||||
static constexpr auto System_Clock_Too = Timer_IO_Values::CounterMode::ClockSource.with(2u);
|
||||
static constexpr auto Dot_Clock_Too = Timer_IO_Values::CounterMode::ClockSource.with(3u);
|
||||
};
|
||||
};
|
||||
|
||||
struct Counter1 : public Counter {
|
||||
struct SyncMode {
|
||||
static constexpr auto Pause_During_Vblank = Timer_IO_Values::CounterMode::SyncMode.with(0u);
|
||||
static constexpr auto Zero_At_Vblank = Timer_IO_Values::CounterMode::SyncMode.with(1u);
|
||||
static constexpr auto Zero_At_Vblank_Pause_Outside_Vblank = Timer_IO_Values::CounterMode::SyncMode.with(2u);
|
||||
static constexpr auto Pause_Until_Vblank_Then_FreeRun = Timer_IO_Values::CounterMode::SyncMode.with(3u);
|
||||
};
|
||||
|
||||
struct Source {
|
||||
static constexpr auto System_Clock = Timer_IO_Values::CounterMode::ClockSource.with(0u);
|
||||
static constexpr auto Hblank = Timer_IO_Values::CounterMode::ClockSource.with(1u);
|
||||
static constexpr auto System_Clock_Too = Timer_IO_Values::CounterMode::ClockSource.with(2u);
|
||||
static constexpr auto Hblank_Too = Timer_IO_Values::CounterMode::ClockSource.with(3u);
|
||||
};
|
||||
};
|
||||
|
||||
struct Counter2 : public Counter {
|
||||
struct SyncMode {
|
||||
static constexpr auto Stop_Counter = Timer_IO_Values::CounterMode::SyncMode.with(0u);
|
||||
static constexpr auto FreeRun = Timer_IO_Values::CounterMode::SyncMode.with(1u);
|
||||
static constexpr auto FreeRun_Too = Timer_IO_Values::CounterMode::SyncMode.with(2u);
|
||||
static constexpr auto Stop_Counter_Too = Timer_IO_Values::CounterMode::SyncMode.with(3u);
|
||||
};
|
||||
|
||||
struct Source {
|
||||
static constexpr auto System_Clock = Timer_IO_Values::CounterMode::ClockSource.with(0u);
|
||||
static constexpr auto System_Clock_Too = Timer_IO_Values::CounterMode::ClockSource.with(1u);
|
||||
static constexpr auto System_Clock_Div_8 = Timer_IO_Values::CounterMode::ClockSource.with(2u);
|
||||
static constexpr auto System_Clock_Div_8_Too = Timer_IO_Values::CounterMode::ClockSource.with(3u);
|
||||
};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
static constexpr uintptr_t counter_base_adr(size_t ID) {
|
||||
return (0x1F801100 + (ID*0x10));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
#pragma once
|
||||
#include "IOValues/timer_io_values.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Timer_IO {
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
|
||||
inline void set_target_value(uint16_t value) {
|
||||
this->target.write(Timer_IO_Values::CounterTarget{0}.set_range(Timer_IO_Values::CounterTarget::CounterTargetValue, value));
|
||||
}
|
||||
|
||||
inline void set_mode(Timer_IO_Values::CounterMode mode) {
|
||||
this->mode.write(mode);
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct Counter0 : public Counter {
|
||||
struct SyncMode {
|
||||
static constexpr auto Zero_At_Hblank = Timer_IO_Values::CounterMode::SyncMode.with(1u);
|
||||
static constexpr auto Pause_During_Hblank = Timer_IO_Values::CounterMode::SyncMode.with(0u);
|
||||
static constexpr auto Zero_At_Hblank_Pause_Outside_Hblank = Timer_IO_Values::CounterMode::SyncMode.with(2u);
|
||||
static constexpr auto Pause_Until_Hblank_Then_Freerun = Timer_IO_Values::CounterMode::SyncMode.with(3u);
|
||||
};
|
||||
|
||||
struct Source {
|
||||
static constexpr auto System_Clock = Timer_IO_Values::CounterMode::ClockSource.with(0u);
|
||||
static constexpr auto Dot_Clock = Timer_IO_Values::CounterMode::ClockSource.with(1u);
|
||||
static constexpr auto System_Clock_Too = Timer_IO_Values::CounterMode::ClockSource.with(2u);
|
||||
static constexpr auto Dot_Clock_Too = Timer_IO_Values::CounterMode::ClockSource.with(3u);
|
||||
};
|
||||
};
|
||||
|
||||
struct Counter1 : public Counter {
|
||||
struct SyncMode {
|
||||
static constexpr auto Pause_During_Vblank = Timer_IO_Values::CounterMode::SyncMode.with(0u);
|
||||
static constexpr auto Zero_At_Vblank = Timer_IO_Values::CounterMode::SyncMode.with(1u);
|
||||
static constexpr auto Zero_At_Vblank_Pause_Outside_Vblank = Timer_IO_Values::CounterMode::SyncMode.with(2u);
|
||||
static constexpr auto Pause_Until_Vblank_Then_FreeRun = Timer_IO_Values::CounterMode::SyncMode.with(3u);
|
||||
};
|
||||
|
||||
struct Source {
|
||||
static constexpr auto System_Clock = Timer_IO_Values::CounterMode::ClockSource.with(0u);
|
||||
static constexpr auto Hblank = Timer_IO_Values::CounterMode::ClockSource.with(1u);
|
||||
static constexpr auto System_Clock_Too = Timer_IO_Values::CounterMode::ClockSource.with(2u);
|
||||
static constexpr auto Hblank_Too = Timer_IO_Values::CounterMode::ClockSource.with(3u);
|
||||
};
|
||||
};
|
||||
|
||||
struct Counter2 : public Counter {
|
||||
struct SyncMode {
|
||||
static constexpr auto Stop_Counter = Timer_IO_Values::CounterMode::SyncMode.with(0u);
|
||||
static constexpr auto FreeRun = Timer_IO_Values::CounterMode::SyncMode.with(1u);
|
||||
static constexpr auto FreeRun_Too = Timer_IO_Values::CounterMode::SyncMode.with(2u);
|
||||
static constexpr auto Stop_Counter_Too = Timer_IO_Values::CounterMode::SyncMode.with(3u);
|
||||
};
|
||||
|
||||
struct Source {
|
||||
static constexpr auto System_Clock = Timer_IO_Values::CounterMode::ClockSource.with(0u);
|
||||
static constexpr auto System_Clock_Too = Timer_IO_Values::CounterMode::ClockSource.with(1u);
|
||||
static constexpr auto System_Clock_Div_8 = Timer_IO_Values::CounterMode::ClockSource.with(2u);
|
||||
static constexpr auto System_Clock_Div_8_Too = Timer_IO_Values::CounterMode::ClockSource.with(3u);
|
||||
};
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
static constexpr uintptr_t counter_base_adr(size_t ID) {
|
||||
return (0x1F801100 + (ID*0x10));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
@@ -1,20 +1,20 @@
|
||||
#pragma once
|
||||
#include "syscalls.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Callback {
|
||||
struct [[deprecated("Currently not supported")]] VSyncCallback {
|
||||
using Function = void (*)();
|
||||
|
||||
static Function callback;
|
||||
|
||||
static void install(Function function) {
|
||||
VSyncCallback::callback = function;
|
||||
}
|
||||
|
||||
static void uninstall() {
|
||||
VSyncCallback::install(nullptr);
|
||||
}
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include "syscalls.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace Callback {
|
||||
struct [[deprecated("Currently not supported")]] VSyncCallback {
|
||||
using Function = void (*)();
|
||||
|
||||
static Function callback;
|
||||
|
||||
static void install(Function function) {
|
||||
VSyncCallback::callback = function;
|
||||
}
|
||||
|
||||
static void uninstall() {
|
||||
VSyncCallback::install(nullptr);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,293 +1,293 @@
|
||||
#pragma once
|
||||
#include "../jabyengine_defines.hpp"
|
||||
|
||||
/*
|
||||
R0 zr Constant Zero
|
||||
R1 at Reserved for the assembler
|
||||
R2-R3 v0-v1 Values for results and expression evaluation
|
||||
R4-R7 a0-a3 Arguments
|
||||
R8-R15 t0-t7 Temporaries (not preserved across call)
|
||||
R16-R23 s0-s7 Saved (preserved across call)
|
||||
R24-R25 t8-t9 More temporaries (not preserved across call)
|
||||
R26-R27 k0-k1 Reserved for OS Kernel
|
||||
R28 gp Global Pointer
|
||||
R29 sp Stack Pointer
|
||||
R30 fp Frame Pointer
|
||||
R31 ra Return address (set by function call)
|
||||
*/
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace BIOS {
|
||||
struct Version {
|
||||
enum Type {
|
||||
Unkown,
|
||||
Devboard,
|
||||
PS1,
|
||||
PS2,
|
||||
PS3,
|
||||
PSCompatible, // internal usage only
|
||||
No$psx,
|
||||
XEBRA
|
||||
};
|
||||
|
||||
struct {
|
||||
uint8_t day;
|
||||
uint8_t month;
|
||||
uint16_t year;
|
||||
} date;
|
||||
Type type;
|
||||
const char* kernel_maker;
|
||||
const char* version_str;
|
||||
const char* gui_version;
|
||||
const char* copyright;
|
||||
};
|
||||
|
||||
extern const Version version;
|
||||
}
|
||||
|
||||
struct TCB {
|
||||
uint32_t status;
|
||||
uint32_t unused;
|
||||
uint32_t reg[32];
|
||||
uint32_t epc;
|
||||
uint32_t hi;
|
||||
uint32_t lo;
|
||||
uint32_t sr;
|
||||
uint32_t cause;
|
||||
uint32_t unused2[9];
|
||||
};
|
||||
|
||||
struct PCB {
|
||||
TCB* current_tcb;
|
||||
};
|
||||
|
||||
struct ToT {
|
||||
using ExCB = void;
|
||||
using EvCB = void;
|
||||
using FCB = void;
|
||||
|
||||
ExCB* exception_chain;
|
||||
uint32_t exception_chain_size;
|
||||
PCB* processes;
|
||||
uint32_t processes_size;
|
||||
TCB* threads;
|
||||
uint32_t threads_size;
|
||||
uint32_t reserved_0;
|
||||
uint32_t reserved_1;
|
||||
EvCB* events;
|
||||
uint32_t events_size;
|
||||
uint32_t reserved_2;
|
||||
uint32_t reserved_3;
|
||||
uint32_t reserved_4;
|
||||
uint32_t reserved_5;
|
||||
uint32_t reserved_6;
|
||||
uint32_t reserved_7;
|
||||
FCB* files;
|
||||
uint32_t files_size;
|
||||
uint32_t reserved_8;
|
||||
uint32_t reserved_9;
|
||||
};
|
||||
|
||||
extern ToT table_of_tables;
|
||||
|
||||
namespace SysCall {
|
||||
static constexpr const uint32_t Table_A = 0xA0;
|
||||
static constexpr const uint32_t Table_B = 0xB0;
|
||||
static constexpr const uint32_t Table_C = 0xC0;
|
||||
|
||||
enum struct Priority {
|
||||
CdromDmaIrq = 0,
|
||||
CdromIoIrq = 0,
|
||||
SyscallException = 0,
|
||||
|
||||
CardSpecificIrq = 1,
|
||||
VblankIrq = 1,
|
||||
Timer2Irq = 1,
|
||||
Timer1Irq = 1,
|
||||
Timer0Irq = 1,
|
||||
|
||||
PadCardIrq = 2,
|
||||
|
||||
DefInt = 3
|
||||
};
|
||||
|
||||
enum InterruptVerifierResult {
|
||||
SkipHandler = 0,
|
||||
ExecuteHandler = 1
|
||||
};
|
||||
|
||||
typedef InterruptVerifierResult (*InterruptVerifier)();
|
||||
typedef void (*InterruptHandler)(uint32_t);
|
||||
using ThreadHandle = uint32_t;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct InterruptCallback {
|
||||
struct InterruptCallback* next;
|
||||
InterruptHandler handler_function;
|
||||
InterruptVerifier verifier_function;
|
||||
uint32_t notUsed;
|
||||
|
||||
static constexpr InterruptCallback from(InterruptVerifier verifier, InterruptHandler handler) {
|
||||
return InterruptCallback{nullptr, handler, verifier, 0};
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#define __syscall_function_cast(table, ...) reinterpret_cast<__VA_ARGS__>(table)
|
||||
|
||||
static __always_inline uint32_t* get_gp() {
|
||||
uint32_t* gp;
|
||||
__asm__("sw $gp, %0" : "=m"(gp));
|
||||
return gp;
|
||||
}
|
||||
|
||||
static __always_inline void DequeueCdIntr() {
|
||||
register uint32_t FuncID asm("t1") = 0xa3;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_A, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void FlushCache() {
|
||||
register uint32_t FuncID asm("t1") = 0x44;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_A, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void* memcpy(void *dst, const void *src, size_t len) {
|
||||
register uint32_t FuncID asm("t1") = 0x2A;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
return __syscall_function_cast(Table_A, void*(*)(void*, const void*, size_t))(dst, src, len);
|
||||
}
|
||||
|
||||
static __always_inline ThreadHandle OpenThread(void (*thread_func)(), uint32_t* stack_ptr, uint32_t* gp) {
|
||||
register uint32_t FuncID asm("t1") = 0x0E;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
return __syscall_function_cast(Table_B, ThreadHandle(*)(void(*)(), uint32_t*, uint32_t*))(thread_func, stack_ptr, gp);
|
||||
}
|
||||
|
||||
static __always_inline void [[noreturn]] ChangeThread(ThreadHandle handle) {
|
||||
register uint32_t FuncID asm("t1") = 0x10;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)(ThreadHandle))(handle);
|
||||
}
|
||||
|
||||
static __always_inline void InitPad(uint8_t *portA, uint32_t portASize, uint8_t *portB, uint32_t portBSize) {
|
||||
register uint32_t FuncID asm("t1") = 0x12;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)(uint8_t*, uint32_t, uint8_t*, uint32_t))(portA, portASize, portB, portBSize);
|
||||
}
|
||||
|
||||
static __always_inline void StartPad() {
|
||||
register uint32_t FuncID asm("t1") = 0x13;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void StopPad() {
|
||||
register uint32_t FuncID asm("t1") = 0x14;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void ChangeClearPad(int32_t _reserved) {
|
||||
register uint32_t FuncID asm("t1") = 0x5B;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)(int32_t))(_reserved);
|
||||
}
|
||||
|
||||
static __always_inline void [[noreturn]] ReturnFromException() {
|
||||
register uint32_t FuncID asm("t1") = 0x17;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void SetDefaultExitFromException() {
|
||||
register uint32_t FuncID asm("t1") = 0x18;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline int SysEnqIntRP(Priority prio, InterruptCallback* interElm) {
|
||||
register uint32_t FuncID asm("t1") = 0x02;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
return __syscall_function_cast(Table_C, int(*)(Priority prio, InterruptCallback *interElm))(prio, interElm);
|
||||
}
|
||||
|
||||
static __always_inline int SysDeqIntRP(Priority prio, InterruptCallback *interElm) {
|
||||
register uint32_t FuncID asm("t1") = 0x03;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
return __syscall_function_cast(Table_C, int(*)(Priority prio, InterruptCallback *interElm))(prio, interElm);
|
||||
}
|
||||
|
||||
static __always_inline uint32_t EnterCriticalSection() {
|
||||
register uint32_t FuncID asm("a0") = 0x01;
|
||||
register uint32_t returnValue asm("v0");
|
||||
|
||||
__asm__ volatile("syscall" : "=r"(returnValue) : "r"(FuncID) : "memory");
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
static __always_inline void ExitCriticalSection() {
|
||||
register uint32_t FuncID asm("a0") = 0x02;
|
||||
|
||||
__asm__ volatile("syscall" :: "r"(FuncID) : "memory");
|
||||
}
|
||||
|
||||
static __always_inline void DeliverEvent(uint32_t classId, uint32_t spec) {
|
||||
register uint32_t FuncID asm("t1") = 0x07;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
__syscall_function_cast(Table_B, void (*)(uint32_t, uint32_t))(classId, spec);
|
||||
}
|
||||
|
||||
static __always_inline uint32_t OpenEvent(uint32_t classId, uint32_t spec, uint32_t mode, void (*handler)()) {
|
||||
register uint32_t FuncID asm("t1") = 0x08;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
return __syscall_function_cast(Table_B, uint32_t(*)(uint32_t, uint32_t, uint32_t, void(*)()))(classId, spec, mode, handler);
|
||||
}
|
||||
|
||||
static __always_inline int CloseEvent(uint32_t event) {
|
||||
register uint32_t FuncID asm("t1") = 0x09;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
return __syscall_function_cast(Table_B, uint32_t(*)(uint32_t))(event);
|
||||
}
|
||||
|
||||
static __always_inline int32_t TestEvent(uint32_t event) {
|
||||
register uint32_t FuncID asm("t1") = 0x0B;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
return __syscall_function_cast(Table_B, int32_t (*)(uint32_t))(event);
|
||||
}
|
||||
|
||||
static __always_inline int32_t EnableEvent(uint32_t event) {
|
||||
register uint32_t FuncID asm("t1") = 0x0C;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
return __syscall_function_cast(Table_B, int32_t (*)(uint32_t))(event);
|
||||
}
|
||||
|
||||
static __always_inline const uint16_t* Krom2RawAdd(uint16_t sjis_code) {
|
||||
register uint32_t FuncID asm("t1") = 0x51;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
return __syscall_function_cast(Table_B, const uint16_t* (*)(uint16_t))(sjis_code);
|
||||
}
|
||||
|
||||
void printf(const char* txt, ...);
|
||||
}
|
||||
#pragma once
|
||||
#include "../jabyengine_defines.hpp"
|
||||
|
||||
/*
|
||||
R0 zr Constant Zero
|
||||
R1 at Reserved for the assembler
|
||||
R2-R3 v0-v1 Values for results and expression evaluation
|
||||
R4-R7 a0-a3 Arguments
|
||||
R8-R15 t0-t7 Temporaries (not preserved across call)
|
||||
R16-R23 s0-s7 Saved (preserved across call)
|
||||
R24-R25 t8-t9 More temporaries (not preserved across call)
|
||||
R26-R27 k0-k1 Reserved for OS Kernel
|
||||
R28 gp Global Pointer
|
||||
R29 sp Stack Pointer
|
||||
R30 fp Frame Pointer
|
||||
R31 ra Return address (set by function call)
|
||||
*/
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace BIOS {
|
||||
struct Version {
|
||||
enum Type {
|
||||
Unkown,
|
||||
Devboard,
|
||||
PS1,
|
||||
PS2,
|
||||
PS3,
|
||||
PSCompatible, // internal usage only
|
||||
No$psx,
|
||||
XEBRA
|
||||
};
|
||||
|
||||
struct {
|
||||
uint8_t day;
|
||||
uint8_t month;
|
||||
uint16_t year;
|
||||
} date;
|
||||
Type type;
|
||||
const char* kernel_maker;
|
||||
const char* version_str;
|
||||
const char* gui_version;
|
||||
const char* copyright;
|
||||
};
|
||||
|
||||
extern const Version version;
|
||||
}
|
||||
|
||||
struct TCB {
|
||||
uint32_t status;
|
||||
uint32_t unused;
|
||||
uint32_t reg[32];
|
||||
uint32_t epc;
|
||||
uint32_t hi;
|
||||
uint32_t lo;
|
||||
uint32_t sr;
|
||||
uint32_t cause;
|
||||
uint32_t unused2[9];
|
||||
};
|
||||
|
||||
struct PCB {
|
||||
TCB* current_tcb;
|
||||
};
|
||||
|
||||
struct ToT {
|
||||
using ExCB = void;
|
||||
using EvCB = void;
|
||||
using FCB = void;
|
||||
|
||||
ExCB* exception_chain;
|
||||
uint32_t exception_chain_size;
|
||||
PCB* processes;
|
||||
uint32_t processes_size;
|
||||
TCB* threads;
|
||||
uint32_t threads_size;
|
||||
uint32_t reserved_0;
|
||||
uint32_t reserved_1;
|
||||
EvCB* events;
|
||||
uint32_t events_size;
|
||||
uint32_t reserved_2;
|
||||
uint32_t reserved_3;
|
||||
uint32_t reserved_4;
|
||||
uint32_t reserved_5;
|
||||
uint32_t reserved_6;
|
||||
uint32_t reserved_7;
|
||||
FCB* files;
|
||||
uint32_t files_size;
|
||||
uint32_t reserved_8;
|
||||
uint32_t reserved_9;
|
||||
};
|
||||
|
||||
extern ToT table_of_tables;
|
||||
|
||||
namespace SysCall {
|
||||
static constexpr const uint32_t Table_A = 0xA0;
|
||||
static constexpr const uint32_t Table_B = 0xB0;
|
||||
static constexpr const uint32_t Table_C = 0xC0;
|
||||
|
||||
enum struct Priority {
|
||||
CdromDmaIrq = 0,
|
||||
CdromIoIrq = 0,
|
||||
SyscallException = 0,
|
||||
|
||||
CardSpecificIrq = 1,
|
||||
VblankIrq = 1,
|
||||
Timer2Irq = 1,
|
||||
Timer1Irq = 1,
|
||||
Timer0Irq = 1,
|
||||
|
||||
PadCardIrq = 2,
|
||||
|
||||
DefInt = 3
|
||||
};
|
||||
|
||||
enum InterruptVerifierResult {
|
||||
SkipHandler = 0,
|
||||
ExecuteHandler = 1
|
||||
};
|
||||
|
||||
typedef InterruptVerifierResult (*InterruptVerifier)();
|
||||
typedef void (*InterruptHandler)(uint32_t);
|
||||
using ThreadHandle = uint32_t;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct InterruptCallback {
|
||||
struct InterruptCallback* next;
|
||||
InterruptHandler handler_function;
|
||||
InterruptVerifier verifier_function;
|
||||
uint32_t notUsed;
|
||||
|
||||
static constexpr InterruptCallback from(InterruptVerifier verifier, InterruptHandler handler) {
|
||||
return InterruptCallback{nullptr, handler, verifier, 0};
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#define __syscall_function_cast(table, ...) reinterpret_cast<__VA_ARGS__>(table)
|
||||
|
||||
static __always_inline uint32_t* get_gp() {
|
||||
uint32_t* gp;
|
||||
__asm__("sw $gp, %0" : "=m"(gp));
|
||||
return gp;
|
||||
}
|
||||
|
||||
static __always_inline void DequeueCdIntr() {
|
||||
register uint32_t FuncID asm("t1") = 0xa3;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_A, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void FlushCache() {
|
||||
register uint32_t FuncID asm("t1") = 0x44;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_A, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void* memcpy(void *dst, const void *src, size_t len) {
|
||||
register uint32_t FuncID asm("t1") = 0x2A;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
return __syscall_function_cast(Table_A, void*(*)(void*, const void*, size_t))(dst, src, len);
|
||||
}
|
||||
|
||||
static __always_inline ThreadHandle OpenThread(void (*thread_func)(), uint32_t* stack_ptr, uint32_t* gp) {
|
||||
register uint32_t FuncID asm("t1") = 0x0E;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
return __syscall_function_cast(Table_B, ThreadHandle(*)(void(*)(), uint32_t*, uint32_t*))(thread_func, stack_ptr, gp);
|
||||
}
|
||||
|
||||
static __always_inline void [[noreturn]] ChangeThread(ThreadHandle handle) {
|
||||
register uint32_t FuncID asm("t1") = 0x10;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)(ThreadHandle))(handle);
|
||||
}
|
||||
|
||||
static __always_inline void InitPad(uint8_t *portA, uint32_t portASize, uint8_t *portB, uint32_t portBSize) {
|
||||
register uint32_t FuncID asm("t1") = 0x12;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)(uint8_t*, uint32_t, uint8_t*, uint32_t))(portA, portASize, portB, portBSize);
|
||||
}
|
||||
|
||||
static __always_inline void StartPad() {
|
||||
register uint32_t FuncID asm("t1") = 0x13;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void StopPad() {
|
||||
register uint32_t FuncID asm("t1") = 0x14;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void ChangeClearPad(int32_t _reserved) {
|
||||
register uint32_t FuncID asm("t1") = 0x5B;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)(int32_t))(_reserved);
|
||||
}
|
||||
|
||||
static __always_inline void [[noreturn]] ReturnFromException() {
|
||||
register uint32_t FuncID asm("t1") = 0x17;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline void SetDefaultExitFromException() {
|
||||
register uint32_t FuncID asm("t1") = 0x18;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
__syscall_function_cast(Table_B, void(*)())();
|
||||
}
|
||||
|
||||
static __always_inline int SysEnqIntRP(Priority prio, InterruptCallback* interElm) {
|
||||
register uint32_t FuncID asm("t1") = 0x02;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
return __syscall_function_cast(Table_C, int(*)(Priority prio, InterruptCallback *interElm))(prio, interElm);
|
||||
}
|
||||
|
||||
static __always_inline int SysDeqIntRP(Priority prio, InterruptCallback *interElm) {
|
||||
register uint32_t FuncID asm("t1") = 0x03;
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
|
||||
return __syscall_function_cast(Table_C, int(*)(Priority prio, InterruptCallback *interElm))(prio, interElm);
|
||||
}
|
||||
|
||||
static __always_inline uint32_t EnterCriticalSection() {
|
||||
register uint32_t FuncID asm("a0") = 0x01;
|
||||
register uint32_t returnValue asm("v0");
|
||||
|
||||
__asm__ volatile("syscall" : "=r"(returnValue) : "r"(FuncID) : "memory");
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
static __always_inline void ExitCriticalSection() {
|
||||
register uint32_t FuncID asm("a0") = 0x02;
|
||||
|
||||
__asm__ volatile("syscall" :: "r"(FuncID) : "memory");
|
||||
}
|
||||
|
||||
static __always_inline void DeliverEvent(uint32_t classId, uint32_t spec) {
|
||||
register uint32_t FuncID asm("t1") = 0x07;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
__syscall_function_cast(Table_B, void (*)(uint32_t, uint32_t))(classId, spec);
|
||||
}
|
||||
|
||||
static __always_inline uint32_t OpenEvent(uint32_t classId, uint32_t spec, uint32_t mode, void (*handler)()) {
|
||||
register uint32_t FuncID asm("t1") = 0x08;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
return __syscall_function_cast(Table_B, uint32_t(*)(uint32_t, uint32_t, uint32_t, void(*)()))(classId, spec, mode, handler);
|
||||
}
|
||||
|
||||
static __always_inline int CloseEvent(uint32_t event) {
|
||||
register uint32_t FuncID asm("t1") = 0x09;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
return __syscall_function_cast(Table_B, uint32_t(*)(uint32_t))(event);
|
||||
}
|
||||
|
||||
static __always_inline int32_t TestEvent(uint32_t event) {
|
||||
register uint32_t FuncID asm("t1") = 0x0B;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
return __syscall_function_cast(Table_B, int32_t (*)(uint32_t))(event);
|
||||
}
|
||||
|
||||
static __always_inline int32_t EnableEvent(uint32_t event) {
|
||||
register uint32_t FuncID asm("t1") = 0x0C;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
return __syscall_function_cast(Table_B, int32_t (*)(uint32_t))(event);
|
||||
}
|
||||
|
||||
static __always_inline const uint16_t* Krom2RawAdd(uint16_t sjis_code) {
|
||||
register uint32_t FuncID asm("t1") = 0x51;
|
||||
|
||||
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
|
||||
return __syscall_function_cast(Table_B, const uint16_t* (*)(uint16_t))(sjis_code);
|
||||
}
|
||||
|
||||
void printf(const char* txt, ...);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user