1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Switches drives 0 and 1.

This commit is contained in:
Thomas Harte 2019-06-10 14:58:39 -04:00
parent 9230969f43
commit 3c075e9542

View File

@ -61,7 +61,7 @@ uint8_t IWM::read(int address) {
case ENABLE: /* Read data register. */ case ENABLE: /* Read data register. */
if(data_register_ & 0x80) { if(data_register_ & 0x80) {
printf("[%02x] ", data_register_); printf("[%02x] ", data_register_);
data_register_ = 0; // data_register_ = 0;
} }
printf("Reading data register\n"); printf("Reading data register\n");
return data_register_; return data_register_;
@ -212,6 +212,7 @@ void IWM::access(int address) {
// defined at the top of this file — CA0, CA1, etc. // defined at the top of this file — CA0, CA1, etc.
address &= 0xf; address &= 0xf;
const auto mask = 1 << (address >> 1); const auto mask = 1 << (address >> 1);
const auto old_state = state_;
// printf("[(%02x) %c%c%c%c ", mask, (state_ & CA2) ? '2' : '-', (state_ & CA1) ? '1' : '-', (state_ & CA0) ? '0' : '-', (state_ & SEL) ? 'S' : '-'); // printf("[(%02x) %c%c%c%c ", mask, (state_ & CA2) ? '2' : '-', (state_ & CA1) ? '1' : '-', (state_ & CA0) ? '0' : '-', (state_ & SEL) ? 'S' : '-');
if(address & 1) { if(address & 1) {
@ -222,13 +223,17 @@ void IWM::access(int address) {
// printf("-> %c%c%c%c] ", (state_ & CA2) ? '2' : '-', (state_ & CA1) ? '1' : '-', (state_ & CA0) ? '0' : '-', (state_ & SEL) ? 'S' : '-'); // printf("-> %c%c%c%c] ", (state_ & CA2) ? '2' : '-', (state_ & CA1) ? '1' : '-', (state_ & CA0) ? '0' : '-', (state_ & SEL) ? 'S' : '-');
// React appropriately to motor requests and to LSTRB register writes. // React appropriately to motor requests and to LSTRB register writes.
if(old_state != state_) {
switch(mask) { switch(mask) {
default: break; default: break;
case LSTRB: case LSTRB:
if(address & 1) { // Catch high-to-low LSTRB transitions.
if(!(address & 1)) {
switch(state_ & (CA1 | CA0 | SEL)) { switch(state_ & (CA1 | CA0 | SEL)) {
default: break; default:
printf("Unhandled LSTRB\n");
break;
case 0: case 0:
printf("LSTRB Set stepping direction: %d\n", state_ & CA2); printf("LSTRB Set stepping direction: %d\n", state_ & CA2);
@ -265,7 +270,7 @@ void IWM::access(int address) {
break; break;
case DRIVESEL: { case DRIVESEL: {
const int new_drive = (address & 1)^1; const int new_drive = address & 1;
if(new_drive != active_drive_) { if(new_drive != active_drive_) {
if(drives_[active_drive_]) drives_[active_drive_]->set_motor_on(false); if(drives_[active_drive_]) drives_[active_drive_]->set_motor_on(false);
active_drive_ = new_drive; active_drive_ = new_drive;
@ -274,6 +279,7 @@ void IWM::access(int address) {
} break; } break;
} }
} }
}
void IWM::set_select(bool enabled) { void IWM::set_select(bool enabled) {
// Store SEL as an extra state bit. // Store SEL as an extra state bit.