/[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 1014 - (show annotations)
Thu Dec 12 20:50:14 2013 UTC (6 years, 3 months ago) by dbug
File MIME type: text/plain
File size: 3142 byte(s)
FloppyBuilder 0.5
- removed some unused variables
- cleaned the offset/track/sector management code
- the 'SetBootSector' command is now 'WriteSector' and automatically move to the next sector after writing data
1 #ifndef FLOPPY_H_
2 #define FLOPPY_H_
3
4 #include <vector>
5 #include <map>
6 #include <sstream>
7 #include <iostream>
8
9 // File structure:
10 // MFM_DISK
11
12 #define header_dsk 256+156
13
14 // Nombre de secteur pour une piste
15 #define taille_piste 17
16 #define taille_secteur 256
17 // Header secteur
18 #define nb_oct_before_sector 59 // Cas de 17 secteurs/pistes !
19 #define nb_oct_after_sector 43 //#define nb_oct_after_sector 31
20
21
22 // This class is meant to be mapped on memory area supposed to be of MFM disk format.
23 // The header is 256 bytes long, so this class memory usage should be similar in size and structure.
24 class FloppyHeader
25 {
26 public:
27 FloppyHeader();
28 ~FloppyHeader();
29
30 bool IsValidHeader() const;
31
32 int GetSideNumber() const;
33 int GetTrackNumber() const;
34
35
36 private:
37 char m_Signature[8]; // (MFM_DISK)
38 unsigned char m_Sides[4]; // : 4 bytes (2)
39 unsigned char m_Tracks[4]; // : 4 bytes (42/$2A)
40 unsigned char m_Geometry[4]; // : 4 bytes (1)
41 unsigned char m_Padding[236]; // : 236 bytes (000000...00000 )
42 };
43
44
45 class FileEntry
46 {
47 public:
48 FileEntry();
49 ~FileEntry();
50
51 public:
52 int m_FloppyNumber; // 0 for a single floppy program
53 int m_StartSide; // 0 or 1
54 int m_StartTrack; // 0 to 42 (80...)
55 int m_StartSector; // 1 to 17 (or 16 or 18...)
56 int m_SectorCount;
57 int m_TotalSize;
58 int m_LoadAddress;
59 std::string m_FilePath;
60 };
61
62
63 class Floppy
64 {
65 public:
66 Floppy();
67 ~Floppy();
68
69 bool LoadDisk(const char* fileName);
70 bool SaveDisk(const char* fileName) const;
71 bool SaveDescription(const char* fileName) const;
72
73 void WriteSector(const char *fileName);
74 int WriteFile(const char *fileName,int loadAddress); // Returns the number of sectors
75
76 bool AddDefine(std::string defineName,std::string defineValue);
77
78 unsigned int SetPosition(int track,int sector)
79 {
80 m_CurrentSector=sector;
81 m_CurrentTrack =track;
82 return GetDskImageOffset();
83 }
84
85 void MoveToNextSector()
86 {
87 m_CurrentSector++;
88
89 if (m_CurrentSector==taille_piste+1) // We reached the end of the track!
90 {
91 m_CurrentSector=1;
92 m_CurrentTrack++;
93 if (m_CurrentTrack==m_TrackNumber)
94 {
95 // Next side is following on the floppy in the DSK format, so technically we should have nothing to do
96 // All the hard work is in the loader
97 }
98 }
99 }
100
101 private:
102 unsigned int GetDskImageOffset();
103
104 private:
105 void* m_Buffer;
106 size_t m_BufferSize;
107 int m_TrackNumber; // 42
108 int m_SectorNumber; // 17
109 int m_SideNumber; // 2
110
111 int m_CurrentTrack;
112 int m_CurrentSector;
113
114 std::vector<FileEntry> m_FileEntries;
115 std::vector<std::pair<std::string,std::string>> m_DefineList;
116
117 std::stringstream code_sector;
118 std::stringstream code_track;
119 std::stringstream code_nombre_secteur;
120 std::stringstream code_adress_low;
121 std::stringstream code_adress_high;
122 };
123
124 #endif

  ViewVC Help
Powered by ViewVC 1.1.26