2020-01-15 03:23:00 +00:00
|
|
|
//
|
|
|
|
// DiskController.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 14/01/2020.
|
|
|
|
// Copyright © 2020 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef DiskController_h
|
|
|
|
#define DiskController_h
|
|
|
|
|
|
|
|
namespace Oric {
|
|
|
|
|
|
|
|
class DiskController: public WD::WD1770 {
|
|
|
|
public:
|
2020-01-17 02:34:57 +00:00
|
|
|
DiskController(WD::WD1770::Personality personality, int clock_rate, Storage::Disk::Drive::ReadyType ready_type) :
|
2020-02-12 02:59:13 +00:00
|
|
|
WD::WD1770(personality), clock_rate_(clock_rate), ready_type_(ready_type) {
|
|
|
|
emplace_drives(4, clock_rate_, 300, 2, ready_type_);
|
|
|
|
// TODO: don't assume four drives?
|
|
|
|
}
|
2020-01-15 03:23:00 +00:00
|
|
|
|
|
|
|
void set_disk(std::shared_ptr<Storage::Disk::Disk> disk, int d) {
|
2020-02-12 02:59:13 +00:00
|
|
|
get_drive(size_t(d)).set_disk(disk);
|
2020-01-15 03:23:00 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 03:53:27 +00:00
|
|
|
enum class PagedItem {
|
|
|
|
DiskROM,
|
|
|
|
BASIC,
|
|
|
|
RAM
|
2020-01-15 03:23:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Delegate: public WD1770::Delegate {
|
2020-01-15 03:53:27 +00:00
|
|
|
virtual void disk_controller_did_change_paged_item(DiskController *controller) = 0;
|
2020-01-15 03:23:00 +00:00
|
|
|
};
|
|
|
|
inline void set_delegate(Delegate *delegate) {
|
|
|
|
delegate_ = delegate;
|
|
|
|
WD1770::set_delegate(delegate);
|
2020-01-15 03:53:27 +00:00
|
|
|
if(delegate) delegate->disk_controller_did_change_paged_item(this);
|
2020-01-15 03:23:00 +00:00
|
|
|
}
|
2020-01-15 03:53:27 +00:00
|
|
|
inline PagedItem get_paged_item() {
|
|
|
|
return paged_item_;
|
2020-01-15 03:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2020-01-15 03:53:27 +00:00
|
|
|
Delegate *delegate_ = nullptr;
|
2020-01-15 03:23:00 +00:00
|
|
|
|
2020-07-30 01:06:41 +00:00
|
|
|
void set_paged_item(PagedItem item) {
|
|
|
|
if(paged_item_ == item) return;
|
|
|
|
paged_item_ = item;
|
|
|
|
if(delegate_) {
|
|
|
|
delegate_->disk_controller_did_change_paged_item(this);
|
2020-01-16 04:15:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-15 03:23:00 +00:00
|
|
|
private:
|
2020-01-15 03:53:27 +00:00
|
|
|
PagedItem paged_item_ = PagedItem::DiskROM;
|
2020-01-15 03:23:00 +00:00
|
|
|
int clock_rate_;
|
2020-01-17 02:34:57 +00:00
|
|
|
Storage::Disk::Drive::ReadyType ready_type_;
|
2020-01-15 03:23:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* DiskController_h */
|