Draw first triangle
This commit is contained in:
@@ -21,17 +21,27 @@ namespace JabyEngine {
|
||||
static constexpr uint16_t ScanlinesV = 240;
|
||||
#endif //JABYENGINE_PAL
|
||||
|
||||
static void exchange_buffer_and_display();
|
||||
static uint32_t exchange_buffer_and_display();
|
||||
};
|
||||
|
||||
void wait_vsync(uint8_t syncs);
|
||||
|
||||
static void wait_ready_for_CMD() {
|
||||
while(!GPU_IO::GPUSTAT.is_set(GPU_IO::GPUSTAT_t::GP0ReadyForCMD));
|
||||
}
|
||||
|
||||
static void set_draw_area(uint16_t x, uint16_t y) {
|
||||
GPU_IO::GP0 = GPU_IO::Command::DrawAreaTopLeft(x, y);
|
||||
GPU_IO::GP0 = GPU_IO::Command::DrawAreaBottomRight((x + Display::Width), (y + Display::Height));
|
||||
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));
|
||||
|
||||
wait_ready_for_CMD();
|
||||
GPU_IO::GP0 = top_left;
|
||||
wait_ready_for_CMD();
|
||||
GPU_IO::GP0 = bottom_right;
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -39,17 +49,19 @@ namespace JabyEngine {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void reset_cmd_buffer() {
|
||||
GPU_IO::GP1 = GPU_IO::Command::ResetCMDBufer();
|
||||
static void set_draw_offset(int16_t x, int16_t y) {
|
||||
wait_ready_for_CMD();
|
||||
GPU_IO::GP0 = GPU_IO::Command::SetDrawOffset(x, y);
|
||||
}
|
||||
|
||||
static void wait_ready_for_CMD() {
|
||||
while(!GPU_IO::GPUSTAT.is_set(GPU_IO::GPUSTAT_t::GP0ReadyForCMD));
|
||||
static void reset_cmd_buffer() {
|
||||
GPU_IO::GP1 = GPU_IO::Command::ResetCMDBufer();
|
||||
}
|
||||
|
||||
namespace DMA {
|
||||
|
@@ -44,7 +44,7 @@ namespace JabyEngine {
|
||||
SimpleTIMSize size_info;
|
||||
size_t words_left; //32bit values
|
||||
|
||||
constexpr SimpleTIMState(const SimpleTIM& dst_info) : dst_info(dst_info) {
|
||||
constexpr SimpleTIMState(const SimpleTIM& dst_info) : dst_info(dst_info), words_left(0) {
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -37,10 +37,13 @@ namespace JabyEngine {
|
||||
__syscall_ReturnFromException();
|
||||
}
|
||||
|
||||
void Display :: exchange_buffer_and_display() {
|
||||
GPU::internal::set_draw_area(0, (PublicDisplay::Height*PublicDisplay::current_id));
|
||||
uint32_t Display :: exchange_buffer_and_display() {
|
||||
const auto draw_area_y = (PublicDisplay::Height*PublicDisplay::current_id);
|
||||
|
||||
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));
|
||||
return draw_area_y;
|
||||
}
|
||||
|
||||
void wait_vsync(uint8_t syncs) {
|
||||
@@ -53,6 +56,13 @@ namespace JabyEngine {
|
||||
while(vsync_count < syncs);
|
||||
vsync_count = 0;
|
||||
}
|
||||
|
||||
void render(const uint32_t* data, size_t words) {
|
||||
wait_ready_for_CMD();
|
||||
for(size_t n = 0; n < words; n++) {
|
||||
GPU_IO::GP0 = data[n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_NO$PSX
|
||||
@@ -70,10 +80,16 @@ namespace JabyEngine {
|
||||
}
|
||||
#endif //USE_NO$PSX
|
||||
|
||||
uint8_t swap_buffers_vsync(uint8_t syncs) {
|
||||
// Wait finish draw
|
||||
uint8_t swap_buffers_vsync(uint8_t syncs, bool clear_screen) {
|
||||
// Waits for finish FIFO
|
||||
internal::wait_ready_for_CMD();
|
||||
|
||||
internal::wait_vsync(syncs);
|
||||
internal::Display::exchange_buffer_and_display();
|
||||
const auto 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});
|
||||
}
|
||||
return Display::current_id;
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#include <PSX/GPU/gpu_primitives.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
extern void main();
|
||||
|
Reference in New Issue
Block a user