1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-11 15:49:38 +00:00
CLK/Storage/Disk/DiskImage/Formats/SSD.cpp
Thomas Harte 0ccc104027 Corrects start sector and track interleaving for MSX DSK.
MSX DSKs start with sector 1; Acorn disks still begin with sector 0. Also it turns out that MSX DSKs are indeed interleaved.
2018-01-07 21:59:18 -05:00

50 lines
1.2 KiB
C++

//
// SSD.cpp
// Clock Signal
//
// Created by Thomas Harte on 18/09/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#include "SSD.hpp"
#include <cstring>
#include "Utility/ImplicitSectors.hpp"
namespace {
static const int sectors_per_track = 10;
static const int sector_size = 1;
}
using namespace Storage::Disk;
SSD::SSD(const char *file_name) : MFMSectorDump(file_name) {
// very loose validation: the file needs to be a multiple of 256 bytes
// and not ungainly large
if(file_.stats().st_size & 255) throw ErrorNotSSD;
if(file_.stats().st_size < 512) throw ErrorNotSSD;
if(file_.stats().st_size > 800*256) throw ErrorNotSSD;
// this has two heads if the suffix is .dsd, one if it's .ssd
head_count_ = (tolower(file_name[std::strlen(file_name) - 3]) == 'd') ? 2 : 1;
track_count_ = static_cast<int>(file_.stats().st_size / (256 * 10));
if(track_count_ < 40) track_count_ = 40;
else if(track_count_ < 80) track_count_ = 80;
set_geometry(sectors_per_track, sector_size, 0, false);
}
int SSD::get_head_position_count() {
return track_count_;
}
int SSD::get_head_count() {
return head_count_;
}
long SSD::get_file_offset_for_position(Track::Address address) {
return (address.position * head_count_ + address.head) * 256 * 10;
}