diff --git a/Analyser/Static/DiskII/StaticAnalyser.cpp b/Analyser/Static/DiskII/StaticAnalyser.cpp index 3da62f061..b207cd224 100644 --- a/Analyser/Static/DiskII/StaticAnalyser.cpp +++ b/Analyser/Static/DiskII/StaticAnalyser.cpp @@ -67,7 +67,7 @@ Analyser::Static::TargetList Analyser::Static::DiskII::GetTargets( // Grab track 0, sector 0: the boot sector. const auto track_zero = - disk->get_track_at_position(Storage::Disk::Track::Address(0, Storage::Disk::HeadPosition(0))); + disk->track_at_position(Storage::Disk::Track::Address(0, Storage::Disk::HeadPosition(0))); const auto sector_map = Storage::Encodings::AppleGCR::sectors_from_segment( Storage::Disk::track_serialisation(*track_zero, Storage::Time(1, 50000))); diff --git a/Analyser/Static/FAT12/StaticAnalyser.cpp b/Analyser/Static/FAT12/StaticAnalyser.cpp index 35db3c70e..2b6600e54 100644 --- a/Analyser/Static/FAT12/StaticAnalyser.cpp +++ b/Analyser/Static/FAT12/StaticAnalyser.cpp @@ -44,7 +44,7 @@ Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets( // Attempt to grab MFM track 0, sector 1: the boot sector. const auto track_zero = - disk->get_track_at_position(Storage::Disk::Track::Address(0, Storage::Disk::HeadPosition(0))); + disk->track_at_position(Storage::Disk::Track::Address(0, Storage::Disk::HeadPosition(0))); const auto sector_map = Storage::Encodings::MFM::sectors_from_segment( Storage::Disk::track_serialisation( *track_zero, diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme index dbea90fe3..1dec5b8a5 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme +++ b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme @@ -24,8 +24,8 @@ diff --git a/Storage/Disk/Disk.hpp b/Storage/Disk/Disk.hpp index 8bdacbeca..5bf4d526b 100644 --- a/Storage/Disk/Disk.hpp +++ b/Storage/Disk/Disk.hpp @@ -43,12 +43,12 @@ public: @returns the @c Track at @c position underneath @c head if there are any detectable events there; returns @c nullptr otherwise. */ - virtual std::shared_ptr get_track_at_position(Track::Address address) = 0; + virtual Track *track_at_position(Track::Address) = 0; /*! Replaces the Track at position @c position underneath @c head with @c track. Ignored if this disk is read-only. */ - virtual void set_track_at_position(Track::Address address, const std::shared_ptr &track) = 0; + virtual void set_track_at_position(Track::Address, const std::shared_ptr &) = 0; /*! Provides a hint that no further tracks are likely to be written for a while. diff --git a/Storage/Disk/DiskImage/DiskImage.hpp b/Storage/Disk/DiskImage/DiskImage.hpp index 08b0aaa9e..5bca222be 100644 --- a/Storage/Disk/DiskImage/DiskImage.hpp +++ b/Storage/Disk/DiskImage/DiskImage.hpp @@ -103,7 +103,7 @@ public: HeadPosition get_maximum_head_position(); int get_head_count(); - std::shared_ptr get_track_at_position(Track::Address address); + Track *track_at_position(Track::Address address); void set_track_at_position(Track::Address address, const std::shared_ptr &track); void flush_tracks(); bool get_is_read_only(); diff --git a/Storage/Disk/DiskImage/DiskImageImplementation.hpp b/Storage/Disk/DiskImage/DiskImageImplementation.hpp index 198dca7bd..c791a982c 100644 --- a/Storage/Disk/DiskImage/DiskImageImplementation.hpp +++ b/Storage/Disk/DiskImage/DiskImageImplementation.hpp @@ -42,18 +42,18 @@ template void DiskImageHolder::set_track_at_position(Track::Addr cached_tracks_[address] = track; } -template std::shared_ptr DiskImageHolder::get_track_at_position(Track::Address address) { +template Track *DiskImageHolder::track_at_position(Track::Address address) { if(address.head >= get_head_count()) return nullptr; if(address.position >= get_maximum_head_position()) return nullptr; const auto canonical_address = disk_image_.canonical_address(address); auto cached_track = cached_tracks_.find(canonical_address); - if(cached_track != cached_tracks_.end()) return cached_track->second; + if(cached_track != cached_tracks_.end()) return cached_track->second.get(); std::shared_ptr track = disk_image_.track_at_position(canonical_address); if(!track) return nullptr; cached_tracks_[canonical_address] = track; - return track; + return track.get(); } template DiskImageHolder::~DiskImageHolder() { diff --git a/Storage/Disk/Drive.cpp b/Storage/Disk/Drive.cpp index f6f25d4b8..f38ef4df1 100644 --- a/Storage/Disk/Drive.cpp +++ b/Storage/Disk/Drive.cpp @@ -8,8 +8,6 @@ #include "Drive.hpp" -#include "Track/UnformattedTrack.hpp" - #include #include #include @@ -107,7 +105,7 @@ void Drive::step(HeadPosition offset) { did_step(head_position_); } -std::shared_ptr Drive::step_to(HeadPosition offset) { +Track *Drive::step_to(HeadPosition offset) { HeadPosition old_head_position = head_position_; head_position_ = std::max(offset, HeadPosition(0)); @@ -343,8 +341,8 @@ void Drive::process_next_event() { // MARK: - Track management -std::shared_ptr Drive::get_track() { - if(disk_) return disk_->get_track_at_position(Track::Address(head_, head_position_)); +Track *Drive::get_track() { + if(disk_) return disk_->track_at_position(Track::Address(head_, head_position_)); return nullptr; } @@ -355,7 +353,7 @@ void Drive::set_track(const std::shared_ptr &track) { void Drive::setup_track() { track_ = get_track(); if(!track_) { - track_ = std::make_shared(); + track_ = &unformatted_track_; } float offset = 0.0f; @@ -426,11 +424,11 @@ void Drive::end_writing() { if(!patched_track_) { // Avoid creating a new patched track if this one is already patched - patched_track_ = std::dynamic_pointer_cast(track_); - if(!patched_track_ || !patched_track_->is_resampled_clone()) { - Track *const tr = track_.get(); +// patched_track_ = dynamic_cast(track_); +// if(!patched_track_ || !patched_track_->is_resampled_clone()) { + Track *const tr = track_; patched_track_.reset(PCMTrack::resampled_clone(tr, high_resolution_track_rate)); - } +// } } patched_track_->add_segment(write_start_time_, write_segment_, clamp_writing_to_index_hole_); cycles_since_index_hole_ %= cycles_per_revolution_; diff --git a/Storage/Disk/Drive.hpp b/Storage/Disk/Drive.hpp index 259133844..93e561f48 100644 --- a/Storage/Disk/Drive.hpp +++ b/Storage/Disk/Drive.hpp @@ -11,6 +11,7 @@ #include "Disk.hpp" #include "Track/PCMSegment.hpp" #include "Track/PCMTrack.hpp" +#include "Track/UnformattedTrack.hpp" #include "../TimedEventLoop.hpp" #include "../../Activity/Observer.hpp" @@ -174,7 +175,7 @@ public: It's for the benefit of user-optional fast-loading mechanisms **ONLY**. */ - std::shared_ptr step_to(HeadPosition offset); + Track *step_to(HeadPosition offset); /*! Alters the rotational velocity of this drive. @@ -209,7 +210,8 @@ private: // Drives contain an entire disk; from that a certain track // will be currently under the head. std::shared_ptr disk_; - std::shared_ptr track_; + UnformattedTrack unformatted_track_; + Track *track_ = nullptr; bool has_disk_ = false; // Contains the multiplier that converts between track-relative lengths @@ -274,7 +276,7 @@ private: /*! @returns the track underneath the current head at the location now stepped to. */ - std::shared_ptr get_track(); + Track *get_track(); /*! Attempts to set @c track as the track underneath the current head at the location now stepped to. diff --git a/Storage/Disk/Encodings/MFM/Parser.cpp b/Storage/Disk/Encodings/MFM/Parser.cpp index 7b1589dde..a0880e811 100644 --- a/Storage/Disk/Encodings/MFM/Parser.cpp +++ b/Storage/Disk/Encodings/MFM/Parser.cpp @@ -25,7 +25,7 @@ void Parser::install_track(const Storage::Disk::Track::Address &address) { return; } - const auto track = disk_->get_track_at_position(address); + const auto track = disk_->track_at_position(address); if(!track) { return; }