/[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 1018 - (show annotations)
Sat Dec 14 14:02:00 2013 UTC (6 years ago) by dbug
File MIME type: text/plain
File size: 3258 byte(s)
FloppyBuilder 0.6
- Added the 'LoadDiskTemplate' and 'DefineDisk' commands (and removed these parameters from the command line, define disk does not work at the moment)
- Added the 'AddTapFile' command, similar to 'AddFile' but automatically removes the header and extract the start address of the file
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 CreateDisk(int numberOfSides,int numberOfTracks,int numberOfSectors);
70 bool LoadDisk(const char* fileName);
71 bool SaveDisk(const char* fileName) const;
72 bool SaveDescription(const char* fileName) const;
73
74 bool WriteSector(const char *fileName);
75 bool WriteFile(const char *fileName,int loadAddress,bool removeHeaderIfPresent);
76 bool WriteTapeFile(const char *fileName);
77
78 bool AddDefine(std::string defineName,std::string defineValue);
79
80 unsigned int SetPosition(int track,int sector)
81 {
82 m_CurrentSector=sector;
83 m_CurrentTrack =track;
84 return GetDskImageOffset();
85 }
86
87 void MoveToNextSector()
88 {
89 m_CurrentSector++;
90
91 if (m_CurrentSector==taille_piste+1) // We reached the end of the track!
92 {
93 m_CurrentSector=1;
94 m_CurrentTrack++;
95 if (m_CurrentTrack==m_TrackNumber)
96 {
97 // Next side is following on the floppy in the DSK format, so technically we should have nothing to do
98 // All the hard work is in the loader
99 }
100 }
101 }
102
103 private:
104 unsigned int GetDskImageOffset();
105
106 private:
107 void* m_Buffer;
108 size_t m_BufferSize;
109 int m_TrackNumber; // 42
110 int m_SectorNumber; // 17
111 int m_SideNumber; // 2
112
113 int m_CurrentTrack;
114 int m_CurrentSector;
115
116 std::vector<FileEntry> m_FileEntries;
117 std::vector<std::pair<std::string,std::string>> m_DefineList;
118
119 std::stringstream code_sector;
120 std::stringstream code_track;
121 std::stringstream code_nombre_secteur;
122 std::stringstream code_adress_low;
123 std::stringstream code_adress_high;
124 };
125
126 #endif

  ViewVC Help
Powered by ViewVC 1.1.26