diff --git a/Storage/Disk/DiskImage/Formats/WOZ.cpp b/Storage/Disk/DiskImage/Formats/WOZ.cpp index bea9fd702..9dd11b047 100644 --- a/Storage/Disk/DiskImage/Formats/WOZ.cpp +++ b/Storage/Disk/DiskImage/Formats/WOZ.cpp @@ -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 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 track_contents; diff --git a/Storage/Disk/DiskImage/Formats/WOZ.hpp b/Storage/Disk/DiskImage/Formats/WOZ.hpp index f131f46c7..cf2d2e5a6 100644 --- a/Storage/Disk/DiskImage/Formats/WOZ.hpp +++ b/Storage/Disk/DiskImage/Formats/WOZ.hpp @@ -31,6 +31,7 @@ class WOZ: public DiskImage { std::shared_ptr get_track_at_position(Track::Address address) final; void set_tracks(const std::map> &tracks) final; bool get_is_read_only() final; + bool tracks_differ(Track::Address, Track::Address) final; private: Storage::FileHolder file_;