2016-09-25 21:46:11 +00:00
|
|
|
//
|
|
|
|
// AcornADF.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 25/09/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "AcornADF.hpp"
|
|
|
|
|
2017-09-30 02:07:23 +00:00
|
|
|
#include "Utility/ImplicitSectors.hpp"
|
2016-09-25 21:46:11 +00:00
|
|
|
|
2016-09-27 01:20:30 +00:00
|
|
|
namespace {
|
2017-10-07 01:45:12 +00:00
|
|
|
static const int sectors_per_track = 16;
|
|
|
|
static const int sector_size = 1;
|
2016-09-27 01:20:30 +00:00
|
|
|
}
|
|
|
|
|
2016-09-25 21:46:11 +00:00
|
|
|
using namespace Storage::Disk;
|
|
|
|
|
2017-10-01 00:30:15 +00:00
|
|
|
AcornADF::AcornADF(const char *file_name) : MFMSectorDump(file_name) {
|
2016-09-25 21:46:11 +00:00
|
|
|
// very loose validation: the file needs to be a multiple of 256 bytes
|
|
|
|
// and not ungainly large
|
2017-10-01 00:30:15 +00:00
|
|
|
if(file_stats_.st_size % (off_t)(128 << sector_size)) throw ErrorNotAcornADF;
|
|
|
|
if(file_stats_.st_size < 7 * (off_t)(128 << sector_size)) throw ErrorNotAcornADF;
|
2016-09-25 21:46:11 +00:00
|
|
|
|
|
|
|
// check that the initial directory's 'Hugo's are present
|
2016-11-21 12:14:09 +00:00
|
|
|
fseek(file_, 513, SEEK_SET);
|
2016-09-25 21:46:11 +00:00
|
|
|
uint8_t bytes[4];
|
2016-11-21 12:14:09 +00:00
|
|
|
fread(bytes, 1, 4, file_);
|
2016-09-25 21:46:11 +00:00
|
|
|
if(bytes[0] != 'H' || bytes[1] != 'u' || bytes[2] != 'g' || bytes[3] != 'o') throw ErrorNotAcornADF;
|
|
|
|
|
2016-11-21 12:14:09 +00:00
|
|
|
fseek(file_, 0x6fb, SEEK_SET);
|
|
|
|
fread(bytes, 1, 4, file_);
|
2016-09-25 21:46:11 +00:00
|
|
|
if(bytes[0] != 'H' || bytes[1] != 'u' || bytes[2] != 'g' || bytes[3] != 'o') throw ErrorNotAcornADF;
|
2017-10-01 00:30:15 +00:00
|
|
|
|
|
|
|
set_geometry(sectors_per_track, sector_size, true);
|
2016-09-25 21:46:11 +00:00
|
|
|
}
|
|
|
|
|
2017-10-07 01:45:12 +00:00
|
|
|
int AcornADF::get_head_position_count() {
|
2016-09-25 21:46:11 +00:00
|
|
|
return 80;
|
|
|
|
}
|
|
|
|
|
2017-10-07 01:45:12 +00:00
|
|
|
int AcornADF::get_head_count() {
|
2016-09-27 01:20:30 +00:00
|
|
|
return 1;
|
2016-09-25 21:46:11 +00:00
|
|
|
}
|
|
|
|
|
2017-10-07 01:45:12 +00:00
|
|
|
long AcornADF::get_file_offset_for_position(Track::Address address) {
|
|
|
|
return (address.position * 1 + address.head) * (128 << sector_size) * sectors_per_track;
|
2016-12-30 23:03:30 +00:00
|
|
|
}
|