From d897cfe52bac6df92db73d7a79f9395b79b06556 Mon Sep 17 00:00:00 2001 From: Jaby Date: Sun, 26 Nov 2023 18:43:23 -0500 Subject: [PATCH] Sketch setup of Font --- Support/include/FontWriter/font_writer.hpp | 3 +- Support/src/FontWriter/src/font_writer.cpp | 47 +++++++++++++++---- examples/PoolBox/application/src/main.cpp | 1 + .../Primitives/primitive_support_types.hpp | 4 ++ 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/Support/include/FontWriter/font_writer.hpp b/Support/include/FontWriter/font_writer.hpp index d2badc56..e63e68d9 100644 --- a/Support/include/FontWriter/font_writer.hpp +++ b/Support/include/FontWriter/font_writer.hpp @@ -3,6 +3,7 @@ namespace JabyEngine { struct FontWriter { - static void setup(const FontBufferInfo& buffer_info, SimpleTIM vram_dst, const FontInfo& font_info); + static void setup(const FontBufferInfo& buffer_info, const SimpleTIM& vram_dst, const FontInfo& font_info); + static void render(); }; } \ No newline at end of file diff --git a/Support/src/FontWriter/src/font_writer.cpp b/Support/src/FontWriter/src/font_writer.cpp index 992b30ec..f683b0c5 100644 --- a/Support/src/FontWriter/src/font_writer.cpp +++ b/Support/src/FontWriter/src/font_writer.cpp @@ -1,25 +1,56 @@ +#include #include #include +#include + namespace JabyEngine { struct DoubleBuffer { - // Hooks? - FontBufferInfo prim_buffer; + GPU::TexPage::Linked tex_page; + GPU::SPRT::Linked* cur_sprt_ptr; + FontBufferInfo prim_buffer; + + GPU::SPRT_16::Linked planschi; static constexpr DoubleBuffer empty() { - return DoubleBuffer{.prim_buffer = FontBufferInfo::empty()}; + return DoubleBuffer{.tex_page = {0}, .cur_sprt_ptr = nullptr, .prim_buffer = FontBufferInfo::empty()}; } - void setup(const FontBufferInfo& buffer_info) { + void setup(const FontBufferInfo& buffer_info, const SimpleTIM& vram_dst, const GPU::SizeI16& font_size) { + this->tex_page = GPU::TexPage::create(vram_dst.get_texture_position(), GPU::TexturePageColor::$4bit).linked(); this->prim_buffer = buffer_info; + + this->planschi = GPU::SPRT_16::create( + GPU::PositionI16::create(0, 0), + GPU::PagePositionClut::create(GPU::PagePosition::create(0, 0), GPU::PageClut::create(vram_dst.get_clut_position())) + ).linked(); + + for(size_t buffer_id = 0; buffer_id < 2; buffer_id++) { + for(size_t buffer_element_id = 0; buffer_element_id < buffer_info.single_buffer_length; buffer_element_id++) { + this->prim_buffer.double_buffer[buffer_id][buffer_element_id] = GPU::SPRT::create( + GPU::AreaI16::create(GPU::PositionI16::create(0, 0), font_size), + GPU::PagePositionClut::create(GPU::PagePosition::create(0, 0), GPU::PageClut::create(vram_dst.get_clut_position())) + ).linked(); + + this->prim_buffer.double_buffer[buffer_id][buffer_element_id]->set_identitiy(); + } + } } }; static auto double_buffer = DoubleBuffer::empty(); - void FontWriter :: setup(const FontBufferInfo& buffer_info, SimpleTIM vram_dst, const FontInfo& font_info) { - double_buffer.setup(buffer_info); - - printf("Hello Planschi c:\n"); + void FontWriter :: setup(const FontBufferInfo& buffer_info, const SimpleTIM& vram_dst, const FontInfo& font_info) { + printf("Hello Planschi c: @0x%p @0x%p\n", buffer_info.double_buffer[0], buffer_info.double_buffer[1]); + double_buffer.setup(buffer_info, vram_dst, GPU::SizeI16::create(font_info.FontSize.width, font_info.FontSize.height)); + + //TMP + double_buffer.prim_buffer.double_buffer[0][0].terminate(); + double_buffer.tex_page.concat(double_buffer.prim_buffer.double_buffer[0][0]); + //TMP-END + } + + void FontWriter :: render() { + GPU::render(double_buffer.tex_page); } } \ No newline at end of file diff --git a/examples/PoolBox/application/src/main.cpp b/examples/PoolBox/application/src/main.cpp index 24c249a1..15604d58 100644 --- a/examples/PoolBox/application/src/main.cpp +++ b/examples/PoolBox/application/src/main.cpp @@ -40,6 +40,7 @@ static void render() { GPU::swap_buffers_vsync(1); FontWriter::FontWriter::render(); paco.render(); + NewFontWriter::render(); } void main() { diff --git a/include/PSX/GPU/Primitives/primitive_support_types.hpp b/include/PSX/GPU/Primitives/primitive_support_types.hpp index d8f52b66..3eb9c8f1 100644 --- a/include/PSX/GPU/Primitives/primitive_support_types.hpp +++ b/include/PSX/GPU/Primitives/primitive_support_types.hpp @@ -72,6 +72,10 @@ namespace JabyEngine { static constexpr PageClut create(uint16_t x, uint16_t y) { return PageClut{static_cast((y << 6) | ((x >> 4) & 0x3f))}; } + + static constexpr PageClut create(const PositionU16& clut_pos) { + return PageClut::create(clut_pos.x, clut_pos.y); + } }; struct TPage {