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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#pragma once
#include <factories/BaseFactory.h>
#include <unordered_set>
namespace FZX {
typedef std::variant<uint8_t, uint16_t, uint32_t> SeqArg;
enum class SeqArgType {
U8, S16, CS16
};
enum class SequenceState {
player,
channel,
layer,
data,
envelope
};
struct SeqLabelInfo {
uint32_t pos;
SequenceState state;
uint32_t channel;
uint32_t layer;
bool largeNotes;
SeqLabelInfo(uint32_t pos, SequenceState state, uint32_t channel, uint32_t layer, bool largeNotes) : pos(pos), state(state), channel(channel), layer(layer), largeNotes(largeNotes) {}
};
struct SeqCommand {
uint8_t cmd;
uint32_t pos;
SequenceState state;
int32_t channel;
int32_t layer;
uint32_t size;
std::vector<SeqArg> args;
bool operator<(const SeqCommand& command) const {
return pos < command.pos;
}
};
class SequenceData : public IParsedData {
public:
std::vector<SeqCommand> mCmds;
std::unordered_set<uint32_t> mLabels;
bool mHasFooter;
SequenceData(std::vector<SeqCommand> cmds, std::unordered_set<uint32_t> labels, bool hasFooter) : mCmds(std::move(cmds)), mLabels(std::move(labels)), mHasFooter(hasFooter) {}
};
class SequenceHeaderExporter : public BaseExporter {
ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};
class SequenceBinaryExporter : public BaseExporter {
ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};
class SequenceCodeExporter : public BaseExporter {
ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};
class SequenceFactory : public BaseFactory {
public:
std::optional<std::shared_ptr<IParsedData>> parse(std::vector<uint8_t>& buffer, YAML::Node& data) override;
inline std::unordered_map<ExportType, std::shared_ptr<BaseExporter>> GetExporters() override {
return {
REGISTER(Code, SequenceCodeExporter)
REGISTER(Header, SequenceHeaderExporter)
REGISTER(Binary, SequenceBinaryExporter)
};
}
};
}
|