| 1 |
#ifndef IPSPATCH_HH |
| 2 |
#define IPSPATCH_HH |
| 3 |
|
| 4 |
#include "PatchInterface.hh" |
| 5 |
|
| 6 |
#include "Filename.hh" |
| 7 |
|
| 8 |
#include "MemBuffer.hh" |
| 9 |
|
| 10 |
#include <memory> |
| 11 |
#include <vector> |
| 12 |
|
| 13 |
namespace openmsx { |
| 14 |
|
| 15 |
class IPSPatch final : public PatchInterface |
| 16 |
{ |
| 17 |
public: |
| 18 |
IPSPatch(Filename filename, |
| 19 |
std::unique_ptr<const PatchInterface> parent); |
| 20 |
|
| 21 |
void copyBlock(size_t src, std::span<uint8_t> dst) const override; |
| 22 |
[[nodiscard]] size_t getSize() const override { return size; } |
| 23 |
[[nodiscard]] std::vector<Filename> getFilenames() const override; |
| 24 |
|
| 25 |
private: |
| 26 |
struct Chunk { |
| 27 |
size_t startAddress; |
| 28 |
MemBuffer<uint8_t> content; |
| 29 |
|
| 30 |
[[nodiscard]] size_t size() const { return content.size(); } |
| 31 |
[[nodiscard]] size_t stopAddress() const { return startAddress + size(); } |
| 32 |
[[nodiscard]] auto begin() const { return content.begin(); } |
| 33 |
[[nodiscard]] auto end () const { return content.end(); } |
| 34 |
}; |
| 35 |
|
| 36 |
const Filename filename; |
| 37 |
const std::unique_ptr<const PatchInterface> parent; |
| 38 |
const std::vector<Chunk> chunks; |
| 39 |
const size_t size; |
| 40 |
|
| 41 |
private: |
| 42 |
|
| 43 |
[[nodiscard]] std::vector<Chunk> parseChunks() const; |
| 44 |
[[nodiscard]] size_t calcSize() const; |
| 45 |
}; |
| 46 |
|
| 47 |
} |
| 48 |
|
| 49 |
#endif |