Fix inconsistent EOL
This commit is contained in:
@@ -1,73 +1,73 @@
|
||||
#pragma once
|
||||
#include "../../Auxiliary/types.hpp"
|
||||
#include "../cd_file_types.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace FileProcessor {
|
||||
class State {
|
||||
public:
|
||||
struct Reserved {
|
||||
uint32_t reserved[8];
|
||||
};
|
||||
|
||||
struct CDDataProcessor;
|
||||
|
||||
template<typename T>
|
||||
using GenericProcessRoutine = Progress (*)(CDDataProcessor&, T&);
|
||||
|
||||
typedef GenericProcessRoutine<Reserved> ProcessRoutine;
|
||||
|
||||
struct CDDataProcessor {
|
||||
ProcessRoutine process_routine = nullptr;
|
||||
const uint8_t* data_adr = nullptr;
|
||||
size_t data_bytes = 0ull;
|
||||
|
||||
template<typename T>
|
||||
static __always_inline CDDataProcessor from(GenericProcessRoutine<T> process_routine, const uint8_t* data_adr) {
|
||||
return {reinterpret_cast<ProcessRoutine>(process_routine), data_adr};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T simple_read_r() {
|
||||
static constexpr size_t T_SIZE = sizeof(T);
|
||||
|
||||
T value = *reinterpret_cast<const T*>(this->data_adr);
|
||||
CDDataProcessor::processed(T_SIZE);
|
||||
return value;
|
||||
}
|
||||
|
||||
constexpr void processed(size_t bytes) {
|
||||
this->data_adr += bytes;
|
||||
this->data_bytes -= bytes;
|
||||
}
|
||||
|
||||
constexpr void skip(size_t bytes) {
|
||||
CDDataProcessor::processed(bytes);
|
||||
}
|
||||
};
|
||||
|
||||
CDDataProcessor data_proc;
|
||||
Reserved reserved;
|
||||
|
||||
template<typename T>
|
||||
static __always_inline State from(const T& state, const uint32_t* data_adr, GenericProcessRoutine<T> process_routine) {
|
||||
return {CDDataProcessor::from(process_routine, reinterpret_cast<const uint8_t*>(data_adr)), *reinterpret_cast<const Reserved*>(&state)};
|
||||
static_assert(sizeof(T) <= sizeof(Reserved));
|
||||
}
|
||||
|
||||
public:
|
||||
Progress process(size_t bytes_ready) {
|
||||
this->data_proc.data_bytes += bytes_ready;
|
||||
return (*this->data_proc.process_routine)(this->data_proc, this->reserved);
|
||||
}
|
||||
};
|
||||
|
||||
// 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 TIM& 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);
|
||||
}
|
||||
#pragma once
|
||||
#include "../../Auxiliary/types.hpp"
|
||||
#include "../cd_file_types.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace FileProcessor {
|
||||
class State {
|
||||
public:
|
||||
struct Reserved {
|
||||
uint32_t reserved[8];
|
||||
};
|
||||
|
||||
struct CDDataProcessor;
|
||||
|
||||
template<typename T>
|
||||
using GenericProcessRoutine = Progress (*)(CDDataProcessor&, T&);
|
||||
|
||||
typedef GenericProcessRoutine<Reserved> ProcessRoutine;
|
||||
|
||||
struct CDDataProcessor {
|
||||
ProcessRoutine process_routine = nullptr;
|
||||
const uint8_t* data_adr = nullptr;
|
||||
size_t data_bytes = 0ull;
|
||||
|
||||
template<typename T>
|
||||
static __always_inline CDDataProcessor from(GenericProcessRoutine<T> process_routine, const uint8_t* data_adr) {
|
||||
return {reinterpret_cast<ProcessRoutine>(process_routine), data_adr};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T simple_read_r() {
|
||||
static constexpr size_t T_SIZE = sizeof(T);
|
||||
|
||||
T value = *reinterpret_cast<const T*>(this->data_adr);
|
||||
CDDataProcessor::processed(T_SIZE);
|
||||
return value;
|
||||
}
|
||||
|
||||
constexpr void processed(size_t bytes) {
|
||||
this->data_adr += bytes;
|
||||
this->data_bytes -= bytes;
|
||||
}
|
||||
|
||||
constexpr void skip(size_t bytes) {
|
||||
CDDataProcessor::processed(bytes);
|
||||
}
|
||||
};
|
||||
|
||||
CDDataProcessor data_proc;
|
||||
Reserved reserved;
|
||||
|
||||
template<typename T>
|
||||
static __always_inline State from(const T& state, const uint32_t* data_adr, GenericProcessRoutine<T> process_routine) {
|
||||
return {CDDataProcessor::from(process_routine, reinterpret_cast<const uint8_t*>(data_adr)), *reinterpret_cast<const Reserved*>(&state)};
|
||||
static_assert(sizeof(T) <= sizeof(Reserved));
|
||||
}
|
||||
|
||||
public:
|
||||
Progress process(size_t bytes_ready) {
|
||||
this->data_proc.data_bytes += bytes_ready;
|
||||
return (*this->data_proc.process_routine)(this->data_proc, this->reserved);
|
||||
}
|
||||
};
|
||||
|
||||
// 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 TIM& 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,62 +1,62 @@
|
||||
#pragma once
|
||||
#include "Processor/file_processor.hpp"
|
||||
#include "cd_file_types.hpp"
|
||||
#include <limits.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace FileProcessor {
|
||||
namespace Helper {
|
||||
template<typename T>
|
||||
static Progress exchange_and_execute_process_function(State::GenericProcessRoutine<T> process_routine, State::CDDataProcessor& data_proc, T& state) {
|
||||
data_proc.process_routine = reinterpret_cast<State::ProcessRoutine>(process_routine);
|
||||
return process_routine(data_proc, state);
|
||||
}
|
||||
|
||||
namespace DMA {
|
||||
struct WordsReady {
|
||||
uint32_t words_to_use;
|
||||
bool is_last;
|
||||
|
||||
static constexpr WordsReady calculate(const State::CDDataProcessor& data_proc, size_t words_left) {
|
||||
const auto config_data_words = (data_proc.data_bytes/sizeof(uint32_t));
|
||||
const auto words_to_use = (config_data_words > words_left) ? words_left : config_data_words;
|
||||
|
||||
return {
|
||||
.words_to_use = words_to_use,
|
||||
.is_last = words_to_use == words_left
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
static size_t send_words(size_t words_to_send, bool send_all) {
|
||||
auto blocks_to_send = words_to_send/16;
|
||||
while(blocks_to_send > 0) {
|
||||
const auto block_send = (blocks_to_send > UI16_MAX) ? UI16_MAX : blocks_to_send;
|
||||
|
||||
// Send data!
|
||||
T::wait();
|
||||
T::Receive::start(blocks_to_send);
|
||||
blocks_to_send -= block_send;
|
||||
}
|
||||
|
||||
if(send_all) {
|
||||
const auto last_words_to_send = (words_to_send & 0b1111);
|
||||
if(last_words_to_send > 0) {
|
||||
T::wait();
|
||||
T::Receive::start(1, last_words_to_send);
|
||||
}
|
||||
|
||||
T::wait();
|
||||
T::end();
|
||||
return words_to_send;
|
||||
}
|
||||
|
||||
else {
|
||||
return (words_to_send & ~0b1111);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma once
|
||||
#include "Processor/file_processor.hpp"
|
||||
#include "cd_file_types.hpp"
|
||||
#include <limits.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace FileProcessor {
|
||||
namespace Helper {
|
||||
template<typename T>
|
||||
static Progress exchange_and_execute_process_function(State::GenericProcessRoutine<T> process_routine, State::CDDataProcessor& data_proc, T& state) {
|
||||
data_proc.process_routine = reinterpret_cast<State::ProcessRoutine>(process_routine);
|
||||
return process_routine(data_proc, state);
|
||||
}
|
||||
|
||||
namespace DMA {
|
||||
struct WordsReady {
|
||||
uint32_t words_to_use;
|
||||
bool is_last;
|
||||
|
||||
static constexpr WordsReady calculate(const State::CDDataProcessor& data_proc, size_t words_left) {
|
||||
const auto config_data_words = (data_proc.data_bytes/sizeof(uint32_t));
|
||||
const auto words_to_use = (config_data_words > words_left) ? words_left : config_data_words;
|
||||
|
||||
return {
|
||||
.words_to_use = words_to_use,
|
||||
.is_last = words_to_use == words_left
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
static size_t send_words(size_t words_to_send, bool send_all) {
|
||||
auto blocks_to_send = words_to_send/16;
|
||||
while(blocks_to_send > 0) {
|
||||
const auto block_send = (blocks_to_send > UI16_MAX) ? UI16_MAX : blocks_to_send;
|
||||
|
||||
// Send data!
|
||||
T::wait();
|
||||
T::Receive::start(blocks_to_send);
|
||||
blocks_to_send -= block_send;
|
||||
}
|
||||
|
||||
if(send_all) {
|
||||
const auto last_words_to_send = (words_to_send & 0b1111);
|
||||
if(last_words_to_send > 0) {
|
||||
T::wait();
|
||||
T::Receive::start(1, last_words_to_send);
|
||||
}
|
||||
|
||||
T::wait();
|
||||
T::end();
|
||||
return words_to_send;
|
||||
}
|
||||
|
||||
else {
|
||||
return (words_to_send & ~0b1111);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user