Introduce the JabyEngine namespace to all files

This commit is contained in:
Jaby 2022-12-23 21:18:25 +01:00
parent c0f2669f8a
commit 82a3b1f74e
27 changed files with 1320 additions and 1282 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,6 +3,7 @@
#include "../Auxiliary/complex_bitmap.hpp"
#include "../jabyengine_defines.h"
namespace JabyEngine {
struct __no_align SimpleTIM : private ComplexBitMap<uint32_t> {
static constexpr auto TextureX = BitRange<uint32_t>(0, 8);
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);
}
};
}
#endif // !__JABYENGINE_FILE_TYPES_HPP__

View File

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

View File

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

View File

@ -2,6 +2,7 @@
#define __JABYENGINE_OVERLAY__HPP__
#include "../../stdint.h"
namespace JabyEngine {
struct __attribute__((packed)) OverlayHeader {
void (*execute)();
uint16_t lba_size;
@ -12,4 +13,5 @@ struct __attribute__((packed)) OverlayLBA {
uint16_t lba;
uint16_t size;
};
}
#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
extern const OverlayHeader overlay_header;
extern const OverlayLBA overlay_lba[];
extern const JabyEngine::OverlayHeader overlay_header;
extern const JabyEngine::OverlayLBA overlay_lba[];
#define __declare_overlay_header(function, enum_struct) \
[[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]] \
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__

View File

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

View File

@ -3,6 +3,7 @@
#include "ioport.hpp"
#include "../../GPU/gpu_types.hpp"
namespace JabyEngine {
namespace GPU {
enum struct SemiTransparency {
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(GPUStatusRegister, GPUSTAT, 0x1F801814);
}
}
#endif //!__JABYENGINE_GPU_IO_HPP__

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,6 +4,7 @@
#include <PSX/System/IOPorts/dma_io.hpp>
#include <PSX/System/IOPorts/gpu_io.hpp>
namespace JabyEngine {
namespace GPU {
namespace Screen {
struct Mode {
@ -78,7 +79,7 @@ namespace GPU {
namespace DMA {
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() {
@ -93,7 +94,7 @@ namespace GPU {
}
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) {
@ -105,10 +106,11 @@ namespace GPU {
}
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)));
::DMA::GPU.channel_ctrl.write(::DMA::CHCHR::StartGPUReceive());
::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());
}
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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