blob: d7671a46a986ba4689d3dbac89294a3d7a1789ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#pragma once
#include <vector>
#include <cstdint>
#include <unordered_map>
#include <yaml-cpp/yaml.h>
#include <optional>
#include <cstdint>
#include "BinaryReader.h"
enum class CompressionType {
None,
MIO0,
YAY0,
YAZ0,
};
struct DataChunk {
uint8_t* data;
size_t size;
};
struct DecompressedData {
DataChunk* root;
DataChunk segment;
LUS::BinaryReader GetReader() {
return LUS::BinaryReader(reinterpret_cast<char*>(segment.data), segment.size);
}
};
class Decompressor {
public:
static DataChunk* Decode(const std::vector<uint8_t>& buffer, uint32_t offset, CompressionType type);
static DecompressedData AutoDecode(YAML::Node& node, std::vector<uint8_t>& buffer, std::optional<size_t> size = std::nullopt);
static DecompressedData AutoDecode(uint32_t offset, std::optional<size_t> size, std::vector<uint8_t>& buffer);
static uint32_t TranslateAddr(uint32_t addr, bool baseAddress = false);
static bool IsSegmented(uint32_t addr);
static void ClearCache();
};
|