mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-20 14:29:11 +00:00
Switch to faster timer implementation; it seems to work.
This commit is contained in:
parent
e1c7a140d0
commit
c2646a415f
@ -178,29 +178,16 @@ void MFP68901::write(int address, uint8_t value) {
|
|||||||
void MFP68901::run_for(HalfCycles time) {
|
void MFP68901::run_for(HalfCycles time) {
|
||||||
cycles_left_ += time;
|
cycles_left_ += time;
|
||||||
|
|
||||||
// TODO: this is the stupidest possible implementation. Improve.
|
const int cycles = int(cycles_left_.flush<Cycles>().as_integral());
|
||||||
int cycles = int(cycles_left_.flush<Cycles>().as_integral());
|
|
||||||
while(cycles--) {
|
|
||||||
for(int c = 0; c < 4; ++c) {
|
for(int c = 0; c < 4; ++c) {
|
||||||
if(timers_[c].mode >= TimerMode::Delay) {
|
if(timers_[c].mode >= TimerMode::Delay) {
|
||||||
--timers_[c].divisor;
|
const int dividend = (cycles + timers_[c].prescale - timers_[c].divisor);
|
||||||
if(!timers_[c].divisor) {
|
const int decrements = dividend / timers_[c].prescale;
|
||||||
timers_[c].divisor = timers_[c].prescale;
|
timers_[c].divisor = timers_[c].prescale - (dividend % timers_[c].prescale);
|
||||||
decrement_timer(c, 1);
|
if(decrements) decrement_timer(c, decrements);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// const int cycles = int(cycles_left_.flush<Cycles>().as_integral());
|
|
||||||
// for(int c = 0; c < 4; ++c) {
|
|
||||||
// if(timers_[c].mode >= TimerMode::Delay) {
|
|
||||||
// const int dividend = (cycles + timers_[c].prescale - timers_[c].divisor);
|
|
||||||
// const int decrements = dividend / timers_[c].prescale;
|
|
||||||
// timers_[c].divisor = timers_[c].prescale - (dividend % timers_[c].prescale);
|
|
||||||
// if(decrements) decrement_timer(c, decrements);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
HalfCycles MFP68901::get_next_sequence_point() {
|
HalfCycles MFP68901::get_next_sequence_point() {
|
||||||
return HalfCycles(-1);
|
return HalfCycles(-1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user