Good improvement maybe to chop the dma, we don't want to run the dma for a very long time
and starve the frontend, another thing to do is to
CYCLES_PER_FRAME = 1000
MAX_TO_RUN = 100
while self.cpu_frame < CYCLES_PER_FRAME {
if self.excess = 0 {
self.excess = self.cpu.run();
self.cpu_frame += self.excess;
}
let to_run = min(self.excess, MAX_TO_RUN);
self.excess -= to_run;
self.clocks.run(to_run);
}
self.cpu_frame -= CYCLES_PER_FRAME;
loop 1:
self.cpu_frame = 0
self.excess = 0
self.cpu_frame = 100
self.excess = 100
self.excess = 0 // done
self.cpu_frame = 1100
self.excess = 1000
self.excess = 900
self.cpu_frame = 100
loop 2:
self.cpu_frame = 100
self.excess = 900
self.excess = 800
...
self.excess = 0
self.cpu_frame = 200
self.excess = 100
loop 11:
self.cpu_frame = 0
self.excess = 0
self.cpu_frame = 10000
self.excess = 10000
self.excess = 9900
self.cpu_frame = 9000
self.cpu_frame = 8000
self.cpu_frame = 7000
... // doing 9 frame renders without clocking the compoenents, excess is still at 9900
self.cpu_frame = 0