1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-26 09:29:45 +00:00

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.
This commit is contained in:
Thomas Harte 2018-01-07 21:59:18 -05:00
parent 8be6cb827b
commit 0ccc104027
5 changed files with 10 additions and 8 deletions

View File

@ -33,7 +33,7 @@ AcornADF::AcornADF(const char *file_name) : MFMSectorDump(file_name) {
file_.read(bytes, 4);
if(bytes[0] != 'H' || bytes[1] != 'u' || bytes[2] != 'g' || bytes[3] != 'o') throw ErrorNotAcornADF;
set_geometry(sectors_per_track, sector_size, true);
set_geometry(sectors_per_track, sector_size, 0, true);
}
int AcornADF::get_head_position_count() {

View File

@ -14,10 +14,11 @@ using namespace Storage::Disk;
MFMSectorDump::MFMSectorDump(const char *file_name) : file_(file_name) {}
void MFMSectorDump::set_geometry(int sectors_per_track, uint8_t sector_size, bool is_double_density) {
void MFMSectorDump::set_geometry(int sectors_per_track, uint8_t sector_size, uint8_t first_sector, bool is_double_density) {
sectors_per_track_ = sectors_per_track;
sector_size_ = sector_size;
is_double_density_ = is_double_density;
first_sector_ = first_sector;
}
std::shared_ptr<Track> MFMSectorDump::get_track_at_position(Track::Address address) {
@ -32,7 +33,7 @@ std::shared_ptr<Track> MFMSectorDump::get_track_at_position(Track::Address addre
file_.read(sectors, sizeof(sectors));
}
return track_for_sectors(sectors, static_cast<uint8_t>(address.position), static_cast<uint8_t>(address.head), 0, sector_size_, is_double_density_);
return track_for_sectors(sectors, static_cast<uint8_t>(address.position), static_cast<uint8_t>(address.head), first_sector_, sector_size_, is_double_density_);
}
void MFMSectorDump::set_tracks(const std::map<Track::Address, std::shared_ptr<Track>> &tracks) {
@ -43,7 +44,7 @@ void MFMSectorDump::set_tracks(const std::map<Track::Address, std::shared_ptr<Tr
for(auto &track : tracks) {
// Assumption here: sector IDs will run from 0.
decode_sectors(*track.second, parsed_track, 0, static_cast<uint8_t>(sectors_per_track_-1), sector_size_, is_double_density_);
decode_sectors(*track.second, parsed_track, first_sector_, first_sector_ + static_cast<uint8_t>(sectors_per_track_-1), sector_size_, is_double_density_);
long file_offset = get_file_offset_for_position(track.first);
std::lock_guard<std::mutex> lock_guard(file_.get_file_access_mutex());

View File

@ -21,7 +21,7 @@ namespace Disk {
class MFMSectorDump: public DiskImage {
public:
MFMSectorDump(const char *file_name);
void set_geometry(int sectors_per_track, uint8_t sector_size, bool is_double_density);
void set_geometry(int sectors_per_track, uint8_t sector_size, uint8_t first_sector, bool is_double_density);
bool get_is_read_only() override;
void set_tracks(const std::map<Track::Address, std::shared_ptr<Track>> &tracks) override;
@ -36,6 +36,7 @@ class MFMSectorDump: public DiskImage {
int sectors_per_track_ = 0;
uint8_t sector_size_ = 0;
bool is_double_density_ = true;
uint8_t first_sector_ = 0;
};
}

View File

@ -43,7 +43,7 @@ MSXDSK::MSXDSK(const char *file_name) :
head_count_ = 2;
}
set_geometry(sectors_per_track, sector_size, true);
set_geometry(sectors_per_track, sector_size, 1, true);
}
int MSXDSK::get_head_position_count() {
@ -55,5 +55,5 @@ int MSXDSK::get_head_count() {
}
long MSXDSK::get_file_offset_for_position(Track::Address address) {
return (address.position + address.head*track_count_) * 512 * 9;
return (address.position*2 + address.head) * 512 * 9;
}

View File

@ -33,7 +33,7 @@ SSD::SSD(const char *file_name) : MFMSectorDump(file_name) {
if(track_count_ < 40) track_count_ = 40;
else if(track_count_ < 80) track_count_ = 80;
set_geometry(sectors_per_track, sector_size, false);
set_geometry(sectors_per_track, sector_size, 0, false);
}
int SSD::get_head_position_count() {