1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Remove dead TODO, correct for overflow position.

This commit is contained in:
Thomas Harte 2021-06-29 15:44:02 -04:00
parent 8ce8fbd977
commit 3d8fc9952d

View File

@ -229,8 +229,6 @@ void TimedInterruptSource::write(uint16_t address, uint8_t value) {
} }
} }
// TODO: don't muck about with update_channel if channels have a reload value of 0.
void TimedInterruptSource::update_channel(int c, bool is_linked, int decrement) { void TimedInterruptSource::update_channel(int c, bool is_linked, int decrement) {
if(channels_[c].sync) { if(channels_[c].sync) {
channels_[c].value = channels_[c].reload; channels_[c].value = channels_[c].reload;
@ -238,12 +236,12 @@ void TimedInterruptSource::update_channel(int c, bool is_linked, int decrement)
if(decrement <= channels_[c].value) { if(decrement <= channels_[c].value) {
channels_[c].value -= decrement; channels_[c].value -= decrement;
} else { } else {
const int num_flips = (decrement - (channels_[c].value + 1)) / (channels_[c].reload + 1); const int num_flips = (decrement - channels_[c].value) / (channels_[c].reload + 1);
if(is_linked && num_flips + channels_[c].level >= 2) { if(is_linked && num_flips + channels_[c].level >= 2) {
interrupts_ |= uint8_t(Interrupt::VariableFrequency); interrupts_ |= uint8_t(Interrupt::VariableFrequency);
} }
channels_[c].level ^= (num_flips & 1); channels_[c].level ^= (num_flips & 1);
channels_[c].value = (decrement - (channels_[c].value + 1)) % (channels_[c].reload + 1); channels_[c].value = (decrement - channels_[c].value) % (channels_[c].reload + 1);
} }
} }
} }