]> Shamusworld >> Repos - apple2/blob - src/floppy.h
Set eol-style to sane default.
[apple2] / src / floppy.h
1 //
2 // Apple 2 floppy disk support
3 //
4
5 #ifndef __FLOPPY_H__
6 #define __FLOPPY_H__
7
8 // MAX_PATH isn't defined in stdlib.h on *nix, so we do it here...
9 #ifdef __GCCUNIX__
10 #include <limits.h>
11 #define MAX_PATH                _POSIX_PATH_MAX
12 #else
13 #include <stdlib.h>                                                             // for MAX_PATH on MinGW/Darwin
14 #endif
15 #include "types.h"
16
17 enum { DT_UNKNOWN, DT_DOS33, DT_PRODOS, DT_NYBBLE };
18
19 class FloppyDrive
20 {
21         public:
22                 FloppyDrive();
23                 ~FloppyDrive();
24
25                 bool LoadImage(const char * filename, uint8 driveNum = 0);
26                 bool SaveImage(uint8 driveNum = 0);
27                 bool SaveImageAs(const char * filename, uint8 driveNum = 0);
28                 void CreateBlankImage(uint8 driveNum = 0);
29                 void SwapImages(void);
30
31                 // I/O functions ($C0Ex accesses)
32
33                 void ControlStepper(uint8 addr);
34                 void ControlMotor(uint8 addr);
35                 void DriveEnable(uint8 addr);
36                 uint8 ReadWrite(void);
37                 uint8 GetLatchValue(void);
38                 void SetLatchValue(uint8 value);
39                 void SetReadMode(void);
40                 void SetWriteMode(void);
41
42         protected:
43                 void DetectImageType(const char * filename, uint8 driveNum);
44                 void NybblizeImage(uint8 driveNum);
45                 void DenybblizeImage(uint8 driveNum);
46
47         private:
48                 char imageName[2][MAX_PATH];
49                 uint8 * disk[2];
50                 uint32 diskSize[2];
51                 uint8 diskType[2];
52                 bool imageDirty[2];
53                 uint8 motorOn;
54                 uint8 activeDrive;
55                 uint8 ioMode;
56                 uint8 latchValue;
57                 uint8 phase;
58                 uint8 track;
59
60                 uint8 nybblizedImage[2][232960];
61                 uint32 currentPos;
62
63                 // And here are some private class variables (to reduce function redundancy):
64                 static uint8 header[21];
65                 static uint8 doSector[16];
66                 static uint8 poSector[16];
67 };
68
69 #endif  // __FLOPPY_H__