openMSX
XSAExtractor.hh
Go to the documentation of this file.
1#ifndef XSAEXTRACTOR_HH
2#define XSAEXTRACTOR_HH
3
4#include "DiskImageUtils.hh"
5
6#include <array>
7#include <cstdint>
8#include <span>
9#include <vector>
10
11namespace openmsx {
12
14{
15public:
16 explicit XSAExtractor(std::span<const uint8_t> file);
17 std::vector<SectorBuffer> extractData() &&;
18
19private:
20 static constexpr int MAX_STR_LEN = 254;
21 static constexpr int TBL_SIZE = 16;
22 static constexpr int MAX_HUF_CNT = 127;
23
24 [[nodiscard]] inline uint8_t charIn();
25 void chkHeader();
26 void unLz77();
27 [[nodiscard]] unsigned rdStrLen();
28 [[nodiscard]] int rdStrPos();
29 [[nodiscard]] bool bitIn();
30 void initHufInfo();
31 void mkHufTbl();
32
33 struct HufNode {
34 HufNode* child1;
35 HufNode* child2;
36 int weight;
37 };
38
39private:
40 std::span<const uint8_t> file; // the not-yet-consumed part of the file
41 std::vector<SectorBuffer> output;
42
43 int updHufCnt;
44 std::array<int, TBL_SIZE + 1> cpDist;
45 std::array<int, TBL_SIZE> tblSizes;
46 std::array<HufNode, 2 * TBL_SIZE - 1> hufTbl;
47
48 uint8_t bitFlg; // flag with the bits
49 uint8_t bitCnt; // nb bits left
50
51 static constexpr std::array<uint8_t, TBL_SIZE> cpdExt = { // Extra bits for distance codes
52 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
53 };
54};
55
56} // namespace openmsx
57
58#endif
std::vector< SectorBuffer > extractData() &&
This file implemented 3 utility functions:
Definition Autofire.cc:11