2020-01-15 03:23:00 +00:00
|
|
|
//
|
2020-01-15 04:15:27 +00:00
|
|
|
// BD500.cpp
|
2020-01-15 03:23:00 +00:00
|
|
|
// Clock Signal
|
|
|
|
//
|
2020-01-15 04:15:27 +00:00
|
|
|
// Created by Thomas Harte on 14/01/2020.
|
2020-01-15 03:23:00 +00:00
|
|
|
// Copyright © 2020 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2020-01-15 04:15:27 +00:00
|
|
|
#include "BD500.hpp"
|
2020-01-15 03:23:00 +00:00
|
|
|
|
|
|
|
using namespace Oric;
|
|
|
|
|
2020-01-15 04:15:27 +00:00
|
|
|
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;
|
2020-01-15 04:24:11 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
printf("Write to %04x?\n", address);
|
|
|
|
break;
|
2020-01-15 04:15:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t BD500::read(int address) {
|
|
|
|
switch(address) {
|
|
|
|
case 0x0320: case 0x0321: case 0x0322: case 0x0323:
|
|
|
|
return WD::WD1770::read(address);
|
2020-01-15 04:24:11 +00:00
|
|
|
|
|
|
|
case 0x312: return (get_data_request_line() ? 0x80 : 0x00) | (get_interrupt_request_line() ? 0x40 : 0x00);
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("Read from %04x?\n", address);
|
|
|
|
break;
|
2020-01-15 04:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BD500::set_head_load_request(bool head_load) {
|
|
|
|
// Turn all motors on or off, and load the head instantly.
|
2020-01-15 04:45:36 +00:00
|
|
|
is_loading_head_ |= head_load;
|
2020-01-15 04:15:27 +00:00
|
|
|
for(auto &drive : drives_) {
|
|
|
|
if(drive) drive->set_motor_on(head_load);
|
|
|
|
}
|
2020-01-15 04:45:36 +00:00
|
|
|
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);
|
2020-01-15 04:15:27 +00:00
|
|
|
}
|