| 1 |
#ifndef SECTORACCESSIBLEDISK_HH |
| 2 |
#define SECTORACCESSIBLEDISK_HH |
| 3 |
|
| 4 |
#include "DiskImageUtils.hh" |
| 5 |
#include "Filename.hh" |
| 6 |
|
| 7 |
#include "sha1.hh" |
| 8 |
|
| 9 |
#include <memory> |
| 10 |
#include <span> |
| 11 |
#include <vector> |
| 12 |
|
| 13 |
namespace openmsx { |
| 14 |
|
| 15 |
class FilePool; |
| 16 |
class PatchInterface; |
| 17 |
|
| 18 |
class SectorAccessibleDisk |
| 19 |
{ |
| 20 |
public: |
| 21 |
static constexpr size_t SECTOR_SIZE = sizeof(SectorBuffer); |
| 22 |
|
| 23 |
|
| 24 |
void readSector (size_t sector, SectorBuffer& buf); |
| 25 |
void writeSector(size_t sector, const SectorBuffer& buf); |
| 26 |
void readSectors (std::span< SectorBuffer> buffers, size_t startSector); |
| 27 |
void writeSectors(std::span<const SectorBuffer> buffers, size_t startSector); |
| 28 |
[[nodiscard]] size_t getNbSectors(); |
| 29 |
|
| 30 |
|
| 31 |
[[nodiscard]] bool isWriteProtected() const; |
| 32 |
void forceWriteProtect(); |
| 33 |
|
| 34 |
[[nodiscard]] virtual bool isDummyDisk() const; |
| 35 |
|
| 36 |
|
| 37 |
void applyPatch(Filename patchFile); |
| 38 |
[[nodiscard]] std::vector<Filename> getPatches() const; |
| 39 |
[[nodiscard]] bool hasPatches() const; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
[[nodiscard]] Sha1Sum getSha1Sum(FilePool& filePool); |
| 45 |
|
| 46 |
|
| 47 |
virtual void readSectorsImpl( |
| 48 |
std::span<SectorBuffer> buffers, size_t startSector); |
| 49 |
|
| 50 |
|
| 51 |
virtual void readSectorImpl(size_t sector, SectorBuffer& buf); |
| 52 |
|
| 53 |
protected: |
| 54 |
SectorAccessibleDisk(); |
| 55 |
~SectorAccessibleDisk(); |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
void setPeekMode(bool peek) { peekMode = peek; } |
| 61 |
[[nodiscard]] bool isPeekMode() const { return peekMode; } |
| 62 |
|
| 63 |
virtual void checkCaches(); |
| 64 |
virtual void flushCaches(); |
| 65 |
virtual Sha1Sum getSha1SumImpl(FilePool& filePool); |
| 66 |
|
| 67 |
private: |
| 68 |
virtual void writeSectorImpl(size_t sector, const SectorBuffer& buf) = 0; |
| 69 |
[[nodiscard]] virtual size_t getNbSectorsImpl() = 0; |
| 70 |
[[nodiscard]] virtual bool isWriteProtectedImpl() const = 0; |
| 71 |
|
| 72 |
private: |
| 73 |
std::unique_ptr<const PatchInterface> patch; |
| 74 |
Sha1Sum sha1cache; |
| 75 |
bool forcedWriteProtect = false; |
| 76 |
bool peekMode = false; |
| 77 |
}; |
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
#endif |