mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-09 05:25:01 +00:00
Started sketching out basic MFM track encoding. Which possibly even means that the shifters don't need to be public?
This commit is contained in:
@@ -8,4 +8,60 @@
|
|||||||
|
|
||||||
#include "MFM.hpp"
|
#include "MFM.hpp"
|
||||||
|
|
||||||
using namespace Storage::Encodings;
|
#import "../PCMTrack.hpp"
|
||||||
|
|
||||||
|
using namespace Storage::Encodings::MFM;
|
||||||
|
|
||||||
|
std::shared_ptr<Storage::Disk::Track> Storage::Encodings::MFM::GetMFMTrackWithSectors(const std::vector<Sector> §ors)
|
||||||
|
{
|
||||||
|
class MFMVectorShifter: public MFMShifter<MFMVectorShifter> {
|
||||||
|
void output_short(uint16_t value) {
|
||||||
|
data.push_back(value & 0xff);
|
||||||
|
data.push_back(value >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> data;
|
||||||
|
} shifter;
|
||||||
|
|
||||||
|
// output the index mark
|
||||||
|
shifter.add_index_address_mark();
|
||||||
|
|
||||||
|
// add the post-index mark
|
||||||
|
for(int c = 0; c < 50; c++) shifter.add_byte(0x4e);
|
||||||
|
|
||||||
|
// add sectors
|
||||||
|
for(const Sector §or : sectors)
|
||||||
|
{
|
||||||
|
for(int c = 0; c < 12; c++) shifter.add_byte(0x00);
|
||||||
|
|
||||||
|
shifter.add_ID_address_mark();
|
||||||
|
shifter.add_byte(sector.track);
|
||||||
|
shifter.add_byte(sector.side);
|
||||||
|
shifter.add_byte(sector.sector);
|
||||||
|
switch(sector.data.size())
|
||||||
|
{
|
||||||
|
default: shifter.add_byte(0); break;
|
||||||
|
case 256: shifter.add_byte(1); break;
|
||||||
|
case 512: shifter.add_byte(2); break;
|
||||||
|
case 1024: shifter.add_byte(3); break;
|
||||||
|
case 2048: shifter.add_byte(4); break;
|
||||||
|
case 4196: shifter.add_byte(5); break;
|
||||||
|
}
|
||||||
|
// TODO: CRC of bytes since the track number
|
||||||
|
|
||||||
|
for(int c = 0; c < 22; c++) shifter.add_byte(0x4e);
|
||||||
|
for(int c = 0; c < 12; c++) shifter.add_byte(0x00);
|
||||||
|
|
||||||
|
shifter.add_data_address_mark();
|
||||||
|
for(size_t c = 0; c < sector.data.size(); c++) shifter.add_byte(sector.data[c]);
|
||||||
|
// TODO: CRC of data
|
||||||
|
|
||||||
|
for(int c = 0; c < 18; c++) shifter.add_byte(0x00);
|
||||||
|
for(int c = 0; c < 32; c++) shifter.add_byte(0x4e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: total size check
|
||||||
|
|
||||||
|
Storage::Disk::PCMSegment segment;
|
||||||
|
return std::shared_ptr<Storage::Disk::Track>(new Storage::Disk::PCMTrack(std::move(segment)));
|
||||||
|
}
|
||||||
|
@@ -10,9 +10,12 @@
|
|||||||
#define Storage_Disk_Encodings_MFM_hpp
|
#define Storage_Disk_Encodings_MFM_hpp
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
#import "../Disk.hpp"
|
||||||
|
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
namespace Encodings {
|
namespace Encodings {
|
||||||
|
namespace MFM {
|
||||||
|
|
||||||
template <class T> class Shifter {
|
template <class T> class Shifter {
|
||||||
public:
|
public:
|
||||||
@@ -108,6 +111,15 @@ template <class T> class FMShifter: public Shifter<T> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Sector {
|
||||||
|
uint8_t track, side, sector;
|
||||||
|
std::vector<uint8_t> data;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::shared_ptr<Storage::Disk::Track> GetMFMTrackWithSectors(const std::vector<Sector> §ors);
|
||||||
|
std::shared_ptr<Storage::Disk::Track> GetFMTrackWithSectors(const std::vector<Sector> §ors);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user