mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-23 03:32:32 +00:00
Introduced a master 'is sleeping' flag. I'm starting to think there's a pattern forming here.
This commit is contained in:
parent
8ce46b6e49
commit
2d9efccc98
@ -91,6 +91,8 @@ i8272::i8272(BusHandler &bus_handler, Cycles clock_rate, int clock_rate_multipli
|
|||||||
void i8272::run_for(Cycles cycles) {
|
void i8272::run_for(Cycles cycles) {
|
||||||
Storage::Disk::MFMController::run_for(cycles);
|
Storage::Disk::MFMController::run_for(cycles);
|
||||||
|
|
||||||
|
if(is_sleeping_) return;
|
||||||
|
|
||||||
// check for an expired timer
|
// check for an expired timer
|
||||||
if(delay_time_ > 0) {
|
if(delay_time_ > 0) {
|
||||||
if(cycles.as_int() >= delay_time_) {
|
if(cycles.as_int() >= delay_time_) {
|
||||||
@ -103,6 +105,7 @@ void i8272::run_for(Cycles cycles) {
|
|||||||
|
|
||||||
// update seek status of any drives presently seeking
|
// update seek status of any drives presently seeking
|
||||||
if(drives_seeking_) {
|
if(drives_seeking_) {
|
||||||
|
int drives_left = drives_seeking_;
|
||||||
for(int c = 0; c < 4; c++) {
|
for(int c = 0; c < 4; c++) {
|
||||||
if(drives_[c].phase == Drive::Seeking) {
|
if(drives_[c].phase == Drive::Seeking) {
|
||||||
drives_[c].step_rate_counter += cycles.as_int();
|
drives_[c].step_rate_counter += cycles.as_int();
|
||||||
@ -122,6 +125,9 @@ void i8272::run_for(Cycles cycles) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drives_left--;
|
||||||
|
if(!drives_left) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,6 +152,8 @@ void i8272::run_for(Cycles cycles) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_sleeping_ = !delay_time_ && !drives_seeking_ && !head_timers_running_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void i8272::set_register(int address, uint8_t value) {
|
void i8272::set_register(int address, uint8_t value) {
|
||||||
@ -190,7 +198,7 @@ void i8272::set_disk(std::shared_ptr<Storage::Disk::Disk> disk, int drive) {
|
|||||||
|
|
||||||
#define MS_TO_CYCLES(x) x * 8000
|
#define MS_TO_CYCLES(x) x * 8000
|
||||||
#define WAIT_FOR_EVENT(mask) resume_point_ = __LINE__; interesting_event_mask_ = (int)mask; return; case __LINE__:
|
#define WAIT_FOR_EVENT(mask) resume_point_ = __LINE__; interesting_event_mask_ = (int)mask; return; case __LINE__:
|
||||||
#define WAIT_FOR_TIME(ms) resume_point_ = __LINE__; interesting_event_mask_ = (int)Event8272::Timer; delay_time_ = MS_TO_CYCLES(ms); case __LINE__: if(delay_time_) return;
|
#define WAIT_FOR_TIME(ms) resume_point_ = __LINE__; interesting_event_mask_ = (int)Event8272::Timer; delay_time_ = MS_TO_CYCLES(ms); is_sleeping_ = false; case __LINE__: if(delay_time_) return;
|
||||||
|
|
||||||
#define PASTE(x, y) x##y
|
#define PASTE(x, y) x##y
|
||||||
#define CONCAT(x, y) PASTE(x, y)
|
#define CONCAT(x, y) PASTE(x, y)
|
||||||
@ -248,6 +256,7 @@ void i8272::set_disk(std::shared_ptr<Storage::Disk::Disk> disk, int drive) {
|
|||||||
if(drives_[active_drive_].head_is_loaded[active_head_]) {\
|
if(drives_[active_drive_].head_is_loaded[active_head_]) {\
|
||||||
if(drives_[active_drive_].head_unload_delay[active_head_] == 0) { \
|
if(drives_[active_drive_].head_unload_delay[active_head_] == 0) { \
|
||||||
head_timers_running_++; \
|
head_timers_running_++; \
|
||||||
|
is_sleeping_ = false; \
|
||||||
} \
|
} \
|
||||||
drives_[active_drive_].head_unload_delay[active_head_] = MS_TO_CYCLES(head_unload_time_);\
|
drives_[active_drive_].head_unload_delay[active_head_] = MS_TO_CYCLES(head_unload_time_);\
|
||||||
}
|
}
|
||||||
@ -701,6 +710,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
// Increment the seeking count if this drive wasn't already seeking.
|
// Increment the seeking count if this drive wasn't already seeking.
|
||||||
if(drives_[drive].phase != Drive::Seeking) {
|
if(drives_[drive].phase != Drive::Seeking) {
|
||||||
drives_seeking_++;
|
drives_seeking_++;
|
||||||
|
is_sleeping_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set currently seeking, with a step to occur right now (yes, it sounds like jamming these
|
// Set currently seeking, with a step to occur right now (yes, it sounds like jamming these
|
||||||
|
@ -128,6 +128,8 @@ class i8272: public Storage::Disk::MFMController {
|
|||||||
// Internal registers.
|
// Internal registers.
|
||||||
uint8_t cylinder_, head_, sector_, size_;
|
uint8_t cylinder_, head_, sector_, size_;
|
||||||
|
|
||||||
|
// Master switch on not performing any work.
|
||||||
|
bool is_sleeping_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user