1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Implement custom tracks_differ; support WOZ 2 3.5" drive geometry properly.

This commit is contained in:
Thomas Harte 2020-07-17 22:09:55 -04:00
parent 9d1d162cc8
commit f6b7467d75
2 changed files with 26 additions and 5 deletions

View File

@ -112,10 +112,22 @@ int WOZ::get_head_count() {
}
long WOZ::file_offset(Track::Address address) {
// Calculate table position; if this track is defined to be unformatted, return no track.
const int table_position = address.head * (is_3_5_disk_ ? 80 : 160) +
(is_3_5_disk_ ? address.position.as_int() : address.position.as_quarter());
if(track_map_[table_position] == 0xff) return NoSuchTrack;
// Calculate table position.
int table_position;
if(!is_3_5_disk_) {
table_position = address.head * 160 + address.position.as_quarter();
} else {
if(type_ == Type::WOZ1) {
table_position = address.head * 80 + address.position.as_int();
} else {
table_position = address.head + (address.position.as_int() * 2);
}
}
// Check that this track actually exists.
if(track_map_[table_position] == 0xff) {
return NoSuchTrack;
}
// Seek to the real track.
switch(type_) {
@ -125,9 +137,17 @@ long WOZ::file_offset(Track::Address address) {
}
}
bool WOZ::tracks_differ(Track::Address lhs, Track::Address rhs) {
const long offset1 = file_offset(lhs);
const long offset2 = file_offset(rhs);
return offset1 != offset2;
}
std::shared_ptr<Track> WOZ::get_track_at_position(Track::Address address) {
const long offset = file_offset(address);
if(offset == NoSuchTrack) return nullptr;
if(offset == NoSuchTrack) {
return nullptr;
}
// Seek to the real track.
std::vector<uint8_t> track_contents;

View File

@ -31,6 +31,7 @@ class WOZ: public DiskImage {
std::shared_ptr<Track> get_track_at_position(Track::Address address) final;
void set_tracks(const std::map<Track::Address, std::shared_ptr<Track>> &tracks) final;
bool get_is_read_only() final;
bool tracks_differ(Track::Address, Track::Address) final;
private:
Storage::FileHolder file_;