Prepare GPU setup

This commit is contained in:
jaby 2022-09-08 20:36:36 +02:00
parent 5c7d464425
commit f5d1453555
2 changed files with 32 additions and 3 deletions

View File

@ -36,9 +36,33 @@ namespace GPU {
GPU2CPU = 3,
};
struct __no_align Command : public ComplexBitMap<uint32_t> {
enum struct DisplayState {
On = 0,
Off = 1
};
namespace Command {
static constexpr uint32_t construct_cmd(uint8_t cmd, uint32_t value) {
return ((cmd << 24) | value);
}
struct __no_align GP0 : public ComplexBitMap<uint32_t> {
__io_port_inherit_complex_bit_map(GP0);
};
struct __no_align GP1 : public ComplexBitMap<uint32_t> {
__io_port_inherit_complex_bit_map(GP1);
static constexpr GP1 Reset() {
return {0};
}
static constexpr GP1 SetDisplayState(DisplayState state) {
return {construct_cmd(0x03, static_cast<uint32_t>(state))};
}
};
}
struct __no_align GPUStatusRegister : public ComplexBitMap<uint32_t> {
static constexpr auto DrawingOddLinesInterlaced = Bit<uint32_t>(31);
static constexpr auto DMADirectionValue = BitRange<DMADirection>::from_to(29, 30);
@ -68,6 +92,10 @@ namespace GPU {
static constexpr auto TexturePageY256 = Bit<uint32_t>(4);
};
__declare_io_port_global(Command::GP0, GP0, 0x1F801810);
__declare_io_port_global(Command::GP1, GP1, 0x1F801814);
__declare_io_port_global_const(uint32_t, GPUREAD, 0x1F801810);
__declare_io_port_global_const(GPUStatusRegister, GPUSTAT, 0x1F801814);
}
}

View File

@ -1,7 +1,8 @@
#include <PSX/GPU/GPU_Types.hpp>
#include <PSX/System/IOPorts/GPU_IO.hpp>
namespace GPU {
void setup() {
Port::GP1.write(Port::Command::GP1::Reset());
Port::GP1.write(Port::Command::GP1::SetDisplayState(Port::DisplayState::On));
}
}