From 13c7cba59959af7e7f672c70308ee2162a920c5c Mon Sep 17 00:00:00 2001 From: Jaby Date: Thu, 15 Jun 2023 20:48:25 +0200 Subject: [PATCH] Testing font and color font --- examples/PoolBox/application/src/assets.hpp | 4 +++ examples/PoolBox/application/src/main.cpp | 20 +++++++++++++- .../PoolBox/application/src/main_assets.cpp | 26 +++++++++++++++++-- .../PSX/GPU/Primitives/linked_elements.hpp | 7 ++++- include/PSX/GPU/gpu_types.hpp | 16 ++++++------ 5 files changed, 61 insertions(+), 12 deletions(-) diff --git a/examples/PoolBox/application/src/assets.hpp b/examples/PoolBox/application/src/assets.hpp index 000ae349..a92673eb 100644 --- a/examples/PoolBox/application/src/assets.hpp +++ b/examples/PoolBox/application/src/assets.hpp @@ -1,7 +1,11 @@ #ifndef __ASSETS_HPP__ #define __ASSETS_HPP__ +#include namespace Assets { + using namespace JabyEngine; + + static constexpr auto FontTIM = SimpleTIM(960, 0, 960, 511); void load_for_main(); } diff --git a/examples/PoolBox/application/src/main.cpp b/examples/PoolBox/application/src/main.cpp index 9bc34324..277b9103 100644 --- a/examples/PoolBox/application/src/main.cpp +++ b/examples/PoolBox/application/src/main.cpp @@ -1,7 +1,25 @@ #include "assets.hpp" +#include +#include #include +using namespace JabyEngine; +static auto FontPage = GPU::TexPage({Assets::FontTIM.get_texture_x(), Assets::FontTIM.get_texture_y()}, GPU::TexturePageColor::$4bit).linked(); +static auto FontTest = GPU::SPRT( + GPU::AreaI16({0, 0}, {256, 96}), {GPU::PagePosition(0, 0), GPU::PageClut(Assets::FontTIM.get_clut_x(), Assets::FontTIM.get_clut_y())}, + GPU::Color24::Grey() +).linked(); +static auto FontTestColor = GPU::SPRT( + GPU::AreaI16({0, 96}, {256, 96}), {GPU::PagePosition(0, 0), GPU::PageClut(Assets::FontTIM.get_clut_x(), Assets::FontTIM.get_clut_y())}, + GPU::Color24(0x0, 0x0, 0xA0) +).linked(); + void main() { Assets::load_for_main(); - printf("Planschbecken c:\n"); + + FontPage.concat(FontTest).concat(FontTestColor); + while(true) { + GPU::swap_buffers_vsync(1); + GPU::render(FontPage); + } } \ No newline at end of file diff --git a/examples/PoolBox/application/src/main_assets.cpp b/examples/PoolBox/application/src/main_assets.cpp index 050c9162..b3ea8041 100644 --- a/examples/PoolBox/application/src/main_assets.cpp +++ b/examples/PoolBox/application/src/main_assets.cpp @@ -1,5 +1,4 @@ #include "assets.hpp" -#include #include #include @@ -13,6 +12,29 @@ namespace Assets { __declare_lba_header(LBA); void load_for_main() { - printf("Loading assets! %i\n", lba[LBA::FONT].get_lba()); + static const CDFile Assets[] = { + CDFileBuilder::simple_tim(LBA::FONT, FontTIM), + }; + + const auto buffer_cfg = CDFileProcessor::BufferConfiguration::new_default(); + CDFileProcessor file_processor; + + file_processor.setup(lba, Assets, buffer_cfg); + while(true) { + switch(file_processor.process()) { + case Progress::InProgress: + break; + + case Progress::Done: + if(!file_processor.next(lba, buffer_cfg)) { + return; + } + break; + + case Progress::Error: + printf("Error detected! Aborting load\n"); + return; + } + } } } \ No newline at end of file diff --git a/include/PSX/GPU/Primitives/linked_elements.hpp b/include/PSX/GPU/Primitives/linked_elements.hpp index 5a1b2c13..45c8f49e 100644 --- a/include/PSX/GPU/Primitives/linked_elements.hpp +++ b/include/PSX/GPU/Primitives/linked_elements.hpp @@ -34,11 +34,16 @@ namespace JabyEngine { } template - const T& concat(const T& obj) { + T& concat(T& obj) { Link::set_adr(&obj); return obj; } + template + const T& concat(const T& obj) { + return concat(const_cast(obj)); + } + constexpr void terminate() { this->value |= TerminationValue; } diff --git a/include/PSX/GPU/gpu_types.hpp b/include/PSX/GPU/gpu_types.hpp index 0ef84a80..6900da29 100644 --- a/include/PSX/GPU/gpu_types.hpp +++ b/include/PSX/GPU/gpu_types.hpp @@ -78,20 +78,20 @@ namespace JabyEngine { return Color24(0xFF, 0xFF, 0xFF); } - static constexpr Color24 Red() { - return Color24(0xFF, 0x0, 0x0); + static constexpr Color24 Red(uint8_t base = 0xFF) { + return Color24(base, 0x0, 0x0); } - static constexpr Color24 Green() { - return Color24(0x0, 0xFF, 0x0); + static constexpr Color24 Green(uint8_t base = 0xFF) { + return Color24(0x0, base, 0x0); } - static constexpr Color24 Blue() { - return Color24(0x0, 0x0, 0xFF); + static constexpr Color24 Blue(uint8_t base = 0xFF) { + return Color24(0x0, 0x0, base); } - static constexpr Color24 Yellow() { - return Color24(0xFF, 0xFF, 0x0); + static constexpr Color24 Yellow(uint8_t base = 0xFF) { + return Color24(base, base, 0x0); } constexpr Color24 invert() const {