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
8namespace openmsx {
9
10class RawTrack;
11
13{
14public:
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
29 [[nodiscard]] virtual bool hasChanged() const { return false; }
30
31 [[nodiscard]] bool isDoubleSided();
32
33protected:
34 explicit Disk(DiskName name);
35 [[nodiscard]] size_t physToLog(byte track, byte side, byte sector);
36 struct TSS { byte track, side, sector; };
37 [[nodiscard]] TSS logToPhys(size_t log);
38
39 virtual void detectGeometry();
40 virtual void detectGeometryFallback();
41
42 void setSectorsPerTrack(unsigned num) { sectorsPerTrack = num; }
43 [[nodiscard]] unsigned getSectorsPerTrack();
44 void setNbSides(unsigned num) { nbSides = num; }
45
46 virtual void writeTrackImpl(byte track, byte side, const RawTrack& input) = 0;
47
48private:
49 const DiskName name;
50 unsigned sectorsPerTrack;
51 unsigned nbSides;
52};
53
54} // namespace openmsx
55
56#endif
virtual void detectGeometryFallback()
Definition: Disk.cc:70
void writeTrack(byte track, byte side, const RawTrack &input)
Replace a full track in this image with the given track.
Definition: Disk.cc:12
const DiskName & getName() const
Definition: Disk.hh:17
unsigned getSectorsPerTrack()
Definition: Disk.cc:62
void setNbSides(unsigned num)
Definition: Disk.hh:44
virtual bool hasChanged() const
Has the content of this disk changed, by some other means than the MSX writing to the disk.
Definition: Disk.hh:29
virtual ~Disk()=default
Disk(DiskName name)
Definition: Disk.cc:7
bool isDoubleSided()
Definition: Disk.cc:21
void setSectorsPerTrack(unsigned num)
Definition: Disk.hh:42
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:207
This file implemented 3 utility functions:
Definition: Autofire.cc:9