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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1045 - (hide annotations)
Fri Dec 20 17:42:53 2013 UTC (5 years, 11 months ago) by dbug
File MIME type: text/plain
File size: 4011 byte(s)
Floppy Builder 0.11
- Added support for metadata that can be used later on by the programmer
Also modified Link65 to handle #include correctly in assembler source files
The SlideShow now correctly displays the name of the pictures and their authors from the exported metadata (Still need transitions)

1 dbug 1002 #ifndef FLOPPY_H_
2     #define FLOPPY_H_
3    
4     #include <vector>
5 dbug 1009 #include <map>
6 dbug 1038 #include <set>
7 dbug 1009 #include <sstream>
8     #include <iostream>
9 dbug 1002
10    
11 dbug 1035 enum CompressionMode
12     {
13     e_CompressionNone,
14     e_CompressionFilepack
15     };
16 dbug 1002
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 dbug 1022 void Clear();
26    
27 dbug 1002 bool IsValidHeader() const;
28    
29 dbug 1022 void SetSignature(char signature[8]);
30    
31     void SetSideNumber(int sideNumber);
32 dbug 1002 int GetSideNumber() const;
33 dbug 1022
34     void SetTrackNumber(int trackNumber);
35 dbug 1002 int GetTrackNumber() const;
36    
37 dbug 1022 void SetGeometry(int geometry);
38     int GetGeometry() const;
39 dbug 1002
40 dbug 1022 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 dbug 1002 private:
43 dbug 1022 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 dbug 1002 };
49    
50    
51 dbug 1009 class FileEntry
52     {
53     public:
54     FileEntry();
55     ~FileEntry();
56    
57     public:
58 dbug 1035 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 dbug 1038 int m_FinalFileSize;
64     int m_StoredFileSize;
65 dbug 1035 CompressionMode m_CompressionMode;
66     int m_LoadAddress;
67     std::string m_FilePath;
68 dbug 1045 std::map<std::string,std::string> m_Metadata;
69 dbug 1009 };
70    
71    
72 dbug 1002 class Floppy
73     {
74     public:
75 dbug 1035
76     public:
77 dbug 1002 Floppy();
78     ~Floppy();
79    
80 dbug 1018 bool CreateDisk(int numberOfSides,int numberOfTracks,int numberOfSectors);
81 dbug 1009 bool LoadDisk(const char* fileName);
82     bool SaveDisk(const char* fileName) const;
83     bool SaveDescription(const char* fileName) const;
84 dbug 1002
85 dbug 1018 bool WriteSector(const char *fileName);
86 dbug 1045 bool WriteFile(const char *fileName,int loadAddress,bool removeHeaderIfPresent,const std::map<std::string,std::string>& metadata);
87 dbug 1018 bool WriteTapeFile(const char *fileName);
88 dbug 1002
89 dbug 1009 bool AddDefine(std::string defineName,std::string defineValue);
90 dbug 1002
91 dbug 1035 void SetCompressionMode(CompressionMode compressionMode)
92     {
93     m_CompressionMode=compressionMode;
94     }
95    
96 dbug 1014 unsigned int SetPosition(int track,int sector)
97 dbug 1002 {
98 dbug 1014 m_CurrentSector=sector;
99     m_CurrentTrack =track;
100     return GetDskImageOffset();
101 dbug 1002 }
102    
103 dbug 1014 void MoveToNextSector()
104 dbug 1002 {
105 dbug 1014 m_CurrentSector++;
106    
107 dbug 1022 if (m_CurrentSector==m_SectorNumber+1) // We reached the end of the track!
108 dbug 1014 {
109     m_CurrentSector=1;
110     m_CurrentTrack++;
111     if (m_CurrentTrack==m_TrackNumber)
112     {
113     // Next side is following on the floppy in the DSK format, so technically we should have nothing to do
114     // All the hard work is in the loader
115     }
116     }
117 dbug 1002 }
118    
119 dbug 1038 void MarkCurrentSectorUsed();
120    
121 dbug 1002 private:
122 dbug 1014 unsigned int GetDskImageOffset();
123    
124     private:
125 dbug 1002 void* m_Buffer;
126     size_t m_BufferSize;
127 dbug 1022 int m_TrackNumber; // 42
128     int m_SectorNumber; // 17
129     int m_SideNumber; // 2
130     int m_OffsetFirstSector; // 156 (Location of the first byte of data of the first sector)
131     int m_InterSectorSpacing; // 358 (Number of bytes to skip to go to the next sector: 256+59+43)
132 dbug 1009
133 dbug 1014 int m_CurrentTrack;
134     int m_CurrentSector;
135    
136 dbug 1038 std::set<int> m_SectorUsageMap;
137    
138 dbug 1035 CompressionMode m_CompressionMode;
139    
140 dbug 1009 std::vector<FileEntry> m_FileEntries;
141     std::vector<std::pair<std::string,std::string>> m_DefineList;
142 dbug 1045
143     std::set<std::string> m_MetadataCategories;
144 dbug 1002 };
145    
146     #endif

  ViewVC Help
Powered by ViewVC 1.1.26