diff --git a/Machines/PCCompatible/PCCompatible.cpp b/Machines/PCCompatible/PCCompatible.cpp index 55ab27e77..3e4646460 100644 --- a/Machines/PCCompatible/PCCompatible.cpp +++ b/Machines/PCCompatible/PCCompatible.cpp @@ -110,10 +110,10 @@ template class FloppyController { public: FloppyController( - PIC &pic, + PICs &pics, DMA &dma, int drive_count - ) : pic_(pic), dma_(dma) { + ) : pics_(pics), dma_(dma) { // Default: one floppy drive only. for(int c = 0; c < 4; c++) { drives_[c].exists = drive_count > c; @@ -146,7 +146,7 @@ public: } hold_reset_ = hold_reset; if(hold_reset_) { - pic_.template apply_edge<6>(false); + pics_.pic[0].template apply_edge<6>(false); } } @@ -182,7 +182,7 @@ public: // TODO: what if head has changed? drives_[decoder_.target().drive].status = decoder_.drive_head(); drives_[decoder_.target().drive].raised_interrupt = true; - pic_.template apply_edge<6>(true); + pics_.pic[0].template apply_edge<6>(true); } break; case Command::ReadDeletedData: @@ -243,22 +243,24 @@ public: // TODO: what if head has changed? drives_[decoder_.target().drive].status = decoder_.drive_head(); drives_[decoder_.target().drive].raised_interrupt = true; - pic_.template apply_edge<6>(true); + pics_.pic[0].template apply_edge<6>(true); } break; case Command::Recalibrate: drives_[decoder_.target().drive].track = 0; drives_[decoder_.target().drive].raised_interrupt = true; - drives_[decoder_.target().drive].status = decoder_.target().drive | uint8_t(Intel::i8272::Status0::SeekEnded); - pic_.template apply_edge<6>(true); + drives_[decoder_.target().drive].status = + decoder_.target().drive | uint8_t(Intel::i8272::Status0::SeekEnded); + pics_.pic[0].template apply_edge<6>(true); break; case Command::Seek: drives_[decoder_.target().drive].track = decoder_.seek_target(); drives_[decoder_.target().drive].raised_interrupt = true; - drives_[decoder_.target().drive].status = decoder_.drive_head() | uint8_t(Intel::i8272::Status0::SeekEnded); - pic_.template apply_edge<6>(true); + drives_[decoder_.target().drive].status = + decoder_.drive_head() | uint8_t(Intel::i8272::Status0::SeekEnded); + pics_.pic[0].template apply_edge<6>(true); break; case Command::SenseInterruptStatus: { @@ -276,7 +278,7 @@ public: any_remaining_interrupts |= drives_[c].raised_interrupt; } if(!any_remaining_interrupts) { - pic_.template apply_edge<6>(false); + pics_.pic[0].template apply_edge<6>(false); } } break; case Command::Specify: @@ -330,7 +332,7 @@ public: // // TODO: drive should only transition to unready if it was ready in the first place. // drives_[drive].status = uint8_t(Intel::i8272::Status0::BecameNotReady); // drives_[drive].raised_interrupt = true; -// pic_.apply_edge<6>(true); +// pics_.pic[0].apply_edge<6>(true); // } drives_[drive].set_disk(disk); } @@ -348,14 +350,14 @@ private: drives_[c].raised_interrupt = true; drives_[c].status = uint8_t(Intel::i8272::Status0::BecameNotReady); } - pic_.template apply_edge<6>(true); + pics_.pic[0].template apply_edge<6>(true); using MainStatus = Intel::i8272::MainStatus; status_.set(MainStatus::DataReady, true); status_.set(MainStatus::DataIsToProcessor, false); } - PIC &pic_; + PICs &pics_; DMA &dma_; bool hold_reset_ = false; @@ -405,7 +407,7 @@ class KeyboardController; template class KeyboardController> { public: - KeyboardController(PIC &pic, PCSpeaker &) : pic_(pic) {} + KeyboardController(PICs &pics, PCSpeaker &) : pics_(pics) {} // KB Status Port 61h high bits: //; 01 - normal operation. wait for keypress, when one comes in, @@ -422,13 +424,13 @@ public: switch(mode_) { case Mode::NormalOperation: break; case Mode::NoIRQsIgnoreInput: - pic_.template apply_edge<1>(false); + pics_.pic[0].template apply_edge<1>(false); break; case Mode::Reset: input_.clear(); [[fallthrough]]; case Mode::ClearIRQReset: - pic_.template apply_edge<1>(false); + pics_.pic[0].template apply_edge<1>(false); break; } @@ -450,7 +452,7 @@ public: } uint8_t read() { - pic_.template apply_edge<1>(false); + pics_.pic[0].template apply_edge<1>(false); if(input_.empty()) { return 0; } @@ -458,7 +460,7 @@ public: const uint8_t key = input_.front(); input_.erase(input_.begin()); if(!input_.empty()) { - pic_.template apply_edge<1>(true); + pics_.pic[0].template apply_edge<1>(true); } return key; } @@ -468,7 +470,7 @@ public: return; } input_.push_back(value); - pic_.template apply_edge<1>(true); + pics_.pic[0].template apply_edge<1>(true); } private: @@ -480,7 +482,7 @@ private: } mode_; std::vector input_; - PIC &pic_; + PICs &pics_; int reset_delay_ = 0; }; @@ -488,7 +490,7 @@ private: template class KeyboardController> { public: - KeyboardController(PIC &pic, PCSpeaker &speaker) : pic_(pic), speaker_(speaker) {} + KeyboardController(PICs &pics, PCSpeaker &speaker) : pics_(pics), speaker_(speaker) {} void run_for([[maybe_unused]] const Cycles cycles) { } @@ -529,7 +531,7 @@ public: } private: - PIC &pic_; + PICs &pics_; PCSpeaker &speaker_; uint8_t refresh_toggle_ = 0; }; @@ -537,7 +539,7 @@ private: template class PITObserver { public: - PITObserver(PIC &pic, PCSpeaker &speaker) : pic_(pic), speaker_(speaker) {} + PITObserver(PICs &pics, PCSpeaker &speaker) : pics_(pics), speaker_(speaker) {} template void update_output(const bool new_level) { @@ -546,13 +548,13 @@ public: // channel 2 is gated by a PPI output and feeds into the speaker. switch(channel) { default: break; - case 0: pic_.template apply_edge<0>(new_level); break; - case 2: speaker_.set_pit(new_level); break; + case 0: pics_.pic[0].template apply_edge<0>(new_level); break; + case 2: speaker_.set_pit(new_level); break; } } private: - PIC &pic_; + PICs &pics_; PCSpeaker &speaker_; }; @@ -668,13 +670,13 @@ public: PIT &pit, DMA &dma, PPI &ppi, - PIC &pic, + PICs &pics, typename Adaptor