diff --git a/examples/PoolBox/application/src/Overlay/ControllerTest/include/controller_state.hpp b/examples/PoolBox/application/src/Overlay/ControllerTest/include/controller_state.hpp index f64e5365..5378d575 100644 --- a/examples/PoolBox/application/src/Overlay/ControllerTest/include/controller_state.hpp +++ b/examples/PoolBox/application/src/Overlay/ControllerTest/include/controller_state.hpp @@ -18,7 +18,7 @@ namespace ControllerTest { ControllerState state; for(auto& tex_page : state.tex_page) { - tex_page = Make::TexPage(ControllerButtonTIM.get_texture_position(), GPU::TexturePageColor::$4bit).linked(); + tex_page = Make::TexPage(ControllerButtonTIM.get_texture_position(), GPU::TextureColorMode::clut4).linked(); } for(auto& buttons : state.buttons) { @@ -51,10 +51,10 @@ namespace ControllerTest { } for(auto& arrows : state.arrows) { - arrows[0] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect( Make::AreaI16(Make::PositionI16( 7, 5).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); - arrows[1] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect270(Make::AreaI16(Make::PositionI16(14, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); - arrows[2] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect180(Make::AreaI16(Make::PositionI16( 7, 17).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); - arrows[3] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect90( Make::AreaI16(Make::PositionI16( 0, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); + arrows[0] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect( Make::AreaI16(Make::PositionI16( 7, 5).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); + arrows[1] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect270(Make::AreaI16(Make::PositionI16(14, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); + arrows[2] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect180(Make::AreaI16(Make::PositionI16( 7, 17).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); + arrows[3] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect90( Make::AreaI16(Make::PositionI16( 0, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked(); } return state; diff --git a/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp b/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp index e2305328..9851670b 100644 --- a/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp +++ b/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp @@ -11,12 +11,12 @@ namespace GPUTest { // Some default values for the objects static constexpr auto TriangleColor = GPU::Color24::from_rgb(0x0, 0xFF, 0xFF); static constexpr auto TriangleArea = Make::AreaI16(Make::PositionI16(0, 0), Make::SizeI16(64, 64)); - static constexpr auto TriangleTPage = Make::TPage(TexPageTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit); + static constexpr auto TriangleTPage = Make::TPage(TexPageTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4); static constexpr auto TriangleClut = Make::PageClut(TexPageTIM.get_clut_position()); static constexpr auto RectangleColor = GPU::Color24::from_rgb(0x80, 0x80, 0xFF); static constexpr auto RectangleArea = Make::AreaI16(Make::PositionI16(0, TriangleArea.size.height), Make::SizeI16(80, 80)); - static constexpr auto RectangleTPage = Make::TPage(IconTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit); + static constexpr auto RectangleTPage = Make::TPage(IconTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4); static constexpr auto RectangleClut = Make::PageClut(IconTIM.get_clut_position()); static constexpr auto LineColor = GPU::Color24::from_rgb(0xFF, 0x0, 0x0); @@ -109,7 +109,7 @@ namespace GPUTest { static constexpr const auto rect3 = Make::TILE_8(Make::PositionI16(GPU::Display::Width - 8, GPU::Display::Height - 8), GPU::Color24::Yellow()); static constexpr const auto rect4 = Make::TILE_1(Make::PositionI16(GPU::Display::Width - 1, GPU::Display::Height - 1), GPU::Color24::Red()); - static constexpr const auto texpage = Make::TexPage(TexPageTIM.get_texture_position(), GPU::TexturePageColor::$4bit); + static constexpr const auto texpage = Make::TexPage(TexPageTIM.get_texture_position(), GPU::TextureColorMode::clut4); static constexpr const auto rect5 = Make::SPRT(Make::AreaI16(Make::PositionI16(0, GPU::Display::Height - 32), Make::SizeI16(32, 32)), {Make::PageOffset(0, 0), TriangleClut}, GPU::Color24::Green()); static constexpr const auto rect6 = Make::SPRT_16(Make::Vertex(0, GPU::Display::Height - 16), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Blue()); static constexpr const auto rect7 = Make::SPRT_8(Make::Vertex(0, GPU::Display::Height - 8), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Yellow()); diff --git a/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp b/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp index bb2645ab..f3b1d467 100644 --- a/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp +++ b/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp @@ -8,9 +8,9 @@ namespace GTETest { using namespace JabyEngine; static auto doener_fish = Make::POLY_FT4( - Make::AreaI16(Make::PositionI16(0, 0), Assets::Main::DoenerFishInfo.size), + GPU::Display::center(Make::AreaI16(Make::PositionI16(0, 0), Assets::Main::DoenerFishInfo.size)), Assets::Main::DoenerFishInfo.tim.get_page_offset_clut4(), - Make::TPage(Assets::Main::DoenerFishInfo.tim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TexturePageColor::$4bit), + Make::TPage(Assets::Main::DoenerFishInfo.tim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4), Make::PageClut(Assets::Main::DoenerFishInfo.tim.get_clut_position()), GPU::Color24::Grey() ); diff --git a/examples/PoolBox/application/src/include/paco.hpp b/examples/PoolBox/application/src/include/paco.hpp index 052dc8c6..ab64ccc8 100644 --- a/examples/PoolBox/application/src/include/paco.hpp +++ b/examples/PoolBox/application/src/include/paco.hpp @@ -20,7 +20,7 @@ namespace object { constexpr Paco() : tex_page(Make::TexPage(Make::PositionU16( Assets::Main::PacoTIM.get_texture_x(), Assets::Main::PacoTIM.get_texture_y()), - GPU::TexturePageColor::$4bit).linked()), + GPU::TextureColorMode::clut4).linked()), sprite(Make::SPRT( Make::AreaI16(Make::PositionI16(GPU::Display::Width - Size.width, GPU::Display::Height - Size.height), Size), Make::OffsetPageWithClut(Make::PageOffset(0, 0), Make::PageClut(Assets::Main::PacoTIM.get_clut_x(), Assets::Main::PacoTIM.get_clut_y())), diff --git a/include/PSX/GPU/Primitives/primitive_gpu_commands.hpp b/include/PSX/GPU/Primitives/primitive_gpu_commands.hpp index adebfa98..63f423ed 100644 --- a/include/PSX/GPU/Primitives/primitive_gpu_commands.hpp +++ b/include/PSX/GPU/Primitives/primitive_gpu_commands.hpp @@ -10,7 +10,7 @@ namespace JabyEngine { struct GPU_IO::GP0 value; - static constexpr TexPage create(const PositionU16& tex_pos, TexturePageColor tex_color, SemiTransparency transparency = SemiTransparency::B_Half_add_F_Half, bool dither = false) { + static constexpr TexPage create(const PositionU16& tex_pos, TextureColorMode tex_color, SemiTransparency transparency = SemiTransparency::B_Half_add_F_Half, bool dither = false) { return TexPage{.value = GPU_IO::Command::TexPage(tex_pos, transparency, tex_color, dither, false)}; } }; diff --git a/include/PSX/GPU/Primitives/primitive_support_types.hpp b/include/PSX/GPU/Primitives/primitive_support_types.hpp index 916be67f..1ed04230 100644 --- a/include/PSX/GPU/Primitives/primitive_support_types.hpp +++ b/include/PSX/GPU/Primitives/primitive_support_types.hpp @@ -86,11 +86,11 @@ namespace JabyEngine { uint16_t value; - static constexpr TPage create(uint16_t x, uint16_t y, ::JabyEngine::GPU::SemiTransparency transparency, TexturePageColor clut_color) { + static constexpr TPage create(uint16_t x, uint16_t y, ::JabyEngine::GPU::SemiTransparency transparency, TextureColorMode clut_color) { return TPage{static_cast(TexturePageX.as_value(x >> 6) | TexturePageY.as_value(y >> 8) | SemiTransparency.as_value(static_cast(transparency)) | TextureClut.as_value(static_cast(clut_color)))}; } - static constexpr TPage create(const PositionU16& pos, ::JabyEngine::GPU::SemiTransparency transparency, TexturePageColor clut_color) { + static constexpr TPage create(const PositionU16& pos, ::JabyEngine::GPU::SemiTransparency transparency, TextureColorMode clut_color) { return TPage::create(pos.x, pos.y, transparency, clut_color); } }; diff --git a/include/PSX/GPU/gpu.hpp b/include/PSX/GPU/gpu.hpp index 4ccf6434..b12490f2 100644 --- a/include/PSX/GPU/gpu.hpp +++ b/include/PSX/GPU/gpu.hpp @@ -21,11 +21,16 @@ namespace JabyEngine { #else static constexpr size_t Width = 320; static constexpr size_t Height = 240; - static constexpr uint32_t frames_per_sec = 50; + static constexpr uint32_t frames_per_sec = 60; #endif static uint8_t current_id; + template + static constexpr Area center(const Area& area) { + return Area::create(Position::create((Display::Width - area.size.width)/2, (Display::Height - area.size.height)/2), area.size); + } + static void enable() { GPU_IO::GP1.write(GPU_IO::Command::SetDisplayState(GPU_IO::DisplayState::On)); } diff --git a/include/PSX/GPU/gpu_auto_load_font.hpp b/include/PSX/GPU/gpu_auto_load_font.hpp index 0b04510e..432697cf 100644 --- a/include/PSX/GPU/gpu_auto_load_font.hpp +++ b/include/PSX/GPU/gpu_auto_load_font.hpp @@ -12,11 +12,11 @@ namespace JabyEngine { static constexpr auto CLUTLoadPos = Configuration::BIOSFont::CLUTLoadPos; static constexpr TexPage get_tex_page() { - return TexPage::create(BIOS_Font::TextureLoadPos, GPU::TexturePageColor::$4bit); + return TexPage::create(BIOS_Font::TextureLoadPos, GPU::TextureColorMode::clut4); } static constexpr TPage get_tpage() { - return TPage::create(TextureLoadPos.x, TextureLoadPos.y, SemiTransparency::B_add_F, TexturePageColor::$4bit); + return TPage::create(TextureLoadPos.x, TextureLoadPos.y, SemiTransparency::B_add_F, TextureColorMode::clut4); } static constexpr PageOffset get_offset_page() { diff --git a/include/PSX/GPU/gpu_types.hpp b/include/PSX/GPU/gpu_types.hpp index 2d52f176..966b6fd2 100644 --- a/include/PSX/GPU/gpu_types.hpp +++ b/include/PSX/GPU/gpu_types.hpp @@ -93,10 +93,10 @@ namespace JabyEngine { B_add_F_Quarter = 3, }; - enum struct TexturePageColor { - $4bit = 0, - $8bit = 1, - $15bit = 2, + enum struct TextureColorMode { + clut4 = 0, + clut8 = 1, + direct16 = 2, }; struct Color24 : public internal::PredefinedColors { @@ -249,8 +249,8 @@ namespace JabyEngine { static constexpr Area create(T position_x, T position_y, T size_width, T size_height) { return Area{Position::create(position_x, position_y), Size::create(size_width, size_height)}; } - - constexpr Area centered() const { + + constexpr Area centered() const { return Area(this->position.sub(this->size.width/2, this->size.height/2), this->size); } diff --git a/include/PSX/GPU/make_gpu_primitives.hpp b/include/PSX/GPU/make_gpu_primitives.hpp index c359e699..06a15390 100644 --- a/include/PSX/GPU/make_gpu_primitives.hpp +++ b/include/PSX/GPU/make_gpu_primitives.hpp @@ -140,21 +140,21 @@ namespace JabyEngine { // ################################################################### static constexpr GPU::TPage TPage() { - return creator_template(0_u16, 0_u16, GPU::SemiTransparency::B_add_F, GPU::TexturePageColor::$4bit); + return creator_template(0_u16, 0_u16, GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4); } - static constexpr GPU::TPage TPage(uint16_t x, uint16_t y, GPU::SemiTransparency transparency, GPU::TexturePageColor clut_color) { + static constexpr GPU::TPage TPage(uint16_t x, uint16_t y, GPU::SemiTransparency transparency, GPU::TextureColorMode clut_color) { return creator_template(x, y, transparency, clut_color); } - static constexpr GPU::TPage TPage(const GPU::PositionU16& tex_pos, GPU::SemiTransparency transparency, GPU::TexturePageColor clut_color) { + static constexpr GPU::TPage TPage(const GPU::PositionU16& tex_pos, GPU::SemiTransparency transparency, GPU::TextureColorMode clut_color) { return creator_template(tex_pos, transparency, clut_color); } // ################################################################### static constexpr GPU::TexPage TexPage() { - return creator_template(PositionU16(), GPU::TexturePageColor::$4bit, GPU::SemiTransparency::B_Half_add_F_Half, false); + return creator_template(PositionU16(), GPU::TextureColorMode::clut4, GPU::SemiTransparency::B_Half_add_F_Half, false); } - static constexpr GPU::TexPage TexPage(const GPU::PositionU16& tex_pos, GPU::TexturePageColor tex_color, GPU::SemiTransparency transparency = GPU::SemiTransparency::B_Half_add_F_Half, bool dither = false) { + static constexpr GPU::TexPage TexPage(const GPU::PositionU16& tex_pos, GPU::TextureColorMode tex_color, GPU::SemiTransparency transparency = GPU::SemiTransparency::B_Half_add_F_Half, bool dither = false) { return creator_template(tex_pos, tex_color, transparency, dither); } diff --git a/include/PSX/System/IOPorts/gpu_io.hpp b/include/PSX/System/IOPorts/gpu_io.hpp index 1946051f..0c91ffe0 100644 --- a/include/PSX/System/IOPorts/gpu_io.hpp +++ b/include/PSX/System/IOPorts/gpu_io.hpp @@ -104,7 +104,7 @@ namespace JabyEngine { return Helper::construct_cmd(0xA0, 0); } - static constexpr struct GP0 TexPage(const GPU::PositionU16& page_pos, GPU::SemiTransparency transparency, GPU::TexturePageColor tex_color, bool dither, bool draw_on_display_area) { + static constexpr struct GP0 TexPage(const GPU::PositionU16& page_pos, GPU::SemiTransparency transparency, GPU::TextureColorMode tex_color, bool dither, bool draw_on_display_area) { constexpr auto TexXRange = BitRange::from_to(0, 3); constexpr auto TexYRange = BitRange::from_to(4, 4); constexpr auto TransparencyRange = BitRange::from_to(5, 6); diff --git a/support/src/FontWriter/src/font_writer.cpp b/support/src/FontWriter/src/font_writer.cpp index 06e9be77..ad7bacf6 100644 --- a/support/src/FontWriter/src/font_writer.cpp +++ b/support/src/FontWriter/src/font_writer.cpp @@ -56,7 +56,7 @@ namespace JabyEngine { void FontWriter :: setup(const SimpleTIM& vram_dst, const FontInfo::RenderInfo& font_render_info) { for(auto& tex_page : this->tex_page) { - tex_page = Make::TexPage(vram_dst.get_texture_position(), GPU::TexturePageColor::$4bit).linked(); + tex_page = Make::TexPage(vram_dst.get_texture_position(), GPU::TextureColorMode::clut4).linked(); } this->render_info = font_render_info; this->clut = Make::PageClut(vram_dst.get_clut_position());