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  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  size_t physToLog(byte track, byte side, byte sector);
30  void logToPhys(size_t log, byte& track, byte& side, byte& sector);
31 
32  virtual void detectGeometry();
33  virtual void detectGeometryFallback();
34 
35  void setSectorsPerTrack(unsigned num) { sectorsPerTrack = num; }
36  unsigned getSectorsPerTrack();
37  void setNbSides(unsigned num) { nbSides = num; }
38 
39  virtual void writeTrackImpl(byte track, byte side, const RawTrack& input) = 0;
40 
41 private:
42  const DiskName name;
43  unsigned sectorsPerTrack;
44  unsigned nbSides;
45 };
46 
47 } // namespace openmsx
48 
49 #endif
openmsx.hh
openmsx::SectorAccessibleDisk
Definition: SectorAccessibleDisk.hh:15
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:12
openmsx::Disk::~Disk
virtual ~Disk()=default
openmsx::Disk::writeTrackImpl
virtual void writeTrackImpl(byte track, byte side, const RawTrack &input)=0
openmsx::Disk::logToPhys
void logToPhys(size_t log, byte &track, byte &side, byte &sector)
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::DiskName
Definition: DiskName.hh:8
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:71
openmsx::Disk::setNbSides
void setNbSides(unsigned num)
Definition: Disk.hh:37
openmsx::Disk::detectGeometry
virtual void detectGeometry()
Definition: Disk.cc:79
cstd::log
constexpr double log(double x)
Definition: cstd.hh:279
openmsx::Disk::setSectorsPerTrack
void setSectorsPerTrack(unsigned num)
Definition: Disk.hh:35
openmsx::Disk::getSectorsPerTrack
unsigned getSectorsPerTrack()
Definition: Disk.cc:63
openmsx::Disk::getName
const DiskName & getName() const
Definition: Disk.hh:17
openmsx::Disk::Disk
Disk(DiskName name)
Definition: Disk.cc:9
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5