2018-04-24 05:11:31 +00:00
|
|
|
//
|
|
|
|
// DiskII.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 23/04/2018.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2018 Thomas Harte. All rights reserved.
|
2018-04-24 05:11:31 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#include "DiskIICard.hpp"
|
|
|
|
|
|
|
|
using namespace AppleII;
|
|
|
|
|
|
|
|
DiskIICard::DiskIICard(const ROMMachine::ROMFetcher &rom_fetcher, bool is_16_sector) {
|
|
|
|
auto roms = rom_fetcher(
|
|
|
|
"DiskII",
|
|
|
|
{
|
2018-04-25 03:25:02 +00:00
|
|
|
is_16_sector ? "boot-16.rom" : "boot-13.rom",
|
|
|
|
is_16_sector ? "state-machine-16.rom" : "state-machine-13.rom"
|
2018-04-24 05:11:31 +00:00
|
|
|
});
|
|
|
|
boot_ = std::move(*roms[0]);
|
2018-04-24 15:29:05 +00:00
|
|
|
diskii_.set_state_machine(*roms[1]);
|
2018-04-24 05:11:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DiskIICard::perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
2018-05-09 02:05:43 +00:00
|
|
|
if(address < 0x100) {
|
2018-05-14 02:36:02 +00:00
|
|
|
if(isReadOperation(operation)) *value = boot_[address];
|
2018-04-24 05:11:31 +00:00
|
|
|
} else {
|
2018-05-18 01:39:11 +00:00
|
|
|
// TODO: data input really shouldn't happen only upon a write.
|
|
|
|
diskii_.set_data_input(*value);
|
|
|
|
const int disk_value = diskii_.read_address(address);
|
2018-05-09 02:05:43 +00:00
|
|
|
if(isReadOperation(operation)) {
|
2018-05-18 01:39:11 +00:00
|
|
|
if(disk_value != diskii_.DidNotLoad)
|
|
|
|
*value = static_cast<uint8_t>(disk_value);
|
2018-04-24 05:11:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DiskIICard::run_for(Cycles cycles, int stretches) {
|
2018-04-24 15:29:05 +00:00
|
|
|
diskii_.run_for(Cycles(cycles.as_int() * 2));
|
2018-04-24 05:11:31 +00:00
|
|
|
}
|
2018-04-25 02:44:45 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|