Start configurating GPU

This commit is contained in:
Jaby 2022-10-02 17:32:23 +02:00 committed by Jaby
parent 33c785c908
commit 38f56c65a6
7 changed files with 58 additions and 18 deletions

View File

@ -153,17 +153,20 @@ public:
} }
// For easier constructing // For easier constructing
constexpr __always_inline ComplexBitMap<T>& set(const BitRange<T>& range, T value) { template<typename S>
constexpr __always_inline ComplexBitMap<T>& set(const BitRange<S>& range, T value) {
this->set_value(value, range); this->set_value(value, range);
return *this; return *this;
} }
constexpr __always_inline ComplexBitMap<T>& set(const BitRangeValue<T>& value) { template<typename S>
constexpr __always_inline ComplexBitMap<T>& set(const BitRangeValue<S>& value) {
this->set_value(value.value, {value.begin, value.length}); this->set_value(value.value, {value.begin, value.length});
return *this; return *this;
} }
constexpr __always_inline ComplexBitMap<T>& set(const Bit<T>& bit) { template<typename S>
constexpr __always_inline ComplexBitMap<T>& set(const Bit<S>& bit) {
this->set_bit(bit.value); this->set_bit(bit.value);
return *this; return *this;
} }

View File

@ -11,22 +11,27 @@ namespace GPU {
B_add_F_Quarter = 3, B_add_F_Quarter = 3,
}; };
enum struct DisplayAreaColorDepth {
$15bit = 0,
$24bit = 1,
};
enum struct TexturePageColor { enum struct TexturePageColor {
_4bit = 0, $4bit = 0,
_8bit = 1, $8bit = 1,
_15bit = 2, $15bit = 2,
}; };
enum struct HorizontalResolution { enum struct HorizontalResolution {
_256 = 0, $256 = 0,
_320 = 1, $320 = 1,
_512 = 2, $512 = 2,
_640 = 3, $640 = 3,
}; };
enum struct VerticalResolution { enum struct VerticalResolution {
_240 = 0, $240 = 0,
_480 = 1 $480 = 1
}; };
enum struct DMADirection { enum struct DMADirection {
@ -84,6 +89,10 @@ namespace GPU {
static constexpr GP1 DMADirection(DMADirection dir) { static constexpr GP1 DMADirection(DMADirection dir) {
return ComplexBitMap{construct_cmd(0x04, static_cast<uint32_t>(dir))}; return ComplexBitMap{construct_cmd(0x04, static_cast<uint32_t>(dir))};
} }
static constexpr GP1 DisplayMode(uint32_t mode) {
return ComplexBitMap{construct_cmd(0x08, mode)};
}
}; };
} }
@ -97,7 +106,7 @@ namespace GPU {
static constexpr auto InterruptRequest = Bit<uint32_t>(24); static constexpr auto InterruptRequest = Bit<uint32_t>(24);
static constexpr auto DisplayDisabled = Bit<uint32_t>(23); static constexpr auto DisplayDisabled = Bit<uint32_t>(23);
static constexpr auto VerticalInterlaceOn = Bit<uint32_t>(22); static constexpr auto VerticalInterlaceOn = Bit<uint32_t>(22);
static constexpr auto DisplayAreaColorDepth24bit = Bit<uint32_t>(21); static constexpr auto DisplayAreaColorDepth = BitRange<GPU::DisplayAreaColorDepth>::from_to(21, 21);
static constexpr auto VideoModePal = Bit<uint32_t>(20); static constexpr auto VideoModePal = Bit<uint32_t>(20);
static constexpr auto VerticalResolutionValue = BitRange<VerticalResolution>::from_to(19, 19); static constexpr auto VerticalResolutionValue = BitRange<VerticalResolution>::from_to(19, 19);
static constexpr auto HorizontalResolutionValue = BitRange<HorizontalResolution>::from_to(17, 18); static constexpr auto HorizontalResolutionValue = BitRange<HorizontalResolution>::from_to(17, 18);

View File

@ -5,6 +5,29 @@
#include <PSX/System/IOPorts/GPU_IO.hpp> #include <PSX/System/IOPorts/GPU_IO.hpp>
namespace GPU { namespace GPU {
struct DisplayMode {
enum struct TVEncoding {
NTSC = 0,
PAL = 1,
};
static constexpr auto HorizontalResolution368 = Bit<uint32_t>(6);
static constexpr auto VerticalInterlace = Bit<uint32_t>(5);
static constexpr auto DisplayAreaColorDepth = BitRange<GPU::DisplayAreaColorDepth>::from_to(4, 4);
static constexpr auto VideoMode = BitRange<TVEncoding>::from_to(3, 3);
static constexpr auto VerticalResolution = BitRange<GPU::VerticalResolution>::from_to(2, 2);
static constexpr auto HorizontalResolution = BitRange<GPU::HorizontalResolution>::from_to(0, 1);
static constexpr uint32_t PAL() {
return ComplexBitMap<uint32_t>::with(
DisplayMode::HorizontalResolution.with(GPU::HorizontalResolution::$320),
DisplayMode::VerticalResolution.with(GPU::VerticalResolution::$240),
DisplayMode::VideoMode.with(TVEncoding::PAL),
DisplayMode::DisplayAreaColorDepth.with(GPU::DisplayAreaColorDepth::$15bit)
).raw;
}
};
static void quick_fill_fast(const Color24& color, const PositionU16& pos, const SizeU16& size) { static void quick_fill_fast(const Color24& color, const PositionU16& pos, const SizeU16& size) {
GP0.write(Command::GP0::QuickFill(color)); GP0.write(Command::GP0::QuickFill(color));
GP0.write(Command::GP0::TopLeftPosition(pos.x, pos.y)); GP0.write(Command::GP0::TopLeftPosition(pos.x, pos.y));

View File

@ -1,4 +1,4 @@
#include "../../include/GPU/GPU.h" #include "../../include/GPU/GPU.hpp"
#include <PSX/File/Processor/File_Processor.hpp> #include <PSX/File/Processor/File_Processor.hpp>
#include <PSX/GPU/GPU.hpp> #include <PSX/GPU/GPU.hpp>
@ -7,7 +7,6 @@
namespace GPU { namespace GPU {
void display_logo() { void display_logo() {
Display::disable(); Display::disable();
quick_fill_fast(Color24(0x0, 0x80, 0x80), PositionU16(0, 0), SizeU16(640, 480));
// Upload SplashScreen picture // Upload SplashScreen picture
auto state = FileProcessor::create(reinterpret_cast<const uint32_t*>(SplashScreen), SimpleTIM(93, 0, 0, 0)); auto state = FileProcessor::create(reinterpret_cast<const uint32_t*>(SplashScreen), SimpleTIM(93, 0, 0, 0));
@ -18,6 +17,7 @@ namespace GPU {
void setup() { void setup() {
GP1.write(Command::GP1::Reset()); GP1.write(Command::GP1::Reset());
GP1.write(Command::GP1::DisplayMode(DisplayMode::PAL()));
quick_fill_fast(Color24::Black(), PositionU16(0, 0), SizeU16(640, 480)); quick_fill_fast(Color24::Black(), PositionU16(0, 0), SizeU16(640, 480));
} }

View File

@ -12,11 +12,11 @@ namespace JabyEngine {
enable_DMA(); enable_DMA();
SPU::stop_voices(); SPU::stop_voices();
GPU::setup();
GPU::display_logo(); GPU::display_logo();
//Pause?? //Pause??
//Do not setup GPU for now
//GPU::setup();
SPU::setup(); SPU::setup();
printf("Setup done!\n"); printf("Setup done!\n");
} }

View File

@ -1,4 +1,4 @@
#include "../../../include/GPU/GPU.h" #include "../../../include/GPU/GPU.hpp"
#include "SimpleHelper.hpp" #include "SimpleHelper.hpp"
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>

View File

@ -0,0 +1,5 @@
#include <PSX/GPU/GPU.hpp>
namespace GPU {
}