Integrate all the progress into master #6
|
@ -1,4 +1,5 @@
|
|||
#include <PSX/Timer/high_res_timer.hpp>
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" void busy_loop(int count);
|
||||
|
@ -16,6 +17,11 @@ static void mesaure_busy_loop() {
|
|||
}
|
||||
|
||||
void main() {
|
||||
printf("Hello Planschbecken!\n");
|
||||
printf("Hello PoolBox!\n");
|
||||
mesaure_busy_loop();
|
||||
|
||||
while(true) {
|
||||
printf("Doing stuff...\n");
|
||||
JabyEngine::GPU::swap_buffers_vsync(2);
|
||||
}
|
||||
}
|
|
@ -33,6 +33,8 @@ namespace JabyEngine {
|
|||
|
||||
static void set_offset(uint16_t x, uint16_t y);
|
||||
};
|
||||
|
||||
uint8_t swap_buffers_vsync(uint8_t syncs);
|
||||
}
|
||||
}
|
||||
#endif //!__JABYENGINE_GPU_HPP__
|
|
@ -24,6 +24,8 @@ namespace JabyEngine {
|
|||
static void exchange_buffer_and_display();
|
||||
};
|
||||
|
||||
void wait_vsync(uint8_t syncs);
|
||||
|
||||
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));
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace JabyEngine {
|
|||
extern InterrupCallback callback;
|
||||
}
|
||||
}
|
||||
|
||||
namespace boot {
|
||||
namespace CD {
|
||||
using JabyEngine::CD::internal::Command;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "../../internal-include/GPU/gpu_internal.hpp"
|
||||
#include <PSX/File/Processor/file_processor.hpp>
|
||||
#include <PSX/System/IOPorts/interrupt_io.hpp>
|
||||
#include <PSX/Auxiliary/lz4_decompressor.hpp>
|
||||
#include <PSX/File/Processor/file_processor.hpp>
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -13,6 +14,12 @@
|
|||
extern "C" uint32_t __boot_loader_end;
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace GPU {
|
||||
namespace internal {
|
||||
extern InterrupCallback callback;
|
||||
}
|
||||
}
|
||||
|
||||
namespace boot {
|
||||
namespace GPU {
|
||||
using namespace JabyEngine::GPU;
|
||||
|
@ -61,6 +68,11 @@ namespace JabyEngine {
|
|||
|
||||
GPU::internal::wait_ready_for_CMD();
|
||||
GPU::internal::quick_fill_fast(Color24::Black(), PositionU16(32, 0), SizeU16(Display::Width, Display::Height));
|
||||
|
||||
__syscall_EnterCriticalSection();
|
||||
__syscall_SysEnqIntRP(VblankIrq, &::JabyEngine::GPU::internal::callback);
|
||||
Interrupt::enable_irq(Interrupt::VBlank);
|
||||
__syscall_ExitCriticalSection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
#include "../../internal-include/BootLoader/boot_loader.hpp"
|
||||
#include <PSX/System/IOPorts/dMa_io.hpp>
|
||||
|
||||
// 2x For setup timing
|
||||
#include <PSX/Timer/high_res_timer.hpp>
|
||||
#include "../../internal-include/GPU/gpu_internal.hpp"
|
||||
#include <PSX/System/IOPorts/dma_io.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace boot {
|
||||
namespace Start {
|
||||
//This should become part of the bootloader later
|
||||
static void enable_DMA() {
|
||||
DMA_IO::DPCR = DMA_IO::DPCR_t(DMA_IO::DPCR).set(DMA_IO::DPCR_t::SPUEnable).set(DMA_IO::DPCR_t::GPUEnable).set(DMA_IO::DPCR_t::CDROMEnable);
|
||||
}
|
||||
|
@ -35,6 +32,7 @@ namespace JabyEngine {
|
|||
boot::Start::setup();
|
||||
|
||||
printf("Running main...\n");
|
||||
GPU::internal::wait_vsync(0);
|
||||
run();
|
||||
}
|
||||
}
|
|
@ -1,15 +1,58 @@
|
|||
#include "../../internal-include/GPU/gpu_internal.hpp"
|
||||
#include <PSX/System/IOPorts/interrupt_io.hpp>
|
||||
#include <PSX/System/syscalls.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace GPU {
|
||||
uint8_t Display :: current_id = 1; //< Setup will call exchange and set it to 0
|
||||
|
||||
namespace internal {
|
||||
static uint8_t vsync_count = 0;
|
||||
|
||||
static InterruptVerifierResult interrupt_verifier();
|
||||
static void interrupt_handler(uint32_t);
|
||||
|
||||
InterrupCallback callback = {
|
||||
.next = nullptr,
|
||||
.handler_function = reinterpret_cast<InterruptHandler>(interrupt_handler),
|
||||
.verifier_function = interrupt_verifier
|
||||
};
|
||||
|
||||
static InterruptVerifierResult interrupt_verifier() {
|
||||
if(Interrupt::is_irq(Interrupt::VBlank)) {
|
||||
return InterruptVerifierResult::ExecuteHandler;
|
||||
}
|
||||
|
||||
else {
|
||||
return InterruptVerifierResult::SkipHandler;
|
||||
}
|
||||
}
|
||||
|
||||
static void interrupt_handler(uint32_t) {
|
||||
if(vsync_count != 0xFF) {
|
||||
vsync_count++;
|
||||
}
|
||||
|
||||
Interrupt::ack_irq(Interrupt::VBlank);
|
||||
__syscall_ReturnFromException();
|
||||
}
|
||||
|
||||
void Display :: exchange_buffer_and_display() {
|
||||
GPU::internal::set_draw_area(0, (PublicDisplay::Height*PublicDisplay::current_id));
|
||||
PublicDisplay::current_id ^= 1;
|
||||
GPU_IO::GP1 = GPU_IO::Command::DisplayArea(0, (PublicDisplay::Height*PublicDisplay::current_id));
|
||||
}
|
||||
|
||||
void wait_vsync(uint8_t syncs) {
|
||||
volatile uint8_t& vsync_count = reinterpret_cast<volatile uint8_t&>(internal::vsync_count);
|
||||
|
||||
if(internal::vsync_count >= syncs) {
|
||||
syncs = internal::vsync_count + 1;
|
||||
}
|
||||
|
||||
while(vsync_count < syncs);
|
||||
vsync_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_NO$PSX
|
||||
|
@ -21,10 +64,17 @@ namespace JabyEngine {
|
|||
GPU_IO::GP1 = GPU_IO::Command::VerticalDisplayRange(y, y + Display::Height);
|
||||
}
|
||||
#else
|
||||
void Screen :: set_offset(uint16_t x, uint16_t y) {
|
||||
void Display :: set_offset(uint16_t x, uint16_t y) {
|
||||
GPU_IO::GP1 = GPU_IO::Command::HorizontalDisplayRange(x, (x + Display::Width*8));
|
||||
GPU_IO::GP1 = GPU_IO::Command::VerticalDisplayRange(y - (ScanlinesV/2), y + (ScanlinesV/2));
|
||||
}
|
||||
#endif //USE_NO$PSX
|
||||
|
||||
uint8_t swap_buffers_vsync(uint8_t syncs) {
|
||||
// Wait finish draw
|
||||
internal::wait_vsync(syncs);
|
||||
internal::Display::exchange_buffer_and_display();
|
||||
return Display::current_id;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue