Small improvements for code readability

This commit is contained in:
Jaby 2024-01-23 14:44:10 -05:00
parent e2916d3a2b
commit c546b3de4e
12 changed files with 35 additions and 30 deletions

View File

@ -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;

View File

@ -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());

View File

@ -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()
);

View File

@ -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())),

View File

@ -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)};
}
};

View File

@ -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<uint16_t>(TexturePageX.as_value(x >> 6) | TexturePageY.as_value(y >> 8) | SemiTransparency.as_value(static_cast<uint16_t>(transparency)) | TextureClut.as_value(static_cast<uint16_t>(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);
}
};

View File

@ -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<typename T>
static constexpr Area<T> center(const Area<T>& area) {
return Area<T>::create(Position<T>::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));
}

View File

@ -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() {

View File

@ -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<Color24> {
@ -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<T>::create(position_x, position_y), Size<T>::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);
}

View File

@ -140,21 +140,21 @@ namespace JabyEngine {
// ###################################################################
static constexpr GPU::TPage TPage() {
return creator_template<GPU::TPage>(0_u16, 0_u16, GPU::SemiTransparency::B_add_F, GPU::TexturePageColor::$4bit);
return creator_template<GPU::TPage>(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<GPU::TPage>(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<GPU::TPage>(tex_pos, transparency, clut_color);
}
// ###################################################################
static constexpr GPU::TexPage TexPage() {
return creator_template<GPU::TexPage>(PositionU16(), GPU::TexturePageColor::$4bit, GPU::SemiTransparency::B_Half_add_F_Half, false);
return creator_template<GPU::TexPage>(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<GPU::TexPage>(tex_pos, tex_color, transparency, dither);
}

View File

@ -104,7 +104,7 @@ namespace JabyEngine {
return Helper::construct_cmd<struct GP0>(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);

View File

@ -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());