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 <cstdint>
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(uint8_t track, uint8_t side, const RawTrack& input);
21
23 virtual void readTrack (uint8_t track, uint8_t 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(uint8_t track, uint8_t side, uint8_t sector);
36 struct TSS { uint8_t 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(uint8_t track, uint8_t side, const RawTrack& input) = 0;
47
48private:
49 const DiskName name;
50 unsigned sectorsPerTrack;
51 unsigned nbSides = 0;
52};
53
54} // namespace openmsx
55
56#endif
virtual void detectGeometryFallback()
Definition Disk.cc:71
size_t physToLog(uint8_t track, uint8_t side, uint8_t sector)
Definition Disk.cc:36
virtual void writeTrackImpl(uint8_t track, uint8_t side, const RawTrack &input)=0
virtual void readTrack(uint8_t track, uint8_t side, RawTrack &output)=0
Read a full track from this disk image.
const DiskName & getName() const
Definition Disk.hh:17
unsigned getSectorsPerTrack()
Definition Disk.cc:63
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
void writeTrack(uint8_t track, uint8_t side, const RawTrack &input)
Replace a full track in this image with the given track.
Definition Disk.cc:13
virtual ~Disk()=default
bool isDoubleSided()
Definition Disk.cc:22
void setSectorsPerTrack(unsigned num)
Definition Disk.hh:42
virtual void detectGeometry()
Definition Disk.cc:79
TSS logToPhys(size_t log)
Definition Disk.cc:46
This file implemented 3 utility functions:
Definition Autofire.cc:9
uint8_t sector
Definition Disk.hh:36
uint8_t track
Definition Disk.hh:36
uint8_t side
Definition Disk.hh:36