mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-05 08:26:28 +00:00
Overtly treat .ST images as FAT12.
This commit is contained in:
@@ -53,5 +53,5 @@ int FAT12::get_head_count() {
|
||||
}
|
||||
|
||||
long FAT12::get_file_offset_for_position(Track::Address address) {
|
||||
return (address.position.as_int()*head_count_ + address.head) * sector_size_ * sector_count_;
|
||||
return (address.position.as_int() * head_count_ + address.head) * sector_size_ * sector_count_;
|
||||
}
|
||||
|
@@ -1,42 +0,0 @@
|
||||
//
|
||||
// ST.cpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 12/11/2019.
|
||||
// Copyright © 2019 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#include "ST.hpp"
|
||||
|
||||
namespace {
|
||||
constexpr int sectors_per_track = 10;
|
||||
constexpr int sector_size = 2;
|
||||
}
|
||||
|
||||
using namespace Storage::Disk;
|
||||
|
||||
ST::ST(const std::string &file_name) : MFMSectorDump(file_name) {
|
||||
// Very loose validation: the file needs to be a whole number of tracks,
|
||||
// and not more than 160 of them.
|
||||
const auto stats = file_.stats();
|
||||
if(stats.st_size % (512*10)) throw Error::InvalidFormat;
|
||||
if(stats.st_size > 512*10*160) throw Error::InvalidFormat;
|
||||
|
||||
// Head count: 2 if there are more than 80 tracks. Otherwise 1.
|
||||
head_count_ = (stats.st_size >= 512 * 10 * 80) ? 2 : 1;
|
||||
track_count_ = std::max(80, int(stats.st_size / (512 * 10 * head_count_)));
|
||||
|
||||
set_geometry(sectors_per_track, sector_size, 1, true);
|
||||
}
|
||||
|
||||
HeadPosition ST::get_maximum_head_position() {
|
||||
return HeadPosition(track_count_);
|
||||
}
|
||||
|
||||
int ST::get_head_count() {
|
||||
return head_count_;
|
||||
}
|
||||
|
||||
long ST::get_file_offset_for_position(Track::Address address) {
|
||||
return (address.position.as_int() * head_count_ + address.head) * 512 * sectors_per_track;
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
//
|
||||
// ST.hpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 12/11/2019.
|
||||
// Copyright © 2019 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef ST_hpp
|
||||
#define ST_hpp
|
||||
|
||||
#include "MFMSectorDump.hpp"
|
||||
|
||||
namespace Storage {
|
||||
namespace Disk {
|
||||
|
||||
/*!
|
||||
Provides a @c Disk containing an ST disk image: a decoded sector dump of an Atari ST disk.
|
||||
*/
|
||||
class ST: public MFMSectorDump {
|
||||
public:
|
||||
/*!
|
||||
Construct an @c ST containing content from the file with name @c file_name.
|
||||
|
||||
@throws Storage::FileHolder::Error::CantOpen if this file can't be opened.
|
||||
@throws Error::InvalidFormat if the file doesn't appear to contain a .ST format image.
|
||||
*/
|
||||
ST(const std::string &file_name);
|
||||
|
||||
HeadPosition get_maximum_head_position() final;
|
||||
int get_head_count() final;
|
||||
|
||||
private:
|
||||
long get_file_offset_for_position(Track::Address address) final;
|
||||
|
||||
int head_count_;
|
||||
int track_count_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ST_hpp */
|
Reference in New Issue
Block a user