mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-12 15:31:09 +00:00
60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
//
|
|
// DiskII.cpp
|
|
// Clock Signal
|
|
//
|
|
// Created by Thomas Harte on 23/04/2018.
|
|
// Copyright 2018 Thomas Harte. All rights reserved.
|
|
//
|
|
|
|
#include "DiskIICard.hpp"
|
|
|
|
using namespace AppleII;
|
|
|
|
DiskIICard::DiskIICard(const ROMMachine::ROMFetcher &rom_fetcher, bool is_16_sector) {
|
|
auto roms = rom_fetcher(
|
|
"DiskII",
|
|
{
|
|
is_16_sector ? "boot-16.rom" : "boot-13.rom",
|
|
is_16_sector ? "state-machine-16.rom" : "state-machine-13.rom"
|
|
});
|
|
boot_ = std::move(*roms[0]);
|
|
diskii_.set_state_machine(*roms[1]);
|
|
set_select_constraints(None);
|
|
diskii_.set_sleep_observer(this);
|
|
}
|
|
|
|
void DiskIICard::perform_bus_operation(Select select, bool is_read, uint16_t address, uint8_t *value) {
|
|
diskii_.set_data_input(*value);
|
|
switch(select) {
|
|
default: break;
|
|
case IO: {
|
|
const int disk_value = diskii_.read_address(address);
|
|
if(is_read) {
|
|
if(disk_value != diskii_.DidNotLoad)
|
|
*value = static_cast<uint8_t>(disk_value);
|
|
}
|
|
} break;
|
|
case Device:
|
|
if(is_read) *value = boot_[address & 0xff];
|
|
break;
|
|
}
|
|
}
|
|
|
|
void DiskIICard::run_for(Cycles cycles, int stretches) {
|
|
if(diskii_is_sleeping_) return;
|
|
diskii_.run_for(Cycles(cycles.as_int() * 2));
|
|
}
|
|
|
|
void DiskIICard::set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk, int drive) {
|
|
diskii_.set_disk(disk, drive);
|
|
}
|
|
|
|
void DiskIICard::set_activity_observer(Activity::Observer *observer) {
|
|
diskii_.set_activity_observer(observer);
|
|
}
|
|
|
|
void DiskIICard::set_component_is_sleeping(Sleeper *component, bool is_sleeping) {
|
|
diskii_is_sleeping_ = is_sleeping;
|
|
set_select_constraints(is_sleeping ? (IO | Device) : 0);
|
|
}
|