Integrate CircularBuffer as essential part of loading files from CD and dedicate file processing to the FileProcessor
This commit is contained in:
@@ -11,6 +11,10 @@ namespace JabyEngine {
|
||||
Progress progress;
|
||||
size_t bytes_ready;
|
||||
|
||||
constexpr operator bool() const {
|
||||
return this->progress != Progress::Error;
|
||||
}
|
||||
|
||||
static constexpr Result new_error() {
|
||||
return {Progress::Error, 0};
|
||||
}
|
||||
@@ -27,6 +31,7 @@ namespace JabyEngine {
|
||||
private:
|
||||
struct State {
|
||||
enum struct Step {
|
||||
Disabled,
|
||||
ReadToken,
|
||||
ObtainLiteralLength,
|
||||
CopyLiterals,
|
||||
@@ -35,12 +40,23 @@ namespace JabyEngine {
|
||||
CopyMatch,
|
||||
};
|
||||
|
||||
Step step = Step::ReadToken;
|
||||
Step step = Step::Disabled;
|
||||
size_t literal_length = 0;
|
||||
size_t match_length = 0;
|
||||
uint16_t match_offset = 0xFFFF;
|
||||
uint16_t match_offset = 0;
|
||||
|
||||
State() = default;
|
||||
|
||||
void enable() {
|
||||
this->step = Step::ReadToken;
|
||||
this->literal_length = 0;
|
||||
this->match_length = 0;
|
||||
this->match_offset = 0xFFFF;
|
||||
}
|
||||
|
||||
void disable() {
|
||||
this->step = Step::Disabled;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -56,7 +72,7 @@ namespace JabyEngine {
|
||||
}
|
||||
|
||||
void setup(uint8_t* dst_adr);
|
||||
void reset();
|
||||
void disable();
|
||||
|
||||
Result process(ArrayRange<const uint8_t> data, bool is_last);
|
||||
};
|
||||
|
@@ -25,17 +25,15 @@ namespace JabyEngine {
|
||||
};
|
||||
|
||||
private:
|
||||
FileProcessor::State file_pro_state;
|
||||
FileProcessor::State file_state;
|
||||
CircularBuffer<CD_IO::DataSector> circular_buffer;
|
||||
LZ4Decompressor lz4_decomp;
|
||||
JobArray jobs;
|
||||
const AutoLBAEntry* lba = nullptr;
|
||||
uint32_t*const tmp_area = nullptr; //< The start of the area to copy data to
|
||||
uint32_t* dst_area = nullptr; //< Current target for copying the data
|
||||
uint32_t*const tmp_area = nullptr; //< The start of the area to copy data to for the file processor
|
||||
|
||||
void start_cur_job();
|
||||
void reading_state(const CDFile& file);
|
||||
void done_state(const CDFile& file);
|
||||
void start_cur_job();
|
||||
bool process_data();
|
||||
|
||||
public:
|
||||
CDFileProcessor() = default;
|
||||
|
@@ -51,6 +51,8 @@ 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);
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,12 @@
|
||||
#ifndef __JABYENGINE_FILE_TYPES_HPP__
|
||||
#define __JABYENGINE_FILE_TYPES_HPP__
|
||||
#include "../Auxiliary/bits.hpp"
|
||||
#include "../jabyengine_defines.h"
|
||||
|
||||
namespace JabyEngine {
|
||||
struct __no_align Nothing {
|
||||
};
|
||||
|
||||
struct __no_align SimpleTIM {
|
||||
static constexpr auto TextureX = BitRange::from_to(0, 8);
|
||||
static constexpr auto TextureY = BitRange::from_to(9, 16);
|
||||
|
Reference in New Issue
Block a user