Introduce the JabyEngine namespace to all files
This commit is contained in:
@@ -3,30 +3,32 @@
|
||||
#include "../cd_file_types.hpp"
|
||||
#include "file_processor.hpp"
|
||||
|
||||
namespace CDFileProcessor {
|
||||
class State {
|
||||
private:
|
||||
FileProcessor::State file_processor_state;
|
||||
const uint32_t* data_adr;
|
||||
namespace JabyEngine {
|
||||
namespace CDFileProcessor {
|
||||
class State {
|
||||
private:
|
||||
FileProcessor::State file_processor_state;
|
||||
const uint32_t* data_adr;
|
||||
|
||||
public:
|
||||
State() = default;
|
||||
public:
|
||||
State() = default;
|
||||
|
||||
void setup(uint16_t lba, uint16_t size, const CDFile::Payload& payload);
|
||||
bool process();
|
||||
};
|
||||
void setup(uint16_t lba, uint16_t size, const CDFile::Payload& payload);
|
||||
bool process();
|
||||
};
|
||||
|
||||
template<size_t Size>
|
||||
static void load_from_cd(const OverlayLBA* overlay_lbas, const CDFile (&cd_files)[Size]) {
|
||||
State state;
|
||||
template<size_t Size>
|
||||
static void load_from_cd(const OverlayLBA* overlay_lbas, const CDFile (&cd_files)[Size]) {
|
||||
State state;
|
||||
|
||||
for(const auto& file : cd_files) {
|
||||
const auto& lba_info = overlay_lbas[file.rel_lba_idx];
|
||||
for(const auto& file : cd_files) {
|
||||
const auto& lba_info = overlay_lbas[file.rel_lba_idx];
|
||||
|
||||
state.setup(lba_info.lba, lba_info.size, file.payload);
|
||||
//while(state.process());???
|
||||
}
|
||||
}
|
||||
state.setup(lba_info.lba, lba_info.size, file.payload);
|
||||
//while(state.process());???
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This will be used as the file processor but will work on cd types
|
||||
|
@@ -2,50 +2,51 @@
|
||||
#define __JABYENGINE_FILE_PROCESSOR_HPP__
|
||||
#include "../file_types.hpp"
|
||||
|
||||
namespace FileProcessor {
|
||||
class State {
|
||||
private:
|
||||
struct Reserved {
|
||||
uint32_t reserved[4];
|
||||
};
|
||||
namespace JabyEngine {
|
||||
namespace FileProcessor {
|
||||
class State {
|
||||
private:
|
||||
struct Reserved {
|
||||
uint32_t reserved[4];
|
||||
};
|
||||
|
||||
struct Configuration;
|
||||
typedef bool (*ProcessRoutine)(Configuration&, Reserved&);
|
||||
struct Configuration;
|
||||
typedef bool (*ProcessRoutine)(Configuration&, Reserved&);
|
||||
|
||||
struct Configuration {
|
||||
ProcessRoutine process_routine = nullptr;
|
||||
const uint32_t* data_adr = nullptr;
|
||||
size_t data_word_size = 0ull;
|
||||
struct Configuration {
|
||||
ProcessRoutine process_routine = nullptr;
|
||||
const uint32_t* data_adr = nullptr;
|
||||
size_t data_word_size = 0ull;
|
||||
|
||||
template<typename T>
|
||||
static __always_inline Configuration from(bool (*process_routine)(Configuration&, T&), const uint32_t* data_adr) {
|
||||
return {reinterpret_cast<ProcessRoutine>(process_routine), data_adr};
|
||||
}
|
||||
|
||||
constexpr void processed(size_t words) {
|
||||
this->data_adr += words;
|
||||
this->data_word_size -= words;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
Configuration config;
|
||||
Reserved reserved;
|
||||
|
||||
template<typename T>
|
||||
static __always_inline Configuration from(bool (*process_routine)(Configuration&, T&), const uint32_t* data_adr) {
|
||||
return {reinterpret_cast<ProcessRoutine>(process_routine), data_adr};
|
||||
static __always_inline State from(const T& reserved, const uint32_t* data_adr, bool (*process_routine)(Configuration&, T&)) {
|
||||
return {Configuration::from(process_routine, data_adr), *reinterpret_cast<const Reserved*>(&reserved)};
|
||||
static_assert(sizeof(T) <= sizeof(Reserved));
|
||||
}
|
||||
|
||||
constexpr void processed(size_t words) {
|
||||
this->data_adr += words;
|
||||
this->data_word_size -= words;
|
||||
|
||||
public:
|
||||
bool process(size_t word_size) {
|
||||
this->config.data_word_size += word_size;
|
||||
return (*this->config.process_routine)(this->config, this->reserved);
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
Configuration config;
|
||||
Reserved reserved;
|
||||
|
||||
template<typename T>
|
||||
static __always_inline State from(const T& reserved, const uint32_t* data_adr, bool (*process_routine)(Configuration&, T&)) {
|
||||
return {Configuration::from(process_routine, data_adr), *reinterpret_cast<const Reserved*>(&reserved)};
|
||||
static_assert(sizeof(T) <= sizeof(Reserved));
|
||||
}
|
||||
|
||||
public:
|
||||
bool process(size_t word_size) {
|
||||
this->config.data_word_size += word_size;
|
||||
return (*this->config.process_routine)(this->config, this->reserved);
|
||||
}
|
||||
};
|
||||
|
||||
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__
|
@@ -3,25 +3,27 @@
|
||||
#include "../Overlay/overlay.hpp"
|
||||
#include "file_types.hpp"
|
||||
|
||||
enum struct CDFileType : uint8_t {
|
||||
SimpleTIM = 0,
|
||||
Custom
|
||||
};
|
||||
|
||||
struct __no_align CDFile {
|
||||
union __no_align Payload {
|
||||
uint32_t empty;
|
||||
SimpleTIM simple_tim;
|
||||
namespace JabyEngine {
|
||||
enum struct CDFileType : uint8_t {
|
||||
SimpleTIM = 0,
|
||||
Custom
|
||||
};
|
||||
|
||||
uint8_t rel_lba_idx;
|
||||
CDFileType type;
|
||||
Payload payload;
|
||||
};
|
||||
struct __no_align CDFile {
|
||||
union __no_align Payload {
|
||||
uint32_t empty;
|
||||
SimpleTIM simple_tim;
|
||||
};
|
||||
|
||||
namespace CDFileBuilder {
|
||||
static constexpr CDFile simple_tim(uint8_t rel_lba_idx, SimpleTIM simple_tim) {
|
||||
return CDFile{.rel_lba_idx = rel_lba_idx, .type = CDFileType::SimpleTIM, .payload = {.simple_tim = simple_tim}};
|
||||
uint8_t rel_lba_idx;
|
||||
CDFileType type;
|
||||
Payload payload;
|
||||
};
|
||||
|
||||
namespace CDFileBuilder {
|
||||
static constexpr CDFile simple_tim(uint8_t rel_lba_idx, SimpleTIM simple_tim) {
|
||||
return CDFile{.rel_lba_idx = rel_lba_idx, .type = CDFileType::SimpleTIM, .payload = {.simple_tim = simple_tim}};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //!__JABYENGINE_CD_FILE_TYPES_HPP__
|
@@ -3,35 +3,35 @@
|
||||
#include "../Auxiliary/complex_bitmap.hpp"
|
||||
#include "../jabyengine_defines.h"
|
||||
|
||||
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);
|
||||
static constexpr auto ClutX = BitRange<uint32_t>(17, 22);
|
||||
static constexpr auto ClutY = BitRange<uint32_t>(23, 31);
|
||||
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);
|
||||
static constexpr auto ClutX = BitRange<uint32_t>(17, 22);
|
||||
static constexpr auto ClutY = BitRange<uint32_t>(23, 31);
|
||||
|
||||
constexpr SimpleTIM() {
|
||||
this->raw = 0;
|
||||
}
|
||||
constexpr SimpleTIM() {
|
||||
this->raw = 0;
|
||||
}
|
||||
|
||||
constexpr SimpleTIM(uint16_t texX, uint16_t texY, uint16_t clutX, uint16_t clutY) : ComplexBitMap(ComplexBitMap::with(TextureX.with(texX >> 1), TextureY.with(texY >> 1), ClutX.with(clutX >> 4), ClutY.with(clutY))) {
|
||||
}
|
||||
constexpr SimpleTIM(uint16_t texX, uint16_t texY, uint16_t clutX, uint16_t clutY) : ComplexBitMap(ComplexBitMap::with(TextureX.with(texX >> 1), TextureY.with(texY >> 1), ClutX.with(clutX >> 4), ClutY.with(clutY))) {
|
||||
}
|
||||
|
||||
constexpr uint16_t getTextureX() const {
|
||||
return (ComplexBitMap<uint32_t>::get_value(SimpleTIM::TextureX) << 1);
|
||||
}
|
||||
constexpr uint16_t getTextureX() const {
|
||||
return (ComplexBitMap<uint32_t>::get_value(SimpleTIM::TextureX) << 1);
|
||||
}
|
||||
|
||||
constexpr uint16_t getTextureY() const {
|
||||
return (ComplexBitMap<uint32_t>::get_value(SimpleTIM::TextureY) << 1);
|
||||
}
|
||||
|
||||
constexpr uint16_t getClutX() const {
|
||||
return (ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutX) << 4);
|
||||
}
|
||||
|
||||
constexpr uint16_t getClutY() const {
|
||||
return ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutY);
|
||||
}
|
||||
};
|
||||
constexpr uint16_t getTextureY() const {
|
||||
return (ComplexBitMap<uint32_t>::get_value(SimpleTIM::TextureY) << 1);
|
||||
}
|
||||
|
||||
constexpr uint16_t getClutX() const {
|
||||
return (ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutX) << 4);
|
||||
}
|
||||
|
||||
constexpr uint16_t getClutY() const {
|
||||
return ComplexBitMap<uint32_t>::get_value(SimpleTIM::ClutY);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif // !__JABYENGINE_FILE_TYPES_HPP__
|
Reference in New Issue
Block a user