Add more make functions

This commit is contained in:
jaby 2023-10-03 16:04:37 +02:00
parent a9f9ef8215
commit 9385f53bad
4 changed files with 100 additions and 18 deletions

View File

@ -15,12 +15,12 @@ using namespace JabyEngine;
// Some default values for the objects
static constexpr auto TriangleColor = GPU::Color24::from_rgb(0x0, 0xFF, 0xFF);
static constexpr auto TriangleArea = GPU::AreaI16::create(Make::PositionI16(0, 0), Make::SizeI16(64, 64));
static constexpr auto TriangleArea = Make::AreaI16(Make::PositionI16(0, 0), Make::SizeI16(64, 64));
static constexpr auto TriangleTPage = GPU::TPage::create(320, 0, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit);
static constexpr auto TriangleClut = GPU::PageClut::create(320, 511);
static constexpr auto RectangleColor = GPU::Color24(0x80, 0x80, 0xFF);
static constexpr auto RectangleArea = GPU::AreaI16::create(Make::PositionI16(0, TriangleArea.size.height), Make::SizeI16(80, 80));
static constexpr auto RectangleArea = Make::AreaI16(Make::PositionI16(0, TriangleArea.size.height), Make::SizeI16(80, 80));
static constexpr auto RectangleTPage = GPU::TPage::create(320, 256, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit);
static constexpr auto RectangleClut = GPU::PageClut::create(320, 510);
@ -38,9 +38,9 @@ static constexpr const auto triangle2 = GPU::POLY_FT3::create({
Make::Vertex(TriangleArea.size.width, TriangleArea.size.height)
},{
// Texture
GPU::PagePosition::create(TriangleArea.position.x, TriangleArea.position.y),
GPU::PagePosition::create(TriangleArea.size.width, TriangleArea.position.y),
GPU::PagePosition::create(TriangleArea.size.width, TriangleArea.size.height)
Make::PagePosition(TriangleArea.position.x, TriangleArea.position.y),
Make::PagePosition(TriangleArea.size.width, TriangleArea.position.y),
Make::PagePosition(TriangleArea.size.width, TriangleArea.size.height)
}, TriangleTPage, TriangleClut, GPU::Color24::Grey()
);
static constexpr const auto triangle3 = GPU::POLY_G3::create({
@ -57,8 +57,8 @@ static constexpr const auto triangle4 = GPU::POLY_GT3::create({
);
static constexpr const auto rectangle1 = GPU::POLY_F4::create(RectangleArea, RectangleColor);
static constexpr const auto rectangle2 = GPU::POLY_FT4::create(GPU::AreaI16::create(
RectangleArea.position.move(RectangleArea.size.width, 0), RectangleArea.size), GPU::PagePosition::create(0, 0),
static constexpr const auto rectangle2 = GPU::POLY_FT4::create(Make::AreaI16(
RectangleArea.position.move(RectangleArea.size.width, 0), RectangleArea.size), Make::PagePosition(0, 0),
RectangleTPage,
RectangleClut,
GPU::Color24::Grey()
@ -69,8 +69,8 @@ static constexpr const auto rectangle3 = GPU::POLY_G4::create(
GPU::Color24::Blue(),
GPU::Color24::Green(),
GPU::Color24::White()});
static constexpr const auto rectangle4 = GPU::POLY_GT4::create(GPU::AreaI16::create(
RectangleArea.position.move(RectangleArea.size.width*3, 0), RectangleArea.size), GPU::PagePosition::create(0, 0),
static constexpr const auto rectangle4 = GPU::POLY_GT4::create(Make::AreaI16(
RectangleArea.position.move(RectangleArea.size.width*3, 0), RectangleArea.size), Make::PagePosition(0, 0),
RectangleTPage,
RectangleClut, {
GPU::Color24::Red(),
@ -78,8 +78,8 @@ static constexpr const auto rectangle4 = GPU::POLY_GT4::create(GPU::AreaI16::cre
GPU::Color24::Green(),
GPU::Color24::White()}
);
static constexpr const auto rectangle5 = GPU::POLY_GT4::create(GPU::AreaI16::create(
RectangleArea.position.move(0, RectangleArea.size.height), RectangleArea.size), GPU::PagePosition::create(0, 0),
static constexpr const auto rectangle5 = GPU::POLY_GT4::create(Make::AreaI16(
RectangleArea.position.move(0, RectangleArea.size.height), RectangleArea.size), Make::PagePosition(0, 0),
RectangleTPage,
RectangleClut, {
GPU::Color24::Red(),
@ -109,19 +109,19 @@ static constexpr const auto line4 = GPU::LINE_G::create(
GPU::ColorVertex{GPU::Color24::White(), Make::Vertex(0, 0)}
);
static constexpr const auto rect1 = GPU::TILE::create(GPU::AreaI16::create(Make::PositionI16(GPU::Display::Width - 32, GPU::Display::Height - 32), Make::SizeI16(32, 32)), GPU::Color24::Green());
static constexpr const auto rect1 = GPU::TILE::create(Make::AreaI16(Make::PositionI16(GPU::Display::Width - 32, GPU::Display::Height - 32), Make::SizeI16(32, 32)), GPU::Color24::Green());
static constexpr const auto rect2 = GPU::TILE_16::create(Make::PositionI16(GPU::Display::Width - 16, GPU::Display::Height - 16), GPU::Color24::Blue());
static constexpr const auto rect3 = GPU::TILE_8::create(Make::PositionI16(GPU::Display::Width - 8, GPU::Display::Height - 8), GPU::Color24::Yellow());
static constexpr const auto rect4 = GPU::TILE_1::create(Make::PositionI16(GPU::Display::Width - 1, GPU::Display::Height - 1), GPU::Color24::Red());
static constexpr const auto texpage = GPU::TexPage::create(Make::PositionU16(320, 0), GPU::TexturePageColor::$4bit);
static constexpr const auto rect5 = GPU::SPRT::create(GPU::AreaI16(Make::PositionI16(0, GPU::Display::Height - 32), Make::SizeI16(32, 32)), {GPU::PagePosition::create(0, 0), TriangleClut}, GPU::Color24::Green());
static constexpr const auto rect6 = GPU::SPRT_16::create(Make::Vertex(0, GPU::Display::Height - 16), {GPU::PagePosition::create(0, 0), TriangleClut}, GPU::Color24::Blue());
static constexpr const auto rect7 = GPU::SPRT_8::create(Make::Vertex(0, GPU::Display::Height - 8), {GPU::PagePosition::create(0, 0), TriangleClut}, GPU::Color24::Yellow());
static constexpr const auto rect8 = GPU::SPRT_1::create(Make::Vertex(0, GPU::Display::Height - 1), {GPU::PagePosition::create(0, 0), TriangleClut}, GPU::Color24::Red());
static constexpr const auto rect5 = GPU::SPRT::create(Make::AreaI16(Make::PositionI16(0, GPU::Display::Height - 32), Make::SizeI16(32, 32)), {Make::PagePosition(0, 0), TriangleClut}, GPU::Color24::Green());
static constexpr const auto rect6 = GPU::SPRT_16::create(Make::Vertex(0, GPU::Display::Height - 16), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Blue());
static constexpr const auto rect7 = GPU::SPRT_8::create(Make::Vertex(0, GPU::Display::Height - 8), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Yellow());
static constexpr const auto rect8 = GPU::SPRT_1::create(Make::Vertex(0, GPU::Display::Height - 1), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Red());
static auto rect9 = GPU::SPRT::create(GPU::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2), Make::SizeI16(32, 32)).centered(), {GPU::PagePosition::create(0, 0), TriangleClut}, GPU::Color24::Grey()).linked();
static auto rect10 = GPU::SPRT::create(GPU::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2 - 32), Make::SizeI16(32, 32)).centered(), {GPU::PagePosition::create(0, 0), TriangleClut}, GPU::Color24::Grey()).linked();
static auto rect9 = GPU::SPRT::create(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2), Make::SizeI16(32, 32)).centered(), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Grey()).linked();
static auto rect10 = GPU::SPRT::create(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2 - 32), Make::SizeI16(32, 32)).centered(), Make::PagePositionClut(Make::PagePosition(0, 0), TriangleClut), GPU::Color24::Grey()).linked();
static void load_assets() {
static const CDFile Assets[] = {

View File

@ -8,6 +8,10 @@ namespace JabyEngine {
struct PagePositionClut {
PagePosition page;
PageClut clut;
static constexpr PagePositionClut create(PagePosition page, PageClut clut) {
return PagePositionClut{page, clut};
}
};
namespace internal {

View File

@ -65,6 +65,76 @@ namespace JabyEngine {
static constexpr GPU::Vertex Vertex(int16_t x, int16_t y) {
return creator_template<GPU::Vertex>(x, y);
}
// ###################################################################
static constexpr GPU::AreaI16 AreaI16(int16_t x, int16_t y, int16_t w, int16_t h) {
return creator_template<GPU::AreaI16>(x, y, w, h);
}
static constexpr GPU::AreaI16 AreaI16(GPU::PositionI16 pos, GPU::SizeI16 size) {
return creator_template<GPU::AreaI16>(pos, size);
}
// ###################################################################
static constexpr GPU::AreaU16 AreaU16(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
return creator_template<GPU::AreaU16>(x, y, w, h);
}
static constexpr GPU::AreaU16 AreaU16(GPU::PositionU16 pos, GPU::SizeU16 size) {
return creator_template<GPU::AreaU16>(pos, size);
}
// ###################################################################
static constexpr GPU::PagePosition PagePosition() {
return creator_template<GPU::PagePosition>(0, 0);
}
static constexpr GPU::PagePosition PagePosition(uint8_t u, uint8_t v) {
return creator_template<GPU::PagePosition>(u, v);
}
// ###################################################################
static constexpr GPU::PageClut PageClut() {
return creator_template<GPU::PageClut>(0, 0);
}
static constexpr GPU::PageClut PageClut(uint16_t x, uint16_t y) {
return creator_template<GPU::PageClut>(x, y);
}
// ###################################################################
static constexpr GPU::PagePositionClut PagePositionClut() {
return creator_template<GPU::PagePositionClut>(PagePosition(), PageClut());
}
static constexpr GPU::PagePositionClut PagePositionClut(GPU::PagePosition page, GPU::PageClut clut) {
return creator_template<GPU::PagePositionClut>(page, clut);
}
// ###################################################################
static constexpr GPU::VertexColor VertexColor() {
return creator_template<GPU::VertexColor>(Vertex(), GPU::Color24::Black());
}
static constexpr GPU::VertexColor VertexColor(GPU::Vertex pos, GPU::Color24 color) {
return creator_template<GPU::VertexColor>(pos, color);
}
// ###################################################################
static constexpr GPU::ColorVertex ColorVertex() {
return creator_template<GPU::ColorVertex>(GPU::Color24::Black(), Vertex());
}
static constexpr GPU::ColorVertex ColorVertex(GPU::Color24 color, GPU::Vertex pos) {
return creator_template<GPU::ColorVertex>(color, pos);
}
}
}

View File

@ -207,11 +207,19 @@ namespace JabyEngine {
struct VertexColor {
Vertex position;
Color24 color;
static constexpr VertexColor create(Vertex vertex, Color24 color) {
return VertexColor{vertex, color};
}
};
struct ColorVertex {
Color24 color;
alignas(2) Vertex position;
static constexpr ColorVertex create(Color24 color, Vertex vertex) {
return ColorVertex{color, vertex};
}
};
}
}