1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-02 20:30:00 +00:00

Renamed class, intending to turn a Disk::Drive into literally just that, and have a thing with a PLL that consumes events be a Controller.

This commit is contained in:
Thomas Harte 2016-09-25 20:05:56 -04:00
parent 7f4c78139c
commit 9bbcbd1001
10 changed files with 39 additions and 41 deletions

View File

@ -12,7 +12,7 @@
using namespace WD;
WD1770::WD1770() :
Storage::Disk::Drive(8000000, 1, 300),
Storage::Disk::Controller(8000000, 1, 300),
status_(0),
interesting_event_mask_(Event::Command),
resume_point_(0),
@ -60,7 +60,7 @@ uint8_t WD1770::get_register(int address)
void WD1770::run_for_cycles(unsigned int number_of_cycles)
{
if(status_ & Flag::MotorOn) Storage::Disk::Drive::run_for_cycles((int)number_of_cycles);
if(status_ & Flag::MotorOn) Storage::Disk::Controller::run_for_cycles((int)number_of_cycles);
if(delay_time_)
{

View File

@ -9,11 +9,11 @@
#ifndef _770_hpp
#define _770_hpp
#include "../../Storage/Disk/DiskDrive.hpp"
#include "../../Storage/Disk/DiskController.hpp"
namespace WD {
class WD1770: public Storage::Disk::Drive {
class WD1770: public Storage::Disk::Controller {
public:
WD1770();

View File

@ -14,7 +14,7 @@ using namespace Commodore::C1540;
Machine::Machine() :
_shift_register(0),
Storage::Disk::Drive(1000000, 4, 300)
Storage::Disk::Controller(1000000, 4, 300)
{
// create a serial port and a VIA to run it
_serialPortVIA.reset(new SerialPortVIA);
@ -106,7 +106,7 @@ void Machine::run_for_cycles(int number_of_cycles)
{
CPU6502::Processor<Machine>::run_for_cycles(number_of_cycles);
if(_driveVIA.get_motor_enabled()) // TODO: motor speed up/down
Storage::Disk::Drive::run_for_cycles(number_of_cycles);
Storage::Disk::Controller::run_for_cycles(number_of_cycles);
}
#pragma mark - 6522 delegate

View File

@ -15,7 +15,7 @@
#include "../SerialBus.hpp"
#include "../../../Storage/Disk/Disk.hpp"
#include "../../../Storage/Disk/DiskDrive.hpp"
#include "../../../Storage/Disk/DiskController.hpp"
namespace Commodore {
namespace C1540 {
@ -216,7 +216,7 @@ class Machine:
public CPU6502::Processor<Machine>,
public MOS::MOS6522IRQDelegate::Delegate,
public DriveVIA::Delegate,
public Storage::Disk::Drive {
public Storage::Disk::Controller {
public:
Machine();

View File

@ -318,9 +318,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
case 0xfc00:
if(_wd1770 && (address&0x00f0) == 0x00c0)
{
if(isReadOperation(operation))
*value = 1;
else
if(!isReadOperation(operation))
{
// TODO:
// bit 0 => enable or disable drive 1

View File

@ -45,7 +45,7 @@
4B69FB3D1C4D908A00B5F0AA /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B69FB3B1C4D908A00B5F0AA /* Tape.cpp */; };
4B69FB441C4D941400B5F0AA /* TapeUEF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B69FB421C4D941400B5F0AA /* TapeUEF.cpp */; };
4B69FB461C4D950F00B5F0AA /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B69FB451C4D950F00B5F0AA /* libz.tbd */; };
4B6C73BD1D387AE500AFCFCA /* DiskDrive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B6C73BB1D387AE500AFCFCA /* DiskDrive.cpp */; };
4B6C73BD1D387AE500AFCFCA /* DiskController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B6C73BB1D387AE500AFCFCA /* DiskController.cpp */; };
4B73C71A1D036BD90074D992 /* Vic20Document.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B73C7191D036BD90074D992 /* Vic20Document.swift */; };
4B73C71D1D036C030074D992 /* Vic20Document.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B73C71B1D036C030074D992 /* Vic20Document.xib */; };
4B92EACA1B7C112B00246143 /* 6502TimingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B92EAC91B7C112B00246143 /* 6502TimingTests.swift */; };
@ -457,8 +457,8 @@
4B69FB421C4D941400B5F0AA /* TapeUEF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TapeUEF.cpp; sourceTree = "<group>"; };
4B69FB431C4D941400B5F0AA /* TapeUEF.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TapeUEF.hpp; sourceTree = "<group>"; };
4B69FB451C4D950F00B5F0AA /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
4B6C73BB1D387AE500AFCFCA /* DiskDrive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DiskDrive.cpp; sourceTree = "<group>"; };
4B6C73BC1D387AE500AFCFCA /* DiskDrive.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DiskDrive.hpp; sourceTree = "<group>"; };
4B6C73BB1D387AE500AFCFCA /* DiskController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DiskController.cpp; sourceTree = "<group>"; };
4B6C73BC1D387AE500AFCFCA /* DiskController.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DiskController.hpp; sourceTree = "<group>"; };
4B73C7191D036BD90074D992 /* Vic20Document.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Vic20Document.swift; sourceTree = "<group>"; };
4B73C71C1D036C030074D992 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = "Clock Signal/Base.lproj/Vic20Document.xib"; sourceTree = SOURCE_ROOT; };
4B92EAC91B7C112B00246143 /* 6502TimingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 6502TimingTests.swift; sourceTree = "<group>"; };
@ -1115,11 +1115,11 @@
children = (
4B0BE4261D3481E700D5256B /* DigitalPhaseLockedLoop.cpp */,
4BAB62AB1D3272D200DF5BA0 /* Disk.cpp */,
4B6C73BB1D387AE500AFCFCA /* DiskDrive.cpp */,
4B6C73BB1D387AE500AFCFCA /* DiskController.cpp */,
4BAB62B61D3302CA00DF5BA0 /* PCMTrack.cpp */,
4B0BE4271D3481E700D5256B /* DigitalPhaseLockedLoop.hpp */,
4BAB62AC1D3272D200DF5BA0 /* Disk.hpp */,
4B6C73BC1D387AE500AFCFCA /* DiskDrive.hpp */,
4B6C73BC1D387AE500AFCFCA /* DiskController.hpp */,
4BAB62B71D3302CA00DF5BA0 /* PCMTrack.hpp */,
4BB697CF1D4BA44900248BDF /* Encodings */,
4BAB62B21D327F7E00DF5BA0 /* Formats */,
@ -2137,7 +2137,7 @@
4BD468F71D8DF41D0084958B /* 1770.cpp in Sources */,
4BBF99141C8FBA6F0075DAFB /* CRTInputBufferBuilder.cpp in Sources */,
4B2409551C45AB05004DA684 /* Speaker.cpp in Sources */,
4B6C73BD1D387AE500AFCFCA /* DiskDrive.cpp in Sources */,
4B6C73BD1D387AE500AFCFCA /* DiskController.cpp in Sources */,
4B643F3A1D77AD1900D431D6 /* CSStaticAnalyser.mm in Sources */,
4B4DC8281D2C2470003C5BF8 /* C1540.cpp in Sources */,
4B1E85751D170228001EF87D /* Typer.cpp in Sources */,

View File

@ -7,17 +7,17 @@
//
#include "Disk.hpp"
#include "../../Storage/Disk/DiskDrive.hpp"
#include "../../Storage/Disk/DiskController.hpp"
#include "../../Storage/Disk/Encodings/MFM.hpp"
#include "../../NumberTheory/CRC.hpp"
#include <algorithm>
using namespace StaticAnalyser::Acorn;
class FMParser: public Storage::Disk::Drive {
class FMParser: public Storage::Disk::Controller {
public:
FMParser(bool is_mfm) :
Storage::Disk::Drive(4000000, 1, 300),
Storage::Disk::Controller(4000000, 1, 300),
crc_generator_(0x1021, 0xffff),
shift_register_(0), track_(0), is_mfm_(is_mfm)
{

View File

@ -7,7 +7,7 @@
//
#include "Disk.hpp"
#include "../../Storage/Disk/DiskDrive.hpp"
#include "../../Storage/Disk/DiskController.hpp"
#include "../../Storage/Disk/Encodings/CommodoreGCR.hpp"
#include "Utilities.hpp"
@ -17,9 +17,9 @@
using namespace StaticAnalyser::Commodore;
class CommodoreGCRParser: public Storage::Disk::Drive {
class CommodoreGCRParser: public Storage::Disk::Controller {
public:
CommodoreGCRParser() : Storage::Disk::Drive(4000000, 1, 300), shift_register_(0), track_(1)
CommodoreGCRParser() : Storage::Disk::Controller(4000000, 1, 300), shift_register_(0), track_(1)
{
// Make sure this drive really is at track '1'.
while(!get_is_track_zero()) step(-1);

View File

@ -1,16 +1,16 @@
//
// DiskDrive.cpp
// DiskController.cpp
// Clock Signal
//
// Created by Thomas Harte on 14/07/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#include "DiskDrive.hpp"
#include "DiskController.hpp"
using namespace Storage::Disk;
Drive::Drive(unsigned int clock_rate, unsigned int clock_rate_multiplier, unsigned int revolutions_per_minute) :
Controller::Controller(unsigned int clock_rate, unsigned int clock_rate_multiplier, unsigned int revolutions_per_minute) :
_clock_rate(clock_rate * clock_rate_multiplier),
_clock_rate_multiplier(clock_rate_multiplier),
_head_position(0),
@ -22,7 +22,7 @@ Drive::Drive(unsigned int clock_rate, unsigned int clock_rate_multiplier, unsign
_rotational_multiplier.simplify();
}
void Drive::set_expected_bit_length(Time bit_length)
void Controller::set_expected_bit_length(Time bit_length)
{
_bit_length = bit_length;
@ -33,23 +33,23 @@ void Drive::set_expected_bit_length(Time bit_length)
_pll->set_delegate(this);
}
void Drive::set_disk(std::shared_ptr<Disk> disk)
void Controller::set_disk(std::shared_ptr<Disk> disk)
{
_disk = disk;
set_track(Time());
}
bool Drive::has_disk()
bool Controller::has_disk()
{
return (bool)_disk;
}
bool Drive::get_is_track_zero()
bool Controller::get_is_track_zero()
{
return _head_position == 0;
}
void Drive::step(int direction)
void Controller::step(int direction)
{
_head_position = std::max(_head_position + direction, 0);
Time extra_time = get_time_into_next_event() / _rotational_multiplier;
@ -58,7 +58,7 @@ void Drive::step(int direction)
set_track(_time_into_track);
}
void Drive::set_track(Time initial_offset)
void Controller::set_track(Time initial_offset)
{
_track = _disk->get_track_at_position(0, (unsigned int)_head_position);
// TODO: probably a better implementation of the empty track?
@ -80,7 +80,7 @@ void Drive::set_track(Time initial_offset)
reset_timer_to_offset(offset * _rotational_multiplier);
}
void Drive::run_for_cycles(int number_of_cycles)
void Controller::run_for_cycles(int number_of_cycles)
{
if(has_disk())
{
@ -99,7 +99,7 @@ void Drive::run_for_cycles(int number_of_cycles)
#pragma mark - Track timed event loop
void Drive::get_next_event()
void Controller::get_next_event()
{
if(_track)
_current_event = _track->get_next_event();
@ -115,7 +115,7 @@ void Drive::get_next_event()
set_next_event_time_interval(_current_event.length * _rotational_multiplier);
}
void Drive::process_next_event()
void Controller::process_next_event()
{
switch(_current_event.type)
{
@ -134,7 +134,7 @@ void Drive::process_next_event()
#pragma mark - PLL delegate
void Drive::digital_phase_locked_loop_output_bit(int value)
void Controller::digital_phase_locked_loop_output_bit(int value)
{
process_input_bit(value, _cycles_since_index_hole);
}

View File

@ -1,13 +1,13 @@
//
// DiskDrive.hpp
// DiskController.hpp
// Clock Signal
//
// Created by Thomas Harte on 14/07/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#ifndef DiskDrive_hpp
#define DiskDrive_hpp
#ifndef Storage_Disk_Controller_hpp
#define Storage_Disk_Controller_hpp
#include "Disk.hpp"
#include "DigitalPhaseLockedLoop.hpp"
@ -27,13 +27,13 @@ namespace Disk {
TODO: double sided disks, communication of head size and permissible stepping extents, appropriate
simulation of gain.
*/
class Drive: public DigitalPhaseLockedLoop::Delegate, public TimedEventLoop {
class Controller: public DigitalPhaseLockedLoop::Delegate, public TimedEventLoop {
public:
/*!
Constructs a @c DiskDrive that will be run at @c clock_rate and runs its PLL at @c clock_rate*clock_rate_multiplier,
spinning inserted disks at @c revolutions_per_minute.
*/
Drive(unsigned int clock_rate, unsigned int clock_rate_multiplier, unsigned int revolutions_per_minute);
Controller(unsigned int clock_rate, unsigned int clock_rate_multiplier, unsigned int revolutions_per_minute);
/*!
Communicates to the PLL the expected length of a bit as a fraction of a second.