Support all primitives
This commit is contained in:
parent
299ba7a9d6
commit
cc77237150
|
@ -110,10 +110,16 @@ static constexpr const auto line4 = GPU::LINE_G::create(
|
||||||
GPU::ColorVertex{GPU::Color24::White(), {0, 0}}
|
GPU::ColorVertex{GPU::Color24::White(), {0, 0}}
|
||||||
);
|
);
|
||||||
|
|
||||||
static constexpr const auto rect1 = GPU::RECT_FVAR(GPU::Color24::Green(), GPU::AreaI16({GPU::Display::Width - 32, GPU::Display::Height - 32}, {32, 32}));
|
static constexpr const auto rect1 = GPU::TILE(GPU::AreaI16({GPU::Display::Width - 32, GPU::Display::Height - 32}, {32, 32}), GPU::Color24::Green());
|
||||||
static constexpr const auto rect2 = GPU::RECT_F16(GPU::Color24::Blue(), {GPU::Display::Width - 16, GPU::Display::Height - 16});
|
static constexpr const auto rect2 = GPU::TILE_16({GPU::Display::Width - 16, GPU::Display::Height - 16}, GPU::Color24::Blue());
|
||||||
static constexpr const auto rect3 = GPU::RECT_F8(GPU::Color24::Yellow(), {GPU::Display::Width - 8, GPU::Display::Height - 8});
|
static constexpr const auto rect3 = GPU::TILE_8({GPU::Display::Width - 8, GPU::Display::Height - 8}, GPU::Color24::Yellow());
|
||||||
static constexpr const auto rect4 = GPU::RECT_F1(GPU::Color24::Red(), {GPU::Display::Width - 1, GPU::Display::Height - 1});
|
static constexpr const auto rect4 = GPU::TILE_1({GPU::Display::Width - 1, GPU::Display::Height - 1}, GPU::Color24::Red());
|
||||||
|
|
||||||
|
static constexpr const auto texpage = GPU::TexPage({320, 0}, GPU::TexturePageColor::$4bit);
|
||||||
|
static constexpr const auto rect5 = GPU::SPRT(GPU::AreaI16({0, GPU::Display::Height - 32}, {32, 32}), {{0, 0}, TriangleClut}, GPU::Color24::Green());
|
||||||
|
static constexpr const auto rect6 = GPU::SPRT_16({0, GPU::Display::Height - 16}, {{0, 0}, TriangleClut}, GPU::Color24::Blue());
|
||||||
|
static constexpr const auto rect7 = GPU::SPRT_8({0, GPU::Display::Height - 8}, {{0, 0}, TriangleClut}, GPU::Color24::Yellow());
|
||||||
|
static constexpr const auto rect8 = GPU::SPRT_1({0, GPU::Display::Height - 1}, {{0, 0}, TriangleClut}, GPU::Color24::Red());
|
||||||
|
|
||||||
static void load_assets() {
|
static void load_assets() {
|
||||||
static const CDFile Assets[] = {
|
static const CDFile Assets[] = {
|
||||||
|
@ -163,6 +169,11 @@ void main() {
|
||||||
GPU::render(rect2);
|
GPU::render(rect2);
|
||||||
GPU::render(rect3);
|
GPU::render(rect3);
|
||||||
GPU::render(rect4);
|
GPU::render(rect4);
|
||||||
|
GPU::render(texpage);
|
||||||
|
GPU::render(rect5);
|
||||||
|
GPU::render(rect6);
|
||||||
|
GPU::render(rect7);
|
||||||
|
GPU::render(rect8);
|
||||||
|
|
||||||
GPU::render(line1);
|
GPU::render(line1);
|
||||||
GPU::render(line2);
|
GPU::render(line2);
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef __JABYENGINE_PRIMITIVE_GPU_COMMANDS_HPP__
|
||||||
|
#define __JABYENGINE_PRIMITIVE_GPU_COMMANDS_HPP__
|
||||||
|
#include "../../System/IOPorts/gpu_io.hpp"
|
||||||
|
#include "primitive_support_types.hpp"
|
||||||
|
|
||||||
|
namespace JabyEngine {
|
||||||
|
namespace GPU {
|
||||||
|
struct TexPage {
|
||||||
|
GPU_IO::GP0_t value;
|
||||||
|
|
||||||
|
constexpr TexPage(const PositionU16& tex_pos, TexturePageColor tex_color, SemiTransparency transparency = SemiTransparency::B_Half_add_F_Half, bool dither = false) : value{
|
||||||
|
GPU_IO::Command::TexPage(tex_pos, transparency, tex_color, dither, false)} {}
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
__jaby_engine_declare_render_primitive(TexPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !__JABYENGINE_PRIMITIVE_GPU_COMMANDS_HPP__
|
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace GPU {
|
namespace GPU {
|
||||||
|
struct PagePositionClut {
|
||||||
|
PagePosition page;
|
||||||
|
PageClut clut;
|
||||||
|
};
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
struct RectCode : public CodeBase<RectCode> {
|
struct RectCode : public CodeBase<RectCode> {
|
||||||
enum struct Size : uint8_t {
|
enum struct Size : uint8_t {
|
||||||
|
@ -37,7 +42,7 @@ namespace JabyEngine {
|
||||||
Vertex position;
|
Vertex position;
|
||||||
|
|
||||||
constexpr RECT_F() = default;
|
constexpr RECT_F() = default;
|
||||||
constexpr RECT_F(const Color24& color, const Vertex& position) : color(color), code(IdentityCode), position(position) {
|
constexpr RECT_F(const Vertex& position, const Color24& color) : color(color), code(IdentityCode), position(position) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,45 +55,46 @@ namespace JabyEngine {
|
||||||
Code code;
|
Code code;
|
||||||
Vertex position;
|
Vertex position;
|
||||||
PagePosition page;
|
PagePosition page;
|
||||||
|
PageClut clut;
|
||||||
|
|
||||||
constexpr RECT_T() = default;
|
constexpr RECT_T() = default;
|
||||||
constexpr RECT_T(const Color24& color, const Vertex& position, const PagePosition& page) : color(color), code(IdentityCode), position(position), page(page) {
|
constexpr RECT_T(const Vertex& position, const PagePositionClut& page, const Color24& color = Color24::Grey()) : color(color), code(IdentityCode), position(position), page(page.page), clut(page.clut) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef internal::RECT_F<internal::RectCode::Size::Pixel1x1> RECT_F1;
|
typedef internal::RECT_F<internal::RectCode::Size::Pixel1x1> TILE_1;
|
||||||
typedef internal::RECT_F<internal::RectCode::Size::Sprite8x8> RECT_F8;
|
typedef internal::RECT_F<internal::RectCode::Size::Sprite8x8> TILE_8;
|
||||||
typedef internal::RECT_F<internal::RectCode::Size::Sprite16x16> RECT_F16;
|
typedef internal::RECT_F<internal::RectCode::Size::Sprite16x16> TILE_16;
|
||||||
struct RECT_FVAR : public internal::RECT_F<internal::RectCode::Size::Variable> {
|
struct TILE : public internal::RECT_F<internal::RectCode::Size::Variable> {
|
||||||
Vertex position_bottom_right;
|
Vertex position_bottom_right;
|
||||||
|
|
||||||
constexpr RECT_FVAR() = default;
|
constexpr TILE() = default;
|
||||||
constexpr RECT_FVAR(const Color24& color, const AreaI16& area) : RECT_F(color, area.position), position_bottom_right(area.get_bottom_left()) {
|
constexpr TILE(const AreaI16& area, const Color24& color) : RECT_F(area.position, color), position_bottom_right(area.get_bottom_left()) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef internal::RECT_T<internal::RectCode::Size::Pixel1x1> RECT_T1;
|
typedef internal::RECT_T<internal::RectCode::Size::Pixel1x1> SPRT_1;
|
||||||
typedef internal::RECT_T<internal::RectCode::Size::Sprite8x8> RECT_T8;
|
typedef internal::RECT_T<internal::RectCode::Size::Sprite8x8> SPRT_8;
|
||||||
typedef internal::RECT_T<internal::RectCode::Size::Sprite16x16> RECT_T16;
|
typedef internal::RECT_T<internal::RectCode::Size::Sprite16x16> SPRT_16;
|
||||||
struct RECT_TVAR : public internal::RECT_T<internal::RectCode::Size::Variable> {
|
struct SPRT : public internal::RECT_T<internal::RectCode::Size::Variable> {
|
||||||
Vertex position_bottom_right;
|
Vertex position_bottom_right;
|
||||||
|
|
||||||
constexpr RECT_TVAR() = default;
|
constexpr SPRT() = default;
|
||||||
constexpr RECT_TVAR(const Color24& color, const AreaI16& area, const PagePosition& page) : RECT_T(color, area.position, page), position_bottom_right(area.get_bottom_left()) {
|
constexpr SPRT(const AreaI16& area, const PagePositionClut& page, const Color24& color = Color24::Grey()) : RECT_T(area.position, page, color), position_bottom_right(area.get_bottom_left()) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
__jaby_engine_declare_render_primitive(RECT_F1);
|
__jaby_engine_declare_render_primitive(TILE_1);
|
||||||
__jaby_engine_declare_render_primitive(RECT_F8);
|
__jaby_engine_declare_render_primitive(TILE_8);
|
||||||
__jaby_engine_declare_render_primitive(RECT_F16);
|
__jaby_engine_declare_render_primitive(TILE_16);
|
||||||
__jaby_engine_declare_render_primitive(RECT_FVAR);
|
__jaby_engine_declare_render_primitive(TILE);
|
||||||
|
|
||||||
__jaby_engine_declare_render_primitive(RECT_T1);
|
__jaby_engine_declare_render_primitive(SPRT_1);
|
||||||
__jaby_engine_declare_render_primitive(RECT_T8);
|
__jaby_engine_declare_render_primitive(SPRT_8);
|
||||||
__jaby_engine_declare_render_primitive(RECT_T16);
|
__jaby_engine_declare_render_primitive(SPRT_16);
|
||||||
__jaby_engine_declare_render_primitive(RECT_TVAR);
|
__jaby_engine_declare_render_primitive(SPRT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,10 +71,6 @@ namespace JabyEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reexport for easier use
|
|
||||||
typedef JabyEngine::GPU_IO::SemiTransparency SemiTransparency;
|
|
||||||
typedef JabyEngine::GPU_IO::TexturePageColor TexturePageColor;
|
|
||||||
|
|
||||||
struct PageClut {
|
struct PageClut {
|
||||||
uint16_t value = 0;
|
uint16_t value = 0;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#ifndef __JABYENGINE_GPU_PRIMITIVES_HPP__
|
#ifndef __JABYENGINE_GPU_PRIMITIVES_HPP__
|
||||||
#define __JABYENGINE_GPU_PRIMITIVES_HPP__
|
#define __JABYENGINE_GPU_PRIMITIVES_HPP__
|
||||||
|
#include "Primitives/primitive_gpu_commands.hpp"
|
||||||
#include "Primitives/primitive_line_types.hpp"
|
#include "Primitives/primitive_line_types.hpp"
|
||||||
#include "Primitives/primitive_rectangle_types.hpp"
|
#include "Primitives/primitive_rectangle_types.hpp"
|
||||||
#include "Primitives/primitive_poly_types.hpp"
|
#include "Primitives/primitive_poly_types.hpp"
|
||||||
|
|
|
@ -32,6 +32,19 @@ namespace JabyEngine {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum struct SemiTransparency {
|
||||||
|
B_Half_add_F_Half = 0,
|
||||||
|
B_add_F = 1,
|
||||||
|
B_sub_F = 2,
|
||||||
|
B_add_F_Quarter = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum struct TexturePageColor {
|
||||||
|
$4bit = 0,
|
||||||
|
$8bit = 1,
|
||||||
|
$15bit = 2,
|
||||||
|
};
|
||||||
|
|
||||||
struct Color24 {
|
struct Color24 {
|
||||||
uint8_t red = 0;
|
uint8_t red = 0;
|
||||||
uint8_t green = 0;
|
uint8_t green = 0;
|
||||||
|
|
|
@ -6,24 +6,11 @@
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
namespace GPU_IO {
|
namespace GPU_IO {
|
||||||
enum struct SemiTransparency {
|
|
||||||
B_Half_add_F_Half = 0,
|
|
||||||
B_add_F = 1,
|
|
||||||
B_sub_F = 2,
|
|
||||||
B_add_F_Quarter = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum struct DisplayAreaColorDepth {
|
enum struct DisplayAreaColorDepth {
|
||||||
$15bit = 0,
|
$15bit = 0,
|
||||||
$24bit = 1,
|
$24bit = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum struct TexturePageColor {
|
|
||||||
$4bit = 0,
|
|
||||||
$8bit = 1,
|
|
||||||
$15bit = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum struct HorizontalResolution {
|
enum struct HorizontalResolution {
|
||||||
$256 = 0,
|
$256 = 0,
|
||||||
$320 = 1,
|
$320 = 1,
|
||||||
|
@ -114,9 +101,20 @@ namespace JabyEngine {
|
||||||
return {(0b101u << 29)};
|
return {(0b101u << 29)};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static constexpr GP0_t DrawMode(const GPU::PositionU16& page_pos, SemiTransparency transparency, TexturePageColor tex_color, bool dither) {
|
static constexpr GP0_t TexPage(const GPU::PositionU16& page_pos, GPU::SemiTransparency transparency, GPU::TexturePageColor 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);
|
||||||
|
constexpr auto TextureColorRange = BitRange::from_to(7, 8);
|
||||||
|
constexpr auto DitherBit = BitRange::from_to(9, 9);
|
||||||
|
constexpr auto DrawOnDisplayAreaBit = BitRange::from_to(10, 10);
|
||||||
|
|
||||||
}*/
|
return {Helper::construct_cmd(0xE1,
|
||||||
|
TexXRange.as_value(page_pos.x >> 6) | TexYRange.as_value(page_pos.y >> 7) |
|
||||||
|
TransparencyRange.as_value(static_cast<uint32_t>(transparency)) | TextureColorRange.as_value(static_cast<uint32_t>(tex_color)) |
|
||||||
|
DitherBit.as_value(static_cast<uint32_t>(dither)) | DrawOnDisplayAreaBit.as_value(static_cast<uint32_t>(draw_on_display_area))
|
||||||
|
)};
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr GP0_t DrawAreaTopLeft(const GPU::PositionU16& position) {
|
static constexpr GP0_t DrawAreaTopLeft(const GPU::PositionU16& position) {
|
||||||
return Helper::DrawAreaTemplate(0xE3, position.x, position.y);
|
return Helper::DrawAreaTemplate(0xE3, position.x, position.y);
|
||||||
|
@ -126,7 +124,7 @@ namespace JabyEngine {
|
||||||
return Helper::DrawAreaTemplate(0xE4, position.x, position.y);
|
return Helper::DrawAreaTemplate(0xE4, position.x, position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GP0_t SetDrawOffset(const GPU::PositionI16& offset) {
|
static constexpr GP0_t SetDrawOffset(const GPU::PositionI16& offset) {
|
||||||
constexpr auto X = BitRange::from_to(0, 10);
|
constexpr auto X = BitRange::from_to(0, 10);
|
||||||
constexpr auto Y = BitRange::from_to(11, 21);
|
constexpr auto Y = BitRange::from_to(11, 21);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue