mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +00:00
The MSX is now an activity source.
Completing the set.
This commit is contained in:
parent
3ba6b6f1ee
commit
d0fd4dd4db
@ -56,11 +56,12 @@ void DiskROM::run_for(HalfCycles half_cycles) {
|
||||
controller_cycles_ %= 715909;
|
||||
}
|
||||
|
||||
void DiskROM::set_disk(std::shared_ptr<Storage::Disk::Disk> disk, int drive) {
|
||||
void DiskROM::set_disk(std::shared_ptr<Storage::Disk::Disk> disk, size_t drive) {
|
||||
if(!drives_[drive]) {
|
||||
drives_[drive].reset(new Storage::Disk::Drive(8000000, 300, 2));
|
||||
drives_[drive]->set_head(selected_head_);
|
||||
if(drive == selected_drive_) set_drive(drives_[drive]);
|
||||
drives_[drive]->set_activity_observer(observer_, drive_name(drive), true);
|
||||
}
|
||||
drives_[drive]->set_disk(disk);
|
||||
}
|
||||
@ -69,3 +70,16 @@ void DiskROM::set_head_load_request(bool head_load) {
|
||||
// Magic!
|
||||
set_head_loaded(head_load);
|
||||
}
|
||||
|
||||
void DiskROM::set_activity_observer(Activity::Observer *observer) {
|
||||
size_t c = 0;
|
||||
observer_ = observer;
|
||||
for(auto &drive: drives_) {
|
||||
if(drive) drive->set_activity_observer(observer, drive_name(c), true);
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
std::string DiskROM::drive_name(size_t index) {
|
||||
return "Drive " + std::to_string(index);
|
||||
}
|
||||
|
@ -11,9 +11,12 @@
|
||||
|
||||
#include "ROMSlotHandler.hpp"
|
||||
|
||||
#include "../../Activity/Source.hpp"
|
||||
#include "../../Components/1770/1770.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace MSX {
|
||||
@ -26,17 +29,20 @@ class DiskROM: public ROMSlotHandler, public WD::WD1770 {
|
||||
uint8_t read(uint16_t address) override;
|
||||
void run_for(HalfCycles half_cycles) override;
|
||||
|
||||
void set_disk(std::shared_ptr<Storage::Disk::Disk> disk, int drive);
|
||||
void set_disk(std::shared_ptr<Storage::Disk::Disk> disk, size_t drive);
|
||||
void set_activity_observer(Activity::Observer *observer);
|
||||
|
||||
private:
|
||||
const std::vector<uint8_t> &rom_;
|
||||
|
||||
long int controller_cycles_ = 0;
|
||||
int selected_drive_ = 0;
|
||||
size_t selected_drive_ = 0;
|
||||
int selected_head_ = 0;
|
||||
std::shared_ptr<Storage::Disk::Drive> drives_[4];
|
||||
std::array<std::shared_ptr<Storage::Disk::Drive>, 2> drives_;
|
||||
|
||||
void set_head_load_request(bool head_load) override;
|
||||
std::string drive_name(size_t index);
|
||||
Activity::Observer *observer_ = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "../../Storage/Tape/Parsers/MSX.hpp"
|
||||
#include "../../Storage/Tape/Tape.hpp"
|
||||
|
||||
#include "../../Activity/Source.hpp"
|
||||
#include "../CRTMachine.hpp"
|
||||
#include "../ConfigurationTarget.hpp"
|
||||
#include "../KeyboardMachine.hpp"
|
||||
@ -87,7 +88,8 @@ class ConcreteMachine:
|
||||
public KeyboardMachine::Machine,
|
||||
public Configurable::Device,
|
||||
public MemoryMap,
|
||||
public Sleeper::SleepObserver {
|
||||
public Sleeper::SleepObserver,
|
||||
public Activity::Source {
|
||||
public:
|
||||
ConcreteMachine():
|
||||
z80_(*this),
|
||||
@ -200,14 +202,16 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
if(!media.disks.empty()) {
|
||||
DiskROM *disk_rom = dynamic_cast<DiskROM *>(memory_slots_[2].handler.get());
|
||||
int drive = 0;
|
||||
DiskROM *disk_rom = get_disk_rom();
|
||||
if(disk_rom) {
|
||||
size_t drive = 0;
|
||||
for(auto &disk : media.disks) {
|
||||
disk_rom->set_disk(disk, drive);
|
||||
drive++;
|
||||
if(drive == 2) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set_use_fast_tape();
|
||||
|
||||
@ -556,7 +560,18 @@ class ConcreteMachine:
|
||||
set_use_fast_tape();
|
||||
}
|
||||
|
||||
// MARK: - Activity::Source
|
||||
void set_activity_observer(Activity::Observer *observer) override {
|
||||
DiskROM *disk_rom = get_disk_rom();
|
||||
if(disk_rom) {
|
||||
disk_rom->set_activity_observer(observer);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
DiskROM *get_disk_rom() {
|
||||
return dynamic_cast<DiskROM *>(memory_slots_[2].handler.get());
|
||||
}
|
||||
void update_audio() {
|
||||
speaker_.run_for(audio_queue_, time_since_ay_update_.divide_cycles(Cycles(2)));
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ void Microdisc::set_disk(std::shared_ptr<Storage::Disk::Disk> disk, size_t drive
|
||||
if(!drives_[drive]) {
|
||||
drives_[drive].reset(new Storage::Disk::Drive(8000000, 300, 2));
|
||||
if(drive == selected_drive_) set_drive(drives_[drive]);
|
||||
drives_[drive]->set_activity_observer(observer_, "Drive" + std::to_string(drive), false);
|
||||
drives_[drive]->set_activity_observer(observer_, drive_name(drive), false);
|
||||
}
|
||||
drives_[drive]->set_disk(disk);
|
||||
}
|
||||
@ -132,7 +132,11 @@ void Microdisc::set_activity_observer(Activity::Observer *observer) {
|
||||
}
|
||||
size_t c = 0;
|
||||
for(auto &drive : drives_) {
|
||||
if(drive) drive->set_activity_observer(observer, "Drive" + std::to_string(c), false);
|
||||
if(drive) drive->set_activity_observer(observer, drive_name(c), false);
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Microdisc::drive_name(size_t index) {
|
||||
return "Drive " + std::to_string(index);
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ class Microdisc: public WD::WD1770 {
|
||||
Delegate *delegate_ = nullptr;
|
||||
uint8_t last_control_ = 0;
|
||||
Activity::Observer *observer_ = nullptr;
|
||||
|
||||
std::string drive_name(size_t index);
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user