Update GPU IOs (What a pain)

This commit is contained in:
2024-09-28 17:49:04 +02:00
parent 54b12b13e9
commit 3fab693049
9 changed files with 319 additions and 239 deletions

View File

@@ -32,37 +32,34 @@ namespace JabyEngine {
}
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.write(top_left);
GPU_IO::GP0.set_draw_area_top_left(pos);
wait_ready_for_CMD();
GPU_IO::GP0.write(bottom_right);
GPU_IO::GP0.set_draw_area_bottom_right(pos.move((Display::Width - 1), (Display::Height - 1)));
}
static void copy_vram_to_vram(const AreaU16& dst, const PositionU16& src) {
wait_ready_for_CMD();
GPU_IO::GP0.write(GPU_IO::Command::VRAM2VRAM_Blitting());
GPU_IO::GP0.write(GPU_IO::Command::TopLeftPosition(src));
GPU_IO::GP0.write(GPU_IO::Command::TopLeftPosition(dst.position));
GPU_IO::GP0.write(GPU_IO::Command::WidthHeight(dst.size));
GPU_IO::GP0.set_vram2vram_blitting();
GPU_IO::GP0.pass_top_left_position(src);
GPU_IO::GP0.pass_top_left_position(dst.position);
GPU_IO::GP0.pass_width_height(dst.size);
}
static void quick_fill_fast(const Color24& color, const AreaU16& area) {
wait_ready_for_CMD();
GPU_IO::GP0.write(GPU_IO::Command::QuickFill(color));
GPU_IO::GP0.write(GPU_IO::Command::TopLeftPosition(area.position));
GPU_IO::GP0.write(GPU_IO::Command::WidthHeight(area.size));
GPU_IO::GP0.quick_fill(color);
GPU_IO::GP0.pass_top_left_position(area.position);
GPU_IO::GP0.pass_width_height(area.size);
}
static void set_draw_offset(const PositionI16& offset) {
wait_ready_for_CMD();
GPU_IO::GP0.write(GPU_IO::Command::SetDrawOffset(offset));
GPU_IO::GP0.set_draw_offset(offset);
}
static void reset_cmd_buffer() {
GPU_IO::GP1.write(GPU_IO::Command::ResetCMDBufer());
GPU_IO::GP1.reset_cmd_buffer();
}
struct DMA {
@@ -81,7 +78,7 @@ namespace JabyEngine {
struct Receive {
static void prepare() {
GPU_IO::GP1.write(GPU_IO::Command::DMADirection(GPU_IO::DMADirection::CPU2GPU));
GPU_IO::GP1.set_dma_direction(GPU_IO::GPUSTAT::DMADirection::CPU2GPU);
reset_cmd_buffer();
}
@@ -95,9 +92,9 @@ namespace JabyEngine {
static void set_dst(const PositionU16& position, const SizeU16& size) {
wait_ready_for_CMD();
GPU_IO::GP0.write(GPU_IO::Command::CPU2VRAM_Blitting());
GPU_IO::GP0.write(GPU_IO::Command::TopLeftPosition(position));
GPU_IO::GP0.write(GPU_IO::Command::WidthHeight(size));
GPU_IO::GP0.set_cpu2vram_blitting();
GPU_IO::GP0.pass_top_left_position(position);
GPU_IO::GP0.pass_width_height(size);
}
static void start(uint16_t blockCount, uint16_t wordsPerBlock = 0x10) {

View File

@@ -47,8 +47,8 @@ namespace JabyEngine {
namespace GPU {
using namespace JabyEngine::GPU;
static void configurate_display() {
GPU_IO::GP1.write(GPU_IO::Command::DisplayMode(::JabyEngine::GPU::internal::Display::DisplayMode));
static void configure_display() {
GPU_IO::GP1.set_display_mode(::JabyEngine::GPU::internal::Display::DisplayMode);
GPU::Display::set_offset(0, 0);
}
@@ -92,8 +92,8 @@ namespace JabyEngine {
}
void setup() {
GPU_IO::GP1.write(GPU_IO::Command::Reset());
configurate_display();
GPU_IO::GP1.reset();
configure_display();
::JabyEngine::GPU::internal::Display::exchange_buffer_and_display();
GPU::internal::wait_ready_for_CMD();

View File

@@ -44,7 +44,7 @@ namespace JabyEngine {
GPU::internal::set_draw_area(GPU::PositionU16::create(0, draw_area_y));
PublicDisplay::current_id ^= 1;
GPU_IO::GP1.write(GPU_IO::Command::DisplayArea(GPU::PositionU16::create(0, static_cast<uint16_t>((TexturePageHeight*PublicDisplay::current_id)))));
GPU_IO::GP1.set_display_area(GPU::PositionU16::create(0, static_cast<uint16_t>((TexturePageHeight*PublicDisplay::current_id))));
return draw_area_y;
}
@@ -61,7 +61,7 @@ namespace JabyEngine {
wait_ready_for_CMD();
#ifdef __SUPPORT_PS3__
// The PS3 needs explict change to FiFo
GPU_IO::GP1.write(GPU_IO::Command::DMADirection(GPU_IO::DMADirection::Fifo));
GPU_IO::GP1.set_dma_direction(GPU_IO::GPUSTAT::DMADirection::Fifo);
#endif // __SUPPORT_PS3__
for(size_t n = 0; n < words; n++) {
@@ -72,7 +72,7 @@ namespace JabyEngine {
void render_dma(const uint32_t* data) {
// DPCR already enabled
DMA_IO::GPU.wait();
GPU_IO::GP1.write(GPU_IO::Command::DMADirection(GPU_IO::DMADirection::CPU2GPU));
GPU_IO::GP1.set_dma_direction(GPU_IO::GPUSTAT::DMADirection::CPU2GPU);
DMA_IO::GPU.set_adr(reinterpret_cast<uintptr_t>(data));
DMA_IO::GPU.block_ctrl.write(DMA_IO::BCR::SyncMode2::for_gpu_cmd());
@@ -94,8 +94,8 @@ namespace JabyEngine {
x += (internal::Display::DisplayRange.x + Configuration::DisplayDefaultOffset.x);
y += (internal::Display::DisplayRange.y + Configuration::DisplayDefaultOffset.y);
GPU_IO::GP1.write(GPU_IO::Command::HorizontalDisplayRange((x << 3), (x + Display::Width + PS3_CorrectionX) << 3));
GPU_IO::GP1.write(GPU_IO::Command::VerticalDisplayRange(y, y + Display::Height + PS3_CorrectionY));
GPU_IO::GP1.set_horizontal_display_range((x << 3), (x + Display::Width + PS3_CorrectionX) << 3);
GPU_IO::GP1.set_vertical_display_range( y, y + Display::Height + PS3_CorrectionY);
}
uint8_t swap_buffers_vsync(uint8_t syncs, bool clear_screen) {