mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-30 04:50:08 +00:00
7b7beb13a3
The Disk II seems lower level than that; it will read the data bus whenever it likes, it is the programmer's responsibility to keep up with that. It also reserves the right not to load the bus regardless of whether it receives a read or write access.
49 lines
1.3 KiB
C++
49 lines
1.3 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]);
|
|
}
|
|
|
|
void DiskIICard::perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
|
if(address < 0x100) {
|
|
if(isReadOperation(operation)) *value = boot_[address];
|
|
} else {
|
|
// TODO: data input really shouldn't happen only upon a write.
|
|
diskii_.set_data_input(*value);
|
|
const int disk_value = diskii_.read_address(address);
|
|
if(isReadOperation(operation)) {
|
|
if(disk_value != diskii_.DidNotLoad)
|
|
*value = static_cast<uint8_t>(disk_value);
|
|
}
|
|
}
|
|
}
|
|
|
|
void DiskIICard::run_for(Cycles cycles, int stretches) {
|
|
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);
|
|
}
|