Integrate all the progress into master #6
|
@ -40,6 +40,21 @@ namespace JabyEngine {
|
|||
constexpr RECT_F(const Color24& color, const Vertex& position) : color(color), code(IdentityCode), position(position) {
|
||||
}
|
||||
};
|
||||
|
||||
template<typename RectCode::Size Size>
|
||||
struct RECT_T : public RectCodeInterface<RECT_T<Size>> {
|
||||
typedef RECT_T<Size>::Code Code;
|
||||
static constexpr auto IdentityCode = Code(RECT_F<Size>::IdentityCode).set(Code::Textured);
|
||||
|
||||
Color24 color;
|
||||
Code code;
|
||||
Vertex position;
|
||||
PagePosition page;
|
||||
|
||||
constexpr RECT_T() = default;
|
||||
constexpr RECT_T(const Color24& color, const Vertex& position, const PagePosition& page) : color(color), code(IdentityCode), position(position), page(page) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
typedef internal::RECT_F<internal::RectCode::Size::Pixel1x1> RECT_F1;
|
||||
|
@ -49,7 +64,18 @@ namespace JabyEngine {
|
|||
Vertex position_bottom_right;
|
||||
|
||||
constexpr RECT_FVAR() = default;
|
||||
constexpr RECT_FVAR(const Color24& color, const AreaI16& area) : RECT_F(color, area.position), position_bottom_right(area.position.move(area.size.width, area.size.height)) {
|
||||
constexpr RECT_FVAR(const Color24& color, const AreaI16& area) : RECT_F(color, area.position), position_bottom_right(area.get_bottom_left()) {
|
||||
}
|
||||
};
|
||||
|
||||
typedef internal::RECT_T<internal::RectCode::Size::Pixel1x1> RECT_T1;
|
||||
typedef internal::RECT_T<internal::RectCode::Size::Sprite8x8> RECT_T8;
|
||||
typedef internal::RECT_T<internal::RectCode::Size::Sprite16x16> RECT_T16;
|
||||
struct RECT_TVAR : public internal::RECT_T<internal::RectCode::Size::Variable> {
|
||||
Vertex position_bottom_right;
|
||||
|
||||
constexpr RECT_TVAR() = 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()) {
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -58,6 +84,11 @@ namespace JabyEngine {
|
|||
__jaby_engine_declare_render_primitive(RECT_F8);
|
||||
__jaby_engine_declare_render_primitive(RECT_F16);
|
||||
__jaby_engine_declare_render_primitive(RECT_FVAR);
|
||||
|
||||
__jaby_engine_declare_render_primitive(RECT_T1);
|
||||
__jaby_engine_declare_render_primitive(RECT_T8);
|
||||
__jaby_engine_declare_render_primitive(RECT_T16);
|
||||
__jaby_engine_declare_render_primitive(RECT_TVAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,6 +142,10 @@ namespace JabyEngine {
|
|||
}
|
||||
constexpr Area(T position_x, T position_y, T size_width, T size_height) : position{position_x, position_y}, size{size_width, size_height} {
|
||||
}
|
||||
|
||||
constexpr Position<T> get_bottom_left() const {
|
||||
return this->position.move(this->size.width, this->size.height);
|
||||
}
|
||||
};
|
||||
|
||||
// Type used for primitives
|
||||
|
|
|
@ -114,27 +114,31 @@ namespace JabyEngine {
|
|||
return {(0b101u << 29)};
|
||||
}
|
||||
|
||||
static constexpr GP0_t DrawAreaTopLeft(uint16_t x, uint16_t y) {
|
||||
return Helper::DrawAreaTemplate(0xE3, x, y);
|
||||
/*static constexpr GP0_t DrawMode(const GPU::PositionU16& page_pos, SemiTransparency transparency, TexturePageColor tex_color, bool dither) {
|
||||
|
||||
}*/
|
||||
|
||||
static constexpr GP0_t DrawAreaTopLeft(const GPU::PositionU16& position) {
|
||||
return Helper::DrawAreaTemplate(0xE3, position.x, position.y);
|
||||
}
|
||||
|
||||
static constexpr GP0_t DrawAreaBottomRight(uint16_t x, uint16_t y) {
|
||||
return Helper::DrawAreaTemplate(0xE4, x, y);
|
||||
static constexpr GP0_t DrawAreaBottomRight(const GPU::PositionU16& position) {
|
||||
return Helper::DrawAreaTemplate(0xE4, position.x, position.y);
|
||||
}
|
||||
|
||||
static GP0_t SetDrawOffset(int16_t x, int16_t y) {
|
||||
static GP0_t SetDrawOffset(const GPU::PositionI16& offset) {
|
||||
constexpr auto X = BitRange::from_to(0, 10);
|
||||
constexpr auto Y = BitRange::from_to(11, 21);
|
||||
|
||||
return {Helper::construct_cmd(0xE5, X.as_value(static_cast<int32_t>(x)) | Y.as_value(static_cast<int32_t>(y)))};
|
||||
return {Helper::construct_cmd(0xE5, X.as_value(static_cast<int32_t>(offset.x)) | Y.as_value(static_cast<int32_t>(offset.y)))};
|
||||
}
|
||||
|
||||
static constexpr GP0_t TopLeftPosition(uint16_t x, uint16_t y) {
|
||||
return {(static_cast<uint32_t>(y) << 16u) | x};
|
||||
static constexpr GP0_t TopLeftPosition(const GPU::PositionU16& position) {
|
||||
return {(static_cast<uint32_t>(position.y) << 16u) | position.x};
|
||||
}
|
||||
|
||||
static constexpr GP0_t WidthHeight(uint16_t w, uint16_t h) {
|
||||
return {(static_cast<uint32_t>(h) << 16u) | w};
|
||||
static constexpr GP0_t WidthHeight(const GPU::SizeU16& size) {
|
||||
return {(static_cast<uint32_t>(size.height) << 16u) | size.width};
|
||||
}
|
||||
|
||||
static constexpr GP1_t Reset() {
|
||||
|
@ -153,11 +157,11 @@ namespace JabyEngine {
|
|||
return {Helper::construct_cmd(0x04, static_cast<uint32_t>(dir))};
|
||||
}
|
||||
|
||||
static constexpr GP1_t DisplayArea(uint16_t x, uint16_t y) {
|
||||
static constexpr GP1_t DisplayArea(const GPU::PositionU16& position) {
|
||||
constexpr auto X = BitRange::from_to(0, 9);
|
||||
constexpr auto Y = BitRange::from_to(10, 18);
|
||||
|
||||
return {Helper::construct_cmd(0x05, X.as_value(static_cast<uint32_t>(x)) | Y.as_value(static_cast<uint32_t>(y)))};
|
||||
return {Helper::construct_cmd(0x05, X.as_value(static_cast<uint32_t>(position.x)) | Y.as_value(static_cast<uint32_t>(position.y)))};
|
||||
}
|
||||
|
||||
static constexpr GP1_t HorizontalDisplayRange(uint16_t x1, uint16_t x2) {
|
||||
|
|
|
@ -30,9 +30,9 @@ namespace JabyEngine {
|
|||
while(!GPU_IO::GPUSTAT.is_set(GPU_IO::GPUSTAT_t::GP0ReadyForCMD));
|
||||
}
|
||||
|
||||
static void set_draw_area(uint16_t x, uint16_t y) {
|
||||
const auto top_left = GPU_IO::Command::DrawAreaTopLeft(x, y);
|
||||
const auto bottom_right = GPU_IO::Command::DrawAreaBottomRight((x + Display::Width - 1), (y + Display::Height - 1));
|
||||
static void set_draw_area(const PositionU16& pos) {
|
||||
const auto top_left = GPU_IO::Command::DrawAreaTopLeft(pos);
|
||||
const auto bottom_right = GPU_IO::Command::DrawAreaBottomRight(pos.move((Display::Width - 1), (Display::Height - 1)));
|
||||
|
||||
wait_ready_for_CMD();
|
||||
GPU_IO::GP0 = top_left;
|
||||
|
@ -43,21 +43,21 @@ namespace JabyEngine {
|
|||
static void copy_vram_to_vram(const AreaU16& dst, const PositionU16& src) {
|
||||
wait_ready_for_CMD();
|
||||
GPU_IO::GP0 = GPU_IO::Command::VRAM2VRAM_Blitting();
|
||||
GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(src.x, src.y);
|
||||
GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(dst.position.x, dst.position.y);
|
||||
GPU_IO::GP0 = GPU_IO::Command::WidthHeight(dst.size.width, dst.size.height);
|
||||
GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(src);
|
||||
GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(dst.position);
|
||||
GPU_IO::GP0 = GPU_IO::Command::WidthHeight(dst.size);
|
||||
}
|
||||
|
||||
static void quick_fill_fast(const Color24& color, const AreaU16& area) {
|
||||
wait_ready_for_CMD();
|
||||
GPU_IO::GP0 = GPU_IO::Command::QuickFill(color);
|
||||
GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(area.position.x, area.position.y);
|
||||
GPU_IO::GP0 = GPU_IO::Command::WidthHeight(area.size.width, area.size.height);
|
||||
GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(area.position);
|
||||
GPU_IO::GP0 = GPU_IO::Command::WidthHeight(area.size);
|
||||
}
|
||||
|
||||
static void set_draw_offset(int16_t x, int16_t y) {
|
||||
static void set_draw_offset(const PositionI16& offset) {
|
||||
wait_ready_for_CMD();
|
||||
GPU_IO::GP0 = GPU_IO::Command::SetDrawOffset(x, y);
|
||||
GPU_IO::GP0 = GPU_IO::Command::SetDrawOffset(offset);
|
||||
}
|
||||
|
||||
static void reset_cmd_buffer() {
|
||||
|
@ -86,8 +86,8 @@ namespace JabyEngine {
|
|||
static void set_dst(const PositionU16& position, const SizeU16& size) {
|
||||
wait_ready_for_CMD();
|
||||
GPU_IO::GP0 = GPU_IO::Command::CPU2VRAM_Blitting();
|
||||
GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(position.x, position.y);
|
||||
GPU_IO::GP0 = GPU_IO::Command::WidthHeight(size.width, size.height);
|
||||
GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(position);
|
||||
GPU_IO::GP0 = GPU_IO::Command::WidthHeight(size);
|
||||
}
|
||||
|
||||
static void start(uint16_t blockCount, uint16_t wordsPerBlock = 0x10) {
|
||||
|
|
|
@ -38,11 +38,11 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
uint32_t Display :: exchange_buffer_and_display() {
|
||||
const auto draw_area_y = (PublicDisplay::Height*PublicDisplay::current_id);
|
||||
const uint16_t draw_area_y = (PublicDisplay::Height*PublicDisplay::current_id);
|
||||
|
||||
GPU::internal::set_draw_area(0, draw_area_y);
|
||||
GPU::internal::set_draw_area({0, draw_area_y});
|
||||
PublicDisplay::current_id ^= 1;
|
||||
GPU_IO::GP1 = GPU_IO::Command::DisplayArea(0, (PublicDisplay::Height*PublicDisplay::current_id));
|
||||
GPU_IO::GP1 = GPU_IO::Command::DisplayArea({0, static_cast<uint16_t>((PublicDisplay::Height*PublicDisplay::current_id))});
|
||||
return draw_area_y;
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,8 @@ namespace JabyEngine {
|
|||
internal::wait_ready_for_CMD();
|
||||
|
||||
internal::wait_vsync(syncs);
|
||||
const auto draw_offset_y = internal::Display::exchange_buffer_and_display();
|
||||
internal::set_draw_offset(0, draw_offset_y);
|
||||
const int16_t draw_offset_y = internal::Display::exchange_buffer_and_display();
|
||||
internal::set_draw_offset({0, draw_offset_y});
|
||||
if(clear_screen) {
|
||||
internal::quick_fill_fast(Color24::Black(), AreaU16{0, static_cast<uint16_t>(draw_offset_y), Display::Width, Display::Height});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue