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
openmsx::Disk::TSS::side
byte side
Definition: Disk.hh:30
openmsx.hh
openmsx::SectorAccessibleDisk
Definition: SectorAccessibleDisk.hh:16
openmsx::Disk::writeTrack
void writeTrack(byte track, byte side, const RawTrack &input)
Replace a full track in this image with the given track.
Definition: Disk.cc:14
openmsx::RawTrack
Definition: RawTrack.hh:62
DiskName.hh
SectorAccessibleDisk.hh
openmsx::Disk::isDoubleSided
bool isDoubleSided()
Definition: Disk.cc:23
openmsx::Disk
Definition: Disk.hh:13
openmsx::Disk::~Disk
virtual ~Disk()=default
openmsx::Disk::TSS::sector
byte sector
Definition: Disk.hh:30
openmsx::Disk::writeTrackImpl
virtual void writeTrackImpl(byte track, byte side, const RawTrack &input)=0
openmsx::Disk::logToPhys
TSS logToPhys(size_t log)
Definition: Disk.cc:47
openmsx::Disk::readTrack
virtual void readTrack(byte track, byte side, RawTrack &output)=0
Read a full track from this disk image.
openmsx::Disk::TSS::track
byte track
Definition: Disk.hh:30
openmsx::DiskName
Definition: DiskName.hh:9
openmsx::RawTrack
RawTrack
Definition: RawTrack.cc:279
openmsx::Disk::physToLog
size_t physToLog(byte track, byte side, byte sector)
Definition: Disk.cc:37
openmsx::Disk::detectGeometryFallback
virtual void detectGeometryFallback()
Definition: Disk.cc:72
openmsx::Disk::setNbSides
void setNbSides(unsigned num)
Definition: Disk.hh:38
openmsx::Disk::detectGeometry
virtual void detectGeometry()
Definition: Disk.cc:80
cstd::log
constexpr double log(double x)
Definition: cstd.hh:315
openmsx::Disk::setSectorsPerTrack
void setSectorsPerTrack(unsigned num)
Definition: Disk.hh:36
openmsx::Disk::getSectorsPerTrack
unsigned getSectorsPerTrack()
Definition: Disk.cc:64
openmsx::Disk::TSS
Definition: Disk.hh:30
openmsx::Disk::getName
const DiskName & getName() const
Definition: Disk.hh:17
openmsx::Disk::Disk
Disk(DiskName name)
Definition: Disk.cc:9
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5