Rename include folder to internal-include for easier destinguishing with the JabyEngine include folder
This commit is contained in:
35
src/Library/internal-include/BootLoader/boot_loader.hpp
Normal file
35
src/Library/internal-include/BootLoader/boot_loader.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef BOOT_LOADER_HPP
|
||||
#define BOOT_LOADER_HPP
|
||||
#include <PSX/jabyengine.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
//boot namespace?
|
||||
namespace boot {
|
||||
namespace BootFile {
|
||||
JabyEngine::NextRoutine setup();
|
||||
}
|
||||
|
||||
namespace CD {
|
||||
void setup();
|
||||
}
|
||||
|
||||
namespace GPU {
|
||||
void display_logo();
|
||||
void setup();
|
||||
}
|
||||
|
||||
namespace SPU {
|
||||
void stop_voices();
|
||||
void setup();
|
||||
}
|
||||
|
||||
namespace Start {
|
||||
JabyEngine::NextRoutine setup();
|
||||
}
|
||||
|
||||
namespace Timer {
|
||||
void setup();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //!BOOT_LOADER_HPP
|
||||
53
src/Library/internal-include/CD/cd_internal.hpp
Normal file
53
src/Library/internal-include/CD/cd_internal.hpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef __JABYENGINE_CD_INTERNAL_HPP__
|
||||
#define __JABYENGINE_CD_INTERNAL_HPP__
|
||||
#include "cd_types.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace CD {
|
||||
namespace internal {
|
||||
extern CD_IO::Interrupt::Type last_interrupt;
|
||||
extern State current_state;
|
||||
|
||||
static CD_IO::Interrupt::Type read_last_interrupt() {
|
||||
return const_cast<volatile CD_IO::Interrupt::Type&>(last_interrupt);
|
||||
}
|
||||
|
||||
static State read_current_state() {
|
||||
return const_cast<volatile State&>(current_state);
|
||||
}
|
||||
|
||||
struct Command {
|
||||
static void wait_until(CD_IO::Interrupt::Type irq) {
|
||||
while(read_last_interrupt() != irq);
|
||||
}
|
||||
|
||||
template<typename...ARGS>
|
||||
static void send(CD_IO::CommandFifo_v& cmd_fifo, CD_IO::ParameterFifo_v& parameter_fifo, CD_IO::Command::Desc cmd, ARGS...args) {
|
||||
while(CD_IO::IndexStatus.is_set(CD_IO::IndexStatus_t::IsTransmissionBusy));
|
||||
|
||||
((parameter_fifo = args),...);
|
||||
cmd_fifo = cmd.id;
|
||||
}
|
||||
|
||||
template<typename T, typename...ARGS>
|
||||
static void send(CD_IO::Command::Desc cmd, ARGS...args) {
|
||||
send(T::CommandFifo, T::ParameterFifo, cmd, args...);
|
||||
}
|
||||
|
||||
template<typename...ARGS>
|
||||
static void send_wait(CD_IO::CommandFifo_v& cmd_fifo, CD_IO::ParameterFifo_v& parameter_fifo, CD_IO::Command::Desc cmd, ARGS...args) {
|
||||
send(cmd_fifo, parameter_fifo, cmd, args...);
|
||||
wait_until(cmd.complete_irq);
|
||||
}
|
||||
|
||||
template<typename T, typename...ARGS>
|
||||
static void send_wait(CD_IO::Command::Desc cmd, ARGS...args) {
|
||||
send_wait(T::CommandFifo, T::ParameterFifo, cmd, args...);
|
||||
}
|
||||
};
|
||||
|
||||
void read_file(FileInfo file_info, const SectorBufferAllocator& buffer_allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //!__JABYENGINE_CD_INTERNAL_HPP__
|
||||
86
src/Library/internal-include/CD/cd_types.hpp
Normal file
86
src/Library/internal-include/CD/cd_types.hpp
Normal file
@@ -0,0 +1,86 @@
|
||||
#ifndef __JABYENGINE_INTERNAL_CD_TYPES_HPP__
|
||||
#define __JABYENGINE_INTERNAL_CD_TYPES_HPP__
|
||||
#include <PSX/AutoLBA/auto_lba.hpp>
|
||||
#include <PSX/Auxiliary/math_helper.hpp>
|
||||
#include <PSX/System/IOPorts/cd_io.hpp>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace CD {
|
||||
namespace internal {
|
||||
enum struct State {
|
||||
Free = 0,
|
||||
Done = 0,
|
||||
|
||||
Reading,
|
||||
BufferFull,
|
||||
Error,
|
||||
};
|
||||
|
||||
struct FileInfo {
|
||||
uint16_t lba;
|
||||
uint16_t sectors;
|
||||
|
||||
static constexpr FileInfo from(const AutoLBAEntry& entry) {
|
||||
return FileInfo{entry.lba, CD_IO::DataSector::words_to_sectors(entry.size_words)};
|
||||
}
|
||||
};
|
||||
|
||||
class SectorBufferAllocator {
|
||||
private:
|
||||
typedef CD_IO::DataSector* (*AllocatorFunction)(void* ctx);
|
||||
|
||||
private:
|
||||
void* ctx = nullptr;
|
||||
AllocatorFunction allocate = nullptr;
|
||||
|
||||
constexpr SectorBufferAllocator(void* ctx, AllocatorFunction function) : ctx(ctx), allocate(function) {
|
||||
}
|
||||
|
||||
public:
|
||||
constexpr SectorBufferAllocator() = default;
|
||||
|
||||
static constexpr SectorBufferAllocator create(void* obj, AllocatorFunction function) {
|
||||
return SectorBufferAllocator(obj, function);
|
||||
}
|
||||
|
||||
inline CD_IO::DataSector* allocate_sector() const {
|
||||
return this->allocate(this->ctx);
|
||||
}
|
||||
};
|
||||
|
||||
struct CDTimeStamp {
|
||||
static constexpr size_t MaxSector = 75;
|
||||
static constexpr size_t MaxSeconds = 60;
|
||||
|
||||
uint8_t min;
|
||||
uint8_t sec;
|
||||
uint8_t sector;
|
||||
|
||||
static constexpr CDTimeStamp from(uint16_t lba) {
|
||||
const auto [min, new_lba] = div_and_mod(lba, static_cast<uint16_t>(MaxSector*MaxSeconds));
|
||||
const auto [sec, sectors] = div_and_mod(new_lba, static_cast<uint16_t>(MaxSector));
|
||||
|
||||
return CDTimeStamp{static_cast<uint8_t>(min), static_cast<uint8_t>(sec), static_cast<uint8_t>(sectors)};
|
||||
}
|
||||
|
||||
static constexpr CDTimeStamp from(const FileInfo& file_info) {
|
||||
return CDTimeStamp::from(file_info.lba);
|
||||
}
|
||||
|
||||
constexpr uint8_t get_min_cd() const {
|
||||
return to_bcd(this->min);
|
||||
}
|
||||
|
||||
constexpr uint8_t get_sec_cd() const {
|
||||
return to_bcd(this->sec);
|
||||
}
|
||||
|
||||
constexpr uint8_t get_sector_cd() const {
|
||||
return to_bcd(this->sector);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //!__JABYENGINE_INTERNAL_CD_TYPES_HPP__
|
||||
87
src/Library/internal-include/GPU/gpu_internal.hpp
Normal file
87
src/Library/internal-include/GPU/gpu_internal.hpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#ifndef __JABYENGINE_GPU_INTERNAL_HPP__
|
||||
#define __JABYENGINE_GPU_INTERNAL_HPP__
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/System/IOPorts/dma_io.hpp>
|
||||
#include <PSX/System/IOPorts/gpu_io.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace GPU {
|
||||
namespace internal {
|
||||
struct Screen {
|
||||
static void configurate() {
|
||||
static constexpr uint16_t FirstVisiblePixelH = 0x260;
|
||||
|
||||
#ifdef JABYENGINE_PAL
|
||||
static constexpr uint16_t FirstVisiblePixelV = 0xA3;
|
||||
|
||||
GPU_IO::GP1 = GPU_IO::Command::DisplayMode(GPU_IO::DisplayMode_t::PAL());
|
||||
GPU::Screen::set_offset(0, 0);
|
||||
#else
|
||||
static constexpr uint16_t FirstVisiblePixelV = 0x88;
|
||||
|
||||
GPU_IO::GP1 = GPU_IO::Command::DisplayMode(GPU_IO::DisplayMode_t::NTSC());
|
||||
GPU::Screen::set_offset(0, 5); //< Random values
|
||||
#endif
|
||||
}
|
||||
|
||||
static void exchange_buffer_and_display();
|
||||
};
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
static void quick_fill_fast(const Color24& color, const PositionU16& pos, const SizeU16& size) {
|
||||
GPU_IO::GP0 = GPU_IO::Command::QuickFill(color);
|
||||
GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(pos.x, pos.y);
|
||||
GPU_IO::GP0 = GPU_IO::Command::WidthHeight(size.width, size.height);
|
||||
}
|
||||
|
||||
static void reset_cmd_buffer() {
|
||||
GPU_IO::GP1 = GPU_IO::Command::ResetCMDBufer();
|
||||
}
|
||||
|
||||
static void wait_ready_for_CMD() {
|
||||
while(!GPU_IO::GPUSTAT.is_set(GPU_IO::GPUSTAT_t::GP0ReadyForCMD));
|
||||
}
|
||||
|
||||
namespace DMA {
|
||||
static void wait() {
|
||||
::JabyEngine::DMA_IO::GPU.wait();
|
||||
}
|
||||
|
||||
static void end() {
|
||||
reset_cmd_buffer();
|
||||
}
|
||||
|
||||
namespace Receive {
|
||||
static void prepare() {
|
||||
GPU_IO::GP1 = GPU_IO::Command::DMADirection(GPU_IO::DMADirection::CPU2GPU);
|
||||
reset_cmd_buffer();
|
||||
}
|
||||
|
||||
static void set_src(uintptr_t adr) {
|
||||
DMA_IO::GPU.set_adr(adr);
|
||||
}
|
||||
|
||||
static void set_dst(const PositionU16& position, const SizeU16& size) {
|
||||
wait_ready_for_CMD();
|
||||
GPU_IO::GP0 = GPU_IO::Command::CPU2VRAM_Blitting();
|
||||
GPU_IO::GP0 = GPU_IO::Command::TopLeftPosition(position.x, position.y);
|
||||
GPU_IO::GP0 = GPU_IO::Command::WidthHeight(size.width, size.height);
|
||||
}
|
||||
|
||||
static void start(uint16_t blockCount, uint16_t wordsPerBlock = 0x10) {
|
||||
typedef DMA_IO::BCR_t::SyncMode1 SyncMode1;
|
||||
|
||||
DMA_IO::GPU.block_ctrl = DMA_IO::BCR_t::from(SyncMode1::BlockSize.with(wordsPerBlock), SyncMode1::BlockAmount.with(blockCount));
|
||||
DMA_IO::GPU.channel_ctrl = DMA_IO::CHCHR_t::StartGPUReceive();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //!__JABYENGINE_GPU_INTERNAL_HPP__
|
||||
Reference in New Issue
Block a user