1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-22 15:28:56 +00:00
CLK/Machines/Oric/BD500.cpp

64 lines
1.4 KiB
C++
Raw Normal View History

//
// BD500.cpp
// Clock Signal
//
// Created by Thomas Harte on 14/01/2020.
// Copyright © 2020 Thomas Harte. All rights reserved.
//
#include "BD500.hpp"
using namespace Oric;
BD500::BD500() : DiskController(P1793, 9000000) {
set_paged_item(PagedItem::DiskROM);
set_is_double_density(true);
}
void BD500::write(int address, uint8_t value) {
switch(address) {
case 0x0320: case 0x0321: case 0x0322: case 0x0323:
WD::WD1770::write(address, value);
break;
default:
printf("Write to %04x?\n", address);
break;
}
}
uint8_t BD500::read(int address) {
switch(address) {
case 0x0320: case 0x0321: case 0x0322: case 0x0323:
return WD::WD1770::read(address);
case 0x312: return (get_data_request_line() ? 0x80 : 0x00) | (get_interrupt_request_line() ? 0x40 : 0x00);
default:
printf("Read from %04x?\n", address);
break;
}
return 0xff;
}
void BD500::set_head_load_request(bool head_load) {
// Turn all motors on or off, and load the head instantly.
is_loading_head_ |= head_load;
for(auto &drive : drives_) {
if(drive) drive->set_motor_on(head_load);
}
if(!head_load) set_head_loaded(false);
}
void BD500::run_for(const Cycles cycles) {
// If a head load is in progress and the selected drive is now ready,
// declare head loaded.
if(is_loading_head_ && drives_[selected_drive_] && drives_[selected_drive_]->get_is_ready()) {
set_head_loaded(true);
is_loading_head_ = false;
}
WD::WD1770::run_for(cycles);
}