/[projet1]/public/pc/tools/osdk/main/makedisk/Floppy.h
Defence Force logotype

Contents of /public/pc/tools/osdk/main/makedisk/Floppy.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1038 - (show annotations)
Tue Dec 17 21:24:32 2013 UTC (5 years, 11 months ago) by dbug
File MIME type: text/plain
File size: 3835 byte(s)
FloppyBuilder 0.10
- The compression code now generates correct data (it was using the Atari ST mode encoding, making the unpacking code not happy)
- Added to the report file the occupation ratio of the floppy (by maintaining an internal list of used sectors also used to check if there's no overlap)
The loader code is now able to decompress data on the fly just using the page 2 as a temporary sector loader.
1 #ifndef FLOPPY_H_
2 #define FLOPPY_H_
3
4 #include <vector>
5 #include <map>
6 #include <set>
7 #include <sstream>
8 #include <iostream>
9
10
11 enum CompressionMode
12 {
13 e_CompressionNone,
14 e_CompressionFilepack
15 };
16
17 // This class is meant to be mapped on memory area supposed to be of MFM disk format.
18 // The header is 256 bytes long, so this class memory usage should be similar in size and structure.
19 class FloppyHeader
20 {
21 public:
22 FloppyHeader();
23 ~FloppyHeader();
24
25 void Clear();
26
27 bool IsValidHeader() const;
28
29 void SetSignature(char signature[8]);
30
31 void SetSideNumber(int sideNumber);
32 int GetSideNumber() const;
33
34 void SetTrackNumber(int trackNumber);
35 int GetTrackNumber() const;
36
37 void SetGeometry(int geometry);
38 int GetGeometry() const;
39
40 int FindNumberOfSectors(int& firstSectorOffset,int& sectorInterleave) const; ///< Note: This function will expect valid data to exist past the padding because it needs to scan the data...
41
42 private:
43 char m_Signature[8]; // (MFM_DISK)
44 unsigned char m_Sides[4]; // : 4 bytes (2)
45 unsigned char m_Tracks[4]; // : 4 bytes (42/$2A)
46 unsigned char m_Geometry[4]; // : 4 bytes (1)
47 unsigned char m_Padding[236]; // : 236 bytes (000000...00000 )
48 };
49
50
51 class FileEntry
52 {
53 public:
54 FileEntry();
55 ~FileEntry();
56
57 public:
58 int m_FloppyNumber; // 0 for a single floppy program
59 int m_StartSide; // 0 or 1
60 int m_StartTrack; // 0 to 42 (80...)
61 int m_StartSector; // 1 to 17 (or 16 or 18...)
62 int m_SectorCount;
63 int m_FinalFileSize;
64 int m_StoredFileSize;
65 CompressionMode m_CompressionMode;
66 int m_LoadAddress;
67 std::string m_FilePath;
68 };
69
70
71 class Floppy
72 {
73 public:
74
75 public:
76 Floppy();
77 ~Floppy();
78
79 bool CreateDisk(int numberOfSides,int numberOfTracks,int numberOfSectors);
80 bool LoadDisk(const char* fileName);
81 bool SaveDisk(const char* fileName) const;
82 bool SaveDescription(const char* fileName) const;
83
84 bool WriteSector(const char *fileName);
85 bool WriteFile(const char *fileName,int loadAddress,bool removeHeaderIfPresent);
86 bool WriteTapeFile(const char *fileName);
87
88 bool AddDefine(std::string defineName,std::string defineValue);
89
90 void SetCompressionMode(CompressionMode compressionMode)
91 {
92 m_CompressionMode=compressionMode;
93 }
94
95 unsigned int SetPosition(int track,int sector)
96 {
97 m_CurrentSector=sector;
98 m_CurrentTrack =track;
99 return GetDskImageOffset();
100 }
101
102 void MoveToNextSector()
103 {
104 m_CurrentSector++;
105
106 if (m_CurrentSector==m_SectorNumber+1) // We reached the end of the track!
107 {
108 m_CurrentSector=1;
109 m_CurrentTrack++;
110 if (m_CurrentTrack==m_TrackNumber)
111 {
112 // Next side is following on the floppy in the DSK format, so technically we should have nothing to do
113 // All the hard work is in the loader
114 }
115 }
116 }
117
118 void MarkCurrentSectorUsed();
119
120 private:
121 unsigned int GetDskImageOffset();
122
123 private:
124 void* m_Buffer;
125 size_t m_BufferSize;
126 int m_TrackNumber; // 42
127 int m_SectorNumber; // 17
128 int m_SideNumber; // 2
129 int m_OffsetFirstSector; // 156 (Location of the first byte of data of the first sector)
130 int m_InterSectorSpacing; // 358 (Number of bytes to skip to go to the next sector: 256+59+43)
131
132 int m_CurrentTrack;
133 int m_CurrentSector;
134
135 std::set<int> m_SectorUsageMap;
136
137 CompressionMode m_CompressionMode;
138
139 std::vector<FileEntry> m_FileEntries;
140 std::vector<std::pair<std::string,std::string>> m_DefineList;
141 };
142
143 #endif

  ViewVC Help
Powered by ViewVC 1.1.26