Cleanup GPU code more

This commit is contained in:
Jaby 2023-04-26 20:42:44 +02:00 committed by Jaby
parent dfe084f611
commit 9d46658e0f
4 changed files with 28 additions and 36 deletions

View File

@ -21,6 +21,8 @@ namespace JabyEngine {
static constexpr size_t Height = 240; static constexpr size_t Height = 240;
#endif #endif
static uint8_t current_id;
static void enable() { static void enable() {
GPU_IO::GP1 = GPU_IO::Command::SetDisplayState(GPU_IO::DisplayState::On); GPU_IO::GP1 = GPU_IO::Command::SetDisplayState(GPU_IO::DisplayState::On);
} }
@ -28,10 +30,6 @@ namespace JabyEngine {
static void disable() { static void disable() {
GPU_IO::GP1 = GPU_IO::Command::SetDisplayState(GPU_IO::DisplayState::Off); GPU_IO::GP1 = GPU_IO::Command::SetDisplayState(GPU_IO::DisplayState::Off);
} }
};
struct Screen {
static uint8_t CurrentDisplayAreaID;
static void set_offset(uint16_t x, uint16_t y); static void set_offset(uint16_t x, uint16_t y);
}; };

View File

@ -7,22 +7,19 @@
namespace JabyEngine { namespace JabyEngine {
namespace GPU { namespace GPU {
namespace internal { namespace internal {
struct Screen { struct Display {
static void configurate() { typedef ::JabyEngine::GPU::Display PublicDisplay;
static constexpr uint16_t FirstVisiblePixelH = 0x260;
static constexpr auto Width = PublicDisplay::Width;
static constexpr auto Height = PublicDisplay::Height;
#ifdef JABYENGINE_PAL #ifdef JABYENGINE_PAL
static constexpr uint16_t FirstVisiblePixelV = 0xA3; static constexpr auto DisplayMode = GPU_IO::DisplayMode_t::PAL();
static constexpr uint16_t ScanlinesV = 288;
GPU_IO::GP1 = GPU_IO::Command::DisplayMode(GPU_IO::DisplayMode_t::PAL());
GPU::Screen::set_offset(0, 0);
#else #else
static constexpr uint16_t FirstVisiblePixelV = 0x88; static constexpr auto DisplayMode = GPU_IO::DisplayMode_t::NTSC();
static constexpr uint16_t ScanlinesV = 240;
GPU_IO::GP1 = GPU_IO::Command::DisplayMode(GPU_IO::DisplayMode_t::NTSC()); #endif //JABYENGINE_PAL
GPU::Screen::set_offset(0, 5); //< Random values
#endif
}
static void exchange_buffer_and_display(); static void exchange_buffer_and_display();
}; };

View File

@ -17,6 +17,12 @@ namespace JabyEngine {
namespace GPU { namespace GPU {
using namespace JabyEngine::GPU; using namespace JabyEngine::GPU;
static void configurate_display() {
// Ideal I hope that an offset of 0,0 will produce a well enough centered picture for every TV
GPU_IO::GP1 = GPU_IO::Command::DisplayMode(internal::Display::DisplayMode);
GPU::Display::set_offset(0, 0);
}
static size_t decompress_logo() { static size_t decompress_logo() {
LZ4Decompressor lz4_decomp(reinterpret_cast<uint8_t*>(&__boot_loader_end)); LZ4Decompressor lz4_decomp(reinterpret_cast<uint8_t*>(&__boot_loader_end));
@ -50,8 +56,8 @@ namespace JabyEngine {
void setup() { void setup() {
GPU_IO::GP1 = GPU_IO::Command::Reset(); GPU_IO::GP1 = GPU_IO::Command::Reset();
internal::Screen::configurate(); configurate_display();
internal::Screen::exchange_buffer_and_display(); internal::Display::exchange_buffer_and_display();
GPU::internal::wait_ready_for_CMD(); GPU::internal::wait_ready_for_CMD();
GPU::internal::quick_fill_fast(Color24::Black(), PositionU16(32, 0), SizeU16(Display::Width, Display::Height)); GPU::internal::quick_fill_fast(Color24::Black(), PositionU16(32, 0), SizeU16(Display::Width, Display::Height));

View File

@ -2,26 +2,18 @@
namespace JabyEngine { namespace JabyEngine {
namespace GPU { namespace GPU {
uint8_t Screen :: CurrentDisplayAreaID = 1; //< Setup will call exchange and set it to 0 uint8_t Display :: current_id = 1; //< Setup will call exchange and set it to 0
namespace internal { namespace internal {
typedef ::JabyEngine::GPU::Screen PublicScreenClass; void Display :: exchange_buffer_and_display() {
GPU::internal::set_draw_area(0, (PublicDisplay::Height*PublicDisplay::current_id));
#ifdef JABYENGINE_PAL PublicDisplay::current_id ^= 1;
static constexpr uint16_t ScanlinesV = 288; GPU_IO::GP1 = GPU_IO::Command::DisplayArea(0, (PublicDisplay::Height*PublicDisplay::current_id));
#else
static constexpr uint16_t ScanlinesV = 240;
#endif //JABYENGINE_PAL
void Screen :: exchange_buffer_and_display() {
GPU::internal::set_draw_area(0, (Display::Height*PublicScreenClass::CurrentDisplayAreaID));
PublicScreenClass::CurrentDisplayAreaID ^= 1;
GPU_IO::GP1 = GPU_IO::Command::DisplayArea(0, (Display::Height*PublicScreenClass::CurrentDisplayAreaID));
} }
} }
#ifndef USE_NO$PSX #ifndef USE_NO$PSX
void Screen :: set_offset(uint16_t x, uint16_t y) { void Display :: set_offset(uint16_t x, uint16_t y) {
x += 78; x += 78;
y += 43; y += 43;
@ -35,5 +27,4 @@ namespace JabyEngine {
} }
#endif //USE_NO$PSX #endif //USE_NO$PSX
} }
} }