1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-05 10:28:58 +00:00

Provide correct input when one of the tone generators is the interrupt source.

This commit is contained in:
Thomas Harte 2021-06-29 15:41:08 -04:00
parent 7f08218b28
commit 8ce8fbd977

View File

@ -293,9 +293,23 @@ Cycles TimedInterruptSource::get_next_sequence_point() const {
}
uint8_t TimedInterruptSource::get_divider_state() {
bool programmable_flag = false;
switch(rate_) {
case InterruptRate::OnekHz:
case InterruptRate::FiftyHz:
programmable_flag = programmable_level_;
break;
case InterruptRate::ToneGenerator0:
programmable_flag = channels_[0].level;
break;
case InterruptRate::ToneGenerator1:
programmable_flag = channels_[1].level;
break;
}
// one_hz_offset_ counts downwards, so when it crosses the halfway mark
// it enters the high part of its wave.
return
(one_hz_offset_ < half_clock_rate ? 0x4 : 0x0) |
(programmable_level_ ? 0x1 : 0x0);
(programmable_flag ? 0x1 : 0x0);
}