#ifndef __JABYENGINE_GPU_HPP__ #define __JABYENGINE_GPU_HPP__ #include "../Auxiliary/type_traits.hpp" #include "../System/IOPorts/gpu_io.hpp" #include "gpu_primitives.hpp" #if !defined(JABYENGINE_NTSC) && !defined(JABYENGINE_PAL) #error "JABYENGINE_NTSC or JABYENGINE_PAL must be defined" #else #if defined(JABYENGINE_NTSC) && defined(JABYENGINE_PAL) #error "Please define only JABYENGINE_NTSC or JABYENGINE_PAL" #endif #endif namespace JabyEngine { namespace GPU { struct Display { #ifdef JABYENGINE_PAL static constexpr size_t Width = 320; static constexpr size_t Height = 256; #else static constexpr size_t Width = 320; static constexpr size_t Height = 240; #endif static uint8_t current_id; static void enable() { GPU_IO::GP1 = GPU_IO::Command::SetDisplayState(GPU_IO::DisplayState::On); } static void disable() { GPU_IO::GP1 = GPU_IO::Command::SetDisplayState(GPU_IO::DisplayState::Off); } static void set_offset(uint16_t x, uint16_t y); }; namespace internal { void render(const uint32_t* data, size_t words); void render_dma(const uint32_t* data); } template static void render(const LinkedElement& linked_primitives) { internal::render_dma(&linked_primitives.value); } template static enable_if::type render(const T& primitive) { internal::render(reinterpret_cast(&primitive), sizeof(T)/sizeof(uint32_t)); } template static enable_if::type render(const LINE_F (&primitives)[N]) { internal::render(reinterpret_cast(&primitives), (sizeof(T)/sizeof(uint32_t))*N); } uint8_t swap_buffers_vsync(uint8_t syncs, bool clear_screen = true); } } #endif //!__JABYENGINE_GPU_HPP__