2018-04-23 22:11:31 -07:00
|
|
|
//
|
|
|
|
// DiskII.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 23/04/2018.
|
2018-05-13 15:19:52 -04:00
|
|
|
// Copyright 2018 Thomas Harte. All rights reserved.
|
2018-04-23 22:11:31 -07: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-24 20:25:02 -07:00
|
|
|
is_16_sector ? "boot-16.rom" : "boot-13.rom",
|
|
|
|
is_16_sector ? "state-machine-16.rom" : "state-machine-13.rom"
|
2018-04-23 22:11:31 -07:00
|
|
|
});
|
|
|
|
boot_ = std::move(*roms[0]);
|
2018-04-24 08:29:05 -07:00
|
|
|
diskii_.set_state_machine(*roms[1]);
|
2018-04-23 22:11:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DiskIICard::perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
|
2018-05-08 22:05:43 -04:00
|
|
|
if(address < 0x100) {
|
|
|
|
if(isReadOperation(operation)) *value &= boot_[address];
|
2018-04-23 22:11:31 -07:00
|
|
|
} else {
|
2018-05-08 22:05:43 -04:00
|
|
|
if(isReadOperation(operation)) {
|
|
|
|
*value = diskii_.get_register(address);
|
|
|
|
} else {
|
|
|
|
diskii_.set_register(address, *value);
|
2018-04-23 22:11:31 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DiskIICard::run_for(Cycles cycles, int stretches) {
|
2018-04-24 08:29:05 -07:00
|
|
|
diskii_.run_for(Cycles(cycles.as_int() * 2));
|
2018-04-23 22:11:31 -07:00
|
|
|
}
|
2018-04-24 19:44:45 -07:00
|
|
|
|
|
|
|
void DiskIICard::set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk, int drive) {
|
|
|
|
diskii_.set_disk(disk, drive);
|
|
|
|
}
|
2018-05-10 22:17:13 -04:00
|
|
|
|
|
|
|
void DiskIICard::set_activity_observer(Activity::Observer *observer) {
|
|
|
|
diskii_.set_activity_observer(observer);
|
|
|
|
}
|