Introduce the JabyEngine namespace to all files
This commit is contained in:
@@ -1,23 +1,24 @@
|
||||
#ifndef BOOT_LOADER_HPP
|
||||
#define BOOT_LOADER_HPP
|
||||
#include <PSX/jabyengine.h>
|
||||
#include <PSX/jabyengine.hpp>
|
||||
|
||||
namespace GPU {
|
||||
void display_logo();
|
||||
void setup();
|
||||
namespace JabyEngine {
|
||||
namespace GPU {
|
||||
void display_logo();
|
||||
void setup();
|
||||
}
|
||||
|
||||
namespace SPU {
|
||||
void stop_voices();
|
||||
void setup();
|
||||
}
|
||||
|
||||
namespace Setup {
|
||||
JabyEngine::NextRoutine start();
|
||||
}
|
||||
|
||||
namespace BootFile {
|
||||
JabyEngine::NextRoutine setup();
|
||||
}
|
||||
}
|
||||
|
||||
namespace SPU {
|
||||
void stop_voices();
|
||||
void setup();
|
||||
}
|
||||
|
||||
namespace Setup {
|
||||
JabyEngine::NextRoutine start();
|
||||
}
|
||||
|
||||
namespace BootFile {
|
||||
JabyEngine::NextRoutine setup();
|
||||
}
|
||||
|
||||
#endif //!BOOT_LOADER_HPP
|
@@ -2,17 +2,18 @@
|
||||
#define __JABYENGINE_CD_HPP__
|
||||
#include <stdint.h>
|
||||
|
||||
namespace CD {
|
||||
namespace CircularBuffer {
|
||||
extern uint8_t* write_ptr;
|
||||
extern uint8_t* read_ptr;
|
||||
extern uint8_t* end_ptr;
|
||||
namespace JabyEngine {
|
||||
namespace CD {
|
||||
namespace CircularBuffer {
|
||||
extern uint8_t* write_ptr;
|
||||
extern uint8_t* read_ptr;
|
||||
extern uint8_t* end_ptr;
|
||||
}
|
||||
|
||||
enum struct State {
|
||||
};
|
||||
|
||||
extern State state;
|
||||
}
|
||||
|
||||
enum struct State {
|
||||
};
|
||||
|
||||
extern State state;
|
||||
}
|
||||
|
||||
#endif //!__JABYENGINE_CD_HPP__
|
@@ -4,111 +4,113 @@
|
||||
#include <PSX/System/IOPorts/dma_io.hpp>
|
||||
#include <PSX/System/IOPorts/gpu_io.hpp>
|
||||
|
||||
namespace GPU {
|
||||
namespace Screen {
|
||||
struct Mode {
|
||||
enum struct TVEncoding {
|
||||
NTSC = 0,
|
||||
PAL = 1,
|
||||
namespace JabyEngine {
|
||||
namespace GPU {
|
||||
namespace Screen {
|
||||
struct Mode {
|
||||
enum struct TVEncoding {
|
||||
NTSC = 0,
|
||||
PAL = 1,
|
||||
};
|
||||
|
||||
static constexpr auto HorizontalResolution368 = Bit<uint32_t>(6);
|
||||
static constexpr auto VerticalInterlace = Bit<uint32_t>(5);
|
||||
static constexpr auto DisplayAreaColorDepth = BitRange<GPU::DisplayAreaColorDepth>::from_to(4, 4);
|
||||
static constexpr auto VideoMode = BitRange<TVEncoding>::from_to(3, 3);
|
||||
static constexpr auto VerticalResolution = BitRange<GPU::VerticalResolution>::from_to(2, 2);
|
||||
static constexpr auto HorizontalResolution = BitRange<GPU::HorizontalResolution>::from_to(0, 1);
|
||||
|
||||
static constexpr uint32_t PAL() {
|
||||
return ComplexBitMap<uint32_t>::with(
|
||||
Mode::HorizontalResolution.with(GPU::HorizontalResolution::$320),
|
||||
Mode::VerticalResolution.with(GPU::VerticalResolution::$240),
|
||||
Mode::VideoMode.with(TVEncoding::PAL),
|
||||
Mode::DisplayAreaColorDepth.with(GPU::DisplayAreaColorDepth::$15bit)
|
||||
).raw;
|
||||
}
|
||||
|
||||
static constexpr uint32_t NTSC() {
|
||||
return ComplexBitMap<uint32_t>::with(
|
||||
Mode::HorizontalResolution.with(GPU::HorizontalResolution::$320),
|
||||
Mode::VerticalResolution.with(GPU::VerticalResolution::$240),
|
||||
Mode::VideoMode.with(TVEncoding::NTSC),
|
||||
Mode::DisplayAreaColorDepth.with(GPU::DisplayAreaColorDepth::$15bit)
|
||||
).raw;
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr auto HorizontalResolution368 = Bit<uint32_t>(6);
|
||||
static constexpr auto VerticalInterlace = Bit<uint32_t>(5);
|
||||
static constexpr auto DisplayAreaColorDepth = BitRange<GPU::DisplayAreaColorDepth>::from_to(4, 4);
|
||||
static constexpr auto VideoMode = BitRange<TVEncoding>::from_to(3, 3);
|
||||
static constexpr auto VerticalResolution = BitRange<GPU::VerticalResolution>::from_to(2, 2);
|
||||
static constexpr auto HorizontalResolution = BitRange<GPU::HorizontalResolution>::from_to(0, 1);
|
||||
static void configurate() {
|
||||
static constexpr uint16_t FirstVisiblePixelH = 0x260;
|
||||
|
||||
static constexpr uint32_t PAL() {
|
||||
return ComplexBitMap<uint32_t>::with(
|
||||
Mode::HorizontalResolution.with(GPU::HorizontalResolution::$320),
|
||||
Mode::VerticalResolution.with(GPU::VerticalResolution::$240),
|
||||
Mode::VideoMode.with(TVEncoding::PAL),
|
||||
Mode::DisplayAreaColorDepth.with(GPU::DisplayAreaColorDepth::$15bit)
|
||||
).raw;
|
||||
#ifdef JABYENGINE_PAL
|
||||
static constexpr uint16_t FirstVisiblePixelV = 0xA3;
|
||||
|
||||
GP1.write(Command::GP1::DisplayMode(Mode::PAL()));
|
||||
GPU::Screen::Range::set_offset(0, 0);
|
||||
#else
|
||||
static constexpr uint16_t FirstVisiblePixelV = 0x88;
|
||||
|
||||
GP1.write(Command::GP1::DisplayMode(Mode::NTSC()));
|
||||
GPU::Screen::set_offset(0, 5); //< Random values
|
||||
#endif
|
||||
}
|
||||
|
||||
static constexpr uint32_t NTSC() {
|
||||
return ComplexBitMap<uint32_t>::with(
|
||||
Mode::HorizontalResolution.with(GPU::HorizontalResolution::$320),
|
||||
Mode::VerticalResolution.with(GPU::VerticalResolution::$240),
|
||||
Mode::VideoMode.with(TVEncoding::NTSC),
|
||||
Mode::DisplayAreaColorDepth.with(GPU::DisplayAreaColorDepth::$15bit)
|
||||
).raw;
|
||||
void exchange_buffer_and_display();
|
||||
}
|
||||
|
||||
static void set_draw_area(uint16_t x, uint16_t y) {
|
||||
GP0.write(Command::GP0::DrawAreaTopLeft(x, y));
|
||||
GP0.write(Command::GP0::DrawAreaBottomRight((x + Display::Width), (y + Display::Height)));
|
||||
}
|
||||
|
||||
static void quick_fill_fast(const Color24& color, const PositionU16& pos, const SizeU16& size) {
|
||||
GP0.write(Command::GP0::QuickFill(color));
|
||||
GP0.write(Command::GP0::TopLeftPosition(pos.x, pos.y));
|
||||
GP0.write(Command::GP0::WidthHeight(size.width, size.height));
|
||||
}
|
||||
|
||||
static void reset_cmd_buffer() {
|
||||
GP1.write(Command::GP1::ResetCMDBufer());
|
||||
}
|
||||
|
||||
static void wait_ready_for_CMD() {
|
||||
while(!GPUSTAT.ref().is(GPUStatusRegister::GP0ReadyForCMD));
|
||||
}
|
||||
|
||||
namespace DMA {
|
||||
static void wait() {
|
||||
while(::JabyEngine::DMA::GPU.channel_ctrl.ref().is(::JabyEngine::DMA::CHCHR::Busy));
|
||||
}
|
||||
};
|
||||
|
||||
static void configurate() {
|
||||
static constexpr uint16_t FirstVisiblePixelH = 0x260;
|
||||
|
||||
#ifdef JABYENGINE_PAL
|
||||
static constexpr uint16_t FirstVisiblePixelV = 0xA3;
|
||||
|
||||
GP1.write(Command::GP1::DisplayMode(Mode::PAL()));
|
||||
GPU::Screen::Range::set_offset(0, 0);
|
||||
#else
|
||||
static constexpr uint16_t FirstVisiblePixelV = 0x88;
|
||||
|
||||
GP1.write(Command::GP1::DisplayMode(Mode::NTSC()));
|
||||
GPU::Screen::set_offset(0, 5); //< Random values
|
||||
#endif
|
||||
}
|
||||
|
||||
void exchange_buffer_and_display();
|
||||
}
|
||||
|
||||
static void set_draw_area(uint16_t x, uint16_t y) {
|
||||
GP0.write(Command::GP0::DrawAreaTopLeft(x, y));
|
||||
GP0.write(Command::GP0::DrawAreaBottomRight((x + Display::Width), (y + Display::Height)));
|
||||
}
|
||||
|
||||
static void quick_fill_fast(const Color24& color, const PositionU16& pos, const SizeU16& size) {
|
||||
GP0.write(Command::GP0::QuickFill(color));
|
||||
GP0.write(Command::GP0::TopLeftPosition(pos.x, pos.y));
|
||||
GP0.write(Command::GP0::WidthHeight(size.width, size.height));
|
||||
}
|
||||
|
||||
static void reset_cmd_buffer() {
|
||||
GP1.write(Command::GP1::ResetCMDBufer());
|
||||
}
|
||||
|
||||
static void wait_ready_for_CMD() {
|
||||
while(!GPUSTAT.ref().is(GPUStatusRegister::GP0ReadyForCMD));
|
||||
}
|
||||
|
||||
namespace DMA {
|
||||
static void wait() {
|
||||
while(::DMA::GPU.channel_ctrl.ref().is(::DMA::CHCHR::Busy));
|
||||
}
|
||||
|
||||
static void end() {
|
||||
reset_cmd_buffer();
|
||||
}
|
||||
|
||||
namespace Receive {
|
||||
static void prepare()
|
||||
{
|
||||
GP1.write(Command::GP1::DMADirection(DMADirection::CPU2GPU));
|
||||
static void end() {
|
||||
reset_cmd_buffer();
|
||||
}
|
||||
|
||||
static void set_src(uintptr_t adr) {
|
||||
::DMA::GPU.adr.ref().set_value(static_cast<uint32_t>(adr), ::DMA::MADR::MemoryAdr);
|
||||
}
|
||||
namespace Receive {
|
||||
static void prepare()
|
||||
{
|
||||
GP1.write(Command::GP1::DMADirection(DMADirection::CPU2GPU));
|
||||
reset_cmd_buffer();
|
||||
}
|
||||
|
||||
static void set_dst(const PositionU16& position, const SizeU16& size) {
|
||||
static void set_src(uintptr_t adr) {
|
||||
::JabyEngine::DMA::GPU.adr.ref().set_value(static_cast<uint32_t>(adr), ::JabyEngine::DMA::MADR::MemoryAdr);
|
||||
}
|
||||
|
||||
wait_ready_for_CMD();
|
||||
GP0.write(Command::GP0::CPU2VRAM_Blitting());
|
||||
GP0.write(Command::GP0::TopLeftPosition(position.x, position.y));
|
||||
GP0.write(Command::GP0::WidthHeight(size.width, size.height));
|
||||
}
|
||||
static void set_dst(const PositionU16& position, const SizeU16& size) {
|
||||
|
||||
static void start(uint16_t blockCount, uint16_t wordsPerBlock = 0x10) {
|
||||
typedef ::DMA::BCR::SyncMode1 SyncMode1;
|
||||
wait_ready_for_CMD();
|
||||
GP0.write(Command::GP0::CPU2VRAM_Blitting());
|
||||
GP0.write(Command::GP0::TopLeftPosition(position.x, position.y));
|
||||
GP0.write(Command::GP0::WidthHeight(size.width, size.height));
|
||||
}
|
||||
|
||||
::DMA::GPU.block_ctrl.write(SyncMode1::with(SyncMode1::BlockSize.with(wordsPerBlock), SyncMode1::BlockAmount.with(blockCount)));
|
||||
::DMA::GPU.channel_ctrl.write(::DMA::CHCHR::StartGPUReceive());
|
||||
static void start(uint16_t blockCount, uint16_t wordsPerBlock = 0x10) {
|
||||
typedef ::JabyEngine::DMA::BCR::SyncMode1 SyncMode1;
|
||||
|
||||
::JabyEngine::DMA::GPU.block_ctrl.write(SyncMode1::with(SyncMode1::BlockSize.with(wordsPerBlock), SyncMode1::BlockAmount.with(blockCount)));
|
||||
::JabyEngine::DMA::GPU.channel_ctrl.write(::JabyEngine::DMA::CHCHR::StartGPUReceive());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user