1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Introduced a test within the disk controller so as not to request illegal tracks from disks, instead automatically substituting an 'unformatted' track. Which is just empty.

This commit is contained in:
Thomas Harte 2017-08-15 21:52:12 -04:00
parent aefbafa18d
commit 6cfc3daacb
6 changed files with 74 additions and 6 deletions

View File

@ -121,6 +121,7 @@
4BAB62B51D327F7E00DF5BA0 /* G64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BAB62B31D327F7E00DF5BA0 /* G64.cpp */; };
4BAB62B81D3302CA00DF5BA0 /* PCMTrack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BAB62B61D3302CA00DF5BA0 /* PCMTrack.cpp */; };
4BACC5B11F3DFF7C0037C015 /* CharacterMapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BACC5AF1F3DFF7C0037C015 /* CharacterMapper.cpp */; };
4BAD9B961F43D7E900724854 /* UnformattedTrack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BAD9B941F43D7E900724854 /* UnformattedTrack.cpp */; };
4BB17D4E1ED7909F00ABD1E1 /* tests.expected.json in Resources */ = {isa = PBXBuildFile; fileRef = 4BB17D4C1ED7909F00ABD1E1 /* tests.expected.json */; };
4BB17D4F1ED7909F00ABD1E1 /* tests.in.json in Resources */ = {isa = PBXBuildFile; fileRef = 4BB17D4D1ED7909F00ABD1E1 /* tests.in.json */; };
4BB298F11B587D8400A49093 /* start in Resources */ = {isa = PBXBuildFile; fileRef = 4BB297E51B587D8300A49093 /* start */; };
@ -673,6 +674,8 @@
4BAB62B71D3302CA00DF5BA0 /* PCMTrack.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PCMTrack.hpp; sourceTree = "<group>"; };
4BACC5AF1F3DFF7C0037C015 /* CharacterMapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CharacterMapper.cpp; path = AmstradCPC/CharacterMapper.cpp; sourceTree = "<group>"; };
4BACC5B01F3DFF7C0037C015 /* CharacterMapper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CharacterMapper.hpp; path = AmstradCPC/CharacterMapper.hpp; sourceTree = "<group>"; };
4BAD9B941F43D7E900724854 /* UnformattedTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnformattedTrack.cpp; sourceTree = "<group>"; };
4BAD9B951F43D7E900724854 /* UnformattedTrack.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UnformattedTrack.hpp; sourceTree = "<group>"; };
4BB06B211F316A3F00600C7A /* ForceInline.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ForceInline.h; sourceTree = "<group>"; };
4BB17D4C1ED7909F00ABD1E1 /* tests.expected.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = tests.expected.json; path = FUSE/tests.expected.json; sourceTree = "<group>"; };
4BB17D4D1ED7909F00ABD1E1 /* tests.in.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = tests.in.json; path = FUSE/tests.in.json; sourceTree = "<group>"; };
@ -1552,6 +1555,7 @@
4B3F1B441E0388D200DB26EE /* PCMPatchedTrack.cpp */,
4B121F961E060CF000BFDA12 /* PCMSegment.cpp */,
4BAB62B61D3302CA00DF5BA0 /* PCMTrack.cpp */,
4BAD9B941F43D7E900724854 /* UnformattedTrack.cpp */,
4B0BE4271D3481E700D5256B /* DigitalPhaseLockedLoop.hpp */,
4BAB62AC1D3272D200DF5BA0 /* Disk.hpp */,
4B6C73BC1D387AE500AFCFCA /* DiskController.hpp */,
@ -1560,6 +1564,7 @@
4B3F1B451E0388D200DB26EE /* PCMPatchedTrack.hpp */,
4B121F971E060CF000BFDA12 /* PCMSegment.hpp */,
4BAB62B71D3302CA00DF5BA0 /* PCMTrack.hpp */,
4BAD9B951F43D7E900724854 /* UnformattedTrack.hpp */,
4BB697CF1D4BA44900248BDF /* Encodings */,
4BAB62B21D327F7E00DF5BA0 /* Formats */,
4B3FE75F1F3CF6BA00448EE4 /* Parsers */,
@ -2709,6 +2714,7 @@
4BD14B111D74627C0088EAD6 /* StaticAnalyser.cpp in Sources */,
4BBF99151C8FBA6F0075DAFB /* CRTOpenGL.cpp in Sources */,
4B95FA9D1F11893B0008E395 /* ZX8081OptionsPanel.swift in Sources */,
4BAD9B961F43D7E900724854 /* UnformattedTrack.cpp in Sources */,
4B0CCC451C62D0B3001CAC5F /* CRT.cpp in Sources */,
4B8378DC1F336631005CA9E4 /* CharacterMapper.cpp in Sources */,
4B8378E51F3378C4005CA9E4 /* CharacterMapper.cpp in Sources */,

View File

@ -28,6 +28,9 @@ void Disk::set_track_at_position(unsigned int head, unsigned int position, const
}
std::shared_ptr<Track> Disk::get_track_at_position(unsigned int head, unsigned int position) {
if(head >= get_head_count()) return nullptr;
if(position >= get_head_position_count()) return nullptr;
int address = get_id_for_track_at_position(head, position);
std::map<int, std::shared_ptr<Track>>::iterator cached_track = cached_tracks_.find(address);
if(cached_track != cached_tracks_.end()) return cached_track->second;

View File

@ -7,6 +7,7 @@
//
#include "DiskController.hpp"
#include "UnformattedTrack.hpp"
#include "../../NumberTheory/Factors.hpp"
#include <cassert>
@ -30,15 +31,17 @@ Controller::Controller(Cycles clock_rate, int clock_rate_multiplier, int revolut
void Controller::setup_track() {
track_ = drive_->get_track();
if(!track_) {
track_.reset(new UnformattedTrack);
}
Time offset;
Time track_time_now = get_time_into_track();
assert(track_time_now >= Time(0) && current_event_.length <= Time(1));
if(track_) {
Time time_found = track_->seek_to(track_time_now);
assert(time_found >= Time(0) && time_found <= track_time_now);
offset = track_time_now - time_found;
}
Time time_found = track_->seek_to(track_time_now);
assert(time_found >= Time(0) && time_found <= track_time_now);
offset = track_time_now - time_found;
get_next_event(offset);
}

View File

@ -9,7 +9,7 @@
#ifndef PCMPatchedTrack_hpp
#define PCMPatchedTrack_hpp
#include "PCMTrack.hpp"
#include "Disk.hpp"
#include "PCMSegment.hpp"
namespace Storage {

View File

@ -0,0 +1,26 @@
//
// UnformattedTrack.cpp
// Clock Signal
//
// Created by Thomas Harte on 15/08/2017.
// Copyright © 2017 Thomas Harte. All rights reserved.
//
#include "UnformattedTrack.hpp"
using namespace Storage::Disk;
Track::Event UnformattedTrack::get_next_event() {
Track::Event event;
event.type = Event::IndexHole;
event.length = Time(1);
return event;
}
Storage::Time UnformattedTrack::seek_to(const Time &time_since_index_hole) {
return Time(0);
}
Track *UnformattedTrack::clone() {
return new UnformattedTrack;
}

View File

@ -0,0 +1,30 @@
//
// UnformattedTrack.hpp
// Clock Signal
//
// Created by Thomas Harte on 15/08/2017.
// Copyright © 2017 Thomas Harte. All rights reserved.
//
#ifndef UnformattedTrack_hpp
#define UnformattedTrack_hpp
#include "Disk.hpp"
namespace Storage {
namespace Disk {
/*!
A subclass of @c Track with no contents. Just an index hole.
*/
class UnformattedTrack: public Track {
public:
Event get_next_event();
Time seek_to(const Time &time_since_index_hole);
Track *clone();
};
}
}
#endif /* UnformattedTrack_hpp */