openMSX
Disk.hh
Go to the documentation of this file.
1 #ifndef DISK_HH
2 #define DISK_HH
3 
5 #include "DiskName.hh"
6 #include "openmsx.hh"
7 
8 namespace openmsx {
9 
10 class RawTrack;
11 
12 class Disk : public SectorAccessibleDisk
13 {
14 public:
15  virtual ~Disk() = default;
16 
17  [[nodiscard]] const DiskName& getName() const { return name; }
18 
20  void writeTrack(byte track, byte side, const RawTrack& input);
21 
23  virtual void readTrack (byte track, byte side, RawTrack& output) = 0;
24 
25  bool isDoubleSided();
26 
27 protected:
28  explicit Disk(DiskName name);
29  [[nodiscard]] size_t physToLog(byte track, byte side, byte sector);
30  struct TSS { byte track, side, sector; };
31  [[nodiscard]] TSS logToPhys(size_t log);
32 
33  virtual void detectGeometry();
34  virtual void detectGeometryFallback();
35 
36  void setSectorsPerTrack(unsigned num) { sectorsPerTrack = num; }
37  [[nodiscard]] unsigned getSectorsPerTrack();
38  void setNbSides(unsigned num) { nbSides = num; }
39 
40  virtual void writeTrackImpl(byte track, byte side, const RawTrack& input) = 0;
41 
42 private:
43  const DiskName name;
44  unsigned sectorsPerTrack;
45  unsigned nbSides;
46 };
47 
48 } // namespace openmsx
49 
50 #endif
virtual void detectGeometryFallback()
Definition: Disk.cc:70
const DiskName & getName() const
Definition: Disk.hh:17
void writeTrack(byte track, byte side, const RawTrack &input)
Replace a full track in this image with the given track.
Definition: Disk.cc:12
unsigned getSectorsPerTrack()
Definition: Disk.cc:62
void setNbSides(unsigned num)
Definition: Disk.hh:38
virtual ~Disk()=default
Disk(DiskName name)
Definition: Disk.cc:7
bool isDoubleSided()
Definition: Disk.cc:21
void setSectorsPerTrack(unsigned num)
Definition: Disk.hh:36
virtual void detectGeometry()
Definition: Disk.cc:78
TSS logToPhys(size_t log)
Definition: Disk.cc:45
virtual void readTrack(byte track, byte side, RawTrack &output)=0
Read a full track from this disk image.
size_t physToLog(byte track, byte side, byte sector)
Definition: Disk.cc:35
virtual void writeTrackImpl(byte track, byte side, const RawTrack &input)=0
constexpr double log(double x)
Definition: cstd.hh:316
This file implemented 3 utility functions:
Definition: Autofire.cc:9