diff --git a/examples/PoolBox/application/src/Overlay/ScreenCenter/include/frame.hpp b/examples/PoolBox/application/src/Overlay/ScreenCenter/include/frame.hpp index 3ba02d37..dfb6180d 100644 --- a/examples/PoolBox/application/src/Overlay/ScreenCenter/include/frame.hpp +++ b/examples/PoolBox/application/src/Overlay/ScreenCenter/include/frame.hpp @@ -1,51 +1,103 @@ #pragma once #include #include +#include namespace ScreenCenter { using namespace JabyEngine; // TODO: Fit these pieces into 16Word buffers (sizeof(T) >> 2 == words) // TODO: Can we DMA all of this? - class Frame : public GPU::internal::LinkedElementCreator { + class Frame { private: - GPU::TILE top_left[2]; - GPU::TILE top_right[2]; - GPU::TILE bottom_left[2]; - GPU::TILE bottom_right[2]; - GPU::LINE_G_MULTI<5> border; - GPU::LINE_G_SINGLE cross[2]; + struct TopBorder : public GPU::internal::LinkedElementCreator { + GPU::TILE top_left[2]; + GPU::TILE top_right[2]; + static constexpr TopBorder::Linked create(GPU::Color24 BaseColor, GPU::SizeI16 Size) { + TopBorder frame; + + frame.top_left[0] = Make::TILE(Make::AreaI16(0, 0, Size.width, Size.height), BaseColor); + frame.top_left[1] = Make::TILE(Make::AreaI16(0, 0, Size.height, Size.width), BaseColor); + + frame.top_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, 0, Size.width, Size.height), BaseColor); + frame.top_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, 0, Size.height, Size.width), BaseColor); + return frame.linked(); + } + }; + + struct BottomBorder : GPU::internal::LinkedElementCreator { + GPU::TILE bottom_left[2]; + GPU::TILE bottom_right[2]; + + static constexpr BottomBorder::Linked create(GPU::Color24 BaseColor, GPU::SizeI16 Size) { + BottomBorder frame; + + frame.bottom_left[0] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor); + frame.bottom_left[1] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor); + + frame.bottom_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor); + frame.bottom_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor); + return frame.linked(); + } + }; + + struct LineBorder : GPU::internal::LinkedElementCreator { + GPU::LINE_G_MULTI<5> border; + + static constexpr LineBorder::Linked create() { + LineBorder frame; + + frame.border = Make::LINE_G( + GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)}, + GPU::ColorVertex{GPU::Color24::Green(), Make::Vertex(0, GPU::Display::Height - 1)}, + GPU::ColorVertex{GPU::Color24::Blue(), Make::Vertex(GPU::Display::Width - 1, GPU::Display::Height - 1)}, + GPU::ColorVertex{GPU::Color24::Yellow(), Make::Vertex(GPU::Display::Width - 1, 0)}, + GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)} + ); + return frame.linked(); + } + }; + + struct LineCross : GPU::internal::LinkedElementCreator { + GPU::LINE_G_SINGLE cross[2]; + + static constexpr LineCross::Linked create(const decltype(LineBorder::border)& border) { + LineCross frame; + + frame.cross[0] = Make::LINE_G(border[0], border[2]); + frame.cross[1] = Make::LINE_G(border[3], border[1]); + return frame.linked(); + } + }; + + TopBorder::Linked top_border; + BottomBorder::Linked bottom_border; + LineBorder::Linked line_border; + LineCross::Linked line_cross; public: - static constexpr Frame::Linked create() { + static constexpr Frame create() { constexpr auto BaseColor = GPU::Color24::from_rgb(0x1D, 0xA0, 0xA3); constexpr auto Size = Make::SizeI16(64, 16); Frame frame; - frame.top_left[0] = Make::TILE(Make::AreaI16(0, 0, Size.width, Size.height), BaseColor); - frame.top_left[1] = Make::TILE(Make::AreaI16(0, 0, Size.height, Size.width), BaseColor); + frame.top_border = TopBorder::create(BaseColor, Size); + frame.bottom_border = BottomBorder::create(BaseColor, Size); + frame.line_border = LineBorder::create(); + frame.line_cross = LineCross::create(frame.line_border->border); + return frame; + } - frame.top_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, 0, Size.width, Size.height), BaseColor); - frame.top_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, 0, Size.height, Size.width), BaseColor); + void setup() { + // TODO: I want this in one line + this->top_border.concat(this->bottom_border); + this->bottom_border.concat(this->line_border); + this->line_border.concat(this->line_cross); + } - frame.bottom_left[0] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor); - frame.bottom_left[1] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor); - - frame.bottom_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor); - frame.bottom_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor); - - frame.border = Make::LINE_G( - GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)}, - GPU::ColorVertex{GPU::Color24::Green(), Make::Vertex(0, GPU::Display::Height - 1)}, - GPU::ColorVertex{GPU::Color24::Blue(), Make::Vertex(GPU::Display::Width - 1, GPU::Display::Height - 1)}, - GPU::ColorVertex{GPU::Color24::Yellow(), Make::Vertex(GPU::Display::Width - 1, 0)}, - GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)} - ); - - frame.cross[0] = Make::LINE_G(frame.border[0], frame.border[2]); - frame.cross[1] = Make::LINE_G(frame.border[3], frame.border[1]); - return frame.linked(); + void render() const { + GPU::render(this->top_border); } }; } \ No newline at end of file diff --git a/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp b/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp index 87858a47..cdfafcfc 100644 --- a/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp +++ b/examples/PoolBox/application/src/Overlay/ScreenCenter/screen_center.cpp @@ -77,7 +77,7 @@ namespace ScreenCenter { Formular{.name = PSYQ::Name, .function = PSYQ::set_offset} }; - static const auto frame = Frame::create(); + static auto frame = Frame::create(); static ButtonPulser button_pulse[4]; static void (*update)() = nullptr; @@ -160,6 +160,7 @@ namespace ScreenCenter { static void setup() { Shared::back_menu.reset(); + frame.setup(); for(auto& pulse : button_pulse) { pulse.setup(); @@ -182,7 +183,7 @@ namespace ScreenCenter { } static void render() { - GPU::render(frame); + frame.render(); Shared::back_menu.render(); } diff --git a/examples/PoolBox/application/src/font_writer.cpp b/examples/PoolBox/application/src/font_writer.cpp index 35d7ce53..1dc6e23c 100644 --- a/examples/PoolBox/application/src/font_writer.cpp +++ b/examples/PoolBox/application/src/font_writer.cpp @@ -20,7 +20,7 @@ namespace FontWriter { JabyEngine::GlobalFontPrimitivePool::setup(font_buffer); new_font_writer.setup(LibraryFontTIM, JabyEngine::DefaultFont::Info); - bios_font_writer.setup(JabyEngine::BIOSFont::TIM, JabyEngine::BIOSFont::Info); + bios_font_writer.setup(LibraryFontTIM, JabyEngine::DefaultFont::Info);//(JabyEngine::BIOSFont::TIM, JabyEngine::BIOSFont::Info); timer.reset(); } diff --git a/include/PSX/GPU/Primitives/linked_elements.hpp b/include/PSX/GPU/Primitives/linked_elements.hpp index 1e52a3c0..855ff391 100644 --- a/include/PSX/GPU/Primitives/linked_elements.hpp +++ b/include/PSX/GPU/Primitives/linked_elements.hpp @@ -77,8 +77,8 @@ namespace JabyEngine { return &this->element; } - // TODO: Remove this magic number? - //static_assert((sizeof(T) >> 2) <= 16); + // TODO: Replace this magic number? + static_assert((sizeof(T) >> 2) <= 16); }; namespace internal { diff --git a/src/Library/src/BootLoader/BIOSFont/bios_font_types.hpp b/src/Library/src/BootLoader/BIOSFont/bios_font_types.hpp index 6e4c6cfa..5d3576d5 100644 --- a/src/Library/src/BootLoader/BIOSFont/bios_font_types.hpp +++ b/src/Library/src/BootLoader/BIOSFont/bios_font_types.hpp @@ -30,8 +30,8 @@ namespace JabyEngine { }; // Letters are actually only 16x15 but should be treated 16x16 - // TODO: DMA this? - struct Letter : public GPU::internal::LinkedElementCreator { + // FIXME: This is to big for Linked Lists. Maybe we do not buffer this at all? Or just double buffer it? + struct Letter /*: public GPU::internal::LinkedElementCreator*/ { CPU2VRAM cmd; Line lines[BIOS_Font::Size.height - 1]; Line empty_line; @@ -50,14 +50,14 @@ namespace JabyEngine { } }; - // v double buffer do not change size without adjusting - Letter::Linked letter_buffer[2*4]; + // v ::Linked v double buffer do not change size without adjusting + Letter letter_buffer[2*4]; uint8_t free_idx; void setup() { for(auto& letter : this->letter_buffer) { - letter->setup(SizeU16::create(16/4, 16)); - letter.set_link_identitiy(); + letter.setup(SizeU16::create(16/4, 16)); + //letter.set_link_identitiy(); } this->free_idx = 0; } @@ -65,24 +65,24 @@ namespace JabyEngine { void load_to(const PositionU16& pos, const uint16_t* bit_map) { auto& cur_letter = this->letter_buffer[this->free_idx++]; - cur_letter->load_to(pos, bit_map); + cur_letter.load_to(pos, bit_map); if((this->free_idx&0x3) == 0) { - cur_letter.terminate(); - GPU::render(this->letter_buffer[this->free_idx - 4]); + //cur_letter.terminate(); + //GPU::render(this->letter_buffer[this->free_idx - 4]); this->free_idx &= ~0x7; } else { - cur_letter.concat(this->letter_buffer[this->free_idx]); + //cur_letter.concat(this->letter_buffer[this->free_idx]); } } void flush() { if((this->free_idx&0x3) != 0) { - this->letter_buffer[this->free_idx - 1].terminate(); + //this->letter_buffer[this->free_idx - 1].terminate(); const auto idx = this->free_idx > 3 ? 4 : 0; - GPU::render(this->letter_buffer[idx]); + //GPU::render(this->letter_buffer[idx]); } }