-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdrive.h
142 lines (132 loc) · 3.1 KB
/
drive.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#ifndef _DRIVE_H
#define _DRIVE_H
#include <cstddef>
#include "Clockable.h"
class CTCBM;
class CIECDrive;
class CIECInterface;
class FDC;
class FdcGcr;
class DRIVEMEM;
class TED;
class Drive {
public:
Drive(unsigned int dn) : devNr(dn) {
};
virtual ~Drive() { };
virtual void Reset() = 0;
virtual void AttachDisk(const char *fname) = 0;
virtual void DetachDisk() = 0;
static void ChangeEmulation();
protected:
unsigned int devNr;
unsigned char *ram;
unsigned char *rom;
};
class FakeDrive : public Drive {
public:
FakeDrive();
virtual ~FakeDrive() { };
virtual void Reset();
virtual void AttachDisk(const char *fname);
virtual void DetachDisk();
private:
CTCBM *tcbm;
CIECInterface *iec;
CIECDrive *device;
};
class CTrueDrive : public Drive
, public Clockable
{
public:
CTrueDrive(unsigned int type, unsigned int dn);
virtual ~CTrueDrive();
static unsigned int NrOfDrivesAttached;
//
enum { TDE_1541, TDE_1541II, TDE_1551, TDE_1581 };
static CTrueDrive *Drives[4];
// Reset drive
virtual void Reset();
// Reset all drives
static void ResetAllDrives();
// Change drive type
void ChangeDriveType(unsigned int type);
// Obtain pointer to the drive FDC object
FdcGcr *GetFdc() {
return static_cast<FdcGcr*>(Fdc);
};
virtual void AttachDisk(const char *fname);
virtual void DetachDisk();
static void SwapDisk(const char *fname);
static CTrueDrive *GetRoot() { return RootDevice; };
CTrueDrive *GetNext() { return NextDevice; };
unsigned int GetDevNr() { return devNr; };
// Obtain index of highest available drive device number
static unsigned int GetHighestDevNr() {
unsigned int MaxofDrives = 0;
CTrueDrive *Drive = CTrueDrive::GetRoot();
while ( Drive ) {
unsigned int dn = (Drive->GetDevNr() & 7) + 1;
if ( dn > MaxofDrives)
MaxofDrives = dn;
Drive = Drive->GetNext();
}
return MaxofDrives;
}
static unsigned int GetLowestDevNr() {
unsigned int MinofDrives = 3;
CTrueDrive *Drive = CTrueDrive::GetRoot();
while ( Drive ) {
unsigned int dn = Drive->GetDevNr() & 7;
if ( dn < MinofDrives)
MinofDrives = dn;
Drive = Drive->GetNext();
}
return MinofDrives;
}
unsigned int getDriveType() {
return driveType;
}
int loadCustomRom(char *path);
static bool hasCustomRom(char *path);
protected:
//
static CTrueDrive *RootDevice;
static CTrueDrive *LastDevice;
CTrueDrive *PrevDevice;
CTrueDrive *NextDevice;
//
FdcGcr *FdcGCR, *Fdc;
DRIVEMEM *Mem1541;
//TCBMMEM *Mem1551;
TED *Ted;
unsigned char *originalRom;
unsigned char *patchedRom;
size_t romSize;
static int loadCustomRom(char *path, unsigned char *buffer, size_t size);
private:
unsigned int driveType;
};
//-------------
class IecFakeSerial;
class FakeSerialDrive : public Drive
{
public:
FakeSerialDrive(unsigned int dn);
virtual ~FakeSerialDrive();
virtual void Reset() {};
virtual void AttachDisk(const char *fname) {
//iecDrive->
}
virtual void DetachDisk() {
}
CIECDrive *getIecDrive() {
return iecDrive;
}
//virtual bool changeROM(_TCHAR *fname);
//virtual bool changeOutputPath(_TCHAR *path);
protected:
IecFakeSerial *iecInterFace;
CIECDrive *iecDrive;
};
#endif // _DRIVE_H