1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-02 02:49:28 +00:00
CLK/Machines/AppleII/DiskIICard.cpp

49 lines
1.3 KiB
C++
Raw Normal View History

//
// 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) {
2018-05-14 02:36:02 +00:00
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);
}
2018-05-11 02:17:13 +00:00
void DiskIICard::set_activity_observer(Activity::Observer *observer) {
diskii_.set_activity_observer(observer);
}