mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-17 10:06:21 +00:00
Adds support for ADL-format disk images.
This commit is contained in:
parent
4bd6ffa9e4
commit
ac95e4d758
@ -98,6 +98,7 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::
|
|||||||
Format("81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 81
|
Format("81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 81
|
||||||
Format("a26", result.cartridges, Cartridge::BinaryDump, TargetPlatform::Atari2600) // A26
|
Format("a26", result.cartridges, Cartridge::BinaryDump, TargetPlatform::Atari2600) // A26
|
||||||
Format("adf", result.disks, Disk::DiskImageHolder<Storage::Disk::AcornADF>, TargetPlatform::Acorn) // ADF
|
Format("adf", result.disks, Disk::DiskImageHolder<Storage::Disk::AcornADF>, TargetPlatform::Acorn) // ADF
|
||||||
|
Format("adl", result.disks, Disk::DiskImageHolder<Storage::Disk::AcornADF>, TargetPlatform::Acorn) // ADL
|
||||||
Format("bin", result.cartridges, Cartridge::BinaryDump, TargetPlatform::AllCartridge) // BIN (cartridge dump)
|
Format("bin", result.cartridges, Cartridge::BinaryDump, TargetPlatform::AllCartridge) // BIN (cartridge dump)
|
||||||
Format("cas", result.tapes, Tape::CAS, TargetPlatform::MSX) // CAS
|
Format("cas", result.tapes, Tape::CAS, TargetPlatform::MSX) // CAS
|
||||||
Format("cdt", result.tapes, Tape::TZX, TargetPlatform::AmstradCPC) // CDT
|
Format("cdt", result.tapes, Tape::TZX, TargetPlatform::AmstradCPC) // CDT
|
||||||
|
@ -18,12 +18,13 @@ namespace {
|
|||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
AcornADF::AcornADF(const std::string &file_name) : MFMSectorDump(file_name) {
|
AcornADF::AcornADF(const std::string &file_name) : MFMSectorDump(file_name) {
|
||||||
// very loose validation: the file needs to be a multiple of 256 bytes
|
// Check that the disk image contains a whole number of sector.
|
||||||
// and not ungainly large
|
|
||||||
if(file_.stats().st_size % off_t(128 << sector_size)) throw Error::InvalidFormat;
|
if(file_.stats().st_size % off_t(128 << sector_size)) throw Error::InvalidFormat;
|
||||||
|
|
||||||
|
// Check that the disk image is at least large enough to hold an ADFS catalogue.
|
||||||
if(file_.stats().st_size < 7 * off_t(128 << sector_size)) throw Error::InvalidFormat;
|
if(file_.stats().st_size < 7 * off_t(128 << sector_size)) throw Error::InvalidFormat;
|
||||||
|
|
||||||
// check that the initial directory's 'Hugo's are present
|
// Check that the initial directory's 'Hugo's are present.
|
||||||
file_.seek(513, SEEK_SET);
|
file_.seek(513, SEEK_SET);
|
||||||
uint8_t bytes[4];
|
uint8_t bytes[4];
|
||||||
file_.read(bytes, 4);
|
file_.read(bytes, 4);
|
||||||
@ -33,6 +34,10 @@ AcornADF::AcornADF(const std::string &file_name) : MFMSectorDump(file_name) {
|
|||||||
file_.read(bytes, 4);
|
file_.read(bytes, 4);
|
||||||
if(bytes[0] != 'H' || bytes[1] != 'u' || bytes[2] != 'g' || bytes[3] != 'o') throw Error::InvalidFormat;
|
if(bytes[0] != 'H' || bytes[1] != 'u' || bytes[2] != 'g' || bytes[3] != 'o') throw Error::InvalidFormat;
|
||||||
|
|
||||||
|
// Pick a number of heads; treat this image as double sided if it's too large to be single-sided.
|
||||||
|
head_count_ = 1 + (file_.stats().st_size > sectors_per_track * off_t(128 << sector_size) * 80);
|
||||||
|
|
||||||
|
// Announce disk geometry.
|
||||||
set_geometry(sectors_per_track, sector_size, 0, true);
|
set_geometry(sectors_per_track, sector_size, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,9 +46,9 @@ HeadPosition AcornADF::get_maximum_head_position() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int AcornADF::get_head_count() {
|
int AcornADF::get_head_count() {
|
||||||
return 1;
|
return head_count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
long AcornADF::get_file_offset_for_position(Track::Address address) {
|
long AcornADF::get_file_offset_for_position(Track::Address address) {
|
||||||
return address.position.as_int() * (128 << sector_size) * sectors_per_track;
|
return (address.position.as_int() * head_count_ + address.head) * (128 << sector_size) * sectors_per_track;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ class AcornADF: public MFMSectorDump {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
long get_file_offset_for_position(Track::Address address) final;
|
long get_file_offset_for_position(Track::Address address) final;
|
||||||
|
int head_count_ = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user