OXYGENHUB
◆ main openmsx / src / fdc / Disk.hh
1.5 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef DISK_HH
2
#define DISK_HH
3
4
#include "DiskName.hh"
5
#include "SectorAccessibleDisk.hh"
6
7
#include <cstdint>
8
9
namespace openmsx {
10
11
class RawTrack;
12
13
class Disk : public SectorAccessibleDisk
14
{
15
public:
16
	virtual ~Disk() = default;
17
18
	[[nodiscard]] const DiskName& getName() const { return name; }
19
20
	/** Replace a full track in this image with the given track. */
21
	void writeTrack(uint8_t track, uint8_t side, const RawTrack& input);
22
23
	/** Read a full track from this disk image. */
24
	virtual void readTrack (uint8_t track, uint8_t side, RawTrack& output) = 0;
25
26
	/** Has the content of this disk changed, by some other means than the
27
	 * MSX writing to the disk. In other words: should caches on the MSX
28
	 * side be dropped? (E.g. via the 'disk-changed-signal' that's present
29
	 * in (some) MSX disk interfaces). */
30
	[[nodiscard]] virtual bool hasChanged() const { return false; }
31
32
	[[nodiscard]] bool isDoubleSided();
33
34
protected:
35
	explicit Disk(DiskName name);
36
	[[nodiscard]] size_t physToLog(uint8_t track, uint8_t side, uint8_t sector);
37
	struct TSS { uint8_t track, side, sector; };
38
	[[nodiscard]] TSS logToPhys(size_t log);
39
40
	virtual void detectGeometry();
41
	virtual void detectGeometryFallback();
42
43
	void setSectorsPerTrack(unsigned num) { sectorsPerTrack = num; }
44
	[[nodiscard]] unsigned getSectorsPerTrack();
45
	void setNbSides(unsigned num) {	nbSides = num; }
46
47
	virtual void writeTrackImpl(uint8_t track, uint8_t side, const RawTrack& input) = 0;
48
49
private:
50
	const DiskName name;
51
	unsigned sectorsPerTrack;
52
	unsigned nbSides = 0;
53
};
54
55
} // namespace openmsx
56
57
#endif