Prepare VAG loading
This commit is contained in:
@@ -37,8 +37,8 @@ namespace JabyEngine {
|
||||
Reserved reserved;
|
||||
|
||||
template<typename T>
|
||||
static __always_inline State from(const T& state, const uint8_t* data_adr, GenericProcessRoutine<T> process_routine) {
|
||||
return {Configuration::from(process_routine, data_adr), *reinterpret_cast<const Reserved*>(&state)};
|
||||
static __always_inline State from(const T& state, const uint32_t* data_adr, GenericProcessRoutine<T> process_routine) {
|
||||
return {Configuration::from(process_routine, reinterpret_cast<const uint8_t*>(data_adr)), *reinterpret_cast<const Reserved*>(&state)};
|
||||
static_assert(sizeof(T) <= sizeof(Reserved));
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace JabyEngine {
|
||||
// The nothing state
|
||||
State create(const uint32_t* data_adr, const Nothing& nothing);
|
||||
State create(const uint32_t* data_adr, const SimpleTIM& file);
|
||||
State create(const uint32_t* data_adr, const VAG& file);
|
||||
|
||||
State create_custom(const uint32_t* data_adr, const CDFileType_t& file_type, const CDFile::Payload& payload);
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <PSX/jabyengine_config.hpp>
|
||||
#include "../Overlay/overlay.hpp"
|
||||
#include "file_types.hpp"
|
||||
|
||||
@@ -7,8 +8,11 @@ namespace JabyEngine {
|
||||
using RawPayload_t = uint32_t;
|
||||
|
||||
enum struct CDFileType : CDFileType_t {
|
||||
SimpleTIM = 0,
|
||||
CopyTo,
|
||||
CopyTo = 0,
|
||||
SimpleTIM,
|
||||
#ifdef __SUPPORT_VAG__
|
||||
SonyVAG,
|
||||
#endif // __SUPPORT_VAG__
|
||||
Custom,
|
||||
};
|
||||
|
||||
@@ -16,8 +20,9 @@ namespace JabyEngine {
|
||||
struct CDFile {
|
||||
union Payload {
|
||||
RawPayload_t raw;
|
||||
SimpleTIM simple_tim;
|
||||
CopyTo copy_to;
|
||||
SimpleTIM simple_tim;
|
||||
VAG vag;
|
||||
Overlay overlay;
|
||||
};
|
||||
|
||||
@@ -38,13 +43,19 @@ namespace JabyEngine {
|
||||
#pragma pack(pop)
|
||||
|
||||
struct CDFileBuilder {
|
||||
static constexpr CDFile copy_to(uint8_t rel_lba_idx, uint32_t* dst) {
|
||||
return CDFile{.rel_lba_idx = rel_lba_idx, .type = CDFileType::CopyTo, .payload = {.copy_to = CopyTo{dst}}};
|
||||
}
|
||||
|
||||
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}};
|
||||
}
|
||||
|
||||
static constexpr CDFile copy_to(uint8_t rel_lba_idx, uint32_t* dst) {
|
||||
return CDFile{.rel_lba_idx = rel_lba_idx, .type = CDFileType::CopyTo, .payload = {.copy_to = CopyTo{dst}}};
|
||||
#ifdef __SUPPORT_VAG__
|
||||
static constexpr CDFile sony_vag(uint8_t lba_idx, VAG vag) {
|
||||
return CDFile{.rel_lba_idx = lba_idx, .type = CDFileType::SonyVAG, .payload = {.vag = vag}};
|
||||
}
|
||||
#endif //__SUPPORT_VAG__
|
||||
|
||||
static constexpr CDFile overlay(uint8_t rel_lba_idx, uint32_t* overlay_dst) {
|
||||
return CDFile{.rel_lba_idx = rel_lba_idx, .type = CDFileType::CopyTo, .payload = {.overlay = Overlay{overlay_dst}}};
|
||||
|
@@ -8,6 +8,12 @@ namespace JabyEngine {
|
||||
struct Nothing {
|
||||
};
|
||||
|
||||
struct CopyTo {
|
||||
uint32_t* dst;
|
||||
};
|
||||
|
||||
// TODO: Call TIM?
|
||||
// TODO: Add create function?
|
||||
struct SimpleTIM {
|
||||
static constexpr auto TextureX = BitRange::from_to(0, 8);
|
||||
static constexpr auto TextureY = BitRange::from_to(9, 16);
|
||||
@@ -61,9 +67,14 @@ namespace JabyEngine {
|
||||
}
|
||||
};
|
||||
|
||||
struct CopyTo {
|
||||
uint32_t* dst;
|
||||
struct VAG {
|
||||
uint8_t voice_number;
|
||||
|
||||
static constexpr VAG create(uint8_t voice_num) {
|
||||
return VAG{.voice_number = voice_num};
|
||||
}
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef CopyTo Overlay;
|
||||
|
Reference in New Issue
Block a user