Introduce the JabyEngine namespace to all files

This commit is contained in:
jaby 2022-12-23 21:18:25 +01:00
parent 791fe85ab8
commit def6c6d3b9
27 changed files with 1320 additions and 1282 deletions

View File

@ -2,6 +2,7 @@
#define __JABYENGINE_BITS_HPP__ #define __JABYENGINE_BITS_HPP__
#include "../jabyengine_defines.h" #include "../jabyengine_defines.h"
namespace JabyEngine {
namespace bit { namespace bit {
template<typename T> template<typename T>
static constexpr T set(T raw_value, size_t bit) { static constexpr T set(T raw_value, size_t bit) {
@ -50,6 +51,7 @@ namespace bit {
return *reinterpret_cast<S*>(&value); return *reinterpret_cast<S*>(&value);
} }
} }
}
#define __start_end_bit2_start_length(start_bit, end_bit) start_bit, (end_bit - start_bit + 1) #define __start_end_bit2_start_length(start_bit, end_bit) start_bit, (end_bit - start_bit + 1)
#endif //!__JABYENGINE_BITS_HPP__ #endif //!__JABYENGINE_BITS_HPP__

View File

@ -2,6 +2,7 @@
#define __JABYENGINE_COMPLEX_BITMAP_HPP__ #define __JABYENGINE_COMPLEX_BITMAP_HPP__
#include "bits.hpp" #include "bits.hpp"
namespace JabyEngine {
struct ClearBitValue { struct ClearBitValue {
size_t bit; size_t bit;
@ -191,5 +192,6 @@ public:
return *this; return *this;
} }
}; };
}
#endif //!__JABYENGINE_COMPLEX_BITMAP_HPP__ #endif //!__JABYENGINE_COMPLEX_BITMAP_HPP__

View File

@ -3,6 +3,7 @@
#include "../cd_file_types.hpp" #include "../cd_file_types.hpp"
#include "file_processor.hpp" #include "file_processor.hpp"
namespace JabyEngine {
namespace CDFileProcessor { namespace CDFileProcessor {
class State { class State {
private: private:
@ -28,6 +29,7 @@ namespace CDFileProcessor {
} }
} }
} }
}
// This will be used as the file processor but will work on cd types // This will be used as the file processor but will work on cd types
// Will probably use file_processor // Will probably use file_processor

View File

@ -2,6 +2,7 @@
#define __JABYENGINE_FILE_PROCESSOR_HPP__ #define __JABYENGINE_FILE_PROCESSOR_HPP__
#include "../file_types.hpp" #include "../file_types.hpp"
namespace JabyEngine {
namespace FileProcessor { namespace FileProcessor {
class State { class State {
private: private:
@ -47,5 +48,5 @@ namespace FileProcessor {
State create(const uint32_t* data_adr, const SimpleTIM& file); State create(const uint32_t* data_adr, const SimpleTIM& file);
} }
}
#endif // !__JABYENGINE_FILE_PROCESSOR_HPP__ #endif // !__JABYENGINE_FILE_PROCESSOR_HPP__

View File

@ -3,6 +3,7 @@
#include "../Overlay/overlay.hpp" #include "../Overlay/overlay.hpp"
#include "file_types.hpp" #include "file_types.hpp"
namespace JabyEngine {
enum struct CDFileType : uint8_t { enum struct CDFileType : uint8_t {
SimpleTIM = 0, SimpleTIM = 0,
Custom Custom
@ -24,4 +25,5 @@ namespace CDFileBuilder {
return CDFile{.rel_lba_idx = rel_lba_idx, .type = CDFileType::SimpleTIM, .payload = {.simple_tim = simple_tim}}; return CDFile{.rel_lba_idx = rel_lba_idx, .type = CDFileType::SimpleTIM, .payload = {.simple_tim = simple_tim}};
} }
} }
}
#endif //!__JABYENGINE_CD_FILE_TYPES_HPP__ #endif //!__JABYENGINE_CD_FILE_TYPES_HPP__

View File

@ -3,6 +3,7 @@
#include "../Auxiliary/complex_bitmap.hpp" #include "../Auxiliary/complex_bitmap.hpp"
#include "../jabyengine_defines.h" #include "../jabyengine_defines.h"
namespace JabyEngine {
struct __no_align SimpleTIM : private ComplexBitMap<uint32_t> { struct __no_align SimpleTIM : private ComplexBitMap<uint32_t> {
static constexpr auto TextureX = BitRange<uint32_t>(0, 8); static constexpr auto TextureX = BitRange<uint32_t>(0, 8);
static constexpr auto TextureY = BitRange<uint32_t>(9, 16); static constexpr auto TextureY = BitRange<uint32_t>(9, 16);
@ -32,6 +33,5 @@ struct __no_align SimpleTIM : private ComplexBitMap<uint32_t> {
return ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutY); return ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutY);
} }
}; };
}
#endif // !__JABYENGINE_FILE_TYPES_HPP__ #endif // !__JABYENGINE_FILE_TYPES_HPP__

View File

@ -10,6 +10,7 @@
#endif #endif
#endif #endif
namespace JabyEngine {
namespace GPU { namespace GPU {
namespace Display { namespace Display {
#ifdef JABYENGINE_PAL #ifdef JABYENGINE_PAL
@ -37,5 +38,5 @@ namespace GPU {
} }
} }
} }
}
#endif //!__JABYENGINE_GPU_HPP__ #endif //!__JABYENGINE_GPU_HPP__

View File

@ -3,6 +3,7 @@
#include "../jabyengine_defines.h" #include "../jabyengine_defines.h"
#include "../Auxiliary/complex_bitmap.hpp" #include "../Auxiliary/complex_bitmap.hpp"
namespace JabyEngine {
namespace GPU { namespace GPU {
struct Color24 { struct Color24 {
uint8_t red = 0; uint8_t red = 0;
@ -98,5 +99,5 @@ namespace GPU {
typedef Size<int16_t> SizeI16; typedef Size<int16_t> SizeI16;
typedef Size<uint16_t> SizeU16; typedef Size<uint16_t> SizeU16;
} }
}
#endif //!__JABYENGINE_GPU_TYPES_HPP__ #endif //!__JABYENGINE_GPU_TYPES_HPP__

View File

@ -2,6 +2,7 @@
#define __JABYENGINE_OVERLAY__HPP__ #define __JABYENGINE_OVERLAY__HPP__
#include "../../stdint.h" #include "../../stdint.h"
namespace JabyEngine {
struct __attribute__((packed)) OverlayHeader { struct __attribute__((packed)) OverlayHeader {
void (*execute)(); void (*execute)();
uint16_t lba_size; uint16_t lba_size;
@ -12,4 +13,5 @@ struct __attribute__((packed)) OverlayLBA {
uint16_t lba; uint16_t lba;
uint16_t size; uint16_t size;
}; };
}
#endif //!__JABYENGINE_OVERLAY__HPP__ #endif //!__JABYENGINE_OVERLAY__HPP__

View File

@ -3,12 +3,12 @@
// No include here because this header should be included in a namespace and we don't want multiple namespace definitions of OverlayHeader and OverlayLBA // No include here because this header should be included in a namespace and we don't want multiple namespace definitions of OverlayHeader and OverlayLBA
extern const OverlayHeader overlay_header; extern const JabyEngine::OverlayHeader overlay_header;
extern const OverlayLBA overlay_lba[]; extern const JabyEngine::OverlayLBA overlay_lba[];
#define __declare_overlay_header(function, enum_struct) \ #define __declare_overlay_header(function, enum_struct) \
[[gnu::used]] \ [[gnu::used]] \
const OverlayHeader __section(".header") overlay_header = {.execute = &function, .lba_size = static_cast<uint16_t>(enum_struct::EndOfRequest)}; \ const JabyEngine::OverlayHeader __section(".header") overlay_header = {.execute = &function, .lba_size = static_cast<uint16_t>(enum_struct::EndOfRequest)}; \
[[gnu::used]] \ [[gnu::used]] \
const OverlayLBA __section(".header.lbas") overlay_lba[static_cast<int>(enum_struct::EndOfRequest)] = {0} const JabyEngine::OverlayLBA __section(".header.lbas") overlay_lba[static_cast<int>(enum_struct::EndOfRequest)] = {0}
#endif //!__JABYENGINE_OVERLAY_DECLARATION__HPP__ #endif //!__JABYENGINE_OVERLAY_DECLARATION__HPP__

View File

@ -2,6 +2,7 @@
#define __JABYENGINE_DMA_IO_HPP__ #define __JABYENGINE_DMA_IO_HPP__
#include "ioport.hpp" #include "ioport.hpp"
namespace JabyEngine {
namespace DMA { namespace DMA {
struct __no_align MADR : public ComplexBitMap<uint32_t> { struct __no_align MADR : public ComplexBitMap<uint32_t> {
__io_port_inherit_complex_bit_map(MADR); __io_port_inherit_complex_bit_map(MADR);
@ -140,5 +141,5 @@ namespace DMA {
__declare_io_port_global(DMAControlRegister, DPCR, 0x1F8010F0); __declare_io_port_global(DMAControlRegister, DPCR, 0x1F8010F0);
__declare_io_port_global(DMAInterruptRegister, DICR, 0x1F8010F4); __declare_io_port_global(DMAInterruptRegister, DICR, 0x1F8010F4);
} }
}
#endif //!__JABYENGINE_DMA_IO_HPP__ #endif //!__JABYENGINE_DMA_IO_HPP__

View File

@ -3,6 +3,7 @@
#include "ioport.hpp" #include "ioport.hpp"
#include "../../GPU/gpu_types.hpp" #include "../../GPU/gpu_types.hpp"
namespace JabyEngine {
namespace GPU { namespace GPU {
enum struct SemiTransparency { enum struct SemiTransparency {
B_Half_add_F_Half = 0, B_Half_add_F_Half = 0,
@ -168,5 +169,5 @@ namespace GPU {
__declare_io_port_global_const(uint32_t, GPUREAD, 0x1F801810); __declare_io_port_global_const(uint32_t, GPUREAD, 0x1F801810);
__declare_io_port_global_const(GPUStatusRegister, GPUSTAT, 0x1F801814); __declare_io_port_global_const(GPUStatusRegister, GPUSTAT, 0x1F801814);
} }
}
#endif //!__JABYENGINE_GPU_IO_HPP__ #endif //!__JABYENGINE_GPU_IO_HPP__

View File

@ -2,6 +2,7 @@
#define __JABYENGINE_IOPORT_HPP__ #define __JABYENGINE_IOPORT_HPP__
#include "../../Auxiliary/complex_bitmap.hpp" #include "../../Auxiliary/complex_bitmap.hpp"
namespace JabyEngine {
template<typename T> template<typename T>
class __no_align IOPort { class __no_align IOPort {
private: private:
@ -77,5 +78,5 @@ static constexpr uintptr_t IO_Base_Adr = 0x10000000;
constexpr void __always_inline operator=(ComplexBitMap<T> value) volatile { \ constexpr void __always_inline operator=(ComplexBitMap<T> value) volatile { \
this->raw = value.raw; \ this->raw = value.raw; \
} }
}
#endif //!__JABYENGINE_IOPORT_HPP__ #endif //!__JABYENGINE_IOPORT_HPP__

View File

@ -2,6 +2,7 @@
#define __JABYENGINE_SPU_IO_HPP__ #define __JABYENGINE_SPU_IO_HPP__
#include "ioport.hpp" #include "ioport.hpp"
namespace JabyEngine {
namespace SPU { namespace SPU {
enum struct Mode { enum struct Mode {
Linear = 0, Linear = 0,
@ -165,5 +166,5 @@ namespace SPU {
__declare_io_port_global_array(Voice, Voices, 0x1F801C00, VoiceCount); __declare_io_port_global_array(Voice, Voices, 0x1F801C00, VoiceCount);
} }
}
#endif //!__JABYENGINE_SPU_IO_HPP__ #endif //!__JABYENGINE_SPU_IO_HPP__

View File

@ -2,6 +2,7 @@
#define __JABYENGINE_SCRATCHPAD_HPP__ #define __JABYENGINE_SCRATCHPAD_HPP__
#include "../jabyengine_defines.h" #include "../jabyengine_defines.h"
namespace JabyEngine {
static __always_inline auto& ScratchPad = reinterpret_cast<uint8_t(&)[1024]>(*reinterpret_cast<uint8_t*>(0x1F800000)); static __always_inline auto& ScratchPad = reinterpret_cast<uint8_t(&)[1024]>(*reinterpret_cast<uint8_t*>(0x1F800000));
}
#endif //!__JABYENGINE_SCRATCHPAD_HPP__ #endif //!__JABYENGINE_SCRATCHPAD_HPP__

View File

@ -1,5 +1,5 @@
#ifndef __JABYENGINE__H__ #ifndef __JABYENGINE__HPP__
#define __JABYENGINE__H__ #define __JABYENGINE__HPP__
#include "../stdint.h" #include "../stdint.h"
namespace JabyEngine { namespace JabyEngine {
@ -33,4 +33,4 @@ namespace JabyEngine {
typedef NextRoutine::MainRoutine MainRoutine; typedef NextRoutine::MainRoutine MainRoutine;
} }
#endif //!__JABYENGINE__H__ #endif //!__JABYENGINE__HPP__

View File

@ -1,7 +1,8 @@
#ifndef BOOT_LOADER_HPP #ifndef BOOT_LOADER_HPP
#define BOOT_LOADER_HPP #define BOOT_LOADER_HPP
#include <PSX/jabyengine.h> #include <PSX/jabyengine.hpp>
namespace JabyEngine {
namespace GPU { namespace GPU {
void display_logo(); void display_logo();
void setup(); void setup();
@ -19,5 +20,5 @@ namespace Setup {
namespace BootFile { namespace BootFile {
JabyEngine::NextRoutine setup(); JabyEngine::NextRoutine setup();
} }
}
#endif //!BOOT_LOADER_HPP #endif //!BOOT_LOADER_HPP

View File

@ -2,6 +2,7 @@
#define __JABYENGINE_CD_HPP__ #define __JABYENGINE_CD_HPP__
#include <stdint.h> #include <stdint.h>
namespace JabyEngine {
namespace CD { namespace CD {
namespace CircularBuffer { namespace CircularBuffer {
extern uint8_t* write_ptr; extern uint8_t* write_ptr;
@ -14,5 +15,5 @@ namespace CD {
extern State state; extern State state;
} }
}
#endif //!__JABYENGINE_CD_HPP__ #endif //!__JABYENGINE_CD_HPP__

View File

@ -4,6 +4,7 @@
#include <PSX/System/IOPorts/dma_io.hpp> #include <PSX/System/IOPorts/dma_io.hpp>
#include <PSX/System/IOPorts/gpu_io.hpp> #include <PSX/System/IOPorts/gpu_io.hpp>
namespace JabyEngine {
namespace GPU { namespace GPU {
namespace Screen { namespace Screen {
struct Mode { struct Mode {
@ -78,7 +79,7 @@ namespace GPU {
namespace DMA { namespace DMA {
static void wait() { static void wait() {
while(::DMA::GPU.channel_ctrl.ref().is(::DMA::CHCHR::Busy)); while(::JabyEngine::DMA::GPU.channel_ctrl.ref().is(::JabyEngine::DMA::CHCHR::Busy));
} }
static void end() { static void end() {
@ -93,7 +94,7 @@ namespace GPU {
} }
static void set_src(uintptr_t adr) { static void set_src(uintptr_t adr) {
::DMA::GPU.adr.ref().set_value(static_cast<uint32_t>(adr), ::DMA::MADR::MemoryAdr); ::JabyEngine::DMA::GPU.adr.ref().set_value(static_cast<uint32_t>(adr), ::JabyEngine::DMA::MADR::MemoryAdr);
} }
static void set_dst(const PositionU16& position, const SizeU16& size) { static void set_dst(const PositionU16& position, const SizeU16& size) {
@ -105,10 +106,11 @@ namespace GPU {
} }
static void start(uint16_t blockCount, uint16_t wordsPerBlock = 0x10) { static void start(uint16_t blockCount, uint16_t wordsPerBlock = 0x10) {
typedef ::DMA::BCR::SyncMode1 SyncMode1; typedef ::JabyEngine::DMA::BCR::SyncMode1 SyncMode1;
::DMA::GPU.block_ctrl.write(SyncMode1::with(SyncMode1::BlockSize.with(wordsPerBlock), SyncMode1::BlockAmount.with(blockCount))); ::JabyEngine::DMA::GPU.block_ctrl.write(SyncMode1::with(SyncMode1::BlockSize.with(wordsPerBlock), SyncMode1::BlockAmount.with(blockCount)));
::DMA::GPU.channel_ctrl.write(::DMA::CHCHR::StartGPUReceive()); ::JabyEngine::DMA::GPU.channel_ctrl.write(::JabyEngine::DMA::CHCHR::StartGPUReceive());
}
} }
} }
} }

View File

@ -3,9 +3,11 @@
extern JabyEngine::NextRoutine main(); extern JabyEngine::NextRoutine main();
namespace JabyEngine {
namespace BootFile { namespace BootFile {
JabyEngine::NextRoutine setup() { JabyEngine::NextRoutine setup() {
printf("Running main!\n"); printf("Running main!\n");
return JabyEngine::NextRoutine::from(main); return JabyEngine::NextRoutine::from(main);
} }
} }
}

View File

@ -1,9 +1,11 @@
#include "../../../include/BootLoader/boot_loader.hpp" #include "../../../include/BootLoader/boot_loader.hpp"
#include <stdio.h> #include <stdio.h>
namespace JabyEngine {
namespace BootFile { namespace BootFile {
JabyEngine::NextRoutine setup() { JabyEngine::NextRoutine setup() {
printf("Overlay boot not implemented!\n"); printf("Overlay boot not implemented!\n");
return JabyEngine::NextRoutine::null(); return JabyEngine::NextRoutine::null();
} }
} }
}

View File

@ -8,6 +8,7 @@
#include "splash_image_ntsc_boot.hpp" #include "splash_image_ntsc_boot.hpp"
#endif //JABYENGINE_PAL #endif //JABYENGINE_PAL
namespace JabyEngine {
namespace GPU { namespace GPU {
void display_logo() { void display_logo() {
// Upload SplashScreen picture // Upload SplashScreen picture
@ -26,3 +27,4 @@ namespace GPU {
quick_fill_fast(Color24::Black(), PositionU16(32, 0), SizeU16(Display::Width, Display::Height)); quick_fill_fast(Color24::Black(), PositionU16(32, 0), SizeU16(Display::Width, Display::Height));
} }
} }
}

View File

@ -2,7 +2,10 @@
#include <stdio.h> #include <stdio.h>
#include <limits.h> #include <limits.h>
namespace JabyEngine {
namespace SPU { namespace SPU {
using namespace JabyEngine;
static void clear_main_volume() { static void clear_main_volume() {
static constexpr auto StartVol = SweepVolume::with(SweepVolume::VolumeEnable, SweepVolume::Volume.with(I16_MAX >> 2)); static constexpr auto StartVol = SweepVolume::with(SweepVolume::VolumeEnable, SweepVolume::Volume.with(I16_MAX >> 2));
@ -93,3 +96,4 @@ namespace SPU {
setup_control_register(); setup_control_register();
} }
} }
}

View File

@ -2,6 +2,7 @@
#include <PSX/System/IOPorts/dMa_io.hpp> #include <PSX/System/IOPorts/dMa_io.hpp>
#include <stdio.h> #include <stdio.h>
namespace JabyEngine {
namespace Setup { namespace Setup {
static void enable_DMA() { static void enable_DMA() {
DMA::DPCR.write(DMA::DPCR.read() | DMA::DMAControlRegister::SPUEnable | DMA::DMAControlRegister::GPUEnable); DMA::DPCR.write(DMA::DPCR.read() | DMA::DMAControlRegister::SPUEnable | DMA::DMAControlRegister::GPUEnable);
@ -20,3 +21,4 @@ namespace Setup {
return BootFile::setup(); return BootFile::setup();
} }
} }
}

View File

@ -3,6 +3,7 @@
#define private public #define private public
#include <PSX/File/Processor/file_processor.hpp> #include <PSX/File/Processor/file_processor.hpp>
namespace JabyEngine {
namespace FileProcessor { namespace FileProcessor {
namespace Helper { namespace Helper {
template<typename T> template<typename T>
@ -22,5 +23,5 @@ namespace FileProcessor {
} }
} }
} }
}
#endif // !__JABYENGINE_INTERNAL_SIMPLE_HELPER_HPP__ #endif // !__JABYENGINE_INTERNAL_SIMPLE_HELPER_HPP__

View File

@ -3,6 +3,7 @@
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
namespace JabyEngine {
namespace FileProcessor { namespace FileProcessor {
using GPU::PositionU16; using GPU::PositionU16;
using GPU::SizeU16; using GPU::SizeU16;
@ -127,5 +128,5 @@ namespace FileProcessor {
return State::from(SimpleTIMState(file), data_adr, parse_header); return State::from(SimpleTIMState(file), data_adr, parse_header);
} }
} }
}
#undef private #undef private

View File

@ -1,5 +1,6 @@
#include "../include/GPU/gpu.hpp" #include "../include/GPU/gpu.hpp"
namespace JabyEngine {
namespace GPU { namespace GPU {
namespace Screen { namespace Screen {
uint8_t CurrentDisplayAreaID = 1; //< Setup will call exchange and set it to 0 uint8_t CurrentDisplayAreaID = 1; //< Setup will call exchange and set it to 0
@ -34,3 +35,4 @@ namespace GPU {
} }
} }
} }
}