| 1 |
#ifndef HD_HH |
| 2 |
#define HD_HH |
| 3 |
|
| 4 |
#include "HDCommand.hh" |
| 5 |
|
| 6 |
#include "DiskContainer.hh" |
| 7 |
#include "File.hh" |
| 8 |
#include "Filename.hh" |
| 9 |
#include "MSXMotherBoard.hh" |
| 10 |
#include "SectorAccessibleDisk.hh" |
| 11 |
#include "serialize_meta.hh" |
| 12 |
|
| 13 |
#include "TigerTree.hh" |
| 14 |
|
| 15 |
#include <bitset> |
| 16 |
#include <optional> |
| 17 |
#include <string> |
| 18 |
|
| 19 |
namespace openmsx { |
| 20 |
|
| 21 |
class DeviceConfig; |
| 22 |
|
| 23 |
class HD : public SectorAccessibleDisk, public DiskContainer |
| 24 |
, public TTData, public MediaProvider |
| 25 |
{ |
| 26 |
public: |
| 27 |
static constexpr unsigned MAX_HD = 26; |
| 28 |
using HDInUse = std::bitset<MAX_HD>; |
| 29 |
static std::shared_ptr<HDInUse> getDrivesInUse(MSXMotherBoard& motherBoard); |
| 30 |
|
| 31 |
public: |
| 32 |
explicit HD(const DeviceConfig& config); |
| 33 |
~HD() override; |
| 34 |
|
| 35 |
[[nodiscard]] const std::string& getName() const { return name; } |
| 36 |
[[nodiscard]] const Filename& getImageName() const { return filename; } |
| 37 |
void switchImage(const Filename& filename); |
| 38 |
|
| 39 |
[[nodiscard]] std::string getTigerTreeHash(); |
| 40 |
|
| 41 |
|
| 42 |
void getMediaInfo(TclObject& result) override; |
| 43 |
void setMedia(const TclObject& info, EmuTime time) override; |
| 44 |
|
| 45 |
template<typename Archive> |
| 46 |
void serialize(Archive& ar, unsigned version); |
| 47 |
|
| 48 |
[[nodiscard]] MSXMotherBoard& getMotherBoard() const { return motherBoard; } |
| 49 |
|
| 50 |
private: |
| 51 |
|
| 52 |
void readSectorsImpl( |
| 53 |
std::span<SectorBuffer> buffers, size_t startSector) override; |
| 54 |
void writeSectorImpl(size_t sector, const SectorBuffer& buf) override; |
| 55 |
[[nodiscard]] size_t getNbSectorsImpl() override; |
| 56 |
[[nodiscard]] bool isWriteProtectedImpl() const override; |
| 57 |
[[nodiscard]] Sha1Sum getSha1SumImpl(FilePool& filePool) override; |
| 58 |
|
| 59 |
|
| 60 |
[[nodiscard]] SectorAccessibleDisk* getSectorAccessibleDisk() override; |
| 61 |
[[nodiscard]] std::string_view getContainerName() const override; |
| 62 |
[[nodiscard]] bool diskChanged() override; |
| 63 |
int insertDisk(const std::string& newFilename) override; |
| 64 |
|
| 65 |
|
| 66 |
[[nodiscard]] uint8_t* getData(size_t offset, size_t size) override; |
| 67 |
[[nodiscard]] bool isCacheStillValid(time_t& time) override; |
| 68 |
|
| 69 |
void showProgress(size_t position, size_t maxPosition); |
| 70 |
|
| 71 |
private: |
| 72 |
MSXMotherBoard& motherBoard; |
| 73 |
std::string name; |
| 74 |
std::optional<HDCommand> hdCommand; |
| 75 |
std::optional<TigerTree> tigerTree; |
| 76 |
|
| 77 |
File file; |
| 78 |
Filename filename; |
| 79 |
size_t filesize; |
| 80 |
|
| 81 |
std::shared_ptr<HDInUse> hdInUse; |
| 82 |
|
| 83 |
uint64_t lastProgressTime; |
| 84 |
bool everDidProgress; |
| 85 |
}; |
| 86 |
|
| 87 |
REGISTER_BASE_CLASS(HD, "HD"); |
| 88 |
SERIALIZE_CLASS_VERSION(HD, 2); |
| 89 |
|
| 90 |
} |
| 91 |
|
| 92 |
#endif |